@baique/pi-web-sky 0.1.32 → 0.1.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +17 -8
- package/.next/build-manifest.json +3 -3
- package/.next/react-loadable-manifest.json +27 -6
- package/.next/required-server-files.js +1 -1
- package/.next/required-server-files.json +1 -1
- package/.next/routes-manifest.json +70 -0
- package/.next/server/app/_global-error/page.js +1 -1
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page.js +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +3 -3
- package/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/api/agent/[id]/bash-output/route.js +2 -2
- package/.next/server/app/api/agent/[id]/events/route.js +31 -2
- package/.next/server/app/api/agent/[id]/events/route.js.nft.json +1 -1
- package/.next/server/app/api/agent/[id]/route.js +30 -1
- package/.next/server/app/api/agent/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/agent/new/route.js +1 -1
- package/.next/server/app/api/agent/new/route.js.nft.json +1 -1
- package/.next/server/app/api/agent/running/route.js +30 -1
- package/.next/server/app/api/agent/running/route.js.nft.json +1 -1
- package/.next/server/app/api/app-update/route.js +1 -1
- package/.next/server/app/api/auth/all-providers/route.js +1 -1
- package/.next/server/app/api/auth/api-key/[provider]/route.js +1 -30
- package/.next/server/app/api/auth/api-key/[provider]/route.js.nft.json +1 -1
- package/.next/server/app/api/auth/login/[provider]/route.js +3 -3
- package/.next/server/app/api/auth/logout/[provider]/route.js +1 -30
- package/.next/server/app/api/auth/logout/[provider]/route.js.nft.json +1 -1
- package/.next/server/app/api/auth/providers/route.js +1 -1
- package/.next/server/app/api/boards/[id]/canvas/route.js +1 -0
- package/.next/server/app/api/boards/[id]/canvas/route.js.nft.json +1 -0
- package/.next/server/app/api/boards/[id]/canvas/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/boards/[id]/edges/[eid]/route.js +1 -0
- package/.next/server/app/api/boards/[id]/edges/[eid]/route.js.nft.json +1 -0
- package/.next/server/app/api/boards/[id]/edges/[eid]/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/boards/[id]/edges/route.js +1 -0
- package/.next/server/app/api/boards/[id]/edges/route.js.nft.json +1 -0
- package/.next/server/app/api/boards/[id]/edges/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/boards/[id]/nodes/[nid]/route.js +1 -0
- package/.next/server/app/api/boards/[id]/nodes/[nid]/route.js.nft.json +1 -0
- package/.next/server/app/api/boards/[id]/nodes/[nid]/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/boards/[id]/nodes/route.js +1 -0
- package/.next/server/app/api/boards/[id]/nodes/route.js.nft.json +1 -0
- package/.next/server/app/api/boards/[id]/nodes/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/boards/[id]/route.js +1 -0
- package/.next/server/app/api/boards/[id]/route.js.nft.json +1 -0
- package/.next/server/app/api/boards/[id]/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/boards/reorder/route.js +1 -0
- package/.next/server/app/api/boards/reorder/route.js.nft.json +1 -0
- package/.next/server/app/api/boards/reorder/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/boards/route.js +1 -0
- package/.next/server/app/api/boards/route.js.nft.json +1 -0
- package/.next/server/app/api/boards/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/cwd/browse/route.js +1 -1
- package/.next/server/app/api/cwd/validate/route.js +2 -2
- package/.next/server/app/api/default-cwd/route.js +2 -2
- package/.next/server/app/api/file-index/route.js +2 -2
- package/.next/server/app/api/files/[...path]/route.js +3 -3
- package/.next/server/app/api/files/[...path]/route.js.nft.json +1 -1
- package/.next/server/app/api/git/diff/route.js +1 -35
- package/.next/server/app/api/git/diff/route.js.nft.json +1 -1
- package/.next/server/app/api/git/status/route.js +1 -35
- package/.next/server/app/api/git/status/route.js.nft.json +1 -1
- package/.next/server/app/api/home/route.js +1 -1
- package/.next/server/app/api/mcp/route.js +2 -2
- package/.next/server/app/api/models/route.js +2 -2
- package/.next/server/app/api/models-config/catalog/route.js +1 -1
- package/.next/server/app/api/models-config/discover/route.js +1 -1
- package/.next/server/app/api/models-config/route.js +1 -1
- package/.next/server/app/api/models-config/test/route.js +1 -1
- package/.next/server/app/api/plugins/route.js +2 -2
- package/.next/server/app/api/project-trust/route.js +30 -1
- package/.next/server/app/api/project-trust/route.js.nft.json +1 -1
- package/.next/server/app/api/quota/route.js +1 -1
- package/.next/server/app/api/search/route.js +2 -2
- package/.next/server/app/api/sessions/[id]/auto-name/route.js +31 -2
- package/.next/server/app/api/sessions/[id]/auto-name/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/[id]/context/route.js +30 -1
- package/.next/server/app/api/sessions/[id]/context/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/[id]/entries/[entryId]/thinking/route.js +2 -2
- package/.next/server/app/api/sessions/[id]/export/route.js +2 -2
- package/.next/server/app/api/sessions/[id]/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/[id]/state/route.js +30 -1
- package/.next/server/app/api/sessions/[id]/state/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/[id]/todos/route.js +30 -1
- package/.next/server/app/api/sessions/[id]/todos/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/route.js +30 -1
- package/.next/server/app/api/sessions/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/check/route.js +1 -1
- package/.next/server/app/api/skills/install/route.js +2 -2
- package/.next/server/app/api/skills/route.js +2 -2
- package/.next/server/app/api/skills/search/route.js +1 -1
- package/.next/server/app/api/skills/update/route.js +1 -1
- package/.next/server/app/api/tasks/[id]/board/route.js +1 -0
- package/.next/server/app/api/tasks/[id]/board/route.js.nft.json +1 -0
- package/.next/server/app/api/tasks/[id]/board/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/tasks/[id]/route.js +1 -1
- package/.next/server/app/api/tasks/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/tasks/reorder/route.js +1 -30
- package/.next/server/app/api/tasks/reorder/route.js.nft.json +1 -1
- package/.next/server/app/api/tasks/route.js +1 -30
- package/.next/server/app/api/tasks/route.js.nft.json +1 -1
- package/.next/server/app/api/terminal/[id]/events/route.js +3 -3
- package/.next/server/app/api/terminal/[id]/route.js +2 -2
- package/.next/server/app/api/terminal/route.js +2 -2
- package/.next/server/app/api/worktrees/route.js +2 -2
- package/.next/server/app/favicon.ico/route.js +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +6 -6
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +6 -6
- package/.next/server/app/index.segments/_full.segment.rsc +6 -6
- package/.next/server/app/index.segments/_tree.segment.rsc +3 -3
- package/.next/server/app/manifest.webmanifest/route.js +2 -2
- package/.next/server/app/page.js +8 -8
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +17 -8
- package/.next/server/chunks/2092.js +30 -0
- package/.next/server/chunks/2404.js +1 -1
- package/.next/server/chunks/402.js +1 -1
- package/.next/server/chunks/{3379.js → 5760.js} +1 -1
- package/.next/server/chunks/5794.js +35 -0
- package/.next/server/chunks/6429.js +1 -0
- package/.next/server/chunks/7513.js +1 -1
- package/.next/server/chunks/898.js +30 -0
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/static/chunks/3178.73f47c1845fe51df.js +259 -0
- package/.next/static/chunks/3266.a491c09b3f6b57e6.js +1 -0
- package/.next/static/chunks/{3308.be8762955e7155d1.js → 3308.857c554428b3294e.js} +1 -1
- package/.next/static/chunks/3744.d362159c4d7b91f4.js +1 -0
- package/.next/static/chunks/54a60aa6.0e43cde7298ebcb7.js +78 -0
- package/.next/static/chunks/5518.79782f5b65bbefd6.js +1 -0
- package/.next/static/chunks/70e0d97a.337966195abe6fe0.js +1 -0
- package/.next/static/chunks/7268.7bf6d531e3905a52.js +1 -0
- package/.next/static/chunks/app/_global-error/page-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/agent/[id]/bash-output/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/agent/[id]/events/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/agent/[id]/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/agent/new/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/agent/running/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/app-update/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/auth/all-providers/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/auth/api-key/[provider]/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/auth/login/[provider]/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/auth/logout/[provider]/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/auth/providers/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/boards/[id]/canvas/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/boards/[id]/edges/[eid]/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/boards/[id]/edges/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/boards/[id]/nodes/[nid]/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/boards/[id]/nodes/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/boards/[id]/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/boards/reorder/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/boards/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/cwd/browse/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/cwd/validate/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/default-cwd/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/file-index/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/files/[...path]/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/git/diff/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/git/status/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/home/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/mcp/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/models/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/models-config/catalog/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/models-config/discover/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/models-config/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/models-config/test/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/plugins/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/project-trust/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/quota/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/search/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/auto-name/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/context/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/entries/[entryId]/thinking/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/export/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/state/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/todos/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/sessions/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/skills/check/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/skills/install/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/skills/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/skills/search/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/skills/update/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/tasks/[id]/board/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/tasks/[id]/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/tasks/reorder/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/tasks/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/terminal/[id]/events/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/terminal/[id]/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/terminal/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/api/worktrees/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/{layout-44c2a1db46fb38f3.js → layout-629d926928cb5e43.js} +1 -1
- package/.next/static/chunks/app/manifest.webmanifest/route-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/app/page-fca5ee35186517d3.js +89 -0
- package/.next/static/chunks/e3e7ddb2.a35db430b3564999.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-9cbffd52890a7ee2.js +1 -0
- package/.next/static/chunks/webpack-a0d987c4f912a15f.js +1 -0
- package/.next/static/css/46396d55066d14af.css +1 -0
- package/.next/static/css/77c5948f82acf3c3.css +1 -0
- package/.next/static/css/80c818c5781fbadc.css +4 -0
- package/.next/static/rGUWWAqLz0cYSW8-IDVSA/_buildManifest.js +1 -0
- package/.next/trace +7 -7
- package/.next/trace-build +1 -1
- package/.next/types/app/api/boards/[id]/canvas/route.ts +353 -0
- package/.next/types/app/api/boards/[id]/edges/[eid]/route.ts +353 -0
- package/.next/types/app/api/boards/[id]/edges/route.ts +353 -0
- package/.next/types/app/api/boards/[id]/nodes/[nid]/route.ts +353 -0
- package/.next/types/app/api/boards/[id]/nodes/route.ts +353 -0
- package/.next/types/app/api/boards/[id]/route.ts +353 -0
- package/.next/types/app/api/boards/reorder/route.ts +353 -0
- package/.next/types/app/api/boards/route.ts +353 -0
- package/.next/types/app/api/tasks/[id]/board/route.ts +353 -0
- package/.next/types/routes.d.ts +10 -1
- package/.next/types/validator.ts +81 -0
- package/README.md +11 -0
- package/package.json +2 -1
- package/.next/server/chunks/1457.js +0 -30
- package/.next/static/chunks/3266.4c7192f2067645eb.js +0 -1
- package/.next/static/chunks/7268.236544be8e242c16.js +0 -1
- package/.next/static/chunks/app/_global-error/page-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/agent/[id]/bash-output/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/agent/[id]/events/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/agent/[id]/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/agent/new/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/agent/running/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/app-update/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/auth/all-providers/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/auth/api-key/[provider]/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/auth/login/[provider]/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/auth/logout/[provider]/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/auth/providers/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/cwd/browse/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/cwd/validate/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/default-cwd/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/file-index/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/files/[...path]/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/git/diff/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/git/status/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/home/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/mcp/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/models/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/models-config/catalog/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/models-config/discover/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/models-config/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/models-config/test/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/plugins/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/project-trust/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/quota/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/search/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/auto-name/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/context/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/entries/[entryId]/thinking/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/export/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/state/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/todos/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/sessions/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/skills/check/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/skills/install/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/skills/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/skills/search/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/skills/update/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/tasks/[id]/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/tasks/reorder/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/tasks/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/terminal/[id]/events/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/terminal/[id]/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/terminal/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/api/worktrees/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/manifest.webmanifest/route-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/app/page-255f2073b07c4d6f.js +0 -89
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-11d96eed20d5efa5.js +0 -1
- package/.next/static/chunks/webpack-09241b8782696d25.js +0 -1
- package/.next/static/css/ad030894558ed286.css +0 -1
- package/.next/static/css/de7b7ffe9688501b.css +0 -1
- package/.next/static/qwmfKj7b5-4hr-C6kFkRA/_buildManifest.js +0 -1
- /package/.next/static/{qwmfKj7b5-4hr-C6kFkRA → rGUWWAqLz0cYSW8-IDVSA}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3178],{1015:(e,t,n)=>{"use strict";n.d(t,{p:()=>a,t:()=>s});var r=n(95155),i=n(12115);let o={error:null};class s extends i.Component{static getDerivedStateFromError(e){return{error:e}}state=o;componentDidCatch(e){this.props.onError?.(e)}render(){let{error:e}=this.state;if(null!==e){let{fallback:t}=this.props;return(0,r.jsx)(t,{error:e})}return this.props.children}}function a({children:e,fallback:t,...n}){return null===t?e:(0,r.jsx)(s,{fallback:t,...n,children:e})}},1793:(e,t,n)=>{"use strict";n.d(t,{V:()=>s});var r=n(83102),i=n(24167);function o(e){let t=e.get(),n=new Map;for(let e of t){let{fromId:t,toId:r}=e,i=n.get(t);i?i.push(e):n.set(t,[e]);let o=n.get(r);o?o.push(e):n.set(r,[e])}return n}function s(e){let{store:t}=e,n=t.query.filterHistory("binding"),s=t.query.records("binding");return(0,r.EW)("arrowBindingsIndex",(e,t)=>{let a;if((0,r._O)(e))return o(s);let l=n.getDiffSince(t);if(l===r.c2)return o(s);function d(t){let n=(a??=new Map(e)).get(t.fromId),r=n?.filter(e=>e.id!==t.id);r?.length?a.set(t.fromId,r):a.delete(t.fromId);let i=a.get(t.toId),o=i?.filter(e=>e.id!==t.id);o?.length?a.set(t.toId,o):a.delete(t.toId)}function c(t){let n=(a??=new Map(e)).get(t);return n?n===e.get(t)&&(n=n.slice(0),a.set(t,n)):(n=[],a.set(t,n)),n}function u(e){c(e.fromId).push(e),c(e.toId).push(e)}for(let e of l){for(let t of(0,i.Ic)(e.added))u(t);for(let[t,n]of(0,i.Ic)(e.updated))d(t),u(n);for(let t of(0,i.Ic)(e.removed))d(t)}return a??e})}},2311:(e,t,n)=>{"use strict";let r;n.d(t,{W:()=>ei});var i=n(24167),o=n(47650),s=n(12669),a=n(48077);function l(e,t){let n=new i.Qn(100);return async function(r){let o=n.get(r);if(o)return o;let s=(async()=>{try{let n=await (0,i.hd)(r,t);return(0,i.vA)(n.ok),await e(n)}catch(e){return console.error(e),null}})();return n.set(r,s),s}}let d=l(async e=>await i.Sm.blobToDataUrl(await e.blob()));function c(e,t){return e.replaceWith(t),t}async function u(e,t,n){let r=e.createElement("img");n&&Array.from(n.attributes).forEach(e=>{r.setAttribute(e.name,e.value)}),r.setAttribute("src",t??"data:"),r.setAttribute("decoding","sync"),r.setAttribute("loading","eager");try{await r.decode()}catch{}return r}async function h(e){let t=e.ownerDocument;try{let n=e.toDataURL();return await u(t,n,e)}catch{return await u(t,null,e)}}async function p(e){let t=e.ownerDocument;try{let n=await i.K4.getVideoFrameAsDataUrl(e);return u(t,n,e)}catch(e){console.error("Could not get video frame",e)}return e.poster?u(t,await d(e.poster),e):u(t,null,e)}async function f(e){let t=(0,a.mD)(e);if(e instanceof t.HTMLCanvasElement)return c(e,await h(e));if(e instanceof t.HTMLVideoElement)return c(e,await p(e));if(e instanceof t.HTMLImageElement){let t=e.currentSrc||e.src,n=await d(t);e.setAttribute("src",n??"data:"),e.setAttribute("decoding","sync"),e.setAttribute("loading","eager");try{await e.decode()}catch{}return e}e instanceof t.HTMLInputElement?e.setAttribute("value",e.value):e instanceof t.HTMLTextAreaElement&&(e.textContent=e.value);await Promise.all(Array.from((0,a.$3)(e),e=>f(e)))}let g=/@import\s+(?:"([^"]+)"|'([^']+)'|url\s*\(\s*(?:"([^"]+)"|'([^']+)'|([^'")]+))\s*\))([^;]+);/gi,m=/@font-face\s*{([^}]+)}/gi,y=/url\s*\(\s*(?:"([^"]+)"|'([^']+)'|([^'")]+))\s*\)/gi,b=/(?:^|;)\s*font-family\s*:\s*(?:([^'"][^;\n]+)|"([^"]+)"|'([^']+)')\s*(?:;|$)/gi;function x(e,t){return Array.from(e.matchAll(m),e=>{let n=e[1],r=Array.from(n.matchAll(y),e=>{let n=e[1]||e[2]||e[3];return{original:n,resolved:(0,i.yC)(n,t)?.href??null}}),o=new Set(Array.from(n.matchAll(b),e=>(e[1]||e[2]||e[3]).toLowerCase()));return{fontFace:n,urls:r,fontFamilies:o}})}function w(e){return!(e.startsWith("-")||e.startsWith("animation")||e.startsWith("transition"))&&"cursor"!==e&&"pointer-events"!==e&&"user-select"!==e&&"touch-action"!==e}var v=Object.defineProperty,S=Object.getOwnPropertyDescriptor;let C="tldraw-svg-export";class k{fontFacesPromise=null;foundFontNames=new Set;fontFacesToEmbed=new Set;pendingPromises=[];startFindingDocumentFontFaces(e){(0,i.vA)(!this.fontFacesPromise,"FontEmbedder already started"),this.fontFacesPromise=P(e)}onFontFamilyValue(e){for(let t of((0,i.vA)(this.fontFacesPromise,"FontEmbedder not started"),function(e){let t=/\s*(?:([^'"][^;\n\s,]+)|"([^"]+)"|'([^']+)')\s*/gi,n=/\s*,\s*/gi,r=new Set;for(;;){let i=t.exec(e);if(!i)break;let o=i[1]||i[2]||i[3];if(r.add(o.toLowerCase()),n.lastIndex=t.lastIndex,!n.exec(e))break;t.lastIndex=n.lastIndex}return r}(e))){if(this.foundFontNames.has(t))return;this.foundFontNames.add(t),this.pendingPromises.push(this.fontFacesPromise.then(e=>{for(let n of e.filter(e=>e.fontFamilies.has(t)))if(!this.fontFacesToEmbed.has(n))for(let e of(this.fontFacesToEmbed.add(n),n.urls))e.resolved&&!e.embedded&&(e.embedded=d(e.resolved))}))}}async createCss(){await Promise.all(this.pendingPromises);let e="";for(let t of this.fontFacesToEmbed){let n=`@font-face {${t.fontFace}}`;for(let e of t.urls){if(!e.embedded)continue;let t=await e.embedded;t&&(n=n.replace(e.original,t))}e+=n}return e}}async function P(e){let t=e.defaultView??globalThis,n=[];for(let r of Array.from(e.styleSheets).filter(e=>!e.ownerNode?.closest(`.${C}`))){let i;try{i=r.cssRules}catch{}if(i){for(let i of r.cssRules)if(i instanceof t.CSSFontFaceRule)n.push(x(i.cssText,r.href??e.baseURI));else if(i instanceof t.CSSImportRule){let t=new URL(i.href,i.parentStyleSheet?.href??e.baseURI);n.push(T(t.href))}}else r.href&&n.push(T(r.href))}return(0,i.oE)(await Promise.all(n)).flat()}((e,t,n)=>{for(var r,i=S(t,n),o=e.length-1;o>=0;o--)(r=e[o])&&(i=r(t,n,i)||i);return i&&v(t,n,i)})([i.oI],k.prototype,"onFontFamilyValue");let T=l(async e=>{var t,n;let r=(t=await e.text(),n=e.url,{imports:Array.from(t.matchAll(g),e=>({url:e[1]||e[2]||e[3]||e[4]||e[5],extras:e[6]})),fontFaces:x(t,n)}),o=await Promise.all(r.imports.map(({url:t})=>T(new URL(t,e.url).href)));return[...r.fontFaces,...(0,i.oE)(o).flat()]});var E=n(95155),I=n(27394),_=n(12115),M=n(1015),A=n(22036),j=n(19743),O=n(50585),D=n(67863),L=n(18314),F=n(73352),R=n(59830),z=n(54939),N=Object.defineProperty,$=Object.getOwnPropertyDescriptor;class B{constructor(e){this.maxDelayTimeMs=e}maxDelayTimeMs;isResolved=!1;promisesToWaitFor=[];waitUntil(e){if(this.isResolved)throw Error("Cannot `waitUntil` - the export has already been resolved. Make sure to call `waitUntil` as soon as possible during an export - ie within the first react effect after rendering.");this.promisesToWaitFor.push(e.catch(e=>console.error("Error while waiting for export:",e)))}async resolvePromises(){let e=null;for(;this.promisesToWaitFor.length!==e;)e=this.promisesToWaitFor.length,await Promise.allSettled(this.promisesToWaitFor),await (0,i.yy)(0)}async resolve(){let e=(0,i.yy)(this.maxDelayTimeMs).then(()=>"timeout"),t=this.resolvePromises().then(()=>"resolved");"timeout"===await Promise.race([e,t])&&console.warn("[tldraw] Export delay timed out after ${this.maxDelayTimeMs}ms"),this.isResolved=!0}}function H({editor:e,preserveAspectRatio:t,scale:n,pixelRatio:r,bbox:s,background:a,singleFrameShapeId:l,isDarkMode:d,colorMode:c,renderingShapes:u,onMount:h,waitUntil:p}){let f=(0,F.Ls)(),g=e.getCurrentTheme(),m=(0,I.fp)("export state",{defsById:{},shapeElements:null}),{defsById:y,shapeElements:b}=(0,I.h)(m),x=(0,L._)(e=>{m.update(t=>{if((0,i.mQ)(t.defsById,e.key))return t;let n=Promise.resolve(e.getElement());return p(n.then(t=>{m.update(n=>({...n,defsById:{...n.defsById,[e.key]:{pending:!1,element:t}}}))})),{...t,defsById:{...t.defsById,[e.key]:{pending:!0,element:n}}}})}),w=(0,_.useMemo)(()=>({isDarkMode:d,colorMode:c,waitUntil:p,addExportDef:x,scale:n,pixelRatio:r,async resolveAssetUrl(t,i){let o=e.getAsset(t);return o&&("image"===o.type||"video"===o.type)?await e.resolveAssetUrl(t,{screenScale:n*(i/o.props.w),shouldResolveToOriginal:null===r,dpr:r??void 0}):null}}),[d,c,p,x,n,r,e]),v=(0,_.useRef)(!1);(0,_.useLayoutEffect)(()=>{if(v.current)throw Error("SvgExport should only render once - do not use with react strict mode");v.current=!0,(async()=>{let t={},n=u.map(async({id:n,opacity:r,index:i,backgroundIndex:o})=>{if(n===l)return[];let a=e.getShape(n);if(e.isShapeOfType(a,"group"))return[];let d=[],c=e.getShapeUtil(a);if(c.toSvg||c.toBackgroundSvg){let[n,s]=await Promise.all([c.toSvg?.(a,w),c.toBackgroundSvg?.(a,w)]),l=e.getShapePageTransform(a),u=l.toCssString(),h=1;"scale"in a.props&&1!==a.props.scale&&(h=a.props.scale,u=`${u} scale(${a.props.scale}, ${a.props.scale})`);let p=e.getShapeMask(a.id),g=p?z.V.From(z.V.Inverse(l)).applyToPoints(p):null,m=(0,F.oX)(f,a.id);g&&(t[m]={pending:!1,element:(0,E.jsx)("clipPath",{id:m,children:(0,E.jsx)("path",{d:`M${g.map(({x:e,y:t})=>`${e/h},${t/h}`).join("L")}Z`})})}),n&&d.push({zIndex:i,element:(0,E.jsx)("g",{transform:u,opacity:r,clipPath:p?`url(#${m})`:void 0,children:n},`fg_${a.id}`)}),s&&d.push({zIndex:o,element:(0,E.jsx)("g",{transform:u,opacity:r,clipPath:p?`url(#${m})`:void 0,children:s},`bg_${a.id}`)})}else d.push({zIndex:i,element:(0,E.jsx)(U,{shape:a,util:c,component:A.Gq,className:"tl-shape",bbox:s,opacity:r},`fg_${a.id}`)}),c.backgroundComponent&&d.push({zIndex:o,element:(0,E.jsx)(U,{shape:a,util:c,component:A.u0,className:"tl-shape tl-shape-background",bbox:s,opacity:r},`bg_${a.id}`)});return d}),r=(await Promise.all(n)).flat();(0,o.flushSync)(()=>{m.update(e=>({...e,shapeElements:r.sort((e,t)=>e.zIndex-t.zIndex).map(({element:e})=>e),defsById:{...e.defsById,...t}}))})})()},[s,e,w,f,u,l,m]),(0,_.useEffect)(()=>{let t=new Set;for(let{id:n}of u)for(let r of e.fonts.getShapeFontFaces(n))t.add(r);for(let n of t)x({key:(0,i.NF)(),getElement:async()=>{let t=await e.fonts.toEmbeddedCssDeclaration(n);return(0,E.jsx)("style",{nonce:e.options.nonce,children:t})}})},[e,u,x]),(0,_.useEffect)(()=>{null!==b&&h()},[h,b]);let S=g.colors[c],C=a?S.background:"transparent";if(l&&a){let t=e.getShapeUtil("frame");if(t?.options.showColors){let t=e.getShape(l);C=(0,j.F)(S,t.props.color,"frameFill")}else C=S.solid}return(0,E.jsx)(O.Bb,{editor:e,context:w,children:(0,E.jsxs)("svg",{preserveAspectRatio:t,direction:"ltr",width:s.width*n,height:s.height*n,viewBox:`${s.minX} ${s.minY} ${s.width} ${s.height}`,strokeLinecap:"round",strokeLinejoin:"round",style:{backgroundColor:C},"data-color-mode":d?"dark":"light",className:`tl-container tl-theme__force-sRGB ${d?"tl-theme__dark":"tl-theme__light"}`,children:[(0,E.jsx)("defs",{children:Object.entries(y).map(([e,t])=>t.pending?null:(0,E.jsx)(_.Fragment,{children:t.element},e))}),b]})})}function U({shape:e,util:t,className:n,component:r,bbox:i,opacity:o}){let s=(0,D.hG)(),a=z.V.Translate(-i.minX,-i.minY).multiply(s.getShapePageTransform(e.id)),l=s.getShapeGeometry(e.id).bounds,d=Math.max(l.width,1),c=Math.max(l.height,1);return(0,E.jsx)(M.t,{fallback:()=>null,children:(0,E.jsx)("foreignObject",{x:i.minX,y:i.minY,width:i.w,height:i.h,className:"tl-shape-foreign-object tl-export-embed-styles",children:(0,E.jsx)("div",{className:n,"data-shape-type":e.type,style:{clipPath:s.getShapeClipPath(e.id),transform:a.toCssString(),width:d,height:c,opacity:o},children:(0,E.jsx)(r,{shape:e,util:t})})})})}((e,t,n)=>{for(var r,i=$(t,n),o=e.length-1;o>=0;o--)(r=e[o])&&(i=r(t,n,i)||i);return i&&N(t,n,i)})([i.oI],B.prototype,"waitUntil");let W=(e,t,{currentColor:n})=>"currentColor"===e||e===n,K=(e,t,{parentStyles:n})=>n[t]===e,V=e=>(t,n,{getStyle:r})=>{let i=r(`border-${e}-width`),o=r(`border-${e}-style`);return"0px"===i||"none"===o},Y={"border-block-end-color":W,"border-block-start-color":W,"border-bottom-color":W,"border-inline-end-color":W,"border-inline-start-color":W,"border-left-color":W,"border-right-color":W,"border-top-color":W,"caret-color":W,"column-rule-color":W,"outline-color":W,"text-decoration":(e,t,{currentColor:n})=>"none solid currentColor"===e||e==="none solid "+n,"text-decoration-color":W,"text-emphasis-color":W,"border-collapse":K,"border-spacing":K,"caption-side":K,cursor:K,direction:K,"empty-cells":K,"font-family":K,"font-size":K,"font-style":K,"font-variant":K,"font-weight":K,"font-size-adjust":K,"font-stretch":K,font:K,"letter-spacing":K,"line-height":K,"list-style-image":K,"list-style-position":K,"list-style-type":K,"list-style":K,orphans:K,"overflow-wrap":K,quotes:K,"stroke-linecap":K,"stroke-linejoin":K,"tab-size":K,"text-align":K,"text-align-last":K,"text-indent":K,"text-justify":K,"text-shadow":K,"text-transform":K,visibility:K,"white-space":K,"white-space-collapse":K,widows:K,"word-break":K,"word-spacing":K,"word-wrap":K,"border-top":V("top"),"border-right":V("right"),"border-bottom":V("bottom"),"border-left":V("left"),"border-block-end":V("block-end"),"border-block-start":V("block-start"),"border-inline-end":V("inline-end"),"border-inline-start":V("inline-start"),"border-top-style":V("top"),"border-right-style":V("right"),"border-bottom-style":V("bottom"),"border-left-style":V("left"),"border-block-end-style":V("block-end"),"border-block-start-style":V("block-start"),"border-inline-end-style":V("inline-end"),"border-inline-start-style":V("inline-start"),"border-top-width":V("top"),"border-right-width":V("right"),"border-bottom-width":V("bottom"),"border-left-width":V("left"),"border-block-end-width":V("block-end"),"border-block-start-width":V("block-start"),"border-inline-end-width":V("inline-end")},G={};class q{constructor(e){this.root=e}root;styles=new Map;fonts=new k;readRootElementStyles(e){this.readElementStyles(e,{shouldRespectDefaults:!1,shouldSkipInheritedParentStyles:!1});let t=Array.from((0,a.$3)(e));for(;t.length;){let e=t.pop();t.push(...(0,a.$3)(e)),this.readElementStyles(e,{shouldRespectDefaults:!0,shouldSkipInheritedParentStyles:!0})}}readElementStyles(e,{shouldRespectDefaults:t=!0,shouldSkipInheritedParentStyles:n=!0}){let o=t?function(e,t){let n=ee[t];if(!n){let{foreignObject:o,document:s}=function(e){if(!r||r.ownerDocument!==e){et();let t=e.createElement("iframe");t.style.display="none",e.body.appendChild(t);let n=(0,i.Z1)(t.contentDocument,"frame must have a document"),o=n.createElementNS("http://www.w3.org/2000/svg","svg"),s=n.createElementNS("http://www.w3.org/2000/svg","foreignObject");o.appendChild(s),n.body.appendChild(o),r={iframe:t,foreignObject:s,document:n,ownerDocument:e}}return r}(e),l=s.createElement(t);o.appendChild(l),n=l.computedStyleMap?J(l.computedStyleMap(),en):Z((0,a.L9)(l),en),o.removeChild(l),ee[t]=n}return n}(e.ownerDocument,e.tagName.toLowerCase()):G,s=Object.assign({},G);if(n){let t=e.parentElement;for(;t;){let e=this.styles.get(t)?.self;for(let t in e)s[t]||(s[t]=e[t]);t=t.parentElement}}let l={self:function(e,{defaultStyles:t,parentStyles:n}){return e.computedStyleMap?J(e.computedStyleMap(),{defaultStyles:t,parentStyles:n}):Z((0,a.L9)(e),{defaultStyles:t,parentStyles:n})}(e,{defaultStyles:o,parentStyles:s}),before:X(e,"::before"),after:X(e,"::after")};this.styles.set(e,l)}fetchResources(){let e=[];for(let t of this.styles.values())for(let n of(0,i.Ic)(t))if(n)for(let[t,r]of Object.entries(n)){if(!r)continue;"font-family"===t&&this.fonts.onFontFamilyValue(r);let i=Array.from(r.matchAll(y),e=>({original:e[0],url:e[1]||e[2]||e[3]})).filter(e=>!e.url.startsWith("#"));0!==i.length&&e.push(...i.map(async({url:e,original:i})=>{let o=await d(e)??"data:";n[t]=r.replace(i,`url("${o}")`)}))}return Promise.all(e)}unwrapCustomElements(){let e=new Set,t=(n,r)=>{if(e.has(n))return;e.add(n);let i=n.shadowRoot;if(i){let e=n.ownerDocument.createElement("div");for(let o of(this.styles.set(e,this.styles.get(n)),e.setAttribute("data-tl-custom-element",n.tagName),(r??n.parentElement).appendChild(e),i.childNodes))(0,a.vq)(o)?t(o,e):e.appendChild(o.cloneNode(!0));n.remove()}else if(r){if("style"===n.tagName.toLowerCase())return;let e=n.cloneNode(!1);for(let i of(this.styles.set(e,this.styles.get(n)),r.appendChild(e),(0,a.XH)(n)))(0,a.vq)(i)?t(i,e):e.appendChild(i.cloneNode(!0))}};for(let e of this.styles.keys())t(e,null)}embedStyles(){let e="";for(let[t,n]of this.styles){if(n.after||n.before){let r=`pseudo-${(0,i.NF)()}`;t.classList.add(r),n.before&&(e+=`.${r}::before {${Q(n.before)}}
|
|
2
|
+
`),n.after&&(e+=`.${r}::after {${Q(n.after)}}
|
|
3
|
+
`)}let r=(0,a.EV)(t);for(let[e,t]of Object.entries(n.self))t&&r.setProperty(e,t);"auto"===r.fontKerning&&(r.fontKerning="normal")}return e}async getFontFaceCss(){return await this.fonts.createCss()}dispose(){et()}}function X(e,t){let n=(0,a.L9)(e,t),r=n.getPropertyValue("content");if(""!==r&&"none"!==r)return Z(n,{defaultStyles:G,parentStyles:G})}function J(e,{defaultStyles:t,parentStyles:n}){let r={},o={currentColor:e.get("color")?.toString()||"",parentStyles:n,defaultStyles:t,getStyle:t=>e.get(t)?.toString()??""};for(let n of e.keys()){if(!w(n))continue;let s=e.get(n).toString();if(t[n]===s)continue;let a=(0,i.g5)(Y,n);a&&a(s,n,o)||(r[n]=s)}return r}function Z(e,{defaultStyles:t,parentStyles:n}){let r={},o={currentColor:e.color,parentStyles:n,defaultStyles:t,getStyle:t=>e.getPropertyValue(t)};for(let n in e){if(!w(n))continue;let s=e.getPropertyValue(n);if(t[n]===s)continue;let a=(0,i.g5)(Y,n);a&&a(s,n,o)||(r[n]=s)}return r}function Q(e){let t="";for(let[n,r]of Object.entries(e))t+=`${n}: ${r};`;return t}let ee={};function et(){for(let e in r&&(r.iframe.remove(),r=void 0),ee)delete ee[e]}let en={defaultStyles:G,parentStyles:G},er=1;async function ei(e,t,n={}){let r=function(e,t,n={}){let r=e.getContainerDocument();if(!r)throw Error("No document");let{scale:o=1,background:s=e.getInstanceState().exportBackground,preserveAspectRatio:a}=n,l="number"!=typeof n.padding,d="number"==typeof n.padding?n.padding:e.options.defaultSvgPadding,c=void 0!==n.darkMode?n.darkMode?"dark":"light":e.getColorMode(),u=e.getShapeAndDescendantIds(t),h=e.getUnorderedRenderingShapes(!1).filter(({id:e})=>u.has(e)),p=1===t.length?e.getShape(t[0]):null,f=p&&e.isShapeFrameLike(p)?t[0]:null,g=null,m=!1;if(n.bounds)g=l?n.bounds.clone():n.bounds.clone().expandBy(d);else{let t=function(e,t,n,r){let i=!1,o=null;for(let{id:n}of t){let t=e.getShapeMaskedPageBounds(n);if(!t)continue;let r=e.getShape(n),s=e.getShapeUtil(r).isExportBoundsContainer(r);o?s&&R.az.ContainsApproximately(t,o)?(i=!0,o=t.clone()):(i&&!R.az.ContainsApproximately(o,t)&&(i=!1),o.union(t)):(i=s,o=t.clone())}if(!o)return{box:null,paddingApplied:!1};let s=!r&&!i;return s&&o.expandBy(n),{box:o,paddingApplied:s}}(e,h,d,f);g=t.box,m=t.paddingApplied}if(!g)return;let y=l&&m?d:0,b=g.width*o,x=g.height*o;try{r.body.focus?.()}catch{}let w=new B(e.options.maxExportDelayMs),v=(0,i.il)();return w.waitUntil(v),{jsx:(0,E.jsx)(H,{editor:e,preserveAspectRatio:a,scale:o,pixelRatio:n.pixelRatio??null,bbox:g,background:s,singleFrameShapeId:f,isDarkMode:"dark"===c,colorMode:c,renderingShapes:h,onMount:v.resolve,waitUntil:w.waitUntil}),width:b,height:x,exportDelay:w,trimPadding:y}}(e,t,n);if(!r)return;let l=e.getContainer(),d=l.ownerDocument.createElement("div");d.className=C,d.inert=!0,d.tabIndex=-1,Object.assign(d.style,{position:"absolute",top:"0px",left:"0px",width:r.width+"px",height:r.height+"px",pointerEvents:"none",opacity:0}),l.appendChild(d);let c=(0,s.createRoot)(d,{identifierPrefix:`export_${er++}_`});try{await Promise.resolve(),(0,o.flushSync)(()=>{c.render(r.jsx)}),await r.exportDelay.resolve();let e=d.firstElementChild;return(0,i.vA)(e instanceof(0,a.mD)(l).SVGSVGElement,"Expected an SVG element"),await eo(e),{svg:e,width:r.width,height:r.height,trimPadding:r.trimPadding}}finally{setTimeout(()=>{c.unmount(),l.removeChild(d)},0)}}async function eo(e){let t=[...e.querySelectorAll("foreignObject.tl-export-embed-styles > *")];if(!t.length)return;let n=new q(e);try{for(let r of(n.fonts.startFindingDocumentFontFaces(e.ownerDocument),await Promise.all(t.map(e=>f(e))),t))n.readRootElementStyles(r);await n.fetchResources();let r=await n.getFontFaceCss();n.unwrapCustomElements();let i=n.embedStyles();if(r||i){let t=e.ownerDocument.createElementNS("http://www.w3.org/2000/svg","style");t.textContent=`${r}
|
|
4
|
+
${i}`,e.prepend(t)}}finally{n.dispose()}}},2642:(e,t,n)=>{"use strict";n.d(t,{i:()=>c});var r=n(83102),i=n(81467),o=n(24167),s=n(59830),a=n(82246);class l extends a{}class d{rBush;elementsInTree;constructor(){this.rBush=new l,this.elementsInTree=new Map}search(e){return new Set(this.rBush.search({minX:e.minX,minY:e.minY,maxX:e.maxX,maxY:e.maxY}).map(e=>e.id))}remove(e){let t=this.elementsInTree.get(e);t&&(this.rBush.remove(t),this.elementsInTree.delete(e))}applyBatch(e,t){for(let t of e)this.remove(t);for(let e of t){let t=this.elementsInTree.get(e.id);t&&this.rBush.remove(t),this.rBush.insert(e),this.elementsInTree.set(e.id,e)}}bulkLoad(e){for(let t of(this.rBush.load(e),e))this.elementsInTree.set(t.id,t)}clear(){this.rBush.clear(),this.elementsInTree.clear()}has(e){return this.elementsInTree.has(e)}getSize(){return this.elementsInTree.size}getElement(e){return this.elementsInTree.get(e)}dispose(){this.clear()}}class c{constructor(e){this.editor=e,this.rbush=new d,this.spatialIndexComputed=this.createSpatialIndexComputed()}editor;rbush;spatialIndexComputed;lastPageId=null;_boundsEpoch=0;rebuildAndBumpEpoch(){return this.buildFromScratch(),this._boundsEpoch++,this._boundsEpoch}createSpatialIndexComputed(){let e=this.editor.store.query.filterHistory("shape"),t=this.editor.store.query.filterHistory("binding");return(0,r.EW)("spatialIndex",(n,i)=>{let o=e.getDiffSince(i),s=t.getDiffSince(i),a=this.editor.getCurrentPageId();return(0,r._O)(n)||o===r.c2||s===r.c2||this.lastPageId!==a?(0,r.Pm)(()=>this.rebuildAndBumpEpoch()):(0===o.length&&0===s.length||(0,r.Pm)(()=>this.processIncrementalUpdate(o,s))&&this._boundsEpoch++,this._boundsEpoch)})}buildFromScratch(){this.rbush.clear(),this.lastPageId=this.editor.getCurrentPageId();let e=[];for(let t of this.editor.getCurrentPageShapes()){let n=this.editor.getShapePageBounds(t.id);n&&n.isValid()&&e.push({minX:n.minX,minY:n.minY,maxX:n.maxX,maxY:n.maxY,id:t.id})}this.rbush.bulkLoad(e)}processIncrementalUpdate(e,t){let n=new Set,r=[],s=new Set,a=new Set,l=[],d=e=>{a.has(e)||(a.add(e),l.push(e))};for(let t of e){for(let e of(0,o.Ic)(t.added))(0,i.o2)(e)&&(s.add(e.id),d(e.id));for(let e of(0,o.Ic)(t.removed))(0,i.o2)(e)&&(this.rbush.has(e.id)&&n.add(e.id),(0,i.xh)(e.parentId)||d(e.parentId));for(let[e,n]of(0,o.Ic)(t.updated))(0,i.o2)(n)&&(s.add(n.id),d(n.id),(0,i.o2)(e)&&e.parentId!==n.parentId&&!(0,i.xh)(e.parentId)&&d(e.parentId))}for(let e of t){for(let t of(0,o.Ic)(e.added))(0,i.OT)(t)&&(d(t.fromId),d(t.toId));for(let t of(0,o.Ic)(e.removed))(0,i.OT)(t)&&(d(t.fromId),d(t.toId));for(let[t,n]of(0,o.Ic)(e.updated))(0,i.OT)(n)&&(d(n.fromId),d(n.toId),(0,i.OT)(t)&&(t.fromId!==n.fromId||t.toId!==n.toId)&&(d(t.fromId),d(t.toId)))}let c=[...s];for(;c.length;){let e=c.pop();for(let t of this.editor.getSortedChildIdsForParent(e))s.has(t)||(s.add(t),c.push(t)),d(t)}for(;l.length;){let e=l.pop(),t=this.editor.store.unsafeGetWithoutCapture(e);for(let n of(t&&(0,i.o2)(t)&&!(0,i.xh)(t.parentId)&&d(t.parentId),this.editor.getBindingsInvolvingShape(e)))d(n.fromId),d(n.toId)}for(let e of a){let t=n.has(e)?void 0:this.rbush.getElement(e),o=this.editor.store.unsafeGetWithoutCapture(e);if(!o||!(0,i.o2)(o)||this.editor.getAncestorPageId(o)!==this.lastPageId){this.rbush.has(e)&&n.add(e);continue}let s=this.editor.getShapePageBounds(e);s&&s.isValid()?this.areBoundsEqualToSpatialElement(s,t)||(n.delete(e),r.push({minX:s.minX,minY:s.minY,maxX:s.maxX,maxY:s.maxY,id:e})):this.rbush.has(e)&&n.add(e)}return(0!==n.size||0!==r.length)&&(this.rbush.applyBatch(n,r),!0)}areBoundsEqualToSpatialElement(e,t){return!e&&!t||!!e&&!!t&&e.minX===t.minX&&e.minY===t.minY&&e.maxX===t.maxX&&e.maxY===t.maxY}getShapeIdsInsideBounds(e){return this.spatialIndexComputed.get(),this.rbush.search(e)}getShapeIdsAtPoint(e,t=0){return this.spatialIndexComputed.get(),this.rbush.search(new s.az(e.x-t,e.y-t,2*t,2*t))}dispose(){this.rbush.dispose(),this.lastPageId=null}}},4343:(e,t,n)=>{"use strict";n.d(t,{H:()=>a,w:()=>s});var r=n(81467),i=n(24167),o=n(59830);function s(e){switch(e.type){case"shapes":{let t=e.shapeIds.map(e=>l(e.slice(6)));return`s${t.join(".")}`}case"page":return"p"+l(r.tv.parseId(e.pageId));case"viewport":{let{bounds:t,pageId:n}=e,i=`v${Math.round(t.x)}.${Math.round(t.y)}.${Math.round(t.w)}.${Math.round(t.h)}`;return n&&(i+="."+l(r.tv.parseId(n))),i}default:(0,i.h6)(e)}}function a(e){switch(e[0]){case"s":return{type:"shapes",shapeIds:e.slice(1).split(".").filter(Boolean).map(e=>(0,r.n6)(decodeURIComponent(e)))};case"p":return{type:"page",pageId:r.tv.createId(decodeURIComponent(e.slice(1)))};case"v":{let[t,n,i,s,a]=e.slice(1).split(".");return{type:"viewport",bounds:new o.az(Number(t),Number(n),Number(i),Number(s)),pageId:a?r.tv.createId(decodeURIComponent(a)):void 0}}default:throw Error("Invalid deep link string")}}function l(e){return encodeURIComponent(e).replace(/\./g,"%2E")}},4467:(e,t,n)=>{var r,i=function(){var e=String.fromCharCode,t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",r={};function i(e,t){if(!r[e]){r[e]={};for(var n=0;n<e.length;n++)r[e][e.charAt(n)]=n}return r[e][t]}var o={compressToBase64:function(e){if(null==e)return"";var n=o._compress(e,6,function(e){return t.charAt(e)});switch(n.length%4){default:case 0:return n;case 1:return n+"===";case 2:return n+"==";case 3:return n+"="}},decompressFromBase64:function(e){return null==e?"":""==e?null:o._decompress(e.length,32,function(n){return i(t,e.charAt(n))})},compressToUTF16:function(t){return null==t?"":o._compress(t,15,function(t){return e(t+32)})+" "},decompressFromUTF16:function(e){return null==e?"":""==e?null:o._decompress(e.length,16384,function(t){return e.charCodeAt(t)-32})},compressToUint8Array:function(e){for(var t=o.compress(e),n=new Uint8Array(2*t.length),r=0,i=t.length;r<i;r++){var s=t.charCodeAt(r);n[2*r]=s>>>8,n[2*r+1]=s%256}return n},decompressFromUint8Array:function(t){if(null==t)return o.decompress(t);for(var n=Array(t.length/2),r=0,i=n.length;r<i;r++)n[r]=256*t[2*r]+t[2*r+1];var s=[];return n.forEach(function(t){s.push(e(t))}),o.decompress(s.join(""))},compressToEncodedURIComponent:function(e){return null==e?"":o._compress(e,6,function(e){return n.charAt(e)})},decompressFromEncodedURIComponent:function(e){return null==e?"":""==e?null:(e=e.replace(/ /g,"+"),o._decompress(e.length,32,function(t){return i(n,e.charAt(t))}))},compress:function(t){return o._compress(t,16,function(t){return e(t)})},_compress:function(e,t,n){if(null==e)return"";var r,i,o,s={},a={},l="",d="",c="",u=2,h=3,p=2,f=[],g=0,m=0;for(o=0;o<e.length;o+=1)if(l=e.charAt(o),Object.prototype.hasOwnProperty.call(s,l)||(s[l]=h++,a[l]=!0),d=c+l,Object.prototype.hasOwnProperty.call(s,d))c=d;else{if(Object.prototype.hasOwnProperty.call(a,c)){if(256>c.charCodeAt(0)){for(r=0;r<p;r++)g<<=1,m==t-1?(m=0,f.push(n(g)),g=0):m++;for(i=c.charCodeAt(0),r=0;r<8;r++)g=g<<1|1&i,m==t-1?(m=0,f.push(n(g)),g=0):m++,i>>=1}else{for(r=0,i=1;r<p;r++)g=g<<1|i,m==t-1?(m=0,f.push(n(g)),g=0):m++,i=0;for(i=c.charCodeAt(0),r=0;r<16;r++)g=g<<1|1&i,m==t-1?(m=0,f.push(n(g)),g=0):m++,i>>=1}0==--u&&(u=Math.pow(2,p),p++),delete a[c]}else for(i=s[c],r=0;r<p;r++)g=g<<1|1&i,m==t-1?(m=0,f.push(n(g)),g=0):m++,i>>=1;0==--u&&(u=Math.pow(2,p),p++),s[d]=h++,c=String(l)}if(""!==c){if(Object.prototype.hasOwnProperty.call(a,c)){if(256>c.charCodeAt(0)){for(r=0;r<p;r++)g<<=1,m==t-1?(m=0,f.push(n(g)),g=0):m++;for(i=c.charCodeAt(0),r=0;r<8;r++)g=g<<1|1&i,m==t-1?(m=0,f.push(n(g)),g=0):m++,i>>=1}else{for(r=0,i=1;r<p;r++)g=g<<1|i,m==t-1?(m=0,f.push(n(g)),g=0):m++,i=0;for(i=c.charCodeAt(0),r=0;r<16;r++)g=g<<1|1&i,m==t-1?(m=0,f.push(n(g)),g=0):m++,i>>=1}0==--u&&(u=Math.pow(2,p),p++),delete a[c]}else for(i=s[c],r=0;r<p;r++)g=g<<1|1&i,m==t-1?(m=0,f.push(n(g)),g=0):m++,i>>=1;0==--u&&(u=Math.pow(2,p),p++)}for(r=0,i=2;r<p;r++)g=g<<1|1&i,m==t-1?(m=0,f.push(n(g)),g=0):m++,i>>=1;for(;;){if(g<<=1,m==t-1){f.push(n(g));break}m++}return f.join("")},decompress:function(e){return null==e?"":""==e?null:o._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(t,n,r){var i,o,s,a,l,d,c,u=[],h=4,p=4,f=3,g="",m=[],y={val:r(0),position:n,index:1};for(i=0;i<3;i+=1)u[i]=i;for(s=0,l=4,d=1;d!=l;)a=y.val&y.position,y.position>>=1,0==y.position&&(y.position=n,y.val=r(y.index++)),s|=(a>0)*d,d<<=1;switch(s){case 0:for(s=0,l=256,d=1;d!=l;)a=y.val&y.position,y.position>>=1,0==y.position&&(y.position=n,y.val=r(y.index++)),s|=(a>0)*d,d<<=1;c=e(s);break;case 1:for(s=0,l=65536,d=1;d!=l;)a=y.val&y.position,y.position>>=1,0==y.position&&(y.position=n,y.val=r(y.index++)),s|=(a>0)*d,d<<=1;c=e(s);break;case 2:return""}for(u[3]=c,o=c,m.push(c);;){if(y.index>t)return"";for(s=0,l=Math.pow(2,f),d=1;d!=l;)a=y.val&y.position,y.position>>=1,0==y.position&&(y.position=n,y.val=r(y.index++)),s|=(a>0)*d,d<<=1;switch(c=s){case 0:for(s=0,l=256,d=1;d!=l;)a=y.val&y.position,y.position>>=1,0==y.position&&(y.position=n,y.val=r(y.index++)),s|=(a>0)*d,d<<=1;u[p++]=e(s),c=p-1,h--;break;case 1:for(s=0,l=65536,d=1;d!=l;)a=y.val&y.position,y.position>>=1,0==y.position&&(y.position=n,y.val=r(y.index++)),s|=(a>0)*d,d<<=1;u[p++]=e(s),c=p-1,h--;break;case 2:return m.join("")}if(0==h&&(h=Math.pow(2,f),f++),u[c])g=u[c];else{if(c!==p)return null;g=o+o.charAt(0)}m.push(g),u[p++]=o+g.charAt(0),h--,o=g,0==h&&(h=Math.pow(2,f),f++)}}};return o}();void 0===(r=(function(){return i}).call(t,n,t,e))||(e.exports=r)},4599:(e,t,n)=>{"use strict";n.d(t,{I:()=>s,d:()=>a});var r=n(83102),i=n(24167),o=n(81962);function s(e,t,n){let s=new Set;for(let n of t){let t=e.getShape(n);if(!t)continue;s.add(t);let r=e.getShape(t.parentId);r&&s.add(r)}let l=new Map;for(let t of s){let i=e.getSortedChildIdsForParent(t);if(n?.filter&&!n.filter(t))l.set(t,i);else{let n=function(e,t,n){if(0===n.length)return r.Ml;let i=e.getShapePageBounds(t);if(!i)return r.Ml;let s=e.getShape(t);if(!s)return r.Ml;let a=e.getShapeGeometry(t),l=e.getShapePageTransform(t),d=l.applyToPoints(a.vertices),c=e.getShapeUtil(s.type).getClipPath?.(s),u=c?l.applyToPoints(c):void 0,h=u?(0,o.oQ)(u,d):d;return h?n.filter(t=>{let n=e.getShapePageBounds(t);if(!n||!i.includes(n))return!1;let r=e.getShapePageTransform(t).clone().invert().applyToPoints(h);return e.getShapeGeometry(t).overlapsPolygon(r)}):r.Ml}(e,t.id,i);if(n.length<i.length){let r=e.getShapeUtil(t),o=i.filter(i=>{if(n.includes(i))return!1;let o=e.getShape(i);return!!o&&r.canRemoveChildrenOfType(t,o.type)});o.length>0&&l.set(t,o)}}}let d=e.getCurrentPageShapesSorted().map(e=>e.id),c={};for(let[t,r]of l){let o=(0,i.oE)(r.map(t=>e.getShape(t))),{reparenting:s,remainingShapesToReparent:l}=a(e,o,(e,r)=>(!n?.filter||!!n.filter(r))&&r.id!==t.id&&d.indexOf(r.id)<d.indexOf(e.id));if(s.forEach((e,t)=>{0!==e.length&&(c[t]||(c[t]={parentId:t,shapeIds:[]}),c[t].shapeIds.push(...e.map(e=>e.id)))}),l.size>0){let n=e.findShapeAncestor(t,t=>e.isShapeOfType(t,"group"))?.id??e.getCurrentPageId();l.forEach(r=>{if(!c[n]){let r,o=e.getSortedChildIdsForParent(n),s=o.indexOf(t.id);if(s>-1){let n=o[s+1],a=n?e.getShape(n).index:void 0,l=a&&a>t.index?a:(0,i.AQ)(t.index);r=(0,i.HE)(t.index,l)}c[n]={parentId:n,shapeIds:[],index:r}}c[n].shapeIds.push(r.id)})}}e.run(()=>{Object.values(c).forEach(({parentId:t,shapeIds:n,index:r})=>{0!==n.length&&(n.sort((e,t)=>d.indexOf(e)<d.indexOf(t)?-1:1),e.reparentShapes(n,t,r))})})}function a(e,t,n){let r=new Set(t),s=new Set;for(let n of t){let t=e.getShapeParent(n);t&&e.isShapeOfType(t,"group")&&!s.has(t)&&s.add(t)}for(let t of s){for(let n of(0,i.oE)(e.getSortedChildIdsForParent(t).map(t=>e.getShape(t))))r.delete(n);r.add(t)}let a=new Map,l=new Map,d=new Set(r),c=e.getCurrentPageShapesSorted().filter(t=>{if(d.has(t))return!1;let n=e.getShapeUtil(t);for(let e of d)if(n.canReceiveNewChildrenOfType(t,e.type))return!0;return!1});for(let t=c.length-1;t>=0;t--){let r=c[t],i=e.findShapeAncestor(r,t=>e.isShapeOfType(t,"group"))?.id,s=e.getShapeGeometry(r),u=e.getShapePageTransform(r),h=e.getShapeMask(r),p=u.applyToPoints(s.vertices),f=h?(0,o.oQ)(h,p):p;if(!f)continue;let g=[];for(let t of d){if(r.id===t.id||n&&!n(t,r)||(a.has(t.id)||a.set(t.id,e.findShapeAncestor(t,t=>e.isShapeOfType(t,"group"))?.id),a.get(t.id)!==i||e.findShapeAncestor(r,e=>t.id===e.id)))continue;let o=e.getShapePageTransform(t).clone().invert().applyToPoints(f);if(e.getShapeGeometry(t).overlapsPolygon(o)){if(!e.getShapeUtil(r).canReceiveNewChildrenOfType?.(r,t.type))continue;t.parentId!==r.id&&g.push(t),d.delete(t);continue}}g.length&&l.set(r.id,g)}return{reparenting:l,remainingShapesToReparent:d}}},8242:(e,t,n)=>{"use strict";n.d(t,{$L:()=>_,Ln:()=>g,N0:()=>E,Um:()=>I,Wg:()=>m,X9:()=>s,Ys:()=>h,dL:()=>$,jP:()=>x,n9:()=>P,oM:()=>w,zy:()=>k});var r=n(27050);class i{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class o{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&o.empty)return o.empty}recover(e){let t=0,n=65535&e;if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*n]+t+(e-(65535&e))/65536}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,o=this.inverted?2:1,s=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>e)break;let d=this.ranges[a+o],c=this.ranges[a+s],u=l+d;if(e<=u){let o=d?e==l?-1:e==u?1:t:t,s=l+r+(o<0?0:c);if(n)return s;let h=e==(t<0?l:u)?null:a/3+(e-l)*65536,p=e==l?2:e==u?1:4;return(t<0?e!=l:e!=u)&&(p|=8),new i(s,p,h)}r+=c-d}return n?e+r:new i(e+r,0,null)}touches(e,t){let n=0,r=65535&t,i=this.inverted?2:1,o=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let s=this.ranges[t]-(this.inverted?n:0);if(s>e)break;let a=this.ranges[t+i];if(e<=s+a&&t==3*r)return!0;n+=this.ranges[t+o]-a}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let o=this.ranges[r],s=o-(this.inverted?i:0),a=o+(this.inverted?0:i),l=this.ranges[r+t],d=this.ranges[r+n];e(s,s+l,a,a+d),i+=d-l}}invert(){return new o(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?o.empty:new o(e<0?[0,-e,0]:[0,0,e])}}o.empty=new o([]);class s{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new s(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),null!=t&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],null!=r&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}invert(){let e=new s;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(null!=i.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new i(e,r,null)}}let a=Object.create(null);class l{getMap(){return o.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError("Invalid input for Step.fromJSON");let n=a[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in a)throw RangeError("Duplicate use of step JSON ID "+e);return a[e]=t,t.prototype.jsonID=e,t}}class d{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new d(e,null)}static fail(e){return new d(null,e)}static fromReplace(e,t,n,i){try{return d.ok(e.replace(t,n,i))}catch(e){if(e instanceof r.vI)return d.fail(e.message);throw e}}}function c(e,t,n){let i=[];for(let r=0;r<e.childCount;r++){let o=e.child(r);o.content.size&&(o=o.copy(c(o.content,t,o))),o.isInline&&(o=t(o,n,r)),i.push(o)}return r.FK.fromArray(i)}class u extends l{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),i=n.node(n.sharedDepth(this.to)),o=new r.Ji(c(t.content,(e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e,i),t.openStart,t.openEnd);return d.fromReplace(e,this.from,this.to,o)}invert(){return new h(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new u(t.pos,n.pos,this.mark)}merge(e){return e instanceof u&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new u(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw RangeError("Invalid input for AddMarkStep.fromJSON");return new u(t.from,t.to,e.markFromJSON(t.mark))}}l.jsonID("addMark",u);class h extends l{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new r.Ji(c(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return d.fromReplace(e,this.from,this.to,n)}invert(){return new u(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new h(t.pos,n.pos,this.mark)}merge(e){return e instanceof h&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new h(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw RangeError("Invalid input for RemoveMarkStep.fromJSON");return new h(t.from,t.to,e.markFromJSON(t.mark))}}l.jsonID("removeMark",h);class p extends l{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return d.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return d.fromReplace(e,this.pos,this.pos+1,new r.Ji(r.FK.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new p(this.pos,t.marks[n]);return new p(this.pos,this.mark)}}return new f(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new p(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new p(t.pos,e.markFromJSON(t.mark))}}l.jsonID("addNodeMark",p);class f extends l{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return d.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return d.fromReplace(e,this.pos,this.pos+1,new r.Ji(r.FK.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new p(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new f(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new f(t.pos,e.markFromJSON(t.mark))}}l.jsonID("removeNodeMark",f);class g extends l{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&y(e,this.from,this.to)?d.fail("Structure replace would overwrite content"):d.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new o([this.from,this.to-this.from,this.slice.size])}invert(e){return new g(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),n=this.from==this.to&&g.MAP_BIAS<0?t:e.mapResult(this.from,1);return n.deletedAcross&&t.deletedAcross?null:new g(n.pos,Math.max(n.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof g)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart)if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;else{let t=this.slice.size+e.slice.size==0?r.Ji.empty:new r.Ji(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new g(e.from,this.to,t,this.structure)}{let t=this.slice.size+e.slice.size==0?r.Ji.empty:new r.Ji(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new g(this.from,this.to+(e.to-e.from),t,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw RangeError("Invalid input for ReplaceStep.fromJSON");return new g(t.from,t.to,r.Ji.fromJSON(e,t.slice),!!t.structure)}}g.MAP_BIAS=1,l.jsonID("replace",g);class m extends l{constructor(e,t,n,r,i,o,s=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=o,this.structure=s}apply(e){if(this.structure&&(y(e,this.from,this.gapFrom)||y(e,this.gapTo,this.to)))return d.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return d.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?d.fromReplace(e,this.from,this.to,n):d.fail("Content does not fit in gap")}getMap(){return new o([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new m(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||r<t.pos||i>n.pos?null:new m(t.pos,n.pos,r,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new m(t.from,t.to,t.gapFrom,t.gapTo,r.Ji.fromJSON(e,t.slice),t.insert,!!t.structure)}}function y(e,t,n){let r=e.resolve(t),i=n-t,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let e=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function b(e,t,n,i=n.contentMatch,o=!0){let s=e.doc.nodeAt(t),a=[],l=t+1;for(let t=0;t<s.childCount;t++){let d=s.child(t),c=l+d.nodeSize,u=i.matchType(d.type);if(u){i=u;for(let t=0;t<d.marks.length;t++)n.allowsMarkType(d.marks[t].type)||e.step(new h(l,c,d.marks[t]));if(o&&d.isText&&"pre"!=n.whitespace){let e,t=/\r?\n|\r/g,i;for(;e=t.exec(d.text);)i||(i=new r.Ji(r.FK.from(n.schema.text(" ",n.allowedMarks(d.marks))),0,0)),a.push(new g(l+e.index,l+e.index+e[0].length,i))}}else a.push(new g(l,c,r.Ji.empty));l=c}if(!i.validEnd){let t=i.fillBefore(r.FK.empty,!0);e.replace(l,l,new r.Ji(t,0,0))}for(let t=a.length-1;t>=0;t--)e.step(a[t])}function x(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let o=e.$from.node(n),s=e.$from.index(n)+r,a=e.$to.indexAfter(n)-i;if(n<e.depth&&o.canReplace(s,a,t))return n;if(0==n||o.type.spec.isolating||!((0==s||o.canReplace(s,o.childCount))&&(a==o.childCount||o.canReplace(0,a))))break;s&&(r=1),a<o.childCount&&(i=1)}return null}function w(e,t,n=null,r=e){let i=function(e,t){let{parent:n,startIndex:r,endIndex:i}=e,o=n.contentMatchAt(r).findWrapping(t);if(!o)return null;let s=o.length?o[0]:t;return n.canReplaceWith(r,i,s)?o:null}(e,t),o=i&&function(e,t){let{parent:n,startIndex:r,endIndex:i}=e,o=n.child(r),s=t.contentMatch.findWrapping(o.type);if(!s)return null;let a=(s.length?s[s.length-1]:t).contentMatch;for(let e=r;a&&e<i;e++)a=a.matchType(n.child(e).type);return a&&a.validEnd?s:null}(r,t);return o?i.map(v).concat({type:t,attrs:n}).concat(o.map(v)):null}function v(e){return{type:e,attrs:null}}function S(e,t,n,r){t.forEach((i,o)=>{if(i.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(i.text);){let i=e.mapping.slice(r).map(n+1+o+s.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function C(e,t,n,r){t.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+o);e.replaceWith(i,i+1,t.type.schema.text("\n"))}})}function k(e,t,n=1,r){let i=e.resolve(t),o=i.depth-n,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>o;e--,t--){let n=i.node(e),o=i.index(e);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(o,n.childCount),a=r&&r[t+1];a&&(s=s.replaceChild(0,a.type.create(a.attrs)));let l=r&&r[t]||n;if(!n.canReplace(o+1,n.childCount)||!l.type.validContent(s))return!1}let a=i.indexAfter(o),l=r&&r[0];return i.node(o).canReplaceWith(a,a,l?l.type:i.node(o+1).type)}function P(e,t){let n=e.resolve(t),r=n.index();return T(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function T(e,t){return!!(e&&t&&!e.isLeaf&&function(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i<t.childCount;i++){let o=t.child(i),s=o.type==r?e.type.schema.nodes.text:o.type;if(!(n=n.matchType(s))||!e.type.allowsMarks(o.marks))return!1}return n.validEnd}(e,t))}function E(e,t,n=-1){let r=e.resolve(t);for(let e=r.depth;;e--){let i,o,s=r.index(e);if(e==r.depth?(i=r.nodeBefore,o=r.nodeAfter):n>0?(i=r.node(e+1),s++,o=r.node(e).maybeChild(s)):(i=r.node(e).maybeChild(s-1),o=r.node(e+1)),i&&!i.isTextblock&&T(i,o)&&r.node(e).canReplace(s,s+1))return t;if(0==e)break;t=n<0?r.before(e):r.after(e)}}function I(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let e=0;e<n.openStart;e++)i=i.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,o=r.index(t)+ +(n>0),s=r.node(t),a=!1;if(1==e)a=s.canReplace(o,o,i);else{let e=s.contentMatchAt(o).findWrapping(i.firstChild.type);a=e&&s.canReplaceWith(o,o,e[0])}if(a)return 0==n?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function _(e,t,n=t,i=r.Ji.empty){if(t==n&&!i.size)return null;let o=e.resolve(t),s=e.resolve(n);return M(o,s,i)?new g(t,n,i):new A(o,s,i).fit()}function M(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}l.jsonID("replaceAround",m);class A{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=r.FK.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=r.FK.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,i=this.close(e<0?this.$to:n.doc.resolve(e));if(!i)return null;let o=this.placed,s=n.depth,a=i.depth;for(;s&&a&&1==o.childCount;)o=o.firstChild.content,s--,a--;let l=new r.Ji(o,s,a);return e>-1?new m(n.pos,e,this.$to.pos,this.$to.end(),l,t):l.size||n.pos!=this.$to.pos?new g(n.pos,i.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=1==t?e:this.unplaced.openStart;n>=0;n--){let e=null,i=(n?(e=D(this.unplaced.content,n-1).firstChild).content:this.unplaced.content).firstChild;for(let o=this.depth;o>=0;o--){let{type:s,match:a}=this.frontier[o],l,d=null;if(1==t&&(i?a.matchType(i.type)||(d=a.fillBefore(r.FK.from(i),!1)):e&&s.compatibleContent(e.type)))return{sliceDepth:n,frontierDepth:o,parent:e,inject:d};if(2==t&&i&&(l=a.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:o,parent:e,wrap:l};if(e&&a.matchType(e.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=D(e,t);return!!i.childCount&&!i.firstChild.isLeaf&&(this.unplaced=new r.Ji(e,t+1,Math.max(n,i.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=D(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new r.Ji(j(e,t-1,1),t-1,o?t-1:n)}else this.unplaced=new r.Ji(j(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let e=0;e<o.length;e++)this.openFrontierNode(o[e]);let s=this.unplaced,a=n?n.content:s.content,l=s.openStart-e,d=0,c=[],{match:u,type:h}=this.frontier[t];if(i){for(let e=0;e<i.childCount;e++)c.push(i.child(e));u=u.matchFragment(i)}let p=a.size+e-(s.content.size-s.openEnd);for(;d<a.childCount;){let e=a.child(d),t=u.matchType(e.type);if(!t)break;(++d>1||0==l||e.content.size)&&(u=t,c.push(function e(t,n,i){if(n<=0)return t;let o=t.content;return n>1&&(o=o.replaceChild(0,e(o.firstChild,n-1,1==o.childCount?i-1:0))),n>0&&(o=t.type.contentMatch.fillBefore(o).append(o),i<=0&&(o=o.append(t.type.contentMatch.matchFragment(o).fillBefore(r.FK.empty,!0)))),t.copy(o)}(e.mark(h.allowedMarks(e.marks)),1==d?l:0,d==a.childCount?p:-1)))}let f=d==a.childCount;f||(p=-1),this.placed=O(this.placed,t,r.FK.from(c)),this.frontier[t].match=u,f&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=a;e<p;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=f?0==e?r.Ji.empty:new r.Ji(j(s.content,e-1,1),e-1,p<0?s.openEnd:e-1):new r.Ji(j(s.content,e,d),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return -1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!L(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return -1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=L(e,t,r,n,i);if(o){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=L(e,n,r,t,!0);if(!i||i.childCount)continue e}return{depth:t,fit:o,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=O(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=O(this.placed,this.depth,r.FK.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(r.FK.empty,!0);e.childCount&&(this.placed=O(this.placed,this.frontier.length,e))}}function j(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(j(e.firstChild.content,t-1,n)))}function O(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(O(e.lastChild.content,t-1,n)))}function D(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function L(e,t,n,r,i){let o=e.node(t),s=i?e.indexAfter(t):e.index(t);if(s==o.childCount&&!n.compatibleContent(o.type))return null;let a=r.fillBefore(o.content,!0,s);return a&&!function(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,o.content,s)?a:null}function F(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(r<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}class R extends l{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return d.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let i=t.type.create(n,null,t.marks);return d.fromReplace(e,this.pos,this.pos+1,new r.Ji(r.FK.from(i),0,+!t.isLeaf))}getMap(){return o.empty}invert(e){return new R(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new R(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw RangeError("Invalid input for AttrStep.fromJSON");return new R(t.pos,t.attr,t.value)}}l.jsonID("attr",R);class z extends l{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return d.ok(n)}getMap(){return o.empty}invert(e){return new z(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if("string"!=typeof t.attr)throw RangeError("Invalid input for DocAttrStep.fromJSON");return new z(t.attr,t.value)}}l.jsonID("docAttr",z);let N=class extends Error{};(N=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n}).prototype=Object.create(Error.prototype),N.prototype.constructor=N,N.prototype.name="TransformError";class ${constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new s}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new N(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,i,o)=>{e=Math.min(e,i),t=Math.max(t,o)})}return 1e9==e?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=r.Ji.empty){let i=_(this.doc,e,t,n);return i&&this.step(i),this}replaceWith(e,t,n){return this.replace(e,t,new r.Ji(r.FK.from(n),0,0))}delete(e,t){return this.replace(e,t,r.Ji.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return!function(e,t,n,i){if(!i.size)return e.deleteRange(t,n);let o=e.doc.resolve(t),s=e.doc.resolve(n);if(M(o,s,i))return e.step(new g(t,n,i));let a=F(o,s);0==a[a.length-1]&&a.pop();let l=-(o.depth+1);a.unshift(l);for(let e=o.depth,t=o.pos-1;e>0;e--,t--){let n=o.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;a.indexOf(e)>-1?l=e:o.before(e)==t&&a.splice(1,0,-e)}let d=a.indexOf(l),c=[],u=i.openStart;for(let e=i.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==i.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){var h;let t=c[e],n=(h=t.type).spec.defining||h.spec.definingForContent;if(n&&!t.sameMarkup(o.node(Math.abs(l)-1)))u=e;else if(n||!t.type.isTextblock)break}for(let t=i.openStart;t>=0;t--){let l=(t+u+1)%(i.openStart+1),h=c[l];if(h)for(let t=0;t<a.length;t++){let c=a[(t+d)%a.length],u=!0;c<0&&(u=!1,c=-c);let p=o.node(c-1),f=o.index(c-1);if(p.canReplaceWith(f,f,h.type,h.marks))return e.replace(o.before(c),u?s.after(c):n,new r.Ji(function e(t,n,i,o,s){if(n<i){let r=t.firstChild;t=t.replaceChild(0,r.copy(e(r.content,n+1,i,o,r)))}if(n>o){let e=s.contentMatchAt(0),n=e.fillBefore(t).append(t);t=n.append(e.matchFragment(n).fillBefore(r.FK.empty,!0))}return t}(i.content,0,i.openStart,l),l,i.openEnd))}}let p=e.steps.length;for(let r=a.length-1;r>=0&&(e.replace(t,n,i),!(e.steps.length>p));r--){let e=a[r];e<0||(t=o.before(e),n=s.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){var i=e,o=t;if(!n.isInline&&i==o&&this.doc.resolve(i).parent.content.size){let e=function(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)break}return null}(this.doc,i,n.type);null!=e&&(i=o=e)}return this.replaceRange(i,o,new r.Ji(r.FK.from(n),0,0)),this}deleteRange(e,t){return!function(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&0==r.parentOffset&&0==i.parentOffset){let o=r.sharedDepth(n),s=!1;for(let e=r.depth;e>o;e--)r.node(e).type.spec.isolating&&(s=!0);for(let e=i.depth;e>o;e--)i.node(e).type.spec.isolating&&(s=!0);if(!s){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=i.depth;e>0&&n==i.start(e);e--)n=i.before(e);r=e.doc.resolve(t),i=e.doc.resolve(n)}}let o=F(r,i);for(let t=0;t<o.length;t++){let n=o[t],s=t==o.length-1;if(s&&0==n||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),i.end(n));if(n>0&&(s||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(t-r.start(o)==r.depth-o&&n>r.end(o)&&i.end(o)-n!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return e.delete(r.before(o),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return!function(e,t,n){let{$from:i,$to:o,depth:s}=t,a=i.before(s+1),l=o.after(s+1),d=a,c=l,u=r.FK.empty,h=0;for(let e=s,t=!1;e>n;e--)t||i.index(e)>0?(t=!0,u=r.FK.from(i.node(e).copy(u)),h++):d--;let p=r.FK.empty,f=0;for(let e=s,t=!1;e>n;e--)t||o.after(e+1)<o.end(e)?(t=!0,p=r.FK.from(o.node(e).copy(p)),f++):c++;e.step(new m(d,c,a,l,new r.Ji(u.append(p),h,f),u.size-h,!0))}(this,e,t),this}join(e,t=1){return!function(e,t,n){let i=null,{linebreakReplacement:o}=e.doc.type.schema,s=e.doc.resolve(t-n),a=s.node().type;if(o&&a.inlineContent){let e="pre"==a.whitespace,t=!!a.contentMatch.matchType(o);e&&!t?i=!1:!e&&t&&(i=!0)}let l=e.steps.length;if(!1===i){let r=e.doc.resolve(t+n);C(e,r.node(),r.before(),l)}a.inlineContent&&b(e,t+n-1,a,s.node().contentMatchAt(s.index()),null==i);let d=e.mapping.slice(l),c=d.map(t-n);if(e.step(new g(c,d.map(t+n,-1),r.Ji.empty,!0)),!0===i){let t=e.doc.resolve(c);S(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return!function(e,t,n){let i=r.FK.empty;for(let e=n.length-1;e>=0;e--){if(i.size){let t=n[e].type.contentMatch.matchFragment(i);if(!t||!t.validEnd)throw RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}i=r.FK.from(n[e].type.create(n[e].attrs,i))}let o=t.start,s=t.end;e.step(new m(o,s,o,s,new r.Ji(i,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,i=null){var o=this;if(!n.isTextblock)throw RangeError("Type given to setBlockType should be a textblock");let s=o.steps.length;return o.doc.nodesBetween(e,t,(e,t)=>{var a,l,d;let c,u,h="function"==typeof i?i(e):i;if(e.isTextblock&&!e.hasMarkup(n,h)&&(a=o.doc,l=o.mapping.slice(s).map(t),d=n,u=(c=a.resolve(l)).index(),c.parent.canReplaceWith(u,u+1,d))){let i=null;if(n.schema.linebreakReplacement){let e="pre"==n.whitespace,t=!!n.contentMatch.matchType(n.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}!1===i&&C(o,e,t,s),b(o,o.mapping.slice(s).map(t,1),n,void 0,null===i);let a=o.mapping.slice(s),l=a.map(t,1),d=a.map(t+e.nodeSize,1);return o.step(new m(l,d,l+1,d-1,new r.Ji(r.FK.from(n.create(h,null,e.marks)),0,0),1,!0)),!0===i&&S(o,e,t,s),!1}}),this}setNodeMarkup(e,t,n=null,i){return!function(e,t,n,i,o){let s=e.doc.nodeAt(t);if(!s)throw RangeError("No node at given position");n||(n=s.type);let a=n.create(i,null,o||s.marks);if(s.isLeaf)return e.replaceWith(t,t+s.nodeSize,a);if(!n.validContent(s.content))throw RangeError("Invalid content for node type "+n.name);e.step(new m(t,t+s.nodeSize,t+1,t+s.nodeSize-1,new r.Ji(r.FK.from(a),0,0),1,!0))}(this,e,t,n,i),this}setNodeAttribute(e,t,n){return this.step(new R(e,t,n)),this}setDocAttribute(e,t){return this.step(new z(e,t)),this}addNodeMark(e,t){return this.step(new p(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError("No node at position "+e);if(t instanceof r.CU)t.isInSet(n.marks)&&this.step(new f(e,t));else{let r=n.marks,i,o=[];for(;i=t.isInSet(r);)o.push(new f(e,i)),r=i.removeFromSet(r);for(let e=o.length-1;e>=0;e--)this.step(o[e])}return this}split(e,t=1,n){return!function(e,t,n=1,i){let o=e.doc.resolve(t),s=r.FK.empty,a=r.FK.empty;for(let e=o.depth,t=o.depth-n,l=n-1;e>t;e--,l--){s=r.FK.from(o.node(e).copy(s));let t=i&&i[l];a=r.FK.from(t?t.type.create(t.attrs,a):o.node(e).copy(a))}e.step(new g(t,t,new r.Ji(s.append(a),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){var r;let i,o,s,a;return r=this,s=[],a=[],r.doc.nodesBetween(e,t,(r,l,d)=>{if(!r.isInline)return;let c=r.marks;if(!n.isInSet(c)&&d.type.allowsMarkType(n.type)){let d=Math.max(l,e),p=Math.min(l+r.nodeSize,t),f=n.addToSet(c);for(let e=0;e<c.length;e++)c[e].isInSet(f)||(i&&i.to==d&&i.mark.eq(c[e])?i.to=p:s.push(i=new h(d,p,c[e])));o&&o.to==d?o.to=p:a.push(o=new u(d,p,n))}}),s.forEach(e=>r.step(e)),a.forEach(e=>r.step(e)),this}removeMark(e,t,n){var i;let o,s;return i=this,o=[],s=0,i.doc.nodesBetween(e,t,(i,a)=>{if(!i.isInline)return;s++;let l=null;if(n instanceof r.sX){let e=i.marks,t;for(;t=n.isInSet(e);)(l||(l=[])).push(t),e=t.removeFromSet(e)}else n?n.isInSet(i.marks)&&(l=[n]):l=i.marks;if(l&&l.length){let n=Math.min(a+i.nodeSize,t);for(let t=0;t<l.length;t++){let r=l[t],i;for(let e=0;e<o.length;e++){let t=o[e];t.step==s-1&&r.eq(o[e].style)&&(i=t)}i?(i.to=n,i.step=s):o.push({style:r,from:Math.max(a,e),to:n,step:s})}}}),o.forEach(e=>i.step(new h(e.from,e.to,e.style))),this}clearIncompatible(e,t,n){return b(this,e,t,n),this}}},8810:(e,t,n)=>{"use strict";n.d(t,{c:()=>d});var r=n(83102),i=n(54530),o=n(24167);let s="recording",a="recordingPreserveRedoStack",l="paused";class d{store;dispose;state=s;pendingDiff=new u;stacks=(0,r.eU)("HistoryManager.stacks",{undos:f,redos:f},{isEqual:(e,t)=>e.undos===t.undos&&e.redos===t.redos});annotateError;constructor(e){this.store=e.store,this.annotateError=e.annotateError??o.lQ,this.dispose=this.store.addHistoryInterceptor((e,t)=>{if("user"===t)switch(this.state){case s:this.pendingDiff.apply(e.changes),this.stacks.get().redos.length>0&&this.stacks.update(({undos:e})=>({undos:e,redos:f}));break;case a:this.pendingDiff.apply(e.changes);break;case l:break;default:(0,o.h6)(this.state)}})}flushPendingDiff(){if(this.pendingDiff.isEmpty())return;let e=this.pendingDiff.clear();this.stacks.update(({undos:t,redos:n})=>({undos:t.push({type:"diff",diff:e}),redos:n}))}getNumUndos(){return this.stacks.get().undos.length+ +!this.pendingDiff.isEmpty()}getNumRedos(){return this.stacks.get().redos.length}_isReplaying=!1;isReplaying(){return this._isReplaying}_isInBatch=!1;batch(e,t){let n=this.state;n!==l&&t?.history&&(this.state=c[t.history]);try{if(this._isInBatch)return(0,r.hL)(e),this;this._isInBatch=!0;try{(0,r.hL)(e)}catch(e){throw this.annotateError(e),e}finally{this._isInBatch=!1}return this}finally{this.state=n}}_undo({pushToRedoStack:e,toMark:t}){let n=this.state,r=this._isReplaying;this.state=l,this._isReplaying=!0;try{let{undos:n,redos:r}=this.stacks.get(),s=this.pendingDiff.clear(),a=(0,i.RF)(s),l=(0,i.E8)(s);e&&!a&&(r=r.push({type:"diff",diff:s}));let d=!1;if(a)for(;n.head?.type==="stop";){let i=n.head;if(n=n.tail,e&&(r=r.push(i)),i.id===t){d=!0;break}}if(!d)t:for(;n.head;){let s=n.head;switch(n=n.tail,e&&(r=r.push(s)),s.type){case"diff":(0,i.Fl)(l,[(0,i.E8)(s.diff)]);break;case"stop":if(!t)break t;if(s.id===t){d=!0;break t}break;default:(0,o.h6)(s)}}if(!d&&t)return this.pendingDiff.restore(s),this;this.store.applyDiff(l,{ignoreEphemeralKeys:!0}),this.store.ensureStoreIsUsable(),this.stacks.set({undos:n,redos:r})}finally{this._isReplaying=r,this.state=n}return this}undo(){return this._undo({pushToRedoStack:!0}),this}redo(){let e=this.state,t=this._isReplaying;this.state=l,this._isReplaying=!0;try{this.flushPendingDiff();let{undos:e,redos:t}=this.stacks.get();if(0===t.length)return this;for(;t.head?.type==="stop";)e=e.push(t.head),t=t.tail;let n=(0,i.L4)();for(;t.head;){let r=t.head;if(e=e.push(r),t=t.tail,"diff"===r.type)(0,i.Fl)(n,[r.diff]);else break}this.store.applyDiff(n,{ignoreEphemeralKeys:!0}),this.store.ensureStoreIsUsable(),this.stacks.set({undos:e,redos:t})}finally{this._isReplaying=t,this.state=e}return this}bail(){return this._undo({pushToRedoStack:!1}),this}bailToMark(e){return e&&this._undo({pushToRedoStack:!1,toMark:e}),this}squashToMark(e){let t=this.stacks.get().undos,n=[];for(;t.head&&("stop"!==t.head.type||t.head.id!==e);)"diff"===t.head.type&&n.push(t.head.diff),t=t.tail;if(!t.head||t.head?.id!==e)return console.error("Could not find mark to squash to: ",e),this;if(0===n.length)return this;let r=(0,i.L4)();return(0,i.Fl)(r,n.reverse()),this.stacks.update(({redos:e})=>({undos:t.push({type:"diff",diff:r}),redos:e})),this}_mark(e){(0,r.hL)(()=>{this.flushPendingDiff(),this.stacks.update(({undos:t,redos:n})=>({undos:t.push({type:"stop",id:e}),redos:n}))})}clear(){this.stacks.set({undos:f,redos:f}),this.pendingDiff.clear()}getMarkIdMatching(e){let t=this.stacks.get().undos;for(;t.head;){if("stop"===t.head.type&&t.head.id.includes(e))return t.head.id;t=t.tail}return null}debug(){let{undos:e,redos:t}=this.stacks.get();return{undos:m(e),redos:m(t),pendingDiff:this.pendingDiff.debug(),state:this.state}}}let c={record:s,"record-preserveRedoStack":a,ignore:l};class u{diff=(0,i.L4)();isEmptyAtom=(0,r.eU)("PendingDiff.isEmpty",!0);clear(){let e=this.diff;return this.diff=(0,i.L4)(),this.isEmptyAtom.set(!0),e}restore(e){this.diff=e,this.isEmptyAtom.set((0,i.RF)(e))}isEmpty(){return this.isEmptyAtom.get()}apply(e){(0,i.Fl)(this.diff,[e]),h(e.added)||h(e.removed)?this.isEmptyAtom.set((0,i.RF)(this.diff)):this.isEmptyAtom.__unsafe__getWithoutCapture()&&this.isEmptyAtom.set(!h(e.updated))}debug(){return{diff:this.diff,isEmpty:this.isEmpty()}}}function h(e){for(let t in e)return!0;return!1}class p{length=0;head=null;tail=this;push(e){return new g(e,this)}}let f=new p;class g{constructor(e,t){this.head=e,this.tail=t,this.length=t.length+1}head;tail;length;push(e){return new g(e,this)}}function m(e){if(!e.length)return r.Ml;let t=[];for(;e.length;)t.push(e.head),e=e.tail;return t}},11421:(e,t,n)=>{"use strict";n.d(t,{YO:()=>a,bG:()=>l,of:()=>s});var r=n(83102),i=n(24167),o=n(41463);let s={},a=d("pointerCaptureTrackingObject",{defaults:{all:new Map},shouldStoreForSession:!1}),l={logPreventDefaults:d("logPreventDefaults",{defaults:{all:!1}}),logPointerCaptures:d("logPointerCaptures",{defaults:{all:!1}}),logElementRemoves:d("logElementRemoves",{defaults:{all:!1}}),debugSvg:d("debugSvg",{defaults:{all:!1}}),showFps:d("showFps",{defaults:{all:!1}}),measurePerformance:d("measurePerformance",{defaults:{all:!1}}),throwToBlob:d("throwToBlob",{defaults:{all:!1}}),reconnectOnPing:d("reconnectOnPing",{defaults:{all:!1}}),debugCursors:d("debugCursors",{defaults:{all:!1}}),forceSrgb:d("forceSrgbColors",{defaults:{all:!1}}),debugGeometry:d("debugGeometry",{defaults:{all:!1}}),hideShapes:d("hideShapes",{defaults:{all:!1}}),editOnType:d("editOnType",{defaults:{all:!1}}),a11y:d("a11y",{defaults:{all:!1}}),debugElbowArrows:d("debugElbowArrows",{defaults:{all:!1}})};if("u">typeof Element){let e=Element.prototype.removeChild;(0,r.wv)("element removal logging",()=>{l.logElementRemoves.get()?Element.prototype.removeChild=function(t){return console.warn("[tldraw] removing child:",t),e.call(this,t)}:Element.prototype.removeChild=e})}function d(e,{defaults:t,shouldStoreForSession:n=!0}){var s;let a,l,u;return a=function(e){switch(c(()=>o.env.TLDRAW_ENV)??c(()=>o.env.VERCEL_PUBLIC_TLDRAW_ENV)??c(()=>o.env.NEXT_PUBLIC_TLDRAW_ENV)??"production"){case"production":return e.defaults.production??e.defaults.all;case"preview":case"staging":return e.defaults.staging??e.defaults.all;default:return e.defaults.development??e.defaults.all}}(s={name:e,defaults:t,shouldStoreForSession:n}),l=s.shouldStoreForSession?function(e){try{return JSON.parse((0,i._9)(`tldraw_debug:${e}`)??"null")}catch{return null}}(s.name):null,u=(0,r.eU)(`debug:${s.name}`,l??a),"u">typeof window&&(s.shouldStoreForSession&&(0,r.wv)(`debug:${s.name}`,()=>{let e=u.get();e===a?(0,i.ZJ)(`tldraw_debug:${s.name}`):(0,i.dQ)(`tldraw_debug:${s.name}`,JSON.stringify(e))}),Object.defineProperty(window,`tldraw${s.name.replace(/^[a-z]/,e=>e.toUpperCase())}`,{get:()=>u.get(),set(e){u.set(e)},configurable:!0})),Object.assign(u,s,{reset:()=>u.set(a)})}function c(e){try{return e()}catch{return null}}},12318:(e,t,n)=>{"use strict";n.d(t,{v:()=>f});var r=n(83102),i=n(54530),o=n(81467),s=n(24167),a=n(15727),l=n(46195),d=n(50139),c=n(38335),u=Object.defineProperty,h=Object.getOwnPropertyDescriptor,p=(e,t,n,r)=>{for(var i,o=r>1?void 0:r?h(t,n):t,s=e.length-1;s>=0;s--)(i=e[s])&&(o=(r?i(t,n,o):i(o))||o);return r&&o&&u(t,n,o),o};class f extends c.r{constructor(e){super(e),this.addEditorEvent("frame",this._onFrame)}_onFrame(e){this.updatePointerVelocity(e)}_originPagePoint=(0,r.eU)("originPagePoint",new l.l);getOriginPagePoint(){return this._originPagePoint.get()}get originPagePoint(){return this.getOriginPagePoint()}_originScreenPoint=(0,r.eU)("originScreenPoint",new l.l);getOriginScreenPoint(){return this._originScreenPoint.get()}get originScreenPoint(){return this.getOriginScreenPoint()}_previousPagePoint=(0,r.eU)("previousPagePoint",new l.l);getPreviousPagePoint(){return this._previousPagePoint.get()}get previousPagePoint(){return this.getPreviousPagePoint()}_previousScreenPoint=(0,r.eU)("previousScreenPoint",new l.l);getPreviousScreenPoint(){return this._previousScreenPoint.get()}get previousScreenPoint(){return this.getPreviousScreenPoint()}_currentPagePoint=(0,r.eU)("currentPagePoint",new l.l);getCurrentPagePoint(){return this._currentPagePoint.get()}get currentPagePoint(){return this.getCurrentPagePoint()}_currentScreenPoint=(0,r.eU)("currentScreenPoint",new l.l);getCurrentScreenPoint(){return this._currentScreenPoint.get()}get currentScreenPoint(){return this.getCurrentScreenPoint()}_pointerVelocity=(0,r.eU)("pointerVelocity",new l.l);getPointerVelocity(){return this._pointerVelocity.get()}get pointerVelocity(){return this.getPointerVelocity()}setPointerVelocity(e){this._pointerVelocity.set(e)}keys=new i.uw("keys");buttons=new i.uw("buttons");_isPen=(0,r.eU)("isPen",!1);getIsPen(){return this._isPen.get()}get isPen(){return this.getIsPen()}set isPen(e){this.setIsPen(e)}setIsPen(e){this._isPen.set(e)}_shiftKey=(0,r.eU)("shiftKey",!1);getShiftKey(){return this._shiftKey.get()}get shiftKey(){return this.getShiftKey()}set shiftKey(e){this.setShiftKey(e)}setShiftKey(e){this._shiftKey.set(e)}_metaKey=(0,r.eU)("metaKey",!1);getMetaKey(){return this._metaKey.get()}get metaKey(){return this.getMetaKey()}set metaKey(e){this.setMetaKey(e)}setMetaKey(e){this._metaKey.set(e)}_ctrlKey=(0,r.eU)("ctrlKey",!1);getCtrlKey(){return this._ctrlKey.get()}get ctrlKey(){return this.getCtrlKey()}set ctrlKey(e){this.setCtrlKey(e)}setCtrlKey(e){this._ctrlKey.set(e)}_altKey=(0,r.eU)("altKey",!1);getAltKey(){return this._altKey.get()}get altKey(){return this.getAltKey()}set altKey(e){this.setAltKey(e)}setAltKey(e){this._altKey.set(e)}getAccelKey(){return(0,d.g)({metaKey:this.getMetaKey(),ctrlKey:this.getCtrlKey()})}get accelKey(){return this.getAccelKey()}_isDragging=(0,r.eU)("isDragging",!1);getIsDragging(){return this._isDragging.get()}get isDragging(){return this.getIsDragging()}set isDragging(e){this.setIsDragging(e)}setIsDragging(e){this._isDragging.set(e)}_isPointing=(0,r.eU)("isPointing",!1);getIsPointing(){return this._isPointing.get()}get isPointing(){return this.getIsPointing()}set isPointing(e){this.setIsPointing(e)}setIsPointing(e){this._isPointing.set(e)}_isRightPointing=(0,r.eU)("isRightPointing",!1);getIsRightPointing(){return this._isRightPointing.get()}setIsRightPointing(e){this._isRightPointing.set(e)}_isPinching=(0,r.eU)("isPinching",!1);getIsPinching(){return this._isPinching.get()}get isPinching(){return this.getIsPinching()}set isPinching(e){this.setIsPinching(e)}setIsPinching(e){this._isPinching.set(e)}_isEditing=(0,r.eU)("isEditing",!1);getIsEditing(){return this._isEditing.get()}get isEditing(){return this.getIsEditing()}set isEditing(e){this.setIsEditing(e)}setIsEditing(e){this._isEditing.set(e)}_isPanning=(0,r.eU)("isPanning",!1);getIsPanning(){return this._isPanning.get()}get isPanning(){return this.getIsPanning()}set isPanning(e){this.setIsPanning(e)}setIsPanning(e){this._isPanning.set(e)}_isSpacebarPanning=(0,r.eU)("isSpacebarPanning",!1);getIsSpacebarPanning(){return this._isSpacebarPanning.get()}get isSpacebarPanning(){return this.getIsSpacebarPanning()}set isSpacebarPanning(e){this.setIsSpacebarPanning(e)}setIsSpacebarPanning(e){this._isSpacebarPanning.set(e)}_getHasCollaborators(){return this.editor.getCollaborators().length>0}_velocityPrevPoint=new l.l;updatePointerVelocity(e){let t=this.getCurrentScreenPoint(),n=this.getPointerVelocity();if(0===e)return;let r=l.l.Sub(t,this._velocityPrevPoint);this._velocityPrevPoint=t.clone();let i=r.len(),o=i?r.div(i):new l.l(0,0),s=1-Math.pow(.5,e/16),a=n.clone().lrp(o.mul(i/e),s);.01>Math.abs(a.x)&&(a.x=0),.01>Math.abs(a.y)&&(a.y=0),n.equals(a)||this._pointerVelocity.set(a)}updateFromEvent(e){let t=this._currentScreenPoint.__unsafe__getWithoutCapture(),n=this._currentPagePoint.__unsafe__getWithoutCapture(),i=this._isPinching.__unsafe__getWithoutCapture(),{screenBounds:s}=this.editor.store.unsafeGetWithoutCapture(o.O9),{x:d,y:c,z:u}=(0,r.Pm)(()=>this.editor.getCamera()),h=e.point.x-s.x,p=e.point.y-s.y,f=e.point.z??.5;this._previousScreenPoint.set(t),this._previousPagePoint.set(n),this._currentScreenPoint.set(new l.l(h,p));let g=h/u-d,m=p/u-c;isFinite(g)&&isFinite(m)&&this._currentPagePoint.set(new l.l(g,m,f)),this._isPen.set("pointer"===e.type&&e.isPen),("pointer_down"===e.name||i)&&(this._pointerVelocity.set(new l.l),this._originScreenPoint.set(this._currentScreenPoint.__unsafe__getWithoutCapture()),this._originPagePoint.set(this._currentPagePoint.__unsafe__getWithoutCapture())),this._getHasCollaborators()&&this.editor.run(()=>{let t=this._currentPagePoint.__unsafe__getWithoutCapture();this.editor.store.put([{id:o.G1,typeName:"pointer",x:t.x,y:t.y,lastActivityTimestamp:"pointer"===e.type&&e.pointerId===a.zm.CAMERA_MOVE?this.editor.store.unsafeGetWithoutCapture(o.G1)?.lastActivityTimestamp??Date.now():Date.now(),meta:{}}])},{history:"ignore"})}toJson(){return{originPagePoint:this._originPagePoint.get().toJson(),originScreenPoint:this._originScreenPoint.get().toJson(),previousPagePoint:this._previousPagePoint.get().toJson(),previousScreenPoint:this._previousScreenPoint.get().toJson(),currentPagePoint:this._currentPagePoint.get().toJson(),currentScreenPoint:this._currentScreenPoint.get().toJson(),pointerVelocity:this._pointerVelocity.get().toJson(),shiftKey:this._shiftKey.get(),metaKey:this._metaKey.get(),ctrlKey:this._ctrlKey.get(),altKey:this._altKey.get(),isPen:this._isPen.get(),isDragging:this._isDragging.get(),isPointing:this._isPointing.get(),isPinching:this._isPinching.get(),isEditing:this._isEditing.get(),isPanning:this._isPanning.get(),isSpacebarPanning:this._isSpacebarPanning.get(),keys:Array.from(this.keys.keys()),buttons:Array.from(this.buttons.keys())}}}p([s.oI],f.prototype,"_onFrame",1),p([r.EW],f.prototype,"_getHasCollaborators",1)},12894:(e,t,n)=>{"use strict";n.d(t,{K:()=>f,w:()=>p});for(var r={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},i={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},o="u">typeof navigator&&/Mac/.test(navigator.platform),s="u">typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),a=0;a<10;a++)r[48+a]=r[96+a]=String(a);for(var a=1;a<=24;a++)r[a+111]="F"+a;for(var a=65;a<=90;a++)r[a]=String.fromCharCode(a+32),i[a]=String.fromCharCode(a);for(var l in r)i.hasOwnProperty(l)||(i[l]=r[l]);var d=n(76865);let c="u">typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),u="u">typeof navigator&&/Win/.test(navigator.platform);function h(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function p(e){return new d.k_({props:{handleKeyDown:f(e)}})}function f(e){let t=function(e){let t=Object.create(null);for(let n in e)t[function(e){let t,n,r,i,o=e.split(/-(?!$)/),s=o[o.length-1];"Space"==s&&(s=" ");for(let e=0;e<o.length-1;e++){let s=o[e];if(/^(cmd|meta|m)$/i.test(s))i=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))r=!0;else if(/^mod$/i.test(s))c?i=!0:n=!0;else throw Error("Unrecognized modifier name: "+s)}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),i&&(s="Meta-"+s),r&&(s="Shift-"+s),s}(n)]=e[n];return t}(e);return function(e,n){var a;let l=("Esc"==(a=!(o&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||s&&n.shiftKey&&n.key&&1==n.key.length||"Unidentified"==n.key)&&n.key||(n.shiftKey?i:r)[n.keyCode]||n.key||"Unidentified")&&(a="Escape"),"Del"==a&&(a="Delete"),"Left"==a&&(a="ArrowLeft"),"Up"==a&&(a="ArrowUp"),"Right"==a&&(a="ArrowRight"),"Down"==a&&(a="ArrowDown"),a),d,c=t[h(l,n)];if(c&&c(e.state,e.dispatch,e))return!0;if(1==l.length&&" "!=l){if(n.shiftKey){let r=t[h(l,n,!1)];if(r&&r(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(u&&n.ctrlKey&&n.altKey)&&(d=r[n.keyCode])&&d!=l){let r=t[h(d,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}},13004:(e,t,n)=>{"use strict";n.d(t,{f:()=>c});var r=n(83102),i=n(81467),o=n(97156),s=n(16038),a=Object.defineProperty,l=Object.getOwnPropertyDescriptor,d=(e,t,n,r)=>{for(var i,o=r>1?void 0:r?l(t,n):t,s=e.length-1;s>=0;s--)(i=e[s])&&(o=(r?i(t,n,o):i(o))||o);return r&&o&&a(t,n,o),o};class c{constructor(e,t){if(this.user=e,this.colorScheme=t,"u"<typeof window||!(0,s.CM)().matchMedia)return;const n=(0,s.CM)().matchMedia("(prefers-color-scheme: dark)");n?.matches&&this.systemColorScheme.set("dark");const r=e=>{e.matches?this.systemColorScheme.set("dark"):this.systemColorScheme.set("light")};n?.addEventListener("change",r),this.disposables.add(()=>n?.removeEventListener("change",r))}user;colorScheme;systemColorScheme=(0,r.eU)("systemColorScheme","light");disposables=new Set;dispose(){this.disposables.forEach(e=>e())}updateUserPreferences(e){this.user.setUserPreferences({...this.user.userPreferences.get(),...e})}getUserPreferences(){return{id:this.getExternalId(),name:this.getName(),locale:this.getLocale(),color:this.getColor(),animationSpeed:this.getAnimationSpeed(),areKeyboardShortcutsEnabled:this.getAreKeyboardShortcutsEnabled(),isSnapMode:this.getIsSnapMode(),colorScheme:this.user.userPreferences.get().colorScheme,isDarkMode:this.getIsDarkMode(),isWrapMode:this.getIsWrapMode(),isDynamicResizeMode:this.getIsDynamicResizeMode(),enhancedA11yMode:this.getEnhancedA11yMode(),inputMode:this.getInputMode(),isZoomDirectionInverted:this.getIsZoomDirectionInverted()}}getIsDarkMode(){switch(this.user.userPreferences.get().colorScheme??this.colorScheme){case"dark":return!0;case"light":default:return!1;case"system":return"dark"===this.systemColorScheme.get()}}getEdgeScrollSpeed(){return this.user.userPreferences.get().edgeScrollSpeed??o.Tj.edgeScrollSpeed}getAnimationSpeed(){return this.user.userPreferences.get().animationSpeed??o.Tj.animationSpeed}getAreKeyboardShortcutsEnabled(){return this.user.userPreferences.get().areKeyboardShortcutsEnabled??o.Tj.areKeyboardShortcutsEnabled}getExternalId(){return this.user.userPreferences.get().id}getId(){return this.getExternalId()}getRecordId(){return(0,i.dB)(this.getExternalId())}getName(){return this.user.userPreferences.get().name?.trim()??o.Tj.name}getLocale(){return this.user.userPreferences.get().locale??o.Tj.locale}getColor(){return this.user.userPreferences.get().color??o.Tj.color}getIsSnapMode(){return this.user.userPreferences.get().isSnapMode??o.Tj.isSnapMode}getIsWrapMode(){return this.user.userPreferences.get().isWrapMode??o.Tj.isWrapMode}getIsDynamicResizeMode(){return this.user.userPreferences.get().isDynamicSizeMode??o.Tj.isDynamicSizeMode}getIsPasteAtCursorMode(){return this.user.userPreferences.get().isPasteAtCursorMode??o.Tj.isPasteAtCursorMode}getEnhancedA11yMode(){return this.user.userPreferences.get().enhancedA11yMode??o.Tj.enhancedA11yMode}getInputMode(){return this.user.userPreferences.get().inputMode??o.Tj.inputMode}getIsZoomDirectionInverted(){return this.user.userPreferences.get().isZoomDirectionInverted??o.Tj.isZoomDirectionInverted}}d([r.EW],c.prototype,"getUserPreferences",1),d([r.EW],c.prototype,"getIsDarkMode",1),d([r.EW],c.prototype,"getEdgeScrollSpeed",1),d([r.EW],c.prototype,"getAnimationSpeed",1),d([r.EW],c.prototype,"getAreKeyboardShortcutsEnabled",1),d([r.EW],c.prototype,"getExternalId",1),d([r.EW],c.prototype,"getId",1),d([r.EW],c.prototype,"getRecordId",1),d([r.EW],c.prototype,"getName",1),d([r.EW],c.prototype,"getLocale",1),d([r.EW],c.prototype,"getColor",1),d([r.EW],c.prototype,"getIsSnapMode",1),d([r.EW],c.prototype,"getIsWrapMode",1),d([r.EW],c.prototype,"getIsDynamicResizeMode",1),d([r.EW],c.prototype,"getIsPasteAtCursorMode",1),d([r.EW],c.prototype,"getEnhancedA11yMode",1),d([r.EW],c.prototype,"getInputMode",1),d([r.EW],c.prototype,"getIsZoomDirectionInverted",1)},13248:(e,t,n)=>{"use strict";n.d(t,{sanitizeSvg:()=>k});let r=new Set(["svg","a","altglyph","altglyphdef","altglyphitem","animate","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","feblend","fecolormatrix","fecomponenttransfer","fecomposite","feconvolvematrix","fediffuselighting","fedisplacementmap","fedistantlight","fedropshadow","feflood","fefunca","fefuncb","fefuncg","fefuncr","fegaussianblur","feimage","femerge","femergenode","femorphology","feoffset","fepointlight","fespecularlighting","fespotlight","fetile","feturbulence","filter","font","foreignobject","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","set","stop","style","switch","symbol","text","textpath","title","tref","tspan","use","view","vkern"]),i=new Set(["a","b","blockquote","body","br","code","del","div","em","h1","h2","h3","h4","h5","h6","i","li","mark","ol","p","pre","span","strong","s","sub","sup","table","tbody","td","th","thead","tr","u","ul"]),o=new Set(["script","iframe","object","embed","form","input","textarea","select","button","link","meta","base","img","video","audio","source","picture","svg"]),s=new Set(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clip-path","clip-rule","clippathunits","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","diffuseconstant","direction","display","divisor","dominant-baseline","dur","dx","dy","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","from","fx","fy","g1","g2","glyph-name","glyphref","gradienttransform","gradientunits","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","kernelmatrix","kernelunitlength","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","mask","mask-type","maskcontentunits","maskunits","max","media","method","min","mode","name","numoctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","radius","refx","refy","repeatcount","repeatdur","requiredfeatures","restart","result","role","rotate","rx","ry","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","text-anchor","text-decoration","text-rendering","textlength","to","transform","transform-origin","type","u1","u2","unicode","values","version","vert-adv-y","vert-origin-x","vert-origin-y","viewbox","visibility","width","word-spacing","wrap","writing-mode","x","x1","x2","xchannelselector","xlink:href","xml:id","xml:space","xlink:title","xmlns","xmlns:xlink","y","y1","y2","z","zoomandpan"]),a=new Set(["class","dir","href","id","lang","role","style","tabindex","title"]),l=/^data-/,d=/^aria-/,c=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g,u=/^(?:https?:|mailto:)/i,h=/^data:/i,p=/^data:image\/(?:png|jpeg|jpg|gif|webp|avif|bmp|tiff|x-icon|vnd\.microsoft\.icon)[;,]/i,f=/^data:image\/svg\+xml[;,]/i,g=/^#/,m=/^data:(?:image\/(?:png|jpeg|jpg|gif|webp|avif)|font\/(?:woff2?|opentype|truetype|sfnt)|application\/(?:x-font-woff|font-woff2?|x-font-ttf|x-font-opentype|font-sfnt))[;,]/i;function y(e){let t=e.replace(/\\([0-9a-fA-F]{1,6})\s?|\\([^\n])/g,(e,t,n)=>{if(t){let e=parseInt(t,16);return e>1114111||0===e?"�":String.fromCodePoint(e)}return n});return(t=(t=(t=(t=t.replace(/@import\s+(?:url\s*\([^)]*\)|"[^"]*"|'[^']*')[^;]*;?|@import\b[^;]*;?/gi,"")).replace(/expression\s*\([^)]*\)/gi,"")).replace(/-moz-binding\s*:[^;]*/gi,"")).replace(/behavior\s*:[^;]*/gi,"")).replace(/url\s*\(\s*(['"]?)(.*?)\1\s*\)/gis,(e,t,n)=>{let r=n.replace(c,"");return m.test(r)||g.test(r)?e:""})}let b=new Set(["animate","set","animatecolor","animatetransform"]),x=/^(?:href|xlink:href|on)/i,w=/^on/i,v=new Set(["clip-path","cursor","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"]);function S(e,t){for(let n=e.attributes.length-1;n>=0;n--){let r=e.attributes[n],i=r.name.toLowerCase(),o=i.replace(c,"");if(w.test(o)){e.removeAttribute(r.name);continue}if(!(l.test(i)||d.test(i))){if(!s.has(i)){e.removeAttribute(r.name);continue}if("href"===i||"xlink:href"===i){let n=function(e,t,n){let r=t.replace(c,""),i=e.tagName.toLowerCase();if("image"===i||"feimage"===i){if(p.test(r))return t;if(f.test(r)){let e;if(n>=10)return console.warn("Embedded SVG data URI recursion depth limit (10) reached"),null;try{let t=function(e){let t=e.search(/;base64,/i);if(t>=0){let n=e.slice(t+8),r=Uint8Array.from(atob(n),e=>e.charCodeAt(0));return new TextDecoder().decode(r)}let n=e.indexOf(",");return n<0?null:decodeURIComponent(e.slice(n+1))}(r);if(null===t)return null;e=t}catch{return null}let t=C(e,n+1);return t?"data:image/svg+xml;base64,"+btoa(Array.from(new TextEncoder().encode(t),e=>String.fromCharCode(e)).join("")):null}return null}return"use"===i?g.test(r)?t:null:"a"===i?u.test(r)?t:null:h.test(r)||g.test(r)?t:null}(e,r.value,t);null===n?e.removeAttribute(r.name):n!==r.value&&(r.value=n);continue}if("style"===i){r.value=y(r.value);continue}v.has(i)&&/url\s*\(/i.test(r.value)&&(r.value=y(r.value))}}}function C(e,t){let n=new DOMParser().parseFromString(e,"image/svg+xml");if(n.querySelector("parsererror"))return"";let s=n.documentElement;return"svg"!==s.tagName.toLowerCase()||(S(s,t),!function e(t,n,s){for(let h=t.children.length-1;h>=0;h--){let p=t.children[h],f=p.tagName.toLowerCase();"svg"===n?"foreignobject"===f?(S(p,s),e(p,"html",s)):"style"===f?(S(p,s),p.textContent&&(p.textContent=y(p.textContent))):b.has(f)&&function(e){let t=e.getAttribute("attributeName");return!!t&&x.test(t.replace(c,""))}(p)?p.remove():r.has(f)?(S(p,s),e(p,"svg",s)):p.remove():o.has(f)?p.remove():i.has(f)?(!function(e){let t=e.tagName.toLowerCase();for(let n=e.attributes.length-1;n>=0;n--){let r=e.attributes[n],i=r.name.toLowerCase(),o=i.replace(c,"");if(w.test(o)){e.removeAttribute(r.name);continue}if(!(l.test(i)||d.test(i))){if(!a.has(i)){e.removeAttribute(r.name);continue}if("href"===i){if("a"!==t){e.removeAttribute(r.name);continue}let n=r.value.replace(c,"");u.test(n)||e.removeAttribute(r.name);continue}"style"===i&&(r.value=y(r.value))}}}(p),e(p,"html",s)):p.remove()}}(s,"svg",t),0===s.children.length)?"":new XMLSerializer().serializeToString(s)}function k(e){return C(e,0)}},13656:(e,t,n)=>{"use strict";n.d(t,{p:()=>i,r:()=>r});let r="5.3.2",i={major:"2026-05-06T16:28:18.473Z",minor:"2026-08-05T11:39:54.978Z",patch:"2026-08-18T09:59:40.172Z"}},13982:(e,t,n)=>{"use strict";n.d(t,{$:()=>a,Y:()=>o});var r=n(83102),i=n(16038);let o={isSafari:!1,isIos:!1,isChromeForIos:!1,isFirefox:!1,isAndroid:!1,isWebview:!1,isDarwin:!1,hasCanvasSupport:!1,isTouchDevice:!1},s=!1;"u">typeof window&&("navigator"in window&&(o.isSafari=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),o.isIos=!!navigator.userAgent.match(/iPad/i)||!!navigator.userAgent.match(/iPhone/i),o.isChromeForIos=/crios.*safari/i.test(navigator.userAgent),o.isFirefox=/firefox/i.test(navigator.userAgent),o.isAndroid=/android/i.test(navigator.userAgent),o.isDarwin=(0,i.CM)().navigator.userAgent.toLowerCase().indexOf("mac")>-1),o.hasCanvasSupport="Promise"in window&&"HTMLCanvasElement"in window,s=o.isFirefox&&!o.isAndroid&&!o.isIos,o.isTouchDevice="navigator"in window&&window.navigator.maxTouchPoints>0||"function"==typeof window.matchMedia&&window.matchMedia("(any-pointer: coarse)").matches);let a=(0,r.eU)("tlenvReactive",{isCoarsePointer:!1,supportsP3ColorSpace:!1});if("u">typeof window&&"u">typeof CSS&&CSS.supports("color","color(display-p3 1 1 1)")){let e=window.matchMedia("(color-gamut: p3)"),t=()=>{let t=e.matches;t!==a.__unsafe__getWithoutCapture().supportsP3ColorSpace&&a.update(e=>({...e,supportsP3ColorSpace:t}))};t(),e.addEventListener("change",t)}if("u">typeof window&&!s){let e=(0,i.CM)().matchMedia&&(0,i.CM)().matchMedia("(any-pointer: coarse)");if(e){let t=()=>{let t=e.matches;t!==a.__unsafe__getWithoutCapture().isCoarsePointer&&a.update(e=>({...e,isCoarsePointer:t}))};t(),e.addEventListener("change",t)}(0,i.CM)().addEventListener("pointerdown",e=>{let t="mouse"!==e.pointerType;t!==a.__unsafe__getWithoutCapture().isCoarsePointer&&a.update(e=>({...e,isCoarsePointer:t}))},{capture:!0})}},15727:(e,t,n)=>{"use strict";n.d(t,{BV:()=>a,EI:()=>d,R_:()=>c,Tf:()=>u,bH:()=>l,mp:()=>o,zd:()=>i,zm:()=>s});var r=n(58347);let i={isLocked:!1,wheelBehavior:"pan",panSpeed:1,zoomSpeed:1,zoomSteps:[.05,.1,.25,.5,1,2,4,8]},o={duration:0,easing:r.Z.easeInOutCubic},s={CAMERA_MOVE:-10},a=["top","right","bottom","left"],l=0,d=2,c=1,u=5},16038:(e,t,n)=>{"use strict";n.d(t,{$h:()=>a,CM:()=>u,MM:()=>l,YY:()=>o,gh:()=>h,hP:()=>s,jL:()=>c,oO:()=>d,wo:()=>i});var r=n(11421);function i(e){"cancelable"in e&&!e.cancelable||(e.preventDefault(),r.bG.logPreventDefaults.get()&&console.warn("preventDefault called on event:",e))}function o(e,t){if(e.setPointerCapture(t.pointerId),r.bG.logPointerCaptures.get()){let n=r.YO.get();n.set(e,(n.get(e)??0)+1),console.warn("setPointerCapture called on element:",e,t)}}function s(e,t){if(e.hasPointerCapture(t.pointerId)&&(e.releasePointerCapture(t.pointerId),r.bG.logPointerCaptures.get())){let n=r.YO.get();1===n.get(e)?n.delete(e):n.has(e)?n.set(e,n.get(e)-1):console.warn("Release without capture"),console.warn("releasePointerCapture called on element:",e,t)}}function a(e,t,n){e&&e.style.setProperty(t,String(n))}function l(e,t){if(t.isConnected&&e.isConnected&&"function"==typeof e.moveBefore&&t.ownerDocument===e.ownerDocument)try{e.moveBefore(t,null);return}catch{}e.appendChild(t)}function d(e,t=!0){if(!e)return!1;let n=e.tagName.toLowerCase();return e.isContentEditable||"input"===n||"textarea"===n||t&&"select"===n||t&&"button"===n||e.classList.contains("tlui-slider__thumb")}function c(){return"u">typeof document?document:globalThis.document}function u(){return"u">typeof window?window:globalThis}function h(e=!0,t){return d((t??c()).activeElement,e)}},16398:(e,t,n)=>{"use strict";n.d(t,{O:()=>r});let r={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",tick:"onTick"}},17858:(e,t,n)=>{"use strict";n.d(t,{m:()=>c});var r=n(83102),i=n(81467),o=n(58929),s=n(66122),a=Object.defineProperty,l=Object.getOwnPropertyDescriptor,d=(e,t,n,r)=>{for(var i,o=r>1?void 0:r?l(t,n):t,s=e.length-1;s>=0;s--)(i=e[s])&&(o=(r?i(t,n,o):i(o))||o);return r&&o&&a(t,n,o),o};class c{constructor(e){this.editor=e,this.shapeBounds=new o.N(this),this.handles=new s.O(this)}editor;shapeBounds;handles;_snapIndicators=(0,r.eU)("snapLines",void 0);getIndicators(){return this._snapIndicators.get()??r.Ml}clearIndicators(){this.getIndicators().length&&this._snapIndicators.set(void 0)}setIndicators(e){this._snapIndicators.set(e)}getSnapThreshold(){return this.editor.options.snapThreshold/this.editor.getZoomLevel()}getSnappableShapes(){let{editor:e}=this,t=e.getViewportPageBounds(),n=e.getSelectedShapeIds(),r=new Set,o=s=>{if((0,i.vc)(s)){let t=e.getShape(s);t&&e.isShapeFrameLike(t)&&r.add(s)}for(let i of e.getSortedChildIdsForParent(s)){if(n.includes(i))continue;let s=e.getShape(i);if(!s||!e.getShapeUtil(s).canSnap(s))continue;let a=e.getShapePageBounds(i);if(a&&t.includes(a)){if(e.isShapeOfType(s,"group")){o(i);continue}r.add(i)}}};return o(this.getCurrentCommonAncestor()??e.getCurrentPageId()),r}getCurrentCommonAncestor(){return this.editor.findCommonAncestor(this.editor.getSelectedShapes())}}d([r.EW],c.prototype,"getSnapThreshold",1),d([r.EW],c.prototype,"getSnappableShapes",1),d([r.EW],c.prototype,"getCurrentCommonAncestor",1)},18314:(e,t,n)=>{"use strict";n.d(t,{_:()=>o}),n(27394);var r=n(24167),i=n(12115);function o(e){let t=(0,i.useRef)(void 0);return(0,i.useLayoutEffect)(()=>{t.current=e}),(0,i.useDebugValue)(e),(0,i.useCallback)((...e)=>{let n=t.current;return(0,r.vA)(n,"fn does not exist"),n(...e)},[])}},19065:(e,t,n)=>{"use strict";n.d(t,{XN:()=>u,q1:()=>l});var r=n(24167),i=n(13982),o=n(65009),s=n(11421),a=n(16038);async function l(e,t){let{type:n,width:i,height:l,quality:u=1,pixelRatio:h=2,trimPadding:p=0,scale:f=1}=t;if(i<=0||l<=0)return null;let[g,m]=(0,o.A)(i*h,l*h);g=Math.floor(g),m=Math.floor(m);let y=g/i,b=await d(e,g,m);if(!b)return null;let x=p>0?function(e,t){let n=e.width,r=e.height,i=c(e,t);if(!i)return{canvas:e,width:n,height:r};let{cropLeft:o,cropTop:s,cropRight:l,cropBottom:d}=i,u=l-o,h=d-s,p=(0,a.jL)().createElement("canvas");return p.width=u,p.height=h,p.getContext("2d").drawImage(e,o,s,u,h,0,0,u,h),{canvas:p,width:u,height:h}}(b,p*f*y):{canvas:b,width:g,height:m},w=await new Promise(e=>x.canvas.toBlob(t=>{(!t||s.bG.throwToBlob.get())&&e(null),e(t)},"image/"+n,u));return w?{blob:"png"===n?r.ZA.setPhysChunk(new DataView(await w.arrayBuffer()),y,{type:"image/"+n}):w,width:x.width/y,height:x.height/y}:null}async function d(e,t,n){let o=await r.Sm.blobToDataUrl(new Blob([e],{type:"image/svg+xml"}));return new Promise(e=>{let s=(0,r._V)();s.crossOrigin="anonymous",s.onload=async()=>{i.Y.isSafari&&await (0,r.yy)(250);let o=(0,a.jL)().createElement("canvas"),l=o.getContext("2d");o.width=t,o.height=n,l.imageSmoothingEnabled=!0,l.imageSmoothingQuality="high",l.drawImage(s,0,0,t,n),e(o)},s.onerror=()=>{e(null)},s.src=o})}function c(e,t){let n=e.width,r=e.height,i=e.getContext("2d"),o=Math.ceil(t);if(o<=0||2*o>=n||2*o>=r)return null;let s=i.getImageData(0,0,n,r).data,a=s[0],l=s[1],d=s[2],c=s[3],u=0===c;function h(e){if(u)return s[e+3]>0;{if(s[e+3]!==c)return!0;let t=s[e],n=s[e+1],r=s[e+2];return t!==a||n!==l||r!==d}}let p=n-o,f=r-o,g=o;for(let e=0;e<o;e++){let t=!1;for(let r=0;r<n;r++)if(h((e*n+r)*4)){t=!0;break}if(t){g=e;break}}let m=f;for(let e=r-1;e>=f;e--){let t=!1;for(let r=0;r<n;r++)if(h((e*n+r)*4)){t=!0;break}if(t){m=e+1;break}}let y=o;for(let e=0;e<o;e++){let t=!1;for(let r=g;r<m;r++)if(h((r*n+e)*4)){t=!0;break}if(t){y=e;break}}let b=p;for(let e=n-1;e>=p;e--){let t=!1;for(let r=g;r<m;r++)if(h((r*n+e)*4)){t=!0;break}if(t){b=e+1;break}}return 0===y&&0===g&&b===n&&m===r?null:{cropLeft:y,cropTop:g,cropRight:b,cropBottom:m}}async function u(e,t){let{width:n,height:r,trimPadding:i,scale:o}=t;if(i<=0)return null;let s=Math.floor(n),a=Math.floor(r);if(s<=0||a<=0)return null;let l=await d(e,s,a);if(!l)return null;let u=c(l,i*o);if(!u)return null;let{cropLeft:h,cropTop:p,cropRight:f,cropBottom:g}=u,m=new DOMParser().parseFromString(e,"image/svg+xml").documentElement,y=m.getAttribute("viewBox");if(!y)return null;let[b,x,w,v]=y.split(/\s+/).map(Number),S=b+h/s*w,C=x+p/a*v,k=(f-h)/s*w,P=(g-p)/a*v,T=k*o,E=P*o;return m.setAttribute("viewBox",`${S} ${C} ${k} ${P}`),m.setAttribute("width",String(T)),m.setAttribute("height",String(E)),{svg:new XMLSerializer().serializeToString(m),width:T,height:E}}},19743:(e,t,n)=>{"use strict";n.d(t,{F:()=>o,S:()=>i});var r=n(81467);let i={id:"default",fontSize:16,lineHeight:1.35,strokeWidth:2,fonts:{draw:{fontFamily:r.xX.draw,faces:[{family:"tldraw_draw",src:{url:"tldraw_draw",format:"woff2"},weight:"normal"},{family:"tldraw_draw",src:{url:"tldraw_draw_bold",format:"woff2"},weight:"bold"},{family:"tldraw_draw",src:{url:"tldraw_draw_italic",format:"woff2"},weight:"normal",style:"italic"},{family:"tldraw_draw",src:{url:"tldraw_draw_italic_bold",format:"woff2"},weight:"bold",style:"italic"}]},sans:{fontFamily:r.xX.sans,faces:[{family:"tldraw_sans",src:{url:"tldraw_sans",format:"woff2"},weight:"normal",style:"normal"},{family:"tldraw_sans",src:{url:"tldraw_sans_bold",format:"woff2"},weight:"bold",style:"normal"},{family:"tldraw_sans",src:{url:"tldraw_sans_italic",format:"woff2"},weight:"normal",style:"italic"},{family:"tldraw_sans",src:{url:"tldraw_sans_italic_bold",format:"woff2"},weight:"bold",style:"italic"}]},serif:{fontFamily:r.xX.serif,faces:[{family:"tldraw_serif",src:{url:"tldraw_serif",format:"woff2"},weight:"normal",style:"normal"},{family:"tldraw_serif",src:{url:"tldraw_serif_bold",format:"woff2"},weight:"bold",style:"normal"},{family:"tldraw_serif",src:{url:"tldraw_serif_italic",format:"woff2"},weight:"normal",style:"italic"},{family:"tldraw_serif",src:{url:"tldraw_serif_italic_bold",format:"woff2"},weight:"bold",style:"italic"}]},mono:{fontFamily:r.xX.mono,faces:[{family:"tldraw_mono",src:{url:"tldraw_mono",format:"woff2"},weight:"normal",style:"normal"},{family:"tldraw_mono",src:{url:"tldraw_mono_bold",format:"woff2"},weight:"bold",style:"normal"},{family:"tldraw_mono",src:{url:"tldraw_mono_italic",format:"woff2"},weight:"normal",style:"italic"},{family:"tldraw_mono",src:{url:"tldraw_mono_italic_bold",format:"woff2"},weight:"bold",style:"italic"}]}},colors:{light:{text:"#000000",background:"#f9fafb",negativeSpace:"#f9fafb",solid:"#fcfffe",cursor:"black",noteBorder:"rgb(144, 144, 144)",snap:"hsl(0, 76%, 60%)",selectionStroke:"hsl(214, 84%, 56%)",selectionFill:"hsl(210, 100%, 56%, 24%)",brushFill:"hsl(0, 0%, 56%, 10.2%)",brushStroke:"hsl(0, 0%, 56%, 25.1%)",selectedContrast:"#ffffff",laser:"hsl(0, 100%, 50%)",black:{solid:"#1d1d1d",fill:"#1d1d1d",linedFill:"#363636",frameHeadingStroke:"#717171",frameHeadingFill:"#ffffff",frameStroke:"#717171",frameFill:"#ffffff",frameText:"#000000",noteFill:"#FCE19C",noteText:"#000000",semi:"#e8e8e8",pattern:"#494949",highlightSrgb:"#fddd00",highlightP3:"color(display-p3 0.972 0.8205 0.05)"},blue:{solid:"#4465e9",fill:"#4465e9",linedFill:"#6580ec",frameHeadingStroke:"#6681ec",frameHeadingFill:"#f9fafe",frameStroke:"#6681ec",frameFill:"#f9fafe",frameText:"#000000",noteFill:"#8AA3FF",noteText:"#000000",semi:"#dce1f8",pattern:"#6681ee",highlightSrgb:"#10acff",highlightP3:"color(display-p3 0.308 0.6632 0.9996)"},green:{solid:"#099268",fill:"#099268",linedFill:"#0bad7c",frameHeadingStroke:"#37a684",frameHeadingFill:"#f8fcfa",frameStroke:"#37a684",frameFill:"#f8fcfa",frameText:"#000000",noteFill:"#6FC896",noteText:"#000000",semi:"#d3e9e3",pattern:"#39a785",highlightSrgb:"#00ffc8",highlightP3:"color(display-p3 0.2536 0.984 0.7981)"},grey:{solid:"#9fa8b2",fill:"#9fa8b2",linedFill:"#bbc1c9",frameHeadingStroke:"#aaaaab",frameHeadingFill:"#fbfcfc",frameStroke:"#aaaaab",frameFill:"#fcfcfd",frameText:"#000000",noteFill:"#C0CAD3",noteText:"#000000",semi:"#eceef0",pattern:"#bcc3c9",highlightSrgb:"#cbe7f1",highlightP3:"color(display-p3 0.8163 0.9023 0.9416)"},"light-blue":{solid:"#4ba1f1",fill:"#4ba1f1",linedFill:"#7abaf5",frameHeadingStroke:"#6cb2f3",frameHeadingFill:"#f8fbfe",frameStroke:"#6cb2f3",frameFill:"#fafcff",frameText:"#000000",noteFill:"#9BC4FD",noteText:"#000000",semi:"#ddedfa",pattern:"#6fbbf8",highlightSrgb:"#00f4ff",highlightP3:"color(display-p3 0.1512 0.9414 0.9996)"},"light-green":{solid:"#4cb05e",fill:"#4cb05e",linedFill:"#7ec88c",frameHeadingStroke:"#6dbe7c",frameHeadingFill:"#f8fcf9",frameStroke:"#6dbe7c",frameFill:"#fafdfa",frameText:"#000000",noteFill:"#98D08A",noteText:"#000000",semi:"#dbf0e0",pattern:"#65cb78",highlightSrgb:"#65f641",highlightP3:"color(display-p3 0.563 0.9495 0.3857)"},"light-red":{solid:"#f87777",fill:"#f87777",linedFill:"#f99a9a",frameHeadingStroke:"#f89090",frameHeadingFill:"#fffafa",frameStroke:"#f89090",frameFill:"#fffbfb",frameText:"#000000",noteFill:"#F7A5A1",noteText:"#000000",semi:"#f4dadb",pattern:"#fe9e9e",highlightSrgb:"#ff7fa3",highlightP3:"color(display-p3 0.9988 0.5301 0.6397)"},"light-violet":{solid:"#e085f4",fill:"#e085f4",linedFill:"#e9abf7",frameHeadingStroke:"#e59bf5",frameHeadingFill:"#fefaff",frameStroke:"#e59bf5",frameFill:"#fefbff",frameText:"#000000",noteFill:"#DFB0F9",noteText:"#000000",semi:"#f5eafa",pattern:"#e9acf8",highlightSrgb:"#ff88ff",highlightP3:"color(display-p3 0.9676 0.5652 0.9999)"},orange:{solid:"#e16919",fill:"#e16919",linedFill:"#ea8643",frameHeadingStroke:"#e68544",frameHeadingFill:"#fef9f6",frameStroke:"#e68544",frameFill:"#fef9f6",frameText:"#000000",noteFill:"#FAA475",noteText:"#000000",semi:"#f8e2d4",pattern:"#f78438",highlightSrgb:"#ffa500",highlightP3:"color(display-p3 0.9988 0.6905 0.266)"},red:{solid:"#e03131",fill:"#e03131",linedFill:"#e75f5f",frameHeadingStroke:"#e55757",frameHeadingFill:"#fef7f7",frameStroke:"#e55757",frameFill:"#fef9f9",frameText:"#000000",noteFill:"#FC8282",noteText:"#000000",semi:"#f4dadb",pattern:"#e55959",highlightSrgb:"#ff636e",highlightP3:"color(display-p3 0.9992 0.4376 0.45)"},violet:{solid:"#ae3ec9",fill:"#ae3ec9",linedFill:"#be68d4",frameHeadingStroke:"#bc62d3",frameHeadingFill:"#fcf7fd",frameStroke:"#bc62d3",frameFill:"#fdf9fd",frameText:"#000000",noteFill:"#DB91FD",noteText:"#000000",semi:"#ecdcf2",pattern:"#bd63d3",highlightSrgb:"#c77cff",highlightP3:"color(display-p3 0.7469 0.5089 0.9995)"},yellow:{solid:"#f1ac4b",fill:"#f1ac4b",linedFill:"#f5c27a",frameHeadingStroke:"#f3bb6c",frameHeadingFill:"#fefcf8",frameStroke:"#f3bb6c",frameFill:"#fffdfa",frameText:"#000000",noteFill:"#FED49A",noteText:"#000000",semi:"#f9f0e6",pattern:"#fecb92",highlightSrgb:"#fddd00",highlightP3:"color(display-p3 0.972 0.8705 0.05)"},white:{solid:"#FFFFFF",fill:"#FFFFFF",linedFill:"#ffffff",semi:"#f5f5f5",pattern:"#f9f9f9",frameHeadingStroke:"#7d7d7d",frameHeadingFill:"#ffffff",frameStroke:"#7d7d7d",frameFill:"#ffffff",frameText:"#000000",noteFill:"#FFFFFF",noteText:"#000000",highlightSrgb:"#ffffff",highlightP3:"color(display-p3 1 1 1)"}},dark:{text:"hsl(210, 17%, 98%)",background:"hsl(240, 5%, 6.5%)",negativeSpace:"hsl(240, 5%, 6.5%)",solid:"#010403",cursor:"white",snap:"hsl(0, 76%, 60%)",selectionStroke:"hsl(214, 84%, 56%)",selectionFill:"hsl(209, 100%, 57%, 20%)",brushFill:"hsl(0, 0%, 56%, 10.2%)",brushStroke:"hsl(0, 0%, 56%, 25.1%)",selectedContrast:"#ffffff",laser:"hsl(0, 100%, 50%)",noteBorder:"rgb(20, 20, 20)",black:{solid:"#f2f2f2",fill:"#f2f2f2",linedFill:"#ffffff",frameHeadingStroke:"#5c5c5c",frameHeadingFill:"#252525",frameStroke:"#5c5c5c",frameFill:"#0c0c0c",frameText:"#f2f2f2",noteFill:"#2c2c2c",noteText:"#f2f2f2",semi:"#2c3036",pattern:"#989898",highlightSrgb:"#d2b700",highlightP3:"color(display-p3 0.8078 0.6225 0.0312)"},blue:{solid:"#4f72fc",fill:"#4f72fc",linedFill:"#3c5cdd",frameHeadingStroke:"#384994",frameHeadingFill:"#1C2036",frameStroke:"#384994",frameFill:"#11141f",frameText:"#f2f2f2",noteFill:"#2A3F98",noteText:"#f2f2f2",semi:"#262d40",pattern:"#3a4b9e",highlightSrgb:"#0079d2",highlightP3:"color(display-p3 0.0032 0.4655 0.7991)"},green:{solid:"#099268",fill:"#099268",linedFill:"#087856",frameHeadingStroke:"#10513C",frameHeadingFill:"#14241f",frameStroke:"#10513C",frameFill:"#0E1614",frameText:"#f2f2f2",noteFill:"#014429",noteText:"#f2f2f2",semi:"#253231",pattern:"#366a53",highlightSrgb:"#009774",highlightP3:"color(display-p3 0.0085 0.582 0.4604)"},grey:{solid:"#9398b0",fill:"#9398b0",linedFill:"#8388a5",frameHeadingStroke:"#42474D",frameHeadingFill:"#23262A",frameStroke:"#42474D",frameFill:"#151719",frameText:"#f2f2f2",noteFill:"#56595F",noteText:"#f2f2f2",semi:"#33373c",pattern:"#7c8187",highlightSrgb:"#9cb4cb",highlightP3:"color(display-p3 0.6299 0.7012 0.7856)"},"light-blue":{solid:"#4dabf7",fill:"#4dabf7",linedFill:"#2793ec",frameHeadingStroke:"#075797",frameHeadingFill:"#142839",frameStroke:"#075797",frameFill:"#0B1823",frameText:"#f2f2f2",noteFill:"#1F5495",noteText:"#f2f2f2",semi:"#2a3642",pattern:"#4d7aa9",highlightSrgb:"#00bdc8",highlightP3:"color(display-p3 0.0023 0.7259 0.7735)"},"light-green":{solid:"#40c057",fill:"#40c057",linedFill:"#37a44b",frameHeadingStroke:"#1C5427",frameHeadingFill:"#18251A",frameStroke:"#1C5427",frameFill:"#0F1911",frameText:"#f2f2f2",noteFill:"#21581D",noteText:"#f2f2f2",semi:"#2a3830",pattern:"#4e874e",highlightSrgb:"#00a000",highlightP3:"color(display-p3 0.2711 0.6172 0.0195)"},"light-red":{solid:"#ff8787",fill:"#ff8787",linedFill:"#ff6666",frameHeadingStroke:"#6f3232",frameHeadingFill:"#341818",frameStroke:"#6f3232",frameFill:"#181212",frameText:"#f2f2f2",noteFill:"#7a3333",noteText:"#f2f2f2",semi:"#3c2b2b",pattern:"#a56767",highlightSrgb:"#db005b",highlightP3:"color(display-p3 0.7849 0.0585 0.3589)"},"light-violet":{solid:"#e599f7",fill:"#e599f7",linedFill:"#dc71f4",frameHeadingStroke:"#6c367a",frameHeadingFill:"#2D2230",frameStroke:"#6c367a",frameFill:"#1C151E",frameText:"#f2f2f2",noteFill:"#762F8E",noteText:"#f2f2f2",semi:"#383442",pattern:"#9770a9",highlightSrgb:"#c400c7",highlightP3:"color(display-p3 0.7024 0.0403 0.753)"},orange:{solid:"#f76707",fill:"#f76707",linedFill:"#f54900",frameHeadingStroke:"#773a0e",frameHeadingFill:"#2f1d13",frameStroke:"#773a0e",frameFill:"#1c1512",frameText:"#f2f2f2",noteFill:"#7c3905",noteText:"#f2f2f2",semi:"#3b2e27",pattern:"#9f552d",highlightSrgb:"#d07a00",highlightP3:"color(display-p3 0.7699 0.4937 0.0085)"},red:{solid:"#e03131",fill:"#e03131",linedFill:"#c31d1d",frameHeadingStroke:"#701e1e",frameHeadingFill:"#301616",frameStroke:"#701e1e",frameFill:"#1b1313",frameText:"#f2f2f2",noteFill:"#7e201f",noteText:"#f2f2f2",semi:"#382726",pattern:"#8f3734",highlightSrgb:"#de002c",highlightP3:"color(display-p3 0.7978 0.0509 0.2035)"},violet:{solid:"#ae3ec9",fill:"#ae3ec9",linedFill:"#8f2fa7",frameHeadingStroke:"#6d1583",frameHeadingFill:"#27152e",frameStroke:"#6d1583",frameFill:"#1b0f21",frameText:"#f2f2f2",noteFill:"#5f1c70",noteText:"#f2f2f2",semi:"#342938",pattern:"#763a8b",highlightSrgb:"#9e00ee",highlightP3:"color(display-p3 0.5651 0.0079 0.8986)"},yellow:{solid:"#ffc034",fill:"#ffc034",linedFill:"#ffae00",frameHeadingStroke:"#684e12",frameHeadingFill:"#2a2113",frameStroke:"#684e12",frameFill:"#1e1911",frameText:"#f2f2f2",noteFill:"#8a5e1c",noteText:"#f2f2f2",semi:"#3b352b",pattern:"#fecb92",highlightSrgb:"#d2b700",highlightP3:"color(display-p3 0.8078 0.7225 0.0312)"},white:{solid:"#f3f3f3",fill:"#f3f3f3",linedFill:"#f3f3f3",semi:"#f5f5f5",pattern:"#f9f9f9",frameHeadingStroke:"#ffffff",frameHeadingFill:"#ffffff",frameStroke:"#ffffff",frameFill:"#ffffff",frameText:"#000000",noteFill:"#eaeaea",noteText:"#1d1d1d",highlightSrgb:"#ffffff",highlightP3:"color(display-p3 1 1 1)"}}}};function o(e,t,n){let r=e[t];return r&&"string"!=typeof r?r[n]:t}},20026:(e,t,n)=>{"use strict";n.d(t,{_:()=>d,f:()=>l});var r=n(81467),i=n(24167),o=n(54939),s=n(93286),a=n(46195);function l({editor:e,ids:t}){let n=(0,i.oE)(t.map(t=>e.getShape(t))),r=e.getShapesSharedRotation(t),o=e.getShapesRotatedPageBounds(t);if(!o)return null;let s=o.center.clone().rotWith(o.point,r);return{initialPageCenter:s,initialCursorAngle:s.angle(e.inputs.getOriginPagePoint()),initialShapesRotation:r,shapeSnapshots:n.map(t=>({shape:t,initialPagePoint:e.getShapePageTransform(t.id).point()}))}}function d({delta:e,editor:t,snapshot:n,stage:i,centerOverride:l}){let{initialPageCenter:c,shapeSnapshots:u}=n;t.updateShapes(u.map(({shape:n,initialPagePoint:i})=>{let d=(0,r.vc)(n.parentId)?t.getShapePageTransform(n.parentId):o.V.Identity(),u=a.l.RotWith(i,l??c,e),h=o.V.applyToPoint(o.V.Inverse(d),u),p=(0,s.rg)(n.rotation+e);return{id:n.id,type:n.type,x:h.x,y:h.y,rotation:p}}));let h=[];u.forEach(({shape:e})=>{let n=t.getShape(e.id);if(!n)return;let r=t.getShapeUtil(e);if("start"===i||"one-off"===i){let t=r.onRotateStart?.(e);t&&h.push(t)}let o=r.onRotate?.(e,n);if(o&&h.push(o),"end"===i||"one-off"===i){let t=r.onRotateEnd?.(e,n);t&&h.push(t)}}),h.length>0&&t.updateShapes(h)}},20172:(e,t,n)=>{"use strict";n.d(t,{U:()=>o});var r=n(95155),i=n(69730);function o({children:e,className:t="",...n}){return(0,r.jsx)("svg",{...n,className:i("tl-svg-container",t),"aria-hidden":"true",children:e})}},22036:(e,t,n)=>{"use strict";n.d(t,{Gq:()=>m,u0:()=>y,yp:()=>f});var r=n(95155),i=n(83102),o=n(27394);n(24167);var s=n(12115),a=n(67877),l=n(67863),d=n(26065),c=n(54939),u=n(28879),h=n(16038),p=n(1015);let f=(0,s.memo)(function({id:e,shape:t,util:n,index:u,backgroundIndex:f,opacity:b}){let x=(0,l.hG)(),{ShapeErrorFallback:w,ShapeWrapper:v}=(0,a.B)(),S=(0,s.useRef)(null),C=(0,s.useRef)(null);(0,s.useEffect)(()=>(0,i.wv)("load fonts",()=>{let t=x.fonts.getShapeFontFaces(e);x.fonts.requestFonts(t)}),[x,e]);let k=(0,s.useRef)({transform:"",clipPath:"none",width:0,height:0,x:0,y:0});(0,o.lX)("set shape stuff",()=>{let t=x.getShape(e);if(!t)return;let n=k.current,r=x.getShapeClipPath(e)??"none";r!==n.clipPath&&((0,h.$h)(S.current,"clip-path",r),(0,h.$h)(C.current,"clip-path",r),n.clipPath=r);let i=x.getShapePageTransform(e),o=c.V.toCssString(i),s=x.getShapeGeometry(t).bounds;o!==n.transform&&((0,h.$h)(S.current,"transform",o),(0,h.$h)(C.current,"transform",o),n.transform=o);let a=Math.max(s.width,1),l=Math.max(s.height,1);(a!==n.width||l!==n.height)&&((0,h.$h)(S.current,"width",a+"px"),(0,h.$h)(S.current,"height",l+"px"),(0,h.$h)(C.current,"width",a+"px"),(0,h.$h)(C.current,"height",l+"px"),n.width=a,n.height=l)},[x]),(0,s.useLayoutEffect)(()=>{let e=S.current,t=C.current;(0,h.$h)(e,"opacity",b),(0,h.$h)(t,"opacity",b),(0,h.$h)(e,"z-index",u),(0,h.$h)(t,"z-index",f)},[b,u,f]);let{register:P,unregister:T}=(0,d.R)();(0,s.useLayoutEffect)(()=>{let t=S.current;if(!t)return;let n=x.getCulledShapes().has(e);return P(e,t,C.current,n),()=>{T(e)}},[x,e,P,T]);let E=(0,s.useCallback)(e=>x.annotateError(e,{origin:"shape",willCrashApp:!1}),[x]);return t&&v?(0,r.jsxs)(r.Fragment,{children:[n.backgroundComponent&&(0,r.jsx)(v,{ref:C,shape:t,isBackground:!0,children:(0,r.jsx)(p.p,{fallback:w,onError:E,children:(0,r.jsx)(y,{shape:t,util:n})})}),(0,r.jsxs)(v,{ref:S,shape:t,isBackground:!1,children:[(0,r.jsx)(p.p,{fallback:w,onError:E,children:(0,r.jsx)(m,{shape:t,util:n})}),n.getAppOwnedElement&&(0,r.jsx)(g,{id:e,util:n})]})]}):null}),g=(0,s.memo)(function({id:e,util:t}){let n=(0,l.hG)(),i=(0,s.useRef)(null);return(0,s.useLayoutEffect)(()=>{let r=i.current;if(!r)return;let o=n.getShape(e);if(!o)return;let s=t.getAppOwnedElement?.(o);if(s)return s.isConnected,s.parentNode!==r&&(0,h.MM)(r,s),()=>{let r=n.getShape(e)??o;t.onReleaseAppOwnedElement?.(r,s)}},[n,e,t]),(0,r.jsx)("div",{ref:i,className:"tl-content-slot",draggable:!1})}),m=(0,s.memo)(function({shape:e,util:t}){return(0,o.A1)("InnerShape:"+e.type,()=>t.component(t.editor.store.unsafeGetWithoutCapture(e.id)),[t,e.id])},(e,t)=>(0,u.E)(e.shape,t.shape)&&e.util===t.util),y=(0,s.memo)(function({shape:e,util:t}){return(0,o.A1)("InnerShape:"+e.type,()=>t.backgroundComponent?.(t.editor.store.unsafeGetWithoutCapture(e.id)),[t,e.id])},(e,t)=>e.shape.props===t.shape.props&&e.shape.meta===t.shape.meta&&e.util===t.util)},22690:(e,t,n)=>{"use strict";n.d(t,{T:()=>r});var r={};n.r(r),n.d(r,{ArrayOfValidator:()=>d,DictValidator:()=>h,ObjectValidator:()=>c,UnionValidator:()=>u,ValidationError:()=>o,Validator:()=>l,any:()=>g,array:()=>I,arrayOf:()=>_,bigint:()=>T,boolean:()=>P,dict:()=>L,httpUrl:()=>G,indexKey:()=>q,integer:()=>S,jsonDict:()=>D,jsonValue:()=>O,linkUrl:()=>K,literal:()=>E,literalEnum:()=>H,model:()=>z,nonZeroFiniteNumber:()=>w,nonZeroInteger:()=>k,nonZeroNumber:()=>x,nullable:()=>B,number:()=>y,numberUnion:()=>R,object:()=>A,optional:()=>$,or:()=>X,positiveInteger:()=>C,positiveNumber:()=>b,setEnum:()=>N,srcUrl:()=>Y,string:()=>m,union:()=>F,unitInterval:()=>v,unknown:()=>f,unknownObject:()=>M});var i=n(24167);class o extends Error{constructor(e,t=[]){const n=function(e){if(!e.length)return null;let t="";for(let n of e)"number"==typeof n?t+=`.${n}`:n.startsWith("(")?t.endsWith(")")?t=`${t.slice(0,-1)}, ${n.slice(1)}`:t+=n:t+=`.${n}`;return(t=t.replace(/id = [^,]+, /,"").replace(/id = [^)]+/,"")).startsWith(".")?t.slice(1):t}(t),r=e.split("\n").map((e,t)=>0===t?e:` ${e}`).join("\n");super(n?`At ${n}: ${r}`:r),this.rawMessage=e,this.path=t}rawMessage;path;name="ValidationError"}function s(e,t){if(t instanceof o)throw new o(t.rawMessage,[e,...t.path]);throw new o(t.toString(),[e])}function a(e){if(null===e)return"null";if(Array.isArray(e))return"an array";let t=typeof e;switch(t){case"bigint":case"boolean":case"function":case"number":case"string":case"symbol":return`a ${t}`;case"object":return`an ${t}`;case"undefined":return"undefined";default:(0,i.h6)(t)}}class l{constructor(e,t,n=!1){this.validationFn=e,this.validateUsingKnownGoodVersionFn=t,this.skipSameValueCheck=n}validationFn;validateUsingKnownGoodVersionFn;skipSameValueCheck;validate(e){let t=this.validationFn(e);return t}validateUsingKnownGoodVersion(e,t){return Object.is(e,t)?e:this.validateUsingKnownGoodVersionFn?this.validateUsingKnownGoodVersionFn(e,t):this.validate(t)}isValid(e){try{return this.validate(e),!0}catch{return!1}}nullable(){return B(this)}optional(){return $(this)}refine(e){return new l(t=>e(this.validate(t)),(t,n)=>{let r=this.validateUsingKnownGoodVersion(t,n);return Object.is(t,r)?t:e(r)},!0)}check(e,t){return"string"==typeof e?this.refine(n=>{try{t(n)}catch(t){s(`(check ${e})`,t)}return n}):this.refine(t=>(e(t),t))}}class d extends l{constructor(e){super(t=>{let n=I.validate(t);for(let t=0;t<n.length;t++)try{e.validate(n[t])}catch(e){s(t,e)}return n},(t,n)=>{if(Object.is(t,n))return t;if(!e.validateUsingKnownGoodVersion)return this.validate(n);let r=I.validate(n),i=t.length!==r.length;for(let n=0;n<r.length;n++){let o=r[n];if(n>=t.length){i=!0;try{e.validate(o)}catch(e){s(n,e)}continue}if(!Object.is(t[n],o))try{let r=e.validateUsingKnownGoodVersion(t[n],o);Object.is(r,t[n])||(i=!0)}catch(e){s(n,e)}}return i?n:t}),this.itemValidator=e}itemValidator;nonEmpty(){return this.check(e=>{if(0===e.length)throw new o("Expected a non-empty array")})}lengthGreaterThan1(){return this.check(e=>{if(e.length<=1)throw new o("Expected an array with length greater than 1")})}}class c extends l{constructor(e,t=!1){const n=[],r=[];for(const[t,i]of Object.entries(e))n.push(t),r.push(i);super(l=>{if("object"!=typeof l||null===l)throw new o(`Expected object, got ${a(l)}`);for(let e=0;e<n.length;e++){let t=n[e];try{r[e].validate((0,i.g5)(l,t))}catch(e){s(t,e)}}if(!t){for(let t in l)if((0,i.mQ)(l,t)&&!(0,i.mQ)(e,t))throw new o("Unexpected property",[t])}return l},(l,d)=>{if(Object.is(l,d))return l;if("object"!=typeof d||null===d)throw new o(`Expected object, got ${a(d)}`);let c=!1;for(let e=0;e<n.length;e++){let t=n[e],o=(0,i.g5)(l,t),a=(0,i.g5)(d,t);if(!Object.is(o,a))try{let t=r[e],n=t.validateUsingKnownGoodVersion?t.validateUsingKnownGoodVersion(o,a):t.validate(a);Object.is(n,o)||(c=!0)}catch(e){s(t,e)}}if(t){if(!c){for(let t of Object.keys(d))if(!(0,i.mQ)(e,t)&&!Object.is((0,i.g5)(l,t),(0,i.g5)(d,t))){c=!0;break}}}else for(let t in d)if((0,i.mQ)(d,t)&&!(0,i.mQ)(e,t))throw new o("Unexpected property",[t]);if(!c){for(let e in l)if((0,i.mQ)(l,e)&&!(0,i.mQ)(d,e)){c=!0;break}}return c?d:l}),this.config=e,this.shouldAllowUnknownProperties=t}config;shouldAllowUnknownProperties;allowUnknownProperties(){return new c(this.config,!0)}extend(e){return new c({...this.config,...e})}}class u extends l{constructor(e,t,n,r){super(t=>{this.expectObject(t);let n=this.getMatchingSchema(t);if(void 0===n)return this.unknownValueValidation(t,this.getVariant(t));try{return n.validate(t)}catch(n){s(`(${e} = ${this.getVariant(t)})`,n)}},(t,n)=>{this.expectObject(n),this.expectObject(t);let r=this.getMatchingSchema(n);if(void 0===r)return this.unknownValueValidation(n,this.getVariant(n));try{if((0,i.g5)(t,e)!==(0,i.g5)(n,e))return r.validate(n);if(r.validateUsingKnownGoodVersion)return r.validateUsingKnownGoodVersion(t,n);return r.validate(n)}catch(t){s(`(${e} = ${this.getVariant(n)})`,t)}}),this.key=e,this.config=t,this.unknownValueValidation=n,this.useNumberKeys=r}key;config;unknownValueValidation;useNumberKeys;expectObject(e){if("object"!=typeof e||null===e)throw new o(`Expected an object, got ${a(e)}`,[])}getVariant(e){return(0,i.g5)(e,this.key)}getMatchingSchema(e){let t=(0,i.g5)(e,this.key);if(this.useNumberKeys||"string"==typeof t){if(this.useNumberKeys){let e=Number(t);if(e-e!=0)throw new o(`Expected a number for key "${this.key}", got "${t}"`)}}else throw new o(`Expected a string for key "${this.key}", got ${a(t)}`);return(0,i.mQ)(this.config,t)?this.config[t]:void 0}validateUnknownVariants(e){return new u(this.key,this.config,e,this.useNumberKeys)}}class h extends l{constructor(e,t){super(n=>{if("object"!=typeof n||null===n)throw new o(`Expected object, got ${a(n)}`);for(let r in n)if((0,i.mQ)(n,r))try{e.validate(r),t.validate(n[r])}catch(e){s(r,e)}return n},(n,r)=>{if("object"!=typeof r||null===r)throw new o(`Expected object, got ${a(r)}`);let l=!1,d=0;for(let o in r){if(!(0,i.mQ)(r,o))continue;d++;let a=r[o];if(!(0,i.mQ)(n,o)){l=!0;try{e.validate(o),t.validate(a)}catch(e){s(o,e)}continue}let c=n[o];if(!Object.is(c,a))try{let e=t.validateUsingKnownGoodVersion?t.validateUsingKnownGoodVersion(c,a):t.validate(a);Object.is(e,c)||(l=!0)}catch(e){s(o,e)}}if(!l){let e=0;for(let t in n)(0,i.mQ)(n,t)&&e++;e!==d&&(l=!0)}return l?r:n}),this.keyValidator=e,this.valueValidator=t}keyValidator;valueValidator}function p(e){return new l(t=>{if(typeof t!==e)throw new o(`Expected ${e}, got ${a(t)}`);return t})}let f=new l(e=>e),g=new l(e=>e),m=p("string"),y=new l(e=>{if(Number.isFinite(e))return e;if("number"!=typeof e)throw new o(`Expected number, got ${a(e)}`);if(e!=e)throw new o("Expected a number, got NaN");throw new o(`Expected a finite number, got ${e}`)}),b=new l(e=>{if(Number.isFinite(e)&&e>=0)return e;if("number"!=typeof e)throw new o(`Expected number, got ${a(e)}`);if(e!=e)throw new o("Expected a number, got NaN");if(e<0)throw new o(`Expected a positive number, got ${e}`);throw new o(`Expected a finite number, got ${e}`)}),x=new l(e=>{if(Number.isFinite(e)&&e>0)return e;if("number"!=typeof e)throw new o(`Expected number, got ${a(e)}`);if(e!=e)throw new o("Expected a number, got NaN");if(e<=0)throw new o(`Expected a non-zero positive number, got ${e}`);throw new o(`Expected a finite number, got ${e}`)}),w=new l(e=>{if(Number.isFinite(e)&&0!==e)return e;if("number"!=typeof e)throw new o(`Expected number, got ${a(e)}`);if(e!=e)throw new o("Expected a number, got NaN");if(0===e)throw new o("Expected a non-zero number, got 0");throw new o(`Expected a finite number, got ${e}`)}),v=new l(e=>{if(Number.isFinite(e)&&e>=0&&e<=1)return e;if("number"!=typeof e)throw new o(`Expected number, got ${a(e)}`);if(e!=e)throw new o("Expected a number, got NaN");throw new o(`Expected a number between 0 and 1, got ${e}`)}),S=new l(e=>{if(Number.isInteger(e))return e;if("number"!=typeof e)throw new o(`Expected number, got ${a(e)}`);if(e!=e)throw new o("Expected a number, got NaN");if(e-e!=0)throw new o(`Expected a finite number, got ${e}`);throw new o(`Expected an integer, got ${e}`)}),C=new l(e=>{if(Number.isInteger(e)&&e>=0)return e;if("number"!=typeof e)throw new o(`Expected number, got ${a(e)}`);if(e!=e)throw new o("Expected a number, got NaN");if(e-e!=0)throw new o(`Expected a finite number, got ${e}`);if(e<0)throw new o(`Expected a positive integer, got ${e}`);throw new o(`Expected an integer, got ${e}`)}),k=new l(e=>{if(Number.isInteger(e)&&e>0)return e;if("number"!=typeof e)throw new o(`Expected number, got ${a(e)}`);if(e!=e)throw new o("Expected a number, got NaN");if(e-e!=0)throw new o(`Expected a finite number, got ${e}`);if(e<=0)throw new o(`Expected a non-zero positive integer, got ${e}`);throw new o(`Expected an integer, got ${e}`)}),P=p("boolean"),T=p("bigint");function E(e){return new l(t=>{if(t!==e)throw new o(`Expected ${e}, got ${JSON.stringify(t)}`);return e})}let I=new l(e=>{if(!Array.isArray(e))throw new o(`Expected an array, got ${a(e)}`);return e});function _(e){return new d(e)}let M=new l(e=>{if("object"!=typeof e||null===e)throw new o(`Expected object, got ${a(e)}`);return e});function A(e){return new c(e)}function j(e){return"object"==typeof e&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e)||Object.getPrototypeOf(e)===i.DM)}let O=new l(e=>{if(function e(t){if(null===t||"number"==typeof t||"string"==typeof t||"boolean"==typeof t)return!0;if(Array.isArray(t)){for(let n=0;n<t.length;n++)if(!e(t[n]))return!1;return!0}if(j(t)){for(let n in t)if((0,i.mQ)(t,n)&&!e(t[n]))return!1;return!0}return!1}(e))return e;throw new o(`Expected json serializable value, got ${typeof e}`)},(e,t)=>{if(Array.isArray(e)&&Array.isArray(t)){let n=e.length!==t.length;for(let r=0;r<t.length;r++){if(r>=e.length){n=!0,O.validate(t[r]);continue}let i=e[r],o=t[r];!Object.is(i,o)&&(Object.is(O.validateUsingKnownGoodVersion(i,o),i)||(n=!0))}return n?t:e}if(!(j(e)&&j(t)))return O.validate(t);{let n=!1;for(let r in t){if(!(0,i.mQ)(t,r))continue;if(!(0,i.mQ)(e,r)){n=!0,O.validate(t[r]);continue}let o=e[r],s=t[r];!Object.is(o,s)&&(Object.is(O.validateUsingKnownGoodVersion(o,s),o)||(n=!0))}if(!n){for(let r in e)if((0,i.mQ)(e,r)&&!(0,i.mQ)(t,r)){n=!0;break}}return n?t:e}});function D(){return L(m,O)}function L(e,t){return new h(e,t)}function F(e,t){return new u(e,t,(n,r)=>{throw new o(`Expected one of ${Object.keys(t).map(e=>JSON.stringify(e)).join(" or ")}, got ${JSON.stringify(r)}`,[e])},!1)}function R(e,t){return new u(e,t,(n,r)=>{throw new o(`Expected one of ${Object.keys(t).map(e=>JSON.stringify(e)).join(" or ")}, got ${JSON.stringify(r)}`,[e])},!0)}function z(e,t){return new l(n=>{try{return t.validate(n)}catch(t){s(e,t)}},(n,r)=>{try{if(t.validateUsingKnownGoodVersion)return t.validateUsingKnownGoodVersion(n,r);return t.validate(r)}catch(t){s(e,t)}})}function N(e){return new l(t=>{if(!e.has(t)){let n=Array.from(e,e=>JSON.stringify(e)).join(" or ");throw new o(`Expected ${n}, got ${t}`)}return t})}function $(e){return new l(t=>{if(void 0!==t)return e.validate(t)},(t,n)=>{if(void 0!==n)return e.validateUsingKnownGoodVersion&&void 0!==t?e.validateUsingKnownGoodVersion(t,n):e.validate(n)},e instanceof l&&e.skipSameValueCheck)}function B(e){return new l(t=>null===t?null:e.validate(t),(t,n)=>null===n?null:e.validateUsingKnownGoodVersion&&null!==t?e.validateUsingKnownGoodVersion(t,n):e.validate(n),e instanceof l&&e.skipSameValueCheck)}function H(...e){return N(new Set(e))}function U(e){try{return new URL(e)}catch{if(e.startsWith("/")||e.startsWith("./"))try{return new URL(e,"http://example.com")}catch{}throw new o(`Expected a valid url, got ${JSON.stringify(e)}`)}}let W=new Set(["http:","https:","mailto:"]),K=m.check(e=>{if(""===e)return;let t=U(e);if(!W.has(t.protocol.toLowerCase()))throw new o(`Expected a valid url, got ${JSON.stringify(e)} (invalid protocol)`)}),V=new Set(["http:","https:","data:","asset:"]),Y=m.check(e=>{if(""===e)return;let t=U(e);if(!V.has(t.protocol.toLowerCase()))throw new o(`Expected a valid url, got ${JSON.stringify(e)} (invalid protocol)`)}),G=m.check(e=>{if(""!==e&&!U(e).protocol.toLowerCase().match(/^https?:$/))throw new o(`Expected a valid url, got ${JSON.stringify(e)} (invalid protocol)`)}),q=m.refine(e=>{try{return(0,i.fb)(e),e}catch{throw new o(`Expected an index key, got ${JSON.stringify(e)}`)}});function X(e,t){return new l(n=>{try{return e.validate(n)}catch{return t.validate(n)}})}(0,i.lF)("@tldraw/validate","5.3.2","esm")},23919:(e,t,n)=>{"use strict";n.d(t,{H:()=>s,b:()=>o});var r=n(24167),i=n(13656);async function o(e,t,n){let i=await (0,r.hd)(e);return new File([await i.arrayBuffer()],t,{type:n})}function s(){return`https://cdn.tldraw.com/${i.r}`}},24167:(e,t,n)=>{"use strict";let r,i,o;n.d(t,{RB:()=>Q,qS:()=>ee,Sm:()=>N,_V:()=>z,Qn:()=>K,K4:()=>et,f6:()=>ex,ZA:()=>q,Q7:()=>T,DM:()=>e4,xl:()=>e1,l:()=>O,as:()=>eA,TF:()=>F,vq:()=>S,zK:()=>ef,vA:()=>I,Z1:()=>_,oI:()=>j,sw:()=>eU,D6:()=>eY,oE:()=>b,sg:()=>D,Qq:()=>y,ZJ:()=>eV,h6:()=>E,hd:()=>R,J2:()=>eh,Xz:()=>eg,C$:()=>eG,zM:()=>eB,_9:()=>eW,Gw:()=>B,xp:()=>$,AQ:()=>eF,SB:()=>eR,HE:()=>eL,uu:()=>ez,Zo:()=>eD,MT:()=>eO,g5:()=>ea,mQ:()=>es,Fg:()=>er,O9:()=>e3,n4:()=>p,Ao:()=>em,HV:()=>x,Cc:()=>en,_H:()=>ep,Sk:()=>v,Og:()=>C,wq:()=>w,ww:()=>eo,lQ:()=>P,iA:()=>ec,_e:()=>eu,w$:()=>el,Ic:()=>ed,il:()=>M,lF:()=>a,Sh:()=>ei,yC:()=>e2,Yz:()=>eH,dQ:()=>eK,yy:()=>A,rb:()=>e$,Ky:()=>eN,pN:()=>e6,nF:()=>g,Uo:()=>e0,sb:()=>m,NF:()=>W,fb:()=>ej,mc:()=>e9});let s="__TLDRAW_LIBRARY_VERSIONS__";function a(e,t,n){if(!e||!t||!n)throw Error("Missing name/version/module system in built version of tldraw library");let r=function(){if(globalThis[s])return globalThis[s];let e={versions:[],didWarn:!1,scheduledNotice:null};return Object.defineProperty(globalThis,s,{value:e,writable:!1,configurable:!1,enumerable:!1}),e}();if(!(function(){try{return!1}catch{return!1}}()&&r.versions.some(r=>r.name===e&&r.version===t&&r.modules===n))&&(r.versions.push({name:e,version:t,modules:n}),!r.scheduledNotice))try{r.scheduledNotice=setTimeout(()=>{r.scheduledNotice=null,l(r)},100)}catch{l(r)}}function l(e){if(!e.versions.length||e.didWarn)return;let t=e.versions.sort((e,t)=>d(e.version,t.version)),n=t[t.length-1].version,r=new Set,i=new Map;for(let e of t){if(i.has(e.name)){r.delete(e.name),h(i,e.name,new Set).add(e.version);continue}e.version===n?r.add(e.name):(r.delete(e.name),h(i,e.name,new Set).add(e.version))}if(i.size>0){console.log([`${u("[tldraw]",["bold","bgRed","textWhite"])} ${u("You have multiple versions of tldraw libraries installed. This can lead to bugs and unexpected behavior.",["textRed","bold"])}`,"",`The latest version you have installed is ${u(`v${n}`,["bold","textBlue"])}. The following libraries are on the latest version:`,...Array.from(r,e=>` \u2022 \u2705 ${u(e,["bold"])}`),"","The following libraries are not on the latest version, or have multiple versions installed:",...Array.from(i,([e,t])=>{let r=Array.from(t).sort(d).map(e=>u(`v${e}`,e===n?["textGreen"]:["textRed"]));return` \u2022 \u274C ${u(e,["bold"])} (${r.join(", ")})`})].join("\n")),e.didWarn=!0;return}let o=new Map;for(let e of t)h(o,e.name,{version:e.version,modules:[]}).modules.push(e.modules);let s=new Map;for(let[e,t]of o)t.modules.length>1&&s.set(e,t);if(s.size>0){console.log([`${u("[tldraw]",["bold","bgRed","textWhite"])} ${u("You have multiple instances of some tldraw libraries active. This can lead to bugs and unexpected behavior. ",["textRed","bold"])}`,"","This usually means that your bundler is misconfigured, and is importing the same library multiple times - usually once as an ES Module, and once as a CommonJS module.","","The following libraries have been imported multiple times:",...Array.from(s,([e,t])=>{let n=t.modules.map((e,t)=>"esm"===e?` ${t+1}. ES Modules`:` ${t+1}. CommonJS`).join("\n");return` \u2022 \u274C ${u(e,["bold"])} v${t.version}:
|
|
5
|
+
${n}`}),"","You should configure your bundler to only import one version of each library."].join("\n")),e.didWarn=!0;return}}function d(e,t){let n=e.match(/^(\d+)\.(\d+)\.(\d+)(?:-(\w+))?$/),r=t.match(/^(\d+)\.(\d+)\.(\d+)(?:-(\w+))?$/);return n&&r?n[1]!==r[1]?Number(n[1])-Number(r[1]):n[2]!==r[2]?Number(n[2])-Number(r[2]):n[3]!==r[3]?Number(n[3])-Number(r[3]):n[4]&&r[4]?n[4].localeCompare(r[4]):n[4]?1:r[4]?-1:0:e.localeCompare(t)}let c={bold:"1",textBlue:"94",textRed:"31",textGreen:"32",bgRed:"41",textWhite:"97"};function u(e,t=[]){return`\x1b[${t.map(e=>c[e]).join(";")}m${e}\x1b[m`}function h(e,t,n){return e.has(t)?e.get(t):(e.set(t,n),n)}var p=n(94449),f=n(99017),g=n(71645),m=n(96116);function y(e,t){let n=[];n:for(let r of e){for(let e of n)if(t?t(r,e):r===e)continue n;n.push(r)}return n}function b(e){return e.filter(e=>null!=e)}function x(e){return e[e.length-1]}function w(e,t){let n,r=1/0;for(let i of e){let e=t(i);e<r&&(n=i,r=e)}return n}function v(e,t){let n,r=-1/0;for(let i of e){let e=t(i);e>r&&(n=i,r=e)}return n}function S(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function C(e,t,n){let r=new Set(t.map(t=>t[e])),i=[];for(let t of n)r.has(t[e])||i.push(t);for(let e of t)i.push(e);return i}function k(e){let t=(...n)=>{try{return e(...n)}catch(e){throw e instanceof Error&&Error.captureStackTrace&&Error.captureStackTrace(e,t),e}};return t}function P(){}let T={ok:e=>({ok:!0,value:e}),err:e=>({ok:!1,error:e}),all:e=>e.every(e=>e.ok)?T.ok(e.map(e=>e.value)):T.err(e.find(e=>!e.ok)?.error)};function E(e,t){let n=t&&e&&"object"==typeof e&&t in e?e[t]:e;throw Error(`Unknown switch case ${n}`)}let I=k((e,t)=>{if(!e)throw Error(t||"Assertion Error")}),_=k((e,t)=>{if(null==e)throw Error(t??"value must be defined");return e});function M(){let e,t;return Object.assign(new Promise((n,r)=>{e=n,t=r}),{resolve:e,reject:t})}function A(e){return new Promise(t=>setTimeout(t,e))}function j(...e){if(2===e.length){let[t,n]=e;n.addInitializer(function(){I(Reflect.isExtensible(this),"Cannot bind to a non-extensible class.");let e=t.bind(this);I(Reflect.defineProperty(this,n.name,{value:e,writable:!0,configurable:!0}),"Cannot bind a non-configurable class method.")})}else{let[t,n,r]=e;if(!r||"function"!=typeof r.value)throw TypeError(`Only methods can be decorated with @bind. <${n}> is not a method!`);return{configurable:!0,get(){let e=r.value.bind(this);return Object.defineProperty(this,n,{value:e,configurable:!0,writable:!0}),e}}}}class O{items=new WeakMap;get(e,t){return this.items.has(e)||this.items.set(e,t(e)),this.items.get(e)}}function D(e,t){let n,r=(...r)=>(n||((n={}).promise=new Promise((e,t)=>{n.resolve=e,n.reject=t})),clearTimeout(n.timeout),n.latestArgs=r,n.timeout=setTimeout(()=>{let t=n;n=void 0;try{t.resolve(e(...t.latestArgs))}catch(e){t.reject(e)}},t),n.promise);return r.cancel=()=>{if(!n)return;clearTimeout(n.timeout);let e=n;n=void 0,e.promise.catch(P),e.reject(Error("Debounced function was cancelled"))},r}let L=new WeakMap;function F(e,t){if("object"!=typeof e||null===e)return;let n=L.get(e);n||(n={tags:{},extras:{}},L.set(e,n)),t.tags&&(n.tags={...n.tags,...t.tags}),t.extras&&(n.extras={...n.extras,...t.extras})}async function R(e,t){return window.fetch(e,{referrerPolicy:"strict-origin-when-cross-origin",...t})}function z(e,t){let n=new window.Image(e,t);return n.referrerPolicy="strict-origin-when-cross-origin",n}class N{static async urlToArrayBuffer(e){let t=await R(e);return await t.arrayBuffer()}static async urlToBlob(e){let t=await R(e);return await t.blob()}static async urlToDataUrl(e){if(e.startsWith("data:"))return e;let t=await N.urlToBlob(e);return await N.blobToDataUrl(t)}static async blobToDataUrl(e){return await new Promise((t,n)=>{if(e){let r=new FileReader;r.onload=()=>t(r.result),r.onerror=e=>n(e),r.onabort=e=>n(e),r.readAsDataURL(e)}})}static async blobToText(e){return await new Promise((t,n)=>{if(e){let r=new FileReader;r.onload=()=>t(r.result),r.onerror=e=>n(e),r.onabort=e=>n(e),r.readAsText(e)}})}static rewriteMimeType(e,t){return e.type===t?e:e instanceof File?new File([e],e.name,{type:t}):new Blob([e],{type:t})}}function $(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return t+""}function B(e){let t=new DataView(e),n=0;for(let e=0;e<t.byteLength;e++)n=(n<<5)-n+t.getUint8(e)|0;return n+""}let H=globalThis.crypto,U=function(e=21){var t;t=e-=0,!r||r.length<t?(r=new Uint8Array(128*t),H.getRandomValues(r),i=0):i+t>r.length&&(H.getRandomValues(r),i=0),i+=t;let n="";for(let t=i-e;t<i;t++)n+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&r[t]];return n};function W(e){return U(e)}class K{constructor(e){this.maxSize=e}maxSize;map=new Map;get(e){if(!this.map.has(e))return;let t=this.map.get(e);return this.map.delete(e),this.map.set(e,t),t}set(e,t){this.map.has(e)&&this.map.delete(e),this.map.set(e,t),this.map.size>this.maxSize&&this.map.delete(this.map.keys().next().value)}has(e){return this.map.has(e)}get size(){return this.map.size}}var V=n(92619).Buffer;function Y(e,t){let n=0;for(;e[t+n];)n+=e[t+n]+1;return n+1}let G=[0,0x77073096,0xee0e612c,0x990951ba,0x76dc419,0x706af48f,0xe963a535,0x9e6495a3,0xedb8832,0x79dcb8a4,0xe0d5e91e,0x97d2d988,0x9b64c2b,0x7eb17cbd,0xe7b82d07,0x90bf1d91,0x1db71064,0x6ab020f2,0xf3b97148,0x84be41de,0x1adad47d,0x6ddde4eb,0xf4d4b551,0x83d385c7,0x136c9856,0x646ba8c0,0xfd62f97a,0x8a65c9ec,0x14015c4f,0x63066cd9,0xfa0f3d63,0x8d080df5,0x3b6e20c8,0x4c69105e,0xd56041e4,0xa2677172,0x3c03e4d1,0x4b04d447,0xd20d85fd,0xa50ab56b,0x35b5a8fa,0x42b2986c,0xdbbbc9d6,0xacbcf940,0x32d86ce3,0x45df5c75,0xdcd60dcf,0xabd13d59,0x26d930ac,0x51de003a,0xc8d75180,0xbfd06116,0x21b4f4b5,0x56b3c423,0xcfba9599,0xb8bda50f,0x2802b89e,0x5f058808,0xc60cd9b2,0xb10be924,0x2f6f7c87,0x58684c11,0xc1611dab,0xb6662d3d,0x76dc4190,0x1db7106,0x98d220bc,0xefd5102a,0x71b18589,0x6b6b51f,0x9fbfe4a5,0xe8b8d433,0x7807c9a2,0xf00f934,0x9609a88e,0xe10e9818,0x7f6a0dbb,0x86d3d2d,0x91646c97,0xe6635c01,0x6b6b51f4,0x1c6c6162,0x856530d8,0xf262004e,0x6c0695ed,0x1b01a57b,0x8208f4c1,0xf50fc457,0x65b0d9c6,0x12b7e950,0x8bbeb8ea,0xfcb9887c,0x62dd1ddf,0x15da2d49,0x8cd37cf3,0xfbd44c65,0x4db26158,0x3ab551ce,0xa3bc0074,0xd4bb30e2,0x4adfa541,0x3dd895d7,0xa4d1c46d,0xd3d6f4fb,0x4369e96a,0x346ed9fc,0xad678846,0xda60b8d0,0x44042d73,0x33031de5,0xaa0a4c5f,0xdd0d7cc9,0x5005713c,0x270241aa,0xbe0b1010,0xc90c2086,0x5768b525,0x206f85b3,0xb966d409,0xce61e49f,0x5edef90e,0x29d9c998,0xb0d09822,0xc7d7a8b4,0x59b33d17,0x2eb40d81,0xb7bd5c3b,0xc0ba6cad,0xedb88320,0x9abfb3b6,0x3b6e20c,0x74b1d29a,0xead54739,0x9dd277af,0x4db2615,0x73dc1683,0xe3630b12,0x94643b84,0xd6d6a3e,0x7a6a5aa8,0xe40ecf0b,0x9309ff9d,0xa00ae27,0x7d079eb1,0xf00f9344,0x8708a3d2,0x1e01f268,0x6906c2fe,0xf762575d,0x806567cb,0x196c3671,0x6e6b06e7,0xfed41b76,0x89d32be0,0x10da7a5a,0x67dd4acc,0xf9b9df6f,0x8ebeeff9,0x17b7be43,0x60b08ed5,0xd6d6a3e8,0xa1d1937e,0x38d8c2c4,0x4fdff252,0xd1bb67f1,0xa6bc5767,0x3fb506dd,0x48b2364b,0xd80d2bda,0xaf0a1b4c,0x36034af6,0x41047a60,0xdf60efc3,0xa867df55,0x316e8eef,0x4669be79,0xcb61b38c,0xbc66831a,0x256fd2a0,0x5268e236,0xcc0c7795,0xbb0b4703,0x220216b9,0x5505262f,0xc5ba3bbe,0xb2bd0b28,0x2bb45a92,0x5cb36a04,0xc2d7ffa7,0xb5d0cf31,0x2cd99e8b,0x5bdeae1d,0x9b64c2b0,0xec63f226,0x756aa39c,0x26d930a,0x9c0906a9,0xeb0e363f,0x72076785,0x5005713,0x95bf4a82,0xe2b87a14,0x7bb12bae,0xcb61b38,0x92d28e9b,0xe5d5be0d,0x7cdcefb7,0xbdbdf21,0x86d3d2d4,0xf1d4e242,0x68ddb3f8,0x1fda836e,0x81be16cd,0xf6b9265b,0x6fb077e1,0x18b74777,0x88085ae6,0xff0f6a70,0x66063bca,0x11010b5c,0x8f659eff,0xf862ae69,0x616bffd3,0x166ccf45,0xa00ae278,0xd70dd2ee,0x4e048354,0x3903b3c2,0xa7672661,0xd06016f7,0x4969474d,0x3e6e77db,0xaed16a4a,0xd9d65adc,0x40df0b66,936918e3,0xa9bcae53,0xdebb9ec5,0x47b2cf7f,0x30b5ffe9,0xbdbdf21c,0xcabac28a,0x53b39330,0x24b4a3a6,0xbad03605,0xcdd70693,0x54de5729,0x23d967bf,0xb3667a2e,0xc4614ab8,0x5d681b02,0x2a6f2b94,0xb40bbe37,0xc30c8ea1,0x5a05df1b,0x2d02ef8d];"u">typeof Int32Array&&(G=new Int32Array(G));class q{static isPng(e,t){return 137===e.getUint8(t+0)&&80===e.getUint8(t+1)&&78===e.getUint8(t+2)&&71===e.getUint8(t+3)&&13===e.getUint8(t+4)&&10===e.getUint8(t+5)&&26===e.getUint8(t+6)&&10===e.getUint8(t+7)||!1}static getChunkType(e,t){return[String.fromCharCode(e.getUint8(t)),String.fromCharCode(e.getUint8(t+1)),String.fromCharCode(e.getUint8(t+2)),String.fromCharCode(e.getUint8(t+3))].join("")}static readChunks(e,t=0){let n={};if(!q.isPng(e,t))throw Error("Not a PNG");for(t+=8;t<=e.buffer.byteLength;){let r=t,i=e.getInt32(t);t+=4;let o=q.getChunkType(e,t);if("IDAT"===o&&n[o]){t+=i+4+4;continue}if("IEND"===o)break;n[o]={start:r,dataOffset:t+4,size:i},t+=i+4+4}return n}static parsePhys(e,t){return{ppux:e.getUint32(t),ppuy:e.getUint32(t+4),unit:e.getUint8(t+8)}}static findChunk(e,t){return q.readChunks(e)[t]}static setPhysChunk(e,t=1,n){let r=46,i=0,o=q.findChunk(e,"pHYs");o&&(r=o.start,i=o.size);let s=q.findChunk(e,"IDAT");s&&(r=s.start,i=0);let a=new ArrayBuffer(21),l=new DataView(a);l.setUint32(0,9),l.setUint8(4,112),l.setUint8(5,72),l.setUint8(6,89),l.setUint8(7,115),l.setInt32(8,2835.5*t),l.setInt32(12,2835.5*t),l.setInt8(16,1);let d=new Uint8Array(a.slice(4,17));return l.setInt32(17,(e=>{let t=-1^~~void 0;for(let n=0;n<e.length;n++)t=G[(t^e[n])&255]^t>>>8;return -1^t})(d)),new Blob([e.buffer.slice(0,r),a,e.buffer.slice(r+i)],n)}}let X=Object.freeze(["image/svg+xml"]),J=Object.freeze(["image/jpeg","image/png","image/webp"]),Z=Object.freeze(["image/gif","image/apng","image/avif"]),Q=Object.freeze([...J,...X,...Z]),ee=Object.freeze(["video/mp4","video/webm","video/quicktime"]);Object.freeze([...Q,...ee]).join(",");class et{static loadVideo(e,t){return new Promise((n,r)=>{let i=(t??document).createElement("video");i.onloadeddata=()=>n(i),i.onerror=e=>{console.error(e),r(Error("Could not load video"))},i.crossOrigin="anonymous",i.src=e})}static async getVideoFrameAsDataUrl(e,t=0){let n=M(),r=!1,i=()=>{if(!r)if(!(e.readyState>=e.HAVE_METADATA))return;else r=!0,e.currentTime=t;if(e.readyState>=e.HAVE_CURRENT_DATA){let t=(e.ownerDocument??document).createElement("canvas");t.width=e.videoWidth,t.height=e.videoHeight;let r=t.getContext("2d");if(!r)throw Error("Could not get 2d context");r.drawImage(e,0,0),n.resolve(t.toDataURL())}},o=e=>{console.error(e),n.reject(Error("Could not get video frame"))};e.addEventListener("loadedmetadata",i),e.addEventListener("loadeddata",i),e.addEventListener("canplay",i),e.addEventListener("seeked",i),e.addEventListener("error",o),e.addEventListener("stalled",o),i();try{return await n}finally{e.removeEventListener("loadedmetadata",i),e.removeEventListener("loadeddata",i),e.removeEventListener("canplay",i),e.removeEventListener("seeked",i),e.removeEventListener("error",o),e.removeEventListener("stalled",o)}}static getImageAndDimensions(e,t){return new Promise((n,r)=>{let i=z();i.onload=()=>{let e;if(i.naturalWidth)e={w:i.naturalWidth,h:i.naturalHeight};else{let n=(t??document).body;n.appendChild(i),e={w:i.clientWidth,h:i.clientHeight},n.removeChild(i)}n({...e,image:i})},i.onerror=e=>{console.error(e),r(Error("Could not load image"))},i.crossOrigin="anonymous",i.referrerPolicy="strict-origin-when-cross-origin",i.style.visibility="hidden",i.style.position="absolute",i.style.opacity="0",i.style.zIndex="-9999",i.src=e})}static async getVideoSize(e,t){return et.usingObjectURL(e,async e=>{let n=await et.loadVideo(e,t);return{w:n.videoWidth,h:n.videoHeight}})}static async getImageSize(e,t){let{w:n,h:r}=await et.usingObjectURL(e,e=>et.getImageAndDimensions(e,t));try{if("image/png"===e.type){let t=new DataView(await e.arrayBuffer());if(q.isPng(t,0)){let e=q.findChunk(t,"pHYs");if(e){let i=q.parsePhys(t,e.dataOffset);if(1===i.unit&&i.ppux===i.ppuy){let e=Math.round(.0254*i.ppux),t=e/96,o=e/72,s=1;if(Number.isInteger(t)&&t>1?s=t:Number.isInteger(o)&&o>1&&(s=o),s>1)return{w:Math.ceil(n/s),h:Math.ceil(r/s),pixelRatio:s}}}}}}catch(e){console.error(e)}return{w:n,h:r,pixelRatio:1}}static async isAnimated(e){if("image/gif"===e.type)return function(e){let t,n,r=new Uint8Array(e),i=0,o=0;if("GIF"!==new TextDecoder("ascii").decode(e.slice(0,3)))return!1;for(t=128&r[10],n=7&r[10],i+=6,i+=7,i+=t?3*Math.pow(2,n+1):0;o<2&&i<r.length;)switch(r[i]){case 44:o+=1,t=128&r[i+9],n=7&r[i+9],i+=10,i+=t?3*Math.pow(2,n+1):0,i+=Y(r,i+1)+1;break;case 33:i+=2,i+=Y(r,i);break;default:i=r.length}return o>1}(await e.arrayBuffer());if("image/avif"===e.type)return 44===new Uint8Array(await e.arrayBuffer())[3];if("image/webp"===e.type){let t;return t=new Uint8Array(await e.arrayBuffer()),!(t.length<12)&&87===t[8]&&69===t[9]&&66===t[10]&&80===t[11]&&!!t&&!(t.length<21)&&(t[20]>>1&1)==1}return"image/apng"===e.type&&function(e){let t=new Uint8Array(e);if(!t||!(void 0!==V&&V.isBuffer(t)||t instanceof Uint8Array)||t.length<16||137!==t[0]||80!==t[1]||78!==t[2]||71!==t[3]||13!==t[4]||10!==t[5]||26!==t[6]||10!==t[7])return!1;function n(e,t,r,i,o=1024){if(!t)return -1;let s=(t=RegExp(t,"g")).source.length,a=new TextDecoder,l=e.length;if(void 0===i&&(i=l),r>=l||i<=0||r>=i)return -1;e=e.subarray(r,i);let d=-1,c=0,u=0,h="";r:for(;c<e.length;){let n,r=c+o,i=e.subarray(c,r),l=a.decode(i,{stream:!0}),p=h+l,f=-1;for(;null!==(n=t.exec(p));){d=u+(f=n.index-h.length);break r}c=r,u+=l.length;let g=f>-1?f+s:l.length-s;h=l.slice(g)}return d>=0&&(d+=r>=0?r:l+r),d}let r=n(t,"IDAT",12);return r>=12&&n(t,"acTL",8,r)>=8}(await e.arrayBuffer())}static isAnimatedImageType(e){return Z.includes(e||"")}static isStaticImageType(e){return J.includes(e||"")}static isVectorImageType(e){return X.includes(e||"")}static isImageType(e){return Q.includes(e||"")}static async usingObjectURL(e,t){let n=URL.createObjectURL(e);try{return await t(n)}finally{URL.revokeObjectURL(n)}}}function en(e,t,n){return e+(t-e)*n}function er(e,t,n){return(n-e)/(t-e)}function ei(e=""){let t=0,n=0,r=0,i=0;function o(){let e=t^t<<11;return t=n,n=r,r=i,(i^=(i>>>19^e^e>>>8)>>>0)/0x100000000*2}for(let n=0;n<e.length+64;n++)t^=e.charCodeAt(n),o();return o}function eo(e,t,n,r=!1){let[i,o]=t,[s,a]=n,l=s+(e-i)/(o-i)*(a-s);return r?s<a?Math.max(Math.min(l,a),s):Math.max(Math.min(l,s),a):l}function es(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ea(e,t){if(es(e,t))return e[t]}function el(e){return Object.keys(e)}function ed(e){return Object.values(e)}function ec(e){return Object.entries(e)}function eu(e){return Object.fromEntries(e)}function eh(e,t){let n={},r=!1;for(let i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;let o=e[i];t(i,o)?n[i]=o:r=!0}return r?n:e}function ep(e,t){let n={};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=t(r,e[r]));return n}function ef(e,t){if(e===t)return!0;let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!es(t,r)||!Object.is(e[r],t[r]))return!1;return!0}function eg(e,t){let n=[];for(let r in e)Object.is(e[r],t[r])||n.push(r);return n}function em(e,t,n=1e-6){return f(e,t,(e,t)=>{if("number"==typeof e&&"number"==typeof t)return Math.abs(e-t)<n})}let ey="#40C057",eb="#FFC078";class ex{startTime=0;name="";frames=0;started=!1;frame=null;recordFrame=()=>{this.frames++,this.started&&(this.frame=requestAnimationFrame(this.recordFrame))};start(e){this.name=e,this.frames=0,this.started=!0,null!==this.frame&&cancelAnimationFrame(this.frame),this.frame=requestAnimationFrame(this.recordFrame),this.startTime=performance.now()}stop(){this.started=!1,null!==this.frame&&cancelAnimationFrame(this.frame);let e=(performance.now()-this.startTime)/1e3,t=0===e?0:Math.floor(this.frames/e),n=t>55?ey:t>30?eb:"#E03131",r=this.name[0].toUpperCase()+this.name.slice(1);console.debug(`%cPerf%c ${r} %c${t}%c fps`,`color: white; background: ${ey};padding: 2px;border-radius: 3px;`,"font-weight: normal",`font-weight: bold; padding: 2px; background: ${n};color: ${n===eb?"black":"white"};`,"font-weight: normal")}isStarted(){return this.started}}let ew="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",ev=ew[0],eS=ew[ew.length-1],eC="A"+ev.repeat(26);function ek(e){let t=function(e){if(e>="a"&&e<="z")return e.charCodeAt(0)-97+2;if(e>="A"&&e<="Z")return 90-e.charCodeAt(0)+2;throw Error("invalid order key head: "+e)}(e[0]);if(t>e.length)throw Error("invalid order key: "+e);return e.slice(0,t)}function eP(e){let t=e.charCodeAt(0);return t<=57?t-48:t<=90?t-55:t-61}function eT(e){if(e===eC)throw Error("invalid order key: "+e);let t=ek(e);if(e.length>t.length&&e[e.length-1]===ev)throw Error("invalid order key: "+e)}function eE(e,t){if(null!=t&&e>=t)throw Error(e+" >= "+t);if(e.slice(-1)===ev||t&&t.slice(-1)===ev)throw Error("trailing zero");if(t){let n=0;for(;(e[n]||ev)===t[n];)n++;if(n>0)return t.slice(0,n)+eE(e.slice(n),t.slice(n))}let n=e?eP(e[0]):0,r=null!=t?eP(t[0]):ew.length;return r-n>1?ew[Math.round(.5*(n+r))]:t&&t.length>1?t.slice(0,1):ew[n]+eE(e.slice(1),null)}function eI(e){let[t,...n]=e.split(""),r=!0;for(let e=n.length-1;r&&e>=0;e--){let t=eP(n[e])+1;t===ew.length?n[e]=ev:(n[e]=ew[t],r=!1)}if(r){if("Z"===t)return"a"+ev;if("z"===t)return null;let e=String.fromCharCode(t.charCodeAt(0)+1);return e>"a"?n.push(ev):n.pop(),e+n.join("")}return t+n.join("")}function e_(e,t){if(null!=e&&null!=t&&e>=t)throw Error(e+" >= "+t);if(null==e){if(null==t)return"a"+ev;let e=ek(t),n=t.slice(e.length);if(e===eC)return e+eE("",n);if(e<t)return e;let r=function(e){let[t,...n]=e.split(""),r=!0;for(let e=n.length-1;r&&e>=0;e--){let t=eP(n[e])-1;-1===t?n[e]=eS:(n[e]=ew[t],r=!1)}if(r){if("a"===t)return"Z"+eS;if("A"===t)return null;let e=String.fromCharCode(t.charCodeAt(0)-1);return e<"Z"?n.push(eS):n.pop(),e+n.join("")}return t+n.join("")}(e);if(null==r)throw Error("cannot decrement any more");return r}if(null==t){let t=ek(e),n=e.slice(t.length),r=eI(t);return null==r?t+eE(n,null):r}let n=ek(e),r=e.slice(n.length),i=ek(t),o=t.slice(i.length);if(n===i)return n+eE(r,o);let s=eI(n);if(null==s)throw Error("cannot increment any more");return s<t?s:n+eE(r,null)}let eM=function(e,t,n){if(0===n)return[];null!=e&&eT(e),null!=t&&eT(t);let r=function e(t,n,r){if(0===r)return[];if(1===r)return[e_(t,n)];if(null==n){let e=e_(t,n),i=[e];for(let t=0;t<r-1;t++)i.push(e=e_(e,n));return i}if(null==t){let e=e_(t,n),i=[e];for(let n=0;n<r-1;n++)i.push(e=e_(t,e));return i.reverse(),i}let i=Math.floor(r/2),o=e_(t,n);return[...e(t,o,i),o,...e(o,n,r-i-1)]}(e,t,n+1),i=Array(n);for(let e=0;e<n;e++)i[e]=function(e,t){let n=e_(e,t);for(let r=0;r<16;r++).5>Math.random()?e=n:t=n,n=e_(e,t);return n}(r[e],r[e+1]);return i},eA="a0";function ej(e){try{eT(e)}catch{throw Error("invalid index: "+e)}}function eO(e,t,n){return eM(e??null,t??null,n)}function eD(e,t){return eM(e??null,null,t)}function eL(e,t){return eM(e??null,t??null,1)[0]}function eF(e=null){return eM(e,null,1)[0]}function eR(e=null){return eM(null,e,1)[0]}function ez(e,t="a1"){return[t,...eM(t,null,e)]}function eN(e,t){return e.index<t.index?-1:+(e.index>t.index)}function e$(e,t){return e.id>t.id?1:-1}function eB(e){try{return localStorage.getItem(e)}catch{return null}}function eH(e,t){try{localStorage.setItem(e,t)}catch{}}function eU(){try{localStorage.clear()}catch{}}function eW(e){try{return sessionStorage.getItem(e)}catch{return null}}function eK(e,t){try{sessionStorage.setItem(e,t)}catch{}}function eV(e){try{sessionStorage.removeItem(e)}catch{}}function eY(){try{sessionStorage.clear()}catch{}}function eG(e){if(!e)return"";for(let{segment:t}of(o??=new Intl.Segmenter(void 0,{granularity:"grapheme"})).segment(e))return t;return""}var eq=n(41463);let eX=()=>void 0!==eq&&!1,eJ=e=>.9*Math.floor(1e3/e);class eZ{targetFps;targetTimePerFrame;fpsQueue=[];frameRaf;flushRaf;lastFlushTime;constructor(e=120){this.targetFps=e,this.targetTimePerFrame=eJ(e),this.lastFlushTime=-this.targetTimePerFrame}updateTargetFps(e){e!==this.targetFps&&(this.targetFps=e,this.targetTimePerFrame=eJ(e),this.lastFlushTime=-this.targetTimePerFrame)}flush(){for(let e of this.fpsQueue.splice(0,this.fpsQueue.length))e()}tick(e=!1){if(this.frameRaf)return;let t=Date.now();if(t-this.lastFlushTime<this.targetTimePerFrame){this.frameRaf=requestAnimationFrame(()=>{this.frameRaf=void 0,this.tick(!0)});return}if(e){if(this.flushRaf)return;this.lastFlushTime=t,this.flush()}else{if(this.flushRaf)return;this.flushRaf=requestAnimationFrame(()=>{this.flushRaf=void 0,this.lastFlushTime=Date.now(),this.flush()})}}fpsThrottle(e){if(eX())return e.cancel=()=>{this.frameRaf&&(cancelAnimationFrame(this.frameRaf),this.frameRaf=void 0),this.flushRaf&&(cancelAnimationFrame(this.flushRaf),this.flushRaf=void 0)},e;let t=()=>{this.fpsQueue.includes(e)||(this.fpsQueue.push(e),this.tick())};return t.cancel=()=>{let t=this.fpsQueue.indexOf(e);t>-1&&this.fpsQueue.splice(t,1)},t}throttleToNextFrame(e){return eX()?(e(),()=>void 0):(this.fpsQueue.includes(e)||(this.fpsQueue.push(e),this.tick()),()=>{let t=this.fpsQueue.indexOf(e);t>-1&&this.fpsQueue.splice(t,1)})}}let eQ=new eZ(120);function e0(e){return eQ.throttleToNextFrame(e)}class e1{timeouts=new Map;intervals=new Map;rafs=new Map;constructor(){this.setTimeout=this.setTimeout.bind(this),this.setInterval=this.setInterval.bind(this),this.requestAnimationFrame=this.requestAnimationFrame.bind(this),this.dispose=this.dispose.bind(this)}setTimeout(e,t,n,...r){let i=window.setTimeout(t,n,r),o=this.timeouts.get(e)??[];return this.timeouts.set(e,[...o,i]),i}setInterval(e,t,n,...r){let i=window.setInterval(t,n,r),o=this.intervals.get(e)??[];return this.intervals.set(e,[...o,i]),i}requestAnimationFrame(e,t){let n=window.requestAnimationFrame(t),r=this.rafs.get(e)??[];return this.rafs.set(e,[...r,n]),n}dispose(e){this.timeouts.get(e)?.forEach(e=>clearTimeout(e)),this.intervals.get(e)?.forEach(e=>clearInterval(e)),this.rafs.get(e)?.forEach(e=>cancelAnimationFrame(e)),this.timeouts.delete(e),this.intervals.delete(e),this.rafs.delete(e)}disposeAll(){for(let e of this.timeouts.keys())this.dispose(e)}forContext(e){return{setTimeout:(t,n,...r)=>this.setTimeout(e,t,n,r),setInterval:(t,n,...r)=>this.setInterval(e,t,n,r),requestAnimationFrame:t=>this.requestAnimationFrame(e,t),dispose:()=>this.dispose(e)}}}function e2(e,t){try{return new URL(e,t)}catch{return}}function e3(e){return void 0!==e}let e5="u">typeof globalThis&&globalThis.structuredClone?[globalThis.structuredClone,!0]:"u">typeof global&&global.structuredClone?[global.structuredClone,!0]:"u">typeof window&&window.structuredClone?[window.structuredClone,!0]:[e=>e?JSON.parse(JSON.stringify(e)):e,!1],e6=e5[0];e5[1];let e4=Object.getPrototypeOf(e6({})),e8=new Set;function e9(e){e8.has(e)||(e8.add(e),console.warn(`[tldraw] ${e}`))}a("@tldraw/utils","5.3.2","esm")},26065:(e,t,n)=>{"use strict";n.d(t,{R:()=>l,n:()=>a});var r=n(95155),i=n(12115),o=n(16038);let s=(0,i.createContext)(null);function a({children:e}){let t=(0,i.useRef)(new Map),n=(0,i.useCallback)((e,n,r,i)=>{let s=i?"none":"block";(0,o.$h)(n,"display",s),(0,o.$h)(r,"display",s),t.current.set(e,{container:n,bgContainer:r,isCulled:i})},[]),l=(0,i.useCallback)(e=>{t.current.delete(e)},[]),d=(0,i.useCallback)(e=>{let n;for(let[r,i]of t.current)if((n=e.has(r))!==i.isCulled){let e=n?"none":"block";(0,o.$h)(i.container,"display",e),(0,o.$h)(i.bgContainer,"display",e),i.isCulled=n}},[]),c=(0,i.useMemo)(()=>({register:n,unregister:l,updateCulling:d}),[n,l,d]);return(0,r.jsx)(s.Provider,{value:c,children:e})}function l(){let e=(0,i.useContext)(s);if(!e)throw Error("useShapeCulling must be used within ShapeCullingProvider");return e}},26614:(e,t,n)=>{"use strict";n.d(t,{i:()=>i});var r=n(83102);class i{constructor(e){this.editor=e}editor;static configure(e){return class extends this{options={...this.options,...e}}}options={};static props;static migrations;static type;static handledAssetTypes;indicator(e){return null}getFontFaces(e){return r.Ml}canSnap(e){return!0}canTabTo(e){return!0}canScroll(e){return!1}canBind(e){return!0}canEdit(e,t){return!1}canResize(e){return!0}canResizeChildren(e){return!0}canEditInReadonly(e){return!1}canEditWhileLocked(e){return!1}canCrop(e){return!1}canBeLaidOut(e,t){return!0}canCull(e){return!0}providesBackgroundForChildren(e){return!1}hideResizeHandles(e){return!1}hideRotateHandle(e){return!1}hideSelectionBoundsBg(e){return!1}hideSelectionBoundsFg(e){return!1}isAspectRatioLocked(e){return!1}isFrameLike(e){return!1}isExportBoundsContainer(e){return!1}canReceiveNewChildrenOfType(e,t){return!1}canRemoveChildrenOfType(e,t){return!0}expandSelectionOutlinePx(e){return 0}getCanvasSvgDefs(){return[]}getBoundsSnapGeometry(e){return{}}getHandleSnapGeometry(e){return{}}getText(e){}getReferencedUserIds(e){return r.Ml}getAriaDescriptor(e){}}},27050:(e,t,n)=>{"use strict";function r(e){this.content=e}function i(e){return e>=56320&&e<57344}function o(e){return e>=55296&&e<56320}n.d(t,{S4:()=>H,ZF:()=>J,FK:()=>s,CU:()=>c,sX:()=>N,bP:()=>P,u$:()=>C,vI:()=>u,Sj:()=>$,Ji:()=>h}),r.prototype={constructor:r,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return -1},get:function(e){var t=this.find(e);return -1==t?void 0:this.content[t+1]},update:function(e,t,n){var i=n&&n!=e?this.remove(n):this,o=i.find(e),s=i.content.slice();return -1==o?s.push(n||e,t):(s[o+1]=t,n&&(s[o]=n)),new r(s)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new r(n)},addToStart:function(e,t){return new r([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new r(n)},addBefore:function(e,t,n){var i=this.remove(t),o=i.content.slice(),s=i.find(e);return o.splice(-1==s?o.length:s,0,t,n),new r(o)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=r.from(e)).size?new r(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=r.from(e)).size?new r(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=r.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},r.from=function(e){if(e instanceof r)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new r(t)};class s{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let o=0,s=0;s<t;o++){let a=this.content[o],l=s+a.nodeSize;if(l>e&&!1!==n(a,r+s,i||null,o)&&a.content.size){let i=s+1;a.nodesBetween(Math.max(0,e-i),Math.min(a.content.size,t-i),n,r+i)}s=l}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i="",o=!0;return this.nodesBetween(e,t,(s,a)=>{let l=s.isText?s.text.slice(Math.max(e,a)-a,t-a):s.isLeaf?r?"function"==typeof r?r(s):r:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&l||s.isTextblock)&&n&&(o?o=!1:i+=n),i+=l},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,r=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(n)&&(r[r.length-1]=t.withText(t.text+n.text),i=1);i<e.content.length;i++)r.push(e.content[i]);return new s(r,this.size+e.size)}cut(e,t=this.size){if(0==e&&t==this.size)return this;let n=[],r=0;if(t>e)for(let i=0,o=0;o<t;i++){let s=this.content[i],a=o+s.nodeSize;a>e&&((o<e||a>t)&&(s=s.isText?s.cut(Math.max(0,e-o),Math.min(s.text.length,t-o)):s.cut(Math.max(0,e-o-1),Math.min(s.content.size,t-o-1))),n.push(s),r+=s.nodeSize),o=a}return new s(n,r)}cutByIndex(e,t){return e==t?s.empty:0==e&&t==this.content.length?this:new s(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let r=this.content.slice(),i=this.size+t.nodeSize-n.nodeSize;return r[e]=t,new s(r,i)}addToStart(e){return new s([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new s(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return function e(t,n,r){for(let s=0;;s++){if(s==t.childCount||s==n.childCount)return t.childCount==n.childCount?null:r;let a=t.child(s),l=n.child(s);if(a==l){r+=a.nodeSize;continue}if(!a.sameMarkup(l))return r;if(a.isText&&a.text!=l.text){let e=a.text,t=l.text,n=0;for(;e[n]==t[n];n++)r++;return n&&n<e.length&&n<t.length&&o(e.charCodeAt(n-1))&&i(e.charCodeAt(n))&&r--,r}if(a.content.size||l.content.size){let t=e(a.content,l.content,r+1);if(null!=t)return t}r+=a.nodeSize}}(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return function e(t,n,r,s){for(let a=t.childCount,l=n.childCount;;){if(0==a||0==l)return a==l?null:{a:r,b:s};let d=t.child(--a),c=n.child(--l),u=d.nodeSize;if(d==c){r-=u,s-=u;continue}if(!d.sameMarkup(c))return{a:r,b:s};if(d.isText&&d.text!=c.text){let e=d.text,t=c.text,n=e.length,a=t.length;for(;n>0&&a>0&&e[n-1]==t[a-1];)n--,a--,r--,s--;return n&&a&&n<e.length&&o(e.charCodeAt(n-1))&&i(e.charCodeAt(n))&&(r++,s++),{a:r,b:s}}if(d.content.size||c.content.size){let t=e(d.content,c.content,r-1,s-1);if(t)return t}r-=u,s-=u}}(this,e,t,n)}findIndex(e){if(0==e)return l(0,e);if(e==this.size)return l(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=n+this.child(t).nodeSize;if(r>=e){if(r==e)return l(t+1,r);return l(t,n)}n=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return s.empty;if(!Array.isArray(t))throw RangeError("Invalid input for Fragment.fromJSON");return s.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return s.empty;let t,n=0;for(let r=0;r<e.length;r++){let i=e[r];n+=i.nodeSize,r&&i.isText&&e[r-1].sameMarkup(i)?(t||(t=e.slice(0,r)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new s(t||e,n)}static from(e){if(!e)return s.empty;if(e instanceof s)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new s([e],e.nodeSize);throw RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}s.empty=new s([],0);let a={index:0,offset:0};function l(e,t){return a.index=e,a.offset=t,a}function d(e,t){if(e===t)return!0;if(!(e&&"object"==typeof e)||!(t&&"object"==typeof t))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!d(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!d(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class c{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,r));else{if(i.type.excludes(this.type))return e;!n&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(i)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&d(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return c.none;if(e instanceof c)return[e];let t=e.slice();return t.sort((e,t)=>e.type.rank-t.type.rank),t}}c.none=[];class u extends Error{}class h{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=function e(t,n,r,i,o,s){let{index:a,offset:l}=t.findIndex(n),d=t.maybeChild(a);if(l==n||d.isText)return s&&i<=0&&o<=0&&!s.canReplace(a,a,r)?null:t.cut(0,n).append(r).append(t.cut(n));let c=e(d.content,n-l-1,r,0==a?i-1:0,a==t.childCount-1?o-1:0,d);return c&&t.replaceChild(a,d.copy(c))}(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return n&&new h(n,this.openStart,this.openEnd)}removeBetween(e,t){return new h(function e(t,n,r){let{index:i,offset:o}=t.findIndex(n),s=t.maybeChild(i),{index:a,offset:l}=t.findIndex(r);if(o==n||s.isText){if(l!=r&&!t.child(a).isText)throw RangeError("Removing non-flat range");return t.cut(0,n).append(t.cut(r))}if(i!=a)throw RangeError("Removing non-flat range");return t.replaceChild(i,s.copy(e(s.content,n-o-1,r-o-1)))}(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return h.empty;let n=t.openStart||0,r=t.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw RangeError("Invalid input for Slice.fromJSON");return new h(s.fromJSON(e,t.content),n,r)}static maxOpen(e,t=!0){let n=0,r=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)r++;return new h(e,n,r)}}function p(e,t){if(!t.type.compatibleContent(e.type))throw new u("Cannot join "+t.type.name+" onto "+e.type.name)}function f(e,t,n){let r=e.node(n);return p(r,t.node(n)),r}function g(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function m(e,t,n,r){let i=(t||e).node(n),o=0,s=t?t.index(n):i.childCount;e&&(o=e.index(n),e.depth>n?o++:e.textOffset&&(g(e.nodeAfter,r),o++));for(let e=o;e<s;e++)g(i.child(e),r);t&&t.depth==n&&t.textOffset&&g(t.nodeBefore,r)}function y(e,t){if(!e.type.validContent(t))throw new u("Invalid content for node "+e.type.name);return e.copy(t)}function b(e,t,n){let r=[];return m(null,e,n,r),e.depth>n&&g(y(f(e,t,n+1),b(e,t,n+1)),r),m(t,null,n,r),new s(r)}h.empty=new h(s.empty,0,0);class x{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],r=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return c.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var o=0;o<i.length;o++)!1!==i[o].type.spec.inclusive||r&&i[o].isInSet(r.marks)||(i=i[o--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)!1!==n[i].type.spec.inclusive||r&&n[i].isInSet(r.marks)||(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new C(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw RangeError("Position "+t+" out of range");let n=[],r=0,i=t;for(let t=e;;){let{index:e,offset:o}=t.content.findIndex(i),s=i-o;if(n.push(t,e,r+o),!s||(t=t.child(e)).isText)break;i=s-1,r+=o+1}return new x(t,n,i)}static resolveCached(e,t){let n=S.get(e);if(n)for(let e=0;e<n.elts.length;e++){let r=n.elts[e];if(r.pos==t)return r}else S.set(e,n=new w);let r=n.elts[n.i]=x.resolve(e,t);return n.i=(n.i+1)%v,r}}class w{constructor(){this.elts=[],this.i=0}}let v=12,S=new WeakMap;class C{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}let k=Object.create(null);class P{constructor(e,t,n,r=c.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||s.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&d(this.attrs,t||e.defaultAttrs||k)&&c.sameSet(this.marks,n||c.none)}copy(e=null){return e==this.content?this:new P(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new P(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return h.empty;let r=this.resolve(e),i=this.resolve(t),o=n?0:r.sharedDepth(t),s=r.start(o);return new h(r.node(o).content.cut(r.pos-s,i.pos-s),r.depth-o,i.depth-o)}replace(e,t,n){var r=this.resolve(e),i=this.resolve(t);if(n.openStart>r.depth)throw new u("Inserted content deeper than insertion position");if(r.depth-n.openStart!=i.depth-n.openEnd)throw new u("Inconsistent open depths");return function e(t,n,r,i){let o=t.index(i),a=t.node(i);if(o==n.index(i)&&i<t.depth-r.openStart){let s=e(t,n,r,i+1);return a.copy(a.content.replaceChild(o,s))}if(!r.content.size)return y(a,b(t,n,i));if(r.openStart||r.openEnd||t.depth!=i||n.depth!=i){let{start:e,end:o}=function(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(s.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(r,t);return y(a,function e(t,n,r,i,o){let a=t.depth>o&&f(t,n,o+1),l=i.depth>o&&f(r,i,o+1),d=[];return m(null,t,o,d),a&&l&&n.index(o)==r.index(o)?(p(a,l),g(y(a,e(t,n,r,i,o+1)),d)):(a&&g(y(a,b(t,n,o+1)),d),m(n,r,o,d),l&&g(y(l,b(r,i,o+1)),d)),m(i,null,o,d),new s(d)}(t,e,o,n,i))}{let e=t.parent,i=e.content;return y(e,i.cut(0,t.parentOffset).append(r.content).append(i.cut(n.parentOffset)))}}(r,i,n,0)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(!(t=t.maybeChild(n)))return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return x.resolveCached(this,e)}resolveNoCache(e){return x.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),E(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=s.empty,r=0,i=n.childCount){let o=this.contentMatchAt(e).matchFragment(n,r,i),a=o&&o.matchFragment(this.content,t);if(!a||!a.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),o=i&&i.matchFragment(this.content,t);return!!o&&o.validEnd}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=c.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!c.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){let n;if(!t)throw RangeError("Invalid input for Node.fromJSON");if(t.marks){if(!Array.isArray(t.marks))throw RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw RangeError("Invalid text node in JSON");return e.text(t.text,n)}let r=s.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}}P.prototype.text=void 0;class T extends P{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):E(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new T(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new T(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function E(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class I{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){var n;let r,i=new _(e,t);if(null==i.next)return I.empty;let o=function e(t){let n=[];do n.push(function(t){let n=[];do n.push(function(t){let n=function(t){if(t.eat("(")){let n=e(t);return t.eat(")")||t.err("Missing closing paren"),n}if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=(function(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return 0==i.length&&e.err("No node type or group '"+t+"' found"),i})(t,t.next).map(e=>(null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e}));return t.pos++,1==e.length?e[0]:{type:"choice",exprs:e}}}(t);for(;;)if(t.eat("+"))n={type:"plus",expr:n};else if(t.eat("*"))n={type:"star",expr:n};else if(t.eat("?"))n={type:"opt",expr:n};else if(t.eat("{"))n=function(e,t){let n=M(e),r=n;return e.eat(",")&&(r="}"!=e.next?M(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}(t,n);else break;return n}(t));while(t.next&&")"!=t.next&&"|"!=t.next);return 1==n.length?n[0]:{type:"seq",exprs:n}}(t));while(t.eat("|"));return 1==n.length?n[0]:{type:"choice",exprs:n}}(i);i.next&&i.err("Unexpected trailing text");let s=(n=function(e){let t=[[]];return i(function e(t,o){if("choice"==t.type)return t.exprs.reduce((t,n)=>t.concat(e(n,o)),[]);if("seq"==t.type)for(let r=0;;r++){let s=e(t.exprs[r],o);if(r==t.exprs.length-1)return s;i(s,o=n())}else if("star"==t.type){let s=n();return r(o,s),i(e(t.expr,s),s),[r(s)]}else if("plus"==t.type){let s=n();return i(e(t.expr,o),s),i(e(t.expr,s),s),[r(s)]}else if("opt"==t.type)return[r(o)].concat(e(t.expr,o));else if("range"==t.type){let s=o;for(let r=0;r<t.min;r++){let r=n();i(e(t.expr,s),r),s=r}if(-1==t.max)i(e(t.expr,s),s);else for(let o=t.min;o<t.max;o++){let o=n();r(s,o),i(e(t.expr,s),o),s=o}return[r(s)]}else if("name"==t.type)return[r(o,void 0,t.value)];else throw Error("Unknown expr type")}(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}}(o),r=Object.create(null),function e(t){let i=[];t.forEach(e=>{n[e].forEach(({term:e,to:t})=>{let r;if(e){for(let t=0;t<i.length;t++)i[t][0]==e&&(r=i[t][1]);j(n,t).forEach(t=>{r||i.push([e,r=[]]),-1==r.indexOf(t)&&r.push(t)})}})});let o=r[t.join(",")]=new I(t.indexOf(n.length-1)>-1);for(let t=0;t<i.length;t++){let n=i[t][1].sort(A);o.next.push({type:i[t][0],next:r[n.join(",")]||e(n)})}return o}(j(n,0)));return function(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,o=[];for(let t=0;t<e.next.length;t++){let{type:n,next:s}=e.next[t];o.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),-1==r.indexOf(s)&&r.push(s)}i&&t.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(s,i),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];return function i(o,a){let l=o.matchFragment(e,n);if(l&&(!t||l.validEnd))return s.from(a.map(e=>e.createAndFill()));for(let e=0;e<o.next.length;e++){let{type:t,next:n}=o.next[e];if(!(t.isText||t.hasRequiredAttrs())&&-1==r.indexOf(n)){r.push(n);let e=i(n,a.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:o,next:s}=i.next[e];o.isLeaf||o.hasRequiredAttrs()||o.name in t||r.type&&!s.validEnd||(n.push({match:o.contentMatch,type:o,via:r}),t[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return!function t(n){e.push(n);for(let r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map((t,n)=>{let r=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)r+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return r}).join("\n")}}I.empty=new I(!0);class _{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+" (in content expression '"+this.string+"')")}}function M(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function A(e,t){return t-e}function j(e,t){let n=[];return function t(r){let i=e[r];if(1==i.length&&!i[0].term)return t(i[0].to);n.push(r);for(let e=0;e<i.length;e++){let{term:r,to:o}=i[e];r||-1!=n.indexOf(o)||t(o)}}(t),n.sort(A)}function O(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function D(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(void 0===i){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function L(e,t,n,r){for(let i in t)if(!(i in e))throw RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let n in e)e[n].validate&&e[n].validate(t[n])}function F(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new z(e,r,t[r]);return n}class R{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=F(e,n.attrs),this.defaultAttrs=O(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==I.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:D(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error("NodeType.create can't construct text nodes");return new P(this,this.computeAttrs(e),s.from(t),c.setFrom(n))}createChecked(e=null,t,n){return t=s.from(t),this.checkContent(t),new P(this,this.computeAttrs(e),t,c.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=s.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(s.empty,!0);return i?new P(this,e,t.append(i),c.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){L(this.attrs,e,"node",this.name)}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){let t;if(null==this.markSet)return e;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:c.none:e}static compile(e,t){let n=Object.create(null);e.forEach((e,r)=>n[e]=new R(e,t,r));let r=t.spec.topNode||"doc";if(!n[r])throw RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw RangeError("The text node type should not have attributes");return n}}class z{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(e,t,n){let r=n.split("|");return n=>{let i=null===n?"null":typeof n;if(0>r.indexOf(i))throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class N{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=F(e,r.attrs),this.excluded=null;let i=O(this.attrs);this.instance=i?new c(this,i):null}create(e=null){return!e&&this.instance?this.instance:new c(this,D(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach((e,i)=>n[e]=new N(e,r++,t,i)),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){L(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class ${constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=r.from(e.nodes),t.marks=r.from(e.marks||{}),this.nodes=R.compile(this.spec.nodes,this),this.marks=N.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+" can not be both a node and a mark");let t=this.nodes[e],r=t.spec.content||"",i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=I.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError("Multiple linebreak nodes defined");if(!t.isInline||!t.isLeaf)throw RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=t}t.markSet="_"==i?null:i?B(this,i.split(" ")):""!=i&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:B(this,n.split(" "))}this.nodeFromJSON=e=>P.fromJSON(this,e),this.markFromJSON=e=>c.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if("string"==typeof e)e=this.nodeType(e);else if(e instanceof R){if(e.schema!=this)throw RangeError("Node type from different schema used ("+e.name+")")}else throw RangeError("Invalid node type: "+e);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new T(n,n.defaultAttrs,e,c.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError("Unknown node type: "+e);return t}}function B(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],o=e.marks[i],s=o;if(o)n.push(o);else for(let t in e.marks){let r=e.marks[t];("_"==i||r.spec.group&&r.spec.group.split(" ").indexOf(i)>-1)&&n.push(s=r)}if(!s)throw SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}class H{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(null!=e.tag)this.tags.push(e);else if(null!=e.style){let t=/[^=]*/.exec(e.style)[0];0>n.indexOf(t)&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new G(this,t,!1);return n.addAll(e,c.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new G(this,t,!0);return n.addAll(e,c.none,t.from,t.to),h.maxOpen(n.finish())}matchTag(e,t,n){for(let o=n?this.tags.indexOf(n)+1:0;o<this.tags.length;o++){var r,i;let n=this.tags[o];if(r=e,i=n.tag,(r.matches||r.msMatchesSelector||r.webkitMatchesSelector||r.mozMatchesSelector).call(r,i)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],o=r.style;if(0==o.indexOf(e)&&(!r.context||n.matchesContext(r.context))&&(!(o.length>e.length)||61==o.charCodeAt(e.length)&&o.slice(e.length+1)==t)){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((null==e.priority?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=q(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=q(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new H(e,H.schemaRules(e)))}}let U={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},W={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},K={ol:!0,ul:!0};function V(e,t,n){return null!=t?!!t|2*("full"===t):e&&"pre"==e.whitespace?3:-5&n}class Y{constructor(e,t,n,r,i,o){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=o,this.content=[],this.activeMarks=c.none,this.match=i||(4&o?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(s.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e=this.content[this.content.length-1],t;e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))&&(e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=e.withText(e.text.slice(0,e.text.length-t[0].length)))}let t=s.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(s.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!U.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class G{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,o=V(null,t.preserveWhitespace,0)|4*!!n;i=r?new Y(r.type,r.attrs,c.none,!0,t.topMatch||r.type.contentMatch,o):n?new Y(null,null,c.none,!0,null,o):new Y(e.schema.topNodeType,null,c.none,!0,null,o),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=2&r.options?"full":this.localPreserveWS||(1&r.options)>0,{schema:o}=this.parser;if("full"===i||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(i)if("full"===i)n=n.replace(/\r\n?/g,"\n");else if(o.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(o.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(o.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(o.text(e[n]),t,!/\S/.test(e[n]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&"BR"==i.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}n&&this.insertNode(o.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),s;K.hasOwnProperty(o)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&K.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(s=this.parser.matchTag(e,this,n));i:if(a?a.ignore:W.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let n,r=this.needsBlock;if(U.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break i}let s=a&&a.skip?t:this.readStyles(e,t);s&&this.addAll(e,s),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,a,n,!1===a.consuming?s:void 0)}this.localPreserveWS=r}leafFallback(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}ignoreFallback(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1===n.consuming)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,o;if(t.node)if((o=this.parser.schema.nodes[t.node]).isLeaf)this.insertNode(o.create(t.attrs),n,"BR"==e.nodeName)||this.leafFallback(e,n);else{let e=this.enter(o,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let s=this.top;if(o&&o.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;"string"==typeof t.contentElement?r=e.querySelector(t.contentElement):"function"==typeof t.contentElement?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(s)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let o=n?e.childNodes[n]:e.firstChild,s=null==r?null:e.childNodes[r];o!=s;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,o=0;t>=0;t--){let s=this.nodes[t],a=s.findWrapping(e);if(a&&(!r||r.length>a.length+o)&&(r=a,i=s,!a.length))break;if(s.solid){if(n)break;o+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let n=c.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):X(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&(i=this.enterInner(e,t,n,!0,r)),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let s=V(e,i,o.options);4&o.options&&0==o.content.length&&(s|=4);let a=c.none;return n=n.filter(t=>(o.type?!o.type.allowsMarkType(t.type):!X(t.type,e))||(a=t.addToSet(a),!1)),this.nodes.push(new Y(e,t,a,r,null,s)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=1);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,o=(e,s)=>{for(;e>=0;e--){let a=t[e];if(""==a){if(e==t.length-1||0==e)continue;for(;s>=i;s--)if(o(e-1,s))return!0;return!1}{let e=s>0||0==s&&r?this.nodes[s].type:n&&s>=i?n.node(s-i).type:null;if(!e||e.name!=a&&!e.isInGroup(a))return!1;s--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}}function q(e){let t={};for(let n in e)t[n]=e[n];return t}function X(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let o=[],s=e=>{o.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||0>o.indexOf(i)&&s(i))return!0}};if(s(i.contentMatch))return!0}}class J{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=Q(t).createDocumentFragment());let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,o=0;for(;n<i.length&&o<e.marks.length;){let t=e.marks[o];if(!this.marks[t.type.name]){o++;continue}if(!t.eq(i[n][0])||!1===t.type.spec.spanning)break;n++,o++}for(;n<i.length;)r=i.pop()[1];for(;o<e.marks.length;){let n=e.marks[o++],s=this.serializeMark(n,e.isInline,t);s&&(i.push([n,r]),r.appendChild(s.dom),r=s.contentDOM||s.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return Q(t).createTextNode(e.text);let{dom:n,contentDOM:r}=et(Q(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&et(Q(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return"string"==typeof t?{dom:e.createTextNode(t)}:et(e,t,n,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new J(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Z(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return Z(e.marks)}}function Z(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Q(e){return e.document||window.document}let ee=new WeakMap;function et(e,t,n,r){let i,o,s;if(1==t.nodeType)return{dom:t};if(t.dom&&1==t.dom.nodeType)return t;let a=t[0],l;if("string"!=typeof a)throw RangeError("Invalid array passed to renderSpec");if(r&&(void 0===(o=ee.get(r))&&ee.set(r,(s=null,!function e(t){if(t&&"object"==typeof t)if(Array.isArray(t))if("string"==typeof t[0])s||(s=[]),s.push(t);else for(let n=0;n<t.length;n++)e(t[n]);else for(let n in t)e(t[n])}(r),o=s)),l=o)&&l.indexOf(t)>-1)throw RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let d=a.indexOf(" ");d>0&&(n=a.slice(0,d),a=a.slice(d+1));let c=n?e.createElementNS(n,a):e.createElement(a),u=t[1],h=1;if(u&&"object"==typeof u&&null==u.nodeType&&!Array.isArray(u)){for(let e in h=2,u)if(null!=u[e]){let t=e.indexOf(" ");t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),u[e]):"style"==e&&c.style?c.style.cssText=u[e]:c.setAttribute(e,u[e])}}for(let o=h;o<t.length;o++){let s=t[o];if(0===s){if(o<t.length-1||o>h)throw RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}if("string"==typeof s)c.appendChild(e.createTextNode(s));else{let{dom:t,contentDOM:o}=et(e,s,n,r);if(c.appendChild(t),o){if(i)throw RangeError("Multiple content holes");i=o}}}return{dom:c,contentDOM:i}}},27164:(e,t,n)=>{"use strict";n.d(t,{MI:()=>d,vq:()=>c});var r=n(24167),i=n(59830),o=n(81962),s=n(54939),a=n(93286),l=n(46195);let d={EXCLUDE_NON_STANDARD:{includeLabels:!1,includeInternal:!1},INCLUDE_ALL:{includeLabels:!0,includeInternal:!0},EXCLUDE_LABELS:{includeLabels:!1,includeInternal:!0},EXCLUDE_INTERNAL:{includeLabels:!0,includeInternal:!1}};class c{isFilled=!1;isClosed=!0;isLabel=!1;isEmptyLabel=!1;isInternal=!1;excludeFromShapeBounds=!1;debugColor;ignore;constructor(e){const{isLabel:t=!1,isEmptyLabel:n=!1,isInternal:r=!1,excludeFromShapeBounds:i=!1}=e;this.isFilled=e.isFilled,this.isClosed=e.isClosed,this.debugColor=e.debugColor,this.ignore=e.ignore,this.isLabel=t,this.isEmptyLabel=n,this.isInternal=r,this.excludeFromShapeBounds=i}isExcludedByFilter(e){return!!e&&(!!this.isLabel&&!e.includeLabels||!!this.isInternal&&!e.includeInternal)}hitTestPoint(e,t=0,n=!1,r){return!!(this.isClosed&&(this.isFilled||n)&&(0,a.s3)(e,this.vertices))||l.l.Dist2(e,this.nearestPoint(e))<=t*t}distanceToPoint(e,t=!1,n){return l.l.Dist(e,this.nearestPoint(e,n))*(this.isClosed&&(this.isFilled||t)&&(0,a.s3)(e,this.vertices)?-1:1)}distanceToLineSegment(e,t,n){let r,i,s,d;if(l.l.Equals(e,t))return this.distanceToPoint(e,!1,n);let{vertices:c}=this;if(0===c.length)throw Error("nearest point not found");if(1===c.length)return l.l.Dist(e,c[0]);let u=1/0,h=this.isClosed?c.length:c.length-1;for(let n=0;n<c.length;n++){if(s=c[n],n<h){let r=c[(n+1)%c.length];if((0,o.HV)(e,t,s,r))return 0}d=l.l.NearestPointOnLineSegment(e,t,s,!0),(i=l.l.Dist2(s,d))<u&&(u=i,r=d)}if(!r)throw Error("nearest point not found");return u=Math.sqrt(u),this.isClosed&&this.isFilled&&(0,a.s3)(r,this.vertices)?-u:u}hitTestLineSegment(e,t,n=0,r){return this.distanceToLineSegment(e,t,r)<=n}intersectLineSegment(e,t,n){return(this.isClosed?(0,o.lq)(e,t,this.vertices):(0,o.NC)(e,t,this.vertices))??[]}intersectCircle(e,t,n){return(this.isClosed?(0,o.SU)(e,t,this.vertices):(0,o.y5)(e,t,this.vertices))??[]}intersectPolygon(e,t){return(0,o.B8)(e,this.vertices,!0,this.isClosed)}intersectPolyline(e,t){return(0,o.B8)(e,this.vertices,!1,this.isClosed)}interpolateAlongEdge(e,t){let{vertices:n}=this;if(0===n.length)return new l.l(0,0);if(1===n.length||e<=0)return n[0];let i=e*this.length,o=0;for(let e=0;e<(this.isClosed?n.length:n.length-1);e++){let t=n[e],s=n[(e+1)%n.length],a=l.l.Dist(t,s),d=o+a;if(d>=i){if(0===a)return t;return l.l.Lrp(t,s,(0,r.Fg)(o,d,i))}o=d}return this.isClosed?n[0]:n[n.length-1]}uninterpolateAlongEdge(e,t){let{vertices:n,length:i}=this,o=null,s=1/0,a=0;if(0===n.length||1===n.length)return 0;for(let t=0;t<(this.isClosed?n.length:n.length-1);t++){let r=n[t],i=n[(t+1)%n.length],d=l.l.NearestPointOnLineSegment(r,i,e,!0),c=l.l.Dist(d,e);c<s&&(s=c,o={start:r,end:i,nearestPoint:d,distanceToStart:a}),a+=l.l.Dist(r,i)}(0,r.vA)(o);let d=o.distanceToStart+l.l.Dist(o.start,o.nearestPoint);return 0===i?0:d/i}isPointInBounds(e,t=0){let{bounds:n}=this;return!(e.x<n.minX-t||e.y<n.minY-t||e.x>n.maxX+t||e.y>n.maxY+t)}overlapsPolygon(e){let t=e.map(e=>l.l.From(e)),{vertices:n,center:r,isFilled:i,isEmptyLabel:s,isClosed:d}=this;if(s)return!1;if(n.some(e=>(0,a.s3)(e,t)))return!0;if(d){if(i&&((0,a.s3)(r,t)||t.every(e=>(0,a.s3)(e,n)))||(0,o.Rx)(t,n))return!0}else if((0,o.j0)(t,n))return!0;return!1}transform(e,t){return new u(this,e,t)}_vertices;get vertices(){return this._vertices||(this._vertices=this.getVertices(d.EXCLUDE_LABELS)),this._vertices}getBoundsVertices(){return this.excludeFromShapeBounds?[]:this.vertices}_boundsVertices;get boundsVertices(){return this._boundsVertices||(this._boundsVertices=this.getBoundsVertices()),this._boundsVertices}getBounds(){return i.az.FromPoints(this.boundsVertices)}_bounds;get bounds(){return this._bounds||(this._bounds=this.getBounds()),this._bounds}get center(){return this.bounds.center}_area;get area(){return this._area||(this._area=this.getArea()),this._area}getArea(){if(!this.isClosed)return 0;let{vertices:e}=this,t=0;for(let n=0,r=e.length;n<r;n++){let i=e[n],o=e[(n+1)%r];t+=i.x*o.y-o.x*i.y}return t/2}toSimpleSvgPath(){let e="",{vertices:t}=this,n=t.length;if(0===n)return e;e+=`M${t[0].x},${t[0].y}`;for(let r=1;r<n;r++)e+=`L${t[r].x},${t[r].y}`;return this.isClosed&&(e+="Z"),e}_length;get length(){return this._length||(this._length=this.getLength(d.EXCLUDE_LABELS)),this._length}getLength(e){let t=this.getVertices(e??d.EXCLUDE_LABELS);if(0===t.length)return 0;let n=t[0],r=0;for(let e=1;e<t.length;e++){let i=t[e];r+=l.l.Dist(n,i),n=i}return this.isClosed&&(r+=l.l.Dist(t[t.length-1],t[0])),r}ignoreHit(e){return!1}}class u extends c{constructor(e,t,n){super(e),this.geometry=e,this.matrix=t,this.inverse=s.V.Inverse(t),this.decomposed=s.V.Decompose(t),n&&(null!=n.isLabel&&(this.isLabel=n.isLabel),null!=n.isInternal&&(this.isInternal=n.isInternal),null!=n.debugColor&&(this.debugColor=n.debugColor),null!=n.ignore&&(this.ignore=n.ignore)),(0,r.vA)((0,a.YY)(this.decomposed.scaleX,this.decomposed.scaleY),"non-uniform scaling is not yet supported")}geometry;matrix;inverse;decomposed;getVertices(e){return this.geometry.getVertices(e).map(e=>s.V.applyToPoint(this.matrix,e))}getBoundsVertices(){return this.geometry.getBoundsVertices().map(e=>s.V.applyToPoint(this.matrix,e))}nearestPoint(e,t){return s.V.applyToPoint(this.matrix,this.geometry.nearestPoint(s.V.applyToPoint(this.inverse,e),t))}hitTestPoint(e,t=0,n,r){return this.geometry.hitTestPoint(s.V.applyToPoint(this.inverse,e),t/this.decomposed.scaleX,n,r)}distanceToPoint(e,t=!1,n){return this.geometry.distanceToPoint(s.V.applyToPoint(this.inverse,e),t,n)*this.decomposed.scaleX}distanceToLineSegment(e,t,n){return this.geometry.distanceToLineSegment(s.V.applyToPoint(this.inverse,e),s.V.applyToPoint(this.inverse,t),n)*this.decomposed.scaleX}hitTestLineSegment(e,t,n=0,r){return this.geometry.hitTestLineSegment(s.V.applyToPoint(this.inverse,e),s.V.applyToPoint(this.inverse,t),n/this.decomposed.scaleX,r)}intersectLineSegment(e,t,n){return s.V.applyToPoints(this.matrix,this.geometry.intersectLineSegment(s.V.applyToPoint(this.inverse,e),s.V.applyToPoint(this.inverse,t),n))}intersectCircle(e,t,n){return s.V.applyToPoints(this.matrix,this.geometry.intersectCircle(s.V.applyToPoint(this.inverse,e),t/this.decomposed.scaleX,n))}intersectPolygon(e,t){return s.V.applyToPoints(this.matrix,this.geometry.intersectPolygon(s.V.applyToPoints(this.inverse,e),t))}intersectPolyline(e,t){return s.V.applyToPoints(this.matrix,this.geometry.intersectPolyline(s.V.applyToPoints(this.inverse,e),t))}ignoreHit(e){return this.geometry.ignoreHit(s.V.applyToPoint(this.inverse,e))}transform(e,t){return new u(this.geometry,s.V.Multiply(e,this.matrix),{isLabel:t?.isLabel??this.isLabel,isInternal:t?.isInternal??this.isInternal,debugColor:t?.debugColor??this.debugColor,ignore:t?.ignore??this.ignore})}getSvgPathData(){throw Error("Cannot get SVG path data for transformed geometry.")}}},27394:(e,t,n)=>{"use strict";n.d(t,{u4:()=>c,fp:()=>u,HO:()=>h,lX:()=>p,a1:()=>f,A1:()=>s,h:()=>g});var r=n(24167),i=n(12115),o=n(83102);function s(e,t,n=[]){let r=i.useRef(t);r.current=t;let[a,l,d]=i.useMemo(()=>{let t=null,n=new o.VM(`useStateTracking(${e})`,()=>r.current?.(),{scheduleEffect(){t?.()}});return[n,e=>(t=e,()=>{t=null}),()=>n.scheduleCount]},[e,...n]);return i.useSyncExternalStore(l,d,d),i.useEffect(()=>(a.attach(),a.maybeScheduleEffect(),()=>{a.detach()}),[a]),a.execute()}let a={apply:(e,t,n)=>s(e.displayName??e.name??"tracked(???)",()=>e.apply(t,n))},l=Symbol.for("react.memo"),d=Symbol.for("react.forward_ref");function c(e){let t=null,n=e.$$typeof;return(n===l&&(t=(e=e.type).compare),n===d)?(0,i.memo)((0,i.forwardRef)(new Proxy(e.render,a))):(0,i.memo)(new Proxy(e,a),t)}function u(e,t,n){return(0,i.useState)(()=>{let r="function"==typeof t?t():t;return(0,o.eU)(`useAtom(${e})`,r,n)})[0]}function h(){let e=arguments[0],t=arguments[1],n=3==arguments.length?void 0:arguments[2],r=3==arguments.length?arguments[2]:arguments[3];return(0,i.useMemo)(()=>(0,o.EW)(`useComputed(${e})`,t,n),r)}function p(e,t,n=o.Ml){(0,i.useEffect)(()=>{let n=new o.VM(e,t);return n.attach(),n.execute(),()=>{n.detach()}},n)}function f(e,t,n=[]){(0,i.useEffect)(()=>{let n,i=new o.VM(e,t,{scheduleEffect:e=>{n=(0,r.Uo)(e)}});return i.attach(),i.execute(),()=>{i.detach(),n?.()}},n)}function g(){let e=arguments,t=3===e.length?e[2]:[e[0]],n=3===e.length?e[0]:`useValue(${e[0].name})`,{$val:r,subscribe:s,getSnapshot:a}=(0,i.useMemo)(()=>{let t=1===e.length?e[0]:(0,o.EW)(n,e[1]);return{$val:t,subscribe:e=>(0,o.wv)(`useValue(${n})`,()=>{try{t.get()}catch{}e()}),getSnapshot:()=>t.lastChangedEpoch}},t);return(0,i.useSyncExternalStore)(s,a,a),r.__unsafe__getWithoutCapture()}(0,r.lF)("@tldraw/state-react","5.3.2","esm")},28879:(e,t,n)=>{"use strict";function r(e,t){return e.props===t.props&&e.meta===t.meta}n.d(t,{E:()=>r})},31428:(e,t,n)=>{"use strict";n.d(t,{d:()=>i});var r=n(31796);class i extends r.H{constructor(e){if(super({...e}),this.isClosed=!0,e.points.length<3)throw Error("Polygon2d: points must be an array of at least 3 points")}}},31796:(e,t,n)=>{"use strict";n.d(t,{H:()=>a});var r=n(93286),i=n(46195),o=n(55667),s=n(27164);class a extends s.vq{_points;_segments;constructor(e){super({isClosed:!1,isFilled:!1,...e});const{points:t}=e;if(this._points=t,t.length<2)throw Error("Polyline2d: points must be an array of at least 2 points")}get segments(){if(!this._segments){this._segments=[];let{vertices:e}=this;for(let t=0,n=e.length-1;t<n;t++){let n=e[t],r=e[t+1];this._segments.push(new o.A({start:n,end:r}))}this.isClosed&&this._segments.push(new o.A({start:e[e.length-1],end:e[0]}))}return this._segments}getLength(){return this.segments.reduce((e,t)=>e+t.length,0)}getVertices(){return this._points}nearestPoint(e){let{vertices:t}=this,n=t[0].x,r=t[0].y,o=(e.x-n)*(e.x-n)+(e.y-r)*(e.y-r),s=this.isClosed?t.length:t.length-1;for(let i=0;i<s;i++){let s,a,l=t[i],d=t[(i+1)%t.length],c=d.x-l.x,u=d.y-l.y,h=c*c+u*u;if(0===h)s=l.x,a=l.y;else{let t=((e.x-l.x)*c+(e.y-l.y)*u)/h;t<=0?(s=l.x,a=l.y):t>=1?(s=d.x,a=d.y):(s=l.x+c*t,a=l.y+u*t)}let p=e.x-s,f=e.y-a,g=p*p+f*f;g<o&&(n=s,r=a,o=g)}return new i.l(n,r)}hitTestPoint(e,t=0,n=!1){return this.distanceToPoint(e,n)<=t}distanceToPoint(e,t=!1){let{segments:n}=this,i=1/0;for(let t=0;t<n.length;t++){let r=n[t].distanceToPoint(e);r<i&&(i=r)}return this.isClosed&&(this.isFilled||t)&&(0,r.s3)(e,this.vertices)?-i:i}hitTestLineSegment(e,t,n=0){let{segments:r}=this;for(let i=0,o=r.length;i<o;i++)if(r[i].hitTestLineSegment(e,t,n))return!0;return!1}getSvgPathData(){let{vertices:e}=this;return e.length<2?"":e.reduce((e,t,n)=>0===n?`M ${t.x} ${t.y}`:`${e} L ${t.x} ${t.y}`,"")}}},31832:(e,t,n)=>{"use strict";n.d(t,{N:()=>d,P:()=>l});var r=n(83102),i=n(24167),o=n(19743),s=Object.defineProperty,a=Object.getOwnPropertyDescriptor;function l(e){return{default:o.S,...e}}class d{constructor(e,t){this.editor=e,this._themes=(0,r.eU)("ThemeManager._definitions",t.themes),this._currentThemeId=(0,r.eU)("ThemeManager._currentThemeName",t.initial)}editor;_themes;_currentThemeId;getColorMode(){return this.editor.user.getIsDarkMode()?"dark":"light"}getThemes(){return this._themes.get()}getTheme(e){return this._themes.get()[e]}getCurrentThemeId(){return this._currentThemeId.get()}getCurrentTheme(){return this._themes.get()[this.getCurrentThemeId()]}setCurrentTheme(e){this._currentThemeId.set(e)}updateThemes(e){this._themes.update(t=>{let n="function"==typeof e?e((0,i.pN)(t)):e;return this._currentThemeId.get()in n||this._currentThemeId.set("default"),n})}updateTheme(e){this._themes.update(t=>({...t,[e.id]:e}))}dispose(){}}((e,t,n)=>{for(var r,i=a(t,n),o=e.length-1;o>=0;o--)(r=e[o])&&(i=r(t,n,i)||i);return i&&s(t,n,i)})([r.EW],d.prototype,"getColorMode")},32314:(e,t,n)=>{"use strict";n.d(t,{s:()=>l});var r=n(24167),i=n(46195),o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=(e,t,n,r)=>{for(var i,a=r>1?void 0:r?s(t,n):t,l=e.length-1;l>=0;l--)(i=e[l])&&(a=(r?i(t,n,a):i(a))||a);return r&&a&&o(t,n,a),a};class l{constructor(e){this.editor=e}editor;_clickId="";_clickTimeout;_clickScreenPoint;_previousScreenPoint;_isPressingWhilePending=!1;_getClickTimeout(e,t=(0,r.NF)()){this._clickId=t,clearTimeout(this._clickTimeout),this._clickTimeout=this.editor.timers.setTimeout(()=>{this._clickState===e&&this._clickId===t&&("pendingOverflow"===this._clickState&&this.editor.dispatch({...this.lastPointerInfo,type:"click",name:"double_click",phase:this._isPressingWhilePending?"settle-down":"settle-up"}),this._clickState="idle")},"idle"===e||"pendingDouble"===e?this.editor.options.doubleClickDurationMs:this.editor.options.multiClickDurationMs)}_clickState="idle";get clickState(){return this._clickState}lastPointerInfo={};handlePointerEvent(e){switch(e.name){case"pointer_down":if(!this._clickState)break;switch(this._clickScreenPoint=i.l.From(e.point),this._isPressingWhilePending=!0,this._previousScreenPoint&&i.l.Dist2(this._previousScreenPoint,this._clickScreenPoint)>1600&&(this._clickState="idle"),this._previousScreenPoint=this._clickScreenPoint,this.lastPointerInfo=e,this._clickState){case"pendingDouble":return this._clickState="pendingOverflow",this._clickTimeout=this._getClickTimeout(this._clickState),{...e,type:"click",name:"double_click",phase:"down"};case"idle":this._clickState="pendingDouble";break;case"pendingOverflow":this._clickState="overflow"}this._clickTimeout=this._getClickTimeout(this._clickState);break;case"pointer_up":if(!this._clickState)break;if(this._clickScreenPoint=i.l.From(e.point),this._isPressingWhilePending=!1,"pendingOverflow"===this._clickState)return{...this.lastPointerInfo,type:"click",name:"double_click",phase:"up"};break;case"pointer_move":"idle"!==this._clickState&&this._clickScreenPoint&&i.l.Dist2(this._clickScreenPoint,this.editor.inputs.getCurrentScreenPoint())>(this.editor.getInstanceState().isCoarsePointer?this.editor.options.coarseDragDistanceSquared:this.editor.options.dragDistanceSquared)&&this.cancelDoubleClickTimeout()}return e}cancelDoubleClickTimeout(){this._clickTimeout=clearTimeout(this._clickTimeout),this._clickState="idle",this._isPressingWhilePending=!1}}a([r.oI],l.prototype,"_getClickTimeout",1),a([r.oI],l.prototype,"cancelDoubleClickTimeout",1)},36649:(e,t,n)=>{"use strict";function r(e){let t=[],n=new Set;for(let r of e){if(n.has(r.type))throw Error(`Asset type "${r.type}" is defined more than once`);t.push(r),n.add(r.type)}return t}n.d(t,{U:()=>r})},37920:(e,t,n)=>{"use strict";n.d(t,{L:()=>p});var r=n(95155),i=n(81467),o=n(20172),s=n(75567),a=n(93097),l=n(26614),d=n(71136),c=n(27394),u=n(67863);function h({bounds:e,className:t}){let n=(0,u.hG)(),i=(0,c.h)("zoom level",()=>n.getEfficientZoomLevel(),[n]);return(0,r.jsx)("g",{className:t,pointerEvents:"none",strokeLinecap:"round",strokeLinejoin:"round",children:e.sides.map((e,t)=>{let{strokeDasharray:n,strokeDashoffset:o}=(0,d.E)(e[0].dist(e[1]),1/i,{style:"dashed",lengthRatio:4});return(0,r.jsx)("line",{x1:e[0].x,y1:e[0].y,x2:e[1].x,y2:e[1].y,strokeDasharray:n,strokeDashoffset:o},t)})})}class p extends l.i{static type="group";static props=i.h4;static migrations=i.gf;hideSelectionBoundsFg(e){return!0}canBind(){return!1}canResize(){return!0}canResizeChildren(){return!0}getDefaultProps(){return{}}getGeometry(e){let t=this.editor.getSortedChildIdsForParent(e.id);return 0===t.length?new a.k({width:1,height:1,isFilled:!1}):new s.I({children:t.map(e=>{let t=this.editor.getShape(e);return this.editor.getShapeGeometry(e).transform(this.editor.getShapeLocalTransform(t),{isLabel:!1})})})}component(e){let t=this.editor.getErasingShapeIds().includes(e.id),{hintingShapeIds:n}=this.editor.getCurrentPageState(),i=n.length>0&&n.some(t=>t!==e.id&&this.editor.isShapeOfType(this.editor.getShape(t),"group")),s=this.editor.getCurrentPageState().focusedGroupId!==e.id;if(!t&&(s||i))return null;let a=this.editor.getShapeGeometry(e).bounds;return(0,r.jsx)(o.U,{children:(0,r.jsx)(h,{className:"tl-group",bounds:a})})}getIndicatorPath(e){let t=this.editor.getShapeGeometry(e).bounds,n=this.editor.getEfficientZoomLevel(),r=new Path2D;for(let e of t.sides){let[t,i]=e,o=t.dist(i);if(o<=0)continue;let{strokeDasharray:s,strokeDashoffset:a}=(0,d.E)(o,1/n,{style:"dashed",lengthRatio:4});if("none"===s){r.moveTo(t.x,t.y),r.lineTo(i.x,i.y);continue}let[l,c]=s.split(" ").map(Number),u=Number(a),h=l+c;if(!Number.isFinite(h)||h<=0)continue;let p=(i.x-t.x)/o,f=(i.y-t.y)/o;for(let e=-u;e<o;e+=h){let n=Math.min(o,e+l),i=Math.max(0,e);n<=i||(r.moveTo(t.x+p*i,t.y+f*i),r.lineTo(t.x+p*n,t.y+f*n))}}return r}onChildrenChange(e){let t=this.editor.getSortedChildIdsForParent(e.id);if(0===t.length){this.editor.getCurrentPageState().focusedGroupId===e.id&&this.editor.popFocusedGroupId(),this.editor.deleteShapes([e.id]);return}if(1===t.length){this.editor.getCurrentPageState().focusedGroupId===e.id&&this.editor.popFocusedGroupId(),this.editor.reparentShapes(t,e.parentId,e.index),this.editor.deleteShapes([e.id]);return}}}},38335:(e,t,n)=>{"use strict";n.d(t,{r:()=>r});class r{constructor(e){this.editor=e}editor;disposables=new Set;register(e){return this.disposables.add(e),e}addEditorEvent(e,t){this.editor.on(e,t),this.register(()=>this.editor.off(e,t))}dispose(){this.disposables.forEach(e=>e()),this.disposables.clear()}}},40002:(e,t,n)=>{"use strict";n.d(t,{D:()=>l});var r=n(24167),i=n(38335);n(41463);var o=Object.defineProperty,s=Object.getOwnPropertyDescriptor;let a=r.Uo;class l extends i.r{constructor(e){super(e),this.start()}cancelRaf;isPaused=!0;now=0;start(){this.isPaused=!1,this.cancelRaf?.(),this.cancelRaf=a(this.tick),this.now=Date.now()}tick(){if(this.isPaused)return;let e=Date.now(),t=e-this.now;this.now=e,this.editor.emit("frame",t),this.editor.emit("tick",t),this.cancelRaf=a(this.tick)}dispose(){this.isPaused=!0,this.cancelRaf?.(),super.dispose()}}((e,t,n)=>{for(var r,i=s(t,n),a=e.length-1;a>=0;a--)(r=e[a])&&(i=r(t,n,i)||i);return i&&o(t,n,i)})([r.oI],l.prototype,"tick")},42080:(e,t,n)=>{"use strict";n.d(t,{$B:()=>a,Sd:()=>o,T2:()=>s});var r=n(8242),i=n(27050);function o(e,t=null){return function(n,o){let{$from:s,$to:a}=n.selection,l=s.blockRange(a);if(!l)return!1;let d=o?n.tr:null;return!!function(e,t,n,o=null){let s=!1,a=t,l=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&0==t.startIndex){if(0==t.$from.index(t.depth-1))return!1;let e=l.resolve(t.start-2);a=new i.u$(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new i.u$(t.$from,l.resolve(t.$to.end(t.depth)),t.depth)),s=!0}let d=(0,r.oM)(a,n,o,t);return!!d&&(e&&function(e,t,n,o,s){let a=i.FK.empty;for(let e=n.length-1;e>=0;e--)a=i.FK.from(n[e].type.create(n[e].attrs,a));e.step(new r.Wg(t.start-2*!!o,t.end,t.start,t.end,new i.Ji(a,0,0),n.length,!0));let l=0;for(let e=0;e<n.length;e++)n[e].type==s&&(l=e+1);let d=n.length-l,c=t.start+n.length-2*!!o,u=t.parent;for(let n=t.startIndex,i=t.endIndex,o=!0;n<i;n++,o=!1)!o&&(0,r.zy)(e.doc,c,d)&&(e.split(c,d),c+=2*d),c+=u.child(n).nodeSize}(e,t,d,s,n),!0)}(d,l,e,t)&&(o&&o(d.scrollIntoView()),!0)}}function s(e){return function(t,n){let{$from:o,$to:s}=t.selection,a=o.blockRange(s,t=>t.childCount>0&&t.firstChild.type==e);return!!a&&(!n||(o.node(a.depth-1).type==e?function(e,t,n,o){let s=e.tr,a=o.end,l=o.$to.end(o.depth);a<l&&(s.step(new r.Wg(a-1,l,a,l,new i.Ji(i.FK.from(n.create(null,o.parent.copy())),1,0),1,!0)),o=new i.u$(s.doc.resolve(o.$from.pos),s.doc.resolve(l),o.depth));let d=(0,r.jP)(o);if(null==d)return!1;s.lift(o,d);let c=s.doc.resolve(s.mapping.map(a,-1)-1);return(0,r.n9)(s.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&s.join(c.pos),t(s.scrollIntoView()),!0}(t,n,e,a):function(e,t,n){let o=e.tr,s=n.parent;for(let e=n.end,t=n.endIndex-1,r=n.startIndex;t>r;t--)e-=s.child(t).nodeSize,o.delete(e-1,e+1);let a=o.doc.resolve(n.start),l=a.nodeAfter;if(o.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let d=0==n.startIndex,c=n.endIndex==s.childCount,u=a.node(-1),h=a.index(-1);if(!u.canReplace(h+ +!d,h+1,l.content.append(c?i.FK.empty:i.FK.from(s))))return!1;let p=a.pos,f=p+l.nodeSize;return o.step(new r.Wg(p-!!d,f+ +!!c,p+1,f-1,new i.Ji((d?i.FK.empty:i.FK.from(s.copy(i.FK.empty))).append(c?i.FK.empty:i.FK.from(s.copy(i.FK.empty))),+!d,+!c),+!d)),t(o.scrollIntoView()),!0}(t,n,a)))}}function a(e){return function(t,n){let{$from:o,$to:s}=t.selection,a=o.blockRange(s,t=>t.childCount>0&&t.firstChild.type==e);if(!a)return!1;let l=a.startIndex;if(0==l)return!1;let d=a.parent,c=d.child(l-1);if(c.type!=e)return!1;if(n){let o=c.lastChild&&c.lastChild.type==d.type,s=i.FK.from(o?e.create():null),l=new i.Ji(i.FK.from(e.create(null,i.FK.from(d.type.create(null,s)))),o?3:1,0),u=a.start,h=a.end;n(t.tr.step(new r.Wg(u-(o?3:1),h,u,h,l,1,!0)).scrollIntoView())}return!0}}},43336:(e,t,n)=>{"use strict";n.d(t,{u:()=>o});let r=[n(37920).L],i=new Set(r.map(e=>e.type));function o(e){let t=[...r],n=new Set;for(let r of e){if(i.has(r.type))throw Error(`Shape type "${r.type}" is a core shapes type and cannot be overridden`);if(n.has(r.type))throw Error(`Shape type "${r.type}" is defined more than once`);t.push(r),n.add(r.type)}return t}},43502:(e,t,n)=>{"use strict";n.d(t,{O:()=>o,T:()=>h});var r=n(24167),i=n(38335);function o(e,t){return Math.round(e*t)}let s=/\r?\n|\r/g;function a(e){return e.replace(s,"\n").split("\n").map(e=>e||" ").join("\n")}let l={start:"left","start-legacy":"left",middle:"center","middle-legacy":"center",end:"right","end-legacy":"right"},d=/\s/,c=new Intl.Segmenter(void 0,{granularity:"grapheme"}),u=Object.freeze({"overflow-wrap":"break-word","word-break":"auto",width:null,height:null,"max-width":null,"min-width":null});class h extends i.r{elm;poolElms=[];constructor(e){super(e),this.elm=this.createMeasurementEl(),this.editor.getContainer().appendChild(this.elm),this.register(()=>{for(let{el:e}of(this.elm.remove(),this.poolElms))e.remove();this.poolElms.length=0})}createMeasurementEl(){let e=this.editor.getContainerDocument().createElement("div");for(let t of(e.classList.add("tl-text"),e.classList.add("tl-text-measure"),e.setAttribute("dir","auto"),e.tabIndex=-1,(0,r.w$)(u)))e.style.setProperty(t,u[t]);return e}resetElementStyles(e,t){for(let n of t)n in u?e.style.setProperty(n,u[n]):e.style.removeProperty(n)}setElementStyles(e,t){let n=[];for(let[r,i]of Object.entries(t)){let t=e.style.getPropertyValue(r);if("string"==typeof i){if(t===i)continue;n.push([r,t||null]),e.style.setProperty(r,i)}else{if(!t)continue;n.push([r,t]),e.style.removeProperty(r)}}return()=>{for(let[t,r]of n)null===r||""===r?e.style.removeProperty(t):e.style.setProperty(t,r)}}getMeasureStyles(e){return{"font-family":e.fontFamily,"font-style":e.fontStyle,"font-weight":e.fontWeight,"font-size":e.fontSize+"px","line-height":`${o(e.fontSize,e.lineHeight)}px`,"--tl-rich-text-heading-line-height":`${e.lineHeight}`,padding:e.padding,"max-width":e.maxWidth?e.maxWidth+"px":void 0,"min-width":e.minWidth?e.minWidth+"px":void 0,"overflow-wrap":e.disableOverflowWrapBreaking?"normal":"break-word",...e.otherStyles}}ensurePoolSize(e){if(this.poolElms.length>=e)return;let t=this.editor.getContainerDocument().createDocumentFragment();for(;this.poolElms.length<e;){let e=this.createMeasurementEl();this.poolElms.push({el:e,html:"",appliedStyleKeys:[]}),t.appendChild(e)}this.editor.getContainer().appendChild(t)}getPoolItem(e){return this.ensurePoolSize(e+1),this.poolElms[e]}measureHtmlBatch(e){if(0===e.length)return[];for(;this.poolElms.length>e.length;){let{el:e}=this.poolElms.pop();e.remove()}for(let t=0;t<e.length;t++){let{html:n,opts:r}=e[t],i=this.getPoolItem(t),{el:o}=i;this.resetElementStyles(o,i.appliedStyleKeys);let s=this.getMeasureStyles(r);this.setElementStyles(o,s),i.appliedStyleKeys=Object.keys(s),i.html!==n&&(o.innerHTML=n,i.html=n)}let t=[];for(let n=0;n<e.length;n++){let r=this.getPoolItem(n).el,i=e[n].opts.measureScrollWidth?r.scrollWidth:0,o=r.getBoundingClientRect();t.push({x:0,y:0,w:o.width,h:o.height,scrollWidth:i})}return t}measureText(e,t){let n=this.editor.getContainerDocument().createElement("div");return n.textContent=a(e),this.measureHtml(n.innerHTML,t)}measureHtml(e,t){let{elm:n}=this,r=this.setElementStyles(n,this.getMeasureStyles(t));try{n.innerHTML=e;let r=t.measureScrollWidth?n.scrollWidth:0,i=n.getBoundingClientRect();return{x:0,y:0,w:i.width,h:i.height,scrollWidth:r}}finally{r()}}measureElementTextNodeSpans(e,{shouldTruncateToFirstLine:t=!1}={}){let n=[],r=e.getBoundingClientRect(),i=-r.left,o=-r.top,s=new Range,a=e.childNodes[0],l=0,u=null,h=null,p=0,f=0,g=!1;for(let r of e.childNodes)if(r.nodeType===Node.TEXT_NODE)for(let{segment:e}of c.segment(r.textContent??"")){s.setStart(a,l),s.setEnd(a,l+e.length);let r=s.getClientRects(),c=r[r.length-1];if(!c){l+=e.length;continue}let m=c.top+o,y=c.left+i,b=c.right+i,x=y<f,w=d.test(e);if(w===h&&m===p&&u)x&&(u.box.x=y),u.box.w=x?u.box.w+c.width:b-u.box.x,u.text+=e;else{if(u){if(t&&m!==p){g=!0;break}n.push(u)}u={box:{x:y,y:m,w:c.width,h:c.height},text:e},f=y}"\n"===e&&(f=0),h=w,p=m,l+=e.length}return u&&n.push(u),{spans:n,didTruncate:g}}measureTextSpans(e,t){if(""===e)return[];let{elm:n}=this,r="truncate-ellipsis"===t.overflow||"truncate-clip"===t.overflow,i=Math.ceil(t.width-2*t.padding),s={"font-family":t.fontFamily,"font-style":t.fontStyle,"font-weight":t.fontWeight,"font-size":t.fontSize+"px","line-height":`${o(t.fontSize,t.lineHeight)}px`,width:`${i}px`,height:"min-content","text-align":l[t.textAlign],"overflow-wrap":r?"anywhere":"break-word","word-break":r?"break-all":"normal",...t.otherStyles},d=this.setElementStyles(n,s);try{let o=a(e);n.textContent=o;let{spans:s,didTruncate:l}=this.measureElementTextNodeSpans(n,{shouldTruncateToFirstLine:r});if("truncate-ellipsis"===t.overflow&&l){n.textContent="…";let e=Math.ceil(this.measureElementTextNodeSpans(n).spans[0].box.w);n.style.setProperty("width",`${i-e}px`),n.textContent=o;let r=this.measureElementTextNodeSpans(n,{shouldTruncateToFirstLine:!0}).spans,s=r[r.length-1];return r.push({text:"…",box:{x:Math.min(s.box.x+s.box.w,t.width-t.padding-e),y:s.box.y,w:e,h:s.box.h}}),r}return s}finally{d()}}}},43631:(e,t,n)=>{"use strict";n.d(t,{b:()=>s});var r=n(83102);n(27394),n(12115),n(80614);var i=n(97156);let o=(0,r.EW)("defaultLocalStorageUserPrefs",()=>(0,i.oE)());function s(e={}){return{userPreferences:e.userPreferences??o,setUserPreferences:e.setUserPreferences??i.A2}}},46195:(e,t,n)=>{"use strict";n.d(t,{l:()=>s});let{easeInQuad:r,easeInOutQuad:i}=n(58347).Z;function o(e){return Math.round(100*e)/100}class s{constructor(e=0,t=0,n=1){this.x=e,this.y=t,this.z=n}x;y;z;get pressure(){return this.z}set(e=this.x,t=this.y,n=this.z){return this.x=e,this.y=t,this.z=n,this}setTo({x:e=0,y:t=0,z:n=1}){return this.x=e,this.y=t,this.z=n,this}rot(e){if(0===e)return this;let{x:t,y:n}=this,r=Math.sin(e),i=Math.cos(e);return this.x=t*i-n*r,this.y=t*r+n*i,this}rotWith(e,t){if(0===t)return this;let n=this.x-e.x,r=this.y-e.y,i=Math.sin(t),o=Math.cos(t);return this.x=e.x+(n*o-r*i),this.y=e.y+(n*i+r*o),this}clone(){let{x:e,y:t,z:n}=this;return new s(e,t,n)}sub(e){return this.x-=e.x,this.y-=e.y,this}subXY(e,t){return this.x-=e,this.y-=t,this}subScalar(e){return this.x-=e,this.y-=e,this}add(e){return this.x+=e.x,this.y+=e.y,this}addXY(e,t){return this.x+=e,this.y+=t,this}addScalar(e){return this.x+=e,this.y+=e,this}clamp(e,t){return this.x=Math.max(this.x,e),this.y=Math.max(this.y,e),void 0!==t&&(this.x=Math.min(this.x,t),this.y=Math.min(this.y,t)),this}div(e){return this.x/=e,this.y/=e,this}divV(e){return this.x/=e.x,this.y/=e.y,this}mul(e){return this.x*=e,this.y*=e,this}mulV(e){return this.x*=e.x,this.y*=e.y,this}abs(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this}nudge(e,t){let n=s.Tan(e,this);return this.add(n.mul(t))}neg(){return this.x*=-1,this.y*=-1,this}cross(e){return this.x=this.y*e.z-this.z*e.y,this.y=this.z*e.x-this.x*e.z,this}dpr(e){return s.Dpr(this,e)}cpr(e){return s.Cpr(this,e)}len2(){return s.Len2(this)}len(){return s.Len(this)}pry(e){return s.Pry(this,e)}per(){let{x:e,y:t}=this;return this.x=t,this.y=-e,this}uni(){let e=this.len();return 0===e||(this.x/=e,this.y/=e),this}tan(e){return this.sub(e).uni()}dist(e){return s.Dist(this,e)}distanceToLineSegment(e,t){return s.DistanceToLineSegment(e,t,this)}slope(e){return s.Slope(this,e)}snapToGrid(e){return this.x=Math.round(this.x/e)*e,this.y=Math.round(this.y/e)*e,this}angle(e){return s.Angle(this,e)}toAngle(){return s.ToAngle(this)}lrp(e,t){return this.x=this.x+(e.x-this.x)*t,this.y=this.y+(e.y-this.y)*t,this}equals(e){return s.Equals(this,e)}equalsXY(e,t){return s.EqualsXY(this,e,t)}toFixed(){return this.x=o(this.x),this.y=o(this.y),this}toString(){return s.ToString(s.ToFixed(this))}toJson(){return s.ToJson(this)}toArray(){return s.ToArray(this)}static Add(e,t){return new s(e.x+t.x,e.y+t.y)}static AddXY(e,t,n){return new s(e.x+t,e.y+n)}static Sub(e,t){return new s(e.x-t.x,e.y-t.y)}static SubXY(e,t,n){return new s(e.x-t,e.y-n)}static AddScalar(e,t){return new s(e.x+t,e.y+t)}static SubScalar(e,t){return new s(e.x-t,e.y-t)}static Div(e,t){return new s(e.x/t,e.y/t)}static Mul(e,t){return new s(e.x*t,e.y*t)}static DivV(e,t){return new s(e.x/t.x,e.y/t.y)}static MulV(e,t){return new s(e.x*t.x,e.y*t.y)}static Neg(e){return new s(-e.x,-e.y)}static Per(e){return new s(e.y,-e.x)}static Abs(e){return new s(Math.abs(e.x),Math.abs(e.y))}static Dist(e,t){return((e.y-t.y)**2+(e.x-t.x)**2)**.5}static ManhattanDist(e,t){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)}static DistMin(e,t,n){return(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y)<n**2}static Dist2(e,t){return(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y)}static Dpr(e,t){return e.x*t.x+e.y*t.y}static Cross(e,t){return new s(e.y*t.z-e.z*t.y,e.z*t.x-e.x*t.z)}static Cpr(e,t){return e.x*t.y-t.x*e.y}static Len2(e){return e.x*e.x+e.y*e.y}static Len(e){return(e.x*e.x+e.y*e.y)**.5}static Pry(e,t){return s.Dpr(e,t)/s.Len(t)}static Uni(e){let t=s.Len(e);return new s(0===t?0:e.x/t,0===t?0:e.y/t)}static Tan(e,t){return s.Uni(s.Sub(e,t))}static Min(e,t){return new s(Math.min(e.x,t.x),Math.min(e.y,t.y))}static Max(e,t){return new s(Math.max(e.x,t.x),Math.max(e.y,t.y))}static From({x:e,y:t,z:n=1}){return new s(e,t,n)}static FromArray(e){return new s(e[0],e[1])}static Rot(e,t=0){let n=Math.sin(t),r=Math.cos(t);return new s(e.x*r-e.y*n,e.x*n+e.y*r)}static RotWith(e,t,n){let r=e.x-t.x,i=e.y-t.y,o=Math.sin(n),a=Math.cos(n);return new s(t.x+(r*a-i*o),t.y+(r*o+i*a))}static NearestPointOnLineThroughPoint(e,t,n){let r=(n.x-e.x)*t.x+(n.y-e.y)*t.y;return new s(e.x+t.x*r,e.y+t.y*r)}static NearestPointOnLineSegment(e,t,n,r=!0){let i=t.x-e.x,o=t.y-e.y,a=i*i+o*o;if(0===a)return s.From(e);let l=((n.x-e.x)*i+(n.y-e.y)*o)/a;return r&&(l<0?l=0:l>1&&(l=1)),new s(e.x+l*i,e.y+l*o)}static DistanceToLineThroughPoint(e,t,n){let r=n.x-e.x,i=n.y-e.y;return Math.abs(r*t.y-i*t.x)}static DistanceToLineSegment(e,t,n,r=!0){let i=t.x-e.x,o=t.y-e.y,a=i*i+o*o;if(0===a)return s.Dist(e,n);let l=((n.x-e.x)*i+(n.y-e.y)*o)/a;r&&(l<0?l=0:l>1&&(l=1));let d=e.x+l*i-n.x,c=e.y+l*o-n.y;return Math.sqrt(d*d+c*c)}static Snap(e,t=1){return new s(Math.round(e.x/t)*t,Math.round(e.y/t)*t)}static Cast(e){return e instanceof s?e:s.From(e)}static Slope(e,t){return e.x===t.y?NaN:(e.y-t.y)/(e.x-t.x)}static IsNaN(e){return isNaN(e.x)||isNaN(e.y)}static IsFinite(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}static Angle(e,t){return Math.atan2(t.y-e.y,t.x-e.x)}static AngleBetween(e,t){let n=e.x*t.x+e.y*t.y,r=Math.sqrt((e.x*e.x+e.y*e.y)*(t.x*t.x+t.y*t.y));return(e.x*t.y-e.y*t.x<0?-1:1)*Math.acos(Math.max(-1,Math.min(n/r,1)))}static Lrp(e,t,n){return new s(e.x+(t.x-e.x)*n,e.y+(t.y-e.y)*n)}static Med(e,t){return new s((e.x+t.x)/2,(e.y+t.y)/2)}static Equals(e,t){return 1e-4>Math.abs(e.x-t.x)&&1e-4>Math.abs(e.y-t.y)}static EqualsXY(e,t,n){return e.x===t&&e.y===n}static Clockwise(e,t,n){return(n.x-e.x)*(t.y-e.y)-(t.x-e.x)*(n.y-e.y)<0}static Rescale(e,t){let n=s.Len(e);return new s(t*e.x/n,t*e.y/n)}static ScaleWithOrigin(e,t,n){return s.Sub(e,n).mul(t).add(n)}static ToFixed(e){return new s(o(e.x),o(e.y))}static ToInt(e){return new s(parseInt(e.x.toFixed(0)),parseInt(e.y.toFixed(0)),parseInt((e.z??0).toFixed(0)))}static ToCss(e){return`${e.x},${e.y}`}static Nudge(e,t,n){return s.Add(e,s.Tan(t,e).mul(n))}static ToString(e){return`${e.x}, ${e.y}`}static ToAngle(e){let t=Math.atan2(e.y,e.x);return t<0&&(t+=2*Math.PI),t}static FromAngle(e,t=1){return new s(Math.cos(e)*t,Math.sin(e)*t)}static ToArray(e){return[e.x,e.y,e.z]}static ToJson(e){let{x:t,y:n,z:r}=e;return{x:t,y:n,z:r}}static Average(e){let t=e.length,n=new s(0,0);if(0===t)return n;for(let r=0;r<t;r++)n.add(e[r]);return n.div(t)}static Clamp(e,t,n){return void 0===n?new s(Math.min(Math.max(e.x,t)),Math.min(Math.max(e.y,t))):new s(Math.min(Math.max(e.x,t),n),Math.min(Math.max(e.y,t),n))}static PointsBetween(e,t,n=6,o=r){let a=[];for(let r=0;r<n;r++){let l=o(r/(n-1)),d=s.Lrp(e,t,l);d.z=Math.min(1,.5+.65*Math.abs(.5-i(l))),a.push(d)}return a}static SnapToGrid(e,t=8){return new s(Math.round(e.x/t)*t,Math.round(e.y/t)*t)}}},48077:(e,t,n)=>{"use strict";function r(e){if(e.shadowRoot)return e.shadowRoot.childNodes;if(function(e){var t;return"getRootNode"in e&&(t=e.getRootNode())instanceof l(t).ShadowRoot&&e instanceof l(e).HTMLSlotElement}(e)){let t=e.assignedNodes();if(t?.length)return t}return e.childNodes}function*i(e){for(let t of r(e))d(t)&&(yield t)}function o(e){if(!e)return globalThis;let t=a(e)?e:e.ownerDocument;return t?.defaultView??globalThis}function s(e){return e?a(e)?e:e.ownerDocument??globalThis.document:globalThis.document}function a(e){return e.nodeType===Node.DOCUMENT_NODE}function l(e){return e.ownerDocument?.defaultView??globalThis}function d(e){return e instanceof l(e).Element}function c(e){return e.style}function u(e,t){return l(e).getComputedStyle(e,t)}n.d(t,{$3:()=>i,EV:()=>c,L9:()=>u,TW:()=>s,XH:()=>r,mD:()=>o,vq:()=>d})},48877:(e,t,n)=>{"use strict";function r(e,t){let n=e,r=new Set(t);for(;r.has(n);)n=/^.*(\d+)$/.exec(n)?.[1]?n.replace(/(\d+)$/,e=>(+e+1).toString()):`${n} 1`;return n}n.d(t,{g:()=>r})},49402:(e,t,n)=>{"use strict";n.d(t,{c:()=>l});var r=n(24167),i=n(38335),o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=(e,t,n,r)=>{for(var i,a=r>1?void 0:r?s(t,n):t,l=e.length-1;l>=0;l--)(i=e[l])&&(a=(r?i(t,n,a):i(a))||a);return r&&a&&o(t,n,a),a};class l extends i.r{constructor(e,t){super(e);const n=e.sideEffects.registerAfterChangeHandler("instance",(e,t)=>{e.isFocused!==t.isFocused&&this.updateContainerClass()});this.register(()=>n?.()),t!==e.getInstanceState().isFocused&&e.updateInstanceState({isFocused:!!t}),this.updateContainerClass();const r=e.getContainerDocument().body;r.addEventListener("keydown",this.handleKeyDown),r.addEventListener("mousedown",this.handleMouseDown),this.register(()=>{r.removeEventListener("keydown",this.handleKeyDown),r.removeEventListener("mousedown",this.handleMouseDown)})}updateContainerClass(){let e=this.editor.getContainer();this.editor.getInstanceState().isFocused?e.classList.add("tl-container__focused"):e.classList.remove("tl-container__focused"),e.classList.add("tl-container__no-focus-ring")}handleKeyDown(e){let t=this.editor.getContainer(),n=t.ownerDocument.activeElement;this.editor.getEditingShapeId()&&!n?.closest(".tlui-contextual-toolbar")||(n!==t||!(this.editor.getSelectedShapeIds().length>0))&&["Tab","ArrowUp","ArrowDown"].includes(e.key)&&t.classList.remove("tl-container__no-focus-ring")}handleMouseDown(){this.editor.getContainer().classList.add("tl-container__no-focus-ring")}focus(){this.editor.getContainer().focus()}blur({blurContainer:e=!0}={}){this.editor.complete(),e&&this.editor.getContainer().blur()}}a([r.oI],l.prototype,"handleKeyDown",1),a([r.oI],l.prototype,"handleMouseDown",1)},49450:(e,t,n)=>{"use strict";n.d(t,{i:()=>a});var r=n(83102),i=n(81467),o=n(24167);function s(e,t){let n={};return Array.from(e.get(),e=>t.get(e)).sort(o.Ky).forEach(e=>{n[e.parentId]??=[],n[e.parentId].push(e.id)}),n}function a(e){let t=e.query.ids("shape"),n=e.query.filterHistory("shape");return(0,r.EW)("parentsToChildrenWithIndexes",(a,l)=>{let d;if((0,r._O)(a))return s(t,e);let c=n.getDiffSince(l);if(c===r.c2)return s(t,e);if(0===c.length)return a;let u=null,h=e=>{u||(u={...a}),u[e]?u[e]===a[e]&&(u[e]=[...u[e]]):u[e]=[]},p=new Set;for(let e=0,t=c.length;e<t;e++){for(let t of Object.values((d=c[e]).added))(0,i.o2)(t)&&(h(t.parentId),u[t.parentId].push(t.id),p.add(u[t.parentId]));for(let[e,t]of Object.values(d.updated))if((0,i.o2)(t)&&(0,i.o2)(e)){if(e.parentId!==t.parentId)h(e.parentId),h(t.parentId),u[e.parentId].splice(u[e.parentId].indexOf(t.id),1),u[t.parentId].push(t.id),p.add(u[t.parentId]);else if(e.index!==t.index){h(t.parentId);let e=u[t.parentId].indexOf(t.id);u[t.parentId][e]=t.id,p.add(u[t.parentId])}}for(let e of Object.values(d.removed))(0,i.o2)(e)&&(h(e.parentId),u[e.parentId].splice(u[e.parentId].indexOf(e.id),1))}for(let t of p){let n=0;for(let r=0;r<t.length;r++)e.get(t[r])&&(t[n++]=t[r]);t.length=n,t.sort((t,n)=>{let r=e.get(t),i=e.get(n);return(0,o.Ky)(r,i)})}return u??a})}},50139:(e,t,n)=>{"use strict";n.d(t,{g:()=>i});var r=n(13982);function i(e){return r.Y.isDarwin?e.metaKey:e.ctrlKey||e.metaKey}},50585:(e,t,n)=>{"use strict";n.d(t,{Bb:()=>c,Jf:()=>u,ls:()=>h});var r=n(95155),i=n(24167),o=n(12115),s=n(87767),a=n(67863),l=n(18314);let d=(0,o.createContext)(null);function c({context:e,editor:t,children:n}){let i=t.options.exportProvider;return(0,r.jsx)(a.zz,{editor:t,children:(0,r.jsx)(s.ts,{container:t.getContainer(),children:(0,r.jsx)(d.Provider,{value:e,children:(0,r.jsx)(i,{children:n})})})})}function u(){return(0,o.useContext)(d)}function h(){let e=(0,o.useContext)(d),[t]=(0,o.useState)(i.il);return(0,o.useEffect)(()=>(e?.waitUntil(t),()=>{t.resolve()}),[t,e]),(0,l._)(()=>{t.resolve()})}},51286:(e,t,n)=>{"use strict";n.d(t,{L:()=>l});var r=n(83102),i=n(54530),o=n(24167);let s={get:()=>void 0},a={get:()=>void 0};class l{constructor(e,t){this.editor=e,this.assetUrls=t,this.shapeFontFacesCache=e.store.createComputedCache("shape font faces",e=>this.editor.getShapeUtil(e).getFontFaces(e),{areResultsEqual:o.vq,areRecordsEqual:(e,t)=>e.props===t.props&&e.meta===t.meta}),this.shapeFontLoadStateCache=e.store.createCache(e=>{let t=(0,r.EW)("font faces",()=>this.getShapeFontFaces(e));return(0,r.EW)("font load state",()=>t.get().map(e=>this.getFontState(e)),{isEqual:o.vq})})}editor;assetUrls;dispose(){this.fontStates.clear(),this.fontsToLoad.clear(),this.shapeFontFacesCache=s,this.shapeFontLoadStateCache=a}shapeFontFacesCache;shapeFontLoadStateCache;getShapeFontFaces(e){let t="string"==typeof e?e:e.id;return this.shapeFontFacesCache.get(t)??r.Ml}trackFontsForShape(e){let t="string"==typeof e?e:e.id;this.shapeFontLoadStateCache.get(t)}async loadRequiredFontsForCurrentPage(e=1/0){let t=new Set;for(let e of this.editor.getCurrentPageShapeIds())for(let n of this.getShapeFontFaces(this.editor.getShape(e)))t.add(n);if(t.size>e)return;let n=Array.from(t,e=>this.ensureFontIsLoaded(e));await Promise.all(n)}fontStates=new i._j("font states");getFontState(e){return this.fontStates.get(e)??null}ensureFontIsLoaded(e){let t=this.getFontState(e);if(t)return t.loadingPromise;let n=this.findOrCreateFontFace(e),r=()=>this.fontStates.__unsafe__getWithoutCapture(e)!==i,i={state:"loading",instance:n,loadingPromise:n.load().then(()=>{r()?console.debug(`Font "${e.family}" load interrupted by editor dispose`):(this.editor.getContainerDocument().fonts.add(n),this.fontStates.update(e,e=>({...e,state:"ready"})))}).catch(t=>{r()?console.debug(`Font "${e.family}" load interrupted by editor dispose`,t):(console.error(t),this.fontStates.update(e,e=>({...e,state:"error"})))})};return this.fontStates.set(e,i),i.loadingPromise}fontsToLoad=new Set;requestFonts(e){for(let t of(this.fontsToLoad.size||queueMicrotask(()=>{if(this.editor.isDisposed)return;let e=this.fontsToLoad;this.fontsToLoad=new Set,(0,r.hL)(()=>{for(let t of e)this.ensureFontIsLoaded(t)})}),e))this.fontsToLoad.add(t)}findOrCreateFontFace(e){var t;let n=this.editor.getContainerDocument(),r=c.get(n);r||(r=new Map,c.set(n,r));let i=JSON.stringify([(t=e).family,...(0,o.iA)(d).map(([e,n])=>t[e]??n)]),s=r.get(i);if(s)return s;let a=n.fonts;for(let t of a)if(t.family===e.family&&(0,o.iA)(d).every(([n,r])=>t[n]===(e[n]??r)))return r.set(i,t),t;let l=this.assetUrls?.[e.src.url]??e.src.url,u=new FontFace(e.family,`url(${JSON.stringify(l)})`,{...(0,o._H)(d,t=>e[t]),display:"swap"});return a.add(u),r.set(i,u),u}async toEmbeddedCssDeclaration(e){let t=this.assetUrls?.[e.src.url]??e.src.url,n=await o.Sm.urlToDataUrl(t),r=(0,o.oE)([`url("${n}")`,e.src.format?`format(${e.src.format})`:null,e.src.tech?`tech(${e.src.tech})`:null]).join(" ");return(0,o.oE)(["@font-face {",` font-family: "${e.family}";`,e.ascentOverride?` ascent-override: ${e.ascentOverride};`:null,e.descentOverride?` descent-override: ${e.descentOverride};`:null,e.stretch?` font-stretch: ${e.stretch};`:null,e.style?` font-style: ${e.style};`:null,e.weight?` font-weight: ${e.weight};`:null,e.featureSettings?` font-feature-settings: ${e.featureSettings};`:null,e.lineGapOverride?` line-gap-override: ${e.lineGapOverride};`:null,e.unicodeRange?` unicode-range: ${e.unicodeRange};`:null,` src: ${r};`,"}"]).join("\n")}}let d={style:"normal",weight:"normal",stretch:"normal",unicodeRange:"U+0-10FFFF",featureSettings:"normal",ascentOverride:"normal",descentOverride:"normal",lineGapOverride:"normal"},c=new WeakMap},52800:(e,t,n)=>{"use strict";function r(e){let t=[],n=new Set;for(let r of e){if(n.has(r.type))throw Error(`Binding type "${r.type}" is defined more than once`);t.push(r),n.add(r.type)}return t}n.d(t,{t:()=>r})},54530:(e,t,n)=>{"use strict";let r;n.d(t,{_j:()=>V,uw:()=>Y,zq:()=>X,ee:()=>eu,il:()=>ex,fX:()=>eS,uY:()=>ev,L4:()=>eo,bo:()=>Z,_B:()=>J,XD:()=>Q,WE:()=>eh,RF:()=>ea,E8:()=>es,Dm:()=>ed,Fl:()=>ec});var i=n(24167),o=n(83102);function s(e){return e>>>1&0x40000000|0xbfffffff&e}let a=Object.prototype.valueOf;function l(e){if(null==e)return d(e);if("function"==typeof e.hashCode)return s(e.hashCode(e));let t=(n=e).valueOf!==a&&"function"==typeof n.valueOf?n.valueOf(n):n;if(null==t)return d(t);switch(typeof t){case"boolean":return t?0x42108421:0x42108420;case"number":var n,r,i,o,l=t;if(l!=l||l===1/0)return 0;let f=0|l;for(f!==l&&(f^=0xffffffff*l);l>0xffffffff;)l/=0xffffffff,f^=l;return s(f);case"string":let b;return void 0===(b=g[r=t])&&(b=c(r),m===y&&(m=0,g={}),g[r]=b,m++),b;case"object":case"function":let x;return i=t,void 0!==(x=h.get(i))||(x=u(),h.set(i,x)),x;case"symbol":let w;return void 0!==(w=p[o=t])||(w=u(),p[o]=w),w;default:if("function"==typeof t.toString)return c(t.toString());throw Error("Value type "+typeof t+" cannot be hashed.")}}function d(e){return null===e?0x42108422:0x42108423}function c(e){let t=0;for(let n=0;n<e.length;n++)t=31*t+e.charCodeAt(n)|0;return s(t)}function u(){let e=++f;return 0x40000000&f&&(f=0),e}let h=new WeakMap,p=Object.create(null),f=0,g={},m=0,y=24e3,b={};function x(){return{value:!1}}function w(e){e&&(e.value=!0)}function v(e,t=0){return e.slice(t)}class S{}class C{_root;size;__ownerID;__hash;__altered;constructor(e){return null==e?F():e instanceof C?e:F().withMutations(t=>{for(let[n,r]of e)t.set(n,r)})}get(e,t){return this._root?this._root.get(0,void 0,e,t):t}set(e,t){return R(this,e,t)}delete(e){return R(this,e,b)}deleteAll(e){return this.withMutations(t=>{for(let n of e)t.delete(n)})}__ensureOwner(e){return e===this.__ownerID?this:e?L(this.size,this._root,e,this.__hash):0===this.size?F():(this.__ownerID=e,this.__altered=!1,this)}withMutations(e){let t=this.asMutable();return e(t),t.wasAltered()?t.__ensureOwner(this.__ownerID):this}wasAltered(){return this.__altered}asMutable(){return this.__ownerID?this:this.__ensureOwner(new S)}[Symbol.iterator](){return this.entries()[Symbol.iterator]()}entries(){return new _(this,D,!1)}keys(){return new _(this,j,!1)}values(){return new _(this,O,!1)}}class k{constructor(e,t){this.ownerID=e,this.entries=t}ownerID;entries;get(e,t,n,r){let i=this.entries;for(let e=0,t=i.length;e<t;e++)if(Object.is(n,i[e][0]))return i[e][1];return r}update(e,t,n,r,i,o,s){let a=i===b,d=this.entries,c=0,u=d.length;for(;c<u&&!Object.is(r,d[c][0]);c++);let h=c<u;if(h?d[c][1]===i:a)return this;if(w(s),(a||!h)&&w(o),a&&1===d.length)return;if(!h&&!a&&d.length>=U){var p=e,f=d,g=r,m=i;p||(p=new S);let t=new I(p,l(g),[g,m]);for(let e=0;e<f.length;e++){let n=f[e];t=t.update(p,0,void 0,n[0],n[1])}return t}let y=e&&e===this.ownerID,x=y?d:v(d);return(h?a?c===u-1?x.pop():x[c]=x.pop():x[c]=[r,i]:x.push([r,i]),y)?(this.entries=x,this):new k(e,x)}}class P{constructor(e,t,n){this.ownerID=e,this.bitmap=t,this.nodes=n}ownerID;bitmap;nodes;get(e,t,n,r){void 0===t&&(t=l(n));let i=1<<((0===e?t:t>>>e)&31),o=this.bitmap;return(o&i)==0?r:this.nodes[B(o&i-1)].get(e+5,t,n,r)}update(e,t,n,r,i,o,s){void 0===n&&(n=l(r));let a=(0===t?n:n>>>t)&31,d=1<<a,c=this.bitmap,u=(c&d)!=0;if(!u&&i===b)return this;let h=B(c&d-1),p=this.nodes,f=u?p[h]:void 0,g=z(f,e,t+5,n,r,i,o,s);if(g===f)return this;if(!u&&g&&p.length>=W){var m=e,y=p,x=c,w=a,v=g;let t=0,n=Array(32);for(let e=0;0!==x;e++,x>>>=1)n[e]=1&x?y[t++]:void 0;return n[w]=v,new T(m,t+1,n)}if(u&&!g&&2===p.length&&N(p[1^h]))return p[1^h];if(u&&g&&1===p.length&&N(g))return g;let S=e&&e===this.ownerID,C=u?g?c:c^d:c|d,k=u?g?H(p,h,g,S):function(e,t,n){let r=e.length-1;if(n&&t===r)return e.pop(),e;let i=Array(r),o=0;for(let n=0;n<r;n++)n===t&&(o=1),i[n]=e[n+o];return i}(p,h,S):function(e,t,n,r){let i=e.length+1;if(r&&t+1===i)return e[t]=n,e;let o=Array(i),s=0;for(let r=0;r<i;r++)r===t?(o[r]=n,s=-1):o[r]=e[r+s];return o}(p,h,g,S);return S?(this.bitmap=C,this.nodes=k,this):new P(e,C,k)}}class T{constructor(e,t,n){this.ownerID=e,this.count=t,this.nodes=n}ownerID;count;nodes;get(e,t,n,r){void 0===t&&(t=l(n));let i=(0===e?t:t>>>e)&31,o=this.nodes[i];return o?o.get(e+5,t,n,r):r}update(e,t,n,r,i,o,s){void 0===n&&(n=l(r));let a=(0===t?n:n>>>t)&31,d=i===b,c=this.nodes,u=c[a];if(d&&!u)return this;let h=z(u,e,t+5,n,r,i,o,s);if(h===u)return this;let p=this.count;if(u){if(!h&&--p<K)return function(e,t,n,r){let i=0,o=0,s=Array(n);for(let e=0,n=1,a=t.length;e<a;e++,n<<=1){let a=t[e];void 0!==a&&e!==r&&(i|=n,s[o++]=a)}return new P(e,i,s)}(e,c,p,a)}else p++;let f=e&&e===this.ownerID,g=H(c,a,h,f);return f?(this.count=p,this.nodes=g,this):new T(e,p,g)}}class E{constructor(e,t,n){this.ownerID=e,this.keyHash=t,this.entries=n}ownerID;keyHash;entries;get(e,t,n,r){let i=this.entries;for(let e=0,t=i.length;e<t;e++)if(Object.is(n,i[e][0]))return i[e][1];return r}update(e,t,n,r,i,o,s){void 0===n&&(n=l(r));let a=i===b;if(n!==this.keyHash)return a?this:(w(s),w(o),$(this,e,t,n,[r,i]));let d=this.entries,c=0,u=d.length;for(;c<u&&!Object.is(r,d[c][0]);c++);let h=c<u;if(h?d[c][1]===i:a)return this;if(w(s),(a||!h)&&w(o),a&&2===u)return new I(e,this.keyHash,d[1^c]);let p=e&&e===this.ownerID,f=p?d:v(d);return(h?a?c===u-1?f.pop():f[c]=f.pop():f[c]=[r,i]:f.push([r,i]),p)?(this.entries=f,this):new E(e,this.keyHash,f)}}class I{constructor(e,t,n){this.ownerID=e,this.keyHash=t,this.entry=n}ownerID;keyHash;entry;get(e,t,n,r){return Object.is(n,this.entry[0])?this.entry[1]:r}update(e,t,n,r,i,o,s){let a=i===b,d=Object.is(r,this.entry[0]);return(d?i===this.entry[1]:a)?this:(w(s),a)?void w(o):d?e&&e===this.ownerID?(this.entry[1]=i,this):new I(e,this.keyHash,[r,i]):(w(o),$(this,e,t,l(r),[r,i]))}}class _{constructor(e,t,n){this._type=t,this._reverse=n,this._stack=e._root&&A(e._root)}_type;_reverse;_stack;[Symbol.iterator](){return this}next(){let e=this._type,t=this._stack;for(;t;){let n,r=t.node,i=t.index++;if(r.entry){if(0===i)return M(e,r.entry)}else if("entries"in r&&r.entries){if(i<=(n=r.entries.length-1))return M(e,r.entries[this._reverse?n-i:i])}else if(i<=(n=r.nodes.length-1)){let o=r.nodes[this._reverse?n-i:i];if(o){if(o.entry)return M(e,o.entry);t=this._stack=A(o,t)}continue}t=this._stack=this._stack.__prev}return{value:void 0,done:!0}}}function M(e,t){var n,r,i,o;let s;return n=e,r=t[0],i=t[1],s=n===j?r:n===O?i:[r,i],o?o.value=s:o={value:s,done:!1},o}function A(e,t){return{node:e,index:0,__prev:t}}let j=0,O=1,D=2;function L(e,t,n,r){let i=Object.create(C.prototype);return i.size=e,i._root=t,i.__ownerID=n,i.__hash=r,i.__altered=!1,i}function F(){return r||(r=L(0))}function R(e,t,n){let r,i;if(e._root){let o=x(),s=x();if(r=z(e._root,e.__ownerID,0,void 0,t,n,o,s),!s.value)return e;i=e.size+(o.value?n===b?-1:1:0)}else{if(n===b)return e;i=1,r=new k(e.__ownerID,[[t,n]])}return e.__ownerID?(e.size=i,e._root=r,e.__hash=void 0,e.__altered=!0,e):r?L(i,r):F()}function z(e,t,n,r,i,o,s,a){return e?e.update(t,n,r,i,o,s,a):o===b?e:(w(a),w(s),new I(t,r,[i,o]))}function N(e){return e.constructor===I||e.constructor===E}function $(e,t,n,r,i){let o;if(e.keyHash===r)return new E(t,r,[e.entry,i]);let s=(0===n?e.keyHash:e.keyHash>>>n)&31,a=(0===n?r:r>>>n)&31,l=s===a?[$(e,t,n+5,r,i)]:(o=new I(t,r,i),s<a?[e,o]:[o,e]);return new P(t,1<<s|1<<a,l)}function B(e){return e-=e>>1&0x55555555,e=(e=(0x33333333&e)+(e>>2&0x33333333))+(e>>4)&0xf0f0f0f,e+=e>>8,127&(e+=e>>16)}function H(e,t,n,r){let i=r?e:v(e);return i[t]=n,i}let U=8,W=16,K=8;class V{constructor(e,t){this.name=e;let n=F();t&&(n=n.withMutations(n=>{for(let[r,i]of t)n.set(r,(0,o.eU)(`${e}:${String(r)}`,i))})),this.atoms=(0,o.eU)(`${e}:atoms`,n)}name;atoms;getAtom(e){let t=this.atoms.__unsafe__getWithoutCapture().get(e);return t||void this.atoms.get()}get(e){let t=this.getAtom(e)?.get();return(0,i.vA)(t!==o.UP),t}__unsafe__getWithoutCapture(e){let t=this.atoms.__unsafe__getWithoutCapture().get(e);if(!t)return;let n=t.__unsafe__getWithoutCapture();return(0,i.vA)(n!==o.UP),n}has(e){let t=this.getAtom(e);return!!t&&t.get()!==o.UP}__unsafe__hasWithoutCapture(e){let t=this.atoms.__unsafe__getWithoutCapture().get(e);return!!t&&((0,i.vA)(t.__unsafe__getWithoutCapture()!==o.UP),!0)}set(e,t){let n=this.atoms.__unsafe__getWithoutCapture().get(e);return n?n.set(t):this.atoms.update(n=>n.set(e,(0,o.eU)(`${this.name}:${String(e)}`,t))),this}update(e,t){let n=this.atoms.__unsafe__getWithoutCapture().get(e);if(!n)throw Error(`AtomMap: key ${e} not found`);let r=n.__unsafe__getWithoutCapture();(0,i.vA)(r!==o.UP),n.set(t(r))}delete(e){let t=this.atoms.__unsafe__getWithoutCapture().get(e);return!!t&&((0,o.hL)(()=>{t.set(o.UP),this.atoms.update(t=>t.delete(e))}),!0)}deleteMany(e){return(0,o.hL)(()=>{let t=[],n=this.atoms.get().withMutations(n=>{for(let r of e){let e=n.get(r);if(!e)continue;let s=e.get();(0,i.vA)(s!==o.UP),t.push([r,s]),n.delete(r),e.set(o.UP)}});return t.length&&this.atoms.set(n),t})}clear(){return(0,o.hL)(()=>{for(let e of this.atoms.__unsafe__getWithoutCapture().values())e.set(o.UP);this.atoms.set(F())})}*entries(){for(let[e,t]of this.atoms.get()){let n=t.get();(0,i.vA)(n!==o.UP),yield[e,n]}}*keys(){for(let e of this.atoms.get().keys())yield e}*values(){for(let e of this.atoms.get().values()){let t=e.get();(0,i.vA)(t!==o.UP),yield t}}get size(){return this.atoms.get().size}forEach(e,t){for(let[n,r]of this.entries())e.call(t,r,n,this)}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="AtomMap"}class Y{constructor(e,t){this.name=e;const n=t?Array.from(t,e=>[e,e]):void 0;this.map=new V(e,n)}name;map;add(e){return this.map.set(e,e),this}clear(){this.map.clear()}delete(e){return this.map.delete(e)}forEach(e,t){for(let n of this)e.call(t,n,n,this)}has(e){return this.map.has(e)}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.keys()}[Symbol.iterator](){return this.map.keys()}[Symbol.toStringTag]="AtomSet"}let G=!1;try{G=!1}catch(e){}try{G=G||(void 0).DEV||(void 0).TEST||"development"===(void 0).MODE||"test"===(void 0).MODE}catch(e){}function q(e){if(!G)return e;let t=Object.getPrototypeOf(e);if(t&&!(Array.isArray(e)||t===Object.prototype||null===t||t===i.DM))throw console.error("cannot include non-js data in a record",e),Error("cannot include non-js data in a record");if(Object.isFrozen(e))return e;for(let t of Object.getOwnPropertyNames(e)){let n=e[t];n&&"object"==typeof n&&q(n)}return Object.freeze(e)}class X{constructor(e){this.previousValue=e}previousValue;nextValue;diff;get(){let e=this.diff?.removed?.size??0,t=this.diff?.added?.size??0;if(0!==e||0!==t)return{value:this.nextValue,diff:this.diff}}_add(e,t){this.nextValue??=new Set(this.previousValue),this.nextValue.add(e),this.diff??={},t?this.diff.removed?.delete(e):(this.diff.added??=new Set,this.diff.added.add(e))}add(e){let t=this.previousValue.has(e);if(t){if(!this.diff?.removed?.has(e))return;return this._add(e,t)}this.nextValue?.has(e)||this._add(e,t)}_remove(e,t){this.nextValue??=new Set(this.previousValue),this.nextValue.delete(e),this.diff??={},t?(this.diff.removed??=new Set,this.diff.removed.add(e)):this.diff.added?.delete(e)}remove(e){let t=this.previousValue.has(e);if(!t){if(!this.diff?.added?.has(e))return;return this._remove(e,t)}this.diff?.removed?.has(e)||this._remove(e,t)}}function J({sequence:e,sequenceId:t,retroactive:n=!0}){let r={sequenceId:t,retroactive:n,sequence:function(e){let t=[];for(let n=e.length-1;n>=0;n--){let r=e[n];if("id"in r)t.unshift(r);else{let e=r.dependsOn,n=t[0];n&&(t[0]={...n,dependsOn:e.concat(n.dependsOn??[])})}}return t}(e)};return en(r),r}function Z(e,t){return Object.fromEntries((0,i.iA)(t).map(([t,n])=>[t,`${e}/${n}`]))}function Q(e){return J({sequenceId:e.sequenceId,retroactive:e.retroactive??!0,sequence:e.sequence.map(t=>"id"in t?{...t,scope:"record",filter:n=>n.typeName===e.recordType&&(t.filter?.(n)??!0)&&(e.filter?.(n)??!0)}:t)})}function ee(e){let[t,n]=e.split("/");return{sequenceId:t,version:parseInt(n)}}function et(e,t){t&&(0,i.vA)(e.startsWith(t+"/"),`Every migration in sequence '${t}' must have an id starting with '${t}/'. Got invalid id: '${e}'`),(0,i.vA)(e.match(/^(.*?)\/(0|[1-9]\d*)$/),`Invalid migration id: '${e}'`)}function en(e){if((0,i.vA)(!e.sequenceId.includes("/"),`sequenceId cannot contain a '/', got ${e.sequenceId}`),(0,i.vA)(e.sequenceId.length,"sequenceId must be a non-empty string"),0===e.sequence.length)return;et(e.sequence[0].id,e.sequenceId);let t=ee(e.sequence[0].id).version;(0,i.vA)(1===t,`Expected the first migrationId to be '${e.sequenceId}/1' but got '${e.sequence[0].id}'`);for(let n=1;n<e.sequence.length;n++){let r=e.sequence[n].id;et(r,e.sequenceId);let o=ee(r).version;(0,i.vA)(o===t+1,`Migration id numbers must increase in increments of 1, expected ${e.sequenceId}/${t+1} but got '${e.sequence[n].id}'`),t=o}}let er="target-version-too-old",ei="migration-error";function eo(){return{added:{},updated:{},removed:{}}}function es(e){let t={added:e.removed,removed:e.added,updated:{}};for(let[n,r]of Object.values(e.updated))t.updated[n.id]=[r,n];return t}function ea(e){return!el(e.added)&&!el(e.updated)&&!el(e.removed)}function el(e){for(let t in e)return!0;return!1}function ed(e,t){let n=t?.mutateFirstDiff?e[0]:{added:{},removed:{},updated:{}};return ec(n,t?.mutateFirstDiff?e.slice(1):e),n}function ec(e,t){for(let n of t){let t=el(e.removed);for(let r in n.added){let i=n.added[r];if(t&&e.removed[r]){let t=e.removed[r];delete e.removed[r],t!==i&&(e.updated[r]=[t,i])}else e.added[r]=i}let r=el(e.added);for(let i in n.updated){let o=n.updated[i][1];if(r&&e.added[i]){e.added[i]=o,delete e.updated[i],t&&delete e.removed[i];continue}let s=e.updated[i];if(s){s[1]=o,t&&delete e.removed[i];continue}e.updated[i]=[n.updated[i][0],o],t&&delete e.removed[i]}for(let t in n.removed)e.added[t]?delete e.added[t]:e.updated[t]?(e.removed[t]=e.updated[t][0],delete e.updated[t]):e.removed[t]=n.removed[t]}}class eu{constructor(e,t){this.typeName=e,this.createDefaultProperties=t.createDefaultProperties,this.validator=t.validator??{validate:e=>e},this.scope=t.scope??"document",this.ephemeralKeys=t.ephemeralKeys;const n=new Set;if(t.ephemeralKeys)for(const[e,r]of(0,i.iA)(t.ephemeralKeys))r&&n.add(e);this.ephemeralKeySet=n}typeName;createDefaultProperties;validator;ephemeralKeys;ephemeralKeySet;scope;create(e){let t={...this.createDefaultProperties(),id:e.id??this.createId()};for(let[n,r]of Object.entries(e))void 0!==r&&(t[n]=r);return t.typeName=this.typeName,t}clone(e){return{...(0,i.pN)(e),id:this.createId()}}createId(e){return this.typeName+":"+(e??(0,i.NF)())}parseId(e){if(!this.isId(e))throw Error(`ID "${e}" is not a valid ID for type "${this.typeName}"`);return e.slice(this.typeName.length+1)}isInstance(e){return e?.typeName===this.typeName}isId(e){if(!e)return!1;for(let t=0;t<this.typeName.length;t++)if(e[t]!==this.typeName[t])return!1;return":"===e[this.typeName.length]}withDefaultProperties(e){return new eu(this.typeName,{createDefaultProperties:e,validator:this.validator,scope:this.scope,ephemeralKeys:this.ephemeralKeys})}validate(e,t){return t&&this.validator.validateUsingKnownGoodVersion?this.validator.validateUsingKnownGoodVersion(t,e):this.validator.validate(e)}}function eh(e,t){return new eu(e,{createDefaultProperties:()=>({}),validator:t.validator,scope:t.scope,ephemeralKeys:t.ephemeralKeys})}function ep(e){return"object"==typeof e&&null!==e&&("eq"in e||"neq"in e||"gt"in e)}function ef(e,t){for(let[n,r]of Object.entries(e)){let e=t[n];if(ep(r)){if("eq"in r&&e!==r.eq||"neq"in r&&(e===r.neq||void 0===e)||"gt"in r&&("number"!=typeof e||e<=r.gt))return!1;continue}if("object"!=typeof e||null===e||!ef(r,e))return!1}return!0}function eg(e,t,n){let r=function e(t,n=""){let r=[];for(let[i,o]of Object.entries(t)){let t=n?`${n}\\${i}`:i;ep(o)?r.push({path:t,matcher:o}):"object"==typeof o&&null!==o&&r.push(...e(o,t))}return r}(n),i=Object.fromEntries(r.map(({path:e})=>[e,new Set]));for(let{path:n,matcher:o}of r){let r=e.index(t,n);if("eq"in o){let e=r.get().get(o.eq);if(e)for(let t of e)i[n].add(t)}else if("neq"in o){for(let[e,t]of r.get())if(e!==o.neq)for(let e of t)i[n].add(e)}else if("gt"in o){for(let[e,t]of r.get())if("number"==typeof e&&e>o.gt)for(let e of t)i[n].add(e)}if(0===i[n].size)return new Set}return function(e){if(0===e.length)return new Set;let t=e[0],n=e.slice(1),r=new Set;for(let e of t)n.every(t=>t.has(e))&&r.add(e);return r}(Object.values(i))}class em{constructor(e,t){this.recordMap=e,this.history=t}recordMap;history;indexCache=new Map;historyCache=new Map;getAllIdsForType(e){let t=new Set;for(let n of this.recordMap.values())n.typeName===e&&t.add(n.id);return t}getRecordById(e,t){let n=this.recordMap.get(t);if(n&&n.typeName===e)return n}getNestedValue(e,t){let n=e;for(let e of t){if(null==n||"object"!=typeof n)return;n=n[e]}return n}filterHistory(e){if(this.historyCache.has(e))return this.historyCache.get(e);let t=(0,o.EW)("filterHistory:"+e,(t,n)=>{if((0,o._O)(t))return this.history.get();let r=this.history.getDiffSince(n);if(r===o.c2)return this.history.get();let s={added:{},removed:{},updated:{}},a=0,l=0,d=0;for(let t of r){for(let n of(0,i.Ic)(t.added))if(n.typeName===e)if(s.removed[n.id]){let e=s.removed[n.id];delete s.removed[n.id],l--,e!==n&&(s.updated[n.id]=[e,n],d++)}else s.added[n.id]=n,a++;for(let[n,r]of(0,i.Ic)(t.updated))r.typeName===e&&(s.added[r.id]?s.added[r.id]=r:s.updated[r.id]?s.updated[r.id]=[s.updated[r.id][0],r]:(s.updated[r.id]=[n,r],d++));for(let n of(0,i.Ic)(t.removed))n.typeName===e&&(s.added[n.id]?(delete s.added[n.id],a--):(s.updated[n.id]?(s.removed[n.id]=s.updated[n.id][0],delete s.updated[n.id],d--):s.removed[n.id]=n,l++))}return a||l||d?(0,o._D)(this.history.get(),s):t},{historyLength:100});return this.historyCache.set(e,t),t}index(e,t){let n=e+":"+t;if(this.indexCache.has(n))return this.indexCache.get(n);let r=this.__uncached_createIndex(e,t);return this.indexCache.set(n,r),r}__uncached_createIndex(e,t){let n=this.filterHistory(e),r=t.split("\\"),s=r.length>1?e=>this.getNestedValue(e,r):e=>e[t],a=()=>{n.get();let t=new Map;for(let n of this.recordMap.values())if(n.typeName===e){let e=s(n);void 0!==e&&(t.has(e)||t.set(e,new Set),t.get(e).add(n.id))}return t};return(0,o.EW)("index:"+e+":"+t,(t,r)=>{let l,d;if((0,o._O)(t))return a();let c=n.getDiffSince(r);if(c===o.c2)return a();let u=new Map,h=(e,n)=>{let r=u.get(e);r||(r=new X(t.get(e)??new Set)),r.add(n),u.set(e,r)},p=(e,n)=>{let r=u.get(e);r||(r=new X(t.get(e)??new Set)),r.remove(n),u.set(e,r)};for(let t of c){for(let n of(0,i.Ic)(t.added))if(n.typeName===e){let e=s(n);void 0!==e&&h(e,n.id)}for(let[n,r]of(0,i.Ic)(t.updated))if(r.typeName===e){let e=s(n),t=s(r);e!==t&&(void 0!==e&&p(e,r.id),void 0!==t&&h(t,r.id))}for(let n of(0,i.Ic)(t.removed))if(n.typeName===e){let e=s(n);void 0!==e&&p(e,n.id)}}for(let[e,n]of u){let r=n.get();r&&(l||(l=new Map(t)),d||(d=new Map),0===r.value.size?l.delete(e):l.set(e,r.value),d.set(e,r.diff))}return l&&d?(0,o._D)(l,d):t},{historyLength:100})}record(e,t=()=>({}),n="record:"+e+(t?":"+t.toString():"")){let r=this.ids(e,t,n);return(0,o.EW)(n,()=>{for(let e of r.get())return this.recordMap.get(e)})}records(e,t=()=>({}),n="records:"+e+(t?":"+t.toString():"")){let r=this.ids(e,t,"ids:"+n);return(0,o.EW)(n,()=>Array.from(r.get(),e=>this.recordMap.get(e)),{isEqual:i.vq})}ids(e,t=()=>({}),n="ids:"+e+(t?":"+t.toString():"")){let r=this.filterHistory(e),s=()=>{r.get();let n=t();return 0===Object.keys(n).length?this.getAllIdsForType(e):eg(this,e,n)},a=e=>{let t=s(),n=function(e,t){let n={};for(let r of t)e.has(r)||(n.added??=new Set,n.added.add(r));for(let r of e)t.has(r)||(n.removed??=new Set,n.removed.add(r));return n.added||n.removed?n:void 0}(e,t);return n?(0,o._D)(t,n):e},l=(0,o.EW)("ids_query:"+n,t,{isEqual:i.n4});return(0,o.EW)("query:"+n,(t,n)=>{let d=l.get();if((0,o._O)(t))return s();if(n<l.lastChangedEpoch)return a(t);let c=r.getDiffSince(n);if(c===o.c2)return a(t);let u=new X(t);for(let t of c){for(let n of(0,i.Ic)(t.added))n.typeName===e&&ef(d,n)&&u.add(n.id);for(let[n,r]of(0,i.Ic)(t.updated))r.typeName===e&&(ef(d,r)?u.add(r.id):u.remove(r.id));for(let n of(0,i.Ic)(t.removed))n.typeName===e&&u.remove(n.id)}let h=u.get();return h?(0,o._D)(h.value,h.diff):t},{historyLength:50})}exec(e,t){let n=eg(this,e,t);return 0===n.size?o.Ml:Array.from(n,e=>this.recordMap.get(e))}}class ey{constructor(e){this.store=e}store;_beforeCreateHandlers={};_afterCreateHandlers={};_beforeChangeHandlers={};_afterChangeHandlers={};_beforeDeleteHandlers={};_afterDeleteHandlers={};_operationCompleteHandlers=[];_isEnabled=!0;isEnabled(){return this._isEnabled}setIsEnabled(e){this._isEnabled=e}handleBeforeCreate(e,t){if(!this._isEnabled)return e;let n=this._beforeCreateHandlers[e.typeName];if(n){let r=e;for(let e of n)r=e(r,t);return r}return e}handleAfterCreate(e,t){if(!this._isEnabled)return;let n=this._afterCreateHandlers[e.typeName];if(n)for(let r of n)r(e,t)}handleBeforeChange(e,t,n){if(!this._isEnabled)return t;let r=this._beforeChangeHandlers[t.typeName];if(r){let i=t;for(let t of r)i=t(e,i,n);return i}return t}handleAfterChange(e,t,n){if(!this._isEnabled)return;let r=this._afterChangeHandlers[t.typeName];if(r)for(let i of r)i(e,t,n)}handleBeforeDelete(e,t){if(!this._isEnabled)return!0;let n=this._beforeDeleteHandlers[e.typeName];if(n){for(let r of n)if(!1===r(e,t))return!1}return!0}handleAfterDelete(e,t){if(!this._isEnabled)return;let n=this._afterDeleteHandlers[e.typeName];if(n)for(let r of n)r(e,t)}handleOperationComplete(e){if(this._isEnabled)for(let t of this._operationCompleteHandlers)t(e)}register(e){let t=[];for(let[n,r]of Object.entries(e))r?.beforeCreate&&t.push(this.registerBeforeCreateHandler(n,r.beforeCreate)),r?.afterCreate&&t.push(this.registerAfterCreateHandler(n,r.afterCreate)),r?.beforeChange&&t.push(this.registerBeforeChangeHandler(n,r.beforeChange)),r?.afterChange&&t.push(this.registerAfterChangeHandler(n,r.afterChange)),r?.beforeDelete&&t.push(this.registerBeforeDeleteHandler(n,r.beforeDelete)),r?.afterDelete&&t.push(this.registerAfterDeleteHandler(n,r.afterDelete));return()=>{for(let e of t)e()}}registerBeforeCreateHandler(e,t){return this._beforeCreateHandlers[e]||(this._beforeCreateHandlers[e]=[]),this._beforeCreateHandlers[e].push(t),()=>eb(this._beforeCreateHandlers[e],t)}registerAfterCreateHandler(e,t){return this._afterCreateHandlers[e]||(this._afterCreateHandlers[e]=[]),this._afterCreateHandlers[e].push(t),()=>eb(this._afterCreateHandlers[e],t)}registerBeforeChangeHandler(e,t){return this._beforeChangeHandlers[e]||(this._beforeChangeHandlers[e]=[]),this._beforeChangeHandlers[e].push(t),()=>eb(this._beforeChangeHandlers[e],t)}registerAfterChangeHandler(e,t){return this._afterChangeHandlers[e]||(this._afterChangeHandlers[e]=[]),this._afterChangeHandlers[e].push(t),()=>eb(this._afterChangeHandlers[e],t)}registerBeforeDeleteHandler(e,t){return this._beforeDeleteHandlers[e]||(this._beforeDeleteHandlers[e]=[]),this._beforeDeleteHandlers[e].push(t),()=>eb(this._beforeDeleteHandlers[e],t)}registerAfterDeleteHandler(e,t){return this._afterDeleteHandlers[e]||(this._afterDeleteHandlers[e]=[]),this._afterDeleteHandlers[e].push(t),()=>eb(this._afterDeleteHandlers[e],t)}registerOperationCompleteHandler(e){return this._operationCompleteHandlers.push(e),()=>eb(this._operationCompleteHandlers,e)}}function eb(e,t){let n=e.indexOf(t);n>=0&&e.splice(n,1)}class ex{id;records;history=(0,o.eU)("history",0,{historyLength:1e3});query;listeners=new Set;historyAccumulator=new ew;historyReactor;cancelHistoryReactor(){}schema;props;scopedTypes;sideEffects=new ey(this);constructor(e){const{initialData:t,schema:n,id:r}=e;this.id=r??(0,i.NF)(),this.schema=n,this.props=e.props,t?this.records=new V("store",(0,i.iA)(t).map(([e,t])=>[e,q(this.schema.validateRecord(this,t,"initialize",null))])):this.records=new V("store"),this.query=new em(this.records,this.history),this.historyReactor=(0,o.Px)("Store.historyReactor",()=>{this.history.get(),this._flushHistory()},{scheduleEffect:e=>this.cancelHistoryReactor=(0,i.Uo)(e)}),this.scopedTypes={document:new Set((0,i.Ic)(this.schema.types).filter(e=>"document"===e.scope).map(e=>e.typeName)),session:new Set((0,i.Ic)(this.schema.types).filter(e=>"session"===e.scope).map(e=>e.typeName)),presence:new Set((0,i.Ic)(this.schema.types).filter(e=>"presence"===e.scope).map(e=>e.typeName))}}_flushHistory(){if(this.historyAccumulator.hasChanges())for(let{changes:e,source:t}of this.historyAccumulator.flush()){let n=null,r=null,i=null;for(let{onHistory:o,filters:s}of this.listeners)if("all"===s.source||s.source===t)if("all"!==s.scope)if("document"===s.scope){if(!(r??=this.filterChangesByScope(e,"document")))continue;o({changes:r,source:t})}else if("session"===s.scope){if(!(n??=this.filterChangesByScope(e,"session")))continue;o({changes:n,source:t})}else{if(!(i??=this.filterChangesByScope(e,"presence")))continue;o({changes:i,source:t})}else o({changes:e,source:t})}}dispose(){this.cancelHistoryReactor()}filterChangesByScope(e,t){let n={added:(0,i.J2)(e.added,(e,n)=>this.scopedTypes[t].has(n.typeName)),updated:(0,i.J2)(e.updated,(e,n)=>this.scopedTypes[t].has(n[1].typeName)),removed:(0,i.J2)(e.removed,(e,n)=>this.scopedTypes[t].has(n.typeName))};return el(n.added)||el(n.updated)||el(n.removed)?n:null}updateHistory(e){this.historyAccumulator.add({changes:e,source:this.isMergingRemoteChanges?"remote":"user"}),0===this.listeners.size&&this.historyAccumulator.clear(),this.history.set(this.history.get()+1,e)}validate(e){this.allRecords().forEach(t=>this.schema.validateRecord(this,t,e,null))}put(e,t){this.atomic(()=>{let n,r={},i={},o=!1,s=this.isMergingRemoteChanges?"remote":"user";for(let a=0,l=e.length;a<l;a++){n=e[a];let l=this.records.__unsafe__getWithoutCapture(n.id);if(l){n=this.sideEffects.handleBeforeChange(l,n,s);let e=this.schema.validateRecord(this,n,t??"updateRecord",l);if(e===l)continue;n=q(e),this.records.set(n.id,n),o=!0,r[n.id]=[l,n],this.addDiffForAfterEvent(l,n)}else n=this.sideEffects.handleBeforeCreate(n,s),o=!0,i[(n=q(n=this.schema.validateRecord(this,n,t??"createRecord",null))).id]=n,this.addDiffForAfterEvent(null,n),this.records.set(n.id,n)}o&&this.updateHistory({added:i,updated:r,removed:{}})})}remove(e){this.atomic(()=>{let t=new Set(e),n=this.isMergingRemoteChanges?"remote":"user";if(this.sideEffects.isEnabled())for(let r of e){let e=this.records.__unsafe__getWithoutCapture(r);e&&!1===this.sideEffects.handleBeforeDelete(e,n)&&t.delete(r)}let r=this.records.deleteMany(t);if(0===r.length)return;let i={};for(let[e,t]of r)i[e]=t,this.addDiffForAfterEvent(t,null);this.updateHistory({added:{},updated:{},removed:i})})}get(e){return this.records.get(e)}unsafeGetWithoutCapture(e){return this.records.__unsafe__getWithoutCapture(e)}serialize(e="document"){let t={};for(let[n,r]of this.records)("all"===e||this.scopedTypes[e].has(r.typeName))&&(t[n]=r);return t}getStoreSnapshot(e="document"){return{store:this.serialize(e),schema:this.schema.serialize()}}migrateSnapshot(e){let t=this.schema.migrateStoreSnapshot(e);if("error"===t.type)throw Error(`Failed to migrate snapshot: ${t.reason}`);return{store:t.value,schema:this.schema.serialize()}}loadStoreSnapshot(e){let t=this.schema.migrateStoreSnapshot(e);if("error"===t.type)throw Error(`Failed to migrate snapshot: ${t.reason}`);let n=this.sideEffects.isEnabled();try{this.sideEffects.setIsEnabled(!1),this.atomic(()=>{this.clear(),this.put(Object.values(t.value)),this.ensureStoreIsUsable()},!1)}finally{this.sideEffects.setIsEnabled(n)}}allRecords(){return Array.from(this.records.values())}clear(){this.remove(Array.from(this.records.keys()))}update(e,t){let n=this.unsafeGetWithoutCapture(e);n?this.put([t(n)]):console.error(`Record ${e} not found. This is probably an error`)}has(e){return this.records.has(e)}listen(e,t){this._flushHistory();let n={onHistory:e,filters:{source:t?.source??"all",scope:t?.scope??"all"}};return this.historyReactor.scheduler.isActivelyListening||(this.historyReactor.start(),this.historyReactor.scheduler.execute()),this.listeners.add(n),()=>{this.listeners.delete(n),0===this.listeners.size&&this.historyReactor.stop()}}isMergingRemoteChanges=!1;mergeRemoteChanges(e){if(this.isMergingRemoteChanges)return e();if(this._isInAtomicOp)throw Error("Cannot merge remote changes while in atomic operation");try{this.atomic(e,!0,!0)}finally{this.ensureStoreIsUsable()}}extractingChanges(e){let t=[],n=this.historyAccumulator.addInterceptor(e=>t.push(e.changes));try{return(0,o.hL)(e),ed(t)}finally{n()}}applyDiff(e,{runCallbacks:t=!0,ignoreEphemeralKeys:n=!1}={}){this.atomic(()=>{let t=(0,i.Ic)(e.added);for(let[r,o]of(0,i.Ic)(e.updated)){let e=this.schema.getType(o.typeName);if(n&&e.ephemeralKeySet.size){let n=this.get(o.id);if(!n){t.push(o);continue}let r=null;for(let[t,s]of Object.entries(o))e.ephemeralKeySet.has(t)||Object.is(s,(0,i.g5)(n,t))||(r||(r={...n}),r[t]=s);r&&t.push(r)}else t.push(o)}let r=(0,i.w$)(e.removed);t.length&&this.put(t),r.length&&this.remove(r)},t)}createCache(e){let t=new i.l;return{get:n=>{let r=this.records.getAtom(n);if(r)return t.get(r,()=>e(n,r)).get()}}}createComputedCache(e,t,n){return this.createCache((r,i)=>{let s=n?.areRecordsEqual?(0,o.EW)(`${e}:${r}:isEqual`,()=>i.get(),{isEqual:n.areRecordsEqual}):i;return(0,o.EW)(e+":"+r,()=>t(s.get()),{isEqual:n?.areResultsEqual})})}_integrityChecker;ensureStoreIsUsable(){this.atomic(()=>{this._integrityChecker??=this.schema.createIntegrityChecker(this),this._integrityChecker?.()})}_isPossiblyCorrupted=!1;markAsPossiblyCorrupted(){this._isPossiblyCorrupted=!0}isPossiblyCorrupted(){return this._isPossiblyCorrupted}pendingAfterEvents=null;addDiffForAfterEvent(e,t){if((0,i.vA)(this.pendingAfterEvents,"must be in event operation"),e===t||(e&&t&&(0,i.vA)(e.id===t.id),!e&&!t))return;let n=(e||t).id,r=this.pendingAfterEvents.get(n);r?r.after=t:this.pendingAfterEvents.set(n,{before:e,after:t})}flushAtomicCallbacks(e){let t=0,n=e?"remote":"user";for(;this.pendingAfterEvents;){let e=this.pendingAfterEvents;if(this.pendingAfterEvents=null,this.sideEffects.isEnabled()){if(++t>100)throw Error("Maximum store update depth exceeded, bailing out");for(let{before:t,after:r}of e.values())t&&r&&t!==r&&!(0,i.n4)(t,r)?this.sideEffects.handleAfterChange(t,r,n):t&&!r?this.sideEffects.handleAfterDelete(t,n):!t&&r&&this.sideEffects.handleAfterCreate(r,n);this.pendingAfterEvents?n="user":this.sideEffects.handleOperationComplete(n)}}}_isInAtomicOp=!1;atomic(e,t=!0,n=!1){return(0,o.hL)(()=>{if(this._isInAtomicOp){this.pendingAfterEvents||(this.pendingAfterEvents=new Map);let r=this.sideEffects.isEnabled();(0,i.vA)(!n,"cannot call mergeRemoteChanges while in atomic operation");try{return r&&!t&&this.sideEffects.setIsEnabled(!1),e()}finally{this.sideEffects.setIsEnabled(r)}}this.pendingAfterEvents=new Map;let r=this.sideEffects.isEnabled();this.sideEffects.setIsEnabled(t&&r),this._isInAtomicOp=!0,n&&(this.isMergingRemoteChanges=!0);try{let t=e();return this.isMergingRemoteChanges=!1,this.flushAtomicCallbacks(n),t}finally{this.pendingAfterEvents=null,this.sideEffects.setIsEnabled(r),this._isInAtomicOp=!1,this.isMergingRemoteChanges=!1}})}addHistoryInterceptor(e){return this.historyAccumulator.addInterceptor(t=>e(t,this.isMergingRemoteChanges?"remote":"user"))}}class ew{_history=[];_interceptors=new Set;addInterceptor(e){return this._interceptors.add(e),()=>{this._interceptors.delete(e)}}add(e){for(let t of(this._history.push(e),this._interceptors))t(e)}flush(){let e=function(e){let t;if(0===e.length)return[];let n=[],r=[e[0]];for(let i=1,o=e.length;i<o;i++)t=e[i],r[0].source!==t.source&&(n.push(r),r=[]),r.push(t);return n.push(r),q(n.map(e=>({source:e[0].source,changes:1===e.length?e[0].changes:ed(e.map(e=>e.changes))})))}(this._history);return this._history=[],e}clear(){this._history=[]}hasChanges(){return this._history.length>0}}function ev(e,t,n){let r=new i.l;return{get:(i,o)=>r.get(i,()=>(i instanceof ex?i:i.store).createComputedCache(e,e=>t(i,e),n)).get(o)}}class eS{constructor(e,t){for(const n of(this.types=e,this.options=t,t.migrations??[]))(0,i.vA)(!this.migrations[n.sequenceId],`Duplicate migration sequenceId ${n.sequenceId}`),en(n),this.migrations[n.sequenceId]=n;const n=Object.values(this.migrations).flatMap(e=>e.sequence);for(const e of(this.sortedMigrations=function(e){if(0===e.length)return[];let t=new Map(e.map(e=>[e.id,e])),n=new Map,r=new Map,o=new Map;for(let t of e)r.set(t.id,0),n.set(t.id,new Set),o.set(t.id,new Set);for(let i of e){let{version:e,sequenceId:s}=ee(i.id),a=`${s}/${e-1}`;if(t.has(a)&&(n.get(a).add(i.id),r.set(i.id,r.get(i.id)+1)),i.dependsOn)for(let e of i.dependsOn)t.has(e)&&(n.get(e).add(i.id),o.get(i.id).add(e),r.set(i.id,r.get(i.id)+1))}let s=e.filter(e=>0===r.get(e.id)),a=[],l=new Set;for(;s.length>0;){let e,i=-1/0;for(let t of s){let r=0;for(let e of n.get(t.id)||[])!l.has(e)&&(r+=1,o.get(e).has(t.id)&&(r+=100));(r>i||r===i&&0>t.id.localeCompare(e?.id??""))&&(e=t,i=r)}let d=e;for(let e of(s.splice(s.indexOf(d),1),a.push(d),l.add(d.id),n.get(d.id)||[]))l.has(e)||(r.set(e,r.get(e)-1),0===r.get(e)&&s.push(t.get(e)))}if(a.length!==e.length){let t=e.filter(e=>!l.has(e.id));(0,i.vA)(!1,`Circular dependency in migrations: ${t[0].id}`)}return a}(n),this.sortedMigrations))if(e.dependsOn?.length)for(const t of e.dependsOn){const r=n.find(e=>e.id===t);(0,i.vA)(r,`Migration '${e.id}' depends on missing migration '${t}'`)}}types;options;static create(e,t){return new eS(e,t??{})}migrations={};sortedMigrations;migrationCache=new WeakMap;validateRecord(e,t,n,r){try{let e=(0,i.g5)(this.types,t.typeName);if(!e)throw Error(`Missing definition for record type ${t.typeName}`);return e.validate(t,r??void 0)}catch(i){if(this.options.onValidationFailure)return this.options.onValidationFailure({store:e,record:t,phase:n,recordBefore:r,error:i});throw i}}getMigrationsSince(e){let t=this.migrationCache.get(e);if(t)return t;let n=function(e){if(e.schemaVersion>2||e.schemaVersion<1)return i.Q7.err("Bad schema version");if(2===e.schemaVersion)return i.Q7.ok(e);let t={schemaVersion:2,sequences:{"com.tldraw.store":e.storeVersion}};for(let[n,r]of Object.entries(e.recordVersions))if(t.sequences[`com.tldraw.${n}`]=r.version,"subTypeKey"in r)for(let[e,i]of Object.entries(r.subTypeVersions))t.sequences[`com.tldraw.${n}.${e}`]=i;return i.Q7.ok(t)}(e);if(!n.ok)return this.migrationCache.set(e,n),n;let r=n.value,o=new Set(Object.keys(r.sequences).filter(e=>this.migrations[e]));for(let e in this.migrations)void 0===r.sequences[e]&&this.migrations[e].retroactive&&o.add(e);if(0===o.size){let t=i.Q7.ok([]);return this.migrationCache.set(e,t),t}let s=new Set;for(let t of o){let n=r.sequences[t];if("number"!=typeof n&&this.migrations[t].retroactive||0===n){for(let e of this.migrations[t].sequence)s.add(e.id);continue}let o=`${t}/${n}`,a=this.migrations[t].sequence.findIndex(e=>e.id===o);if(-1===a){let t=i.Q7.err("Incompatible schema?");return this.migrationCache.set(e,t),t}for(let e of this.migrations[t].sequence.slice(a+1))s.add(e.id)}let a=i.Q7.ok(this.sortedMigrations.filter(({id:e})=>s.has(e)));return this.migrationCache.set(e,a),a}migratePersistedRecord(e,t,n="up"){let r=this.getMigrationsSince(t);if(!r.ok)return console.error("Error migrating record",r.error),{type:"error",reason:ei};let o=r.value;if(0===o.length)return{type:"success",value:e};if(!o.every(e=>"record"===e.scope))return{type:"error",reason:"down"===n?er:"target-version-too-new"};if("down"===n){if(!o.every(e=>"record"===e.scope&&e.down))return{type:"error",reason:er};o=o.slice().reverse()}e=(0,i.pN)(e);try{for(let t of o){if("store"===t.scope||"storage"===t.scope)throw Error();if(!(!t.filter||t.filter(e)))continue;let r=t[n](e);r&&(e=(0,i.pN)(r))}}catch(e){return console.error("Error migrating record",e),{type:"error",reason:ei}}return{type:"success",value:e}}migrateStorage(e){let t=e.getSchema();(0,i.vA)(t,"Schema is missing.");let n=this.getMigrationsSince(t);if(!n.ok)throw console.error("Error migrating store",n.error),Error(n.error);let r=n.value;if(0!==r.length){for(let t of(e.setSchema(this.serialize()),r))if("record"===t.scope){let n=[];for(let[r,o]of e.entries()){if(!(!t.filter||t.filter(o)))continue;let e=(0,i.pN)(o),s=t.up(e)??e;(0,i.n4)(s,o)||n.push([r,s])}for(let[t,r]of n)e.set(t,r)}else if("store"===t.scope){let n=Object.fromEntries(e.entries()),r=(0,i.pN)(n);for(let[o,s]of Object.entries(r=t.up(r)??r))s&&((0,i.n4)(s,n[o])||e.set(o,s));for(let t of Object.keys(n))r[t]||e.delete(t)}else"storage"===t.scope?t.up(e):(0,i.h6)(t);for(let[t,n]of e.entries())"document"!==this.getType(n.typeName).scope&&e.delete(t)}}migrateStoreSnapshot(e,t){let n=this.getMigrationsSince(e.schema);if(!n.ok)return console.error("Error migrating store",n.error),{type:"error",reason:ei};if(0===n.value.length)return{type:"success",value:e.store};let r=Object.assign(new Map((0,i.iA)(e.store).map(q)),{getSchema:()=>e.schema,setSchema:e=>{}});try{if(this.migrateStorage(r),!t?.mutateInputStore)return{type:"success",value:Object.fromEntries(r.entries())};for(let[t,n]of r.entries())e.store[t]=n;for(let t of Object.keys(e.store))r.has(t)||delete e.store[t];return{type:"success",value:e.store}}catch(e){return console.error("Error migrating store",e),{type:"error",reason:ei}}}createIntegrityChecker(e){return this.options.createIntegrityChecker?.(e)??void 0}serialize(){return{schemaVersion:2,sequences:Object.fromEntries(Object.values(this.migrations).map(({sequenceId:e,sequence:t})=>[e,t.length?ee(t.at(-1).id).version:0]))}}serializeEarliestVersion(){return{schemaVersion:2,sequences:Object.fromEntries(Object.values(this.migrations).map(({sequenceId:e})=>[e,0]))}}getType(e){let t=(0,i.g5)(this.types,e);return(0,i.vA)(t,"record type does not exist"),t}}(0,i.lF)("@tldraw/store","5.3.2","esm")},54939:(e,t,n)=>{"use strict";n.d(t,{V:()=>s});var r=n(59830),i=n(93286),o=n(46195);class s{constructor(e,t,n,r,i,o){this.a=e,this.b=t,this.c=n,this.d=r,this.e=i,this.f=o}a=1;b=0;c=0;d=1;e=0;f=0;equals(e){return this===e||this.a===e.a&&this.b===e.b&&this.c===e.c&&this.d===e.d&&this.e===e.e&&this.f===e.f}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0,this}multiply(e){let{a:t,b:n,c:r,d:i,e:o,f:s}=this;return this.a=t*e.a+r*e.b,this.c=t*e.c+r*e.d,this.e=t*e.e+r*e.f+o,this.b=n*e.a+i*e.b,this.d=n*e.c+i*e.d,this.f=n*e.e+i*e.f+s,this}rotate(e,t,n){return 0===e?this:void 0===t?this.multiply(s.Rotate(e)):this.translate(t,n).multiply(s.Rotate(e)).translate(-t,-n)}translate(e,t){return this.multiply(s.Translate(e,t))}scale(e,t){return this.multiply(s.Scale(e,t))}invert(){let{a:e,b:t,c:n,d:r,e:i,f:o}=this,s=e*r-t*n;return this.a=r/s,this.b=-(t/s),this.c=-(n/s),this.d=e/s,this.e=-((r*i-n*o)/s),this.f=(t*i-e*o)/s,this}applyToPoint(e){return s.applyToPoint(this,e)}applyToPoints(e){return s.applyToPoints(this,e)}rotation(){return s.Rotation(this)}point(){return s.Point(this)}decomposed(){return s.Decompose(this)}toCssString(){return s.toCssString(this)}setTo(e){return Object.assign(this,e),this}decompose(){return s.Decompose(this)}clone(){return new s(this.a,this.b,this.c,this.d,this.e,this.f)}static Identity(){return new s(1,0,0,1,0,0)}static Translate(e,t){return new s(1,0,0,1,e,t)}static Rotate(e,t,n){if(0===e)return s.Identity();let r=Math.cos(e),i=Math.sin(e),o=new s(r,i,-i,r,0,0);return void 0===t?o:s.Compose(s.Translate(t,n),o,s.Translate(-t,-n))}static Scale(e,t,n,r){let i=new s(e,0,0,t,0,0);return void 0===n?i:s.Translate(n,r).multiply(i).translate(-n,-r)}static Multiply(e,t){return{a:e.a*t.a+e.c*t.b,c:e.a*t.c+e.c*t.d,e:e.a*t.e+e.c*t.f+e.e,b:e.b*t.a+e.d*t.b,d:e.b*t.c+e.d*t.d,f:e.b*t.e+e.d*t.f+e.f}}static Inverse(e){let t=e.a*e.d-e.b*e.c;return{a:e.d/t,b:-(e.b/t),c:-(e.c/t),d:e.a/t,e:-((e.d*e.e-e.c*e.f)/t),f:(e.b*e.e-e.a*e.f)/t}}static Absolute(e){let t=e.a*e.d-e.b*e.c;return{a:e.d/t,b:-(e.b/t),c:-(e.c/t),d:e.a/t,e:(e.d*e.e-e.c*e.f)/t,f:-((e.b*e.e-e.a*e.f)/t)}}static Compose(...e){let t=s.Identity();for(let n=0,r=e.length;n<r;n++)t.multiply(e[n]);return t}static Point(e){return new o.l(e.e,e.f)}static Rotation(e){let t;if(0!==e.a||0!==e.c){let n=(e.a*e.a+e.c*e.c)**.5;t=Math.acos(e.a/n)*(e.c>0?-1:1)}else if(0!==e.b||0!==e.d){let n=(e.b*e.b+e.d*e.d)**.5;t=i.sK+Math.acos(e.b/n)*(e.d>0?-1:1)}else t=0;return(0,i.yD)(t)}static Decompose(e){let t,n,r;if(0!==e.a||0!==e.c){let i=(e.a*e.a+e.c*e.c)**.5;t=i,n=(e.a*e.d-e.b*e.c)/i,r=Math.acos(e.a/i)*(e.c>0?-1:1)}else if(0!==e.b||0!==e.d){let o=(e.b*e.b+e.d*e.d)**.5;t=(e.a*e.d-e.b*e.c)/o,n=o,r=i.sK+Math.acos(e.b/o)*(e.d>0?-1:1)}else t=0,n=0,r=0;return{x:e.e,y:e.f,scaleX:t,scaleY:n,rotation:(0,i.yD)(r)}}static Smooth(e,t=1e10){return e.a=Math.round(e.a*t)/t,e.b=Math.round(e.b*t)/t,e.c=Math.round(e.c*t)/t,e.d=Math.round(e.d*t)/t,e.e=Math.round(e.e*t)/t,e.f=Math.round(e.f*t)/t,e}static toCssString(e){return`matrix(${(0,i.WM)(e.a)}, ${(0,i.WM)(e.b)}, ${(0,i.WM)(e.c)}, ${(0,i.WM)(e.d)}, ${(0,i.WM)(e.e)}, ${(0,i.WM)(e.f)})`}static applyToPoint(e,t){return new o.l(e.a*t.x+e.c*t.y+e.e,e.b*t.x+e.d*t.y+e.f,t.z)}static applyToXY(e,t,n){return[e.a*t+e.c*n+e.e,e.b*t+e.d*n+e.f]}static applyToPoints(e,t){return t.map(t=>new o.l(e.a*t.x+e.c*t.y+e.e,e.b*t.x+e.d*t.y+e.f,t.z))}static applyToBounds(e,t){return new r.az(e.e+t.minX,e.f+t.minY,t.width,t.height)}static From(e){return new s(e.a,e.b,e.c,e.d,e.e,e.f)}static Cast(e){return e instanceof s?e:s.From(e)}}},55667:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(46195),i=n(27164);class o extends i.vq{_start;_end;_dx;_dy;_len2;constructor(e){super({...e,isClosed:!1,isFilled:!1});const{start:t,end:n}=e;this._start=t,this._end=n,this._dx=n.x-t.x,this._dy=n.y-t.y,this._len2=this._dx*this._dx+this._dy*this._dy}getLength(){return Math.sqrt(this._len2)}getVertices(){return[this._start,this._end]}nearestPoint(e){let{_start:t,_end:n,_dx:i,_dy:o,_len2:s}=this;if(0===s)return t;let a=((e.x-t.x)*i+(e.y-t.y)*o)/s;return a<=0?t:a>=1?n:new r.l(t.x+i*a,t.y+o*a)}distanceToPoint(e,t=!1){let n,i,{_start:o,_end:s,_dx:a,_dy:l,_len2:d}=this;if(0===d)return r.l.Dist(e,o);let c=((e.x-o.x)*a+(e.y-o.y)*l)/d;c<=0?(n=o.x,i=o.y):c>=1?(n=s.x,i=s.y):(n=o.x+a*c,i=o.y+l*c);let u=e.x-n,h=e.y-i;return Math.sqrt(u*u+h*h)}getSvgPathData(e=!0){let{_start:t,_end:n}=this;return`${e?`M${t.toFixed()}`:""} L${n.toFixed()}`}}},58347:(e,t,n)=>{"use strict";n.d(t,{Z:()=>r});let r={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>e*(2-e),easeInOutQuad:e=>e<.5?2*e*e:-1+(4-2*e)*e,easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1,easeInQuart:e=>e*e*e*e,easeOutQuart:e=>1- --e*e*e*e,easeInOutQuart:e=>e<.5?8*e*e*e*e:1-8*--e*e*e*e,easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>1+--e*e*e*e*e,easeInOutQuint:e=>e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e,easeInSine:e=>1-Math.cos(e*Math.PI/2),easeOutSine:e=>Math.sin(e*Math.PI/2),easeInOutSine:e=>-(Math.cos(Math.PI*e)-1)/2,easeInExpo:e=>e<=0?0:Math.pow(2,10*e-10),easeOutExpo:e=>e>=1?1:1-Math.pow(2,-10*e),easeInOutExpo:e=>e<=0?0:e>=1?1:e<.5?Math.pow(2,20*e-10)/2:(2-Math.pow(2,-20*e+10))/2}},58929:(e,t,n)=>{"use strict";n.d(t,{N:()=>f});var r=n(83102),i=n(24167),o=n(59830),s=n(54939),a=n(93286),l=n(46195),d=Object.defineProperty,c=Object.getOwnPropertyDescriptor,u=(e,t,n,r)=>{for(var i,o=r>1?void 0:r?c(t,n):t,s=e.length-1;s>=0;s--)(i=e[s])&&(o=(r?i(t,n,o):i(o))||o);return r&&o&&d(t,n,o),o};let h=e=>Math.round(1e8*e)/1e8;function p(e,t,n,r,i){let o=e.filter(e=>("forward"===r?e.startNode.id===t:e.endNode.id===t)&&h(e.length)===h(n)&&(0,a.$C)(e.breadthIntersection[0],e.breadthIntersection[1],i[0],i[1]));if(0===o.length)return[];let s=new Set;return o.forEach(t=>{let l="forward"===r?t.endNode.id:t.startNode.id;if(!s.has(l)){s.add(l);let d=p(e,l,n,r,(0,a.$C)(t.breadthIntersection[0],t.breadthIntersection[1],i[0],i[1]));o.push(...d)}}),o}class f{constructor(e){this.manager=e,this.editor=e.editor}manager;editor;getSnapPointsCache(){let{editor:e}=this;return e.store.createComputedCache("snapPoints",t=>{let n=e.getShapePageTransform(t.id);if(!n)return;let r=e.getShapeUtil(t).getBoundsSnapGeometry(t).points??e.getShapeGeometry(t).bounds.cornersAndCenter;if(n&&r)return r.map((e,r)=>{let{x:i,y:o}=s.V.applyToPoint(n,e);return{x:i,y:o,id:`${t.id}:${r}`}})})}getSnapPoints(e){return this.getSnapPointsCache().get(e)??[]}getSnappablePoints(){let e=this.getSnapPointsCache(),t=this.manager.getSnappableShapes(),n=[];for(let r of t){let t=e.get(r);t&&n.push(...t)}return n}getSnappableGapNodes(){return Array.from(this.manager.getSnappableShapes(),e=>({id:e,pageBounds:(0,i.Z1)(this.editor.getShapePageBounds(e))}))}getVisibleGaps(){let e,t,n=[],r=[],i=this.getSnappableGapNodes().sort((e,t)=>e.pageBounds.minX-t.pageBounds.minX);for(let r=0;r<i.length;r++){e=i[r];for(let o=r+1;o<i.length;o++)t=i[o],e.pageBounds.maxX<t.pageBounds.minX&&(0,a.g6)(e.pageBounds.minY,e.pageBounds.maxY,t.pageBounds.minY,t.pageBounds.maxY)&&n.push({startNode:e,endNode:t,startEdge:[new l.l(e.pageBounds.maxX,e.pageBounds.minY),new l.l(e.pageBounds.maxX,e.pageBounds.maxY)],endEdge:[new l.l(t.pageBounds.minX,t.pageBounds.minY),new l.l(t.pageBounds.minX,t.pageBounds.maxY)],length:t.pageBounds.minX-e.pageBounds.maxX,breadthIntersection:(0,a.$C)(e.pageBounds.minY,e.pageBounds.maxY,t.pageBounds.minY,t.pageBounds.maxY)})}let o=i.sort((e,t)=>e.pageBounds.minY-t.pageBounds.minY);for(let n=0;n<o.length;n++){e=o[n];for(let i=n+1;i<o.length;i++)t=o[i],e.pageBounds.maxY<t.pageBounds.minY&&(0,a.g6)(e.pageBounds.minX,e.pageBounds.maxX,t.pageBounds.minX,t.pageBounds.maxX)&&r.push({startNode:e,endNode:t,startEdge:[new l.l(e.pageBounds.minX,e.pageBounds.maxY),new l.l(e.pageBounds.maxX,e.pageBounds.maxY)],endEdge:[new l.l(t.pageBounds.minX,t.pageBounds.minY),new l.l(t.pageBounds.maxX,t.pageBounds.minY)],length:t.pageBounds.minY-e.pageBounds.maxY,breadthIntersection:(0,a.$C)(e.pageBounds.minX,e.pageBounds.maxX,t.pageBounds.minX,t.pageBounds.maxX)})}return{horizontal:n,vertical:r}}snapTranslateShapes({lockedAxis:e,initialSelectionPageBounds:t,initialSelectionSnapPoints:n,dragDelta:r}){let i=this.manager.getSnapThreshold(),o=this.getSnappablePoints(),s=t.clone().translate(r),a=n.map(({x:e,y:t},n)=>({id:"selection:"+n,x:e+r.x,y:t+r.y})),d=[],c=[],u=new l.l(i,i);this.collectPointSnaps({minOffset:u,nearestSnapsX:d,nearestSnapsY:c,otherNodeSnapPoints:o,selectionSnapPoints:a}),this.collectGapSnaps({selectionPageBounds:s,nearestSnapsX:d,nearestSnapsY:c,minOffset:u});let h=new l.l("x"===e?0:d[0]?.nudge??0,"y"===e?0:c[0]?.nudge??0);u.x=0,u.y=0,d.length=0,c.length=0,a.forEach(e=>{e.x+=h.x,e.y+=h.y}),s.translate(h),this.collectPointSnaps({minOffset:u,nearestSnapsX:d,nearestSnapsY:c,otherNodeSnapPoints:o,selectionSnapPoints:a}),this.collectGapSnaps({selectionPageBounds:s,nearestSnapsX:d,nearestSnapsY:c,minOffset:u});let p=this.getPointSnapLines({nearestSnapsX:d,nearestSnapsY:c}),f=this.getGapSnapLines({selectionPageBounds:s,nearestSnapsX:d,nearestSnapsY:c});return this.manager.setIndicators([...f,...p]),{nudge:h}}snapResizeShapes({initialSelectionPageBounds:e,dragDelta:t,handle:n,isAspectRatioLocked:r,isResizingFromCenter:i}){let s=this.manager.getSnapThreshold(),{box:a,scaleX:d,scaleY:c}=o.az.Resize(e,n,i?2*t.x:t.x,i?2*t.y:t.y,r),u=n;d<0&&(u=(0,o.mB)(u)),c<0&&(u=(0,o.tU)(u)),i&&(a.center=e.center);let h="top"===u||"bottom"===u,p="left"===u||"right"===u,f=g(u,a),m=this.getSnappablePoints(),y=[],b=[],x=new l.l(s,s);this.collectPointSnaps({minOffset:x,nearestSnapsX:y,nearestSnapsY:b,otherNodeSnapPoints:m,selectionSnapPoints:f});let w=new l.l(h?0:y[0]?.nudge??0,p?0:b[0]?.nudge??0);if(r&&(0,o.UB)(u)&&0!==w.len()){let t=y.length&&b.length?Math.abs(w.x)<Math.abs(w.y)?"x":"y":y.length?"x":"y",n=e.aspectRatio;"x"===t?(b.length=0,w.y=w.x/n,("bottom_left"===u||"top_right"===u)&&(w.y=-w.y)):(y.length=0,w.x=w.y*n,("bottom_left"===u||"top_right"===u)&&(w.x=-w.x))}let v=l.l.Add(t,w),{box:S}=o.az.Resize(e,n,i?2*v.x:v.x,i?2*v.y:v.y,r);i&&(S.center=e.center);let C=g("any",S);y.length=0,b.length=0,x.x=0,x.y=0,this.collectPointSnaps({minOffset:x,nearestSnapsX:y,nearestSnapsY:b,otherNodeSnapPoints:m,selectionSnapPoints:C});let k=this.getPointSnapLines({nearestSnapsX:y,nearestSnapsY:b});return this.manager.setIndicators([...k]),{nudge:w}}collectPointSnaps({selectionSnapPoints:e,otherNodeSnapPoints:t,minOffset:n,nearestSnapsX:r,nearestSnapsY:i}){for(let o of e)for(let e of t){let t=l.l.Sub(o,e),s=Math.abs(t.x),a=Math.abs(t.y);h(s)<=h(n.x)&&(h(s)<h(n.x)&&(r.length=0),r.push({type:"points",points:{thisPoint:o,otherPoint:e},nudge:e.x-o.x}),n.x=s),h(a)<=h(n.y)&&(h(a)<h(n.y)&&(i.length=0),i.push({type:"points",points:{thisPoint:o,otherPoint:e},nudge:e.y-o.y}),n.y=a)}}collectGapSnaps({selectionPageBounds:e,minOffset:t,nearestSnapsX:n,nearestSnapsY:r}){let{horizontal:i,vertical:o}=this.getVisibleGaps();for(let r of i){if(!(0,a.g6)(r.breadthIntersection[0],r.breadthIntersection[1],e.minY,e.maxY))continue;let i=r.startEdge[0].x+r.length/2-e.center.x;if(r.length>e.width&&h(Math.abs(i))<=h(t.x)){h(Math.abs(i))<h(t.x)&&(n.length=0),t.x=Math.abs(i);let e={type:"gap_center",gap:r,nudge:i},o=n.find(({type:e})=>"gap_center"===e),s=o&&(0,a.$C)(r.breadthIntersection[0],r.breadthIntersection[1],o.gap.breadthIntersection[0],o.gap.breadthIntersection[1]);o&&o.gap.length>r.length&&s?n[n.indexOf(o)]=e:o&&s||n.push(e)}let o=r.startNode.pageBounds.minX-r.length-e.maxX;h(Math.abs(o))<=h(t.x)&&(h(Math.abs(o))<h(t.x)&&(n.length=0),t.x=Math.abs(o),n.push({type:"gap_duplicate",gap:r,protrusionDirection:"left",nudge:o}));let s=r.endNode.pageBounds.maxX+r.length-e.minX;h(Math.abs(s))<=h(t.x)&&(h(Math.abs(s))<h(t.x)&&(n.length=0),t.x=Math.abs(s),n.push({type:"gap_duplicate",gap:r,protrusionDirection:"right",nudge:s}))}for(let n of o){if(!(0,a.g6)(n.breadthIntersection[0],n.breadthIntersection[1],e.minX,e.maxX))continue;let i=n.startEdge[0].y+n.length/2-e.center.y;if(n.length>e.height&&h(Math.abs(i))<=h(t.y)){h(Math.abs(i))<h(t.y)&&(r.length=0),t.y=Math.abs(i);let e={type:"gap_center",gap:n,nudge:i},o=r.find(({type:e})=>"gap_center"===e),s=o&&(0,a.g6)(o.gap.breadthIntersection[0],o.gap.breadthIntersection[1],n.breadthIntersection[0],n.breadthIntersection[1]);o&&o.gap.length>n.length&&s?r[r.indexOf(o)]=e:o&&s||r.push(e);continue}let o=n.startNode.pageBounds.minY-n.length-e.maxY;h(Math.abs(o))<=h(t.y)&&(h(Math.abs(o))<h(t.y)&&(r.length=0),t.y=Math.abs(o),r.push({type:"gap_duplicate",gap:n,protrusionDirection:"top",nudge:o}));let s=n.endNode.pageBounds.maxY+n.length-e.minY;h(Math.abs(s))<=h(t.y)&&(h(Math.abs(s))<h(t.y)&&(r.length=0),t.y=Math.abs(s),r.push({type:"gap_duplicate",gap:n,protrusionDirection:"bottom",nudge:s}))}}getPointSnapLines({nearestSnapsX:e,nearestSnapsY:t}){let n={},r={};if(e.length>0){for(let t of e)if("points"===t.type){let e=h(t.points.otherPoint.x);n[e]||(n[e]=[]),n[e].push(t.points)}}if(t.length>0){for(let e of t)if("points"===e.type){let t=h(e.points.otherPoint.y);r[t]||(r[t]=[]),r[t].push(e.points)}}return Object.values(n).concat(Object.values(r)).map(e=>({id:(0,i.NF)(),type:"points",points:(0,i.Qq)(e.map(e=>l.l.From(e.otherPoint)).concat(e.map(e=>l.l.From(e.thisPoint))),(e,t)=>e.equals(t))}))}getGapSnapLines({selectionPageBounds:e,nearestSnapsX:t,nearestSnapsY:n}){let{vertical:r,horizontal:o}=this.getVisibleGaps(),s={top:e.sides[0],right:e.sides[1],bottom:[e.corners[3],e.corners[2]],left:[e.corners[0],e.corners[3]]},l=[];if(t.length>0)for(let n of t){if("points"===n.type)continue;let{gap:{breadthIntersection:t,startEdge:r,startNode:d,endNode:c,length:u,endEdge:h}}=n;switch(n.type){case"gap_center":{let n=(u-e.width)/2,f=(0,a.$C)(t[0],t[1],e.minY,e.maxY);l.push({type:"gaps",direction:"horizontal",id:(0,i.NF)(),gaps:[...p(o,d.id,n,"backward",f),{startEdge:r,endEdge:s.left},{startEdge:s.right,endEdge:h},...p(o,c.id,n,"forward",f)]});break}case"gap_duplicate":{let f=(0,a.$C)(t[0],t[1],e.minY,e.maxY);l.push({type:"gaps",direction:"horizontal",id:(0,i.NF)(),gaps:"left"===n.protrusionDirection?[{startEdge:s.right,endEdge:r.map(e=>e.clone().addXY(-d.pageBounds.width,0))},{startEdge:r,endEdge:h},...p(o,c.id,u,"forward",f)]:[...p(o,d.id,u,"backward",f),{startEdge:r,endEdge:h},{startEdge:h.map(e=>e.clone().addXY(n.gap.endNode.pageBounds.width,0)),endEdge:s.left}]})}}}if(n.length>0)for(let t of n){if("points"===t.type)continue;let{gap:{breadthIntersection:n,startEdge:o,startNode:d,endNode:c,length:u,endEdge:h}}=t;switch(t.type){case"gap_center":{let c=(u-e.height)/2,f=(0,a.$C)(n[0],n[1],e.minX,e.maxX);l.push({type:"gaps",direction:"vertical",id:(0,i.NF)(),gaps:[...p(r,d.id,c,"backward",f),{startEdge:o,endEdge:s.top},{startEdge:s.bottom,endEdge:h},...p(r,t.gap.endNode.id,c,"forward",f)]});break}case"gap_duplicate":{let f=(0,a.$C)(n[0],n[1],e.minX,e.maxX);l.push({type:"gaps",direction:"vertical",id:(0,i.NF)(),gaps:"top"===t.protrusionDirection?[{startEdge:s.bottom,endEdge:o.map(e=>e.clone().addXY(0,-d.pageBounds.height))},{startEdge:o,endEdge:h},...p(r,c.id,u,"forward",f)]:[...p(r,d.id,u,"backward",f),{startEdge:o,endEdge:h},{startEdge:h.map(e=>e.clone().addXY(0,c.pageBounds.height)),endEdge:s.top}]})}}}l.sort((e,t)=>t.gaps.length-e.gaps.length);for(let e=l.length-1;e>0;e--){let t=l[e];for(let n=e-1;n>=0;n--){let r=l[n];if(r.direction===t.direction&&t.gaps.every(e=>r.gaps.some(t=>h(e.startEdge[0].x)===h(t.startEdge[0].x)&&h(e.startEdge[0].y)===h(t.startEdge[0].y)&&h(e.startEdge[1].x)===h(t.startEdge[1].x)&&h(e.startEdge[1].y)===h(t.startEdge[1].y))&&r.gaps.some(t=>h(e.endEdge[0].x)===h(t.endEdge[0].x)&&h(e.endEdge[0].y)===h(t.endEdge[0].y)&&h(e.endEdge[1].x)===h(t.endEdge[1].x)&&h(e.endEdge[1].y)===h(t.endEdge[1].y)))){l.splice(e,1);break}}}return l}}function g(e,t){let{minX:n,maxX:r,minY:i,maxY:o}=t,s=[];switch(e){case"top":case"left":case"top_left":case"any":s.push({id:"top_left",handle:"top_left",x:n,y:i})}switch(e){case"top":case"right":case"top_right":case"any":s.push({id:"top_right",handle:"top_right",x:r,y:i})}switch(e){case"bottom":case"right":case"bottom_right":case"any":s.push({id:"bottom_right",handle:"bottom_right",x:r,y:o})}switch(e){case"bottom":case"left":case"bottom_left":case"any":s.push({id:"bottom_left",handle:"bottom_left",x:n,y:o})}return s}u([r.EW],f.prototype,"getSnapPointsCache",1),u([r.EW],f.prototype,"getSnappablePoints",1),u([r.EW],f.prototype,"getSnappableGapNodes",1),u([r.EW],f.prototype,"getVisibleGaps",1)},59466:(e,t,n)=>{"use strict";n.d(t,{Jr:()=>m,Os:()=>u,WK:()=>y,e6:()=>g});var r=n(83102),i=n(81467),o=n(24167),s=n(22690),a=n(13982),l=n(16038);let d="TLDRAW_TAB_ID_v2",c=globalThis.window,u=c?c[d]??(0,o._9)(d)??"TLDRAW_INSTANCE_STATE_V1_"+(0,o.NF)():"<error>";c&&(c[d]=u,c&&(["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes((0,l.CM)().navigator.platform)||a.Y.isDarwin&&"ontouchend"in(0,l.jL)())?(0,o.dQ)(d,u):(0,o.ZJ)(d)),void 0!==c&&(0,l.CM)().addEventListener("beforeunload",()=>{(0,o.dQ)(d,u)});let h={Initial:0},p=Math.max(...Object.values(h)),f=s.T.object({version:s.T.number,currentPageId:i.ny.optional(),isFocusMode:s.T.boolean.optional(),exportBackground:s.T.boolean.optional(),isDebugMode:s.T.boolean.optional(),isToolLocked:s.T.boolean.optional(),isGridMode:s.T.boolean.optional(),pageStates:s.T.arrayOf(s.T.object({pageId:i.ny,camera:s.T.object({x:s.T.number,y:s.T.number,z:s.T.number}).optional(),selectedShapeIds:s.T.arrayOf(i.zo).optional(),focusedGroupId:i.zo.nullable().optional()})).optional()});function g(e){let t=e.query.ids("page");return(0,r.EW)("sessionStateSnapshot",()=>{let n=e.get(i.O9);if(!n)return null;let r=[...t.get()];return{version:p,currentPageId:n.currentPageId,exportBackground:n.exportBackground,isFocusMode:n.isFocusMode,isDebugMode:n.isDebugMode,isToolLocked:n.isToolLocked,isGridMode:n.isGridMode,pageStates:r.map(t=>{let n=e.get(i.jA.createId(t)),r=e.get(i.Xu.createId(t));return{pageId:t,camera:{x:r?.x??0,y:r?.y??0,z:r?.z??1},selectedShapeIds:n?.selectedShapeIds??[],focusedGroupId:n?.focusedGroupId??null}})}},{isEqual:o.n4})}function m(e,t,n){let r=function(e){if(!e||"object"!=typeof e)return console.warn("Invalid instance state"),null;if(!("version"in e)||"number"!=typeof e.version)return console.warn("No version in instance state"),null;if(e.version!==p){var t;(t=e=(0,o.pN)(e)).version,h.Initial,t.version=p}try{return f.validate(e)}catch(e){return console.warn(e),null}}(t);if(!r)return;let s=e.get(i.O9),a=(0,i.Pu)(s),l=n?.forceOverwrite?r:a,d=n?.forceOverwrite?a:r,c=e.schema.types.instance.create({id:i.O9,...a,currentPageId:r.currentPageId??s?.currentPageId,isDebugMode:l?.isDebugMode??d?.isDebugMode,isFocusMode:l?.isFocusMode??d?.isFocusMode,isToolLocked:l?.isToolLocked??d?.isToolLocked,isGridMode:l?.isGridMode??d?.isGridMode,exportBackground:l?.exportBackground??d?.exportBackground});e.atomic(()=>{for(let t of r.pageStates??[]){if(!e.has(t.pageId))continue;let n=i.Xu.createId(t.pageId),r=i.jA.createId(t.pageId),o=e.get(n),s=e.get(r);e.put([i.Xu.create({id:n,x:t.camera?.x??o?.x,y:t.camera?.y??o?.y,z:t.camera?.z??o?.z}),i.jA.create({id:r,pageId:t.pageId,selectedShapeIds:t.selectedShapeIds??s?.selectedShapeIds,focusedGroupId:t.focusedGroupId??s?.focusedGroupId})])}e.put([c]),e.ensureStoreIsUsable()})}function y(e){let t=[];for(let n of Object.values(e))n.typeName?.match(/^(instance.*|pointer|camera)$/)&&t.push(n);let n=t.filter(e=>"instance"===e.typeName&&e.id!==i.O9)[0];if(!n)return null;let r={version:p,currentPageId:n.currentPageId,exportBackground:!!n.exportBackground,isFocusMode:!!n.isFocusMode,isDebugMode:!!n.isDebugMode,isToolLocked:!!n.isToolLocked,isGridMode:!1,pageStates:t.filter(e=>"instance_page_state"===e.typeName&&e.instanceId===n.id).map(t=>{let n=e[t.cameraId]??{x:0,y:0,z:1};return{pageId:t.pageId,camera:{x:n.x,y:n.y,z:n.z},selectedShapeIds:t.selectedShapeIds,focusedGroupId:t.focusedGroupId}})};try{return f.validate(r),r}catch{return null}}},59830:(e,t,n)=>{"use strict";n.d(t,{UB:()=>c,Wj:()=>d,az:()=>o,mB:()=>a,tU:()=>s});var r=n(93286),i=n(46195);class o{constructor(e=0,t=0,n=0,r=0){this.x=e,this.y=t,this.w=n,this.h=r}x=0;y=0;w=0;h=0;get point(){return new i.l(this.x,this.y)}set point(e){this.x=e.x,this.y=e.y}get minX(){return this.x}set minX(e){this.x=e}get left(){return this.x}get midX(){return this.x+this.w/2}get maxX(){return this.x+this.w}get right(){return this.x+this.w}get minY(){return this.y}set minY(e){this.y=e}get top(){return this.y}get midY(){return this.y+this.h/2}get maxY(){return this.y+this.h}get bottom(){return this.y+this.h}get width(){return this.w}set width(e){this.w=e}get height(){return this.h}set height(e){this.h=e}get aspectRatio(){return this.width/this.height}get center(){return new i.l(this.x+this.w/2,this.y+this.h/2)}set center(e){this.x=e.x-this.w/2,this.y=e.y-this.h/2}get corners(){return[new i.l(this.x,this.y),new i.l(this.x+this.w,this.y),new i.l(this.x+this.w,this.y+this.h),new i.l(this.x,this.y+this.h)]}get cornersAndCenter(){return[new i.l(this.x,this.y),new i.l(this.x+this.w,this.y),new i.l(this.x+this.w,this.y+this.h),new i.l(this.x,this.y+this.h),new i.l(this.x+this.w/2,this.y+this.h/2)]}get sides(){let{corners:e}=this;return[[e[0],e[1]],[e[1],e[2]],[e[2],e[3]],[e[3],e[0]]]}get size(){return new i.l(this.w,this.h)}isValid(){return Number.isFinite(this.x)&&Number.isFinite(this.y)&&Number.isFinite(this.w)&&Number.isFinite(this.h)}toFixed(){return this.x=(0,r.QX)(this.x),this.y=(0,r.QX)(this.y),this.w=(0,r.QX)(this.w),this.h=(0,r.QX)(this.h),this}setTo(e){return this.x=e.x,this.y=e.y,this.w=e.w,this.h=e.h,this}set(e=0,t=0,n=0,r=0){return this.x=e,this.y=t,this.w=n,this.h=r,this}expand(e){let t=Math.min(this.x,e.x),n=Math.min(this.y,e.y),r=Math.max(this.x+this.w,e.x+e.w),i=Math.max(this.y+this.h,e.y+e.h);return this.x=t,this.y=n,this.w=r-t,this.h=i-n,this}expandBy(e){return this.x-=e,this.y-=e,this.w+=2*e,this.h+=2*e,this}scale(e){return this.x/=e,this.y/=e,this.w/=e,this.h/=e,this}clone(){let{x:e,y:t,w:n,h:r}=this;return new o(e,t,n,r)}translate(e){return this.x+=e.x,this.y+=e.y,this}snapToGrid(e){let t=Math.round(this.x/e)*e,n=Math.round(this.y/e)*e,r=Math.round((this.x+this.w)/e)*e,i=Math.round((this.y+this.h)/e)*e;this.minX=t,this.minY=n,this.width=Math.max(1,r-t),this.height=Math.max(1,i-n)}collides(e){return o.Collides(this,e)}contains(e){return o.Contains(this,e)}includes(e){return o.Includes(this,e)}containsPoint(e,t=0){return o.ContainsPoint(this,e,t)}getHandlePoint(e){switch(e){case"top_left":return new i.l(this.x,this.y);case"top_right":return new i.l(this.x+this.w,this.y);case"bottom_left":return new i.l(this.x,this.y+this.h);case"bottom_right":return new i.l(this.x+this.w,this.y+this.h);case"top":return new i.l(this.x+this.w/2,this.y);case"right":return new i.l(this.x+this.w,this.y+this.h/2);case"bottom":return new i.l(this.x+this.w/2,this.y+this.h);case"left":return new i.l(this.x,this.y+this.h/2)}}toJson(){return{x:this.x,y:this.y,w:this.w,h:this.h}}resize(e,t,n){let{minX:r,minY:i,maxX:o,maxY:s}=this,{minX:a,minY:l,maxX:d,maxY:c}=this;switch(e){case"left":case"top_left":case"bottom_left":a+=t;break;case"right":case"top_right":case"bottom_right":d+=t}switch(e){case"top":case"top_left":case"top_right":l+=n;break;case"bottom":case"bottom_left":case"bottom_right":c+=n}let u=(c-l)/(s-i);if((d-a)/(o-r)<0){let e=d;d=a,a=e}if(u<0){let e=c;c=l,l=e}this.minX=a,this.minY=l,this.width=Math.abs(d-a),this.height=Math.abs(c-l)}union(e){let t=Math.min(this.x,e.x),n=Math.min(this.y,e.y),r=Math.max(this.x+this.w,e.x+e.w),i=Math.max(this.y+this.h,e.y+e.h);return this.x=t,this.y=n,this.width=r-t,this.height=i-n,this}static From(e){return new o(e.x,e.y,e.w,e.h)}static FromCenter(e,t){return new o(e.x-t.x/2,e.y-t.y/2,t.x,t.y)}static FromPoints(e){let t;if(0===e.length)return new o;let n=1/0,r=1/0,i=-1/0,s=-1/0;for(let o=0,a=e.length;o<a;o++)n=Math.min((t=e[o]).x,n),r=Math.min(t.y,r),i=Math.max(t.x,i),s=Math.max(t.y,s);return new o(n,r,i-n,s-r)}static Expand(e,t){let n=Math.min(t.minX,e.minX),r=Math.min(t.minY,e.minY);return new o(n,r,Math.max(t.maxX,e.maxX)-n,Math.max(t.maxY,e.maxY)-r)}static ExpandBy(e,t){return new o(e.minX-t,e.minY-t,e.width+2*t,e.height+2*t)}static Collides(e,t){return!(e.maxX<t.minX||e.minX>t.maxX||e.maxY<t.minY||e.minY>t.maxY)}static Contains(e,t){return e.minX<t.minX&&e.minY<t.minY&&e.maxY>t.maxY&&e.maxX>t.maxX}static ContainsApproximately(e,t,n){return(0,r.rT)(e.minX,t.minX,n)&&(0,r.rT)(e.minY,t.minY,n)&&(0,r.rT)(t.maxX,e.maxX,n)&&(0,r.rT)(t.maxY,e.maxY,n)}static Includes(e,t){return o.Collides(e,t)||o.Contains(e,t)}static ContainsPoint(e,t,n=0){return!(t.x<e.minX-n||t.y<e.minY-n||t.x>e.maxX+n||t.y>e.maxY+n)}static Common(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let o=0;o<e.length;o++){let s=e[o];t=Math.min(t,s.minX),n=Math.min(n,s.minY),r=Math.max(r,s.maxX),i=Math.max(i,s.maxY)}return new o(t,n,r-t,i-n)}static Sides(e,t=0){let{corners:n}=e;return[[n[0],n[1]],[n[1],n[2]],[n[2],n[3]],[n[3],n[0]]]}static Resize(e,t,n,r,i=!1){let{minX:s,minY:a,maxX:l,maxY:d}=e,{minX:c,minY:u,maxX:h,maxY:p}=e;switch(t){case"left":case"top_left":case"bottom_left":c+=n;break;case"right":case"top_right":case"bottom_right":h+=n}switch(t){case"top":case"top_left":case"top_right":u+=r;break;case"bottom":case"bottom_left":case"bottom_right":p+=r}let f=(h-c)/(l-s),g=(p-u)/(d-a);if(i){let e=(l-s)/(d-a),n=Math.abs(h-c),r=Math.abs(p-u),i=n*(g<0?1:-1)*(1/e),o=r*(f<0?1:-1)*e,m=e<n/r;switch(t){case"top_left":m?u=p+i:c=h+o;break;case"top_right":m?u=p+i:h=c-o;break;case"bottom_right":m?p=u-i:h=c-o;break;case"bottom_left":m?p=u-i:c=h+o;break;case"bottom":case"top":{let t=(c+h)/2,n=r*e;c=t-n/2,h=t+n/2;break}case"left":case"right":{let t=(u+p)/2,r=n/e;u=t-r/2,p=t+r/2}}}if(f<0){let e=h;h=c,c=e}if(g<0){let e=p;p=u,u=e}let m=new o(c,u,Math.abs(h-c),Math.abs(p-u));return{box:m,scaleX:+(m.width/e.width*(f>0?1:-1)).toFixed(5),scaleY:+(m.height/e.height*(g>0?1:-1)).toFixed(5)}}equals(e){return o.Equals(this,e)}static Equals(e,t){return t.x===e.x&&t.y===e.y&&t.w===e.w&&t.h===e.h}zeroFix(){return this.w=Math.max(1,this.w),this.h=Math.max(1,this.h),this}static ZeroFix(e){return new o(e.x,e.y,Math.max(1,e.w),Math.max(1,e.h))}}function s(e){switch(e){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 e}}function a(e){switch(e){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 e}}let l=["top","top_right","right","bottom_right","bottom","bottom_left","left","top_left"];function d(e,t){let n=Math.round((t%=r.uA)/(r.PI/4)),i=l.indexOf(e);return l[(i+n)%l.length]}function c(e){return"top_left"===e||"top_right"===e||"bottom_right"===e||"bottom_left"===e}},61307:(e,t,n)=>{"use strict";n.d(t,{Q:()=>a});var r=n(83102),i=Object.defineProperty,o=Object.getOwnPropertyDescriptor,s=(e,t,n,r)=>{for(var s,a=r>1?void 0:r?o(t,n):t,l=e.length-1;l>=0;l--)(s=e[l])&&(a=(r?s(t,n,a):s(a))||a);return r&&a&&i(t,n,a),a};class a{constructor(e){this.editor=e}editor;_overlayUtils=new Map;registerUtil(e){let t=e.constructor.type;if(!t)throw Error(`Overlay util ${e.constructor.name} is missing a static 'type' property.`);if(this._overlayUtils.has(t))throw Error(`Duplicate overlay util type: "${t}"`);this._overlayUtils.set(t,e)}dispose(){for(let e of this._overlayUtils.values())e.dispose()}getOverlayUtil(e){let t="string"==typeof e?e:e.type,n=this._overlayUtils.get(t);if(!n)throw Error(`No overlay util found for type: "${t}"`);return n}getOverlayUtilsInZOrder(){return Array.from(this._overlayUtils.values()).map((e,t)=>({util:e,i:t,z:e.options.zIndex??0})).sort((e,t)=>e.z-t.z||e.i-t.i).map(e=>e.util)}getActiveOverlayEntries(){let e=[];for(let t of this.getOverlayUtilsInZOrder())t.isActive()&&e.push({util:t,overlays:t.getOverlays()});return e}getCurrentOverlays(){let e=[];for(let{overlays:t}of this.getActiveOverlayEntries())e.push(...t);return e}_geometryCache=new WeakMap;getOverlayGeometry(e){let t=this._geometryCache.get(e);if(void 0!==t)return t;let n=this.getOverlayUtil(e).getGeometry(e);return this._geometryCache.set(e,n),n}_hoveredOverlayId=(0,r.eU)("hoveredOverlayId",null);getHoveredOverlayId(){return this._hoveredOverlayId.get()}getHoveredOverlay(){let e=this._hoveredOverlayId.get();return e?this.getCurrentOverlays().find(t=>t.id===e)??null:null}setHoveredOverlay(e){e!==this._hoveredOverlayId.get()&&this._hoveredOverlayId.set(e)}getOverlayAtPoint(e,t=0){let n=this.getActiveOverlayEntries();for(let r=n.length-1;r>=0;r--){let{overlays:i}=n[r];for(let n of i){let r=this.getOverlayGeometry(n);if(r&&r.hitTestPoint(e,r.isFilled?0:t,!0))return n}}return null}}s([r.EW],a.prototype,"getOverlayUtilsInZOrder",1),s([r.EW],a.prototype,"getActiveOverlayEntries",1),s([r.EW],a.prototype,"getCurrentOverlays",1)},64411:e=>{"use strict";var t=Object.prototype.hasOwnProperty,n="~";function r(){}function i(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,r,o,s){if("function"!=typeof r)throw TypeError("The listener must be a function");var a=new i(r,o||e,s),l=n?n+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],a]:e._events[l].push(a):(e._events[l]=a,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function a(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1)),a.prototype.eventNames=function(){var e,r,i=[];if(0===this._eventsCount)return i;for(r in e=this._events)t.call(e,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},a.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,o=r.length,s=Array(o);i<o;i++)s[i]=r[i].fn;return s},a.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},a.prototype.emit=function(e,t,r,i,o,s){var a=n?n+e:e;if(!this._events[a])return!1;var l,d,c=this._events[a],u=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,r),!0;case 4:return c.fn.call(c.context,t,r,i),!0;case 5:return c.fn.call(c.context,t,r,i,o),!0;case 6:return c.fn.call(c.context,t,r,i,o,s),!0}for(d=1,l=Array(u-1);d<u;d++)l[d-1]=arguments[d];c.fn.apply(c.context,l)}else{var h,p=c.length;for(d=0;d<p;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),u){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,r);break;case 4:c[d].fn.call(c[d].context,t,r,i);break;default:if(!l)for(h=1,l=Array(u-1);h<u;h++)l[h-1]=arguments[h];c[d].fn.apply(c[d].context,l)}}return!0},a.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},a.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},a.prototype.removeListener=function(e,t,r,i){var o=n?n+e:e;if(!this._events[o])return this;if(!t)return s(this,o),this;var a=this._events[o];if(a.fn)a.fn!==t||i&&!a.once||r&&a.context!==r||s(this,o);else{for(var l=0,d=[],c=a.length;l<c;l++)(a[l].fn!==t||i&&!a[l].once||r&&a[l].context!==r)&&d.push(a[l]);d.length?this._events[o]=1===d.length?d[0]:d:s(this,o)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&s(this,t)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,e.exports=a},65009:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var r=n(16038);let i=null,o={area:[16384,14188,11402,11180,10836,8192,4096],height:[8388607,65535,32767,16384,8192,4096],width:[4194303,65535,32767,16384,8192,4096]};function s(e){let t=(0,r.jL)().createElement("canvas");t.width=1,t.height=1;let n=t.getContext("2d");for(let i of o[e]){let o="height"===e?1:i,s="width"===e?1:i,a=(0,r.jL)().createElement("canvas");a.width=o,a.height=s,a.getContext("2d").fillRect(o-1,s-1,1,1),n.drawImage(a,o-1,s-1,1,1,0,0,1,1);let l=0!==n.getImageData(0,0,1,1).data[3];if(a.width=0,a.height=0,l){if(t.width=0,t.height=0,"area"===e)return i*i;return i}}throw t.width=0,t.height=0,Error("Failed to determine maximum canvas dimension")}function a(e,t){if(e<=8192&&t<=8192&&e*t<=0x1000000)return[e,t];let{maxWidth:n,maxHeight:r,maxArea:o}=(i||(i={maxWidth:s("width"),maxHeight:s("height"),maxArea:s("area")}),i),a=e/t;if(e>n&&(t=(e=n)/a),t>r&&(e=(t=r)*a),e*t>o){let n=Math.sqrt(o/(e*t));e*=n,t*=n}return[e,t]}},65390:(e,t,n)=>{"use strict";n.d(t,{_:()=>o});var r=n(12115),i=n(15727);let o={maxShapesPerPage:4e3,maxFilesAtOnce:100,maxPages:40,animationMediumMs:320,followChaseViewportSnap:2,doubleClickDurationMs:450,multiClickDurationMs:200,coarseDragDistanceSquared:36,dragDistanceSquared:16,uiDragDistanceSquared:16,uiCoarseDragDistanceSquared:625,defaultSvgPadding:32,cameraSlideFriction:.09,gridSteps:[{min:-1,mid:.15,step:64},{min:.05,mid:.375,step:16},{min:.15,mid:1,step:4},{min:.7,mid:2.5,step:1}],collaboratorInactiveTimeoutMs:6e4,collaboratorIdleTimeoutMs:3e3,collaboratorCheckIntervalMs:1200,cameraMovingTimeoutMs:64,hitTestMargin:3,coarseHitTestMargin:4,edgeScrollDelay:200,edgeScrollEaseDuration:200,edgeScrollSpeed:25,edgeScrollDistance:8,coarsePointerWidth:12,coarseHandleRadius:20,handleRadius:12,longPressDurationMs:500,textShadowLod:.35,adjacentShapeMargin:10,flattenImageBoundsExpand:64,flattenImageBoundsPadding:16,laserDelayMs:1200,laserFadeoutMs:500,maxExportDelayMs:5e3,tooltipDelayMs:700,temporaryAssetPreviewLifetimeMs:18e4,actionShortcutsLocation:"swap",createTextOnCanvasDoubleClick:!0,exportProvider:r.Fragment,enableToolbarKeyboardShortcuts:!0,maxFontsToLoadBeforeRender:1/0,nonce:void 0,debouncedZoom:!0,debouncedZoomThreshold:500,spacebarPanning:!0,rightClickPanning:!0,zoomToFitPadding:128,snapThreshold:8,selectLockedShapes:!1,camera:i.zd,text:{},deepLinks:void 0,quickZoomPreservesScreenBounds:!0,onBeforeCopyToClipboard:void 0,onBeforePasteFromClipboard:void 0,onClipboardPasteRaw:void 0,experimental__onDropOnCanvas:void 0}},66122:(e,t,n)=>{"use strict";n.d(t,{O:()=>c});var r=n(83102),i=n(24167),o=n(46195),s=Object.defineProperty,a=Object.getOwnPropertyDescriptor;let l=()=>null,d=()=>[];class c{constructor(e){this.manager=e,this.editor=e.editor}manager;editor;getSnapGeometryCache(){let{editor:e}=this;return e.store.createComputedCache("handle snap geometry",t=>{let n=e.getShapeUtil(t).getHandleSnapGeometry(t),r=n.getSelfSnapOutline?n.getSelfSnapOutline.bind(n):l,i=n.getSelfSnapPoints?n.getSelfSnapPoints.bind(n):d;return{outline:void 0===n.outline?e.getShapeGeometry(t):n.outline,points:n.points??[],getSelfSnapOutline:r,getSelfSnapPoints:i}})}*iterateSnapPointsInPageSpace(e,t){let n=this.getSnapGeometryCache().get(e)?.getSelfSnapPoints(t);if(n&&n.length){let t=(0,i.Z1)(this.editor.getShapePageTransform(e));for(let e of n)yield t.applyToPoint(e)}for(let t of this.manager.getSnappableShapes()){if(t===e)continue;let n=this.getSnapGeometryCache().get(t)?.points;if(!n||!n.length)continue;let r=(0,i.Z1)(this.editor.getShapePageTransform(t));for(let e of n)yield r.applyToPoint(e)}}*iterateSnapOutlines(e,t){let n=this.getSnapGeometryCache().get(e)?.getSelfSnapOutline(t);for(let t of(n&&(yield{shapeId:e,outline:n}),this.manager.getSnappableShapes())){if(t===e)continue;let n=this.getSnapGeometryCache().get(t)?.outline;n&&(yield{shapeId:t,outline:n})}}getHandleSnapPosition({currentShapeId:e,handle:t,handleInPageSpace:n}){let r=this.manager.getSnapThreshold(),s=r,a=null;for(let r of this.iterateSnapPointsInPageSpace(e,t))o.l.DistMin(n,r,s)&&(s=o.l.Dist(n,r),a=r);if(a)return a;let l=r,d=null;for(let{shapeId:r,outline:s}of this.iterateSnapOutlines(e,t)){let e=(0,i.Z1)(this.editor.getShapePageTransform(r)),t=this.editor.getPointInShapeSpace(r,n),a=s.nearestPoint(t),c=e.applyToPoint(a);o.l.DistMin(n,c,l)&&(l=o.l.Dist(n,c),d=c)}return d||null}getHandleSnapData({handle:e,currentShapeId:t}){let n=this.manager.getSnapThreshold(),r=(0,i.Z1)(this.editor.getShapePageTransform(t)).applyToPoint(e),s=null,a=null,l=n,d=n;for(let n of this.iterateSnapPointsInPageSpace(t,e)){let e=Math.abs(r.x-n.x),t=Math.abs(r.y-n.y);e<l&&(l=e,s=n),t<d&&(d=t,a=n)}if(!s&&!a)return null;let c=new o.l(s?s.x-r.x:0,a?a.y-r.y:0),u=o.l.Add(r,c),h=[];if(s){let e=new o.l(s.x,u.y);h.push({id:(0,i.NF)(),type:"points",points:[s,e]})}if(a){let e=new o.l(u.x,a.y);h.push({id:(0,i.NF)(),type:"points",points:[a,e]})}return{snaps:h,nudge:c}}snapHandle({currentShapeId:e,handle:t}){let n=(0,i.Z1)(this.editor.getShapePageTransform(e)).applyToPoint(t),r=t.canSnap?"point":t.snapType;if("point"===r){let r=this.getHandleSnapPosition({currentShapeId:e,handle:t,handleInPageSpace:n});return r?(this.manager.setIndicators([{id:(0,i.NF)(),type:"points",points:[r]}]),{nudge:o.l.Sub(r,n)}):null}if("align"===r){let n=this.getHandleSnapData({handle:t,currentShapeId:e});return n?(this.manager.setIndicators(n.snaps),{nudge:n.nudge}):null}return null}}((e,t,n)=>{for(var r,i=a(t,n),o=e.length-1;o>=0;o--)(r=e[o])&&(i=r(t,n,i)||i);return i&&s(t,n,i)})([r.EW],c.prototype,"getSnapGeometryCache")},67863:(e,t,n)=>{"use strict";n.d(t,{fr:()=>l,hG:()=>a,zz:()=>d});var r=n(95155),i=n(12115),o=n(73352);let s=(0,i.createContext)(null);function a(){let e=i.useContext(s);if(!e)throw Error("useEditor must be used inside of the <Tldraw /> or <TldrawEditor /> components");return e}function l(){return i.useContext(s)}function d({editor:e,children:t}){return(0,r.jsx)(s.Provider,{value:e,children:(0,r.jsx)(o.JE,{children:t})})}},67877:(e,t,n)=>{"use strict";n.d(t,{$:()=>i,B:()=>o});var r=n(12115);let i=(0,r.createContext)(null);function o(){let e=(0,r.useContext)(i);if(!e)throw Error("useEditorComponents must be used inside of <EditorComponentsProvider />");return e}},68935:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var r=n(83102),i=n(54530),o=n(81467);let s=(e,t,n)=>{for(;!(0,o.xh)(n.parentId);){let t=e.get(n.parentId);if(!t)return!1;n=t}return n.parentId===t};function a(e,t){let n=e.query.ids("shape"),a=null;function l(){let r=t();return a=r,new Set([...n.get()].filter(t=>s(e,r,e.get(t))))}return(0,r.EW)("_shapeIdsInCurrentPage",(n,d)=>{if((0,r._O)(n))return l();let c=t();if(c!==a)return l();let u=e.history.getDiffSince(d);if(u===r.c2)return l();let h=new i.zq(n);for(let t of u){for(let n of Object.values(t.added))(0,o.o2)(n)&&s(e,c,n)&&h.add(n.id);for(let[n,r]of Object.values(t.updated))(0,o.o2)(r)&&(s(e,c,r)?h.add(r.id):h.remove(r.id));for(let e of Object.keys(t.removed))(0,o.vc)(e)&&h.remove(e)}let p=h.get();return p?(0,r._D)(p.value,p.diff):n})}},69409:(e,t,n)=>{"use strict";n.d(t,{T:()=>i});var r=n(24167);function i(e,t,n,i){if(0===n.length)return[];let s=new Map;for(let t of(0,r.oE)(n.map(t=>e.getShape(t)))){let{parentId:n}=t;s.has(n)||s.set(n,{children:(0,r.oE)(e.getSortedChildIdsForParent(n).map(t=>e.getShape(t))),moving:new Set}),s.get(n).moving.add(t)}let a=[];switch(t){case"toBack":s.forEach(({moving:e,children:t})=>(function(e,t,n){let i,o,s=t.length;if(e.size!==s){for(let n=0;n<s;n++){let r=t[n];if(e.has(r))i=r.index,e.delete(r);else{o=r.index;break}}if(0===e.size)return;{let t=(0,r.MT)(i,o,e.size);n.push(...Array.from(e.values()).sort(r.Ky).map((e,n)=>({...e,index:t[n]})))}}})(e,t,a));break;case"toFront":s.forEach(({moving:e,children:t})=>(function(e,t,n){let i,o,s=t.length;if(e.size!==s){for(let n=s-1;n>-1;n--){let r=t[n];if(e.has(r))o=r.index,e.delete(r);else{i=r.index;break}}if(0===e.size)return;{let t=(0,r.MT)(i,o,e.size);n.push(...Array.from(e.values()).sort(r.Ky).map((e,n)=>({...e,index:t[n]})))}}})(e,t,a));break;case"forward":s.forEach(({moving:t,children:n})=>(function(e,t,n,i,s){let a=o(e,t),l=n.length;if(t.size===l)return;let d={name:"skipping"};for(let e=0;e<l;e++){let o=t.has(n[e]);switch(d.name){case"skipping":if(!o)continue;d={name:"selecting",selectIndex:e};break;case"selecting":{if(o||!s?.considerAllShapes&&!a(n[e]))continue;let{selectIndex:l}=d;(0,r.MT)(n[e].index,n[e+1]?.index,e-l).forEach((e,r)=>{let o=n[l+r];t.has(o)&&i.push({...o,index:e})}),d={name:"skipping"}}}}})(e,t,n,a,i));break;case"backward":s.forEach(({moving:t,children:n})=>(function(e,t,n,i,s){let a=o(e,t),l=n.length;if(t.size===l)return;let d={name:"skipping"};for(let e=l-1;e>-1;e--){let o=t.has(n[e]);switch(d.name){case"skipping":if(!o)continue;d={name:"selecting",selectIndex:e};break;case"selecting":if(o||!s?.considerAllShapes&&!a(n[e]))continue;(0,r.MT)(n[e-1]?.index,n[e].index,d.selectIndex-e).forEach((r,o)=>{let s=n[e+o+1];t.has(s)&&i.push({...s,index:r})}),d={name:"skipping"}}}})(e,t,n,a,i))}return a}function o(e,t){let n=(0,r.oE)(Array.from(t).map(t=>{let n=e.getShapePageBounds(t);return n?{shape:t,bounds:n}:null}));return t=>{let r=e.getShapePageBounds(t);return!!r&&n.some(e=>e.bounds.includes(r))}}},69730:(e,t)=>{var n;!function(){"use strict";var r={}.hasOwnProperty;function i(){for(var e="",t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=o(e,function(e){if("string"==typeof e||"number"==typeof e)return e;if("object"!=typeof e)return"";if(Array.isArray(e))return i.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var t="";for(var n in e)r.call(e,n)&&e[n]&&(t=o(t,n));return t}(n)))}return e}function o(e,t){return t?e?e+" "+t:e+t:e}e.exports?(i.default=i,e.exports=i):void 0===(n=(function(){return i}).apply(t,[]))||(e.exports=n)}()},71136:(e,t,n)=>{"use strict";function r(e,t,n={}){let{closed:i=!1,snap:o=1,start:s="outset",end:a="outset",lengthRatio:l=2,style:d="dashed",forceSolid:c=!1}=n,u=0,h=0,p=1,f=0,g=0;if(c||"none"===d)return{strokeDasharray:"none",strokeDashoffset:"none"};switch(d){case"dashed":p=1,u=Math.min(t*l,e/4);break;case"dotted":u=t/(p=100);break;default:return{strokeDasharray:"none",strokeDashoffset:"none"}}return i||("outset"===s?(e+=u/2,g+=u/2):"skip"===s&&(e-=u,g-=u),"outset"===a?e+=u/2:"skip"===a&&(e-=u)),h=Math.floor(e/u/(2*p)),(h-=h%o)<3&&"dashed"===d?e/t<4?(u=e,h=1,f=0):(u=1/3*e,f=1/3*e):(u=e/h/(2*p),i?(g=u/2,f=(e-h*u)/h):f=(e-h*u)/Math.max(1,h-1)),{strokeDasharray:[u,f].join(" "),strokeDashoffset:g.toString()}}n.d(t,{E:()=>r})},71645:(e,t,n)=>{var r="Expected a function",i=0/0,o=/^\s+|\s+$/g,s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,l=/^0o[0-7]+$/i,d=parseInt,c="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,u="object"==typeof self&&self&&self.Object===Object&&self,h=c||u||Function("return this")(),p=Object.prototype.toString,f=Math.max,g=Math.min,m=function(){return h.Date.now()};function y(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function b(e){if("number"==typeof e)return e;if("symbol"==typeof(t=e)||t&&"object"==typeof t&&"[object Symbol]"==p.call(t))return i;if(y(e)){var t,n="function"==typeof e.valueOf?e.valueOf():e;e=y(n)?n+"":n}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(o,"");var r=a.test(e);return r||l.test(e)?d(e.slice(2),r?2:8):s.test(e)?i:+e}e.exports=function(e,t,n){var i=!0,o=!0;if("function"!=typeof e)throw TypeError(r);return y(n)&&(i="leading"in n?!!n.leading:i,o="trailing"in n?!!n.trailing:o),function(e,t,n){var i,o,s,a,l,d,c=0,u=!1,h=!1,p=!0;if("function"!=typeof e)throw TypeError(r);function x(t){var n=i,r=o;return i=o=void 0,c=t,a=e.apply(r,n)}function w(e){var n=e-d,r=e-c;return void 0===d||n>=t||n<0||h&&r>=s}function v(){var e,n,r,i=m();if(w(i))return S(i);l=setTimeout(v,(e=i-d,n=i-c,r=t-e,h?g(r,s-n):r))}function S(e){return(l=void 0,p&&i)?x(e):(i=o=void 0,a)}function C(){var e,n=m(),r=w(n);if(i=arguments,o=this,d=n,r){if(void 0===l)return c=e=d,l=setTimeout(v,t),u?x(e):a;if(h)return l=setTimeout(v,t),x(d)}return void 0===l&&(l=setTimeout(v,t)),a}return t=b(t)||0,y(n)&&(u=!!n.leading,s=(h="maxWait"in n)?f(b(n.maxWait)||0,t):s,p="trailing"in n?!!n.trailing:p),C.cancel=function(){void 0!==l&&clearTimeout(l),c=0,i=d=o=l=void 0},C.flush=function(){return void 0===l?a:S(m())},C}(e,t,{leading:i,maxWait:t,trailing:o})}},73352:(e,t,n)=>{"use strict";n.d(t,{JE:()=>u,Ls:()=>a,Xh:()=>l,ni:()=>d,oX:()=>s});var r=n(95155),i=n(24167),o=n(12115);function s(e,t){return d(`${e}_${t}`)}function a(e){return d(`${(0,o.useId)()}${e??""}`)}function l(e){let t=(0,i.Z1)((0,o.useContext)(c));return d(`${t}_${e}`)}function d(e){return e.replace(/:/g,"_")}let c=(0,o.createContext)(null);function u({children:e}){let t=a();return(0,r.jsx)(c.Provider,{value:t,children:e})}},73578:(e,t,n)=>{"use strict";n.d(t,{y:()=>o});var r=n(24167),i=n(46195);class o{constructor(e){this.editor=e}editor;sessions=new Map;startSession(e={}){let t=e.id??(0,r.NF)(),n={id:t,items:[],state:"active",options:{selfConsume:e.selfConsume??!0,idleTimeoutMs:e.idleTimeoutMs??0,fadeMode:e.fadeMode??"individual",fadeEasing:e.fadeEasing??("grouped"===e.fadeMode?"ease-in":"linear"),fadeDurationMs:e.fadeDurationMs??this.editor.options.laserFadeoutMs},fadeElapsed:0,totalPointsAtFadeStart:0};return this.sessions.set(t,n),n.options.idleTimeoutMs>0&&this.resetIdleTimeout(n),t}addScribbleToSession(e,t,n=(0,r.NF)()){let i=this.sessions.get(e);if(!i)throw Error(`Session ${e} not found`);let o={id:n,scribble:{id:n,size:20,color:"accent",opacity:.8,delay:0,points:[],shrink:.1,taper:!0,...t,state:"starting"},timeoutMs:0,delayRemaining:t.delay??0,prev:null,next:null};return i.items.push(o),i.options.idleTimeoutMs>0&&this.resetIdleTimeout(i),o}addPointToSession(e,t,n,r,o=.5){let s=this.sessions.get(e);if(!s)throw Error(`Session ${e} not found`);let a=s.items.find(e=>e.id===t);if(!a)throw Error(`Scribble ${t} not found in session ${e}`);let l={x:n,y:r,z:o};return(!a.prev||i.l.Dist(a.prev,l)>=1)&&(a.next=l),s.options.idleTimeoutMs>0&&this.resetIdleTimeout(s),a}extendSession(e){let t=this.sessions.get(e);t&&t.options.idleTimeoutMs>0&&this.resetIdleTimeout(t)}stopSession(e){let t=this.sessions.get(e);if(t&&"active"===t.state)if(this.clearIdleTimeout(t),t.state="stopping","grouped"===t.options.fadeMode)for(let e of(t.totalPointsAtFadeStart=t.items.reduce((e,t)=>e+t.scribble.points.length,0),t.fadeElapsed=0,t.items))e.scribble.state="stopping";else for(let e of t.items)e.delayRemaining=Math.min(e.delayRemaining,200),e.scribble.state="stopping"}clearSession(e){let t=this.sessions.get(e);if(t){for(let e of(this.clearIdleTimeout(t),t.items))e.scribble.points.length=0;t.state="complete"}}isSessionActive(e){let t=this.sessions.get(e);return t?.state==="active"}addScribble(e,t=(0,r.NF)()){let n=this.startSession();return this.addScribbleToSession(n,e,t)}addPoint(e,t,n,r=.5){for(let o of this.sessions.values()){let s=o.items.find(t=>t.id===e);if(s){let e={x:t,y:n,z:r};return(!s.prev||i.l.Dist(s.prev,e)>=1)&&(s.next=e),o.options.idleTimeoutMs>0&&this.resetIdleTimeout(o),s}}throw Error(`Scribble with id ${e} not found`)}complete(e){for(let t of this.sessions.values()){let n=t.items.find(t=>t.id===e);if(n)return("starting"===n.scribble.state||"active"===n.scribble.state)&&(n.scribble.state="complete"),n}throw Error(`Scribble with id ${e} not found`)}stop(e){for(let t of this.sessions.values()){let n=t.items.find(t=>t.id===e);if(n)return n.delayRemaining=Math.min(n.delayRemaining,200),n.scribble.state="stopping",n}throw Error(`Scribble with id ${e} not found`)}reset(){for(let e of this.sessions.values())this.clearIdleTimeout(e);this.sessions.clear(),this.editor.updateInstanceState({scribbles:[]})}tick(e){let t=this.editor.getInstanceState().scribbles;(0!==this.sessions.size||0!==t.length)&&this.editor.run(()=>{for(let t of this.sessions.values())this.tickSession(t,e);for(let[e,t]of this.sessions)"complete"===t.state&&(this.clearIdleTimeout(t),this.sessions.delete(e));let t=[];for(let e of this.sessions.values())for(let n of e.items)n.scribble.points.length>0&&t.push({...n.scribble,points:[...n.scribble.points]});this.editor.updateInstanceState({scribbles:t})})}resetIdleTimeout(e){this.clearIdleTimeout(e),e.idleTimeoutHandle=this.editor.timers.setTimeout(()=>{this.stopSession(e.id)},e.options.idleTimeoutMs)}clearIdleTimeout(e){void 0!==e.idleTimeoutHandle&&(clearTimeout(e.idleTimeoutHandle),e.idleTimeoutHandle=void 0)}tickSession(e,t){"complete"===e.state||("stopping"===e.state&&"grouped"===e.options.fadeMode?this.tickGroupedFade(e,t):this.tickSessionItems(e,t),e.items.some(e=>e.scribble.points.length>0)||"stopping"!==e.state&&0!==e.items.length||(e.state="complete"))}tickSessionItems(e,t){for(let n of e.items)e.options.selfConsume||"stopping"===e.state||"stopping"===n.scribble.state?this.tickSelfConsumingItem(n,t):this.tickPersistentItem(n);if("individual"===e.options.fadeMode)for(let t=e.items.length-1;t>=0;t--)0===e.items[t].scribble.points.length&&e.items.splice(t,1)}tickPersistentItem(e){let{scribble:t}=e;if("starting"===t.state){let{next:n,prev:r}=e;n&&n!==r&&(e.prev=n,t.points.push(n)),t.points.length>8&&(t.state="active");return}if("active"===t.state){let{next:n,prev:r}=e;n&&n!==r&&(e.prev=n,t.points.push(n))}}tickSelfConsumingItem(e,t){let{scribble:n}=e;if("starting"===n.state){let{next:t,prev:r}=e;t&&t!==r&&(e.prev=t,n.points.push(t)),n.points.length>8&&(n.state="active");return}e.delayRemaining>0&&(e.delayRemaining=Math.max(0,e.delayRemaining-t)),e.timeoutMs+=t,e.timeoutMs>=16&&(e.timeoutMs=0);let{delayRemaining:r,timeoutMs:i,prev:o,next:s}=e;switch(n.state){case"active":s&&s!==o?(e.prev=s,n.points.push(s),0===r&&n.points.length>8&&n.points.shift()):0===i&&(n.points.length>1?n.points.shift():e.delayRemaining=n.delay);break;case"stopping":if(0===r&&0===i){if(n.points.length<=1){n.points.length=0;return}n.shrink&&(n.size=Math.max(1,n.size*(1-n.shrink))),n.points.shift()}}}tickGroupedFade(e,t){e.fadeElapsed+=t;let n=0;for(let t of e.items)n+=t.scribble.points.length;if(0===n)return;if(e.fadeElapsed>=e.options.fadeDurationMs){for(let t of e.items)t.scribble.points.length=0;return}let r=e.fadeElapsed/e.options.fadeDurationMs,i=Math.max(1,Math.floor(("ease-in"===e.options.fadeEasing?r*r:r)*e.totalPointsAtFadeStart)-(e.totalPointsAtFadeStart-n)),o=0,s=0;for(;o<i&&s<e.items.length;){let t=e.items[s];t.scribble.points.length>0?(t.scribble.points.shift(),o++):s++}}}},75567:(e,t,n)=>{"use strict";n.d(t,{I:()=>l});var r=n(83102),i=n(24167),o=n(59830),s=n(46195),a=n(27164);class l extends a.vq{children=[];ignoredChildren=[];constructor(e){super({...e,isClosed:!0,isFilled:!1});const t=e=>{for(let n of e)n instanceof l?t(n.children):n.ignore?this.ignoredChildren.push(n):this.children.push(n)};if(t(e.children),0===this.children.length)throw Error("Group2d must have at least one child")}getVertices(e){return this.isExcludedByFilter(e)?[]:this.children.filter(t=>!t.isExcludedByFilter(e)).flatMap(t=>t.getVertices(e))}nearestPoint(e,t){let n,r,i,o=1/0,{children:a}=this;if(0===a.length)throw Error("no children");for(let l of a)!l.isExcludedByFilter(t)&&(r=l.nearestPoint(e,t),(i=s.l.Dist2(r,e))<o&&(o=i,n=r));if(!n)throw Error("nearest point not found");return n}distanceToPoint(e,t=!1,n){let r=1/0;for(let i of this.children){if(i.isExcludedByFilter(n))continue;let o=i.distanceToPoint(e,t,n);o<r&&(r=o)}return r}hitTestPoint(e,t,n,r=a.MI.EXCLUDE_LABELS){return!!this.children.filter(e=>!e.isExcludedByFilter(r)).find(r=>r.hitTestPoint(e,t,n))}hitTestLineSegment(e,t,n,r=a.MI.EXCLUDE_LABELS){return!!this.children.filter(e=>!e.isExcludedByFilter(r)).find(r=>r.hitTestLineSegment(e,t,n))}intersectLineSegment(e,t,n){return this.children.flatMap(i=>i.isExcludedByFilter(n)?r.Ml:i.intersectLineSegment(e,t,n))}intersectCircle(e,t,n){return this.children.flatMap(i=>i.isExcludedByFilter(n)?r.Ml:i.intersectCircle(e,t,n))}getBoundsVertices(){return this.excludeFromShapeBounds?[]:this.children.flatMap(e=>e.getBoundsVertices())}intersectPolygon(e,t){return this.children.flatMap(n=>n.isExcludedByFilter(t)?r.Ml:n.intersectPolygon(e,t))}intersectPolyline(e,t){return this.children.flatMap(n=>n.isExcludedByFilter(t)?r.Ml:n.intersectPolyline(e,t))}interpolateAlongEdge(e,t){let n=e*this.getLength(t),r=0;for(let e of this.children){if(e.isExcludedByFilter(t))continue;let o=r+e.length;if(o>=n)return e.interpolateAlongEdge((0,i.Fg)(r,o,n),t);r=o}return this.children[this.children.length-1].interpolateAlongEdge(1,t)}uninterpolateAlongEdge(e,t){let n=this.getLength(t),r=null,o=1/0,s=0;for(let n of this.children){if(n.isExcludedByFilter(t))continue;let i=s+n.getLength(t),a=n.distanceToPoint(e,!1,t);a<o&&(o=a,r={startLength:s,endLength:i,child:n}),s=i}(0,i.vA)(r);let a=r.child.uninterpolateAlongEdge(e,t);return(0,i.Cc)(r.startLength,r.endLength,a)/n}transform(e){return new l({children:this.children.map(t=>t.transform(e)),isLabel:this.isLabel,debugColor:this.debugColor,ignore:this.ignore})}getArea(){return this.children[0].area}toSimpleSvgPath(){let e="";for(let t of this.children)e+=t.toSimpleSvgPath();let t=o.az.FromPoints(this.boundsVertices).corners;for(let n=0,r=t.length;n<r;n++){let i=t[n],o=t[(n-1+r)%r],s=i.dist(o),a=t[(n+1)%r],l=i.dist(a),d=i.clone().lrp(o,4/s),c=i.clone().lrp(a,4/l);e+=`M${d.x},${d.y} L${i.x},${i.y} L${c.x},${c.y} `}return e}getLength(e){let t=0;for(let n of this.children)n.isExcludedByFilter(e)||(t+=n.length);return t}getSvgPathData(){return this.children.map((e,t)=>e.isLabel?"":e.getSvgPathData(0===t)).join(" ")}overlapsPolygon(e){return this.children.some(t=>t.overlapsPolygon(e))}}},76865:(e,t,n)=>{"use strict";n.d(t,{$t:()=>C,LN:()=>s,U3:()=>c,hs:()=>E,i5:()=>f,k_:()=>k,nh:()=>h});var r=n(27050),i=n(8242);let o=Object.create(null);class s{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new a(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=r.Ji.empty){let n=t.content.lastChild,i=null;for(let e=0;e<t.openEnd;e++)i=n,n=n.lastChild;let o=e.steps.length,s=this.ranges;for(let a=0;a<s.length;a++){let{$from:l,$to:d}=s[a],c=e.mapping.slice(o);e.replaceRange(c.map(l.pos),c.map(d.pos),a?r.Ji.empty:t),0==a&&y(e,o,(n?n.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:o,$to:s}=r[i],a=e.mapping.slice(n),l=a.map(o.pos),d=a.map(s.pos);i?e.deleteRange(l,d):(e.replaceRangeWith(l,d,t),y(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new c(e):m(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let i=t<0?m(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):m(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new f(e.node(0))}static atStart(e){return m(e,e,0,0,1)||new f(e)}static atEnd(e){return m(e,e,e.content.size,e.childCount,-1)||new f(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError("Invalid input for Selection.fromJSON");let n=o[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in o)throw RangeError("Duplicate use of selection JSON ID "+e);return o[e]=t,t.prototype.jsonID=e,t}getBookmark(){return c.between(this.$anchor,this.$head).getBookmark()}}s.prototype.visible=!0;class a{constructor(e,t){this.$from=e,this.$to=t}}let l=!1;function d(e){l||e.parent.inlineContent||(l=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class c extends s{constructor(e,t=e){d(e),d(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return s.near(n);let r=e.resolve(t.map(this.anchor));return new c(r.parent.inlineContent?r:n,n)}replace(e,t=r.Ji.empty){if(super.replace(e,t),t==r.Ji.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof c&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new u(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw RangeError("Invalid input for TextSelection.fromJSON");return new c(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(e,t,n){let r=e.pos-t.pos;if((!n||r)&&(n=r>=0?1:-1),!t.parent.inlineContent){let e=s.findFrom(t,n,!0)||s.findFrom(t,-n,!0);if(!e)return s.near(t,n);t=e.$head}return e.parent.inlineContent||(0==r?e=t:(e=(s.findFrom(e,-n,!0)||s.findFrom(e,n,!0)).$anchor).pos<t.pos!=r<0&&(e=t)),new c(e,t)}}s.jsonID("text",c);class u{constructor(e,t){this.anchor=e,this.head=t}map(e){return new u(e.map(this.anchor),e.map(this.head))}resolve(e){return c.between(e.resolve(this.anchor),e.resolve(this.head))}}class h extends s{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:r}=t.mapResult(this.anchor),i=e.resolve(r);return n?s.near(i):new h(i)}content(){return new r.Ji(r.FK.from(this.node),0,0)}eq(e){return e instanceof h&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new p(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw RangeError("Invalid input for NodeSelection.fromJSON");return new h(e.resolve(t.anchor))}static create(e,t){return new h(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}h.prototype.visible=!1,s.jsonID("node",h);class p{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new u(n,n):new p(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&h.isSelectable(n)?new h(t):s.near(t)}}class f extends s{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=r.Ji.empty){if(t==r.Ji.empty){e.delete(0,e.doc.content.size);let t=s.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new f(e)}map(e){return new f(e)}eq(e){return e instanceof f}getBookmark(){return g}}s.jsonID("all",f);let g={map(){return this},resolve:e=>new f(e)};function m(e,t,n,r,i,o=!1){if(t.inlineContent)return c.create(e,n);for(let s=r-(i>0?0:1);i>0?s<t.childCount:s>=0;s+=i){let r=t.child(s);if(r.isAtom){if(!o&&h.isSelectable(r))return h.create(e,n-(i<0?r.nodeSize:0))}else{let t=m(e,r,n+i,i<0?r.childCount:0,i,o);if(t)return t}n+=r.nodeSize*i}return null}function y(e,t,n){let r,o=e.steps.length-1;if(o<t)return;let a=e.steps[o];(a instanceof i.Ln||a instanceof i.Wg)&&(e.mapping.maps[o].forEach((e,t,n,i)=>{null==r&&(r=i)}),e.setSelection(s.near(e.doc.resolve(r),n)))}class b extends i.dL{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(1|this.updated)&-3,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return r.CU.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||r.CU.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),this.selection.empty||this.selection.to!=t+e.length||this.setSelection(s.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function x(e,t){return t&&e?e.bind(t):e}class w{constructor(e,t,n){this.name=e,this.init=x(t.init,n),this.apply=x(t.apply,n)}}let v=[new w("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new w("selection",{init:(e,t)=>e.selection||s.atStart(t.doc),apply:e=>e.selection}),new w("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,r)=>r.selection.$cursor?e.storedMarks:null}),new w("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class S{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=v.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new w(e.key,e.spec.state,e))})}}class C{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let s=this.config.plugins[o];if(s.spec.appendTransaction){let a=r?r[o].n:0,l=r?r[o].state:this,d=a<t.length&&s.spec.appendTransaction.call(s,a?t.slice(a):t,l,n);if(d&&n.filterTransaction(d,o)){if(d.setMeta("appendedTransaction",e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<o?{state:n,n:t.length}:{state:this,n:0})}t.push(d),n=n.applyInner(d),i=!0}r&&(r[o]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw RangeError("Applying a mismatched transaction");let t=new C(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let i=n[r];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new b(this)}static create(e){let t=new S(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new C(t);for(let r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n}reconfigure(e){let t=new S(this.schema,e.plugins),n=t.fields,r=new C(t);for(let t=0;t<n.length;t++){let i=n[t].name;r[i]=this.hasOwnProperty(i)?this[i]:n[t].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,n){if(!t)throw RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw RangeError("Required config field 'schema' missing");let i=new S(e.schema,e.plugins),o=new C(i);return i.fields.forEach(i=>{if("doc"==i.name)o.doc=r.bP.fromJSON(e.schema,t.doc);else if("selection"==i.name)o.selection=s.fromJSON(o.doc,t.selection);else if("storedMarks"==i.name)t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let r in n){let s=n[r],a=s.spec.state;if(s.key==i.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(t,r)){o[i.name]=a.fromJSON.call(s,e,t[r],o);return}}o[i.name]=i.init(e,o)}}),o}}class k{constructor(e){this.spec=e,this.props={},e.props&&function e(t,n,r){for(let i in t){let o=t[i];o instanceof Function?o=o.bind(n):"handleDOMEvents"==i&&(o=e(o,n,{})),r[i]=o}return r}(e.props,this,this.props),this.key=e.key?e.key.key:T("plugin")}getState(e){return e[this.key]}}let P=Object.create(null);function T(e){return e in P?e+"$"+ ++P[e]:(P[e]=0,e+"$")}class E{constructor(e="key"){this.key=T(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}},78663:(e,t,n)=>{"use strict";n.d(t,{Y:()=>a});var r=n(83102),i=n(24167),o=n(11421),s=n(16398);class a{constructor(e,t){this.editor=e;const{id:n,children:o,initial:s,isLockable:a,useCoalescedEvents:l}=this.constructor;this.id=n,this._isActive=(0,r.eU)("toolIsActive"+this.id,!1),this._current=(0,r.eU)("toolState"+this.id,void 0),this._path=(0,r.EW)("toolPath"+this.id,()=>{let e=this.getCurrent();return this.id+(e?`.${e.getPath()}`:"")}),this.parent=t??{},t?o&&s?(this.type="branch",this.initial=s,this.children=Object.fromEntries(o().map(e=>[e.id,new e(this.editor,this)])),this._current.set(this.children[this.initial])):this.type="leaf":(this.type="root",o&&s&&(this.initial=s,this.children=Object.fromEntries(o().map(e=>[e.id,new e(this.editor,this)])),this._current.set(this.children[this.initial]))),this.isLockable=a,this.useCoalescedEvents=l,this.performanceTracker=new i.f6}editor;performanceTracker;static id;static initial;static children;static isLockable=!0;static useCoalescedEvents=!1;static trackPerformance=!1;id;type;shapeType;initial;children;isLockable;useCoalescedEvents;parent;getPath(){return this._path.get()}_path;getCurrent(){return this._current.get()}_current;getIsActive(){return this._isActive.get()}_isActive;transition(e,t={}){let n=e.split("."),r=this;for(let e=0;e<n.length;e++){let i=n[e],o=r.getCurrent(),s=r.children?.[i];if(!s)throw Error(`${r.id} - no child state exists with the id ${i}.`);if(o?.id!==s.id&&(o?.exit(t,i),r._current.set(s),s.enter(t,o?.id||"initial"),!s.getIsActive()))break;r=s}return this}handleEvent(e){let t=s.O[e.name],n=this._current.__unsafe__getWithoutCapture();this[t]?.(e),this._isActive.__unsafe__getWithoutCapture()&&n&&n===this._current.__unsafe__getWithoutCapture()&&n.handleEvent(e)}enter(e,t){if(this.constructor.trackPerformance&&(o.bG.measurePerformance.get()&&this.performanceTracker.start(this.id),this.editor.performance._notifyInteractionStart(this.id,this.getPath())),this._isActive.set(!0),this.onEnter?.(e,t),this.children&&this.initial&&this.getIsActive()){let n=this.children[this.initial];this._current.set(n),n.enter(e,t)}}exit(e,t){this.constructor.trackPerformance&&(o.bG.measurePerformance.get()&&this.performanceTracker.isStarted()&&this.performanceTracker.stop(),this.editor.performance._notifyInteractionEnd()),this._isActive.set(!1),this.onExit?.(e,t),this.getIsActive()||this.getCurrent()?.exit(e,t)}_currentToolIdMask=(0,r.eU)("curent tool id mask",void 0);getCurrentToolIdMask(){return this._currentToolIdMask.get()}setCurrentToolIdMask(e){this._currentToolIdMask.set(e)}addChild(e){if("leaf"===this.type)throw Error("StateNode.addChild: cannot add child to a leaf node");this.children||(this.children={});let t=new e(this.editor,this);if(this.children[t.id])throw Error(`StateNode.addChild: a child with id '${t.id}' already exists`);return this.children[t.id]=t,this}}},78943:(e,t,n)=>{"use strict";n.d(t,{y:()=>i});var r=n(78663);class i extends r.Y{static id="root";static initial="";static children(){return[]}}},79224:(e,t,n)=>{"use strict";n.d(t,{f:()=>l});var r=n(83102),i=n(24167),o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=(e,t,n,r)=>{for(var i,a=r>1?void 0:r?s(t,n):t,l=e.length-1;l>=0;l--)(i=e[l])&&(a=(r?i(t,n,a):i(a))||a);return r&&a&&o(t,n,a),a};class l{constructor(e){this.editor=e}editor;_visibilityClockStarted=!1;_startVisibilityClock(){this._visibilityClockStarted||(this._visibilityClockStarted=!0,this.editor.timers.setInterval(()=>{this._visibilityClock.set(Date.now())},this.editor.options.collaboratorCheckIntervalMs))}_visibilityClock=(0,r.eU)("collaboratorVisibilityClock",Date.now());_getCollaboratorsQuery(){return this.editor.store.query.records("instance_presence",()=>({userId:{neq:this.editor.user.getRecordId()}}))}getCollaborators(){let e=this._getCollaboratorsQuery().get();return e.length?[...new Set(e.map(e=>e.userId))].sort().map(t=>(0,i.Sk)(e.filter(e=>e.userId===t),e=>e.lastActivityTimestamp??0)):r.Ml}getCollaboratorsOnCurrentPage(){let e=this.editor.getCurrentPageId();return this.getCollaborators().filter(t=>t.currentPageId===e)}getVisibleCollaborators(){let{editor:e}=this,{collaboratorInactiveTimeoutMs:t,collaboratorIdleTimeoutMs:n}=e.options;this._startVisibilityClock(),this._visibilityClock.get();let i=Date.now(),o=this.getCollaborators();if(!o.length)return r.Ml;let{followingUserId:s,highlightedUserIds:a}=this.editor.getInstanceState(),l=this.editor.user.getRecordId();return o.filter(e=>{let{lastActivityTimestamp:r,userId:o,chatMessage:d}=e,c=r?Math.max(0,i-r):0;return c>t?s===o||a.includes(o):!(c>n)||e.followingUserId!==l||!!(d||a.includes(o))})}getVisibleCollaboratorsOnCurrentPage(){let e=this.editor.getCurrentPageId();return this.getVisibleCollaborators().filter(t=>t.currentPageId===e)}}a([r.EW],l.prototype,"_getCollaboratorsQuery",1),a([(0,r.EW)({isEqual:i.vq})],l.prototype,"getCollaborators",1),a([(0,r.EW)({isEqual:i.vq})],l.prototype,"getCollaboratorsOnCurrentPage",1),a([(0,r.EW)({isEqual:i.vq})],l.prototype,"getVisibleCollaborators",1),a([(0,r.EW)({isEqual:i.vq})],l.prototype,"getVisibleCollaboratorsOnCurrentPage",1)},80614:(e,t,n)=>{"use strict";n.d(t,{H:()=>a,d:()=>d});var r=n(24167),i=n(12115);function o(e,t){let n=(0,i.useRef)(e);return t(e,n.current)?n.current:(n.current=e,e)}let s=(e,t)=>(e??=null)===(t??=null)||!!e&&!!t&&(0,r.vq)(e,t);function a(e){return o(e,s)}let l=(e,t)=>(e??=null)===(t??=null)||!!e&&!!t&&(0,r.zK)(e,t);function d(e){return o(e,l)}},81467:(e,t,n)=>{"use strict";n.d(t,{sr:()=>ee,ro:()=>Q,qf:()=>J,Kx:()=>eQ,Xu:()=>ep,sd:()=>e9,iv:()=>B,Pe:()=>W,u8:()=>K,xX:()=>Y,ye:()=>V,yM:()=>tw,Sg:()=>X,nM:()=>tU,YU:()=>tv,tg:()=>tS,jA:()=>eB,Yj:()=>nn,eB:()=>tL,tv:()=>eP,yI:()=>e5,O9:()=>eR,G1:()=>eV,XA:()=>eA,g8:()=>el,P_:()=>es,ud:()=>ei,FX:()=>et,K6:()=>tl,Es:()=>h,Vt:()=>c,hN:()=>e8,aW:()=>e6,BN:()=>T,gP:()=>t2,n6:()=>L,Wt:()=>t9,dB:()=>ej,de:()=>th,KB:()=>tc,up:()=>ty,Pw:()=>tg,Sp:()=>tx,X2:()=>tb,s4:()=>tP,X8:()=>tC,jP:()=>nr,lg:()=>F,gf:()=>tE,h4:()=>tT,RE:()=>tM,M6:()=>tI,h1:()=>g,_8:()=>p,Uc:()=>tD,lX:()=>tj,OT:()=>P,GY:()=>G,xh:()=>eT,o2:()=>O,vc:()=>D,bT:()=>tN,e9:()=>tR,fq:()=>tH,SW:()=>t$,ny:()=>ev,Pu:()=>eD,Mc:()=>U,AF:()=>q,eH:()=>E,zo:()=>C,E4:()=>tV,xj:()=>tW,TP:()=>I,jh:()=>b,EO:()=>m,w9:()=>tq,ZM:()=>tY});var r,i=n(24167),o=n(22690);function s(e){return o.T.string.refine(t=>{if(!t.startsWith(`${e}:`))throw Error(`${e} ID must start with "${e}:"`);return t})}let a=s("asset");function l(e,t,n){let r=t instanceof o.T.Validator?t:t?o.T.object(t):o.T.jsonValue;return o.T.object({id:a,typeName:o.T.literal("asset"),type:o.T.literal(e),props:r,meta:n?o.T.object(n):o.T.jsonValue})}var d=n(54530);let c={title:o.T.string,description:o.T.string,image:o.T.string,favicon:o.T.string,src:o.T.srcUrl.nullable()};l("bookmark",o.T.object(c));let u=(0,d.bo)("com.tldraw.asset.bookmark",{MakeUrlsValid:1,AddFavicon:2}),h=(0,d.XD)({sequenceId:"com.tldraw.asset.bookmark",recordType:"asset",filter:e=>"bookmark"===e.type,sequence:[{id:u.MakeUrlsValid,up:e=>{o.T.srcUrl.isValid(e.props.src)||(e.props.src="")},down:e=>{}},{id:u.AddFavicon,up:e=>{o.T.srcUrl.isValid(e.props.favicon)||(e.props.favicon="")},down:e=>{delete e.props.favicon}}]}),p={w:o.T.number,h:o.T.number,name:o.T.string,isAnimated:o.T.boolean,mimeType:o.T.string.nullable(),src:o.T.srcUrl.nullable(),fileSize:o.T.nonZeroNumber.optional(),pixelRatio:o.T.positiveNumber.optional()};l("image",o.T.object(p));let f=(0,d.bo)("com.tldraw.asset.image",{AddIsAnimated:1,RenameWidthHeight:2,MakeUrlsValid:3,AddFileSize:4,MakeFileSizeOptional:5,AddPixelRatio:6}),g=(0,d.XD)({sequenceId:"com.tldraw.asset.image",recordType:"asset",filter:e=>"image"===e.type,sequence:[{id:f.AddIsAnimated,up:e=>{e.props.isAnimated=!1},down:e=>{delete e.props.isAnimated}},{id:f.RenameWidthHeight,up:e=>{e.props.w=e.props.width,e.props.h=e.props.height,delete e.props.width,delete e.props.height},down:e=>{e.props.width=e.props.w,e.props.height=e.props.h,delete e.props.w,delete e.props.h}},{id:f.MakeUrlsValid,up:e=>{o.T.srcUrl.isValid(e.props.src)||(e.props.src="")},down:e=>{}},{id:f.AddFileSize,up:e=>{e.props.fileSize=-1},down:e=>{delete e.props.fileSize}},{id:f.MakeFileSizeOptional,up:e=>{-1===e.props.fileSize&&(e.props.fileSize=void 0)},down:e=>{void 0===e.props.fileSize&&(e.props.fileSize=-1)}},{id:f.AddPixelRatio,up:e=>{},down:e=>{delete e.props.pixelRatio}}]}),m={w:o.T.number,h:o.T.number,name:o.T.string,isAnimated:o.T.boolean,mimeType:o.T.string.nullable(),src:o.T.srcUrl.nullable(),fileSize:o.T.number.optional()};l("video",o.T.object(m));let y=(0,d.bo)("com.tldraw.asset.video",{AddIsAnimated:1,RenameWidthHeight:2,MakeUrlsValid:3,AddFileSize:4,MakeFileSizeOptional:5}),b=(0,d.XD)({sequenceId:"com.tldraw.asset.video",recordType:"asset",filter:e=>"video"===e.type,sequence:[{id:y.AddIsAnimated,up:e=>{e.props.isAnimated=!1},down:e=>{delete e.props.isAnimated}},{id:y.RenameWidthHeight,up:e=>{e.props.w=e.props.width,e.props.h=e.props.height,delete e.props.width,delete e.props.height},down:e=>{e.props.width=e.props.w,e.props.height=e.props.h,delete e.props.w,delete e.props.h}},{id:y.MakeUrlsValid,up:e=>{o.T.srcUrl.isValid(e.props.src)||(e.props.src="")},down:e=>{}},{id:y.AddFileSize,up:e=>{e.props.fileSize=-1},down:e=>{delete e.props.fileSize}},{id:y.MakeFileSizeOptional,up:e=>{-1===e.props.fileSize&&(e.props.fileSize=void 0)},down:e=>{void 0===e.props.fileSize&&(e.props.fileSize=-1)}}]}),x=o.T.object({x:o.T.number,y:o.T.number,z:o.T.number.optional()}),w=o.T.object({x:o.T.number,y:o.T.number,w:o.T.number,h:o.T.number}),v=o.T.unitInterval,S=o.T.string.refine(e=>{if(!e.startsWith("page:")&&!e.startsWith("shape:"))throw Error('Parent ID must start with "page:" or "shape:"');return e}),C=s("shape"),k=s("binding");function P(e){return!!e&&"binding"===e.typeName}function T(e){return`binding:${e??(0,i.NF)()}`}(0,d.bo)("com.tldraw.binding",{}),(0,d.XD)({sequenceId:"com.tldraw.binding",recordType:"binding",sequence:[]});let E=o.T.object({type:o.T.string,content:o.T.arrayOf(o.T.unknown),attrs:o.T.any.optional()});function I(e){return{type:"doc",content:e.split("\n").map(e=>e?{type:"paragraph",content:[{type:"text",text:e}]}:{type:"paragraph"})}}class _{constructor(e,t,n){this.id=e,this.defaultValue=t,this.type=n}id;defaultValue;type;static define(e,t){let{defaultValue:n,type:r=o.T.any}=t;return new _(e,n,r)}static defineEnum(e,t){let{defaultValue:n,values:r}=t;return new M(e,n,r)}setDefaultValue(e){this.defaultValue=e}validate(e){return this.type.validate(e)}validateUsingKnownGoodVersion(e,t){return this.type.validateUsingKnownGoodVersion?this.type.validateUsingKnownGoodVersion(e,t):this.validate(t)}}class M extends _{constructor(e,t,n){super(e,t,o.T.literalEnum(...n)),this.values=[...n]}values;addValues(...e){for(let t of e)this.values.includes(t)||this.values.push(t);this.type=o.T.literalEnum(...this.values)}removeValues(...e){for(let t of e)this.values.includes(t)&&this.values.splice(this.values.indexOf(t),1);this.type=o.T.literalEnum(...this.values)}}let A=(0,d.bo)("com.tldraw.shape",{AddIsLocked:1,HoistOpacity:2,AddMeta:3,AddWhite:4}),j=(0,d.XD)({sequenceId:"com.tldraw.shape",recordType:"shape",sequence:[{id:A.AddIsLocked,up:e=>{e.isLocked=!1},down:e=>{delete e.isLocked}},{id:A.HoistOpacity,up:e=>{e.opacity=Number(e.props.opacity??"1"),delete e.props.opacity},down:e=>{let t=e.opacity;delete e.opacity,e.props.opacity=t<.175?"0.1":t<.375?"0.25":t<.625?"0.5":t<.875?"0.75":"1"}},{id:A.AddMeta,up:e=>{e.meta={}}},{id:A.AddWhite,up:e=>{},down:e=>{"white"===e.props.color&&(e.props.color="black")}}]});function O(e){return!!e&&"shape"===e.typeName}function D(e){return!!e&&e.startsWith("shape:")}function L(e){return`shape:${e??(0,i.NF)()}`}function F(e){let t=new Map;for(let[n,r]of Object.entries(e))if(r instanceof _){if(t.has(r))throw Error(`Duplicate style prop ${r.id}. Each style prop can only be used once within a shape.`);t.set(r,n)}return t}function R(e,t){return(0,i._H)(t,(t,n)=>`com.tldraw.shape.${e}/${n}`)}function z(e,t){let n=[];for(let[r,{migrations:o}]of Object.entries(t)){let t=`com.tldraw.${e}.${r}`;o?"sequenceId"in o?((0,i.vA)(t===o.sequenceId,`sequenceId mismatch for ${r} ${d.ee} migrations. Expected '${t}', got '${o.sequenceId}'`),n.push(o)):"sequence"in o?n.push((0,d._B)({sequenceId:t,retroactive:!0,sequence:o.sequence.map(t=>"id"in t?N(e,r,t):t)})):n.push((0,d._B)({sequenceId:t,retroactive:!0,sequence:Object.keys(o.migrators).map(e=>Number(e)).sort((e,t)=>e-t).map(n=>({id:`${t}/${n}`,scope:"record",filter:t=>t.typeName===e&&t.type===r,up:e=>{let t=o.migrators[n].up(e);if(t)return t},down:e=>{let t=o.migrators[n].down(e);if(t)return t}}))})):n.push((0,d._B)({sequenceId:t,retroactive:!0,sequence:[]}))}return n}function N(e,t,n){return{id:n.id,dependsOn:n.dependsOn,scope:"record",filter:n=>n.typeName===e&&n.type===t,up:e=>{let t=n.up(e.props);t&&(e.props=t)},down:"function"==typeof n.down?e=>{let t=n.down(e.props);t&&(e.props=t)}:void 0}}let $=["black","grey","light-violet","violet","blue","light-blue","yellow","orange","green","light-green","light-red","red","white"],B=_.defineEnum("tldraw:color",{defaultValue:"black",values:$}),H=_.defineEnum("tldraw:labelColor",{defaultValue:"black",values:$});function U(e){let t=new Set;for(let n of Object.values(e))for(let e of[n.colors.light,n.colors.dark])for(let[n,r]of Object.entries(e))"object"==typeof r&&null!==r&&t.add(n);t.size>0&&(B.addValues(...t),H.addValues(...t));let n=B.values.filter(e=>!t.has(e));n.length>0&&(B.removeValues(...n),H.removeValues(...n))}let W=_.defineEnum("tldraw:dash",{defaultValue:"draw",values:["draw","solid","dashed","dotted","none"]}),K=_.defineEnum("tldraw:fill",{defaultValue:"none",values:["none","semi","solid","pattern","fill","lined-fill"]}),V=_.defineEnum("tldraw:font",{defaultValue:"draw",values:["draw","sans","serif","mono"]}),Y={draw:"'tldraw_draw', sans-serif",sans:"'tldraw_sans', sans-serif",serif:"'tldraw_serif', serif",mono:"'tldraw_mono', monospace"};function G(e){return"object"==typeof e&&null!==e&&"fontFamily"in e}function q(e){let t=new Set;for(let n of Object.values(e))if(n.fonts)for(let[e,r]of Object.entries(n.fonts))G(r)&&t.add(e);let n=[...t].filter(e=>!V.values.includes(e));n.length>0&&V.addValues(...n);let r=V.values.filter(e=>!t.has(e));r.length>0&&V.removeValues(...r)}let X=_.defineEnum("tldraw:size",{defaultValue:"m",values:["s","m","l","xl"]}),J=_.defineEnum("tldraw:arrowKind",{defaultValue:"arc",values:["arc","elbow"]}),Z=["arrow","triangle","square","dot","pipe","diamond","inverted","bar","none"],Q=_.defineEnum("tldraw:arrowheadStart",{defaultValue:"none",values:Z}),ee=_.defineEnum("tldraw:arrowheadEnd",{defaultValue:"arrow",values:Z}),et={kind:J,labelColor:H,color:B,fill:K,dash:W,size:X,arrowheadStart:Q,arrowheadEnd:ee,font:V,start:x,end:x,bend:o.T.number,richText:E,labelPosition:o.T.number,scale:o.T.nonZeroNumber,elbowMidPoint:o.T.number},en=R("arrow",{AddLabelColor:1,AddIsPrecise:2,AddLabelPosition:3,ExtractBindings:4,AddScale:5,AddElbow:6,AddRichText:7,AddRichTextAttrs:8});function er(e){return N("shape","arrow",e)}let ei=(0,d._B)({sequenceId:"com.tldraw.shape.arrow",retroactive:!1,sequence:[er({id:en.AddLabelColor,up:e=>{e.labelColor="black"},down:"retired"}),er({id:en.AddIsPrecise,up:({start:e,end:t})=>{"binding"===e.type&&(e.isPrecise=.5!==e.normalizedAnchor.x||.5!==e.normalizedAnchor.y),"binding"===t.type&&(t.isPrecise=.5!==t.normalizedAnchor.x||.5!==t.normalizedAnchor.y)},down:({start:e,end:t})=>{"binding"===e.type&&(e.isPrecise||(e.normalizedAnchor={x:.5,y:.5}),delete e.isPrecise),"binding"===t.type&&(t.isPrecise||(t.normalizedAnchor={x:.5,y:.5}),delete t.isPrecise)}}),er({id:en.AddLabelPosition,up:e=>{e.labelPosition=.5},down:e=>{delete e.labelPosition}}),{id:en.ExtractBindings,scope:"storage",up:e=>{let t=[];for(let n of e.values()){if("shape"!==n.typeName||"arrow"!==n.type)continue;let e=(0,i.pN)(n),{start:r,end:o}=n.props;if("binding"===r.type){let i=T(),o={typeName:"binding",id:i,type:"arrow",fromId:n.id,toId:r.boundShapeId,meta:{},props:{terminal:"start",normalizedAnchor:r.normalizedAnchor,isExact:r.isExact,isPrecise:r.isPrecise}};t.push([i,o]),e.props.start={x:0,y:0}}else delete e.props.start.type;if("binding"===o.type){let r=T(),i={typeName:"binding",id:r,type:"arrow",fromId:n.id,toId:o.boundShapeId,meta:{},props:{terminal:"end",normalizedAnchor:o.normalizedAnchor,isExact:o.isExact,isPrecise:o.isPrecise}};t.push([r,i]),e.props.end={x:0,y:0}}else delete e.props.end.type;t.push([n.id,e])}for(let[n,r]of t)e.set(n,r)}},er({id:en.AddScale,up:e=>{e.scale=1},down:e=>{delete e.scale}}),er({id:en.AddElbow,up:e=>{e.kind="arc",e.elbowMidPoint=.5},down:e=>{delete e.kind,delete e.elbowMidPoint}}),er({id:en.AddRichText,up:e=>{e.richText=I(e.text),delete e.text}}),er({id:en.AddRichTextAttrs,up:e=>{},down:e=>{e.richText&&"attrs"in e.richText&&delete e.richText.attrs}})]}),eo=o.T.literalEnum("center","edge-point","edge","none"),es={terminal:o.T.literalEnum("start","end"),normalizedAnchor:x,isExact:o.T.boolean,isPrecise:o.T.boolean,snap:eo},ea=(r={AddSnap:1},(0,i._H)(r,(e,t)=>`com.tldraw.binding.arrow/${t}`)),el={sequence:[{dependsOn:[en.ExtractBindings]},{id:ea.AddSnap,up:e=>{e.snap="none"},down:e=>{delete e.snap}}]};var ed=n(83102);let ec=o.T.model("camera",o.T.object({typeName:o.T.literal("camera"),id:s("camera"),x:o.T.number,y:o.T.number,z:o.T.number,meta:o.T.jsonValue})),eu=(0,d.bo)("com.tldraw.camera",{AddMeta:1}),eh=(0,d.XD)({sequenceId:"com.tldraw.camera",recordType:"camera",sequence:[{id:eu.AddMeta,up:e=>{e.meta={}}}]}),ep=(0,d.WE)("camera",{validator:ec,scope:"session"}).withDefaultProperties(()=>({x:0,y:0,z:1,meta:{}})),ef=new Set(["none","default","pointer","cross","comment","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"]),eg=o.T.setEnum(ef),em=o.T.object({type:eg,rotation:o.T.number}),ey=new Set(["accent","white","black","selection-stroke","selection-fill","laser","muted-1"]),eb=o.T.setEnum(ey),ex=new Set(["starting","paused","active","complete","stopping"]),ew=o.T.object({id:o.T.string,points:o.T.arrayOf(x),size:o.T.positiveNumber,color:eb,opacity:o.T.number,state:o.T.setEnum(ex),delay:o.T.number,shrink:o.T.number,taper:o.T.boolean}),ev=s("page"),eS=o.T.model("page",o.T.object({typeName:o.T.literal("page"),id:ev,name:o.T.string,index:o.T.indexKey,meta:o.T.jsonValue})),eC=(0,d.bo)("com.tldraw.page",{AddMeta:1}),ek=(0,d.XD)({sequenceId:"com.tldraw.page",recordType:"page",sequence:[{id:eC.AddMeta,up:e=>{e.meta={}}}]}),eP=(0,d.WE)("page",{validator:eS,scope:"document"}).withDefaultProperties(()=>({meta:{}}));function eT(e){return eP.isId(e)}let eE=s("user"),eI=(0,d.bo)("com.tldraw.user",{Initial:1}),e_=(0,d.XD)({sequenceId:"com.tldraw.user",recordType:"user",sequence:[{id:eI.Initial,up:e=>{}}]});function eM(e){let t=e?.meta,n=t?o.T.object(Object.fromEntries(Object.entries(t).map(([e,t])=>[e,new o.T.Validator(e=>{if(void 0!==e)return t.validate(e)})]))).allowUnknownProperties():o.T.jsonValue,r=o.T.model("user",o.T.object({typeName:o.T.literal("user"),id:eE,name:o.T.string,color:o.T.string,imageUrl:o.T.string,meta:n}));return(0,d.WE)("user",{validator:r,scope:"document"}).withDefaultProperties(()=>({name:"",color:"",imageUrl:"",meta:{}}))}o.T.model("user",o.T.object({typeName:o.T.literal("user"),id:eE,name:o.T.string,color:o.T.string,imageUrl:o.T.string,meta:o.T.jsonValue}));let eA=eM();function ej(e){return eA.createId(e)}let eO={id:!1,typeName:!1,currentPageId:!1,opacityForNextShape:!1,stylesForNextShape:!1,followingUserId:!1,highlightedUserIds:!1,brush:!1,cursor:!1,scribbles:!1,isFocusMode:!0,isDebugMode:!0,isToolLocked:!0,exportBackground:!0,screenBounds:!0,insets:!0,zoomBrush:!1,chatMessage:!1,isChatting:!1,isPenMode:!1,isGridMode:!0,isFocused:!0,devicePixelRatio:!0,isCoarsePointer:!0,isHoveringCanvas:!1,openMenus:!1,isChangingStyle:!1,isReadonly:!0,meta:!1,duplicateProps:!1,cameraState:!1};function eD(e){return e?(0,i.J2)(e,e=>eO[e]):null}s("instance");let eL=(0,d.bo)("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,AddCameraState:26}),eF=(0,d.XD)({sequenceId:"com.tldraw.instance",recordType:"instance",sequence:[{id:eL.AddTransparentExportBgs,up:e=>({...e,exportBackground:!0})},{id:eL.RemoveDialog,up:({dialog:e,...t})=>t},{id:eL.AddToolLockMode,up:e=>({...e,isToolLocked:!1})},{id:eL.RemoveExtraPropsForNextShape,up:({propsForNextShape:e,...t})=>({...t,propsForNextShape:Object.fromEntries(Object.entries(e).filter(([e])=>["color","labelColor","dash","fill","size","font","align","verticalAlign","icon","geo","arrowheadStart","arrowheadEnd","spline"].includes(e)))})},{id:eL.AddLabelColor,up:({propsForNextShape:e,...t})=>({...t,propsForNextShape:{...e,labelColor:"black"}})},{id:eL.AddFollowingUserId,up:e=>({...e,followingUserId:null})},{id:eL.RemoveAlignJustify,up:e=>{let t=e.propsForNextShape.align;return"justify"===t&&(t="start"),{...e,propsForNextShape:{...e.propsForNextShape,align:t}}}},{id:eL.AddZoom,up:e=>({...e,zoomBrush:null})},{id:eL.AddVerticalAlign,up:e=>({...e,propsForNextShape:{...e.propsForNextShape,verticalAlign:"middle"}})},{id:eL.AddScribbleDelay,up:e=>null!==e.scribble?{...e,scribble:{...e.scribble,delay:0}}:{...e}},{id:eL.RemoveUserId,up:({userId:e,...t})=>t},{id:eL.AddIsPenModeAndIsGridMode,up:e=>({...e,isPenMode:!1,isGridMode:!1})},{id:eL.HoistOpacity,up:({propsForNextShape:{opacity:e,...t},...n})=>({...n,opacityForNextShape:Number(e??"1"),propsForNextShape:t})},{id:eL.AddChat,up:e=>({...e,chatMessage:"",isChatting:!1})},{id:eL.AddHighlightedUserIds,up:e=>({...e,highlightedUserIds:[]})},{id:eL.ReplacePropsForNextShapeWithStylesForNextShape,up:({propsForNextShape:e,...t})=>({...t,stylesForNextShape:{}})},{id:eL.AddMeta,up:e=>({...e,meta:{}})},{id:eL.RemoveCursorColor,up:e=>{let{color:t,...n}=e.cursor;return{...e,cursor:n}}},{id:eL.AddLonelyProperties,up:e=>({...e,canMoveCamera:!0,isFocused:!1,devicePixelRatio:1,isCoarsePointer:!1,openMenus:[],isChangingStyle:!1,isReadOnly:!1})},{id:eL.ReadOnlyReadonly,up:({isReadOnly:e,...t})=>({...t,isReadonly:e})},{id:eL.AddHoveringCanvas,up:e=>({...e,isHoveringCanvas:null})},{id:eL.AddScribbles,up:({scribble:e,...t})=>({...t,scribbles:[]})},{id:eL.AddInset,up:e=>({...e,insets:[!1,!1,!1,!1]}),down:({insets:e,...t})=>({...t})},{id:eL.AddDuplicateProps,up:e=>({...e,duplicateProps:null}),down:({duplicateProps:e,...t})=>({...t})},{id:eL.RemoveCanMoveCamera,up:({canMoveCamera:e,...t})=>({...t}),down:e=>({...e,canMoveCamera:!0})},{id:eL.AddCameraState,up:e=>({...e,cameraState:"idle"}),down:({cameraState:e,...t})=>t}]}),eR="instance:instance",ez=o.T.model("instance_page_state",o.T.object({typeName:o.T.literal("instance_page_state"),id:s("instance_page_state"),pageId:ev,selectedShapeIds:o.T.arrayOf(C),hintingShapeIds:o.T.arrayOf(C),erasingShapeIds:o.T.arrayOf(C),hoveredShapeId:C.nullable(),editingShapeId:C.nullable(),croppingShapeId:C.nullable(),focusedGroupId:C.nullable(),meta:o.T.jsonValue})),eN=(0,d.bo)("com.tldraw.instance_page_state",{AddCroppingId:1,RemoveInstanceIdAndCameraId:2,AddMeta:3,RenameProperties:4,RenamePropertiesAgain:5}),e$=(0,d.XD)({sequenceId:"com.tldraw.instance_page_state",recordType:"instance_page_state",sequence:[{id:eN.AddCroppingId,up(e){e.croppingShapeId=null}},{id:eN.RemoveInstanceIdAndCameraId,up(e){delete e.instanceId,delete e.cameraId}},{id:eN.AddMeta,up:e=>{e.meta={}}},{id:eN.RenameProperties,up:e=>{},down:e=>{}},{id:eN.RenamePropertiesAgain,up:e=>{e.selectedShapeIds=e.selectedIds,delete e.selectedIds,e.hintingShapeIds=e.hintingIds,delete e.hintingIds,e.erasingShapeIds=e.erasingIds,delete e.erasingIds,e.hoveredShapeId=e.hoveredId,delete e.hoveredId,e.editingShapeId=e.editingId,delete e.editingId,e.croppingShapeId=e.croppingShapeId??e.croppingId??null,delete e.croppingId,e.focusedGroupId=e.focusLayerId,delete e.focusLayerId},down:e=>{e.selectedIds=e.selectedShapeIds,delete e.selectedShapeIds,e.hintingIds=e.hintingShapeIds,delete e.hintingShapeIds,e.erasingIds=e.erasingShapeIds,delete e.erasingShapeIds,e.hoveredId=e.hoveredShapeId,delete e.hoveredShapeId,e.editingId=e.editingShapeId,delete e.editingShapeId,e.croppingId=e.croppingShapeId,delete e.croppingShapeId,e.focusLayerId=e.focusedGroupId,delete e.focusedGroupId}}]}),eB=(0,d.WE)("instance_page_state",{validator:ez,scope:"session",ephemeralKeys:{pageId:!1,selectedShapeIds:!1,editingShapeId:!0,croppingShapeId:!1,meta:!1,hintingShapeIds:!0,erasingShapeIds:!0,hoveredShapeId:!0,focusedGroupId:!0}}).withDefaultProperties(()=>({editingShapeId:null,croppingShapeId:null,selectedShapeIds:[],hoveredShapeId:null,erasingShapeIds:[],hintingShapeIds:[],focusedGroupId:null,meta:{}})),eH=o.T.model("pointer",o.T.object({typeName:o.T.literal("pointer"),id:s("pointer"),x:o.T.number,y:o.T.number,lastActivityTimestamp:o.T.number,meta:o.T.jsonValue})),eU=(0,d.bo)("com.tldraw.pointer",{AddMeta:1}),eW=(0,d.XD)({sequenceId:"com.tldraw.pointer",recordType:"pointer",sequence:[{id:eU.AddMeta,up:e=>{e.meta={}}}]}),eK=(0,d.WE)("pointer",{validator:eH,scope:"session"}).withDefaultProperties(()=>({x:0,y:0,lastActivityTimestamp:0,meta:{}})),eV=eK.createId("pointer"),eY=o.T.model("instance_presence",o.T.object({typeName:o.T.literal("instance_presence"),id:s("instance_presence"),userId:eE,userName:o.T.string,lastActivityTimestamp:o.T.number.nullable(),followingUserId:eE.nullable(),cursor:o.T.object({x:o.T.number,y:o.T.number,type:eg,rotation:o.T.number}).nullable(),color:o.T.string,camera:o.T.object({x:o.T.number,y:o.T.number,z:o.T.number}).nullable(),screenBounds:w.nullable(),selectedShapeIds:o.T.arrayOf(s("shape")),currentPageId:s("page"),brush:w.nullable(),scribbles:o.T.arrayOf(ew),chatMessage:o.T.string,meta:o.T.jsonValue})),eG=(0,d.bo)("com.tldraw.instance_presence",{AddScribbleDelay:1,RemoveInstanceId:2,AddChatMessage:3,AddMeta:4,RenameSelectedShapeIds:5,NullableCameraCursor:6}),eq=(0,d.XD)({sequenceId:"com.tldraw.instance_presence",recordType:"instance_presence",sequence:[{id:eG.AddScribbleDelay,up:e=>{null!==e.scribble&&(e.scribble.delay=0)}},{id:eG.RemoveInstanceId,up:e=>{delete e.instanceId}},{id:eG.AddChatMessage,up:e=>{e.chatMessage=""}},{id:eG.AddMeta,up:e=>{e.meta={}}},{id:eG.RenameSelectedShapeIds,up:e=>{}},{id:eG.NullableCameraCursor,up:e=>{},down:e=>{null===e.camera&&(e.camera={x:0,y:0,z:1}),null===e.lastActivityTimestamp&&(e.lastActivityTimestamp=0),null===e.cursor&&(e.cursor={type:"default",x:0,y:0,rotation:0}),null===e.screenBounds&&(e.screenBounds={x:0,y:0,w:1,h:1})}}]}),eX=(0,d.WE)("instance_presence",{validator:eY,scope:"presence"}).withDefaultProperties(()=>({lastActivityTimestamp:null,followingUserId:null,color:"#FF0000",camera:null,cursor:null,screenBounds:null,selectedShapeIds:[],brush:null,scribbles:[],chatMessage:"",meta:{}})),eJ=(0,d.bo)("com.tldraw.asset",{AddMeta:1}),eZ=(0,d.XD)({sequenceId:"com.tldraw.asset",recordType:"asset",sequence:[{id:eJ.AddMeta,up:e=>{e.meta={}}}]}),eQ=(0,d.WE)("asset",{scope:"document"}).withDefaultProperties(()=>({meta:{}})),e0=o.T.model("document",o.T.object({typeName:o.T.literal("document"),id:o.T.literal("document:document"),gridSize:o.T.number,name:o.T.string,meta:o.T.jsonValue})),e1=(0,d.bo)("com.tldraw.document",{AddName:1,AddMeta:2}),e2=(0,d.XD)({sequenceId:"com.tldraw.document",recordType:"document",sequence:[{id:e1.AddName,up:e=>{e.name=""},down:e=>{delete e.name}},{id:e1.AddMeta,up:e=>{e.meta={}}}]}),e3=(0,d.WE)("document",{validator:e0,scope:"document"}).withDefaultProperties(()=>({gridSize:10,name:"",meta:{}})),e5=e3.createId("document"),e6={w:o.T.nonZeroNumber,h:o.T.nonZeroNumber,assetId:a.nullable(),url:o.T.linkUrl},e4=R("bookmark",{NullAssetId:1,MakeUrlsValid:2}),e8={sequence:[{id:e4.NullAssetId,up:e=>{void 0===e.assetId&&(e.assetId=null)},down:"retired"},{id:e4.MakeUrlsValid,up:e=>{o.T.linkUrl.isValid(e.url)||(e.url="")},down:e=>{}}]},e9=2,e7="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",te=new Uint8Array(128);for(let e=0;e<64;e++)te[e7.charCodeAt(e)]=e;let tt=new Float64Array(31);for(let e=0;e<31;e++)tt[e]=Math.pow(2,e-15);let tn=6103515625e-14/1024,tr=new Float64Array(1024);for(let e=0;e<1024;e++)tr[e]=1+e/1024;let ti="function"==typeof DataView.prototype.getFloat16?function(e,t){return e.getFloat16(t,!0)}:function(e,t){return function(e){let t=e>>15,n=e>>10&31,r=1023&e;if(0===n)return t?-r*tn:r*tn;if(31===n)return r?NaN:t?-1/0:1/0;let i=tt[n]*tr[r];return t?-i:i}(e.getUint16(t,!0))},to="function"==typeof DataView.prototype.setFloat16?function(e,t,n){e.setFloat16(t,n,!0)}:function(e,t,n){e.setUint16(t,function(e){if(0===e)return 32768*!!Object.is(e,-0);if(!Number.isFinite(e))return Number.isNaN(e)?32256:e>0?31744:64512;let t=+(e<0),n=Math.floor(Math.log2(e=Math.abs(e))),r=n+15;if(r>=31)return t<<15|31744;if(r<=0)return t<<15|1023&Math.round(16384*e*1024);let i=Math.round(1024*(e/Math.pow(2,n)-1));return i>=1024&&(i=0,++r>=31)?t<<15|31744:t<<15|r<<10|i}(n),!0)},ts="function"==typeof Uint8Array.prototype.toBase64?function(e){return e.toBase64()}:function(e){let t=e.length,n=3*Math.floor(t/3),r="";for(let t=0;t<n;t+=3){let n=e[t]<<16|e[t+1]<<8|e[t+2];r+=e7[n>>18&63]+e7[n>>12&63]+e7[n>>6&63]+e7[63&n]}let i=t-n;if(1===i){let t=e[n]<<16;r+=e7[t>>18&63]+e7[t>>12&63]+"=="}else if(2===i){let t=e[n]<<16|e[n+1]<<8;r+=e7[t>>18&63]+e7[t>>12&63]+e7[t>>6&63]+"="}return r},ta="function"==typeof Uint8Array.fromBase64?function(e){return Uint8Array.fromBase64(e)}:function(e){let t=e.length,n=0;t>0&&61===e.charCodeAt(t-1)&&(n++,t>1&&61===e.charCodeAt(t-2)&&n++);let r=new Uint8Array(Math.floor(3*t/4)-n),i=0,o=4*Math.floor((t-n)/4);for(let t=0;t<o;t+=4){let n=te[e.charCodeAt(t)]<<18|te[e.charCodeAt(t+1)]<<12|te[e.charCodeAt(t+2)]<<6|te[e.charCodeAt(t+3)];r[i++]=n>>16&255,r[i++]=n>>8&255,r[i++]=255&n}if(1===n){let t=te[e.charCodeAt(o)]<<18|te[e.charCodeAt(o+1)]<<12|te[e.charCodeAt(o+2)]<<6;r[i++]=t>>16&255,r[i++]=t>>8&255}else if(2===n){let t=te[e.charCodeAt(o)],n=te[e.charCodeAt(o+1)];r[i++]=(t<<18|n<<12)>>16&255}return r};class tl{static _legacyEncodePoint(e,t,n){let r=new Uint8Array(6),i=new DataView(r.buffer);return to(i,0,e),to(i,2,t),to(i,4,n),ts(r)}static _legacyEncodePoints(e){if(0===e.length)return"";let t=new Uint8Array(6*e.length),n=new DataView(t.buffer);for(let t=0;t<e.length;t++){let r=e[t],i=6*t;to(n,i,r.x),to(n,i+2,r.y),to(n,i+4,r.z??.5)}return ts(t)}static _legacyDecodePoints(e){let t=ta(e),n=new DataView(t.buffer,t.byteOffset,t.byteLength),r=[];for(let e=0;e<t.length;e+=6)r.push({x:ti(n,e),y:ti(n,e+2),z:ti(n,e+4)});return r}static encodePoints(e,t){if(t===e9)return tl.encodePoints2D(e);if(0===e.length)return"";let n=new Uint8Array(12+(e.length-1)*6),r=new DataView(n.buffer),i=e[0];r.setFloat32(0,i.x,!0),r.setFloat32(4,i.y,!0),r.setFloat32(8,i.z??.5,!0);let o=i.x,s=i.y,a=i.z??.5;for(let t=1;t<e.length;t++){let n=e[t],i=n.z??.5,l=12+(t-1)*6;to(r,l,n.x-o),to(r,l+2,n.y-s),to(r,l+4,i-a),o=n.x,s=n.y,a=i}return ts(n)}static decodePoints(e,t){if(t===e9)return tl.decodePoints2D(e);if(0===e.length)return[];let n=ta(e),r=new DataView(n.buffer,n.byteOffset,n.byteLength),i=[],o=r.getFloat32(0,!0),s=r.getFloat32(4,!0),a=r.getFloat32(8,!0);i.push({x:o,y:s,z:a});for(let e=12;e<n.length;e+=6)o+=ti(r,e),s+=ti(r,e+2),i.push({x:o,y:s,z:a+=ti(r,e+4)});return i}static decodeFirstPoint(e,t){if(t===e9)return tl.decodeFirstPoint2D(e);if(e.length<16)return null;let n=ta(e.slice(0,16)),r=new DataView(n.buffer,n.byteOffset,n.byteLength);return{x:r.getFloat32(0,!0),y:r.getFloat32(4,!0),z:r.getFloat32(8,!0)}}static decodeLastPoint(e,t){if(t===e9)return tl.decodeLastPoint2D(e);if(e.length<16)return null;let n=ta(e),r=new DataView(n.buffer,n.byteOffset,n.byteLength),i=r.getFloat32(0,!0),o=r.getFloat32(4,!0),s=r.getFloat32(8,!0);for(let e=12;e<n.length;e+=6)i+=ti(r,e),o+=ti(r,e+2),s+=ti(r,e+4);return{x:i,y:o,z:s}}static encodePoints2D(e){if(0===e.length)return"";let t=new Uint8Array(8+(e.length-1)*4),n=new DataView(t.buffer),r=e[0];n.setFloat32(0,r.x,!0),n.setFloat32(4,r.y,!0);let i=r.x,o=r.y;for(let t=1;t<e.length;t++){let r=e[t],s=8+(t-1)*4;to(n,s,r.x-i),to(n,s+2,r.y-o),i=r.x,o=r.y}return ts(t)}static decodePoints2D(e){if(0===e.length)return[];let t=ta(e),n=new DataView(t.buffer,t.byteOffset,t.byteLength),r=[],i=n.getFloat32(0,!0),o=n.getFloat32(4,!0);r.push({x:i,y:o,z:.5});for(let e=8;e<t.length;e+=4)i+=ti(n,e),r.push({x:i,y:o+=ti(n,e+2),z:.5});return r}static decodeFirstPoint2D(e){if(e.length<12)return null;let t=ta(e.slice(0,12)),n=new DataView(t.buffer,t.byteOffset,t.byteLength);return{x:n.getFloat32(0,!0),y:n.getFloat32(4,!0),z:.5}}static decodeLastPoint2D(e){if(e.length<12)return null;let t=ta(e),n=new DataView(t.buffer,t.byteOffset,t.byteLength),r=n.getFloat32(0,!0),i=n.getFloat32(4,!0);for(let e=8;e<t.length;e+=4)r+=ti(n,e),i+=ti(n,e+2);return{x:r,y:i,z:.5}}static isSinglePoint(e,t){return e.length<=(t===e9?12:16)}}let td=o.T.object({type:o.T.literalEnum("free","straight"),path:o.T.string,dim:o.T.literalEnum(e9,3).optional()}),tc={color:B,fill:K,dash:W,size:X,segments:o.T.arrayOf(td),isComplete:o.T.boolean,isClosed:o.T.boolean,isPen:o.T.boolean,scale:o.T.nonZeroNumber,scaleX:o.T.nonZeroFiniteNumber,scaleY:o.T.nonZeroFiniteNumber},tu=R("draw",{AddInPen:1,AddScale:2,Base64:3,LegacyPointsConversion:4,OmitNonPressureZ:5}),th={sequence:[{id:tu.AddInPen,up:e=>{let{points:t}=e.segments[0];if(0===t.length){e.isPen=!1;return}let n=0!==t[0].z&&.5!==t[0].z;t[1]&&(n=n&&0!==t[1].z&&.5!==t[1].z),e.isPen=n},down:"retired"},{id:tu.AddScale,up:e=>{e.scale=1},down:e=>{delete e.scale}},{id:tu.Base64,up:e=>{e.segments=e.segments.map(e=>{if(void 0!==e.path)return e;let{points:t,...n}=e,r=Array.isArray(t)?t:tl._legacyDecodePoints(t);return{...n,path:tl.encodePoints(r)}}),e.scaleX=e.scaleX??1,e.scaleY=e.scaleY??1},down:e=>{e.segments=e.segments.map(e=>{let{path:t,...n}=e;return{...n,points:tl.decodePoints(t)}}),delete e.scaleX,delete e.scaleY}},{id:tu.LegacyPointsConversion,up:e=>{e.segments=e.segments.map(e=>{if(void 0!==e.path)return e;let{points:t,...n}=e,r=Array.isArray(t)?t:tl._legacyDecodePoints(t);return{...n,path:tl.encodePoints(r)}})},down:e=>{}},{id:tu.OmitNonPressureZ,up:e=>{},down:e=>{e.segments=e.segments.map(e=>{if(void 0===e.dim)return e;let{dim:t,...n}=e;return t===e9?{...n,path:tl.encodePoints(tl.decodePoints(e.path,e9))}:n})}}]},tp=/(^\/r\/[^/]+\/?$)/,tf=[{hostnames:["beta.tldraw.com","tldraw.com","localhost:3000"],canEditWhileLocked:!0,fromEmbedUrl:e=>{let t=(0,i.yC)(e);if(t&&t.pathname.match(tp))return e}},{hostnames:["figma.com"],canEditWhileLocked:!0,fromEmbedUrl:e=>{let t=(0,i.yC)(e);if(t&&t.pathname.match(/^\/embed\/?$/)){let e=t.searchParams.get("url");if(e)return e}}},{hostnames:["google.*"],canEditWhileLocked:!0,fromEmbedUrl:e=>{let t=(0,i.yC)(e);if(t&&t.pathname.match(/^\/maps\/embed\/v1\/view\/?$/)&&t.searchParams.has("center")&&t.searchParams.get("zoom")){let e=t.searchParams.get("zoom"),[n,r]=t.searchParams.get("center").split(",");return`https://www.google.com/maps/@${n},${r},${e}z`}}},{hostnames:["val.town"],canEditWhileLocked:!0,fromEmbedUrl:e=>{let t=(0,i.yC)(e),n=t&&t.pathname.match(/\/embed\/(.+)\/?/);if(n)return`https://www.val.town/v/${n[1]}`}},{hostnames:["codesandbox.io"],canEditWhileLocked:!0,fromEmbedUrl:e=>{let t=(0,i.yC)(e),n=t&&t.pathname.match(/\/embed\/([^/]+)\/?/);if(n)return`https://codesandbox.io/s/${n[1]}`}},{hostnames:["codepen.io"],canEditWhileLocked:!0,fromEmbedUrl:e=>{let t=e.match(/https:\/\/codepen.io\/([^/]+)\/embed\/([^/]+)/);if(t){let[e,n,r]=t;return`https://codepen.io/${n}/pen/${r}`}}},{hostnames:["scratch.mit.edu"],canEditWhileLocked:!0,fromEmbedUrl:e=>{let t=e.match(/https:\/\/scratch.mit.edu\/projects\/embed\/([^/]+)/);if(t){let[e,n]=t;return`https://scratch.mit.edu/projects/${n}`}}},{hostnames:["*.youtube.com","youtube.com","youtu.be"],canEditWhileLocked:!0,fromEmbedUrl:e=>{let t=(0,i.yC)(e);if(t&&"youtube.com"===t.hostname.replace(/^www./,"")){let e=t.pathname.match(/^\/embed\/([^/]+)\/?/);if(e)return`https://www.youtube.com/watch?v=${e[1]}`}}},{hostnames:["calendar.google.*"],canEditWhileLocked:!0,fromEmbedUrl:e=>{let t=(0,i.yC)(e),n=t?.searchParams.get("src");if(t?.pathname.match(/\/calendar\/embed/)&&n){for(let e of(t.pathname="/calendar/u/0",Array.from(t.searchParams.keys())))t.searchParams.delete(e);return t.searchParams.set("cid",n),t.href}}},{hostnames:["docs.google.*"],canEditWhileLocked:!0,fromEmbedUrl:e=>{let t=(0,i.yC)(e);if(t?.pathname.match(/^\/presentation/)&&t?.pathname.match(/\/embed\/?$/)){for(let e of(t.pathname=t.pathname.replace(/\/embed$/,"/pub"),Array.from(t.searchParams.keys())))t.searchParams.delete(e);return t.href}}},{hostnames:["gist.github.com"],canEditWhileLocked:!0,fromEmbedUrl:e=>{let t=(0,i.yC)(e);if(t&&t.pathname.match(/\/([^/]+)\/([^/]+)/)){if(!e.split("/").pop())return;return e}}},{hostnames:["replit.com"],canEditWhileLocked:!0,fromEmbedUrl:e=>{let t=(0,i.yC)(e);if(t&&t.pathname.match(/\/@([^/]+)\/([^/]+)/)&&t.searchParams.has("embed"))return t.searchParams.delete("embed"),t.href}},{hostnames:["felt.com"],canEditWhileLocked:!0,fromEmbedUrl:e=>{let t=(0,i.yC)(e);if(t&&t.pathname.match(/^\/embed\/map\//))return t.pathname=t.pathname.replace(/^\/embed/,""),t.href}},{hostnames:["open.spotify.com"],canEditWhileLocked:!0,fromEmbedUrl:e=>{let t=(0,i.yC)(e);if(t&&t.pathname.match(/^\/embed\/(artist|album)\//))return t.origin+t.pathname.replace(/^\/embed/,"")}},{hostnames:["vimeo.com","player.vimeo.com"],canEditWhileLocked:!0,fromEmbedUrl:e=>{let t=(0,i.yC)(e);if(t&&"player.vimeo.com"===t.hostname){let e=t.pathname.match(/^\/video\/([^/]+)\/?$/);if(e)return"https://vimeo.com/"+e[1]}}},{hostnames:["observablehq.com"],canEditWhileLocked:!0,fromEmbedUrl:e=>{let t=(0,i.yC)(e);return t&&t.pathname.match(/^\/embed\/@([^/]+)\/([^/]+)\/?$/)?`${t.origin}${t.pathname.replace("/embed","")}#cell-*`:t&&t.pathname.match(/^\/embed\/([^/]+)\/?$/)?`${t.origin}${t.pathname.replace("/embed","/d")}#cell-*`:void 0}},{hostnames:["desmos.com"],canEditWhileLocked:!0,fromEmbedUrl:e=>{let t=(0,i.yC)(e);if(t&&"www.desmos.com"===t.hostname&&t.pathname.match(/^\/calculator\/([^/]+)\/?$/)&&"?embed"===t.search&&""===t.hash)return e.replace("?embed","")}}],tg={w:o.T.nonZeroNumber,h:o.T.nonZeroNumber,url:o.T.string},tm=R("embed",{GenOriginalUrlInEmbed:1,RemoveDoesResize:2,RemoveTmpOldUrl:3,RemovePermissionOverrides:4}),ty={sequence:[{id:tm.GenOriginalUrlInEmbed,up:e=>{try{let t,n=e.url,r=new URL(n).host.replace("www.","");for(let e of tf)if(e.hostnames.includes(r))try{t=e.fromEmbedUrl(n)}catch(e){console.warn(e)}e.tmpOldUrl=e.url,e.url=t??""}catch{e.url="",e.tmpOldUrl=e.url}},down:"retired"},{id:tm.RemoveDoesResize,up:e=>{delete e.doesResize},down:"retired"},{id:tm.RemoveTmpOldUrl,up:e=>{delete e.tmpOldUrl},down:"retired"},{id:tm.RemovePermissionOverrides,up:e=>{delete e.overridePermissions},down:"retired"}]},tb={w:o.T.nonZeroNumber,h:o.T.nonZeroNumber,name:o.T.string,color:{validate:e=>B.validate(e)}},tx={sequence:[{id:R("frame",{AddColorProp:1}).AddColorProp,up:e=>{e.color="black"},down:e=>{delete e.color}}]},tw=_.defineEnum("tldraw:horizontalAlign",{defaultValue:"middle",values:["start","middle","end","start-legacy","end-legacy","middle-legacy"]}),tv=_.defineEnum("tldraw:verticalAlign",{defaultValue:"middle",values:["start","middle","end"]}),tS=_.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"]}),tC={geo:tS,dash:W,url:o.T.linkUrl,w:o.T.nonZeroNumber,h:o.T.nonZeroNumber,growY:o.T.positiveNumber,scale:o.T.nonZeroNumber,flipX:o.T.boolean,flipY:o.T.boolean,labelColor:H,color:B,fill:K,size:X,font:V,align:tw,verticalAlign:tv,richText:E},tk=R("geo",{AddUrlProp:1,AddLabelColor:2,RemoveJustify:3,AddCheckBox:4,AddVerticalAlign:5,MigrateLegacyAlign:6,AddCloud:7,MakeUrlsValid:8,AddScale:9,AddRichText:10,AddRichTextAttrs:11,AddFlipProps:12}),tP={sequence:[{id:tk.AddUrlProp,up:e=>{e.url=""},down:"retired"},{id:tk.AddLabelColor,up:e=>{e.labelColor="black"},down:"retired"},{id:tk.RemoveJustify,up:e=>{"justify"===e.align&&(e.align="start")},down:"retired"},{id:tk.AddCheckBox,up:e=>{},down:"retired"},{id:tk.AddVerticalAlign,up:e=>{e.verticalAlign="middle"},down:"retired"},{id:tk.MigrateLegacyAlign,up:e=>{let t;switch(e.align){case"start":t="start-legacy";break;case"end":t="end-legacy";break;default:t="middle-legacy"}e.align=t},down:"retired"},{id:tk.AddCloud,up:e=>{},down:"retired"},{id:tk.MakeUrlsValid,up:e=>{o.T.linkUrl.isValid(e.url)||(e.url="")},down:e=>{}},{id:tk.AddScale,up:e=>{e.scale=1},down:e=>{delete e.scale}},{id:tk.AddRichText,up:e=>{e.richText=I(e.text),delete e.text}},{id:tk.AddRichTextAttrs,up:e=>{},down:e=>{e.richText&&"attrs"in e.richText&&delete e.richText.attrs}},{id:tk.AddFlipProps,up:e=>{e.flipX=!1,e.flipY=!1},down:e=>{delete e.flipX,delete e.flipY}}]},tT={},tE={sequence:[]},tI={color:B,size:X,segments:o.T.arrayOf(td),isComplete:o.T.boolean,isPen:o.T.boolean,scale:o.T.nonZeroNumber,scaleX:o.T.nonZeroFiniteNumber,scaleY:o.T.nonZeroFiniteNumber},t_=R("highlight",{AddScale:1,Base64:2,LegacyPointsConversion:3,OmitNonPressureZ:4}),tM={sequence:[{id:t_.AddScale,up:e=>{e.scale=1},down:e=>{delete e.scale}},{id:t_.Base64,up:e=>{e.segments=e.segments.map(e=>{if(void 0!==e.path)return e;let{points:t,...n}=e,r=Array.isArray(t)?t:tl._legacyDecodePoints(t);return{...n,path:tl.encodePoints(r)}}),e.scaleX=e.scaleX??1,e.scaleY=e.scaleY??1},down:e=>{e.segments=e.segments.map(e=>{let{path:t,...n}=e;return{...n,points:tl.decodePoints(t)}}),delete e.scaleX,delete e.scaleY}},{id:t_.LegacyPointsConversion,up:e=>{e.segments=e.segments.map(e=>{if(void 0!==e.path)return e;let{points:t,...n}=e,r=Array.isArray(t)?t:tl._legacyDecodePoints(t);return{...n,path:tl.encodePoints(r)}})},down:e=>{}},{id:t_.OmitNonPressureZ,up:e=>{},down:e=>{e.segments=e.segments.map(e=>{if(void 0===e.dim)return e;let{dim:t,...n}=e;return t===e9?{...n,path:tl.encodePoints(tl.decodePoints(e.path,e9))}:n})}}]},tA=o.T.object({topLeft:x,bottomRight:x,isCircle:o.T.boolean.optional()}),tj={w:o.T.nonZeroNumber,h:o.T.nonZeroNumber,playing:o.T.boolean,url:o.T.linkUrl,assetId:a.nullable(),crop:tA.nullable(),flipX:o.T.boolean,flipY:o.T.boolean,altText:o.T.string},tO=R("image",{AddUrlProp:1,AddCropProp:2,MakeUrlsValid:3,AddFlipProps:4,AddAltText:5}),tD={sequence:[{id:tO.AddUrlProp,up:e=>{e.url=""},down:"retired"},{id:tO.AddCropProp,up:e=>{e.crop=null},down:e=>{delete e.crop}},{id:tO.MakeUrlsValid,up:e=>{o.T.linkUrl.isValid(e.url)||(e.url="")},down:e=>{}},{id:tO.AddFlipProps,up:e=>{e.flipX=!1,e.flipY=!1},down:e=>{delete e.flipX,delete e.flipY}},{id:tO.AddAltText,up:e=>{e.altText=""},down:e=>{delete e.altText}}]},tL=_.defineEnum("tldraw:spline",{defaultValue:"line",values:["cubic","line"]}),tF=o.T.object({id:o.T.string,index:o.T.indexKey,x:o.T.number,y:o.T.number}),tR={color:B,dash:W,size:X,spline:tL,points:o.T.dict(o.T.string,tF),scale:o.T.nonZeroNumber},tz=R("line",{AddSnapHandles:1,RemoveExtraHandleProps:2,HandlesToPoints:3,PointIndexIds:4,AddScale:5}),tN={sequence:[{id:tz.AddSnapHandles,up:e=>{for(let t of Object.values(e.handles))t.canSnap=!0},down:"retired"},{id:tz.RemoveExtraHandleProps,up:e=>{e.handles=(0,i._e)(Object.values(e.handles).map(e=>[e.index,{x:e.x,y:e.y}]))},down:e=>{let t=Object.entries(e.handles).map(([e,t])=>({index:e,...t})).sort(i.Ky);e.handles=Object.fromEntries(t.map((e,n)=>{let r=0===n?"start":n===t.length-1?"end":`handle:${e.index}`;return[r,{id:r,type:"vertex",canBind:!1,canSnap:!0,index:e.index,x:e.x,y:e.y}]}))}},{id:tz.HandlesToPoints,up:e=>{let t=Object.entries(e.handles).map(([e,{x:t,y:n}])=>({x:t,y:n,index:e})).sort(i.Ky);e.points=t.map(({x:e,y:t})=>({x:e,y:t})),delete e.handles},down:e=>{let t=(0,i.uu)(e.points.length);e.handles=Object.fromEntries(e.points.map((e,n)=>[t[n],{x:e.x,y:e.y}])),delete e.points}},{id:tz.PointIndexIds,up:e=>{let t=(0,i.uu)(e.points.length);e.points=Object.fromEntries(e.points.map((e,n)=>{let r=t[n];return[r,{id:r,index:r,x:e.x,y:e.y}]}))},down:e=>{let t=Object.values(e.points).sort(i.Ky);e.points=t.map(({x:e,y:t})=>({x:e,y:t}))}},{id:tz.AddScale,up:e=>{e.scale=1},down:e=>{delete e.scale}}]},t$={color:B,labelColor:H,size:X,font:V,fontSizeAdjustment:o.T.positiveNumber.nullable(),align:tw,verticalAlign:tv,growY:o.T.positiveNumber,url:o.T.linkUrl,richText:E,scale:o.T.nonZeroNumber,textLastEditedBy:o.T.string.nullable()},tB=R("note",{AddUrlProp:1,RemoveJustify:2,MigrateLegacyAlign:3,AddVerticalAlign:4,MakeUrlsValid:5,AddFontSizeAdjustment:6,AddScale:7,AddLabelColor:8,AddRichText:9,AddRichTextAttrs:10,AddFirstEditedBy:11,MakeFontSizeAdjustmentRatio:12,RenameFirstEditedByToLast:13}),tH={sequence:[{id:tB.AddUrlProp,up:e=>{e.url=""},down:"retired"},{id:tB.RemoveJustify,up:e=>{"justify"===e.align&&(e.align="start")},down:"retired"},{id:tB.MigrateLegacyAlign,up:e=>{switch(e.align){case"start":e.align="start-legacy";return;case"end":e.align="end-legacy";return;default:e.align="middle-legacy";return}},down:"retired"},{id:tB.AddVerticalAlign,up:e=>{e.verticalAlign="middle"},down:"retired"},{id:tB.MakeUrlsValid,up:e=>{o.T.linkUrl.isValid(e.url)||(e.url="")},down:e=>{}},{id:tB.AddFontSizeAdjustment,up:e=>{e.fontSizeAdjustment=0},down:e=>{delete e.fontSizeAdjustment}},{id:tB.AddScale,up:e=>{e.scale=1},down:e=>{delete e.scale}},{id:tB.AddLabelColor,up:e=>{e.labelColor="black"},down:e=>{delete e.labelColor}},{id:tB.AddRichText,up:e=>{e.richText=I(e.text),delete e.text}},{id:tB.AddRichTextAttrs,up:e=>{},down:e=>{e.richText&&"attrs"in e.richText&&delete e.richText.attrs}},{id:tB.AddFirstEditedBy,up:e=>{e.textFirstEditedBy=null},down:e=>{delete e.textFirstEditedBy}},{id:tB.MakeFontSizeAdjustmentRatio,up:e=>{e.fontSizeAdjustment=0===e.fontSizeAdjustment?1:null},down:e=>{e.fontSizeAdjustment=0}},{id:tB.RenameFirstEditedByToLast,up:e=>{e.textLastEditedBy=e.textFirstEditedBy??null,delete e.textFirstEditedBy},down:e=>{e.textFirstEditedBy=e.textLastEditedBy??null,delete e.textLastEditedBy}}]},tU=_.defineEnum("tldraw:textAlign",{defaultValue:"start",values:["start","middle","end"]}),tW={color:B,size:X,font:V,textAlign:tU,w:o.T.nonZeroNumber,richText:E,scale:o.T.nonZeroNumber,autoSize:o.T.boolean},tK=R("text",{RemoveJustify:1,AddTextAlign:2,AddRichText:3,AddRichTextAttrs:4}),tV={sequence:[{id:tK.RemoveJustify,up:e=>{"justify"===e.align&&(e.align="start")},down:"retired"},{id:tK.AddTextAlign,up:e=>{e.textAlign=e.align,delete e.align},down:e=>{e.align=e.textAlign,delete e.textAlign}},{id:tK.AddRichText,up:e=>{e.richText=I(e.text),delete e.text}},{id:tK.AddRichTextAttrs,up:e=>{},down:e=>{e.richText&&"attrs"in e.richText&&delete e.richText.attrs}}]},tY={w:o.T.nonZeroNumber,h:o.T.nonZeroNumber,time:o.T.number,playing:o.T.boolean,autoplay:o.T.boolean,url:o.T.linkUrl,assetId:a.nullable(),altText:o.T.string},tG=R("video",{AddUrlProp:1,MakeUrlsValid:2,AddAltText:3,AddAutoplay:4}),tq={sequence:[{id:tG.AddUrlProp,up:e=>{e.url=""},down:"retired"},{id:tG.MakeUrlsValid,up:e=>{o.T.linkUrl.isValid(e.url)||(e.url="")},down:e=>{}},{id:tG.AddAltText,up:e=>{e.altText=""},down:e=>{delete e.altText}},{id:tG.AddAutoplay,up:e=>{e.autoplay=!0},down:e=>{delete e.autoplay}}]},tX=(0,d.bo)("com.tldraw.store",{RemoveCodeAndIconShapeTypes:1,AddInstancePresenceType:2,RemoveTLUserAndPresenceAndAddPointer:3,RemoveUserDocument:4,FixIndexKeys:5}),tJ=(0,d._B)({sequenceId:"com.tldraw.store",retroactive:!1,sequence:[{id:tX.RemoveCodeAndIconShapeTypes,scope:"storage",up:e=>{for(let[t,n]of e.entries())"shape"===n.typeName&&"type"in n&&("icon"===n.type||"code"===n.type)&&e.delete(t)}},{id:tX.AddInstancePresenceType,scope:"storage",up(e){}},{id:tX.RemoveTLUserAndPresenceAndAddPointer,scope:"storage",up:e=>{for(let[t,n]of e.entries())n.typeName.match(/^(user|user_presence)$/)&&e.delete(t)}},{id:tX.RemoveUserDocument,scope:"storage",up:e=>{for(let[t,n]of e.entries())n.typeName.match("user_document")&&e.delete(t)}},{id:tX.FixIndexKeys,scope:"record",up:e=>{if(["shape","page"].includes(e.typeName)&&"index"in e&&(e.index.endsWith("0")&&"a0"!==e.index&&(e.index=e.index.slice(0,-1)+t0(3)),"shape"===e.typeName&&"line"===e.type))for(let[t,n]of(0,i.iA)(e.props.points))n.index.endsWith("0")&&"a0"!==n.index&&(n.index=n.index.slice(0,-1)+t0(3))},down:()=>{}}]}),tZ="123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",tQ=()=>tZ.charAt(Math.floor(Math.random()*tZ.length)),t0=e=>Array.from({length:e},tQ).join("");function t1(e){"asset"===e.typeName&&("src"in e&&(e.src="<redacted>"),"src"in e.props&&(e.props.src="<redacted>"))}function t2(e){let t=new Map;return n=>{let r=t.get(n);return r||(r=(0,ed.EW)("resolve-user-"+n,()=>e(n)),t.set(n,r)),r}}function t3({error:e,phase:t,record:n,recordBefore:r}){throw(0,i.TF)(e,{tags:{origin:"store.validateRecord",storePhase:t,isExistingValidationIssue:"initialize"===t},extras:{recordBefore:r?t1((0,i.pN)(r)):void 0,recordAfter:t1((0,i.pN)(n))}}),e}function t5(e){let t=e.query.ids("page"),n=e.query.records("instance_page_state"),r=()=>{if(!e.has(e5))return e.put([e3.create({id:e5,name:e.props.defaultName})]),r();if(!e.has(eV))return e.put([eK.create({id:eV})]),r();let o=t.get();if(0===o.size)return e.put([eP.create({id:"page:page",name:"Page 1",index:"a1",meta:{}})]),r();let s=()=>[...o].map(t=>e.get(t)).sort(i.Ky)[0].id,a=e.get(eR);if(!a)return e.put([e.schema.types.instance.create({id:eR,currentPageId:s(),exportBackground:!0})]),r();if(!o.has(a.currentPageId))return e.put([{...a,currentPageId:s()}]),r();let l=new Set,d=new Set;for(let t of o){let n=eB.createId(t);e.get(n)||l.add(n);let r=ep.createId(t);e.has(r)||d.add(r)}for(let t of(l.size>0&&e.put([...l].map(e=>eB.create({id:e,pageId:eB.parseId(e)}))),d.size>0&&e.put([...d].map(e=>ep.create({id:e}))),n.get())){if(!o.has(t.pageId)){e.remove([t.id]);continue}if(t.croppingShapeId&&!e.has(t.croppingShapeId))return e.put([{...t,croppingShapeId:null}]),r();if(t.focusedGroupId&&!e.has(t.focusedGroupId))return e.put([{...t,focusedGroupId:null}]),r();if(t.hoveredShapeId&&!e.has(t.hoveredShapeId))return e.put([{...t,hoveredShapeId:null}]),r();let n=t.selectedShapeIds.filter(t=>e.has(t));if(n.length!==t.selectedShapeIds.length)return e.put([{...t,selectedShapeIds:n}]),r();let i=t.hintingShapeIds.filter(t=>e.has(t));if(i.length!==t.hintingShapeIds.length)return e.put([{...t,hintingShapeIds:i}]),r();let s=t.erasingShapeIds.filter(t=>e.has(t));if(s.length!==t.erasingShapeIds.length)return e.put([{...t,erasingShapeIds:s}]),r()}};return r}let t6={arrow:{migrations:ei,props:et},bookmark:{migrations:e8,props:e6},draw:{migrations:th,props:tc},embed:{migrations:ty,props:tg},frame:{migrations:tx,props:tb},geo:{migrations:tP,props:tC},group:{migrations:tE,props:tT},highlight:{migrations:tM,props:tI},image:{migrations:tD,props:tj},line:{migrations:tN,props:tR},note:{migrations:tH,props:t$},text:{migrations:tV,props:tW},video:{migrations:tq,props:tY}},t4={arrow:{migrations:el,props:es}},t8={image:{migrations:g,props:p},video:{migrations:b,props:m},bookmark:{migrations:h,props:c}};function t9({shapes:e=t6,bindings:t=t4,assets:n=t8,user:r,records:a={},migrations:c}={}){let u=new Map;for(let t of(0,i.Ic)(e))for(let e of F(t.props??{}).keys()){if(u.has(e.id)&&u.get(e.id)!==e)throw Error(`Multiple StyleProp instances with the same id: ${e.id}`);u.set(e.id,e)}let h=(0,d.WE)("shape",{scope:"document",validator:o.T.model("shape",o.T.union("type",(0,i._H)(e,(e,{props:t,meta:n})=>o.T.object({id:C,typeName:o.T.literal("shape"),x:o.T.number,y:o.T.number,rotation:o.T.number,index:o.T.indexKey,parentId:S,type:o.T.literal(e),isLocked:o.T.boolean,opacity:v,props:t?o.T.object(t):o.T.jsonValue,meta:n?o.T.object(n):o.T.jsonValue}))))}).withDefaultProperties(()=>({x:0,y:0,rotation:0,isLocked:!1,opacity:1,meta:{}})),p=(0,d.WE)("binding",{scope:"document",validator:o.T.model("binding",o.T.union("type",(0,i._H)(t,(e,{props:t,meta:n})=>o.T.object({id:k,typeName:o.T.literal("binding"),type:o.T.literal(e),fromId:C,toId:C,props:t?o.T.object(t):o.T.jsonValue,meta:n?o.T.object(n):o.T.jsonValue}))))}).withDefaultProperties(()=>({meta:{}})),f=(0,d.WE)("asset",{scope:"document",validator:o.T.model("asset",o.T.union("type",(0,i._H)(n,(e,{props:t,meta:n})=>l(e,t,n))))}).withDefaultProperties(()=>({meta:{}})),g=function(e){let t={};for(let[n,r]of e)t[n]=o.T.optional(r);let n=o.T.model("instance",o.T.object({typeName:o.T.literal("instance"),id:s("instance"),currentPageId:ev,followingUserId:eE.nullable(),brush:w.nullable(),opacityForNextShape:v,stylesForNextShape:o.T.object(t),cursor:em,scribbles:o.T.arrayOf(ew),isFocusMode:o.T.boolean,isDebugMode:o.T.boolean,isToolLocked:o.T.boolean,exportBackground:o.T.boolean,screenBounds:w,insets:o.T.arrayOf(o.T.boolean),zoomBrush:w.nullable(),isPenMode:o.T.boolean,isGridMode:o.T.boolean,chatMessage:o.T.string,isChatting:o.T.boolean,highlightedUserIds:o.T.arrayOf(eE),isFocused:o.T.boolean,devicePixelRatio:o.T.number,isCoarsePointer:o.T.boolean,isHoveringCanvas:o.T.boolean.nullable(),openMenus:o.T.arrayOf(o.T.string),isChangingStyle:o.T.boolean,isReadonly:o.T.boolean,meta:o.T.jsonValue,duplicateProps:o.T.object({shapeIds:o.T.arrayOf(s("shape")),offset:o.T.object({x:o.T.number,y:o.T.number})}).nullable(),cameraState:o.T.literalEnum("idle","moving")}));return(0,d.WE)("instance",{validator:n,scope:"session",ephemeralKeys:{currentPageId:!1,meta:!1,followingUserId:!0,opacityForNextShape:!0,stylesForNextShape:!0,brush:!0,cursor:!0,scribbles:!0,isFocusMode:!0,isDebugMode:!0,isToolLocked:!0,exportBackground:!0,screenBounds:!0,insets:!0,zoomBrush:!0,isPenMode:!0,isGridMode:!0,chatMessage:!0,isChatting:!0,highlightedUserIds:!0,isFocused:!0,devicePixelRatio:!0,isCoarsePointer:!0,isHoveringCanvas:!0,openMenus:!0,isChangingStyle:!0,isReadonly:!0,duplicateProps:!0,cameraState:!0}}).withDefaultProperties(()=>({followingUserId:null,opacityForNextShape:1,stylesForNextShape:{},brush:null,scribbles:[],cursor:{type:"default",rotation:0},isFocusMode:!1,exportBackground:!1,isDebugMode:!1,isToolLocked:!1,screenBounds:{x:0,y:0,w:1080,h:720},insets:[!1,!1,!1,!1],zoomBrush:null,isGridMode:!1,isPenMode:!1,chatMessage:"",isChatting:!1,highlightedUserIds:[],isFocused:!1,devicePixelRatio:"u"<typeof window?1:window.devicePixelRatio,isCoarsePointer:!1,isHoveringCanvas:null,openMenus:[],isChangingStyle:!1,isReadonly:!1,meta:{},duplicateProps:null,cameraState:"idle"}))}(u),m=r?eM(r):eA,y=new Set(["asset","binding","camera","document","instance","instance_page_state","page","instance_presence","pointer","shape","store","user"]),b={};for(let[e,t]of Object.entries(a)){if(y.has(e))throw Error(`Custom record type name '${e}' conflicts with tldraw's built-in record type of that name. Choose a different name instead.`);b[e]=(0,d.WE)(e,{scope:t.scope,validator:t.validator}).withDefaultProperties(t.createDefaultProperties??(()=>({})))}return d.fX.create({asset:f,binding:p,camera:ep,document:e3,instance:g,instance_page_state:eB,page:eP,instance_presence:eX,pointer:eK,shape:h,user:m,...b},{migrations:[tJ,eZ,eh,e2,eF,e$,ek,eq,eW,j,e_,...z("asset",n),...z("shape",e),...z("binding",t),...function(e){let t=[];for(let[n,r]of Object.entries(e)){let e=`com.tldraw.${n}`,{migrations:o}=r;o?"sequenceId"in o?((0,i.vA)(e===o.sequenceId,`sequenceId mismatch for ${n} custom record migrations. Expected '${e}', got '${o.sequenceId}'`),t.push(o)):"sequence"in o&&t.push((0,d._B)({sequenceId:e,retroactive:!0,sequence:o.sequence.map(e=>"id"in e?{id:e.id,dependsOn:e.dependsOn,scope:"record",filter:e=>e.typeName===n,up:t=>{let n=e.up(t);if(n)return n},down:"function"==typeof e.down?t=>{let n=e.down(t);if(n)return n}:void 0}:e)})):t.push((0,d._B)({sequenceId:e,retroactive:!0,sequence:[]}))}return t}(a),...r?.migrations??[],...c??[]],onValidationFailure:t3,createIntegrityChecker:t5})}let t7=o.T.string.check(e=>{if(0===e.length||e.length>64)throw new o.T.ValidationError(`Expected an emoji of 1-64 characters, got ${e.length}`)}),ne=o.T.union("type",{shape:o.T.object({type:o.T.literal("shape"),shapeId:s("shape"),x:o.T.number,y:o.T.number,isPrecise:o.T.boolean}),point:o.T.object({type:o.T.literal("point"),x:o.T.number,y:o.T.number}),region:o.T.object({type:o.T.literal("region"),x:o.T.number,y:o.T.number,w:o.T.number,h:o.T.number,pinX:o.T.number.optional(),pinY:o.T.number.optional()}),page:o.T.object({type:o.T.literal("page")})});function nt(e,t=[]){return(0,d.XD)({sequenceId:`com.tldraw.${e}`,recordType:e,retroactive:!0,sequence:[{id:`com.tldraw.${e}/1`,up:e=>e},...t]})}nt("comment-thread",[{id:"com.tldraw.comment-thread/2",up:e=>{let t=e.anchor;return t?.type==="shape"&&void 0===t.x&&(e.anchor={...t,x:1,y:0,isPrecise:!1}),e},down:e=>{let t=e.anchor;return t?.type==="shape"&&(e.anchor={type:"shape",shapeId:t.shapeId}),e}},{id:"com.tldraw.comment-thread/3",up:e=>e,down:e=>{let t=e.anchor;if(t?.type==="region"){let{pinX:n,pinY:r,...i}=t;e.anchor=i}return e}}]),o.T.object({id:s("comment-thread"),typeName:o.T.literal("comment-thread"),pageId:s("page"),anchor:ne,createdBy:o.T.string,createdAt:o.T.number,resolved:o.T.object({at:o.T.number,by:o.T.string}).nullable(),isDeleted:o.T.boolean,meta:o.T.jsonValue}),nt("comment"),o.T.object({id:s("comment"),typeName:o.T.literal("comment"),threadId:s("comment-thread"),pageId:s("page"),authorId:o.T.string,createdAt:o.T.number,editedAt:o.T.number.nullable(),body:E,isDeleted:o.T.boolean,meta:o.T.jsonValue}),nt("comment-reaction"),o.T.object({id:s("comment-reaction"),typeName:o.T.literal("comment-reaction"),commentId:s("comment"),threadId:s("comment-thread"),pageId:s("page"),userId:o.T.string,emoji:t7,createdAt:o.T.number,meta:o.T.jsonValue});let nn=[{locale:"id",label:"Bahasa Indonesia"},{locale:"ms",label:"Bahasa Melayu"},{locale:"ca",label:"Catal\xe0"},{locale:"cs",label:"Čeština"},{locale:"da",label:"Danish"},{locale:"de",label:"Deutsch"},{locale:"en",label:"English"},{locale:"es",label:"Espa\xf1ol"},{locale:"tl",label:"Filipino"},{locale:"fr",label:"Fran\xe7ais"},{locale:"gl",label:"Galego"},{locale:"hr",label:"Hrvatski"},{locale:"it",label:"Italiano"},{locale:"hu",label:"Magyar"},{locale:"nl",label:"Nederlands"},{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ă"},{locale:"sl",label:"Slovenščina"},{locale:"so",label:"Somali"},{locale:"fi",label:"Suomi"},{locale:"sv",label:"Svenska"},{locale:"vi",label:"Tiếng Việt"},{locale:"tr",label:"T\xfcrk\xe7e"},{locale:"el",label:"Ελληνικά"},{locale:"ru",label:"Русский"},{locale:"uk",label:"Українська"},{locale:"he",label:"עברית"},{locale:"ur",label:"اردو"},{locale:"ar",label:"عربي"},{locale:"fa",label:"فارسی"},{locale:"ne",label:"नेपाली"},{locale:"mr",label:"मराठी"},{locale:"hi-in",label:"हिन्दी"},{locale:"bn",label:"বাংলা"},{locale:"pa",label:"ਪੰਜਾਬੀ"},{locale:"gu-in",label:"ગુજરાતી"},{locale:"ta",label:"தமிழ்"},{locale:"te",label:"తెలుగు"},{locale:"kn",label:"ಕನ್ನಡ"},{locale:"ml",label:"മലയാളം"},{locale:"th",label:"ภาษาไทย"},{locale:"km-kh",label:"ភាសាខ្មែរ"},{locale:"ko-kr",label:"한국어"},{locale:"ja",label:"日本語"},{locale:"zh-cn",label:"简体中文"},{locale:"zh-tw",label:"繁體中文 (台灣)"}];function nr(){var e="u">typeof window&&window.navigator?window.navigator.languages??["en"]:["en"];for(let t of e){let e=function(e){let t=nn.find(t=>t.locale===e.toLowerCase());if(t)return t.locale;let[n,r]=e.split(/[-_]/).map(e=>e.toLowerCase());if(r){let e=nn.find(e=>e.locale===n);if(e)return e.locale}return n in ni?ni[n]:null}(t);if(e)return e}return"en"}let ni={zh:"zh-cn",pt:"pt-br",ko:"ko-kr",hi:"hi-in"};(0,i.lF)("@tldraw/tlschema","5.3.2","esm")},81962:(e,t,n)=>{"use strict";n.d(t,{B8:()=>g,HV:()=>p,NC:()=>a,Op:()=>d,Rx:()=>y,SU:()=>c,j0:()=>b,lq:()=>l,oQ:()=>f,vr:()=>s,y5:()=>u});var r=n(93286),i=n(46195);function o(e,t,n,r,s=1e-10){let a=e.x-n.x,l=e.y-n.y,d=r.x-n.x,c=r.y-n.y,u=t.x-e.x,h=t.y-e.y,p=d*l-c*a,f=u*l-h*a,g=c*u-d*h;if(Math.abs(p)<=s||Math.abs(f)<=s||Math.abs(g)<=s)return null;let m=p/g,y=f/g;return m>=-s&&m<=1+s&&y>=-s&&y<=1+s?new i.l(e.x+m*u,e.y+m*h):null}function s(e,t,n,r){let o=t.x-e.x,s=t.y-e.y,a=e.x-n.x,l=e.y-n.y,d=o*o+s*s,c=2*(o*a+s*l),u=c*c-4*d*(a*a+l*l-r*r);if(u<=0)return null;let h=Math.sqrt(u),p=(-c+h)/(2*d),f=(-c-h)/(2*d);if((p<0||p>1)&&(f<0||f>1))return null;let g=[];return(p>=0&&p<=1&&g.push(new i.l(e.x+o*p,e.y+s*p)),f>=0&&f<=1&&g.push(new i.l(e.x+o*f,e.y+s*f)),0===g.length)?null:g}function a(e,t,n){let r,i=[];for(let s=0,a=n.length-1;s<a;s++)(r=o(e,t,n[s],n[s+1]))&&i.push(r);return 0===i.length?null:i}function l(e,t,n){let r,i=[];for(let s=1,a=n.length;s<a+1;s++)(r=o(e,t,n[s-1],n[s%n.length]))&&i.push(r);return 0===i.length?null:i}function d(e,t,n,r){let o=n.x-e.x,s=n.y-e.y,a=Math.sqrt(o*o+s*s),l=(a*a-r*r+t*t)/(2*a),d=Math.sqrt(t*t-l*l);return o/=a,s/=a,[new i.l(e.x+o*l-s*d,e.y+s*l+o*d),new i.l(e.x+o*l+s*d,e.y+s*l-o*d)]}function c(e,t,n){let r,i=[];for(let o=0,a=n.length;o<a;o++)(r=s(n[o],n[(o+1)%n.length],e,t))&&i.push(...r);return 0===i.length?null:i}function u(e,t,n){let r,i=[];for(let o=1,a=n.length;o<a;o++)(r=s(n[o-1],n[o],e,t))&&i.push(...r);return 0===i.length?null:i}function h(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}function p(e,t,n,r){return h(e,n,r)!==h(t,n,r)&&h(e,t,n)!==h(e,t,r)}function f(e,t){var n;let s,a,l,d=new Map;for(let n=0,i=e.length;n<i;n++)if(a=e[n],(0,r.s3)(a,t)){let e=m(a);d.has(e)||d.set(e,a)}for(let n=0,i=t.length;n<i;n++)if(a=t[n],(0,r.s3)(a,e)){let e=m(a);d.has(e)||d.set(e,a)}for(let n=0,r=e.length;n<r;n++){a=e[n],l=e[(n+1)%e.length];for(let e=0,n=t.length;e<n;e++){let n=o(a,l,t[e],t[(e+1)%t.length]);if(null!==n){let e=m(n);d.has(e)||d.set(e,n)}}}return 0===d.size?null:(n=[...d.values()],s=i.l.Average(n),n.sort((e,t)=>i.l.Angle(s,e)-i.l.Angle(s,t)))}function g(e,t,n,r){let i=new Map;for(let s=0,a=n?e.length:e.length-1;s<a;s++){let n=e[s],a=e[(s+1)%e.length];for(let e=0,s=r?t.length:t.length-1;e<s;e++){let r=o(n,a,t[e],t[(e+1)%t.length]);if(null!==r){let e=m(r);i.has(e)||i.set(e,r)}}}return[...i.values()]}function m(e){return`${e.x},${e.y}`}function y(e,t){let n,r;for(let i=0,o=e.length;i<o;i++){n=e[i],r=e[(i+1)%o];for(let e=0,i=t.length;e<i;e++)if(p(n,r,t[e],t[(e+1)%i]))return!0}return!1}function b(e,t){let n,r;for(let i=0,o=e.length;i<o;i++){n=e[i],r=e[(i+1)%o];for(let e=1,i=t.length;e<i;e++)if(p(n,r,t[e-1],t[e]))return!0}return!1}},82246:function(e){e.exports=function(){"use strict";function e(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function t(e,t){return e<t?-1:+(e>t)}var n=function(e){void 0===e&&(e=9),this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function r(e,t){i(e,0,e.children.length,t,e)}function i(e,t,n,r,i){i||(i=h(null)),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(var s=t;s<n;s++){var a=e.children[s];o(i,e.leaf?r(a):a)}return i}function o(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function s(e,t){return e.minX-t.minX}function a(e,t){return e.minY-t.minY}function l(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function d(e){return e.maxX-e.minX+(e.maxY-e.minY)}function c(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function u(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function h(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function p(n,r,i,o,s){for(var a=[r,i];a.length;)if(!((i=a.pop())-(r=a.pop())<=o)){var l=r+Math.ceil((i-r)/o/2)*o;(function t(n,r,i,o,s){for(;o>i;){if(o-i>600){var a=o-i+1,l=r-i+1,d=Math.log(a),c=.5*Math.exp(2*d/3),u=.5*Math.sqrt(d*c*(a-c)/a)*(l-a/2<0?-1:1),h=Math.max(i,Math.floor(r-l*c/a+u)),p=Math.min(o,Math.floor(r+(a-l)*c/a+u));t(n,r,h,p,s)}var f=n[r],g=i,m=o;for(e(n,i,r),s(n[o],f)>0&&e(n,i,o);g<m;){for(e(n,g,m),g++,m--;0>s(n[g],f);)g++;for(;s(n[m],f)>0;)m--}0===s(n[i],f)?e(n,i,m):e(n,++m,o),m<=r&&(i=m+1),r<=m&&(o=m-1)}})(n,l,r||0,i||n.length-1,s||t),a.push(r,l,l,i)}}return n.prototype.all=function(){return this._all(this.data,[])},n.prototype.search=function(e){var t=this.data,n=[];if(!u(e,t))return n;for(var r=this.toBBox,i=[];t;){for(var o=0;o<t.children.length;o++){var s=t.children[o],a=t.leaf?r(s):s;u(e,a)&&(t.leaf?n.push(s):c(e,a)?this._all(s,n):i.push(s))}t=i.pop()}return n},n.prototype.collides=function(e){var t=this.data;if(!u(e,t))return!1;for(var n=[];t;){for(var r=0;r<t.children.length;r++){var i=t.children[r],o=t.leaf?this.toBBox(i):i;if(u(e,o)){if(t.leaf||c(e,o))return!0;n.push(i)}}t=n.pop()}return!1},n.prototype.load=function(e){if(!e||!e.length)return this;if(e.length<this._minEntries){for(var t=0;t<e.length;t++)this.insert(e[t]);return this}var n=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){var r=this.data;this.data=n,n=r}this._insert(n,this.data.height-n.height-1,!0)}else this.data=n;return this},n.prototype.insert=function(e){return e&&this._insert(e,this.data.height-1),this},n.prototype.clear=function(){return this.data=h([]),this},n.prototype.remove=function(e,t){if(!e)return this;for(var n,r,i,o=this.data,s=this.toBBox(e),a=[],l=[];o||a.length;){if(o||(o=a.pop(),r=a[a.length-1],n=l.pop(),i=!0),o.leaf){var d=function(e,t,n){if(!n)return t.indexOf(e);for(var r=0;r<t.length;r++)if(n(e,t[r]))return r;return -1}(e,o.children,t);if(-1!==d)return o.children.splice(d,1),a.push(o),this._condense(a),this}i||o.leaf||!c(o,s)?r?(n++,o=r.children[n],i=!1):o=null:(a.push(o),l.push(n),n=0,r=o,o=o.children[0])}return this},n.prototype.toBBox=function(e){return e},n.prototype.compareMinX=function(e,t){return e.minX-t.minX},n.prototype.compareMinY=function(e,t){return e.minY-t.minY},n.prototype.toJSON=function(){return this.data},n.prototype.fromJSON=function(e){return this.data=e,this},n.prototype._all=function(e,t){for(var n=[];e;)e.leaf?t.push.apply(t,e.children):n.push.apply(n,e.children),e=n.pop();return t},n.prototype._build=function(e,t,n,i){var o,s=n-t+1,a=this._maxEntries;if(s<=a)return r(o=h(e.slice(t,n+1)),this.toBBox),o;i||(i=Math.ceil(Math.log(s)/Math.log(a)),a=Math.ceil(s/Math.pow(a,i-1))),(o=h([])).leaf=!1,o.height=i;var l=Math.ceil(s/a),d=l*Math.ceil(Math.sqrt(a));p(e,t,n,d,this.compareMinX);for(var c=t;c<=n;c+=d){var u=Math.min(c+d-1,n);p(e,c,u,l,this.compareMinY);for(var f=c;f<=u;f+=l){var g=Math.min(f+l-1,u);o.children.push(this._build(e,f,g,i-1))}}return r(o,this.toBBox),o},n.prototype._chooseSubtree=function(e,t,n,r){for(;r.push(t),!t.leaf&&r.length-1!==n;){for(var i=1/0,o=1/0,s=void 0,a=0;a<t.children.length;a++){var d=t.children[a],c=l(d),u=(Math.max(d.maxX,e.maxX)-Math.min(d.minX,e.minX))*(Math.max(d.maxY,e.maxY)-Math.min(d.minY,e.minY))-c;u<o?(o=u,i=c<i?c:i,s=d):u===o&&c<i&&(i=c,s=d)}t=s||t.children[0]}return t},n.prototype._insert=function(e,t,n){var r=n?e:this.toBBox(e),i=[],s=this._chooseSubtree(r,this.data,t,i);for(s.children.push(e),o(s,r);t>=0&&i[t].children.length>this._maxEntries;)this._split(i,t),t--;this._adjustParentBBoxes(r,i,t)},n.prototype._split=function(e,t){var n=e[t],i=n.children.length,o=this._minEntries;this._chooseSplitAxis(n,o,i);var s=this._chooseSplitIndex(n,o,i),a=h(n.children.splice(s,n.children.length-s));a.height=n.height,a.leaf=n.leaf,r(n,this.toBBox),r(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(n,a)},n.prototype._splitRoot=function(e,t){this.data=h([e,t]),this.data.height=e.height+1,this.data.leaf=!1,r(this.data,this.toBBox)},n.prototype._chooseSplitIndex=function(e,t,n){for(var r,o,s,a,d,c=1/0,u=1/0,h=t;h<=n-t;h++){var p=i(e,0,h,this.toBBox),f=i(e,h,n,this.toBBox),g=(o=void 0,s=void 0,a=void 0,o=Math.max(p.minX,f.minX),s=Math.max(p.minY,f.minY),Math.max(0,(a=Math.min(p.maxX,f.maxX))-o)*Math.max(0,Math.min(p.maxY,f.maxY)-s)),m=l(p)+l(f);g<c?(c=g,r=h,u=m<u?m:u):g===c&&m<u&&(u=m,r=h)}return r||n-t},n.prototype._chooseSplitAxis=function(e,t,n){var r=e.leaf?this.compareMinX:s,i=e.leaf?this.compareMinY:a;this._allDistMargin(e,t,n,r)<this._allDistMargin(e,t,n,i)&&e.children.sort(r)},n.prototype._allDistMargin=function(e,t,n,r){e.children.sort(r);for(var s=this.toBBox,a=i(e,0,t,s),l=i(e,n-t,n,s),c=d(a)+d(l),u=t;u<n-t;u++){var h=e.children[u];o(a,e.leaf?s(h):h),c+=d(a)}for(var p=n-t-1;p>=t;p--){var f=e.children[p];o(l,e.leaf?s(f):f),c+=d(l)}return c},n.prototype._adjustParentBBoxes=function(e,t,n){for(var r=n;r>=0;r--)o(t[r],e)},n.prototype._condense=function(e){for(var t=e.length-1,n=void 0;t>=0;t--)0===e[t].children.length?t>0?(n=e[t-1].children).splice(n.indexOf(e[t]),1):this.clear():r(e[t],this.toBBox)},n}()},83102:(e,t,n)=>{"use strict";let r;n.d(t,{Ml:()=>u,VM:()=>U,c2:()=>w,UP:()=>O,eU:()=>A,EW:()=>B,_O:()=>D,wv:()=>W,Px:()=>K,hL:()=>I,Pm:()=>m,_D:()=>F});var i=n(24167);function o(e){return e&&"object"==typeof e&&"parents"in e}function s(e){for(let t=0,n=e.parents.length;t<n;t++)if(e.parents[t].__unsafe__getWithoutCapture(!0),e.parents[t].lastChangedEpoch!==e.parentEpochs[t])return!0;return!1}function a(e,t){if(e.children.remove(t)&&e.children.isEmpty&&o(e))for(let t=0,n=e.parents.length;t<n;t++)a(e.parents[t],e)}function l(e,t){if(e.children.add(t)&&o(e))for(let t=0,n=e.parents.length;t<n;t++)l(e.parents[t],e)}function d(e,t){return e===t||Object.is(e,t)||!!(e&&t&&"function"==typeof e.equals&&e.equals(t))}function c(e,t){let n=Symbol.for(`com.tldraw.state/${e}`),r=globalThis;return r[n]??=t(),r[n]}let u=c("empty_array",()=>Object.freeze([]));class h{arraySize=0;array=Array(8);set=null;get isEmpty(){if(this.array)return 0===this.arraySize;if(this.set)return 0===this.set.size;throw Error("no set or array")}add(e){if(this.array)return -1===this.array.indexOf(e)&&(this.arraySize<8?(this.array[this.arraySize]=e,this.arraySize++):(this.set=new Set(this.array),this.array=null,this.set.add(e)),!0);if(this.set)return!this.set.has(e)&&(this.set.add(e),!0);throw Error("no set or array")}remove(e){if(this.array){let t=this.array.indexOf(e);return -1!==t&&(this.array[t]=void 0,this.arraySize--,t!==this.arraySize&&(this.array[t]=this.array[this.arraySize],this.array[this.arraySize]=void 0),!0)}if(this.set)return!!this.set.has(e)&&(this.set.delete(e),!0);throw Error("no set or array")}visit(e){if(this.array){for(let t=0;t<this.arraySize;t++){let n=this.array[t];void 0!==n&&e(n)}return}if(this.set)return void this.set.forEach(e);throw Error("no set or array")}*[Symbol.iterator](){if(this.array)for(let e=0;e<this.arraySize;e++){let t=this.array[e];void 0!==t&&(yield t)}else if(this.set)yield*this.set;else throw Error("no set or array")}has(e){return this.array?-1!==this.array.indexOf(e):this.set.has(e)}clear(){this.set?this.set.clear():(this.arraySize=0,this.array=[])}size(){return this.set?this.set.size:this.arraySize}}function p(e){return!!(e&&!0===e.__isComputed)}class f{constructor(e,t){this.below=e,this.child=t}below;child;offset=0;maybeRemoved}let g=c("capture",()=>({stack:null}));function m(e){let t=g.stack;g.stack=null;try{return e()}finally{g.stack=t}}function y(e){if(g.stack=new f(g.stack,e),e.__debug_ancestor_epochs__){let t=e.__debug_ancestor_epochs__;for(let t of(e.__debug_ancestor_epochs__=null,e.parents))t.__unsafe__getWithoutCapture(!0);!function(e,t){let n=function e(t,n){let r={};for(let i=0;i<t.parents.length;i++){let o=t.parents[i];if(!n.has(o))continue;let s=n.get(o);o.lastChangedEpoch!==s&&(p(o)?r[o.name]=e(o,n):r[o.name]=null)}return r}(e,t);if(0===Object.keys(n).length)return console.log(`Effect(${e.name}) was executed manually.`);let r=p(e)?`Computed(${e.name}) is recomputing because:`:`Effect(${e.name}) is executing because:`;!function e(t,n){let i="\n"+" ".repeat(n)+"↳ ";for(let[o,s]of Object.entries(t))s?(r+=`${i}Computed(${o}) changed`,e(s,n+2)):r+=`${i}Atom(${o}) changed`}(n,1),console.log(r)}(e,t)}e.parentSet.clear()}function b(){let e=g.stack;if(g.stack=e.below,e.offset<e.child.parents.length){for(let t=e.offset;t<e.child.parents.length;t++){let n=e.child.parents[t];e.child.parentSet.has(n)||a(n,e.child)}e.child.parents.length=e.offset,e.child.parentEpochs.length=e.offset}if(e.maybeRemoved)for(let t=0;t<e.maybeRemoved.length;t++){let n=e.maybeRemoved[t];e.child.parentSet.has(n)||a(n,e.child)}e.child.__debug_ancestor_epochs__&&function e(t,n){for(let r=0;r<t.parents.length;r++){let i=t.parents[r],o=t.parentEpochs[r];n.set(i,o),p(i)&&e(i,n)}return n}(e.child,e.child.__debug_ancestor_epochs__)}function x(e){if(g.stack&&!g.stack.child.parentSet.has(e)){if(g.stack.child.parentSet.add(e),g.stack.child.isActivelyListening&&l(e,g.stack.child),g.stack.offset<g.stack.child.parents.length){let t=g.stack.child.parents[g.stack.offset];t!==e&&(g.stack.maybeRemoved?g.stack.maybeRemoved.push(t):g.stack.maybeRemoved=[t])}g.stack.child.parents[g.stack.offset]=e,g.stack.child.parentEpochs[g.stack.offset]=e.lastChangedEpoch,g.stack.offset++}}let w=Symbol.for("com.tldraw.state/RESET_VALUE");class v{constructor(e){this.capacity=e,this.buffer=Array(e)}capacity;index=0;buffer;pushEntry(e,t,n){if(void 0!==n){if(n===w)return void this.clear();this.buffer[this.index]=[e,t,n],this.index=(this.index+1)%this.capacity}}clear(){this.index=0,this.buffer.fill(void 0)}getChangesSince(e){let{index:t,capacity:n,buffer:r}=this;for(let i=0;i<n;i++){let o=(t-1+n-i)%n,s=r[o];if(!s)break;let[a,l]=s;if(0===i&&e>=l)return[];if(a<=e&&e<l){let e=i+1,t=Array(e);for(let i=0;i<e;i++)t[i]=r[(o+i)%n][2];return t}}return w}}class S{constructor(e,t){this.parent=e,this.isSync=t}parent;isSync;asyncProcessCount=0;initialAtomValues=new Map;get isRoot(){return null===this.parent}commit(){if(C.globalIsReacting)for(let e of this.initialAtomValues.keys())E(e);else this.isRoot?T(this.initialAtomValues.keys()):this.initialAtomValues.forEach((e,t)=>{this.parent.initialAtomValues.has(t)||this.parent.initialAtomValues.set(t,e)})}abort(){C.globalEpoch++,this.initialAtomValues.forEach((e,t)=>{t.set(e),t.historyBuffer?.clear()}),this.commit()}}let C=c("transactions",()=>({globalEpoch:0,globalIsReacting:!1,currentTransaction:null,cleanupReactors:null,reactionEpoch:0}));function k(){return C.globalEpoch}function P(e,t){r=e,function e(t){t.lastTraversedEpoch!==C.globalEpoch&&(t.lastTraversedEpoch=C.globalEpoch,"__isEffectScheduler"in t?r.add(t):t.children.visit(e))}(t)}function T(e){if(C.globalIsReacting)throw Error("flushChanges cannot be called during a reaction");let t=C.currentTransaction;try{C.currentTransaction=null,C.globalIsReacting=!0,C.reactionEpoch=C.globalEpoch;let t=new Set;for(let n of e)n.children.visit(e=>P(t,e));for(let e of t)e.maybeScheduleEffect();let n=0;for(;C.cleanupReactors?.size;){if(n++>1e3)throw Error("Reaction update depth limit exceeded");let e=C.cleanupReactors;for(let t of(C.cleanupReactors=null,e))t.maybeScheduleEffect()}}finally{C.cleanupReactors=null,C.globalIsReacting=!1,C.currentTransaction=t,r=void 0}}function E(e){let t=C.cleanupReactors??=new Set;e.children.visit(e=>P(t,e))}function I(e){if(C.currentTransaction)return e();let t=new S(C.currentTransaction,!0);C.currentTransaction=t;try{let n,r=!1;try{n=e(()=>r=!0)}catch(e){throw t.abort(),e}if(C.currentTransaction!==t)throw Error("Transaction boundaries overlap");return r?t.abort():t.commit(),n}finally{C.currentTransaction=t.parent}}class _{constructor(e,t,n){if(this.name=e,this.current=t,this.isEqual=n?.isEqual??null,!n)return;n.historyLength&&(this.historyBuffer=new v(n.historyLength)),this.computeDiff=n.computeDiff}name;current;isEqual;computeDiff;lastChangedEpoch=k();children=new h;historyBuffer;__unsafe__getWithoutCapture(e){return this.current}get(){return x(this),this.current}set(e,t){if(this.isEqual?.(this.current,e)??d(this.current,e))return this.current;C.globalEpoch++,this.historyBuffer&&this.historyBuffer.pushEntry(this.lastChangedEpoch,k(),t??this.computeDiff?.(this.current,e,this.lastChangedEpoch,k())??w),this.lastChangedEpoch=k();let n=this.current;return this.current=e,C.currentTransaction?C.currentTransaction.initialAtomValues.has(this)||C.currentTransaction.initialAtomValues.set(this,n):C.globalIsReacting?E(this):T([this]),e}update(e){return this.set(e(this.current))}getDiffSince(e){return(x(this),e>=this.lastChangedEpoch)?u:this.historyBuffer?.getChangesSince(e)??w}}let M=c("Atom",()=>_);function A(e,t,n){return new M(e,t,n)}let j=!1,O=Symbol.for("com.tldraw.state/UNINITIALIZED");function D(e){return e===O}let L=c("WithDiff",()=>class{constructor(e,t){this.value=e,this.diff=t}value;diff});function F(e,t){return new L(e,t)}class R{constructor(e,t,n){this.name=e,this.derive=t,n?.historyLength&&(this.historyBuffer=new v(n.historyLength)),this.computeDiff=n?.computeDiff,this.isEqual=n?.isEqual??d}name;derive;__isComputed=!0;lastChangedEpoch=-1;lastTraversedEpoch=-1;__debug_ancestor_epochs__=null;lastCheckedEpoch=-1;parentSet=new h;parents=[];parentEpochs=[];children=new h;get isActivelyListening(){return!this.children.isEmpty}historyBuffer;state=O;error=null;computeDiff;isEqual;__unsafe__getWithoutCapture(e){let t=-1===this.lastChangedEpoch,n=k();if(!t&&(this.lastCheckedEpoch===n||this.isActivelyListening&&C.globalIsReacting&&this.lastTraversedEpoch<C.reactionEpoch||!s(this))){if(this.lastCheckedEpoch=n,!this.error)return this.state;if(e)return this.state;throw this.error.thrownValue}try{y(this);let e=this.derive(this.state,this.lastCheckedEpoch),t=e instanceof L?e.value:e,n=this.state===O;if(n||!this.isEqual(this.state,t)){if(this.historyBuffer&&!n){let n=e instanceof L?e.diff:void 0;this.historyBuffer.pushEntry(this.lastChangedEpoch,k(),n??this.computeDiff?.(this.state,t,this.lastCheckedEpoch,k())??w)}this.lastChangedEpoch=k(),this.state=t}return this.error=null,this.lastCheckedEpoch=k(),this.state}catch(t){if(this.state!==O&&(this.state=O,this.lastChangedEpoch=k()),this.lastCheckedEpoch=k(),this.historyBuffer&&this.historyBuffer.clear(),this.error={thrownValue:t},!e)throw t;return this.state}finally{b()}}get(){try{return this.__unsafe__getWithoutCapture()}finally{x(this)}}getDiffSince(e){return(this.__unsafe__getWithoutCapture(!0),x(this),e>=this.lastChangedEpoch)?u:this.historyBuffer?.getChangesSince(e)??w}}let z=c("Computed",()=>R);function N(e={},t){if(2===t.length){let n,r,[o,s]=t;return(0,i.vA)("method"===s.kind,"@computed can only be used on methods"),n=Symbol.for("__@tldraw/state__computed__"+String(s.name)),(r=function(){let t=this[n];return t||Object.defineProperty(this,n,{enumerable:!1,configurable:!1,writable:!1,value:t=new z(String(s.name),o.bind(this),e)}),t.get()})[$]=!0,r}{let[n,r,i]=t;return i.get?(j||(j=!0,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.
|
|
6
|
+
|
|
7
|
+
// Before
|
|
8
|
+
@computed
|
|
9
|
+
get foo() {
|
|
10
|
+
return 'foo'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// After
|
|
14
|
+
@computed
|
|
15
|
+
getFoo() {
|
|
16
|
+
return 'foo'
|
|
17
|
+
}
|
|
18
|
+
`)),function(e={},t,n){let r=n.get,i=Symbol.for("__@tldraw/state__computed__"+t);return n.get=function(){let n=this[i];return n||Object.defineProperty(this,i,{enumerable:!1,configurable:!1,writable:!1,value:n=new z(t,r.bind(this),e)}),n.get()},n}(e,r,i)):function(e={},t,n){let r=n.value,i=Symbol.for("__@tldraw/state__computed__"+t);return n.value=function(){let n=this[i];return n||Object.defineProperty(this,i,{enumerable:!1,configurable:!1,writable:!1,value:n=new z(t,r.bind(this),e)}),n.get()},n.value[$]=!0,n}(e,r,i)}}let $="@@__isComputedMethod__@@";function B(){if(1==arguments.length){let e=arguments[0];return(...t)=>N(e,t)}return"string"==typeof arguments[0]?new z(arguments[0],arguments[1],arguments[2]):N(void 0,arguments)}class H{constructor(e,t,n){this.name=e,this.runEffect=t,this._scheduleEffect=n?.scheduleEffect}name;runEffect;__isEffectScheduler=!0;_isActivelyListening=!1;get isActivelyListening(){return this._isActivelyListening}lastTraversedEpoch=-1;lastReactedEpoch=-1;_scheduleCount=0;__debug_ancestor_epochs__=null;get scheduleCount(){return this._scheduleCount}parentSet=new h;parentEpochs=[];parents=[];_scheduleEffect;maybeScheduleEffect(){if(this._isActivelyListening&&this.lastReactedEpoch!==k()){if(this.parents.length&&!s(this)){this.lastReactedEpoch=k();return}this.scheduleEffect()}}scheduleEffect(){this._scheduleCount++,this._scheduleEffect?this._scheduleEffect(this.maybeExecute):this.execute()}maybeExecute=()=>{this._isActivelyListening&&this.execute()};attach(){this._isActivelyListening=!0;for(let e=0,t=this.parents.length;e<t;e++)l(this.parents[e],this)}detach(){this._isActivelyListening=!1;for(let e=0,t=this.parents.length;e<t;e++)a(this.parents[e],this)}execute(){try{y(this);let e=k(),t=this.runEffect(this.lastReactedEpoch);return this.lastReactedEpoch=e,t}finally{b()}}}let U=c("EffectScheduler",()=>H);function W(e,t,n){let r=new U(e,t,n);return r.attach(),r.scheduleEffect(),()=>{r.detach()}}function K(e,t,n){let r=new U(e,t,n);return{scheduler:r,start:e=>{let t=e?.force??!1;r.attach(),t?r.scheduleEffect():r.maybeScheduleEffect()},stop:()=>{r.detach()}}}if(1!==c("apiVersion",()=>1))throw Error("You have multiple incompatible versions of @tldraw/state in your app. Please deduplicate the package.");(0,i.lF)("@tldraw/state","5.3.2","esm")},84469:(e,t,n)=>{"use strict";n.d(t,{N:()=>r});let r={menus:(0,n(83102).eU)("open menus",[]),getOpenMenus(e){return e?this.menus.get().filter(t=>t.endsWith("-"+e)):this.menus.get()},addOpenMenu(e,t=""){let n=t?`${e}-${t}`:e,r=new Set(this.menus.get());r.has(n)||(r.add(n),this.menus.set([...r]))},deleteOpenMenu(e,t=""){let n=t?`${e}-${t}`:e,r=new Set(this.menus.get());r.has(n)&&(r.delete(n),this.menus.set([...r]))},clearOpenMenus(e){this.menus.set(e?this.menus.get().filter(t=>!t.endsWith("-"+e)):[])},_hiddenMenus:[],hideOpenMenus(e){if(this._hiddenMenus=[...this.getOpenMenus(e)],0!==this._hiddenMenus.length)for(let t of this._hiddenMenus)this.deleteOpenMenu(t,e)},showOpenMenus(e){if(0!==this._hiddenMenus.length){for(let t of this._hiddenMenus)this.addOpenMenu(t,e);this._hiddenMenus=[]}},isMenuOpen(e,t){return this.getOpenMenus(t).includes(`${e}-${t}`)},hasOpenMenus(e){return this.getOpenMenus(e).length>0},hasAnyOpenMenus(){return this.getOpenMenus().length>0},forContext(e){return{getOpenMenus:()=>this.getOpenMenus(e),addOpenMenu:t=>this.addOpenMenu(t,e),deleteOpenMenu:t=>this.deleteOpenMenu(t,e),clearOpenMenus:()=>this.clearOpenMenus(e),isMenuOpen:t=>this.isMenuOpen(t,e),hasOpenMenus:()=>this.hasOpenMenus(e),hasAnyOpenMenus:()=>this.hasAnyOpenMenus()}}}},87767:(e,t,n)=>{"use strict";n.d(t,{NF:()=>l,ts:()=>a});var r=n(95155),i=n(24167),o=n(12115);let s=(0,o.createContext)(null);function a({container:e,children:t}){return(0,r.jsx)(s.Provider,{value:e,children:t})}function l(){return(0,i.Z1)((0,o.useContext)(s),"useContainer used outside of <Tldraw />")}},89658:(e,t,n)=>{"use strict";n.d(t,{s:()=>r});let r=new(n(24167)).xl},89908:(e,t,n)=>{"use strict";n.d(t,{t:()=>i});var r=Object.defineProperty,i=(e,t)=>{let n={};for(var i in e)r(n,i,{get:e[i],enumerable:!0});return t||r(n,Symbol.toStringTag,{value:"Module"}),n}},91072:(e,t,n)=>{"use strict";let r;n.d(t,{QVi:()=>h.QVi,A8:()=>h.A8,Hif:()=>bm,F0h:()=>xp,y5O:()=>bA,hDc:()=>h.hDc,dGg:()=>bp,JGv:()=>bf,pY9:()=>br,Isx:()=>ba,tJe:()=>bs,$EK:()=>bd,C_T:()=>bh,f1t:()=>bu,pPo:()=>bl,hLL:()=>bg,k2C:()=>bc,T:()=>h.T,Z1z:()=>Pm,n6Y:()=>h.n6Y,Ats:()=>ko,mfH:()=>h.mfH,hGv:()=>h.hGv,hau:()=>h.hau});var i,o,s,a,l,d,c,u,h=n(93647);let p=e=>.65*e+.35*(0,h.dwc)(e*h.PI/2),f=e=>({size:e,thinning:0,streamline:(0,h.wwY)(e,[9,16],[.64,.74],!0),smoothing:.62,simulatePressure:!1,easing:h.Z4H.linear});function g({strokeWidth:e,showAsComplete:t}){return{size:1+e,thinning:0,streamline:.5,smoothing:.5,simulatePressure:!1,easing:h.Z4H.easeOutSine,last:t}}function m(e,t,n,r){let i=e.isComplete||n;if(r)if(!e.isPen)return{...f(t),last:i};else return{...{size:t,thinning:0,streamline:.62,smoothing:.62,simulatePressure:!1,easing:h.Z4H.linear},last:i};if("draw"===e.dash)if(e.isPen)return{size:1+1.2*t,thinning:.62,streamline:.62,smoothing:.62,simulatePressure:!1,easing:p,last:i};else return{...{size:t,thinning:.5,streamline:(0,h.wwY)(t,[9,16],[.64,.74],!0),smoothing:.62,easing:h.Z4H.easeOutSine,simulatePressure:!0},last:i};return{...f(t),last:i}}function y(e,t=1,n=1){let r=[];for(let i of e)!function(e,t,n,r=[]){let i=h.K6A.decodePoints(e.path,e.dim);if(1!==t||1!==n)for(let e of i)e.x*=t,e.y*=n;if("free"===e.type||i.length<2)r.push(...i.map(h.l2P.From));else{let e=h.l2P.From(i[0]),t=h.l2P.From(i[1]),n=h.l2P.Dist(t,e);if(0===n)r.push(e);else{let i=h.l2P.Tan(t,e),o=Math.min(1,Math.floor(n/4)),s=h.l2P.Add(e,h.l2P.Mul(i,o)),a=h.l2P.Add(t,h.l2P.Mul(i,-o)),l=Math.max(4,Math.floor(n/16));r.push(e,...h.l2P.PointsBetween(s,a,l,h.Z4H.easeInOutCubic),t)}}}(i,t,n,r);return r}var b=n(95155);class x{static lineThroughPoints(e,t){let n=new x;n.moveTo(e[0].x,e[0].y,{...t,offset:t?.endOffsets??t?.offset});for(let r=1;r<e.length;r++){let i=r===e.length-1;n.lineTo(e[r].x,e[r].y,i?{offset:t?.endOffsets}:void 0)}return n}static cubicSplineThroughPoints(e,t){let n=new x,r=e.length,i=r-2;n.moveTo(e[0].x,e[0].y,{...t,offset:t?.endOffsets??t?.offset});for(let o=0;o<r-1;o++){let r,s,a,l,d,c=0===o?e[0]:e[o-1],u=e[o],h=e[o+1],p=o===i?h:e[o+2];0===o?(r=c.x,s=c.y):(r=u.x+(h.x-c.x)/6*1.25,s=u.y+(h.y-c.y)/6*1.25),o===i?(a=h.x,l=h.y,d={offset:t?.endOffsets}):(a=h.x-(p.x-u.x)/6*1.25,l=h.y-(p.y-u.y)/6*1.25),n.cubicBezierTo(h.x,h.y,r,s,a,l,d)}return n}commands=[];lastMoveTo=null;assertHasMoveTo(){return(0,h.vAR)(this.lastMoveTo,"Start an SVGPathBuilder with `.moveTo()`"),this.lastMoveTo}moveTo(e,t,n){return this.lastMoveTo={type:"move",x:e,y:t,closeIdx:null,isClose:!1,opts:n},this.commands.push(this.lastMoveTo),this}lineTo(e,t,n){return this.assertHasMoveTo(),this.commands.push({type:"line",x:e,y:t,isClose:!1,opts:n}),this}circularArcTo(e,t,n,r,i,o){return this.arcTo(e,e,t,n,0,r,i,o)}arcTo(e,t,n,r,i,o,s,a){this.assertHasMoveTo();let l=this.commands[this.commands.length-1].x,d=this.commands[this.commands.length-1].y;if(l===o&&d===s)return this;if(0===e||0===t)return this.lineTo(o,s,a);let c=Math.sin(i),u=Math.cos(i),p=Math.abs(e),f=Math.abs(t),g=(l-o)/2,m=(d-s)/2,y=u*g+c*m,b=-c*g+u*m,x=y*y/(p*p)+b*b/(f*f);if(x>1){let e=Math.sqrt(x);p*=e,f*=e}let w=(p*p*f*f-p*p*b*b-f*f*y*y)/(p*p*b*b+f*f*y*y),v=(n!==r?1:-1)*Math.sqrt(w=w<0?0:w),S=p*b/f*v,C=-(f*y)/p*v,k=u*S-c*C+(l+o)/2,P=c*S+u*C+(d+s)/2,T=Math.atan2((b-C)/f,(y-S)/p),E=Math.atan2((-b-C)/f,(-y-S)/p);!r&&E>T?E-=2*Math.PI:r&&E<T&&(E+=2*Math.PI);let I=E-T,_=Math.max(p,f)*Math.abs(I),M=Math.min(4,Math.ceil(Math.abs(I)/(Math.PI/2))),A=Math.ceil((0,h.qnK)(_)/M),j=I/M,O=e=>({x:k+p*Math.cos(e)*u-f*Math.sin(e)*c,y:P+p*Math.cos(e)*c+f*Math.sin(e)*u}),D=e=>({x:-p*Math.sin(e)*u-f*Math.cos(e)*c,y:-p*Math.sin(e)*c+f*Math.cos(e)*u});for(let e=0;e<M;e++){let t=T+e*j,n=T+(e+1)*j,r=n-t,i=O(t),o=O(n),s=D(t),l=D(n),d=4/3*Math.tan(r/4),c=i.x+d*s.x,u=i.y+d*s.y,h=o.x-d*l.x,p=o.y-d*l.y,f=0===e?a:{...a,mergeWithPrevious:!0};this.cubicBezierToWithResolution(o.x,o.y,c,u,h,p,f,A)}return this}cubicBezierTo(e,t,n,r,i,o,s){return this.cubicBezierToWithResolution(e,t,n,r,i,o,s)}cubicBezierToWithResolution(e,t,n,r,i,o,s,a){return this.assertHasMoveTo(),this.commands.push({type:"cubic",x:e,y:t,cp1:{x:n,y:r},cp2:{x:i,y:o},isClose:!1,opts:s,resolution:a}),this}close(){let e=this.assertHasMoveTo(),t=this.commands[this.commands.length-1];return(0,h.YY0)(e.x,t.x)&&(0,h.YY0)(e.y,t.y)?t.isClose=!0:this.commands.push({type:"line",x:e.x,y:e.y,isClose:!0}),e.closeIdx=this.commands.length-1,this.lastMoveTo=null,this}transform(e){let t=new x;for(let n of this.commands){let[r,i]=h.V8r.applyToXY(e,n.x,n.y);switch(n.type){case"move":case"line":t.commands.push({...n,x:r,y:i,_info:void 0});break;case"cubic":{let[o,s]=h.V8r.applyToXY(e,n.cp1.x,n.cp1.y),[a,l]=h.V8r.applyToXY(e,n.cp2.x,n.cp2.y);t.commands.push({...n,x:r,y:i,cp1:{x:o,y:s},cp2:{x:a,y:l},_info:void 0});break}default:(0,h.h6G)(n,"type")}}return t}toD(e={}){let{startIdx:t=0,endIdx:n=this.commands.length,onlyFilled:r=!1}=e,i=[],o=!1,s=!1,a=!1,l=e=>{if(s||0===e)return;s=!0;let t=this.commands[e-1];i.push("M",(0,h.WMC)(t.x),(0,h.WMC)(t.y))};for(let e=t;e<n;e++){let t=this.commands[e];switch(t.type){case"move":{let e=t.opts?.geometry!==!1&&(t.opts?.geometry?.isFilled??!1);r&&!e?o=!0:(o=!1,s=!0,a=!0,i.push("M",(0,h.WMC)(t.x),(0,h.WMC)(t.y)));break}case"line":if(o)break;l(e),t.isClose&&a?i.push("Z"):i.push("L",(0,h.WMC)(t.x),(0,h.WMC)(t.y));break;case"cubic":if(o)break;l(e),i.push("C",(0,h.WMC)(t.cp1.x),(0,h.WMC)(t.cp1.y),(0,h.WMC)(t.cp2.x),(0,h.WMC)(t.cp2.y),(0,h.WMC)(t.x),(0,h.WMC)(t.y));break;default:(0,h.h6G)(t,"type")}}return i.join(" ")}toSvg(e){if("none"===e.style)return null;if(e.forceSolid)return this.toSolidSvg(e);switch(e.style){case"solid":return this.toSolidSvg(e);case"dashed":case"dotted":return this.toDashedSvg(e);case"draw":return this.toDrawSvg(e);default:(0,h.h6G)(e,"style")}}toPath2D(e){return"none"===e.style?new Path2D:new Path2D(e.forceSolid||"solid"===e.style?this.toD({onlyFilled:e.onlyFilled}):"draw"===e.style?this.toDrawD(e):this.toD({onlyFilled:e.onlyFilled}))}toGeometry(){let e=[],t=null;for(let n=0;n<this.commands.length;n++){let r=this.commands[n];"move"===r.type&&(t&&t.opts?.geometry!==!1&&e.push(new v(this,t.startIdx,n,{...t.opts?.geometry,isFilled:t.opts?.geometry?.isFilled??!1,isClosed:null!==t.moveCommand.closeIdx})),t={startIdx:n,moveCommand:r,opts:r.opts,isClosed:!1}),r.isClose&&((0,h.vAR)(t,"No current move command"),t.isClosed=!0)}return(t&&t.opts?.geometry!==!1&&e.push(new v(this,t.startIdx,this.commands.length,{...t.opts?.geometry,isFilled:t.opts?.geometry?.isFilled??!1,isClosed:null!==t.moveCommand.closeIdx})),(0,h.vAR)(e.length>0),1===e.length)?e[0]:new h.IQE({children:e})}toSolidSvg(e){let{strokeWidth:t,props:n}=e;return(0,b.jsx)("path",{strokeWidth:t,d:this.toD({onlyFilled:e.onlyFilled}),...n})}toDashedSvg(e){let t,{style:n,strokeWidth:r,snap:i,lengthRatio:o,props:{markerStart:s,markerEnd:a,...l}={}}=e,d=[],c=!1,u=!1,p=null,f=()=>{if(!p)return;let{startIdx:t,endIdx:l,isFirst:c,isLast:u,length:f,lineOpts:g,pathIsClosed:m}=p;if(p=null,t===l&&"move"===this.commands[t].type)return;let y=g?.dashStart??e.start,x=g?.dashEnd??e.end,{strokeDasharray:w,strokeDashoffset:v}=(0,h.EK8)(f,r,{style:n,snap:i,lengthRatio:o,start:c?y??(m?"outset":"none"):"outset",end:u?x??(m?"outset":"none"):"outset"}),S=this.toD({startIdx:t,endIdx:l+1});d.push((0,b.jsx)("path",{d:S,strokeDasharray:w,strokeDashoffset:v,markerStart:c?s:void 0,markerEnd:u?a:void 0},d.length))};for(let n=0;n<this.commands.length;n++){let r=this.commands[n],i=this.commands[n-1];if("move"===r.type){c=null!==r.closeIdx;let n=r.opts?.geometry!==!1&&(r.opts?.geometry?.isFilled??!1);e.onlyFilled&&!n?u=!0:(u=!1,t=r.opts);continue}if(u)continue;let o=this.calculateSegmentLength(i,r),s="move"===i.type,a=r.isClose||n===this.commands.length-1||this.commands[n+1]?.type==="move";p&&r.opts?.mergeWithPrevious?(p.length+=o,p.endIdx=n,p.isLast=a):(f(),p={startIdx:n,endIdx:n,isFirst:s,isLast:a,length:o,lineOpts:t,pathIsClosed:c})}return f(),(0,b.jsx)("g",{strokeWidth:r,...l,children:d})}toDrawSvg(e){return(0,b.jsx)("path",{strokeWidth:e.strokeWidth,d:this.toDrawD(e),...e.props})}toDrawD(e){let{strokeWidth:t,randomSeed:n,offset:r=t/3,roundness:i=2*t,passes:o=2,onlyFilled:s=!1}=e,a=[],l=this.getCommandInfo(),d=[],c=null;for(let e=0;e<this.commands.length;e++){let t=this.commands[e],n=t.opts?.offset??r,o=t.opts?.roundness??i;"move"===t.type&&(c=e);let s=t.isClose?(0,h.Z1O)(c)+1:this.commands[e+1]&&"move"!==this.commands[e+1].type?e+1:void 0,a=void 0!==s&&this.commands[s]&&this.commands[s]?.type!=="move"?l[s]:void 0,u=w[t.type],p=void 0!==s&&w[this.commands[s].type],f=l[e],g=f?.tangentEnd,m=a?.tangentStart,y=u&&p&&g&&m&&h.l2P.Len2(g)>.01&&h.l2P.Len2(m)>.01?(0,h.wwY)(Math.abs(h.l2P.AngleBetween(g,m)),[Math.PI/2,Math.PI],[o,0],!0):0,b=Math.min(f?.length??1/0,a?.length??1/0)-2*y,x=(0,h.qE8)(n,0,b/4),v=Math.min(y,(f?.length??1/0)/4),S=Math.min(y,(a?.length??1/0)/4),C={command:t,offsetAmount:x,roundnessBefore:v,roundnessAfter:S,tangentToPrev:l[e]?.tangentEnd,tangentToNext:a?.tangentStart,moveDidClose:!1};if(d.push(C),t.isClose&&null!==c){let e=d[c];e.moveDidClose=!0,e.roundnessAfter=S}else"move"===t.type&&(c=e)}for(let e=0;e<o;e++){let t=(0,h.She)(n+e),r={x:0,y:0},i=!1;for(let{command:e,offsetAmount:n,roundnessBefore:o,roundnessAfter:l,tangentToNext:c,tangentToPrev:u}of d){let d;if(e.isClose)d=r;else{let e=new h.l2P(t(),t()).uni(),r=Math.sqrt(Math.abs(t()))*n;d=h.l2P.Mul(e,r)}if("move"===e.type){r=d;let t=e.opts?.geometry!==!1&&(e.opts?.geometry?.isFilled??!1);i=!!s&&!t}if(i)continue;let p=h.l2P.Add(e,d),f=c&&l>0?h.l2P.Mul(c,-l).add(p):p,g=u&&o>0?h.l2P.Mul(u,o).add(p):p;if(f===p||g===p)switch(e.type){case"move":a.push("M",(0,h.WMC)(f.x),(0,h.WMC)(f.y));break;case"line":a.push("L",(0,h.WMC)(f.x),(0,h.WMC)(f.y));break;case"cubic":{let t=h.l2P.Add(e.cp1,d),n=h.l2P.Add(e.cp2,d);a.push("C",(0,h.WMC)(t.x),(0,h.WMC)(t.y),(0,h.WMC)(n.x),(0,h.WMC)(n.y),(0,h.WMC)(f.x),(0,h.WMC)(f.y));break}default:(0,h.h6G)(e,"type")}else switch(e.type){case"move":a.push("M",(0,h.WMC)(f.x),(0,h.WMC)(f.y));break;case"line":a.push("L",(0,h.WMC)(g.x),(0,h.WMC)(g.y),"Q",(0,h.WMC)(p.x),(0,h.WMC)(p.y),(0,h.WMC)(f.x),(0,h.WMC)(f.y));break;case"cubic":{let t=h.l2P.Add(e.cp1,d),n=h.l2P.Add(e.cp2,d);a.push("C",(0,h.WMC)(t.x),(0,h.WMC)(t.y),(0,h.WMC)(n.x),(0,h.WMC)(n.y),(0,h.WMC)(p.x),(0,h.WMC)(p.y));break}default:(0,h.h6G)(e,"type")}}}return a.join(" ")}calculateSegmentLength(e,t){switch(t.type){case"move":return 0;case"line":return h.l2P.Dist(e,t);case"cubic":return S.length(e.x,e.y,t.cp1.x,t.cp1.y,t.cp2.x,t.cp2.y,t.x,t.y);default:(0,h.h6G)(t,"type")}}getCommands(){return this.commands}getCommandInfo(){let e=[];for(let t=1;t<this.commands.length;t++){let n,r,i=this.commands[t-1],o=this.commands[t];if(o._info){e[t]=o._info;continue}if("move"!==o.type){switch(o.type){case"line":n=r=h.l2P.Sub(i,o).uni();break;case"cubic":n=h.l2P.Sub(o.cp1,i).uni(),r=h.l2P.Sub(o.cp2,o).uni();break;default:(0,h.h6G)(o,"type")}o._info={tangentStart:n,tangentEnd:r,length:this.calculateSegmentLength(i,o)},e[t]=o._info}}return e}}let w={line:!0,move:!0,cubic:!1};class v extends h.vqJ{constructor(e,t,n,r){super(r),this.path=e,this.startIdx=t,this.endIdx=n}path;startIdx;endIdx;_segments=null;getSegments(){if(this._segments)return this._segments;this._segments=[];let e=this.path.commands[this.startIdx];(0,h.vAR)("move"===e.type);for(let t=this.startIdx+1;t<this.endIdx;t++){let n=this.path.commands[t];switch((0,h.vAR)("move"!==n.type),n.type){case"line":this._segments.push(new h.AoN({start:h.l2P.From(e),end:h.l2P.From(n)}));break;case"cubic":this._segments.push(new h.iON({start:h.l2P.From(e),cp1:h.l2P.From(n.cp1),cp2:h.l2P.From(n.cp2),end:h.l2P.From(n),resolution:n.resolution}));break;default:(0,h.h6G)(n,"type")}e=n}return this._segments}getVertices(e){let t=this.getSegments().flatMap(t=>t.getVertices(e)).filter((e,t,n)=>{let r=n[t-1];return!r||!h.l2P.Equals(r,e)});if(this.isClosed){let e=t[t.length-1],n=t[0];h.l2P.Equals(e,n)||t.push(n)}return t}nearestPoint(e,t){let n=null,r=1/0;for(let t of this.getSegments()){let i=t.nearestPoint(e),o=h.l2P.Dist2(e,i);o<r&&(r=o,n=i)}return(0,h.vAR)(n,"No nearest point found"),n}hitTestLineSegment(e,t,n=0,r){return super.hitTestLineSegment(e,t,n,r)}getSvgPathData(){return this.path.toD({startIdx:this.startIdx,endIdx:this.endIdx})}}let S={base3(e,t,n,r,i){let o=e*(-3*t+9*n-9*r+3*i)+6*t-12*n+6*r;return e*o-3*t+3*n},length(e,t,n,r,i,o,s,a,l=1){let d=(l=l>1?1:l<0?0:l)/2,c=0;c=0;for(let l=0;l<12;l++){let u=d*S.Tvalues[l]+d,h=S.base3(u,e,n,i,s),p=S.base3(u,t,r,o,a),f=h*h+p*p;c+=S.Cvalues[l]*Math.sqrt(f)}return d*c},Tvalues:[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],Cvalues:[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472]};var C=n(12115),k=n.t(C,2);function P(){let e=(0,h.frr)(),t=(0,h.hau)("animationSpeed",()=>e?.user.getAnimationSpeed(),[e]),[n,r]=(0,C.useState)(!1);return(0,C.useEffect)(()=>{if(void 0!==t)return void r(0===t);let n=e?.getContainerWindow()??window;if(!("matchMedia"in n))return;let i=n.matchMedia("(prefers-reduced-motion: reduce)"),o=()=>{r(i.matches)};return o(),i.addEventListener("change",o),()=>i.removeEventListener("change",o)},[t,e]),n}function T(e){return"richText"in e.props&&h.eHF.isValid(e.props.richText)}function E(e,t,n={}){let r="string"==typeof t?e.getShape(t):t;if(r&&e.canEditShape(r)){if(!T(r))throw Error("Shape does not have rich text");e.setEditingShape(r),e.setCurrentTool("select.editing_shape",{...n.info,target:"shape",shape:r}),n.selectAll&&e.emit("select-all-text",{shapeId:r.id})}}let I=(0,C.createContext)(null);function _({children:e}){let t=(0,h.fpl)("a11y",{msg:"",priority:"assertive"}),n=(0,C.useContext)(I),r=(0,C.useMemo)(()=>({currentMsg:t,announce(e){e&&t.set(e)}}),[t]);return n?(0,b.jsx)(b.Fragment,{children:e}):(0,b.jsx)(I.Provider,{value:r,children:e})}function M(){let e=(0,C.useContext)(I);if(!e)throw Error("useA11y must be used within a A11yContext.Provider");return e}let A=(0,C.createContext)(null);function j({assetUrls:e,children:t}){return(0,C.useEffect)(()=>{let t=new Set;for(let n of[...Object.values(e.icons),...Object.values(e.embedIcons)]){if(!n)continue;let e=n.split("#")[0];if(t.has(e))continue;t.add(e);let r=(0,h._V3)();r.crossOrigin="anonymous",r.src=n,r.decode().catch(h.lQ1)}},[e]),(0,b.jsx)(A.Provider,{value:e,children:t})}function O(){let e=(0,C.useContext)(A);if(!e)throw Error("useAssetUrls must be used within an AssetUrlsProvider");return e}let D={"action.toggle-auto-pan":"Auto (trackpad)","action.toggle-auto-zoom":"Auto (mouse)","action.toggle-auto-none":"Auto","action.toggle-mouse":"Mouse","action.toggle-trackpad":"Trackpad","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.copy-hovered-styles":"Copy hovered styles","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.download-original":"Download original","action.duplicate":"Duplicate","action.edit-link":"Edit link…","action.exit-pen-mode":"Exit pen mode","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-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.frame-selection":"Frame selection","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-kbd-shortcuts":"Keyboard shortcuts","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-keyboard-shortcuts.menu":"Enable keyboard shortcuts","action.toggle-keyboard-shortcuts":"Toggle keyboard shortcuts","action.enhanced-a11y-mode.menu":"Enhanced accessibility mode","action.enhanced-a11y-mode":"Toggle enhanced accessibility mode","action.toggle-edge-scrolling.menu":"Edge scrolling","action.toggle-edge-scrolling":"Toggle edge scrolling","action.toggle-invert-zoom.menu":"Invert mouse zoom","action.toggle-invert-zoom":"Toggle invert mouse zoom","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","action.zoom-quick":"Quick zoom","action.select-zoom-tool":"Zoom","assets.files.size-too-big":"File size is too big","assets.files.maximum-size":"Maximum file size is {size}","assets.files.type-not-allowed":"File type is not allowed","assets.files.upload-failed":"Upload failed","assets.files.amount-too-many":"Too many files","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","fill-style.lined-fill":"Lined 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.cloud":"Cloud","geo-style.diamond":"Diamond","geo-style.ellipse":"Ellipse","geo-style.heart":"Heart","geo-style.hexagon":"Hexagon","geo-style.octagon":"Octagon","geo-style.oval":"Oval","geo-style.pentagon":"Pentagon","geo-style.rectangle":"Rectangle","geo-style.rhombus":"Rhombus","geo-style.rhombus-2":"Rhombus left","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","arrow-kind-style.arc":"Arc","arrow-kind-style.elbow":"Elbow","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.heart":"Heart","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.media":"Media","tool.frame":"Frame","tool.note":"Note","tool.laser":"Laser","tool.embed":"Embed","tool.text":"Text","tool.pointer-down":"Pointer down","tool.image-zoom":"Zoom","tool.replace-media":"Replace media…","tool.flip-horz":"Flip horizontally","tool.flip-vert":"Flip vertically","tool.rotate-cw":"Rotate","tool.aspect-ratio":"Aspect ratio","tool.aspect-ratio.original":"Original","tool.aspect-ratio.square":"Square (1:1)","tool.aspect-ratio.circle":"Circle (1:1)","tool.aspect-ratio.landscape":"Landscape (4:3)","tool.aspect-ratio.portrait":"Portrait (3:4)","tool.aspect-ratio.wide":"Wide (16:9)","tool.image-toolbar-title":"Image tools","tool.image-crop":"Crop image","tool.image-crop-confirm":"Confirm","tool.media-alt-text":"Alternative text","tool.media-alt-text-desc":"Give a description…","tool.media-alt-text-confirm":"Confirm","tool.rich-text-bold":"Bold","tool.rich-text-italic":"Italic","tool.rich-text-code":"Code","tool.rich-text-highlight":"Highlight","tool.rich-text-strikethrough":"Strikethrough","tool.rich-text-link":"Link","tool.rich-text-link-visit":"Visit link","tool.rich-text-link-remove":"Remove link","tool.rich-text-header":"Header","tool.rich-text-bulletList":"Bulleted list","tool.rich-text-toolbar-title":"Text formatting","tool.rich-text-orderedList":"Ordered list","tool.bookmark":"Bookmark","a11y.status":"Status","a11y.skip-to-main-content":"Move focus to canvas","a11y.shape-index":"{num} of {total}","a11y.shape-image":"Image","a11y.shape-video":"Video","a11y.multiple-shapes":"{num} shapes selected","a11y.select-shape":"Select next shape","a11y.select-shape-direction":"Select shape in direction","a11y.enter-leave-container":"Enter/leave container","a11y.repeat-shape":"Repeat shape","a11y.move-shape":"Move shape","a11y.move-shape-faster":"Move shape faster","a11y.rotate-shape-cw":"Rotate shape clockwise","a11y.rotate-shape-ccw":"Rotate shape counterclockwise","a11y.rotate-shape-cw-fine":"Rotate shape clockwise (fine)","a11y.rotate-shape-ccw-fine":"Rotate shape counterclockwise (fine)","a11y.enlarge-shape":"Enlarge shape","a11y.shrink-shape":"Shrink shape","a11y.pan-camera":"Pan camera","a11y.adjust-shape-styles":"Adjust shape styles","a11y.open-context-menu":"Context menu…","a11y.open-keyboard-shortcuts":"Keyboard shortcuts","menu.title":"Menu","menu.theme":"Theme","menu.color-theme":"Color theme","menu.accessibility":"Accessibility","menu.copy-as":"Copy as","menu.edit":"Edit","menu.export-as":"Export as","menu.file":"File","menu.language":"Language","menu.preferences":"Preferences","menu.view":"View","menu.input-device":"Input device","context-menu.title":"Context menu","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-pages-reached":"Maximum 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.resize":"Resize page list","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.copy-link":"Copy editor link","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…","share-menu.copied":"Copied link","document-name-menu.copy-link":"Copy link","status.offline":"Offline","people-menu.title":"People","people-menu.change-name":"Change name","people-menu.avatar-color":"Avatar color","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","people-menu.anonymous-user":"New user","help-menu.import-tldr-file":"Import file…","help-menu.title":"Help and resources","help-menu.about":"About tldraw","help-menu.discord":"Discord","help-menu.github":"GitHub","help-menu.keyboard-shortcuts":"Keyboard shortcuts","help-menu.twitter":"Twitter","help-menu.terms":"Terms of service","help-menu.privacy":"Privacy policy","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","edit-link-dialog.external-link":"External link","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.","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","shortcuts-dialog.a11y":"Accessibility","shortcuts-dialog.text-formatting":"Text formatting","style-panel.title":"Styles","style-panel.align":"Align","style-panel.label-align":"Label 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.arrow-kind":"Line","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","style-panel.selected":"selected","tool-panel.title":"Tools","tool-panel.more":"More","navigation-zone.title":"Navigation","navigation-zone.minimap":"Minimap","navigation-zone.toggle-minimap":"Toggle minimap","navigation-zone.zoom":"Zoom","focus-mode.toggle-focus-mode":"Toggle focus mode","toast.close":"Close","toast.success":"Success","toast.error":"Error","toast.info":"Info","toast.warning":"Warning","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…","app.loading":"Loading tldraw…","handle.resize-top":"Resize top","handle.resize-bottom":"Resize bottom","handle.resize-left":"Resize left","handle.resize-right":"Resize right","handle.resize-top-left":"Resize top left","handle.resize-top-right":"Resize top right","handle.resize-bottom-left":"Resize bottom left","handle.resize-bottom-right":"Resize bottom right","handle.rotate.top_left_rotate":"Rotate top left","handle.rotate.top_right_rotate":"Rotate top right","handle.rotate.bottom_left_rotate":"Rotate bottom left","handle.rotate.bottom_right_rotate":"Rotate bottom right","handle.rotate.mobile_rotate":"Rotate","handle.crop.top":"Crop top","handle.crop.bottom":"Crop bottom","handle.crop.left":"Crop left","handle.crop.right":"Crop right","handle.crop.top-left":"Crop top left","handle.crop.top-right":"Crop top right","handle.crop.bottom-left":"Crop bottom left","handle.crop.bottom-right":"Crop bottom right","ui.close":"Close","ui.checked":"Checked","ui.unchecked":"Unchecked","comments.title":"Comments","comments.empty":"No comments on this page yet.","comments.empty-filtered":"No comments match your filters.","comments.thread-title":"Comment","comments.resolved":"Resolved","comments.filter":"Filter comments","comments.show-resolved":"Show resolved comments","comments.only-my-comments":"Only my comments","comments.only-unread":"Only unread","comments.show-all-pages":"Show all pages","comments.more-options":"More options","comments.hide":"Hide comments","comments.show":"Show comments","comments.reply-placeholder":"Reply…","comments.edit-placeholder":"Edit comment…","comments.add-placeholder":"Add a comment…","comments.save":"Save","comments.edit":"Edit","comments.resolve":"Resolve","comments.reopen":"Reopen","comments.delete":"Delete thread","comments.edit-comment":"Edit comment","comments.delete-comment":"Delete comment","comments.dismiss":"Dismiss","comments.copy-link":"Copy link","comments.link-copied":"Link copied","comments.send":"Send","comments.resolved-by":"Resolved by {name}","comments.add-reaction":"Add reaction","comments.reacted-1":"{a} reacted","comments.reacted-2":"{a} and {b} reacted","comments.reacted-3":"{a}, {b} and {c} reacted","comments.reacted-more":"{a}, {b}, {c} and {count} others reacted","comments.reacted-more-one":"{a}, {b}, {c} and 1 other reacted","comments.mention-you":"You","comments.mention-no-matches":"No matches","comments.preview-more":"{count} more","comments.replies-one":"1 reply","comments.replies":"{count} replies","comments.pin-label":"Comment by {name}","comments.pin-label-resolved":"Resolved comment by {name}","comments.cluster-label":"{count} comments here","comments.stack-label":"{count} comments at this spot"},L=new Set(["ar","fa","he","ur","ku"]),F={locale:"en",label:"English",messages:D,dir:"ltr"};async function R(e,t){if(!(await (0,h.hdJ)(t.translations.en)).ok)return console.warn("No main translations found."),F;if("en"===e)return F;let n=h.Yjb.find(t=>t.locale===e);if(!n)return console.warn(`No translation found for locale ${e}`),F;let r=await (0,h.hdJ)(t.translations[n.locale]),i=await r.json();if(!i)return console.warn(`No messages found for locale ${e}`),F;let o=[];for(let e in F.messages)i[e]||o.push(e);return o.length,{locale:e,label:n.label,dir:L.has(n.locale)?"rtl":"ltr",messages:{...F.messages,...i}}}let z=C.createContext(null);function N({overrides:e,locale:t,children:n}){let r=O(),[i,o]=C.useState(()=>e&&e.en?{locale:"en",label:"English",dir:"ltr",messages:{...D,...e.en}}:{locale:"en",label:"English",dir:"ltr",messages:D});return C.useEffect(()=>{let n=!1;return async function(){let i=await R(t,r);i&&!n&&(e&&e[t]?o({...i,messages:{...i.messages,...e[t]}}):o(i))}(),()=>{n=!0}},[r,t,e]),(0,b.jsx)(z.Provider,{value:i,children:n})}function $(){let e=C.useContext(z),t=e?.messages??D;return C.useEffect(()=>{e?.messages||(0,h.mcG)("No translation messages found, falling back to default translation. Wrap your app in <TldrawUiContextProvider>, or in both <AssetUrlsProvider> and <TldrawUiTranslationProvider>, to provide translations.")},[e?.messages]),C.useCallback(function(e){return t[e]??e},[t])}function B(){let e=C.useContext(z);return e?.dir??"ltr"}function H(e,t){let n=t?e.getAsset(t):null;if(n&&!n.props.image)if(!n.props.title)return 46;else return 101;return 320}function U(e,t){return{...t,props:{...t.props,h:H(e,t.props.assetId)}}}function W(e,t,n){if(t)return t;if(!n)return null;let r=h.Kx3.createId((0,h.xpx)(n));return e.getAsset(r)?r:null}function K(e,t){let n=W(e,t.props.assetId,t.props.url);return n===t.props.assetId?t.props.h:H(e,n)}async function V(e,t){if(e.isDisposed)return;let{url:n}=t.props,r=await e.getAssetForExternalContent({type:"url",url:n});r&&e.run(()=>{e.createAssets([r]),e.updateShapes([{id:t.id,type:t.type,props:{assetId:r.id}}])})}let Y=new WeakMap;async function G(e,{url:t,center:n=e.getViewportPageBounds().center}){try{let r=h.Kx3.createId((0,h.xpx)(t)),i=e.getAsset(r),o=(0,h.n6Y)(),s={id:o,type:"bookmark",x:n.x-150,y:n.y-160,rotation:0,opacity:1,props:{url:t,assetId:i?.id??null,w:300,h:H(e,i?.id)}};e.run(()=>{e.createShapes([s])});let a=e.getShape(o);if(!a)return h.Q7C.err("Failed to create bookmark shape");if(i)return h.Q7C.ok(a);return q(e,o,t),h.Q7C.ok(a)}catch(e){return h.Q7C.err(e instanceof Error?e.message:"Failed to create bookmark")}}async function q(e,t,n){let r;try{r=await e.getAssetForExternalContent({type:"url",url:n})}catch(e){console.error(e);return}if(e.isDisposed||!r)return;let i=e.getShape(t);!i||i.props.url!==n||i.props.assetId||e.run(()=>{e.getAsset(r.id)||e.createAssets([r]),e.updateShapes([{id:t,type:"bookmark",props:{assetId:r.id}}])},{history:"ignore"})}function X(){return{topLeft:{x:0,y:0},bottomRight:{x:1,y:1}}}let J=["original","square","circle","landscape","portrait","wide"],Z={original:0,square:1,circle:1,landscape:4/3,portrait:3/4,wide:16/9};function Q(e,t){return t?{w:e.w/(t.bottomRight.x-t.topLeft.x),h:e.h/(t.bottomRight.y-t.topLeft.y)}:{w:e.w,h:e.h}}function ee(e){return{width:e.bottomRight.x-e.topLeft.x,height:e.bottomRight.y-e.topLeft.y}}function et(e){let{width:t,height:n}=ee(e);return{x:e.topLeft.x+t/2,y:e.topLeft.y+n/2}}function en(e,t,n,r,i){let o=Math.max(0,Math.min(1-n,e-n/2)),s=Math.max(0,Math.min(1-r,t-r/2));return{topLeft:{x:o,y:s},bottomRight:{x:o+n,y:s+r},isCircle:i}}let er={fontWeight:"normal",fontVariant:"normal",fontStyle:"normal",padding:"0px"},ei={s:1,m:1.75,l:2.5,xl:5},eo={s:1.125,m:1.5,l:2.25,xl:2.75},es={s:1.125,m:1.375,l:1.625,xl:2},ea={s:1.125,m:1.25,l:1.5,xl:1.75},el={draw:"var(--tl-font-draw)",sans:"var(--tl-font-sans)",serif:"var(--tl-font-serif)",mono:"var(--tl-font-mono)"};function ed(e,t){let n=e.fonts[t];return n?n.fontFamily:el[t]??t}async function ec(e,t,n){let{elements:r,files:i}=t,o={shapes:[],bindings:[],rootShapeIds:[],assets:[],schema:e.store.schema.serialize()},s=new Map,a=new Map,l=e.getCurrentPageId(),d=new Map,c=[],u=new Set;r.forEach(e=>{if(d.set(e.id,(0,h.n6Y)()),null!==e.boundElements)for(let t of e.boundElements)"text"===t.type&&u.add(t.id)});let p=h.as9;for(let t of r){if(u.has(t.id))continue;let n=d.get(t.id),f={id:n,typeName:"shape",parentId:l,index:p,x:t.x,y:t.y,rotation:0,isLocked:t.locked,opacity:eu(t.opacity),meta:{}};switch(0!==t.angle&&a.set(n,t.angle),t.groupIds&&t.groupIds.length>0?s.has(t.groupIds[0])?s.get(t.groupIds[0])?.push(n):s.set(t.groupIds[0],[n]):c.push(n),t.type){case"rectangle":case"ellipse":case"diamond":{let n="",i="middle";if(null!==t.boundElements){for(let e of t.boundElements)if("text"===e.type){let t=r.find(t=>t.id===e.id);t&&(n=t.text,i=ew[t.textAlign])}}let s="transparent"===t.backgroundColor?t.strokeColor:t.backgroundColor;o.shapes.push({...f,type:"geo",props:{...e.getShapeUtil("geo").getDefaultProps(),geo:t.type,url:t.link??"",w:t.width,h:t.height,size:eh[t.strokeWidth]??"draw",color:ey[s]??"black",richText:(0,h.TP3)(n),align:i,dash:eC(t),fill:ek(t)}});break}case"freedraw":{let n=t.points.map(([e,t,n=.5])=>({x:e,y:t,z:n})),r=h.K6A.encodePoints(n);o.shapes.push({...f,type:"draw",props:{...e.getShapeUtil("draw").getDefaultProps(),dash:eC(t),size:eh[t.strokeWidth],color:ey[t.strokeColor]??"black",segments:[{type:"free",path:r}]}});break}case"line":{if(t.points.slice().length<2)break;let n=(0,h.uud)(t.points.length);o.shapes.push({...f,type:"line",props:{...e.getShapeUtil("line").getDefaultProps(),dash:eC(t),size:eh[t.strokeWidth],color:ey[t.strokeColor]??"black",spline:t.roundness?"cubic":"line",points:{...Object.fromEntries(t.points.map(([e,t],r)=>{let i=n[r];return[i,{id:i,index:i,x:e,y:t}]}))}}});break}case"arrow":{let i="";if(null!==t.boundElements){for(let e of t.boundElements)if("text"===e.type){let t=r.find(t=>t.id===e.id);t&&(i=t.text)}}let s=t.points[0],a=t.points[t.points.length-1],l=d.get(t.startBinding?.elementId),c=d.get(t.endBinding?.elementId);o.shapes.push({...f,type:"arrow",props:{...e.getShapeUtil("arrow").getDefaultProps(),richText:(0,h.TP3)(i),kind:t.elbowed?"elbow":"arc",bend:function(e,t,n){let r=0;if(e.points.length>2){let i=new h.l2P(t[0],t[1]),o=new h.l2P(n[0],n[1]),s=new h.l2P(e.points[1][0],e.points[1][1]),a=h.l2P.Sub(o,i),l=h.l2P.Per(a),d=h.l2P.Med(o,i),c=h.l2P.Sub(d,l),u=h.l2P.Add(d,l),p=h.l2P.NearestPointOnLineSegment(c,u,s,!1);r=h.l2P.Dist(p,d),h.l2P.Clockwise(p,o,d)&&(r*=-1)}return r}(t,s,a),dash:eC(t),size:eh[t.strokeWidth]??"m",color:ey[t.strokeColor]??"black",start:{x:s[0],y:s[1]},end:{x:a[0],y:a[1]},arrowheadEnd:eS[t.endArrowhead]??"none",arrowheadStart:eS[t.startArrowhead]??"none"}}),l&&o.bindings.push({id:(0,h.BNi)(),typeName:"binding",type:"arrow",fromId:n,toId:l,props:{terminal:"start",snap:"none",normalizedAnchor:{x:.5,y:.5},isPrecise:!1,isExact:!1},meta:{}}),c&&o.bindings.push({id:(0,h.BNi)(),typeName:"binding",type:"arrow",fromId:n,toId:c,props:{terminal:"end",snap:"none",normalizedAnchor:{x:.5,y:.5},isPrecise:!1,isExact:!1},meta:{}});break}case"text":{let{size:n,scale:r}=function(e){let t=ep[e];return t?{size:t,scale:1}:e<16?{size:"s",scale:e/16}:e>36?{size:"xl",scale:e/36}:{size:"m",scale:1}}(t.fontSize);o.shapes.push({...f,type:"text",props:{...e.getShapeUtil("text").getDefaultProps(),size:n,scale:r,font:ef[t.fontFamily]??"draw",color:ey[t.strokeColor]??"black",richText:(0,h.TP3)(t.text),textAlign:ev[t.textAlign]}});break}case"image":{let n=i[t.fileId];if(!n)break;let r=h.Kx3.createId();o.assets.push({id:r,typeName:"asset",type:"image",props:{w:t.width,h:t.height,fileSize:n.size,name:t.id??"Untitled",isAnimated:!1,mimeType:n.mimeType,src:n.dataURL},meta:{}}),o.shapes.push({...f,type:"image",props:{...e.getShapeUtil("image").getDefaultProps(),w:t.width,h:t.height,assetId:r}})}}p=(0,h.AQy)(p)}let f=n??(e.inputs.getShiftKey()?e.inputs.getCurrentPagePoint():void 0);for(let t of(e.putContentOntoCurrentPage(o,{point:f,select:!1,preserveIds:!0}),s.values()))if(t.length>1){e.groupShapes(t);let n=e.getShape(t[0]);n?.parentId&&(0,h.vc4)(n.parentId)&&c.push(n.parentId)}for(let[t,n]of a)e.select(t),e.rotateShapesBy([t],n);let g=(0,h.oE7)(c.map(t=>e.getShape(t))),m=h.azJ.Common(g.map(t=>e.getShapePageBounds(t))),y=e.getViewportPageBounds().center;e.updateShapes(g.map(e=>{let t={x:(e.x??0)-(m.x+m.w/2),y:(e.y??0)-(m.y+m.h/2)};return{id:e.id,type:e.type,x:y.x+t.x,y:y.y+t.y}})),e.setSelectedShapes(c)}let eu=e=>{let t=e/100;return t<.2?.1:t<.4?.25:t<.6?.5:t<.8?.75:1},eh={1:"s",2:"m",3:"l",4:"xl"},ep={16:"s",20:"m",28:"l",36:"xl"},ef={1:"draw",2:"sans",3:"mono"},eg={gray:["#f8f9fa","#e9ecef","#ced4da","#868e96","#343a40"],red:["#fff5f5","#ffc9c9","#ff8787","#fa5252","#e03131"],pink:["#fff0f6","#fcc2d7","#f783ac","#e64980","#c2255c"],grape:["#f8f0fc","#eebefa","#da77f2","#be4bdb","#9c36b5"],violet:["#f3f0ff","#d0bfff","#9775fa","#7950f2","#6741d9"],indigo:["#edf2ff","#bac8ff","#748ffc","#4c6ef5","#3b5bdb"],blue:["#e7f5ff","#a5d8ff","#4dabf7","#228be6","#1971c2"],cyan:["#e3fafc","#99e9f2","#3bc9db","#15aabf","#0c8599"],teal:["#e6fcf5","#96f2d7","#38d9a9","#12b886","#099268"],green:["#ebfbee","#b2f2bb","#69db7c","#40c057","#2f9e44"],lime:["#f4fce3","#d8f5a2","#a9e34b","#82c91e","#66a80f"],yellow:["#fff9db","#ffec99","#ffd43b","#fab005","#f08c00"],orange:["#fff4e6","#ffd8a8","#ffa94d","#fd7e14","#e8590c"]};function em(e,t,n){return Object.fromEntries([0,1,2,3,4].map(t=>eg[e][t]).map((e,r)=>[e,r<3?t:n]))}let ey={...em("gray","grey","black"),...em("red","light-red","red"),...em("pink","light-red","red"),...em("grape","light-violet","violet"),...em("blue","light-blue","blue"),...em("cyan","light-blue","blue"),...em("teal","light-green","green"),...em("green","light-green","green"),...em("yellow","yellow","orange"),...em("orange","yellow","orange"),"#ffffff":"white","#000000":"black"},eb={solid:"draw",dashed:"dashed",dotted:"dotted"},ex={"cross-hatch":"pattern",hachure:"pattern",solid:"solid"},ew={left:"start",center:"middle",right:"end"},ev={left:"start",center:"middle",right:"end"},eS={arrow:"arrow",dot:"dot",triangle:"triangle",bar:"pipe"},eC=e=>{let t=eb[e.strokeStyle]??"draw";return"draw"===t&&0===e.roughness&&(t="solid"),t},ek=e=>"transparent"===e.backgroundColor?"none":ex[e.fillStyle]??"solid";var eP=n(82159);let eT=e=>{let t=/`([^`]+)`(?!`)$/.exec(e);return!t||t.index>0&&"`"===e[t.index-1]?null:{index:t.index,text:t[0],replaceWith:t[1]}},eE=e=>{let t,n=/`([^`]+)`(?!`)/g,r=[];for(;null!==(t=n.exec(e));)t.index>0&&"`"===e[t.index-1]||r.push({index:t.index,text:t[0],replaceWith:t[1]});return r},eI=eP.CU.create({name:"code",addOptions:()=>({HTMLAttributes:{}}),excludes:"_",code:!0,exitable:!0,parseHTML:()=>[{tag:"code"}],renderHTML({HTMLAttributes:e}){return["code",(0,eP.KV)(this.options.HTMLAttributes,e),0]},markdownTokenName:"codespan",parseMarkdown:(e,t)=>t.applyMark("code",[{type:"text",text:e.text||""}]),renderMarkdown:(e,t)=>e.content?`\`${t.renderChildren(e.content)}\``:"",addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[(0,eP.OX)({find:eT,type:this.type})]},addPasteRules(){return[(0,eP.Zc)({find:eE,type:this.type})]}}),e_=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,eM=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,eA=eP.CU.create({name:"highlight",addOptions:()=>({multicolor:!1,HTMLAttributes:{}}),addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute("data-color")||(0,eP.hs)(e,"background-color")||e.style.backgroundColor,renderHTML:e=>e.color?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML:()=>[{tag:"mark"}],renderHTML({HTMLAttributes:e}){return["mark",(0,eP.KV)(this.options.HTMLAttributes,e),0]},renderMarkdown:(e,t)=>`==${t.renderChildren(e)}==`,parseMarkdown:(e,t)=>t.applyMark("highlight",t.parseInline(e.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:e=>e.indexOf("=="),tokenize(e,t,n){let r=/^(==)([^=]+)(==)/.exec(e);if(r){let e=r[2].trim(),t=n.inlineTokens(e);return{type:"highlight",raw:r[0],text:e,tokens:t}}}},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[(0,eP.OX)({find:e_,type:this.type})]},addPasteRules(){return[(0,eP.Zc)({find:eM,type:this.type})]}});var ej=n(27050),eO=n(76865);let eD=new WeakSet,eL=new WeakSet;function eF(e){return eD.add(e),e}function eR(e){return Array.isArray(e)&&eD.has(e)}let ez=(e,t)=>(function(e,t){if("slot"===e)return 0;if(e instanceof Function){let n=e(t);return!Array.isArray(n)||eR(n)||eL.has(n)?n:eF(n)}let{children:n,...r}=null!=t?t:{};if("svg"===e)throw Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");if(Array.isArray(n)){if(eR(n))return eF([e,r,n]);if(0===n.length)return eF([e,r]);let t=function e(t){return t.flatMap(t=>null==t?[]:Array.isArray(t)&&eL.has(t)&&!eR(t)?e(t):[t])}(n);return 0===t.length?eF([e,r]):eF([e,r,...t])}return null!=n?eF([e,r,n]):eF([e,r])})(e,t),eN=/^\s*>\s$/,e$=eP.bP.create({name:"blockquote",addOptions:()=>({HTMLAttributes:{}}),content:"block+",group:"block",defining:!0,parseHTML:()=>[{tag:"blockquote"}],renderHTML({HTMLAttributes:e}){return ez("blockquote",{...(0,eP.KV)(this.options.HTMLAttributes,e),children:ez("slot",{})})},parseMarkdown:(e,t)=>{var n;let r=null!=(n=t.parseBlockChildren)?n:t.parseChildren;return t.createNode("blockquote",void 0,r(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return"";let n=[];return e.content.forEach((e,r)=>{var i,o;let s=(null!=(i=null==(o=t.renderChild)?void 0:o.call(t,e,r))?i:t.renderChildren([e])).split("\n").map(e=>""===e.trim()?">":`> ${e}`);n.push(s.join("\n"))}),n.join(`
|
|
19
|
+
>
|
|
20
|
+
`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>((e,t)=>{var n;let{state:r}=e,{selection:i}=r;if(!i.empty)return!1;let{$from:o}=i;if(0!==o.parentOffset)return!1;let s=o.depth-1;if(s<0)return!1;let a=o.node(s),l=o.index(s);if(0===l)return!1;if(a.type===t)return e.commands.lift(t.name);let d=a.child(l-1);if(d.type!==t||!(null==(n=d.lastChild)?void 0:n.isTextblock))return!1;let c=o.before()-1-1;return e.commands.command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=o.parent.content,r=new ej.Ji(n,0,0);return e.replace(c,o.after(),r),e.setSelection(eO.U3.create(e.doc,c+n.size)),e.scrollIntoView(),t(e),!0})})(this.editor,this.type)}},addInputRules(){return[(0,eP.tG)({find:eN,type:this.type})]}}),eB=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,eH=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,eU=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,eW=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,eK=eP.CU.create({name:"bold",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>"normal"!==e.style.fontWeight&&null},{style:"font-weight=400",clearMark:e=>e.type.name===this.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return ez("strong",{...(0,eP.KV)(this.options.HTMLAttributes,e),children:ez("slot",{})})},markdownTokenName:"strong",parseMarkdown:(e,t)=>t.applyMark("bold",t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[(0,eP.OX)({find:eB,type:this.type}),(0,eP.OX)({find:eU,type:this.type})]},addPasteRules(){return[(0,eP.Zc)({find:eH,type:this.type}),(0,eP.Zc)({find:eW,type:this.type})]}}),eV=/^```([a-z]+)?[\s\n]$/,eY=/^~~~([a-z]+)?[\s\n]$/,eG=eP.bP.create({name:"codeBlock",addOptions:()=>({languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}),content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{var t;let{languageClassPrefix:n}=this.options;if(!n)return null;let r=[...(null==(t=e.firstElementChild)?void 0:t.classList)||[]].filter(e=>e.startsWith(n)).map(e=>e.replace(n,""))[0];return r||null},rendered:!1}}},parseHTML:()=>[{tag:"pre",preserveWhitespace:"full"}],renderHTML({node:e,HTMLAttributes:t}){return["pre",(0,eP.KV)(this.options.HTMLAttributes,t),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(e,t)=>{var n,r;return(null==(n=e.raw)?void 0:n.startsWith("```"))===!1&&(null==(r=e.raw)?void 0:r.startsWith("~~~"))===!1&&"indented"!==e.codeBlockStyle?[]:t.createNode("codeBlock",{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[])},renderMarkdown:(e,t)=>{var n;let r=(null==(n=e.attrs)?void 0:n.language)||"";return e.content?[`\`\`\`${r}`,t.renderChildren(e.content),"```"].join("\n"):`\`\`\`${r}
|
|
21
|
+
|
|
22
|
+
\`\`\``},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=1===t.pos;return!!e&&t.parent.type.name===this.name&&(!!n||!t.parent.textContent.length)&&this.editor.commands.clearNodes()},Tab:({editor:e})=>{var t;if(!this.options.enableTabIndentation)return!1;let n=null!=(t=this.options.tabSize)?t:4,{state:r}=e,{selection:i}=r,{$from:o,empty:s}=i;if(o.parent.type!==this.type)return!1;let a=" ".repeat(n);return s?e.commands.insertContent(a):e.commands.command(({tr:e})=>{let{from:t,to:n}=i,o=r.doc.textBetween(t,n,"\n","\n").split("\n").map(e=>a+e).join("\n");return e.replaceWith(t,n,r.schema.text(o)),!0})},"Shift-Tab":({editor:e})=>{var t;if(!this.options.enableTabIndentation)return!1;let n=null!=(t=this.options.tabSize)?t:4,{state:r}=e,{selection:i}=r,{$from:o,empty:s}=i;return o.parent.type===this.type&&(s?e.commands.command(({tr:e})=>{var t;let{pos:i}=o,s=o.start(),a=o.end(),l=r.doc.textBetween(s,a,"\n","\n").split("\n"),d=0,c=0,u=i-s;for(let e=0;e<l.length;e+=1){if(c+l[e].length>=u){d=e;break}c+=l[e].length+1}let h=Math.min(((null==(t=l[d].match(/^ */))?void 0:t[0])||"").length,n);if(0===h)return!0;let p=s;for(let e=0;e<d;e+=1)p+=l[e].length+1;return e.delete(p,p+h),i-p<=h&&e.setSelection(eO.U3.create(e.doc,p)),!0}):e.commands.command(({tr:e})=>{let{from:t,to:o}=i,s=r.doc.textBetween(t,o,"\n","\n").split("\n").map(e=>{var t;let r=Math.min(((null==(t=e.match(/^ */))?void 0:t[0])||"").length,n);return e.slice(r)}).join("\n");return e.replaceWith(t,o,r.schema.text(s)),!0}))},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;let o=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith("\n\n");return!!o&&!!s&&e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:e})=>{if(!this.options.exitOnArrowUp)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type||0!==r.parentOffset)return!1;let o=r.before();return!(o>0)&&e.commands.insertDefaultBlock({pos:o})},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:o}=n;if(!o||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let s=i.after();return void 0!==s&&(r.nodeAt(s)?e.commands.command(({tr:e})=>(e.setSelection(eO.LN.near(r.resolve(s))),!0)):e.commands.exitCode())}}},addInputRules(){return[(0,eP.JJ)({find:eV,type:this.type,getAttributes:e=>({language:e[1]})}),(0,eP.JJ)({find:eY,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new eO.k_({key:new eO.hs("codeBlockVSCodeHandler"),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData("text/plain"),r=t.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,o=null==i?void 0:i.mode;if(!n||!o)return!1;let{tr:s,schema:a}=e.state,l=a.text(n.replace(/\r\n?/g,"\n"));return s.replaceSelectionWith(this.type.create({language:o},l)),s.selection.$from.parent.type!==this.type&&s.setSelection(eO.U3.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),e.dispatch(s),!0}}})]}}),eq=eP.bP.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,"\n\n"):""}),eX=eP.bP.create({name:"hardBreak",markdownTokenName:"br",addOptions:()=>({keepMarks:!0,HTMLAttributes:{}}),inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML:()=>[{tag:"br"}],renderHTML({HTMLAttributes:e}){return["br",(0,eP.KV)(this.options.HTMLAttributes,e)]},renderText:()=>"\n",renderMarkdown:()=>`
|
|
23
|
+
`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:o}=this.options,{splittableMarks:s}=r.extensionManager,a=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&a&&o){let t=a.filter(e=>s.includes(e.type.name));e.ensureMarks(t)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),eJ=eP.bP.create({name:"heading",addOptions:()=>({levels:[1,2,3,4,5,6],HTMLAttributes:{}}),content:"inline*",group:"block",defining:!0,addAttributes:()=>({level:{default:1,rendered:!1}}),parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,(0,eP.KV)(this.options.HTMLAttributes,t),0]},parseMarkdown:(e,t)=>t.createNode("heading",{level:e.depth||1},t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>{var n;let r=(null==(n=e.attrs)?void 0:n.level)?parseInt(e.attrs.level,10):1,i="#".repeat(r);return e.content?`${i} ${t.renderChildren(e.content)}`:""},addCommands(){return{setHeading:e=>({commands:t})=>!!this.options.levels.includes(e.level)&&t.setNode(this.name,e),toggleHeading:e=>({commands:t})=>!!this.options.levels.includes(e.level)&&t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>(0,eP.JJ)({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),eZ=eP.bP.create({name:"horizontalRule",addOptions:()=>({HTMLAttributes:{},nextNodeType:"paragraph"}),group:"block",parseHTML:()=>[{tag:"hr"}],renderHTML({HTMLAttributes:e}){return["hr",(0,eP.KV)(this.options.HTMLAttributes,e)]},markdownTokenName:"hr",parseMarkdown:(e,t)=>t.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!(0,eP.AB)(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return(0,eP.BQ)(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:e,tr:t,dispatch:n})=>{if(n){let{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(eO.U3.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(eO.nh.create(t.doc,n.pos)):t.setSelection(eO.U3.create(t.doc,n.pos));else{let i=e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType,o=null==i?void 0:i.create();o&&(t.insert(r,o),t.setSelection(eO.U3.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[(0,eP.Ce)({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),eQ=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,e0=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,e1=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,e2=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,e3=eP.CU.create({name:"italic",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>"normal"!==e.style.fontStyle&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",(0,eP.KV)(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(e,t)=>t.applyMark("italic",t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[(0,eP.OX)({find:eQ,type:this.type}),(0,eP.OX)({find:e1,type:this.type})]},addPasteRules(){return[(0,eP.Zc)({find:e0,type:this.type}),(0,eP.Zc)({find:e2,type:this.type})]}}),e5="numeric",e6="ascii",e4="alpha",e8="asciinumeric",e9="alphanumeric",e7="domain",te="emoji",tt="whitespace";function tn(e,t,n){for(let r in t[e5]&&(t[e8]=!0,t[e9]=!0),t[e6]&&(t[e8]=!0,t[e4]=!0),t[e8]&&(t[e9]=!0),t[e4]&&(t[e9]=!0),t[e9]&&(t[e7]=!0),t[te]&&(t[e7]=!0),t){let t=(r in n||(n[r]=[]),n[r]);0>t.indexOf(e)&&t.push(e)}}function tr(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}tr.groups={},tr.prototype={accepts(){return!!this.t},go(e){let t=this.j[e];if(t)return t;for(let t=0;t<this.jr.length;t++){let n=this.jr[t][0],r=this.jr[t][1];if(r&&n.test(e))return r}return this.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let i=0;i<e.length;i++)this.tt(e[i],t,n,r)},tr(e,t,n,r){let i;return r=r||tr.groups,t&&t.j?i=t:(i=new tr(t),n&&r&&tn(t,n,r)),this.jr.push([e,i]),i},ts(e,t,n,r){let i=this,o=e.length;if(!o)return i;for(let t=0;t<o-1;t++)i=i.tt(e[t]);return i.tt(e[o-1],t,n,r)},tt(e,t,n,r){if(r=r||tr.groups,t&&t.j)return this.j[e]=t,t;let i,o=this.go(e);return o?(Object.assign((i=new tr).j,o.j),i.jr.push.apply(i.jr,o.jr),i.jd=o.jd,i.t=o.t):i=new tr,t&&(r&&(i.t&&"string"==typeof i.t?tn(t,Object.assign(function(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}(i.t,r),n),r):n&&tn(t,n,r)),i.t=t),this.j[e]=i,i}};let ti=(e,t,n,r,i)=>e.ta(t,n,r,i),to=(e,t,n,r,i)=>e.tr(t,n,r,i),ts=(e,t,n,r,i)=>e.ts(t,n,r,i),ta=(e,t,n,r,i)=>e.tt(t,n,r,i),tl="WORD",td="UWORD",tc="ASCIINUMERICAL",tu="ALPHANUMERICAL",th="LOCALHOST",tp="UTLD",tf="SCHEME",tg="SLASH_SCHEME",tm="OPENBRACE",ty="CLOSEBRACE",tb="OPENBRACKET",tx="CLOSEBRACKET",tw="OPENPAREN",tv="CLOSEPAREN",tS="OPENANGLEBRACKET",tC="CLOSEANGLEBRACKET",tk="FULLWIDTHLEFTPAREN",tP="FULLWIDTHRIGHTPAREN",tT="LEFTCORNERBRACKET",tE="RIGHTCORNERBRACKET",tI="LEFTWHITECORNERBRACKET",t_="RIGHTWHITECORNERBRACKET",tM="FULLWIDTHLESSTHAN",tA="FULLWIDTHGREATERTHAN",tj="AMPERSAND",tO="APOSTROPHE",tD="ASTERISK",tL="BACKSLASH",tF="BACKTICK",tR="CARET",tz="COLON",tN="COMMA",t$="DOLLAR",tB="EQUALS",tH="EXCLAMATION",tU="HYPHEN",tW="PERCENT",tK="PIPE",tV="PLUS",tY="POUND",tG="QUERY",tq="QUOTE",tX="FULLWIDTHMIDDLEDOT",tJ="SEMI",tZ="SLASH",tQ="TILDE",t0="UNDERSCORE",t1="EMOJI";var t2=Object.freeze({__proto__:null,ALPHANUMERICAL:tu,AMPERSAND:tj,APOSTROPHE:tO,ASCIINUMERICAL:tc,ASTERISK:tD,AT:"AT",BACKSLASH:tL,BACKTICK:tF,CARET:tR,CLOSEANGLEBRACKET:tC,CLOSEBRACE:ty,CLOSEBRACKET:tx,CLOSEPAREN:tv,COLON:tz,COMMA:tN,DOLLAR:t$,DOT:"DOT",EMOJI:t1,EQUALS:tB,EXCLAMATION:tH,FULLWIDTHGREATERTHAN:tA,FULLWIDTHLEFTPAREN:tk,FULLWIDTHLESSTHAN:tM,FULLWIDTHMIDDLEDOT:tX,FULLWIDTHRIGHTPAREN:tP,HYPHEN:tU,LEFTCORNERBRACKET:tT,LEFTWHITECORNERBRACKET:tI,LOCALHOST:th,NL:"NL",NUM:"NUM",OPENANGLEBRACKET:tS,OPENBRACE:tm,OPENBRACKET:tb,OPENPAREN:tw,PERCENT:tW,PIPE:tK,PLUS:tV,POUND:tY,QUERY:tG,QUOTE:tq,RIGHTCORNERBRACKET:tE,RIGHTWHITECORNERBRACKET:t_,SCHEME:tf,SEMI:tJ,SLASH:tZ,SLASH_SCHEME:tg,SYM:"SYM",TILDE:tQ,TLD:"TLD",UNDERSCORE:t0,UTLD:tp,UWORD:td,WORD:tl,WS:"WS"});let t3=/[a-z]/,t5=/\p{L}/u,t6=/\p{Emoji}/u,t4=/\d/,t8=/\s/,t9=null,t7=null;function ne(e,t){let n=function(e){let t=[],n=e.length,r=0;for(;r<n;){let i,o=e.charCodeAt(r),s=o<55296||o>56319||r+1===n||(i=e.charCodeAt(r+1))<56320||i>57343?e[r]:e.slice(r,r+2);t.push(s),r+=s.length}return t}(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[],o=0,s=0;for(;s<r;){let a=e,l=null,d=0,c=null,u=-1,h=-1;for(;s<r&&(l=a.go(n[s]));)(a=l).accepts()?(u=0,h=0,c=a):u>=0&&(u+=n[s].length,h++),d+=n[s].length,o+=n[s].length,s++;o-=u,s-=h,d-=u,i.push({t:c.t,v:t.slice(o-d,o),s:o-d,e:o})}return i}function nt(e,t,n,r,i){let o,s=t.length;for(let n=0;n<s-1;n++){let s=t[n];e.j[s]?o=e.j[s]:((o=new tr(r)).jr=i.slice(),e.j[s]=o),e=o}return(o=new tr(n)).jr=i.slice(),e.j[t[s-1]]=o,o}function nn(e){let t=[],n=[],r=0;for(;r<e.length;){let i=0;for(;"0123456789".indexOf(e[r+i])>=0;)i++;if(i>0){t.push(n.join(""));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}let nr={defaultProtocol:"http",events:null,format:no,formatHref:no,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function ni(e,t=null){let n=Object.assign({},nr);e&&(n=Object.assign(n,e instanceof ni?e.o:e));let r=n.ignoreTags,i=[];for(let e=0;e<r.length;e++)i.push(r[e].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=i}function no(e){return e}function ns(e,t){this.t="token",this.v=e,this.tk=t}function na(e,t){class n extends ns{constructor(t,n){super(t,n),this.t=e}}for(let e in t)n.prototype[e]=t[e];return n.t=e,n}ni.prototype={o:nr,ignoreTags:[],defaultRender:e=>e,check(e){return this.get("validate",e.toString(),e)},get(e,t,n){let r=null!=t,i=this.o[e];return i&&("object"==typeof i?"function"==typeof(i=n.t in i?i[n.t]:nr[e])&&r&&(i=i(t,n)):"function"==typeof i&&r&&(i=i(t,n.t,n))),i},getObj(e,t,n){let r=this.o[e];return"function"==typeof r&&null!=t&&(r=r(t,n.t,n)),r},render(e){let t=e.render(this);return(this.get("render",null,e)||this.defaultRender)(t,e.t,e)}},ns.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let t=this.toString(),n=e.get("truncate",t,this),r=e.get("format",t,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(e){return e.get("formatHref",this.toHref(e.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=nr.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get("validate",this.toString(),this)},render(e){let t=this.toHref(e.get("defaultProtocol")),n=e.get("formatHref",t,this),r=e.get("tagName",t,this),i=this.toFormattedString(e),o={},s=e.get("className",t,this),a=e.get("target",t,this),l=e.get("rel",t,this),d=e.getObj("attributes",t,this),c=e.getObj("events",t,this);return o.href=n,s&&(o.class=s),a&&(o.target=a),l&&(o.rel=l),d&&Object.assign(o,d),{tagName:r,attributes:o,content:i,eventListeners:c}}};let nl=na("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),nd=na("text"),nc=na("nl"),nu=na("url",{isLink:!0,toHref(e=nr.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==th&&e[1].t===tz}}),nh=e=>new tr(e);function np(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}let nf="u">typeof console&&console&&console.warn||(()=>{}),ng={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function nm(e,t=!1){if(ng.initialized&&nf(`linkifyjs: already initialized - will not register custom scheme "${e}" until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format.
|
|
24
|
+
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
25
|
+
2. Cannot start or end with "-"
|
|
26
|
+
3. "-" cannot repeat`);ng.customSchemes.push([e,t])}function ny(e){return ng.initialized||function(){ng.scanner=function(e=[]){let t={};tr.groups=t;let n=new tr;null==t9&&(t9=nn("aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xf6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2")),null==t7&&(t7=nn("ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2")),ta(n,"'",tO),ta(n,"{",tm),ta(n,"}",ty),ta(n,"[",tb),ta(n,"]",tx),ta(n,"(",tw),ta(n,")",tv),ta(n,"<",tS),ta(n,">",tC),ta(n,"(",tk),ta(n,")",tP),ta(n,"「",tT),ta(n,"」",tE),ta(n,"『",tI),ta(n,"』",t_),ta(n,"<",tM),ta(n,">",tA),ta(n,"&",tj),ta(n,"*",tD),ta(n,"@","AT"),ta(n,"`",tF),ta(n,"^",tR),ta(n,":",tz),ta(n,",",tN),ta(n,"$",t$),ta(n,".","DOT"),ta(n,"=",tB),ta(n,"!",tH),ta(n,"-",tU),ta(n,"%",tW),ta(n,"|",tK),ta(n,"+",tV),ta(n,"#",tY),ta(n,"?",tG),ta(n,'"',tq),ta(n,"/",tZ),ta(n,";",tJ),ta(n,"~",tQ),ta(n,"_",t0),ta(n,"\\",tL),ta(n,"・",tX);let r=to(n,t4,"NUM",{[e5]:!0});to(r,t4,r);let i=to(r,t3,tc,{[e8]:!0}),o=to(r,t5,tu,{[e9]:!0}),s=to(n,t3,tl,{[e6]:!0});to(s,t4,i),to(s,t3,s),to(i,t4,i),to(i,t3,i);let a=to(n,t5,td,{[e4]:!0});to(a,t3),to(a,t4,o),to(a,t5,a),to(o,t4,o),to(o,t3),to(o,t5,o);let l=ta(n,"\n","NL",{[tt]:!0}),d=ta(n,"\r","WS",{[tt]:!0}),c=to(n,t8,"WS",{[tt]:!0});ta(n,"",c),ta(d,"\n",l),ta(d,"",c),to(d,t8,c),ta(c,"\r"),ta(c,"\n"),to(c,t8,c),ta(c,"",c);let u=to(n,t6,t1,{[te]:!0});ta(u,"#"),to(u,t6,u),ta(u,"️",u);let h=ta(u,"");ta(h,"#"),to(h,t6,u);let p=[[t3,s],[t4,i]],f=[[t3,null],[t5,a],[t4,o]];for(let e=0;e<t9.length;e++)nt(n,t9[e],"TLD",tl,p);for(let e=0;e<t7.length;e++)nt(n,t7[e],tp,td,f);tn("TLD",{tld:!0,ascii:!0},t),tn(tp,{utld:!0,alpha:!0},t),nt(n,"file",tf,tl,p),nt(n,"mailto",tf,tl,p),nt(n,"http",tg,tl,p),nt(n,"https",tg,tl,p),nt(n,"ftp",tg,tl,p),nt(n,"ftps",tg,tl,p),tn(tf,{scheme:!0,ascii:!0},t),tn(tg,{slashscheme:!0,ascii:!0},t),e=e.sort((e,t)=>e[0]>t[0]?1:-1);for(let t=0;t<e.length;t++){let r=e[t][0],i=e[t][1]?{scheme:!0}:{slashscheme:!0};r.indexOf("-")>=0?i[e7]=!0:t3.test(r)?t4.test(r)?i[e8]=!0:i[e6]=!0:i[e5]=!0,ts(n,r,r,i)}return ts(n,"localhost",th,{ascii:!0}),n.jd=new tr("SYM"),{start:n,tokens:Object.assign({groups:t},t2)}}(ng.customSchemes);for(let e=0;e<ng.tokenQueue.length;e++)ng.tokenQueue[e][1]({scanner:ng.scanner});ng.parser=function({groups:e}){let t=e.domain.concat([tj,tD,"AT",tL,tF,tR,t$,tB,tU,"NUM",tW,tK,tV,tY,tZ,"SYM",tQ,t0]),n=[tO,tz,tN,"DOT",tH,tW,tG,tq,tJ,tS,tC,tm,ty,tx,tb,tw,tv,tk,tP,tT,tE,tI,t_,tM,tA],r=[tj,tO,tD,tL,tF,tR,t$,tB,tU,tm,ty,tW,tK,tV,tY,tG,tZ,"SYM",tQ,t0],i=nh(),o=ta(i,tQ);ti(o,r,o),ti(o,e.domain,o);let s=nh(),a=nh(),l=nh();ti(i,e.domain,s),ti(i,e.scheme,a),ti(i,e.slashscheme,l),ti(s,r,o),ti(s,e.domain,s);let d=ta(s,"AT");ta(o,"AT",d),ta(a,"AT",d),ta(l,"AT",d);let c=ta(o,"DOT");ti(c,r,o),ti(c,e.domain,o);let u=nh();ti(d,e.domain,u),ti(u,e.domain,u);let h=ta(u,"DOT");ti(h,e.domain,u);let p=nh(nl);ti(h,e.tld,p),ti(h,e.utld,p),ta(d,th,p);let f=ta(u,tU);ta(f,tU,f),ti(f,e.domain,u),ti(p,e.domain,u),ta(p,"DOT",h),ta(p,tU,f);let g=ta(s,tU),m=ta(s,"DOT");ta(g,tU,g),ti(g,e.domain,s),ti(m,r,o),ti(m,e.domain,s);let y=nh(nu);ti(m,e.tld,y),ti(m,e.utld,y),ti(y,e.domain,s),ti(y,r,o),ta(y,"DOT",m),ta(y,tU,g),ta(y,"AT",d);let b=ta(y,tz),x=nh(nu);ti(b,e.numeric,x);let w=nh(nu),v=nh();ti(w,t,w),ti(w,n,v),ti(v,t,w),ti(v,n,v),ta(y,tZ,w),ta(x,tZ,w);let S=ta(a,tz),C=ta(l,tz),k=ta(C,tZ),P=ta(k,tZ);ti(a,e.domain,s),ta(a,"DOT",m),ta(a,tU,g),ti(l,e.domain,s),ta(l,"DOT",m),ta(l,tU,g),ti(S,e.domain,w),ta(S,tZ,w),ta(S,tG,w),ti(P,e.domain,w),ti(P,t,w),ta(P,tZ,w);let T=[[tm,ty],[tb,tx],[tw,tv],[tS,tC],[tk,tP],[tT,tE],[tI,t_],[tM,tA]];for(let e=0;e<T.length;e++){let[r,i]=T[e],o=ta(w,r);ta(v,r,o);let s=nh(nu);ti(o,t,s);let a=nh();ti(o,n,a),ta(o,i,w),ti(s,t,s),ti(s,n,a),ti(a,t,s),ti(a,n,a),ta(s,i,w),ta(a,i,w)}return ta(i,th,y),ta(i,"NL",nc),{start:i,tokens:t2}}(ng.scanner.tokens);for(let e=0;e<ng.pluginQueue.length;e++)ng.pluginQueue[e][1]({scanner:ng.scanner,parser:ng.parser});ng.initialized=!0}(),function(e,t,n){let r=n.length,i=0,o=[],s=[];for(;i<r;){let a=e,l=null,d=null,c=0,u=null,h=-1;for(;i<r&&!(l=a.go(n[i].t));)s.push(n[i++]);for(;i<r&&(d=l||a.go(n[i].t));)l=null,(a=d).accepts()?(h=0,u=a):h>=0&&h++,i++,c++;if(h<0)(i-=c)<r&&(s.push(n[i]),i++);else{s.length>0&&(o.push(np(nd,t,s)),s=[]),i-=h,c-=h;let e=u.t,r=n.slice(i-c,i);o.push(np(e,t,r))}}return s.length>0&&o.push(np(nd,t,s)),o}(ng.parser.start,e,ne(ng.scanner.start,e))}function nb(e,t=null,n=null){if(t&&"object"==typeof t){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}let r=new ni(n),i=ny(e),o=[];for(let e=0;e<i.length;e++){let n=i[e];n.isLink&&(!t||n.t===t)&&r.check(n)&&o.push(n.toFormattedObject(r))}return o}ny.scan=ne;let nx="[\0- \xa0 -\u2029 ]",nw=new RegExp(nx),nv=RegExp(`${nx}$`),nS=RegExp(nx,"g"),nC=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,nk=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function nP(e,t){let n=0;for(let r=t-1;r>=0&&"\\"===e[r];r-=1)n+=1;return n%2==1}function nT(e,t,n){var r,i;let[,o,s]=t;return!((t.index?e[t.index-1]:void 0)==="!"||nP(e,null!=(r=t.index)?r:0)||function(e,t){let n=0,r=0;for(;r<t;){if("`"!==e[r]||0===n&&nP(e,r)){r+=1;continue}let i=0;for(;r<t&&"`"===e[r];)i+=1,r+=1;0===n?n=i:i===n&&(n=0)}return n>0}(e,null!=(i=t.index)?i:0))&&!!o.trim()&&n(s)}function nE(e){var t,n;let[r,i,o,,s,a,l]=e,d=null!=(t=null!=s?s:a)?t:l;return{index:null!=(n=e.index)?n:0,text:r,replaceWith:i,data:{href:o,title:d||null,markdown:!0}}}function nI(e){var t,n,r;return{href:null==(t=e.data)?void 0:t.href,title:null!=(n=null==(r=e.data)?void 0:r.title)?n:null}}function n_(e,t){let n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return t&&t.forEach(e=>{let t="string"==typeof e?e:e.scheme;t&&n.push(t)}),!e||e.replace(nS,"").match(RegExp(`^(?:(?:${n.map(e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}let nM=eP.CU.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{"string"==typeof e?nm(e):nm(e.scheme,e.optionalSlashes)})},onDestroy(){tr.groups={},ng.scanner=null,ng.parser=null,ng.tokenQueue=[],ng.pluginQueue=[],ng.customSchemes=[],ng.initialized=!1},inclusive(){return this.options.autolink},addOptions:()=>({openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(e,t)=>!!n_(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes("@"))return!0;let r=(e.includes("@")?e.split("@").pop():e).split(/[/?#:]/)[0];return!/^\d{1,3}(\.\d{1,3}){3}$/.test(r)&&!!/\./.test(r)}}),addAttributes(){var e,t,n;return{href:{default:null,parseHTML:e=>e.getAttribute("href")},target:{default:null!=(e=this.options.HTMLAttributes.target)?e:null},rel:{default:null!=(t=this.options.HTMLAttributes.rel)?t:null},class:{default:null!=(n=this.options.HTMLAttributes.class)?n:null},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:e=>{let t=e.getAttribute("href");return!!t&&!!this.options.isAllowedUri(t,{defaultValidate:e=>!!n_(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})&&null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!n_(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",(0,eP.KV)(this.options.HTMLAttributes,e),0]:["a",(0,eP.KV)(this.options.HTMLAttributes,{...e,href:""}),0]},markdownTokenName:"link",parseMarkdown:(e,t)=>t.applyMark("link",t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{var n,r,i,o;let s=null!=(n=null==(r=e.attrs)?void 0:r.href)?n:"",a=null!=(i=null==(o=e.attrs)?void 0:o.title)?i:"",l=t.renderChildren(e);return a?`[${l}](${s} "${a}")`:`[${l}](${s})`},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return!!this.options.isAllowedUri(n,{defaultValidate:e=>!!n_(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})&&t().setMark(this.name,e).setMeta("preventAutolink",!0).run()},toggleLink:e=>({chain:t})=>{let{href:n}=e||{};return(!n||!!this.options.isAllowedUri(n,{defaultValidate:e=>!!n_(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}))&&t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addInputRules(){var e;let t;return this.options.markdownLinks?[(e={type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!n_(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})},t=(0,eP.OX)({find:t=>{let n=nC.exec(t);return n&&nT(t,n,e.isAllowedHref)?nE(n):null},type:e.type,getAttributes:nI}),new eP.fV({find:t.find,handler:e=>{let n=t.handler(e);return null!==n&&e.state.tr.steps.length&&e.state.tr.setMeta("preventAutolink",!0),n}}))]:[]},addPasteRules(){let e=e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options;nb(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!n_(e,n),protocols:n,defaultProtocol:r})).forEach(e=>{this.options.shouldAutoLink(e.value)&&t.push({text:e.value,data:{href:e.href},index:e.start})})}return t};if(this.options.markdownLinks){var t;let n;return[(t={type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!n_(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:e},n=(0,eP.Zc)({find:e=>{var n,r;let i=[];for(let n of e.matchAll(nk))nT(e,n,t.isAllowedHref)&&i.push(nE(n));let o=(null!=(n=null==(r=t.findPlainUrls)?void 0:r.call(t,e))?n:[]).filter(e=>!i.some(t=>t.index<e.index+e.text.length&&e.index<t.index+t.text.length));return[...i,...o]},type:t.type,getAttributes:nI}),new eP._n({find:n.find,handler:e=>{var t;let r=n.handler(e);return null!==r&&e.state.tr.steps.length&&(null==(t=e.match.data)?void 0:t.markdown)&&e.state.tr.setMeta("preventAutolink",!0),r}}))]}return[(0,eP.Zc)({find:e,type:this.type,getAttributes:e=>{var t;return{href:null==(t=e.data)?void 0:t.href}}})]},addProseMirrorPlugins(){var e,t,n;let r=[],{protocols:i,defaultProtocol:o}=this.options;return this.options.autolink&&r.push((e={type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!n_(e,i),protocols:i,defaultProtocol:o}),shouldAutoLink:this.options.shouldAutoLink},new eO.k_({key:new eO.hs("autolink"),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),o=t.some(e=>e.getMeta("preventAutolink"));if(!i||o)return;let{tr:s}=r,a=(0,eP.T7)(n.doc,[...t]);if((0,eP.FF)(a).forEach(({newRange:t})=>{let n,i,o=(0,eP.Nx)(r.doc,t,e=>e.isTextblock);if(o.length>1)n=o[0],i=r.doc.textBetween(n.pos,n.pos+n.node.nodeSize,void 0," ");else if(o.length){let e=r.doc.textBetween(t.from,t.to," "," ");if(!nv.test(e))return;n=o[0],i=r.doc.textBetween(n.pos,t.to,void 0," ")}if(n&&i){let t=i.split(nw).filter(Boolean);if(t.length<=0)return!1;let o=t[t.length-1],a=n.pos+i.lastIndexOf(o);if(!o)return!1;let l=ny(o).map(t=>t.toObject(e.defaultProtocol));if(!(1===l.length?l[0].isLink:3===l.length&&!!l[1].isLink&&["()","[]"].includes(l[0].value+l[2].value)))return!1;l.filter(e=>e.isLink).map(e=>({...e,from:a+e.start+1,to:a+e.end+1})).filter(e=>!r.schema.marks.code||!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code)).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{(0,eP.hO)(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||s.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),s.steps.length)return s}}))),r.push((t={type:this.type,editor:this.editor,openOnClick:"whenNotEditable"===this.options.openOnClick||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection},new eO.k_({key:new eO.hs("handleClickLink"),props:{handleClick:(e,n,r)=>{if(0!==r.button||!e.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let e=r.target;if(!e)return!1;let n=t.editor.view.dom;(i=e.closest("a"))&&!n.contains(i)&&(i=null)}if(!i)return!1;let o=!1;if(t.enableClickSelection&&(o=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){var s,a;let n=(0,eP.gu)(e.state,t.type.name),r=null!=(s=i.href)?s:n.href,l=null!=(a=i.target)?a:n.target;r&&(window.open(r,l),o=!0)}return o}}}))),this.options.linkOnPaste&&r.push((n={editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink},new eO.k_({key:new eO.hs("handlePasteLink"),props:{handlePaste:(e,t,r)=>{let{shouldAutoLink:i}=n,{state:o}=e,{selection:s}=o,{empty:a}=s;if(a)return!1;let l="";r.content.forEach(e=>{l+=e.textContent});let d=nb(l,{defaultProtocol:n.defaultProtocol}).find(e=>e.isLink&&e.value===l);return!!l&&!!d&&(void 0===i||!!i(d.value))&&n.editor.commands.setMark(n.type,{href:d.href})}}}))),r}}),nA="textStyle",nj=/^\s*([-+*])\s$/,nO=eP.bP.create({name:"bulletList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML:()=>[{tag:"ul"}],renderHTML({HTMLAttributes:e}){return["ul",(0,eP.KV)(this.options.HTMLAttributes,e),0]},markdownTokenName:"list",parseMarkdown:(e,t)=>"list"!==e.type||e.ordered?[]:{type:"bulletList",content:e.items?t.parseChildren(e.items):[]},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,"\n"):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(nA)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=(0,eP.tG)({find:nj,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=(0,eP.tG)({find:nj,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(nA),editor:this.editor})),[e]}}),nD=(e,t)=>eP.YY.create({name:`${e}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>{let n;return n=this.editor,((e,t,n,r)=>{let i=((e,t,n)=>{let{selection:r}=e;if(!r.empty)return null;let{$from:i}=r;if(!i.parent.isTextblock||i.parentOffset!==i.parent.content.size)return null;let o=-1;for(let e=i.depth;e>0;e-=1)if(i.node(e).type.name===t){o=e;break}if(o<0)return null;let s=i.node(o),a=i.index(o);if(a+1>=s.childCount)return null;let l=s.child(a+1);if(!n.includes(l.type.name))return null;let d=e.schema.nodes[t],c=!1;if(l.forEach(e=>{e.type===d&&e.childCount>1&&(c=!0)}),!c)return null;let u=e.doc.resolve(i.after()).nodeAfter;if(!u||!n.includes(u.type.name))return null;let h=[];return(u.forEach(e=>{h.push(e)}),0===h.length)?null:{listItemDepth:o,nestedList:u,nestedListPos:i.after(),insertPos:i.after(o),items:h}})(e,n,r);if(!i)return!1;let{selection:o}=e,{nestedList:s,nestedListPos:a,insertPos:l,items:d}=i,c=e.tr;c.delete(a,a+s.nodeSize);let u=c.mapping.map(l);return c.insert(u,ej.FK.from(d)),c.setSelection(o.map(c.doc,c.mapping)),t&&t(c),!0})(n.state,n.view.dispatch,e,t)};return{Delete:n,"Mod-Delete":n}}}),nL=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],nF="abcdefghijklmnopqrstuvwxyz",nR=String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`;function nz(e){let t=e,n="";for(let[e,r]of nL)for(;t>=e;)n+=r,t-=e;return n}function nN(e){return nz(e).toUpperCase()}function n$(e){let t=e.toLowerCase(),n=0,r=0;for(;n<t.length;){let e=!1;for(let[i,o]of nL)if(t.startsWith(o,n)){r+=i,n+=o.length,e=!0;break}if(!e)return 0}return r}function nB(e){if(e<=26)return nF[e-1];let t=Math.floor((e-1)/26)-1,n=(e-1)%26;return t<0?nF[n]:nF[t]+nF[n]}function nH(e){if(!(!e||/^\d+$/.test(e))){if(function(e){if(!/^[ivxlcdmIVXLCDM]+$/.test(e))return!1;let t=n$(e);return!(t<=0)&&(e===e.toLowerCase()?nz(t):nN(t))===e}(e))return e===e.toLowerCase()?"i":"I";if(/^[a-z]{1,2}$/.test(e))return"a";if(/^[A-Z]{1,2}$/.test(e))return"A"}}function nU(e){if(/^\d+$/.test(e))return parseInt(e,10);let t=nH(e);if("i"===t||"I"===t)return n$(e);if("a"===t||"A"===t){let t,n=1===(t=e.toLowerCase()).length?t.charCodeAt(0)-97+1:2===t.length?(t.charCodeAt(0)-97+1)*26+(t.charCodeAt(1)-97)+1:0;return n>0?n:1}let n=parseInt(e,10);return Number.isNaN(n)?1:n}let nW=eP.bP.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:e}){return["li",(0,eP.KV)(this.options.HTMLAttributes,e),0]},markdownTokenName:"list_item",parseMarkdown:(e,t)=>{var n,r,i,o;if("list_item"!==e.type)return[];let s=null!=(n=t.parseBlockChildren)?n:t.parseChildren,a=[];if(e.tokens&&e.tokens.length>0){let n;if(n=null==(r=e.tokens)?void 0:r[0],e.text&&(null==(i=e.tokens)?void 0:i.length)===1&&(null==n?void 0:n.type)==="list"&&n.ordered&&n.raw===e.text)return{type:"listItem",content:[{type:"paragraph",content:(o=e.text||"",t.tokenizeInline?t.parseInline(t.tokenizeInline(o)):t.parseInline([{type:"text",raw:o,text:o}]))}]};if(e.tokens.some(e=>"paragraph"===e.type))a=s(e.tokens);else{let n=e.tokens[0];if(n&&"text"===n.type&&n.tokens&&n.tokens.length>0){if(a=[{type:"paragraph",content:t.parseInline(n.tokens)}],e.tokens.length>1){let t=s(e.tokens.slice(1));a.push(...t)}}else a=s(e.tokens)}}return 0===a.length&&(a=[{type:"paragraph",content:[]}]),{type:"listItem",content:a}},renderMarkdown:(e,t,n)=>(0,eP.kj)(e,t,e=>{if("bulletList"===e.parentType)return"- ";if("orderedList"===e.parentType){var t,n;let r=(null==(t=e.meta)||null==(t=t.parentAttrs)?void 0:t.start)||1;return function(e,t,n=". "){let r=t+1;if(!e||"1"===e)return`${r}${n}`;switch(e){case"a":return`${nB(r)}${n}`;case"A":return`${nB(r).toUpperCase()}${n}`;case"i":return`${nz(r)}${n}`;case"I":return`${nN(r)}${n}`;default:return`${r}${n}`}}(null==(n=e.meta)||null==(n=n.parentAttrs)?void 0:n.type,r-1+(e.index||0),". ")}return"- "},n),addExtensions(){return[nD(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),nK=(e,t)=>{let{$from:n}=t.selection,r=(0,eP.Pg)(e,t.schema),i=n.depth,o=n.pos,s=null;for(;i>0&&null===s;)n.node(i).type===r?s=i:(i-=1,o-=1);return null===s?null:{$pos:t.doc.resolve(o),depth:s}},nV=(e,t)=>{let n=nK(e,t);if(!n)return!1;let[,r]=(0,eP.fl)(t,e,n.$pos.pos+4);return r},nY=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!(0,eP.rU)(e.state,t)&&((e,t)=>{let{$anchor:n}=e.selection,r=Math.max(0,n.pos-2),i=e.doc.resolve(r).node();return!!i&&!!t.includes(i.type.name)})(e.state,n)){let{$anchor:n}=e.state.selection,r=e.state.doc.resolve(n.before()-1),i=[];r.node().descendants((e,n)=>{e.type.name===t&&i.push({node:e,pos:n})});let o=i.at(-1);if(!o)return!1;let s=e.state.doc.resolve(r.start()+o.pos+1);return e.chain().cut({from:n.start()-1,to:n.end()+1},s.end()).joinForward().run()}if(!(0,eP.rU)(e.state,t)||!(0,eP.J_)(e.state))return!1;let{$from:r}=e.state.selection,i=r.depth-1;return r.node(i).type===e.schema.nodes[t]&&0===r.index(i)&&e.chain().liftListItem(t).run()},nG=(e,t)=>{var n,r;let i,o,s,a;if(!(0,eP.rU)(e.state,t)||!(0,eP.QN)(e.state,t))return!1;let{selection:l}=e.state,{$from:d,$to:c}=l;return!(!l.empty&&d.sameParent(c))&&((i=nV(t,n=e.state),(o=nK(t,n))&&i&&(i>o.depth||0))?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():(s=nV(t,r=e.state),(a=nK(t,r))&&s&&(s<a.depth||0))?e.chain().joinForward().joinBackward().run():e.commands.joinItemForward())},nq=(e,t,n)=>{let{state:r}=e,{selection:i}=r;if(!i.empty)return!1;let{$from:o}=i;if(0!==o.parentOffset||!o.parent.isTextblock||(0,eP.rU)(r,t))return!1;let s=(0,eP.H_)(o);if(!s||!n.includes(s.type.name))return!1;let a=s.lastChild;if(!a||a.type.name!==t)return!1;let l=o.parent;if(!a.canReplace(a.childCount,a.childCount,ej.FK.from(l)))return!1;let d=o.before(),c=o.after(),u=d-2;return e.commands.command(({tr:e,dispatch:t})=>(t&&(e.delete(d,c).insert(u,ej.FK.from(l)),e.setSelection(eO.U3.create(e.doc,u+1)),e.scrollIntoView()),!0))},nX=eP.YY.create({name:"listKeymap",addOptions:()=>({listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}),addKeyboardShortcuts(){return{Delete:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{void 0!==e.state.schema.nodes[n]&&nG(e,n)&&(t=!0)}),t},"Mod-Delete":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{void 0!==e.state.schema.nodes[n]&&nG(e,n)&&(t=!0)}),t},Backspace:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{void 0!==e.state.schema.nodes[n]&&nY(e,n,r)&&(t=!0)}),t},"Mod-Backspace":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{void 0!==e.state.schema.nodes[n]&&nY(e,n,r)&&(t=!0)}),t},Tab:({editor:e})=>{for(let{itemName:t,wrapperNames:n}of this.options.listTypes)if(void 0!==e.state.schema.nodes[t]&&nq(e,t,n))return!0;return!1}}}}),nJ=RegExp(`^(\\s*)(${nR})([.)])\\s+(.*)$`),nZ=/^\s/,nQ={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/},n0=RegExp(`^(${nR})([.)])\\s+(.+)$`),n1="textStyle",n2=/^(\d+)\.\s$/;function n3(e){let t=e.match(/list-style-type\s*:\s*([^;]+)/i);if(!t)return null;switch(t[1].trim().toLowerCase()){case"upper-roman":return"I";case"lower-roman":return"i";case"upper-alpha":case"upper-latin":return"A";case"lower-alpha":case"lower-latin":return"a";default:return null}}let n5=eP.bP.create({name:"orderedList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes:()=>({start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:null,parseHTML:e=>{let t=e.getAttribute("type");if(t)return t;let n=e.getAttribute("style");if(n){let e=n3(n);if(e)return e}let r=e.querySelector("li");if(r){let e=r.getAttribute("style");if(e){let t=n3(e);if(t)return t}}return null}}}),parseHTML:()=>[{tag:"ol"}],renderHTML({HTMLAttributes:e}){let{start:t,type:n,...r}=e,i=(0,eP.KV)(this.options.HTMLAttributes,r);return 1!==t&&(i.start=t),n&&"1"!==n&&(i.type=n),["ol",i,0]},markdownTokenName:"list",parseMarkdown:(e,t)=>{var n;if("list"!==e.type||!e.ordered)return[];let r=e.start||1,i=e.typeMarker,o=e.items?(n=e.items,n.map(e=>{if("list_item"!==e.type)return t.parseChildren([e])[0];let n=[];return e.tokens&&e.tokens.length>0&&e.tokens.forEach(e=>{if("paragraph"===e.type||"list"===e.type||"blockquote"===e.type||"code"===e.type)n.push(...t.parseChildren([e]));else if("text"===e.type&&e.tokens){let r=t.parseChildren([e]);n.push({type:"paragraph",content:r})}else{let r=t.parseChildren([e]);r.length>0&&n.push(...r)}}),{type:"listItem",content:n}})):[],s={};return(1!==r&&(s.start=r),i&&(s.type=i),Object.keys(s).length>0)?{type:"orderedList",attrs:s,content:o}:{type:"orderedList",content:o}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,"\n"):"",markdownTokenizer:{name:"orderedList",level:"block",start:()=>-1,tokenize:(e,t,n)=>{var r,i;let o=e.split("\n"),[s,a]=function(e){let t=[],n=0,r=0;for(;n<e.length;){let i=e[n],o=i.match(nJ);if(!o)break;let[,s,a,l,d]=o,c=s.length,u=parseInt(a,10),h=isNaN(u)?nH(a):void 0,p=isNaN(u)?nU(a):u,f=[d],g=n+1,m=[i],y=!1;for(;g<e.length;){let t=e[g];if(t.match(nJ))break;if(""===t.trim())m.push(t),f.push(""),y=!0,g+=1;else if(t.match(nZ)){let e=t.length-t.trimStart().length,n=c+a.length+1;m.push(t),f.push(t.slice(Math.min(e,n))),g+=1}else{if(y||function(e){return Object.values(nQ).some(t=>t.test(e))}(t))break;m.push(t),f.push(t),g+=1}}t.push({indent:c,number:p,type:h,content:f.join("\n").trim(),contentLines:f,raw:m.join("\n")}),r=g,n=g}return[t,r]}(o);if(0===s.length)return;let l=function e(t,n,r){let i=[],o=0;for(;o<t.length;){let s=t[o];if(s.indent===n){let{paragraphLines:a,blockLines:l}=function(e){let t=[],n=[],r=!1;return e.forEach(e=>{let i;if(r)return void n.push(e);if(""===e.trim()||t.length>0&&(i=e.trimStart(),nQ.bulletItem.test(i)||nJ.test(i.trimStart())||nQ.heading.test(i)||nQ.thematicBreak.test(i)&&!i.startsWith("-")||/^>\s?/.test(i)||nQ.codeFence.test(i)||nQ.blockMath.test(i))){r=!0,n.push(e);return}t.push(e)}),{paragraphLines:t,blockLines:n}}(s.contentLines),d=a.join("\n").trim(),c=[];d&&c.push({type:"paragraph",raw:d,tokens:r.inlineTokens(d)});let u=l.join("\n").trim();if(u){let e=r.blockTokens(u);c.push(...e)}let h=o+1,p=[];for(;h<t.length&&t[h].indent>n;)p.push(t[h]),h+=1;if(p.length>0){let t=e(p,Math.min(...p.map(e=>e.indent)),r);c.push({type:"list",ordered:!0,start:p[0].number,typeMarker:p[0].type,items:t,raw:p.map(e=>e.raw).join("\n")})}i.push({type:"list_item",raw:s.raw,tokens:c}),o=h}else o+=1}return i}(s,s[0].indent,n);if(0!==l.length)return{type:"list",ordered:!0,start:(null==(r=s[0])?void 0:r.number)||1,typeMarker:null==(i=s[0])?void 0:i.type,items:l,raw:o.slice(0,a).join("\n")}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(n1)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins:()=>[new eO.k_({props:{handlePaste:(e,t)=>{var n,r;let i=null==(n=t.clipboardData)?void 0:n.getData("text/html");if(null==i?void 0:i.trim())return!1;let o=null==(r=t.clipboardData)?void 0:r.getData("text/plain");if(!o)return!1;let s=function(e){let t=e.split("\n").filter(e=>e.trim().length>0);if(0===t.length)return null;let n=[];for(let e of t){let t=e.trim().match(n0);if(!t)return null;n.push({marker:t[1],content:t[3]})}return!function(e){var t;if(0===e.length)return!1;let n=null!=(t=nH(e[0]))?t:"numeric",r=nU(e[0]);if(r<1)return!1;for(let t=0;t<e.length;t++){let i=function(e,t){if("numeric"===e)return String(t);switch(e){case"a":return nB(t);case"A":return nB(t).toUpperCase();case"i":return nz(t);case"I":return nN(t);default:return String(t)}}(n,r+t);if(e[t]!==i)return!1}return!0}(n.map(e=>e.marker))?null:{type:"orderedList",attrs:function(e){let{type:t,start:n}={type:nH(e),start:nU(e)},r={};return t&&(r.type=t),1!==n&&(r.start=n),r}(n[0].marker),content:n.map(e=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:e.content}]}]}))}}(o);if(!s)return!1;try{let t=e.state.schema.nodeFromJSON(s),n=e.state.tr.replaceSelectionWith(t);return e.dispatch(n),!0}catch{return!1}}}})],addInputRules(){let e=(e,t)=>(!t.attrs.type||"1"===t.attrs.type)&&t.childCount+t.attrs.start===+e[1],t=(0,eP.tG)({find:n2,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=(0,eP.tG)({find:n2,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(n1)}),joinPredicate:e,editor:this.editor})),[t]}}),n6=/^\s*(\[([( |x])?\])\s$/,n4=eP.bP.create({name:"taskItem",addOptions:()=>({nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}),content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes:()=>({checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute("data-checked");return""===t||"true"===t},renderHTML:e=>({"data-checked":e.checked})}}),parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:e=>{var t;return null!=(t=e.querySelector("div"))?t:e}}]},renderHTML({node:e,HTMLAttributes:t}){return["li",(0,eP.KV)(this.options.HTMLAttributes,t,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:e.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode("paragraph",{},t.parseInline(e.tokens))):e.text?n.push(t.createNode("paragraph",{},[t.createNode("text",{text:e.text})])):n.push(t.createNode("paragraph",{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode("taskItem",{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>{var n;let r=`- [${(null==(n=e.attrs)?void 0:n.checked)?"x":" "}] `;return(0,eP.kj)(e,t,r)},addExtensions(){return this.options.nested?[nD(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let i=document.createElement("li"),o=document.createElement("label"),s=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div");s.style.cssText="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0";let d=e=>{var t,n,r;let i=(t=e.attrs.checked,(null==(n=this.options.a11y)||null==(r=n.checkboxLabel)?void 0:r.call(n,e,t))||`Task item checkbox for ${e.textContent||"empty task item"}`);a.setAttribute("aria-label",i),s.textContent=i};d(e),o.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",e=>e.preventDefault()),a.addEventListener("change",t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}let{checked:i}=t.target;r.isEditable&&"function"==typeof n&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if("number"!=typeof t)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...null==r?void 0:r.attrs,checked:i}),!0}).run(),r.isEditable||!this.options.onReadOnlyChecked||this.options.onReadOnlyChecked(e,i)||(a.checked=!a.checked)}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,a.checked=e.attrs.checked,o.append(a,s),i.append(o,l),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let c=new Set(Object.keys(t));return{dom:i,contentDOM:l,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,a.checked=e.attrs.checked,d(e);let t=r.extensionManager.attributes,n=(0,eP.zU)(e,t),o=new Set(Object.keys(n)),s=this.options.HTMLAttributes;return c.forEach(e=>{o.has(e)||(e in s?i.setAttribute(e,s[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{null==t?e in s?i.setAttribute(e,s[e]):i.removeAttribute(e):i.setAttribute(e,t)}),c=o,!0}}}},addInputRules(){return[(0,eP.tG)({find:n6,type:this.type,getAttributes:e=>({checked:"x"===e[e.length-1]})})]}}),n8=eP.bP.create({name:"taskList",addOptions:()=>({itemTypeName:"taskItem",HTMLAttributes:{}}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return["ul",(0,eP.KV)(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode("taskList",{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,"\n"):"",markdownTokenizer:{name:"taskList",level:"block",start(e){var t;let n=null==(t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))?void 0:t.index;return void 0!==n?n:-1},tokenize(e,t,n){let r=e=>{let t=(0,eP.Dd)(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:"x"===e[3].toLowerCase()}),createToken:(e,t)=>({type:"taskItem",raw:"",mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(t){let r={type:"taskList",raw:t.raw,items:t.items},i=e.slice(t.raw.length);return i.trim()?[r,...n.blockTokens(i)]:[r]}return n.blockTokens(e)},i=(0,eP.Dd)(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:"x"===e[3].toLowerCase()}),createToken:(e,t)=>({type:"taskItem",raw:"",mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});eP.YY.create({name:"listKit",addExtensions(){let e=[];return!1!==this.options.bulletList&&e.push(nO.configure(this.options.bulletList)),!1!==this.options.listItem&&e.push(nW.configure(this.options.listItem)),!1!==this.options.listKeymap&&e.push(nX.configure(this.options.listKeymap)),!1!==this.options.orderedList&&e.push(n5.configure(this.options.orderedList)),!1!==this.options.taskItem&&e.push(n4.configure(this.options.taskItem)),!1!==this.options.taskList&&e.push(n8.configure(this.options.taskList)),e}});let n9=" ",n7=eP.bP.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:e}){return["p",(0,eP.KV)(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(1===n.length&&"image"===n[0].type)return t.parseChildren([n[0]]);let r=t.parseInline(n);return 1===n.length&&"text"===n[0].type&&(n[0].raw===n9||n[0].text===n9||"\xa0"===n[0].raw||"\xa0"===n[0].text)&&1===r.length&&"text"===r[0].type&&(r[0].text===n9||"\xa0"===r[0].text)?t.createNode("paragraph",void 0,[]):t.createNode("paragraph",void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return"";let r=Array.isArray(e.content)?e.content:[];if(0===r.length){var i,o;let e=Array.isArray(null==n||null==(i=n.previousNode)?void 0:i.content)?n.previousNode.content:[];return(null==n||null==(o=n.previousNode)?void 0:o.type)==="paragraph"&&0===e.length?n9:""}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),re=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,rt=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,rn=eP.CU.create({name:"strike",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>!!e.includes("line-through")&&{}}],renderHTML({HTMLAttributes:e}){return["s",(0,eP.KV)(this.options.HTMLAttributes,e),0]},markdownTokenName:"del",parseMarkdown:(e,t)=>t.applyMark("strike",t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[(0,eP.OX)({find:re,type:this.type})]},addPasteRules(){return[(0,eP.Zc)({find:rt,type:this.type})]}}),rr=eP.bP.create({name:"text",group:"inline",parseMarkdown:e=>({type:"text",text:e.text||""}),renderMarkdown:e=>e.text||""}),ri=eP.CU.create({name:"underline",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:e=>!!e.includes("underline")&&{}}],renderHTML({HTMLAttributes:e}){return["u",(0,eP.KV)(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||"underline",t.parseInline(e.tokens||[]))},renderMarkdown:(e,t)=>`++${t.renderChildren(e)}++`,markdownTokenizer:{name:"underline",level:"inline",start:e=>e.indexOf("++"),tokenize(e,t,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let i=r[2].trim();return{type:"underline",raw:r[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});var ro=n(8242);class rs{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=null!=(n=t.width)?n:1,this.color=!1===t.color?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(null!=this.cursorPos&&t.doc!=e.state.doc)if(this.lastDragEvent){let e=this.computeTarget(this.lastDragEvent);e==this.cursorPos?this.updateOverlay():this.setCursor(e)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e,t,n=this.editorView.state.doc.resolve(this.cursorPos),r=!n.parent.inlineContent,i,o=this.editorView.dom,s=o.getBoundingClientRect(),a=s.width/o.offsetWidth,l=s.height/o.offsetHeight;if(r){let e=n.nodeBefore,t=n.nodeAfter;if(e||t){let n=this.editorView.nodeDOM(this.cursorPos-(e?e.nodeSize:0));if(n){let r=n.getBoundingClientRect(),o=e?r.bottom:r.top;e&&t&&(o=(o+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*l;i={left:r.left,right:r.right,top:o-s,bottom:o+s}}}}if(!i){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;i={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let d=this.editorView.dom.offsetParent;if(!this.element&&(this.element=d.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",r),this.element.classList.toggle("prosemirror-dropcursor-inline",!r),d&&(d!=document.body||"static"!=getComputedStyle(d).position)){let n=d.getBoundingClientRect(),r=n.width/d.offsetWidth,i=n.height/d.offsetHeight;e=n.left-d.scrollLeft*r,t=n.top-d.scrollTop*i}else e=-pageXOffset,t=-pageYOffset;this.element.style.left=(i.left-e)/a+"px",this.element.style.top=(i.top-t)/l+"px",this.element.style.width=(i.right-i.left)/a+"px",this.element.style.height=(i.bottom-i.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i="function"==typeof r?r(this.editorView,t,e):r;if(!t||i)return null;let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=(0,ro.Um)(this.editorView.state.doc,o,this.editorView.dragging.slice);null!=e&&(o=e)}return o}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);null!=t&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}var ra=n(63197),rl=n(12894);class rd extends eO.LN{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return rd.valid(n)?new rd(n):eO.LN.near(n)}content(){return ej.Ji.empty}eq(e){return e instanceof rd&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if("number"!=typeof t.pos)throw RangeError("Invalid input for GapCursor.fromJSON");return new rd(e.resolve(t.pos))}getBookmark(){return new rc(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!function(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(0==n){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(0==e.childCount&&!e.inlineContent||ru(e.type))return!0;if(e.inlineContent)return!1}}return!0}(e)||!function(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(0==e.childCount&&!e.inlineContent||ru(e.type))return!0;if(e.inlineContent)return!1}}return!0}(e))return!1;let n=t.type.spec.allowGapCursor;if(null!=n)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,t,n=!1){o:for(;;){if(!n&&rd.valid(e))return e;let r=e.pos,i=null;for(let n=e.depth;;n--){let o=e.node(n);if(t>0?e.indexAfter(n)<o.childCount:e.index(n)>0){i=o.child(t>0?e.indexAfter(n):e.index(n)-1);break}if(0==n)return null;r+=t;let s=e.doc.resolve(r);if(rd.valid(s))return s}for(;;){let o=t>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!eO.nh.isSelectable(i)){e=e.doc.resolve(r+i.nodeSize*t),n=!1;continue o}break}i=o,r+=t;let s=e.doc.resolve(r);if(rd.valid(s))return s}return null}}}rd.prototype.visible=!1,rd.findFrom=rd.findGapCursorFrom,eO.LN.jsonID("gapcursor",rd);class rc{constructor(e){this.pos=e}map(e){return new rc(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return rd.valid(t)?new rd(t):eO.LN.near(t)}}function ru(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}let rh=(0,rl.K)({ArrowLeft:rp("horiz",-1),ArrowRight:rp("horiz",1),ArrowUp:rp("vert",-1),ArrowDown:rp("vert",1)});function rp(e,t){let n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,r,i){let o=e.selection,s=t>0?o.$to:o.$from,a=o.empty;if(o instanceof eO.U3){if(!i.endOfTextblock(n)||0==s.depth)return!1;a=!1,s=e.doc.resolve(t>0?s.after():s.before())}let l=rd.findGapCursorFrom(s,t,a);return!!l&&(r&&r(e.tr.setSelection(new rd(l))),!0)}}function rf(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!rd.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return!(i&&i.inside>-1&&eO.nh.isSelectable(e.state.doc.nodeAt(i.inside)))&&(e.dispatch(e.state.tr.setSelection(new rd(r))),!0)}function rg(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof rd))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=ej.FK.empty;for(let e=r.length-1;e>=0;e--)i=ej.FK.from(r[e].createAndFill(null,i));let o=e.state.tr.replace(n.pos,n.pos,new ej.Ji(i,0,0));return o.setSelection(eO.U3.near(o.doc.resolve(n.pos+1))),e.dispatch(o),!1}function rm(e){if(!(e.selection instanceof rd))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",ra.zF.create(e.doc,[ra.NZ.widget(e.selection.head,t,{key:"gapcursor"})])}var ry=function(){};ry.prototype.append=function(e){return e.length?(e=ry.from(e),!this.length&&e||e.length<200&&this.leafAppend(e)||this.length<200&&e.leafPrepend(this)||this.appendInner(e)):this},ry.prototype.prepend=function(e){return e.length?ry.from(e).append(this):this},ry.prototype.appendInner=function(e){return new rx(this,e)},ry.prototype.slice=function(e,t){return(void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t)?ry.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},ry.prototype.get=function(e){if(!(e<0)&&!(e>=this.length))return this.getInner(e)},ry.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},ry.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},ry.from=function(e){return e instanceof ry?e:e&&e.length?new rb(e):ry.empty};var rb=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(!1===e(this.values[i],r+i))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(!1===e(this.values[i],r+i))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=200)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=200)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(ry);ry.empty=new rb([]);var rx=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&!1===this.left.forEachInner(e,t,Math.min(n,i),r)||n>i&&!1===this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&!1===this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)||n<i&&!1===this.left.forEachInvertedInner(e,Math.min(t,i),n,r))return!1},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(ry);class rw{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){let n,r,i,o;if(0==this.eventCount)return null;let s=this.items.length;for(;;s--)if(this.items.get(s-1).selection){--s;break}t&&(r=(n=this.remapping(s,this.items.length)).maps.length);let a=e.tr,l=[],d=[];return this.items.forEach((e,t)=>{if(!e.step){n||(r=(n=this.remapping(s,t+1)).maps.length),r--,d.push(e);return}if(n){d.push(new rv(e.map));let t=e.step.map(n.slice(r)),i;t&&a.maybeStep(t).doc&&(i=a.mapping.maps[a.mapping.maps.length-1],l.push(new rv(i,void 0,void 0,l.length+d.length))),r--,i&&n.appendMap(i,r)}else a.maybeStep(e.step);if(e.selection)return i=n?e.selection.map(n.slice(r)):e.selection,o=new rw(this.items.slice(0,s).append(d.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:o,transform:a,selection:i}}addTransform(e,t,n,r){var i,o;let s,a=[],l=this.eventCount,d=this.items,c=!r&&d.length?d.get(d.length-1):null;for(let n=0;n<e.steps.length;n++){let i=e.steps[n].invert(e.docs[n]),o=new rv(e.mapping.maps[n],i,t),s;(s=c&&c.merge(o))&&(o=s,n?a.pop():d=d.slice(0,d.length-1)),a.push(o),t&&(l++,t=void 0),r||(c=o)}let u=l-n.depth;return u>rC&&(i=d,o=u,i.forEach((e,t)=>{if(e.selection&&0==o--)return s=t,!1}),d=i.slice(s),l-=u),new rw(d.append(a),l)}remapping(e,t){let n=new ro.X9;return this.items.forEach((t,r)=>{let i=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(e){return 0==this.eventCount?this:new rw(this.items.append(e.map(e=>new rv(e))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-t),i=e.mapping,o=e.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},r);let a=t;this.items.forEach(t=>{let r=i.getMirror(--a);if(null==r)return;o=Math.min(o,r);let l=i.maps[r];if(t.step){let o=e.steps[r].invert(e.docs[r]),d=t.selection&&t.selection.map(i.slice(a+1,r));d&&s++,n.push(new rv(l,o,d))}else n.push(new rv(l))},r);let l=[];for(let e=t;e<o;e++)l.push(new rv(i.maps[e]));let d=new rw(this.items.slice(0,r).append(l).append(n),s);return d.emptyItemCount()>500&&(d=d.compress(this.items.length-n.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{!t.step&&e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,r=[],i=0;return this.items.forEach((o,s)=>{if(s>=e)r.push(o),o.selection&&i++;else if(o.step){let e=o.step.map(t.slice(n)),s=e&&e.getMap();if(n--,s&&t.appendMap(s,n),e){let a=o.selection&&o.selection.map(t.slice(n));a&&i++;let l=new rv(s.invert(),e,a),d,c=r.length-1;(d=r.length&&r[c].merge(l))?r[c]=d:r.push(l)}}else o.map&&n--},this.items.length,0),new rw(ry.from(r.reverse()),i)}}rw.empty=new rw(ry.empty,0);class rv{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new rv(t.getMap().invert(),t,this.selection)}}}class rS{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}}let rC=20;function rk(e){let t=[];for(let n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function rP(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),o=t.map(e[r+1],-1);i<=o&&n.push(i,o)}return n}let rT=!1,rE=null;function rI(e){let t=e.plugins;if(rE!=t){rT=!1,rE=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){rT=!0;break}}return rT}let r_=new eO.hs("history"),rM=new eO.hs("closeHistory");function rA(e,t){return(n,r)=>{let i=r_.getState(n);if(!i||0==(e?i.undone:i.done).eventCount)return!1;if(r){let o=function(e,t,n){let r=rI(t),i=r_.get(t).spec.config,o=(n?e.undone:e.done).popEvent(t,r);if(!o)return null;let s=o.selection.resolve(o.transform.doc),a=(n?e.done:e.undone).addTransform(o.transform,t.selection.getBookmark(),i,r),l=new rS(n?a:o.remaining,n?o.remaining:a,null,0,-1);return o.transform.setSelection(s).setMeta(r_,{redo:n,historyState:l})}(i,n,e);o&&r(t?o.scrollIntoView():o)}return!0}}let rj=rA(!1,!0),rO=rA(!0,!0);rA(!1,!1),rA(!0,!1),eP.YY.create({name:"characterCount",addOptions:()=>({limit:null,autoTrim:!0,mode:"textSize",textCounter:e=>e.length,wordCounter:e=>e.split(" ").filter(e=>""!==e).length}),addStorage:()=>({characters:()=>0,words:()=>0}),onBeforeCreate(){this.storage.characters=e=>{let t=(null==e?void 0:e.node)||this.editor.state.doc;if("textSize"===((null==e?void 0:e.mode)||this.options.mode)){let e=t.textBetween(0,t.content.size,void 0," ");return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=(null==e?void 0:e.node)||this.editor.state.doc,n=t.textBetween(0,t.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new eO.k_({key:new eO.hs("characterCount"),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit,o=this.options.autoTrim;if(null==i||0===i||!1===o){e=!0;return}let s=this.storage.characters({node:r.doc});if(s>i){console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let t=r.tr.deleteRange(0,s-i);return e=!0,t}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||0===n||null==n)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta("paste"))return!1;let o=e.selection.$head.pos;return e.deleteRange(o-(i-n),o),!(this.storage.characters({node:e.doc})>n)}})]}});let rD=eP.YY.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[function(e={}){return new eO.k_({view:t=>new rs(t,e)})}(this.options)]}});eP.YY.create({name:"focus",addOptions:()=>({className:"has-focus",mode:"all"}),addProseMirrorPlugins(){return[new eO.k_({key:new eO.hs("focus"),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,o=[];if(!n||!r)return ra.zF.create(e,[]);let s=0;"deepest"===this.options.mode&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;s+=1}});let a=0;return e.descendants((e,t)=>!e.isText&&!!(i>=t&&i<=t+e.nodeSize-1)&&((a+=1,"deepest"===this.options.mode&&s-a>0||"shallowest"===this.options.mode&&a>1)?"deepest"===this.options.mode:void o.push(ra.NZ.node(t,t+e.nodeSize,{class:this.options.className})))),ra.zF.create(e,o)}}})]}});let rL=eP.YY.create({name:"gapCursor",addProseMirrorPlugins:()=>[new eO.k_({props:{decorations:rm,createSelectionBetween:(e,t,n)=>t.pos==n.pos&&rd.valid(n)?new rd(n):null,handleClick:rf,handleKeyDown:rh,handleDOMEvents:{beforeinput:rg}}})],extendNodeSchema(e){var t;let n={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:null!=(t=(0,eP.gk)((0,eP.iI)(e,"allowGapCursor",n)))?t:null}}}),rF="placeholder",rR=new eO.hs("tiptap__placeholder");function rz(e){let{editor:t,placeholder:n,dataAttribute:r,pos:i,node:o,isEmptyDoc:s,hasAnchor:a,classes:{emptyNode:l,emptyEditor:d}}=e,c=[l];return s&&c.push(d),ra.NZ.node(i,i+o.nodeSize,{class:c.join(" "),[r]:"function"==typeof n?n({editor:t,node:o,pos:i,hasAnchor:a}):n})}function rN(e,t){return"function"==typeof e?e(t):e}function r$({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:o,to:s}){let{anchor:a}=i,l=[],d=e.isEmpty;return r.nodesBetween(o,s,(r,i)=>{let o=a>=i&&a<=i+r.nodeSize,s=!r.isLeaf&&(0,eP.Op)(r);return r.type.isTextblock&&(o||!t.showOnlyCurrent)&&s&&l.push(rz({editor:e,isEmptyDoc:d,dataAttribute:n,hasAnchor:o,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:rN(t.emptyNodeClass,{editor:e,node:r,pos:i,hasAnchor:o})},node:r,pos:i})),t.includeChildren}),l}function rB({editor:e,options:t,dataAttribute:n,doc:r,selection:i}){if(!(e.isEditable||!t.showOnlyWhenEditable))return null;let{anchor:o}=i,s=[],a=e.isEmpty;if(t.showOnlyCurrent&&!t.includeChildren){let i=r.resolve(o),l=i.depth>0?i.node(1):i.nodeAfter,d=i.depth>0?i.before(1):o;if(l&&l.type.isTextblock&&(0,eP.Op)(l)){let r=o>=d&&o<=d+l.nodeSize;s.push(rz({editor:e,isEmptyDoc:a,dataAttribute:n,hasAnchor:r,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:rN(t.emptyNodeClass,{editor:e,node:l,pos:d,hasAnchor:r})},node:l,pos:d}))}}else s.push(...r$({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:0,to:r.content.size}));return ra.zF.create(r,s)}function rH(e,t){let n=e.resolve(t);if(0===n.depth){var r;let e=null!=(r=n.nodeAfter)?r:n.nodeBefore;if(!e)return{from:t,to:t};let i=n.nodeAfter?t:t-e.nodeSize;return{from:i,to:i+e.nodeSize}}let i=n.before(1);return{from:i,to:i+n.node(1).nodeSize}}function rU(e,t){return{from:Math.max(0,t.from-1),to:Math.min(e.content.size,t.to-1)}}function rW(e,t){return!e.selection.empty&&!(0,eP.BQ)(e.selection)&&t.isEditable}function rK({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||(null==t?void 0:t.type)===e}eP.YY.create({name:"placeholder",addOptions:()=>({emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:rF,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}),addProseMirrorPlugins(){return[function({editor:e,options:t}){let n=t.dataAttribute?`data-${t.dataAttribute.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}`:`data-${rF}`,r=t.showOnlyCurrent&&!t.includeChildren;return new eO.k_({key:rR,...r?{}:{state:function({editor:e,options:t,dataAttribute:n}){return{init(r,i){let o=rB({editor:e,options:t,dataAttribute:n,doc:i.doc,selection:i.selection});return null!=o?o:ra.zF.empty},apply:(r,i,o,s)=>r.docChanged||r.selectionSet?function({decorations:e,ranges:t,editor:n,options:r,dataAttribute:i,doc:o,selection:s}){let a=e;for(let e of t){let{from:t,to:l}=function(e,t,n){let r=Math.max(0,Math.min(e,n.content.size));return{from:r,to:Math.max(r,Math.min(t,n.content.size))}}(e.from,e.to,o),d=a.find(t,l).filter(e=>e.from>=t&&e.to<=l);d.length&&(a=a.remove(d));let c=r$({editor:n,options:r,dataAttribute:i,doc:o,selection:s,from:t,to:l});c.length&&(a=a.add(o,c))}return a}({decorations:i.map(r.mapping,r.doc),ranges:function(e,t,n){let r=[];if(e.docChanged)for(let t of(0,eP.FF)(e))r.push(...function(e,t){var n,r;let i,o=(n=t.from,r=t.to,i=[],e.forEach((e,t)=>{let o=t+e.nodeSize,s=o+1;t+1<r&&s>n&&i.push({from:t,to:o})}),i);return o.push(rU(e,rH(e,t.from))),t.to>t.from?o.push(rU(e,rH(e,Math.min(t.to,e.content.size+1)-1))):t.from<e.content.size+1&&o.push(rU(e,rH(e,Math.min(t.from+1,e.content.size)))),o}(n.doc,t.newRange));return e.selectionSet&&(r.push(rU(n.doc,rH(n.doc,e.mapping.map(t.selection.anchor)))),r.push(rU(n.doc,rH(n.doc,n.selection.anchor)))),function(e){if(0===e.length)return[];let t=[...e].sort((e,t)=>e.from-t.from),n=[{...t[0]}];for(let e=1;e<t.length;e+=1){let r=n[n.length-1],i=t[e];i.from<=r.to?r.to=Math.max(r.to,i.to):n.push({...i})}return n}(r)}(r,o,s),editor:e,options:t,dataAttribute:n,doc:s.doc,selection:s.selection}):i}}({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:r,selection:i})=>rB({editor:e,options:t,dataAttribute:n,doc:r,selection:i}):n=>{var r;return t.showOnlyWhenEditable&&!e.isEditable?ra.zF.empty:null!=(r=rR.getState(n))?r:ra.zF.empty}}})}({editor:this.editor,options:this.options})]}}),eP.YY.create({name:"selection",addOptions:()=>({className:"selection"}),addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new eO.k_({key:new eO.hs("selection"),props:{decorations:n=>!rW(n,e)||e.isFocused||e.view.dragging?null:ra.zF.create(n.doc,[ra.NZ.inline(n.selection.from,n.selection.to,{class:t.className})]),handleDOMEvents:{blur(t){var n;return!!rW(t.state,e)&&(null==(n=window.getSelection())||n.removeAllRanges(),!1)},focus:t=>!!rW(t.state,e)&&(requestAnimationFrame(()=>{!e.isDestroyed&&t.hasFocus()&&t.focus()}),!1)}}})]}});let rV=eP.YY.create({name:"trailingNode",addOptions:()=>({node:void 0,notAfter:[]}),addProseMirrorPlugins(){var e;let t=new eO.hs(this.name),n=this.options.node||(null==(e=this.editor.schema.topNodeType.contentMatch.defaultType)?void 0:e.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(n).includes(e.name));return[new eO.k_({key:t,appendTransaction:(e,r,i)=>{let{doc:o,tr:s,schema:a}=i,l=t.getState(i),d=o.content.size,c=a.nodes[n];if(!e.some(e=>e.getMeta("skipTrailingNode"))&&l)return s.insert(d,c.create())},state:{init:(e,t)=>!rK({node:t.tr.doc.lastChild,types:r}),apply:(e,t)=>!e.docChanged||e.getMeta("__uniqueIDTransaction")?t:!rK({node:e.doc.lastChild,types:r})}})]}}),rY=eP.YY.create({name:"undoRedo",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:e,dispatch:t})=>rj(e,t),redo:()=>({state:e,dispatch:t})=>rO(e,t)}),addProseMirrorPlugins(){return[function(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new eO.k_({key:r_,state:{init:()=>new rS(rw.empty,rw.empty,null,0,-1),apply:(t,n,r)=>(function(e,t,n,r){let i=n.getMeta(r_),o;if(i)return i.historyState;n.getMeta(rM)&&(e=new rS(e.done,e.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(s&&s.getMeta(r_))if(s.getMeta(r_).redo)return new rS(e.done.addTransform(n,void 0,r,rI(t)),e.undone,rk(n.mapping.maps),e.prevTime,e.prevComposition);else return new rS(e.done,e.undone.addTransform(n,void 0,r,rI(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))if(o=n.getMeta("rebased"))return new rS(e.done.rebased(n,o),e.undone.rebased(n,o),rP(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new rS(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),rP(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let i=n.getMeta("composition"),o=0==e.prevTime||!s&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}(n,e.prevRanges)),a=s?rP(e.prevRanges,n.mapping):rk(n.mapping.maps);return new rS(e.done.addTransform(n,o?t.selection.getBookmark():void 0,r,rI(t)),rw.empty,a,n.time,null==i?e.prevComposition:i)}})(n,r,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r="historyUndo"==n?rj:"historyRedo"==n?rO:null;return!!r&&!!e.editable&&(t.preventDefault(),r(e.state,e.dispatch))}}}})}(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),rG=eP.YY.create({name:"starterKit",addExtensions(){var e,t,n,r;let i=[];return!1!==this.options.bold&&i.push(eK.configure(this.options.bold)),!1!==this.options.blockquote&&i.push(e$.configure(this.options.blockquote)),!1!==this.options.bulletList&&i.push(nO.configure(this.options.bulletList)),!1!==this.options.code&&i.push(eI.configure(this.options.code)),!1!==this.options.codeBlock&&i.push(eG.configure(this.options.codeBlock)),!1!==this.options.document&&i.push(eq.configure(this.options.document)),!1!==this.options.dropcursor&&i.push(rD.configure(this.options.dropcursor)),!1!==this.options.gapcursor&&i.push(rL.configure(this.options.gapcursor)),!1!==this.options.hardBreak&&i.push(eX.configure(this.options.hardBreak)),!1!==this.options.heading&&i.push(eJ.configure(this.options.heading)),!1!==this.options.undoRedo&&i.push(rY.configure(this.options.undoRedo)),!1!==this.options.horizontalRule&&i.push(eZ.configure(this.options.horizontalRule)),!1!==this.options.italic&&i.push(e3.configure(this.options.italic)),!1!==this.options.listItem&&i.push(nW.configure(this.options.listItem)),!1!==this.options.listKeymap&&i.push(nX.configure(null==(e=this.options)?void 0:e.listKeymap)),!1!==this.options.link&&i.push(nM.configure(null==(t=this.options)?void 0:t.link)),!1!==this.options.orderedList&&i.push(n5.configure(this.options.orderedList)),!1!==this.options.paragraph&&i.push(n7.configure(this.options.paragraph)),!1!==this.options.strike&&i.push(rn.configure(this.options.strike)),!1!==this.options.text&&i.push(rr.configure(this.options.text)),!1!==this.options.underline&&i.push(ri.configure(null==(n=this.options)?void 0:n.underline)),!1!==this.options.trailingNode&&i.push(rV.configure(null==(r=this.options)?void 0:r.trailingNode)),i}}),rq={tldraw_draw:{normal:{normal:{family:"tldraw_draw",src:{url:"tldraw_draw",format:"woff2"},weight:"normal"},bold:{family:"tldraw_draw",src:{url:"tldraw_draw_bold",format:"woff2"},weight:"bold"}},italic:{normal:{family:"tldraw_draw",src:{url:"tldraw_draw_italic",format:"woff2"},weight:"normal",style:"italic"},bold:{family:"tldraw_draw",src:{url:"tldraw_draw_italic_bold",format:"woff2"},weight:"bold",style:"italic"}}},tldraw_sans:{normal:{normal:{family:"tldraw_sans",src:{url:"tldraw_sans",format:"woff2"},weight:"normal",style:"normal"},bold:{family:"tldraw_sans",src:{url:"tldraw_sans_bold",format:"woff2"},weight:"bold",style:"normal"}},italic:{normal:{family:"tldraw_sans",src:{url:"tldraw_sans_italic",format:"woff2"},weight:"normal",style:"italic"},bold:{family:"tldraw_sans",src:{url:"tldraw_sans_italic_bold",format:"woff2"},weight:"bold",style:"italic"}}},tldraw_serif:{normal:{normal:{family:"tldraw_serif",src:{url:"tldraw_serif",format:"woff2"},weight:"normal",style:"normal"},bold:{family:"tldraw_serif",src:{url:"tldraw_serif_bold",format:"woff2"},weight:"bold",style:"normal"}},italic:{normal:{family:"tldraw_serif",src:{url:"tldraw_serif_italic",format:"woff2"},weight:"normal",style:"italic"},bold:{family:"tldraw_serif",src:{url:"tldraw_serif_italic_bold",format:"woff2"},weight:"bold",style:"italic"}}},tldraw_mono:{normal:{normal:{family:"tldraw_mono",src:{url:"tldraw_mono",format:"woff2"},weight:"normal",style:"normal"},bold:{family:"tldraw_mono",src:{url:"tldraw_mono_bold",format:"woff2"},weight:"bold",style:"normal"}},italic:{normal:{family:"tldraw_mono",src:{url:"tldraw_mono_italic",format:"woff2"},weight:"normal",style:"italic"},bold:{family:"tldraw_mono",src:{url:"tldraw_mono_italic_bold",format:"woff2"},weight:"bold",style:"italic"}}}},rX=(0,h.Ics)(rq).flatMap(e=>(0,h.Ics)(e).flatMap(e=>Object.values(e)));function rJ(e,t){if(`tldraw_${t}`in rq)return;let n=e.fonts[t];return n?.faces??h.Mlv}let rZ=eP.YY.create({name:"keyboardShiftEnterHandler",addKeyboardShortcuts:()=>({"Shift-Enter":({editor:e})=>e.commands.enter()})});eI.config.excludes=void 0,eA.config.priority=1100;let rQ=[rG.configure({blockquote:!1,codeBlock:!1,horizontalRule:!1,link:{openOnClick:!1,autolink:!0},trailingNode:{notAfter:["paragraph","bulletList","orderedList","listItem"]},...void 0}),eA,rZ,eP.XO.TextDirection.configure({direction:"auto"})],r0=new h.laH;function r1(e,t){return r0.get(t,()=>{let n=e.getTextOptions().tipTapConfig?.extensions??rQ;return(0,eP.Zx)(t,n).replace(/<p([^>]*)><\/p>/g,"<p$1><br /></p>")})}function r2(e,t){let n=r1(e,t);return`<div class="tl-rich-text">${n}</div>`}let r3=new h.laH;function r5(e){if(0===e.content.length)return!0;if(1===e.content.length){let t=e.content[0];if(!t.content||0===t.content.length)return!0}return!1}function r6(e){let t=e.getRichTextEditor();return!!(t?.isActive("bulletList")||t?.isActive("orderedList"))}function r4(e,t){return r5(t)?"":r3.get(t,()=>{let n=e.getTextOptions().tipTapConfig?.extensions??rQ;return(0,eP.Df)(t,n,{blockSeparator:"\n"})})}function r8(e,t,n){for(let n of e.marks)"bold"===n.type.name&&"bold"!==t.weight&&(t={...t,weight:"bold"}),"italic"===n.type.name&&"italic"!==t.style&&(t={...t,style:"italic"}),"code"===n.type.name&&"tldraw_mono"!==t.family&&(t={...t,family:"tldraw_mono"});let r=(0,h.g50)(rq,t.family);if(!r)return t;let i=(0,h.g50)(r,t.style);if(!i)return t;let o=(0,h.g50)(i,t.weight);return o&&n(o),t}class r9{static fixNewLines=/\r?\n|\r/g;static normalizeText(e){return e.replace(r9.fixNewLines,"\n")}static normalizeTextForDom(e){return e.replace(r9.fixNewLines,"\n").split("\n").map(e=>e||" ").join("\n")}}let r7=/[\u0590-\u05FF\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/,ie={"&":"&",""":'"',"'":"'","":"'",""":'"',"&":"&","'":"'","–":"–","—":"—","‘":"‘","’":"’","“":"“","”":"”","…":"…"},it=RegExp(Object.keys(ie).join("|"),"g");function ir(e){return e.replace(it,e=>ie[e])}async function ii(e,{file:t,assetId:n},r){im(e,t,r)||(0,h.vAR)(!1,"File checks failed");let i=await ig(t);i||(0,h.vAR)(!1,"SVG file contained no safe content");let o=await iy(e,i,n);o||(0,h.vAR)(!1,`No asset util found for MIME type "${t.type}"`);let s=await e.uploadAsset(o,i);return o.props.src=s.src,s.meta&&(o.meta={...o.meta,...s.meta}),h.Kx3.create(o)}async function io(e,{file:t,shapeId:n},r){im(e,t,r)||(0,h.vAR)(!1,"File checks failed");let i=await ig(t);if(!i)return;let o=e.getShape(n);o||(0,h.vAR)(!1,"Shape not found");let s=(0,h.Gwq)(await i.arrayBuffer()),a=h.Kx3.createId(s);e.createTemporaryAssetPreview(a,i);let l=await iy(e,i,a);if(!l)return;if(e.createAssets([l]),"image"===o.type){let t=o.props.crop,n=l.props.w,r=l.props.h,i=o.x,s=o.y,d=t;if(t){let e=function(e,t,n){let r=X(),i=e.props.crop||r,o=e.props.w,s=e.props.h,a=r,l=o,d=s;if((0,h.n4T)(e.props.crop,r))l=o,d=o*n/t;else{let r,o,{w:s,h:l}=Q(e.props,e.props.crop||X()),{width:d,height:c}=ee(i),u=d/c,h=et(i),p=t/n/(s/l)/u;if(o=(r=d)*p,p>1.5)if(1/o<1/r){let e=o/.3333333333333333;o/=e,r/=e}else{let e=r/.3333333333333333;r/=e,o/=e}r=Math.max(0,Math.min(1,r)),o=Math.max(0,Math.min(1,o)),a=en(h.x,h.y,r,o,i.isCircle)}let c=e.x+o/2,u=e.y+s/2,p=c-l/2,f=u-d/2;return{crop:a,w:l,h:d,x:p,y:f}}(o,l.props.w,l.props.h);d=e.crop,n=e.w,r=e.h,i=e.x,s=e.y}e.updateShapes([{id:o.id,type:o.type,props:{assetId:a,crop:d,w:n,h:r},x:i,y:s}])}else"video"===o.type&&e.updateShapes([{id:o.id,type:o.type,props:{assetId:a,w:l.props.w,h:l.props.h}}]);let d=await e.getAssetForExternalContent({type:"file",file:i,assetId:a});return e.updateAssets([{...d,id:a}]),d}async function is(e,{url:t},{toasts:n,msg:r}){let i;try{let e=await (0,h.hdJ)(t,{method:"GET",mode:"no-cors"}),n=await e.text(),r=new DOMParser().parseFromString(n,"text/html");(i={image:r.head.querySelector('meta[property="og:image"]')?.getAttribute("content")??"",favicon:r.head.querySelector('link[rel="apple-touch-icon"]')?.getAttribute("href")??r.head.querySelector('link[rel="icon"]')?.getAttribute("href")??"",title:r.head.querySelector('meta[property="og:title"]')?.getAttribute("content")??t,description:r.head.querySelector('meta[property="og:description"]')?.getAttribute("content")??""}).image.startsWith("http")||(i.image=new URL(i.image,t).href),i.favicon.startsWith("http")||(i.favicon=new URL(i.favicon,t).href)}catch(e){console.error(e),n.addToast({title:r("assets.url.failed"),severity:"error"}),i={image:"",favicon:"",title:"",description:""}}return{id:h.Kx3.createId((0,h.xpx)(t)),typeName:"asset",type:"bookmark",props:{src:t,description:i.description,image:i.image,favicon:i.favicon,title:i.title},meta:{}}}async function ia(e,{point:t,text:r}){let{sanitizeSvg:i}=await Promise.resolve().then(n.bind(n,13248));if(!(r=i(r)))return;let o=t??(e.inputs.getShiftKey()?e.inputs.getCurrentPagePoint():e.getViewportPageBounds().center),s=new DOMParser().parseFromString(r,"image/svg+xml").querySelector("svg");if(!s)throw Error("No <svg/> element present");let a=parseFloat(s.getAttribute("width")||"0"),l=parseFloat(s.getAttribute("height")||"0");if(!(a&&l)){let t=e.getContainerDocument();t.body.appendChild(s);let n=s.getBoundingClientRect();t.body.removeChild(s),a=n.width,l=n.height}let d=await e.getAssetForExternalContent({type:"file",file:new File([r],"asset.svg",{type:"image/svg+xml"})});if(!d)throw Error("Could not create an asset");ip(e,[d],o)}async function il(e,{point:t,files:n},r){let{toasts:i,msg:o}=r;if(n.length>e.options.maxFilesAtOnce)return void i.addToast({title:o("assets.files.amount-too-many"),severity:"error"});let s=t??(e.inputs.getShiftKey()?e.inputs.getCurrentPagePoint():e.getViewportPageBounds().center),a=new h.l2P(s.x,s.y),l=[],d=[];for(let t of n){if(!im(e,t,r))continue;let n=await ig(t);if(!n){i.addToast({title:o("assets.files.upload-failed"),severity:"error"});continue}let s=await iy(e,n);s&&("image"===s.type&&e.createTemporaryAssetPreview(s.id,n),l.push(s),d.push({asset:s,file:n}))}Promise.allSettled(d.map(async t=>{try{let n=await e.getAssetForExternalContent({type:"file",file:t.file});if(!n)throw Error("Could not create an asset");e.updateAssets([{...n,id:t.asset.id}])}catch(n){i.addToast({title:o("assets.files.upload-failed"),severity:"error"}),console.error(n),e.deleteAssets([t.asset.id]);return}})),ip(e,l,a)}async function id(e,{point:t,text:n,html:r}){let i,o,s,a,l=t??(e.inputs.getShiftKey()?e.inputs.getCurrentPagePoint():e.getViewportPageBounds().center),d=e.getShapeUtil("text").getDefaultProps(),c=(function(e){let t=e.split("\n");for(;t[0]&&0===t[0].trim().length;)t.shift();let n=1/0;for(let e of t)if(e.trim().length>0){let t=e.length-e.trimStart().length;n=Math.min(n,t)}return t.map(e=>e.slice(n)).join("\n")})(n.replace(/\t/g," ")).replace(/[ \t]+$/gm,"").replace(/\n+$/,""),u=r?(a=e.getTextOptions().tipTapConfig?.extensions??rQ,(0,eP.yQ)(r,a)):(0,h.TP3)(c),p="middle",f=r2(e,u),g=u.content.length>1,m=r7.test(c);g&&(p=g?m?"end":"start":"middle");let y=e.getCurrentTheme(),b=e.textMeasure.measureHtml(f,{...er,lineHeight:y.lineHeight,fontFamily:ed(y,d.font),fontSize:y.fontSize*eo[d.size],maxWidth:null}),x=Math.min(g?.9*e.getViewportPageBounds().width:920,Math.max(200,.9*e.getViewportPageBounds().width));if(b.w>x){let t=e.textMeasure.measureHtml(f,{...er,lineHeight:y.lineHeight,fontFamily:ed(y,d.font),fontSize:y.fontSize*eo[d.size],maxWidth:x});i=t.w,o=t.h,s=!1,p=m?"end":"start"}else i=Math.max(b.w,10),o=Math.max(b.h,10),s=!0;l.y-o/2<e.getViewportPageBounds().minY+40&&(l.y=e.getViewportPageBounds().minY+40+o/2);let w=(0,h.Y8F)(new h.l2P(l.x-i/2,l.y-o/2),e),v=(0,h.n6Y)();e.createShapes([{id:v,type:"text",x:w.x,y:w.y,props:{richText:u,textAlign:p,autoSize:s,w:i}}])}async function ic(e,{point:t,url:n},{toasts:r,msg:i}){if(!h.T.linkUrl.isValid(n)){console.warn(`Could not create a bookmark from an invalid url: ${JSON.stringify(n)}`),r.addToast({title:i("assets.url.failed"),severity:"error"});return}let o=e.getShapeUtil("embed"),s=o?.getEmbedDefinition(n);if(s&&!1!==s.definition.embedOnPaste)return e.putExternalContent({type:"embed",url:s.url,point:t,embed:s.definition});let a=t??(e.inputs.getShiftKey()?e.inputs.getCurrentPagePoint():e.getViewportPageBounds().center);if(!(await G(e,{url:n,center:a})).ok)return void r.addToast({title:i("assets.url.failed"),severity:"error"})}async function iu(e,{point:t,content:n}){e.run(()=>{let r=e.getSelectionPageBounds();for(let t of(e.markHistoryStoppingPoint("paste"),n.shapes))n.rootShapeIds.includes(t.id)&&(t.isLocked=!1);let i=e.isInAny("select.dragging_handle","select.translating","select.resizing","select.rotating");e.putContentOntoCurrentPage(n,{point:t,select:!i});let o=e.getSelectionPageBounds();!i&&r&&o&&r?.collides(o)&&(e.updateInstanceState({isChangingStyle:!0}),e.timers.setTimeout(()=>{e.updateInstanceState({isChangingStyle:!1})},150))})}async function ih(e,{point:t,content:n}){e.run(()=>{ec(e,n,t)})}async function ip(e,t,n){if(!t.length)return[];let r=h.l2P.From(n),i=[];for(let n=0;n<t.length;n++){let o=t[n],s=e.getShapeUtilForAssetType(o.type),a=s?.createShapeForAsset?.(o,r)??null;a&&(i.push(a),"w"in o.props&&"number"==typeof o.props.w&&(r.x+=o.props.w))}return e.run(()=>{let r=t.filter(t=>!e.getAsset(t.id));e.store.atomic(()=>{e.canCreateShapes(i)&&(r.length&&e.createAssets(r),e.createShapes(i).select(...i.map(e=>e.id)),function(e,t){let n=e.getViewportPageBounds(),r=e.getSelectionPageBounds();if(r){let n=r.center.sub(t);e.updateShapes(e.getSelectedShapes().map(t=>{let r=e.getShapeParentTransform(t).decompose().rotation,i=h.l2P.Rot(n,-r);return{id:t.id,type:t.type,x:t.x-i.x,y:t.y-i.y}}))}if((r=e.getSelectionPageBounds())&&e.getInstanceState().isGridMode){let t=e.getDocumentSettings().gridSize,n=new h.l2P(r.minX,r.minY),i=n.clone().snapToGrid(t),o=h.l2P.Sub(n,i);e.updateShapes(e.getSelectedShapes().map(e=>{let t={x:e.x-o.x,y:e.y-o.y};return{id:e.id,type:e.type,x:t.x,y:t.y}}))}(r=e.getSelectionPageBounds())&&!n.contains(r)&&e.zoomToSelection({animation:{duration:e.options.animationMediumMs}})}(e,n))})}),i.map(e=>e.id)}async function ig(e){if("image/svg+xml"!==e.type)return e;try{let t=await e.text(),{sanitizeSvg:r}=await Promise.resolve().then(n.bind(n,13248)),i=r(t);if(!i)return null;return new File([i],e.name,{type:e.type,lastModified:e.lastModified})}catch{return null}}function im(e,t,n){let{maxAssetSize:r=0xa00000,acceptedImageMimeTypes:i,acceptedVideoMimeTypes:o,toasts:s,msg:a}=n;return e.getAssetUtilForMimeType(t.type)||i?.includes(t.type)||o?.includes(t.type)?t.size>r?(s.addToast({title:a("assets.files.size-too-big"),description:a("assets.files.maximum-size").replace("{size}",(e=>{if(0===e)return"0 bytes";let t=Math.floor(Math.log(e)/Math.log(1024)),n=e/Math.pow(1024,t),r=n%1==0?n.toString():n.toFixed(1);return`${r} ${["bytes","KB","MB","GB","TB","PB"][t]}`})(r)),severity:"error"}),!1):!!t.type||(s.addToast({title:a("assets.files.upload-failed"),severity:"error"}),console.error("No mime type"),!1):(s.addToast({title:a("assets.files.type-not-allowed"),severity:"error"}),!1)}async function iy(e,t,n){if(!n){let e=(0,h.Gwq)(await t.arrayBuffer());n=h.Kx3.createId(e)}let r=e.getAssetUtilForMimeType(t.type);return r?await r.getAssetFromFile(t,n):null}async function ib(e,t,n){let r=n.name;if(!r&&(r=`shapes at ${ix()}`,1===t.length)){let n=e.getShape(t[0]);r=e.isShapeOfType(n,"frame")?n.props.name||"frame":`${(0,h.ni0)(n.id)} at ${ix()}`}r+=`.${n.format}`;let{blob:i}=await e.toImage(t,n);iw(new File([i],r,{type:i.type}),e.getContainerDocument())}function ix(){let e=new Date,t=String(e.getFullYear()).slice(2),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0"),i=String(e.getHours()).padStart(2,"0"),o=String(e.getMinutes()).padStart(2,"0"),s=String(e.getSeconds()).padStart(2,"0");return`${t}-${n}-${r} ${i}.${o}.${s}`}function iw(e,t){let n=(t??(0,h.jLo)()).createElement("a"),r=URL.createObjectURL(e);n.href=r,n.download=e.name,n.click(),URL.revokeObjectURL(r)}function iv(e,t){let n=(0,h.oE7)(t.map(t=>e.getShape(t)).filter(t=>t&&e.isShapeFrameLike(t)));if(!n.length)return;let r=[];e.run(()=>{n.map(t=>{let i=e.getSortedChildIdsForParent(t.id);i.length&&((0,h.IeP)(e,i,{filter:e=>!n.find(t=>t.id===e.id)}),r.push(...i))}),e.setSelectedShapes(r),e.deleteShapes(t)})}function iS(e,t,n={padding:50}){let r=h.azJ.FromPoints(e.flatMap(e=>{if(!e)return[];let n=t.getShapeGeometry(e.id),r=t.getShapeLocalTransform(e);return r?.applyToPoints(n.vertices)??[]})),i=n.padding??50,o=r.w+2*i,s=r.h+2*i;return{w:o,h:s,dx:i-r.minX,dy:i-r.minY}}function iC(e,t,n={}){let r=e.getShape(t);if(!r||!e.isShapeFrameLike(r))return;let i=e.getSortedChildIdsForParent(r.id),o=(0,h.oE7)(i.map(t=>e.getShape(t)));if(!o.length)return;let{w:s,h:a,dx:l,dy:d}=iS(o,e,n);if(0===l&&0===d&&r.props.w===s&&r.props.h===a)return;let c=new h.l2P(l,d).rot(r.rotation);e.run(()=>{let t=i.map(t=>{let n=e.getShape(t);return{id:n.id,type:n.type,x:n.x+l,y:n.y+d}});t.push({id:r.id,type:r.type,x:r.x-c.x,y:r.y-c.y,props:{w:s,h:a}}),e.updateShapes(t)})}var ik=n(69730),iP=Object.defineProperty,iT=(e,t)=>iP(e,"name",{value:t,configurable:!0}),iE=!!("u">typeof window&&window.document&&window.document.createElement);function iI(e,t,{checkForDefaultPrevented:n=!0}={}){return iT(function(r){if(e?.(r),!1===n||!r||!r.defaultPrevented)return t?.(r)},"handleEvent")}function i_(e){if(!iE)throw Error("Cannot access document outside of the DOM");return e?.ownerDocument??document}function iM(e){return"IFRAME"===e.tagName}iT(iI,"composeEventHandlers"),iT(function(e){if(!iE)throw Error("Cannot access window outside of the DOM");return e?.ownerDocument?.defaultView??window},"getOwnerWindow"),iT(i_,"getOwnerDocument"),iT(function e(t,n=!1){let{activeElement:r}=i_(t);if(!r?.nodeName)return null;if(iM(r)&&r.contentDocument)return e(r.contentDocument.body,n);if(n){let e=r.getAttribute("aria-activedescendant");if(e){let t=i_(r).getElementById(e);if(t)return t}}return r},"getActiveElement"),iT(iM,"isFrame");var iA=Object.defineProperty,ij=(e,t)=>iA(e,"name",{value:t,configurable:!0});function iO(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function iD(...e){return t=>{let n=!1,r=e.map(e=>{let r=iO(e,t);return n||"function"!=typeof r||(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];"function"==typeof n?n():iO(e[t],null)}}}}function iL(...e){return C.useCallback(iD(...e),e)}ij(iO,"setRef"),ij(iD,"composeRefs"),ij(iL,"useComposedRefs");var iF=Object.defineProperty,iR=(e,t)=>iF(e,"name",{value:t,configurable:!0});function iz(e,t=[]){let n=[];function r(t,r){let i=C.createContext(r);i.displayName=t+"Context";let o=n.length;n=[...n,r];let s=iR(t=>{let{scope:n,children:r,...s}=t,a=n?.[e]?.[o]||i,l=C.useMemo(()=>s,Object.values(s));return(0,b.jsx)(a.Provider,{value:l,children:r})},"Provider");function a(n,s,l={}){let{optional:d=!1}=l,c=s?.[e]?.[o]||i,u=C.useContext(c);if(u)return u;if(void 0!==r)return r;if(!d)throw Error(`\`${n}\` must be used within \`${t}\``)}return s.displayName=t+"Provider",iR(a,"useContext"),[s,a]}iR(r,"createContext");let i=iR(()=>{let t=n.map(e=>C.createContext(e));return iR(function(n){let r=n?.[e]||t;return C.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},"useScope")},"createScope");return i.scopeName=e,[r,iN(i,...t)]}function iN(...e){let t=e[0];if(1===e.length)return t;let n=iR(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return iR(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return C.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}iR(function(e,t){let n=C.createContext(t);n.displayName=e+"Context";let r=iR(e=>{let{children:t,...r}=e,i=C.useMemo(()=>r,Object.values(r));return(0,b.jsx)(n.Provider,{value:i,children:t})},"Provider");function i(r,o={}){let{optional:s=!1}=o,a=C.useContext(n);if(a)return a;if(void 0!==t)return t;if(!s)throw Error(`\`${r}\` must be used within \`${e}\``)}return r.displayName=e+"Provider",iR(i,"useContext"),[r,i]},"createContext"),iR(iz,"createContextScope"),iR(iN,"composeContextScopes");var i$=n(47650),iB=Object.defineProperty,iH=(e,t)=>iB(e,"name",{value:t,configurable:!0});function iU(e){let t=C.forwardRef((t,n)=>{let{children:r,...i}=t,o=null,s=!1,a=[];iZ(r)&&"function"==typeof i2&&(r=i2(r._payload)),C.Children.forEach(r,e=>{if(iX(e)){s=!0;let t="child"in e.props?e.props.child:e.props.children;iZ(t)&&"function"==typeof i2&&(t=i2(t._payload)),o=iY(e,t),a.push(o?.props?.children)}else a.push(e)}),o?o=C.cloneElement(o,void 0,a):!s&&1===C.Children.count(r)&&C.isValidElement(r)&&(o=r);let l=o?iq(o):void 0,d=iL(n,l);if(!o){if(r||0===r)throw Error(s?i1(e):i0(e));return r}let c=iG(i,o.props??{});return o.type!==C.Fragment&&(c.ref=n?d:l),C.cloneElement(o,c)});return t.displayName=`${e}.Slot`,t}iH(iU,"createSlot");var iW=iU("Slot"),iK=Symbol.for("radix.slottable");function iV(e){let t=iH(e=>"child"in e?e.children(e.child):e.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=iK,t}iH(iV,"createSlottable");var iY=iH((e,t)=>{if("child"in e.props){let t=e.props.child;return C.isValidElement(t)?C.cloneElement(t,void 0,e.props.children(t.props.children)):null}return C.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function iG(e,t){let n={...t};for(let r in t){let i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{let t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}function iq(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(n=(t=Object.getOwnPropertyDescriptor(e,"ref")?.get)&&"isReactWarning"in t&&t.isReactWarning)?e.props.ref:e.props.ref||e.ref}function iX(e){return C.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===iK}iH(iG,"mergeProps"),iH(iq,"getElementRef"),iH(iX,"isSlottable");var iJ=Symbol.for("react.lazy");function iZ(e){return null!=e&&"object"==typeof e&&"$$typeof"in e&&e.$$typeof===iJ&&"_payload"in e&&iQ(e._payload)}function iQ(e){return"object"==typeof e&&null!==e&&"then"in e}iH(iZ,"isLazyComponent"),iH(iQ,"isPromiseLike");var i0=iH(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),i1=iH(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),i2=k[" use ".trim().toString()],i3=Object.defineProperty,i5=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let n=iU(`Primitive.${t}`),r=C.forwardRef((e,r)=>{let{asChild:i,...o}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,b.jsx)(i?n:t,{...o,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function i6(e,t){e&&i$.flushSync(()=>e.dispatchEvent(t))}function i4(e){let t=C.useRef(e);return C.useEffect(()=>{t.current=e}),C.useMemo(()=>(...e)=>t.current?.(...e),[])}i3(i6,"name",{value:"dispatchDiscreteCustomEvent",configurable:!0}),(0,Object.defineProperty)(i4,"name",{value:"useCallbackRef",configurable:!0});var i8=Object.defineProperty,i9=(e,t)=>i8(e,"name",{value:t,configurable:!0}),i7="dismissableLayer.update",oe=C.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),ot=C.forwardRef(i9(function(e,t){let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:a,onDismiss:l,...d}=e,u=C.useContext(oe),[h,p]=C.useState(null),f=h?.ownerDocument??globalThis?.document,[,g]=C.useState({}),m=iL(t,p),y=Array.from(u.layers),[x]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),w=x?y.indexOf(x):-1,v=h?y.indexOf(h):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,k=v>=w,P=C.useRef(!1),T=oo(e=>{o?.(e),a?.(e),e.defaultPrevented||l?.()},{ownerDocument:f,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:P,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:C.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...u.branches].some(t=>t.contains(e));return k&&!t},[u.branches,k])}),E=oa(e=>{if(r&&P.current)return;let t=e.target;![...u.branches].some(e=>e.contains(t))&&(s?.(e),a?.(e),e.defaultPrevented||l?.())},f),I=!!h&&v===y.length-1,_=i4(e=>{"Escape"===e.key&&(i?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))});return C.useEffect(()=>{if(I)return f.addEventListener("keydown",_,{capture:!0}),()=>f.removeEventListener("keydown",_,{capture:!0})},[f,I,_]),C.useEffect(()=>{if(h)return n&&(0===u.layersWithOutsidePointerEventsDisabled.size&&(c=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(h)),u.layers.add(h),ol(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(h),0===u.layersWithOutsidePointerEventsDisabled.size&&(f.body.style.pointerEvents=c))}},[h,f,n,u]),C.useEffect(()=>()=>{h&&(u.layers.delete(h),u.layersWithOutsidePointerEventsDisabled.delete(h),ol())},[h,u]),C.useEffect(()=>{let e=i9(()=>g({}),"handleUpdate");return document.addEventListener(i7,e),()=>document.removeEventListener(i7,e)},[]),(0,b.jsx)(i5.div,{...d,ref:m,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:iI(e.onFocusCapture,E.onFocusCapture),onBlurCapture:iI(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:iI(e.onPointerDownCapture,T.onPointerDownCapture)})},"DismissableLayer")),on=C.forwardRef(i9(function(e,t){let n=C.useContext(oe),r=C.useRef(null),i=iL(t,r);return C.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,b.jsx)(i5.div,{...e,ref:i})},"DismissableLayerBranch"));function or(){let e=C.useContext(oe),[t,n]=C.useState(null);return C.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}i9(or,"useDismissableLayerSurface");var oi=i9(()=>!0,"IS_TRUE");function oo(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:o,shouldHandlePointerDownOutside:s=oi}=t,a=i4(e),l=C.useRef(!1),d=C.useRef(!1),c=C.useRef(new Map),u=C.useRef(()=>{});return C.useEffect(()=>{function e(){d.current=!1,i.current=!1,c.current.clear()}function t(){return Array.from(c.current.values()).some(Boolean)}function h(e){if(!d.current)return;let t=e.target;t instanceof Node&&[...o].some(e=>e.contains(t))||c.current.set(e.type,!0),"click"===e.type&&window.setTimeout(()=>{d.current&&u.current()},0)}function p(e){d.current&&c.current.set(e.type,!1)}i9(e,"resetOutsideInteraction"),i9(t,"isOutsideInteractionIntercepted"),i9(h,"handleInteractionCapture"),i9(p,"handleInteractionBubble");let f=i9(o=>{if(o.target&&!l.current){let h=function(){n.removeEventListener("click",u.current);let r=t();e(),r||od("dismissableLayer.pointerDownOutside",a,p,{discrete:!0})};if(i9(h,"handleAndDispatchPointerDownOutsideEvent"),!s(o.target)){n.removeEventListener("click",u.current),e(),l.current=!1;return}let p={originalEvent:o};d.current=!0,i.current=r&&0===o.button,c.current.clear(),r&&0===o.button?(n.removeEventListener("click",u.current),u.current=h,n.addEventListener("click",u.current,{once:!0})):h()}else n.removeEventListener("click",u.current),e();l.current=!1},"handlePointerDown"),g=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(let e of g)n.addEventListener(e,h,!0),n.addEventListener(e,p);let m=window.setTimeout(()=>{n.addEventListener("pointerdown",f)},0);return()=>{for(let e of(window.clearTimeout(m),n.removeEventListener("pointerdown",f),n.removeEventListener("click",u.current),g))n.removeEventListener(e,h,!0),n.removeEventListener(e,p)}},[n,a,r,i,o,s]),{onPointerDownCapture:i9(()=>l.current=!0,"onPointerDownCapture")}}function oa(e,t=globalThis?.document){let n=i4(e),r=C.useRef(!1);return C.useEffect(()=>{let e=i9(e=>{e.target&&!r.current&&od("dismissableLayer.focusOutside",n,{originalEvent:e},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,n]),{onFocusCapture:i9(()=>r.current=!0,"onFocusCapture"),onBlurCapture:i9(()=>r.current=!1,"onBlurCapture")}}function ol(){let e=new CustomEvent(i7);document.dispatchEvent(e)}function od(e,t,n,{discrete:r}){let i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?i6(i,o):i.dispatchEvent(o)}i9(oo,"usePointerDownOutside"),i9(oa,"useFocusOutside"),i9(ol,"dispatchUpdate"),i9(od,"handleAndDispatchCustomEvent");var oc=globalThis?.document?C.useLayoutEffect:()=>{},ou=Object.defineProperty,oh=k[" useId ".trim().toString()]||(()=>void 0),op=0;function of(e){let[t,n]=C.useState(oh());return oc(()=>{e||n(e=>e??String(op++))},[e]),e||(t?`radix-${t}`:"")}ou(of,"name",{value:"useId",configurable:!0});let og=["top","right","bottom","left"],om=Math.min,oy=Math.max,ob=Math.round,ox=Math.floor,ow=e=>({x:e,y:e}),ov={left:"right",right:"left",bottom:"top",top:"bottom"};function oS(e,t){return"function"==typeof e?e(t):e}function oC(e){return e.split("-")[0]}function ok(e){return e.split("-")[1]}function oP(e){return"x"===e?"y":"x"}function oT(e){return"y"===e?"height":"width"}function oE(e){let t=e[0];return"t"===t||"b"===t?"y":"x"}function oI(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}let o_=["left","right"],oM=["right","left"],oA=["top","bottom"],oj=["bottom","top"];function oO(e){let t=oC(e);return ov[t]+e.slice(t.length)}function oD(e){var t,n,r,i;return"number"!=typeof e?{top:null!=(t=e.top)?t:0,right:null!=(n=e.right)?n:0,bottom:null!=(r=e.bottom)?r:0,left:null!=(i=e.left)?i:0}:{top:e,right:e,bottom:e,left:e}}function oL(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function oF(e,t,n){let r,{reference:i,floating:o}=e,s=oE(t),a=oP(oE(t)),l=oT(a),d=oC(t),c=i.x+i.width/2-o.width/2,u=i.y+i.height/2-o.height/2,h=i[l]/2-o[l]/2;switch(d){case"top":r={x:c,y:i.y-o.height};break;case"bottom":r={x:c,y:i.y+i.height};break;case"right":r={x:i.x+i.width,y:u};break;case"left":r={x:i.x-o.width,y:u};break;default:r={x:i.x,y:i.y}}let p=ok(t);return p&&(r[a]+=h*("end"===p?1:-1)*(n&&"y"===s?-1:1)),r}async function oR(e,t){var n;void 0===t&&(t={});let{x:r,y:i,platform:o,rects:s,elements:a,strategy:l}=e,{boundary:d="clippingAncestors",rootBoundary:c="viewport",elementContext:u="floating",altBoundary:h=!1,padding:p=0}=oS(t,e),f=oD(p),g=a[h?"floating"===u?"reference":"floating":u],m=oL(await o.getClippingRect({element:null==(n=await (null==o.isElement?void 0:o.isElement(g)))||n?g:g.contextElement||await (null==o.getDocumentElement?void 0:o.getDocumentElement(a.floating)),boundary:d,rootBoundary:c,strategy:l})),y="floating"===u?{x:r,y:i,width:s.floating.width,height:s.floating.height}:s.reference,b=await (null==o.getOffsetParent?void 0:o.getOffsetParent(a.floating)),x=await (null==o.isElement?void 0:o.isElement(b))&&await (null==o.getScale?void 0:o.getScale(b))||{x:1,y:1},w=oL(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:y,offsetParent:b,strategy:l}):y);return{top:(m.top-w.top+f.top)/x.y,bottom:(w.bottom-m.bottom+f.bottom)/x.y,left:(m.left-w.left+f.left)/x.x,right:(w.right-m.right+f.right)/x.x}}let oz=async(e,t,n)=>{let{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:s}=n,a=s.detectOverflow?s:{...s,detectOverflow:oR},l=await (null==s.isRTL?void 0:s.isRTL(t)),d=await s.getElementRects({reference:e,floating:t,strategy:i}),{x:c,y:u}=oF(d,r,l),h=r,p=0,f={};for(let n=0;n<o.length;n++){let g=o[n];if(!g)continue;let{name:m,fn:y}=g,{x:b,y:x,data:w,reset:v}=await y({x:c,y:u,initialPlacement:r,placement:h,strategy:i,middlewareData:f,rects:d,platform:a,elements:{reference:e,floating:t}});c=null!=b?b:c,u=null!=x?x:u,f[m]={...f[m],...w},v&&p<50&&(p++,"object"==typeof v&&(v.placement&&(h=v.placement),v.rects&&(d=!0===v.rects?await s.getElementRects({reference:e,floating:t,strategy:i}):v.rects),{x:c,y:u}=oF(d,h,l)),n=-1)}return{x:c,y:u,placement:h,strategy:i,middlewareData:f}};function oN(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function o$(e){return og.some(t=>e[t]>=0)}let oB=new Set(["left","top"]);async function oH(e,t){let{placement:n,platform:r,elements:i}=e,o=await (null==r.isRTL?void 0:r.isRTL(i.floating)),s=oC(n),a=ok(n),l="y"===oE(n),d=oB.has(s)?-1:1,c=o&&l?-1:1,u=oS(t,e),{mainAxis:h,crossAxis:p,alignmentAxis:f}="number"==typeof u?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return a&&"number"==typeof f&&(p="end"===a?-1*f:f),l?{x:p*c,y:h*d}:{x:h*d,y:p*c}}function oU(){return"u">typeof window}function oW(e){return oY(e)?(e.nodeName||"").toLowerCase():"#document"}function oK(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function oV(e){var t;return null==(t=(oY(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function oY(e){return!!oU()&&(e instanceof Node||e instanceof oK(e).Node)}function oG(e){return!!oU()&&(e instanceof Element||e instanceof oK(e).Element)}function oq(e){return!!oU()&&(e instanceof HTMLElement||e instanceof oK(e).HTMLElement)}function oX(e){return!(!oU()||"u"<typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof oK(e).ShadowRoot)}function oJ(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=o6(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&"inline"!==i&&"contents"!==i}function oZ(e){try{if(e.matches(":popover-open"))return!0}catch(e){}try{return e.matches(":modal")}catch(e){return!1}}let oQ=/transform|translate|scale|rotate|perspective|filter/,o0=/paint|layout|strict|content/,o1=e=>!!e&&"none"!==e;function o2(e){let t=oG(e)?o6(e):e;return o1(t.transform)||o1(t.translate)||o1(t.scale)||o1(t.rotate)||o1(t.perspective)||!o3()&&(o1(t.backdropFilter)||o1(t.filter))||oQ.test(t.willChange||"")||o0.test(t.contain||"")}function o3(){return null==r&&(r="u">typeof CSS&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),r}function o5(e){return/^(html|body|#document)$/.test(oW(e))}function o6(e){return oK(e).getComputedStyle(e)}function o4(e){return oG(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function o8(e){if("html"===oW(e))return e;let t=e.assignedSlot||e.parentNode||oX(e)&&e.host||oV(e);return oX(t)?t.host:t}function o9(e,t,n){var r;void 0===t&&(t=[]),void 0===n&&(n=!0);let i=function e(t){let n=o8(t);return o5(n)?(t.ownerDocument||t).body:oq(n)&&oJ(n)?n:e(n)}(e),o=i===(null==(r=e.ownerDocument)?void 0:r.body),s=oK(i);if(!o)return t.concat(i,o9(i,[],n));{let e=o7(s);return t.concat(s,s.visualViewport||[],oJ(i)?i:[],e&&n?o9(e):[])}}function o7(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function se(e){let t=o6(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=oq(e),o=i?e.offsetWidth:n,s=i?e.offsetHeight:r,a=ob(n)!==o||ob(r)!==s;return a&&(n=o,r=s),{width:n,height:r,$:a}}function st(e){return oG(e)?e:e.contextElement}function sn(e){let t=st(e);if(!oq(t))return ow(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:o}=se(t),s=(o?ob(n.width):n.width)/r,a=(o?ob(n.height):n.height)/i;return s&&Number.isFinite(s)||(s=1),a&&Number.isFinite(a)||(a=1),{x:s,y:a}}let sr=ow(0);function si(e){let t=oK(e);return o3()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:sr}function so(e,t,n,r){var i;void 0===t&&(t=!1),void 0===n&&(n=!1);let o=e.getBoundingClientRect(),s=st(e),a=ow(1);t&&(r?oG(r)&&(a=sn(r)):a=sn(e));let l=(void 0===(i=n)&&(i=!1),r&&i&&r===oK(s))?si(s):ow(0),d=(o.left+l.x)/a.x,c=(o.top+l.y)/a.y,u=o.width/a.x,h=o.height/a.y;if(s&&r){let e=oK(s),t=oG(r)?oK(r):r,n=e,i=o7(n);for(;i&&t!==n;){let e=sn(i),t=i.getBoundingClientRect(),r=o6(i),o=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,s=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;d*=e.x,c*=e.y,u*=e.x,h*=e.y,d+=o,c+=s,i=o7(n=oK(i))}}return oL({width:u,height:h,x:d,y:c})}function ss(e,t){let n=o4(e).scrollLeft;return t?t.left+n:so(oV(e)).left+n}function sa(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-ss(e,n),y:n.top+t.scrollTop}}function sl(e,t,n){var r;let i;if("viewport"===t||"layoutViewport"===t)i=function(e,t,n){void 0===n&&(n="viewport");let r="layoutViewport"===n,i=oK(e),o=oV(e),s=i.visualViewport,a=o.clientWidth,l=o.clientHeight,d=0,c=0;if(s){let e=!o3()||"fixed"===t;r?e||(d=-s.offsetLeft,c=-s.offsetTop):(a=s.width,l=s.height,e&&(d=s.offsetLeft,c=s.offsetTop))}if(0>=ss(o)){let e=o.ownerDocument,t=e.body,n=getComputedStyle(t),r="CSS1Compat"===e.compatMode&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(o.clientWidth-t.clientWidth-r),s="stable both-edges"===getComputedStyle(o).scrollbarGutter?i/2:i;s<=25&&(a-=s)}return{width:a,height:l,x:d,y:c}}(e,n,t);else if("document"===t){let t,n,o,s,a,l;t=o4(r=oV(e)),n=r.ownerDocument.body,o=oy(r.scrollWidth,r.clientWidth,n.scrollWidth,n.clientWidth),s=oy(r.scrollHeight,r.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+ss(r),l=-t.scrollTop,"rtl"===o6(n).direction&&(a+=oy(r.clientWidth,n.clientWidth)-o),i={width:o,height:s,x:a,y:l}}else if(oG(t)){let e,r,o,s,a,l;r=(e=so(t,!0,"fixed"===n)).top+t.clientTop,o=e.left+t.clientLeft,s=sn(t),a=t.clientWidth*s.x,l=t.clientHeight*s.y,i={width:a,height:l,x:o*s.x,y:r*s.y}}else{let n=si(e);i={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return oL(i)}function sd(e){return"static"===o6(e).position}function sc(e,t){if(!oq(e)||"fixed"===o6(e).position)return null;if(t)return t(e);let n=e.offsetParent;return oV(e)===n&&(n=n.ownerDocument.body),n}function su(e,t){var n;let r=oK(e);if(oZ(e))return r;if(!oq(e)){let t=o8(e);for(;t&&!o5(t);){if(oG(t)&&!sd(t))return t;t=o8(t)}return r}let i=sc(e,t);for(;i&&(n=i,/^(table|td|th)$/.test(oW(n)))&&sd(i);)i=sc(i,t);return i&&o5(i)&&sd(i)&&!o2(i)?r:i||function(e){let t=o8(e);for(;oq(t)&&!o5(t);){if(o2(t))return t;if(oZ(t))break;t=o8(t)}return null}(e)||r}let sh=async function(e){let t=this.getOffsetParent||su,n=this.getDimensions,r=await n(e.floating);return{reference:function(e,t,n){let r=oq(t),i=oV(t),o="fixed"===n,s=so(e,!0,o,t),a={scrollLeft:0,scrollTop:0},l=ow(0);if((r||!o)&&(("body"!==oW(t)||oJ(i))&&(a=o4(t)),r)){let e=so(t,!0,o,t);l.x=e.x+t.clientLeft,l.y=e.y+t.clientTop}!r&&i&&(l.x=ss(i));let d=!i||r||o?ow(0):sa(i,a);return{x:s.left+a.scrollLeft-l.x-d.x,y:s.top+a.scrollTop-l.y-d.y,width:s.width,height:s.height}}(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}},sp={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,o="fixed"===i,s=oV(r),a=!!t&&oZ(t.floating);if(r===s||a&&o)return n;let l={scrollLeft:0,scrollTop:0},d=ow(1),c=ow(0),u=oq(r);if((u||!o)&&(("body"!==oW(r)||oJ(s))&&(l=o4(r)),u)){let e=so(r);d=sn(r),c.x=e.x+r.clientLeft,c.y=e.y+r.clientTop}let h=!s||u||o?ow(0):sa(s,l);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-l.scrollLeft*d.x+c.x+h.x,y:n.y*d.y-l.scrollTop*d.y+c.y+h.y}},getDocumentElement:oV,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,o=[..."clippingAncestors"===n?oZ(t)?[]:function(e,t){let n=t.get(e);if(n)return n;let r=o9(e,[],!1).filter(e=>oG(e)&&"body"!==oW(e)),i=null,o="fixed"===o6(e).position,s=o?o8(e):e;for(;oG(s)&&!o5(s);){let e=o6(s),t=o2(s),n=i?i.position:o?"fixed":"";t||"fixed"!==n&&("absolute"!==n||"static"!==e.position)?i=e:r=r.filter(e=>e!==s),s=o8(s)}return t.set(e,r),r}(t,this._c):[].concat(n),r],s=sl(t,o[0],i),a=s.top,l=s.right,d=s.bottom,c=s.left;for(let e=1;e<o.length;e++){let n=sl(t,o[e],i);a=oy(n.top,a),l=om(n.right,l),d=om(n.bottom,d),c=oy(n.left,c)}return{width:l-c,height:d-a,x:c,y:a}},getOffsetParent:su,getElementRects:sh,getClientRects:function(e){return e.getClientRects?Array.from(e.getClientRects()):[]},getDimensions:function(e){let{width:t,height:n}=se(e);return{width:t,height:n}},getScale:sn,isElement:oG,isRTL:function(e){return"rtl"===o6(e).direction}};function sf(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}let sg=e=>({name:"arrow",options:e,async fn(t){let{x:n,y:r,placement:i,rects:o,platform:s,elements:a,middlewareData:l}=t,{element:d,padding:c=0}=oS(e,t)||{};if(null==d)return{};let u=oD(c),h={x:n,y:r},p=oP(oE(i)),f=oT(p),g=await s.getDimensions(d),m="y"===p,y=m?"clientHeight":"clientWidth",b=o.reference[f]+o.reference[p]-h[p]-o.floating[f],x=h[p]-o.reference[p],w=await (null==s.getOffsetParent?void 0:s.getOffsetParent(d)),v=w?w[y]:0;v&&await (null==s.isElement?void 0:s.isElement(w))||(v=a.floating[y]||o.floating[f]);let S=v/2-g[f]/2-1,C=om(u[m?"top":"left"],S),k=om(u[m?"bottom":"right"],S),P=v-g[f]-k,T=v/2-g[f]/2+(b/2-x/2),E=oy(C,om(T,P)),I=!l.arrow&&null!=ok(i)&&T!==E&&o.reference[f]/2-(T<C?C:k)-g[f]/2<0,_=I?T<C?T-C:T-P:0;return{[p]:h[p]+_,data:{[p]:E,centerOffset:T-E-_,...I&&{alignmentOffset:_}},reset:I}}});var sm="u">typeof document?C.useLayoutEffect:function(){};function sy(e,t){let n,r,i;if(e===t)return!0;if(typeof e!=typeof t)return!1;if("function"==typeof e&&e.toString()===t.toString())return!0;if(e&&t&&"object"==typeof e){if(Array.isArray(e)){if((n=e.length)!==t.length)return!1;for(r=n;0!=r--;)if(!sy(e[r],t[r]))return!1;return!0}if((n=(i=Object.keys(e)).length)!==Object.keys(t).length)return!1;for(r=n;0!=r--;)if(!({}).hasOwnProperty.call(t,i[r]))return!1;for(r=n;0!=r--;){let n=i[r];if(("_owner"!==n||!e.$$typeof)&&!sy(e[n],t[n]))return!1}return!0}return e!=e&&t!=t}function sb(e){return"u"<typeof window?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function sx(e,t){let n=sb(e);return Math.round(t*n)/n}function sw(e){let t=C.useRef(e);return sm(()=>{t.current=e}),t}var sv=Object.defineProperty,sS=C.forwardRef(sv(function(e,t){let{children:n,width:r=10,height:i=5,...o}=e;return(0,b.jsx)(i5.svg,{...o,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:(0,b.jsx)("polygon",{points:"0,0 30,0 15,10"})})},"name",{value:"Arrow",configurable:!0}));function sC(e){let[t,n]=C.useState(void 0);return oc(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{let r,i;if(!Array.isArray(t)||!t.length)return;let o=t[0];if("borderBoxSize"in o){let e=o.borderBoxSize,t=Array.isArray(e)?e[0]:e;r=t.inlineSize,i=t.blockSize}else r=e.offsetWidth,i=e.offsetHeight;n({width:r,height:i})});return t.observe(e,{box:"border-box"}),()=>t.unobserve(e)}n(void 0)},[e]),t}(0,Object.defineProperty)(sC,"name",{value:"useSize",configurable:!0});var sk=Object.defineProperty,sP=(e,t)=>sk(e,"name",{value:t,configurable:!0}),sT="Popper",[sE,sI]=iz(sT),[s_,sM]=sE(sT),sA=sP(e=>{let{__scopePopper:t,children:n}=e,[r,i]=C.useState(null),[o,s]=C.useState(void 0);return(0,b.jsx)(s_,{scope:t,anchor:r,onAnchorChange:i,placementState:o,setPlacementState:s,children:n})},"Popper"),sj=C.forwardRef(sP(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,o=sM("PopperAnchor",n),s=C.useRef(null),a=o.onAnchorChange,l=iL(t,C.useCallback(e=>{s.current=e,e&&a(e)},[a])),d=C.useRef(null);C.useEffect(()=>{if(!r)return;let e=d.current;d.current=r.current,e!==d.current&&a(d.current)});let c=o.placementState&&sB(o.placementState),u=c?.[0],h=c?.[1];return r?null:(0,b.jsx)(i5.div,{"data-radix-popper-side":u,"data-radix-popper-align":h,...i,ref:l})},"PopperAnchor")),sO="PopperContent",[sD,sL]=sE(sO),sF=C.forwardRef(sP(function(e,t){var n,r,i,o,s,a,l,d,c,u,h,p,f;let g,m,y,x,w,v,{__scopePopper:S,side:k="bottom",sideOffset:P=0,align:T="center",alignOffset:E=0,arrowPadding:I=0,avoidCollisions:_=!0,collisionBoundary:M=[],collisionPadding:A=0,sticky:j="partial",hideWhenDetached:O=!1,updatePositionStrategy:D="optimized",onPlaced:L,...F}=e,R=sM(sO,S),[z,N]=C.useState(null),$=iL(t,N),[B,H]=C.useState(null),U=sC(B),W=U?.width??0,K=U?.height??0,V="number"==typeof A?A:{top:0,right:0,bottom:0,left:0,...A},Y=Array.isArray(M)?M:[M],G=Y.length>0,q={padding:V,boundary:Y.filter(sN),altBoundary:G},{refs:X,floatingStyles:J,placement:Z,isPositioned:Q,middlewareData:ee}=function(e){void 0===e&&(e={});let{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:o,floating:s}={},transform:a=!0,whileElementsMounted:l,open:d}=e,[c,u]=C.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=C.useState(r);sy(h,r)||p(r);let[f,g]=C.useState(null),[m,y]=C.useState(null),b=C.useCallback(e=>{e!==S.current&&(S.current=e,g(e))},[]),x=C.useCallback(e=>{e!==k.current&&(k.current=e,y(e))},[]),w=o||f,v=s||m,S=C.useRef(null),k=C.useRef(null),P=C.useRef(c),T=null!=l,E=sw(l),I=sw(i),_=sw(d),M=C.useCallback(()=>{var e,r;let i,o,s;if(!S.current||!k.current)return;let a={placement:t,strategy:n,middleware:h};I.current&&(a.platform=I.current),(e=S.current,r=k.current,i=new Map,o=null!=a?a:{},s={...sp,...o.platform,_c:i},oz(e,r,{...o,platform:s})).then(e=>{let t={...e,isPositioned:!1!==_.current};A.current&&!sy(P.current,t)&&(P.current=t,i$.flushSync(()=>{u(t)}))})},[h,t,n,I,_]);sm(()=>{!1===d&&P.current.isPositioned&&(P.current.isPositioned=!1,u(e=>({...e,isPositioned:!1})))},[d]);let A=C.useRef(!1);sm(()=>(A.current=!0,()=>{A.current=!1}),[]),sm(()=>{if(w&&(S.current=w),v&&(k.current=v),w&&v){if(E.current)return E.current(w,v,M);M()}},[w,v,M,E,T]);let j=C.useMemo(()=>({reference:S,floating:k,setReference:b,setFloating:x}),[b,x]),O=C.useMemo(()=>({reference:w,floating:v}),[w,v]),D=C.useMemo(()=>{let e={position:n,left:0,top:0};if(!O.floating)return e;let t=sx(O.floating,c.x),r=sx(O.floating,c.y);return a?{...e,transform:"translate("+t+"px, "+r+"px)",...sb(O.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:t,top:r}},[n,a,O.floating,c.x,c.y]);return C.useMemo(()=>({...c,update:M,refs:j,elements:O,floatingStyles:D}),[c,M,j,O,D])}({strategy:"fixed",placement:k+("center"!==T?"-"+T:""),whileElementsMounted:sP((...e)=>(function(e,t,n,r){let i;void 0===r&&(r={});let{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:a="function"==typeof ResizeObserver,layoutShift:l="function"==typeof IntersectionObserver,animationFrame:d=!1}=r,c=st(e),u=o||s?[...c?o9(c):[],...t?o9(t):[]]:[];u.forEach(e=>{o&&e.addEventListener("scroll",n),s&&e.addEventListener("resize",n)});let h=c&&l?function(e,t,n){let r,i=null,o=oV(e);function s(){var e;clearTimeout(r),null==(e=i)||e.disconnect(),i=null}function a(n,l){void 0===n&&(n=!1),void 0===l&&(l=1),s();let d=e.getBoundingClientRect(),{left:c,top:u,width:h,height:p}=d;if(n||t(),!h||!p)return;let f={rootMargin:-ox(u)+"px "+-ox(o.clientWidth-(c+h))+"px "+-ox(o.clientHeight-(u+p))+"px "+-ox(c)+"px",threshold:oy(0,om(1,l))||1},g=!0;function m(t){let n=t[0].intersectionRatio;if(!sf(d,e.getBoundingClientRect()))return a();if(n!==l){if(!g)return a();n?a(!1,n):r=setTimeout(()=>{a(!1,1e-7)},1e3)}g=!1}try{i=new IntersectionObserver(m,{...f,root:o.ownerDocument})}catch(e){i=new IntersectionObserver(m,f)}i.observe(e)}let l=oK(e),d=()=>a(n);return l.addEventListener("resize",d),a(!0),()=>{l.removeEventListener("resize",d),s()}}(c,n,s):null,p=-1,f=null;a&&(f=new ResizeObserver(e=>{let[r]=e;r&&r.target===c&&f&&t&&(f.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var e;null==(e=f)||e.observe(t)})),n()}),c&&!d&&f.observe(c),t&&f.observe(t));let g=d?so(e):null;return d&&function t(){let r=so(e);g&&!sf(g,r)&&n(),g=r,i=requestAnimationFrame(t)}(),n(),()=>{var e;u.forEach(e=>{o&&e.removeEventListener("scroll",n),s&&e.removeEventListener("resize",n)}),null==h||h(),null==(e=f)||e.disconnect(),f=null,d&&cancelAnimationFrame(i)}})(...e,{animationFrame:"always"===D}),"whileElementsMounted"),elements:{reference:R.anchor},middleware:[{name:(g={name:"offset",options:r=n={mainAxis:P+K,alignmentAxis:E},async fn(e){var t,n;let{x:i,y:o,placement:s,middlewareData:a}=e,l=await oH(e,r);return s===(null==(t=a.offset)?void 0:t.placement)&&null!=(n=a.arrow)&&n.alignmentOffset?{}:{x:i+l.x,y:o+l.y,data:{...l,placement:s}}}}).name,fn:g.fn,options:[n,void 0]},_&&{name:(m={name:"shift",options:s=o={mainAxis:!0,crossAxis:!1,limiter:"partial"===j?{fn:(i=void 0,{options:i={},fn(e){var t,n,r,o;let{x:s,y:a,placement:l,rects:d,middlewareData:c}=e,{offset:u=0,mainAxis:h=!0,crossAxis:p=!0}=oS(i,e),f={x:s,y:a},g=oE(l),m=oP(g),y=f[m],b=f[g],x=oS(u,e),w="number"==typeof x?{mainAxis:x,crossAxis:0}:{mainAxis:null!=(t=x.mainAxis)?t:0,crossAxis:null!=(n=x.crossAxis)?n:0};if(h){let e="y"===m?"height":"width",t=d.reference[m]-d.floating[e]+w.mainAxis,n=d.reference[m]+d.reference[e]-w.mainAxis;y<t?y=t:y>n&&(y=n)}if(p){let e="y"===m?"width":"height",t=oB.has(oC(l)),n=d.reference[g]-d.floating[e]+(t&&(null==(r=c.offset)?void 0:r[g])||0)+(t?0:w.crossAxis),i=d.reference[g]+d.reference[e]+(t?0:(null==(o=c.offset)?void 0:o[g])||0)-(t?w.crossAxis:0);b<n?b=n:b>i&&(b=i)}return{[m]:y,[g]:b}}}).fn,options:[void 0,void 0]}:void 0,...q},async fn(e){let{x:t,y:n,placement:r,platform:i}=e,{mainAxis:o=!0,crossAxis:a=!1,limiter:l={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...d}=oS(s,e),c={x:t,y:n},u=await i.detectOverflow(e,d),h=oE(r),p=oP(h),f=c[p],g=c[h],m=(e,t)=>oy(t+u["y"===e?"top":"left"],om(t,t-u["y"===e?"bottom":"right"]));o&&(f=m(p,f)),a&&(g=m(h,g));let y=l.fn({...e,[p]:f,[h]:g});return{...y,data:{x:y.x-t,y:y.y-n,enabled:{[p]:o,[h]:a}}}}}).name,fn:m.fn,options:[o,void 0]},_&&{name:(y={name:"flip",options:l=a={...q},async fn(e){var t,n,r,i,o,s,a,d;let c,u,h,{placement:p,middlewareData:f,rects:g,initialPlacement:m,platform:y,elements:b}=e,{mainAxis:x=!0,crossAxis:w=!0,fallbackPlacements:v,fallbackStrategy:S="bestFit",fallbackAxisSideDirection:C="none",flipAlignment:k=!0,...P}=oS(l,e);if(null!=(t=f.arrow)&&t.alignmentOffset)return{};let T=oC(p),E=oE(m),I=oC(m)===m,_=await (null==y.isRTL?void 0:y.isRTL(b.floating)),M=v||(I||!k?[oO(m)]:(c=oO(m),[oI(m),c,oI(c)])),A="none"!==C;!v&&A&&M.push(...(u=ok(m),h=function(e,t,n){switch(e){case"top":case"bottom":if(n)return t?oM:o_;return t?o_:oM;case"left":case"right":return t?oA:oj;default:return[]}}(oC(m),"start"===C,_),u&&(h=h.map(e=>e+"-"+u),k&&(h=h.concat(h.map(oI)))),h));let j=[m,...M],O=await y.detectOverflow(e,P),D=[],L=(null==(n=f.flip)?void 0:n.overflows)||[];if(x&&D.push(O[T]),w){let e,t,n,r,i=(s=p,a=g,void 0===(d=_)&&(d=!1),e=ok(s),n=oT(t=oP(oE(s))),r="x"===t?e===(d?"end":"start")?"right":"left":"start"===e?"bottom":"top",a.reference[n]>a.floating[n]&&(r=oO(r)),[r,oO(r)]);D.push(O[i[0]],O[i[1]])}if(L=[...L,{placement:p,overflows:D}],!D.every(e=>e<=0)){let e=((null==(r=f.flip)?void 0:r.index)||0)+1,t=j[e];if(t&&("alignment"!==w||E===oE(t)||L.every(e=>oE(e.placement)!==E||e.overflows[0]>0)))return{data:{index:e,overflows:L},reset:{placement:t}};let n=null==(i=L.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:i.placement;if(!n)switch(S){case"bestFit":{let e=null==(o=L.filter(e=>{if(A){let t=oE(e.placement);return t===E||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:o[0];e&&(n=e);break}case"initialPlacement":n=m}if(p!==n)return{reset:{placement:n}}}return{}}}).name,fn:y.fn,options:[a,void 0]},{name:(x={name:"size",options:c=d={...q,apply:sP(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:o}=t.reference,s=e.floating.style;s.setProperty("--radix-popper-available-width",`${n}px`),s.setProperty("--radix-popper-available-height",`${r}px`),s.setProperty("--radix-popper-anchor-width",`${i}px`),s.setProperty("--radix-popper-anchor-height",`${o}px`)},"apply")},async fn(e){let t,n,{placement:r,rects:i,platform:o,elements:s}=e,{apply:a=()=>{},...l}=oS(c,e),d=await o.detectOverflow(e,l),u=oC(r),h=ok(r),p="y"===oE(r),{width:f,height:g}=i.floating;"top"===u||"bottom"===u?(t=u,n=h===(await (null==o.isRTL?void 0:o.isRTL(s.floating))?"start":"end")?"left":"right"):(n=u,t="end"===h?"top":"bottom");let m=g-d.top-d.bottom,y=f-d.left-d.right,b=om(g-d[t],m),x=om(f-d[n],y),w=e.middlewareData.shift,v=!w,S=b,C=x;null!=w&&w.enabled.x&&(C=y),null!=w&&w.enabled.y&&(S=m),v&&!h&&(p?C=f-2*oy(d.left,d.right):S=g-2*oy(d.top,d.bottom)),await a({...e,availableWidth:C,availableHeight:S});let k=await o.getDimensions(s.floating);return f!==k.width||g!==k.height?{reset:{rects:!0}}:{}}}).name,fn:x.fn,options:[d,void 0]},B&&{name:(w={name:"arrow",options:h=u={element:B,padding:I},fn(e){let{element:t,padding:n}="function"==typeof h?h(e):h;return t&&({}).hasOwnProperty.call(t,"current")?null!=t.current?sg({element:t.current,padding:n}).fn(e):{}:t?sg({element:t,padding:n}).fn(e):{}}}).name,fn:w.fn,options:[u,void 0]},s$({arrowWidth:W,arrowHeight:K}),O&&{name:(v={name:"hide",options:f=p={strategy:"referenceHidden",...q,boundary:G?q.boundary:void 0},async fn(e){let{rects:t,platform:n}=e,{strategy:r="referenceHidden",...i}=oS(f,e);switch(r){case"referenceHidden":{let r=oN(await n.detectOverflow(e,{...i,elementContext:"reference"}),t.reference);return{data:{referenceHiddenOffsets:r,referenceHidden:o$(r)}}}case"escaped":{let r=oN(await n.detectOverflow(e,{...i,altBoundary:!0}),t.floating);return{data:{escapedOffsets:r,escaped:o$(r)}}}default:return{}}}}).name,fn:v.fn,options:[p,void 0]}]}),et=R.setPlacementState;oc(()=>(et(Z),()=>{et(void 0)}),[Z,et]);let[en,er]=sB(Z),ei=i4(L);oc(()=>{Q&&ei?.()},[Q,ei]);let eo=ee.arrow?.x,es=ee.arrow?.y,ea=ee.arrow?.centerOffset!==0,[el,ed]=C.useState();return oc(()=>{z&&ed(window.getComputedStyle(z).zIndex)},[z]),(0,b.jsx)("div",{ref:X.setFloating,"data-radix-popper-content-wrapper":"",style:{...J,transform:Q?J.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:el,"--radix-popper-transform-origin":[ee.transformOrigin?.x,ee.transformOrigin?.y].join(" "),...ee.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:(0,b.jsx)(sD,{scope:S,placedSide:en,placedAlign:er,onArrowChange:H,arrowX:eo,arrowY:es,shouldHideArrow:ea,children:(0,b.jsx)(i5.div,{"data-side":en,"data-align":er,...F,ref:$,style:{...F.style,animation:Q?F.style?.animation:"none"}})})})},"PopperContent")),sR={top:"bottom",right:"left",bottom:"top",left:"right"},sz=C.forwardRef(sP(function(e,t){let{__scopePopper:n,...r}=e,i=sL("PopperArrow",n),o=sR[i.placedSide];return(0,b.jsx)("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:(0,b.jsx)(sS,{...r,ref:t,style:{...r.style,display:"block"}})})},"PopperArrow"));function sN(e){return null!==e}sP(sN,"isNotNull");var s$=sP(e=>({name:"transformOrigin",options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,o=i.arrow?.centerOffset!==0,s=o?0:e.arrowWidth,a=o?0:e.arrowHeight,[l,d]=sB(n),c={start:"0%",center:"50%",end:"100%"}[d],u=(i.arrow?.x??0)+s/2,h=(i.arrow?.y??0)+a/2,p="",f="";return"bottom"===l?(p=o?c:`${u}px`,f=`${-a}px`):"top"===l?(p=o?c:`${u}px`,f=`${r.floating.height+a}px`):"right"===l?(p=`${-a}px`,f=o?c:`${h}px`):"left"===l&&(p=`${r.floating.width+a}px`,f=o?c:`${h}px`),{data:{x:p,y:f}}}}),"transformOrigin");function sB(e){let[t,n="center"]=e.split("-");return[t,n]}sP(sB,"getSideAndAlignFromPlacement");var sH=Object.defineProperty,sU=(e,t)=>sH(e,"name",{value:t,configurable:!0});function sW(e,t){return C.useReducer((e,n)=>t[e][n]??e,e)}sU(sW,"useStateMachine");var sK=sU(e=>{let{present:t,children:n}=e,r=sV(t),i="function"==typeof n?n({present:r.isPresent}):C.Children.only(n),o=sG(r.ref,sX(i));return"function"==typeof n||r.isPresent?C.cloneElement(i,{ref:o}):null},"Presence");function sV(e){let[t,n]=C.useState(),r=C.useRef(null),i=C.useRef(e),o=C.useRef("none"),s=C.useRef(void 0),[a,l]=sW(e?"mounted":"unmounted",{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return C.useEffect(()=>{"mounted"===a?(o.current=s.current??sq(r.current),s.current=void 0):o.current="none"},[a]),oc(()=>{let t=r.current,n=i.current;if(n!==e){let r=o.current,a=sq(t);e?(s.current=a,l("MOUNT")):"none"===a||t?.display==="none"?l("UNMOUNT"):n&&r!==a?l("ANIMATION_OUT"):l("UNMOUNT"),i.current=e}},[e,l]),oc(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,s=sU(o=>{let s=sq(r.current).includes(CSS.escape(o.animationName));if(o.target===t&&s&&(l("ANIMATION_END"),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode="forwards",e=n.setTimeout(()=>{"forwards"===t.style.animationFillMode&&(t.style.animationFillMode=r)})}},"handleAnimationEnd"),a=sU(e=>{e.target===t&&(o.current=sq(r.current))},"handleAnimationStart");return t.addEventListener("animationstart",a),t.addEventListener("animationcancel",s),t.addEventListener("animationend",s),()=>{n.clearTimeout(e),t.removeEventListener("animationstart",a),t.removeEventListener("animationcancel",s),t.removeEventListener("animationend",s)}}l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:C.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,s.current=sq(t)}else r.current=null;n(e)},[])}}function sY(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function sG(...e){let t=C.useRef(e);return t.current=e,C.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=sY(t,e);return r||"function"!=typeof n||(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];"function"==typeof t?t():sY(n[e],null)}}},[])}function sq(e){return e?.animationName||"none"}function sX(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(n=(t=Object.getOwnPropertyDescriptor(e,"ref")?.get)&&"isReactWarning"in t&&t.isReactWarning)?e.props.ref:e.props.ref||e.ref}sU(sV,"usePresence"),sU(sY,"setRef"),sU(sG,"useStableComposedRefs"),sU(sq,"getAnimationName"),sU(sX,"getElementRef");var sJ=Object.defineProperty,sZ=k[" useEffectEvent ".trim().toString()],sQ=k[" useInsertionEffect ".trim().toString()];function s0(e){if("function"==typeof sZ)return sZ(e);let t=C.useRef(()=>{throw Error("Cannot call an event handler while rendering.")});return"function"==typeof sQ?sQ(()=>{t.current=e}):oc(()=>{t.current=e}),C.useMemo(()=>(...e)=>t.current?.(...e),[])}sJ(s0,"name",{value:"useEffectEvent",configurable:!0});var s1=Object.defineProperty,s2=(e,t)=>s1(e,"name",{value:t,configurable:!0}),s3=k[" useInsertionEffect ".trim().toString()]||oc;function s5({prop:e,defaultProp:t,onChange:n=s2(()=>{},"onChange"),caller:r}){let[i,o,s]=s6({defaultProp:t,onChange:n}),a=void 0!==e,l=a?e:i;return[l,C.useCallback(t=>{if(a){let n=s4(t)?t(e):t;n!==e&&s.current?.(n)}else o(t)},[a,e,o,s])]}function s6({defaultProp:e,onChange:t}){let[n,r]=C.useState(e),i=C.useRef(n),o=C.useRef(t);return s3(()=>{o.current=t},[t]),C.useEffect(()=>{i.current!==n&&(o.current?.(n),i.current=n)},[n,i]),[n,r,o]}function s4(e){return"function"==typeof e}s2(s5,"useControllableState"),s2(s6,"useUncontrolledState"),s2(s4,"isFunction");var s8=Symbol("RADIX:SYNC_STATE");s2(function(e,t,n,r){let{prop:i,defaultProp:o,onChange:s,caller:a}=t,l=void 0!==i,d=s0(s),c=[{...n,state:o}];r&&c.push(r);let[u,h]=C.useReducer((t,n)=>{if(n.type===s8)return{...t,state:n.state};let r=e(t,n);return l&&!Object.is(r.state,t.state)&&d(r.state),r},...c),p=u.state,f=C.useRef(p);C.useEffect(()=>{f.current!==p&&(f.current=p,l||d(p))},[p,f,l]);let g=C.useMemo(()=>void 0!==i?{...u,state:i}:u,[u,i]);return C.useEffect(()=>{l&&!Object.is(i,u.state)&&h({type:s8,state:i})},[i,u.state,l]),[g,h]},"useControllableStateReducer");var s9=Object.defineProperty,s7=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),ae=C.forwardRef(s9(function(e,t){return(0,b.jsx)(i5.span,{...e,ref:t,style:{...s7,...e.style}})},"name",{value:"VisuallyHidden",configurable:!0})),at=Object.defineProperty,an=(e,t)=>at(e,"name",{value:t,configurable:!0}),[ar,ai]=iz("Tooltip",[sI]),ao=sI(),as="tooltip.open",[aa,al]=ar("TooltipProvider"),ad=an(e=>{let{__scopeTooltip:t,delayDuration:n=700,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:o}=e,s=C.useRef(!0),a=C.useRef(!1),l=C.useRef(0);return C.useEffect(()=>{let e=l.current;return()=>window.clearTimeout(e)},[]),(0,b.jsx)(aa,{scope:t,isOpenDelayedRef:s,delayDuration:n,onOpen:C.useCallback(()=>{r<=0||(window.clearTimeout(l.current),s.current=!1)},[r]),onClose:C.useCallback(()=>{r<=0||(window.clearTimeout(l.current),l.current=window.setTimeout(()=>s.current=!0,r))},[r]),isPointerInTransitRef:a,onPointerInTransitChange:C.useCallback(e=>{a.current=e},[]),disableHoverableContent:i,children:o})},"TooltipProvider"),ac="Tooltip",[au,ah]=ar(ac),ap=an(e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:o,disableHoverableContent:s,delayDuration:a}=e,l=al(ac,e.__scopeTooltip),d=ao(t),[c,u]=C.useState(null),[h,p]=C.useState(void 0),f=of(),g=C.useRef(0),m=s??l.disableHoverableContent,y=a??l.delayDuration,x=C.useRef(!1),[w,v]=s5({prop:r,defaultProp:i??!1,onChange:an(e=>{e?(l.onOpen(),document.dispatchEvent(new CustomEvent(as))):l.onClose(),o?.(e)},"onChange"),caller:ac}),S=C.useMemo(()=>w?x.current?"delayed-open":"instant-open":"closed",[w]),k=C.useCallback(()=>{window.clearTimeout(g.current),g.current=0,x.current=!1,v(!0)},[v]),P=C.useCallback(()=>{window.clearTimeout(g.current),g.current=0,v(!1)},[v]),T=C.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{x.current=!0,v(!0),g.current=0},y)},[y,v]);return C.useEffect(()=>()=>{g.current&&(window.clearTimeout(g.current),g.current=0)},[]),(0,b.jsx)(sA,{...d,children:(0,b.jsx)(au,{scope:t,contentId:h??f,setContentId:p,open:w,stateAttribute:S,trigger:c,onTriggerChange:u,onTriggerEnter:C.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:C.useCallback(()=>{m?P():(window.clearTimeout(g.current),g.current=0)},[P,m]),onOpen:k,onClose:P,disableHoverableContent:m,children:n})})},"Tooltip"),af="TooltipTrigger",ag=C.forwardRef(an(function(e,t){let{__scopeTooltip:n,...r}=e,i=ah(af,n),o=al(af,n),s=ao(n),a=iL(t,C.useRef(null),i.onTriggerChange),l=C.useRef(!1),d=C.useRef(!1),c=C.useCallback(()=>l.current=!1,[]);return C.useEffect(()=>()=>document.removeEventListener("pointerup",c),[c]),(0,b.jsx)(sj,{asChild:!0,...s,children:(0,b.jsx)(i5.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:a,onPointerMove:iI(e.onPointerMove,e=>{"touch"!==e.pointerType&&(d.current||o.isPointerInTransitRef.current||(i.onTriggerEnter(),d.current=!0))}),onPointerLeave:iI(e.onPointerLeave,()=>{i.onTriggerLeave(),d.current=!1}),onPointerDown:iI(e.onPointerDown,()=>{i.open&&i.onClose(),l.current=!0,document.addEventListener("pointerup",c,{once:!0})}),onFocus:iI(e.onFocus,()=>{l.current||i.onOpen()}),onBlur:iI(e.onBlur,i.onClose),onClick:iI(e.onClick,i.onClose)})})},"TooltipTrigger")),[am,ay]=ar("TooltipPortal",{forceMount:void 0}),ab="TooltipContent",ax=C.forwardRef(an(function(e,t){let n=ay(ab,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...o}=e,s=ah(ab,e.__scopeTooltip);return(0,b.jsx)(sK,{present:r||s.open,children:s.disableHoverableContent?(0,b.jsx)(aS,{side:i,...o,ref:t}):(0,b.jsx)(aw,{side:i,...o,ref:t})})},"TooltipContent")),aw=C.forwardRef(an(function(e,t){let n=ah(ab,e.__scopeTooltip),r=al(ab,e.__scopeTooltip),i=C.useRef(null),o=iL(t,i),[s,a]=C.useState(null),{trigger:l,onClose:d}=n,c=i.current,{onPointerInTransitChange:u}=r,h=C.useCallback(()=>{a(null),u(!1)},[u]),p=C.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=ak(r,n.getBoundingClientRect());a(aI([...aP(r,i),...aT(t.getBoundingClientRect())])),u(!0)},[u]);return C.useEffect(()=>()=>h(),[h]),C.useEffect(()=>{if(l&&c){let e=an(e=>p(e,c),"handleTriggerLeave"),t=an(e=>p(e,l),"handleContentLeave");return l.addEventListener("pointerleave",e),c.addEventListener("pointerleave",t),()=>{l.removeEventListener("pointerleave",e),c.removeEventListener("pointerleave",t)}}},[l,c,p,h]),C.useEffect(()=>{if(s){let e=an(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=l?.contains(t)||c?.contains(t),i=!aE(n,s);r?h():i&&(h(),d())},"handleTrackPointerGrace");return document.addEventListener("pointermove",e),()=>document.removeEventListener("pointermove",e)}},[l,c,s,d,h]),(0,b.jsx)(aS,{...e,ref:o})},"TooltipContentHoverable")),av=iV("TooltipContent"),aS=C.forwardRef(an(function(e,t){let{__scopeTooltip:n,children:r,"aria-label":i,id:o,onEscapeKeyDown:s,onPointerDownOutside:a,...l}=e,d=ah(ab,n),c=ao(n),{onClose:u}=d;C.useEffect(()=>(document.addEventListener(as,u),()=>document.removeEventListener(as,u)),[u]),C.useEffect(()=>{if(d.trigger){let e=an(e=>{e.target instanceof Node&&e.target.contains(d.trigger)&&u()},"handleScroll");return window.addEventListener("scroll",e,{capture:!0}),()=>window.removeEventListener("scroll",e,{capture:!0})}},[d.trigger,u]);let{setContentId:h}=d;return oc(()=>(h(o),()=>{h(void 0)}),[o,h]),(0,b.jsx)(ot,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,b.jsxs)(sF,{"data-state":d.stateAttribute,role:i?void 0:"tooltip",id:i?void 0:d.contentId,...c,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[(0,b.jsx)(av,{children:r}),i?(0,b.jsx)(ae,{id:d.contentId,role:"tooltip",children:i}):null]})})},"TooltipContentImpl")),aC=C.forwardRef(an(function(e,t){let{__scopeTooltip:n,...r}=e,i=ao(n);return(0,b.jsx)(sz,{...i,...r,ref:t})},"TooltipArrow"));function ak(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(n,r,i,o)){case o:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw Error("unreachable")}}function aP(e,t,n=5){let r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}function aT(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function aE(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,o=t.length-1;e<t.length;o=e++){let s=t[e],a=t[o],l=s.x,d=s.y,c=a.x,u=a.y;d>r!=u>r&&n<(c-l)*(r-d)/(u-d)+l&&(i=!i)}return i}function aI(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:1*!!(e.y>t.y)),a_(t)}function a_(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return(n.pop(),1===t.length&&1===n.length&&t[0].x===n[0].x&&t[0].y===n[0].y)?t:t.concat(n)}an(ak,"getExitSideFromRect"),an(aP,"getPaddedExitPoints"),an(aT,"getPointsFromRect"),an(aE,"isPointInPolygon"),an(aI,"getHull"),an(a_,"getHullPresorted");let aM=(0,C.createContext)({orientation:"horizontal",tooltipSide:"bottom"});function aA({children:e,orientation:t,tooltipSide:n}){let r=aj(),i=n??(t===r.orientation?r.tooltipSide:"horizontal"===t?"bottom":"right");return(0,b.jsx)(aM.Provider,{value:{orientation:t,tooltipSide:i},children:e})}function aj(){return(0,C.useContext)(aM)}let aO=(0,C.forwardRef)(({asChild:e,className:t,tooltipSide:n,...r},i)=>(0,b.jsx)(aA,{orientation:"horizontal",tooltipSide:n,children:(0,b.jsx)(e?iW:"div",{ref:i,className:ik("tlui-row",t),...r})})),aD=(0,C.forwardRef)(({asChild:e,className:t,tooltipSide:n,...r},i)=>(0,b.jsx)(aA,{orientation:"vertical",tooltipSide:n,children:(0,b.jsx)(e?iW:"div",{ref:i,className:ik("tlui-column",t),...r})})),aL=(0,C.forwardRef)(({asChild:e,className:t,tooltipSide:n,...r},i)=>(0,b.jsx)(aA,{orientation:"horizontal",tooltipSide:n,children:(0,b.jsx)(e?iW:"div",{ref:i,className:ik("tlui-grid",t),...r})}));class aF{static instance=null;state=(0,h.eUv)("tooltip state",{name:"idle"});static getInstance(){return aF.instance||(aF.instance=new aF),aF.instance}hideAllTooltips(){this.handleEvent({type:"hide_all"})}handleEvent(e){let t=this.state.get();switch(e.type){case"pointer_down":"waiting_to_hide"===t.name&&clearTimeout(t.timeoutId),this.state.set({name:"pointer_down"});break;case"pointer_up":"pointer_down"===t.name&&this.state.set({name:"idle"});break;case"show":if("pointer_down"===t.name)return;"waiting_to_hide"===t.name&&clearTimeout(t.timeoutId),this.state.set({name:"showing",tooltip:e.tooltip});break;case"hide":{let{tooltipId:n,editor:r,instant:i}=e;if("showing"===t.name&&t.tooltip.id===n)if(r&&!i){let e=r.timers.setTimeout(()=>{let e=this.state.get();"waiting_to_hide"===e.name&&e.tooltip.id===n&&this.state.set({name:"idle"})},300);this.state.set({name:"waiting_to_hide",tooltip:t.tooltip,timeoutId:e})}else this.state.set({name:"idle"});else"waiting_to_hide"===t.name&&t.tooltip.id===n&&i&&(clearTimeout(t.timeoutId),this.state.set({name:"idle"}));break}case"hide_all":if("waiting_to_hide"===t.name&&clearTimeout(t.timeoutId),"pointer_down"===t.name)return;this.state.set({name:"idle"})}}getCurrentTooltipData(){let e=this.state.get(),t=null;return("showing"===e.name?t=e.tooltip:"waiting_to_hide"===e.name&&(t=e.tooltip),t&&(!h.$Gt.get().isCoarsePointer||t.showOnMobile))?t:null}}let aR=aF.getInstance();function az(){aR.hideAllTooltips()}let aN=(0,C.createContext)(!1);function a$({children:e}){return(0,b.jsx)(ad,{skipDelayDuration:700,children:(0,b.jsxs)(aN.Provider,{value:!0,children:[e,(0,b.jsx)(aB,{})]})})}function aB(){let[e,t]=(0,C.useState)(!1),n=(0,C.useRef)(null),r=(0,C.useRef)(!0),i=(0,h.frr)(),o=B(),s=(0,h.hau)("current tooltip",()=>aR.getCurrentTooltipData(),[]),a=(0,h.hau)("camera state",()=>i?.getCameraState(),[i]);return((0,C.useEffect)(()=>{"moving"===a&&e&&s&&aR.handleEvent({type:"hide",tooltipId:s.id,editor:i,instant:!0})},[a,e,s,i]),(0,C.useEffect)(()=>{let t=i?.getContainerDocument()??(0,h.jLo)();function n(t){"Escape"===t.key&&s&&e&&(az(),t.stopPropagation())}return t.addEventListener("keydown",n,{capture:!0}),()=>{t.removeEventListener("keydown",n,{capture:!0})}},[i,s,e]),(0,C.useEffect)(()=>{let e=i?.getContainerDocument()??(0,h.jLo)();function t(){aR.handleEvent({type:"pointer_down"})}function n(){aR.handleEvent({type:"pointer_up"})}return e.addEventListener("pointerdown",t,{capture:!0}),e.addEventListener("pointerup",n,{capture:!0}),e.addEventListener("pointercancel",n,{capture:!0}),()=>{e.removeEventListener("pointerdown",t,{capture:!0}),e.removeEventListener("pointerup",n,{capture:!0}),e.removeEventListener("pointercancel",n,{capture:!0}),aR.handleEvent({type:"pointer_up"})}},[i]),(0,C.useEffect)(()=>{let e=null;if(s&&n.current){let i=s.targetElement.getBoundingClientRect(),o=n.current;o.style.position="fixed",o.style.left="0px",o.style.top="0px";let a=o.getBoundingClientRect();o.style.left=`${i.left-a.left}px`,o.style.top=`${i.top-a.top}px`,o.style.width=`${i.width}px`,o.style.height=`${i.height}px`,o.style.pointerEvents="none",o.style.zIndex="9999",r.current?e=setTimeout(()=>{t(!0),r.current=!1},s.delayDuration):t(!0)}else t(!1),r.current=!0;return()=>{null!==e&&clearTimeout(e)}},[s]),s)?(0,b.jsxs)(ap,{open:e,delayDuration:0,children:[(0,b.jsx)(ag,{asChild:!0,children:(0,b.jsx)("div",{ref:n})}),(0,b.jsxs)(ax,{className:"tlui-tooltip",side:s.side,sideOffset:s.sideOffset,avoidCollisions:!0,collisionPadding:8,dir:o,children:[s.content,(0,b.jsx)(aC,{className:"tlui-tooltip__arrow"})]})]}):null}let aH=(0,C.forwardRef)(({children:e,content:t,side:n,sideOffset:r=5,disabled:i=!1,showOnMobile:o=!1,delayDuration:s},a)=>{let l,d=(0,h.frr)(),c=B(),u=(0,C.useRef)((0,h.NF7)()),p=(0,C.useContext)(aN),f=(0,h.hau)("enhancedA11yMode",()=>d?.user.getEnhancedA11yMode(),[d]),g=aj(),m=n??g.tooltipSide;if((0,C.useEffect)(()=>{let e=u.current;return()=>{p&&aR.handleEvent({type:"hide",tooltipId:e,editor:d,instant:!0})}},[d,p]),i||!t)return(0,b.jsx)(b.Fragment,{children:e});if(l=f?0:s??(d?.options.tooltipDelayMs||700),!p||f)return(0,b.jsxs)(ap,{delayDuration:l,disableHoverableContent:!f,children:[(0,b.jsx)(ag,{asChild:!0,ref:a,children:e}),(0,b.jsxs)(ax,{className:"tlui-tooltip",side:m,sideOffset:r,avoidCollisions:!0,collisionPadding:8,dir:c,children:[t,(0,b.jsx)(aC,{className:"tlui-tooltip__arrow"})]})]});let y=C.Children.only(e);return(0,h.vAR)(C.isValidElement(y),"TldrawUiTooltip children must be a single element"),C.cloneElement(y,{onMouseEnter:e=>{y.props.onMouseEnter?.(e),aR.handleEvent({type:"show",tooltip:{id:u.current,content:t,targetElement:e.currentTarget,side:m,sideOffset:r,showOnMobile:o,delayDuration:l}})},onMouseLeave:e=>{y.props.onMouseLeave?.(e),aR.handleEvent({type:"hide",tooltipId:u.current,editor:d,instant:!1})},onFocus:e=>{y.props.onFocus?.(e),aR.handleEvent({type:"show",tooltip:{id:u.current,content:t,targetElement:e.currentTarget,side:m,sideOffset:r,showOnMobile:o,delayDuration:l}})},onBlur:e=>{y.props.onBlur?.(e),aR.handleEvent({type:"hide",tooltipId:u.current,editor:d,instant:!1})}})}),aU={normal:"tlui-button__normal",primary:"tlui-button__primary",danger:"tlui-button__danger",low:"tlui-button__low",icon:"tlui-button__icon",tool:"tlui-button__tool",menu:"tlui-button__menu",help:"tlui-button__help"},aW=C.forwardRef(function({children:e,type:t,htmlButtonType:n,isActive:r,tooltip:i,...o},s){let a=(0,b.jsx)("button",{ref:s,type:n||"button",draggable:!1,"data-isactive":r,...o,className:ik("tlui-button",aU[t],o.className),"aria-label":o["aria-label"]??o.title,title:i?void 0:o.title,children:e});return i?(0,b.jsx)(aH,{content:i,children:a}):a});function aK({children:e}){return(0,b.jsx)("span",{className:"tlui-button__label",children:e})}var aV=Object.defineProperty,aY=(e,t)=>aV(e,"name",{value:t,configurable:!0}),aG="focusScope.autoFocusOnMount",aq="focusScope.autoFocusOnUnmount",aX={bubbles:!1,cancelable:!0},aJ=C.forwardRef(aY(function(e,t){let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:o,...s}=e,[a,l]=C.useState(null),d=i4(i),c=i4(o),u=C.useRef(null),h=iL(t,l),p=C.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;C.useEffect(()=>{if(r){let e=function(e){if(p.paused||!a)return;let t=e.target;a.contains(t)?u.current=t:a5(u.current,{select:!0})},t=function(e){if(p.paused||!a)return;let t=e.relatedTarget;null!==t&&(a.contains(t)||a5(u.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&a5(a)};aY(e,"handleFocusIn"),aY(t,"handleFocusOut"),aY(n,"handleMutations"),document.addEventListener("focusin",e),document.addEventListener("focusout",t);let r=new MutationObserver(n);return a&&r.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),r.disconnect()}}},[r,a,p.paused]),C.useEffect(()=>{if(a){a6.add(p);let e=document.activeElement;if(!a.contains(e)){let t=new CustomEvent(aG,aX);a.addEventListener(aG,d),a.dispatchEvent(t),t.defaultPrevented||(aZ(a9(a0(a)),{select:!0}),document.activeElement===e&&a5(a))}return()=>{a.removeEventListener(aG,d),setTimeout(()=>{let t=new CustomEvent(aq,aX);a.addEventListener(aq,c),a.dispatchEvent(t),t.defaultPrevented||a5(e??document.body,{select:!0}),a.removeEventListener(aq,c),a6.remove(p)},0)}}},[a,d,c,p]);let f=C.useCallback(e=>{if(!n&&!r||p.paused)return;let t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,o]=aQ(t);r&&o?e.shiftKey||i!==o?e.shiftKey&&i===r&&(e.preventDefault(),n&&a5(o,{select:!0})):(e.preventDefault(),n&&a5(r,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,b.jsx)(i5.div,{tabIndex:-1,...s,ref:h,onKeyDown:f})},"FocusScope"));function aZ(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(a5(r,{select:t}),document.activeElement!==n)return}function aQ(e){let t=a0(e);return[a1(t,e),a1(t.reverse(),e)]}function a0(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:aY(e=>{let t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}function a1(e,t){let n="function"==typeof t.checkVisibility&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):a2(r,{upTo:t})))return r}function a2(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e&&(void 0===t||e!==t);){if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function a3(e){return e instanceof HTMLInputElement&&"select"in e}function a5(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&a3(e)&&t&&e.select()}}aY(aZ,"focusFirst"),aY(aQ,"getTabbableEdges"),aY(a0,"getTabbableCandidates"),aY(a1,"findVisible"),aY(a2,"isHidden"),aY(a3,"isSelectableInput"),aY(a5,"focus");var a6=a4();function a4(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),(e=a8(e,t)).unshift(t)},remove(t){e=a8(e,t),e[0]?.resume()}}}function a8(e,t){let n=[...e],r=n.indexOf(t);return -1!==r&&n.splice(r,1),n}function a9(e){return e.filter(e=>"A"!==e.tagName)}aY(a4,"createFocusScopesStack"),aY(a8,"arrayRemove"),aY(a9,"removeLinks");var a7=Object.defineProperty,le=C.forwardRef(a7(function(e,t){let{container:n,...r}=e,[i,o]=C.useState(!1);oc(()=>o(!0),[]);let s=n||i&&globalThis?.document?.body;return s?i$.createPortal((0,b.jsx)(i5.div,{...r,ref:t}),s):null},"name",{value:"Portal",configurable:!0})),lt=Object.defineProperty,ln=(e,t)=>lt(e,"name",{value:t,configurable:!0}),lr=0,li=null;function lo(){C.useEffect(()=>{li||(li={start:ls(),end:ls()});let{start:e,end:t}=li;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),lr++,()=>{1===lr&&(li?.start.remove(),li?.end.remove(),li=null),lr=Math.max(0,lr-1)}},[])}function ls(){let e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}ln(function(e){return lo(),e.children},"FocusGuards"),ln(lo,"useFocusGuards"),ln(ls,"createFocusGuard");var la=function(){return(la=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function ll(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>t.indexOf(r)&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)0>t.indexOf(r[i])&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}var ld=("function"==typeof SuppressedError&&SuppressedError,"right-scroll-bar-position"),lc="width-before-scroll-bar";function lu(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var lh="u">typeof window?C.useLayoutEffect:C.useEffect,lp=new WeakMap,lf=(void 0===i&&(i={}),(void 0===o&&(o=function(e){return e}),s=[],a=!1,l={read:function(){if(a)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return s.length?s[s.length-1]:null},useMedium:function(e){var t=o(e,a);return s.push(t),function(){s=s.filter(function(e){return e!==t})}},assignSyncMedium:function(e){for(a=!0;s.length;){var t=s;s=[],t.forEach(e)}s={push:function(t){return e(t)},filter:function(){return s}}},assignMedium:function(e){a=!0;var t=[];if(s.length){var n=s;s=[],n.forEach(e),t=s}var r=function(){var n=t;t=[],n.forEach(e)},i=function(){return Promise.resolve().then(r)};i(),s={push:function(e){t.push(e),i()},filter:function(e){return t=t.filter(e),s}}}}).options=la({async:!0,ssr:!1},i),l),lg=function(){},lm=C.forwardRef(function(e,t){var n,r,i,o,s=C.useRef(null),a=C.useState({onScrollCapture:lg,onWheelCapture:lg,onTouchMoveCapture:lg}),l=a[0],d=a[1],c=e.forwardProps,u=e.children,h=e.className,p=e.removeScrollBar,f=e.enabled,g=e.shards,m=e.sideCar,y=e.noRelative,b=e.noIsolation,x=e.inert,w=e.allowPinchZoom,v=e.as,S=e.gapMode,k=ll(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),P=(n=[s,t],r=function(e){return n.forEach(function(t){return lu(t,e)})},(i=(0,C.useState)(function(){return{value:null,callback:r,facade:{get current(){return i.value},set current(value){var e=i.value;e!==value&&(i.value=value,i.callback(value,e))}}}})[0]).callback=r,o=i.facade,lh(function(){var e=lp.get(o);if(e){var t=new Set(e),r=new Set(n),i=o.current;t.forEach(function(e){r.has(e)||lu(e,null)}),r.forEach(function(e){t.has(e)||lu(e,i)})}lp.set(o,n)},[n]),o),T=la(la({},k),l);return C.createElement(C.Fragment,null,f&&C.createElement(m,{sideCar:lf,removeScrollBar:p,shards:g,noRelative:y,noIsolation:b,inert:x,setCallbacks:d,allowPinchZoom:!!w,lockRef:s,gapMode:S}),c?C.cloneElement(C.Children.only(u),la(la({},T),{ref:P})):C.createElement(void 0===v?"div":v,la({},T,{className:h,ref:P}),u))});lm.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},lm.classNames={fullWidth:lc,zeroRight:ld};var ly=function(e){var t=e.sideCar,n=ll(e,["sideCar"]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error("Sidecar medium not found");return C.createElement(r,la({},n))};ly.isSideCarExport=!0;var lb=function(){var e=0,t=null;return{add:function(r){if(0==e&&(t=function(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=u||n.nc;return t&&e.setAttribute("nonce",t),e}())){var i,o;(i=t).styleSheet?i.styleSheet.cssText=r:i.appendChild(document.createTextNode(r)),o=t,(document.head||document.getElementsByTagName("head")[0]).appendChild(o)}e++},remove:function(){--e||!t||(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},lx=function(){var e=lb();return function(t,n){C.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},lw=function(){var e=lx();return function(t){return e(t.styles,t.dynamic),null}},lv={left:0,top:0,right:0,gap:0},lS=function(e){return parseInt(e||"",10)||0},lC=function(e){var t=window.getComputedStyle(document.body),n=t["padding"===e?"paddingLeft":"marginLeft"],r=t["padding"===e?"paddingTop":"marginTop"],i=t["padding"===e?"paddingRight":"marginRight"];return[lS(n),lS(r),lS(i)]},lk=function(e){if(void 0===e&&(e="margin"),"u"<typeof window)return lv;var t=lC(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},lP=lw(),lT="data-scroll-locked",lE=function(e,t,n,r){var i=e.left,o=e.top,s=e.right,a=e.gap;return void 0===n&&(n="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(r,";\n padding-right: ").concat(a,"px ").concat(r,";\n }\n body[").concat(lT,"] {\n overflow: hidden ").concat(r,";\n overscroll-behavior: contain;\n ").concat([t&&"position: relative ".concat(r,";"),"margin"===n&&"\n padding-left: ".concat(i,"px;\n padding-top: ").concat(o,"px;\n padding-right: ").concat(s,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(a,"px ").concat(r,";\n "),"padding"===n&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),"\n }\n \n .").concat(ld," {\n right: ").concat(a,"px ").concat(r,";\n }\n \n .").concat(lc," {\n margin-right: ").concat(a,"px ").concat(r,";\n }\n \n .").concat(ld," .").concat(ld," {\n right: 0 ").concat(r,";\n }\n \n .").concat(lc," .").concat(lc," {\n margin-right: 0 ").concat(r,";\n }\n \n body[").concat(lT,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(a,"px;\n }\n")},lI=function(){var e=parseInt(document.body.getAttribute(lT)||"0",10);return isFinite(e)?e:0},l_=function(){C.useEffect(function(){return document.body.setAttribute(lT,(lI()+1).toString()),function(){var e=lI()-1;e<=0?document.body.removeAttribute(lT):document.body.setAttribute(lT,e.toString())}},[])},lM=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=void 0===r?"margin":r;l_();var o=C.useMemo(function(){return lk(i)},[i]);return C.createElement(lP,{styles:lE(o,!t,i,n?"":"!important")})},lA=!1;if("u">typeof window)try{var lj=Object.defineProperty({},"passive",{get:function(){return lA=!0,!0}});window.addEventListener("test",lj,lj),window.removeEventListener("test",lj,lj)}catch(e){lA=!1}var lO=!!lA&&{passive:!1},lD=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return"hidden"!==n[t]&&(n.overflowY!==n.overflowX||"TEXTAREA"===e.tagName||"visible"!==n[t])},lL=function(e,t){var n=t.ownerDocument,r=t;do{if("u">typeof ShadowRoot&&r instanceof ShadowRoot&&(r=r.host),lF(e,r)){var i=lR(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},lF=function(e,t){return"v"===e?lD(t,"overflowY"):lD(t,"overflowX")},lR=function(e,t){return"v"===e?[t.scrollTop,t.scrollHeight,t.clientHeight]:[t.scrollLeft,t.scrollWidth,t.clientWidth]},lz=function(e,t,n,r,i){var o,s=(o=window.getComputedStyle(t).direction,"h"===e&&"rtl"===o?-1:1),a=s*r,l=n.target,d=t.contains(l),c=!1,u=a>0,h=0,p=0;do{if(!l)break;var f=lR(e,l),g=f[0],m=f[1]-f[2]-s*g;(g||m)&&lF(e,l)&&(h+=m,p+=g);var y=l.parentNode;l=y&&y.nodeType===Node.DOCUMENT_FRAGMENT_NODE?y.host:y}while(!d&&l!==document.body||d&&(t.contains(l)||t===l));return u&&(i&&1>Math.abs(h)||!i&&a>h)?c=!0:!u&&(i&&1>Math.abs(p)||!i&&-a>p)&&(c=!0),c},lN=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},l$=function(e){return[e.deltaX,e.deltaY]},lB=function(e){return e&&"current"in e?e.current:e},lH=0,lU=[];let lW=(d=function(e){var t=C.useRef([]),n=C.useRef([0,0]),r=C.useRef(),i=C.useState(lH++)[0],o=C.useState(lw)[0],s=C.useRef(e);C.useEffect(function(){s.current=e},[e]),C.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var t=(function(e,t,n){if(n||2==arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))})([e.lockRef.current],(e.shards||[]).map(lB),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),t.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=C.useCallback(function(e,t){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!s.current.allowPinchZoom;var i,o=lN(e),a=n.current,l="deltaX"in e?e.deltaX:a[0]-o[0],d="deltaY"in e?e.deltaY:a[1]-o[1],c=e.target,u=Math.abs(l)>Math.abs(d)?"h":"v";if("touches"in e&&"h"===u&&"range"===c.type)return!1;var h=window.getSelection(),p=h&&h.anchorNode;if(p&&(p===c||p.contains(c)))return!1;var f=lL(u,c);if(!f)return!0;if(f?i=u:(i="v"===u?"h":"v",f=lL(u,c)),!f)return!1;if(!r.current&&"changedTouches"in e&&(l||d)&&(r.current=i),!i)return!0;var g=r.current||i;return lz(g,t,e,"h"===g?l:d,!0)},[]),l=C.useCallback(function(e){if(lU.length&&lU[lU.length-1]===o){var n="deltaY"in e?l$(e):lN(e),r=t.current.filter(function(t){var r;return t.name===e.type&&(t.target===e.target||e.target===t.shadowParent)&&(r=t.delta,r[0]===n[0]&&r[1]===n[1])})[0];if(r&&r.should){e.cancelable&&e.preventDefault();return}if(!r){var i=(s.current.shards||[]).map(lB).filter(Boolean).filter(function(t){return t.contains(e.target)});(i.length>0?a(e,i[0]):!s.current.noIsolation)&&e.cancelable&&e.preventDefault()}}},[]),d=C.useCallback(function(e,n,r,i){var o={name:e,delta:n,target:r,should:i,shadowParent:function(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}(r)};t.current.push(o),setTimeout(function(){t.current=t.current.filter(function(e){return e!==o})},1)},[]),c=C.useCallback(function(e){n.current=lN(e),r.current=void 0},[]),u=C.useCallback(function(t){d(t.type,l$(t),t.target,a(t,e.lockRef.current))},[]),h=C.useCallback(function(t){d(t.type,lN(t),t.target,a(t,e.lockRef.current))},[]);C.useEffect(function(){return lU.push(o),e.setCallbacks({onScrollCapture:u,onWheelCapture:u,onTouchMoveCapture:h}),document.addEventListener("wheel",l,lO),document.addEventListener("touchmove",l,lO),document.addEventListener("touchstart",c,lO),function(){lU=lU.filter(function(e){return e!==o}),document.removeEventListener("wheel",l,lO),document.removeEventListener("touchmove",l,lO),document.removeEventListener("touchstart",c,lO)}},[]);var p=e.removeScrollBar,f=e.inert;return C.createElement(C.Fragment,null,f?C.createElement(o,{styles:"\n .block-interactivity-".concat(i," {pointer-events: none;}\n .allow-interactivity-").concat(i," {pointer-events: all;}\n")}):null,p?C.createElement(lM,{noRelative:e.noRelative,gapMode:e.gapMode}):null)},lf.useMedium(d),ly);var lK=C.forwardRef(function(e,t){return C.createElement(lm,la({},e,{ref:t,sideCar:lW}))});lK.classNames=lm.classNames;var lV=new WeakMap,lY=new WeakMap,lG={},lq=0,lX=function(e){return e&&(e.host||lX(e.parentNode))},lJ=function(e,t,n,r){var i=(Array.isArray(e)?e:[e]).map(function(e){if(t.contains(e))return e;var n=lX(e);return n&&t.contains(n)?n:(console.error("aria-hidden",e,"in not contained inside",t,". Doing nothing"),null)}).filter(function(e){return!!e});lG[n]||(lG[n]=new WeakMap);var o=lG[n],s=[],a=new Set,l=new Set(i),d=function(e){!e||a.has(e)||(a.add(e),d(e.parentNode))};i.forEach(d);var c=function(e){!e||l.has(e)||Array.prototype.forEach.call(e.children,function(e){if(a.has(e))c(e);else try{var t=e.getAttribute(r),i=null!==t&&"false"!==t,l=(lV.get(e)||0)+1,d=(o.get(e)||0)+1;lV.set(e,l),o.set(e,d),s.push(e),1===l&&i&&lY.set(e,!0),1===d&&e.setAttribute(n,"true"),i||e.setAttribute(r,"true")}catch(t){console.error("aria-hidden: cannot operate on ",e,t)}})};return c(t),a.clear(),lq++,function(){s.forEach(function(e){var t=lV.get(e)-1,i=o.get(e)-1;lV.set(e,t),o.set(e,i),t||(lY.has(e)||e.removeAttribute(r),lY.delete(e)),i||e.removeAttribute(n)}),--lq||(lV=new WeakMap,lV=new WeakMap,lY=new WeakMap,lG={})}},lZ=function(e,t,n){void 0===n&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=t||("u"<typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),lJ(r,i,n,"aria-hidden")):function(){return null}},lQ=Object.defineProperty,l0=(e,t)=>lQ(e,"name",{value:t,configurable:!0}),l1="Dialog",[l2,l3]=iz(l1),[l5,l6]=l2(l1),l4=l0(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:o,modal:s=!0}=e,a=C.useRef(null),l=C.useRef(null),[d,c]=s5({prop:r,defaultProp:i??!1,onChange:o,caller:l1}),[u,h]=C.useState(0),[p,f]=C.useState(0);return(0,b.jsx)(l5,{scope:t,triggerRef:a,contentRef:l,contentId:of(),titleId:of(),descriptionId:of(),titlePresent:u>0,descriptionPresent:p>0,setTitleCount:h,setDescriptionCount:f,open:d,onOpenChange:c,onOpenToggle:C.useCallback(()=>c(e=>!e),[c]),modal:s,children:n})},"Dialog"),l8="DialogPortal",[l9,l7]=l2(l8,{forceMount:void 0}),de=l0(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,o=l6(l8,t);return(0,b.jsx)(l9,{scope:t,forceMount:n,children:C.Children.map(r,e=>(0,b.jsx)(sK,{present:n||o.open,children:(0,b.jsx)(le,{asChild:!0,container:i,children:e})}))})},"DialogPortal"),dt="DialogOverlay",dn=C.forwardRef(l0(function(e,t){let n=l7(dt,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=l6(dt,e.__scopeDialog);return o.modal?(0,b.jsx)(sK,{present:r||o.open,children:(0,b.jsx)(di,{...i,ref:t})}):null},"DialogOverlay")),dr=iU("DialogOverlay.RemoveScroll"),di=C.forwardRef(l0(function(e,t){let{__scopeDialog:n,...r}=e,i=l6(dt,n),o=iL(t,or());return(0,b.jsx)(lK,{as:dr,allowPinchZoom:!0,shards:[i.contentRef],children:(0,b.jsx)(i5.div,{"data-state":dp(i.open),...r,ref:o,style:{pointerEvents:"auto",...r.style}})})},"DialogOverlayImpl")),ds="DialogContent",da=C.forwardRef(l0(function(e,t){let n=l7(ds,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=l6(ds,e.__scopeDialog);return(0,b.jsx)(sK,{present:r||o.open,children:o.modal?(0,b.jsx)(dl,{...i,ref:t}):(0,b.jsx)(dd,{...i,ref:t})})},"DialogContent")),dl=C.forwardRef(l0(function(e,t){let n=l6(ds,e.__scopeDialog),r=C.useRef(null),i=iL(t,n.contentRef,r);return C.useEffect(()=>{let e=r.current;if(e)return lZ(e)},[]),(0,b.jsx)(dc,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:iI(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:iI(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;(2===t.button||n)&&e.preventDefault()}),onFocusOutside:iI(e.onFocusOutside,e=>e.preventDefault())})},"DialogContentModal")),dd=C.forwardRef(l0(function(e,t){let n=l6(ds,e.__scopeDialog),r=C.useRef(!1),i=C.useRef(!1);return(0,b.jsx)(dc,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,"pointerdown"===t.detail.originalEvent.type&&(i.current=!0));let o=t.target;n.triggerRef.current?.contains(o)&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&i.current&&t.preventDefault()}})},"DialogContentNonModal")),dc=C.forwardRef(l0(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,...s}=e,a=l6(ds,n);return lo(),(0,b.jsx)(b.Fragment,{children:(0,b.jsx)(aJ,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o,children:(0,b.jsx)(ot,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionPresent?a.descriptionId:void 0,"aria-labelledby":a.titlePresent?a.titleId:void 0,"data-state":dp(a.open),...s,ref:t,deferPointerDownOutside:!0,onDismiss:()=>a.onOpenChange(!1)})})})},"DialogContentImpl")),du=C.forwardRef(l0(function(e,t){let{__scopeDialog:n,...r}=e,i=l6("DialogTitle",n),{setTitleCount:o}=i;return oc(()=>(o(e=>e+1),()=>o(e=>e-1)),[o]),(0,b.jsx)(i5.h2,{id:i.titleId,...r,ref:t})},"DialogTitle")),dh=C.forwardRef(l0(function(e,t){let{__scopeDialog:n,...r}=e,i=l6("DialogClose",n);return(0,b.jsx)(i5.button,{type:"button",...r,ref:t,onClick:iI(e.onClick,()=>i.onOpenChange(!1))})},"DialogClose"));function dp(e){return e?"open":"closed"}l0(dp,"getState");let df=(0,C.memo)(function({label:e,small:t,invertIcon:n,icon:r,tiny:i,color:o,className:s,...a}){return"string"==typeof r?(0,b.jsx)(dg,{label:e,small:t,tiny:i,invertIcon:n,icon:r,color:o,className:s,...a}):(0,C.cloneElement)(r,{...a,className:ik({"tlui-icon__small":t,"tlui-icon__tiny":i},s,r.props.className),"aria-label":e,style:{color:o,transform:n?"scale(-1, 1)":void 0,...r.props.style}})});function dg({label:e,small:t,tiny:n,invertIcon:r,icon:i,color:o,className:s,...a}){let l=O(),d=l.icons[i]??l.icons["question-mark-circle"],c=(0,C.useRef)(null);return((0,C.useLayoutEffect)(()=>{d||console.error(`Icon not found: ${i}. Add it to the assetUrls.icons object.`),c?.current&&(c.current.style.webkitMask=`url(${d}) center 100% / 100% no-repeat`)},[c,d,i]),"none"===i)?(0,b.jsx)("div",{className:ik("tlui-icon tlui-icon__placeholder",{"tlui-icon__small":t,"tlui-icon__tiny":n},s),...a}):(0,b.jsx)("div",{...a,ref:c,"aria-label":e,role:"img",className:ik("tlui-icon",{"tlui-icon__small":t,"tlui-icon__tiny":n},s),style:{color:o,mask:`url(${d}) center 100% / 100% no-repeat`,transform:r?"scale(-1, 1)":void 0}})}function dm({icon:e,small:t,invertIcon:n}){return(0,b.jsx)(df,{"aria-hidden":"true",label:"",className:"tlui-button__icon",icon:e,small:t,invertIcon:n})}function dy({className:e,children:t}){return(0,b.jsx)("div",{className:ik("tlui-dialog__header",e),children:t})}function db({className:e,children:t,style:n}){let r=B();return(0,b.jsx)(du,{dir:r,className:ik("tlui-dialog__header__title",e),style:n,children:t})}function dx(){let e=$(),t=B();return(0,b.jsx)("div",{className:"tlui-dialog__header__close",children:(0,b.jsx)(dh,{"data-testid":"dialog.close",dir:t,asChild:!0,children:(0,b.jsx)(aW,{type:"icon","aria-label":e("ui.close"),onTouchEnd:e=>e.target.click(),children:(0,b.jsx)(dm,{small:!0,icon:"cross-2"})})})})}function dw({className:e,children:t,style:n}){return(0,b.jsx)("div",{className:ik("tlui-dialog__body",e),style:n,tabIndex:0,children:t})}function dv({className:e,children:t}){return(0,b.jsx)("div",{className:ik("tlui-dialog__footer",e),children:t})}let dS=C.forwardRef(function({className:e,label:t,icon:n,iconLeft:r,iconLabel:i,autoSelect:o=!1,autoFocus:s=!1,defaultValue:a,maxLength:l,placeholder:d,onComplete:c,onValueChange:u,onCancel:p,onFocus:f,onBlur:g,shouldManuallyMaintainScrollPositionWhenFocused:m=!1,children:y,value:x,"data-testid":w,disabled:v,"aria-label":S},k){let P=(0,h.frr)(),T=C.useRef(null);C.useImperativeHandle(k,()=>T.current);let E=$(),I=C.useRef(a??""),_=C.useRef(a??""),M=C.useRef(!1),[A,j]=C.useState(!1),O=C.useCallback(e=>{j(!0);let t=e.currentTarget;_.current=t.value,P?P.timers.requestAnimationFrame(()=>{o&&t.select()}):h.slq.requestAnimationFrame("anon",()=>{o&&t.select()}),f?.()},[o,P,f]),D=C.useCallback(e=>{let t=e.currentTarget.value;_.current=t,u?.(t)},[u]),L=C.useCallback(e=>{switch(e.key){case"Enter":if(M.current)return;e.currentTarget.blur(),e.stopPropagation(),c?.(e.currentTarget.value);break;case"Escape":e.currentTarget.value=I.current,p?.(e.currentTarget.value),e.currentTarget.blur(),e.stopPropagation()}},[c,p]),F=C.useCallback(e=>{j(!1);let t=e.currentTarget.value;g?.(t)},[g]),R=C.useCallback(()=>M.current=!0,[]),z=C.useCallback(()=>M.current=!1,[]);return C.useEffect(()=>{if(!h.YZA.isIos)return;let e=(P?.getContainerWindow()??window).visualViewport;if(A&&m&&e){let t=()=>{T.current?.scrollIntoView({block:"center"})};return e.addEventListener("resize",t),e.addEventListener("scroll",t),P?P.timers.requestAnimationFrame(()=>{T.current?.scrollIntoView({block:"center"})}):h.slq.requestAnimationFrame("anon",()=>{T.current?.scrollIntoView({block:"center"})}),()=>{e.removeEventListener("resize",t),e.removeEventListener("scroll",t)}}},[A,P,m]),(0,b.jsxs)("div",{draggable:!1,className:"tlui-input__wrapper",children:[y,t&&(0,b.jsx)("label",{children:E(t)}),r&&(0,b.jsx)(df,{label:i?E(i):"",icon:r,className:"tlui-icon-left",small:!0}),(0,b.jsx)("input",{ref:T,className:ik("tlui-input",e),type:"text",defaultValue:a,maxLength:l,onKeyDownCapture:L,onChange:D,onFocus:O,onBlur:F,onCompositionStart:R,onCompositionEnd:z,autoFocus:s,"aria-label":S,placeholder:d,value:x,"data-testid":w,disabled:v}),n&&(0,b.jsx)(df,{label:i?E(i):"",icon:n,small:!!t})]})});function dC(e){return h.T.linkUrl.isValid(e)?{isValid:!0,hasProtocol:!0}:h.T.linkUrl.isValid("https://"+e)?{isValid:!0,hasProtocol:!1}:{isValid:!1,hasProtocol:!1}}function dk(e){return!!(e&&"url"in e.props&&"string"==typeof e.props.url)}function dP(e){if(!dk(e))throw Error("Shape is not a valid ShapeWithUrl")}let dT=(0,h.u4I)(function({onClose:e}){let t=(0,h.hGv)().getOnlySelectedShape();return dk(t)?(0,b.jsx)(dE,{onClose:e,selectedShape:t}):null}),dE=(0,h.u4I)(function({onClose:e,selectedShape:t}){let n=(0,h.hGv)(),r=$(),i=(0,C.useRef)(null);(0,C.useEffect)(()=>{n.timers.requestAnimationFrame(()=>i.current?.focus())},[n]);let o=(0,C.useRef)(t.props.url),[s,a]=(0,C.useState)(()=>{let e=dC(t.props.url),n=!0===e.isValid?e.hasProtocol?t.props.url:"https://"+t.props.url:"https://";return{actual:n,safe:n,valid:!0}}),l=(0,C.useCallback)(e=>{let t=e.replace(/https?:\/\/(https?:\/\/)/,(e,t)=>t),n=dC(t),r=!0===n.isValid?n.hasProtocol?t:"https://"+t:"https://";a({actual:t,safe:r,valid:n.isValid})},[]),d=(0,C.useCallback)(()=>{let t=n.getOnlySelectedShape();t&&(dP(t),n.updateShapes([{id:t.id,type:t.type,props:{url:""}}]),e())},[n,e]),c=(0,C.useCallback)(()=>{let t=n.getOnlySelectedShape();t&&(dP(t),t&&"url"in t.props&&t.props.url!==s.safe&&n.updateShapes([{id:t.id,type:t.type,props:{url:s.safe}}]),e())},[n,e,s]),u=(0,C.useCallback)(()=>{e()},[e]);if(!t)return e(),null;let p=o.current&&!s.valid;return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(dy,{children:[(0,b.jsx)(db,{children:r("edit-link-dialog.title")}),(0,b.jsx)(dx,{})]}),(0,b.jsx)(dw,{children:(0,b.jsxs)("div",{className:"tlui-edit-link-dialog",children:[(0,b.jsx)(dS,{ref:i,className:"tlui-edit-link-dialog__input",label:"edit-link-dialog.url",autoFocus:!0,autoSelect:!0,placeholder:"https://example.com",value:s.actual,onValueChange:l,onComplete:c,onCancel:u}),(0,b.jsx)("div",{children:r(s.valid?"edit-link-dialog.detail":"edit-link-dialog.invalid-url")})]})}),(0,b.jsxs)(dv,{className:"tlui-dialog__footer__actions",children:[(0,b.jsx)(aW,{type:"normal",onClick:u,onTouchEnd:u,children:(0,b.jsx)(aK,{children:r("edit-link-dialog.cancel")})}),p?(0,b.jsx)(aW,{type:"danger",onTouchEnd:d,onClick:d,children:(0,b.jsx)(aK,{children:r("edit-link-dialog.clear")})}):(0,b.jsx)(aW,{type:"primary",disabled:!s.valid,onTouchEnd:c,onClick:c,children:(0,b.jsx)(aK,{children:r("edit-link-dialog.save")})})]})]})});var dI=n(41463);let d_=/(^\/[f|p|r|ro|s|v]\/[^/]+\/?$)/,dM=[{type:"tldraw",title:"tldraw",hostnames:["beta.tldraw.com","tldraw.com","localhost:3000"],minWidth:300,minHeight:300,width:720,height:500,doesResize:!0,overridePermissions:{"allow-top-navigation":!0},toEmbedUrl:e=>{let t=(0,h.yCG)(e);if(t&&t.pathname.match(d_))return t.searchParams.append("embed","true"),e},fromEmbedUrl:e=>{let t=(0,h.yCG)(e);if(t&&t.pathname.match(d_))return t.searchParams.delete("embed"),e},embedOnPaste:!1},{type:"figma",title:"Figma",hostnames:["figma.com"],width:720,height:500,doesResize:!0,toEmbedUrl:e=>{if(e.match(/https:\/\/([\w\.-]+\.)?figma.com\/(file|proto|design)\/([0-9a-zA-Z]{22,128})(?:\/.*)?$/)&&!e.includes("figma.com/embed"))return`https://www.figma.com/embed?embed_host=share&url=${e}`},fromEmbedUrl:e=>{let t=(0,h.yCG)(e);if(t&&t.pathname.match(/^\/embed\/?$/)){let e=t.searchParams.get("url");if(e)return e}},embedOnPaste:!0},{type:"canva",title:"Canva",hostnames:["canva.com"],width:720,height:500,doesResize:!0,toEmbedUrl:e=>{let t=(0,h.yCG)(e);if(t&&t.pathname.match(/^\/design\/([^/]+)\/.+/)&&!t.searchParams.has("embed"))return t.searchParams.set("embed",""),t.href},fromEmbedUrl:e=>{let t=(0,h.yCG)(e);if(t&&t.pathname.match(/^\/design\/([^/]+)\/.+/)&&t.searchParams.has("embed"))return t.searchParams.delete("embed"),t.href},embedOnPaste:!0},{type:"google_maps",title:"Google Maps",hostnames:["google.*"],width:720,height:500,doesResize:!0,overridePermissions:{"allow-presentation":!0},toEmbedUrl:(e,t)=>{if(e.includes("/maps/embed?"))return e;if(e.includes("/maps/")){let n,r=e.match(/@(.*?),(.*?),(.*?)(z|m)/);if(r){let[,i,o,s,a]=r,l="z"===a?"roadmap":"satellite",d="roadmap"===l?s:-Math.log2(parseInt(s)/0xe16861)/.8,c=new URL(e).host.replace("www.",""),u=t?.apiKey??dI.env.NEXT_PUBLIC_GC_API_KEY;n=`https://${c}/maps/embed/v1/view?key=${u}¢er=${i},${o}&zoom=${d}&maptype=${l}`}else n="";return n}},fromEmbedUrl:e=>{let t=(0,h.yCG)(e);if(t&&t.pathname.match(/^\/maps\/embed\/v1\/view\/?$/)&&t.searchParams.has("center")&&t.searchParams.get("zoom")){let e=t.searchParams.get("zoom")??"12",n=t.searchParams.get("maptype")??"roadmap",r="roadmap"===n?e:0xe16861*Math.pow(2,-.8*parseInt(e)),[i,o]=t.searchParams.get("center").split(",");return`https://www.google.com/maps/@${i},${o},${r}${"roadmap"===n?"z":"m"}`}},embedOnPaste:!0},{type:"val_town",title:"Val Town",hostnames:["val.town"],minWidth:260,minHeight:100,width:720,height:500,doesResize:!0,toEmbedUrl:e=>{let t=(0,h.yCG)(e),n=t&&t.pathname.match(/\/v\/(.+)\/?/);if(n)return`https://www.val.town/embed/${n[1]}`},fromEmbedUrl:e=>{let t=(0,h.yCG)(e),n=t&&t.pathname.match(/\/embed\/(.+)\/?/);if(n)return`https://www.val.town/v/${n[1]}`},embedOnPaste:!0},{type:"codesandbox",title:"CodeSandbox",hostnames:["codesandbox.io"],minWidth:300,minHeight:300,width:720,height:500,doesResize:!0,toEmbedUrl:e=>{let t=(0,h.yCG)(e),n=t&&t.pathname.match(/\/s\/([^/]+)\/?/);if(n)return`https://codesandbox.io/embed/${n[1]}`},fromEmbedUrl:e=>{let t=(0,h.yCG)(e),n=t&&t.pathname.match(/\/embed\/([^/]+)\/?/);if(n)return`https://codesandbox.io/s/${n[1]}`},embedOnPaste:!0},{type:"codepen",title:"Codepen",hostnames:["codepen.io"],minWidth:300,minHeight:300,width:520,height:400,doesResize:!0,toEmbedUrl:e=>{let t=e.match(/https:\/\/codepen.io\/([^/]+)\/pen\/([^/]+)/);if(t){let[e,n,r]=t;return`https://codepen.io/${n}/embed/${r}`}},fromEmbedUrl:e=>{let t=e.match(/https:\/\/codepen.io\/([^/]+)\/embed\/([^/]+)/);if(t){let[e,n,r]=t;return`https://codepen.io/${n}/pen/${r}`}},embedOnPaste:!0},{type:"scratch",title:"Scratch",hostnames:["scratch.mit.edu"],width:520,height:400,doesResize:!1,embedOnPaste:!0,toEmbedUrl:e=>{let t=e.match(/https?:\/\/scratch.mit.edu\/projects\/([^/]+)/);if(t){let[e,n]=t;return`https://scratch.mit.edu/projects/embed/${n}`}},fromEmbedUrl:e=>{let t=e.match(/https:\/\/scratch.mit.edu\/projects\/embed\/([^/]+)/);if(t){let[e,n]=t;return`https://scratch.mit.edu/projects/${n}`}}},{type:"youtube",title:"YouTube",hostnames:["*.youtube.com","youtube.com","youtu.be"],width:800,height:450,doesResize:!0,overridePermissions:{"allow-presentation":!0,"allow-popups-to-escape-sandbox":!0},isAspectRatioLocked:!0,embedOnPaste:!0,toEmbedUrl:e=>{let t=(0,h.yCG)(e);if(!t)return;let n=t.hostname.replace(/^www./,"");if("youtu.be"===n){let e=t.pathname.split("/").filter(Boolean)[0],n=new URLSearchParams(t.search),r=n.get("t");r&&(n.set("start",r),n.delete("t"));let i=n.toString()?"?"+n.toString():"";return`https://www.youtube.com/embed/${e}${i}`}if(("youtube.com"===n||"m.youtube.com"===n)&&t.pathname.match(/^\/watch/)){let e=t.searchParams.get("v"),n=new URLSearchParams(t.search);n.delete("v");let r=n.get("t");r&&(n.set("start",r),n.delete("t"));let i=n.toString()?"?"+n.toString():"";return`https://www.youtube.com/embed/${e}${i}`}},fromEmbedUrl:e=>{let t=(0,h.yCG)(e);if(t&&"youtube.com"===t.hostname.replace(/^www./,"")){let e=t.pathname.match(/^\/embed\/([^/]+)\/?/);if(e){let n=new URLSearchParams(t.search);n.set("v",e?.[1]??"");let r=n.get("start");return r&&(n.set("t",r),n.delete("start")),`https://www.youtube.com/watch?${n.toString()}`}}}},{type:"google_calendar",title:"Google Calendar",hostnames:["calendar.google.*"],width:720,height:500,minWidth:460,minHeight:360,doesResize:!0,instructionLink:"https://support.google.com/calendar/answer/41207?hl=en",overridePermissions:{"allow-popups-to-escape-sandbox":!0},embedOnPaste:!0,toEmbedUrl:e=>{let t=(0,h.yCG)(e),n=t?.searchParams.get("cid");if(t?.pathname.match(/\/calendar\/u\/0/)&&n){for(let e of(t.pathname="/calendar/embed",Array.from(t.searchParams.keys())))t.searchParams.delete(e);return t.searchParams.set("src",n),t.href}},fromEmbedUrl:e=>{let t=(0,h.yCG)(e),n=t?.searchParams.get("src");if(t?.pathname.match(/\/calendar\/embed/)&&n){for(let e of(t.pathname="/calendar/u/0",Array.from(t.searchParams.keys())))t.searchParams.delete(e);return t.searchParams.set("cid",n),t.href}}},{type:"google_slides",title:"Google Slides",hostnames:["docs.google.*"],width:720,height:500,minWidth:460,minHeight:360,doesResize:!0,overridePermissions:{"allow-popups-to-escape-sandbox":!0},embedOnPaste:!0,toEmbedUrl:e=>{let t=(0,h.yCG)(e);if(t?.pathname.match(/^\/presentation/)&&t?.pathname.match(/\/pub\/?$/)){for(let e of(t.pathname=t.pathname.replace(/\/pub$/,"/embed"),Array.from(t.searchParams.keys())))t.searchParams.delete(e);return t.href}},fromEmbedUrl:e=>{let t=(0,h.yCG)(e);if(t?.pathname.match(/^\/presentation/)&&t?.pathname.match(/\/embed\/?$/)){for(let e of(t.pathname=t.pathname.replace(/\/embed$/,"/pub"),Array.from(t.searchParams.keys())))t.searchParams.delete(e);return t.href}}},{type:"github_gist",title:"GitHub Gist",hostnames:["gist.github.com"],width:720,height:500,doesResize:!0,embedOnPaste:!0,toEmbedUrl:e=>{let t=(0,h.yCG)(e);if(t&&t.pathname.match(/\/([^/]+)\/([0-9a-f]+)$/)){if(!e.split("/").pop())return;return e}},fromEmbedUrl:e=>{let t=(0,h.yCG)(e);if(t&&t.pathname.match(/\/([^/]+)\/([0-9a-f]+)$/)){if(!e.split("/").pop())return;return e}}},{type:"replit",title:"Replit",hostnames:["replit.com"],width:720,height:500,doesResize:!0,embedOnPaste:!0,toEmbedUrl:e=>{let t=(0,h.yCG)(e);if(t&&t.pathname.match(/\/@([^/]+)\/([^/]+)/))return t.searchParams.append("embed","true"),t.href},fromEmbedUrl:e=>{let t=(0,h.yCG)(e);if(t&&t.pathname.match(/\/@([^/]+)\/([^/]+)/)&&t.searchParams.has("embed"))return t.searchParams.delete("embed"),t.href}},{type:"felt",title:"Felt",hostnames:["felt.com"],width:720,height:500,doesResize:!0,embedOnPaste:!0,toEmbedUrl:e=>{let t=(0,h.yCG)(e);if(t&&t.pathname.match(/^\/map\//))return t.origin+"/embed"+t.pathname},fromEmbedUrl:e=>{let t=(0,h.yCG)(e);if(t&&t.pathname.match(/^\/embed\/map\//))return t.pathname=t.pathname.replace(/^\/embed/,""),t.href}},{type:"spotify",title:"Spotify",hostnames:["open.spotify.com"],width:720,height:500,minHeight:500,overrideOutlineRadius:12,doesResize:!0,embedOnPaste:!0,toEmbedUrl:e=>{let t=(0,h.yCG)(e);if(t&&t.pathname.match(/^\/(artist|album)\//))return t.origin+"/embed"+t.pathname},fromEmbedUrl:e=>{let t=(0,h.yCG)(e);if(t&&t.pathname.match(/^\/embed\/(artist|album)\//))return t.origin+t.pathname.replace(/^\/embed/,"")}},{type:"vimeo",title:"Vimeo",hostnames:["vimeo.com","player.vimeo.com"],width:640,height:360,doesResize:!0,isAspectRatioLocked:!0,embedOnPaste:!0,sizeToContentAspectRatio:!0,toEmbedUrl:e=>{let t=(0,h.yCG)(e);if(t&&"vimeo.com"===t.hostname&&t.pathname.match(/^\/[0-9]+/))return"https://player.vimeo.com/video/"+t.pathname.split("/")[1]+"?title=0&byline=0"},fromEmbedUrl:e=>{let t=(0,h.yCG)(e);if(t&&"player.vimeo.com"===t.hostname){let e=t.pathname.match(/^\/video\/([^/]+)\/?$/);if(e)return"https://vimeo.com/"+e[1]}}},{type:"observable",title:"Observable",hostnames:["observablehq.com"],width:720,height:500,doesResize:!0,isAspectRatioLocked:!1,backgroundColor:"#fff",embedOnPaste:!0,toEmbedUrl:e=>{let t=(0,h.yCG)(e);if(t&&t.pathname.match(/^\/@([^/]+)\/([^/]+)\/?$/))return`${t.origin}/embed${t.pathname}?cell=*`;if(t&&t.pathname.match(/^\/d\/([^/]+)\/?$/)){let e=t.pathname.replace(/^\/d/,"");return`${t.origin}/embed${e}?cell=*`}},fromEmbedUrl:e=>{let t=(0,h.yCG)(e);return t&&t.pathname.match(/^\/embed\/@([^/]+)\/([^/]+)\/?$/)?`${t.origin}${t.pathname.replace("/embed","")}#cell-*`:t&&t.pathname.match(/^\/embed\/([^/]+)\/?$/)?`${t.origin}${t.pathname.replace("/embed","/d")}#cell-*`:void 0}},{type:"desmos",title:"Desmos",hostnames:["desmos.com"],width:700,height:450,doesResize:!0,embedOnPaste:!0,toEmbedUrl:e=>{let t=(0,h.yCG)(e);if(t&&"www.desmos.com"===t.hostname&&t.pathname.match(/^\/calculator\/([^/]+)\/?$/)&&""===t.search&&""===t.hash)return`${e}?embed`},fromEmbedUrl:e=>{let t=(0,h.yCG)(e);if(t&&"www.desmos.com"===t.hostname&&t.pathname.match(/^\/calculator\/([^/]+)\/?$/)&&"?embed"===t.search&&""===t.hash)return e.replace("?embed","")}}],dA={"allow-downloads-without-user-activation":!1,"allow-downloads":!1,"allow-modals":!1,"allow-orientation-lock":!1,"allow-pointer-lock":!1,"allow-popups":!0,"allow-popups-to-escape-sandbox":!1,"allow-presentation":!1,"allow-storage-access-by-user-activation":!1,"allow-top-navigation":!1,"allow-top-navigation-by-user-activation":!1,"allow-scripts":!0,"allow-same-origin":!0,"allow-forms":!0},dj={"allow-same-origin":!1,"allow-forms":!1,"allow-popups":!1},dO=dM.map(e=>e.type);function dD(){let e=(0,h.frr)();if(e&&e.hasShapeUtil("embed"))return e.getShapeUtil("embed")}function dL(){let e=dD();return t=>e?e.getEmbedDefinition(t):void 0}let dF=(0,h.u4I)(function({onClose:e}){let t,n=(0,h.hGv)(),r=$(),i=O(),[o,s]=(0,C.useState)(null),[a,l]=(0,C.useState)(""),[d,c]=(0,C.useState)(null),[u,p]=(0,C.useState)(!1),f=(0,C.useRef)(-1),g=(t=dD())?t.getEmbedDefinitions():[],m=dL();return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(dy,{children:[(0,b.jsx)(db,{children:o?`${r("embed-dialog.title")} \u2014 ${o.title}`:r("embed-dialog.title")}),(0,b.jsx)(dx,{})]}),o?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(dw,{className:"tlui-embed-dialog__enter",children:[(0,b.jsx)(dS,{className:"tlui-embed-dialog__input",label:"embed-dialog.url",placeholder:"https://example.com",autoFocus:!0,onValueChange:e=>{l(e);let t=m(e);c(t&&t.definition.type===o.type?t:null),p(!1),clearTimeout(f.current),f.current=n.timers.setTimeout(()=>p(!t),320)}}),""===a?(0,b.jsxs)("div",{className:"tlui-embed-dialog__instruction",children:[(0,b.jsx)("span",{children:r("embed-dialog.instruction")})," ",o.instructionLink&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("a",{target:"_blank",rel:"noopener noreferrer",href:o.instructionLink,className:"tlui-embed-dialog__instruction__link",children:"Learn more"}),"."]})]}):(0,b.jsx)("div",{className:"tlui-embed-dialog__warning",children:u?r("embed-dialog.invalid-url"):"\xa0"})]}),(0,b.jsxs)(dv,{className:"tlui-dialog__footer__actions",children:[(0,b.jsx)(aW,{type:"normal",onClick:()=>{s(null),c(null),l("")},children:(0,b.jsx)(aK,{children:r("embed-dialog.back")})}),(0,b.jsx)("div",{className:"tlui-embed__spacer"}),(0,b.jsx)(aW,{type:"normal",onClick:e,children:(0,b.jsx)(aK,{children:r("embed-dialog.cancel")})}),(0,b.jsx)(aW,{type:"primary",disabled:!d,onClick:()=>{d&&(n.putExternalContent({type:"embed",url:a,point:n.getViewportPageBounds().center,embed:d.definition}),e())},children:(0,b.jsx)(aK,{children:r("embed-dialog.create")})})]})]}):(0,b.jsx)(b.Fragment,{children:(0,b.jsx)(dw,{className:"tlui-embed-dialog__list",children:g.map(e=>{var t;let n=(t=e.type,dO.includes(t))?i.embedIcons[e.type]:"icon"in e?e.icon:void 0;return(0,b.jsxs)(aW,{type:"menu",onClick:()=>s(e),children:[(0,b.jsx)(aK,{children:e.title}),n&&(0,b.jsx)("div",{className:"tlui-embed-dialog__item__image",style:{backgroundImage:`url(${n})`}})]},e.type)})})})]})}),dR=[0,389,436,476,580,640,840,1023],dz=C.createContext(null);function dN({forceMobile:e=!1,children:t}){let n=(0,h.frr)(),r=(0,h.hau)("breakpoint",()=>{let{width:t}=n?.getViewportScreenBounds()??{width:(0,h.CMG)().innerWidth},r=e?3:dR.length-1;for(let e=0;e<r;e++)if(t>dR[e]&&t<=dR[e+1])return e;return r},[n]);return(0,b.jsx)(dz.Provider,{value:r,children:t})}function d$(){let e=(0,C.useContext)(dz);if(null===e)throw Error("useBreakpoint must be used inside of the <BreakpointProvider /> component");return e}let dB=(0,C.createContext)(null);function dH(){let e=(0,C.useContext)(dB);if(!e)throw Error("useTldrawUiMenuContext must be used within a TldrawUiMenuContextProvider");return e}function dU({type:e,sourceId:t,children:n}){return(0,b.jsx)(dB.Provider,{value:{type:e,sourceId:t},children:n})}function dW(){let e=(0,h.frr)();return e?.store.props.collaboration!==void 0}var dK=Object.defineProperty,dV=(e,t)=>dK(e,"name",{value:t,configurable:!0});function dY(e){let t=e+"CollectionProvider",[n,r]=iz(t),[i,o]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=dV(e=>{let{scope:t,children:n}=e,r=C.useRef(null),o=C.useRef(new Map).current;return(0,b.jsx)(i,{scope:t,itemMap:o,collectionRef:r,children:n})},"CollectionProvider");s.displayName=t;let a=e+"CollectionSlot",l=iU(a),d=C.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=iL(t,o(a,n).collectionRef);return(0,b.jsx)(l,{ref:i,children:r})});d.displayName=a;let c=e+"CollectionItemSlot",u="data-radix-collection-item",h=iU(c),p=C.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,s=C.useRef(null),a=iL(t,s),l=o(c,n);return C.useEffect(()=>(l.itemMap.set(s,{ref:s,...i}),()=>void l.itemMap.delete(s))),(0,b.jsx)(h,{...{[u]:""},ref:a,children:r})});function f(t){let n=o(e+"CollectionConsumer",t);return C.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${u}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return p.displayName=c,dV(f,"useCollection"),[{Provider:s,Slot:d,ItemSlot:p},f,r]}dV(dY,"createCollection");var dG=new WeakMap,dq=class e extends Map{static{dV(this,"OrderedDict")}#e;constructor(e){super(e),this.#e=[...super.keys()],dG.set(this,!0)}set(e,t){return dG.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r,i=this.has(t),o=this.#e.length,s=dZ(e),a=s>=0?s:o+s,l=a<0||a>=o?-1:a;if(l===this.size||i&&l===this.size-1||-1===l)return this.set(t,n),this;let d=this.size+ +!i;s<0&&a++;let c=[...this.#e],u=!1;for(let e=a;e<d;e++)if(a===e){let o=c[e];c[e]===t&&(o=c[e+1]),i&&this.delete(t),r=this.get(o),this.set(t,n)}else{u||c[e-1]!==t||(u=!0);let n=c[u?e:e-1],i=r;r=this.get(n),this.delete(n),this.set(n,i)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return -1===r?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(-1!==(t=-1===t||t===this.size-1?-1:t+1))return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return -1===r?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return void 0!==t&&this.delete(t)}at(e){let t=dX(this.#e,e);if(void 0!==t)return this.get(t)}entryAt(e){let t=dX(this.#e,e);if(void 0!==t)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return dX(this.#e,e)}from(e,t){let n=this.indexOf(e);if(-1===n)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(-1===n)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return -1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=0===r&&1===e.length?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&1===e.length?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){return new e([...this.entries()].sort(t))}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(void 0===t)return r;t<0&&(t+=this.size),void 0!==n&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function dX(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);let n=dJ(e,t);return -1===n?void 0:e[n]}function dJ(e,t){let n=e.length,r=dZ(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}function dZ(e){return e!=e||0===e?0:Math.trunc(e)}function dQ(e,t){if(e===t)return!0;if("object"!=typeof e||"object"!=typeof t||null==e||null==t)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}function d0(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}function d1(e,t){return e[1].element&&t[1].element?d0(e[1].element,t[1].element)?-1:1:0}function d2(e){return new MutationObserver(t=>{for(let n of t)if("childList"===n.type)return void e()})}dV(dX,"at"),dV(dJ,"toSafeIndex"),dV(dZ,"toSafeInteger"),dV(function(e){let t=e+"CollectionProvider",[n,r]=iz(t),[i,o]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new dq,setItemMap:dV(()=>void 0,"setItemMap")}),s=dV(({state:e,...t})=>e?(0,b.jsx)(l,{...t,state:e}):(0,b.jsx)(a,{...t}),"CollectionProvider");s.displayName=t;let a=dV(e=>{let t=g();return(0,b.jsx)(l,{...e,state:t})},"CollectionInit");a.displayName=t+"Init";let l=dV(e=>{let{scope:t,children:n,state:r}=e,o=C.useRef(null),[s,a]=C.useState(null),l=iL(o,a),[d,c]=r;return C.useEffect(()=>{if(!s)return;let e=d2(()=>{});return e.observe(s,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[s]),(0,b.jsx)(i,{scope:t,itemMap:d,setItemMap:c,collectionRef:l,collectionRefObject:o,collectionElement:s,children:n})},"CollectionProviderImpl");l.displayName=t+"Impl";let d=e+"CollectionSlot",c=iU(d),u=C.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=iL(t,o(d,n).collectionRef);return(0,b.jsx)(c,{ref:i,children:r})});u.displayName=d;let h=e+"CollectionItemSlot",p=iU(h),f=C.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,s=C.useRef(null),[a,l]=C.useState(null),d=iL(t,s,l),{setItemMap:c}=o(h,n),u=C.useRef(i);dQ(u.current,i)||(u.current=i);let f=u.current;return C.useEffect(()=>(c(e=>a?e.has(a)?e.set(a,{...f,element:a}).toSorted(d1):(e.set(a,{...f,element:a}),e.toSorted(d1)):e),()=>{c(e=>a&&e.has(a)?(e.delete(a),new dq(e)):e)}),[a,f,c]),(0,b.jsx)(p,{"data-radix-collection-item":"",ref:d,children:r})});function g(){return C.useState(new dq)}function m(t){let{itemMap:n}=o(e+"CollectionConsumer",t);return n}return f.displayName=h,dV(g,"useInitCollection"),dV(m,"useCollection"),[{Provider:s,Slot:u,ItemSlot:f},{createCollectionScope:r,useCollection:m,useInitCollection:g}]},"createCollection"),dV(dQ,"shallowEqual"),dV(d0,"isElementPreceding"),dV(d1,"sortByDocumentPosition"),dV(d2,"getChildListObserver");var d3=Object.defineProperty,d5=C.createContext(void 0);function d6(e){let t=C.useContext(d5);return e||t||"ltr"}d3(d6,"name",{value:"useDirection",configurable:!0});var d4=Object.defineProperty,d8=(e,t)=>d4(e,"name",{value:t,configurable:!0}),d9=!1;function d7(){let[e,t]=C.useState(d9);return C.useEffect(()=>{d9||(d9=!0,t(!0))},[]),e}d8(d7,"useIsHydrated");var ce=k[" useSyncExternalStore ".trim().toString()];function ct(){return()=>{}}function cn(){return ce(ct,()=>!0,()=>!1)}d8(ct,"subscribe"),d8(cn,"useIsHydratedModern");var cr="function"==typeof ce?cn:d7,ci=Object.defineProperty,co=(e,t)=>ci(e,"name",{value:t,configurable:!0}),cs="rovingFocusGroup.onEntryFocus",ca={bubbles:!1,cancelable:!0},cl="RovingFocusGroup",[cd,cc,cu]=dY(cl),[ch,cp]=iz(cl,[cu]),[cf,cg]=ch(cl),cm=C.forwardRef(co(function(e,t){return(0,b.jsx)(cd.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,b.jsx)(cd.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,b.jsx)(cy,{...e,ref:t})})})},"RovingFocusGroup")),cy=C.forwardRef(co(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:o,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:d,preventScrollOnEntryFocus:c=!1,...u}=e,h=C.useRef(null),p=iL(t,h),f=d6(o),[g,m]=s5({prop:s,defaultProp:a??null,onChange:l,caller:cl}),[y,x]=C.useState(!1),w=i4(d),v=cc(n),S=C.useRef(!1),[k,P]=C.useState(0);return C.useEffect(()=>{let e=h.current;if(e)return e.addEventListener(cs,w),()=>e.removeEventListener(cs,w)},[w]),(0,b.jsx)(cf,{scope:n,orientation:r,dir:f,loop:i,currentTabStopId:g,onItemFocus:C.useCallback(e=>m(e),[m]),onItemShiftTab:C.useCallback(()=>x(!0),[]),onFocusableItemAdd:C.useCallback(()=>P(e=>e+1),[]),onFocusableItemRemove:C.useCallback(()=>P(e=>e-1),[]),children:(0,b.jsx)(i5.div,{tabIndex:y||0===k?-1:0,"data-orientation":r,...u,ref:p,style:{outline:"none",...e.style},onMouseDown:iI(e.onMouseDown,()=>{S.current=!0}),onFocus:iI(e.onFocus,e=>{let t=!S.current;if(e.target===e.currentTarget&&t&&!y){let t=new CustomEvent(cs,ca);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=v().filter(e=>e.focusable);cS([e.find(e=>e.active),e.find(e=>e.id===g),...e].filter(Boolean).map(e=>e.ref.current),c)}}S.current=!1}),onBlur:iI(e.onBlur,()=>x(!1))})})},"RovingFocusGroupImpl")),cb=C.forwardRef(co(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:o,children:s,...a}=e,l=of(),d=o||l,c=cg("RovingFocusGroupItem",n),u=c.currentTabStopId===d,h=cc(n),{onFocusableItemAdd:p,onFocusableItemRemove:f,currentTabStopId:g}=c,m=cr();return oc(()=>{if(m&&r)return p(),()=>f()},[m,r,p,f]),C.useEffect(()=>{if(!m&&r)return p(),()=>f()},[m,r,p,f]),(0,b.jsx)(cd.ItemSlot,{scope:n,id:d,focusable:r,active:i,children:(0,b.jsx)(i5.span,{tabIndex:u?0:-1,"data-orientation":c.orientation,...a,ref:t,onMouseDown:iI(e.onMouseDown,e=>{r?c.onItemFocus(d):e.preventDefault()}),onFocus:iI(e.onFocus,()=>c.onItemFocus(d)),onKeyDown:iI(e.onKeyDown,e=>{if("Tab"===e.key&&e.shiftKey)return void c.onItemShiftTab();if(e.target!==e.currentTarget)return;let t=cv(e,c.orientation,c.dir);if(void 0!==t){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=h().filter(e=>e.focusable).map(e=>e.ref.current);if("last"===t)n.reverse();else if("prev"===t||"next"===t){"prev"===t&&n.reverse();let r=n.indexOf(e.currentTarget);n=c.loop?cC(n,r+1):n.slice(r+1)}setTimeout(()=>cS(n))}}),children:"function"==typeof s?s({isCurrentTabStop:u,hasTabStop:null!=g}):s})})},"RovingFocusGroupItem")),cx={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function cw(e,t){return"rtl"!==t?e:"ArrowLeft"===e?"ArrowRight":"ArrowRight"===e?"ArrowLeft":e}function cv(e,t,n){let r=cw(e.key,n);if(!("vertical"===t&&["ArrowLeft","ArrowRight"].includes(r))&&!("horizontal"===t&&["ArrowUp","ArrowDown"].includes(r)))return cx[r]}function cS(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function cC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}co(cw,"getDirectionAwareKey"),co(cv,"getFocusIntent"),co(cS,"focusFirst"),co(cC,"wrapArray");var ck=Object.defineProperty,cP=(e,t)=>ck(e,"name",{value:t,configurable:!0}),cT=["Enter"," "],cE=["ArrowUp","PageDown","End"],cI=["ArrowDown","PageUp","Home",...cE],c_={ltr:[...cT,"ArrowRight"],rtl:[...cT,"ArrowLeft"]},cM={ltr:["ArrowLeft"],rtl:["ArrowRight"]},cA="Menu",[cj,cO,cD]=dY(cA),[cL,cF]=iz(cA,[cD,sI,cp]),cR=sI(),cz=cp(),[cN,c$]=cL(cA),[cB,cH]=cL(cA),cU=cP(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:o,modal:s=!0}=e,a=cR(t),[l,d]=C.useState(null),c=C.useRef(!1),u=i4(o),h=d6(i);return C.useEffect(()=>{let e=cP(()=>{c.current=!0,document.addEventListener("pointerdown",t,{capture:!0,once:!0}),document.addEventListener("pointermove",t,{capture:!0,once:!0})},"handleKeyDown"),t=cP(()=>c.current=!1,"handlePointer");return document.addEventListener("keydown",e,{capture:!0}),()=>{document.removeEventListener("keydown",e,{capture:!0}),document.removeEventListener("pointerdown",t,{capture:!0}),document.removeEventListener("pointermove",t,{capture:!0})}},[]),C.useEffect(()=>{if(!n)return;let e=cP(()=>u(!1),"handleBlur");return window.addEventListener("blur",e),()=>window.removeEventListener("blur",e)},[n,u]),(0,b.jsx)(sA,{...a,children:(0,b.jsx)(cN,{scope:t,open:n,onOpenChange:u,content:l,onContentChange:d,children:(0,b.jsx)(cB,{scope:t,onClose:C.useCallback(()=>u(!1),[u]),isUsingKeyboardRef:c,dir:h,modal:s,children:r})})})},"Menu"),cW=C.forwardRef(cP(function(e,t){let{__scopeMenu:n,...r}=e,i=cR(n);return(0,b.jsx)(sj,{...i,...r,ref:t})},"MenuAnchor")),cK="MenuPortal",[cV,cY]=cL(cK,{forceMount:void 0}),cG=cP(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,o=c$(cK,t);return(0,b.jsx)(cV,{scope:t,forceMount:n,children:(0,b.jsx)(sK,{present:n||o.open,children:(0,b.jsx)(le,{asChild:!0,container:i,children:r})})})},"MenuPortal"),cq="MenuContent",[cX,cJ]=cL(cq),cZ=C.forwardRef(cP(function(e,t){let n=cY(cq,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,o=c$(cq,e.__scopeMenu),s=cH(cq,e.__scopeMenu);return(0,b.jsx)(cj.Provider,{scope:e.__scopeMenu,children:(0,b.jsx)(sK,{present:r||o.open,children:(0,b.jsx)(cj.Slot,{scope:e.__scopeMenu,children:s.modal?(0,b.jsx)(cQ,{...i,ref:t}):(0,b.jsx)(c0,{...i,ref:t})})})})},"MenuContent")),cQ=C.forwardRef(cP(function(e,t){let n=c$(cq,e.__scopeMenu),r=C.useRef(null),i=iL(t,r);return C.useEffect(()=>{let e=r.current;if(e)return lZ(e)},[]),(0,b.jsx)(c2,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:iI(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},"MenuRootContentModal")),c0=C.forwardRef(cP(function(e,t){let n=c$(cq,e.__scopeMenu);return(0,b.jsx)(c2,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},"MenuRootContentNonModal")),c1=iU("MenuContent.ScrollLock"),c2=C.forwardRef(cP(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:d,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:h,onDismiss:p,disableOutsideScroll:f,...g}=e,m=c$(cq,n),y=cH(cq,n),x=cR(n),w=cz(n),v=cO(n),[S,k]=C.useState(null),P=C.useRef(null),T=iL(t,P,m.onContentChange),E=C.useRef(0),I=C.useRef(""),_=C.useRef(0),M=C.useRef(null),A=C.useRef("right"),j=C.useRef(0),O=f?lK:C.Fragment,D=cP(e=>{let t=I.current+e,n=v().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,o=um(n.map(e=>e.textValue),t,i),s=n.find(e=>e.textValue===o)?.ref.current;s&&setTimeout(()=>s.focus())},"handleTypeaheadSearch");C.useEffect(()=>()=>window.clearTimeout(E.current),[]),lo();let L=C.useCallback(e=>A.current===M.current?.side&&ub(e,M.current?.area),[]);return(0,b.jsx)(cX,{scope:n,searchRef:I,onItemEnter:C.useCallback(e=>{L(e)&&e.preventDefault()},[L]),onItemLeave:C.useCallback(e=>{L(e)||(P.current?.focus(),k(null))},[L]),onTriggerLeave:C.useCallback(e=>{L(e)&&e.preventDefault()},[L]),pointerGraceTimerRef:_,onPointerGraceIntentChange:C.useCallback(e=>{M.current=e},[]),children:(0,b.jsx)(O,{...f?{as:c1,allowPinchZoom:!0}:void 0,children:(0,b.jsx)(aJ,{asChild:!0,trapped:i,onMountAutoFocus:iI(o,e=>{e.preventDefault(),P.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:(0,b.jsx)(ot,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:d,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:h,onDismiss:p,children:(0,b.jsx)(cm,{asChild:!0,...w,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:k,onEntryFocus:iI(l,e=>{y.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,b.jsx)(sF,{role:"menu","aria-orientation":"vertical","data-state":uu(m.open),"data-radix-menu-content":"",dir:y.dir,...x,...g,ref:T,style:{outline:"none",...g.style},onKeyDown:iI(g.onKeyDown,e=>{let t=e.target.closest("[data-radix-menu-content]")===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=1===e.key.length;t&&("Tab"===e.key&&e.preventDefault(),!n&&r&&D(e.key));let i=P.current;if(e.target!==i||!cI.includes(e.key))return;e.preventDefault();let o=v().filter(e=>!e.disabled).map(e=>e.ref.current);cE.includes(e.key)&&o.reverse(),uf(o)}),onBlur:iI(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(E.current),I.current="")}),onPointerMove:iI(e.onPointerMove,ux(e=>{let t=e.target,n=j.current!==e.clientX;e.currentTarget.contains(t)&&n&&(A.current=e.clientX>j.current?"right":"left",j.current=e.clientX)}))})})})})})})},"MenuContentImpl")),c3="MenuItem",c5="menu.itemSelect",c6=C.forwardRef(cP(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,o=C.useRef(null),s=cH(c3,e.__scopeMenu),a=cJ(c3,e.__scopeMenu),l=iL(t,o),d=C.useRef(!1),c=cP(()=>{let e=o.current;if(!n&&e){let t=new CustomEvent(c5,{bubbles:!0,cancelable:!0});e.addEventListener(c5,e=>r?.(e),{once:!0}),i6(e,t),t.defaultPrevented?d.current=!1:s.onClose()}},"handleSelect");return(0,b.jsx)(c4,{...i,ref:l,disabled:n,onClick:iI(e.onClick,c),onPointerDown:t=>{e.onPointerDown?.(t),d.current=!0},onPointerUp:iI(e.onPointerUp,e=>{d.current||e.currentTarget?.click()}),onKeyDown:iI(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(""===a.searchRef.current||" "!==e.key)&&cT.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},"MenuItem")),c4=C.forwardRef(cP(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...o}=e,s=cJ(c3,n),a=cz(n),l=C.useRef(null),d=iL(t,l),[c,u]=C.useState(!1),[h,p]=C.useState("");return C.useEffect(()=>{let e=l.current;e&&p((e.textContent??"").trim())},[o.children]),(0,b.jsx)(cj.ItemSlot,{scope:n,disabled:r,textValue:i??h,children:(0,b.jsx)(cb,{asChild:!0,...a,focusable:!r,children:(0,b.jsx)(i5.div,{role:"menuitem","data-highlighted":c?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...o,ref:d,onPointerMove:iI(e.onPointerMove,ux(e=>{r?s.onItemLeave(e):(s.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:iI(e.onPointerLeave,ux(e=>s.onItemLeave(e))),onFocus:iI(e.onFocus,()=>u(!0)),onBlur:iI(e.onBlur,()=>u(!1))})})})},"MenuItemImpl")),c8=C.forwardRef(cP(function(e,t){let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,b.jsx)(ut,{scope:e.__scopeMenu,checked:n,children:(0,b.jsx)(c6,{role:"menuitemcheckbox","aria-checked":uh(n)?"mixed":n,...i,ref:t,"data-state":up(n),onSelect:iI(i.onSelect,()=>r?.(!!uh(n)||!n),{checkForDefaultPrevented:!1})})})},"MenuCheckboxItem")),[c9,c7]=cL("MenuRadioGroup",{value:void 0,onValueChange:cP(()=>{},"onValueChange")}),ue="MenuItemIndicator",[ut,un]=cL(ue,{checked:!1}),ur=C.forwardRef(cP(function(e,t){let{__scopeMenu:n,forceMount:r,...i}=e,o=un(ue,n);return(0,b.jsx)(sK,{present:r||uh(o.checked)||!0===o.checked,children:(0,b.jsx)(i5.span,{...i,ref:t,"data-state":up(o.checked)})})},"MenuItemIndicator")),ui="MenuSub",[uo,us]=cL(ui),ua=cP(e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,o=c$(ui,t),s=cR(t),[a,l]=C.useState(null),[d,c]=C.useState(null),u=i4(i);return C.useEffect(()=>(!1===o.open&&u(!1),()=>u(!1)),[o.open,u]),(0,b.jsx)(sA,{...s,children:(0,b.jsx)(cN,{scope:t,open:r,onOpenChange:u,content:d,onContentChange:c,children:(0,b.jsx)(uo,{scope:t,contentId:of(),triggerId:of(),trigger:a,onTriggerChange:l,children:n})})})},"MenuSub"),ul="MenuSubTrigger",ud=C.forwardRef(cP(function(e,t){let n=c$(ul,e.__scopeMenu),r=cH(ul,e.__scopeMenu),i=us(ul,e.__scopeMenu),o=cJ(ul,e.__scopeMenu),s=C.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=o,d={__scopeMenu:e.__scopeMenu},c=C.useCallback(()=>{s.current&&window.clearTimeout(s.current),s.current=null},[]);C.useEffect(()=>c,[c]),C.useEffect(()=>{let e=a.current;return()=>{window.clearTimeout(e),l(null)}},[a,l]);let u=iL(t,i.onTriggerChange);return(0,b.jsx)(cW,{asChild:!0,...d,children:(0,b.jsx)(c4,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":n.open?i.contentId:void 0,"data-state":uu(n.open),...e,ref:u,onClick:t=>{e.onClick?.(t),e.disabled||t.defaultPrevented||(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:iI(e.onPointerMove,ux(t=>{o.onItemEnter(t),!t.defaultPrevented&&(e.disabled||n.open||s.current||(o.onPointerGraceIntentChange(null),s.current=window.setTimeout(()=>{n.onOpenChange(!0),c()},100)))})),onPointerLeave:iI(e.onPointerLeave,ux(e=>{c();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i="right"===r,s=t[i?"left":"right"],l=t[i?"right":"left"];o.onPointerGraceIntentChange({area:[{x:e.clientX+(i?-5:5),y:e.clientY},{x:s,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:s,y:t.bottom}],side:r}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(e),e.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:iI(e.onKeyDown,t=>{e.disabled||t.target!==t.currentTarget||(""===o.searchRef.current||" "!==t.key)&&c_[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})},"MenuSubTrigger")),uc=C.forwardRef(cP(function(e,t){let n=cY(cq,e.__scopeMenu),{forceMount:r=n.forceMount,align:i="start",...o}=e,s=c$(cq,e.__scopeMenu),a=cH(cq,e.__scopeMenu),l=us("MenuSubContent",e.__scopeMenu),d=C.useRef(null),c=iL(t,d);return(0,b.jsx)(cj.Provider,{scope:e.__scopeMenu,children:(0,b.jsx)(sK,{present:r||s.open,children:(0,b.jsx)(cj.Slot,{scope:e.__scopeMenu,children:(0,b.jsx)(c2,{id:l.contentId,"aria-labelledby":l.triggerId,...o,ref:c,align:i,side:"rtl"===a.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{a.isUsingKeyboardRef.current&&d.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:iI(e.onFocusOutside,e=>{e.target!==l.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:iI(e.onEscapeKeyDown,e=>{a.onClose(),e.preventDefault()}),onKeyDown:iI(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=cM[a.dir].includes(e.key);t&&n&&(s.onOpenChange(!1),l.trigger?.focus(),e.preventDefault())})})})})})},"MenuSubContent"));function uu(e){return e?"open":"closed"}function uh(e){return"indeterminate"===e}function up(e){return uh(e)?"indeterminate":e?"checked":"unchecked"}function uf(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function ug(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function um(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,o=ug(e,Math.max(i,0));1===r.length&&(o=o.filter(e=>e!==n));let s=o.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return s!==n?s:void 0}function uy(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,o=t.length-1;e<t.length;o=e++){let s=t[e],a=t[o],l=s.x,d=s.y,c=a.x,u=a.y;d>r!=u>r&&n<(c-l)*(r-d)/(u-d)+l&&(i=!i)}return i}function ub(e,t){return!!t&&uy({x:e.clientX,y:e.clientY},t)}function ux(e){return t=>"mouse"===t.pointerType?e(t):void 0}cP(uu,"getOpenState"),cP(uh,"isIndeterminate"),cP(up,"getCheckedState"),cP(uf,"focusFirst"),cP(ug,"wrapArray"),cP(um,"getNextMatch"),cP(uy,"isPointInPolygon"),cP(ub,"isPointerInGraceArea"),cP(ux,"whenMouse");var uw=Object.defineProperty,uv=(e,t)=>uw(e,"name",{value:t,configurable:!0}),uS="ContextMenu",[uC,uk]=iz(uS,[cF]),uP=cF(),[uT,uE]=uC(uS),uI=uv(e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,open:i,dir:o,modal:s=!0}=e,a=C.useRef(!1),[l,d]=s5({prop:i,defaultProp:!1,onChange:r,caller:uS}),c=uP(t);return(0,b.jsx)(uT,{scope:t,open:l,onOpenChange:d,modal:s,hasInteractedRef:a,children:(0,b.jsx)(cU,{...c,dir:o,open:l,onOpenChange:d,modal:s,children:n})})},"ContextMenu"),u_=C.forwardRef(uv(function(e,t){let{__scopeContextMenu:n,disabled:r=!1,...i}=e,o=uE("ContextMenuTrigger",n),s=uP(n),[a,l]=C.useState({x:0,y:0}),d=C.useMemo(()=>({current:{getBoundingClientRect:uv(()=>DOMRect.fromRect({width:0,height:0,...a}),"getBoundingClientRect")}}),[a]),c=C.useRef(0),u=C.useCallback(()=>window.clearTimeout(c.current),[]),h=uv(e=>{o.hasInteractedRef.current=!0,l({x:e.clientX,y:e.clientY}),o.onOpenChange(!0)},"handleOpen");return C.useEffect(()=>u,[u]),C.useEffect(()=>void(r&&u()),[r,u]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(cW,{...s,virtualRef:d}),(0,b.jsx)(i5.span,{"data-state":o.open?"open":"closed","data-disabled":r?"":void 0,...i,ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:r?e.onContextMenu:iI(e.onContextMenu,e=>{u(),h(e),e.preventDefault()}),onPointerDown:r?e.onPointerDown:iI(e.onPointerDown,uR(e=>{u(),o.open&&o.onOpenChange(!1),c.current=window.setTimeout(()=>h(e),700)})),onPointerMove:r?e.onPointerMove:iI(e.onPointerMove,uR(u)),onPointerCancel:r?e.onPointerCancel:iI(e.onPointerCancel,uR(u)),onPointerUp:r?e.onPointerUp:iI(e.onPointerUp,uR(u))})]})},"ContextMenuTrigger")),uM=uv(e=>{let{__scopeContextMenu:t,...n}=e,r=uP(t);return(0,b.jsx)(cG,{...r,...n})},"ContextMenuPortal"),uA=C.forwardRef(uv(function(e,t){let{__scopeContextMenu:n,...r}=e,i=uE("ContextMenuContent",n),o=uP(n),s=C.useRef(!1);return(0,b.jsx)(cZ,{...o,...r,ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),!t.defaultPrevented&&s.current&&t.preventDefault(),s.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||i.modal||(s.current=!0)},style:{...e.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")),uj=C.forwardRef(uv(function(e,t){let{__scopeContextMenu:n,...r}=e,i=uP(n);return(0,b.jsx)(c6,{...i,...r,ref:t})},"ContextMenuItem")),uO=C.forwardRef(uv(function(e,t){let{__scopeContextMenu:n,...r}=e,i=uP(n);return(0,b.jsx)(c8,{...i,...r,ref:t})},"ContextMenuCheckboxItem")),uD=uv(e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,open:i,defaultOpen:o}=e,s=uP(t),[a,l]=s5({prop:i,defaultProp:o??!1,onChange:r,caller:"ContextMenuSub"});return(0,b.jsx)(ua,{...s,open:a,onOpenChange:l,children:n})},"ContextMenuSub"),uL=C.forwardRef(uv(function(e,t){let{__scopeContextMenu:n,...r}=e,i=uP(n);return(0,b.jsx)(ud,{...i,...r,ref:t})},"ContextMenuSubTrigger")),uF=C.forwardRef(uv(function(e,t){let{__scopeContextMenu:n,...r}=e,i=uP(n);return(0,b.jsx)(uc,{...i,...r,ref:t,style:{...e.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"));function uR(e){return t=>"mouse"!==t.pointerType?e(t):void 0}function uz(){let e=(0,h.frr)();return(0,h.hau)("isReadonlyMode",()=>!!e?.getIsReadonly(),[e])}uv(uR,"whenTouchOrPen");let uN=h.YZA.isDarwin?"⌘":"__CTRL__",u$=h.YZA.isDarwin?"⌃":"__CTRL__",uB=h.YZA.isDarwin?"⌥":"__ALT__";function uH(e){return","===e?[","]:e.split(",")[0].split(/(\[\[[^\]]+\]\])/g).map(e=>e.startsWith("[[")?e.replace(/[[\]]/g,""):e.replace(/cmd\+/g,uN).replace(/ctrl\+/g,u$).replace(/alt\+/g,uB).replace(/shift\+/g,"⇧").replace(/\$/g,uN).replace(/\?/g,uB).replace(/!/g,"⇧").match(/__CTRL__|__ALT__|./g)||[]).flat().map((e,t)=>{let n;return"+"===e[0]?[]:(n="__CTRL__"===e?"Ctrl":"__ALT__"===e?"Alt":e[0].toUpperCase()+e.slice(1),h.YZA.isDarwin||!t?n:["+",n])}).flat()}function uU(e){return"— "+uH(e).join(" ")}function uW(e){let t=$();return(0,b.jsx)(h.z6X,{"aria-label":t("app.loading"),...e})}var uK=Object.defineProperty,uV=(e,t)=>uK(e,"name",{value:t,configurable:!0}),uY="DropdownMenu",[uG,uq]=iz(uY,[cF]),uX=cF(),[uJ,uZ]=uG(uY),uQ=uV(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:o,onOpenChange:s,modal:a=!0}=e,l=uX(t),d=C.useRef(null),[c,u]=s5({prop:i,defaultProp:o??!1,onChange:s,caller:uY});return(0,b.jsx)(uJ,{scope:t,triggerId:of(),triggerRef:d,contentId:of(),open:c,onOpenChange:u,onOpenToggle:C.useCallback(()=>u(e=>!e),[u]),modal:a,children:(0,b.jsx)(cU,{...l,open:c,onOpenChange:u,dir:r,modal:a,children:n})})},"DropdownMenu"),u0=C.forwardRef(uV(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,o=uZ("DropdownMenuTrigger",n),s=uX(n),a=iL(t,o.triggerRef);return(0,b.jsx)(cW,{asChild:!0,...s,children:(0,b.jsx)(i5.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:a,onPointerDown:iI(e.onPointerDown,e=>{!r&&0===e.button&&!1===e.ctrlKey&&(o.onOpenToggle(),o.open||e.preventDefault())}),onKeyDown:iI(e.onKeyDown,e=>{!r&&(["Enter"," "].includes(e.key)&&o.onOpenToggle(),"ArrowDown"===e.key&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(e.key)&&e.preventDefault())})})})},"DropdownMenuTrigger")),u1=uV(e=>{let{__scopeDropdownMenu:t,...n}=e,r=uX(t);return(0,b.jsx)(cG,{...r,...n})},"DropdownMenuPortal"),u2=C.forwardRef(uV(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=uZ("DropdownMenuContent",n),o=uX(n),s=C.useRef(!1);return(0,b.jsx)(cZ,{id:i.contentId,"aria-labelledby":i.triggerId,...o,...r,ref:t,onCloseAutoFocus:iI(e.onCloseAutoFocus,e=>{s.current||i.triggerRef.current?.focus(),s.current=!1,e.preventDefault()}),onInteractOutside:iI(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey,r=2===t.button||n;(!i.modal||r)&&(s.current=!0)}),style:{...e.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")),u3=C.forwardRef(uV(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=uX(n);return(0,b.jsx)(c6,{...i,...r,ref:t})},"DropdownMenuItem")),u5=C.forwardRef(uV(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=uX(n);return(0,b.jsx)(c8,{...i,...r,ref:t})},"DropdownMenuCheckboxItem")),u6=C.forwardRef(uV(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=uX(n);return(0,b.jsx)(ur,{...i,...r,ref:t})},"DropdownMenuItemIndicator")),u4=uV(e=>{let{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:o}=e,s=uX(t),[a,l]=s5({prop:r,defaultProp:o??!1,onChange:i,caller:"DropdownMenuSub"});return(0,b.jsx)(ua,{...s,open:a,onOpenChange:l,children:n})},"DropdownMenuSub"),u8=C.forwardRef(uV(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=uX(n);return(0,b.jsx)(ud,{...i,...r,ref:t})},"DropdownMenuSubTrigger")),u9=C.forwardRef(uV(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=uX(n);return(0,b.jsx)(uc,{...i,...r,ref:t,style:{...e.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"));let u7=()=>void 0,he=C.createContext(null);function ht({onEvent:e,children:t}){return(0,b.jsx)(he.Provider,{value:e??u7,children:t})}function hn(){return C.useContext(he)??u7}function hr(e,t){let n=(0,h.frr)(),r=(0,C.useCallback)(e=>{e&&n?.complete(),t?.(e)},[n,t]),i=hn(),o=(0,C.useCallback)(t=>{i(t,{source:"unknown",id:e})},[e,i]);return(0,h.ofB)(n?`${e}-${n.contextId}`:e,r,o)}function hi({id:e,children:t,modal:n=!1,debugOpen:r=!1}){let[i,o]=hr(e),s=B();return(0,b.jsx)(uQ,{open:r||i,dir:s,modal:n,onOpenChange:o,children:t})}function ho({children:e,...t}){let n=B();return(0,b.jsx)(u0,{dir:n,asChild:!0,onTouchEnd:e=>(0,h.woC)(e),...t,children:e})}function hs({className:e,side:t="bottom",align:n="start",sideOffset:r=8,alignOffset:i=8,collisionPadding:o=4,children:s}){let a=(0,h.NFA)();return(0,b.jsx)(u1,{container:a,children:(0,b.jsx)(u2,{className:ik("tlui-menu",e),side:t,sideOffset:r,align:n,alignOffset:i,collisionPadding:o,children:s})})}function ha({id:e,children:t}){let[n,r]=hr(e);return(0,b.jsx)(u4,{open:n,onOpenChange:r,children:t})}function hl({id:e,label:t,title:n,disabled:r}){let i=B();return(0,b.jsx)(u8,{dir:i,asChild:!0,disabled:r,children:(0,b.jsxs)(aW,{"data-testid":e,type:"menu",className:"tlui-menu__submenu__trigger",disabled:r,title:n,children:[(0,b.jsx)(aK,{children:t}),(0,b.jsx)(dm,{icon:"rtl"===i?"chevron-left":"chevron-right",small:!0})]})})}function hd({id:e,alignOffset:t=-1,sideOffset:n=-6,size:r="small",children:i}){let o=(0,h.NFA)();return(0,b.jsx)(u1,{container:o,children:(0,b.jsx)(u9,{"data-testid":e,className:"tlui-menu tlui-menu__submenu__content",alignOffset:t,sideOffset:n,collisionPadding:4,"data-size":r,children:i})})}function hc({className:e,children:t}){let n=B();return(0,b.jsx)("div",{dir:n,className:ik("tlui-menu__group",e),children:t})}function hu({noClose:e,children:t}){let n=B();return(0,b.jsx)(u3,{dir:n,asChild:!0,onClick:e?h.woC:void 0,children:t})}function hh({children:e,onSelect:t,...n}){let r=$(),i=B();return(0,b.jsxs)(u5,{dir:i,className:"tlui-button tlui-button__menu tlui-button__checkbox",onSelect:e=>{t?.(e),(0,h.woC)(e)},...n,children:[(0,b.jsx)("div",{className:"tlui-button__checkbox__indicator",children:(0,b.jsx)(u6,{dir:i,children:(0,b.jsx)(df,{label:r("ui.checked"),icon:"check",small:!0})})}),e]})}function hp({children:e,visibleOnMobileLayout:t=!1}){let n=d$();return!t&&n<4?null:(0,b.jsx)("kbd",{className:"tlui-kbd",children:uH(e).map((e,t)=>(0,b.jsx)("span",{children:e},t))})}var hf=Object.defineProperty,hg=C.forwardRef(hf(function(e,t){let{pressed:n,defaultPressed:r,onPressedChange:i,...o}=e,[s,a]=s5({prop:n,onChange:i,defaultProp:r??!1,caller:"Toggle"});return(0,b.jsx)(i5.button,{type:"button","aria-pressed":s,"data-state":s?"on":"off","data-disabled":e.disabled?"":void 0,...o,ref:t,onClick:iI(e.onClick,()=>{e.disabled||a(!s)})})},"name",{value:"Toggle",configurable:!0})),hm=Object.defineProperty,hy=(e,t)=>hm(e,"name",{value:t,configurable:!0}),hb="ToggleGroup",[hx,hw]=iz(hb,[cp]),hv=cp(),hS=C.forwardRef(hy(function(e,t){let{type:n,...r}=e;if("single"===n)return(0,b.jsx)(hP,{role:"radiogroup",...r,ref:t});if("multiple"===n)return(0,b.jsx)(hT,{role:"toolbar",...r,ref:t});throw Error(`Missing prop \`type\` expected on \`${hb}\``)},"ToggleGroup")),[hC,hk]=hx(hb),hP=C.forwardRef(hy(function(e,t){let{value:n,defaultValue:r,onValueChange:i=hy(()=>{},"onValueChange"),...o}=e,[s,a]=s5({prop:n,defaultProp:r??"",onChange:i,caller:hb});return(0,b.jsx)(hC,{scope:e.__scopeToggleGroup,type:"single",value:C.useMemo(()=>s?[s]:[],[s]),onItemActivate:a,onItemDeactivate:C.useCallback(()=>a(""),[a]),children:(0,b.jsx)(h_,{...o,ref:t})})},"ToggleGroupImplSingle")),hT=C.forwardRef(hy(function(e,t){let{value:n,defaultValue:r,onValueChange:i=hy(()=>{},"onValueChange"),...o}=e,[s,a]=s5({prop:n,defaultProp:r??[],onChange:i,caller:hb}),l=C.useCallback(e=>a((t=[])=>[...t,e]),[a]),d=C.useCallback(e=>a((t=[])=>t.filter(t=>t!==e)),[a]);return(0,b.jsx)(hC,{scope:e.__scopeToggleGroup,type:"multiple",value:s,onItemActivate:l,onItemDeactivate:d,children:(0,b.jsx)(h_,{...o,ref:t})})},"ToggleGroupImplMultiple")),[hE,hI]=hx(hb),h_=C.forwardRef(hy(function(e,t){let{__scopeToggleGroup:n,disabled:r=!1,rovingFocus:i=!0,orientation:o,dir:s,loop:a=!0,...l}=e,d=hv(n),c=d6(s),u={dir:c,...l};return(0,b.jsx)(hE,{scope:n,rovingFocus:i,disabled:r,children:i?(0,b.jsx)(cm,{asChild:!0,...d,orientation:o,dir:c,loop:a,children:(0,b.jsx)(i5.div,{...u,ref:t})}):(0,b.jsx)(i5.div,{...u,ref:t})})},"ToggleGroupImpl")),hM="ToggleGroupItem",hA=C.forwardRef(hy(function(e,t){let n=hk(hM,e.__scopeToggleGroup),r=hI(hM,e.__scopeToggleGroup),i=hv(e.__scopeToggleGroup),o=n.value.includes(e.value),s=r.disabled||e.disabled,a={...e,pressed:o,disabled:s},l=C.useRef(null);return r.rovingFocus?(0,b.jsx)(cb,{asChild:!0,...i,focusable:!s,active:o,ref:l,children:(0,b.jsx)(hj,{...a,ref:t})}):(0,b.jsx)(hj,{...a,ref:t})},"ToggleGroupItem")),hj=C.forwardRef(hy(function(e,t){let{__scopeToggleGroup:n,value:r,...i}=e,o=hk(hM,n),s={role:"radio","aria-checked":e.pressed,"aria-pressed":void 0},a="single"===o.type?s:void 0;return(0,b.jsx)(hg,{...a,...i,ref:t,onPressedChange:e=>{e?o.onItemActivate(r):o.onItemDeactivate(r)}})},"ToggleGroupItemImpl")),hO=Object.defineProperty,hD=(e,t)=>hO(e,"name",{value:t,configurable:!0}),hL="Toolbar",[hF,hR]=iz(hL,[cp,hw]),hz=cp(),hN=hw(),[h$,hB]=hF(hL),hH=C.forwardRef(hD(function(e,t){let{__scopeToolbar:n,orientation:r="horizontal",dir:i,loop:o=!0,...s}=e,a=hz(n),l=d6(i);return(0,b.jsx)(h$,{scope:n,orientation:r,dir:l,children:(0,b.jsx)(cm,{asChild:!0,...a,orientation:r,dir:l,loop:o,children:(0,b.jsx)(i5.div,{role:"toolbar","aria-orientation":r,dir:l,...s,ref:t})})})},"Toolbar")),hU=C.forwardRef(hD(function(e,t){let{__scopeToolbar:n,...r}=e,i=hz(n);return(0,b.jsx)(cb,{asChild:!0,...i,focusable:!e.disabled,children:(0,b.jsx)(i5.button,{type:"button",...r,ref:t})})},"ToolbarButton")),hW=C.forwardRef(hD(function(e,t){let{__scopeToolbar:n,...r}=e,i=hB("ToolbarToggleGroup",n),o=hN(n);return(0,b.jsx)(hS,{"data-orientation":i.orientation,dir:i.dir,...o,...r,ref:t,rovingFocus:!1})},"ToolbarToggleGroup")),hK=C.forwardRef(hD(function(e,t){let{__scopeToolbar:n,...r}=e,i=hN(n),o={__scopeToolbar:e.__scopeToolbar};return(0,b.jsx)(hU,{asChild:!0,...o,children:(0,b.jsx)(hA,{...i,...r,ref:t})})},"ToolbarToggleItem"));let hV={horizontal:aO,vertical:aD,grid:aL},hY=C.forwardRef(({children:e,className:t,label:n,orientation:r="horizontal",tooltipSide:i,...o},s)=>{let a=hV[r];return(0,b.jsx)(a,{asChild:!0,tooltipSide:i,children:(0,b.jsx)(hH,{ref:s,...o,className:ik("tlui-toolbar",t),"aria-label":n,orientation:"grid"===r?"horizontal":r,children:e})})}),hG=C.forwardRef(({asChild:e,children:t,type:n,isActive:r,tooltip:i,...o},s)=>{let a=(0,b.jsx)(hU,{ref:s,asChild:e,draggable:!1,"data-isactive":r,...o,"aria-label":o.title,title:void 0,className:ik("tlui-button",`tlui-button__${n}`,o.className),children:t}),l=i||o.title;return(0,b.jsx)(aH,{content:l,children:a})});function hq({children:e,className:t,type:n,asChild:r,...i}){return(0,b.jsx)(hW,{asChild:r,type:n,...i,role:"radiogroup",className:ik("tlui-toolbar-toggle-group",t),children:e})}function hX({children:e,className:t,type:n,value:r,tooltip:i,...o}){let s=(0,b.jsx)(hK,{...o,title:void 0,className:ik("tlui-button",`tlui-button__${n}`,"tlui-toolbar-toggle-group-item",t),value:r,children:e}),a=i||o.title;return(0,b.jsx)(aH,{content:a,children:s})}function hJ({disabled:e=!1,spinner:t=!1,readonlyOk:n=!1,id:r,kbd:i,label:o,icon:s,iconLeft:a,onSelect:l,noClose:d,isSelected:c,onDragStart:u}){let{type:p,sourceId:f}=dH(),g=$(),m=B(),[y,x]=(0,C.useState)(!1);if(uz()&&!n)return null;let w=xI(o,p),v=i?uU(i):void 0,S=w?g(w):void 0,k=S&&v?`${S} ${v}`:S;switch(p){case"menu":return(0,b.jsx)(hu,{children:(0,b.jsxs)(aW,{type:"menu","data-testid":`${f}.${r}`,disabled:e,onClick:e=>{d&&(0,h.woC)(e),y?x(!1):l(f)},children:[a&&(0,b.jsx)(dm,{icon:a,small:!0}),(0,b.jsx)(aK,{children:S}),i&&(0,b.jsx)(hp,{children:i})]})});case"context-menu":if(e)return null;return(0,b.jsxs)(uj,{dir:m,draggable:!1,className:"tlui-button tlui-button__menu","data-testid":`${f}.${r}`,onPointerUp:e=>{0!==e.button&&(0,h.woC)(e)},onSelect:e=>{d&&(0,h.woC)(e),y?x(!1):l(f)},children:[(0,b.jsx)("span",{className:"tlui-button__label",draggable:!1,children:S}),a&&(0,b.jsx)(dm,{icon:a,small:!0}),i&&(0,b.jsx)(hp,{children:i}),t&&(0,b.jsx)(uW,{})]});case"small-icons":case"icons":return(0,b.jsx)(hG,{"aria-pressed":void 0===c?void 0:c?"true":"false","data-testid":`${f}.${r}`,isActive:c,type:"icon",title:k,disabled:e,onClick:()=>l(f),children:(0,b.jsx)(dm,{icon:s,small:!0})});case"keyboard-shortcuts":if(!i)return console.warn(`Menu item '${o}' isn't shown in the keyboard shortcuts dialog because it doesn't have a keyboard shortcut.`),null;return(0,b.jsxs)("div",{className:"tlui-shortcuts-dialog__key-pair","data-testid":`${f}.${r}`,children:[(0,b.jsx)("div",{className:"tlui-shortcuts-dialog__key-pair__key",children:S}),(0,b.jsx)("div",{className:"tlui-shortcuts-dialog__key-pair__value",children:(0,b.jsx)(hp,{visibleOnMobileLayout:!0,children:i})})]});case"helper-buttons":return(0,b.jsxs)(aW,{type:"low","data-testid":`${f}.${r}`,onClick:()=>l(f),children:[(0,b.jsx)(dm,{icon:s}),(0,b.jsx)(aK,{children:S})]});case"toolbar":if(u)return(0,b.jsx)(hZ,{id:r,icon:s,onSelect:l,onDragStart:u,labelStr:S,titleStr:k,disabled:e,isSelected:c});return(0,b.jsx)(hG,{"aria-label":S,"aria-pressed":c?"true":"false","data-testid":`tools.${r}`,"data-value":r,disabled:e,onClick:()=>l("toolbar"),onTouchStart:e=>{(0,h.woC)(e),l("toolbar")},title:k,type:"tool",children:(0,b.jsx)(dm,{icon:s})});case"toolbar-overflow":if(u)return(0,b.jsx)(hZ,{id:r,icon:s,onSelect:l,onDragStart:u,labelStr:S,titleStr:k,disabled:e,isSelected:c,overflow:!0});return(0,b.jsx)(hG,{"aria-label":S,"aria-pressed":c?"true":"false",isActive:c,"data-testid":`tools.more.${r}`,"data-value":r,disabled:e,onClick:()=>l("toolbar"),title:k,type:"icon",children:(0,b.jsx)(dm,{icon:s})});default:throw(0,h.h6G)(p)}}function hZ({id:e,labelStr:t,titleStr:n,disabled:r,isSelected:i,icon:o,onSelect:s,onDragStart:a,overflow:l}){let d,c=(d=(0,h.hGv)(),(0,C.useMemo)(()=>{let e={name:"idle"};return{onPointerDown:function(t){e={name:"pointing",screenSpaceStart:{x:t.clientX,y:t.clientY}},t.currentTarget.setPointerCapture(t.pointerId)},onPointerMove:function(t){if(!t.isSpecialRedispatchedEvent&&"pointing"===e.name&&h.l2P.Dist2(e.screenSpaceStart,{x:t.clientX,y:t.clientY})>(d.getInstanceState().isCoarsePointer?d.options.uiCoarseDragDistanceSquared:d.options.uiDragDistanceSquared)){let n=e.screenSpaceStart;e={name:"dragging",screenSpaceStart:n},d.run(()=>{d.setCurrentTool("select"),d.dispatch({type:"pointer",target:"canvas",name:"pointer_down",...(0,h.yGT)(d,t),point:n}),d.selectNone(),a?.("toolbar",{type:"pointer",target:"canvas",name:"pointer_move",...(0,h.yGT)(d,t),point:n}),az(),d.getContainer().focus()})}},onPointerUp:function(e){e.isSpecialRedispatchedEvent||(e.currentTarget.releasePointerCapture(e.pointerId),d.dispatch({type:"pointer",target:"canvas",name:"pointer_up",...(0,h.yGT)(d,e)}))},onClick:function(){return"dragging"===e.name||"dragged"===e.name?(e={name:"idle"},!0):(e={name:"idle"},s?.("toolbar"),!1)}}},[a,d,s]));return l?(0,b.jsx)(hG,{"aria-label":t,"aria-pressed":i?"true":"false",isActive:i,className:"tlui-button-grid__button","data-testid":`tools.more.${e}`,"data-value":e,disabled:r,title:n,type:"icon",...c,children:(0,b.jsx)(dm,{icon:o})}):(0,b.jsx)(hG,{"aria-label":t,"aria-pressed":i?"true":"false","data-testid":`tools.${e}`,"data-value":e,disabled:r,onTouchStart:e=>{(0,h.woC)(e),s("toolbar")},title:n,type:"tool",...c,children:(0,b.jsx)(dm,{icon:o})})}function hQ({actionId:e="",...t}){let n=xE()[e];return n?(0,b.jsx)(hJ,{...n,...t}):null}function h0({id:e,label:t,className:n,children:r}){let i=dH(),{orientation:o}=aj(),s=$(),a=B(),l=xI(t,i.type),d=l?s(l):void 0;switch(i.type){case"menu":return(0,b.jsx)(hc,{className:n,"data-testid":`${i.sourceId}-group.${e}`,children:r});case"context-menu":return(0,b.jsx)("div",{dir:a,className:ik("tlui-menu__group",n),"data-testid":`${i.sourceId}-group.${e}`,children:r});case"keyboard-shortcuts":return(0,b.jsxs)("div",{className:"tlui-shortcuts-dialog__group","data-testid":`${i.sourceId}-group.${e}`,children:[(0,b.jsx)("h2",{className:"tlui-shortcuts-dialog__group__title",children:d}),(0,b.jsx)("div",{className:"tlui-shortcuts-dialog__group__content",children:r})]});case"toolbar":return(0,b.jsx)("horizontal"===o?aO:aD,{className:"tlui-main-toolbar__group","data-testid":`${i.sourceId}-group.${e}`,children:r});case"toolbar-overflow":return(0,b.jsx)(aL,{className:"tlui-main-toolbar__group","data-testid":`${i.sourceId}-group.${e}`,children:r});default:return r}}let h1=(0,C.createContext)(null);function h2({context:e,children:t}){let n=(0,C.useContext)(h1),r=hn(),i=(0,h.fpl)("dialogs",[]),o=(0,C.useMemo)(()=>({dialogs:i,addDialog(t){let n=t.id??(0,h.NF7)();return i.update(e=>[...e.filter(e=>e.id!==t.id),{...t,id:n}]),r("open-menu",{source:"dialog",id:n}),h.NlK.addOpenMenu(n,e),n},removeDialog(t){let n=i.get().find(e=>e.id===t);return n&&(n.onClose?.(),r("close-menu",{source:"dialog",id:t}),h.NlK.deleteOpenMenu(t,e),i.update(e=>e.filter(e=>e!==n))),t},clearDialogs(){let t=i.get();0!==t.length&&(t.forEach(t=>{t.onClose?.(),r("close-menu",{source:"dialog",id:t.id}),h.NlK.deleteOpenMenu(t.id,e)}),i.set([]))}}),[r,i,e]);return n?(0,b.jsx)(b.Fragment,{children:t}):(0,b.jsx)(h1.Provider,{value:o,children:t})}function h3(){let e=(0,C.useContext)(h1);if(!e)throw Error("useDialogs must be used within a DialogsProvider");return e}var h5=Object.defineProperty,h6=(e,t)=>h5(e,"name",{value:t,configurable:!0}),h4="ToastProvider",[h8,h9,h7]=dY("Toast"),[pe,pt]=iz("Toast",[h7]),[pn,pr]=pe(h4),pi=h6(e=>{let{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:i="right",swipeThreshold:o=50,announcerContainer:s,children:a}=e,[l,d]=C.useState(null),[c,u]=C.useState(0),h=C.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${h4}\`. Expected non-empty \`string\`.`),(0,b.jsx)(h8.Provider,{scope:t,children:(0,b.jsx)(pn,{scope:t,label:n,duration:r,swipeDirection:i,swipeThreshold:o,toastCount:c,viewport:l,onViewportChange:d,onToastAdd:C.useCallback(()=>u(e=>e+1),[]),onToastRemove:C.useCallback(()=>u(e=>e-1),[]),isClosePausedRef:h,announcerContainer:s,children:a})})},"ToastProvider"),po=["F8"],ps="toast.viewportPause",pa="toast.viewportResume",pl=C.forwardRef(h6(function(e,t){let{__scopeToast:n,hotkey:r=po,label:i="Notifications ({hotkey})",...o}=e,s=pr("ToastViewport",n),a=h9(n),l=C.useRef(null),d=C.useRef(null),c=C.useRef(null),u=C.useRef(null),h=iL(t,u,s.onViewportChange),p=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),f=s.toastCount>0;C.useEffect(()=>{let e=h6(e=>{0!==r.length&&r.every(t=>e[t]||e.code===t)&&u.current?.focus()},"handleKeyDown");return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[r]),C.useEffect(()=>{let e=l.current,t=u.current;if(f&&e&&t){let n=h6(()=>{if(!s.isClosePausedRef.current){let e=new CustomEvent(ps);t.dispatchEvent(e),s.isClosePausedRef.current=!0}},"handlePause"),r=h6(()=>{if(s.isClosePausedRef.current){let e=new CustomEvent(pa);t.dispatchEvent(e),s.isClosePausedRef.current=!1}},"handleResume"),i=h6(t=>{e.contains(t.relatedTarget)||r()},"handleFocusOutResume"),o=h6(()=>{e.contains(document.activeElement)||r()},"handlePointerLeaveResume");return e.addEventListener("focusin",n),e.addEventListener("focusout",i),e.addEventListener("pointermove",n),e.addEventListener("pointerleave",o),window.addEventListener("blur",n),window.addEventListener("focus",r),()=>{e.removeEventListener("focusin",n),e.removeEventListener("focusout",i),e.removeEventListener("pointermove",n),e.removeEventListener("pointerleave",o),window.removeEventListener("blur",n),window.removeEventListener("focus",r)}}},[f,s.isClosePausedRef]);let g=C.useCallback(({tabbingDirection:e})=>{let t=a().map(t=>{let n=t.ref.current,r=[n,...pT(n)];return"forwards"===e?r:r.reverse()});return("forwards"===e?t.reverse():t).flat()},[a]);return C.useEffect(()=>{let e=u.current;if(e){let t=h6(t=>{let n=t.altKey||t.ctrlKey||t.metaKey;if("Tab"===t.key&&!n){let n=document.activeElement,r=t.shiftKey;if(t.target===e&&r)return void d.current?.focus();let i=g({tabbingDirection:r?"backwards":"forwards"}),o=i.findIndex(e=>e===n);pE(i.slice(o+1))?t.preventDefault():r?d.current?.focus():c.current?.focus()}},"handleKeyDown");return e.addEventListener("keydown",t),()=>e.removeEventListener("keydown",t)}},[a,g]),(0,b.jsxs)(on,{ref:l,role:"region","aria-label":i.replace("{hotkey}",p),tabIndex:-1,style:{pointerEvents:f?void 0:"none"},children:[f&&(0,b.jsx)(pd,{ref:d,onFocusFromOutsideViewport:()=>{pE(g({tabbingDirection:"forwards"}))}}),(0,b.jsx)(h8.Slot,{scope:n,children:(0,b.jsx)(i5.ol,{tabIndex:-1,...o,ref:h})}),f&&(0,b.jsx)(pd,{ref:c,onFocusFromOutsideViewport:()=>{pE(g({tabbingDirection:"backwards"}))}})]})},"ToastViewport")),pd=C.forwardRef(h6(function(e,t){let{__scopeToast:n,onFocusFromOutsideViewport:r,...i}=e,o=pr("ToastFocusProxy",n);return(0,b.jsx)(ae,{tabIndex:0,...i,ref:t,style:{position:"fixed"},onFocus:e=>{let t=e.relatedTarget;o.viewport?.contains(t)||r()}})},"ToastFocusProxy")),pc="Toast",pu=C.forwardRef(h6(function(e,t){let{forceMount:n,open:r,defaultOpen:i,onOpenChange:o,...s}=e,[a,l]=s5({prop:r,defaultProp:i??!0,onChange:o,caller:pc});return(0,b.jsx)(sK,{present:n||a,children:(0,b.jsx)(pf,{open:a,...s,ref:t,onClose:()=>l(!1),onPause:i4(e.onPause),onResume:i4(e.onResume),onSwipeStart:iI(e.onSwipeStart,e=>{e.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:iI(e.onSwipeMove,e=>{let{x:t,y:n}=e.detail.delta;e.currentTarget.setAttribute("data-swipe","move"),e.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${t}px`),e.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${n}px`)}),onSwipeCancel:iI(e.onSwipeCancel,e=>{e.currentTarget.setAttribute("data-swipe","cancel"),e.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),e.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),e.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),e.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:iI(e.onSwipeEnd,e=>{let{x:t,y:n}=e.detail.delta;e.currentTarget.setAttribute("data-swipe","end"),e.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),e.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),e.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${t}px`),e.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${n}px`),l(!1)})})})},"Toast")),[ph,pp]=pe(pc,{onClose(){}}),pf=C.forwardRef(h6(function(e,t){let{__scopeToast:n,type:r="foreground",duration:i,open:o,onClose:s,onEscapeKeyDown:a,onPause:l,onResume:d,onSwipeStart:c,onSwipeMove:u,onSwipeCancel:h,onSwipeEnd:p,...f}=e,g=pr(pc,n),m=h9(n),[y,x]=C.useState(null),w=iL(t,x),v=C.useRef(null),S=C.useRef(null),k=i||g.duration,P=C.useRef(0),T=C.useRef(k),E=C.useRef(0),{onToastAdd:I,onToastRemove:_}=g,M=i4(()=>{y?.contains(document.activeElement)&&g.viewport?.focus(),s()}),A=C.useCallback(e=>{e&&e!==1/0&&(window.clearTimeout(E.current),P.current=new Date().getTime(),E.current=window.setTimeout(M,e))},[M]);C.useEffect(()=>{let e=g.viewport;if(e){let t=h6(()=>{A(T.current),d?.()},"handleResume"),n=h6(()=>{let e=new Date().getTime()-P.current;T.current=T.current-e,window.clearTimeout(E.current),l?.()},"handlePause");return e.addEventListener(ps,n),e.addEventListener(pa,t),()=>{e.removeEventListener(ps,n),e.removeEventListener(pa,t)}}},[g.viewport,k,l,d,A]),C.useEffect(()=>{o&&!g.isClosePausedRef.current&&A(k)},[o,k,g.isClosePausedRef,A]),C.useEffect(()=>()=>{window.clearTimeout(E.current)},[]),C.useEffect(()=>(I(),()=>_()),[I,_]);let j=C.useMemo(()=>y?pv(y):null,[y]);return g.viewport?(0,b.jsxs)(b.Fragment,{children:[j&&(0,b.jsx)(pg,{__scopeToast:n,role:"status","aria-live":"foreground"===r?"assertive":"polite",children:j}),(0,b.jsx)(ph,{scope:n,onClose:M,children:i$.createPortal((0,b.jsx)(h8.ItemSlot,{scope:n,children:(0,b.jsx)(ot,{asChild:!0,onEscapeKeyDown:iI(a,e=>{m().some(t=>t.ref.current?.contains(e.target))||M()}),children:(0,b.jsx)(i5.li,{tabIndex:0,"data-state":o?"open":"closed","data-swipe-direction":g.swipeDirection,...f,ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:iI(e.onKeyDown,e=>{"Escape"===e.key&&(a?.(e.nativeEvent),e.nativeEvent.defaultPrevented||M())}),onPointerDown:iI(e.onPointerDown,e=>{0===e.button&&(v.current={x:e.clientX,y:e.clientY})}),onPointerMove:iI(e.onPointerMove,e=>{if(!v.current)return;let t=e.clientX-v.current.x,n=e.clientY-v.current.y,r=!!S.current,i=["left","right"].includes(g.swipeDirection),o=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,s=i?o(0,t):0,a=i?0:o(0,n),l="touch"===e.pointerType?10:2,d={x:s,y:a},h={originalEvent:e,delta:d};r?(S.current=d,pS("toast.swipeMove",u,h,{discrete:!1})):pC(d,g.swipeDirection,l)?(S.current=d,pS("toast.swipeStart",c,h,{discrete:!1}),e.target.setPointerCapture(e.pointerId)):(Math.abs(t)>l||Math.abs(n)>l)&&(v.current=null)}),onPointerUp:iI(e.onPointerUp,e=>{let t=S.current,n=e.target;if(n.hasPointerCapture(e.pointerId)&&n.releasePointerCapture(e.pointerId),S.current=null,v.current=null,t){let n=e.currentTarget,r={originalEvent:e,delta:t};pC(t,g.swipeDirection,g.swipeThreshold)?pS("toast.swipeEnd",p,r,{discrete:!0}):pS("toast.swipeCancel",h,r,{discrete:!0}),n.addEventListener("click",e=>e.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null},"ToastImpl")),pg=h6(e=>{let{__scopeToast:t,children:n,...r}=e,i=pr(pc,t),[o,s]=C.useState(!1),[a,l]=C.useState(!1);return pk(()=>s(!0)),C.useEffect(()=>{let e=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(e)},[]),a?null:(0,b.jsx)(le,{asChild:!0,container:i.announcerContainer||void 0,children:(0,b.jsx)(ae,{...r,children:o&&(0,b.jsxs)(b.Fragment,{children:[i.label," ",n]})})})},"ToastAnnounce"),pm=C.forwardRef(h6(function(e,t){let{__scopeToast:n,...r}=e;return(0,b.jsx)(i5.div,{...r,ref:t})},"ToastTitle")),py=C.forwardRef(h6(function(e,t){let{__scopeToast:n,...r}=e;return(0,b.jsx)(i5.div,{...r,ref:t})},"ToastDescription")),pb=C.forwardRef(h6(function(e,t){let{altText:n,...r}=e;return n.trim()?(0,b.jsx)(pw,{altText:n,asChild:!0,children:(0,b.jsx)(px,{...r,ref:t})}):(console.error("Invalid prop `altText` supplied to `ToastAction`. Expected non-empty `string`."),null)},"ToastAction")),px=C.forwardRef(h6(function(e,t){let{__scopeToast:n,...r}=e,i=pp("ToastClose",n);return(0,b.jsx)(pw,{asChild:!0,children:(0,b.jsx)(i5.button,{type:"button",...r,ref:t,onClick:iI(e.onClick,i.onClose)})})},"ToastClose")),pw=C.forwardRef(h6(function(e,t){let{__scopeToast:n,altText:r,...i}=e;return(0,b.jsx)(i5.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...i,ref:t})},"ToastAnnounceExclude"));function pv(e){let t=[];return Array.from(e.childNodes).forEach(e=>{if(e.nodeType===e.TEXT_NODE&&e.textContent&&t.push(e.textContent),pP(e)){let n=e.ariaHidden||e.hidden||"none"===e.style.display,r=""===e.dataset.radixToastAnnounceExclude;if(!n)if(r){let n=e.dataset.radixToastAnnounceAlt;n&&t.push(n)}else t.push(...pv(e))}}),t}function pS(e,t,n,{discrete:r}){let i=n.originalEvent.currentTarget,o=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?i6(i,o):i.dispatchEvent(o)}h6(pv,"getAnnounceTextContent"),h6(pS,"handleAndDispatchCustomEvent");var pC=h6((e,t,n=0)=>{let r=Math.abs(e.x),i=Math.abs(e.y),o=r>i;return"left"===t||"right"===t?o&&r>n:!o&&i>n},"isDeltaInDirection");function pk(e=()=>{}){let t=i4(e);oc(()=>{let e=0,n=0;return e=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(e),window.cancelAnimationFrame(n)}},[t])}function pP(e){return e.nodeType===e.ELEMENT_NODE}function pT(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:h6(e=>{let t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}function pE(e){let t=document.activeElement;return e.some(e=>e===t||(e.focus(),document.activeElement!==t))}h6(pk,"useNextFrame"),h6(pP,"isHTMLElement"),h6(pT,"getTabbableCandidates"),h6(pE,"focusFirst");let pI=(0,C.createContext)(null);function p_({children:e}){let t=(0,h.fpl)("toasts",[]),n=(0,C.useContext)(pI),r=(0,C.useMemo)(()=>({toasts:t,addToast(e){let n=e.id??(0,h.NF7)();return t.update(t=>[...t.filter(t=>t.id!==e.id),{...e,id:n}]),n},removeToast:e=>(t.update(t=>t.filter(t=>t.id!==e)),e),clearToasts(){t.set([])}}),[t]);return n?(0,b.jsx)(b.Fragment,{children:e}):(0,b.jsx)(pi,{children:(0,b.jsx)(pI.Provider,{value:r,children:e})})}function pM(){let e=(0,C.useContext)(pI);if(!e)throw Error("useToasts must be used within a ToastsProvider");return e}function pA(e){return new Promise(t=>{let{allowMultiple:n=!0,mimeTypes:r=[],document:i=(0,h.jLo)()}=e||{},o=i.createElement("input");function s(){o.removeEventListener("change",a),o.removeEventListener("cancel",l),o.remove()}async function a(e){let n=e.target.files;if(!n||0===n.length){t([]),s();return}let r=Array.from(n);o.value="",t(r),s()}function l(){t([]),s()}o.type="file",o.accept=r?.join(","),o.multiple=n,o.style.display="none",i.body.appendChild(o),o.addEventListener("cancel",l),o.addEventListener("change",a),o?.click()})}var pj=n(4467);let pO="web image/vnd.tldraw+png",pD={png:pO},pL={[pO]:"image/png"};async function pF(e,t,n){let r=n.point??("point"in t?t.point:void 0);if(e.options.onBeforePasteFromClipboard){let i=await e.options.onBeforePasteFromClipboard({editor:e,content:t,source:n.source,point:r});if(!1===i)return;null!=i&&(t=i)}return e.putExternalContent(t)}async function pR(e,t,n,r,i="native-event"){let o=t.map(e=>e instanceof File?e:new File([e],"tldrawFile",{type:e.type}));e.markHistoryStoppingPoint("paste"),await pF(e,{type:"files",files:o,point:n,sources:r},{source:i,point:n})}async function pz(e,t,n,r,i="native-event"){return e.markHistoryStoppingPoint("paste"),await pF(e,{type:"url",point:n,url:t,sources:r},{source:i,point:n})}let pN=[pO,"image/png","image/jpeg","image/webp","image/svg+xml"];function p$(e){let t=(0,h.jLo)().implementation.createHTMLDocument("");return t.documentElement.innerHTML=e.trim(),t.body.textContent||t.body.innerText||""}function pB(e){if(!e.includes("<iframe"))return null;let t=new DOMParser().parseFromString(e,"text/html").querySelector("iframe");if(!t)return null;let n=t.getAttribute("src");if(!n||!pH(n))return null;let r=parseInt(t.getAttribute("width")||"",10),i=parseInt(t.getAttribute("height")||"",10),o=NaN,s=NaN,a=t.getAttribute("style");if(a){let e=a.match(/\bwidth:\s*(\d+)px/),t=a.match(/\bheight:\s*(\d+)px/);e&&(o=parseInt(e[1],10)),t&&(s=parseInt(t[1],10))}return{src:n,width:r||o||425,height:i||s||350}}function pH(e){try{let t=new URL(e);return"http:"===t.protocol||"https:"===t.protocol}catch{return!1}}function pU(e){return e.menus.hasAnyOpenMenus()||(0,h.ghB)(!1,e.getContainerDocument())}let pW=(e,t,n,r,i="native-event")=>{let o=(e=>{let t=e.split(/[\n\s]/);for(let e of t)try{let t=new URL(e);if("http:"!==t.protocol&&"https:"!==t.protocol)return}catch{return}return(0,h.sbv)(t)})(t);if(o)for(let t of o)pz(e,t,n,r,i);else if(pH(t))pz(e,t,n,r,i);else/^<svg/.test(t)?(e.markHistoryStoppingPoint("paste"),pF(e,{type:"svg-text",text:t,point:n,sources:r},{source:i,point:n})):(e.markHistoryStoppingPoint("paste"),pF(e,{type:"text",text:t,point:n,sources:r},{source:i,point:n}))};async function pK(e,t,n){if(null!==e.getEditingShapeId())return;if(!t)throw Error("No clipboard data");let r=[];for(let e of Object.values(t.items))switch(e.kind){case"file":r.push({type:"file",source:new Promise(t=>t(e.getAsFile()))});break;case"string":"text/html"===e.type?r.push({type:"html",source:new Promise(t=>e.getAsString(t))}):"text/plain"===e.type?r.push({type:"text",source:new Promise(t=>e.getAsString(t))}):r.push({type:e.type,source:new Promise(t=>e.getAsString(t))})}return await pY(e,r,n,"native-event")}async function pV({editor:e,clipboardItems:t,point:n,fallbackFiles:r,clipboardPasteSource:i}){let o=[];for(let e of t){let t=pN.filter(t=>e.types.includes(t));t.length>0&&o.push({type:"blob",source:(async()=>{for(let n of t){let t=await e.getType(n);if(0!==t.size)return h.SmQ.rewriteMimeType(t,(0,h.g50)(pL,n)??n)}return null})()}),e.types.includes("text/html")&&o.push({type:"html",source:(async()=>{let t=await e.getType("text/html");return await h.SmQ.blobToText(t)})()}),e.types.includes("text/uri-list")&&o.push({type:"url",source:(async()=>{let t=await e.getType("text/uri-list");return await h.SmQ.blobToText(t)})()}),e.types.includes("text/plain")&&o.push({type:"text",source:(async()=>{let t=await e.getType("text/plain");return await h.SmQ.blobToText(t)})()})}return r?.length&&1===o.length&&"text"===o[0].type?(o.pop(),o.push(...r.map(e=>({type:"file",source:Promise.resolve(e)})))):r?.length&&0===o.length&&o.push(...r.map(e=>({type:"file",source:Promise.resolve(e)}))),await pY(e,o,n,i)}async function pY(e,t,n,r){let i=await Promise.all(t.filter(e=>"file"!==e.type&&"blob"!==e.type).map(e=>new Promise(t=>{e.source.then(n=>{let r=n.match(/<div data-tldraw[^>]*>(.*)<\/div>/)?.[1];if(r)try{let e;try{e=JSON.parse(r)}catch{let n=pj.decompressFromBase64(r);if(null===n)return void t({type:"error",data:null,reason:"found tldraw data comment but could not parse"});e=JSON.parse(n)}if("application/tldraw"!==e.type)return void t({type:"error",data:e,reason:`found tldraw data comment but JSON was of a different type: ${e.type}`});if(3===e.version)try{let n=JSON.parse(pj.decompressFromBase64(e.data.otherCompressed)||"{}"),r={assets:e.data.assets||[],...n};t({type:"tldraw",data:r});return}catch(n){t({type:"error",data:e,reason:`failed to decompress version 2 clipboard data: ${n}`});return}if(2===e.version)t({type:"tldraw",data:e.data});else{if("string"==typeof e.data)return void t({type:"error",data:e,reason:"found tldraw json but data was a string instead of a TLClipboardModel object"});t({type:"tldraw",data:e.data});return}}catch{t({type:"error",data:r,reason:"found tldraw json but data was a string instead of a TLClipboardModel object"});return}else{if("html"===e.type)return void t({type:"text",data:n,subtype:"html"});if("url"===e.type)return void t({type:"text",data:n,subtype:"url"});try{let e=JSON.parse(n);if("excalidraw/clipboard"===e.type)return void t({type:"excalidraw",data:e});return void t({type:"text",data:n,subtype:"json"})}catch{t({type:"text",data:n,subtype:"text"});return}}t({type:"error",data:n,reason:"unhandled case"})}).catch(e=>{t({type:"error",data:null,reason:`error reading clipboard data: ${e}`})})}))),o=t.filter(e=>"file"===e.type||"blob"===e.type);if(o.length){if(o.length>e.options.maxFilesAtOnce)throw Error("Too many files");let t=(0,h.oE7)(await Promise.all(o.map(e=>e.source)));return await pR(e,t,n,i,r)}for(let t of i)if("tldraw"===t.type){e.markHistoryStoppingPoint("paste"),pF(e,{type:"tldraw",content:t.data,point:n},{source:r,point:n});return}for(let t of i)if("excalidraw"===t.type){e.markHistoryStoppingPoint("paste"),pF(e,{type:"excalidraw",content:t.data,point:n},{source:r,point:n});return}for(let t of i){if("text"===t.type&&"html"===t.subtype){let o=new DOMParser().parseFromString(t.data,"text/html").querySelector("body"),s=pB(t.data);if(s){e.markHistoryStoppingPoint("paste"),e.putExternalContent({type:"embed",url:s.src,point:n,embed:{width:s.width,height:s.height,doesResize:!0}});return}if(o&&1===Array.from(o.children).filter(e=>1===e.nodeType).length&&o.firstElementChild&&"A"===o.firstElementChild.tagName&&o.firstElementChild.hasAttribute("href")&&""!==o.firstElementChild.getAttribute("href"))return void pW(e,o.firstElementChild.getAttribute("href"),n,i,r);if(!i.some(e=>"text"===e.type&&"html"!==e.subtype)&&t.data.trim()&&p$(t.data))return void pW(e,p$(t.data),n,i,r);if(i.some(e=>"text"===e.type&&"html"!==e.subtype)){let o=p$(t.data)??"";if(o){e.markHistoryStoppingPoint("paste"),pF(e,{type:"text",text:o,html:t.data,point:n,sources:i},{source:r,point:n});return}}}if("text"===t.type&&"text"===t.subtype){let r=pB(t.data);if(r){e.markHistoryStoppingPoint("paste"),e.putExternalContent({type:"embed",url:r.src,point:n,embed:{width:r.width,height:r.height,doesResize:!0}});return}}}for(let t of i)if("text"===t.type&&"url"===t.subtype)return void pz(e,t.data,n,i,r);for(let t of i)if("text"===t.type&&"text"===t.subtype&&t.data.trim())return void pW(e,t.data,n,i,r)}async function pG(e,t={operation:"copy",source:"menu"}){let n=e.getContainerWindow().navigator,r=await e.resolveAssetsInContent(e.getContentFromCurrentPage(e.getSelectedShapeIds()));if(!r)return n?.clipboard?.writeText?.(""),!0;if(e.options.onBeforeCopyToClipboard){let n=await e.options.onBeforeCopyToClipboard({editor:e,content:r,...t});if(!1===n)return!1;null!=n&&(r=n)}let{assets:i,...o}=r,s=JSON.stringify({type:"application/tldraw",kind:"content",version:3,data:{assets:i||[],otherCompressed:pj.compressToBase64(JSON.stringify(o))}});if(void 0===n)return!0;let a=r.shapes.map(t=>e.getShapeUtil(t).getText(t)).filter(h.O9V);if(n.clipboard?.write){let t=new Blob([`<div data-tldraw>${s}</div>`],{type:"text/html"}),r=a.join(" ");""===r&&(r=" ");let i=e.getContainerWindow().ClipboardItem;n.clipboard.write([new i({"text/html":t,"text/plain":new Blob([r],{type:"text/plain"})})])}else n.clipboard?.writeText&&n.clipboard.writeText(`<div data-tldraw>${s}</div>`);return!0}let pq={jpeg:"image/jpeg",png:"image/png",webp:"image/webp",svg:"text/plain"};async function pX(e){await navigator.clipboard?.writeText?.(await e())}let pJ=(0,C.createContext)([]);function pZ(){let e,t,n,r,i,o,s,a,l=(0,h.frr)(),{addToast:d,removeToast:c,clearToasts:u}=pM(),{addDialog:p,clearDialogs:f,removeDialog:g}=h3(),m=$(),y=(e=(0,h.frr)(),t=(0,C.useRef)(null),n=(0,C.useRef)(null),(0,C.useCallback)(async function(){(0,h.vAR)(e,"usePrint: editor is required");let r=e.getContainerDocument(),i=e.getContainerWindow(),o=r.createElement("div"),s=r.createElement("style"),a=(e,t)=>{e&&(e.innerHTML=""),t&&r.head.contains(t)&&r.head.removeChild(t),e&&r.body.contains(e)&&r.body.removeChild(e)};a(t.current,n.current),t.current=o,n.current=s;let l=`tl-print-surface-${(0,h.NF7)()}`;o.className=l,s.innerHTML=`
|
|
27
|
+
.${l} {
|
|
28
|
+
display: none;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.${l} svg {
|
|
32
|
+
max-width: 100%;
|
|
33
|
+
height: 100%;
|
|
34
|
+
display: block;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@media print {
|
|
38
|
+
html, body {
|
|
39
|
+
min-height: 100%;
|
|
40
|
+
height: 100%;
|
|
41
|
+
margin: 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
body {
|
|
45
|
+
position: relative;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
body > * {
|
|
49
|
+
display: none;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.tldraw__editor {
|
|
53
|
+
display: none;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.${l} {
|
|
57
|
+
display: block !important;
|
|
58
|
+
background: white;
|
|
59
|
+
min-height: 100%;
|
|
60
|
+
height: 100%;
|
|
61
|
+
max-width: 100%;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.${l}__item {
|
|
65
|
+
padding: 10mm;
|
|
66
|
+
display: flex;
|
|
67
|
+
min-height: 100%;
|
|
68
|
+
flex-direction: column;
|
|
69
|
+
page-break-after: always;
|
|
70
|
+
position: relative;
|
|
71
|
+
overflow: hidden;
|
|
72
|
+
height: 100%;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.${l}__item__main {
|
|
76
|
+
flex: 1;
|
|
77
|
+
display: flex;
|
|
78
|
+
align-items: center;
|
|
79
|
+
justify-content: center;
|
|
80
|
+
max-height: 100%;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.${l}__item__header {
|
|
84
|
+
display: none;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.${l}__item__footer {
|
|
88
|
+
display: none;
|
|
89
|
+
text-align: right;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.${l}__item__footer__hide {
|
|
93
|
+
display: none;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
`;let d=()=>{r.head.appendChild(s),r.body.appendChild(o)},c=()=>{e.once("tick",()=>{a(o,s)})};function u(e,t,n){try{o.innerHTML+=`<div class="${l}__item">
|
|
100
|
+
<div class="${l}__item__header">
|
|
101
|
+
${e.replace(/</g,"<").replace(/>/g,">")}
|
|
102
|
+
</div>
|
|
103
|
+
<div class="${l}__item__main">
|
|
104
|
+
${n}
|
|
105
|
+
</div>
|
|
106
|
+
<div class="${l}__item__footer ${l}__item__footer__${t?"":"hide"}">
|
|
107
|
+
${t??""}
|
|
108
|
+
</div>
|
|
109
|
+
</div>`}catch(e){console.error(e)}}function p(){h.YZA.isChromeForIos?(d(),i.print()):h.YZA.isSafari?(d(),r.execCommand("print",!1)):i.print()}i.addEventListener("beforeprint",d),i.addEventListener("afterprint",c);let f=e.getSelectedShapeIds(),g=e.getCurrentPageId(),m=e.getPages(),y={scale:1,background:!1,darkMode:!1,preserveAspectRatio:"xMidYMid meet"};if(e.getSelectedShapeIds().length>0){let t=await e.getSvgString(f,y);if(t){let e=m.find(e=>e.id===g);u(`tldraw \u2014 ${e?.name}`,null,t.svg),p()}}else if(1){let t=e.getCurrentPage(),n=await e.getSvgString(e.getSortedChildIdsForParent(t.id),y);n&&(u(`tldraw \u2014 ${t.name}`,null,n.svg),p())}else{for(let t=0;t<m.length;t++){let n=m[t],r=await e.getSvgString(e.getSortedChildIdsForParent(n.id),y);r&&u(`tldraw \u2014 ${n.name}`,`${t}/${m.length}`,r.svg)}p()}i.removeEventListener("beforeprint",d),i.removeEventListener("afterprint",c)},[e])),{cut:b,copy:x,paste:w}=(r=(0,h.frr)(),i=hn(),o=(0,C.useCallback)(async function(e){(0,h.vAR)(r,"editor is required for copy"),0===r.getSelectedShapeIds().length||await pG(r,{operation:"copy",source:"menu"})&&i("copy",{source:e})},[r,i]),s=(0,C.useCallback)(async function(e){!r||0===r.getSelectedShapeIds().length||await pG(r,{operation:"cut",source:"menu"})&&(r.deleteShapes(r.getSelectedShapeIds()),i("cut",{source:e}))},[r,i]),{copy:o,cut:s,paste:a=(0,C.useCallback)(async function(e,t,n){if(!r||null!==r.getEditingShapeId())return;let o=r.getContainerWindow();if(Array.isArray(e)&&e[0]instanceof o.ClipboardItem){if(r.options.onClipboardPasteRaw?.({editor:r,source:"clipboard-read",clipboardItems:e,point:n})===!1)return void i("paste",{source:"menu"});pV({editor:r,clipboardItems:e,point:n,clipboardPasteSource:"clipboard-read"}),i("paste",{source:"menu"})}else o.navigator.clipboard.read().then(e=>{a(e,t,n)})},[r,i])}),v=function(){let e=(0,h.frr)(),{addToast:t}=pM(),n=$();return(0,C.useCallback)((r,i="svg")=>{(0,h.vAR)(e,"useCopyAs: editor is required"),(function(e,t,n){if(!navigator.clipboard)return Promise.reject(Error("Copy not supported"));if("json"===n.format){let n=JSON.stringify(e.getContentFromCurrentPage(t),null," ");return navigator.clipboard.writeText(n)}let r={...n,format:n.format};if(navigator.clipboard.write){var i;let{blobPromise:o,mimeType:s}=function(e,t,n={}){let r=t?.length?t:[...e.getCurrentPageShapeIds()],i=n.format??"png";return{blobPromise:e.toImage(r,n).then(e=>h.SmQ.rewriteMimeType(e.blob,pq[i])),mimeType:pq[i]}}(e,t,r),a={[s]:o},l=(i=n.format,(0,h.g50)(pD,i)??null);l&&"u">typeof ClipboardItem&&"supports"in ClipboardItem&&ClipboardItem.supports(l)&&(a[l]=o.then(e=>h.SmQ.rewriteMimeType(e,l)));let d=Object.entries(a);for(let[e,t]of d)t.catch(e=>console.error(e));return navigator.clipboard.write([new ClipboardItem(a)]).catch(e=>(console.error(e),Promise.all(d.map(async([e,t])=>[e,await t])).then(e=>{let t=(0,h._ed)(e);return navigator.clipboard.write([new ClipboardItem(t)])})))}switch(n.format){case"svg":return pX(async()=>{let n=await e.getSvgString(t,r);if(!n)throw Error("Failed to copy");return n.svg});case"png":throw Error("Copy not supported");default:(0,h.h6G)(n.format)}})(e,r,{format:i}).catch(()=>{t({id:"copy-fail",severity:"warning",title:n("toast.error.copy-fail.title"),description:n("toast.error.copy-fail.desc")})})},[e,t,n])}(),S=function(){let e=(0,h.frr)(),{addToast:t}=pM(),n=$();return(0,C.useCallback)((r,i={})=>{(0,h.vAR)(e,"useExportAs: editor is required");let{format:o="png",name:s,scale:a=1}=i;ib(e,r,{format:o,name:s,scale:a}).catch(e=>{console.error(e.message),t({id:"export-fail",title:n("toast.error.export-fail.title"),description:n("toast.error.export-fail.desc"),severity:"error"})})},[e,t,n])}(),k=dL(),P=5>d$(),T=(0,h.H80)((0,C.useContext)(pJ)),E=(0,C.useCallback)(async()=>{if(!l)return;let e=await pA({allowMultiple:!0,mimeTypes:T,document:l.getContainerDocument()});e.length&&(l.markHistoryStoppingPoint("insert media"),l.putExternalContent({type:"files",files:e,point:l.getViewportPageBounds().center}))},[l,T]),I=(0,C.useCallback)(async e=>{if(!l)return;let t=await pA({allowMultiple:!1,mimeTypes:T?.filter(t=>e?t.startsWith("image/"):t.startsWith("video/")),document:l.getContainerDocument()});if(!t.length)return;let n=l.getOnlySelectedShape();if(!n||e&&"image"!==n.type||!e&&"video"!==n.type)return;l.markHistoryStoppingPoint("replace media");let r=t[0];l.replaceExternalContent({type:"file-replace",file:r,shapeId:n.id,isImage:e})},[l,T]),_=(0,C.useCallback)(()=>I(!0),[I]),M=(0,C.useCallback)(()=>I(!1),[I]);return(0,C.useMemo)(()=>({addToast:d,removeToast:c,clearToasts:u,addDialog:p,removeDialog:g,clearDialogs:f,msg:m,isMobile:P,insertMedia:E,replaceImage:_,replaceVideo:M,printSelectionOrPages:y,cut:b,copy:x,paste:w,copyAs:v,exportAs:S,getEmbedDefinition:k}),[d,c,u,p,g,f,m,P,E,_,M,y,b,x,w,v,S,k])}function pQ(e){return(0,C.useMemo)(()=>e,e)}function p0(e){let t=pQ(null==e?[]:Array.isArray(e)?e:[e]);return(0,C.useMemo)(()=>{let e={};for(let n of t)if(n.translations)for(let[t,r]of(0,h.iAN)(n.translations)){let n=e[t];n||(n=e[t]={}),Object.assign(n,r)}return e},[t])}let p1=C.createContext(null);function p2({overrides:e,children:t}){let n=(0,h.frr)(),r=hn(),i=M(),o=$(),s=pZ(),a=C.useCallback((e,t,n)=>{i.announce({msg:o(t.label)}),r("select-tool",{source:e,id:n??t.id})},[i,o,r]),l=C.useMemo(()=>{if(!n)return{};let t=[{id:"select",label:"tool.select",icon:"tool-pointer",kbd:"v",readonlyOk:!0,onSelect(e){if(n.isIn("select")){let e=n.root.getCurrent();e.exit({},e.id),e.enter({},e.id)}n.setCurrentTool("select"),a(e,this)}},{id:"hand",label:"tool.hand",icon:"tool-hand",kbd:"h",readonlyOk:!0,onSelect(e){n.setCurrentTool("hand"),a(e,this)}},{id:"eraser",label:"tool.eraser",icon:"tool-eraser",kbd:"e",onSelect(e){n.setCurrentTool("eraser"),a(e,this)}},{id:"draw",label:"tool.draw",icon:"tool-pencil",kbd:"d,b,x",onSelect(e){n.setCurrentTool("draw"),a(e,this)}},...[...h.tg8.values].map(e=>({id:e,label:`tool.${e}`,meta:{geo:e},kbd:"rectangle"===e?"r":"ellipse"===e?"o":void 0,icon:"geo-"+e,onSelect(t){n.run(()=>{n.setStyleForNextShapes(h.tg8,e),n.setCurrentTool("geo"),a(t,this,`geo-${e}`)})},onDragStart(t,i){let o=n.getResizeScaleFactor();p5(n,i,{createShape:t=>n.createShape({id:t,type:"geo",props:{w:200*o,h:200*o,geo:e,scale:o}})}),r("drag-tool",{source:t,id:"geo"})}})),{id:"arrow",label:"tool.arrow",icon:"tool-arrow",kbd:"a",onSelect(e){n.setCurrentTool("arrow"),a(e,this)},onDragStart(e,t){let i=n.getResizeScaleFactor();p5(n,t,{createShape:e=>n.createShape({id:e,type:"arrow",props:{start:{x:0,y:200*i},end:{x:200*i,y:0},scale:i}})}),r("drag-tool",{source:e,id:"arrow"})}},{id:"line",label:"tool.line",icon:"tool-line",kbd:"l",onSelect(e){n.setCurrentTool("line"),a(e,this)},onDragStart(e,t){let i=n.getResizeScaleFactor();p5(n,t,{createShape:e=>{let[t,r]=(0,h.MTM)(null,null,2);n.createShape({id:e,type:"line",props:{points:{[t]:{id:t,index:t,x:0,y:200*i},[r]:{id:r,index:r,x:200*i,y:0}},scale:i}})}}),r("drag-tool",{source:e,id:"line"})}},{id:"frame",label:"tool.frame",icon:"tool-frame",kbd:"f",onSelect(e){n.setCurrentTool("frame"),a(e,this)},onDragStart(e,t){let i=n.getResizeScaleFactor();p5(n,t,{createShape:e=>n.createShape({id:e,type:"frame",props:{w:320*i,h:180*i}})}),r("drag-tool",{source:e,id:"frame"})}},{id:"text",label:"tool.text",icon:"tool-text",kbd:"t",onSelect(e){n.setCurrentTool("text"),a(e,this)},onDragStart(e,t){let i=n.getResizeScaleFactor();p5(n,t,{createShape:e=>n.createShape({id:e,type:"text",props:{richText:(0,h.TP3)("Text"),scale:i}}),onDragEnd:e=>{E(n,e,{selectAll:!0})}}),r("drag-tool",{source:e,id:"text"})}},{id:"asset",label:"tool.media",icon:"tool-media",kbd:"cmd+u,ctrl+u",onSelect(e){s.insertMedia(),a(e,this,"media")}},{id:"note",label:"tool.note",icon:"tool-note",kbd:"n",onSelect(e){n.setCurrentTool("note"),a(e,this)},onDragStart(e,t){let i=n.getResizeScaleFactor();p5(n,t,{createShape:e=>n.createShape({id:e,type:"note",props:{scale:i}}),onDragEnd:e=>{E(n,e,{selectAll:!0})}}),r("drag-tool",{source:e,id:"note"})}},{id:"laser",label:"tool.laser",readonlyOk:!0,icon:"tool-laser",kbd:"k",onSelect(e){n.setCurrentTool("laser"),a(e,this)}},{id:"embed",label:"tool.embed",icon:"dot",onSelect(e){s.addDialog({component:dF}),a(e,this)}},{id:"highlight",label:"tool.highlight",icon:"tool-highlight",kbd:"shift+d",onSelect(e){n.setCurrentTool("highlight"),a(e,this)}}];t.forEach(e=>e.onSelect=e.onSelect.bind(e));let i=Object.fromEntries(t.map(e=>[e.id,e]));return e?e(n,i,s):i},[e,n,s,a,r]);return(0,b.jsx)(p1.Provider,{value:l,children:t})}function p3(){let e=C.useContext(p1);if(!e)throw Error("useTools must be used within a ToolProvider");return e}function p5(e,t,n){if(e.getIsReadonly())return;let{x:r,y:i}=e.inputs.getCurrentPagePoint(),o=e.markHistoryStoppingPoint("drag shape tool"),s=(0,h.n6Y)();n.createShape(s);let a=e.getShape(s);if(!a){(0,h.mcG)("onDragFromToolbarToCreateShape: createShape did not create a shape, ignoring drag."),e.setCurrentTool("select.idle");return}let{w:l,h:d}=e.getShapePageBounds(s);e.updateShape({id:s,type:a.type,x:r-l/2,y:i-d/2}),e.select(s),e.setCurrentTool("select.translating",{...t,target:"shape",shape:e.getShape(s),isCreating:!0,creatingMarkId:o,onCreate(){e.setCurrentTool("select.idle"),e.select(s),n.onDragEnd?.(s)}}),e.getCurrentTool().setCurrentToolIdMask(n.maskedToolId??a.type)}function p6({toolId:e="",...t}){let n=p3()[e];return n?(0,b.jsx)(hJ,{...n,...t}):null}function p4(){let e=dW();return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(h0,{label:"shortcuts-dialog.tools",id:"tools",children:[(0,b.jsx)(hQ,{actionId:"toggle-tool-lock"}),(0,b.jsx)(hQ,{actionId:"insert-media"}),(0,b.jsx)(hQ,{actionId:"insert-embed"}),(0,b.jsx)(p6,{toolId:"select"}),(0,b.jsx)(p6,{toolId:"draw"}),(0,b.jsx)(p6,{toolId:"highlight"}),(0,b.jsx)(p6,{toolId:"eraser"}),(0,b.jsx)(p6,{toolId:"hand"}),(0,b.jsx)(p6,{toolId:"rectangle"}),(0,b.jsx)(p6,{toolId:"ellipse"}),(0,b.jsx)(p6,{toolId:"arrow"}),(0,b.jsx)(p6,{toolId:"line"}),(0,b.jsx)(p6,{toolId:"text"}),(0,b.jsx)(p6,{toolId:"frame"}),(0,b.jsx)(p6,{toolId:"note"}),(0,b.jsx)(p6,{toolId:"laser"}),(0,b.jsx)(hJ,{id:"pointer-down",label:"tool.pointer-down",kbd:",",onSelect:()=>{}})]}),(0,b.jsxs)(h0,{label:"shortcuts-dialog.preferences",id:"preferences",children:[(0,b.jsx)(hQ,{actionId:"toggle-dark-mode"}),(0,b.jsx)(hQ,{actionId:"toggle-focus-mode"}),(0,b.jsx)(hQ,{actionId:"toggle-grid"})]}),(0,b.jsxs)(h0,{label:"shortcuts-dialog.edit",id:"edit",children:[(0,b.jsx)(hQ,{actionId:"undo"}),(0,b.jsx)(hQ,{actionId:"redo"}),(0,b.jsx)(hQ,{actionId:"cut"}),(0,b.jsx)(hQ,{actionId:"copy"}),(0,b.jsx)(hQ,{actionId:"copy-as-png"}),(0,b.jsx)(hQ,{actionId:"copy-hovered-styles"}),(0,b.jsx)(hQ,{actionId:"paste"}),(0,b.jsx)(hQ,{actionId:"select-all"}),(0,b.jsx)(hQ,{actionId:"delete"}),(0,b.jsx)(hQ,{actionId:"duplicate"}),(0,b.jsx)(hQ,{actionId:"print"})]}),(0,b.jsxs)(h0,{label:"shortcuts-dialog.view",id:"view",children:[(0,b.jsx)(hQ,{actionId:"select-zoom-tool"}),(0,b.jsx)(hQ,{actionId:"zoom-in"}),(0,b.jsx)(hQ,{actionId:"zoom-out"}),(0,b.jsx)(hQ,{actionId:"zoom-to-100"}),(0,b.jsx)(hQ,{actionId:"zoom-to-fit"}),(0,b.jsx)(hQ,{actionId:"zoom-to-selection"}),(0,b.jsx)(hJ,{id:"zoom-quick",label:"action.zoom-quick",kbd:"shift+z",onSelect:()=>{}})]}),(0,b.jsxs)(h0,{label:"shortcuts-dialog.transform",id:"transform",children:[(0,b.jsx)(hQ,{actionId:"bring-to-front"}),(0,b.jsx)(hQ,{actionId:"bring-forward"}),(0,b.jsx)(hQ,{actionId:"send-backward"}),(0,b.jsx)(hQ,{actionId:"send-to-back"}),(0,b.jsx)(hQ,{actionId:"group"}),(0,b.jsx)(hQ,{actionId:"ungroup"}),(0,b.jsx)(hQ,{actionId:"frame-selection"}),(0,b.jsx)(hQ,{actionId:"flatten-to-image"}),(0,b.jsx)(hQ,{actionId:"toggle-lock"}),(0,b.jsx)(hQ,{actionId:"flip-horizontal"}),(0,b.jsx)(hQ,{actionId:"flip-vertical"}),(0,b.jsx)(hQ,{actionId:"align-top"}),(0,b.jsx)(hQ,{actionId:"align-center-vertical"}),(0,b.jsx)(hQ,{actionId:"align-bottom"}),(0,b.jsx)(hQ,{actionId:"align-left"}),(0,b.jsx)(hQ,{actionId:"align-center-horizontal"}),(0,b.jsx)(hQ,{actionId:"align-right"}),(0,b.jsx)(hQ,{actionId:"distribute-horizontal"}),(0,b.jsx)(hQ,{actionId:"distribute-vertical"})]}),(0,b.jsxs)(h0,{label:"shortcuts-dialog.text-formatting",id:"text",children:[(0,b.jsx)(hJ,{id:"text-bold",label:"tool.rich-text-bold",kbd:"cmd+b",onSelect:()=>{}}),(0,b.jsx)(hJ,{id:"text-italic",label:"tool.rich-text-italic",kbd:"cmd+i",onSelect:()=>{}}),(0,b.jsx)(hJ,{id:"text-code",label:"tool.rich-text-code",kbd:"cmd+e",onSelect:()=>{}}),(0,b.jsx)(hJ,{id:"text-highlight",label:"tool.rich-text-highlight",kbd:"cmd+shift+h",onSelect:()=>{}}),(0,b.jsx)(hJ,{id:"text-strikethrough",label:"tool.rich-text-strikethrough",kbd:"cmd+shift+s",onSelect:()=>{}}),(0,b.jsx)(hJ,{id:"text-link",label:"tool.rich-text-link",kbd:"cmd+shift+k",onSelect:()=>{}}),(0,b.jsx)(hJ,{id:"text-header",label:"tool.rich-text-header",kbd:"cmd+alt+[[1-6]]",onSelect:()=>{}}),(0,b.jsx)(hJ,{id:"text-orderedList",label:"tool.rich-text-orderedList",kbd:"cmd+shift+7",onSelect:()=>{}}),(0,b.jsx)(hJ,{id:"text-bulletedlist",label:"tool.rich-text-bulletList",kbd:"cmd+shift+8",onSelect:()=>{}})]}),(0,b.jsxs)(h0,{label:"shortcuts-dialog.a11y",id:"a11y",children:[(0,b.jsx)(hJ,{id:"a11y-select-next-shape",label:"a11y.select-shape",kbd:"[[Tab]]",onSelect:()=>{}}),(0,b.jsx)(hJ,{id:"a11y-select-next-shape-direction",label:"a11y.select-shape-direction",kbd:"cmd+[[↑→↓←]]",onSelect:()=>{}}),(0,b.jsx)(hJ,{id:"a11y-select-next-shape-container",label:"a11y.enter-leave-container",kbd:"cmd+shift+[[↑↓]]",onSelect:()=>{}}),(0,b.jsx)(hJ,{id:"a11y-pan-camera",label:"a11y.pan-camera",kbd:"[[Space]]+[[↑→↓←]]",onSelect:()=>{}}),(0,b.jsx)(hJ,{id:"adjust-shape-styles",label:"a11y.adjust-shape-styles",kbd:"cmd+[[Enter]]",onSelect:()=>{}}),(0,b.jsx)(hJ,{id:"open-context-menu",label:"a11y.open-context-menu",kbd:"cmd+shift+[[Enter]]",onSelect:()=>{}}),(0,b.jsx)(hJ,{id:"a11y-move-shape",label:"a11y.move-shape",kbd:"[[↑→↓←]]",onSelect:()=>{}}),(0,b.jsx)(hJ,{id:"a11y-move-shape-faster",label:"a11y.move-shape-faster",kbd:"shift+[[↑→↓←]]",onSelect:()=>{}}),(0,b.jsx)(hJ,{id:"a11y-rotate-shape-cw",label:"a11y.rotate-shape-cw",kbd:"shift+﹥",onSelect:()=>{}}),(0,b.jsx)(hJ,{id:"a11y-rotate-shape-cw-fine",label:"a11y.rotate-shape-cw-fine",kbd:"shift+alt+﹥",onSelect:()=>{}}),(0,b.jsx)(hJ,{id:"a11y-rotate-shape-ccw",label:"a11y.rotate-shape-ccw",kbd:"shift+﹤",onSelect:()=>{}}),(0,b.jsx)(hJ,{id:"a11y-rotate-shape-ccw-fine",label:"a11y.rotate-shape-ccw-fine",kbd:"shift+alt+﹤",onSelect:()=>{}}),(0,b.jsx)(hQ,{actionId:"enlarge-shapes"}),(0,b.jsx)(hQ,{actionId:"shrink-shapes"}),(0,b.jsx)(hQ,{actionId:"a11y-repeat-shape-announce"}),(0,b.jsx)(hJ,{id:"a11y-open-keyboard-shortcuts",label:"a11y.open-keyboard-shortcuts",kbd:"cmd+alt+/",onSelect:()=>{}})]}),e&&(0,b.jsx)(h0,{label:"shortcuts-dialog.collaboration",id:"collaboration",children:(0,b.jsx)(hQ,{actionId:"open-cursor-chat"})})]})}let p8=(0,C.memo)(function({children:e}){let t=$(),n=d$(),r=e??(0,b.jsx)(p4,{});return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(dy,{className:"tlui-shortcuts-dialog__header",children:[(0,b.jsx)(db,{children:t("shortcuts-dialog.title")}),(0,b.jsx)(dx,{})]}),(0,b.jsx)(dw,{className:ik("tlui-shortcuts-dialog__body",{"tlui-shortcuts-dialog__body__mobile":n<=2,"tlui-shortcuts-dialog__body__tablet":n<=6}),children:(0,b.jsx)(dU,{type:"keyboard-shortcuts",sourceId:"kbd",children:r})}),(0,b.jsx)("div",{className:"tlui-dialog__scrim"})]})});async function p9(e,t,n){let r=(0,h.oE7)(t.map(t=>{let n=e.getShape(t);if(n&&void 0!==e.getShapeUtil(n.type).toSvg)return n}));if(0===r.length)return;if(1===r.length){let t=r[0];if(!t||e.isShapeOfType(t,"image"))return}let i=[];if(void 0!==n){let t=r.map(t=>({shape:t,bounds:e.getShapeMaskedPageBounds(t).clone().expandBy(n)}));for(let e=0;e<t.length;e++){let n=t[e];if(0===e){i[0]={shapes:[n.shape],bounds:n.bounds};continue}let r=!1;for(let e of i)if(e.bounds.includes(n.bounds)){e.shapes.push(n.shape),e.bounds.expand(n.bounds),r=!0;break}r||i.push({shapes:[n.shape],bounds:n.bounds})}}else{let t=h.azJ.Common(r.map(t=>e.getShapeMaskedPageBounds(t)));i.push({shapes:r,bounds:t})}let o=e.options.flattenImageBoundsPadding;for(let t of i){void 0!==n&&t.bounds.expandBy(-n);let r=await e.getSvgString(t.shapes,{padding:o,background:!1});if(!r?.svg)continue;let i=await e.getAssetForExternalContent({type:"file",file:new File([r.svg],"asset.svg",{type:"image/svg+xml"})});i&&(t.asset=i)}let s=[];return(0,h.hLc)(()=>{for(let t of i){let n,r,i,{asset:a,bounds:l,shapes:d}=t;if(!a)continue;let c=e.findCommonAncestor(d)??e.getCurrentPageId();if(!c)continue;let u="a1";for(let e of d)if(e.parentId===c){e.index>u&&(u=e.index);break}if((0,h.vc4)(c)){let t=e.getShape(c);if(!t)continue;let s=e.getPointInShapeSpace(t,{x:l.x,y:l.y});i=e.getShapePageTransform(c).rotation(),s.sub(new h.l2P(o,o).rot(-i)),n=s.x,r=s.y}else n=l.x-o,r=l.y-o,i=0;e.deleteShapes(d),e.createAssets([{...a,id:a.id}]);let p=(0,h.n6Y)();e.createShape({id:p,type:"image",index:u,parentId:c,x:n,y:r,rotation:-i,props:{assetId:a.id,w:l.w+2*o,h:l.h+2*o}}),s.push(p)}}),s}var p7=Object.defineProperty,fe=(e,t)=>p7(e,"name",{value:t,configurable:!0}),ft="Popover",[fn,fr]=iz(ft,[sI]),fi=sI(),[fo,fs]=fn(ft),fa=fe(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:o,modal:s=!1}=e,a=fi(t),l=C.useRef(null),[d,c]=C.useState(!1),[u,h]=s5({prop:r,defaultProp:i??!1,onChange:o,caller:ft});return(0,b.jsx)(sA,{...a,children:(0,b.jsx)(fo,{scope:t,contentId:of(),triggerRef:l,open:u,onOpenChange:h,onOpenToggle:C.useCallback(()=>h(e=>!e),[h]),hasCustomAnchor:d,onCustomAnchorAdd:C.useCallback(()=>c(!0),[]),onCustomAnchorRemove:C.useCallback(()=>c(!1),[]),modal:s,children:n})})},"Popover"),fl=C.forwardRef(fe(function(e,t){let{__scopePopover:n,...r}=e,i=fs("PopoverTrigger",n),o=fi(n),s=iL(t,i.triggerRef),a=(0,b.jsx)(i5.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":fx(i.open),...r,ref:s,onClick:iI(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?a:(0,b.jsx)(sj,{asChild:!0,...o,children:a})},"PopoverTrigger")),fd="PopoverPortal",[fc,fu]=fn(fd,{forceMount:void 0}),fh=fe(e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,o=fs(fd,t);return(0,b.jsx)(fc,{scope:t,forceMount:n,children:(0,b.jsx)(sK,{present:n||o.open,children:(0,b.jsx)(le,{asChild:!0,container:i,children:r})})})},"PopoverPortal"),fp="PopoverContent",ff=C.forwardRef(fe(function(e,t){let n=fu(fp,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,o=fs(fp,e.__scopePopover);return(0,b.jsx)(sK,{present:r||o.open,children:o.modal?(0,b.jsx)(fm,{...i,ref:t}):(0,b.jsx)(fy,{...i,ref:t})})},"PopoverContent")),fg=iU("PopoverContent.RemoveScroll"),fm=C.forwardRef(fe(function(e,t){let n=fs(fp,e.__scopePopover),r=C.useRef(null),i=iL(t,r),o=C.useRef(!1);return C.useEffect(()=>{let e=r.current;if(e)return lZ(e)},[]),(0,b.jsx)(lK,{as:fg,allowPinchZoom:!0,children:(0,b.jsx)(fb,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:iI(e.onCloseAutoFocus,e=>{e.preventDefault(),o.current||n.triggerRef.current?.focus()}),onPointerDownOutside:iI(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;o.current=2===t.button||n},{checkForDefaultPrevented:!1}),onFocusOutside:iI(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})},"PopoverContentModal")),fy=C.forwardRef(fe(function(e,t){let n=fs(fp,e.__scopePopover),r=C.useRef(!1),i=C.useRef(!1);return(0,b.jsx)(fb,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,"pointerdown"===t.detail.originalEvent.type&&(i.current=!0));let o=t.target;n.triggerRef.current?.contains(o)&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&i.current&&t.preventDefault()}})},"PopoverContentNonModal")),fb=C.forwardRef(fe(function(e,t){let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:d,onInteractOutside:c,...u}=e,h=fs(fp,n),p=fi(n);return lo(),(0,b.jsx)(aJ,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o,children:(0,b.jsx)(ot,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:c,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:d,onDismiss:()=>h.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,b.jsx)(sF,{"data-state":fx(h.open),role:"dialog",id:h.contentId,...p,...u,ref:t,style:{...u.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)"}})})})},"PopoverContentImpl"));function fx(e){return e?"open":"closed"}function fw({id:e,children:t,onOpenChange:n,open:r,className:i}){let[o,s]=hr(e,n);return(0,b.jsx)(fa,{onOpenChange:s,open:r||o,children:(0,b.jsx)("div",{className:ik("tlui-popover",i),children:t})})}function fv({children:e}){let t=B();return(0,b.jsx)(fl,{asChild:!0,dir:t,children:e})}function fS({side:e,children:t,align:n="center",sideOffset:r=8,alignOffset:i=0,collisionPadding:o,disableEscapeKeyDown:s=!1,autoFocusFirstButton:a=!0}){let l=(0,h.NFA)(),d=B(),c=C.useRef(null),u=C.useCallback(()=>{if(!a)return;let e=[...c.current?.querySelectorAll("button:not([disabled])")??[]].filter(e=>e.offsetWidth||e.offsetHeight)[0];e&&e.focus()},[a]);return(0,b.jsx)(fh,{container:l,children:(0,b.jsx)(ff,{className:"tlui-popover__content",side:e,sideOffset:r,align:n,alignOffset:i,collisionPadding:o,dir:d,ref:c,onOpenAutoFocus:u,onEscapeKeyDown:e=>s&&e.preventDefault(),children:t})})}fe(fx,"getState");var fC=n(54530);function fk(e,t,n){let r=e.getBindingsFromShape(t,"arrow").find(e=>e.props.terminal===n);if(!r)return;let i=e.getShape(r.toId);if(!i)return;let o=e.getShapePageTransform(i),s="start"===n?"none"!==t.props.arrowheadStart:"none"!==t.props.arrowheadEnd,a=e.getShapeGeometry(i,s?void 0:{context:"@tldraw/arrow-without-arrowhead"});return{shape:i,transform:o,isClosed:a.isClosed,isExact:r.props.isExact,didIntersect:!1,geometry:a}}function fP(e,t,n,r){let i=e.getShape(n.toId);if(!i)return new h.l2P(0,0);{var o;let s,{point:a,size:l}=e.getShapeGeometry(i).bounds,d=n.props.isPrecise||r?(o=n.props.normalizedAnchor,{x:(s=e=>Math.max(.001,Math.min(.999,e)))(o.x),y:s(o.y)}):{x:.5,y:.5},c=h.l2P.Add(a,h.l2P.MulV(d,l)),u=h.V8r.applyToPoint(e.getShapePageTransform(i),c);return h.V8r.applyToPoint(h.V8r.Inverse(t),u)}}let fT=(0,fC.uY)("arrow bindings",(e,t)=>{let n=e.getBindingsFromShape(t.id,"arrow");return{start:n.find(e=>"start"===e.props.terminal),end:n.find(e=>"end"===e.props.terminal)}},{areRecordsEqual:(e,t)=>e.id===t.id,areResultsEqual:(e,t)=>e.start===t.start&&e.end===t.end});function fE(e,t){return fT.get(e,t.id)}function fI(e,t,n){let r=e.getShapePageTransform(t),i=fA(e,n.start?.toId,n.end?.toId);return{start:n.start?fP(e,r,n.start,"double-bound"===i||"start-contains-end"===i):h.l2P.From(t.props.start),end:n.end?fP(e,r,n.end,"double-bound"===i||"end-contains-start"===i):h.l2P.From(t.props.end)}}function f_(e,t,n,r){let i="string"==typeof t?t:t.id,o="string"==typeof n?n:n.id,s=e.getBindingsFromShape(i,"arrow").filter(e=>e.props.terminal===r.terminal);s.length>1&&e.deleteBindings(s.slice(1));let a=s[0];a?e.updateBinding({...a,toId:o,props:r}):e.createBinding({type:"arrow",fromId:i,toId:o,props:r})}function fM(e,t,n){let r=e.getBindingsFromShape(t,"arrow").filter(e=>e.props.terminal===n);e.deleteBindings(r)}function fA(e,t,n){if(!t||!n)return"safe";if(t===n)return"double-bound";let r=e.getShapePageBounds(t),i=e.getShapePageBounds(n);if(r&&i){if(r.contains(i))return"start-contains-end";if(i.contains(r))return"end-contains-start"}return"safe"}function fj(e,t,n,r,i){if(!i)return;let o=e.getShapeMask(i.shape.id);if(!o)return;let s=h.V8r.applyToPoint(r,t);if((0,h.s3y)(s,o))return;let a=h.V8r.applyToPoint(r,n),l=h.l2P.Sub(a,s).uni(),d=h.l2P.Add(a,h.l2P.Mul(l,1)),c=(0,h.lqI)(d,s,o);if(!c||0===c.length)return;let u=c[0],p=h.l2P.Dist2(u,s);for(let e=1;e<c.length;e++){let t=h.l2P.Dist2(c[e],s);t<p&&(u=c[e],p=t)}let f=h.V8r.applyToPoint(h.V8r.Inverse(r),u);t.setTo(f)}function fO(){let e=(0,h.hGv)();return(0,h.hau)("threeStackableItems",()=>e.getSelectedShapeIds().map(t=>e.getShape(t)).filter(t=>{if(!t)return!1;if(e.isShapeOfType(t,"arrow")){let n=fE(e,t);if(n.start||n.end)return!1}return!0}).length>2,[e])}function fD(){let e=(0,h.hGv)();return(0,h.hau)("isInSelectState",()=>e.isIn("select"),[e])}function fL(){let e=(0,h.hGv)();return(0,h.hau)("allow group",()=>{let t=e.getSelectedShapes();if(t.length<2)return!1;for(let n of t)if(e.isShapeOfType(n,"arrow")){let r=fE(e,n);if(r.start&&!t.some(e=>e.id===r.start.toId)||r.end&&!t.some(e=>e.id===r.end.toId))return!1}return!0},[e])}function fF(){let e=(0,h.hGv)();return(0,h.hau)("allowUngroup",()=>e.getSelectedShapeIds().some(t=>e.getShape(t)?.type==="group"),[e])}let fR="u">typeof window&&"navigator"in window&&!!navigator.clipboard&&!!navigator.clipboard.read;function fz(e,t){let n=(0,h.hGv)();return(0,h.hau)("selectedShapes",()=>{let r=n.getSelectedShapes().length;if(void 0===e)if(void 0===t)return r;else return r<=t;return void 0===t?r>=e:r>=e&&r<=t},[n,e,t])}function fN(e,t){let n=(0,h.hGv)();return(0,h.hau)("selectedShapes",()=>{let r=n.getSelectedShapes().filter(e=>!n.isShapeOrAncestorLocked(e)).length;if(void 0===e)if(void 0===t)return r;else return r<=t;return void 0===t?r>=e:r>=e&&r<=t},[n])}function f$(){let e=(0,h.hGv)();return(0,h.hau)("hasLinkShapeSelected",()=>{let t=e.getOnlySelectedShape();return!!(t&&"embed"!==t.type&&"url"in t.props&&!t.isLocked)},[e])}function fB(){let e=(0,h.hGv)();return(0,h.hau)("useCanRedo",()=>e.getCanRedo(),[e])}function fH(){let e=(0,h.hGv)();return(0,h.hau)("useCanUndo",()=>e.getCanUndo(),[e])}function fU(){let e=(0,h.hGv)();return(0,h.hau)("hasShapesOnPage",()=>e.getCurrentPageShapeIds().size>0,[e])}function fW(){let e=(0,h.hGv)();return(0,h.hau)("canApplySelectionAction",()=>e.isIn("select")&&e.getSelectedShapeIds().length>0,[e])}function fK({id:e,kbd:t,label:n,lang:r,readonlyOk:i,onSelect:o,toggle:s=!1,disabled:a=!1,checked:l=!1}){let{type:d,sourceId:c}=dH(),u=uz(),p=$(),f=B();if(u&&!i)return null;let g=xI(n,d),m=g?p(g):void 0;switch(d){case"menu":return(0,b.jsxs)(u5,{dir:f,lang:r,className:"tlui-button tlui-button__menu tlui-button__checkbox",onSelect:e=>{o?.(c),(0,h.woC)(e)},disabled:a,checked:l,children:[(0,b.jsx)(df,{small:!0,label:p(l?"ui.checked":"ui.unchecked"),icon:s?l?"toggle-on":"toggle-off":l?"check":"none"}),m&&(0,b.jsx)("span",{className:"tlui-button__label",draggable:!1,children:m}),t&&(0,b.jsx)(hp,{children:t})]});case"context-menu":return(0,b.jsxs)(uO,{className:"tlui-button tlui-button__menu tlui-button__checkbox",dir:f,lang:r,onSelect:e=>{o(c),(0,h.woC)(e)},disabled:a,checked:l,children:[(0,b.jsx)(df,{small:!0,label:p(l?"ui.checked":"ui.unchecked"),icon:s?l?"toggle-on":"toggle-off":l?"check":"none"}),m&&(0,b.jsx)("span",{className:"tlui-button__label",draggable:!1,children:m}),t&&(0,b.jsx)(hp,{children:t})]},e);default:return null}}function fV({actionId:e="",...t}){let n=xE()[e];return n?(0,b.jsx)(fK,{...n,...t}):null}function fY({id:e,disabled:t=!1,label:n,size:r="small",children:i}){let{type:o,sourceId:s}=dH(),a=(0,h.NFA)(),l=$(),d=B(),c=n?"string"==typeof n?n:n[o]??n.default:void 0,u=c?l(c):void 0;switch(o){case"menu":return(0,b.jsxs)(ha,{id:`${s}-sub.${e}`,children:[(0,b.jsx)(hl,{id:`${s}-sub.${e}-button`,disabled:t,label:u}),(0,b.jsx)(hd,{id:`${s}-sub.${e}-content`,size:r,children:i})]});case"context-menu":if(t)return null;return(0,b.jsxs)(fG,{id:`${s}-sub.${e}`,children:[(0,b.jsx)(uL,{dir:d,disabled:t,asChild:!0,children:(0,b.jsxs)(aW,{"data-testid":`${s}-sub.${e}-button`,type:"menu",className:"tlui-menu__submenu__trigger",children:[(0,b.jsx)(aK,{children:u}),(0,b.jsx)(dm,{icon:"rtl"===d?"chevron-left":"chevron-right",small:!0})]})}),(0,b.jsx)(uM,{container:a,children:(0,b.jsx)(uF,{"data-testid":`${s}-sub.${e}-content`,className:"tlui-menu tlui-menu__submenu__content",alignOffset:-1,sideOffset:-4,collisionPadding:4,"data-size":r,children:i})})]});default:return i}}function fG({id:e,children:t}){let[n,r]=hr(e);return(0,b.jsx)(uD,{open:n,onOpenChange:r,children:t})}function fq(){let e;return(e=(0,h.hGv)(),(0,h.hau)("showAutoSizeToggle",()=>{let t=e.getSelectedShapes();return 1===t.length&&e.isShapeOfType(t[0],"text")&&!1===t[0].props.autoSize},[e]))?(0,b.jsx)(hQ,{actionId:"toggle-auto-size"}):null}function fX(){return f$()?(0,b.jsx)(hQ,{actionId:"edit-link"}):null}function fJ(){return fN(1)?(0,b.jsx)(hQ,{actionId:"duplicate"}):null}function fZ(){let e=(0,h.hGv)();return(0,h.hau)("should display flatten option",()=>{if(0===e.getSelectedShapeIds().length)return!1;let t=e.getOnlySelectedShape();return!(t&&e.isShapeOfType(t,"image"))},[e])?(0,b.jsx)(hQ,{actionId:"flatten-to-image"}):null}function fQ(){let e=(0,h.hGv)();return(0,h.hau)("should display download original option",()=>{let t=e.getSelectedShapes();return 0!==t.length&&t.some(t=>xk(t,e))},[e])?(0,b.jsx)(hQ,{actionId:"download-original"}):null}function f0(){return fL()?(0,b.jsx)(hQ,{actionId:"group"}):null}function f1(){return fF()?(0,b.jsx)(hQ,{actionId:"ungroup"}):null}function f2(){return fL()?(0,b.jsx)(hQ,{actionId:"frame-selection"}):null}function f3(){let e=(0,h.hGv)();return(0,h.hau)("allow unframe",()=>{let t=e.getSelectedShapes();return 0!==t.length&&t.every(t=>e.isShapeFrameLike(t))},[e])?(0,b.jsx)(hQ,{actionId:"remove-frame"}):null}function f5(){let e=(0,h.hGv)();return(0,h.hau)("allow fit frame to content",()=>{let t=e.getOnlySelectedShape();return!!t&&e.isShapeFrameLike(t)&&e.getSortedChildIdsForParent(t).length>0},[e])?(0,b.jsx)(hQ,{actionId:"fit-frame-to-content"}):null}function f6(){return fz(1)?(0,b.jsx)(hQ,{actionId:"toggle-lock"}):null}function f4(){let e=(0,h.hGv)(),t=(0,h.hau)("isTransparentBg",()=>!e.getInstanceState().exportBackground,[e]);return(0,b.jsx)(fV,{actionId:"toggle-transparent",checked:t,toggle:!0})}function f8(){let e=fU();return(0,b.jsx)(hQ,{actionId:"unlock-all",disabled:!e})}function f9(){let e=(0,h.hGv)(),t=(0,h.hau)("zoomed to 100",()=>1===e.getEfficientZoomLevel(),[e]);return(0,b.jsx)(hQ,{actionId:"zoom-to-100",noClose:!0,disabled:t})}function f7(){let e=fU();return(0,b.jsx)(hQ,{actionId:"zoom-to-fit",disabled:!e,"data-testid":"minimap.zoom-menu.zoom-to-fit",noClose:!0})}function ge(){let e=fW();return(0,b.jsx)(hQ,{actionId:"zoom-to-selection",disabled:!e,"data-testid":"minimap.zoom-menu.zoom-to-selection",noClose:!0})}function gt(){return(0,b.jsxs)(h0,{id:"clipboard",children:[(0,b.jsx)(gi,{}),(0,b.jsx)(go,{}),(0,b.jsx)(gs,{}),(0,b.jsx)(fJ,{}),(0,b.jsx)(gd,{})]})}function gn(){let e=(0,h.hGv)(),t=xE(),n=fU(),r=(0,h.hau)("isDebugMode",()=>e.getInstanceState().isDebugMode,[e]),i=!!t["copy-as-json"]&&r;return t["copy-as-svg"]||t["copy-as-png"]||i?(0,b.jsxs)(fY,{id:"copy-as",label:"context-menu.copy-as",size:"small",disabled:!n,children:[(0,b.jsxs)(h0,{id:"copy-as-group",children:[(0,b.jsx)(hQ,{actionId:"copy-as-svg"}),!!e.getContainerWindow().navigator.clipboard?.write&&(0,b.jsx)(hQ,{actionId:"copy-as-png"}),i&&(0,b.jsx)(hQ,{actionId:"copy-as-json"})]}),(0,b.jsx)(h0,{id:"copy-as-bg",children:(0,b.jsx)(f4,{})})]}):null}function gr(){let e=xE();return e["export-as-svg"]||e["export-as-png"]?(0,b.jsxs)(fY,{id:"export-as",label:"context-menu.export-as",size:"small",children:[(0,b.jsxs)(h0,{id:"export-as-group",children:[(0,b.jsx)(hQ,{actionId:"export-as-svg"}),(0,b.jsx)(hQ,{actionId:"export-as-png"})]}),(0,b.jsx)(h0,{id:"export-as-bg",children:(0,b.jsx)(f4,{})})]}):null}function gi(){let e=fW(),t=fN(1);return(0,b.jsx)(hQ,{actionId:"cut",disabled:!e||!t})}function go(){let e=fW();return(0,b.jsx)(hQ,{actionId:"copy",disabled:!e})}function gs(){return(0,b.jsx)(hQ,{actionId:"paste",disabled:!fR})}function ga(){return fU()?(0,b.jsxs)(h0,{id:"conversions",children:[(0,b.jsx)(gn,{}),(0,b.jsx)(gr,{}),(0,b.jsx)(fQ,{})]}):null}function gl(){let e=fU();return(0,b.jsx)(hQ,{actionId:"select-all",disabled:!e})}function gd(){let e=fW(),t=fN(1);return(0,b.jsx)(hQ,{actionId:"delete",disabled:!e||!t})}function gc(){let e=uz();return!fz(1)||e?null:(0,b.jsxs)(fY,{id:"edit",label:"context-menu.edit",size:"small",children:[(0,b.jsx)(f0,{}),(0,b.jsx)(f1,{}),(0,b.jsx)(fZ,{}),(0,b.jsx)(f2,{}),(0,b.jsx)(fX,{}),(0,b.jsx)(f5,{}),(0,b.jsx)(f3,{}),(0,b.jsx)(gy,{}),(0,b.jsx)(gm,{}),(0,b.jsx)(fq,{}),(0,b.jsx)(f6,{})]})}function gu(){let e,t=fN(2),n=(e=(0,h.hGv)(),(0,h.hau)("onlyFlippableShape",()=>{let t=e.getOnlySelectedShape();return t&&(e.isShapeOfType(t,"group")||e.isShapeOfType(t,"image")||e.isShapeOfType(t,"arrow")||e.isShapeOfType(t,"line")||e.isShapeOfType(t,"draw")||e.isShapeOfType(t,"geo"))},[e]));return uz()||!(t||n)?null:(0,b.jsxs)(fY,{id:"arrange",label:"context-menu.arrange",size:"small",children:[t&&(0,b.jsxs)(h0,{id:"align",children:[(0,b.jsx)(hQ,{actionId:"align-left"}),(0,b.jsx)(hQ,{actionId:"align-center-horizontal"}),(0,b.jsx)(hQ,{actionId:"align-right"}),(0,b.jsx)(hQ,{actionId:"align-top"}),(0,b.jsx)(hQ,{actionId:"align-center-vertical"}),(0,b.jsx)(hQ,{actionId:"align-bottom"})]}),(0,b.jsx)(gh,{}),t&&(0,b.jsxs)(h0,{id:"stretch",children:[(0,b.jsx)(hQ,{actionId:"stretch-horizontal"}),(0,b.jsx)(hQ,{actionId:"stretch-vertical"})]}),(t||n)&&(0,b.jsxs)(h0,{id:"flip",children:[(0,b.jsx)(hQ,{actionId:"flip-horizontal"}),(0,b.jsx)(hQ,{actionId:"flip-vertical"})]}),(0,b.jsx)(gp,{})]})}function gh(){return fN(3)?(0,b.jsxs)(h0,{id:"distribute",children:[(0,b.jsx)(hQ,{actionId:"distribute-horizontal"}),(0,b.jsx)(hQ,{actionId:"distribute-vertical"})]}):null}function gp(){let e=fN(2),t=fO();return e?(0,b.jsxs)(h0,{id:"order",children:[(0,b.jsx)(hQ,{actionId:"pack"}),t&&(0,b.jsx)(hQ,{actionId:"stack-horizontal"}),t&&(0,b.jsx)(hQ,{actionId:"stack-vertical"})]}):null}function gf(){let e=uz(),t=fN(1);return e||!t?null:(0,b.jsx)(fY,{id:"reorder",label:"context-menu.reorder",size:"small",children:(0,b.jsxs)(h0,{id:"reorder",children:[(0,b.jsx)(hQ,{actionId:"bring-to-front"}),(0,b.jsx)(hQ,{actionId:"bring-forward"}),(0,b.jsx)(hQ,{actionId:"send-backward"}),(0,b.jsx)(hQ,{actionId:"send-to-back"})]})})}function gg(){let e=(0,h.hGv)(),t=(0,h.hau)("pages",()=>e.getPages(),[e]),n=(0,h.hau)("current page id",()=>e.getCurrentPageId(),[e]),{addToast:r}=pM(),i=hn(),o=uz();return!fN(1)||o?null:(0,b.jsxs)(fY,{id:"move-to-page",label:"context-menu.move-to-page",size:"small",children:[(0,b.jsx)(h0,{id:"pages",children:t.map(t=>(0,b.jsx)(hJ,{id:t.id,disabled:n===t.id,label:t.name.length>30?`${t.name.slice(0,30)}\u2026`:t.name,onSelect:()=>{e.markHistoryStoppingPoint("move_shapes_to_page"),e.moveShapesToPage(e.getSelectedShapeIds(),t.id);let o=e.getPage(t.id);o&&r({title:"Changed page",description:`Moved to ${o.name}.`,actions:[{label:"Go back",type:"primary",onClick:()=>{e.markHistoryStoppingPoint("change-page"),e.setCurrentPage(n)}}]}),i("move-to-page",{source:"context-menu"})}},t.id))}),(0,b.jsx)(h0,{id:"new-page",children:(0,b.jsx)(hQ,{actionId:"move-to-new-page"})})]})}function gm(){let e=(0,h.hGv)();return(0,h.hau)("oneEmbedSelected",()=>{let t=e.getOnlySelectedShape();return!!t&&!!(e.isShapeOfType(t,"embed")&&t.props.url&&!e.isShapeOrAncestorLocked(t))},[e])?(0,b.jsx)(hQ,{actionId:"convert-to-bookmark"}):null}function gy(){let e=(0,h.hGv)(),t=dL();return(0,h.hau)("oneEmbeddableBookmarkSelected",()=>{let n=e.getOnlySelectedShape();return!!n&&!!(e.isShapeOfType(n,"bookmark")&&n.props.url&&t(n.props.url)&&!e.isShapeOrAncestorLocked(n))},[e])?(0,b.jsx)(hQ,{actionId:"convert-to-embed"}):null}function gb(){let e=(0,h.hGv)(),t=(0,h.hau)("isSnapMode",()=>e.user.getIsSnapMode(),[e]);return(0,b.jsx)(fV,{actionId:"toggle-snap-mode",checked:t})}function gx(){let e=(0,h.hGv)(),t=(0,h.hau)("isToolLock",()=>e.getInstanceState().isToolLocked,[e]);return(0,b.jsx)(fV,{actionId:"toggle-tool-lock",checked:t})}function gw(){let e=(0,h.hGv)(),t=(0,h.hau)("isGridMode",()=>e.getInstanceState().isGridMode,[e]);return(0,b.jsx)(fV,{actionId:"toggle-grid",checked:t})}function gv(){let e=(0,h.hGv)(),t=(0,h.hau)("isWrapMode",()=>e.user.getIsWrapMode(),[e]);return(0,b.jsx)(fV,{actionId:"toggle-wrap-mode",checked:t})}function gS(){let e=(0,h.hGv)(),t=(0,h.hau)("isFocusMode",()=>e.getInstanceState().isFocusMode,[e]);return(0,b.jsx)(fV,{actionId:"toggle-focus-mode",checked:t})}function gC(){let e=(0,h.hGv)(),t=(0,h.hau)("edgeScrollSpeed",()=>e.user.getEdgeScrollSpeed(),[e]);return(0,b.jsx)(fV,{actionId:"toggle-edge-scrolling",checked:1===t})}function gk(){let e=(0,h.hGv)(),t=(0,h.hau)("inputMode",()=>"mouse"===e.user.getUserPreferences().inputMode,[e]),n=(0,h.hau)("isZoomDirectionInverted",()=>e.user.getIsZoomDirectionInverted(),[e]);return(0,b.jsx)(fV,{actionId:"toggle-invert-zoom",checked:n,disabled:!t})}function gP(){let e=(0,h.hGv)(),t=(0,h.hau)("animationSpeed",()=>e.user.getAnimationSpeed(),[e]);return(0,b.jsx)(fV,{actionId:"toggle-reduce-motion",checked:0===t})}function gT(){let e=(0,h.hGv)(),t=(0,h.hau)("keyboardShortcuts",()=>e.user.getAreKeyboardShortcutsEnabled(),[e]);return(0,b.jsx)(fV,{actionId:"toggle-keyboard-shortcuts",checked:t})}function gE(){let e=(0,h.hGv)(),t=(0,h.hau)("enhancedA11yMode",()=>e.user.getEnhancedA11yMode(),[e]);return(0,b.jsx)(fV,{actionId:"enhanced-a11y-mode",checked:t})}function gI(){let e=(0,h.hGv)(),t=(0,h.hau)("isDebugMode",()=>e.getInstanceState().isDebugMode,[e]);return(0,b.jsx)(fV,{actionId:"toggle-debug-mode",checked:t})}function g_(){let e=(0,h.hGv)(),t=(0,h.hau)("dynamic resize",()=>e.user.getIsDynamicResizeMode(),[e]);return(0,b.jsx)(fV,{actionId:"toggle-dynamic-size-mode",checked:t})}function gM(){let e=(0,h.hGv)(),t=(0,h.hau)("paste at cursor",()=>e.user.getIsPasteAtCursorMode(),[e]);return(0,b.jsx)(fV,{actionId:"toggle-paste-at-cursor",checked:t})}function gA(){let e=(0,h.hGv)();return(0,h.hau)("show cursor chat",()=>"select"===e.getCurrentToolId()&&!e.getInstanceState().isCoarsePointer,[e])?(0,b.jsx)(hQ,{actionId:"open-cursor-chat"}):null}function gj(){return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(gO,{}),(0,b.jsx)(gD,{}),(0,b.jsx)(gL,{}),(0,b.jsx)(gF,{}),(0,b.jsx)(gR,{}),(0,b.jsx)(gN,{}),(0,b.jsx)(g$,{}),(0,b.jsx)(gB,{})]})}function gO(){let e=fN(2),t=fD(),n=e&&t;return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(hQ,{actionId:"align-left",disabled:!n}),(0,b.jsx)(hQ,{actionId:"align-center-horizontal",disabled:!n}),(0,b.jsx)(hQ,{actionId:"align-right",disabled:!n}),(0,b.jsx)(hQ,{actionId:"stretch-horizontal",disabled:!n}),(0,b.jsx)(hQ,{actionId:"align-top",disabled:!n}),(0,b.jsx)(hQ,{actionId:"align-center-vertical",disabled:!n}),(0,b.jsx)(hQ,{actionId:"align-bottom",disabled:!n}),(0,b.jsx)(hQ,{actionId:"stretch-vertical",disabled:!n})]})}function gD(){let e=fN(3),t=fD(),n=e&&t;return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(hQ,{actionId:"distribute-horizontal",disabled:!n}),(0,b.jsx)(hQ,{actionId:"distribute-vertical",disabled:!n})]})}function gL(){let e=fO(),t=fD(),n=e&&t;return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(hQ,{actionId:"stack-horizontal",disabled:!n}),(0,b.jsx)(hQ,{actionId:"stack-vertical",disabled:!n})]})}function gF(){let e=fN(1),t=fD(),n=e&&t;return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(hQ,{actionId:"send-to-back",disabled:!n}),(0,b.jsx)(hQ,{actionId:"send-backward",disabled:!n}),(0,b.jsx)(hQ,{actionId:"bring-forward",disabled:!n}),(0,b.jsx)(hQ,{actionId:"bring-to-front",disabled:!n})]})}function gR(){return 5>d$()?(0,b.jsx)(f9,{}):(0,b.jsx)(gz,{})}function gz(){let e=fN(1),t=fD();return(0,b.jsx)(hQ,{actionId:"rotate-ccw",disabled:!(e&&t)})}function gN(){let e=fN(1),t=fD();return(0,b.jsx)(hQ,{actionId:"rotate-cw",disabled:!(e&&t)})}function g$(){let e=f$(),t=fD();return(0,b.jsx)(hQ,{actionId:"edit-link",disabled:!(e&&t)})}function gB(){let e=fL(),t=fF();return e?(0,b.jsx)(gH,{}):t?(0,b.jsx)(gU,{}):(0,b.jsx)(gH,{})}function gH(){let e=fN(2),t=fD();return(0,b.jsx)(hQ,{actionId:"group",disabled:!(e&&t)})}function gU(){return(0,b.jsx)(hQ,{actionId:"ungroup"})}let gW=(0,C.memo)(function({children:e}){let t=$(),n=d$(),r=uz(),{orientation:i}=aj(),o=(0,C.useRef)(null);(0,h.I9L)(o);let s=(0,h.hGv)(),a=(0,h.hau)("should display quick actions when in readonly",()=>s.isInAny("hand","zoom"),[s]),l=e??(0,b.jsx)(gj,{});if(!r||a)return(0,b.jsxs)(fw,{id:"actions-menu",children:[(0,b.jsx)(fv,{children:(0,b.jsx)(hG,{type:"icon","data-testid":"actions-menu.button",title:t("actions-menu.title"),children:(0,b.jsx)(dm,{icon:"horizontal"===i?"dots-vertical":"dots-horizontal",small:!0})})}),(0,b.jsx)(fS,{side:"horizontal"===i?n>=6?"bottom":"top":"right",sideOffset:6,children:(0,b.jsx)(hY,{ref:o,label:t("actions-menu.title"),className:"tlui-actions-menu","data-testid":"actions-menu.content",orientation:"grid",children:(0,b.jsx)(dU,{type:"icons",sourceId:"actions-menu",children:l})})})]})});function gK(){let e=(0,h.hGv)(),t=dW(),n=(0,h.hau)("isSinglePageMode",()=>e.options.maxPages<=1,[e]);return(0,b.jsxs)(b.Fragment,{children:[t&&(0,b.jsx)(gA,{}),(0,b.jsxs)(h0,{id:"modify",children:[(0,b.jsx)(gc,{}),(0,b.jsx)(gu,{}),(0,b.jsx)(gf,{}),!n&&(0,b.jsx)(gg,{})]}),(0,b.jsx)(gt,{}),(0,b.jsx)(ga,{}),(0,b.jsx)(h0,{id:"select-all",children:(0,b.jsx)(gl,{})})]})}let gV=(0,C.memo)(function({children:e,disabled:t=!1}){let n=(0,h.hGv)(),r=$(),{Canvas:i}=(0,h.BSi)(),o=(0,h.hau)("context menu can open",()=>!n.getInstanceState().isCoarsePointer||n.isIn("select"),[n]),s=(0,C.useCallback)(e=>{"Escape"===e.key&&(e.stopPropagation(),n.getContainer().focus())},[n]);(0,C.useEffect)(()=>{let e=n.getContainerDocument().body;return()=>{e.removeEventListener("keydown",s,{capture:!0})}},[n,s]);let a=(0,C.useRef)(0),l=(0,C.useCallback)(e=>{let t=n.getContainerDocument().body;if(e){if(t.addEventListener("keydown",s,{capture:!0}),n.getInstanceState().isCoarsePointer){a.current=Date.now()+500;let e=n.getSelectedShapes(),t=n.inputs.getCurrentPagePoint(),r=n.getShapesAtPoint(t);if(!n.getSelectedShapes().length||!r.some(t=>e.includes(t))){let e=r.filter(e=>n.isShapeOrAncestorLocked(e));e.length&&n.select(...e.map(e=>e.id))}}}else{let e=n.getOnlySelectedShape();e&&n.isShapeOrAncestorLocked(e)&&n.setSelectedShapes([]),n.timers.requestAnimationFrame(()=>{t.removeEventListener("keydown",s,{capture:!0})})}},[n,s]),d=(0,h.NFA)(),c=B(),[u,p]=hr("context menu",l),f=e??(0,b.jsx)(gK,{});return(0,b.jsxs)(uI,{dir:c,onOpenChange:p,modal:!1,children:[(0,b.jsx)(u_,{onContextMenu:o?void 0:h.woC,dir:"ltr",disabled:t||!o,children:i?(0,b.jsx)(i,{}):null}),u&&(0,b.jsx)(uM,{container:d,children:(0,b.jsx)(uA,{className:"tlui-menu tlui-scrollable","data-testid":"context-menu","aria-label":r("context-menu.title"),alignOffset:-4,collisionPadding:4,onContextMenu:h.woC,onPointerDownOutside:e=>{Date.now()<a.current&&e.preventDefault()},onInteractOutside:e=>{Date.now()<a.current&&e.preventDefault()},onFocusOutside:e=>{Date.now()<a.current&&e.preventDefault()},children:(0,b.jsx)(dU,{type:"context-menu",sourceId:"context-menu",children:f})})})]})}),gY=(0,h.u4I)(function(){let e=(0,h.hGv)(),{isChatting:t,chatMessage:n}=e.getInstanceState(),r=(0,C.useRef)(-1),[i,o]=(0,C.useState)("");return((0,C.useEffect)(()=>((!t&&n||t)&&(r.current=e.timers.setTimeout(()=>{e.updateInstanceState({chatMessage:"",isChatting:!1}),o(""),e.focus()},t?5e3:2e3)),()=>{clearTimeout(r.current)}),[e,n,t]),t)?(0,b.jsx)(gX,{value:i,setValue:o,chatMessage:n}):n.trim()?(0,b.jsx)(gq,{chatMessage:n}):null});function gG(e){let t=(0,h.hGv)();(0,C.useLayoutEffect)(()=>{if(!e.current)return;let{x:n,y:r}=t.inputs.getCurrentScreenPoint();function i(n){let{minX:r,minY:i}=t.getViewportScreenBounds();e.current?.style.setProperty("transform",`translate(${n.clientX-r}px, ${n.clientY-i}px)`)}e.current?.style.setProperty("transform",`translate(${n}px, ${r}px)`);let o=t.getContainerWindow();return o.addEventListener("pointermove",i),()=>{o.removeEventListener("pointermove",i)}},[e,t])}let gq=({chatMessage:e})=>{let t=(0,h.hGv)(),n=(0,C.useRef)(null);return gG(n),(0,b.jsx)("div",{ref:n,className:"tl-cursor-chat tl-cursor-chat__bubble",style:{backgroundColor:t.user.getColor()},children:e})},gX=(0,h.u4I)(function({chatMessage:e,value:t,setValue:n}){let r=(0,h.hGv)(),i=$(),o=(0,C.useRef)(null),s=e||i("cursor-chat.type-to-chat");gG(o),(0,C.useLayoutEffect)(()=>{let e=o.current;if(!e)return;let n=r.textMeasure.measureText(t||s,{fontFamily:"inherit",fontSize:12,fontWeight:"500",fontStyle:"normal",maxWidth:null,lineHeight:1,padding:"6px"});e.style.setProperty("width",n.w+"px")},[r,t,s]),(0,C.useLayoutEffect)(()=>{let e=r.timers.requestAnimationFrame(()=>{o.current?.focus()});return()=>{cancelAnimationFrame(e)}},[r]);let a=(0,C.useCallback)(()=>{r.updateInstanceState({isChatting:!1}),r.focus()},[r]),l=(0,C.useCallback)(e=>{let{value:t}=e.target;n(t.slice(0,64)),r.updateInstanceState({chatMessage:t})},[r,n]),d=(0,C.useCallback)(e=>{let t=o.current;if(!t)return;let{value:r}=t;switch(e.key){case"Enter":if((0,h.woC)(e),e.stopPropagation(),!r)return void a();n("");break;case"Escape":(0,h.woC)(e),e.stopPropagation(),a()}},[a,n]),c=(0,C.useCallback)(e=>{e.stopPropagation()},[]);return(0,b.jsx)("input",{ref:o,className:"tl-cursor-chat",style:{backgroundColor:r.user.getColor()},onBlur:a,onChange:l,onKeyDown:d,onPaste:c,value:t,placeholder:s,spellCheck:!1})});function gJ({checked:e}){let t=$();return(0,b.jsx)(df,{"data-checked":!!e,label:t(e?"ui.checked":"ui.unchecked"),icon:e?"check":"none",className:"tlui-button__icon",small:!0})}function gZ({customDebugFlags:e,customFeatureFlags:t}){let n=(0,h.hGv)(),{addToast:r}=pM(),{addDialog:i}=h3(),[o,s]=C.useState(!1);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(h0,{id:"items",children:[(0,b.jsx)(hJ,{id:"hard-reset",onSelect:h.W$r,label:"Hard reset"}),(0,b.jsx)(hJ,{id:"add-toast",onSelect:()=>{r({id:(0,h.NF7)(),title:"Something good happened",description:"Hey, attend to this thing over here. It might be important!",keepOpen:!0,severity:"success"}),r({id:(0,h.NF7)(),title:"Something happened",description:"Hey, attend to this thing over here. It might be important!",keepOpen:!0,severity:"info",actions:[{label:"Primary",type:"primary",onClick:()=>{}},{label:"Normal",type:"normal",onClick:()=>{}},{label:"Danger",type:"danger",onClick:()=>{}}]}),r({id:(0,h.NF7)(),title:"Something maybe bad happened",description:"Hey, attend to this thing over here. It might be important!",keepOpen:!0,severity:"warning",actions:[{label:"Primary",type:"primary",onClick:()=>{}},{label:"Normal",type:"normal",onClick:()=>{}},{label:"Danger",type:"danger",onClick:()=>{}}]}),r({id:(0,h.NF7)(),title:"Something bad happened",severity:"error",keepOpen:!0})},label:"Show toast"}),(0,b.jsx)(hJ,{id:"show-dialog",label:"Show dialog",onSelect:()=>{i({component:({onClose:e})=>(0,b.jsx)(g1,{displayDontShowAgain:!0,onCancel:()=>e(),onContinue:()=>e()}),onClose:()=>{}})}}),(0,b.jsx)(hJ,{id:"create-shapes",label:"Create 100 shapes",onSelect:()=>(function(e){let t=e.options.adjacentShapeMargin,n=Array(100),r=Math.floor(Math.sqrt(100));for(let e=0;e<100;e++)g3++,n[e]={id:(0,h.n6Y)("box"+g3),type:"geo",x:e%r*(100+t),y:Math.floor(e/r)*(100+t)};e.run(()=>{e.createShapes(n).setSelectedShapes(n.map(e=>e.id))})})(n)}),(0,b.jsx)(hJ,{id:"count-nodes",label:"Count shapes / nodes",onSelect:()=>{let e=n.getSelectedShapes(),t=0===e.length?n.getRenderingShapes():e;window.alert(`Shapes ${t.length}, DOM nodes:${n.getContainerDocument().querySelector(".tl-shapes").querySelectorAll("*")?.length}`)}}),(()=>{if(o)throw Error("oh no!");return null})(),(0,b.jsx)(hJ,{id:"throw-error",onSelect:()=>s(!0),label:"Throw error"})]}),(0,b.jsxs)(h0,{id:"flags",children:[(0,b.jsx)(gQ,{customDebugFlags:e}),(0,b.jsx)(g0,{customFeatureFlags:t})]})]})}function gQ(e){let t=Object.values(e.customDebugFlags??h.bGJ);return t.length?(0,b.jsx)(fY,{id:"debug flags",label:"Debug flags",children:(0,b.jsx)(h0,{id:"debug flags",children:t.map(e=>(0,b.jsx)(g2,{flag:e},e.name))})}):null}function g0(e){let t=Object.values(e.customFeatureFlags??h.ofH);return t.length?(0,b.jsx)(fY,{id:"feature flags",label:"Feature flags",children:(0,b.jsx)(h0,{id:"feature flags",children:t.map(e=>(0,b.jsx)(g2,{flag:e},e.name))})}):null}function g1({title:e="title",body:t="hello hello hello",cancel:n="Cancel",confirm:r="Continue",displayDontShowAgain:i=!1,maxWidth:o="350",onCancel:s,onContinue:a}){let[l,d]=C.useState(!1);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(dy,{children:[(0,b.jsx)(db,{children:e}),(0,b.jsx)(dx,{})]}),(0,b.jsx)(dw,{style:{maxWidth:o},children:t}),(0,b.jsxs)(dv,{className:"tlui-dialog__footer__actions",children:[i&&(0,b.jsxs)(aW,{type:"normal",onClick:()=>d(!l),style:{marginRight:"auto"},children:[(0,b.jsx)(gJ,{checked:l}),(0,b.jsx)(aK,{children:"Don’t show again"})]}),(0,b.jsx)(aW,{type:"normal",onClick:s,children:(0,b.jsx)(aK,{children:n})}),(0,b.jsx)(aW,{type:"primary",onClick:async()=>a(),children:(0,b.jsx)(aK,{children:r})})]})]})}let g2=(0,h.u4I)(function({flag:e,onChange:t}){let n=e.get();return(0,b.jsx)(fK,{id:e.name,title:e.name,label:e.name.replace(/([a-z0-9])([A-Z])/g,e=>`${e[0]} ${e[1].toLowerCase()}`).replace(/^[a-z]/,e=>e.toUpperCase()),checked:n,onSelect:()=>{e.set(!n),t?.(!n)}})}),g3=0;function g5({children:e}){let t=(0,h.hGv)(),n=e??(0,b.jsx)(gZ,{});return(0,C.useEffect)(()=>{let e=window;return e.editor=t,()=>{e.editor===t&&delete e.editor}},[t]),(0,b.jsxs)(hi,{id:"debug",children:[(0,b.jsx)(ho,{children:(0,b.jsx)(aW,{type:"icon",title:"Debug menu",children:(0,b.jsx)(dm,{icon:"dots-horizontal"})})}),(0,b.jsx)(hs,{side:"top",align:"end",alignOffset:0,children:(0,b.jsx)(dU,{type:"menu",sourceId:"debug-panel",children:n})})]})}let g6=(0,C.memo)(function(){let{DebugMenu:e}=xS(),t=(0,C.useRef)(null);return(0,h.I9L)(t),(0,b.jsxs)("footer",{ref:t,className:"tlui-debug-panel",children:[(0,b.jsx)(g4,{}),(0,b.jsx)(g8,{}),e&&(0,b.jsx)(e,{})]})}),g4=(0,h.u4I)(function(){let e=(0,h.hGv)().getPath();return(0,b.jsx)("div",{className:"tlui-debug-panel__current-state",children:`${e}`})});function g8(){let e=(0,h.hGv)(),t=(0,h.hau)("show_fps",()=>h.bGJ.showFps.get(),[h.bGJ]),n=(0,C.useRef)(null);return((0,C.useEffect)(()=>{if(!t)return;let r=0,i=-1,o=performance.now(),s=0,a=0,l=!1;return!function t(){if(a++,(s=performance.now()-o)>250){let e=Math.round(250/s*a*4);e>r&&(r=e);let t=.75*r;(e<t&&!l||e>=t&&l)&&(l=!l),n.current.innerHTML=`FPS ${e.toString()} (max: ${r})`,n.current.className="tlui-debug-panel__fps"+(l?" tlui-debug-panel__fps__slow":""),s-=250,a=0,o=performance.now()}i=e.timers.requestAnimationFrame(t)}(),()=>{cancelAnimationFrame(i)}},[t,e]),t)?(0,b.jsx)("div",{ref:n}):null}function g9(){let e=(0,h.hGv)(),t=(0,h.hau)("follow",()=>e.getInstanceState().followingUserId,[e]);return t?(0,b.jsx)(g7,{userId:t}):null}function g7({userId:e}){let t=(0,h.xQ_)(e);return t?(0,b.jsx)("div",{className:"tlui-following-indicator",style:{borderColor:t.color}}):null}let me=(0,C.memo)(function(){let e=d$(),t=$(),n=(0,C.useRef)(null);(0,h.I9L)(n);let{MainMenu:r,QuickActions:i,ActionsMenu:o,PageMenu:s}=xS(),a=(0,h.hGv)(),l=(0,h.hau)("isSinglePageMode",()=>a.options.maxPages<=1,[a]),d="menu"===a.options.actionShortcutsLocation||"toolbar"!==a.options.actionShortcutsLocation&&e>=6;return r||s||d?(0,b.jsx)("nav",{ref:n,className:"tlui-menu-zone",children:(0,b.jsxs)(aO,{children:[r&&(0,b.jsx)(r,{}),s&&!l&&(0,b.jsx)(s,{}),d?(0,b.jsxs)(hY,{orientation:"horizontal",label:t("actions-menu.title"),children:[i&&(0,b.jsx)(i,{}),o&&(0,b.jsx)(o,{})]}):null]})}):null}),mt=({id:e,component:t,preventBackgroundClose:n})=>{let{removeDialog:r}=h3(),i=(0,h.NFA)(),o=B(),s=(0,C.useCallback)(t=>{t||r(e)},[e,r]);return(0,b.jsx)(l4,{onOpenChange:s,defaultOpen:!0,children:(0,b.jsxs)(de,{container:i,children:[(0,b.jsx)(dn,{dir:o,className:"tlui-dialog__overlay"}),(0,b.jsx)("div",{dir:o,className:"tlui-dialog__positioner",children:(0,b.jsx)(da,{dir:o,className:"tlui-dialog__content","aria-describedby":void 0,onInteractOutside:e=>{n&&e.preventDefault()},children:(0,b.jsx)(t,{onClose:()=>s(!1)})})})]})})},mn=(0,C.memo)(function(){let{dialogs:e}=h3();return(0,h.hau)("dialogs",()=>e.get(),[e]).map(e=>(0,b.jsx)(mt,{...e},e.id))});function mr(){let e=(0,h.hGv)();return(0,h.hau)("is pen mode",()=>e.getInstanceState().isPenMode,[e])?(0,b.jsx)(hQ,{actionId:"exit-pen-mode"}):null}function mi(){let e=(0,h.hGv)(),t=xE();return(0,h.hau)("is following user",()=>!!e.getInstanceState().followingUserId,[e])?(0,b.jsx)(hJ,{...t["stop-following"]}):null}function mo(){return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(mr,{}),(0,b.jsx)(xA,{}),(0,b.jsx)(mi,{})]})}function ms({children:e}){let t=e??(0,b.jsx)(mo,{});return(0,b.jsx)("div",{className:"tlui-helper-buttons",children:(0,b.jsx)(dU,{type:"helper-buttons",sourceId:"helper-buttons",children:t})})}function ma(){return(0,b.jsx)(fY,{id:"help menu accessibility",label:"menu.accessibility",children:(0,b.jsxs)(h0,{id:"accessibility",children:[(0,b.jsx)(gP,{}),(0,b.jsx)(gT,{}),(0,b.jsx)(gE,{})]})})}let ml=[{colorScheme:"light",label:"theme.light"},{colorScheme:"dark",label:"theme.dark"},{colorScheme:"system",label:"theme.system"}];function md(){let e=(0,h.hGv)(),t=hn(),n=(0,h.hau)("colorScheme",()=>e.user.getUserPreferences().colorScheme??(e.user.getIsDarkMode()?"dark":"light"),[e]);return(0,b.jsx)(fY,{id:"help menu color-scheme",label:"menu.theme",children:(0,b.jsx)(h0,{id:"theme",children:ml.map(({colorScheme:r,label:i})=>(0,b.jsx)(fK,{id:`color-scheme-${r}`,label:i,checked:r===n,readonlyOk:!0,onSelect:()=>{e.user.updateUserPreferences({colorScheme:r}),t("color-scheme",{source:"menu",value:r})}},r))})})}function mc(){let e=(0,h.frr)(),t=hn(),n=(0,h.hau)("locale",()=>e?.user.getLocale(),[e]);return e?(0,b.jsx)(fY,{id:"help menu language",label:"menu.language",children:(0,b.jsx)(h0,{id:"languages",className:"tlui-language-menu",children:h.Yjb.map(({locale:r,label:i})=>(0,b.jsx)(fK,{id:`language-${r}`,lang:r,title:r,label:i,checked:r===n,readonlyOk:!0,onSelect:()=>{e.user.updateUserPreferences({locale:r}),t("change-language",{source:"menu",locale:r})}},r))})}):null}function mu(){return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(mc,{}),(0,b.jsx)(mh,{})]})}function mh(){let{KeyboardShortcutsDialog:e}=xS(),{addDialog:t}=h3(),n=(0,C.useCallback)(()=>{e&&t({component:e})},[t,e]);return e?(0,b.jsx)(hJ,{id:"keyboard-shortcuts-button",label:"help-menu.keyboard-shortcuts",readonlyOk:!0,onSelect:n}):null}let mp=["auto","trackpad","mouse"];function mf(){let e=(0,h.hGv)(),t=hn(),n=(0,h.hau)("inputMode",()=>e.user.getUserPreferences().inputMode,[e]),r=(0,h.hau)("wheelBehavior",()=>e.getCameraOptions().wheelBehavior,[e]);return(0,b.jsxs)(fY,{id:"help menu input-mode",label:"menu.input-device",children:[(0,b.jsx)(h0,{id:"peripheral-mode",children:mp.map(i=>(0,b.jsx)(fK,{id:`peripheral-mode-${i}`,label:"auto"===i?`action.toggle-auto-${r}`:"trackpad"===i?"action.toggle-trackpad":"action.toggle-mouse",checked:"auto"===i?null===n:n===i,readonlyOk:!0,onSelect:()=>{switch(t("input-mode",{source:"menu",value:i}),i){case"auto":e.user.updateUserPreferences({inputMode:null});break;case"trackpad":e.user.updateUserPreferences({inputMode:"trackpad"});break;case"mouse":e.user.updateUserPreferences({inputMode:"mouse"})}}},i))}),(0,b.jsx)(h0,{id:"invert-zoom-group",children:(0,b.jsx)(gk,{})})]})}function mg(){return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(h0,{id:"basic",children:[(0,b.jsx)(my,{}),(0,b.jsx)(mv,{}),(0,b.jsx)(mm,{}),(0,b.jsx)(mS,{})]}),(0,b.jsx)(mC,{})]})}function mm(){let e=xE();return e["export-all-as-svg"]||e["export-all-as-png"]?(0,b.jsxs)(fY,{id:"export-all-as",label:"context-menu.export-all-as",size:"small",children:[(0,b.jsxs)(h0,{id:"export-all-as-group",children:[(0,b.jsx)(hQ,{actionId:"export-all-as-svg"}),(0,b.jsx)(hQ,{actionId:"export-all-as-png"})]}),(0,b.jsx)(h0,{id:"export-all-as-bg",children:(0,b.jsx)(f4,{})})]}):null}function my(){return(0,b.jsxs)(fY,{id:"edit",label:"menu.edit",children:[(0,b.jsx)(mw,{}),(0,b.jsx)(gt,{}),(0,b.jsx)(ga,{}),(0,b.jsx)(mb,{}),(0,b.jsx)(mx,{}),(0,b.jsx)(h0,{id:"select-all",children:(0,b.jsx)(gl,{})})]})}function mb(){return(0,b.jsxs)(h0,{id:"misc",children:[(0,b.jsx)(f0,{}),(0,b.jsx)(f1,{}),(0,b.jsx)(fX,{}),(0,b.jsx)(fq,{}),(0,b.jsx)(f3,{}),(0,b.jsx)(f5,{}),(0,b.jsx)(gy,{}),(0,b.jsx)(gm,{}),(0,b.jsx)(fZ,{})]})}function mx(){return(0,b.jsxs)(h0,{id:"lock",children:[(0,b.jsx)(f6,{}),(0,b.jsx)(f8,{})]})}function mw(){let e=fH(),t=fB();return(0,b.jsxs)(h0,{id:"undo-redo",children:[(0,b.jsx)(hQ,{actionId:"undo",disabled:!e}),(0,b.jsx)(hQ,{actionId:"redo",disabled:!t})]})}function mv(){return(0,b.jsx)(fY,{id:"view",label:"menu.view",children:(0,b.jsxs)(h0,{id:"view-actions",children:[(0,b.jsx)(hQ,{actionId:"zoom-in"}),(0,b.jsx)(hQ,{actionId:"zoom-out"}),(0,b.jsx)(f9,{}),(0,b.jsx)(f7,{}),(0,b.jsx)(ge,{})]})})}function mS(){return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(hQ,{actionId:"insert-embed"}),(0,b.jsx)(hQ,{actionId:"insert-media"})]})}function mC(){return(0,b.jsxs)(h0,{id:"preferences",children:[(0,b.jsxs)(fY,{id:"preferences",label:"menu.preferences",children:[(0,b.jsxs)(h0,{id:"preferences-actions",children:[(0,b.jsx)(gb,{}),(0,b.jsx)(gx,{}),(0,b.jsx)(gw,{}),(0,b.jsx)(gv,{}),(0,b.jsx)(gS,{}),(0,b.jsx)(gC,{}),(0,b.jsx)(g_,{}),(0,b.jsx)(gM,{}),(0,b.jsx)(gI,{})]}),(0,b.jsxs)(h0,{id:"user-interface-submenus",children:[(0,b.jsx)(ma,{}),(0,b.jsx)(mf,{}),(0,b.jsx)(md,{})]})]}),(0,b.jsx)(mc,{}),(0,b.jsx)(mh,{})]})}let mk=(0,C.memo)(function({children:e}){let t=(0,h.NFA)(),[n,r]=hr("main menu"),i=$(),o=B(),s=e??(0,b.jsx)(mg,{});return(0,b.jsxs)(uQ,{dir:o,open:n,onOpenChange:r,modal:!1,children:[(0,b.jsx)(u0,{asChild:!0,dir:o,children:(0,b.jsx)(aW,{type:"icon","data-testid":"main-menu.button",title:i("menu.title"),children:(0,b.jsx)(dm,{icon:"menu",small:!0})})}),(0,b.jsx)(u1,{container:t,children:(0,b.jsx)(u2,{className:"tlui-menu",side:"bottom",align:"start",collisionPadding:4,alignOffset:0,sideOffset:6,children:(0,b.jsx)(dU,{type:"menu",sourceId:"main-menu",children:s})})})]})});var mP=Object.defineProperty,mT=Object.getOwnPropertyDescriptor,mE=(e,t,n,r)=>{for(var i,o=r>1?void 0:r?mT(t,n):t,s=e.length-1;s>=0;s--)(i=e[s])&&(o=(r?i(t,n,o):i(o))||o);return r&&o&&mP(t,n,o),o};class mI{constructor(e,t,n){this.editor=e,this.elem=t,this.container=n;const r=t.getContext("2d");if(!r)throw Error("Minimap: could not get 2D canvas context");this.ctx=r,this.shapeRectCache=e.store.createComputedCache("minimap-shape-rect",t=>{let n=e.getShapeUtil(t.type);return n.hideInMinimap?.(t)?null:e.getShapeMaskedPageBounds(t.id)??null}),this.colors=this._getColors(),this.disposables.push(this._listenForCanvasResize(),(0,h.wvh)("minimap render",this.render))}editor;elem;container;disposables=[];close(){this.disposables.forEach(e=>e())}ctx;shapeRectCache;_getColors(){let e=this.editor.getContainerWindow().getComputedStyle(this.editor.getContainer());return{shapeFill:e.getPropertyValue("--tl-color-text-3").trim(),selectFill:e.getPropertyValue("--tl-color-selected").trim(),viewportFill:e.getPropertyValue("--tl-color-muted-1").trim(),background:e.getPropertyValue("--tl-color-low").trim()}}colors;updateColors(){this.colors=this._getColors()}id=(0,h.NF7)();getDpr(){return this.editor.getInstanceState().devicePixelRatio}getContentPageBounds(){let e=this.editor.getViewportPageBounds(),t=this.editor.getCurrentPageBounds();return t?h.azJ.Expand(t,e):e}_getCanvasBoundingRect(){let{x:e,y:t,width:n,height:r}=this.elem.getBoundingClientRect();return new h.azJ(e,t,n,r)}canvasBoundingClientRect=(0,h.eUv)("canvasBoundingClientRect",new h.azJ);getCanvasScreenBounds(){return this.canvasBoundingClientRect.get()}_listenForCanvasResize(){let e=new ResizeObserver(()=>{let e=this._getCanvasBoundingRect();this.canvasBoundingClientRect.set(e)});return e.observe(this.elem),e.observe(this.container),()=>e.disconnect()}getCanvasSize(){let e=this.canvasBoundingClientRect.get(),t=this.getDpr();return new h.l2P(e.width*t,e.height*t)}originPagePoint=new h.l2P;originPageCenter=new h.l2P;isInViewport=!1;getCanvasPageBounds(){let e=this.getCanvasScreenBounds(),t=this.getContentPageBounds(),n=e.width/e.height,r=t.width,i=r/n;i<t.height&&(r=(i=t.height)*n);let o=new h.azJ(0,0,r,i);return o.center=t.center,o}getZoom(){return this.getCanvasScreenBounds().width/this.getCanvasPageBounds().width}getMinimapPagePoint(e,t){let n=this.getCanvasPageBounds(),r=this.getCanvasScreenBounds(),i=e-r.x,o=t-r.y;return i*=n.width/r.width,o*=n.height/r.height,i+=n.minX,o+=n.minY,new h.l2P(i,o,1)}minimapScreenPointToPagePoint(e,t,n=!1,r=!1){let{editor:i}=this,o=i.getViewportPageBounds(),{x:s,y:a}=this.getMinimapPagePoint(e,t);if(r){let e=this.editor.getCurrentPageBounds()??new h.azJ,t=e.minX-o.width/2,n=e.maxX+o.width/2,r=e.minY-o.height/2,i=e.maxY+o.height/2,l=Math.max(0,t+o.width-s),d=Math.max(0,-(n-o.width-s)),c=Math.max(0,r+o.height-a),u=Math.max(0,-(i-o.height-a));s+=(l-d)/2,a+=(c-u)/2,s=(0,h.qE8)(s,t,n),a=(0,h.qE8)(a,r,i)}if(n){let{originPagePoint:e}=this;Math.abs(s-e.x)>Math.abs(a-e.y)?a=e.y:s=e.x}return new h.l2P(s,a)}getShapePaths(){let{editor:e}=this,t=new Set(e.getSelectedShapeIds()),n=e.getCurrentPageShapeIdsSorted(),r=new Path2D,i=new Path2D;for(let e=0,o=n.length;e<o;e++){let o=n[e],s=this.shapeRectCache.get(o);s&&(t.has(o)?i:r).rect(s.x,s.y,s.w,s.h)}return{shapes:r,selected:i}}render(){let{ctx:e,editor:t,elem:n}=this,r=this.getCanvasSize(),i=this.getCanvasPageBounds(),o=this.getDpr(),s=this.getZoom();(n.width!==r.x||n.height!==r.y)&&(n.width=r.x,n.height=r.y),e.resetTransform(),e.fillStyle=this.colors.background,e.fillRect(0,0,r.x,r.y),e.scale(o*s,o*s),e.translate(-i.minX,-i.minY);let{shapes:a,selected:l}=this.getShapePaths();e.fillStyle=this.colors.shapeFill,e.fill(a),e.fillStyle=this.colors.selectFill,e.fill(l);let{minX:d,minY:c,width:u,height:p}=t.getViewportPageBounds(),f=Math.min(u/4,p/4,4/s);for(let{util:n,overlays:r}of(e.beginPath(),f*s<1?e.rect(d,c,u,p):e.roundRect(d,c,u,p,f),e.fillStyle=this.colors.viewportFill,e.fill(),t.overlays.getActiveOverlayEntries()))e.save(),n.renderMinimap(e,r,s),e.restore();let g=3/s;for(let n of t.getVisibleCollaboratorsOnCurrentPage())n.cursor&&(e.beginPath(),e.arc(n.cursor.x,n.cursor.y,g,0,h.uAR),e.fillStyle=n.color,e.fill())}}function m_(){let e=(0,h.hGv)(),t=(0,h.NFA)(),n=$(),r=C.useRef(null),i=C.useRef(!1),o=C.useRef(null),s=C.useRef(new h.l2P),a=C.useRef(void 0);C.useEffect(()=>{try{return a.current=new mI(e,r.current,t),a.current.close}catch(t){e.annotateError(t,{origin:"minimap",willCrashApp:!1}),e.timers.setTimeout(()=>{throw t});return}},[e,t]);let l=C.useCallback(t=>{if(!e.getCurrentPageShapeIds().size)return;let n=a.current;if(!n)return;let{clientX:r,clientY:i}=t,o=n.minimapScreenPointToPagePoint(r,i,!1,!0);n.originPagePoint.setTo(o),n.originPageCenter.setTo(e.getViewportPageBounds().center);let s=n.minimapScreenPointToPagePoint(r,i,!1,!1);e.centerOnPoint(s,{animation:{duration:e.options.animationMediumMs}})},[e]),d=C.useCallback(t=>{let n=a.current;if(!n||0!==t.button)return;let r=t.currentTarget;if((0,h.YYG)(r,t),!e.getCurrentPageShapeIds().size)return;let{clientX:l,clientY:d}=t;i.current=!0,o.current=t.pointerId,s.current=new h.l2P(l,d),n.isInViewport=!1;let c=n.minimapScreenPointToPagePoint(l,d,!1,!1),u=e.getViewportPageBounds(),p=n.getContentPageBounds();if(new h.azJ(p.x-u.width/2,p.y-u.height/2,p.width+u.width,p.height+u.height).containsPoint(c)&&!u.containsPoint(c)){let t=h.l2P.Sub(u.center,u.point),r=h.l2P.Add(c,t);n.originPagePoint.setTo(r),n.originPageCenter.setTo(c),e.centerOnPoint(c,{animation:{duration:e.options.animationMediumMs}})}else{let e=n.minimapScreenPointToPagePoint(l,d,!1,!0);n.isInViewport=u.containsPoint(e),n.originPagePoint.setTo(e),n.originPageCenter.setTo(u.center)}let f=e.getContainerDocument().body;function g(){null!==o.current&&r.hasPointerCapture(o.current)&&r.releasePointerCapture(o.current),i.current=!1,o.current=null,f.removeEventListener("pointerup",g),f.removeEventListener("pointercancel",g),f.removeEventListener("contextmenu",g,!0)}f.addEventListener("pointerup",g),f.addEventListener("pointercancel",g),f.addEventListener("contextmenu",g,!0)},[e]),c=C.useCallback(t=>{let n=a.current;if(!n)return;let{clientX:r,clientY:o}=t,l=n.minimapScreenPointToPagePoint(r,o,t.shiftKey,!0);if(i.current){if(4>=h.l2P.Dist2(s.current,new h.l2P(r,o)))return;if(n.isInViewport){let t=n.originPagePoint.clone().sub(n.originPageCenter);e.centerOnPoint(h.l2P.Sub(l,t));return}e.centerOnPoint(l)}let d=n.getMinimapPagePoint(r,o),c=e.pageToScreen(d),u={type:"pointer",target:"canvas",name:"pointer_move",...(0,h.yGT)(e,t),point:c,isPen:e.getInstanceState().isPenMode};e.dispatch(u)},[e]),u=C.useCallback(t=>{let n=(0,h.jaC)(t);e.dispatch({type:"wheel",name:"wheel",delta:n,point:new h.l2P(t.clientX,t.clientY),shiftKey:t.shiftKey,altKey:t.altKey,ctrlKey:t.metaKey||t.ctrlKey,metaKey:t.metaKey,accelKey:(0,h.gu7)(t)})},[e]),p=(0,h.G67)(),f=(0,h.hau)("current theme id",()=>e.getCurrentThemeId(),[e]);return C.useEffect(()=>{e.timers.setTimeout(()=>{a.current?.updateColors(),a.current?.render()})},[p,f,e]),(0,b.jsx)("div",{className:"tlui-minimap",children:(0,b.jsx)("canvas",{ref:r,role:"img","aria-label":n("navigation-zone.minimap"),"data-testid":"minimap.canvas",className:"tlui-minimap__canvas",onDoubleClick:l,onPointerMove:c,onPointerDown:d,onWheelCapture:u})})}mE([h.oIE],mI.prototype,"close",1),mE([h.EWP],mI.prototype,"getDpr",1),mE([h.EWP],mI.prototype,"getContentPageBounds",1),mE([h.EWP],mI.prototype,"getCanvasSize",1),mE([h.EWP],mI.prototype,"getCanvasPageBounds",1),mE([h.EWP],mI.prototype,"getZoom",1),mE([h.EWP],mI.prototype,"getShapePaths",1),mE([h.oIE],mI.prototype,"render",1);let mM=(0,C.memo)(function(){let e=xE(),t=$(),n=B(),r=d$(),i=(0,C.useRef)(null);(0,h.I9L)(i);let[o,s]=function(e,t){let[n,r]=C.useState(t);return C.useLayoutEffect(()=>{let t=(0,h.zMQ)(e);if(t)try{r(JSON.parse(t))}catch{console.error(`Could not restore value ${e} from local storage.`)}},[e]),[n,C.useCallback(t=>{r(n=>{let r="function"==typeof t?t(n):t;return(0,h.Yz5)(e,JSON.stringify(r)),r})},[e])]}("minimap",!0),a=(0,C.useCallback)(()=>{s(e=>!e)},[s]),{ZoomMenu:l,Minimap:d}=xS();return r<4?null:(0,b.jsxs)("div",{ref:i,className:"tlui-navigation-panel",children:[(0,b.jsx)(hY,{orientation:"horizontal",label:t("navigation-zone.title"),children:l&&r<6?(0,b.jsx)(l,{}):(0,b.jsxs)(b.Fragment,{children:[d&&"rtl"===n&&(0,b.jsx)(hG,{type:"icon","data-testid":"minimap.toggle-button",title:t("navigation-zone.toggle-minimap"),onClick:a,children:(0,b.jsx)(dm,{small:!0,icon:o?"chevron-left":"chevron-right"})}),!o&&(0,b.jsx)(hG,{type:"icon","data-testid":"minimap.zoom-out",title:`${t(xI(e["zoom-out"].label))} ${uU(e["zoom-out"].kbd)}`,onClick:()=>e["zoom-out"].onSelect("navigation-zone"),children:(0,b.jsx)(dm,{small:!0,icon:"minus"})}),l&&(0,b.jsx)(l,{},"zoom-menu"),!o&&(0,b.jsx)(hG,{type:"icon","data-testid":"minimap.zoom-in",title:`${t(xI(e["zoom-in"].label))} ${uU(e["zoom-in"].kbd)}`,onClick:()=>e["zoom-in"].onSelect("navigation-zone"),children:(0,b.jsx)(dm,{small:!0,icon:"plus"})}),d&&"rtl"!==n&&(0,b.jsx)(hG,{type:"icon","data-testid":"minimap.toggle-button",title:t("navigation-zone.toggle-minimap"),onClick:a,children:(0,b.jsx)(dm,{small:!0,icon:o?"chevron-right":"chevron-left"})})]})}),d&&r>=6&&!o&&(0,b.jsx)(d,{})]})});function mA(e,t,n,r,i){let o;if(n===r)return;let s=e.getPages(),a=n>r?s[r-1]:s[r],l=n>r?s[r]:s[r+1];(o=a&&!l?(0,h.AQy)(a.index):!a&&l?(0,h.SBu)(s[0].index):(0,h.HEt)(a.index,l.index))!==s[n].index&&(e.markHistoryStoppingPoint("moving page"),e.updatePage({id:t,index:o}),i("move-page",{source:"page-menu"}))}let mj=function({name:e,id:t,isCurrentPage:n,onCancel:r,onComplete:i}){let o=(0,h.hGv)(),s=hn(),a=(0,C.useRef)(null),l=(0,C.useCallback)(()=>{a.current=o.markHistoryStoppingPoint("rename page")},[o]),d=(0,C.useCallback)(e=>{o.renamePage(t,e||"New Page"),s("rename-page",{source:"page-menu"})},[o,t,s]),c=(0,C.useCallback)(()=>{a.current&&o.bailToMark(a.current),r()},[o,r]),u=(0,C.useCallback)(()=>{i?.()},[i]);return(0,b.jsx)(dS,{className:"tlui-page-menu__item__input",defaultValue:e,onValueChange:d,onComplete:i,onCancel:c,onFocus:l,onBlur:u,shouldManuallyMaintainScrollPositionWhenFocused:!0,autoFocus:!0,autoSelect:!0})},mO=(0,h.u4I)(function({index:e,listSize:t,item:n,onRename:r}){let i=(0,h.hGv)(),o=$(),s=hn(),a=(0,C.useCallback)(()=>{i.markHistoryStoppingPoint("creating page");let e=h.tvM.createId();i.duplicatePage(n.id,e),s("duplicate-page",{source:"page-menu"})},[i,n,s]),l=(0,C.useCallback)(()=>{mA(i,n.id,e,e-1,s)},[i,n,e,s]),d=(0,C.useCallback)(()=>{mA(i,n.id,e,e+1,s)},[i,n,e,s]),c=(0,C.useCallback)(()=>{i.markHistoryStoppingPoint("deleting page"),i.deletePage(n.id),s("delete-page",{source:"page-menu"})},[i,n,s]);return(0,b.jsxs)(hi,{id:`page item submenu ${e}`,children:[(0,b.jsx)(ho,{children:(0,b.jsx)(aW,{type:"icon",tooltip:o("page-menu.submenu.title"),title:o("page-menu.submenu.title"),"data-testid":"page-menu.item-submenu",children:(0,b.jsx)(dm,{icon:"dots-vertical",small:!0})})}),(0,b.jsx)(hs,{side:"bottom",align:"start",alignOffset:0,sideOffset:0,children:(0,b.jsxs)(dU,{type:"menu",sourceId:"page-menu",children:[(0,b.jsxs)(h0,{id:"modify",children:[r&&(0,b.jsx)(hJ,{id:"rename",label:"page-menu.submenu.rename",onSelect:r}),(0,b.jsx)(hJ,{id:"duplicate",label:"page-menu.submenu.duplicate-page",onSelect:a,disabled:t>=i.options.maxPages}),e>0&&(0,b.jsx)(hJ,{id:"move-up",onSelect:l,label:"page-menu.submenu.move-up"}),e<t-1&&(0,b.jsx)(hJ,{id:"move-down",label:"page-menu.submenu.move-down",onSelect:d})]}),t>1&&(0,b.jsx)(h0,{id:"delete",children:(0,b.jsx)(hJ,{id:"delete",onSelect:c,label:"page-menu.submenu.delete"})})]})})]})}),mD="tldraw_page_menu_list_height";function mL(){if("u"<typeof window)return null;try{let e=window.localStorage.getItem(mD);if(!e)return null;let t=Number(e);return Number.isFinite(t)&&t>=40?t:null}catch{return null}}let mF=(0,C.memo)(function(){let e=(0,h.hGv)(),t=hn(),n=$(),r=d$(),[i,o]=(0,C.useState)(null),s=(0,C.useCallback)(t=>{let n=`-${e.contextId}`;for(let r of e.menus.getOpenMenus()){let i=r.endsWith(n)?r.slice(0,-n.length):r;i.startsWith("page item submenu ")&&(void 0===t||i!==`page item submenu ${t}`)&&e.menus.deleteOpenMenu(i)}},[e]),[a,l]=hr("page-menu",(0,C.useCallback)(e=>{o(null),e||s()},[s])),d=(0,C.useRef)(null),c=(0,h.hau)("pages",()=>e.getPages(),[e]),u=(0,h.hau)("currentPage",()=>e.getCurrentPage(),[e]),p=uz(),f=(0,h.hau)("isCoarsePointer",()=>e.getInstanceState().isCoarsePointer,[e]),[g,m]=(0,C.useState)(mL),[y,x]=(0,C.useState)(!1),[w,v]=(0,C.useState)(()=>"u"<typeof window?800:window.innerHeight),S=(0,C.useCallback)(()=>{if("u"<typeof window)return;let e=d.current?.closest(".tlui-popover__content"),t=e?Number.parseFloat(getComputedStyle(e).getPropertyValue("--radix-popover-content-available-height")):NaN;v(Number.isFinite(t)?t:window.innerHeight)},[]);(0,C.useEffect)(()=>{let e=()=>S();return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[S]),(0,C.useEffect)(()=>{a&&e.timers.requestAnimationFrame(S)},[e,a,S]);let k=Math.max(40,Math.min(800,.62*w)-41),P=Math.max(40,36*c.length+4),T=Math.min(g??P,k),E=c.length>=e.options.maxPages,I=n(E?"page-menu.max-pages-reached":"page-menu.create-new-page"),_=(0,C.useCallback)(e=>{e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId);let n=e.clientY,r=t.previousElementSibling?.getBoundingClientRect().height??0,i=r;x(!0);let o=e=>{m(i=Math.max(40,r+(e.clientY-n)))},s=()=>{t.removeEventListener("pointermove",o),t.removeEventListener("pointerup",s),t.removeEventListener("pointercancel",s),x(!1);try{window.localStorage.setItem(mD,String(i))}catch{}};t.addEventListener("pointermove",o),t.addEventListener("pointerup",s,{once:!0}),t.addEventListener("pointercancel",s,{once:!0})},[]),M=(0,C.useCallback)(()=>{m(null);try{window.localStorage.removeItem(mD)}catch{}},[]);(0,C.useEffect)(function(){let t=e.getContainerDocument();function n(){i||t.activeElement===t.body&&e.menus.clearOpenMenus()}return t.addEventListener("keydown",n,{passive:!0}),()=>{t.removeEventListener("keydown",n)}},[e,i]);let A=(0,C.useRef)({status:"idle",id:null,startIndex:0,dragIndex:0,startY:0,startScrollTop:0,lastClientY:0,justDragged:!1,startedOnDragHandle:!1,autoScrollScheduled:!1}),[j,O]=(0,C.useState)(null);(0,C.useEffect)(()=>{a&&e.timers.requestAnimationFrame(()=>{let t=d.current;if(!t)return;let n=e.getPages().findIndex(e=>e.id===u.id);if(-1===n)return;let r=e.getContainerDocument().querySelector(`[data-pageid="${u.id}"]`);r?.querySelector("button.tlui-page-menu__item__button")?.focus();let i=36*n,o=i+36,s=t.scrollTop,a=s+t.clientHeight;i<s?t.scrollTo({top:i}):o>a&&t.scrollTo({top:o-t.clientHeight})})},[u.id,a,e]);let D=(0,C.useCallback)(e=>{let t=A.current;if("dragging"!==t.status||!t.id)return;let n=d.current?.scrollTop??0,r=e-t.startY+(n-t.startScrollTop),i=Math.max(0,Math.min((c.length-1)*36,36*t.startIndex+r)),o=i-36*t.startIndex,s=Math.max(0,Math.min(Math.round(i/36),c.length-1));t.dragIndex=s,t.lastClientY=e,O({id:t.id,startIndex:t.startIndex,dragIndex:s,offsetY:o})},[c.length]);(0,C.useEffect)(()=>{if(!a)return;let e=d.current;if(e)return e.addEventListener("wheel",t,{passive:!1}),()=>e.removeEventListener("wheel",t);function t(e){"dragging"===A.current.status&&e.preventDefault()}},[a]);let L=(0,C.useCallback)(()=>{let t=A.current,n=d.current;if("dragging"!==t.status||!n){t.autoScrollScheduled=!1;return}let r=n.getBoundingClientRect(),i=t.lastClientY-r.top,o=r.bottom-t.lastClientY,s=n.scrollHeight-n.clientHeight,a=16-i,l=16-o,c=0;if(a>0&&n.scrollTop>0?c=-Math.ceil(1+5*Math.min(1,a/48)):l>0&&n.scrollTop<s&&(c=Math.ceil(1+5*Math.min(1,l/48))),0!==c){let e=n.scrollTop;n.scrollTop=Math.max(0,Math.min(s,e+c)),n.scrollTop!==e&&D(t.lastClientY)}e.timers.requestAnimationFrame(L)},[e,D]),F=(0,C.useCallback)(()=>{let t=A.current;t.autoScrollScheduled||(t.autoScrollScheduled=!0,e.timers.requestAnimationFrame(L))},[e,L]),R=(0,C.useCallback)(e=>{if(0!==e.button)return;let{clientY:t,currentTarget:n}=e,{id:r,index:i}=n.dataset;if(!r||void 0===i)return;let o="true"===n.dataset.dragHandle;o&&(e.preventDefault(),e.stopPropagation());let s=A.current;(0,h.YYG)(n,e),s.status="pointing",s.id=r,s.startIndex=+i,s.dragIndex=+i,s.startY=t,s.lastClientY=t,s.startScrollTop=d.current?.scrollTop??0,s.startedOnDragHandle=o},[]),z=(0,C.useCallback)(e=>{let t=A.current,{clientY:n}=e;if("pointing"===t.status){if(5>=Math.abs(n-t.startY))return;t.status="dragging",t.lastClientY=n,F()}"dragging"===t.status&&(e.preventDefault(),D(n))},[F,D]),N=(0,C.useCallback)(n=>{let r=A.current;"dragging"===r.status&&r.id&&(mA(e,r.id,r.startIndex,r.dragIndex,t),r.startedOnDragHandle||(r.justDragged=!0)),(0,h.hPm)(n.currentTarget,n),r.status="idle",r.id=null,r.startedOnDragHandle=!1,O(null)},[e,t]),B=(0,C.useCallback)((t,n)=>{t.preventDefault(),t.stopPropagation(),s(n),e.menus.addOpenMenu(`page item submenu ${n}`)},[s,e]),H=(0,C.useCallback)(e=>{let t=A.current;(0,h.hPm)(e.currentTarget,e),t.status="idle",t.id=null,t.startedOnDragHandle=!1,O(null)},[]),U=(0,C.useCallback)(e=>{let t=A.current;"Escape"===e.key&&"idle"!==t.status&&(t.status="idle",t.id=null,t.startedOnDragHandle=!1,O(null))},[]),W=r<5&&f,K=!p&&f,V=(0,C.useCallback)((r,i)=>{if(!p){if(W){let o=window.prompt(n("action.rename"),i);o&&o!==i&&(e.renamePage(r,o),t("rename-page",{source:"page-menu"}));return}o(r)}},[e,n,p,W,t]),Y=(0,C.useCallback)(()=>{if(p)return;let r=h.tvM.createId(),i=n("page-menu.new-page-initial-name"),o=i;if(W){let e=window.prompt(n("page-menu.create-new-page"),i);if(null===e)return;o=e||i}e.run(()=>{e.markHistoryStoppingPoint("creating page"),e.createPage({name:o,id:r}),e.setCurrentPage(r)}),W||V(r,i),t("new-page",{source:"page-menu"})},[e,n,p,W,V,t]),G=(0,C.useCallback)(n=>{e.setCurrentPage(n),t("change-page",{source:"page-menu"})},[e,t]);return(0,b.jsxs)(fw,{id:"pages",onOpenChange:l,open:a,children:[(0,b.jsx)(fv,{"data-testid":"main.page-menu",children:(0,b.jsxs)(aW,{type:"menu",tooltip:u.name,title:u.name,"data-testid":"page-menu.button",className:"tlui-page-menu__trigger",children:[(0,b.jsx)(aK,{children:u.name}),(0,b.jsx)(dm,{icon:"chevron-down",small:!0})]})}),(0,b.jsx)(fS,{side:"bottom",align:"start",sideOffset:0,disableEscapeKeyDown:null!==i,children:(0,b.jsxs)("div",{className:"tlui-page-menu__wrapper",children:[(0,b.jsx)("div",{"data-testid":"page-menu.list",className:"tlui-page-menu__list",ref:d,style:{height:T},children:(0,b.jsx)("div",{className:"tlui-page-menu__list__content","data-dragging":null!==j,style:{height:P},children:c.map((t,r)=>{let s=t.id===u.id,a=i===t.id,l=j?.id===t.id,d=36*r;if(j)if(l)d=36*j.startIndex+j.offsetY;else{let{startIndex:e,dragIndex:t}=j;t<e&&r>=t&&r<e?d=(r+1)*36:t>e&&r>e&&r<=t&&(d=(r-1)*36)}return(0,b.jsxs)("div",{"data-pageid":t.id,"data-testid":"page-menu.item","data-iscurrent":s,"data-dragging":l,"data-editing":a,className:"tlui-page-menu__item",onContextMenu:p||a?void 0:e=>B(e,r),style:{zIndex:l?c.length+2:s?c.length+1:r,transform:`translateY(${d}px)`},children:[a?(0,b.jsx)("div",{className:"tlui-page-menu__item__title",children:(0,b.jsx)(mj,{id:t.id,name:t.name,isCurrentPage:s,onComplete:()=>o(null),onCancel:()=>o(null)})}):(0,b.jsxs)(b.Fragment,{children:[K&&(0,b.jsx)(aW,{type:"icon",className:"tlui-page-menu__item__drag-handle","data-testid":"page-menu.item-drag-handle","data-id":t.id,"data-index":r,"data-drag-handle":"true",onPointerDown:R,onPointerMove:z,onPointerUp:N,onPointerCancel:H,onKeyDown:U,tooltip:n("context-menu.reorder"),title:n("context-menu.reorder"),children:(0,b.jsx)(dm,{icon:"drag-handle-dots",small:!0})}),(0,b.jsx)(aW,{type:"normal",className:"tlui-page-menu__item__button",onClick:()=>{if(A.current.justDragged){A.current.justDragged=!1;return}G(t.id)},onDoubleClick:()=>V(t.id,t.name),onPointerDown:p||K?void 0:R,onPointerMove:p||K?void 0:z,onPointerUp:p||K?void 0:N,onPointerCancel:p||K?void 0:H,tooltip:n("page-menu.go-to-page"),title:n("page-menu.go-to-page"),"data-id":t.id,"data-index":r,onKeyDown:n=>{"Escape"===n.key?U(n):"Enter"===n.key&&s&&(V(t.id,t.name),e.markEventAsHandled(n))},children:(0,b.jsx)(aK,{children:t.name})})]}),!p&&!a&&(0,b.jsx)("div",{className:"tlui-page-menu__item__submenu",children:(0,b.jsx)(mO,{index:r,item:t,listSize:c.length,onRename:()=>V(t.id,t.name)})})]},t.id)})})}),(0,b.jsx)("div",{className:"tlui-page-menu__resize-handle","data-resizing":y,onPointerDown:_,onDoubleClick:M,role:"separator","aria-orientation":"horizontal","aria-label":n("page-menu.resize")}),(0,b.jsxs)(aW,{type:"menu",className:"tlui-page-menu__create-button","data-testid":"page-menu.create",tooltip:I,title:I,disabled:p||E,onClick:Y,children:[(0,b.jsx)(aK,{children:I}),!E&&(0,b.jsx)(dm,{icon:"plus",small:!0})]})]})})]})});function mR(){return(0,h.VKK)((0,h.YgL)(),"commenting")}function mz(){let e=(0,h.hGv)(),t=uz(),n=(0,h.hau)("should display quick actions",()=>e.isInAny("select","hand","zoom"),[e]);if(!t||n)return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(mB,{}),(0,b.jsx)(mN,{}),(0,b.jsx)(m$,{})]})}function mN(){let e=fN(1),t=fD(),n=e&&t;return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(hQ,{actionId:"delete",disabled:!n}),(0,b.jsx)(hQ,{actionId:"duplicate",disabled:!n})]})}function m$(){let e=(0,h.hGv)(),t=mR(),n=(0,h.hau)("is comment tool selected",()=>"comment"===e.getCurrentToolId(),[e]);return t?(0,b.jsx)(p6,{toolId:"comment",isSelected:n}):null}function mB(){let e=fH(),t=fB();return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(hQ,{actionId:"undo",disabled:!e}),(0,b.jsx)(hQ,{actionId:"redo",disabled:!t})]})}let mH=(0,C.memo)(function({children:e}){let t=e??(0,b.jsx)(mz,{});return(0,b.jsx)(dU,{type:"small-icons",sourceId:"quick-actions",children:t})});function mU(){let e=$();return(0,b.jsx)(aH,{content:e("status.offline"),children:(0,b.jsx)("div",{className:"tlui-offline-indicator",children:(0,b.jsx)(df,{icon:"status-offline",label:e("status.offline"),small:!0})})})}function mW({userIds:e}){let{PeopleMenuItem:t,UserPresenceEditor:n}=xS();return(0,b.jsxs)(b.Fragment,{children:[n&&(0,b.jsx)("div",{className:"tlui-people-menu__section",children:(0,b.jsx)(n,{})}),t&&e.length>0&&(0,b.jsx)("div",{className:"tlui-people-menu__section",children:e.map(e=>(0,b.jsx)(t,{userId:e},e+"_presence"))})]})}function mK({children:e}){let t,n=$(),r=B(),i=(0,h.NFA)(),o=(0,h.hGv)(),s=(0,h.oKA)(),a=(0,h.hau)("user",()=>o.user.getColor(),[o]),l=(0,h.hau)("user",()=>o.user.getName(),[o]),[d,c]=hr("people menu"),u=(t=(0,h.frr)(),(0,h.hau)("sync status",()=>t?.store.props.collaboration?.status?t.store.props.collaboration.status.get():null,[t])),{PeopleMenuFacePile:p}=xS();if("offline"===u)return(0,b.jsx)(mU,{});if(!s.length||!e&&!p)return null;let f=e??(0,b.jsx)(mW,{userIds:s});return(0,b.jsxs)(fa,{onOpenChange:c,open:d,children:[(0,b.jsx)(fl,{dir:r,asChild:!0,children:(0,b.jsx)("button",{className:"tlui-people-menu__avatars-button",title:n("people-menu.title"),children:p?(0,b.jsx)(p,{userColor:a,userIds:s,userName:l}):null})}),(0,b.jsx)(fh,{container:i,children:(0,b.jsx)(ff,{dir:r,className:"tlui-menu",side:"bottom",sideOffset:2,collisionPadding:4,children:(0,b.jsx)("div",{className:"tlui-people-menu__wrapper",children:f})})})]})}function mV({userId:e}){let t=(0,h.xQ_)(e);return t?(0,b.jsx)("div",{className:"tlui-people-menu__avatar",style:{backgroundColor:t.color},children:(0,h.C$h)(t.userName??"")}):null}function mY({userIds:e,userName:t,userColor:n}){let{PeopleMenuAvatar:r}=xS(),i=2>=d$()?1:5;return(0,b.jsxs)("div",{className:"tlui-people-menu__avatars",children:[r&&e.slice(-i).map(e=>(0,b.jsx)(r,{userId:e},e)),e.length>0&&(0,b.jsx)("div",{className:"tlui-people-menu__avatar",style:{backgroundColor:n},children:(0,h.C$h)(t??"")}),e.length>i&&(0,b.jsx)("div",{className:"tlui-people-menu__avatar tlui-people-menu__more",children:Math.abs(e.length-i)})]})}let mG=(0,h.u4I)(function({userId:e}){let t=(0,h.hGv)(),n=$(),r=hn(),i=(0,h.xQ_)(e),o=(0,C.useCallback)(()=>{t.getInstanceState().followingUserId===e?(t.stopFollowingUser(),r("stop-following",{source:"people-menu"})):(t.startFollowingUser(e),r("start-following",{source:"people-menu"}))},[t,e,r]),s=i?.followingUserId===t.user.getRecordId(),a=t.getInstanceState().followingUserId===e;return i?(0,b.jsxs)(aO,{className:"tlui-people-menu__item","data-follow":a||s,children:[(0,b.jsxs)(aW,{type:"menu",className:"tlui-people-menu__item__button",onClick:()=>t.zoomToUser(e),onDoubleClick:o,children:[(0,b.jsx)(df,{label:n("people-menu.avatar-color"),icon:"color",color:i.color}),(0,b.jsx)("div",{className:"tlui-people-menu__name",children:i.userName?.trim()||n("people-menu.anonymous-user")})]}),(0,b.jsx)(aW,{type:"icon",className:"tlui-people-menu__item__follow",title:n(s?"people-menu.leading":a?"people-menu.following":"people-menu.follow"),onClick:o,disabled:s,children:(0,b.jsx)(dm,{icon:s?"leading":a?"following":"follow"})})]}):null});function mq(){let{PeopleMenu:e}=xS();return e?(0,b.jsx)("div",{className:"tlui-share-zone",draggable:!1,children:(0,b.jsx)(e,{})}):null}let mX=(0,h.u4I)(function(){let e=(0,h.hGv)(),t=(0,h.NFA)(),n=$(),r=B(),i=hn(),o=(0,C.useRef)(!1),[s,a]=(0,C.useState)(!1),l=(0,C.useCallback)(e=>{a(e)},[]),d=e.user.getColor(),c=(0,C.useCallback)(t=>{e.user.updateUserPreferences({color:t}),i("set-color",{source:"people-menu"})},[e,i]),{handleButtonClick:u,handleButtonPointerDown:p,handleButtonPointerEnter:f,handleButtonPointerUp:g}=C.useMemo(()=>{let e=()=>{o.current=!1,(0,h.mDw)(t).removeEventListener("pointerup",e)};return{handleButtonClick:e=>{let{id:t}=e.currentTarget.dataset;t&&d!==t&&c(t)},handleButtonPointerDown:n=>{let{id:r}=n.currentTarget.dataset;r&&(c(r),o.current=!0,(0,h.mDw)(t).addEventListener("pointerup",e))},handleButtonPointerEnter:e=>{if(!o.current)return;let{id:t}=e.currentTarget.dataset;t&&c(t)},handleButtonPointerUp:e=>{let{id:t}=e.currentTarget.dataset;t&&c(t)}}},[t,d,c]);return(0,b.jsxs)(fa,{onOpenChange:l,open:s,children:[(0,b.jsx)(fl,{dir:r,asChild:!0,children:(0,b.jsx)(aW,{type:"icon",className:"tlui-people-menu__user__color",style:{color:e.user.getColor()},title:n("people-menu.change-color"),children:(0,b.jsx)(dm,{icon:"color"})})}),(0,b.jsx)(fh,{container:t,children:(0,b.jsx)(ff,{dir:r,className:"tlui-menu tlui-people-menu__user__color-picker",align:"start",side:"left",sideOffset:8,children:(0,b.jsx)(aL,{children:h.xXO.map(e=>(0,b.jsx)(aW,{type:"icon","data-id":e,"data-testid":e,"aria-label":e,isActive:d===e,title:e,style:{color:e},onPointerEnter:f,onPointerDown:p,onPointerUp:g,onClick:u,children:(0,b.jsx)(dm,{icon:"color"})},e))})})})]})});function mJ(){let e=(0,h.hGv)(),t=hn(),n=(0,h.hau)("userName",()=>e.user.getName(),[]),r=$(),i=(0,C.useRef)(n),o=(0,C.useRef)(n),[s,a]=(0,C.useState)(!1),l=(0,C.useCallback)(()=>{a(e=>!e)},[]),d=(0,C.useCallback)(t=>{o.current=t,e.user.updateUserPreferences({name:t})},[e]),c=(0,C.useCallback)(()=>{i.current!==o.current&&(t("change-user-name",{source:"people-menu"}),i.current=o.current)},[t]),u=(0,C.useCallback)(()=>{a(!1),e.user.updateUserPreferences({name:i.current}),e.menus.clearOpenMenus()},[e]);return(0,b.jsxs)("div",{className:"tlui-people-menu__user",children:[(0,b.jsx)(mX,{}),s?(0,b.jsx)(dS,{className:"tlui-people-menu__user__input",defaultValue:n,onValueChange:d,onComplete:l,onCancel:u,onBlur:c,shouldManuallyMaintainScrollPositionWhenFocused:!0,autoFocus:!0,autoSelect:!0}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"tlui-people-menu__user__name",onDoubleClick:()=>{s||a(!0)},children:n||r("people-menu.anonymous-user")}),n?null:(0,b.jsx)("div",{className:"tlui-people-menu__user__label",children:r("people-menu.user")})]}),(0,b.jsx)(aW,{type:"icon",className:"tlui-people-menu__user__edit","data-testid":"people-menu.change-name",title:r("people-menu.change-name"),onClick:l,children:(0,b.jsx)(dm,{icon:s?"check":"edit"})})]})}let mZ=Object.freeze([h.ive,h.Pe6,h.u8f,h.Sg3]);function mQ(e=mZ){let t=(0,h.hGv)();return(0,h.hau)("getRelevantStyles",()=>{let n=new h.bDP(t.getSharedStyles()),r=!!t.root.getCurrent()?.shapeType,i=t.isIn("select")&&t.getSelectedShapeIds().length>0;if(0===n.size&&t.isIn("select")&&0===t.getSelectedShapeIds().length)for(let r of e)n.applyValue(r,t.getStyleForNextShape(r));return r||i||n.size>0?n:null},[t])}function m0(e,t){return{flipX:t.scaleX<0!==e.flipX,flipY:t.scaleY<0!==e.flipY}}let m1={rectangle:{snapType:"polygon",icon:"geo-rectangle",getPath(e,t,n){let r="none"!==n.props.fill;return new x().moveTo(0,0,{geometry:{isFilled:r}}).lineTo(e,0).lineTo(e,t).lineTo(0,t).close()}},ellipse:{snapType:"blobby",icon:"geo-ellipse",getPath(e,t,n){let r="none"!==n.props.fill,i=e/2,o=t/2;return new x().moveTo(0,o,{geometry:{isFilled:r}}).arcTo(i,o,!1,!0,0,e,o).arcTo(i,o,!1,!0,0,0,o).close()}},triangle:{snapType:"polygon",icon:"geo-triangle",getPath(e,t,n){let r="none"!==n.props.fill;return new x().moveTo(e/2,0,{geometry:{isFilled:r}}).lineTo(e,t).lineTo(0,t).close()}},diamond:{snapType:"polygon",icon:"geo-diamond",getPath(e,t,n){let r="none"!==n.props.fill,i=e/2,o=t/2;return new x().moveTo(i,0,{geometry:{isFilled:r}}).lineTo(e,o).lineTo(i,t).lineTo(0,o).close()}},star:{snapType:"polygon",icon:"geo-star",defaultSize:{w:200,h:190},getPath:(e,t,n)=>{var r,i,o;let s,a,l,d,c,u,p,f,g,m,y,b,w,v,S;return r=e,i=t,o="none"!==n.props.fill,s=h.uAR/5/2,a=2*Math.floor(5/4),l=2*Math.floor(2.5),d=Math.cos(-h.sKG+a*s)*r/2,c=Math.cos(-h.sKG+(10-a)*s)*r/2,u=Math.sin(-h.sKG+0*s)*i/2,p=Math.sin(-h.sKG+l*s)*i/2,f=r-Math.abs(d-c),g=i-Math.abs(p-u),m=(r-(r/2+c-(r/2-d)))/2,y=(i-(i/2+u-(i/2-p)))/2,b=(r+f)/2,w=(i+g)/2,v=b/2,S=w/2,x.lineThroughPoints(Array.from(Array(10),(e,t)=>{let n=-h.sKG+t*s;return new h.l2P(m+(t%2?v:b)*Math.cos(n),y+(t%2?S:w)*Math.sin(n))}),{geometry:{isFilled:o}}).close()}},pentagon:{snapType:"polygon",icon:"geo-pentagon",getPath(e,t,n){let r="none"!==n.props.fill;return x.lineThroughPoints((0,h.yeN)(e,t,5),{geometry:{isFilled:r}}).close()}},hexagon:{snapType:"polygon",icon:"geo-hexagon",getPath(e,t,n){let r="none"!==n.props.fill;return x.lineThroughPoints((0,h.yeN)(e,t,6),{geometry:{isFilled:r}}).close()}},octagon:{snapType:"polygon",icon:"geo-octagon",getPath(e,t,n){let r="none"!==n.props.fill;return x.lineThroughPoints((0,h.yeN)(e,t,8),{geometry:{isFilled:r}}).close()}},rhombus:{snapType:"polygon",icon:"geo-rhombus",getPath(e,t,n){let r="none"!==n.props.fill,i=Math.min(.38*e,.38*t);return new x().moveTo(i,0,{geometry:{isFilled:r}}).lineTo(e,0).lineTo(e-i,t).lineTo(0,t).close()}},"rhombus-2":{snapType:"polygon",icon:"geo-rhombus-2",getPath(e,t,n){let r="none"!==n.props.fill,i=Math.min(.38*e,.38*t);return new x().moveTo(0,0,{geometry:{isFilled:r}}).lineTo(e-i,0).lineTo(e,t).lineTo(i,t).close()}},oval:{snapType:"blobby",icon:"geo-oval",getPath:(e,t,n)=>(function(e,t,n){if(t>e){let r=e/2;return new x().moveTo(0,r,{geometry:{isFilled:n}}).arcTo(r,r,!1,!0,0,e,r).lineTo(e,t-r).arcTo(r,r,!1,!0,0,0,t-r).close()}let r=t/2;return new x().moveTo(r,t,{geometry:{isFilled:n}}).arcTo(r,r,!1,!0,0,r,0).lineTo(e-r,0).arcTo(r,r,!1,!0,0,e-r,t).close()})(e,t,"none"!==n.props.fill)},trapezoid:{snapType:"polygon",icon:"geo-trapezoid",getPath(e,t,n){let r="none"!==n.props.fill,i=Math.min(.38*e,.38*t);return new x().moveTo(i,0,{geometry:{isFilled:r}}).lineTo(e-i,0).lineTo(e,t).lineTo(0,t).close()}},"arrow-left":{snapType:"polygon",icon:"geo-arrow-left",getPath(e,t,n){let r="none"!==n.props.fill,i=.38*Math.min(e,t),o=.16*t;return new x().moveTo(i,0,{geometry:{isFilled:r}}).lineTo(i,o).lineTo(e,o).lineTo(e,t-o).lineTo(i,t-o).lineTo(i,t).lineTo(0,t/2).close()}},"arrow-up":{snapType:"polygon",icon:"geo-arrow-up",getPath(e,t,n){let r="none"!==n.props.fill,i=.16*e,o=.38*Math.min(e,t);return new x().moveTo(e/2,0,{geometry:{isFilled:r}}).lineTo(e,o).lineTo(e-i,o).lineTo(e-i,t).lineTo(i,t).lineTo(i,o).lineTo(0,o).close()}},"arrow-down":{snapType:"polygon",icon:"geo-arrow-down",getPath(e,t,n){let r="none"!==n.props.fill,i=.16*e,o=.38*Math.min(e,t);return new x().moveTo(i,0,{geometry:{isFilled:r}}).lineTo(e-i,0).lineTo(e-i,t-o).lineTo(e,t-o).lineTo(e/2,t).lineTo(0,t-o).lineTo(i,t-o).close()}},"arrow-right":{snapType:"polygon",icon:"geo-arrow-right",getPath(e,t,n){let r="none"!==n.props.fill,i=.38*Math.min(e,t),o=.16*t;return new x().moveTo(0,o,{geometry:{isFilled:r}}).lineTo(e-i,o).lineTo(e-i,0).lineTo(e,t/2).lineTo(e-i,t).lineTo(e-i,t-o).lineTo(0,t-o).close()}},cloud:{snapType:"blobby",icon:"geo-cloud",defaultSize:{w:300,h:180},getPath(e,t,n){let r="none"!==n.props.fill;return function(e,t,n,r,i,o){let s=new x,a=(0,h.She)(n),l=m6(e,t),d=Math.max(Math.ceil(l/m4[r]),6,Math.ceil(l/Math.min(e,t))),c=l/d*.2,u=Math.max(e-2*c,1),p=Math.max(t-2*c,1),f=m6(u,p)/d,g=(e-u)/2,m=(t-p)/2,y=(function(e,t,n){let r=Math.min(e,t)/2,i=Math.max(e,t)-2*r,o=(2*r*Math.PI+2*i)/n,s=e>t?[{type:"straight",start:new h.l2P(r,0),delta:new h.l2P(1,0)},{type:"arc",center:new h.l2P(e-r,r),startAngle:-h.PI/2},{type:"straight",start:new h.l2P(e-r,t),delta:new h.l2P(-1,0)},{type:"arc",center:new h.l2P(r,r),startAngle:h.PI/2}]:[{type:"straight",start:new h.l2P(e,r),delta:new h.l2P(0,1)},{type:"arc",center:new h.l2P(r,t-r),startAngle:0},{type:"straight",start:new h.l2P(0,t-r),delta:new h.l2P(0,-1)},{type:"arc",center:new h.l2P(r,r),startAngle:h.PI}],a=0,l=[];for(let e=0;e<n;e++){let e=s[0];"straight"===e.type?l.push(h.l2P.Add(e.start,h.l2P.Mul(e.delta,a))):l.push((0,h.AQe)(e.center,r,e.startAngle+a/r)),a+=o;let t="straight"===e.type?i:h.PI*r;for(;a>t;)a-=t,s.push(s.shift()),t="straight"===s[0].type?i:h.PI*r}return l})(u,p,d).map(e=>e.addXY(g,m)),b=e<20?0:.3*c,w=t<20?0:.3*c,v=y.slice(0);for(let e=0;e<Math.floor(d/2);e++)v[e]=h.l2P.AddXY(v[e],a()*b*i,a()*w*i),v[d-e-1]=h.l2P.AddXY(v[d-e-1],a()*b*i,a()*w*i);for(let n=0;n<v.length;n++){let r=n===v.length-1?0:n+1,i=v[n],a=v[r],l=y[n],d=y[r],c=h.l2P.Dist(l,d),u=(Math.max(g,m)+(f-c))*(h.l2P.Dist(i,a)/c),p=h.l2P.Lrp(l,d,.5).add(h.l2P.Sub(d,l).uni().per().mul(u));p.x<0?p.x=0:p.x>e&&(p.x=e),p.y<0?p.y=0:p.y>t&&(p.y=t);let b=(0,h.oj6)(i,a,p),x=h.l2P.Dist(b||h.l2P.Average([i,a]),i);0===n&&s.moveTo(i.x,i.y,{geometry:{isFilled:o}}),s.circularArcTo(x,!1,!0,a.x,a.y)}return s.close()}(e,t,n.id,n.props.size,n.props.scale,r)}},"x-box":{snapType:"polygon",icon:"geo-x-box",getPath(e,t,n,r){let i="none"!==n.props.fill;return function(e,t,n,r,i){let o=e/2,s=t/2,a=new x().moveTo(0,0,{geometry:{isFilled:i}}).lineTo(e,0).lineTo(e,t).lineTo(0,t).close();if("none"===r)return a;if("dashed"===r||"dotted"===r)return a.moveTo(0,0,{geometry:{isInternal:!0,isFilled:!1},dashStart:"skip",dashEnd:"outset"}).lineTo(o,s).moveTo(e,t,{geometry:{isInternal:!0,isFilled:!1},dashStart:"skip",dashEnd:"outset"}).lineTo(o,s).moveTo(0,t,{geometry:{isInternal:!0,isFilled:!1},dashStart:"skip",dashEnd:"outset"}).lineTo(o,s).moveTo(e,0,{geometry:{isInternal:!0,isFilled:!1},dashStart:"skip",dashEnd:"outset"}).lineTo(o,s);let l=.62*("draw"===r);return a.moveTo((0,h.qE8)(n*l,0,e),(0,h.qE8)(n*l,0,t),{geometry:{isInternal:!0,isFilled:!1}}).lineTo((0,h.qE8)(e-n*l,0,e),(0,h.qE8)(t-n*l,0,t)).moveTo((0,h.qE8)(e-n*l,0,e),(0,h.qE8)(n*l,0,t)).lineTo((0,h.qE8)(n*l,0,e),(0,h.qE8)(t-n*l,0,t)),a}(e,t,r,n.props.dash,i)}},"check-box":{snapType:"polygon",icon:"geo-check-box",getPath(e,t,n){let r="none"!==n.props.fill,i=.82*Math.min(e,t),o=(e-i)/2,s=(t-i)/2;return new x().moveTo(0,0,{geometry:{isFilled:r}}).lineTo(e,0).lineTo(e,t).lineTo(0,t).close().moveTo((0,h.qE8)(o+.25*i,0,e),(0,h.qE8)(s+.52*i,0,t),{geometry:{isInternal:!0,isFilled:!1},offset:0}).lineTo((0,h.qE8)(o+.45*i,0,e),(0,h.qE8)(s+.82*i,0,t)).lineTo((0,h.qE8)(o+.82*i,0,e),(0,h.qE8)(s+.22*i,0,t),{offset:0})}},heart:{snapType:"blobby",icon:"geo-heart",getPath(e,t,n){let r="none"!==n.props.fill,i=e/2,o=e/4,s=t/4;return new x().moveTo(i,t,{geometry:{isFilled:r}}).cubicBezierTo(0,1.2*s,1.5*o,3*s,0,2.5*s).cubicBezierTo(i,.9*s,0,-(.32*s),1.85*o,-(.32*s)).cubicBezierTo(e,1.2*s,2.15*o,-(.32*s),e,-(.32*s)).cubicBezierTo(i,t,e,2.5*s,2.5*o,3*s).close()}}};function m2(e,t){return t?.[e]??m1[e]}let m3=new h.laH;function m5(e,t,n){return m3.get(e,e=>(function(e,t,n){let r=Math.max(1,e.props.w),i=Math.max(1,e.props.h+e.props.growY),o=t*e.props.scale,s=m2(e.props.geo,n);if(!s)throw Error(`Unknown geo type: ${e.props.geo}`);let a=s.getPath(r,i,e,o),{flipX:l,flipY:d}=e.props;if(l||d){var c;return a.transform({a:(c={flipX:l,flipY:d}).flipX?-1:1,b:0,c:0,d:c.flipY?-1:1,e:c.flipX?r:0,f:c.flipY?i:0})}return a})(e,t,n))}function m6(e,t){return e>t?(h.PI*(t/2)+(e-t))*2:(h.PI*(e/2)+(t-e))*2}let m4={s:50,m:70,l:100,xl:130};function m8(e){return"object"==typeof e&&null!==e&&"solid"in e}let m9={draw:"font-draw",sans:"font-sans",serif:"font-serif",mono:"font-mono"};function m7(e,t){return null!=e.icon?e.icon:m9[t]??"font-draw"}let ye=[{value:"none",icon:"fill-none"},{value:"semi",icon:"fill-semi"},{value:"solid",icon:"fill-solid"}],yt=[{value:"pattern",icon:"fill-pattern"},{value:"lined-fill",icon:"fill-lined-fill"},{value:"fill",icon:"fill-fill"}],yn=[{value:"draw",icon:"dash-draw"},{value:"dashed",icon:"dash-dashed"},{value:"dotted",icon:"dash-dotted"},{value:"solid",icon:"dash-solid"}],yr=[{value:"s",icon:"size-small"},{value:"m",icon:"size-medium"},{value:"l",icon:"size-large"},{value:"xl",icon:"size-extra-large"}],yi=[{value:"start",icon:"text-align-left"},{value:"middle",icon:"text-align-center"},{value:"end",icon:"text-align-right"}],yo=[{value:"start",icon:"horizontal-align-start"},{value:"middle",icon:"horizontal-align-middle"},{value:"end",icon:"horizontal-align-end"}],ys=[{value:"start",icon:"vertical-align-start"},{value:"middle",icon:"vertical-align-middle"},{value:"end",icon:"vertical-align-end"}],ya=[{value:"arc",icon:"arrow-arc"},{value:"elbow",icon:"arrow-elbow"}],yl=[{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"}],yd=[{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"}],yc=[{value:"line",icon:"spline-line"},{value:"cubic",icon:"spline-cubic"}];function yu(e,[t,n]){return Math.min(n,Math.max(t,e))}function yh(e){let t=C.useRef({value:e,previous:e});return C.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}(0,Object.defineProperty)(yu,"name",{value:"clamp",configurable:!0}),(0,Object.defineProperty)(yh,"name",{value:"usePrevious",configurable:!0});var yp=Object.defineProperty,yf=(e,t)=>yp(e,"name",{value:t,configurable:!0}),yg=["PageUp","PageDown"],ym=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],yy={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},yb="Slider",[yx,yw,yv]=dY(yb),[yS,yC]=iz(yb,[yv]),[yk,yP]=yS(yb),yT=C.forwardRef(yf(function(e,t){let{name:n,min:r=0,max:i=100,step:o=1,orientation:s="horizontal",disabled:a=!1,minStepsBetweenThumbs:l=0,defaultValue:d=[r],value:c,onValueChange:u=yf(()=>{},"onValueChange"),onValueCommit:h=yf(()=>{},"onValueCommit"),inverted:p=!1,form:f,...g}=e,m=C.useRef(new Set),y=C.useRef(0),x=C.useRef(!1),w="horizontal"===s,[v,S]=C.useState(null),k=iL(t,S),[P=[],T]=s5({prop:c,defaultProp:d,onChange:yf(e=>{let t=[...m.current];t[y.current]?.focus({preventScroll:!0,focusVisible:x.current}),x.current=!1,u(e)},"onChange")}),E=C.useRef(P),I=C.useRef(P);function _(e){let t=yK(P,e);j(e,t)}function M(e){j(e,y.current)}function A(){String(P)!==String(E.current)&&h(P)}function j(e,t,{commit:n}={commit:!1}){let s=yX(o),a=yu(yJ(Math.round((e-r)/o)*o+r,s),[r,i]);T((e=[])=>{let r=yH(e,a,t);if(!yG(r,l*o))return e;{y.current=r.indexOf(a);let t=String(r)!==String(e);return t&&n&&h(r),t?r:e}})}return C.useEffect(()=>{let e=f?v?.ownerDocument.getElementById(f):v?.closest("form");if(e instanceof HTMLFormElement){let t=yf(()=>T(I.current),"reset");return e.addEventListener("reset",t),()=>e.removeEventListener("reset",t)}},[v,f,T]),yf(_,"handleSlideStart"),yf(M,"handleSlideMove"),yf(A,"handleSlideEnd"),yf(j,"updateValues"),(0,b.jsx)(yk,{scope:e.__scopeSlider,name:n,disabled:a,min:r,max:i,valueIndexToChangeRef:y,thumbs:m.current,values:P,orientation:s,form:f,children:(0,b.jsx)(yx.Provider,{scope:e.__scopeSlider,children:(0,b.jsx)(yx.Slot,{scope:e.__scopeSlider,children:(0,b.jsx)(w?y_:yM,{"aria-disabled":a,"data-disabled":a?"":void 0,...g,ref:k,onPointerDown:iI(g.onPointerDown,()=>{a||(E.current=P,x.current=!1)}),min:r,max:i,inverted:p,onSlideStart:a?void 0:_,onSlideMove:a?void 0:M,onSlideEnd:a?void 0:A,onHomeKeyDown:()=>{a||(x.current=!0,j(r,0,{commit:!0}))},onEndKeyDown:()=>{a||(x.current=!0,j(i,P.length-1,{commit:!0}))},onStepKeyDown:({event:e,direction:t})=>{if(!a){x.current=!0;let n=yg.includes(e.key)||e.shiftKey&&ym.includes(e.key),i=y.current;j(yZ(P[i],{min:r,step:o,direction:t,multiplier:n?10:1}),i,{commit:!0})}}})})})})},"Slider")),[yE,yI]=yS(yb,{startEdge:"left",endEdge:"right",size:"width",direction:1}),y_=C.forwardRef(yf(function(e,t){let{min:n,max:r,dir:i,inverted:o,onSlideStart:s,onSlideMove:a,onSlideEnd:l,onStepKeyDown:d,...c}=e,[u,h]=C.useState(null),p=iL(t,h),f=C.useRef(void 0),g=d6(i),m="ltr"===g,y=m&&!o||!m&&o;function x(e){let t=f.current||u.getBoundingClientRect(),i=yq([0,t.width],y?[n,r]:[r,n]);return f.current=t,i(e-t.left)}return yf(x,"getValueFromPointer"),(0,b.jsx)(yE,{scope:e.__scopeSlider,startEdge:y?"left":"right",endEdge:y?"right":"left",direction:y?1:-1,size:"width",children:(0,b.jsx)(yA,{dir:g,"data-orientation":"horizontal",...c,ref:p,style:{...c.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:e=>{let t=x(e.clientX);s?.(t)},onSlideMove:e=>{let t=x(e.clientX);a?.(t)},onSlideEnd:()=>{f.current=void 0,l?.()},onStepKeyDown:e=>{let t=yy[y?"from-left":"from-right"].includes(e.key);d?.({event:e,direction:t?-1:1})}})})},"SliderHorizontal")),yM=C.forwardRef(yf(function(e,t){let{min:n,max:r,inverted:i,onSlideStart:o,onSlideMove:s,onSlideEnd:a,onStepKeyDown:l,...d}=e,c=C.useRef(null),u=iL(t,c),h=C.useRef(void 0),p=!i;function f(e){let t=h.current||c.current.getBoundingClientRect(),i=yq([0,t.height],p?[r,n]:[n,r]);return h.current=t,i(e-t.top)}return yf(f,"getValueFromPointer"),(0,b.jsx)(yE,{scope:e.__scopeSlider,startEdge:p?"bottom":"top",endEdge:p?"top":"bottom",size:"height",direction:p?1:-1,children:(0,b.jsx)(yA,{"data-orientation":"vertical",...d,ref:u,style:{...d.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:e=>{let t=f(e.clientY);o?.(t)},onSlideMove:e=>{let t=f(e.clientY);s?.(t)},onSlideEnd:()=>{h.current=void 0,a?.()},onStepKeyDown:e=>{let t=yy[p?"from-bottom":"from-top"].includes(e.key);l?.({event:e,direction:t?-1:1})}})})},"SliderVertical")),yA=C.forwardRef(yf(function(e,t){let{__scopeSlider:n,onSlideStart:r,onSlideMove:i,onSlideEnd:o,onHomeKeyDown:s,onEndKeyDown:a,onStepKeyDown:l,...d}=e,c=yP(yb,n);return(0,b.jsx)(i5.span,{...d,ref:t,onKeyDown:iI(e.onKeyDown,e=>{"Home"===e.key?(s(e),e.preventDefault()):"End"===e.key?(a(e),e.preventDefault()):yg.concat(ym).includes(e.key)&&(l(e),e.preventDefault())}),onPointerDown:iI(e.onPointerDown,e=>{let t=e.target;t.setPointerCapture(e.pointerId),e.preventDefault(),c.thumbs.has(t)?t.focus({preventScroll:!0,focusVisible:!1}):r(e)}),onPointerMove:iI(e.onPointerMove,e=>{e.target.hasPointerCapture(e.pointerId)&&i(e)}),onPointerUp:iI(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&(t.releasePointerCapture(e.pointerId),o(e))})})},"SliderImpl")),yj=C.forwardRef(yf(function(e,t){let{__scopeSlider:n,...r}=e,i=yP("SliderTrack",n);return(0,b.jsx)(i5.span,{"data-disabled":i.disabled?"":void 0,"data-orientation":i.orientation,...r,ref:t})},"SliderTrack")),yO="SliderRange",yD=C.forwardRef(yf(function(e,t){let{__scopeSlider:n,...r}=e,i=yP(yO,n),o=yI(yO,n),s=iL(t,C.useRef(null)),a=i.values.length,l=i.values.map(e=>yU(e,i.min,i.max)),d=a>1?Math.min(...l):0,c=100-Math.max(...l);return(0,b.jsx)(i5.span,{"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,...r,ref:s,style:{...e.style,[o.startEdge]:d+"%",[o.endEdge]:c+"%"}})},"SliderRange")),[yL,yF]=yS("SliderThumb");function yR(e){let{__scopeSlider:t,name:n,children:r,internal_do_not_use_render:i}=e,o=yP("SliderThumbProvider",t),s=yw(t),[a,l]=C.useState(null),d=C.useMemo(()=>a?s().findIndex(e=>e.ref.current===a):-1,[s,a]),c=sC(a),u=!a||!!o.form||!!a.closest("form"),h=o.values[d],p=n??(o.name?o.name+(o.values.length>1?"[]":""):void 0),f=void 0===h?0:yU(h,o.min,o.max);C.useEffect(()=>{if(a)return o.thumbs.add(a),()=>{o.thumbs.delete(a)}},[a,o.thumbs]);let g={value:h,name:p,form:o.form,isFormControl:u,index:d,thumb:a,onThumbChange:l,percent:f,size:c};return(0,b.jsx)(yL,{scope:t,...g,children:yQ(i)?i(g):r})}yf(yR,"SliderThumbProvider");var yz="SliderThumbTrigger",yN=C.forwardRef(yf(function(e,t){let{__scopeSlider:n,...r}=e,i=yP(yz,n),o=yI(yz,n),{index:s,value:a,percent:l,size:d,onThumbChange:c}=yF(yz,n),u=iL(t,c),h=yW(s,i.values.length),p=d?.[o.size],f=p?yV(p,l,o.direction):0;return(0,b.jsx)("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[o.startEdge]:`calc(${l}% + ${f}px)`},children:(0,b.jsx)(yx.ItemSlot,{scope:n,children:(0,b.jsx)(i5.span,{role:"slider","aria-label":e["aria-label"]||h,"aria-valuemin":i.min,"aria-valuenow":a,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...r,ref:u,style:void 0===a?{display:"none"}:e.style,onFocus:iI(e.onFocus,()=>{i.valueIndexToChangeRef.current=s})})})})},"SliderThumbTrigger")),y$=C.forwardRef(yf(function(e,t){let{__scopeSlider:n,name:r,...i}=e;return(0,b.jsx)(yR,{__scopeSlider:n,name:r,internal_do_not_use_render:({index:e,isFormControl:r})=>(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(yN,{...i,ref:t,__scopeSlider:n}),r?(0,b.jsx)(yB,{__scopeSlider:n},e):null]})})},"SliderThumb")),yB=C.forwardRef(yf(function({__scopeSlider:e,...t},n){let{value:r,name:i,form:o}=yF("SliderBubbleInput",e),s=C.useRef(null),a=iL(s,n),l=yh(r);return C.useEffect(()=>{let e=s.current;if(!e)return;let t=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set;if(l!==r&&t){let n=new Event("input",{bubbles:!0});t.call(e,r),e.dispatchEvent(n)}},[l,r]),(0,b.jsx)(i5.input,{style:{display:"none"},name:i,form:o,...t,ref:a,defaultValue:r})},"SliderBubbleInput"));function yH(e=[],t,n){let r=[...e];return r[n]=t,r.sort((e,t)=>e-t)}function yU(e,t,n){return yu(100/(n-t)*(e-t),[0,100])}function yW(e,t){return t>2?`Value ${e+1} of ${t}`:2===t?["Minimum","Maximum"][e]:void 0}function yK(e,t){if(1===e.length)return 0;let n=e.map(e=>Math.abs(e-t)),r=Math.min(...n);return n.indexOf(r)}function yV(e,t,n){let r=e/2,i=yq([0,50],[0,r]);return(r-i(t)*n)*n}function yY(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function yG(e,t){return!(t>0)||Math.min(...yY(e))>=t}function yq(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function yX(e){if(!Number.isFinite(e))return 0;let t=e.toString();if(t.includes("e")){let[e,n]=t.split("e"),r=e.split(".")[1]||"",i=Number(n);return Math.max(0,r.length-i)}let n=t.split(".")[1];return n?n.length:0}function yJ(e,t){let n=Math.pow(10,t);return Math.round(e*n)/n}function yZ(e,{min:t,step:n,direction:r,multiplier:i}){let o,s=yX(n),a=(e-t)/n,l=Math.round(a);return o=yJ(l*n+t,s)===yJ(e,s)?l+i*r:r>0?Math.ceil(a):Math.floor(a),yJ(o*n+t,s)}function yQ(e){return"function"==typeof e}yf(yH,"getNextSortedValues"),yf(yU,"convertValueToPercentage"),yf(yW,"getLabel"),yf(yK,"getClosestValueIndex"),yf(yV,"getThumbInBoundsOffset"),yf(yY,"getStepsBetweenValues"),yf(yG,"hasMinStepsBetweenValues"),yf(yq,"linearScale"),yf(yX,"getDecimalCount"),yf(yJ,"roundValue"),yf(yZ,"getNextStepValue"),yf(yQ,"isFunction");let y0=C.forwardRef(function({onHistoryMark:e,title:t,min:n,steps:r,value:i,label:o,onValueChange:s,"data-testid":a,ariaValueModifier:l=1},d){let c=$(),u=B(),[p,f]=(0,C.useState)(""),[g,m]=(0,C.useState)(-1);(0,C.useEffect)(()=>{m(0)},[]);let y=(0,C.useCallback)(e=>{s(e[0])},[s]),x=(0,C.useCallback)(()=>{az(),e?.("click slider")},[e]);(0,C.useEffect)(()=>{let e=h.slq.setTimeout("set title and label",()=>{f(t+" — "+c(o))},0);return()=>clearTimeout(e)},[o,c,t]);let w=(0,C.useCallback)(e=>{"Tab"===e.key&&e.stopPropagation()},[]);return(0,b.jsx)("div",{className:"tlui-slider__container",children:(0,b.jsx)(aH,{content:p,children:(0,b.jsxs)(yT,{"data-testid":a,className:"tlui-slider",dir:u,min:n??0,max:r,step:1,value:null!==i?[i]:void 0,onPointerDown:x,onValueChange:y,onKeyDownCapture:w,onKeyUpCapture:w,children:[(0,b.jsx)(yj,{className:"tlui-slider__track",dir:u,children:null!==i&&(0,b.jsx)(yD,{className:"tlui-slider__range",dir:u})}),null!==i&&(0,b.jsx)(y$,{"aria-valuemin":(n??0)*l,"aria-valuenow":i*l,"aria-valuemax":r*l,"aria-label":p,className:"tlui-slider__thumb",dir:u,ref:d,tabIndex:g})]})})})}),y1=(0,C.createContext)(null);function y2({children:e,styles:t}){let n=(0,h.hGv)(),r=hn(),i=(0,C.useCallback)(e=>n.markHistoryStoppingPoint(e),[n]),o=(0,h.hau)("enhancedA11yMode",()=>n.user.getEnhancedA11yMode(),[n]),s=(0,C.useCallback)(function(e,t){let i=(0,h.PmD)(()=>n.getSelectedShapeIds().length>0&&n.inputs.getAccelKey());n.run(()=>{n.isIn("select")&&n.setStyleForSelectedShapes(e,t),i||n.setStyleForNextShapes(e,t),n.updateInstanceState({isChangingStyle:!0})}),r("set-style",{source:"style-panel",id:e.id,value:t})},[n,r]),a=(0,C.useCallback)(function(e){let t=(0,h.PmD)(()=>n.getSelectedShapeIds().length>0&&n.inputs.getAccelKey());n.run(()=>{n.isIn("select")&&n.setOpacityForSelectedShapes(e),t||n.setOpacityForNextShapes(e),n.updateInstanceState({isChangingStyle:!0})}),r("set-style",{source:"style-panel",id:"opacity",value:e})},[n,r]);return(0,b.jsx)(y1.Provider,{value:{styles:t,enhancedA11yMode:o,onHistoryMark:i,onValueChange:s,onOpacityChange:a},children:e})}function y3(){let e=(0,C.useContext)(y1);if(!e)throw Error("useStylePanelContext must be used within a StylePanelContextProvider");return e}function y5({children:e}){return(0,b.jsx)("h3",{className:"tlui-style-panel__subheading",children:e})}let y6=(0,C.memo)(function(e){let{enhancedA11yMode:t}=y3();return(0,b.jsxs)(b.Fragment,{children:[t&&(0,b.jsx)(y5,{children:e.title}),(0,b.jsx)(hY,{label:e.title,children:(0,b.jsx)(y4,{...e})})]})}),y4=(0,C.memo)(function(e){let t=y3(),{uiType:n,items:r,title:i,style:o,value:s,onValueChange:a=t.onValueChange,onHistoryMark:l=t.onHistoryMark}=e,d=(0,h.hGv)(),c=(0,h.hau)("style panel button picker colors",()=>d.getCurrentTheme().colors[d.getColorMode()],[d]),u=$(),p=d$(),f=(0,C.useRef)(!1),g=(0,C.useRef)(null),{handleButtonClick:m,handleButtonPointerDown:y,handleButtonPointerEnter:x,handleButtonPointerUp:w}=(0,C.useMemo)(()=>{let e=()=>{f.current=!1,d.getContainerWindow().removeEventListener("pointerup",e);let t=g.current;t&&(0,h.oOb)(t,!1)?t.focus():p>=5&&d.getContainer().focus(),g.current=null};return{handleButtonClick:e=>{let{id:t}=e.currentTarget.dataset;("shared"!==s.type||s.value!==t)&&(l?.("point picker item"),a(o,t))},handleButtonPointerDown:t=>{let{id:n}=t.currentTarget.dataset;l?.("point picker item"),a(o,n),f.current=!0,g.current=d.getContainerDocument().activeElement,d.getContainerWindow().addEventListener("pointerup",e)},handleButtonPointerEnter:e=>{if(!f.current)return;let{id:t}=e.currentTarget.dataset;a(o,t)},handleButtonPointerUp:e=>{if(!f.current)return;let{id:t}=e.currentTarget.dataset;("shared"!==s.type||s.value!==t)&&a(o,t)}}},[d,p,s,l,a,o]),v=r.length>4?aL:aO;return(0,b.jsx)(hq,{"data-testid":`style.${n}`,type:"single",value:"shared"===s.type?s.value:null,asChild:!0,children:(0,b.jsx)(v,{children:r.map(e=>{let t="shared"===s.type&&s.value===e.value,r=i+" — "+u(`${n}-style.${e.value}`);return(0,b.jsx)(hX,{type:"icon","data-id":e.value,"data-testid":`style.${n}.${e.value}`,"aria-label":r+(t?` (${u("style-panel.selected")})`:""),tooltip:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{children:r}),t?(0,b.jsxs)("div",{children:["(",u("style-panel.selected"),")"]}):null]}),value:e.value,"data-state":"shared"===s.type&&s.value===e.value?"on":"off","data-isactive":t,title:r,style:o===h.ive?{color:(0,h.FHQ)(c,e.value,"solid")}:void 0,onPointerEnter:x,onPointerDown:y,onPointerUp:w,onClick:m,children:(0,b.jsx)(dm,{icon:e.icon})},e.value)})})})}),y8=C.memo(function(e){let t=$();return(0,b.jsxs)("div",{className:"tlui-style-panel__double-select-picker",children:[(0,b.jsx)("div",{title:t(e.label),className:"tlui-style-panel__double-select-picker-label",children:t(e.label)}),(0,b.jsx)(hY,{orientation:"horizontal",label:t(e.label),children:(0,b.jsx)(y9,{...e})})]})}),y9=C.memo(function(e){let t=y3(),{uiTypeA:n,uiTypeB:r,labelA:i,labelB:o,itemsA:s,itemsB:a,styleA:l,styleB:d,valueA:c,valueB:u,onValueChange:p=t.onValueChange}=e,f=(0,h.hGv)(),g=$(),[m,y]=C.useState(!1),[x,w]=C.useState(!1),v=C.useMemo(()=>s.find(e=>"shared"===c.type&&c.value===e.value)?.icon??"mixed",[s,c]),S=C.useMemo(()=>a.find(e=>"shared"===u.type&&u.value===e.value)?.icon??"mixed",[a,u]);if(void 0===c&&void 0===u)return null;let k=`style panel ${n} A`,P=`style panel ${r} B`;return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(fw,{id:k,open:m,onOpenChange:y,children:[(0,b.jsx)(fv,{children:(0,b.jsx)(hG,{type:"icon","data-testid":`style.${n}`,title:g(i)+" — "+(null===c||"mixed"===c.type?g("style-panel.mixed"):g(`${n}-style.${c.value}`)),children:(0,b.jsx)(dm,{icon:v,small:!0,invertIcon:!0})})}),(0,b.jsx)(fS,{side:"left",align:"center",sideOffset:80,alignOffset:0,children:(0,b.jsx)(hY,{orientation:"grid",label:g(i),children:(0,b.jsx)(dU,{type:"icons",sourceId:"style-panel",children:s.map(e=>(0,b.jsx)(hG,{"data-testid":`style.${n}.${e.value}`,type:"icon",onClick:()=>{p(l,e.value),h.NlK.deleteOpenMenu(k,f.contextId),y(!1)},title:`${g(i)} \u2014 ${g(`${n}-style.${e.value}`)}`,children:(0,b.jsx)(dm,{icon:e.icon,invertIcon:!0})},e.value))})})})]}),(0,b.jsxs)(fw,{id:P,open:x,onOpenChange:w,children:[(0,b.jsx)(fv,{children:(0,b.jsx)(hG,{type:"icon","data-testid":`style.${r}`,title:g(o)+" — "+(null===u||"mixed"===u.type?g("style-panel.mixed"):g(`${r}-style.${u.value}`)),children:(0,b.jsx)(dm,{icon:S,small:!0})})}),(0,b.jsx)(fS,{side:"left",align:"center",sideOffset:116,alignOffset:0,children:(0,b.jsx)(hY,{orientation:"grid",label:g(o),children:(0,b.jsx)(dU,{type:"icons",sourceId:"style-panel",children:a.map(e=>(0,b.jsx)(hG,{type:"icon",title:`${g(o)} \u2014 ${g(`${r}-style.${e.value}`)}`,"data-testid":`style.${r}.${e.value}`,onClick:()=>{p(d,e.value),h.NlK.deleteOpenMenu(P,f.contextId),w(!1)},children:(0,b.jsx)(dm,{icon:e.icon})},e.value))})})})]})]})}),y7=C.memo(function(e){let t=$()(e.label?e.label:`style-panel.${e.stylePanelType}`);return(0,b.jsx)(hY,{label:t,children:(0,b.jsx)(be,{...e})})}),be=C.memo(function(e){let t=y3(),{id:n,label:r,uiType:i,stylePanelType:o,isOverflow:s,style:a,items:l,type:d,value:c,onValueChange:u=t.onValueChange,testIdType:p=i,sideOffset:f=8}=e,g=$(),m=(0,h.hGv)(),[y,x]=C.useState(!1),w=C.useMemo(()=>"mixed"===c.type?"mixed":l.find(e=>e.value===c.value)?.icon??l[0]?.icon,[l,c]),v=g(`style-panel.${o}`),S="mixed"!==c.type&&l.some(e=>e.value===c.value),k="mixed"===c.type?g("style-panel.mixed"):S?v+" — "+g(`${i}-style.${c.value}`):v,P=r?g(r):"",T=`style panel ${n}`;return(0,b.jsxs)(fw,{id:T,open:y,onOpenChange:x,className:"tlui-style-panel__dropdown-picker",children:[(0,b.jsx)(fv,{children:(0,b.jsxs)(hG,{type:d,"data-testid":`style.${p}`,"data-direction":"left",isActive:s&&S,title:k,children:[P&&(0,b.jsx)(aK,{children:P}),(0,b.jsx)(dm,{icon:w})]})}),(0,b.jsx)(fS,{side:"left",align:"center",sideOffset:f,children:(0,b.jsx)(hY,{orientation:l.length>4?"grid":"horizontal",label:P,children:(0,b.jsx)(dU,{type:"icons",sourceId:"style-panel",children:l.map(e=>(0,b.jsx)(hG,{type:"icon","data-testid":`style.${p}.${e.value}`,title:v+" — "+g(`${i}-style.${e.value}`),isActive:S&&w===e.icon,onClick:()=>{t.onHistoryMark("select style dropdown item"),u(a,e.value),h.NlK.deleteOpenMenu(T,m.contextId),x(!1)},children:(0,b.jsx)(dm,{icon:e.icon})},e.value))})})})]})});function bt(){return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(bn,{children:[(0,b.jsx)(br,{}),(0,b.jsx)(bo,{})]}),(0,b.jsxs)(bn,{children:[(0,b.jsx)(bs,{}),(0,b.jsx)(ba,{}),(0,b.jsx)(bl,{})]}),(0,b.jsxs)(bn,{children:[(0,b.jsx)(bd,{}),(0,b.jsx)(bc,{}),(0,b.jsx)(bu,{})]}),(0,b.jsxs)(bn,{children:[(0,b.jsx)(bh,{}),(0,b.jsx)(bp,{}),(0,b.jsx)(bf,{}),(0,b.jsx)(bg,{})]})]})}function bn({children:e}){return(0,b.jsx)("div",{className:"tlui-style-panel__section",children:e})}function br(){let e=(0,h.hGv)(),{styles:t}=y3(),n=$(),r=t.get(h.ive),i=(0,h.hau)("style panel color items",()=>(function(e){let t=[],n=new Set;for(let r of h.ive.values)if(r in e&&m8(e[r])){if("white"===r)continue;t.push({value:r,icon:"color"}),n.add(r)}for(let[r,i]of Object.entries(e))!n.has(r)&&"white"!==r&&m8(i)&&t.push({value:r,icon:"color"});return t})(e.getCurrentTheme().colors[e.getColorMode()]),[e]);return void 0===r?null:(0,b.jsx)(y6,{title:n("style-panel.color"),uiType:"color",style:h.ive,items:i,value:r})}let bi=[.1,.25,.5,.75,1];function bo(){let e=(0,h.hGv)(),{onHistoryMark:t,onOpacityChange:n,enhancedA11yMode:r}=y3(),i=(0,h.hau)("opacity",()=>e.getSharedOpacity(),[e]),o=$(),s=C.useCallback(e=>{n(bi[e])},[n]);if(void 0===i)return null;let a="mixed"===i.type?-1:bi.indexOf((0,h.wql)(bi,e=>Math.abs(e-i.value)));return(0,b.jsxs)(b.Fragment,{children:[r&&(0,b.jsx)(y5,{children:o("style-panel.opacity")}),(0,b.jsx)(y0,{"data-testid":"style.opacity",value:a>=0?a:bi.length-1,label:"mixed"===i.type?"style-panel.mixed":`opacity-style.${i.value}`,onValueChange:s,steps:bi.length-1,title:o("style-panel.opacity"),onHistoryMark:t,ariaValueModifier:25})]})}function bs(){let{styles:e,enhancedA11yMode:t}=y3(),n=$(),r=e.get(h.u8f);if(void 0===r)return null;let i=n("style-panel.fill");return(0,b.jsxs)(b.Fragment,{children:[t&&(0,b.jsx)(y5,{children:i}),(0,b.jsxs)(hY,{orientation:"horizontal",label:i,children:[(0,b.jsx)(y4,{title:i,uiType:"fill",style:h.u8f,items:ye,value:r}),(0,b.jsx)(be,{type:"icon",id:"fill-extra",uiType:"fill",testIdType:"fill-extra",stylePanelType:"fill",style:h.u8f,items:yt,value:r,sideOffset:116,isOverflow:!0})]})]})}function ba(){let{styles:e}=y3(),t=$(),n=e.get(h.Pe6);return void 0===n?null:(0,b.jsx)(y6,{title:t("style-panel.dash"),uiType:"dash",style:h.Pe6,items:yn,value:n})}function bl(){let e=(0,h.hGv)(),{styles:t,onValueChange:n}=y3(),r=$(),i=t.get(h.Sg3);return void 0===i?null:(0,b.jsx)(y6,{title:r("style-panel.size"),uiType:"size",style:h.Sg3,items:yr,value:i,onValueChange:(t,r)=>{n(t,r);let i=e.getSelectedShapeIds();i.length>0&&(0,h.IeP)(e,i)}})}function bd(){let e=(0,h.hGv)(),{styles:t}=y3(),n=$(),r=t.get(h.yes),i=(0,h.hau)("style panel font items",()=>(function(e){let t=[],n=new Set;for(let r of h.yes.values){let i=e.fonts[r];r in e.fonts&&(0,h.GYP)(i)&&(t.push({value:r,icon:m7(i,r)}),n.add(r))}for(let[r,i]of Object.entries(e.fonts))!n.has(r)&&(0,h.GYP)(i)&&t.push({value:r,icon:m7(i,r)});return t})(e.getCurrentTheme()),[e]);return void 0===r?null:(0,b.jsx)(y6,{title:n("style-panel.font"),uiType:"font",style:h.yes,items:i,value:r})}function bc(){let{styles:e,enhancedA11yMode:t}=y3(),n=$(),r=e.get(h.nM1);if(void 0===r)return null;let i=n("style-panel.align");return(0,b.jsxs)(b.Fragment,{children:[t&&(0,b.jsx)(y5,{children:i}),(0,b.jsxs)(hY,{orientation:"horizontal",label:i,children:[(0,b.jsx)(y4,{title:i,uiType:"align",style:h.nM1,items:yi,value:r}),(0,b.jsx)(hG,{type:"icon",title:n("style-panel.vertical-align"),"data-testid":"vertical-align",disabled:!0,children:(0,b.jsx)(dm,{icon:"vertical-align-middle"})})]})]})}function bu(){let{styles:e,enhancedA11yMode:t}=y3(),n=$(),r=e.get(h.yMj),i=e.get(h.YUb);if(void 0===r)return null;let o=n("style-panel.label-align");return(0,b.jsxs)(b.Fragment,{children:[t&&(0,b.jsx)(y5,{children:o}),(0,b.jsxs)(hY,{orientation:"horizontal",label:o,children:[(0,b.jsx)(y4,{title:o,uiType:"align",style:h.yMj,items:yo,value:r}),void 0===i?(0,b.jsx)(hG,{type:"icon",title:n("style-panel.vertical-align"),"data-testid":"vertical-align",disabled:!0,children:(0,b.jsx)(dm,{icon:"vertical-align-middle"})}):(0,b.jsx)(be,{type:"icon",id:"geo-vertical-alignment",uiType:"verticalAlign",stylePanelType:"vertical-align",style:h.YUb,items:ys,value:i,sideOffset:116})]})]})}function bh(){let e=(0,h.hGv)(),{styles:t}=y3(),n=t.get(h.tg8);if(void 0===n)return null;let r=e.getShapeUtil("geo").options.customGeoTypes,i=Object.entries({...m1,...r}).map(([e,t])=>({value:e,icon:t.icon}));return(0,b.jsx)(y7,{label:"style-panel.geo",type:"menu",id:"geo",uiType:"geo",stylePanelType:"geo",style:h.tg8,items:i,value:n})}function bp(){let{styles:e}=y3(),t=e.get(h.qfG);return void 0===t?null:(0,b.jsx)(y7,{id:"arrow-kind",type:"menu",label:"style-panel.arrow-kind",uiType:"arrow-kind",stylePanelType:"arrow-kind",style:h.qfG,items:ya,value:t})}function bf(){let{styles:e}=y3(),t=e.get(h.srS),n=e.get(h.roz);return void 0===t||void 0===n?null:(0,b.jsx)(y8,{label:"style-panel.arrowheads",uiTypeA:"arrowheadStart",styleA:h.roz,itemsA:yl,valueA:n,uiTypeB:"arrowheadEnd",styleB:h.srS,itemsB:yd,valueB:t,labelA:"style-panel.arrowhead-start",labelB:"style-panel.arrowhead-end"})}function bg(){let{styles:e}=y3(),t=e.get(h.eBK);return void 0===t?null:(0,b.jsx)(y7,{type:"menu",id:"spline",uiType:"spline",stylePanelType:"spline",label:"style-panel.spline",style:h.eBK,items:yc,value:t})}let bm=(0,C.memo)(function({isMobile:e,styles:t,children:n}){let r=(0,h.hGv)(),i=(0,h.hau)("enhancedA11yMode",()=>r.user.getEnhancedA11yMode(),[r]),o=(0,C.useRef)(null);(0,h.I9L)(o);let s=mQ();return void 0===t&&(t=s),(0,C.useEffect)(()=>{let e=o.current;if(e)return e.addEventListener("pointermove",t),e.addEventListener("keydown",n,{capture:!0}),()=>{e.removeEventListener("pointermove",t),e.removeEventListener("keydown",n,{capture:!0})};function t(e){r.markEventAsHandled(e)}function n(e){"Escape"===e.key&&o.current?.contains(r.getContainerDocument().activeElement)&&(e.stopPropagation(),r.getContainer().focus())}},[r]),t&&(0,b.jsx)("div",{ref:o,"data-testid":"style.panel",className:ik("tlui-style-panel",{"tlui-style-panel__wrapper":!e}),"data-ismobile":e,"data-enhanced-a11y-mode":i,children:(0,b.jsx)(y2,{styles:t,children:n??(0,b.jsx)(bt,{})})})}),by={success:"check-circle",warning:"warning-triangle",error:"cross-circle",info:"info-circle"};function bb({toast:e}){let{removeToast:t}=pM(),n=$(),r=e.actions&&e.actions.length>0,i=e.icon||e.severity&&by[e.severity],o=e.iconLabel||(e.severity?n(`toast.${e.severity}`):"");return(0,b.jsxs)(pu,{onOpenChange:n=>{n||t(e.id)},className:"tlui-toast__container",duration:e.keepOpen?1/0:4e3,"data-severity":e.severity,children:[i&&(0,b.jsx)("div",{className:"tlui-toast__icon",children:(0,b.jsx)(df,{label:o,icon:i})}),(0,b.jsxs)("div",{className:"tlui-toast__main","data-title":!!e.title,"data-description":!!e.description,"data-actions":!!e.actions,children:[(0,b.jsxs)("div",{className:"tlui-toast__content",children:[e.title&&(0,b.jsx)(pm,{className:"tlui-toast__title",children:e.title}),e.description&&(0,b.jsx)(py,{className:"tlui-toast__description",children:e.description})]}),e.actions&&(0,b.jsxs)("div",{className:"tlui-toast__actions",children:[e.actions.map((e,t)=>(0,b.jsx)(pb,{altText:e.label,asChild:!0,onClick:e.onClick,children:(0,b.jsx)(aW,{type:e.type,children:(0,b.jsx)(aK,{children:e.label})})},t)),(0,b.jsx)(px,{asChild:!0,children:(0,b.jsx)(aW,{type:"normal",className:"tlui-toast__close",style:{marginLeft:"auto"},children:(0,b.jsx)(aK,{children:e.closeLabel??n("toast.close")})})})]})]}),!r&&(0,b.jsx)(px,{asChild:!0,children:(0,b.jsx)(aW,{type:"normal",className:"tlui-toast__close",children:(0,b.jsx)(aK,{children:e.closeLabel??n("toast.close")})})})]})}let bx=(0,C.memo)(function(){let{toasts:e}=pM(),t=(0,h.hau)("toasts",()=>e.get(),[]);return(0,b.jsxs)(b.Fragment,{children:[t.map(e=>(0,b.jsx)(bb,{toast:e},e.id)),(0,b.jsx)(pl,{className:"tlui-toast__viewport"})]})});function bw({children:e,className:t,isMousingDown:n,getSelectionBounds:r,changeOnlyWhenYChanges:i=!1,label:o}){let s=(0,h.hGv)(),a=(0,C.useRef)(null);(0,h.I9L)(a);let{isVisible:l,isInteractive:d,hide:c,show:u,position:p,move:f}=function(e){let t=(0,h.hGv)(),n=(0,C.useRef)({name:"hidden"}),[r,i]=(0,C.useState)(!1),[o,s]=(0,C.useState)(!1),[a,l]=(0,C.useState)({x:-1e3,y:-1e3}),d=(0,C.useRef)(new h.l2P(-1e3,-1e3)),c=(0,C.useRef)(new h.l2P(-1e3,-1e3)),u=(0,C.useRef)(-1),p=(0,C.useRef)(-1),f=(0,C.useCallback)((r,i,o=!1)=>{if(c.current.x=r,c.current.y=i,"hidden"===n.current.name||"showing"===n.current.name)return;clearTimeout(p.current);let s=()=>{var t,r;if("shown"===n.current.name&&(t=c.current,r=d.current,e?h.l2P.Sub(r,t).y**2>=256:h.l2P.Len2(h.l2P.Sub(r,t))>=256)){let{x:e,y:t}=c.current;d.current=new h.l2P(e,t),o?(0,i$.flushSync)(()=>l({x:e,y:t})):l({x:e,y:t})}};o?s():p.current=t.timers.setTimeout(s,150)},[t,e]),g=(0,C.useCallback)((e=!1)=>{switch(n.current.name){case"showing":clearTimeout(u.current),n.current={name:"hidden"};break;case"shown":n.current={name:"hiding"},i(!1),e?(n.current={name:"hidden"},s(!1)):u.current=t.timers.setTimeout(()=>{n.current={name:"hidden"},s(!1)},16)}},[t]);return{isVisible:o,isInteractive:r,show:(0,C.useCallback)(()=>{switch(n.current.name){case"hidden":n.current={name:"showing"},u.current=t.timers.setTimeout(()=>{let{x:e,y:t}=c.current;d.current=new h.l2P(e,t),l({x:e,y:t}),n.current={name:"shown"},s(!0),i(!0)},16);break;case"hiding":clearTimeout(u.current),n.current={name:"shown"},i(!0),f(c.current.x,c.current.y)}},[t,f]),hide:g,move:f,position:a}}(i),g=(0,C.useRef)(!1),[m,y]=(0,C.useState)(!1),x=(0,h.fpl)("content size update counter",0);(0,C.useEffect)(()=>{(0,h.vAR)(a.current);let e=new ResizeObserver(()=>{x.update(e=>e+1)});return e.observe(a.current),()=>e.disconnect()},[x]),(0,C.useEffect)(()=>{let e=x.get();return(0,h.wvh)("toolbar position",function(){let t=a.current;if(!t)return;let n=x.get();s.getCamera(),x.get();let i=function(e,t,n){let r=n()?.clone();if(!r)return;let i=e.getViewportScreenBounds();if(r.x-=i.x,r.y-=i.y,r.midY<16||r.midY>i.h-16||r.midX<16||r.midX>i.w-16)return;let o=bv(t.getBoundingClientRect());if(!o.width||!o.height)return;let{scrollLeft:s,scrollTop:a}=e.getContainer(),l=r.midX-o.w/2,d=r.y-o.h-8;return l=(0,h.qE8)(l,16,i.w-o.w-16),d=(0,h.qE8)(d,16,i.h-o.h-16),l+=s,d+=a,{x:l=Math.round(l),y:d=Math.round(d)}}(s,t,r);if(i){if("moving"===s.getCameraState()){let e=a.current;e&&e.style.setProperty("transform",`translate(${i.x}px, ${i.y}px)`)}else{let t=e!==n;f(i.x,i.y,t)}g.current||(g.current=!0,y(!0))}else g.current&&(g.current=!1,y(!1));e=n})},[s,r,x,f]);let w=(0,h.hau)("camera state",()=>s.getCameraState(),[s]);return(0,C.useEffect)(()=>{n||!m?c():u()},[m,w,n,u,c]),(0,C.useLayoutEffect)(()=>{let e=a.current;e&&(e.dataset.visible=`${l}`)},[l,p]),(0,C.useLayoutEffect)(()=>{let e=a.current;e&&e.style.setProperty("transform",`translate(${p.x}px, ${p.y}px)`)},[p]),(0,C.useLayoutEffect)(()=>{let e=a.current;e&&(e.dataset.interactive=`${d}`)},[d]),(0,b.jsx)("div",{ref:a,"data-interactive":!1,"data-visible":!1,"data-testid":"contextual-toolbar",className:ik("tlui-contextual-toolbar",t),onPointerDown:s.markEventAsHandled,children:(0,b.jsx)(hY,{orientation:"horizontal",className:"tlui-menu",label:o,tooltipSide:"top",children:e})})}function bv(e){return new h.azJ(e.x,e.y,e.width,e.height)}function bS({shapeId:e,onClose:t,source:n}){let r=(0,h.hGv)(),[i,o]=(0,C.useState)(()=>{let t=r.getShape(e);if(!t)return"";if(!("altText"in t.props))throw Error("Shape does not have altText property");return t.props.altText||""}),s=$(),a=(0,C.useRef)(null),l=hn(),d=r.getIsReadonly(),c=(0,C.useCallback)(()=>{l("set-alt-text",{source:n});let o=r.getShape(e);o&&(r.updateShapes([{id:o.id,type:o.type,props:{altText:i}}]),t())},[l,n,r,e,i,t]),u=(0,C.useCallback)(()=>t(),[t]);return(0,C.useEffect)(()=>{let e=r.getContainerDocument();function t(e){"Escape"===e.key&&(e.stopPropagation(),u())}return a.current?.select(),e.addEventListener("keydown",t,{capture:!0}),()=>{e.removeEventListener("keydown",t,{capture:!0})}},[r,u]),(0,C.useEffect)(()=>{let e=r.getContainerDocument(),t=t=>{let n=e.querySelector(".tlui-media__toolbar");n?.contains(t.target)||c()};return e.addEventListener("pointerdown",t,{capture:!0}),()=>{e.removeEventListener("pointerdown",t,{capture:!0})}},[r,c]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(dS,{ref:a,className:"tlui-media__toolbar-alt-text-input","data-testid":"media-toolbar.alt-text-input",value:i,placeholder:s("tool.media-alt-text-desc"),"aria-label":s("tool.media-alt-text-desc"),onValueChange:e=>o(e),onComplete:c,onCancel:u,disabled:d}),!d&&(0,b.jsx)(aW,{title:s("tool.media-alt-text-confirm"),"data-testid":"tool.media-alt-text-confirm",type:"icon",onPointerDown:h.woC,onClick:()=>c(),children:(0,b.jsx)(dm,{small:!0,icon:"check"})})]})}let bC=(0,h.u4I)(function({imageShapeId:e,isManipulating:t,onEditAltTextStart:n,onManipulatingStart:r,onManipulatingEnd:i}){let o=(0,h.hGv)(),s=hn(),a=$(),l=(0,C.useRef)(null),d=o.getIsReadonly(),c=(0,h.hau)("crop",()=>o.getShape(e).props.crop,[o,e]),u=c?Math.min(1-(c.bottomRight.x-c.topLeft.x),1-(c.bottomRight.y-c.topLeft.y)):0,[p,f]=(0,C.useState)(c?Math.max(u,1-.3333333333333333):3),g=xE();(0,C.useEffect)(()=>{f(c?Math.max(u,1-.3333333333333333):3)},[c,u,p]);let m=(0,C.useCallback)(e=>o.markHistoryStoppingPoint(e),[o]),y=(0,C.useCallback)((e,t)=>Math.pow(e/t,1.5)*t,[]),x=c&&p?(0,h.wwY)(y(u,p),[0,p],[0,100],!0):0,w=(0,C.useCallback)(t=>{o.setCurrentTool("select.crop.idle");let n=Math.pow(t/100,.6666666666666666)*Math.min(1-.3333333333333333,p??1-.3333333333333333),r=o.getShape(e);if(!r)return;let i=function(e,t,n){let r,i,o=t.props.crop||X(),{width:s,height:a}=ee(o),l=s/a,d=1+e*((n?1/(1-n):3)-1);l>1?i=(r=Math.min(1,1/d))/l:r=(i=Math.min(1,1/d))*l;let c=function(e,t,n,r=!0,i=!1){let o,s,{w:a,h:l}=Q(e.props,e.props.crop??X()),d=e.props.crop||X(),c=e.x+e.props.w/2,u=e.y+e.props.h/2;if(r){let{x:e,y:t}=et(d);o=e,s=t}else o=.5,s=.5;let h=en(o,s,t,n,i),p=t*a,f=n*l;return{crop:h,w:p,h:f,x:c-p/2,y:u-f/2}}(t,r,i,!0,o.isCircle),u=Math.min(3,s/r);c.w*=u,c.h*=u;let h=t.x+t.props.w/2,p=t.y+t.props.h/2;return c.x=h-c.w/2,c.y=p-c.h/2,c}(n>=1?1:n/(2*(1-n)),r,p);o.updateShape({id:r.id,type:r.type,x:i.x,y:i.y,props:{w:i.w,h:i.h,crop:i.crop}}),s("set-style",{source:"image-toolbar",id:"zoom",value:t})},[o,s,e,p]),v=(0,C.useCallback)(()=>g["image-replace"].onSelect("image-toolbar"),[g]),S=(0,C.useCallback)(()=>g["download-original"].onSelect("image-toolbar"),[g]),k=(0,h.hau)("altText",()=>o.getShape(e).props.altText,[o,e]),P=(0,h.hau)("shapeAspectRatio",()=>{let t=o.getShape(e);return t.props.w/t.props.h},[o,e]),T=!c||(0,h.n4T)(c,X());return((0,C.useEffect)(()=>{t&&o.timers.setTimeout(()=>l.current?.focus(),0)},[o,t]),(0,C.useEffect)(()=>{function e(e){t&&("Escape"===e.key?(o.cancel(),i()):"Enter"===e.key&&(o.complete(),i()))}let n=l.current;return n&&n.addEventListener("keydown",e),()=>{n&&n.removeEventListener("keydown",e)}},[o,t,i]),t)?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(y0,{ref:l,value:x,label:"tool.image-zoom",onValueChange:w,onHistoryMark:m,min:0,steps:100,"data-testid":"tool.image-zoom",title:a("tool.image-zoom")}),(0,b.jsxs)(hi,{id:"image-toolbar-aspect-ratio",children:[(0,b.jsx)(ho,{children:(0,b.jsx)(hG,{title:a("tool.aspect-ratio"),type:"icon","data-testid":"tool.image-aspect-ratio",children:(0,b.jsx)(dm,{icon:"corners"})})}),(0,b.jsx)(hs,{side:"top",align:"center",children:J.map(t=>{let n=!1;return T?"original"===t&&(n=!0):n="circle"===t?!!c.isCircle:"square"===t?!c?.isCircle&&(0,h.YY0)(P,Z[t],.1):"original"!==t&&!T&&(0,h.YY0)(P,Z[t],.01),(0,b.jsx)(hh,{onSelect:()=>{let n;(n=o.getShape(e))&&o.run(()=>{o.setCurrentTool("select.crop.idle");let r=function(e,t){let n,r;if("original"===e){let{w:e,h:n}=Q(t.props,t.props.crop??X()),r=t.x+t.props.w/2,i=t.y+t.props.h/2;return{crop:X(),w:e,h:n,x:r-e/2,y:i-n/2}}let i=Z[e],{w:o,h:s}=Q(t.props,t.props.crop||X()),a=o/s,l=t.props.crop||X(),{width:d,height:c}=ee(l),u=et(l),h=Math.min(1/d,1/c);if(0!==a&&Number.isFinite(a)&&0!==i){let e,t,l=d*o,u=c*s,h=Math.max(l,u);l>=u?t=(e=h)/i:e=(t=h)*i,n=e/o,r=t/s,n>1&&(n=1,r=a/i),r>1&&(r=1,n=i/a),n=Math.max(0,Math.min(1,n)),r=Math.max(0,Math.min(1,r))}else n=1,r=1;let p=Math.min(1/n,1/r);n*=p/h,r*=p/h,n=Math.max(0,Math.min(1,n)),r=Math.max(0,Math.min(1,r));let f=en(u.x,u.y,n,r,"circle"===e),g=f.bottomRight.x-f.topLeft.x,m=f.bottomRight.y-f.topLeft.y,y=1;d>0?y=t.props.w/(d*o):c>0&&(y=t.props.h/(c*s));let b=g*o*y,x=m*s*y;return{crop:f,w:b,h:x,x:t.x+t.props.w/2-b/2,y:t.y+t.props.h/2-x/2}}(t,n);o.markHistoryStoppingPoint("aspect ratio"),o.updateShape({id:e,type:"image",x:r.x,y:r.y,props:{crop:r.crop,w:r.w,h:r.h}}),(0,h.IeP)(o,[e])})},checked:n,title:a(`tool.aspect-ratio.${t}`),children:(0,b.jsx)(aK,{children:a(`tool.aspect-ratio.${t}`)})},t)})})]}),(0,b.jsx)(hG,{type:"icon",onClick:i,"data-testid":"tool.image-crop-confirm",style:{borderLeft:"1px solid var(--tl-color-divider)",marginLeft:"2px"},title:a("tool.image-crop-confirm"),children:(0,b.jsx)(dm,{small:!0,icon:"check"})})]}):(0,b.jsxs)(b.Fragment,{children:[!d&&(0,b.jsx)(hG,{type:"icon","data-testid":"tool.image-replace",onClick:v,title:a("tool.replace-media"),children:(0,b.jsx)(dm,{small:!0,icon:"tool-media"})}),!d&&(0,b.jsx)(hG,{type:"icon",title:a("tool.image-crop"),onClick:r,"data-testid":"tool.image-crop",children:(0,b.jsx)(dm,{small:!0,icon:"crop"})}),(0,b.jsx)(hG,{type:"icon",title:a("action.download-original"),onClick:S,"data-testid":"tool.image-download",children:(0,b.jsx)(dm,{small:!0,icon:"download"})}),(k||!d)&&(0,b.jsx)(hG,{type:"icon",title:a("tool.media-alt-text"),"data-testid":"tool.image-alt-text",onClick:()=>{s("alt-text-start",{source:"image-toolbar"}),n()},children:(0,b.jsx)(dm,{small:!0,icon:"alt"})})]})});function bk({children:e}){let t=(0,h.hGv)(),n=(0,h.hau)("imageShape",()=>{let e=t.getOnlySelectedShape();return e&&"image"===e.type?e.id:null},[t]),r=(0,h.hau)("showToolbar",()=>t.isInAny("select.idle","select.pointing_shape","select.crop"),[t]),i=(0,h.hau)("locked",()=>!!n&&t.getShape(n)?.isLocked,[t,n]);return n&&r&&!i?(0,b.jsx)(bP,{imageShapeId:n,children:e},n):null}function bP({children:e,imageShapeId:t}){let n=(0,h.hGv)(),r=$(),i=(0,h.hau)("editor path",()=>n.isInAny("select.crop.cropping","select.crop.pointing_crop_handle","select.crop.translating_crop"),[n]),o=(0,h.hau)("camera",()=>n.getCamera(),[n]),s=(0,h.hau)("editor path",()=>n.isIn("select.crop."),[n]),a=(0,C.useRef)(void 0),l=(0,C.useCallback)(()=>{n.setCroppingShape(null),n.setCurrentTool("select.idle")},[n]),[d,c]=(0,C.useState)(!1),u=(0,C.useCallback)(()=>c(!0),[]),p=(0,C.useCallback)(()=>n.setCurrentTool("select.crop.idle"),[n]),f=(0,C.useCallback)(()=>c(!1),[]);(0,C.useEffect)(()=>{a.current=void 0},[o]);let g=(0,C.useCallback)(()=>{if(s&&a.current)return a.current;let e=n.getSelectionScreenBounds();if(!e)return;let t=new h.azJ(e.x,e.y,e.width,0);return a.current=t,t},[n,s]);return i?(a.current=void 0,null):(0,b.jsx)(bw,{className:"tlui-media__toolbar tlui-image__toolbar",getSelectionBounds:g,label:r("tool.image-toolbar-title"),children:e||(d?(0,b.jsx)(bS,{shapeId:t,onClose:f,source:"image-toolbar"}):(0,b.jsx)(bC,{imageShapeId:t,isManipulating:s,onEditAltTextStart:u,onManipulatingStart:p,onManipulatingEnd:l}))})}function bT({textEditor:e,onEditLinkStart:t}){let n=(0,h.hGv)(),r=hn(),i=$(),[o,s]=(0,C.useState)(0);return(0,C.useEffect)(function(){function t(){s(e=>e+1)}e.on("update",t),e.on("selectionUpdate",t)},[e]),(0,C.useEffect)(()=>{function e(e){t&&(0,h.gu7)(e)&&e.shiftKey&&"k"===e.key&&(e.preventDefault(),t())}let r=n.getContainerDocument();return r.addEventListener("keydown",e),()=>{r.removeEventListener("keydown",e)}},[n,t]),(0,C.useMemo)(()=>{function n(t,n){e.view&&(r("rich-text",{operation:t,source:"rich-text-menu"}),e.chain().focus()[n]().run())}return[{name:"bold",onSelect(){n("bold","toggleBold")}},{name:"italic",onSelect(){n("bold","toggleItalic")}},{name:"code",onSelect(){n("bold","toggleCode")}},t?{name:"link",onSelect(){t()}}:void 0,{name:"bulletList",onSelect(){n("bulletList","toggleBulletList")}},{name:"highlight",onSelect(){n("bulletList","toggleHighlight")}}].filter(Boolean)},[e,r,t]).map(({name:t,attrs:n,onSelect:r})=>{let o=!!e.view&&e.isActive(t,n);return(0,b.jsx)(hG,{title:i(`tool.rich-text-${t}`),"data-testid":`rich-text.${t}`,type:"icon",isActive:o,onPointerDown:h.woC,onClick:r,role:"option","aria-pressed":o,children:(0,b.jsx)(dm,{small:!0,icon:t})},t)})}function bE({textEditor:e,value:t,onClose:n}){let r=(0,h.hGv)(),[i,o]=(0,C.useState)(t),s=$(),a=(0,C.useRef)(null),l=hn(),d="rich-text-menu",c=i.startsWith("http")?i:`https://${i}`,u=(0,C.useCallback)(t=>{l("rich-text",{operation:"link-edit",source:d}),t.startsWith("http://")||t.startsWith("https://")||(t=`https://${t}`),e.chain().setLink({href:t}).run(),r.getInstanceState().isCoarsePointer?e.commands.blur():e.commands.focus(),n()},[l,d,e,r,n]),p=(0,C.useCallback)(()=>{l("rich-text",{operation:"link-remove",source:d}),e.chain().unsetLink().focus().run(),n()},[l,d,e,n]);return(0,C.useEffect)(()=>{let e=r.getContainerDocument(),t=t=>{let n=e.querySelector(".tlui-rich-text__toolbar");n?.contains(t.target)||(i?u(i):p())};return e.addEventListener("pointerdown",t,{capture:!0}),()=>{e.removeEventListener("pointerdown",t,{capture:!0})}},[r,u,p,i]),(0,C.useEffect)(()=>{a.current?.focus()},[i]),(0,C.useEffect)(()=>{o(t)},[t]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(dS,{ref:a,"data-testid":"rich-text.link-input",className:"tlui-rich-text__toolbar-link-input",value:i,onValueChange:e=>o(e),onComplete:u,onCancel:()=>n(),placeholder:"example.com","aria-label":"example.com"}),(0,b.jsx)(aW,{className:"tlui-rich-text__toolbar-link-visit",title:s("tool.rich-text-link-visit"),type:"icon",onPointerDown:h.woC,onClick:()=>{l("rich-text",{operation:"link-visit",source:d}),(0,h.D1x)(c,"_blank"),n()},disabled:!i,children:(0,b.jsx)(dm,{small:!0,icon:"external-link"})}),(0,b.jsx)(aW,{className:"tlui-rich-text__toolbar-link-remove",title:s("tool.rich-text-link-remove"),"data-testid":"rich-text.link-remove",type:"icon",onPointerDown:h.woC,onClick:p,children:(0,b.jsx)(dm,{small:!0,icon:"trash"})})]})}let bI=(0,h.u4I)(function({children:e}){let t=(0,h.hGv)(),n=(0,h.hau)("textEditor",()=>t.getRichTextEditor(),[t]);return t.getInstanceState().isCoarsePointer||!n?null:(0,b.jsx)(b_,{textEditor:n,children:e})});function b_({textEditor:e,children:t}){let n=(0,h.hGv)(),{isEditingLink:r,onEditLinkStart:i,onEditLinkClose:o}=function(e){let[t,n]=(0,C.useState)(!1);(0,C.useEffect)(()=>{if(!e)return void n(!1);let t=()=>{n(e.isActive("link"))};return e.view.dom.addEventListener("click",t),()=>{e.isInitialized&&e.view.dom.removeEventListener("click",t)}},[e,t]),(0,C.useEffect)(()=>{if(e&&e.isActive("link"))try{let{from:t,to:n}=(0,eP.ve)(e.state.doc.resolve(e.state.selection.from),e.schema.marks.link);e.state.selection.empty&&e.commands.setTextSelection({from:t,to:n})}catch{}},[e,t]);let r=(0,C.useCallback)(()=>{n(!0)},[]),i=(0,C.useCallback)(()=>{n(!1)},[]);return{isEditingLink:t,onEditLinkStart:r,onEditLinkClose:(0,C.useCallback)(()=>{if(n(!1),!e)return;let t=e.state.selection.from;e.commands.setTextSelection({from:t,to:t})},[e]),onEditLinkCancel:i}}(e),[s,a]=(0,C.useState)(null),l=(0,C.useRef)(void 0),d=function(e){let[t,n]=(0,C.useState)(!1);return(0,C.useEffect)(()=>{if(!e)return;let t=(0,h.sg1)(({isPointing:e})=>{n(e)},16),r=()=>t({isPointing:!0}),i=()=>t({isPointing:!1}),o=["touchstart","pointerdown","mousedown"],s=["touchend","pointerup","mouseup"];o.forEach(t=>{e.view.dom.addEventListener(t,r)});let a=e.view.dom.ownerDocument;return s.forEach(e=>{a.body.addEventListener(e,i)}),()=>{o.forEach(t=>{e.isInitialized&&e.view.dom.removeEventListener(t,r)}),s.forEach(e=>{a.body.removeEventListener(e,i)})}},[e]),t}(e),c=$(),u=(0,C.useCallback)(()=>{if(r)return l.current;let e=n.getContainerWindow().getSelection();if(!s||!e||0===e.rangeCount||e.isCollapsed)return;let t=[];for(let n=0;n<e.rangeCount;n++){let r=e.getRangeAt(n);t.push(bv(r.getBoundingClientRect()))}let i=h.azJ.Common(t);return l.current=i,i},[n,s,r]);return(0,C.useEffect)(()=>{let t=({editor:e})=>a(e.state.selection);return e.on("selectionUpdate",t),t({editor:e}),()=>{e.off("selectionUpdate",t)}},[e]),(0,b.jsx)(bw,{className:"tlui-rich-text__toolbar",getSelectionBounds:u,isMousingDown:d,changeOnlyWhenYChanges:!0,label:c("tool.rich-text-toolbar-title"),children:t||(r?(0,b.jsx)(bE,{textEditor:e,value:e.isActive("link")?e.getAttributes("link").href:"",onClose:o}):(0,b.jsx)(bT,{textEditor:e,onEditLinkStart:i}))})}function bM(){let e=(0,h.hGv)(),t=$(),{orientation:n}=aj(),r=mQ(),i=r?.get(h.ive),o=(0,h.hau)("mobile style panel current color",()=>{let t=e.getCurrentTheme().colors[e.getColorMode()];return i?.type==="shared"?(0,h.FHQ)(t,i.value,"solid"):(0,h.FHQ)(t,"black","solid")},[e,i]),s=(0,h.hau)("disable style panel",()=>e.isInAny("hand","zoom","eraser","laser"),[e]),a=(0,C.useCallback)(t=>{t||e.updateInstanceState({isChangingStyle:!1})},[e]),{StylePanel:l}=xS();return l?(0,b.jsxs)(fw,{id:"mobile style menu",onOpenChange:a,children:[(0,b.jsx)(fv,{children:(0,b.jsx)(aW,{type:"tool","data-testid":"mobile-styles.button",style:{color:s?"var(--tl-color-muted-1)":o},title:t("style-panel.title"),disabled:s,children:(0,b.jsx)(dm,{icon:s?"blob":i?.type==="mixed"?"mixed":"blob"})})}),(0,b.jsx)(fS,{side:"horizontal"===n?"top":"right",align:"end",children:l&&(0,b.jsx)(l,{isMobile:!0})})]}):null}function bA(){return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bO,{}),(0,b.jsx)(bD,{}),(0,b.jsx)(bL,{}),(0,b.jsx)(bF,{}),(0,b.jsx)(bR,{}),(0,b.jsx)(bz,{}),(0,b.jsx)(bN,{}),(0,b.jsx)(b$,{}),(0,b.jsx)(bB,{}),(0,b.jsx)(bH,{}),(0,b.jsx)(bW,{}),(0,b.jsx)(bU,{}),(0,b.jsx)(bY,{}),(0,b.jsx)(bX,{}),(0,b.jsx)(bK,{}),(0,b.jsx)(bq,{}),(0,b.jsx)(bG,{}),(0,b.jsx)(bV,{}),(0,b.jsx)(bJ,{}),(0,b.jsx)(bZ,{}),(0,b.jsx)(bQ,{}),(0,b.jsx)(b0,{}),(0,b.jsx)(b1,{}),(0,b.jsx)(b2,{}),(0,b.jsx)(b3,{}),(0,b.jsx)(b5,{}),(0,b.jsx)(b4,{}),(0,b.jsx)(b6,{})]})}function bj({tool:e}){var t;let n,r,i=(t=p3()[e],n=(0,h.hGv)(),r=t?.meta?.geo,(0,h.hau)("is tool selected",()=>{if(!t)return!1;let e=n.getCurrentToolId();return"geo"===e?r===n.getSharedStyles().getAsKnownValue(h.tg8):e===t.id},[n,t?.id,r]));return(0,b.jsx)(p6,{toolId:e,isSelected:i})}function bO(){return(0,b.jsx)(bj,{tool:"select"})}function bD(){return(0,b.jsx)(bj,{tool:"hand"})}function bL(){return(0,b.jsx)(bj,{tool:"draw"})}function bF(){return(0,b.jsx)(bj,{tool:"eraser"})}function bR(){return(0,b.jsx)(bj,{tool:"arrow"})}function bz(){return(0,b.jsx)(bj,{tool:"text"})}function bN(){return(0,b.jsx)(bj,{tool:"note"})}function b$(){return(0,b.jsx)(p6,{toolId:"asset"})}function bB(){return(0,b.jsx)(bj,{tool:"rectangle"})}function bH(){return(0,b.jsx)(bj,{tool:"ellipse"})}function bU(){return(0,b.jsx)(bj,{tool:"diamond"})}function bW(){return(0,b.jsx)(bj,{tool:"triangle"})}function bK(){return(0,b.jsx)(bj,{tool:"rhombus"})}function bV(){return(0,b.jsx)(bj,{tool:"heart"})}function bY(){return(0,b.jsx)(bj,{tool:"hexagon"})}function bG(){return(0,b.jsx)(bj,{tool:"cloud"})}function bq(){return(0,b.jsx)(bj,{tool:"star"})}function bX(){return(0,b.jsx)(bj,{tool:"oval"})}function bJ(){return(0,b.jsx)(bj,{tool:"x-box"})}function bZ(){return(0,b.jsx)(bj,{tool:"check-box"})}function bQ(){return(0,b.jsx)(bj,{tool:"arrow-left"})}function b0(){return(0,b.jsx)(bj,{tool:"arrow-up"})}function b1(){return(0,b.jsx)(bj,{tool:"arrow-down"})}function b2(){return(0,b.jsx)(bj,{tool:"arrow-right"})}function b3(){return(0,b.jsx)(bj,{tool:"line"})}function b5(){return(0,b.jsx)(bj,{tool:"highlight"})}function b6(){return(0,b.jsx)(bj,{tool:"frame"})}function b4(){return(0,b.jsx)(bj,{tool:"laser"})}let b8=["copy","cut","paste","asset"];function b9(e){return e.menus.hasAnyOpenMenus()||null!==e.getEditingShapeId()||e.getCrashingError()||!e.user.getAreKeyboardShortcutsEnabled()}let b7={shift:"shift","⇧":"shift",alt:"alt",option:"alt","⌥":"alt",ctrl:"ctrl",control:"ctrl","⌃":"ctrl",cmd:"meta",command:"meta",meta:"meta","⌘":"meta"},xe={"⌫":"backspace","↩":"enter",return:"enter",esc:"escape",del:"delete",ins:"insert",left:"arrowleft",right:"arrowright",up:"arrowup",down:"arrowdown",space:" "},xt={"<":",",">":".","?":"/",":":";",'"':"'","{":"[","}":"]","|":"\\",_:"-","+":"=","~":"`","!":"1","@":"2","#":"3",$:"4","%":"5","^":"6","&":"7","*":"8","(":"9",")":"0"},xn={KeyA:"a",KeyB:"b",KeyC:"c",KeyD:"d",KeyE:"e",KeyF:"f",KeyG:"g",KeyH:"h",KeyI:"i",KeyJ:"j",KeyK:"k",KeyL:"l",KeyM:"m",KeyN:"n",KeyO:"o",KeyP:"p",KeyQ:"q",KeyR:"r",KeyS:"s",KeyT:"t",KeyU:"u",KeyV:"v",KeyW:"w",KeyX:"x",KeyY:"y",KeyZ:"z",Digit0:"0",Digit1:"1",Digit2:"2",Digit3:"3",Digit4:"4",Digit5:"5",Digit6:"6",Digit7:"7",Digit8:"8",Digit9:"9",Comma:",",Period:".",Slash:"/",Semicolon:";",Quote:"'",BracketLeft:"[",BracketRight:"]",Backslash:"\\",Minus:"-",Equal:"=",Backquote:"`"};function xr(e,t){let n;if(e.shiftKey!==t.shift||e.altKey!==t.alt||e.ctrlKey!==t.ctrl||e.metaKey!==t.meta)return!1;if(e.shiftKey){let n=/^Digit([0-9])$/.exec(e.code);if(n)return t.key===n[1]}let r=(n=e.key.toLowerCase(),e.shiftKey&&xt[n]&&(n=xt[n]),n);return r===t.key||!(1===r.length&&/^[\x20-\x7e]$/.test(r))&&xn[e.code]===t.key}function xi(e){if(e.isComposing)return!0;let t=e.target;if(!t)return!1;if(t.isContentEditable)return!0;let n=t.tagName;return"SELECT"===n||("TEXTAREA"===n?!t.readOnly:"INPUT"===n&&!["checkbox","radio","range","button","file","reset","submit","color"].includes(t.type)&&!t.readOnly)}function xo(e){return xs(e).map(e=>{let t=e.includes("!"),n=e.includes("?"),r=e.includes("$"),i=e.replace(/[!?$]/g,"");return t&&n&&r?`cmd+shift+alt+${i},ctrl+shift+alt+${i}`:t&&r?`cmd+shift+${i},ctrl+shift+${i}`:n&&r?`cmd+alt+${i},ctrl+alt+${i}`:n&&t?`shift+alt+${i}`:t?`shift+${i}`:n?`alt+${i}`:r?`cmd+${i},ctrl+${i}`:i}).join(",")}function xs(e){"string"!=typeof e&&(e="");let t=(e=e.replace(/\s/g,"")).split(","),n=t.lastIndexOf("");for(;n>=0;)t[n-1]+=",",t.splice(n,1),n=t.lastIndexOf("");return t}let xa=(0,C.createContext)(!1),xl={1:0,2:1,3:2,4:3,5:4,6:5,7:6,8:7,9:8,0:9};function xd({children:e,orientation:t,sizingParentClassName:n,minItems:r,minSizePx:i,maxItems:o,maxSizePx:s}){let a=(0,h.hGv)(),l=(0,h.LsA)(),d=d$(),c=$(),u=(0,C.useRef)([]),[p,f]=(0,C.useState)(!1),g=(0,C.useRef)(null),[m,y]=(0,C.useState)(null),[x,w]=(0,C.useState)(null),[v,S]=(0,C.useState)(!1),k=(0,h._q_)(()=>{if(!g.current)return;let e="horizontal"===t?"offsetWidth":"offsetHeight",a=d(g.current.children),l=m?d(m.children):null;function d(e){let t=[];for(let n of e)n.classList.contains("tlui-main-toolbar__group")?t.push({type:"group",items:d(n.children),element:n}):n.hasAttribute("data-radix-popper-content-wrapper")||t.push({type:"item",element:n});return t}let c=xc(g.current,n)[e],p=Math.floor((0,h.wwY)(c,[i,s],[r,o],!0)),f=0,y=null,b=!1,v=[],{didShowAnyInOverflow:C}=function e(t,n){n&&(0,h.vAR)(t.length===n.length);let r=!1,i=!1;for(let o=0;o<t.length;o++){let s=t[o],a=n?.[o];if("item"===s.type){let e,t=s.element.getAttribute("data-value")===x;e=x?f<p||t:f<=p;let n=f>=p;r||=e,i||=n,xu(s.element,"data-toolbar-visible",e?"true":"false"),a&&((0,h.vAR)("item"===a.type),xu(a.element,"data-toolbar-visible",n?"true":"false")),n&&"true"===s.element.getAttribute("aria-pressed")&&(y=s.element.getAttribute("data-value")),e&&"BUTTON"===s.element.tagName&&v.push(s.element),!n&&t&&(b=!0),f++}else{let t,n;a?((0,h.vAR)("group"===a.type),n=a,t=e(s.items,n.items)):t=e(s.items,null),r||=t.didShowAnyInMain,i||=t.didShowAnyInOverflow,xu(s.element,"data-toolbar-visible",t.didShowAnyInMain?"true":"false"),n&&xu(n.element,"data-toolbar-visible",t.didShowAnyInOverflow?"true":"false")}}return{didShowAnyInMain:r,didShowAnyInOverflow:i}}(a,l);S(C),y?w(y):b&&w(null),u.current=v});(0,C.useLayoutEffect)(()=>{k()}),(0,C.useLayoutEffect)(()=>{if(!g.current)return;let e=new MutationObserver(k);e.observe(g.current,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["aria-pressed","data-value"]});let t=xc(g.current,n),r=new ResizeObserver(k);return r.observe(t),()=>{e.disconnect(),r.disconnect()}},[k,n]),(0,C.useEffect)(()=>{if(!a.options.enableToolbarKeyboardShortcuts)return;function e(e){if(b9(a)||(0,h.ghB)(!1,a.getContainerDocument())||e.ctrlKey||e.metaKey||e.altKey||e.shiftKey)return;let t=xl[e.key];"number"==typeof t&&((0,h.woC)(e),u.current[t]?.click())}let t=a.getContainerDocument();return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}},[a]);let P="toolbar overflow";return(0,b.jsx)(b.Fragment,{children:(0,b.jsxs)(hY,{orientation:t,className:ik("tlui-main-toolbar__tools",{"tlui-main-toolbar__tools__mobile":d<5}),label:c("tool-panel.title"),children:[(0,b.jsx)("horizontal"===t?aO:aD,{id:`${l}_main`,ref:g,children:(0,b.jsx)(dU,{type:"toolbar",sourceId:"toolbar",children:e})}),v&&(0,b.jsx)(xa.Provider,{value:!0,children:(0,b.jsxs)(fw,{id:P,open:p,onOpenChange:f,children:[(0,b.jsx)(fv,{children:(0,b.jsx)(hG,{title:c("tool-panel.more"),type:"tool",className:"tlui-main-toolbar__overflow","data-testid":"tools.more-button",children:(0,b.jsx)(dm,{icon:"horizontal"===t?"chevron-up":"chevron-right"})})}),(0,b.jsx)(fS,{side:"horizontal"===t?"top":"right",align:"horizontal"===t?"center":"end",children:(0,b.jsx)(hY,{orientation:"grid",className:"tlui-main-toolbar__overflow-content",ref:y,"data-testid":"tools.more-content",label:c("tool-panel.more"),id:`${l}_more`,onClick:()=>{h.NlK.deleteOpenMenu(P,a.contextId),f(!1)},children:(0,b.jsx)(dU,{type:"toolbar-overflow",sourceId:"toolbar",children:e})})})]})})]})})}function xc(e,t){let n=e;for(;n;){if(n.classList.contains(t))return n;n=n.parentElement}throw Error("Could not find parent with class name "+t)}function xu(e,t,n){e.getAttribute(t)!==n&&e.setAttribute(t,n)}function xh({activeToolId:e}){let t=(0,h.hGv)(),n=d$(),r=$(),i=xE(),o=(0,h.hau)("is tool locked",()=>t.getInstanceState().isToolLocked,[t]),s=(0,h.hau)("current tool",()=>t.getCurrentTool(),[t]);if(!e||!s.isLockable)return null;let a=i["toggle-tool-lock"],l=a?.kbd?`${r("action.toggle-tool-lock")} ${uU(a.kbd)}`:r("action.toggle-tool-lock");return(0,b.jsx)(aH,{content:l,children:(0,b.jsx)(aW,{type:"normal","data-testid":"tool-lock",className:ik("tlui-main-toolbar__lock-button",{"tlui-main-toolbar__lock-button__mobile":n<5}),onClick:()=>t.updateInstanceState({isToolLocked:!o}),children:(0,b.jsx)(dm,{icon:o?"lock":"unlock",small:!0})})})}let xp=(0,C.memo)(function({children:e,orientation:t="horizontal",minItems:n=4,minSizePx:r=310,maxItems:i,maxSizePx:o}){let s=(0,h.hGv)(),a=$(),l=d$(),d=uz(),c=(0,h.hau)("current tool id",()=>s.getCurrentToolId(),[s]),u=(0,C.useRef)(null);(0,h.I9L)(u);let{ActionsMenu:p,QuickActions:f}=xS(),g="menu"!==s.options.actionShortcutsLocation&&("toolbar"===s.options.actionShortcutsLocation||l<6);return(0,b.jsx)(aA,{orientation:t,tooltipSide:"horizontal"===t?"top":"right",children:(0,b.jsx)("div",{ref:u,className:ik("tlui-main-toolbar",`tlui-main-toolbar--${t}`),children:(0,b.jsxs)("div",{className:"tlui-main-toolbar__inner",children:[(0,b.jsxs)("div",{className:"tlui-main-toolbar__left",children:[!d&&(0,b.jsxs)("div",{className:"tlui-main-toolbar__extras",children:[g&&(0,b.jsxs)(hY,{orientation:t,className:"tlui-main-toolbar__extras__controls",label:a("actions-menu.title"),children:[f&&(0,b.jsx)(f,{}),p&&(0,b.jsx)(p,{})]}),(0,b.jsx)(xh,{activeToolId:c})]}),(0,b.jsx)(xd,{orientation:t,sizingParentClassName:"tlui-main-toolbar",minItems:n,maxItems:i??8,minSizePx:r,maxSizePx:o??470,children:e??(0,b.jsx)(bA,{})})]}),l<5&&!d&&(0,b.jsx)("div",{className:"tlui-main-toolbar__tools tlui-main-toolbar__mobile-style-panel",children:(0,b.jsx)(bM,{})})]})})})}),xf=(0,h.u4I)(function({videoShapeId:e,onEditAltTextStart:t}){let n=(0,h.hGv)(),r=hn(),i=$(),o=n.getIsReadonly(),s=xE(),a=(0,C.useCallback)(()=>s["video-replace"].onSelect("video-toolbar"),[s]),l=(0,C.useCallback)(()=>s["download-original"].onSelect("video-toolbar"),[s]),d=(0,h.hau)("altText",()=>n.getShape(e).props.altText,[n,e]);return(0,b.jsxs)(b.Fragment,{children:[!o&&(0,b.jsx)(hG,{type:"icon",title:i("tool.replace-media"),onClick:a,"data-testid":"tool.video-replace",children:(0,b.jsx)(dm,{small:!0,icon:"tool-media"})}),(0,b.jsx)(hG,{type:"icon",title:i("action.download-original"),onClick:l,"data-testid":"tool.video-download",children:(0,b.jsx)(dm,{small:!0,icon:"download"})}),(d||!o)&&(0,b.jsx)(hG,{type:"icon",isActive:!!d,title:i("tool.media-alt-text"),"data-testid":"tool.video-alt-text",onClick:()=>{r("alt-text-start",{source:"video-toolbar"}),t()},children:(0,b.jsx)(dm,{small:!0,icon:"alt"})})]})}),xg=(0,h.u4I)(function({children:e}){let t=(0,h.hGv)(),n=(0,h.hau)("videoShape",()=>{let e=t.getOnlySelectedShape();return e&&"video"===e.type?e.id:null},[t]),r=t.isInAny("select.idle","select.pointing_shape"),i=(0,h.hau)("locked",()=>!!n&&t.getShape(n)?.isLocked,[t,n]);return n&&r&&!i?(0,b.jsx)(xm,{videoShapeId:n,children:e},n):null});function xm({children:e,videoShapeId:t}){let n=(0,h.hGv)(),r=$(),[i,o]=(0,C.useState)(!1),s=(0,C.useCallback)(()=>o(!0),[]),a=(0,C.useCallback)(()=>o(!1),[]),l=(0,C.useCallback)(()=>{let e=n.getSelectionScreenBounds();if(e)return new h.azJ(e.x,e.y,e.width,0)},[n]);return(0,b.jsx)(bw,{className:"tlui-media__toolbar tlui-video__toolbar",getSelectionBounds:l,label:r("tool.video-toolbar-title"),children:e||(i?(0,b.jsx)(bS,{shapeId:t,onClose:a,source:"video-toolbar"}):(0,b.jsx)(xf,{videoShapeId:t,onEditAltTextStart:s}))})}function xy(){return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(hQ,{actionId:"zoom-in",noClose:!0}),(0,b.jsx)(hQ,{actionId:"zoom-out",noClose:!0}),(0,b.jsx)(f9,{}),(0,b.jsx)(f7,{}),(0,b.jsx)(ge,{})]})}let xb=(0,C.memo)(function({children:e}){let t=(0,h.NFA)(),[n,r]=hr("zoom menu"),i=B(),o=e??(0,b.jsx)(xy,{});return(0,b.jsxs)(uQ,{dir:i,open:n,onOpenChange:r,modal:!1,children:[(0,b.jsx)(xx,{}),(0,b.jsx)(u1,{container:t,children:(0,b.jsx)(u2,{className:"tlui-menu",side:"top",align:"start",alignOffset:0,sideOffset:8,collisionPadding:4,children:(0,b.jsx)(dU,{type:"menu",sourceId:"zoom-menu",children:o})})})]})}),xx=()=>{let e=(0,h.hGv)(),t=d$(),n=(0,h.hau)("zoom",()=>e.getZoomLevel(),[e]),r=$(),i=B(),o=(0,C.useCallback)(()=>{e.resetZoom(e.getViewportScreenCenter(),{animation:{duration:e.options.animationMediumMs}})},[e]),s=`${Math.floor(100*n)}%`;return(0,b.jsx)(hG,{asChild:!0,type:"icon","aria-label":`${r("navigation-zone.zoom")} \u2014 ${s}`,title:`${r("navigation-zone.zoom")} \u2014 ${s}`,"data-testid":"minimap.zoom-menu-button",className:"tlui-zoom-menu__button",onDoubleClick:o,children:(0,b.jsx)(u0,{dir:i,children:t<4?null:(0,b.jsx)("span",{style:{flexGrow:0,textAlign:"center"},children:s})})})},xw=(0,C.createContext)(null);function xv({overrides:e={},children:t}){let n=(0,h.dSk)(e),r=dW();return(0,b.jsx)(xw.Provider,{value:(0,C.useMemo)(()=>({ContextMenu:gV,ActionsMenu:gW,HelpMenu:null,ZoomMenu:xb,MainMenu:mk,Minimap:m_,StylePanel:bm,PageMenu:mF,NavigationPanel:mM,Toolbar:xp,RichTextToolbar:bI,ImageToolbar:bk,VideoToolbar:xg,KeyboardShortcutsDialog:p8,QuickActions:mH,HelperButtons:ms,DebugPanel:g6,DebugMenu:g5,MenuPanel:me,SharePanel:r?mq:null,CursorChatBubble:r?gY:null,TopPanel:null,Dialogs:mn,Toasts:bx,A11y:xO,FollowingIndicator:g9,PeopleMenu:mK,PeopleMenuAvatar:mV,PeopleMenuItem:mG,PeopleMenuFacePile:mY,UserPresenceEditor:mJ,...n}),[n,r]),children:t})}function xS(){let e=(0,C.useContext)(xw);if(!e)throw Error("useTldrawUiComponents must be used within a TldrawUiComponentsProvider");return e}let xC=C.createContext(null);function xk(e,t){return(t.isShapeOfType(e,"image")||t.isShapeOfType(e,"video"))&&!!e.props.assetId}function xP(e,t){if(0===e.getSelectedShapes().length)return e.getDocumentSettings().name||t}function xT({overrides:e,children:t}){let n=(0,h.frr)(),r=dW(),i=pZ(),o=xS(),s=hn(),a=M(),l=$(),d=i.msg("document.default-name"),c=C.useMemo(()=>{if(!n)return{};function t(){return n.isIn("select")||(n.complete(),n.setCurrentTool("select")),!1}function c(){return n.isIn("select")&&n.getSelectedShapeIds().length>0}function u(e){if(!c()||t())return;n.markHistoryStoppingPoint("resize shapes");let r=n.getSelectedShapeIds();0!==r.length&&n.run(()=>{r.map(e=>n.getShape(e)).filter(Boolean).forEach(t=>{n.resizeShape(t.id,new h.l2P(e,e),{scaleOrigin:n.getSelectionPageBounds()?.center})})})}let p=[{id:"edit-link",label:"action.edit-link",icon:"link",onSelect(e){!c()||t()||(s("edit-link",{source:e}),n.markHistoryStoppingPoint("edit-link"),i.addDialog({component:dT}))}},{id:"insert-embed",label:"action.insert-embed",kbd:"cmd+i,ctrl+i",onSelect(e){s("insert-embed",{source:e}),i.addDialog({component:dF})}},{id:"open-kbd-shortcuts",label:"action.open-kbd-shortcuts",kbd:"cmd+alt+/,ctrl+alt+/",onSelect(e){s("open-kbd-shortcuts",{source:e}),i.addDialog({component:o.KeyboardShortcutsDialog??p8})}},{id:"insert-media",label:"action.insert-media",kbd:"cmd+u,ctrl+u",onSelect(e){s("insert-media",{source:e}),i.insertMedia()}},{id:"undo",label:"action.undo",icon:"undo",kbd:"cmd+z,ctrl+z",onSelect(e){s("undo",{source:e}),n.undo()}},{id:"redo",label:"action.redo",icon:"redo",kbd:"cmd+shift+z,ctrl+shift+z",onSelect(e){s("redo",{source:e}),n.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:!0,onSelect(e){let t=n.getSelectedShapeIds();0===t.length&&(t=Array.from(n.getCurrentPageShapeIds().values())),0!==t.length&&(s("export-as",{format:"svg",source:e}),i.exportAs(t,{format:"svg",name:xP(n,d)}))}},{id:"export-as-png",label:{default:"action.export-as-png",menu:"action.export-as-png.short","context-menu":"action.export-as-png.short"},readonlyOk:!0,onSelect(e){let t=n.getSelectedShapeIds();0===t.length&&(t=Array.from(n.getCurrentPageShapeIds().values())),0!==t.length&&(s("export-as",{format:"png",source:e}),i.exportAs(t,{format:"png",name:xP(n,d)}))}},{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:!0,onSelect(e){let t=n.getSelectedShapeIds();0===t.length&&(t=Array.from(n.getCurrentPageShapeIds().values())),0!==t.length&&(s("export-all-as",{format:"svg",source:e}),i.exportAs(Array.from(n.getCurrentPageShapeIds()),{format:"svg",name:xP(n,d)}))}},{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:!0,onSelect(e){let t=Array.from(n.getCurrentPageShapeIds().values());0!==t.length&&(s("export-all-as",{format:"png",source:e}),i.exportAs(t,{format:"png",name:xP(n,d)}))}},{id:"copy-as-svg",label:{default:"action.copy-as-svg",menu:"action.copy-as-svg.short","context-menu":"action.copy-as-svg.short"},readonlyOk:!0,onSelect(e){let t=n.getSelectedShapeIds();0===t.length&&(t=Array.from(n.getCurrentPageShapeIds().values())),0!==t.length&&(s("copy-as",{format:"svg",source:e}),i.copyAs(t,"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:!0,kbd:"cmd+shift+c,ctrl+shift+c",onSelect(e){let t=n.getSelectedShapeIds();0===t.length&&(t=Array.from(n.getCurrentPageShapeIds().values())),0!==t.length&&(s("copy-as",{format:"png",source:e}),i.copyAs(t,"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:!0,onSelect(e){let t=n.getSelectedShapeIds();0===t.length&&(t=Array.from(n.getCurrentPageShapeIds().values())),0!==t.length&&(s("copy-as",{format:"json",source:e}),i.copyAs(t,"json"))}},{id:"toggle-auto-size",label:"action.toggle-auto-size",onSelect(e){!c()||t()||(s("toggle-auto-size",{source:e}),n.markHistoryStoppingPoint("toggling auto size"),n.run(()=>{let e=n.getSelectedShapes().filter(e=>n.isShapeOfType(e,"text")&&!1===e.props.autoSize);n.updateShapes(e.map(e=>({id:e.id,type:e.type,props:{...e.props,w:8,autoSize:!0}}))),(0,h.IeP)(n,e.map(e=>e.id))}))}},{id:"open-embed-link",label:"action.open-embed-link",readonlyOk:!0,onSelect(e){s("open-embed-link",{source:e});let t=n.getSelectedShapeIds(),r="No embed shapes selected";if(1!==t.length)return void console.error(r);let i=n.getShape(t[0]);i&&n.isShapeOfType(i,"embed")?(0,h.D1x)(i.props.url,"_blank"):console.error(r)}},{id:"select-zoom-tool",label:"action.select-zoom-tool",readonlyOk:!0,kbd:"z, !z",onSelect(e){if(n.inputs.getAccelKey())return;let t=n.getPath();t.endsWith(".idle")&&n.root.getCurrent()?.id!=="zoom"&&(s("zoom-tool",{source:e}),n.setCurrentTool("zoom",{onInteractionEnd:t,maskAs:"zoom"}))}},{id:"convert-to-bookmark",label:"action.convert-to-bookmark",async onSelect(e){if(!c()||t())return;s("convert-to-bookmark",{source:e});let r=n.getSelectedShapes(),i=n.markHistoryStoppingPoint("convert shapes to bookmark"),o=[];for(let e of r){if(!e||!n.isShapeOfType(e,"embed")||!e.props.url)continue;let t=n.getShapePageBounds(e)?.center;t&&(n.deleteShapes([e.id]),o.push(G(n,{url:e.props.url,center:t}).then(e=>{if(!e.ok)throw Error(e.error);return e})))}await Promise.all(o).catch(e=>{n.bailToMark(i),console.error(e)})}},{id:"convert-to-embed",label:"action.convert-to-embed",onSelect(e){!c()||t()||(s("convert-to-embed",{source:e}),n.run(()=>{let e=n.getSelectedShapeIds(),t=(0,h.oE7)(e.map(e=>n.getShape(e))),r=[],o=[];for(let e of t){if(!n.isShapeOfType(e,"bookmark"))continue;let{url:t}=e.props,s=i.getEmbedDefinition(t);if(!s||!s.definition)continue;let{width:a,height:l}=s.definition,d=new h.l2P(e.x,e.y);d.rot(-e.rotation),d.add(new h.l2P(e.props.w/2-a/2,e.props.h/2-l/2)),d.rot(e.rotation);let c={id:(0,h.n6Y)(),type:"embed",x:d.x,y:d.y,rotation:e.rotation,props:{url:t,w:a,h:l}};r.push(c),o.push(e.id)}n.markHistoryStoppingPoint("convert shapes to embed"),n.deleteShapes(o),n.createShapes(r)}))}},{id:"duplicate",kbd:"cmd+d,ctrl+d",label:"action.duplicate",icon:"duplicate",onSelect(e){let r,i;if(!c()||t())return;s("duplicate-shapes",{source:e});let o=n.getInstanceState();if(o.duplicateProps)r=o.duplicateProps.shapeIds,i=o.duplicateProps.offset;else{r=n.getSelectedShapeIds();let e=h.azJ.Common((0,h.oE7)(r.map(e=>n.getShapePageBounds(e))));i=n.getCameraOptions().isLocked?{x:n.options.adjacentShapeMargin,y:n.options.adjacentShapeMargin}:{x:e.width+n.options.adjacentShapeMargin,y:0}}n.markHistoryStoppingPoint("duplicate shapes"),n.duplicateShapes(r,i),o.duplicateProps&&n.updateInstanceState({duplicateProps:{...o.duplicateProps,shapeIds:n.getSelectedShapeIds()}})}},{id:"ungroup",label:"action.ungroup",kbd:"cmd+shift+g,ctrl+shift+g",icon:"ungroup",onSelect(e){!c()||t()||(s("ungroup-shapes",{source:e}),n.markHistoryStoppingPoint("ungroup"),n.ungroupShapes(n.getSelectedShapeIds()))}},{id:"group",label:"action.group",kbd:"cmd+g,ctrl+g",icon:"group",onSelect(e){if(!c()||t())return;s("group-shapes",{source:e});let r=n.getOnlySelectedShape();r&&n.isShapeOfType(r,"group")?(n.markHistoryStoppingPoint("ungroup"),n.ungroupShapes(n.getSelectedShapeIds())):(n.markHistoryStoppingPoint("group"),n.groupShapes(n.getSelectedShapeIds()))}},{id:"frame-selection",label:"action.frame-selection",kbd:"cmd+alt+g",onSelect(e){if(!c()||t())return;let r=n.getSelectedShapes();if(r.length>0&&r.every(e=>n.isShapeOfType(e,"frame"))){s("remove-frame",{source:e}),n.markHistoryStoppingPoint("remove-frame"),iv(n,r.map(e=>e.id));return}let i=n.getSelectedShapeIds();if(i.length<2)return;let o=(0,h.oE7)(i.map(e=>n.getShape(e))),a=n.getSelectionPageBounds();if(!a)return;s("frame-selection",{source:e}),n.markHistoryStoppingPoint("frame-selection");let l=n.findCommonAncestor(o)??n.getCurrentPageId(),d=(0,h.n6Y)(),u=25/n.getZoomLevel();n.run(()=>{n.createShapes([{id:d,type:"frame",parentId:l,x:a.x,y:a.y,props:{w:a.w,h:a.h}}]),n.reparentShapes(i,d),iC(n,d,{padding:u}),n.select(d)})}},{id:"remove-frame",label:"action.remove-frame",onSelect(e){if(!c())return;s("remove-frame",{source:e});let t=n.getSelectedShapes();t.length>0&&t.every(e=>n.isShapeFrameLike(e))&&(n.markHistoryStoppingPoint("remove-frame"),iv(n,t.map(e=>e.id)))}},{id:"fit-frame-to-content",label:"action.fit-frame-to-content",onSelect(e){if(!c())return;s("fit-frame-to-content",{source:e});let t=n.getOnlySelectedShape();t&&n.isShapeFrameLike(t)&&(n.markHistoryStoppingPoint("fit-frame-to-content"),iC(n,t.id))}},{id:"align-left",label:"action.align-left",kbd:"alt+A",icon:"align-left",onSelect(e){!c()||t()||(s("align-shapes",{operation:"left",source:e}),n.markHistoryStoppingPoint("align left"),n.run(()=>{let e=n.getSelectedShapeIds();n.alignShapes(e,"left"),(0,h.IeP)(n,e)}))}},{id:"align-center-horizontal",label:{default:"action.align-center-horizontal","context-menu":"action.align-center-horizontal.short"},kbd:"alt+H",icon:"align-center-horizontal",onSelect(e){!c()||t()||(s("align-shapes",{operation:"center-horizontal",source:e}),n.markHistoryStoppingPoint("align center horizontal"),n.run(()=>{let e=n.getSelectedShapeIds();n.alignShapes(e,"center-horizontal"),(0,h.IeP)(n,e)}))}},{id:"align-right",label:"action.align-right",kbd:"alt+D",icon:"align-right",onSelect(e){!c()||t()||(s("align-shapes",{operation:"right",source:e}),n.markHistoryStoppingPoint("align right"),n.run(()=>{let e=n.getSelectedShapeIds();n.alignShapes(e,"right"),(0,h.IeP)(n,e)}))}},{id:"align-center-vertical",label:{default:"action.align-center-vertical","context-menu":"action.align-center-vertical.short"},kbd:"alt+V",icon:"align-center-vertical",onSelect(e){!c()||t()||(s("align-shapes",{operation:"center-vertical",source:e}),n.markHistoryStoppingPoint("align center vertical"),n.run(()=>{let e=n.getSelectedShapeIds();n.alignShapes(e,"center-vertical"),(0,h.IeP)(n,e)}))}},{id:"align-top",label:"action.align-top",icon:"align-top",kbd:"alt+W",onSelect(e){!c()||t()||(s("align-shapes",{operation:"top",source:e}),n.markHistoryStoppingPoint("align top"),n.run(()=>{let e=n.getSelectedShapeIds();n.alignShapes(e,"top"),(0,h.IeP)(n,e)}))}},{id:"align-bottom",label:"action.align-bottom",icon:"align-bottom",kbd:"alt+S",onSelect(e){!c()||t()||(s("align-shapes",{operation:"bottom",source:e}),n.markHistoryStoppingPoint("align bottom"),n.run(()=>{let e=n.getSelectedShapeIds();n.alignShapes(e,"bottom"),(0,h.IeP)(n,e)}))}},{id:"distribute-horizontal",label:{default:"action.distribute-horizontal","context-menu":"action.distribute-horizontal.short"},icon:"distribute-horizontal",kbd:"alt+shift+h",onSelect(e){!c()||t()||(s("distribute-shapes",{operation:"horizontal",source:e}),n.markHistoryStoppingPoint("distribute horizontal"),n.run(()=>{let e=n.getSelectedShapeIds();n.distributeShapes(e,"horizontal"),(0,h.IeP)(n,e)}))}},{id:"distribute-vertical",label:{default:"action.distribute-vertical","context-menu":"action.distribute-vertical.short"},icon:"distribute-vertical",kbd:"alt+shift+V",onSelect(e){!c()||t()||(s("distribute-shapes",{operation:"vertical",source:e}),n.markHistoryStoppingPoint("distribute vertical"),n.run(()=>{let e=n.getSelectedShapeIds();n.distributeShapes(e,"vertical"),(0,h.IeP)(n,e)}))}},{id:"stretch-horizontal",label:{default:"action.stretch-horizontal","context-menu":"action.stretch-horizontal.short"},icon:"stretch-horizontal",onSelect(e){!c()||t()||(s("stretch-shapes",{operation:"horizontal",source:e}),n.markHistoryStoppingPoint("stretch horizontal"),n.run(()=>{let e=n.getSelectedShapeIds();n.stretchShapes(e,"horizontal"),(0,h.IeP)(n,e)}))}},{id:"stretch-vertical",label:{default:"action.stretch-vertical","context-menu":"action.stretch-vertical.short"},icon:"stretch-vertical",onSelect(e){!c()||t()||(s("stretch-shapes",{operation:"vertical",source:e}),n.markHistoryStoppingPoint("stretch vertical"),n.run(()=>{let e=n.getSelectedShapeIds();n.stretchShapes(e,"vertical"),(0,h.IeP)(n,e)}))}},{id:"flip-horizontal",label:{default:"action.flip-horizontal","context-menu":"action.flip-horizontal.short"},kbd:"shift+h",onSelect(e){!c()||t()||(s("flip-shapes",{operation:"horizontal",source:e}),n.markHistoryStoppingPoint("flip horizontal"),n.run(()=>{let e=n.getSelectedShapeIds();n.flipShapes(e,"horizontal"),(0,h.IeP)(n,e)}))}},{id:"flip-vertical",label:{default:"action.flip-vertical","context-menu":"action.flip-vertical.short"},kbd:"shift+v",onSelect(e){!c()||t()||(s("flip-shapes",{operation:"vertical",source:e}),n.markHistoryStoppingPoint("flip vertical"),n.run(()=>{let e=n.getSelectedShapeIds();n.flipShapes(e,"vertical"),(0,h.IeP)(n,e)}))}},{id:"pack",label:"action.pack",icon:"pack",onSelect(e){!c()||t()||(s("pack-shapes",{source:e}),n.markHistoryStoppingPoint("pack"),n.run(()=>{let e=n.getSelectedShapeIds();n.packShapes(e,n.options.adjacentShapeMargin),(0,h.IeP)(n,e)}))}},{id:"stack-vertical",label:{default:"action.stack-vertical","context-menu":"action.stack-vertical.short"},icon:"stack-vertical",onSelect(e){!c()||t()||(s("stack-shapes",{operation:"vertical",source:e}),n.markHistoryStoppingPoint("stack-vertical"),n.run(()=>{let e=n.getSelectedShapeIds();n.stackShapes(e,"vertical",n.options.adjacentShapeMargin),(0,h.IeP)(n,e)}))}},{id:"stack-horizontal",label:{default:"action.stack-horizontal","context-menu":"action.stack-horizontal.short"},icon:"stack-horizontal",onSelect(e){!c()||t()||(s("stack-shapes",{operation:"horizontal",source:e}),n.markHistoryStoppingPoint("stack-horizontal"),n.run(()=>{let e=n.getSelectedShapeIds();n.stackShapes(e,"horizontal",n.options.adjacentShapeMargin),(0,h.IeP)(n,e)}))}},{id:"bring-to-front",label:"action.bring-to-front",kbd:"]",icon:"bring-to-front",onSelect(e){!c()||t()||(s("reorder-shapes",{operation:"toFront",source:e}),n.markHistoryStoppingPoint("bring to front"),n.bringToFront(n.getSelectedShapeIds()))}},{id:"bring-forward",label:"action.bring-forward",icon:"bring-forward",kbd:"alt+]",onSelect(e){!c()||t()||(s("reorder-shapes",{operation:"forward",source:e}),n.markHistoryStoppingPoint("bring forward"),n.bringForward(n.getSelectedShapeIds()))}},{id:"send-backward",label:"action.send-backward",icon:"send-backward",kbd:"alt+[",onSelect(e){!c()||t()||(s("reorder-shapes",{operation:"backward",source:e}),n.markHistoryStoppingPoint("send backward"),n.sendBackward(n.getSelectedShapeIds()))}},{id:"send-to-back",label:"action.send-to-back",icon:"send-to-back",kbd:"[",onSelect(e){!c()||t()||(s("reorder-shapes",{operation:"toBack",source:e}),n.markHistoryStoppingPoint("send to back"),n.sendToBack(n.getSelectedShapeIds()))}},{id:"cut",label:"action.cut",kbd:"cmd+x,ctrl+x",onSelect(e){!c()||t()||(n.markHistoryStoppingPoint("cut"),i.cut(e))}},{id:"copy",label:"action.copy",kbd:"cmd+c,ctrl+c",readonlyOk:!0,onSelect(e){!c()||t()||i.copy(e)}},{id:"paste",label:"action.paste",kbd:"cmd+v,ctrl+v",onSelect(e){navigator.clipboard?.read().then(t=>{i.paste(t,e,"context-menu"===e?n.inputs.getCurrentPagePoint():void 0)}).catch(()=>{i.addToast({title:i.msg("action.paste-error-title"),description:i.msg("action.paste-error-description"),severity:"error"})})}},{id:"paste-at-cursor",label:"action.paste",kbd:"$?v",onSelect(e){let t=n.user.getIsPasteAtCursorMode()?void 0:n.inputs.getCurrentPagePoint();navigator.clipboard?.read().then(n=>{i.paste(n,e,t)}).catch(()=>{i.addToast({title:i.msg("action.paste-error-title"),description:i.msg("action.paste-error-description"),severity:"error"})})}},{id:"paste-plain-text-at-cursor",label:"action.paste",kbd:"$!?v",onSelect(){let e=n.user.getIsPasteAtCursorMode()?n.getViewportPageBounds().center:n.inputs.getCurrentPagePoint();navigator.clipboard?.readText().then(t=>{t?.trim()&&(n.markHistoryStoppingPoint("paste"),id(n,{text:t,point:e}))}).catch(()=>{i.addToast({title:i.msg("action.paste-error-title"),description:i.msg("action.paste-error-description"),severity:"error"})})}},{id:"select-all",label:"action.select-all",kbd:"cmd+a,ctrl+a",readonlyOk:!0,onSelect(e){n.run(()=>{t()||(s("select-all-shapes",{source:e}),n.markHistoryStoppingPoint("select all kbd"),n.selectAll())})}},{id:"select-none",label:"action.select-none",readonlyOk:!0,onSelect(e){!c()||t()||(s("select-none-shapes",{source:e}),n.markHistoryStoppingPoint("select none"),n.selectNone())}},{id:"delete",label:"action.delete",kbd:"⌫,del",icon:"trash",onSelect(e){!c()||t()||(s("delete-shapes",{source:e}),n.markHistoryStoppingPoint("delete"),n.deleteShapes(n.getSelectedShapeIds()))}},{id:"rotate-cw",label:"action.rotate-cw",icon:"rotate-cw",kbd:"shift+.,shift+alt+.",onSelect(e){if(!c()||t())return;let r=n.inputs.getAltKey();s("rotate-cw",{source:e,fine:r}),n.markHistoryStoppingPoint("rotate-cw"),n.run(()=>{let e=h.sKG/(r?96:6),t=n.getSelectionRotation()%e,i=(0,h.YY0)(t,0)||(0,h.YY0)(t,e),o=n.getSelectedShapeIds();n.rotateShapesBy(o,e-(i?0:t)),(0,h.IeP)(n,o)})}},{id:"rotate-ccw",label:"action.rotate-ccw",icon:"rotate-ccw",kbd:"shift+,,shift+alt+,",onSelect(e){if(!c()||t())return;let r=n.inputs.getAltKey();s("rotate-ccw",{source:e,fine:r}),n.markHistoryStoppingPoint("rotate-ccw"),n.run(()=>{let e=h.sKG/(r?96:6),t=n.getSelectionRotation()%e,i=(0,h.YY0)(t,0),o=n.getSelectedShapeIds();n.rotateShapesBy(o,i?-e:-t),(0,h.IeP)(n,o)})}},{id:"zoom-in",label:"action.zoom-in",kbd:"cmd+=,ctrl+=,=",readonlyOk:!0,onSelect(e){s("zoom-in",{source:e,towardsCursor:!1}),n.zoomIn(void 0,{animation:{duration:n.options.animationMediumMs}})}},{id:"zoom-in-on-cursor",label:"action.zoom-in",kbd:"shift+cmd+=,shift+ctrl+=,shift+=",readonlyOk:!0,onSelect(e){s("zoom-in",{source:e,towardsCursor:!0}),n.zoomIn(n.inputs.getCurrentScreenPoint(),{animation:{duration:n.options.animationMediumMs}})}},{id:"zoom-out",label:"action.zoom-out",kbd:"cmd+-,ctrl+-,-",readonlyOk:!0,onSelect(e){s("zoom-out",{source:e,towardsCursor:!1}),n.zoomOut(void 0,{animation:{duration:n.options.animationMediumMs}})}},{id:"zoom-out-on-cursor",label:"action.zoom-out",kbd:"shift+cmd+-,shift+ctrl+-,shift+-",readonlyOk:!0,onSelect(e){s("zoom-out",{source:e,towardsCursor:!0}),n.zoomOut(n.inputs.getCurrentScreenPoint(),{animation:{duration:n.options.animationMediumMs}})}},{id:"zoom-to-100",label:"action.zoom-to-100",icon:"reset-zoom",kbd:"shift+0",readonlyOk:!0,onSelect(e){s("reset-zoom",{source:e}),n.resetZoom(void 0,{animation:{duration:n.options.animationMediumMs}})}},{id:"zoom-to-fit",label:"action.zoom-to-fit",kbd:"shift+1",readonlyOk:!0,onSelect(e){s("zoom-to-fit",{source:e}),n.zoomToFit({animation:{duration:n.options.animationMediumMs}})}},{id:"zoom-to-selection",label:"action.zoom-to-selection",kbd:"shift+2",readonlyOk:!0,onSelect(e){!c()||t()||(s("zoom-to-selection",{source:e}),n.zoomToSelection({animation:{duration:n.options.animationMediumMs}}))}},{id:"toggle-snap-mode",label:{default:"action.toggle-snap-mode",menu:"action.toggle-snap-mode.menu"},onSelect(e){s("toggle-snap-mode",{source:e}),n.user.updateUserPreferences({isSnapMode:!n.user.getIsSnapMode()})},checkbox:!0},{id:"toggle-dark-mode",label:{default:"action.toggle-dark-mode",menu:"action.toggle-dark-mode.menu"},kbd:"cmd+/,ctrl+/",readonlyOk:!0,onSelect(e){let t=n.user.getIsDarkMode()?"light":"dark";s("color-scheme",{source:e,value:t}),n.user.updateUserPreferences({colorScheme:t})},checkbox:!0},{id:"toggle-wrap-mode",label:{default:"action.toggle-wrap-mode",menu:"action.toggle-wrap-mode.menu"},readonlyOk:!0,onSelect(e){s("toggle-wrap-mode",{source:e}),n.user.updateUserPreferences({isWrapMode:!n.user.getIsWrapMode()})},checkbox:!0},{id:"toggle-dynamic-size-mode",label:{default:"action.toggle-dynamic-size-mode",menu:"action.toggle-dynamic-size-mode.menu"},readonlyOk:!1,onSelect(e){s("toggle-dynamic-size-mode",{source:e}),n.user.updateUserPreferences({isDynamicSizeMode:!n.user.getIsDynamicResizeMode()})},checkbox:!0},{id:"toggle-paste-at-cursor",label:{default:"action.toggle-paste-at-cursor",menu:"action.toggle-paste-at-cursor.menu"},readonlyOk:!1,onSelect(e){s("toggle-paste-at-cursor",{source:e}),n.user.updateUserPreferences({isPasteAtCursorMode:!n.user.getIsPasteAtCursorMode()})},checkbox:!0},{id:"toggle-reduce-motion",label:{default:"action.toggle-reduce-motion",menu:"action.toggle-reduce-motion.menu"},readonlyOk:!0,onSelect(e){s("toggle-reduce-motion",{source:e}),n.user.updateUserPreferences({animationSpeed:+(0===n.user.getAnimationSpeed())})},checkbox:!0},{id:"toggle-keyboard-shortcuts",label:{default:"action.toggle-keyboard-shortcuts",menu:"action.toggle-keyboard-shortcuts.menu"},readonlyOk:!0,onSelect(e){s("toggle-keyboard-shortcuts",{source:e}),n.user.updateUserPreferences({areKeyboardShortcutsEnabled:!n.user.getAreKeyboardShortcutsEnabled()})},checkbox:!0},{id:"enhanced-a11y-mode",label:{default:"action.enhanced-a11y-mode",menu:"action.enhanced-a11y-mode.menu"},readonlyOk:!0,onSelect(e){s("enhanced-a11y-mode",{source:e}),n.user.updateUserPreferences({enhancedA11yMode:!n.user.getEnhancedA11yMode()})},checkbox:!0},{id:"toggle-edge-scrolling",label:{default:"action.toggle-edge-scrolling",menu:"action.toggle-edge-scrolling.menu"},readonlyOk:!0,onSelect(e){s("toggle-edge-scrolling",{source:e}),n.user.updateUserPreferences({edgeScrollSpeed:+(0===n.user.getEdgeScrollSpeed())})},checkbox:!0},{id:"toggle-invert-zoom",label:{default:"action.toggle-invert-zoom",menu:"action.toggle-invert-zoom.menu"},readonlyOk:!0,onSelect(e){s("toggle-invert-zoom",{source:e}),n.user.updateUserPreferences({isZoomDirectionInverted:!n.user.getIsZoomDirectionInverted()})},checkbox:!0},{id:"toggle-transparent",label:{default:"action.toggle-transparent",menu:"action.toggle-transparent.menu","context-menu":"action.toggle-transparent.context-menu"},readonlyOk:!0,onSelect(e){s("toggle-transparent",{source:e}),n.updateInstanceState({exportBackground:!n.getInstanceState().exportBackground})},checkbox:!0},{id:"toggle-tool-lock",label:{default:"action.toggle-tool-lock",menu:"action.toggle-tool-lock.menu"},kbd:"q",onSelect(e){s("toggle-tool-lock",{source:e}),n.updateInstanceState({isToolLocked:!n.getInstanceState().isToolLocked})},checkbox:!0},{id:"unlock-all",label:"action.unlock-all",onSelect(e){s("unlock-all",{source:e});let t=[];for(let e of n.getCurrentPageShapes())e.isLocked&&t.push({id:e.id,type:e.type,isLocked:!1});t.length>0&&n.updateShapes(t)}},{id:"toggle-focus-mode",label:{default:"action.toggle-focus-mode",menu:"action.toggle-focus-mode.menu"},readonlyOk:!0,kbd:"cmd+.,ctrl+.",checkbox:!0,onSelect(e){n.timers.requestAnimationFrame(()=>{n.run(()=>{s("toggle-focus-mode",{source:e}),i.clearDialogs(),i.clearToasts(),n.updateInstanceState({isFocusMode:!n.getInstanceState().isFocusMode})})})}},{id:"toggle-grid",label:{default:"action.toggle-grid",menu:"action.toggle-grid.menu"},readonlyOk:!0,kbd:"cmd+',ctrl+'",onSelect(e){s("toggle-grid-mode",{source:e}),n.updateInstanceState({isGridMode:!n.getInstanceState().isGridMode})},checkbox:!0},{id:"toggle-debug-mode",label:{default:"action.toggle-debug-mode",menu:"action.toggle-debug-mode.menu"},readonlyOk:!0,onSelect(e){s("toggle-debug-mode",{source:e}),n.updateInstanceState({isDebugMode:!n.getInstanceState().isDebugMode})},checkbox:!0},{id:"print",label:"action.print",kbd:"cmd+p,ctrl+p",readonlyOk:!0,onSelect(e){s("print",{source:e}),i.printSelectionOrPages()}},{id:"exit-pen-mode",label:"action.exit-pen-mode",icon:"cross-2",readonlyOk:!0,onSelect(e){s("exit-pen-mode",{source:e}),n.updateInstanceState({isPenMode:!1})}},{id:"stop-following",label:"action.stop-following",icon:"cross-2",readonlyOk:!0,onSelect(e){s("stop-following",{source:e}),n.stopFollowingUser()}},{id:"back-to-content",label:"action.back-to-content",icon:"arrow-left",readonlyOk:!0,onSelect(e){s("zoom-to-content",{source:e});let t=n.getSelectionPageBounds()??n.getCurrentPageBounds();t&&n.zoomToBounds(t,{targetZoom:Math.min(1,n.getZoomLevel()),animation:{duration:220}})}},{id:"toggle-lock",label:"action.toggle-lock",kbd:"shift+l",onSelect(e){c()&&(n.markHistoryStoppingPoint("locking"),s("toggle-lock",{source:e}),n.toggleLock(n.getSelectedShapeIds()))}},{id:"move-to-new-page",label:"context.pages.new-page",onSelect(e){let t=h.tvM.createId(),r=n.getSelectedShapeIds();n.run(()=>{n.markHistoryStoppingPoint("move_shapes_to_page"),n.createPage({name:i.msg("page-menu.new-page-initial-name"),id:t}),n.moveShapesToPage(r,t)}),s("move-to-new-page",{source:e})}},{id:"select-white-color",label:"color-style.white",kbd:"alt+t",onSelect(e){let t=h.ive;n.run(()=>{n.updateInstanceState({isChangingStyle:!0}),n.markHistoryStoppingPoint("change-color"),n.isIn("select")&&n.setStyleForSelectedShapes(t,"white"),n.setStyleForNextShapes(t,"white")}),s("set-style",{source:e,id:t.id,value:"white"})}},{id:"select-fill-fill",label:"fill-style.fill",kbd:"alt+f",onSelect(e){let t=h.u8f;n.run(()=>{n.updateInstanceState({isChangingStyle:!0}),n.markHistoryStoppingPoint("change-fill"),n.isIn("select")&&n.setStyleForSelectedShapes(t,"fill"),n.setStyleForNextShapes(t,"fill")}),s("set-style",{source:e,id:t.id,value:"fill"})}},{id:"select-fill-lined-fill",label:"fill-style.lined-fill",kbd:"alt+shift+f",onSelect(e){let t=h.u8f;n.run(()=>{n.updateInstanceState({isChangingStyle:!0}),n.markHistoryStoppingPoint("change-fill"),n.isIn("select")&&n.setStyleForSelectedShapes(t,"lined-fill"),n.setStyleForNextShapes(t,"lined-fill")}),s("set-style",{source:e,id:t.id,value:"lined-fill"})}},{id:"flatten-to-image",label:"action.flatten-to-image",kbd:"shift+f",onSelect:async e=>{let t=n.getSelectedShapeIds();if(0===t.length)return;n.markHistoryStoppingPoint("flattening to image"),s("flatten-to-image",{source:e});let r=await p9(n,t,n.options.flattenImageBoundsExpand);r?.length&&n.setSelectedShapes(r)}},{id:"select-geo-tool",kbd:"g",onSelect:async e=>{s("select-tool",{source:e,id:"geo-previous"}),n.setCurrentTool("geo")}},{id:"change-page-prev",kbd:"alt+left,alt+up",readonlyOk:!0,onSelect:async e=>{let t=n.getPages(),r=t.findIndex(e=>e.id===n.getCurrentPageId());r<1||(s("change-page",{source:e,direction:"prev"}),n.setCurrentPage(t[r-1].id))}},{id:"change-page-next",kbd:"alt+right,alt+down",readonlyOk:!0,onSelect:async e=>{let t=n.getPages(),r=t.findIndex(e=>e.id===n.getCurrentPageId());if(-1===r||r>=t.length-1){if(n.getCurrentPageShapes().length<=0||n.getIsReadonly())return;s("new-page",{source:e}),n.run(()=>{n.markHistoryStoppingPoint("creating page");let e=h.tvM.createId();n.createPage({name:i.msg("page-menu.new-page-initial-name"),id:e}),n.setCurrentPage(e)});return}n.setCurrentPage(t[r+1].id),s("change-page",{source:e,direction:"next"})}},{id:"adjust-shape-styles",label:"a11y.adjust-shape-styles",kbd:"cmd+Enter,ctrl+Enter",isRequiredA11yAction:!0,onSelect:async e=>{if(!c())return;let t=n.getOnlySelectedShape();if(t&&(n.isShapeOfType(t,"image")||n.isShapeOfType(t,"video"))){let e=n.getContainer().querySelector(".tlui-contextual-toolbar button:first-child");e?.focus();return}let r=n.getContainer().querySelector(".tlui-style-panel button");r?.focus(),s("adjust-shape-styles",{source:e})}},{id:"a11y-open-context-menu",kbd:"cmd+shift+Enter,ctrl+shift+Enter",isRequiredA11yAction:!0,readonlyOk:!0,onSelect:async e=>{if(!c())return;let t=n.getSelectionPageBounds();if(!t)return;let r=t.x+t.width/2,i=t.y+t.height/2,o=n.pageToScreen(new h.l2P(r,i));n.getContainer().querySelector(".tl-canvas")?.dispatchEvent(new PointerEvent("contextmenu",{clientX:o.x,clientY:o.y,bubbles:!0})),s("open-context-menu",{source:e})}},{id:"enlarge-shapes",label:"a11y.enlarge-shape",kbd:"cmd+alt+shift+=,ctrl+alt+shift+=",onSelect:async e=>{c()&&(u(1.1),s("enlarge-shapes",{source:e}))}},{id:"shrink-shapes",label:"a11y.shrink-shape",kbd:"cmd+alt+shift+-,ctrl+alt+shift+-",onSelect:async e=>{c()&&(u(1/1.1),s("shrink-shapes",{source:e}))}},{id:"a11y-repeat-shape-announce",kbd:"alt+r",label:"a11y.repeat-shape",isRequiredA11yAction:!0,readonlyOk:!0,onSelect:async e=>{let t=n.getSelectedShapeIds();if(!t.length)return;let r=xD({editor:n,selectedShapeIds:t,msg:l});r&&(a.announce({msg:""}),n.timers.requestAnimationFrame(()=>{a.announce({msg:r})}),s("a11y-repeat-shape-announce",{source:e}))}},{id:"image-replace",label:"tool.replace-media",icon:"arrow-cycle",readonlyOk:!1,onSelect:async e=>{s("image-replace",{source:e}),i.replaceImage()}},{id:"video-replace",label:"tool.replace-media",icon:"arrow-cycle",readonlyOk:!1,onSelect:async e=>{s("video-replace",{source:e}),i.replaceVideo()}},{id:"download-original",label:"action.download-original",readonlyOk:!0,onSelect:async e=>{let t=n.getSelectedShapes();if(0===t.length)return;let r=t.filter(e=>xk(e,n));if(0!==r.length){for(let e of r){let t=n.getAsset(e.props.assetId);if(!t||!t.props.src)continue;let r=await n.resolveAssetUrl(t.id,{shouldResolveToOriginal:!0});if(!r)continue;let i="video"!==t.type&&"image"!==t.type||t.props.src.startsWith("asset:")?"download":t.props.name;try{let e=await (0,h.hdJ)(r);if(!e.ok)throw Error(`Failed to fetch asset: ${e.status}`);let t=await e.blob();iw(new File([t],i,{type:t.type}),n.getContainerDocument())}catch{(0,h.D1x)(r,"_blank")}}s("download-original",{source:e})}}},{id:"copy-hovered-styles",label:"action.copy-hovered-styles",kbd:"shift+q",async onSelect(e){let t=n.getShapeAtPoint(n.inputs.getCurrentPagePoint(),{hitInside:!1,hitLabels:!1,hitLocked:n.options.selectLockedShapes,margin:n.getHitTestMargin()}),r=n.getPath();t&&r.endsWith(".idle")&&(n.run(()=>{for(let e of n.styleProps[t.type].keys()){let r=n.getShapeStyleIfExists(t,e);void 0!==r&&e!==h.tg8&&n.setStyleForNextShapes(e,r)}}),s("copy-hovered-styles",{source:e}))}}];r&&p.push({id:"open-cursor-chat",label:"action.open-cursor-chat",readonlyOk:!0,kbd:"/",onSelect(e){s("open-cursor-chat",{source:e}),n.getInstanceState().isCoarsePointer||n.timers.requestAnimationFrame(()=>{n.updateInstanceState({isChatting:!0})})}});let f=Object.fromEntries(p.map(e=>[e.id,e]));return e?e(n,f,i):f},[i,n,s,e,d,r,l,a,o]);return(0,b.jsx)(xC.Provider,{value:c,children:t})}function xE(){let e=C.useContext(xC);if(!e)throw Error("useTools must be used within a ToolProvider");return e}function xI(e,t){return e?"string"==typeof e?e:t?e[t]??e.default:void 0:void 0}let x_=new h.bZT("backToContentSuppressed",()=>!1),xM=new h.bZT("backToContentSuppressTimeout",()=>null);function xA(){let e=(0,h.hGv)(),t=xE(),[n,r]=(0,C.useState)(!1),i=(0,C.useRef)(!1),o=(0,C.useRef)(null);return((0,h.lXS)("toggle showback to content",()=>{let t=!1;if(!x_.get(e)){let n=e.getCurrentPageShapeIds();n.size&&(t=n.size===e.getNotVisibleShapes().size)}if(t===i.current){null!==o.current&&(clearTimeout(o.current),o.current=null);return}t?null===o.current&&(o.current=e.timers.setTimeout(()=>{o.current=null,i.current=!0,r(!0)},1e3)):(null!==o.current&&(clearTimeout(o.current),o.current=null),i.current=!1,r(!1))},[e]),(0,C.useEffect)(()=>()=>{null!==o.current&&(clearTimeout(o.current),o.current=null)},[]),n)?(0,b.jsx)(hQ,{actionId:"back-to-content",onSelect:()=>{t["back-to-content"].onSelect("helper-buttons"),r(!1)}}):null}function xj(){let e=(0,h.hGv)(),t=$(),n=(0,C.useRef)(null),r=(0,C.useCallback)(t=>{e.markEventAsHandled(t),n.current?.blur();let r=e.getCurrentPageShapesInReadingOrder();if(r.length){var i;let t,n;e.setSelectedShapes([r[0].id]),i=e.options.animationMediumMs,x_.set(e,!0),null!==(t=xM.get(e))&&clearTimeout(t),n=e.timers.setTimeout(()=>{x_.set(e,!1),xM.set(e,null)},i),xM.set(e,n),e.zoomToSelectionIfOffscreen(256,{animation:{duration:e.options.animationMediumMs},inset:0}),e.timers.setTimeout(()=>e.getContainer().focus(),100)}},[e]);return(0,b.jsx)(aW,{ref:n,type:"low",tabIndex:0,className:"tl-skip-to-main-content",onClick:r,children:t("a11y.skip-to-main-content")})}let xO=(0,C.memo)(function(){let e,t,n,r,i=M(),o=$(),s=(0,h.hau)("a11y-msg",()=>i.currentMsg.get(),[]);return xL(s.msg),e=(0,h.frr)(),t=M(),n=$(),r=(0,C.useRef)([]),(0,h.a1r)("announce selection",()=>{if(e&&e.isIn("select.idle")){let i=e.getSelectedShapeIds();i!==r.current&&(r.current=i,(0,h.PmD)(()=>{let r=xD({editor:e,selectedShapeIds:i,msg:n});r&&t.announce({msg:r})}))}},[e,t,n]),s.msg&&(0,b.jsx)("div",{"aria-label":o("a11y.status"),"aria-live":s.priority||"assertive",role:"status","aria-hidden":"false",style:{position:"absolute",top:"-10000px",left:"-10000px"},children:s.msg})});function xD(e){let{editor:t,selectedShapeIds:n,msg:r}=e,i="",o=n.length;if(o>1)i=r("a11y.multiple-shapes").replace("{num}",o.toString());else if(1===o){let e=n[0],o=t.getShape(e);if(!o)return"";let s=t.getShapeUtil(o.type),a=["image","video"].includes(o.type),l="";l=r("geo"===o.type?`geo-style.${o.props.geo}`:a?`a11y.shape-${o.type}`:`tool.${o.type}`);let d=t.getCurrentPageShapesInReadingOrder(),c=(d.findIndex(t=>t.id===e)+1).toString(),u=d.length.toString(),h=r("a11y.shape-index").replace("{num}",c).replace("{total}",u),p=s.getAriaDescriptor(o)||s.getText(o)||"";i=(p?`${p}, `:"")+`${l}. ${h}`}return i}let xL=e=>{let t=(0,h.NFA)();(0,C.useEffect)(()=>{if(h.bGJ.a11y.get()){let n=e=>{console.debug(`%ca11y%c: ${e}`,"color: white; background: #40C057; padding: 2px;border-radius: 3px;","font-weight: normal")},r=t.ownerDocument,i=e=>{let t=r.activeElement;if("Tab"===e.key&&t&&t!==r.body&&!t.classList.contains("tl-container")){let e=t.getAttribute("aria-label")||t.getAttribute("title")||t.textContent;e&&n(e)}};return e&&n(e),r.addEventListener("keyup",i),()=>r.removeEventListener("keyup",i)}},[t,e])};class xF extends h.$mH{static type="bookmark";static props=h.VtT;static migrations=h.Esp;getDefaultProps(){return{title:"",description:"",image:"",favicon:"",src:null}}}class xR extends h.$mH{static type="image";static props=h._8g;static migrations=h.h1I;options={maxDimension:5e3,supportedMimeTypes:null};getDefaultProps(){return{w:0,h:0,name:"",isAnimated:!1,mimeType:null,src:null}}getSupportedMimeTypes(){return this.options.supportedMimeTypes??h.RBp}async getAssetFromFile(e,t){let n=this.editor.getContainerDocument(),r=await h.K4L.getImageSize(e,n),i=await h.K4L.isAnimated(e),o="pixelRatio"in r&&1!==r.pixelRatio?r.pixelRatio:void 0,s={id:t,type:"image",typeName:"asset",props:{name:e.name,src:"",w:r.w,h:r.h,fileSize:e.size,mimeType:e.type,isAnimated:i,...o?{pixelRatio:o}:void 0},meta:{}},a=this.options.maxDimension;if(a&&isFinite(a)){var l;let t,n,r={w:s.props.w,h:s.props.h},i=(l={w:a,h:a},t=r.w/l.w,n=r.h/l.h,t<=1&&n<=1?r:t>n?{w:r.w/t,h:r.h/t}:{w:r.w/n,h:r.h/n});r!==i&&h.K4L.isStaticImageType(e.type)&&(s.props.w=i.w,s.props.h=i.h)}return s}}class xz extends h.$mH{static type="video";static props=h.EOG;static migrations=h.jhO;options={supportedMimeTypes:null};getDefaultProps(){return{w:0,h:0,name:"",isAnimated:!0,mimeType:null,src:null}}getSupportedMimeTypes(){return this.options.supportedMimeTypes??h.qSO}async getAssetFromFile(e,t){let n=e.type;"video/quicktime"===n&&(n="video/mp4");let r=this.editor.getContainerDocument(),i=await h.K4L.getVideoSize(e,r);return{id:t,type:"video",typeName:"asset",props:{name:e.name,src:"",w:i.w,h:i.h,fileSize:e.size,mimeType:n,isAnimated:!0},meta:{}}}}let xN=new WeakMap;function x$(e,t,n){let r=e.editor.getCurrentTheme(),i=n??e.editor.getColorMode(),o=xN.get(t);if(o&&o.theme===r&&o.colorMode===i)return o.values;let s={...e.options.getDefaultDisplayValues(e.editor,t,r,i),...e.options.getCustomDisplayValues(e.editor,t,r,i)};return xN.set(t,{theme:r,colorMode:i,values:s}),s}function xB(e,t,n,r){let{arrowheadStart:i,arrowheadEnd:o}=t.props,s=fI(e,t,n),a=s.start.clone(),l=s.end.clone(),d=h.l2P.Med(a,l);if(h.l2P.Equals(a,l))return{bindings:n,type:"straight",start:{handle:a,point:a,arrowhead:t.props.arrowheadStart},end:{handle:l,point:l,arrowhead:t.props.arrowheadEnd},middle:d,isValid:!1,length:0};let c=h.l2P.Sub(l,a).uni(),u=fk(e,t,"start"),p=fk(e,t,"end"),f=e.getShapePageTransform(t);xH(l,s.start,f,p),xH(a,s.end,f,u),fj(e,l,s.end,f,p),fj(e,a,s.start,f,u);let g=0,m=0,y=0,b=0,x=10*t.props.scale,w=e.getCurrentTheme(),v=r??w.strokeWidth*ei[t.props.size],S=u&&p&&u.shape===p.shape,C=u&&p?fA(e,u.shape.id,p.shape.id):"safe";"safe"===C&&u&&p&&!S&&!u.isExact&&!p.isExact&&(p.didIntersect&&!u.didIntersect?u.isClosed&&a.setTo(l.clone().add(c.clone().mul(10*t.props.scale))):!p.didIntersect&&p.isClosed&&l.setTo(a.clone().sub(c.clone().mul(10*t.props.scale))));let k=h.l2P.Sub(l,a),P=h.l2P.Len(k)?k.uni():h.l2P.From(k),T=!h.l2P.Equals(P,c);S||("start-contains-end"!==C&&u&&"none"!==i&&!u.isExact&&(g=(10+(y=v/2+("size"in u.shape.props?w.strokeWidth*ei[u.shape.props.size]/2:0)))*t.props.scale,x+=y*t.props.scale),"end-contains-start"!==C&&p&&"none"!==o&&!p.isExact&&(m=(10+(b=v/2+("size"in p.shape.props?w.strokeWidth*ei[p.shape.props.size]/2:0)))*t.props.scale,x+=b*t.props.scale));let E=a.clone().add(P.clone().mul(g*(T?-1:1))),I=l.clone().sub(P.clone().mul(m*(T?-1:1)));h.l2P.DistMin(E,I,x)&&(0!==g&&0!==m?(g*=-1.5,m*=-1.5):0!==g?g*=-1:0!==m&&(m*=-1)),a.add(P.clone().mul(g*(T?-1:1))),l.sub(P.clone().mul(m*(T?-1:1))),T?(u&&p&&l.setTo(h.l2P.Add(a,P.clone().mul(-10*t.props.scale))),d.setTo(h.l2P.Med(s.start,s.end))):d.setTo(h.l2P.Med(a,l));let _=h.l2P.Dist(a,l);return{bindings:n,type:"straight",start:{handle:s.start,point:a,arrowhead:t.props.arrowheadStart},end:{handle:s.end,point:l,arrowhead:t.props.arrowheadEnd},middle:d,isValid:_>0,length:_}}function xH(e,t,n,r){let i;if(void 0===r||r.isExact)return;let o=h.V8r.applyToPoint(n,t),s=h.V8r.applyToPoint(n,e),a=h.V8r.applyToPoint(h.V8r.Inverse(r.transform),o),l=h.V8r.applyToPoint(h.V8r.Inverse(r.transform),s),d=Array.from(r.geometry.intersectLineSegment(a,l,{includeLabels:!1,includeInternal:!1}));if(d.length&&(i=d.sort((e,t)=>h.l2P.Dist2(e,a)-h.l2P.Dist2(t,a))[0]??(r.isClosed?void 0:l)),void 0===i&&(i=r.geometry.nearestPoint(l,{includeLabels:!1,includeInternal:!1}),!h.l2P.DistMin(i,l,1)))return;let c=h.V8r.applyToPoint(r.transform,i),u=h.V8r.applyToPoint(h.V8r.Inverse(n),c);e.setTo(u),r.didIntersect=!0}function xU(e,t,n){let r=(0,h.oj6)(e,t,n)??h.l2P.Med(e,t),i=h.l2P.Dist(r,e),o=+h.l2P.Clockwise(e,n,t),s=((e.y-t.y)**2+(e.x-t.x)**2)**.5,a=((t.y-n.y)**2+(t.x-n.x)**2)**.5,l=((n.y-e.y)**2+(n.x-e.x)**2)**.5,d=2*Math.acos((a*a+l*l-s*s)/(2*a*l)),c=+(h.PI>d),u=(h.uAR-d)*(o?1:-1);return{center:r,radius:i,size:u,length:u*i,largeArcFlag:c,sweepFlag:o}}let xW=["right","bottom","left","top"],xK={top:{x:0,y:-1},right:{x:1,y:0},bottom:{x:0,y:1},left:{x:-1,y:0}},xV={left:"x",right:"x",top:"y",bottom:"y"},xY={top:"bottom",right:"left",bottom:"top",left:"right"},xG={x:{v:(e,t)=>new h.l2P(e,t),loEdge:"left",hiEdge:"right",crossMid:"midY",gap:"gapX",midRange:"midXRange",self:"x",cross:"y",size:"width"},y:{v:(e,t)=>new h.l2P(t,e),loEdge:"top",hiEdge:"bottom",crossMid:"midX",gap:"gapY",midRange:"midYRange",self:"y",cross:"x",size:"height"}};function xq(e,t){return{min:Math.min(e,t),max:Math.max(e,t)}}function xX(e,t){return e>=t.min&&e<=t.max}function xJ(e){if(!e)return;let t=e.cross.min;e.cross.min=-e.cross.max,e.cross.max=-t,e.crossTarget=-e.crossTarget}function xZ(e){e&&(e.value=-e.value,e.expanded=null===e.expanded?null:-e.expanded)}let xQ={x:1,y:1,transpose:!1},x0={x:-1,y:1,transpose:!0},x1={x:-1,y:-1,transpose:!1},x2={x:1,y:-1,transpose:!0},x3={x:1,y:-1,transpose:!1};function x5(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function x6(e,t){t.x=e.x*t.x,t.y=e.y*t.y,e.transpose&&x5(t,"x","y")}function x4(e,t){-1===e.x&&(t.x=-(t.x+t.width)),-1===e.y&&(t.y=-(t.y+t.height)),e.transpose&&(x5(t,"x","y"),x5(t,"width","height"))}function x8(e,t){-1===e.x&&(x5(t,"left","right"),xJ(t.top),xJ(t.bottom),xZ(t.left),xZ(t.right)),-1===e.y&&(x5(t,"top","bottom"),xJ(t.left),xJ(t.right),xZ(t.top),xZ(t.bottom)),e.transpose&&(x5(t,"left","top"),x5(t,"right","bottom"))}class x9{options;A;B;common;gapX;gapY;midX;midY;bias;constructor(e){this.options=e.options,this.A=e.A,this.B=e.B,this.common=e.common,this.midX=e.midX,this.midY=e.midY,this.gapX=e.gapX,this.gapY=e.gapY,this.bias=new h.l2P(1,1)}transform=xQ;inverse=xQ;apply(e){var t,n;let r;if(this.transform=(t=this.transform,r={...e},t.transpose&&(x5(r,"x","y"),r.transpose=!r.transpose),-1===t.x&&(r.x=-r.x),-1===t.y&&(r.y=-r.y),r),this.inverse=(n=this.transform).transpose?{x:n.y,y:n.x,transpose:!0}:n,x4(e,this.A.original),x4(e,this.B.original),x4(e,this.common.original),x4(e,this.A.expanded),x4(e,this.B.expanded),x4(e,this.common.expanded),x8(e,this.A.edges),x8(e,this.B.edges),x6(e,this.bias),-1===e.x&&(this.gapX=-this.gapX,this.midX=null===this.midX?null:-this.midX),-1===e.y&&(this.gapY=-this.gapY,this.midY=null===this.midY?null:-this.midY),e.transpose){let e=this.midX;this.midX=this.midY,this.midY=e,e=this.gapX,this.gapX=this.gapY,this.gapY=e}}reset(){this.apply(this.inverse)}vec(e,t){let n=new h.l2P(e,t);return x6(this.inverse,n),n}}class x7{constructor(e,t){this.info=e,this.name=t}info;name;points=[];add(e,t){return this.points.push(this.info.vec(e,t)),this}_midpointHandle=null;midpointHandle(e){(0,h.vAR)(null===this._midpointHandle,"midX/midY called multiple times");let t=h.l2P.Lrp(this.points[this.points.length-2],this.points[this.points.length-1],.5);return this._midpointHandle={axis:this.info.transform.transpose?"x"===e?"y":"x":e,point:t,segmentStart:this.points[this.points.length-2].clone(),segmentEnd:this.points[this.points.length-1].clone()},this}build(){let e=[];for(let t=0;t<this.points.length;t++){let n=this.points[t],r=e[e.length-1],i=e[e.length-2];if(r&&i){let t=Math.abs(n.x-r.x),o=Math.abs(n.y-r.y),s=Math.abs(n.x-i.x),a=Math.abs(n.y-i.y);t<.01&&o<.01||(t<.01&&s<.01?r.y=n.y:o<.01&&a<.01?r.x=n.x:e.push(n))}else e.push(n)}return{name:this.name,points:e,distance:function(e){let t=0;for(let n=0;n<e.length-1;n++){let r=e[n],i=e[n+1];t+=Math.abs(i.x-r.x)+Math.abs(i.y-r.y)}return t}(e),aEdgePicking:"manual",bEdgePicking:"manual",skipPointsWhenDrawing:new Set,midpointHandle:this._midpointHandle}}}function we(e){let t=e.A.edges.right,n=e.B.edges.left;if(!t||!n)return null;if(t.crossTarget>n.crossTarget&&e.apply(x3),e.gapX>0&&null!==e.midX)return new x7(e,"to left 1").add(t.value,t.crossTarget).add(e.midX,t.crossTarget).add(e.midX,n.crossTarget).midpointHandle("x").add(n.value,n.crossTarget).build();if(null===t.expanded||null===n.expanded)return null;if(null!==e.midY)return new x7(e,"to left 2").add(t.value,t.crossTarget).add(t.expanded,t.crossTarget).add(t.expanded,e.midY).add(n.expanded,e.midY).midpointHandle("y").add(n.expanded,n.crossTarget).add(n.value,n.crossTarget).build();let r=Math.abs(t.value-e.common.expanded.right)+Math.abs(t.crossTarget-e.common.expanded.bottom)+Math.abs(e.common.expanded.right-n.expanded)+Math.abs(e.common.expanded.bottom-n.crossTarget)+e.options.expandElbowLegLength+6,i=e.options.expandElbowLegLength+Math.abs(t.crossTarget-e.common.expanded.top)+Math.abs(t.expanded-e.common.expanded.left)+Math.abs(e.common.expanded.top-n.crossTarget)+Math.abs(e.common.expanded.left-n.value)+6+e.bias.y,o=e.gapX<0&&null!==e.midX?e.options.expandElbowLegLength+Math.abs(t.crossTarget-e.A.expanded.bottom)+e.common.expanded.width+Math.abs(e.A.expanded.bottom-e.B.expanded.top)+Math.abs(e.B.expanded.top-n.crossTarget)+e.options.expandElbowLegLength+8:1/0;return r<i&&r<o?new x7(e,"to left 3").add(t.value,t.crossTarget).add(e.common.expanded.right,t.crossTarget).add(e.common.expanded.right,e.common.expanded.bottom).add(n.expanded,e.common.expanded.bottom).add(n.expanded,n.crossTarget).add(n.value,n.crossTarget).build():i<o?new x7(e,"to left 4").add(t.value,t.crossTarget).add(t.expanded,t.crossTarget).add(t.expanded,e.common.expanded.top).add(e.common.expanded.left,e.common.expanded.top).add(e.common.expanded.left,n.crossTarget).add(n.value,n.crossTarget).build():null!==e.midX?new x7(e,"to left 5").add(t.value,t.crossTarget).add(t.expanded,t.crossTarget).add(t.expanded,e.A.expanded.bottom).add(e.midX,e.A.expanded.bottom).add(e.midX,e.B.expanded.top).midpointHandle("y").add(n.expanded,e.B.expanded.top).add(n.expanded,n.crossTarget).add(n.value,n.crossTarget).build():null}function wt(e){let t=e.A.edges.right,n=e.B.edges.top;if(!t||!n)return null;if(t.crossTarget<(n.expanded??n.value)&&n.crossTarget>(t.expanded??t.value)||e.A.isPoint&&e.B.expanded.containsPoint(e.A.original.center))return new x7(e,"to top 1").add(t.value,t.crossTarget).add(n.crossTarget,t.crossTarget).add(n.crossTarget,n.value).build();if(e.gapX>0&&null!==e.midX&&null!==n.expanded)return new x7(e,"to top 2").add(t.value,t.crossTarget).add(e.midX,t.crossTarget).add(e.midX,n.expanded).midpointHandle("x").add(n.crossTarget,n.expanded).add(n.crossTarget,n.value).build();if(e.gapY>0&&null!==t.expanded&&n.crossTarget<t.expanded&&null!==e.midY)return new x7(e,"to top 3").add(t.value,t.crossTarget).add(t.expanded,t.crossTarget).add(t.expanded,e.midY).add(n.crossTarget,e.midY).midpointHandle("y").add(n.crossTarget,n.value).build();let r=Math.abs(t.value-e.common.expanded.right)+Math.abs(t.crossTarget-e.common.expanded.top)+Math.abs(n.crossTarget-e.common.expanded.right)+Math.abs(n.value-e.common.expanded.top),i=null!==t.expanded&&null!==e.midY&&null!==n.expanded?Math.abs(t.value-t.expanded)+Math.abs(e.B.expanded.left-t.expanded)+Math.abs(e.B.expanded.left-n.crossTarget)+Math.abs(t.crossTarget-e.B.expanded.top)+Math.abs(n.value-n.expanded):1/0,o=null!==t.expanded&&null!==e.midX&&null!==n.expanded?Math.abs(t.value-e.common.expanded.right)+Math.abs(t.crossTarget-e.A.expanded.bottom)+Math.abs(t.expanded-n.crossTarget)+Math.abs(e.A.expanded.bottom-n.expanded)+Math.abs(n.expanded-n.value):1/0;return r<i&&r<o?new x7(e,"to top 4").add(t.value,t.crossTarget).add(e.common.expanded.right,t.crossTarget).add(e.common.expanded.right,e.common.expanded.top).add(n.crossTarget,e.common.expanded.top).add(n.crossTarget,n.value).build():null!==n.expanded&&null!==t.expanded&&null!==e.midY&&i<o?new x7(e,"to top 5").add(t.value,t.crossTarget).add(t.expanded,t.crossTarget).add(t.expanded,e.midY).add(e.B.expanded.left,e.midY).midpointHandle("y").add(e.B.expanded.left,n.expanded).add(n.crossTarget,n.expanded).add(n.crossTarget,n.value).build():null!==n.expanded&&null!==t.expanded&&null!==e.midX?new x7(e,"to top 6").add(t.value,t.crossTarget).add(t.expanded,t.crossTarget).add(t.expanded,e.A.expanded.bottom).add(e.midX,e.A.expanded.bottom).add(e.midX,n.expanded).midpointHandle("x").add(n.crossTarget,n.expanded).add(n.crossTarget,n.value).build():null}function wn(e){return e.apply(x3),wt(e)}function wr(e){let t=e.A.edges.right,n=e.B.edges.right;if(!t||!n)return null;if((e.gapX<=0||t.crossTarget>e.B.expanded.bottom||t.crossTarget<e.B.expanded.top)&&(n.value>e.A.original.left||n.crossTarget>e.A.expanded.bottom||n.crossTarget<e.A.expanded.top))return new x7(e,"to right 1").add(t.value,t.crossTarget).add(e.common.expanded.right,t.crossTarget).add(e.common.expanded.right,n.crossTarget).add(n.value,n.crossTarget).build();if(null===e.midX)return null;if(null!==n.expanded&&e.gapX>=0){let r=Math.abs(n.crossTarget-e.B.expanded.bottom)+Math.abs(t.crossTarget-e.B.expanded.bottom)<Math.abs(n.crossTarget-e.B.expanded.top)+Math.abs(t.crossTarget-e.B.expanded.top)?"bottom":"top";return new x7(e,`to right 2 via ${r}`).add(t.value,t.crossTarget).add(e.midX,t.crossTarget).add(e.midX,e.B.expanded[r]).midpointHandle("x").add(n.expanded,e.B.expanded[r]).add(n.expanded,n.crossTarget).add(n.value,n.crossTarget).build()}if(null!==t.expanded&&e.gapX<=0){let r=Math.abs(n.crossTarget-e.A.expanded.bottom)+Math.abs(t.crossTarget-e.A.expanded.bottom)<Math.abs(n.crossTarget-e.A.expanded.top)+Math.abs(t.crossTarget-e.A.expanded.top)?"bottom":"top";return new x7(e,`to right 3 via ${r}`).add(t.value,t.crossTarget).add(t.expanded,t.crossTarget).add(t.expanded,e.A.expanded[r]).add(e.midX,e.A.expanded[r]).add(e.midX,n.crossTarget).midpointHandle("x").add(n.value,n.crossTarget).build()}return null}let wi={top:{top:[x2,wr],left:[x2,wt],bottom:[x2,we],right:[x2,wn]},right:{top:[xQ,wt],right:[xQ,wr],bottom:[xQ,wn],left:[xQ,we]},bottom:{top:[x0,we],left:[x0,wn],bottom:[x0,wr],right:[x0,wt]},left:{top:[x1,wn],left:[x1,wr],bottom:[x1,wt],right:[x1,we]}};function wo(e,t,n){let[r,i]=wi[t][n];e.apply(r);let o=i(e);return e.reset(),o}function ws(e,t){let n=null,r=1/0,i=1/0,o=0;for(let[s,a,l,d]of t){o+=1;let t=wo(e,s,a);t&&(t.aEdgePicking=l,t.bEdgePicking=d,t.points.length<r?(r=t.points.length,i=t.distance,n=t):t.points.length===r&&t.distance+o<i&&(i=t.distance,n=t))}return n}function wa(e,t,n,r){var i,o,s;let a,l,d=e.getShapeUtil(t.type).options,c={elbowMidpoint:t.props.elbowMidPoint,expandElbowLegLength:d.expandElbowLegLength[t.props.size]*t.props.scale,minElbowLegLength:d.minElbowLegLength[t.props.size]*t.props.scale},u=wl(e,t,n.start,t.props.start,r),p=wl(e,t,n.end,t.props.end,r);u=wg(u,p,c),p=wg(p,u,c);let f=!!(!u.side&&p.side),{aTerminal:g,bTerminal:m}=f?{aTerminal:p,bTerminal:u}:{aTerminal:u,bTerminal:p},y={top:wc(g,m,"top",c),right:wc(g,m,"right",c),bottom:wc(g,m,"bottom",c),left:wc(g,m,"left",c)},b={top:wc(m,g,"top",c),right:wc(m,g,"right",c),bottom:wc(m,g,"bottom",c),left:wc(m,g,"left",c)},x=wu(y,g.side),w=wu(b,m.side),v=!1;x&&w||(v=!0,x||(m=wp(m)),w||(g=wp(g)),m.bounds.containsPoint(g.target,c.expandElbowLegLength)&&(m=wp(m)),g.bounds.containsPoint(m.target,c.expandElbowLegLength)&&(g=wp(g))),v&&(y={top:wc(g,m,"top",c),right:wc(g,m,"right",c),bottom:wc(g,m,"bottom",c),left:wc(g,m,"left",c)},b={top:wc(m,g,"top",c),right:wc(m,g,"right",c),bottom:wc(m,g,"bottom",c),left:wc(m,g,"left",c)});let S=g.isPoint?g.bounds:g.bounds.clone().expandBy(c.expandElbowLegLength),C=m.isPoint?m.bounds:m.bounds.clone().expandBy(c.expandElbowLegLength),k={original:h.azJ.Common([g.bounds,m.bounds]),expanded:h.azJ.Common([S,C])},P=m.bounds.minX-g.bounds.maxX;P<0&&((P=g.bounds.minX-m.bounds.maxX)<0&&(P=0),P=-P);let T=m.bounds.minY-g.bounds.maxY;T<0&&((T=g.bounds.minY-m.bounds.maxY)<0&&(T=0),T=-T);let E=3*g.minEndSegmentLength,I=3*m.minEndSegmentLength,_=(g.isPoint?E:c.minElbowLegLength)+(m.isPoint?I:c.minElbowLegLength),M=null;P>_?M={a:g.isPoint?g.bounds.maxX+E:S.maxX,b:m.isPoint?m.bounds.minX-I:C.minX}:P<-_&&(M={a:g.isPoint?g.bounds.minX-E:S.minX,b:m.isPoint?m.bounds.maxX+I:C.maxX});let A=null;T>_?A={a:g.isPoint?g.bounds.maxY+E:S.maxY,b:m.isPoint?m.bounds.minY-I:C.minY}:T<-_&&(A={a:g.isPoint?g.bounds.minY-E:S.minY,b:m.isPoint?m.bounds.maxY+I:C.maxY});let j=f?1-c.elbowMidpoint:c.elbowMidpoint,O=M?(0,h.CcK)(M.a,M.b,j):null,D=A?(0,h.CcK)(A.a,A.b,j):null,L={options:c,swapOrder:f,A:{isPoint:g.isPoint,target:g.target,isExact:g.isExact,arrowheadOffset:g.arrowheadOffset,minEndSegmentLength:g.minEndSegmentLength,original:g.bounds,expanded:S,edges:y,geometry:g.geometry},B:{isPoint:m.isPoint,target:m.target,isExact:m.isExact,arrowheadOffset:m.arrowheadOffset,minEndSegmentLength:m.minEndSegmentLength,original:m.bounds,expanded:C,edges:b,geometry:m.geometry},common:k,gapX:P,gapY:T,midX:O,midY:D},F=new x9(L),R=wh(g,m,L.A.edges),z=wh(m,g,L.B.edges);return R&&z?l=(a=wo(i=F,o=R,s=z))?a:i.A.isPoint&&i.B.isPoint?ws(i,[[xY[o],xY[s],"manual","manual"],[o,xY[s],"manual","auto"],[xY[o],s,"auto","manual"]]):i.A.isPoint?wo(i,xY[o],s):i.B.isPoint?wo(i,o,xY[s]):null:R&&!z&&(l=function(e,t){let n=null,r=e.A.edges.right,i=e.A.edges.left,o=e.B.edges.top,s=e.B.edges.bottom;switch(t){case"right":e.gapX>0&&e.gapX>Math.abs(e.gapY)&&null!==e.midX?n=wo(e,"right","left"):r&&o&&(r.expanded??r.value)<=o.crossTarget&&r.crossTarget<=(o.expanded??o.value)?n=wo(e,"right","top"):r&&s&&(r.expanded??r.value)<=s.crossTarget&&r.crossTarget>=(s.expanded??s.value)&&(n=wo(e,"right","bottom"));break;case"left":e.gapX<0&&Math.abs(e.gapX)>Math.abs(e.gapY)&&null!==e.midX?n=wo(e,"left","right"):i&&o&&(i.expanded??i.value)>=o.crossTarget&&i.crossTarget<=(o.expanded??o.value)?n=wo(e,"left","top"):i&&s&&(i.expanded??i.value)>=s.crossTarget&&i.crossTarget>=(s.expanded??s.value)&&(n=wo(e,"left","bottom"));break;case"top":case"bottom":break;default:(0,h.h6G)(t)}if(n)return n.aEdgePicking="manual",n.bEdgePicking="auto",n;switch(t){case"top":return ws(e,[["top","bottom","manual","auto"],["top","right","manual","auto"],["top","left","manual","auto"],["top","top","manual","auto"]]);case"bottom":return ws(e,[["bottom","top","manual","auto"],["bottom","right","manual","auto"],["bottom","left","manual","auto"],["bottom","bottom","manual","auto"]]);case"left":return ws(e,[["left","right","manual","auto"],["left","bottom","manual","auto"],["left","left","manual","auto"],["left","top","manual","auto"]]);case"right":return ws(e,[["right","left","manual","auto"],["right","bottom","manual","auto"],["right","right","manual","auto"],["right","top","manual","auto"]])}}(F,R)),l||(l=function(e,t){let n=null;if(Math.abs(e.gapX)+1>Math.abs(e.gapY)&&null!==e.midX)n=e.gapX>0?wo(e,"right","left"):wo(e,"left","right");else{let t=e.A.edges.right,r=e.A.edges.left,i=e.B.edges.top,o=e.B.edges.bottom;e.A.isPoint&&e.B.isPoint?n=e.gapY>0?wo(e,"bottom","top"):wo(e,"top","bottom"):t&&i&&(t.expanded??t.value)<=i.crossTarget&&t.crossTarget<=(i.expanded??i.value)?n=wo(e,"right","top"):t&&o&&(t.expanded??t.value)<=o.crossTarget&&t.crossTarget>=(o.expanded??o.value)?n=wo(e,"right","bottom"):r&&i&&(r.expanded??r.value)>=i.crossTarget&&r.crossTarget<=(i.expanded??i.value)?n=wo(e,"left","top"):r&&o&&(r.expanded??r.value)>=o.crossTarget&&r.crossTarget>=(o.expanded??o.value)?n=wo(e,"left","bottom"):e.gapY>0&&null!==e.midY?n=wo(e,"bottom","top"):e.gapY<0&&null!==e.midY&&(n=wo(e,"top","bottom"))}if(n)return n.aEdgePicking=t,n.bEdgePicking=t,n;let r=xW.filter(t=>e.A.edges[t]),i=xW.filter(t=>e.B.edges[t]);return ws(e,r.flatMap(e=>i.map(n=>[e,n,t,t])))}(F,R||z?"fallback":"auto")),l&&(wf("first",L.A,L.B,l),wf("last",L.B,L.A,l),function(e,t,n){if(e){if(e.points.length>=3){let n=e.points[0],r=e.points[1];if(h.l2P.ManhattanDist(n,r)<t.minEndSegmentLength&&(e.points.splice(1,1),e.points.length>=3)){let t=(0,h.YY0)(n.x,r.x)?"y":"x";e.points[1][t]=n[t]}}if(e.points.length>=3){let t=e.points[e.points.length-1],r=e.points[e.points.length-2];if(h.l2P.ManhattanDist(t,r)<n.minEndSegmentLength&&(e.points.splice(e.points.length-2,1),e.points.length>=3)){let n=(0,h.YY0)(t.x,r.x)?"y":"x";e.points[e.points.length-2][n]=t[n]}}}}(l,g,m),f&&l.points.reverse()),{...L,route:l,midXRange:M?f?{lo:M.b,hi:M.a}:{lo:M.a,hi:M.b}:null,midYRange:A?f?{lo:A.b,hi:A.a}:{lo:A.a,hi:A.b}:null}}function wl(e,t,n,r,i){let o=e.getCurrentTheme(),s=(i??o.strokeWidth*ei[t.props.size])*t.props.scale/2,a=3*s;if(n){let r=e.getShape(n.toId),i=function(e,t,n,r){let i="start"===r.terminal?"none"!==t.props.arrowheadStart:"none"!==t.props.arrowheadEnd,o=e.getShapeGeometry(n,i?void 0:{context:"@tldraw/arrow-without-arrowhead"});if(!o)return null;let s=e.getShapePageTransform(t.id),a=e.getShapePageTransform(n),l=s.clone().invert().multiply(a),d=o.transform(l),c={x:.5,y:.5},u=r.isPrecise?r.normalizedAnchor:c,p={x:(0,h.CcK)(o.bounds.minX,o.bounds.maxX,u.x),y:(0,h.CcK)(o.bounds.minY,o.bounds.maxY,u.y)},f={x:(0,h.CcK)(o.bounds.minX,o.bounds.maxX,c.x),y:(0,h.CcK)(o.bounds.minY,o.bounds.maxY,c.y)},g=h.V8r.applyToPoint(l,p),m=h.V8r.applyToPoint(l,f);return{bounds:d.bounds,geometry:d,target:g,center:m,shapeToArrowTransform:l}}(e,t,n.toId,n.props);if(i&&r){var l;let e=0,d="start"===n.props.terminal?"arrowheadStart":"arrowheadEnd";if("none"!==t.props[d]){let n="scale"in r.props?r.props.scale:1;e=s+("size"in r.props?o.strokeWidth*(ei[r.props.size]??0)*n/2:0)+10*t.props.scale}let c=null,u=i.target;return n.props.isPrecise&&(l=h.l2P.RotWith(n.props.normalizedAnchor,{x:.5,y:.5},i.shapeToArrowTransform.rotation()),c=(0,h.YY0)(l.x,.5)&&(0,h.YY0)(l.y,.5)?null:Math.abs(l.x-.5)>Math.abs(l.y-.5)-1e-4?l.x<.5?"left":"right":l.y<.5?"top":"bottom"),{targetShapeId:n.toId,isPoint:!1,isExact:n.props.isExact,bounds:i.bounds,geometry:i.geometry,target:u,arrowheadOffset:e,minEndSegmentLength:a,side:c,snap:n.props.snap}}}return{targetShapeId:null,bounds:h.azJ.FromCenter(r,{x:0,y:0}),geometry:null,isExact:!1,isPoint:!0,target:h.l2P.From(r),arrowheadOffset:0,minEndSegmentLength:a,side:null,snap:"none"}}let wd={top:{expand:-1,main:"minY",opposite:"maxY",crossMid:"midX",crossMin:"minX",crossMax:"maxX",bRangeExpand:"max",crossAxis:"x"},bottom:{expand:1,main:"maxY",opposite:"minY",crossMid:"midX",crossMin:"minX",crossMax:"maxX",bRangeExpand:"min",crossAxis:"x"},left:{expand:-1,main:"minX",opposite:"maxX",crossMid:"midY",crossMin:"minY",crossMax:"maxY",bRangeExpand:"max",crossAxis:"y"},right:{expand:1,main:"maxX",opposite:"minX",crossMid:"midY",crossMin:"minY",crossMax:"maxY",bRangeExpand:"min",crossAxis:"y"}};function wc(e,t,n,r){var i,o,s,a,l;let d,c=wd[n],u=e.targetShapeId===t.targetShapeId&&null!==e.targetShapeId&&("edge"===e.snap||"edge-point"===e.snap)&&("edge"===t.snap||"edge-point"===t.snap),p=e.bounds[c.main],f=e.isPoint?null:p+c.expand*r.expandElbowLegLength,g=xq(e.bounds[c.crossMin],e.bounds[c.crossMax]),m=g;if(!m)return null;(0,h.vAR)(g);let y=xq(t.bounds[c.main],t.bounds[c.opposite]);t.isPoint||(y[c.bRangeExpand]-=2*r.minElbowLegLength*c.expand);let b=(i=xq(t.bounds[c.crossMin],t.bounds[c.crossMax]),o=r.expandElbowLegLength,(d={min:i.min-o,max:i.max+o}).min>d.max?null:d);(0,h.vAR)(y&&b);let x=!1;if(xX(p,y)&&!e.isPoint&&!t.isPoint&&!u){let e=(s=m,((0,h.vAR)(s.min<=s.max&&b.min<=b.max),s.min<=b.min&&b.max<=s.max)?[{min:s.min,max:b.min},{min:b.max,max:s.max}]:b.max<=s.min||b.min>=s.max?[s]:b.min<=s.min&&s.max<=b.max?[]:xX(s.min,b)?[{min:b.max,max:s.max}]:xX(s.max,b)?[{min:s.min,max:b.min}]:[]);switch(e.length){case 0:return null;case 1:x=e[0]!==m,m=e[0];break;case 2:x=!0,m=(a=e[0]).max-a.min>(l=e[1]).max-l.min?e[0]:e[1];break;default:(0,h.h6G)(e)}}return xX(e.target[c.crossAxis],m)?{value:p,expanded:f,cross:m,crossTarget:e.target[c.crossAxis],isPartial:x}:null}function wu(e,t){return null===t?!!(e.bottom||e.left||e.right||e.top):"x"===t?!!e.left||!!e.right:"y"===t?!!e.top||!!e.bottom:!!e[t]}function wh(e,t,n){switch(e.side){case null:return null;case"x":if(e.bounds.center.x>t.bounds.center.x&&n?.left)return"left";if(n?.right)return"right";return null;case"y":if(e.bounds.center.y>t.bounds.center.y&&n?.top)return"top";if(n?.bottom)return"bottom";return null;default:return e.side}}function wp(e){if(e.isPoint)return e;let t=null,n=0;return("edge"===e.snap||"edge-point"===e.snap)&&(n=e.arrowheadOffset,("x"===e.side||"left"===e.side||"right"===e.side)&&(t="x"),("y"===e.side||"top"===e.side||"bottom"===e.side)&&(t="y")),{targetShapeId:e.targetShapeId,side:t,bounds:new h.azJ(e.target.x,e.target.y,0,0),geometry:e.geometry,target:e.target,arrowheadOffset:n,minEndSegmentLength:e.minEndSegmentLength,isExact:e.isExact,isPoint:!0,snap:e.snap}}function wf(e,t,n,r){if(!t.geometry)return;let i="first"===e?r.points[0]:r.points[r.points.length-1],o="first"===e?r.points[1]:r.points[r.points.length-2],s=t.geometry.isClosed?o:t.target,a=h.l2P.ManhattanDist(i,s),l=null,d=1/0;if(t.isExact)l=t.target;else if(t.geometry){let e=t.geometry.intersectLineSegment(o,t.target,{includeLabels:!1,includeInternal:!1});for(let n of(t.geometry.hitTestPoint(t.target,Math.max(1,t.arrowheadOffset),!0,h.MI8.EXCLUDE_NON_STANDARD)&&e.push(t.target),e)){let e=h.l2P.ManhattanDist(s,n);e<d&&(d=e,l=n)}}if(l){let s=t.arrowheadOffset,d=h.l2P.ManhattanDist(o,l),c=2*t.arrowheadOffset;d<c&&(s=d-(c-t.arrowheadOffset)),s<t.minEndSegmentLength&&(s=t.geometry.bounds.containsPoint(n.target)?Math.max(0,s):-t.arrowheadOffset);let u=l,p=!1;if(!t.isExact&&0!==s){let e=h.l2P.Nudge(l,o,s);u=e,s<0&&!t.geometry.hitTestPoint(e,0,!0,h.MI8.EXCLUDE_NON_STANDARD)?u=l:(s<0&&(p=!0),u=e)}let f=h.l2P.ManhattanDist(o,u);if(r.distance+=f-a,i.x=u.x,i.y=u.y,p){let t=h.l2P.Lrp(o,i,.5);r.skipPointsWhenDrawing.add(t),r.points.splice("first"===e?1:r.points.length-1,0,t)}}}function wg(e,t,n){if(!e.geometry||e.geometry.isClosed)return e;let r=e.geometry.uninterpolateAlongEdge(e.target,h.MI8.EXCLUDE_NON_STANDARD),i=e.geometry.interpolateAlongEdge(r-.01/e.geometry.length),o=e.geometry.interpolateAlongEdge(r+.01/e.geometry.length).sub(i).per().uni(),s=Math.abs(o.x)>Math.abs(o.y)?xG.x:xG.y;if(e.geometry.bounds.containsPoint(t.target,n.expandElbowLegLength))return e.side=s.self,wp(e);let a=s.v(e.target[s.self]-2*e.bounds[s.size],e.target[s.cross]),l=s.v(e.target[s.self]+2*e.bounds[s.size],e.target[s.cross]),d=null,c=0,u=null,p=0,f=s.self;for(let t of e.geometry.intersectLineSegment(a,l,h.MI8.EXCLUDE_NON_STANDARD))!(1>Math.abs(t[s.self]-e.target[s.self]))&&(t[s.self]<e.target[s.self]?h.l2P.ManhattanDist(t,e.target)>c&&(c=h.l2P.ManhattanDist(t,e.target),d=t):h.l2P.ManhattanDist(t,e.target)>p&&(p=h.l2P.ManhattanDist(t,e.target),u=t));return d&&u?f=c>p?s.hiEdge:s.loEdge:d&&!u?f=s.hiEdge:!d&&u&&(f=s.loEdge),e.side=f,e}let wm=(0,fC.uY)("arrow info",(e,t)=>{let n=fE(e,t),r=e.getShapeUtil(t),i="getDisplayValues"in r.options?x$(r,t).strokeWidth:e.getCurrentTheme().strokeWidth*ei[t.props.size];if("elbow"===t.props.kind){let r=wa(e,t,n,i);if(!r?.route)return xB(e,t,n,i);let o=r.swapOrder?r.B:r.A,s=r.swapOrder?r.A:r.B;return{type:"elbow",bindings:n,start:{handle:o.target,point:r.route.points[0],arrowhead:t.props.arrowheadStart},end:{handle:s.target,point:r.route.points[r.route.points.length-1],arrowhead:t.props.arrowheadEnd},elbow:r,route:r.route,isValid:!0}}return"arc"===t.props.kind&&Math.abs(t.props.bend)<8*t.props.scale?xB(e,t,n,i):function(e,t,n,r){let{arrowheadEnd:i,arrowheadStart:o}=t.props,s=t.props.bend;if(Math.abs(s)>Math.abs(t.props.bend*(10*t.props.scale)))return xB(e,t,n,r);let a=fI(e,t,n),l=h.l2P.Med(a.start,a.end),d=h.l2P.Sub(a.end,a.start),c=h.l2P.Len(d)?d.uni():h.l2P.From(d),u=h.l2P.Add(l,c.per().mul(-s)),p=e.getCurrentTheme(),f=r??p.strokeWidth*ei[t.props.size],g=fk(e,t,"start"),m=fk(e,t,"end"),y=a.start.clone(),b=a.end.clone(),x=u.clone();if(h.l2P.Equals(y,b))return{bindings:n,type:"straight",start:{handle:y,point:y,arrowhead:t.props.arrowheadStart},end:{handle:b,point:b,arrowhead:t.props.arrowheadEnd},middle:x,isValid:!1,length:0};let w=t.props.bend<0,v=w?h.KMq:h.IM4,S=xU(y,b,x),C=h.l2P.Angle(S.center,y),k=h.l2P.Angle(S.center,b),P=v(C,k);if(0===S.length||0===S.size||!(0,h._Bd)(S.length)||!(0,h._Bd)(S.size))return xB(e,t,n,r);let T=y.clone(),E=b.clone(),I=x.clone(),_=e.getShapePageTransform(t),M=0,A=0,j=10*t.props.scale;if(g&&!g.isExact){let n,r=h.V8r.applyToPoint(_,T),i=h.V8r.applyToPoint(_,S.center),s=h.V8r.applyToPoint(_,E),a=h.V8r.Inverse(g.transform),l=h.V8r.applyToPoint(a,r),d=h.V8r.applyToPoint(a,i),c=h.V8r.applyToPoint(a,s),{isClosed:u}=g,m=Array.from(g.geometry.intersectCircle(d,S.radius,{includeLabels:!1,includeInternal:!1}));if(m.length){let e=d.angle(l),t=v(e,d.angle(c));m=m.filter(n=>v(e,d.angle(n))<=t);let r=.25*t;m.sort(u?(t,n)=>Math.abs(v(e,d.angle(t))-r)<Math.abs(v(e,d.angle(n))-r)?-1:1:(t,n)=>v(e,d.angle(t))<v(e,d.angle(n))?-1:1),n=m[0]}if(!n)if(u){let e=g.geometry.nearestPoint(l,{includeInternal:!1,includeLabels:!1});h.l2P.DistMin(e,l,1)&&(n=e)}else n=l;if(n&&(T.setTo(e.getPointInShapeSpace(t,h.V8r.applyToPoint(g.transform,n))),g.didIntersect=!0,"none"!==o)){let e=f/2+("size"in g.shape.props?p.strokeWidth*ei[g.shape.props.size]/2:0);M=(10+e)*t.props.scale,j+=e*t.props.scale}}if(m&&!m.isExact){let n,r=h.V8r.applyToPoint(_,T),o=h.V8r.applyToPoint(_,E),s=h.V8r.applyToPoint(_,S.center),a=h.V8r.Inverse(m.transform),l=h.V8r.applyToPoint(a,r),d=h.V8r.applyToPoint(a,s),c=h.V8r.applyToPoint(a,o),u=m.isClosed,g=Array.from(m.geometry.intersectCircle(d,S.radius,{includeLabels:!1,includeInternal:!1}));if(g.length){let e=d.angle(l),t=v(e,d.angle(c)),r=.75*t;(g=g.filter(n=>v(e,d.angle(n))<=t)).sort(u?(t,n)=>Math.abs(v(e,d.angle(t))-r)<Math.abs(v(e,d.angle(n))-r)?-1:1:(t,n)=>v(e,d.angle(t))<v(e,d.angle(n))?-1:1),n=g[0]}if(!n)if(u){let e=m.geometry.nearestPoint(c,{includeInternal:!1,includeLabels:!1});h.l2P.DistMin(e,c,1)&&(n=e)}else n=c;if(n&&(E.setTo(e.getPointInShapeSpace(t,h.V8r.applyToPoint(m.transform,n))),m.didIntersect=!0,"none"!==i)){let e=f/2+("size"in m.shape.props?p.strokeWidth*ei[m.shape.props.size]/2:0);A=(10+e)*t.props.scale,j+=e*t.props.scale}}fj(e,T,y,_,g),fj(e,E,b,_,m);let O=h.l2P.Angle(S.center,T),D=h.l2P.Angle(S.center,E),L=v(O,D),F=L*S.radius,R=T.clone(),z=E.clone();if(0!==M&&R.setTo(S.center).add(h.l2P.FromAngle(O+M/F*(w?1:-1)*L).mul(S.radius)),0!==A&&z.setTo(S.center).add(h.l2P.FromAngle(D+A/F*(w?-1:1)*L).mul(S.radius)),h.l2P.DistMin(R,z,j)){0!==M&&0!==A?(M*=-1.5,A*=-1.5):0!==M?M*=-2:0!==A&&(A*=-2);let e=.1-v(C,O)*S.radius,t=.1-v(D,k)*S.radius;M=Math.max(M,e),A=Math.max(A,t)}if(0!==M&&T.setTo(S.center).add(h.l2P.FromAngle(O+M/F*(w?1:-1)*L).mul(S.radius)),0!==A&&E.setTo(S.center).add(h.l2P.FromAngle(D+A/F*(w?-1:1)*L).mul(S.radius)),g&&m&&!g.isExact&&!m.isExact){F=(L=v(O=h.l2P.Angle(S.center,T),D=h.l2P.Angle(S.center,E)))*S.radius;let n=fA(e,g.shape.id,m.shape.id);"double-bound"===n&&F<30?(T.setTo(y),E.setTo(b),I.setTo(x)):"safe"===n&&(g&&!g.didIntersect&&T.setTo(y),(m&&!m.didIntersect||v(C,O)>v(C,D))&&E.setTo(S.center).add(h.l2P.FromAngle(O+L*(Math.min(.9,10*t.props.scale/F)*(w?1:-1))).mul(S.radius)))}(function(e,t,n,r,i,o,s){let a=h.l2P.Angle(e,n),l=h.l2P.Angle(e,r),d=(0,h.KMq)(a,l);if(s||(d=h.uAR-d),i.setTo(e).add(h.l2P.FromAngle(a+.5*(s?1:-1)*d).mul(t)),d>o){i.rotWith(e,h.PI);let t=r.clone();r.setTo(n),n.setTo(t)}})(S.center,S.radius,T,E,I,P,w),T.equals(E)&&(T.setTo(I.clone().addXY(1,1)),E.setTo(I.clone().subXY(1,1))),y.setTo(T),b.setTo(E),x.setTo(I);let N=xU(y,b,x);return{bindings:n,type:"arc",start:{point:y,handle:a.start,arrowhead:t.props.arrowheadStart},end:{point:b,handle:a.end,arrowhead:t.props.arrowheadEnd},middle:x,handleArc:S,bodyArc:N,isValid:0!==N.length&&isFinite(N.center.x)&&isFinite(N.center.y)}}(e,t,n,i)},{areRecordsEqual:(e,t)=>e.props===t.props,areResultsEqual:h.Ao2});function wy(e,t){let n="string"==typeof t?t:t.id;return wm.get(e,n)}class wb extends h.bU{static type="arrow_binding_hint";options={zIndex:150,strokeWidth:2,opacity:.16,dashLengthRatio:2.5,dotRadius:4,crossSize:6,dashedMinZoom:.2};isActive(){let e=this.editor;if(e.getIsReadonly())return!1;let t=e.getOnlySelectedShapeId();if(!t)return!1;let n=e.getShape(t);if(!n||"arrow"!==n.type||!e.isInAny("select.idle","select.pointing_handle","select.dragging_handle","select.translating","arrow.dragging"))return!1;let r=fE(e,n);return!!(r.start||r.end)}getOverlays(){let e=this.editor.getOnlySelectedShapeId();return e?[{id:"arrow_binding_hint",type:"arrow_binding_hint",props:{arrowId:e}}]:[]}render(e,t){let n=t[0];if(!n)return;let r=this.editor,i=r.getShape(n.props.arrowId);if(!i)return;let o=wy(r,i);if(!o?.isValid)return;let s=fE(r,i);if(!s.start&&!s.end)return;let a=r.getShapePageTransform(i);if(!a)return;let l=r.getZoomLevel(),d=r.getCurrentTheme().colors[r.getColorMode()],c=this.options.strokeWidth/l;e.save(),e.transform(a.a,a.b,a.c,a.d,a.e,a.f),e.strokeStyle=d.text,e.fillStyle=d.text,e.lineWidth=c,e.lineCap="round",e.lineJoin="round",e.globalAlpha=this.options.opacity,s.start&&this.drawEndpoint(e,o,"start",s.start.props.isExact,s.start.props.isPrecise,c,l),s.end&&this.drawEndpoint(e,o,"end",s.end.props.isExact,s.end.props.isPrecise,c,l),e.restore()}drawEndpoint(e,t,n,r,i,o,s){let a=t[n].handle,l=t[n].point,d=h.l2P.Dist(a,l),c=(i?this.options.crossSize/2*Math.SQRT2:this.options.dotRadius)/s;if(d>c+.5){let r;if(e.save(),e.beginPath(),"arc"===t.type){let{center:i,radius:o,sweepFlag:s}=t.bodyArc,d=Math.atan2(l.y-i.y,l.x-i.x),u=Math.atan2(a.y-i.y,a.x-i.x),p=!s,f=u+c/o*((s?1:-1)*("start"===n?1:-1)),g=d-u;g>Math.PI?g-=h.uAR:g<-Math.PI&&(g+=h.uAR),r=Math.max(0,o*Math.abs(g)-c),"start"===n?e.arc(i.x,i.y,o,f,d,p):e.arc(i.x,i.y,o,d,f,p)}else{r=d-c;let t=c/d,n={x:a.x+(l.x-a.x)*t,y:a.y+(l.y-a.y)*t};e.moveTo(n.x,n.y),e.lineTo(l.x,l.y)}if(s>=this.options.dashedMinZoom){let{strokeDasharray:t,strokeDashoffset:n}=(0,h.EK8)(r,o,{style:"dashed",end:"skip",start:"skip"});if("none"!==t){let[r,i]=t.split(" ").map(Number);e.setLineDash([r,i]),e.lineDashOffset=Number(n)}}e.stroke(),e.restore()}if(r)return;let u=d>.5?this.getMarkerAngle(t,n,a,l):0;if(i){let t=this.options.crossSize/s/2;e.save(),e.translate(a.x,a.y),e.rotate(u),e.beginPath(),e.moveTo(-t,-t),e.lineTo(t,t),e.moveTo(-t,t),e.lineTo(t,-t),e.stroke(),e.restore()}else{let t=this.options.dotRadius/s;e.beginPath(),e.arc(a.x,a.y,t,0,h.uAR),e.stroke()}}getMarkerAngle(e,t,n,r){if("arc"===e.type){let{center:r,sweepFlag:i}=e.bodyArc;return Math.atan2(n.y-r.y,n.x-r.x)+(i?1:-1)*("start"===t?1:-1)*Math.PI/2}return Math.atan2(r.y-n.y,r.x-n.x)}}class wx extends h.mbh{static type="arrow";static props=h.P_i;static migrations=h.g8l;getDefaultProps(){return{isPrecise:!1,isExact:!1,normalizedAnchor:{x:.5,y:.5},snap:"none"}}onAfterCreate({binding:e}){let t=this.editor.getShape(e.fromId);t&&wv(this.editor,t)}onAfterChange({bindingAfter:e}){let t=this.editor.getShape(e.fromId);t&&wv(this.editor,t)}onAfterChangeFromShape({shapeBefore:e,shapeAfter:t,reason:n}){("ancestry"===n||e.parentId!==t.parentId||e.index!==t.index)&&wv(this.editor,t)}onAfterChangeToShape({binding:e,shapeBefore:t,shapeAfter:n,reason:r}){e.props.isPrecise&&"geo"===t.type&&"geo"===n.type&&t.props.geo!==n.props.geo&&this.editor.isIn("select.idle")&&!this.editor.isReplayingHistory()&&function(e,t,n){let r=e.getShapeGeometry(n);if(!r.isClosed)return;let{point:i,size:o}=r.bounds;if(0===o.x||0===o.y)return;let s=h.l2P.Add(i,h.l2P.MulV(t.props.normalizedAnchor,o));if(r.hitTestPoint(s,0,!0))return;let a=r.nearestPoint(s,h.MI8.EXCLUDE_LABELS);e.updateBinding({id:t.id,type:t.type,props:{normalizedAnchor:{x:(a.x-i.x)/o.x,y:(a.y-i.y)/o.y}}})}(this.editor,e,n),("ancestry"===r||t.parentId!==n.parentId||t.index!==n.index)&&ww(this.editor,e.fromId)}onBeforeIsolateFromShape({binding:e}){if(this.editor.isReplayingHistory())return;let t=this.editor.getShape(e.fromId);t&&wS({editor:this.editor,arrow:t,terminal:e.props.terminal})}}function ww(e,t){let n,r,i,o=e.getShape(t);if(!o)return;let{start:s,end:a}=fE(e,o),l=s?e.getShape(s.toId):void 0,d=a?e.getShape(a.toId):void 0,c=e.getAncestorPageId(o);if(!c)return;if(l&&d){var u,p,f;let t;n=(u=e,p=l,f=d,p.id===f.id?t=p:u.hasAncestor(p,f.id)?t=f:u.hasAncestor(f,p.id)&&(t=p),(t&&u.isShapeFrameLike(t)?t.id:void 0)??e.findCommonAncestor([l,d])??c)}else{if(!l&&!d)return;let e=(l||d)?.parentId;n=e&&e===o.parentId?o.parentId:c}n&&n!==o.parentId&&e.reparentShapes([t],n);let g=e.getShape(t);if(!g)throw Error("no reparented arrow");let m=e.getShapeNearestSibling(g,l),y=e.getShapeNearestSibling(g,d);if(m&&y)r=m.index>y.index?m:y;else if(m&&!y)r=m;else{if(!y||m)return;r=y}let b=e.getSortedChildIdsForParent(r.parentId).map(t=>e.getShape(t)).filter(e=>e.index>r.index);if(b.length){let e=b.find(e=>"arrow"!==e.type);if(g.index>r.index&&(!e||g.index<e.index))return;i=(0,h.HEt)(r.index,b[0].index)}else i=(0,h.AQy)(r.index);i!==g.index&&e.updateShapes([{id:t,type:"arrow",index:i}])}function wv(e,t){let n=fE(e,t);for(let r of["start","end"]){let i=n[r];if(!i)continue;let o=e.getShape(i.toId),s=e.getAncestorPageId(t)===e.getAncestorPageId(o);o&&s||wS({editor:e,arrow:t,terminal:r,unbind:!0})}ww(e,t.id)}function wS({editor:e,arrow:t,terminal:n,unbind:r=!1,useHandle:i=!1}){let o=wy(e,t);if(!o)throw Error("expected arrow info");let s=wC(i?o.start.handle:o.start.point,t.props.start),a=wC(i?o.end.handle:o.end.point,t.props.end),l="start"===n?s:a,d={id:t.id,type:"arrow",props:{[n]:{x:l.x,y:l.y},bend:t.props.bend}};if("arc"===o.type){let i="start"===n?s:wC(o.start.handle,t.props.start),l="end"===n?a:wC(o.end.handle,t.props.end),c=h.l2P.Med(i,l),u=h.l2P.Sub(i,l);if((0,h.YY0)(h.l2P.Len2(u),0)){e.updateShape(d),r&&fM(e,t,n);return}let p=u.per().uni().mul(2*o.handleArc.radius*Math.sign(t.props.bend)),f=h.l2P.Add(c,p);if(!h.l2P.IsFinite(o.handleArc.center)||!Number.isFinite(o.handleArc.radius)||!h.l2P.IsFinite(f)){e.updateShape(d),r&&fM(e,t,n);return}let g=(0,h.vrM)(o.handleArc.center,f,o.handleArc.center,o.handleArc.radius);if(g?.length){let e=g.reduce((e,t)=>h.l2P.Dist2(t,f)<h.l2P.Dist2(e,f)?t:e),n=h.l2P.Dist(c,e)*Math.sign(t.props.bend);(0,h.YY0)(n,d.props.bend)||(d.props.bend=n)}}e.updateShape(d),r&&fM(e,t,n)}function wC(e,t){return h.l2P.From(h.l2P.IsFinite(e)?e:t)}let wk=new h.laH;function wP(e){return wk.get(e,()=>(0,h.eUv)("arrowTarget",null))}function wT(e){wP(e).set(null)}function wE({editor:e,pointInPageSpace:t,arrow:n,isPrecise:r,currentBinding:i,oppositeBinding:o}){let s=e.getShapeUtil("arrow");if(s.options.shouldIgnoreTargets(e))return wP(e).set(null),null;let a=n?n.props.kind:e.getStyleForNextShape(h.qfG),l=e.getShapeAtPoint(t,{hitInside:!0,hitFrameInside:!0,margin:"elbow"===a?8:[8,0],filter:t=>!t.isLocked&&e.canBindShapes({fromShape:n??wI,toShape:t,binding:"arrow"})});if(!l)return wP(e).set(null),null;let d=e.getShapeGeometry(l),c=h.azJ.ZeroFix(d.bounds),u=d.center,p=e.getShapePageTransform(l),f=e.getPointInShapeSpace(l,t),g=Math.max(d.bounds.width,d.bounds.height),m=(0,h._Hz)(xK,(e,t)=>{let n=xG[xV[e]],r=h.l2P.Mul(t,g).add(u),i=!1,o=n.v(c[e],c[n.crossMid]),s=0;for(let e of d.intersectLineSegment(u,r,h.MI8.EXCLUDE_NON_STANDARD)){let t=h.l2P.Dist2(e,u);t>s&&(s=t,o=e,i=d.isClosed)}return{point:p.applyToPoint(o),isEnabled:i,far:p.applyToPoint(r)}}),y=e.getZoomLevel(),b=s.options.minElbowHandleDistance/y,x=p.applyToPoint(u);for(let e of(0,h.w$g)(m)){let t=m[e];h.l2P.DistMin(t.point,x,b)&&(t.isEnabled=!1)}let w=r;w||i&&(!i||l.id===i.toId)||(w=.5>e.inputs.getPointerVelocity().len()),!r&&(d.isClosed||(w=!0),o&&l.id===o.toId&&o.props.isPrecise&&(w=!0));let v=s.options.shouldBeExact(e,w);v&&(w=!0);let S=!v&&w&&d.isClosed,C=!v&&(w&&"elbow"===a||!d.isClosed),k=!v&&w&&"elbow"===a&&d.isClosed,P=w&&(d.isClosed||v),T=!v&&w&&"elbow"===a&&d.isClosed,E="none",I=t;if(P||(E="center",I=x),C){let n=P?w_(e,c,s.options.elbowArrowEdgeSnapDistance):1/0,r=d.nearestPoint(f,{includeLabels:!1,includeInternal:!1}),i=p.applyToPoint(r);h.l2P.Dist(i,t)<n&&(E="edge",I=i)}if(T){let n=w_(e,c,s.options.elbowArrowAxisSnapDistance),r=h.l2P.DistanceToLineSegment(m.left.far,m.right.far,t),i=h.l2P.DistanceToLineSegment(m.top.far,m.bottom.far,t),o=r<i&&r<n?"x":i<n?"y":null;if(o){let e=xG[o],n=h.l2P.Dist2(m[e.loEdge].far,t)<h.l2P.Dist2(m[e.hiEdge].far,t)?e.loEdge:e.hiEdge;m[n].isEnabled&&(E="edge-point",I=m[n].point)}}if(k){let n=w_(e,c,s.options.elbowArrowPointSnapDistance),r=null,i=1/0;for(let[e,o]of(0,h.iAN)(m)){if(!o.isEnabled)continue;let s=h.l2P.Dist(o.point,t);s<n&&s<i&&(i=s,r=e)}r&&(E="edge-point",I=m[r].point)}if(S){let t=w_(e,c,"elbow"===a?s.options.elbowArrowCenterSnapDistance:s.options.arcArrowCenterSnapDistance);h.l2P.Dist(f,c.center)<t&&(E="center",I=x)}let _=e.getPointInShapeSpace(l,I),M={target:l,arrowKind:a,handlesInPageSpace:m,centerInPageSpace:x,anchorInPageSpace:I,isExact:v,isPrecise:w,snap:E,normalizedAnchor:{x:(0,h.Fg_)(c.minX,c.maxX,_.x),y:(0,h.Fg_)(c.minY,c.maxY,_.y)}};return wP(e).set(M),M}let wI={type:"arrow"};function w_(e,t,n){return(0,h.qE8)(.15*Math.min(t.width,t.height),4,n)/e.getZoomLevel()}let wM=(0,h.uYT)("arrowHintIndicatorPath",(e,t)=>e.getShapeUtil(t).getIndicatorPath(t),{areRecordsEqual:(e,t)=>e.props===t.props});class wA extends h.bU{static type="arrow_hint";options={zIndex:1e3,lineWidth:1.5,edgeRadius:8,edgePointRadius:12,handleRadius:4};isActive(){let e=this.editor;if(e.isInAny("arrow.idle","arrow.pointing"))return!0;if(e.isIn("select.pointing_handle")){let t=e.getStateDescendant("select.pointing_handle");if("arrow"===t.info.shape.type&&("start"===t.info.handle.id||"end"===t.info.handle.id))return!0}if(e.isIn("select.dragging_handle")){let t=e.getStateDescendant("select.dragging_handle");if("arrow"===t.info.shape.type&&("start"===t.info.handle.id||"end"===t.info.handle.id))return!0}return!1}getOverlays(){let e=wP(this.editor).get();if(!e)return[];let{handlesInPageSpace:t,snap:n,anchorInPageSpace:r,arrowKind:i,isExact:o,isPrecise:s}=e;return[{id:"arrow_hint",type:"arrow_hint",props:{targetId:e.target.id,handles:{top:{x:t.top.point.x,y:t.top.point.y,isEnabled:t.top.isEnabled},bottom:{x:t.bottom.point.x,y:t.bottom.point.y,isEnabled:t.bottom.isEnabled},left:{x:t.left.point.x,y:t.left.point.y,isEnabled:t.left.isEnabled},right:{x:t.right.point.x,y:t.right.point.y,isEnabled:t.right.isEnabled}},anchorX:r.x,anchorY:r.y,snap:n,isExact:o,isPrecise:s,arrowKind:i,showEdgeHints:!o&&"elbow"===i}}]}render(e,t){let n=t[0];if(!n)return;let r=this.editor,i=r.getZoomLevel(),o=r.getCurrentTheme().colors[r.getColorMode()],{targetId:s,handles:a,anchorX:l,anchorY:d,snap:c,showEdgeHints:u}=n.props,h=r.getShape(s);if(h){let t=r.getShapePageTransform(h),n=wM.get(r,s);t&&n&&(e.save(),e.transform(t.a,t.b,t.c,t.d,t.e,t.f),e.strokeStyle=o.selectionStroke,e.lineWidth=this.options.lineWidth/i,e.lineCap="round",e.lineJoin="round",this._renderIndicatorPath(e,n),e.restore())}if(!u)return;if("edge"===c||"edge-point"===c){let t=("edge-point"===c?this.options.edgePointRadius:this.options.edgeRadius)/i;e.beginPath(),e.arc(l,d,t,0,2*Math.PI),e.fillStyle=o.selectionFill,e.fill()}let p=this.options.handleRadius/i;for(let t of(e.fillStyle=o.selectedContrast,e.strokeStyle=o.selectionStroke,e.lineWidth=this.options.lineWidth/i,e.beginPath(),Object.values(a)))t.isEnabled&&(e.moveTo(t.x+p,t.y),e.arc(t.x,t.y,p,0,2*Math.PI));e.fill(),e.stroke()}_renderIndicatorPath(e,t){if(t instanceof Path2D)e.stroke(t);else{let{path:n,clipPath:r,additionalPaths:i}=t;if(r?(e.save(),e.clip(r,"evenodd"),e.stroke(n),e.restore()):e.stroke(n),i)for(let t of i)e.stroke(t)}}}class wj extends h.bU{static type="brush";options={zIndex:300,getDefaultDisplayValues(e,t,n,r){let i=n.colors[r];return{fillColor:i.brushFill,strokeColor:i.brushStroke,lineWidth:1}},getCustomDisplayValues:()=>({})};isActive(){return null!==this.editor.getInstanceState().brush}getOverlays(){let e=this.editor.getInstanceState().brush;return e?[{id:"brush",type:"brush",props:{x:e.x,y:e.y,w:Math.max(1,e.w),h:Math.max(1,e.h)}}]:[]}render(e,t){let n=t[0];if(!n)return;let{x:r,y:i,w:o,h:s}=n.props,a=this.editor.getZoomLevel(),l=(0,h.tjK)(this,n);e.fillStyle=l.fillColor,e.fillRect(r,i,o,s),e.lineWidth=l.lineWidth/a,e.strokeStyle=l.strokeColor,e.strokeRect(r,i,o,s)}renderMinimap(e,t,n){let r=t[0];if(!r)return;let{x:i,y:o,w:s,h:a}=r.props,l=(0,h.tjK)(this,r);e.fillStyle=l.fillColor,e.fillRect(i,o,s,a),e.lineWidth=l.lineWidth/n,e.strokeStyle=l.strokeColor,e.strokeRect(i,o,s,a)}}class wO extends h.bU{static type="zoom_brush";options={zIndex:400,lineWidth:1};isActive(){return null!==this.editor.getInstanceState().zoomBrush}getOverlays(){let e=this.editor.getInstanceState().zoomBrush;return e?[{id:"zoom_brush",type:"zoom_brush",props:{x:e.x,y:e.y,w:Math.max(1,e.w),h:Math.max(1,e.h)}}]:[]}render(e,t){let n=t[0];if(!n)return;let{x:r,y:i,w:o,h:s}=n.props,a=this.editor.getZoomLevel(),l=this.editor.getCurrentTheme().colors[this.editor.getColorMode()];e.fillStyle=l.brushFill,e.fillRect(r,i,o,s),e.lineWidth=this.options.lineWidth/a,e.strokeStyle=l.brushStroke,e.strokeRect(r,i,o,s)}renderMinimap(e,t,n){let r=t[0];if(!r)return;let{x:i,y:o,w:s,h:a}=r.props,l=this.editor.getCurrentTheme().colors[this.editor.getColorMode()];e.fillStyle=l.brushFill,e.fillRect(i,o,s,a),e.lineWidth=this.options.lineWidth/n,e.strokeStyle=l.brushStroke,e.strokeRect(i,o,s,a)}}let wD=e=>e*(2-e),wL=e=>--e*e*e+1,{min:wF}=Math,wR=256,wz=new Float64Array(256),wN=new Float64Array(wR),w$=new Float64Array(wR),wB=new Float64Array(wR),wH=new Float64Array(wR),wU=new Float64Array(wR),wW=new Float64Array(wR),wK=new Float64Array(wR),wV=new Float64Array(wR),wY=0,wG=256,wq=new Float64Array(256),wX=new Float64Array(wG),wJ=new Float64Array(wG);function wZ(e,t){let n=void 0===e.z?1:e.z;return t&&n<.025?.025:n}function wQ(e,t={}){let{streamline:n=.5,size:r=16,simulatePressure:i=!1}=t;wY=0;let o=e.length;if(0===o)return;let s=.15+(1-n)*.85;var a=o+8;if(!(a<=wG)){for(;wG<a;)wG*=2;wq=new Float64Array(wG),wX=new Float64Array(wG),wJ=new Float64Array(wG)}var l=o+8;if(!(l<=wR)){for(;wR<l;)wR*=2;wz=new Float64Array(wR),wN=new Float64Array(wR),w$=new Float64Array(wR),wB=new Float64Array(wR),wH=new Float64Array(wR),wU=new Float64Array(wR),wW=new Float64Array(wR),wK=new Float64Array(wR),wV=new Float64Array(wR)}let d=wq,c=wX,u=wJ,h=(r/3)**2,p=!i,f=e[0],g=wZ(f,p),m=1;for(;m<o;){let t=e[m],n=t.x-f.x,r=t.y-f.y;if(n*n+r*r>h)break;g=Math.max(g,wZ(t,p)),m++}d[0]=f.x,c[0]=f.y,u[0]=g;let y=1;for(let t=m;t<o;t++){let n=e[t];d[y]=n.x,c[y]=n.y,u[y]=wZ(n,p),y++}let b=0;if(y>1){let e=d[y-1],t=c[y-1],n=y-2;for(;n>=0;){let r=d[n]-e,i=c[n]-t;if(r*r+i*i>h)break;n--,b++}n<y-2&&(d[n+1]=e,c[n+1]=t,u[n+1]=u[y-1],y=n+2)}let x=t.last||!t.simulatePressure||y>1&&(d[y-1]-d[y-2])*(d[y-1]-d[y-2])+(c[y-1]-c[y-2])*(c[y-1]-c[y-2])<r**2||b>0;if(2===y&&t.simulatePressure){let e=d[0],t=c[0],n=u[0],r=d[1],i=c[1],o=u[1];for(let s=1;s<5;s++){let a=s/4;d[s]=e+(r-e)*a,c[s]=t+(i-t)*a,u[s]=(n+(o-n))*s/4}y=5}let w=wz,v=wN,S=w$,C=wB,k=wH,P=wU,T=wW,E=wK,I=wV;w[0]=d[0],v[0]=c[0],S[0]=d[0],C[0]=c[0],k[0]=u[0],P[0]=i?.5:u[0],T[0]=0,E[0]=0,I[0]=1;let _=1;x&&n>0&&(d[y]=d[y-1],c[y]=c[y-1],u[y]=u[y-1],y++);let M=0,A=d[0],j=c[0],O=1-s,D=t.last;for(let e=1;e<y;e++){let t,n;if(!s||D&&e===y-1?(t=d[e],n=c[e]):(t=d[e]+(A-d[e])*O,n=c[e]+(j-c[e])*O),1e-4>Math.abs(A-t)&&1e-4>Math.abs(j-n))continue;let o=((n-j)**2+(t-A)**2)**.5;M+=o,e<4&&M<r||(w[_]=t,v[_]=n,S[_]=d[e],C[_]=c[e],k[_]=u[e],P[_]=i?.5:u[e],T[_]=o,E[_]=M,I[_]=1,_++,A=t,j=n)}if(M<1){let e=.5;for(let t=0;t<_;t++)e=Math.max(e,P[t]);for(let t=0;t<_;t++)P[t]=e}wY=_}function w0(e,t,n){return e?!0===e?Math.max(t,n):e:0}function w1(e){let{size:t=16,thinning:n=.5,simulatePressure:r=!0,easing:i=e=>e,start:o={},end:s={}}=e,{easing:a=wD}=o,{easing:l=wL}=s,d=wY,c=wU,u=wW,h=wK,p=wV,f=h[d-1];if(!r&&f<t){let e=.5;for(let t=0;t<d;t++)e=Math.max(e,c[t]);for(let r=0;r<d;r++)c[r]=e,p[r]=t*i(.5-n*(.5-e));return}let g=c[0];for(let e=0;e<d;e++){let n;if(h[e]>5*t)break;let i=wF(1,u[e]/t);if(r){let e=wF(1,1-i);n=wF(1,g+.275*i*(e-g))}else n=wF(1,g+(c[e]-g)*.5);g+=(n-g)*.5}let m=w0(o.taper,t,f),y=w0(s.taper,t,f),b=m||y;for(let e=0;e<d;e++){let o;if(n){let s=c[e],a=wF(1,u[e]/t);if(r){let e=wF(1,1-a);s=wF(1,g+.275*a*(e-g))}else s=wF(1,g+.275*a*(s-g));o=t*i(.5-n*(.5-s)),g=s}else o=t/2;if(b){let t=h[e];o=Math.max(.01,o*Math.min(t<m?a(t/m):1,f-t<y?l((f-t)/y):1))}p[e]=o}}let w2=256,w3=new Float64Array(256),w5=new Float64Array(w2),w6=new Float64Array(w2),w4=new Float64Array(w2),w8=new Float64Array(w2),w9=new Float64Array(w2),w7=new Float64Array(w2),ve=new Uint8Array(w2),vt=0;function vn(e){if(!(e<=w2)){for(;w2<e;)w2*=2;w3=new Float64Array(w2),w5=new Float64Array(w2),w6=new Float64Array(w2),w4=new Float64Array(w2),w8=new Float64Array(w2),w9=new Float64Array(w2),w7=new Float64Array(w2),ve=new Uint8Array(w2)}}function vr(){let e=wY;vn(e);let t=w3,n=w5,r=w6,i=w4,o=w8,s=w9,a=w7,l=ve,d=wz,c=wN,u=w$,h=wB,p=wH,f=wK,g=wV;for(let m=0;m<e;m++)t[m]=d[m],n[m]=c[m],r[m]=p[m],i[m]=u[m],o[m]=h[m],s[m]=g[m],a[m]=f[m],l[m]=+(0===m||m===e-1);vt=e}let{PI:vi}=Math,vo=vi+1e-4,vs=1024,va=new Float64Array(1024),vl=new Float64Array(vs),vd=new Float64Array(vs),vc=new Float64Array(vs),vu=0,vh=0;function vp(e,t,n,r){if(n<=2||r<=0)return n;let i=r*r,o=1,s=0,a=n-1;for(;s<a;){let n=s+1,r=s+8>a?a:s+8,l=e[s],d=t[s];r:for(let o=s+2;o<=r;o++){let r=e[o]-l,a=t[o]-d,c=r*r+a*a;for(let n=s+1;n<o;n++){let o=0===c?0:((e[n]-l)*r+(t[n]-d)*a)/c;o=o<0?0:o>1?1:o;let s=e[n]-(l+r*o),u=t[n]-(d+a*o);if(s*s+u*u>i)break r}n=o}e[o]=e[n],t[o]=t[n],o++,s=n}return o}function vf(e,t,n,r){let{size:i=16,smoothing:o=.5}=e,s=0,a=0;vu=0,vh=0;let l=vt;if(0===l||i<=0)return;let d=w3,c=w5,u=w4,h=w8,p=w9,f=w7,g=ve,m=va,y=vl,b=vd,x=vc,w=f[l-1],v=Math.pow(i*o,2),S=1,C=1;if(l>1){let e=d[0]-d[1],t=c[0]-c[1],n=(e*e+t*t)**.5;0===n?(S=e,C=t):(S=e/n,C=t/n)}let k=S,P=C,T=d[0],E=c[0],I=T,_=E,M=T,A=E,j=I,O=_,D=!1;for(let e=0;e<l;e++){let i=d[e],o=c[e],L=p[e],F=S,R=C,z=F,N=R;if(e<l-1){let s=0===e&&l>2&&t?n:i,a=0===e&&l>2&&t?r:o,u=s-d[e+1],h=a-c[e+1],p=(u*u+h*h)**.5;0===p?(z=u,N=h):(z=u/p,N=h/p)}S=z,C=N,(s+13+1>vs||a+13+1>vs)&&(!function(){let e=new Float64Array(vs*=2);e.set(va),va=e;let t=new Float64Array(vs);t.set(vl),vl=t;let n=new Float64Array(vs);n.set(vd),vd=n;let r=new Float64Array(vs);r.set(vc),vc=r}(),m=va,y=vl,b=vd,x=vc);let $=F*k+R*P,B=e<l-1?z*F+N*R:1,H=B<.2;if($<0&&!D||H){if(B>-.62&&w-f[e]>L){let e=k*L,t=P*L;k*N-P*z<0?(M=i+e,A=o+t,j=i-e,O=o-t):(M=i-e,A=o-t,j=i+e,O=o+t),m[s]=M,y[s]=A,s++,b[a]=j,x[a]=O,a++}else{let t=u[e],n=h[e],r=-P*L,i=k*L;for(let e=0;e<1;e+=.07692307692307693){let o=vo*e,l=Math.sin(o),d=Math.cos(o);M=t+(r*d-i*l),A=n+(r*l+i*d),m[s]=M,y[s]=A,s++,l=Math.sin(o=vo+-(vo*e)),j=t+(r*(d=Math.cos(o))-i*l),O=n+(r*l+i*d),b[a]=j,x[a]=O,a++}}T=M,E=A,I=j,_=O,H&&(D=!0);continue}if(D=!1,g[e]){let e=R*L,t=-F*L;m[s]=i-e,y[s]=o-t,s++,b[a]=i+e,x[a]=o+t,a++;continue}let U=z+(F-z)*B,W=(N+(R-N)*B)*L,K=-U*L;M=i-W,A=o-K,(e<=1||(T-M)**2+(E-A)**2>v)&&(m[s]=M,y[s]=A,s++,T=M,E=A),j=i+W,O=o+K,(e<=1||(I-j)**2+(_-O)**2>v)&&(b[a]=j,x[a]=O,a++,I=j,_=O),k=F,P=R}let L=.05*i;vu=vp(va,vl,s,L),vh=vp(vd,vc,a,L)}function vg(e,t,n,r,i){if(e<=n)return r;let o=Math.ceil(t/(2*Math.acos(1-n/e)));return o<r?r:o>i?i:o}function vm(e,t={}){return(wQ(e,t),0===wY)?[]:(w1(t),vr(),function(e={}){let{size:t=16,start:n={},end:r={},last:i=!1}=e,{cap:o=!0}=n,{cap:s=!0}=r,a=vt;if(0===a||t<=0)return[];let l=w7[a-1],d=w0(n.taper,t,l),c=w0(r.taper,t,l);vf(e,!1,0,0);let u=Math.max(.05,.02*t),p=w9[0],f=new h.l2P(w3[0],w5[0],w6[0]),g=a>1?new h.l2P(w3[a-1],w5[a-1],w6[a-1]):h.l2P.AddXY(f,1,1);if(1===a&&(!(d||c)||i)){let e=h.l2P.Add(f,h.l2P.Sub(f,g).uni().per().mul(-p)),t=[],n=vg(p,2*vo,u,8,13);for(let r=1/n,i=r;i<=1;i+=r)t.push(h.l2P.RotWith(e,f,2*vo*i));return t}let m=[];if(d||c&&1===a);else if(o){let e=new h.l2P(vd[0],vc[0]),t=vg(p,vo,u,4,8);for(let n=1/t,r=n;r<=1;r+=n){let t=h.l2P.RotWith(e,f,vo*r);m.push(t)}}else{let e=new h.l2P(va[0]-vd[0],vl[0]-vc[0]),t=h.l2P.Mul(e,.5),n=h.l2P.Mul(e,.51);m.push(h.l2P.Sub(f,t),h.l2P.Sub(f,n),h.l2P.Add(f,n),h.l2P.Add(f,t))}let y=[],b=w9[a-1],x=1,w=1;if(a>1){let e=w3[a-2]-w3[a-1],t=w5[a-2]-w5[a-1],n=(e*e+t*t)**.5;0===n?(x=e,w=t):(x=e/n,w=t/n)}let v=new h.l2P(-w,x);if(c||d&&1===a)y.push(g);else if(s){let e=h.l2P.Add(g,h.l2P.Mul(v,b)),t=vg(b,3*vo,u,8,29);for(let n=1/t,r=n;r<1;r+=n)y.push(h.l2P.RotWith(e,g,3*vo*r))}else y.push(h.l2P.Add(g,h.l2P.Mul(v,b)),h.l2P.Add(g,h.l2P.Mul(v,.99*b)),h.l2P.Sub(g,h.l2P.Mul(v,.99*b)),h.l2P.Sub(g,h.l2P.Mul(v,b)));let S=va,C=vl,k=vd,P=vc,T=Array(vu);for(let e=0;e<vu;e++)T[e]=new h.l2P(S[e],C[e]);let E=Array(vh);for(let e=0;e<vh;e++)E[e]=new h.l2P(k[vh-1-e],P[vh-1-e]);return T.concat(y,E,m)}(t))}class vy extends h.bU{static type="scribble";options={zIndex:600,streamline:.32,cacheSize:500};_scribblePathCache=new Map;isActive(){return this.editor.getInstanceState().scribbles.length>0}getOverlays(){return this.editor.getInstanceState().scribbles.map(e=>({id:`scribble:${e.id}`,type:"scribble",props:{scribble:e}}))}render(e,t){let n=this.editor.getZoomLevel(),r=this.editor.getCurrentTheme().colors[this.editor.getColorMode()];for(let i of t){let t,{scribble:o}=i.props,s=o.points.length;if(!s)continue;let a=o.points[s-1],l=this._scribblePathCache.get(o.id);if(l&&l.len===s&&l.lastX===a.x&&l.lastY===a.y&&l.zoom===n&&l.size===o.size&&l.taper===o.taper&&l.state===o.state)t=l.path;else{let e,r=vm(o.points,{size:o.size/n,start:{taper:o.taper,easing:h.Z4H.linear},last:"complete"===o.state||"stopping"===o.state,simulatePressure:!1,streamline:this.options.streamline});if(r.length<4){let t=o.size/n/2,{x:r,y:i}=a;e=`M ${r-t},${i} a ${t},${t} 0 1,0 ${2*t},0 a ${t},${t} 0 1,0 ${-(2*t)},0`}else e=(0,h.JDT)(r);t=new Path2D(e),this._scribblePathCache.set(o.id,{len:s,lastX:a.x,lastY:a.y,zoom:n,size:o.size,taper:o.taper,state:o.state,path:t}),this._scribblePathCache.size>this.options.cacheSize&&this._scribblePathCache.clear()}e.fillStyle=function(e,t){switch(t){case"accent":case"selection-stroke":return e.selectionStroke;case"selection-fill":return e.selectionFill;case"white":return e.selectedContrast;case"black":default:return e.text;case"laser":return e.laser;case"muted-1":return e.brushFill}}(r,o.color),e.globalAlpha=o.opacity,e.fill(t),e.globalAlpha=1}}}let vb=null;class vx extends h.bU{static type="collaborator_hint";options={zIndex:900,lineWidth:3,viewportPadding:5};isActive(){let e=this.editor.getViewportPageBounds(),t=this.editor.getZoomLevel();return this.editor.getVisibleCollaboratorsOnCurrentPage().some(n=>{let{cursor:r}=n;return!!r&&!(0,h.KHk)(r,e,t)})}getOverlays(){let e=[],t=this.editor.getViewportPageBounds(),n=this.editor.getZoomLevel();for(let r of this.editor.getVisibleCollaboratorsOnCurrentPage()){let{cursor:i,color:o,userId:s}=r;if(!i||(0,h.KHk)(i,t,n))continue;let a=this.options.viewportPadding/n,l=(0,h.qE8)(i.x,t.minX+a,t.maxX-a),d=(0,h.qE8)(i.y,t.minY+a,t.maxY-a),c=h.l2P.Angle(t.center,i);e.push({id:`collaborator_hint:${s}`,type:"collaborator_hint",props:{x:l,y:d,rotation:c,color:o}})}return e}render(e,t){let n=1/this.editor.getZoomLevel();for(let r of t){let{x:t,y:i,rotation:o,color:s}=r.props;e.save(),e.translate(t,i),e.scale(n,n),e.rotate(o);let a=(vb||(vb=new Path2D("M -2 -5 L 2 0 L -2 5 Z")),vb);e.lineWidth=this.options.lineWidth,e.strokeStyle="#ffffff",e.stroke(a),e.fillStyle=s,e.fill(a),e.restore()}}}class vw extends h.bU{static type="collaborator_brush";options={zIndex:700,lineWidth:1};isActive(){return this.editor.getVisibleCollaboratorsOnCurrentPage().some(e=>null!==e.brush)}getOverlays(){let e=[];for(let t of this.editor.getVisibleCollaboratorsOnCurrentPage()){let{brush:n,color:r,userId:i}=t;n&&e.push({id:`collaborator_brush:${i}`,type:"collaborator_brush",props:{x:n.x,y:n.y,w:Math.max(1,n.w),h:Math.max(1,n.h),color:r}})}return e}render(e,t){let n=this.editor.getZoomLevel();for(let r of t){let{x:t,y:i,w:o,h:s,color:a}=r.props;e.globalAlpha=.075,e.fillStyle=a,e.fillRect(t,i,o,s),e.globalAlpha=.1,e.strokeStyle=a,e.lineWidth=this.options.lineWidth/n,e.strokeRect(t,i,o,s),e.globalAlpha=1}}renderMinimap(e,t){for(let n of t){let{x:t,y:r,w:i,h:o,color:s}=n.props;e.globalAlpha=.75,e.fillStyle=s,e.fillRect(t,r,i,o)}e.globalAlpha=1}}class vv extends h.bU{static type="collaborator_scribble";options={zIndex:800,streamline:.32,cacheSize:500};_collabScribblePathCache=new Map;isActive(){return this.editor.getVisibleCollaboratorsOnCurrentPage().some(e=>e.scribbles.length>0)}getOverlays(){let e=[];for(let t of this.editor.getVisibleCollaboratorsOnCurrentPage()){let{scribbles:n,color:r,userId:i}=t;for(let t of n)e.push({id:`collaborator_scribble:${i}:${t.id}`,type:"collaborator_scribble",props:{scribble:t,color:r}})}return e}render(e,t){let n=this.editor.getZoomLevel();for(let r of t){let t,{scribble:i,color:o}=r.props,s=i.points.length;if(!s)continue;let a=i.points[s-1],l=r.id,d=this._collabScribblePathCache.get(l);if(d&&d.len===s&&d.lastX===a.x&&d.lastY===a.y&&d.zoom===n&&d.size===i.size&&d.taper===i.taper&&d.state===i.state)t=d.path;else{let e,r=vm(i.points,{size:i.size/n,start:{taper:i.taper,easing:h.Z4H.linear},last:"complete"===i.state||"stopping"===i.state,simulatePressure:!1,streamline:this.options.streamline});if(r.length<4){let t=i.size/n/2,{x:r,y:o}=a;e=`M ${r-t},${o} a ${t},${t} 0 1,0 ${2*t},0 a ${t},${t} 0 1,0 ${-(2*t)},0`}else e=(0,h.JDT)(r);t=new Path2D(e),this._collabScribblePathCache.set(l,{len:s,lastX:a.x,lastY:a.y,zoom:n,size:i.size,taper:i.taper,state:i.state,path:t}),this._collabScribblePathCache.size>this.options.cacheSize&&this._collabScribblePathCache.clear()}e.fillStyle=o,e.globalAlpha="laser"===i.color?.5:.1,e.fill(t),e.globalAlpha=1}}}class vS extends h.bU{static type="collaborator_shape_indicator";options={zIndex:49,lineWidth:1.5,alpha:.7};isActive(){return this.editor.getVisibleCollaboratorsOnCurrentPage().some(e=>e.selectedShapeIds.length>0)}getOverlays(){let e=this.editor,t=e.getVisibleCollaboratorsOnCurrentPage().filter(e=>e.selectedShapeIds.length>0);if(0===t.length)return[];let n=new Set(e.getRenderingShapes().map(e=>e.id)),r=[];for(let i of t){let t=i.selectedShapeIds.filter(t=>n.has(t)&&!e.isShapeHidden(t));0!==t.length&&r.push({color:i.color,shapeIds:t})}return 0===r.length?[]:[{id:"collaborator_shape_indicator",type:"collaborator_shape_indicator",props:{indicators:r}}]}render(e,t){let n=t[0];if(!n)return;let r=this.editor,i=r.getZoomLevel();for(let{color:t,shapeIds:o}of(e.lineCap="round",e.lineJoin="round",e.lineWidth=this.options.lineWidth/i,e.globalAlpha=this.options.alpha,n.props.indicators))e.strokeStyle=t,(0,h.APM)(r,e,o);e.globalAlpha=1}}class vC extends h.bU{static type="shape_handle";options={zIndex:200,lineWidth:1.5};isActive(){let e=this.editor;if(e.getIsReadonly()||e.getInstanceState().isChangingStyle)return!1;let t=e.getOnlySelectedShape();return!!t&&!!e.getShapeHandles(t)&&(!!e.isInAny("select.idle","select.pointing_handle")||!!e.isIn("select.editing_shape")&&e.isShapeOfType(t,"note"))}getOverlays(){let e=this.editor,t=e.getOnlySelectedShape();if(!t)return[];let n=e.getShapeHandles(t);if(!n||e.isShapeHidden(t))return[];let r=e.getZoomLevel(),i=(e.getInstanceState().isCoarsePointer?e.options.coarseHandleRadius:e.options.handleRadius)/r*2,o=n.filter(e=>"vertex"===e.type),s=[],a=[];for(let e of n)"virtual"===e.type&&o.some(t=>h.l2P.Dist(e,t)<i)||("vertex"===e.type?s.push(e):a.push(e));return s.concat(a).map(e=>({id:`handle:${t.id}:${e.id}`,type:"shape_handle",props:{shapeId:t.id,handle:e}}))}getGeometry(e){let t=this.editor,{shapeId:n,handle:r}=e.props,i=t.getShapePageTransform(n);if(!i)return null;let o=t.getZoomLevel(),s=(t.getInstanceState().isCoarsePointer?t.options.coarseHandleRadius:t.options.handleRadius)/o,a=h.V8r.applyToPoint(i,{x:r.x,y:r.y});return new h.PUi({x:a.x-s,y:a.y-s,radius:s,isFilled:!0})}getCursor(e){return"grab"}render(e,t){if(0===t.length)return;let n=this.editor,r=t[0].props.shapeId,i=n.getShapePageTransform(r);if(!i)return;let o=n.getZoomLevel(),s=n.getInstanceState().isCoarsePointer,a=n.getCurrentTheme().colors[n.getColorMode()],l=a.selectedContrast,d=a.selectionStroke,c=a.selectionFill,u=n.overlays.getHoveredOverlayId(),p=(s?n.options.coarseHandleRadius:n.options.handleRadius)/o;e.save(),e.transform(i.a,i.b,i.c,i.d,i.e,i.f),e.strokeStyle=d,e.lineWidth=this.options.lineWidth/o;for(let n=t.length-1;n>=0;n--){let r=t[n],{handle:i}=r.props,a=r.id===u;if("create"===i.type&&!s&&!a)continue;if(a&&(e.fillStyle=c,e.beginPath(),e.arc(i.x,i.y,p,0,2*Math.PI),e.fill()),"clone"===i.type){let t=3/o,n=-Math.PI/2*(1-h.BV.indexOf(i.id));e.save(),e.translate(i.x,i.y),e.rotate(n),e.fillStyle=d,e.beginPath(),e.moveTo(0,-t),e.arc(0,0,t,-Math.PI/2,Math.PI/2),e.closePath(),e.fill(),e.restore();continue}let f=("create"===i.type&&s?3:4)/Math.max(o,.25);e.fillStyle=l,e.beginPath(),e.arc(i.x,i.y,f,0,2*Math.PI),e.fill(),e.stroke()}e.restore()}}var vk=n(83102);class vP extends h.bU{static type="shape_indicator";options={zIndex:50,lineWidth:1.5,hintedLineWidth:2.5};_instanceFlags$=(0,vk.EW)("shape indicator instance flags",()=>{let e=this.editor.getInstanceState();return{isChangingStyle:e.isChangingStyle,isHoveringCanvas:e.isHoveringCanvas,isCoarsePointer:e.isCoarsePointer}},{isEqual:(e,t)=>e.isChangingStyle===t.isChangingStyle&&e.isHoveringCanvas===t.isHoveringCanvas&&e.isCoarsePointer===t.isCoarsePointer});isActive(){return!0}getOverlays(){let e=this.editor,t=new Set(e.getRenderingShapes().map(e=>e.id)),n=[],{isChangingStyle:r,isHoveringCanvas:i,isCoarsePointer:o}=this._instanceFlags$.get(),s=e.isInAny("select.idle","select.editing_shape"),a=e.isInAny("select.brushing","select.scribble_brushing","select.pointing_shape","select.pointing_selection","select.pointing_handle","select.pointing_resize_handle","select.pointing_rotate_handle");if(!r&&(s||a)){for(let r of e.getSelectedShapeIds())t.has(r)&&n.push(r);if(s&&i&&!o){let r=e.getHoveredShapeId();r&&t.has(r)&&!n.includes(r)&&n.push(r)}}let l=[];for(let n of e.getHintingShapeIds())t.has(n)&&l.push(n);return 0===n.length&&0===l.length?[]:[{id:"shape_indicator",type:"shape_indicator",props:{idsToDisplay:n,hintingShapeIds:l}}]}render(e,t){let n=t[0];if(!n)return;let r=this.editor,i=r.getZoomLevel(),{idsToDisplay:o,hintingShapeIds:s}=n.props;e.lineCap="round",e.lineJoin="round",e.strokeStyle=r.getCurrentTheme().colors[r.getColorMode()].selectionStroke,e.lineWidth=this.options.lineWidth/i,(0,h.APM)(r,e,o),s.length>0&&(e.lineWidth=this.options.hintedLineWidth/i,(0,h.APM)(r,e,s))}}let vT=Math.sqrt(Math.PI),vE={top_left_rotate:"nwse-rotate",top_right_rotate:"nesw-rotate",bottom_left_rotate:"swne-rotate",bottom_right_rotate:"senw-rotate"},vI={top_left:"nwse-resize",top_right:"nesw-resize",bottom_right:"nwse-resize",bottom_left:"nesw-resize",top:"ns-resize",bottom:"ns-resize",left:"ew-resize",right:"ew-resize"};class v_ extends h.bU{static type="selection_foreground";options={zIndex:100,lineWidth:1.5};isActive(){return!!this.editor.getSelectionRotatedPageBounds()&&this.editor.isInAny("select.idle","select.brushing","select.scribble_brushing","select.pointing_canvas","select.pointing_selection","select.pointing_shape","select.pointing_resize_handle","select.pointing_rotate_handle","select.resizing","select.crop.idle","select.crop.pointing_crop","select.crop.pointing_crop_handle")}getOverlays(){let e=this._computeSelectionState();if(!e)return[];let t=[];return this._collectResizeCornerOverlays(e,t),this._collectResizeEdgeOverlays(e,t),this._collectRotateOverlays(e,t),t}getGeometry(e){let t=this._computeSelectionState();if(!t)return null;let n=h.V8r.Compose(h.V8r.Translate(t.bounds.x,t.bounds.y),h.V8r.Rotate(t.rotation),h.V8r.Translate(t.expandOffsetX,t.expandOffsetY)),{overlayType:r,handle:i}=e.props;switch(r){case"resize_handle":return this._getResizeHandleGeometry(i,t,n);case"rotate_handle":return this._getRotateHandleGeometry(i,t,n);case"mobile_rotate":return this._getMobileRotateGeometry(t,n);default:return null}}render(e,t){let n=this._computeSelectionState();if(!n)return;e.save(),e.translate(n.bounds.x,n.bounds.y),e.rotate(n.rotation),e.translate(n.expandOffsetX,n.expandOffsetY);let r=this._getThemeColors();this._renderSelectionBox(e,n,r),this._renderResizeCorners(e,n,r),this._renderCropHandles(e,n,r),this._renderMobileRotateHandle(e,n,r),this._renderTextResizeHandles(e,n,r),e.restore()}getCursor(e){let{overlayType:t,handle:n}=e.props;switch(t){case"rotate_handle":return vE[n];case"mobile_rotate":return"grab";case"resize_handle":return vI[n];default:return}}_collectResizeCornerOverlays(e,t){e.showHandles&&(t.push(this._makeOverlay("resize_handle","top_left")),e.hideAlternateCornerHandles||(t.push(this._makeOverlay("resize_handle","top_right")),t.push(this._makeOverlay("resize_handle","bottom_left"))),(!e.showOnlyOneHandle||e.showCropHandles)&&t.push(this._makeOverlay("resize_handle","bottom_right")))}_collectResizeEdgeOverlays(e,t){if(!e.showHandles)return;let{showCropHandles:n,hideAlternateCropHandles:r,hideAlternateCornerHandles:i,showOnlyOneHandle:o,isCoarsePointer:s,onlyShape:a}=e,l=n?r:i||o||s,d=s&&!!a&&"text"===a.type;l||(t.push(this._makeOverlay("resize_handle","top")),t.push(this._makeOverlay("resize_handle","bottom"))),(n?r:l&&!d)||(t.push(this._makeOverlay("resize_handle","right")),t.push(this._makeOverlay("resize_handle","left")))}_collectRotateOverlays(e,t){e.showCornerRotateHandles&&(t.push(this._makeOverlay("rotate_handle","top_left_rotate")),t.push(this._makeOverlay("rotate_handle","top_right_rotate")),t.push(this._makeOverlay("rotate_handle","bottom_left_rotate")),t.push(this._makeOverlay("rotate_handle","bottom_right_rotate"))),e.showMobileRotateHandle&&t.push(this._makeOverlay("mobile_rotate","mobile_rotate"))}_getResizeHandleGeometry(e,t,n){if("top"===e||"bottom"===e||"left"===e||"right"===e){let r=this._getEdgeLocalRect(e,t);return new h.dxv({points:this._localRectToPoints(r.x,r.y,r.w,r.h).map(e=>h.V8r.applyToPoint(n,e)),isFilled:!0})}let r=this._getCornerLocalPoint(e,t.width,t.height),i=1.5*Math.max(t.hitTargetSizeX,t.hitTargetSizeY);return new h.dxv({points:this._localRectToPoints(r.x-i,r.y-i,2*i,2*i).map(e=>h.V8r.applyToPoint(n,e)),isFilled:!0})}_getRotateHandleGeometry(e,t,n){let r=1.62*Math.max(t.hitTargetSizeX,t.hitTargetSizeY),i=this._getRotateHandleLocalCenter(e,t.width,t.height,r);return new h.krb({x:i.x-r,y:i.y-r,width:2*r,height:2*r,isFilled:!0}).transform(n)}_getMobileRotateGeometry(e,t){let n=Math.max(14*(1/e.zoom),20/Math.max(1,e.zoom)),{cx:r,cy:i}=this._getMobileRotateCenter(e);return new h.dxv({points:this._localRectToPoints(r-n,i-n,2*n,2*n).map(e=>h.V8r.applyToPoint(t,e)),isFilled:!0})}_renderSelectionBox(e,t,n){t.shouldDisplayBox&&(e.strokeStyle=n.strokeColor,e.lineWidth=this.options.lineWidth/t.zoom,e.strokeRect(0,0,t.width,t.height))}_renderResizeCorners(e,t,n){if(!t.showResizeHandles)return;let{handleSize:r,width:i,height:o,hideAlternateCornerHandles:s,showOnlyOneHandle:a,zoom:l}=t;e.fillStyle=n.bgColor,e.strokeStyle=n.strokeColor,e.lineWidth=this.options.lineWidth/l;let d=(t,n,i)=>{i||(e.fillRect(t-r/2,n-r/2,r,r),e.strokeRect(t-r/2,n-r/2,r,r))};d(0,0,!1),d(i,0,s),d(i,o,a),d(0,o,s)}_renderCropHandles(e,t,n){if(!t.showCropHandles)return;let{handleSize:r,width:i,height:o,hideAlternateCropHandles:s}=t,a=r/3,l=a/2;e.beginPath(),e.strokeStyle=n.strokeColor,e.lineWidth=a,e.lineCap="butt",e.lineJoin="miter",e.moveTo(-l,r),e.lineTo(-l,-l),e.lineTo(r,-l),e.moveTo(i+l,o-r),e.lineTo(i+l,o+l),e.lineTo(i-r,o+l),s||(e.moveTo(i-r,-l),e.lineTo(i+l,-l),e.lineTo(i+l,r),e.moveTo(r,o+l),e.lineTo(-l,o+l),e.lineTo(-l,o-r),e.moveTo(i/2-r,-l),e.lineTo(i/2+r,-l),e.moveTo(i+l,o/2-r),e.lineTo(i+l,o/2+r),e.moveTo(i/2-r,o+l),e.lineTo(i/2+r,o+l),e.moveTo(-l,o/2-r),e.lineTo(-l,o/2+r)),e.stroke()}_renderMobileRotateHandle(e,t,n){if(!t.showMobileRotateHandle)return;let{cx:r,cy:i}=this._getMobileRotateCenter(t),o=t.handleSize/vT;e.fillStyle=n.bgColor,e.strokeStyle=n.strokeColor,e.lineWidth=this.options.lineWidth/t.zoom,e.beginPath(),e.arc(r,i,o,0,2*Math.PI),e.fill(),e.stroke()}_renderTextResizeHandles(e,t,n){let{shouldDisplayControls:r,isCoarsePointer:i,onlyShape:o,zoom:s,width:a,height:l,handleSize:d,hitTargetSizeY:c}=t;if(!r||!i||!o||"text"!==o.type)return;let u=Math.min(24/s,l-3*c);if(u*s<4)return;let h=d/2,p=d/4;e.fillStyle=n.strokeColor,e.beginPath(),e.roundRect(0-h/2,l/2-u/2,h,u,p),e.fill(),e.beginPath(),e.roundRect(a-h/2,l/2-u/2,h,u,p),e.fill()}_computeSelectionState(){let e=this.editor,t=e.getSelectionRotatedPageBounds();if(!t)return null;let n=e.getOnlySelectedShape();if(n&&e.isShapeHidden(n))return null;let r=n?e.getShapeUtil(n):null,i=!!(n&&e.isShapeOrAncestorLocked(n)),o=n&&r?r.expandSelectionOutlinePx(n):0,s=o instanceof h.azJ?t.clone().expand(o).zeroFix():t.clone().expandBy(o).zeroFix(),a=e.getInstanceState(),l=a.isCoarsePointer,d=a.isChangingStyle,c=e.getIsReadonly(),u=e.getZoomLevel(),p=e.getSelectionRotation(),f=s.width,g=s.height,m=8/u,y=f<2*m,b=g<2*m,x=f<4*m,w=g<4*m,v=l?1.75:1,S=6/u*v,C=s.x-t.x,k=s.y-t.y,P=e.isInAny("select.idle","select.pointing_selection","select.pointing_shape","select.pointing_resize_handle","select.pointing_rotate_handle","select.crop.idle")&&!d&&!c,T=e.isInAny("select.crop.idle","select.crop.pointing_crop","select.crop.pointing_crop_handle")&&!c,E=!n||!r||r.canResize(n)&&!r.hideResizeHandles(n),I=!!n&&!!r&&r.hideRotateHandle(n),_=!!n&&!!r&&r.hideSelectionBoundsFg(n),M=P&&!i&&!T&&E,A=!_&&!d,j=A&&e.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","select.pointing_rotate_handle")||A&&e.isIn("select.resizing")&&!!(n&&e.isShapeOfType(n,"text"));return{bounds:t,onlyShape:n,isCoarsePointer:l,zoom:u,rotation:p,width:f,height:g,handleSize:m,hitTargetSize:S,hitTargetSizeX:.75*v*(x?S/2:S),hitTargetSizeY:.75*v*(w?S/2:S),expandOffsetX:C,expandOffsetY:k,isSmallX:x,shouldDisplayControls:P,shouldDisplayBox:j,showCropHandles:T,showResizeHandles:M,showCornerRotateHandles:P&&!i&&!l&&!(y||b)&&!I,showMobileRotateHandle:P&&!i&&l&&(!x||!w)&&!I,showHandles:M||T,hideAlternateCornerHandles:y||b,hideAlternateCropHandles:f<5*m||g<5*m,showOnlyOneHandle:y&&b}}_getMobileRotateCenter(e){let{width:t,height:n,hitTargetSize:r,isSmallX:i,onlyShape:o,rotation:s}=e,a=this.editor,l=!!o&&(a.isShapeOfType(o,"image")||a.isShapeOfType(o,"video")),d=s/h.sKG>1.6&&s/h.sKG<2.4;return{cx:i?-(1.5*r):t/2,cy:i?n/2:l&&!d?n+1.5*r:-(1.5*r)}}_getThemeColors(){let e=this.editor,t=e.getCurrentTheme().colors[e.getColorMode()];return{strokeColor:t.selectionStroke,bgColor:t.background}}_makeOverlay(e,t){return{id:`selection_fg:${t}`,type:"selection_foreground",props:{overlayType:e,handle:t}}}_getEdgeLocalRect(e,t){let{width:n,height:r,hitTargetSizeX:i,hitTargetSizeY:o}=t;switch(e){case"top":return{x:0,y:-o,w:n,h:2*o};case"right":return{x:n-i,y:0,w:2*i,h:r};case"bottom":return{x:0,y:r-o,w:n,h:2*o};case"left":return{x:-i,y:0,w:2*i,h:r}}}_getRotateHandleLocalCenter(e,t,n,r){switch(e){case"top_left_rotate":return new h.l2P(-r,-r);case"top_right_rotate":return new h.l2P(t+r,-r);case"bottom_left_rotate":return new h.l2P(-r,n+r);case"bottom_right_rotate":return new h.l2P(t+r,n+r);default:return new h.l2P(0,0)}}_getCornerLocalPoint(e,t,n){switch(e){case"top_left":return new h.l2P(0,0);case"top_right":return new h.l2P(t,0);case"bottom_right":return new h.l2P(t,n);case"bottom_left":return new h.l2P(0,n)}}_localRectToPoints(e,t,n,r){return[new h.l2P(e,t),new h.l2P(e+n,t),new h.l2P(e+n,t+r),new h.l2P(e,t+r)]}}class vM extends h.bU{static type="snap_indicator";options={zIndex:500,lineWidth:1};isActive(){return this.editor.snaps.getIndicators().length>0}getOverlays(){return this.editor.snaps.getIndicators().map(e=>({id:`snap:${e.id}`,type:"snap_indicator",props:{line:e}}))}render(e,t){let n=this.editor.getZoomLevel(),r=this.editor.getCurrentTheme().colors[this.editor.getColorMode()].snap;for(let i of t){let{line:t}=i.props;"points"===t.type?this._renderPoints(e,t,n,r):"gaps"===t.type&&this._renderGaps(e,t,n,r)}}_renderPoints(e,t,n,r){let i,o,s,a,{points:l}=t;if(0===l.length)return;let d=2.5/n,c=1/0,u=-1/0,h=1/0,p=-1/0;for(let e of l)e.x<c&&(c=e.x),e.x>u&&(u=e.x),e.y<h&&(h=e.y),e.y>p&&(p=e.y);let f=!1;for(let e of l)if(e.x===c&&e.y===h){f=!0;break}for(let t of(f?(i=c,o=h,s=u,a=p):(i=c,o=p,s=u,a=h),e.strokeStyle=r,e.lineWidth=this.options.lineWidth/n,e.beginPath(),e.moveTo(i,o),e.lineTo(s,a),e.stroke(),e.beginPath(),l))e.moveTo(t.x-d,t.y-d),e.lineTo(t.x+d,t.y+d),e.moveTo(t.x-d,t.y+d),e.lineTo(t.x+d,t.y-d);e.stroke()}_renderGaps(e,t,n,r){let{gaps:i,direction:o}=t;if(0===i.length)return;let s=3.5/n,a=2*s,l="horizontal"===o,d=[-1/0,1/0],c=null;for(let e of i){if(c=(0,h.$Cz)(d[0],d[1],l?e.startEdge[0].y:e.startEdge[0].x,l?e.startEdge[1].y:e.startEdge[1].x))d=c,(c=(0,h.$Cz)(d[0],d[1],l?e.endEdge[0].y:e.endEdge[0].x,l?e.endEdge[1].y:e.endEdge[1].x))&&(d=c)}let u=(d[0]+d[1])/2;for(let{startEdge:t,endEdge:o}of(e.strokeStyle=r,e.lineWidth=this.options.lineWidth/n,e.beginPath(),i))if(l){e.moveTo(t[0].x,u-a),e.lineTo(t[1].x,u+a),e.moveTo(o[0].x,u-a),e.lineTo(o[1].x,u+a),e.moveTo(t[0].x,u),e.lineTo(o[0].x,u);let n=(t[0].x+o[0].x)/2;e.moveTo(n,u-s),e.lineTo(n,u+s)}else{e.moveTo(u-a,t[0].y),e.lineTo(u+a,t[1].y),e.moveTo(u-a,o[0].y),e.lineTo(u+a,o[1].y),e.moveTo(u,t[0].y),e.lineTo(u,o[0].y);let n=(t[0].y+o[0].y)/2;e.moveTo(u-s,n),e.lineTo(u+s,n)}e.stroke()}}let vA=[xR,xz,xF],vj=[wx],vO=[wb,wA,wj,vw,vx,vv,vS,vy,v_,vC,vP,vM,wO];class vD extends h.YM5{static id="idle";isPrecise=!1;isPreciseTimerId=null;preciseTargetId=null;onPointerMove(){this.update()}onPointerDown(e){this.parent.transition("pointing",{...e,isPrecise:this.isPrecise})}onEnter(){this.editor.setCursor({type:"cross",rotation:0}),this.update()}onCancel(){this.editor.setCurrentTool("select")}onExit(){wT(this.editor),null!==this.isPreciseTimerId&&clearTimeout(this.isPreciseTimerId)}onKeyDown(){this.update()}onKeyUp(e){if(this.update(),"Enter"===e.key){let e=this.editor.getOnlySelectedShape();this.editor.canEditShape(e)&&E(this.editor,e,{selectAll:!0})}}update(){let e=this.editor.getShapeUtil("arrow"),t=wE({editor:this.editor,pointInPageSpace:this.editor.inputs.getCurrentPagePoint(),arrow:void 0,isPrecise:this.isPrecise,currentBinding:void 0,oppositeBinding:void 0});t&&t.target.id!==this.preciseTargetId?(null!==this.isPreciseTimerId&&clearTimeout(this.isPreciseTimerId),this.preciseTargetId=t.target.id,this.isPreciseTimerId=this.editor.timers.setTimeout(()=>{this.isPrecise=!0,this.update()},e.options.hoverPreciseTimeout)):!t&&this.preciseTargetId&&(this.isPrecise=!1,this.preciseTargetId=null,null!==this.isPreciseTimerId&&clearTimeout(this.isPreciseTimerId))}}class vL extends h.YM5{static id="pointing";shape;isPrecise=!1;isPreciseTimerId=null;markId="";onEnter(e){(this.markId="",this.isPrecise=!!e.isPrecise,wE({editor:this.editor,pointInPageSpace:this.editor.inputs.getCurrentPagePoint(),arrow:void 0,isPrecise:this.isPrecise,currentBinding:void 0,oppositeBinding:void 0})||(this.createArrowShape(),this.shape))?this.startPreciseTimeout():this.cancel()}onExit(){this.shape=void 0,wT(this.editor),this.clearPreciseTimeout()}onPointerMove(){if(this.editor.inputs.getIsDragging()){if(this.shape||this.createArrowShape(),!this.shape)return void this.cancel();this.updateArrowShapeEndHandle(),this.editor.setCurrentTool("select.dragging_handle",{shape:this.shape,handle:{id:"end",type:"vertex",index:"a3",x:0,y:0},isCreating:!0,creatingMarkId:this.markId||void 0,onInteractionEnd:"arrow"})}}onPointerUp(){this.cancel()}onLongPress(){this.editor.getInstanceState().isCoarsePointer&&this.cancel()}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){this.shape&&this.editor.bailToMark(this.markId),this.parent.transition("idle")}createArrowShape(){let e=this.editor.inputs.getOriginPagePoint(),t=(0,h.n6Y)();this.markId=this.editor.markHistoryStoppingPoint(`creating_arrow:${t}`);let n=(0,h.Y8F)(e,this.editor);this.editor.createShape({id:t,type:"arrow",x:n.x,y:n.y,props:{scale:this.editor.getResizeScaleFactor()}});let r=this.editor.getShape(t);if(!r)return;let i=this.editor.getShapeHandles(r);if(!i)throw Error("expected handles for arrow");let o=this.editor.getShapeUtil("arrow"),s=this.shape,a=i.find(e=>"start"===e.id),l=o.onHandleDrag?.(r,{handle:{...a,x:0,y:0},isPrecise:!0,isCreatingShape:!0,initial:s});l&&this.editor.updateShapes([l]),this.shape=this.editor.getShape(t),this.editor.select(t)}updateArrowShapeEndHandle(){let e=this.shape;if(!e)throw Error("expected shape");let t=this.editor.getShapeHandles(e);if(!t)throw Error("expected handles for arrow");{let n=this.editor.getShapeUtil("arrow"),r=this.shape,i=t.find(e=>"start"===e.id),o=n.onHandleDrag?.(e,{handle:{...i,x:0,y:0},isPrecise:this.isPrecise,isCreatingShape:!0,initial:r});o&&this.editor.updateShapes([o])}{let n=this.editor.getShapeUtil("arrow"),r=this.shape,i=this.editor.getPointInShapeSpace(e,this.editor.inputs.getCurrentPagePoint()),o=t.find(e=>"end"===e.id),s=n.onHandleDrag?.(this.editor.getShape(e),{handle:{...o,x:i.x,y:i.y},isPrecise:this.isPrecise,isCreatingShape:!0,initial:r});s&&this.editor.updateShapes([s])}this.shape=this.editor.getShape(e.id)}startPreciseTimeout(){let e=this.editor.getShapeUtil("arrow");this.isPreciseTimerId=this.editor.timers.setTimeout(()=>{this.getIsActive()&&(this.isPrecise=!0)},e.options.pointingPreciseTimeout)}clearPreciseTimeout(){null!==this.isPreciseTimerId&&clearTimeout(this.isPreciseTimerId)}}class vF extends h.YM5{static id="arrow";static initial="idle";static children(){return[vD,vL]}shapeType="arrow"}class vR extends h.YM5{static id="drawing";static trackPerformance=!0;info={};initialShape;shapeType="highlight"===this.parent.id?"highlight":"draw";util=this.editor.getShapeUtil(this.shapeType);isPen=!1;isPenOrStylus=!1;segmentDim=void 0;segmentMode="free";didJustShiftClickToExtendPreviousShapeLine=!1;pagePointWhereCurrentSegmentChanged={};pagePointWhereNextSegmentChanged=null;lastRecordedPoint={};mergeNextPoint=!1;currentLineLength=0;zoomOnEnter=1;currentSegmentPoints=[];markId=null;onEnter(e){this.markId=null,this.info=e,this.lastRecordedPoint=this.editor.inputs.getCurrentPagePoint().clone(),this.zoomOnEnter=this.editor.getZoomLevel(),this.startShape()}onPointerMove(){let{inputs:e}=this.editor,t=e.getIsPen();if(this.isPen&&!t&&this.markId){this.editor.bailToMark(this.markId),this.startShape();return}if(this.isPenOrStylus){let t=e.getCurrentPagePoint();h.l2P.Dist(t,this.lastRecordedPoint)>=1/this.zoomOnEnter?(this.lastRecordedPoint=t.clone(),this.mergeNextPoint=!1):this.mergeNextPoint=!0}else this.mergeNextPoint=!1;this.updateDrawingShape()}onKeyDown(e){if("Shift"===e.key)switch(this.segmentMode){case"free":this.segmentMode="starting_straight",this.pagePointWhereNextSegmentChanged=this.editor.inputs.getCurrentPagePoint().clone();break;case"starting_free":this.segmentMode="starting_straight"}this.updateDrawingShape()}onKeyUp(e){if("Shift"===e.key)switch(this.editor.snaps.clearIndicators(),this.segmentMode){case"straight":this.segmentMode="starting_free",this.pagePointWhereNextSegmentChanged=this.editor.inputs.getCurrentPagePoint().clone();break;case"starting_straight":this.pagePointWhereNextSegmentChanged=null,this.segmentMode="free"}this.updateDrawingShape()}onExit(){this.editor.snaps.clearIndicators(),this.pagePointWhereCurrentSegmentChanged=this.editor.inputs.getCurrentPagePoint().clone()}canClose(){return"highlight"!==this.shapeType}getIsClosed(e,t,n,r){if(!this.canClose())return!1;void 0===r&&(r=this.editor.getCurrentTheme().strokeWidth*ei[t]);let i=h.K6A.decodeFirstPoint(e[0].path,e[0].dim),o=e[e.length-1],s=h.K6A.decodeLastPoint(o.path,o.dim),a=this.editor.user.getIsDynamicResizeMode()?(r+2)*n:6+2*Math.sqrt(.8*r)+100/(1+Math.pow(this.zoomOnEnter/.18,3));return null!==i&&null!==s&&i!==s&&this.currentLineLength>4*r*n&&h.l2P.DistMin(i,s,a)}makeSegment(e,t){let n=h.K6A.encodePoints(t,this.segmentDim);return this.segmentDim===h.sdu?{type:e,path:n,dim:h.sdu}:{type:e,path:n}}startShape(){let e=this.editor.inputs,t=e.getOriginPagePoint(),n=e.getIsPen();this.markId=this.editor.markHistoryStoppingPoint("draw start");let{z:r=.5}=this.info.point;this.isPen=n,this.isPenOrStylus=n&&0!==r||r>0&&r<.5||r>.5&&r<1,this.segmentDim=this.isPenOrStylus?void 0:h.sdu;let i=this.isPenOrStylus?1.25*r:.5;if(this.segmentMode=this.editor.inputs.getShiftKey()?"straight":"free",this.didJustShiftClickToExtendPreviousShapeLine=!1,this.lastRecordedPoint=t.clone(),this.initialShape){let e=this.editor.getShape(this.initialShape.id);if(e&&"straight"===this.segmentMode){this.didJustShiftClickToExtendPreviousShapeLine=!0;let n=(0,h.HVh)(e.props.segments);if(!n)throw Error("Expected a previous segment!");let r=h.K6A.decodeLastPoint(n.path,n.dim);if(!r)throw Error("Expected a previous point!");let{x:o,y:s}=this.editor.getPointInShapeSpace(e,t).toFixed(),a=this.makeSegment(this.segmentMode,[{x:r.x,y:r.y,z:+i.toFixed(2)},{x:o,y:s,z:+i.toFixed(2)}]),l=h.V8r.applyToPoint(this.editor.getShapePageTransform(e.id),r);this.pagePointWhereCurrentSegmentChanged=l,this.pagePointWhereNextSegmentChanged=null;let d=[...e.props.segments,a],c=x$(this.util,e).strokeWidth;this.currentLineLength<4*c&&(this.currentLineLength=this.getLineLength(d));let u={id:e.id,type:this.shapeType,props:{segments:d}};this.canClose()&&(u.props.isClosed=this.getIsClosed(d,e.props.size,e.props.scale)),this.editor.updateShapes([u]);return}}this.pagePointWhereCurrentSegmentChanged=t.clone();let o=(0,h.n6Y)(),s=new h.l2P(0,0,+i.toFixed(2));(this.currentSegmentPoints=[s],this.editor.createShape({id:o,type:this.shapeType,x:t.x,y:t.y,props:{isPen:this.isPenOrStylus,scale:this.editor.getResizeScaleFactor(),segments:[this.makeSegment(this.segmentMode,[s])]}}),this.editor.getShape(o))?(this.currentLineLength=0,this.initialShape=this.editor.getShape(o)):this.cancel()}updateDrawingShape(){let{initialShape:e}=this,{inputs:t}=this.editor;if(!e)return;let{id:n,props:{size:r,scale:i}}=e,o=this.editor.getShape(n);if(!o)return;let{segments:s}=o.props,a=t.getCurrentPagePoint(),{x:l,y:d,z:c}=this.editor.getPointInShapeSpace(o,a).toFixed(),u={x:l,y:d,z:this.isPenOrStylus?+(1.25*a.z).toFixed(2):.5};switch(this.segmentMode){case"starting_straight":{let{pagePointWhereNextSegmentChanged:e}=this;if(null===e)throw Error("We should have a point where the segment changed");if(h.l2P.Dist2(e,t.getCurrentPagePoint())>this.editor.options.dragDistanceSquared){let e;this.pagePointWhereCurrentSegmentChanged=this.pagePointWhereNextSegmentChanged.clone(),this.pagePointWhereNextSegmentChanged=null,this.segmentMode="straight";let t=(0,h.HVh)(s);if(!t)throw Error("Expected a previous segment!");let a=h.K6A.decodeLastPoint(t.path,t.dim);if(!a)throw Error("Expected a previous last point!");let l=this.editor.getPointInShapeSpace(o,this.pagePointWhereCurrentSegmentChanged).toFixed().toJson();if("straight"===t.type){this.currentLineLength+=h.l2P.Dist(a,l),e=this.makeSegment("straight",[a,l]);let t=this.editor.getShapePageTransform(o);this.pagePointWhereCurrentSegmentChanged=h.V8r.applyToPoint(t,a)}else e=this.makeSegment("straight",[l,u]);let d={id:n,type:this.shapeType,props:{segments:[...s,e]}};this.canClose()&&(d.props.isClosed=this.getIsClosed(s,r,i)),this.editor.updateShapes([d])}break}case"starting_free":{let{pagePointWhereNextSegmentChanged:e}=this;if(null===e)throw Error("We should have a point where the segment changed");if(h.l2P.Dist2(e,t.getCurrentPagePoint())>this.editor.options.dragDistanceSquared){this.pagePointWhereCurrentSegmentChanged=this.pagePointWhereNextSegmentChanged.clone(),this.pagePointWhereNextSegmentChanged=null,this.segmentMode="free";let e=s.slice(),t=e[e.length-1],a=h.K6A.decodeLastPoint(t.path,t.dim);if(!a)throw Error("No previous point!");let l=h.l2P.PointsBetween(a,u,6).map(e=>new h.l2P((0,h.Mg8)(e.x),(0,h.Mg8)(e.y),(0,h.Mg8)(e.z)));this.currentSegmentPoints=l;let d=[...e,this.makeSegment("free",l)],c=x$(this.util,o).strokeWidth;this.currentLineLength<4*c&&(this.currentLineLength=this.getLineLength(d));let p={id:n,type:this.shapeType,props:{segments:d}};this.canClose()&&(p.props.isClosed=this.getIsClosed(d,r,i)),this.editor.updateShapes([p])}break}case"straight":{let e,t,a=s.slice(),l=a[a.length-1],{pagePointWhereCurrentSegmentChanged:d}=this,c=this.editor.inputs,u=c.getCtrlKey(),p=c.getCurrentPagePoint();if(!d)throw Error("We should have a point where the segment changed");let f=!1;this.didJustShiftClickToExtendPreviousShapeLine?this.editor.inputs.getIsDragging()&&(f=!u,this.didJustShiftClickToExtendPreviousShapeLine=!1):f=!u;let g=this.editor.getPointInShapeSpace(o,p).toFixed().toJson(),m=!1;if((this.editor.user.getIsSnapMode()?!u:u)&&a.length>2){let e,n=8/this.zoomOnEnter;for(let r=0,i=s.length-2;r<i;r++){let i=s[r];if(!i)break;if("free"===i.type)continue;let o=h.K6A.decodeFirstPoint(i.path,i.dim),a=h.K6A.decodeLastPoint(i.path,i.dim);if(!(o&&a))continue;let l=h.l2P.NearestPointOnLineSegment(o,a,g);if(h.l2P.DistMin(l,g,n)){e=l.toFixed().toJson(),n=h.l2P.Dist(l,g),t=i;break}}e&&(m=!0,g=e)}if(m&&t){let e=this.editor.getShapePageTransform(o),n=h.K6A.decodeFirstPoint(t.path,t.dim),r=h.K6A.decodeLastPoint(t.path,t.dim);if(!n||!r)throw Error("Expected a last point!");let i=h.V8r.applyToPoint(e,n),s=h.V8r.applyToPoint(e,r),a=h.V8r.applyToPoint(e,g);this.editor.snaps.setIndicators([{id:(0,h.NF7)(),type:"points",points:[i,a,s]}])}else{if(this.editor.snaps.clearIndicators(),f){let t=h.l2P.Angle(d,p),n=(0,h.cL9)(t,24);e=h.l2P.RotWith(p,d,n-t)}else e=p.clone();g=this.editor.getPointInShapeSpace(o,e).toFixed().toJson()}this.currentLineLength+=a.length&&h.K6A.decodeFirstPoint(l.path,l.dim)?h.l2P.Dist(h.K6A.decodeFirstPoint(l.path,l.dim),h.l2P.From(g)):0,a[a.length-1]={...l,type:"straight",path:h.K6A.encodePoints([h.K6A.decodeFirstPoint(l.path,l.dim),h.l2P.From(g)],l.dim)};let y={id:n,type:this.shapeType,props:{segments:a}};this.canClose()&&(y.props.isClosed=this.getIsClosed(s,r,i)),this.editor.updateShapes([y]);break}case"free":{let e=this.currentSegmentPoints;if(e.length&&this.mergeNextPoint){let t=e[e.length-1];t.x=u.x,t.y=u.y,t.z=t.z?Math.max(t.z,u.z):u.z}else this.currentLineLength+=e.length?h.l2P.Dist(e[e.length-1],u):0,e.push(new h.l2P(u.x,u.y,u.z));let a=s.slice(),l=a[a.length-1];a[a.length-1]={...l,path:h.K6A.encodePoints(e,l.dim)};let d=x$(this.util,o).strokeWidth;this.currentLineLength<4*d&&(this.currentLineLength=this.getLineLength(a));let p={id:n,type:this.shapeType,props:{segments:a}};if(this.canClose()&&(p.props.isClosed=this.getIsClosed(a,r,i)),this.editor.updateShapes([p]),e.length>this.util.options.maxPointsPerShape){this.editor.updateShapes([{id:n,type:this.shapeType,props:{isComplete:!0}}]);let e=(0,h.n6Y)(),r=this.editor.getShape(n).props;if(!this.editor.canCreateShapes([e]))return this.cancel();let i=t.getCurrentPagePoint(),o=new h.l2P(0,0,this.isPenOrStylus?+(1.25*c).toFixed():.5);this.currentSegmentPoints=[o],this.editor.createShape({id:e,type:this.shapeType,x:(0,h.Mg8)(i.x),y:(0,h.Mg8)(i.y),props:{isPen:this.isPenOrStylus,scale:r.scale,segments:[this.makeSegment("free",[o])]}});let s=this.editor.getShape(e);if(!s)return this.cancel();this.initialShape=(0,h.pN9)(s),this.mergeNextPoint=!1,this.lastRecordedPoint=i.clone(),this.currentLineLength=0}}}}getLineLength(e){let t=0;for(let n=0;n<e.length;n++){let r=h.K6A.decodePoints(e[n].path,e[n].dim);for(let e=0;e<r.length-1;e++)t+=h.l2P.Dist2(r[e],r[e+1])}return Math.sqrt(t)}onPointerUp(){this.complete()}onCancel(){this.cancel()}onComplete(){this.complete()}onInterrupt(){this.editor.inputs.getIsDragging()||(this.markId&&this.editor.bailToMark(this.markId),this.cancel())}complete(){let{initialShape:e}=this;e&&(this.editor.updateShapes([{id:e.id,type:e.type,props:{isComplete:!0}}]),this.parent.transition("idle"))}cancel(){this.parent.transition("idle",this.info)}}class vz extends h.YM5{static id="idle";onPointerDown(e){e.accelKey&&!e.shiftKey?this.editor.setCurrentTool("eraser.pointing",{...e,onInteractionEnd:this.parent.id}):this.parent.transition("drawing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onCancel(){this.editor.setCurrentTool("select")}}class vN extends h.YM5{static id="draw";static initial="idle";static isLockable=!1;static useCoalescedEvents=!0;static children(){return[vz,vR]}shapeType="draw";onExit(){this.children.drawing.initialShape=void 0}}class v$ extends h.QVi{static id="frame";static initial="idle";shapeType="frame";onCreate(e){e&&(this.editor.reparentShapes(vB(this.editor,e),e.id),this.editor.getInstanceState().isToolLocked?this.editor.setCurrentTool("frame"):this.editor.setCurrentTool("select.idle"))}}function vB(e,t){let n=e.getShapePageBounds(t);if(!n)return[];let r=[],i=e.getShapeAncestors(t).map(e=>e.id);return e.getSortedChildIdsForParent(t.parentId).map(o=>{var s,a,l;let d=e.getShape(o);if(!d||d.id===t.id||d.isLocked)return;let c=e.getShapePageBounds(d);c&&n.contains(c)&&(s=d,a=i,l=t,!a.includes(s.id)&&s.parentId===l.parentId)&&r.push(d.id)}),r}class vH extends h.YM5{static id="idle";onPointerDown(e){this.parent.transition("pointing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onKeyUp(e){let{editor:t}=this;if("Enter"===e.key){let e=t.getOnlySelectedShape();t.canEditShape(e)&&E(t,e,{selectAll:!0})}}onCancel(){this.editor.setCurrentTool("select")}}class vU extends h.YM5{static id="pointing";onPointerUp(){this.complete()}onLongPress(){this.editor.getInstanceState().isCoarsePointer&&this.cancel()}onPointerMove(e){if(this.editor.inputs.getIsDragging()){let t=this.editor.inputs.getOriginPagePoint(),n=(0,h.n6Y)(),r=this.editor.markHistoryStoppingPoint(`creating_geo:${n}`),i=(0,h.Y8F)(t,this.editor);if(this.editor.createShapes([{id:n,type:"geo",x:i.x,y:i.y,props:{w:1,h:1,geo:this.editor.getStyleForNextShape(h.tg8),scale:this.editor.getResizeScaleFactor()}}]).select(n),!this.editor.getShape(n))return void this.cancel();this.editor.setCurrentTool("select.resizing",{...e,target:"selection",handle:"bottom_right",isCreating:!0,creatingMarkId:r,creationCursorOffset:{x:1,y:1},onInteractionEnd:"geo"})}}onCancel(){this.cancel()}onComplete(){this.complete()}onInterrupt(){this.cancel()}complete(){let e=this.editor.inputs.getOriginPagePoint(),t=(0,h.n6Y)();this.editor.markHistoryStoppingPoint(`creating_geo:${t}`);let n=this.editor.getResizeScaleFactor(),r=m2(this.editor.getStyleForNextShape(h.tg8),this.editor.getShapeUtil("geo").options.customGeoTypes),i=r?.defaultSize??{w:200,h:200};this.editor.createShapes([{id:t,type:"geo",x:e.x,y:e.y,props:{geo:this.editor.getStyleForNextShape(h.tg8),scale:n,...i}}]);let o=this.editor.getShape(t);if(!o)return void this.cancel();let{w:s,h:a}=o.props,l=new h.l2P(s/2,a/2).mul(n),d=this.editor.getShapeParentTransform(o);d&&l.rot(-d.rotation());let c=(0,h.Y8F)(new h.l2P(o.x-l.x,o.y-l.y),this.editor);this.editor.select(t),this.editor.updateShape({id:o.id,type:"geo",x:c.x,y:c.y,props:{geo:this.editor.getStyleForNextShape(h.tg8),w:s*n,h:a*n}}),this.editor.getInstanceState().isToolLocked?this.parent.transition("idle"):this.editor.setCurrentTool("select",{})}cancel(){this.parent.transition("idle")}}class vW extends h.YM5{static id="geo";static initial="idle";static children(){return[vH,vU]}shapeType="geo"}class vK extends h.YM5{static id="highlight";static initial="idle";static useCoalescedEvents=!0;static children(){return[vz,vR]}static isLockable=!1;shapeType="highlight";onExit(){this.children.drawing.initialShape=void 0}}class vV extends h.YM5{static id="idle";shapeId="";onEnter(e){this.shapeId=e.shapeId,this.editor.setCursor({type:"cross",rotation:0})}onPointerDown(){this.parent.transition("pointing",{shapeId:this.shapeId})}onCancel(){this.editor.setCurrentTool("select")}}class vY extends h.YM5{static id="pointing";shape={};markId;onEnter(e){let{inputs:t}=this.editor,n=t.getCurrentPagePoint();this.markId=void 0;let r=e.shapeId&&this.editor.getShape(e.shapeId);if(r&&t.getShiftKey()){this.markId=this.editor.markHistoryStoppingPoint(`creating_line:${r.id}`),this.shape=r;let e=this.editor.getShapeHandles(this.shape);if(!e)return;let t=e.filter(e=>"vertex"===e.type).sort(h.Ky),i=t[t.length-1],o=t[t.length-2],s=h.V8r.applyToPoint(this.editor.getShapeParentTransform(this.shape),new h.l2P(this.shape.x,this.shape.y)),a=h.l2P.Sub(n,s).addXY(.1,.1),l=(0,h.Y8F)(a,this.editor),d=(0,h.pN9)(this.shape.props.points),c=2/this.editor.getZoomLevel();if(h.l2P.DistMin(i,o,c)||h.l2P.DistMin(l,i,c))d[i.id]={id:i.id,index:i.index,x:l.x,y:l.y};else{let e=(0,h.AQy)(i.index);d[e]={id:e,index:e,x:l.x,y:l.y}}this.editor.updateShapes([{id:this.shape.id,type:this.shape.type,props:{points:d}}])}else{let e=(0,h.n6Y)();this.markId=this.editor.markHistoryStoppingPoint(`creating_line:${e}`);let t=(0,h.Y8F)(n,this.editor);if(this.editor.createShapes([{id:e,type:"line",x:t.x,y:t.y,props:{scale:this.editor.getResizeScaleFactor()}}]),!this.editor.getShape(e))return void this.cancel();this.editor.select(e),this.shape=this.editor.getShape(e)}}onPointerMove(){if(this.shape&&this.editor.inputs.getIsDragging()){let e=this.editor.getShapeHandles(this.shape);if(!e)throw this.markId&&this.editor.bailToMark(this.markId),Error("No handles found");let t=(0,h.HVh)(e);this.editor.setCurrentTool("select.dragging_handle",{shape:this.shape,isCreating:!0,creatingMarkId:this.markId,handle:{...t,x:t.x-.1,y:t.y-.1},onInteractionEnd:"line"})}}onPointerUp(){this.complete()}onLongPress(){this.editor.getInstanceState().isCoarsePointer&&this.cancel()}onCancel(){this.cancel()}onComplete(){this.complete()}onInterrupt(){this.parent.transition("idle"),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(){this.markId&&this.editor.bailToMark(this.markId),this.parent.transition("idle",{shapeId:this.shape.id}),this.editor.snaps.clearIndicators()}}class vG extends h.YM5{static id="line";static initial="idle";static children(){return[vV,vY]}shapeType="line"}class vq extends h.YM5{static id="idle";onPointerDown(e){this.parent.transition("pointing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onCancel(){this.editor.setCurrentTool("select")}}function vX(e,t){let{pagePoint:n,pageRotation:r,growY:i,extraHeight:o,scale:s,noteWidth:a,noteHeight:l}=t;return Object.fromEntries((function(e,t,n,r){if(1===t)return[[["a1"],new h.l2P(.5*n,-.5*r-e.options.adjacentShapeMargin)],[["a2"],new h.l2P(1.5*n+e.options.adjacentShapeMargin,.5*r)],[["a3"],new h.l2P(.5*n,1.5*r+e.options.adjacentShapeMargin)],[["a4"],new h.l2P(-.5*n-e.options.adjacentShapeMargin,.5*r)]];let i=n*t,o=r*t,s=e.options.adjacentShapeMargin*t;return[[["a1"],new h.l2P(.5*i,-.5*o-s)],[["a2"],new h.l2P(1.5*i+s,.5*o)],[["a3"],new h.l2P(.5*i,1.5*o+s)],[["a4"],new h.l2P(-.5*i-s,.5*o)]]})(e,s,a,l).map(([e,t],s)=>{let a=t.clone();return 0===s&&o?a.y-=o:2===s&&i&&(a.y+=i),[e,a.rot(r).add(n)]}))}function vJ(e,t){let n,{rotation:r,scale:i,extraHeight:o,noteWidth:s,noteHeight:a}=t,l=new Set(e.getSelectedShapeIds()),d=(Math.max(s,a)+e.options.adjacentShapeMargin+o)**2,c=new Map,u=[];for(let t of e.getCurrentPageShapes()){if(!e.isShapeOfType(t,"note")||i!==t.props.scale||l.has(t.id))continue;let n=e.getShapePageTransform(t.id);r===n.rotation()&&(c.set(t,e.getShapePageBounds(t).center),u.push(...Object.values(vX(e,{pagePoint:n.point(),pageRotation:r,growY:t.props.growY,extraHeight:o,scale:i,noteWidth:s,noteHeight:a}))))}let p=u.length;for(let[t,r]of c)for(let i=0;i<p;i++)(n=u[i])&&!(h.l2P.Dist2(r,n)>d)&&e.isPointInShape(t,n)&&(u[i]=void 0);return(0,h.oE7)(u)}function vZ(e,t){let n,{shape:r,center:i,pageRotation:o,noteWidth:s,noteHeight:a,forceNew:l=!1}=t,d=e.getCurrentPageShapesSorted(),c=(Math.max(s,a)+e.options.adjacentShapeMargin**2)**r.props.scale;for(let t=d.length-1;t>=0;t--){let o=d[t];if("note"===o.type&&o.id!==r.id){let t=e.getShapePageBounds(o);if(t&&h.l2P.Dist2(t.center,i)<c&&e.isPointInShape(o,i)){n=o;break}}}if(e.complete(),!n||l){e.markHistoryStoppingPoint("creating note shape");let t=(0,h.n6Y)();e.createShape({id:t,type:"note",x:i.x,y:i.y,rotation:o,opacity:r.opacity,props:{...r.props,richText:(0,h.TP3)(""),growY:0,fontSizeAdjustment:1,url:"",textLastEditedBy:null}});let l=e.getShape(t);if(!l)return;let d=e.getPointInParentSpace(l,h.l2P.Sub(i,h.l2P.Rot(new h.l2P(s/2,a/2).mul(l.props.scale),o)));e.updateShape({id:t,type:"note",x:d.x,y:d.y}),n=e.getShape(t)}return e.zoomToSelectionIfOffscreen(16,{animation:{duration:e.options.animationMediumMs},inset:0}),n}class vQ extends h.YM5{static id="pointing";dragged=!1;info={};markId="";shape={};shapeId;shapeCenter=new h.l2P;hasCreatedShape=!1;onEnter(){let{editor:e}=this;this.hasCreatedShape=!1,this.shapeId=(0,h.n6Y)(),this.markId=e.markHistoryStoppingPoint(`creating_note:${this.shapeId}`);let t=e.getShapeUtil("note"),n=x$(t,{props:t.getDefaultProps()}),r=e.inputs.getOriginPagePoint().clone(),i=function(e,t,n,r,i){let o,s=10/e.getZoomLevel();for(let a of vJ(e,{rotation:0,scale:n,extraHeight:0,noteWidth:r,noteHeight:i})){let e=h.l2P.Sub(t,a),n=e.len();n<s&&(s=n,o=e)}return o}(e,r,e.getResizeScaleFactor(),n.noteWidth,n.noteHeight);i&&r.sub(i),this.shapeCenter=r,e.getInstanceState().isCoarsePointer||this.ensureShapeCreated()}ensureShapeCreated(){if(this.hasCreatedShape)return;let e=function(e,t,n){e.createShape({id:t,type:"note",x:n.x,y:n.y,props:{scale:e.getResizeScaleFactor()}});let r=e.getShape(t);if(!r)return;e.select(t);let i=e.getShapeGeometry(r).bounds,o=(0,h.Y8F)(new h.l2P(r.x-i.width/2,r.y-i.height/2),e);return e.updateShapes([{id:t,type:"note",x:o.x,y:o.y}]),e.getShape(t)}(this.editor,this.shapeId,this.shapeCenter);e?(this.shape=e,this.hasCreatedShape=!0):this.cancel()}onPointerMove(e){this.editor.inputs.getIsDragging()&&(this.ensureShapeCreated(),this.hasCreatedShape&&this.editor.setCurrentTool("select.translating",{...e,target:"shape",shape:this.shape,onInteractionEnd:"note",isCreating:!0,creatingMarkId:this.markId,onCreate:()=>{E(this.editor,this.shape.id)}}))}onPointerUp(){this.complete()}onLongPress(){this.editor.getInstanceState().isCoarsePointer&&this.cancel()}onInterrupt(){this.cancel()}onComplete(){this.complete()}onCancel(){this.cancel()}complete(){this.ensureShapeCreated(),this.hasCreatedShape&&(this.editor.getInstanceState().isToolLocked?this.parent.transition("idle"):E(this.editor,this.shape.id,{info:this.info}))}cancel(){this.editor.bailToMark(this.markId),this.parent.transition("idle",this.info)}}class v0 extends h.YM5{static id="note";static initial="idle";static children(){return[vq,vQ]}shapeType="note"}let v1=new WeakMap;function v2(e){let t=e.getShapeAtPoint(e.inputs.getCurrentPagePoint(),{hitInside:!1,hitLabels:!1,hitLocked:e.options.selectLockedShapes,margin:e.getHitTestMargin(),renderingOnly:!0});if(!t)return null;let n=e.getOutermostSelectableShape(t);return(n===t||n.id===e.getFocusedGroupId()||e.getSelectedShapeIds().includes(n.id)?t:n).id}function v3(e){if(e.isDisposed)return;if("moving"!==e.getCameraState()){v1.set(e,!1);let t=v2(e);return e.setHoveredShape(t)}if(v1.get(e))return;let t=e.getHoveredShapeId();t?v2(e)!==t&&(e.setHoveredShape(null),v1.set(e,!0)):v1.set(e,!0)}let v5=new WeakMap;function v6(e){let t;((t=v5.get(e))||(t=(0,h.nFR)(v3,32),v5.set(e,t)),t)(e)}function v4(e){v5.get(e)?.cancel()}class v8 extends h.YM5{static id="idle";onPointerMove(e){switch(e.target){case"shape":case"canvas":v6(this.editor)}}onPointerDown(e){this.parent.transition("pointing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onExit(){v4(this.editor)}onKeyDown(e){if("Enter"===e.key){let t=this.editor.getOnlySelectedShape();this.editor.canEditShape(t)&&(this.editor.setCurrentTool("select"),E(this.editor,t.id,{info:e}))}}onCancel(){this.editor.setCurrentTool("select")}}class v9 extends h.YM5{static id="pointing";shape;markId="";enterTime=0;onEnter(){this.enterTime=Date.now()}onExit(){this.editor.setHintingShapes([])}onPointerMove(e){if(Date.now()-this.enterTime<150)return;let{editor:t}=this;if(!t.inputs.getIsPointing())return;let n=t.inputs.getOriginPagePoint(),r=t.inputs.getCurrentPagePoint(),i=Math.abs(n.x-r.x);if(i>6*Math.sqrt(t.getInstanceState().isCoarsePointer?t.options.coarseDragDistanceSquared:t.options.dragDistanceSquared)/t.getZoomLevel()){let r=(0,h.n6Y)();this.markId=t.markHistoryStoppingPoint(`creating_text:${r}`);let o=this.createTextShape(r,n,!1,i);if(!o)return void this.cancel();this.shape=t.getShape(o),t.select(r);let s=this.editor.getResizeScaleFactor();t.setCurrentTool("select.resizing",{...e,target:"selection",handle:"right",isCreating:!0,creatingMarkId:this.markId,creationCursorOffset:{x:i*s,y:1},onInteractionEnd:"text",onCreate:()=>{E(t,o.id)}})}}onPointerUp(){this.complete()}onLongPress(){this.editor.getInstanceState().isCoarsePointer&&this.cancel()}onComplete(){this.cancel()}onCancel(){this.cancel()}onInterrupt(){this.cancel()}complete(){this.editor.markHistoryStoppingPoint("creating text shape");let e=(0,h.n6Y)(),t=this.editor.inputs.getOriginPagePoint();this.createTextShape(e,t,!0,20)&&(this.editor.select(e),E(this.editor,e))}cancel(){this.parent.transition("idle"),this.editor.bailToMark(this.markId)}createTextShape(e,t,n,r){this.editor.createShape({id:e,type:"text",x:t.x,y:t.y,props:{richText:(0,h.TP3)(""),autoSize:n,w:r,scale:this.editor.getResizeScaleFactor()}});let i=this.editor.getShape(e);if(!i)return void this.cancel();let o=this.editor.getShapePageBounds(i),s=new h.l2P;if(n)switch(i.props.textAlign){case"start":s.x=0;break;case"middle":s.x=-o.width/2;break;case"end":s.x=-o.width}else s.x=0;if(s.y=-o.height/2,(0,h.vc4)(i.parentId)){let e=this.editor.getShapeParentTransform(i);s.rot(-e.rotation())}let a=i.x+s.x,l=i.y+s.y;if(this.editor.getInstanceState().isGridMode){let e=new h.l2P(a,l),t=(0,h.Y8F)(e,this.editor),n=h.l2P.Sub(e,t);this.editor.updateShape({...i,x:a-n.x,y:l-n.y})}else this.editor.updateShape({...i,x:a,y:l});return i}}class v7 extends h.YM5{static id="text";static initial="idle";static children(){return[v8,v9]}shapeType="text"}let Se={solid:"semi",pattern:"pattern",fill:"fill","lined-fill":"linedFill"};function St(e){return{key:`${h.yes.id}:${e}`,getElement:async()=>"pattern"!==e?null:(0,b.jsx)(Sn,{})}}function Sn(){let e=Sd(),t=(0,h.LsA)(),n=(0,h.hGv)(),r=(0,h.G67)(),i=n.getCurrentTheme().colors[r],o=8/12;return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("mask",{id:t,children:[(0,b.jsx)("rect",{x:"0",y:"0",width:"8",height:"8",fill:"white"}),(0,b.jsxs)("g",{strokeLinecap:"round",stroke:"black",children:[(0,b.jsx)("line",{x1:+o,y1:3*o,x2:3*o,y2:+o}),(0,b.jsx)("line",{x1:5*o,y1:7*o,x2:7*o,y2:5*o}),(0,b.jsx)("line",{x1:9*o,y1:11*o,x2:11*o,y2:9*o})]})]}),(0,b.jsx)("pattern",{id:e(1,r),width:"8",height:"8",patternUnits:"userSpaceOnUse",children:(0,b.jsx)("rect",{x:"0",y:"0",width:"8",height:"8",fill:i.solid,mask:`url(#${t})`})})]})}function Sr(){return{key:`${h.yes.id}:pattern`,component:Su}}let Si=new Map;function So(e,t,n){let r=`${e}_${t}_${n}`,i=Si.get(r);!i&&((i=new Promise((r,i)=>{let o=8*t*e,s=(0,h.jLo)().createElement("canvas");s.width=o,s.height=o;let a=s.getContext("2d");if(!a)return void i();a.fillStyle=n,a.fillRect(0,0,o,o),a.globalCompositeOperation="destination-out",a.lineCap="round",a.lineWidth=1.25*t*e;let l=8/12;a.beginPath(),a.moveTo(l*t*e,3*l*t*e),a.lineTo(3*l*t*e,l*t*e),a.moveTo(5*l*t*e,7*l*t*e),a.lineTo(7*l*t*e,5*l*t*e),a.moveTo(9*l*t*e,11*l*t*e),a.lineTo(11*l*t*e,9*l*t*e),a.stroke(),s.toBlob(e=>{!e||h.bGJ.throwToBlob.get()?i():r(e)})})).catch(()=>Si.delete(r)),Si.set(r,i));return i}let Ss=(e,t)=>{let n=(0,h.jLo)().createElement("canvas");n.width=e[0],n.height=e[1];let r=n.getContext("2d");return r?(t(r),n.toDataURL()):""},Sa=null;function Sl(e){return Math.ceil(Math.log2(Math.max(1,e)))}function Sd(){let e=(0,h.Xhk)("hash_pattern");return(0,C.useCallback)((t,n)=>{let r=Sl(t);return(0,h.oX2)(e,`${n}_${r}`)},[e])}function Sc(e){let t=[],n=Sl(e);for(let e=0;e<=n;e++)t.push(Math.pow(2,e));return t}function Su(){let e=(0,h.hGv)(),t=(0,C.useRef)(null),{defs:n,isReady:r}=function(){let e=(0,h.hGv)(),t=(0,h.hau)("devicePixelRatio",()=>e.getInstanceState().devicePixelRatio,[e]),n=(0,h.hau)("maxEffectiveZoom",()=>{let t=e.getCameraOptions().zoomSteps;return(0,h.HVh)(t)/t[0]},[e]),[r,i]=(0,C.useState)(!1),[o,s]=(0,C.useState)(()=>{let e;return Sa||(Sa={white:Ss([1,1],e=>{e.fillStyle="#f8f9fa",e.fillRect(0,0,1,1)}),black:Ss([1,1],e=>{e.fillStyle="#212529",e.fillRect(0,0,1,1)})}),e=Sa,Sc(n).flatMap(t=>[{zoom:t,url:e.white,theme:"light"},{zoom:t,url:e.black,theme:"dark"}])}),a=Sd();return(0,C.useEffect)(()=>{let r=e.getCurrentTheme(),o=r.colors.light.solid,a=r.colors.dark.solid,l=Promise.all(Sc(n).flatMap(e=>[So(t,e,o).then(t=>({zoom:e,theme:"light",url:URL.createObjectURL(t)})),So(t,e,a).then(t=>({zoom:e,theme:"dark",url:URL.createObjectURL(t)}))])),d=!1;return l.then(e=>{d||(s(e),i(!0))}),()=>{d=!0,i(!1),l.then(e=>{for(let{url:t}of e)URL.revokeObjectURL(t)})}},[t,n,e]),{defs:(0,b.jsx)(b.Fragment,{children:o.map(e=>{let t=a(e.zoom,e.theme);return(0,b.jsx)("pattern",{id:t,width:8,height:8,patternUnits:"userSpaceOnUse",children:(0,b.jsx)("image",{href:e.url,width:8,height:8})},t)})}),isReady:r}}();return(0,C.useEffect)(()=>{if(r&&h.YZA.isSafari){let n=function e(t){return t.classList.contains("tl-html-layer")?t:t.parentElement?e(t.parentElement):null}(t.current);n&&e.timers.requestAnimationFrame(()=>{n.style.display="none",e.timers.requestAnimationFrame(()=>{n.style.display=""})})}},[e,r]),(0,b.jsx)("g",{ref:t,"data-testid":r?"ready-pattern-fill-defs":void 0,children:n})}function Sh({d:e,fillColor:t,patternFillFallbackColor:n,scale:r=1}){let i=(0,h.hGv)(),o=(0,h.Jf5)(),s=(0,h.hau)("zoomLevel",()=>i.getEfficientZoomLevel(),[i]),a=(0,h.G67)(),l=Sd(),d=(0,h.LsA)(),c=s*r,u=c<=.18,p=l(c,a);return(0,b.jsxs)(b.Fragment,{children:[!o&&!u&&1!==r&&(0,b.jsx)("pattern",{id:d,href:`#${p}`,patternTransform:`scale(${r})`}),(0,b.jsx)("path",{fill:t,d:e}),(0,b.jsx)("path",{fill:o?`url(#${l(1,a)})`:u?n:1!==r?`url(#${d})`:`url(#${p})`,d:e})]})}let Sp=C.forwardRef(function({shapeId:e,isEditing:t,richText:n,handleFocus:r,handleChange:i,handleBlur:o,handleKeyDown:s,handleDoubleClick:a,hasCustomTabBehavior:l,handlePaste:d},c){let u=(0,h.hGv)(),p=(0,h.LsA)("tip-tap-editor"),f=u.getTextOptions().tipTapConfig,g=(0,C.useRef)(n),m=(0,C.useRef)(null),y=(0,C.useRef)(null);(0,C.useLayoutEffect)(()=>{m.current?(0,h.n4T)(g.current,n)||m.current.commands.setContent(n):g.current=n},[n]);let x=(0,C.useRef)({selectAll:!1,caretPosition:null});(0,C.useLayoutEffect)(()=>{function e(e){e.shapeId===u.getEditingShapeId()&&(x.current.selectAll=!0)}function t(e){e.shapeId===u.getEditingShapeId()&&(x.current.caretPosition=e.point)}return u.on("select-all-text",e),u.on("place-caret",t),()=>{u.off("select-all-text",e),u.off("place-caret",t)}},[u,t]);let w=(0,h._q_)(i),v=(0,h._q_)(s),S=(0,h._q_)(r),k=(0,h._q_)(o),P=(0,h._q_)(a),T=(0,h._q_)(d);return((0,C.useLayoutEffect)(()=>{if(!t||!f||!y.current)return;let{editorProps:n,...r}=f,i=new eP.KE({element:y.current,autofocus:!0,editable:t,onUpdate:e=>{let t=e.editor.state.doc.toJSON();g.current=t,w({richText:t})},onFocus:S,onBlur:k,onCreate:t=>{if(u.getEditingShapeId()!==e)return;let n=t.editor;u.setRichTextEditor(n);let{selectAll:r,caretPosition:i}=x.current;if(r)n.chain().focus().selectAll().run();else if(i){let e=n.view.posAtCoords({left:i.x,top:i.y})?.pos;e?n.chain().focus().setTextSelection(e).run():n.chain().focus().selectAll().run()}},editorProps:{handleKeyDown:(e,t)=>{l||"Tab"!==t.key||function(e,t,n){if(n.preventDefault(),r6(e))return;let{state:r,dispatch:i}=t,{$from:o,$to:s}=r.selection,a=n.shiftKey,l=r.tr,d=s.end();for(;d>=o.start();){let e=r.doc.resolve(d).blockRange();if(!e)break;let t=e.start,n=e.end,i=r.doc.textBetween(t,n,"\n"),o=!1;r.doc.nodesBetween(t,n,e=>"bulletList"!==e.type.name&&"orderedList"!==e.type.name||(o=!0,!1)),!o&&(a?i.startsWith(" ")&&(l=l.delete(t+1,t+2)):l=l.insertText(" ",t+1)),d=t-1}let c=r.selection.map(l.doc,l.mapping);l.setSelection(c),l.docChanged&&i(l)}(u,e,t),v(t)},handlePaste:(e,t)=>(T(t),!!t.defaultPrevented),handleDoubleClick:(e,t,n)=>P(n),...n},coreExtensionOptions:{clipboardTextSerializer:{blockSeparator:"\n"}},enableCoreExtensions:{textDirection:!1},textDirection:"auto",...r,content:g.current}),o=u.timers.setTimeout(()=>{x.current.caretPosition||x.current.selectAll?i.commands.focus():i.commands.focus("end"),x.current.selectAll=!1,x.current.caretPosition=null},100);return m.current=i,()=>{m.current=null,clearTimeout(o),i.destroy()}},[t,f,S,k,P,w,T,v,u,e,l]),t&&f)?(0,b.jsx)("div",{id:p,ref:c,tabIndex:-1,"data-testid":"rich-text-area",className:"tl-rich-text tl-text tl-text-input",onContextMenu:t?e=>e.stopPropagation():void 0,onPointerDownCapture:e=>e.stopPropagation(),onTouchEnd:e=>e.stopPropagation(),onDragStart:h.woC,children:(0,b.jsx)("div",{className:"tl-rich-text",ref:y})}):null});function Sf(e){return"start-legacy"===e||"middle-legacy"===e||"end-legacy"===e}function Sg(e,t){return(0,h.hau)("isReadyForEditing",()=>{let n=e.getEditingShapeId();return null!==n&&(n===t||e.getHoveredShapeId()===t)},[e,t])}function Sm(e){let t=(0,h.hGv)(),n=(0,h.hau)("isEditing",()=>t.getEditingShapeId()===e,[t]),r=Sg(t,e),i=(0,C.useCallback)(n=>{t.dispatch({...(0,h.yGT)(t,n),type:"pointer",name:"pointer_down",target:"shape",shape:t.getShape(e)}),n.stopPropagation()},[t,e]),o=(0,C.useCallback)(n=>{if(t.getEditingShapeId()===e&&n.clipboardData){let e=n.clipboardData.getData("text/html");if(e&&e.includes("<div data-tldraw")){let e=n.clipboardData.getData("text/plain");(0,h.woC)(n),e&&t.getContainerDocument().execCommand("insertText",!1,e)}}},[t,e]);return{handleFocus:()=>{},handleBlur:()=>{},handleInputPointerDown:i,handleDoubleClick:t.markEventAsHandled,handlePaste:o,isEditing:n,isReadyForEditing:r}}let Sy=C.memo(function({shapeId:e,type:t,richText:n,labelColor:r,fontFamily:i,fontSize:o,lineHeight:s,textAlign:a,verticalAlign:l,wrap:d,isSelected:c,padding:u=0,onKeyDown:p,classNamePrefix:f,style:g,textWidth:m,textHeight:y,hasCustomTabBehavior:x,showTextOutline:w=!0}){let v,S,k,P,T,E=(0,h.hGv)(),I=C.useRef(!1),_=Sf(a),{rInput:M,isEmpty:A,isEditing:j,isReadyForEditing:O,...D}=(S=(v=Sm(e)).isEditing,k=(0,h.hGv)(),P=(0,C.useRef)(null),T=n&&r5(n),(0,C.useEffect)(()=>{if(!S)return;let e=P.current?.querySelector("[contenteditable]");e&&k.getContainerDocument().activeElement!==P.current&&e.focus()},[k,S]),{rInput:P,handleKeyDown:(0,C.useCallback)(t=>{k.getEditingShapeId()===e&&"Enter"===t.key&&(0,h.gu7)(t)&&k.complete()},[k,e]),handleChange:(0,C.useCallback)(({richText:n})=>{k.getEditingShapeId()===e&&k.updateShape({id:e,type:t,props:{richText:n}})},[k,e,t]),isEmpty:T,...v}),L=(0,C.useMemo)(()=>{if(n)return r1(E,n)},[E,n]),F=(0,h.hau)("isSelectToolActive",()=>"select"===E.getCurrentToolId(),[E]);if((0,h.a1r)("isDragging",()=>{E.getInstanceState(),I.current=E.inputs.getIsDragging()},[E]),!j&&A)return null;let R=f||"tl-text";return(0,b.jsx)("div",{className:ik(`${R}-label tl-text-wrapper tl-rich-text-wrapper`,w?"tl-text__outline":"tl-text__no-outline"),"aria-hidden":!j,"data-hastext":!A,"data-isediting":j,"data-textwrap":!!d,"data-isselected":c,style:{fontFamily:i,textAlign:a,justifyContent:"center"===a||_?"center":"end"===a?"flex-end":"flex-start",alignItems:"middle"===l?"center":"end"===l?"flex-end":"flex-start",padding:u,...g},children:(0,b.jsxs)("div",{className:`${R}-label__inner tl-text-content__wrapper`,style:{fontSize:o,lineHeight:`${(0,h.OVI)(o,s)}px`,minHeight:`${(0,h.OVI)(o,s)}px`,"--tl-rich-text-heading-line-height":s,minWidth:Math.ceil(m||0),color:r,width:m?Math.ceil(m):void 0,height:y?Math.ceil(y):void 0},children:[(0,b.jsx)("div",{className:`${R} tl-text tl-text-content`,dir:"auto",children:n&&(0,b.jsx)("div",{className:"tl-rich-text","data-is-select-tool-active":F,dangerouslySetInnerHTML:{__html:L||""},onPointerDown:e=>{let t=E.getContainerWindow().HTMLElement;if(e.target instanceof t&&("A"===e.target.tagName||e.target.closest("a"))){if((0,h.woC)(e),!F)return;let t=e.target.closest("a")?.getAttribute("href")??"",n=e=>{"pointer_up"===e.name&&t&&(I.current||(0,h.D1x)(t,"_blank",!1),E.off("event",n))};E.on("event",n)}},"data-is-ready-for-editing":O})}),(O||c)&&(0,b.jsx)(Sp,{ref:M,richText:n,isEditing:j,shapeId:e,...D,hasCustomTabBehavior:x,handleKeyDown:p??D.handleKeyDown})]})})});function Sb({bounds:e,richText:t,fontSize:n,fontFamily:r,lineHeight:i,textAlign:o,verticalAlign:s,wrap:a,labelColor:l,padding:d,showTextOutline:c=!0}){let u=r1((0,h.hGv)(),t),p=Sf(o),f={display:"flex",fontFamily:r,height:"100%",justifyContent:"center"===o||p?"center":"start"===o?"flex-start":"flex-end",alignItems:"middle"===s?"center":"start"===s?"flex-start":"flex-end",padding:`${d}px`},g={fontSize:`${n}px`,wrap:a?"wrap":"nowrap",color:l,lineHeight:`${(0,h.OVI)(n,i)}px`,"--tl-rich-text-heading-line-height":i,textAlign:o,width:"100%",wordWrap:"break-word",overflowWrap:"break-word",whiteSpace:"pre-wrap",textShadow:c?"var(--tl-text-outline)":"none",tabSize:"var(--tl-tab-size, 2)"};return(0,b.jsx)("foreignObject",{x:e.minX,y:e.minY,width:e.w,height:e.h,className:ik("tl-export-embed-styles tl-rich-text tl-rich-text-svg",c?"tl-text__outline":"tl-text__no-outline"),children:(0,b.jsx)("div",{style:f,children:(0,b.jsx)("div",{dangerouslySetInnerHTML:{__html:u},style:g})})})}function Sx(e=.25){let t=(0,h.hGv)();return(0,h.hau)("efficient zoom threshold",()=>t.getEfficientZoomLevel()<e,[t,e])}function Sw(e,t,n){let r="end"===t?e.end.arrowhead:e.start.arrowhead;if("none"===r)return;let i=function(e,t,n){let r,i="end"===t?e.end.point:e.start.point;switch(e.type){case"straight":{let o="end"===t?e.start.point:e.end.point,s=h.l2P.Dist(o,i),a=(0,h.qE8)(s/5,n,3*n);r=h.l2P.Nudge(i,o,a);break}case"arc":{let o=Math.abs(e.bodyArc.length),s=(0,h.qE8)(o/5,n,3*n),a=(0,h.OpZ)(i,s,e.handleArc.center,e.handleArc.radius);r="end"===t?e.handleArc.sweepFlag?a[0]:a[1]:e.handleArc.sweepFlag?a[1]:a[0];break}case"elbow":{let o="end"===t?e.route.points[e.route.points.length-2]:e.route.points[1],s=h.l2P.ManhattanDist(o,i),a=(0,h.qE8)(s/2,n,3*n);r=o?h.l2P.Nudge(i,o,a):i;break}default:(0,h.h6G)(e,"type")}return h.l2P.IsNaN(r)&&(r=i),{point:i,int:r}}(e,t,n);if(i){switch(r){case"bar":return function({int:e,point:t}){let n=h.l2P.Sub(e,t).div(2),r=h.l2P.Add(t,h.l2P.Rot(n,h.sKG)),i=h.l2P.Sub(t,h.l2P.Rot(n,h.sKG));return`M ${r.x} ${r.y} L ${i.x} ${i.y}`}(i);case"square":return function({int:e,point:t}){let n=h.l2P.Lrp(t,e,.85),r=h.l2P.Sub(n,t).div(2),i=h.l2P.Add(t,h.l2P.Rot(r,h.sKG)),o=h.l2P.Sub(t,h.l2P.Rot(r,h.sKG)),s=h.l2P.Add(n,h.l2P.Rot(r,h.sKG)),a=h.l2P.Sub(n,h.l2P.Rot(r,h.sKG));return`M ${i.x} ${i.y} L ${s.x} ${s.y} L ${a.x} ${a.y} L ${o.x} ${o.y} Z`}(i);case"diamond":return function({point:e,int:t}){let n=h.l2P.Lrp(e,t,.75),r=h.l2P.RotWith(n,e,h.PI/4),i=h.l2P.RotWith(n,e,-h.PI/4),o=h.l2P.Lrp(r,i,.5);return o.add(h.l2P.Sub(o,e)),`M ${o.x} ${o.y} L ${i.x} ${i.y} ${e.x} ${e.y} L ${r.x} ${r.y} Z`}(i);case"dot":return function({point:e,int:t}){let n=h.l2P.Lrp(e,t,.45),r=h.l2P.Dist(n,e);return`M ${n.x-r},${n.y}
|
|
110
|
+
a ${r},${r} 0 1,0 ${2*r},0
|
|
111
|
+
a ${r},${r} 0 1,0 -${2*r},0 `}(i);case"inverted":return function({point:e,int:t}){let n=h.l2P.Sub(t,e).div(2),r=h.l2P.Add(e,h.l2P.Rot(n,h.sKG)),i=h.l2P.Sub(e,h.l2P.Rot(n,h.sKG));return`M ${r.x} ${r.y} L ${t.x} ${t.y} L ${i.x} ${i.y} Z`}(i);case"arrow":return function({point:e,int:t}){let n=h.l2P.RotWith(t,e,h.PI/6),r=h.l2P.RotWith(t,e,-h.PI/6);return`M ${n.x} ${n.y} L ${e.x} ${e.y} L ${r.x} ${r.y}`}(i);case"triangle":return function({point:e,int:t}){let n=h.l2P.RotWith(t,e,h.PI/6),r=h.l2P.RotWith(t,e,-h.PI/6);return`M ${n.x} ${n.y} L ${r.x} ${r.y} L ${e.x} ${e.y} Z`}(i)}return""}}function Sv(e,t){let n=wy(e,t);switch(n.type){case"straight":return new h.AoN({start:h.l2P.From(n.start.point),end:h.l2P.From(n.end.point)});case"arc":return new h.xGO({center:h.l2P.Cast(n.handleArc.center),start:h.l2P.Cast(n.start.point),end:h.l2P.Cast(n.end.point),sweepFlag:n.bodyArc.sweepFlag,largeArcFlag:n.bodyArc.largeArcFlag});case"elbow":return new h.Hes({points:n.route.points});default:(0,h.h6G)(n,"type")}}let SS=(0,h.uYT)("arrow label size",(e,t)=>{e.fonts.trackFontsForShape(t);let n=0,r=0,i=Sv(e,t),o=r2(e,r5(t.props.richText)?(0,h.TP3)("i"):t.props.richText),s=i.bounds,a=x$(e.getShapeUtil("arrow"),t),l=a.labelFontSize*t.props.scale,{w:d,h:c}=e.textMeasure.measureHtml(o,{...er,lineHeight:a.labelLineHeight,fontFamily:a.labelFontFamily,fontSize:l,maxWidth:null});n=d,r=c;let u=!1,p=wy(e,t),f=Sk(t,e.getCurrentTheme()),g="elbow"===p.type?Math.max(p.elbow.A.arrowheadOffset+f,32)+Math.max(p.elbow.B.arrowheadOffset+f,32):64;if(s.width>s.height?(n=Math.max(Math.min(d,g),Math.min(s.width-g,d)),u=!0):n>16*l&&(n=16*l,u=!0),u){let{w:t,h:i}=e.textMeasure.measureHtml(o,{...er,lineHeight:a.labelLineHeight,fontFamily:a.labelFontFamily,fontSize:l,maxWidth:n});n=t,r=i}return new h.l2P(n,r).addScalar(2*a.labelPadding*t.props.scale)},{areRecordsEqual:(e,t)=>{if(e.props===t.props)return!0;let n=(0,h.Xzd)(e.props,t.props);return 1===n.length&&"labelPosition"===n[0]}});function SC(e,t){return SS.get(e,t.id)??new h.l2P(0,0)}function Sk(e,t){let n=t.strokeWidth*ei[e.props.size];return(20+(n-t.strokeWidth*ei.s)*2+20*(n>=t.strokeWidth*ei.xl))*e.props.scale}function SP(e,t,n){if(!n&&r5(t.props.richText)){let n=Sv(e,t).interpolateAlongEdge(.5);return{box:h.azJ.FromCenter(n,new h.l2P(0,0)),debugGeom:[]}}let r=[],i=wy(e,t),o={hasStartBinding:!!i.bindings.start,hasEndBinding:!!i.bindings.end,hasStartArrowhead:"none"!==i.start.arrowhead,hasEndArrowhead:"none"!==i.end.arrowhead},s=function(e,t,n){let r,i,o=Sv(e,t),s=[],a=[new h.IQE({children:[o],debugColor:"lime"})],l=SC(e,t),d=Sk(t,e.getCurrentTheme()),c=d/o.length;if("elbow"===n.type)s.push(n.start.point,n.end.point),r=h.azJ.FromCenter(n.start.point,l).expandBy(d),i=h.azJ.FromCenter(n.end.point,l).expandBy(d);else{let e=o.interpolateAlongEdge(c),t=o.interpolateAlongEdge(1-c);s.push(e,t),r=h.azJ.FromCenter(e,l),i=h.azJ.FromCenter(t,l)}let u=o.intersectPolygon(r.corners),p=o.intersectPolygon(i.corners),f=ST(n.start.point,u),g=ST(n.end.point,p),m=f?o.uninterpolateAlongEdge(f):.5,y=g?o.uninterpolateAlongEdge(g):.5;for(let e of(m>y&&(m=.5,y=.5),[...u,...p,...s]))a.push(new h.PUi({x:e.x-3,y:e.y-3,radius:3,isFilled:!1,debugColor:"magenta",ignore:!0}));return a.push(new h.dxv({points:r.corners,debugColor:"lime",isFilled:!1,ignore:!0}),new h.dxv({points:i.corners,debugColor:"lime",isFilled:!1,ignore:!0})),{start:m,end:y,dbg:a}}(e,t,i);s.dbg&&r.push(...s.dbg);let a=function(e,t,n){let{hasEndArrowhead:r,hasEndBinding:i,hasStartBinding:o,hasStartArrowhead:s}=n;return(0,h.qE8)(e.props.labelPosition,s||o?t.start:0,r||i?t.end:1)}(t,s,o),l=Sv(e,t).interpolateAlongEdge(a),d=SC(e,t);return{box:h.azJ.FromCenter(l,d),debugGeom:r}}function ST(e,t){let n=null,r=-1/0;for(let i of t){let t=h.l2P.Dist2(e,i);t>r&&(n=i,r=t)}return n}function SE(e,t){let n=wy(e,t);switch(n.type){case"straight":case"arc":return .5;case"elbow":{let r=n.route.midpointHandle,i=Sv(e,t);if(r&&i)return i.uninterpolateAlongEdge(r.point);return .5}default:(0,h.h6G)(n,"type")}}function SI(e,t){if(!e.isShapeOfType(t,"arrow"))return!1;let n=e.getPointInShapeSpace(t,e.inputs.getCurrentPagePoint()),r=e.getShapeGeometry(t).children[1];return r&&(0,h.s3y)(n,r.vertices)}function S_(e){switch(e.type){case"straight":return new x().moveTo(e.start.point.x,e.start.point.y,{offset:0,roundness:0}).lineTo(e.end.point.x,e.end.point.y,{offset:0,roundness:0});case"arc":return new x().moveTo(e.start.point.x,e.start.point.y,{offset:0,roundness:0}).circularArcTo(e.bodyArc.radius,!!e.bodyArc.largeArcFlag,!!e.bodyArc.sweepFlag,e.end.point.x,e.end.point.y,{offset:0,roundness:0});case"elbow":{let t=new x;t.moveTo(e.start.point.x,e.start.point.y,{offset:0});for(let n=1;n<e.route.points.length;n++){let r=e.route.points[n];e.route.skipPointsWhenDrawing.has(r)||t.lineTo(r.x,r.y,{offset:n===e.route.points.length-1?0:void 0})}return t}default:(0,h.h6G)(e,"type")}}function SM({arrow:e}){let t=(0,h.hGv)(),n=(0,h.hau)("elbow arrow grid",()=>{try{return wa(t,t.getShape(e.id),fE(t,e))}catch(e){console.error(e);return}},[t,e.id]);if(!n)return null;let r=h.azJ.Common([n.A.original,n.B.original]).expandBy(50),i=n.route?.name??"",o=n.route?.midpointHandle;return(0,b.jsxs)(b.Fragment,{children:[null!==n.midX&&(0,b.jsx)(SA,{a:{x:n.midX,y:r.minY},b:{x:n.midX,y:r.maxY},stroke:"red"}),null!==n.midY&&(0,b.jsx)(SA,{a:{x:r.minX,y:n.midY},b:{x:r.maxX,y:n.midY},stroke:"blue"}),o?.axis==="x"&&n.midXRange&&(0,b.jsx)(SA,{a:{x:n.midXRange.lo,y:o.point.y},b:{x:n.midXRange.hi,y:o.point.y},stroke:"red",strokeDasharray:"0 2"}),o?.axis==="y"&&n.midYRange&&(0,b.jsx)(SA,{a:{x:o.point.x,y:n.midYRange.lo},b:{x:o.point.x,y:n.midYRange.hi},stroke:"blue",strokeDasharray:"0 2"}),(0,b.jsx)(SD,{box:n.A.original,stroke:"orange"}),(0,b.jsx)(SD,{box:n.A.expanded,stroke:"orange",strokeWidth:.5}),(0,b.jsx)(SD,{box:n.A.original.clone().expandBy(n.options.minElbowLegLength),stroke:"orange",strokeWidth:.5}),(0,b.jsx)(SD,{box:n.B.original,stroke:"lightskyblue"}),(0,b.jsx)(SD,{box:n.B.expanded,stroke:"lightskyblue",strokeWidth:.5}),(0,b.jsx)(SD,{box:n.B.original.clone().expandBy(n.options.minElbowLegLength),stroke:"lightskyblue",strokeWidth:.5}),(0,b.jsx)(SO,{edge:n.A.edges.top,axis:"x",stroke:"orange"}),(0,b.jsx)(SO,{edge:n.B.edges.top,axis:"x",stroke:"lightskyblue"}),(0,b.jsx)(SO,{edge:n.A.edges.right,axis:"y",stroke:"orange"}),(0,b.jsx)(SO,{edge:n.B.edges.right,axis:"y",stroke:"lightskyblue"}),(0,b.jsx)(SO,{edge:n.A.edges.bottom,axis:"x",stroke:"orange"}),(0,b.jsx)(SO,{edge:n.B.edges.bottom,axis:"x",stroke:"lightskyblue"}),(0,b.jsx)(SO,{edge:n.A.edges.left,axis:"y",stroke:"orange"}),(0,b.jsx)(SO,{edge:n.B.edges.left,axis:"y",stroke:"lightskyblue"}),n.route&&(0,b.jsx)(Sj,{route:n.route.points,strokeWidth:10}),(0,b.jsx)("text",{x:r.minX+5,y:r.minY-3,fontSize:10,fill:"black",stroke:"var(--tl-color-background)",strokeWidth:2,paintOrder:"stroke",children:i}),(0,b.jsxs)("text",{x:n.A.expanded.x,y:n.A.expanded.y,fontSize:10,fill:"black",stroke:"var(--tl-color-background)",strokeWidth:2,paintOrder:"stroke",children:["A",n.route&&`, ${n.route.aEdgePicking}`,n.A.isPoint&&", point"]}),(0,b.jsxs)("text",{x:n.B.expanded.x,y:n.B.expanded.y,fontSize:10,fill:"black",stroke:"var(--tl-color-background)",strokeWidth:2,paintOrder:"stroke",children:["B",n.route&&`, ${n.route.bEdgePicking}`,n.B.isPoint&&", point"]})]})}function SA({a:e,b:t,...n}){return(0,b.jsx)("line",{fill:"none",strokeWidth:1,strokeDasharray:"4,4",stroke:"green",x1:e.x,y1:e.y,x2:t.x,y2:t.y,...n})}function Sj({route:e,...t}){return(0,b.jsx)("polyline",{fill:"none",stroke:"darkorchid",strokeWidth:3,opacity:.5,points:e.map(e=>`${e.x},${e.y}`).join(" "),...t})}function SO({edge:e,axis:t,...n}){if(!e||null===e.expanded)return null;let r=e=>"x"===t?{x:e.y,y:e.x}:e;return(0,b.jsxs)("g",{children:[(0,b.jsx)(SA,{a:r({x:e.expanded,y:e.cross.min}),b:r({x:e.expanded,y:e.cross.max}),strokeDasharray:"0",strokeWidth:1.5,...n}),(0,b.jsx)(SA,{a:r({x:e.expanded-4,y:e.cross.min}),b:r({x:e.expanded+4,y:e.cross.min}),strokeDasharray:"0",strokeWidth:1.5,...n}),(0,b.jsx)(SA,{a:r({x:e.expanded-4,y:e.cross.max}),b:r({x:e.expanded+4,y:e.cross.max}),strokeDasharray:"0",strokeWidth:1.5,...n})]})}function SD({box:e,...t}){return(0,b.jsx)("rect",{x:e.minX,y:e.minY,width:e.width,height:e.height,strokeDasharray:"4,4",strokeWidth:1,fill:"none",...t})}let SL=new h.laH;function SF(e,t){let n=h.l2P.FromAngle(t).per();return h.l2P.Dpr(e,n)}let SR="start",Sz="middle";function SN(e,t,n,r=!1){let i=Math.max(0,Math.min(n,t.w/2,t.h/2));if(0===i)return void e.rect(t.x,t.y,t.w,t.h);if(r){e.moveTo(t.x,t.y+i),e.lineTo(t.x,t.maxY-i),e.arcTo(t.x,t.maxY,t.x+i,t.maxY,i),e.lineTo(t.maxX-i,t.maxY),e.arcTo(t.maxX,t.maxY,t.maxX,t.maxY-i,i),e.lineTo(t.maxX,t.y+i),e.arcTo(t.maxX,t.y,t.maxX-i,t.y,i),e.lineTo(t.x+i,t.y),e.arcTo(t.x,t.y,t.x,t.y+i,i),e.closePath();return}e.moveTo(t.x+i,t.y),e.lineTo(t.maxX-i,t.y),e.arcTo(t.maxX,t.y,t.maxX,t.y+i,i),e.lineTo(t.maxX,t.maxY-i),e.arcTo(t.maxX,t.maxY,t.maxX-i,t.maxY,i),e.lineTo(t.x+i,t.maxY),e.arcTo(t.x,t.maxY,t.x,t.maxY-i,i),e.lineTo(t.x,t.y+i),e.arcTo(t.x,t.y,t.x+i,t.y,i),e.closePath()}class S$ extends h.inY{static type="arrow";static props=h.FXh;static migrations=h.udf;options={expandElbowLegLength:{s:28,m:36,l:44,xl:66},minElbowLegLength:{s:6,m:10.5,l:15,xl:30},minElbowHandleDistance:16,arcArrowCenterSnapDistance:16,elbowArrowCenterSnapDistance:24,elbowArrowEdgeSnapDistance:20,elbowArrowPointSnapDistance:24,elbowArrowAxisSnapDistance:16,labelCenterSnapDistance:10,elbowMidpointSnapDistance:10,elbowMinSegmentLengthToShowMidpointHandle:20,hoverPreciseTimeout:600,pointingPreciseTimeout:320,shouldBeExact:e=>e.inputs.getAltKey(),shouldIgnoreTargets:e=>e.inputs.getCtrlKey(),showTextOutline:!0,getDefaultDisplayValues(e,t,n,r){let{color:i,fill:o,labelColor:s,size:a,font:l}=t.props,d=n.colors[r];return{strokeColor:(0,h.FHQ)(d,i,"solid"),strokeWidth:n.strokeWidth*ei[a],fillColor:"none"===o?"transparent":"semi"===o?d.solid:(0,h.FHQ)(d,i,Se[o]),patternFillFallbackColor:(0,h.FHQ)(d,i,"semi"),labelColor:(0,h.FHQ)(d,s,"solid"),labelFontFamily:ed(n,l),labelFontSize:n.fontSize*ea[a],labelLineHeight:n.lineHeight,labelPadding:4.25,labelBorderRadius:3.5}},getCustomDisplayValues:()=>({})};canEdit(e){return!0}canBind({toShape:e}){return"arrow"!==e.type}canSnap(e){return!1}hideResizeHandles(e){return!0}hideRotateHandle(e){return!0}hideSelectionBoundsBg(e){return!0}hideSelectionBoundsFg(e){return!0}hideInMinimap(){return!0}canBeLaidOut(e,t){if("flip"===t.type){let{start:n,end:r}=fE(this.editor,e),{shapes:i=[]}=t;if(n&&!i.find(e=>e.id===n.toId)||r&&!i.find(e=>e.id===r.toId))return!1}return!0}getFontFaces(e){if(r5(e.props.richText))return h.Mlv;let t=rJ(this.editor.getCurrentTheme(),e.props.font);return t||(0,h.EYW)(this.editor,e.props.richText,{family:`tldraw_${e.props.font}`,weight:"normal",style:"normal"})}getDefaultProps(){return{kind:"arc",elbowMidPoint:.5,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",richText:(0,h.TP3)(""),labelPosition:.5,font:"draw",scale:1}}getGeometry(e){let t,n=this.editor.getEditingShapeId()===e.id,r=wy(this.editor,e),i=[],o="straight"===r.type?new h.AoN({start:h.l2P.From(r.start.point),end:h.l2P.From(r.end.point)}):"arc"===r.type?new h.xGO({center:h.l2P.Cast(r.handleArc.center),start:h.l2P.Cast(r.start.point),end:h.l2P.Cast(r.end.point),sweepFlag:r.bodyArc.sweepFlag,largeArcFlag:r.bodyArc.largeArcFlag}):new h.Hes({points:r.route.points});if(r.isValid&&(n||!r5(e.props.richText))){let r=SP(this.editor,e,n);h.bGJ.debugGeometry.get()&&i.push(...r.debugGeom),t=new h.krb({x:r.box.x,y:r.box.y,width:r.box.w,height:r.box.h,isFilled:!0,isLabel:!0})}return new h.IQE({children:[...t?[o,t]:[o],...i]})}getHandles(e){let t=wy(this.editor,e),n=[{id:SR,type:"vertex",index:"a1",x:t.start.handle.x,y:t.start.handle.y},{id:"end",type:"vertex",index:"a3",x:t.end.handle.x,y:t.end.handle.y}];if("arc"===e.props.kind&&("straight"===t.type||"arc"===t.type)&&n.push({id:Sz,type:"virtual",index:"a2",x:t.middle.x,y:t.middle.y}),"elbow"===e.props.kind&&"elbow"===t.type&&t.route.midpointHandle){let r=this.editor.getShapePageTransform(e.id),i=r.applyToPoint(t.route.midpointHandle.segmentStart),o=r.applyToPoint(t.route.midpointHandle.segmentEnd);h.l2P.Dist(i,o)*this.editor.getEfficientZoomLevel()>this.options.elbowMinSegmentLengthToShowMidpointHandle&&n.push({id:Sz,type:"vertex",index:"a2",x:t.route.midpointHandle.point.x,y:t.route.midpointHandle.point.y})}return n}getText(e){return r4(this.editor,e.props.richText)}onHandleDrag(e,t){let n=t.handle.id;switch(n){case Sz:switch(e.props.kind){case"arc":return this.onArcMidpointHandleDrag(e,t);case"elbow":return this.onElbowMidpointHandleDrag(e,t);default:(0,h.h6G)(e.props.kind)}case SR:case"end":return this.onTerminalHandleDrag(e,t,n);default:(0,h.h6G)(n)}}onArcMidpointHandleDrag(e,{handle:t}){let n=fE(this.editor,e),{start:r,end:i}=fI(this.editor,e,n),o=h.l2P.Sub(i,r),s=h.l2P.Per(o),a=h.l2P.Med(i,r),l=h.l2P.Sub(a,s),d=h.l2P.Add(a,s),c=h.l2P.NearestPointOnLineSegment(l,d,t,!1),u=h.l2P.Dist(c,a);return h.l2P.Clockwise(c,i,a)&&(u*=-1),{id:e.id,type:e.type,props:{bend:u}}}onElbowMidpointHandleDrag(e,{handle:t}){var n;let r=wy(this.editor,e);if(r?.type!=="elbow")return;let i=this.editor.getShapePageTransform(e.id),o=i.applyToPoint(t),s=r.route.midpointHandle?.axis;if(!s)return;let a=xG[s],l=r.elbow[a.midRange];if(!l)return;let d=h.l2P.Angle(i.applyToPoint(a.v(0,0)),i.applyToPoint(a.v(0,1)));d<0&&(d+=Math.PI);let c=SF(o,d),u=SF(i.applyToPoint(a.v(l.lo,0)),d),p=SF(i.applyToPoint(a.v(l.hi,0)),d),f=this.options.elbowMidpointSnapDistance/this.editor.getEfficientZoomLevel(),g=SF(i.applyToPoint(a.v((0,h.CcK)(l.lo,l.hi,.5),0)),d),m=g,y=Math.abs(g-c);for(let[e,t]of(n=this.editor,SL.get(n,e=>{let t=(0,h.EWP)("current selected arrow shape",()=>{let t=e.getOnlySelectedShape();return t&&e.isShapeOfType(t,"arrow")?t.id:null}),n=e.store.query.ids("shape",()=>{let e=t.get();return e?{type:{eq:"arrow"},id:{neq:e}}:{type:{eq:"arrow"}}});return(0,h.EWP)("elbow arrow snap lines",()=>{let t=new Map,r=e.getCurrentPageShapeIds(),i=e.getViewportPageBounds();for(let o of n.get()){if(!r.has(o))continue;let n=e.getShape(o);if(n?.type!=="arrow")continue;let s=e.getShapePageBounds(o);if(!s||!i.includes(s))continue;let a=fE(e,n),l=e.getShapePageTransform(o);if(!l)continue;let d=e.getShapeGeometry(o),c=l.applyToPoints(d.vertices);for(let e=1;e<c.length;e++){let n=c[e-1],r=c[e],i=h.l2P.Angle(n,r);i<0&&(i+=Math.PI);let o=t.get(i);o||(o=new Set,t.set(i,o));let s=SF(n,i);o.add({perpDistance:s,startBoundShapeId:a.start?.toId,endBoundShapeId:a.end?.toId})}}return t})}).get())){let{isParallel:n,isFlippedParallel:i}=function(e,t,n=1e-4){let r=Math.abs(e-t),i=Math.abs(r-Math.PI)<n,o=Math.abs(r-h.uAR)<n;return{isParallel:r<n||o,isFlippedParallel:i}}(d,e);if(n||i)for(let e of t){let t=e.startBoundShapeId&&(e.startBoundShapeId===r.bindings.start?.toId||e.startBoundShapeId===r.bindings.end?.toId),n=e.endBoundShapeId&&(e.endBoundShapeId===r.bindings.start?.toId||e.endBoundShapeId===r.bindings.end?.toId);if(!t&&!n)continue;let o=i?-e.perpDistance:e.perpDistance,s=Math.abs(o-c);s<y&&(m=o,y=s)}}y>f&&(m=c);let b=(0,h.qE8)((0,h.Fg_)(u,p,m),0,1);return{id:e.id,type:e.type,props:{elbowMidPoint:b}}}onTerminalHandleDrag(e,{handle:t,isPrecise:n},r){let i=fE(this.editor,e),o={id:e.id,type:"arrow",props:{}},s=i[r],a=i[r===SR?"end":SR],l=wE({editor:this.editor,pointInPageSpace:this.editor.getShapePageTransform(e.id).applyToPoint(t),arrow:e,isPrecise:n,currentBinding:s,oppositeBinding:a});if(!l){fM(this.editor,e,r);let n=(0,h.Y8F)(new h.l2P(t.x,t.y),this.editor);return o.props[r]={x:n.x,y:n.y},o}let d={terminal:r,normalizedAnchor:l.normalizedAnchor,isPrecise:l.isPrecise,isExact:l.isExact,snap:l.snap};f_(this.editor,e,l.target.id,d);let c=fE(this.editor,e);return c.start&&c.end&&c.start.toId===c.end.toId&&h.l2P.Equals(c.start.props.normalizedAnchor,c.end.props.normalizedAnchor)&&f_(this.editor,e,c.end.toId,{...c.end.props,normalizedAnchor:{x:c.end.props.normalizedAnchor.x+.05,y:c.end.props.normalizedAnchor.y}}),o}onTranslateStart(e){let t=fE(this.editor,e);if("elbow"===e.props.kind&&this.editor.getOnlySelectedShapeId()===e.id){let n=wy(this.editor,e);if(!n)return;let r={id:e.id,type:"arrow",props:{}};return t.start&&(r.props.start={x:n.start.point.x,y:n.start.point.y},fM(this.editor,e,"start")),t.end&&(r.props.end={x:n.end.point.x,y:n.end.point.y},fM(this.editor,e,"end")),r}let n=fI(this.editor,e,t),r=this.editor.getShapePageTransform(e.id),i=this.editor.getSelectedShapeIds();if(!(t.start&&(i.includes(t.start.toId)||this.editor.isAncestorSelected(t.start.toId))||t.end&&(i.includes(t.end.toId)||this.editor.isAncestorSelected(t.end.toId))))for(let i of(SU.set(e,{pagePosition:r.applyToPoint(e),terminalBindings:(0,h._Hz)(n,(e,n)=>{let i=t[e];return i?{binding:i,shapePosition:n,pagePosition:r.applyToPoint(n)}:null})}),t.start&&(wS({editor:this.editor,arrow:e,terminal:"start",useHandle:!0}),e=this.editor.getShape(e.id)),t.end&&wS({editor:this.editor,arrow:e,terminal:"end",useHandle:!0}),[SR,"end"])){let e=t[i];e&&this.editor.updateBinding({...e,props:{...e.props,isPrecise:!0}})}}onTranslate(e,t){let n=SU.get(e);if(!n)return;let r=this.editor.getShapePageTransform(t.id),i=h.l2P.Sub(r.applyToPoint(t),n.pagePosition);for(let e of Object.values(n.terminalBindings)){if(!e)continue;let n=h.l2P.Add(e.pagePosition,h.l2P.Mul(i,.5)),r=this.editor.getShapeAtPoint(n,{hitInside:!0,hitFrameInside:!0,margin:0,filter:e=>!e.isLocked&&this.editor.canBindShapes({fromShape:t,toShape:e,binding:"arrow"})});if(r?.id===e.binding.toId){let i=h.azJ.ZeroFix(this.editor.getShapeGeometry(r).bounds),o=this.editor.getPointInShapeSpace(r,n),s={x:(o.x-i.minX)/i.width,y:(o.y-i.minY)/i.height};f_(this.editor,t,r.id,{...e.binding.props,normalizedAnchor:s,isPrecise:!0})}else fM(this.editor,t,e.binding.props.terminal)}}_resizeInitialBindings=new h.laH;onResize(e,t){let{scaleX:n,scaleY:r}=t,i=this._resizeInitialBindings.get(e,()=>fE(this.editor,e)),o=fI(this.editor,e,i),{start:s,end:a}=(0,h.pN9)(e.props),{bend:l}=e.props;i.start||(s.x=o.start.x*n,s.y=o.start.y*r),i.end||(a.x=o.end.x*n,a.y=o.end.y*r);let d=Math.abs(n),c=Math.abs(r),u=i?.start?h.l2P.From(i.start.props.normalizedAnchor):null,p=i?.end?h.l2P.From(i.end.props.normalizedAnchor):null;return n<0&&r>=0?(0!==l&&(l*=-1*Math.max(d,c)),u&&(u.x=1-u.x),p&&(p.x=1-p.x)):n>=0&&r<0?(0!==l&&(l*=-1*Math.max(d,c)),u&&(u.y=1-u.y),p&&(p.y=1-p.y)):n>=0&&r>=0?0!==l&&(l*=Math.max(d,c)):n<0&&r<0&&(0!==l&&(l*=Math.max(d,c)),u&&(u.x=1-u.x,u.y=1-u.y),p&&(p.x=1-p.x,p.y=1-p.y)),i.start&&u&&f_(this.editor,e,i.start.toId,{...i.start.props,normalizedAnchor:u.toJson()}),i.end&&p&&f_(this.editor,e,i.end.toId,{...i.end.props,normalizedAnchor:p.toJson()}),{props:{start:s,end:a,bend:l}}}onDoubleClickHandle(e,t){switch(t.id){case SR:return{id:e.id,type:e.type,props:{...e.props,arrowheadStart:"none"===e.props.arrowheadStart?"arrow":"none"}};case"end":return{id:e.id,type:e.type,props:{...e.props,arrowheadEnd:"none"===e.props.arrowheadEnd?"arrow":"none"}}}}component(e){let{editor:t}=this,n=x$(this,e),r=(0,h.hau)("is selected",()=>t.getOnlySelectedShape()?.id===e.id,[t,e.id]),i=(0,h.hau)("is editing",()=>t.getEditingShapeId()===e.id,[t,e.id]),o=wy(t,e);if(!o?.isValid)return null;let s=SP(t,e,i),a=i||!r5(e.props.richText);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(h.ULM,{style:{minWidth:50,minHeight:50},children:[(0,b.jsx)(SB,{shape:e,strokeColor:n.strokeColor,strokeWidth:n.strokeWidth,fillColor:n.fillColor,patternFillFallbackColor:n.patternFillFallbackColor,labelBorderRadius:n.labelBorderRadius}),"elbow"===e.props.kind&&h.bGJ.debugElbowArrows.get()&&(0,b.jsx)(SM,{arrow:e})]}),a&&(0,b.jsx)(Sy,{shapeId:e.id,type:"arrow",fontFamily:n.labelFontFamily,fontSize:n.labelFontSize,lineHeight:n.labelLineHeight,textAlign:"center",verticalAlign:"middle",labelColor:n.labelColor,richText:e.props.richText,textWidth:(s.box.w-2*n.labelPadding*e.props.scale)/e.props.scale,isSelected:r,padding:0,showTextOutline:this.options.showTextOutline,style:{transform:`translate(${s.box.center.x}px, ${s.box.center.y}px)${1!==e.props.scale?` scale(${e.props.scale})`:""}`}})]})}getIndicatorPath(e){let t=wy(this.editor,e);if(!t)return;let n=x$(this,e),r=this.editor.getEditingShapeId()===e.id,{start:i,end:o}=fI(this.editor,e,t?.bindings),s=this.editor.getShapeGeometry(e),a=r5(e.props.richText),l=r||!a?s.children[1]:null;if(h.l2P.Equals(i,o))return;let d=n.strokeWidth*e.props.scale;if(r&&l){let t=l.getBounds(),r=new Path2D;return SN(r,t,n.labelBorderRadius*e.props.scale),r}let c=this.editor.getEfficientZoomLevel()<.25/e.props.scale,u=S_(t).toPath2D("draw"!==e.props.dash||c?{style:"solid",strokeWidth:1}:{style:"draw",randomSeed:e.id,strokeWidth:1,passes:1,offset:0,roundness:2*d}),p=t.start.arrowhead&&Sw(t,"start",d),f=t.end.arrowhead&&Sw(t,"end",d),g=!!(p&&"arrow"!==t.start.arrowhead),m=!!(f&&"arrow"!==t.end.arrowhead);if(l||g||m){let t=s.bounds,r=new Path2D;r.rect(t.minX-100,t.minY-100,t.width+200,t.height+200),l&&SN(r,l.getBounds(),n.labelBorderRadius*e.props.scale,!0),g&&p&&r.addPath(new Path2D(p)),m&&f&&r.addPath(new Path2D(f));let i=[];if(p&&i.push(new Path2D(p)),f&&i.push(new Path2D(f)),l){let t=l.getBounds(),r=new Path2D;SN(r,t,n.labelBorderRadius*e.props.scale),i.push(r)}return{path:u,clipPath:r,additionalPaths:i}}let y=new Path2D;return y.addPath(u),p&&y.addPath(new Path2D(p)),f&&y.addPath(new Path2D(f)),y}onEditStart(e){if(r5(e.props.richText)){let t=SE(this.editor,e);this.editor.updateShape({id:e.id,type:e.type,props:{labelPosition:t}})}}toSvg(e,t){t.addExportDef(St(e.props.fill));let n=x$(this,e,t.colorMode),r=1/e.props.scale,i=!r5(e.props.richText);return(0,b.jsxs)("g",{transform:`scale(${r})`,children:[(0,b.jsx)(SB,{shape:e,strokeColor:n.strokeColor,strokeWidth:n.strokeWidth,fillColor:n.fillColor,patternFillFallbackColor:n.patternFillFallbackColor,labelBorderRadius:n.labelBorderRadius}),i&&(0,b.jsx)(Sb,{fontSize:n.labelFontSize*e.props.scale,fontFamily:n.labelFontFamily,lineHeight:n.labelLineHeight,textAlign:"center",verticalAlign:"middle",labelColor:n.labelColor,richText:e.props.richText,bounds:SP(this.editor,e,!1).box.clone().expandBy(-n.labelPadding*e.props.scale),padding:0,showTextOutline:this.options.showTextOutline})]})}getCanvasSvgDefs(){return[Sr()]}getInterpolatedProps(e,t,n){return{...n>.5?t.props:e.props,scale:(0,h.CcK)(e.props.scale,t.props.scale,n),start:{x:(0,h.CcK)(e.props.start.x,t.props.start.x,n),y:(0,h.CcK)(e.props.start.y,t.props.start.y,n)},end:{x:(0,h.CcK)(e.props.end.x,t.props.end.x,n),y:(0,h.CcK)(e.props.end.y,t.props.end.y,n)},bend:(0,h.CcK)(e.props.bend,t.props.bend,n),labelPosition:(0,h.CcK)(e.props.labelPosition,t.props.labelPosition,n)}}}let SB=(0,h.u4I)(function({shape:e,strokeColor:t,strokeWidth:n,fillColor:r,patternFillFallbackColor:i,labelBorderRadius:o=3.5}){var s;let a=(0,h.hGv)(),l=wy(a,e),d=Sx(.25/e.props.scale),c=(0,h.Xhk)(e.id+"_clip"),u=(0,h._As)(e.id),p=a.getShapeGeometry(e);if(!p)return null;let f=h.azJ.ZeroFix(p.bounds),g=r5(e.props.richText);if(!l?.isValid)return null;let m=n*e.props.scale,y=l.start.arrowhead&&Sw(l,"start",m),x=l.end.arrowhead&&Sw(l,"end",m),w=SP(a,e,u),v="none"!==l.start.arrowhead&&"arrow"!==l.start.arrowhead,S="none"!==l.end.arrowhead&&"arrow"!==l.end.arrowhead;return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("defs",{children:(0,b.jsx)("clipPath",{id:c,children:(0,b.jsx)(SH,{radius:o*e.props.scale,hasText:u||!g,bounds:f,labelBounds:w.box,as:v&&y?y:"",ae:S&&x?x:""})})}),(0,b.jsxs)("g",{fill:"none",stroke:t,strokeWidth:m,strokeLinejoin:"round",strokeLinecap:"round",pointerEvents:"none",children:[(0,b.jsxs)("g",{style:{clipPath:`url(#${c})`,WebkitClipPath:`url(#${c})`},children:[(0,b.jsx)("rect",{x:(0,h.WMC)(f.minX-100),y:(0,h.WMC)(f.minY-100),width:(0,h.WMC)(f.width+200),height:(0,h.WMC)(f.height+200),opacity:0}),(s={style:e.props.dash,strokeWidth:m,forceSolid:d,randomSeed:e.id},S_(l).toSvg(s))]}),y&&v&&"none"!==e.props.fill&&("pattern"===e.props.fill?(0,b.jsx)(Sh,{d:y,fillColor:r,patternFillFallbackColor:i,scale:e.props.scale}):(0,b.jsx)("path",{fill:r,d:y})),x&&S&&"none"!==e.props.fill&&("pattern"===e.props.fill?(0,b.jsx)(Sh,{d:x,fillColor:r,patternFillFallbackColor:i,scale:e.props.scale}):(0,b.jsx)("path",{fill:r,d:x})),y&&(0,b.jsx)("path",{d:y}),x&&(0,b.jsx)("path",{d:x})]})]})});function SH({radius:e,hasText:t,bounds:n,labelBounds:r,as:i,ae:o}){let s=(0,C.useMemo)(()=>{let i=new x;return i.moveTo(n.left-100,n.top-100).lineTo(n.right+100,n.top-100).lineTo(n.right+100,n.bottom+100).lineTo(n.left-100,n.bottom+100).close(),t&&i.moveTo(r.left,r.top+e).lineTo(r.left,r.bottom-e).circularArcTo(e,!1,!1,r.left+e,r.bottom).lineTo(r.right-e,r.bottom).circularArcTo(e,!1,!1,r.right,r.bottom-e).lineTo(r.right,r.top+e).circularArcTo(e,!1,!1,r.right-e,r.top).lineTo(r.left+e,r.top).circularArcTo(e,!1,!1,r.left,r.top+e).close(),i.toD()},[e,t,n.bottom,n.left,n.right,n.top,r.bottom,r.left,r.right,r.top]);return(0,b.jsx)("path",{d:`${s}${i}${o}`})}let SU=new WeakMap,SW="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 SK({url:e}){let t=(0,h.hGv)(),n=Sx(),r=(0,C.useCallback)(e=>{t.inputs.getShiftKey()||t.markEventAsHandled(e)},[t]);return(0,b.jsx)("a",{className:ik("tl-hyperlink-button",{"tl-hyperlink-button__hidden":n}),href:e,target:"_blank",rel:"noopener noreferrer",onPointerDown:r,onPointerUp:r,title:e,draggable:!1,children:(0,b.jsx)("div",{className:"tl-hyperlink__icon",style:{mask:`url("${SW}") center 100% / 100% no-repeat`,WebkitMask:`url("${SW}") center 100% / 100% no-repeat`}})})}let SV="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",SY=[{offsetX:0,offsetY:2,blur:4,spread:0,color:"#00000029"},{offsetX:0,offsetY:3,blur:6,spread:0,color:"#0000001f"}];function SG(e){return SY.map(t=>{let{offsetX:n,offsetY:r,blur:i,spread:o,color:s}=t,{x:a,y:l}=new h.l2P(n,r).rot(-e);return`${a}px ${l}px ${i}px ${o}px ${s}`}).join(", ")}class Sq extends h.A8{static type="bookmark";static props=h.aWX;static migrations=h.hNn;options={getDefaultDisplayValues:()=>({}),getCustomDisplayValues:()=>({})};canResize(e){return!1}hideSelectionBoundsFg(e){return!0}getText(e){return e.props.url}getAriaDescriptor(e){let t=e.props.assetId?this.editor.getAsset(e.props.assetId):null;if(t?.props.title)return ir(t.props.title)+(t.props.description?", "+t.props.description:"")}getDefaultProps(){return{url:"",w:300,h:320,assetId:null}}getGeometry(e){return new h.krb({width:e.props.w,height:K(this.editor,e),isFilled:!0})}component(e){let{assetId:t,url:n}=e.props,r=K(this.editor,e),i=this.editor.getShapePageTransform(e).rotation();return(0,b.jsx)(SX,{assetId:t,url:n,h:r,rotation:i})}getIndicatorPath(e){let t=new Path2D;return t.rect(0,0,e.props.w,K(this.editor,e)),t}onBeforeCreate(e){return U(this.editor,e)}onBeforeUpdate(e,t){if(e.props.url!==t.props.url)if(!h.T.linkUrl.isValid(t.props.url))return{...t,props:{...t.props,url:e.props.url}};else!function(e,t){var n,r;let i,{url:o}=t.props,s=h.Kx3.createId((0,h.xpx)(o));e.getAsset(s)?t.props.assetId!==s&&e.updateShapes([{id:t.id,type:t.type,props:{assetId:s}}]):(e.updateShapes([{id:t.id,type:t.type,props:{assetId:null}}]),n=e,r=t,(i=Y.get(n))||(i=(0,h.sg1)(V,500),Y.set(n,i)),i(n,r))}(this.editor,t);if(e.props.assetId!==t.props.assetId)return U(this.editor,t)}getInterpolatedProps(e,t,n){return{...n>.5?t.props:e.props,w:(0,h.CcK)(e.props.w,t.props.w,n),h:(0,h.CcK)(e.props.h,t.props.h,n)}}}function SX({assetId:e,rotation:t,url:n,h:r,showImageContainer:i=!0}){let o=(0,h.hGv)(),s=W(o,e,n),a=s?o.getAsset(s):null,l=!!(0,h.Jf5)()&&h.YZA.isSafari,d=function(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}(n),[c,u]=(0,C.useState)(!0),p=(0,C.useCallback)(e=>{o.inputs.getShiftKey()||o.markEventAsHandled(e)},[o]);return(0,b.jsx)(h.hDc,{children:(0,b.jsxs)("div",{className:ik("tl-bookmark__container",l&&"tl-bookmark__container--safariExport"),style:{boxShadow:l?void 0:SG(t),maxHeight:r},children:[i&&(!a||a.props.image)&&(0,b.jsxs)("div",{className:"tl-bookmark__image_container",children:[a?(0,b.jsx)("img",{className:"tl-bookmark__image",draggable:!1,referrerPolicy:"strict-origin-when-cross-origin",src:a?.props.image,alt:a?.props.title||""}):(0,b.jsx)("div",{className:"tl-bookmark__placeholder"}),a?.props.image&&(0,b.jsx)(SK,{url:n})]}),(0,b.jsxs)("div",{className:"tl-bookmark__copy_container",children:[a?.props.title?(0,b.jsx)("a",{className:"tl-bookmark__link",href:n||"",target:"_blank",rel:"noopener noreferrer",draggable:!1,onPointerDown:p,onPointerUp:p,children:(0,b.jsx)("h2",{className:"tl-bookmark__heading",children:ir(a.props.title)})}):null,a?.props.description&&a?.props.image?(0,b.jsx)("p",{className:"tl-bookmark__description",children:a.props.description}):null,(0,b.jsxs)("a",{className:"tl-bookmark__link",href:n||"",target:"_blank",rel:"noopener noreferrer",draggable:!1,onPointerDown:p,onPointerUp:p,children:[c&&a?.props.favicon?(0,b.jsx)("img",{className:"tl-bookmark__favicon",src:a?.props.favicon,referrerPolicy:"strict-origin-when-cross-origin",onError:()=>u(!1),alt:`favicon of ${d}`}):(0,b.jsx)("div",{className:"tl-hyperlink__icon",style:{mask:`url("${SV}") center 100% / 100% no-repeat`,WebkitMask:`url("${SV}") center 100% / 100% no-repeat`}}),(0,b.jsx)("span",{children:d})]})]})]})})}function SJ(e,t={}){wQ(e,t);let n=wY,r=wz,i=wN,o=w$,s=wB,a=wH,l=wU,d=wW,c=wK,u=Array(n);for(let e=0;e<n;e++){let t=new h.l2P(o[e],s[e],a[e]),n=0===e?t:new h.l2P(r[e],i[e],a[e]);u[e]={point:n,input:t,pressure:l[e],distance:d[e],runningLength:c[e],radius:1}}return u}let SZ=new Uint8Array(65536),SQ=0,S0=new TextDecoder;function S1(e){if(SQ+e>SZ.length){let e=new Uint8Array(2*SZ.length);e.set(SZ),SZ=e}}function S2(e){S1(e.length);for(let t=0;t<e.length;t++)SZ[SQ++]=e.charCodeAt(t)}function S3(e){S1(16),e<0&&(SZ[SQ++]=45,e=-e);let t=e/100|0,n=e-100*t;if(0===t){if(0===n){SZ[SQ++]=48;return}}else if(t<10)SZ[SQ++]=48+t;else if(t<100)SZ[SQ++]=48+(t/10|0),SZ[SQ++]=48+t%10;else{let e=SQ,n=t;for(;n>0;)SZ[SQ++]=48+n%10,n=n/10|0;let r=e,i=SQ-1;for(;r<i;){let e=SZ[r];SZ[r]=SZ[i],SZ[i]=e,r++,i--}}if(0!==n){SZ[SQ++]=46;let e=n%10;SZ[SQ++]=48+(n/10|0),0!==e&&(SZ[SQ++]=48+e)}}function S5(e,t){S3(e),SZ[SQ++]=44,S3(t),SZ[SQ++]=32}function S6(){let e=S0.decode(SZ.subarray(0,SQ));return SQ=0,e}function S4(e){return Math.round(100*e)}function S8(e,t=!1){let n=e.length;if(n<2)return"";if(SQ=0,2===n){let t=e[0].point,n=e[1].point,r=S4(t.x),i=S4(t.y);return S2("M"),S5(r,i),S2("l"),S5(S4(n.x)-r,S4(n.y)-i),S6()}let r=e[0].point,i=e[1].point,o=e[2].point,s=S4(i.x),a=S4(i.y),l=Math.round((r.x+i.x)*50),d=Math.round((r.y+i.y)*50),c=Math.round((i.x+o.x)*50),u=Math.round((i.y+o.y)*50),h=c,p=u;if(t)S2("M"),S5(l,d),S2("q"),S5(s-l,a-d),S5(c-l,u-d),S2("t");else{let e=S4(r.x),t=S4(r.y);S2("M"),S5(e,t),S2("q"),S5(s-e,a-t),S5(c-e,u-t),n>3&&S2("t")}for(let t=2,r=n-1;t<r;t++){let n=e[t].point,r=e[t+1].point,i=Math.round((n.x+r.x)*50),o=Math.round((n.y+r.y)*50);S5(i-h,o-p),h=i,p=o}let f=e[n-1].point;if(t){let e=Math.round((f.x+r.x)*50),t=Math.round((f.y+r.y)*50);S5(e-h,t-p),S5(l-e,d-t),S2("Z")}else S2("l"),S5(S4(f.x)-h,S4(f.y)-p);return S6()}function S9(e,t,n,r,i,o,s,a,l){let d=wz,c=wN,u=wV,h=n-e+1+ +!!i,p=0,f=0,g=t?w$[e]:d[e],m=t?wB[e]:c[e],y=u[e];for(;h-p>2;){let t=e+1+p,n=g-d[t],r=m-c[t];if(n*n+r*r<((y+u[t])/2*.5)**2)o=!0,s=d[t],a=c[t],p++;else break}let b=r?w$[n]:d[n],x=r?wB[n]:c[n],w=u[n];for(;h-p-f>2;){let e=i?n-f:n-1-f,t=b-d[e],r=x-c[e];if(t*t+r*r<((w+u[e])/2*.5)**2)f++;else break}let v=e+1+p;!function(e,t,n,r,i,o,s){vn(r-n+3);let a=w3,l=w5,d=w6,c=w4,u=w8,h=w9,p=w7,f=ve,g=wz,m=wN,y=w$,b=wB,x=wH,w=wK,v=wV;a[0]=t?y[e]:g[e],l[0]=t?b[e]:m[e],d[0]=x[e],c[0]=y[e],u[0]=b[e],h[0]=v[e],p[0]=w[e],f[0]=1;let S=1;for(let e=n;e<=r;e++)a[S]=g[e],l[S]=m[e],d[S]=x[e],c[S]=y[e],u[S]=b[e],h[S]=v[e],p[S]=w[e],f[S]=0,S++;s&&(f[S-1]=1),a[S]=o?y[i]:g[i],l[S]=o?b[i]:m[i],d[S]=x[i],c[S]=y[i],u[S]=b[i],h[S]=v[i],p[S]=w[i],f[S]=1,vt=S+1}(e,t,v,i?n-f:n-1-f,n,r,i&&0===f),Ce(l,o,s,a)}function S7(e,t,n){S2("a"),S3(e),S2(","),S3(e),S2(" 0 0 1 "),S5(t,n)}function Ce(e,t,n,r){let i=vt;if(0===i)return;if(1===i){var o,s,a;let e,t,n;return void(o=w3[0],s=w5[0],a=w9[0],e=S4(o),t=S4(s),n=S4(a),S2("M "),S3(e),S2(" "),S3(t),S2(" m -"),S3(n),S2(", 0 a "),S3(n),S2(","),S3(n),S2(" 0 1,1 "),S3(2*n),S2(",0 a "),S3(n),S2(","),S3(n),S2(" 0 1,1 -"),S3(2*n),S2(",0"))}vf(e,t,n,r);let l=va,d=vl,c=vd,u=vc,h=S4(l[0]),p=S4(d[0]);S2("M"),S5(h,p),S2("t");let f=l[0],g=d[0];for(let e=1;e<vu;e++){let t=l[e],n=d[e],r=Math.round((f+t)*50),i=Math.round((g+n)*50);S5(r-h,i-p),h=r,p=i,f=t,g=n}{let e=w3[i-1],t=w5[i-1],n=w9[i-1],r=w3[i-2]-e,o=w5[i-2]-t,s=Math.sqrt(r*r+o*o),a=-o/s*n,l=r/s*n,d=S4(e+a),c=S4(t+l),u=S4(e-a),f=S4(t-l);S5(d-h,c-p),S7(S4(n),u-d,f-c),S2("t"),h=u,p=f}f=c[vh-1],g=u[vh-1];for(let e=vh-2;e>=0;e--){let t=c[e],n=u[e],r=Math.round((f+t)*50),i=Math.round((g+n)*50);S5(r-h,i-p),h=r,p=i,f=t,g=n}{let e=w3[0],t=w5[0],n=w9[0],r=e-w3[1],i=t-w5[1],o=Math.sqrt(r*r+i*i),s=i/o*n,a=-r/o*n,l=S4(e+s),d=S4(t+a),c=S4(e-s),u=S4(t-a);S5(l-h,d-p),S7(S4(n),c-l,u-d),S2("Z")}}function Ct(e,t,n){let r=[],i=[];e.forEach(e=>r.push(...h.K6A.decodePoints(e.path,e.dim))),t.forEach(e=>i.push(...h.K6A.decodePoints(e.path,e.dim)));let o=Math.max(r.length,i.length),s=[],a=[];for(let e=0;e<o;e++)s.push(r[e]||r[r.length-1]),a.push(i[e]||i[i.length-1]);let l=s.map((e,t)=>{let r=.5;return void 0!==a[t].z&&void 0!==e.z&&(r=(0,h.CcK)(e.z,a[t].z,n)),{x:(0,h.CcK)(e.x,a[t].x,n),y:(0,h.CcK)(e.y,a[t].y,n),z:r}});return[{type:"free",path:h.K6A.encodePoints(l)}]}class Cn extends h.inY{static type="draw";static props=h.KBL;static migrations=h.deR;options={maxPointsPerShape:600,getDefaultDisplayValues(e,t,n,r){let{color:i,fill:o,size:s}=t.props,a=n.colors[r];return{strokeColor:(0,h.FHQ)(a,i,"solid"),strokeWidth:n.strokeWidth*ei[s],fillColor:"none"===o?"transparent":"semi"===o?a.solid:(0,h.FHQ)(a,i,Se[o]),patternFillFallbackColor:(0,h.FHQ)(a,i,"semi")}},getCustomDisplayValues:()=>({})};hideResizeHandles(e){return Ci(e)}hideRotateHandle(e){return Ci(e)}hideSelectionBoundsFg(e){return Ci(e)}getDefaultProps(){return{segments:[],color:"black",fill:"none",dash:"draw",size:"m",isComplete:!1,isClosed:!1,isPen:!1,scale:1,scaleX:1,scaleY:1}}getGeometry(e){let t=y(e.props.segments,e.props.scaleX,e.props.scaleY),n=(x$(this,e).strokeWidth+1)*e.props.scale;if(1===e.props.segments.length){let e=h.azJ.FromPoints(t);if(e.width<2*n&&e.height<2*n)return new h.PUi({x:-n,y:-n,radius:n,isFilled:!0})}let r=SJ(t,m(e.props,n,e.props.isPen,!0)).map(e=>e.point);return e.props.isClosed&&r.length>2?new h.dxv({points:r,isFilled:"none"!==e.props.fill}):1===r.length?new h.PUi({x:-n,y:-n,radius:n,isFilled:!0}):new h.Hes({points:r})}component(e){let t=x$(this,e);return(0,b.jsx)(h.ULM,{children:(0,b.jsx)(Co,{shape:e,strokeColor:t.strokeColor,strokeWidth:t.strokeWidth,fillColor:t.fillColor,patternFillFallbackColor:t.patternFillFallbackColor})})}getIndicatorPath(e){let t=y(e.props.segments,e.props.scaleX,e.props.scaleY),n=(x$(this,e).strokeWidth+1)*e.props.scale,r=this.editor.getEfficientZoomLevel();r<.5&&r<1.5/n||e.props.isPen||"draw"!==e.props.dash||1!==t.length||(n+=(0,h.She)(e.id)()*(n/6));let i=e.props.isComplete||(0,h.HVh)(e.props.segments)?.type==="straight",o=SJ(t,m(e.props,n,i,!0));return new Path2D(o.length>1?S8(o,e.props.isClosed):Cr(t[0],n))}toSvg(e,t){t.addExportDef(St(e.props.fill));let n=x$(this,e,t.colorMode),r=1/e.props.scale;return(0,b.jsx)("g",{transform:`scale(${r})`,children:(0,b.jsx)(Co,{shape:e,zoomOverride:1,strokeColor:n.strokeColor,strokeWidth:n.strokeWidth,fillColor:n.fillColor,patternFillFallbackColor:n.patternFillFallbackColor})})}getCanvasSvgDefs(){return[Sr()]}onResize(e,t){let n=t.scaleX*e.props.scaleX,r=t.scaleY*e.props.scaleY;if(0!==n&&0!==r)return{props:{scaleX:n,scaleY:r}}}expandSelectionOutlinePx(e){let t="draw"===e.props.dash?1.6:1;return x$(this,e).strokeWidth*t/2*e.props.scale}getInterpolatedProps(e,t,n){return{...n>.5?t.props:e.props,segments:Ct(e.props.segments,t.props.segments,n),scale:(0,h.CcK)(e.props.scale,t.props.scale,n)}}}function Cr(e,t){let n=(t+1)*.5;return`M ${e.x} ${e.y} m -${n}, 0 a ${n},${n} 0 1,0 ${2*n},0 a ${n},${n} 0 1,0 -${2*n},0`}function Ci(e){let t=e.props.segments[0];return 1===e.props.segments.length&&h.K6A.isSinglePoint(t.path,t.dim)}function Co({shape:e,zoomOverride:t,strokeColor:n,strokeWidth:r,fillColor:i,patternFillFallbackColor:o}){var s;let a=(0,h.hGv)(),l=y(e.props.segments,e.props.scaleX,e.props.scaleY),d=e.props.isComplete||(0,h.HVh)(e.props.segments)?.type==="straight",c=(r+1)*e.props.scale,u=(0,h.hau)("force solid",()=>{let e=t??a.getEfficientZoomLevel();return e<.5&&e<1.5/c},[a,c,t]),p=(0,h.hau)("dot adjustment",()=>(t??a.getEfficientZoomLevel())<.2?9:.1,[a,t]);u||e.props.isPen||"draw"!==e.props.dash||1!==l.length||(c+=(0,h.She)(e.id)()*(c/6));let f=m(e.props,c,d,u);if(!u&&"draw"===e.props.dash)return(0,b.jsxs)(b.Fragment,{children:[e.props.isClosed&&"none"!==e.props.fill&&l.length>1&&("pattern"===e.props.fill?(0,b.jsx)(Sh,{d:S8(SJ(l,f),e.props.isClosed),fillColor:i,patternFillFallbackColor:o,scale:e.props.scale}):(0,b.jsx)("path",{fill:i,d:S8(SJ(l,f),e.props.isClosed)})),(0,b.jsx)("path",{d:function(e,t={}){let{start:n={},end:r={}}=t,{cap:i=!0}=n,{cap:o=!0}=r;return(0,h.vAR)(!n.taper&&!r.taper,"cap taper not supported here"),(0,h.vAR)(!n.easing&&!r.easing,"cap easing not supported here"),(0,h.vAR)(i&&o,"cap must be true"),wQ(e,t),w1(t),SQ=0,function(e){let t=wY;if(0===t)return;if(t<=2){vr(),Ce(e,!1,0,0);return}let n=wz,r=wN,i=wV,o=0,s=!1,a=!1,l=0,d=0,c=n[1]-n[0],u=r[1]-r[0],h=Math.sqrt(c*c+u*u),p=c/h,f=u/h;for(let g=1;g<t-1;g++){h=Math.sqrt((c=n[g+1]-n[g])*c+(u=r[g+1]-r[g])*u);let t=c/h,m=u/h,y=p*t+f*m;if(p=t,f=m,y<-.8){S9(o,s,g,!0,!1,a,l,d,e),o=g,s=!0,a=!0,l=n[g],d=r[g];continue}if(y>.7)continue;let b=n[g]-n[g-1],x=r[g]-r[g-1],w=n[g+1]-n[g],v=r[g+1]-r[g],S=(i[g-1]+i[g]+i[g+1])/3;if((b*b+x*x+w*w+v*v)/(S*S)<1.5){S9(o,s,g,!1,!0,a,l,d,e),o=g,s=!1,a=!1;continue}}S9(o,s,t-1,!1,!1,a,l,d,e)}(t),S6()}(l,f),strokeLinecap:"round",fill:n})]});let g=SJ(l,f),x=g.length<2,w=x||e.props.isClosed?e.props.fill:"none",v=x?Cr(l[0],0):S8(g,e.props.isClosed&&"none"!==w);return(0,b.jsxs)(b.Fragment,{children:[x||!e.props.isClosed||"none"===w?null:"pattern"===w?(0,b.jsx)(Sh,{d:v,fillColor:i,patternFillFallbackColor:o,scale:e.props.scale}):(0,b.jsx)("path",{fill:i,d:v}),"none"!==e.props.dash&&(0,b.jsx)("path",{d:v,strokeLinecap:"round",fill:x?n:"none",stroke:n,strokeWidth:c,strokeDasharray:x?"none":(s=c,({draw:"none",solid:"none",dotted:`${p} ${2*s}`,dashed:`${2*s} ${2*s}`,none:"none"})[e.props.dash]),strokeDashoffset:"0"})]})}let Cs=(e,t)=>!!e.find(e=>{let n=new RegExp(e.split("*").map(e=>(function(e){if("string"!=typeof e)throw TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")})(e)).join(".+"));return t.match(n)}),Ca=e=>Object.entries(e).filter(([e,t])=>t).map(([e])=>e).join(" ");class Cl extends h.A8{static type="embed";static props=h.Pwo;static migrations=h.upp;options={embedDefinitions:dM,embedConfig:{},getDefaultDisplayValues:()=>({showShadow:!0}),getCustomDisplayValues:()=>({})};canEditWhileLocked(e){let t=this.getEmbedDefinition(e.props.url);return!t||(t.definition.canEditWhileLocked??!0)}static legacyEmbedDefinitions=null;static setEmbedDefinitions(e){Cl.legacyEmbedDefinitions=e}getEmbedDefs(){return Cl.legacyEmbedDefinitions??this.options.embedDefinitions}getEmbedDefinitions(){return this.getEmbedDefs()}getEmbedDefinition(e){var t=this.getEmbedDefs(),n=this.options.embedConfig;try{return function(e,t,n){let r=(0,h.yCG)(t);if(!r)return;let i=r.host.replace("www.","");for(let r of e)if(Cs(r.hostnames,i)){let e=r.toEmbedUrl(t,n?.[r.type]);if(e)return{definition:r,embedUrl:e,url:t}}}(t,e,n)??function(e,t){let n=(0,h.yCG)(t);if(!n)return;let r=n.host.replace("www.","");for(let n of e)if(Cs(n.hostnames,r)){let e=n.fromEmbedUrl(t);if(e)return{definition:n,url:e,embedUrl:t}}}(t,e)}catch{return}}async resolveAspectRatio(e){let{url:t}=e.props,n=this.getEmbedDefinition(t)?.definition;if(!n?.sizeToContentAspectRatio||!t)return;let r=await this.getContentAspectRatio(t);if(this.editor.isDisposed)return;let i=this.editor.getShape(e.id);if(!i||i.props.url!==t)return;let o=function({w:e,h:t,resolvedRatio:n}){if(!n||n<=0||.001>=Math.abs(e/t-n))return null;let r=e*t;return{w:Math.sqrt(r*n),h:Math.sqrt(r/n)}}({w:i.props.w,h:i.props.h,resolvedRatio:r});if(!o)return;let{minWidth:s,minHeight:a}=this.getResizeMinBounds(i),l=Math.max(1,s/o.w,a/o.h),d=o.w*l,c=o.h*l;this.editor.run(()=>{this.editor.resizeShape(i.id,{x:d/i.props.w,y:c/i.props.h},{isAspectRatioLocked:!1})},{history:"ignore"})}async getContentAspectRatio(e){try{let t=await this.editor.getAssetForExternalContent({type:"url",url:e});if(!t||"bookmark"!==t.type)return;let n=t.meta.imageWidth,r=t.meta.imageHeight;if("number"==typeof n&&"number"==typeof r&&n>0&&r>0)return n/r}catch{}}getText(e){return e.props.url}getAriaDescriptor(e){let t=this.getEmbedDefinition(e.props.url);return t?.definition.title}hideSelectionBoundsFg(e){return!this.canResize(e)}canEdit(e){return!0}canResize(e){return this.getEmbedDefinition(e.props.url)?.definition?.doesResize??!0}canEditInReadonly(e){return!0}getDefaultProps(){return{w:300,h:300,url:""}}getGeometry(e){return super.getGeometry(e)}isAspectRatioLocked(e){let t=this.getEmbedDefinition(e.props.url);return t?.definition.isAspectRatioLocked??!1}getResizeMinBounds(e){let t=this.getEmbedDefinition(e.props.url),n=t?.definition.minWidth??200,r=t?.definition.minHeight??200;if(this.isAspectRatioLocked(e)){let t=e.props.w/e.props.h;t>1?n*=t:r/=t}return{minWidth:n,minHeight:r}}onResize(e,t){return(0,h.mfH)(e,t,this.getResizeMinBounds(e))}component(e){let t=(0,h.Jf5)(),{w:n,h:r,url:i}=e.props,o=(0,h._As)(e.id),s=x$(this,e,(0,h.G67)()),a=this.getEmbedDefinition(i),l=(0,h.hau)("is hovering",()=>{let{editingShapeId:e,hoveredShapeId:t}=this.editor.getCurrentPageState();if(e&&t!==e){let t=this.editor.getShape(e);if(t&&this.editor.isShapeOfType(t,"embed"))return!0}return!1},[]),d=this.editor.getShapePageTransform(e).rotation();if(t)return(0,b.jsx)(h.hDc,{className:"tl-embed-container",id:e.id,children:(0,b.jsx)("div",{className:"tl-embed",style:{border:0,boxShadow:s.showShadow?SG(d):"none",borderRadius:a?.definition.overrideOutlineRadius??8,background:a?.definition.backgroundColor??"var(--tl-color-background)",width:n,height:r}})});let c=o||l;if("u">typeof window&&(window!==window.top||window.self!==window.parent)&&a?.definition.type==="tldraw")return null;let u=Ca({...dA,...a?a.definition.overridePermissions??{}:dj});if(a?.definition.type==="github_gist"){let t=a.url.split("/").pop();if(!t)throw Error("No gist id!");let i=Ca({...dA,...a?.definition?.overridePermissions??{},"allow-same-origin":!1});return(0,b.jsx)(h.hDc,{className:"tl-embed-container",id:e.id,children:(0,b.jsx)(Cd,{id:t,sandbox:i,width:(0,h.WMC)(n),height:(0,h.WMC)(r),isInteractive:c,pageRotation:d,showShadow:s.showShadow})})}let p=a?.embedUrl??i;return(0,b.jsx)(h.hDc,{className:"tl-embed-container",id:e.id,children:p?(0,b.jsx)("iframe",{className:"tl-embed",sandbox:u,src:p,width:(0,h.WMC)(n),height:(0,h.WMC)(r),draggable:!1,frameBorder:"0",referrerPolicy:"strict-origin-when-cross-origin",tabIndex:o?0:-1,allowFullScreen:!0,style:{border:0,width:"100%",height:"100%",pointerEvents:c?"auto":"none",zIndex:c?"":"-1",boxShadow:s.showShadow?SG(d):"none",borderRadius:a?.definition?.overrideOutlineRadius??8,background:a?.definition?.backgroundColor}}):(0,b.jsx)(SX,{url:i,h:r,rotation:d,assetId:null,showImageContainer:!1})})}getIndicatorPath(e){let t=new Path2D;return t.rect(0,0,e.props.w,e.props.h),t}getInterpolatedProps(e,t,n){return{...n>.5?t.props:e.props,w:(0,h.CcK)(e.props.w,t.props.w,n),h:(0,h.CcK)(e.props.h,t.props.h,n)}}}function Cd({id:e,sandbox:t,isInteractive:n,width:r,height:i,style:o,pageRotation:s,showShadow:a}){if(!e.match(/^[0-9a-f]+$/))throw Error("No gist id!");return(0,b.jsx)("iframe",{className:"tl-embed",sandbox:t,draggable:!1,width:(0,h.WMC)(r),height:(0,h.WMC)(i),frameBorder:"0",scrolling:"no",referrerPolicy:"strict-origin-when-cross-origin",tabIndex:n?0:-1,style:{...o,pointerEvents:n?"all":"none",zIndex:n?"":"-1",boxShadow:a?SG(s):"none"},srcDoc:`
|
|
112
|
+
<html>
|
|
113
|
+
<head>
|
|
114
|
+
<base target="_blank">
|
|
115
|
+
</head>
|
|
116
|
+
<body>
|
|
117
|
+
<script src=https://gist.github.com/${e}.js></script>
|
|
118
|
+
<style type="text/css">
|
|
119
|
+
* { margin: 0px; }
|
|
120
|
+
table { height: 100%; background-color: red; }
|
|
121
|
+
.gist { background-color: none; height: 100%; }
|
|
122
|
+
.gist .gist-file { height: calc(100vh - 2px); padding: 0px; display: grid; grid-template-rows: 1fr auto; }
|
|
123
|
+
</style>
|
|
124
|
+
</body>
|
|
125
|
+
</html>`})}function Cc(e,t){return e.match(/^\s*$/)?t:e}function Cu(e,t){return Math.floor((2/Math.PI*((0,h.rgm)(e.getShapePageTransform(t.id).rotation())+Math.PI/4)+4)%4)}let Ch=new WeakMap;function Cp(e,t,n){let r=Ch.get(t.props);if(!r){let i=Cc(t.props.name,"Frame")+String.fromCharCode(8203),o=e.textMeasure.measureTextSpans(i,n),s=o[0],a=(0,h.HVh)(o);r=a.box.w+a.box.x-s.box.x,Ch.set(t.props,r)}return new h.azJ(0,-n.height,r,n.height)}function Cf(e,t){return{fontSize:12,fontFamily:t?"Arial":"Inter, sans-serif",textAlign:"start",width:e,height:24,padding:0,lineHeight:1,fontStyle:"normal",fontWeight:"normal",overflow:"truncate-ellipsis",verticalTextAlign:"middle",offsetY:-34,offsetX:0}}function Cg(e,t,n){let r,i=n?"":"px",o=n?"":"deg";switch(t){case 0:r="";break;case 3:r=`translate(${(0,h.WMC)(e.props.w)}${i}, 0${i}) rotate(90${o})`;break;case 2:r=`translate(${(0,h.WMC)(e.props.w)}${i}, ${(0,h.WMC)(e.props.h)}${i}) rotate(180${o})`;break;case 1:r=`translate(0${i}, ${(0,h.WMC)(e.props.h)}${i}) rotate(270${o})`;break;default:throw Error("labelSide out of bounds")}return r}let Cm=(0,C.forwardRef)(({id:e,name:t,isEditing:n},r)=>{let i=(0,h.hGv)(),o=d$(),s=(0,h.hau)("isCoarsePointer",()=>i.getInstanceState().isCoarsePointer,[i]),a=o<5&&s,l=(0,C.useRef)(!1),d=$(),c=(0,C.useCallback)(e=>{n&&i.markEventAsHandled(e)},[i,n]),u=(0,C.useCallback)(e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(i.markEventAsHandled(e),e.currentTarget.blur(),i.setEditingShape(null))},[i]),p=(0,C.useCallback)(t=>{let n=i.getShape(e);n&&n.props.name!==t&&i.updateShapes([{id:e,type:"frame",props:{name:t}}])},[e,i]),f=(0,C.useCallback)(e=>{p(e.currentTarget.value)},[p]),g=(0,C.useCallback)(e=>{p(e.currentTarget.value)},[p]);return(0,C.useEffect)(()=>{if(!n){l.current=!1;return}if(n&&a&&!l.current){l.current=!0;let t=i.getShape(e),n=t?.props.name??"",r=window.prompt(d("action.rename"),n);l.current=!1,null!==r&&p(r),i.setEditingShape(null)}},[n,a,e,d,p,i]),(0,b.jsxs)("div",{className:`tl-frame-label ${n&&!a?"tl-frame-label__editing":""}`,children:[(0,b.jsx)("input",{className:"tl-frame-name-input",ref:r,disabled:!n||a,readOnly:!n||a,style:{display:n?void 0:"none"},value:t,autoFocus:!a,onKeyDown:u,onBlur:f,onChange:g,onPointerDown:c,draggable:!1}),Cc(t,"Frame")+String.fromCharCode(8203)]})}),Cy=(0,C.memo)(function({id:e,name:t,width:n,height:r,fill:i,stroke:o,color:s,offsetX:a,showColors:l}){let d=(0,h.hGv)(),{side:c,translation:u}=(0,h.hau)("shape rotation",()=>{let t=d.getShape(e);if(!t)return{side:0,translation:"translate(0, 0)"};let n=Cu(d,t);return{side:n,translation:Cg(t,n,!1)}},[d,a,e]),p=(0,C.useRef)(null),f=(0,h._As)(e);return(0,C.useEffect)(()=>{let e=p.current;e&&f&&(e.focus(),e.select())},[p,f]),(0,b.jsx)("div",{className:"tl-frame-heading",style:{overflow:f?"visible":"hidden",maxWidth:`calc(var(--tl-zoom) * ${0===c||2===c?Math.ceil(n):Math.ceil(r)}px + ${l?"0px":"var(--tl-frame-offset-width)"})`,bottom:"100%",transform:`${u} scale(min(var(--tl-scale), 3.5)) translateX(${a}px)`},children:(0,b.jsx)("div",{className:"tl-frame-heading-hit-area",style:{color:s,backgroundColor:i,boxShadow:`inset 0px 0px 0px 1px ${o}`},children:(0,b.jsx)(Cm,{ref:p,id:e,name:t,isEditing:f})})})});class Cb extends h.B$v{static type="frame";static props=h.X24;static migrations=h.SpZ;options={showColors:!1,resizeChildren:!1,getDefaultDisplayValues(e,t,n,r){let{color:i}=t.props,o=n.colors[r];return{fillColor:(0,h.FHQ)(o,"black","frameFill"),strokeColor:(0,h.FHQ)(o,"black","frameStroke"),showColorsFillColor:(0,h.FHQ)(o,i,"frameFill"),showColorsStrokeColor:(0,h.FHQ)(o,i,"frameStroke"),headingFillColor:o.negativeSpace,headingStrokeColor:o.negativeSpace,headingTextColor:(0,h.FHQ)(o,"black","frameText"),showColorsHeadingFillColor:(0,h.FHQ)(o,i,"frameHeadingFill"),showColorsHeadingStrokeColor:(0,h.FHQ)(o,i,"frameHeadingStroke"),showColorsHeadingTextColor:(0,h.FHQ)(o,i,"frameText")}},getCustomDisplayValues:()=>({})};static configure(e){let t=super.configure.call(this,e);return e.showColors&&(t.props={...t.props,color:h.ive}),t}canEdit(e,t){return"click-header"===t.type||"unknown"===t.type}canResize(e){return!0}canResizeChildren(e){return this.options.resizeChildren}isExportBoundsContainer(){return!0}getDefaultProps(){return{w:320,h:180,name:"",color:"black"}}getAriaDescriptor(e){return e.props.name}getGeometry(e){let t,n,{editor:r}=this,i=r.getEfficientZoomLevel(),o=Cu(r,e),s=o%2==1,a=s?e.props.h:e.props.w,l=Cp(r,e,Cf(a,!1)),d=this.options.showColors,c=12/i,u=l.w/i,p=l.h/i,f=(0,h.qE8)(u+c,32/i,a+(d?1:c)),g=(d?-1:-7)/i,m=4/i,y=s?p:f,b=s?f:p;switch(o){case 0:t=g,n=-(p+m);break;case 1:t=-(p+m),n=e.props.h-(g+f);break;case 2:t=e.props.w-(g+f),n=e.props.h+m;break;case 3:t=e.props.w+m,n=g}return new h.IQE({children:[new h.krb({width:e.props.w,height:e.props.h,isFilled:!1}),new h.krb({x:t,y:n,width:y,height:b,isFilled:!0,isLabel:!0,excludeFromShapeBounds:!0})]})}getText(e){return e.props.name}component(e){let t=x$(this,e,(0,h.G67)()),n=(0,h.hau)("is creating this shape",()=>{let t=this.editor.getStateDescendant("select.resizing");if(!t||!t.getIsActive())return!1;let n=t?.info;return!!n&&n.isCreating&&this.editor.getOnlySelectedShapeId()===e.id},[e.id]),r=this.options.showColors;return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(h.ULM,{children:(0,b.jsx)("rect",{className:ik("tl-frame__body",{"tl-frame__creating":n}),fill:r?t.showColorsFillColor:t.fillColor,stroke:r?t.showColorsStrokeColor:t.strokeColor,style:{width:`calc(${e.props.w}px + 1px / var(--tl-zoom))`,height:`calc(${e.props.h}px + 1px / var(--tl-zoom))`,transform:"translate(calc(-0.5px / var(--tl-zoom)), calc(-0.5px / var(--tl-zoom)))"}})}),n?null:(0,b.jsx)(Cy,{id:e.id,name:e.props.name,fill:r?t.showColorsHeadingFillColor:t.headingFillColor,stroke:r?t.showColorsHeadingStrokeColor:t.headingStrokeColor,color:r?t.showColorsHeadingTextColor:t.headingTextColor,width:e.props.w,height:e.props.h,offsetX:r?-1:-7,showColors:this.options.showColors})]})}toSvg(e,t){let n=x$(this,e,t.colorMode),r=Cu(this.editor,e),i=r%2==1?e.props.h:e.props.w,o=Cg(e,r,!0),s=Cf(i-12,!0),a=Cc(e.props.name,"Frame")+String.fromCharCode(8203),l=Cp(this.editor,e,s),d=this.editor.textMeasure.measureTextSpans(a,s),c=function(e,t,n){let{padding:r=0}=n;if(0===t.length)return null;let i=h.azJ.From(t[0].box);for(let{box:e}of t)i.union(e);let o=r+(n.offsetX??0),s=(n.offsetY??0)+n.fontSize/2+("start"===n.verticalTextAlign?r:"end"===n.verticalTextAlign?n.height-r-i.height:(Math.ceil(n.height)-i.height)/2),a=null,l=[];for(let{text:e,box:n}of t)null!==a&&n.y>a&&l.push((0,b.jsx)("tspan",{alignmentBaseline:"mathematical",x:o,y:n.y+s,children:"\n"},l.length)),l.push((0,b.jsx)("tspan",{alignmentBaseline:"mathematical",x:n.x+o,y:n.y+s,unicodeBidi:"plaintext",children:e.replace(/\s/g,"\xa0")},l.length)),a=n.y;return(0,b.jsx)("text",{fontSize:n.fontSize,fontFamily:n.fontFamily,fontStyle:n.fontStyle,fontWeight:n.fontWeight,dominantBaseline:"mathematical",alignmentBaseline:"mathematical",stroke:n.stroke,strokeWidth:n.strokeWidth,fill:n.fill,children:l})}(this.editor,d,s),u=this.options.showColors,p=u?n.showColorsHeadingStrokeColor:n.headingStrokeColor,f=u?n.showColorsHeadingFillColor:n.headingFillColor,g=u?n.showColorsHeadingTextColor:n.headingTextColor;return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("rect",{width:e.props.w,height:e.props.h,fill:u?n.showColorsFillColor:n.fillColor,stroke:u?n.showColorsStrokeColor:n.strokeColor,strokeWidth:1,x:0,rx:0,ry:0}),(0,b.jsxs)("g",{fill:g,transform:o,children:[(0,b.jsx)("rect",{x:l.x-6*!u,y:l.y-6,width:Math.min(i,l.width+12),height:l.height,fill:f,stroke:p,rx:4,ry:4}),(0,b.jsx)("g",{transform:`translate(${8*!!u}, 4)`,children:c})]})]})}getIndicatorPath(e){let t=new Path2D;return t.rect(0,0,e.props.w,e.props.h),t}getInterpolatedProps(e,t,n){return{...n>.5?t.props:e.props,w:(0,h.CcK)(e.props.w,t.props.w,n),h:(0,h.CcK)(e.props.h,t.props.h,n)}}onDoubleClickEdge(e,t){if("selection"!==t.target)return;let{handle:n}=t;if(!n)return;let r="left"===n||"right"===n,i="top"===n||"bottom"===n,o=this.editor.getSortedChildIdsForParent(e.id),s=(0,h.oE7)(o.map(e=>this.editor.getShape(e)));if(!s.length)return;let{dx:a,dy:l,w:d,h:c}=iS(s,this.editor,{padding:10});return this.editor.run(()=>{let e=o.map(e=>{let t=this.editor.getShape(e);return{id:t.id,type:t.type,x:r?t.x+a:t.x,y:i?t.y+l:t.y}});this.editor.updateShapes(e)}),{id:e.id,type:e.type,props:{w:r?d:e.props.w,h:i?c:e.props.h}}}onDoubleClickCorner(e){return iC(this.editor,e.id,{padding:10}),{id:e.id,type:e.type}}}function Cx({shape:e,shouldScale:t,forceSolid:n,strokeColor:r,strokeWidth:i,fillColor:o,patternFillFallbackColor:s,customGeoTypes:a}){let l=t?e.props.scale:1,d=i*l,{dash:c,fill:u}=e.props,h=m5(e,i,a),p="draw"!==c||n?h.toD({onlyFilled:!0}):h.toDrawD({strokeWidth:d,randomSeed:e.id,passes:1,offset:0,onlyFilled:!0});return(0,b.jsxs)(b.Fragment,{children:["none"===u?null:"pattern"===u?(0,b.jsx)(Sh,{d:p,fillColor:o,patternFillFallbackColor:s,scale:l}):(0,b.jsx)("path",{fill:o,d:p}),h.toSvg({style:c,strokeWidth:d,forceSolid:n,randomSeed:e.id,props:{fill:"none",stroke:r}})]})}let Cw=Object.freeze({s:12,m:14,l:16,xl:20}),Cv=Object.freeze({start:"start",middle:"center",end:"end","start-legacy":"start","end-legacy":"end","middle-legacy":"center"}),CS=Object.freeze({start:"start",middle:"middle",end:"end"}),CC=Object.freeze({w:0,h:0}),Ck=new Set(Object.keys(m1));class CP extends h.A8{static type="geo";static props=h.X8F;static migrations=h.s4L;static configure(e){if(e.customGeoTypes){let t=[];for(let[n,r]of Object.entries(e.customGeoTypes))Ck.has(n)||t.push([n,r]);t.length>0&&h.tg8.addValues(...t.map(([e])=>e));let n={...e,customGeoTypes:Object.fromEntries(t)};return super.configure(n)}return super.configure(e)}options={showTextOutline:!0,getDefaultDisplayValues(e,t,n,r){let{color:i,size:o,labelColor:s,fill:a,align:l,verticalAlign:d,font:c}=t.props,u=n.colors[r];return{strokeColor:(0,h.FHQ)(u,i,"solid"),strokeRoundness:n.strokeWidth*ei[o]*2,strokeWidth:n.strokeWidth*ei[o],fillColor:"none"===a?"transparent":"semi"===a?u.solid:(0,h.FHQ)(u,i,Se[a]),patternFillFallbackColor:(0,h.FHQ)(u,i,"semi"),labelColor:(0,h.FHQ)(u,s,"solid"),labelFontFamily:ed(n,c),labelFontSize:n.fontSize*es[o],labelMinWidth:Cw[o],labelExtraPadding:n.strokeWidth*ei[o],labelLineHeight:n.lineHeight,labelFontWeight:"normal",labelFontVariant:"normal",labelFontStyle:"normal",labelHorizontalAlign:Cv[l],labelVerticalAlign:CS[d],labelPadding:16,labelEdgeMargin:8,minSizeWithLabel:51}},getCustomDisplayValues:(e,t)=>({})};canEdit(e){return!0}getDefaultProps(){return{w:100,h:100,geo:"rectangle",dash:"draw",growY:0,url:"",scale:1,flipX:!1,flipY:!1,color:"black",labelColor:"black",fill:"none",size:"m",font:"draw",align:"middle",verticalAlign:"middle",richText:(0,h.TP3)("")}}getGeometry(e){let{props:t}=e,{scale:n}=t,r=x$(this,e),i=m5(e,r.strokeWidth,this.options.customGeoTypes).toGeometry(),o=Math.max(1,t.w),s=Math.max(1,t.h+t.growY),a=o/n,l=s/n,d=r5(t.richText),c=d?CC:this.getUnscaledLabelSize(e),u=Math.min(100,a/2),p=Math.min((0,h.OVI)(r.labelFontSize,r.labelLineHeight)+2*r.labelPadding,l/2),f=Math.min(a,Math.max(c.w,Math.min(u,Math.max(1,a-r.labelEdgeMargin)))),g=Math.min(l,Math.max(c.h,Math.min(p,Math.max(1,l-r.labelEdgeMargin)))),m="start"===r.labelHorizontalAlign?0:"end"===r.labelHorizontalAlign?a-f:(a-f)/2,y="start"===r.labelVerticalAlign?0:"end"===r.labelVerticalAlign?l-g:(l-g)/2;return new h.IQE({children:[i,new h.krb({x:m*n,y:y*n,width:f*n,height:g*n,isFilled:!0,isLabel:!0,excludeFromShapeBounds:!0,isEmptyLabel:d})]})}getHandleSnapGeometry(e){let t=this.getGeometry(e),n=t.children[0],r=m2(e.props.geo,this.options.customGeoTypes);if(!r)throw Error(`Unknown geo type: ${e.props.geo}`);return"blobby"===r.snapType?{outline:n,points:[t.bounds.center]}:{outline:n,points:[...n.vertices,t.bounds.center]}}getText(e){return r4(this.editor,e.props.richText)}getFontFaces(e){if(r5(e.props.richText))return h.Mlv;let t=rJ(this.editor.getCurrentTheme(),e.props.font);return t||(0,h.EYW)(this.editor,e.props.richText,{family:`tldraw_${e.props.font}`,weight:"normal",style:"normal"})}component(e){let{id:t,type:n,props:r}=e,{editor:i}=this,o=(0,h.hau)("isGeoOnlySelected",()=>e.id===i.getOnlySelectedShapeId(),[i]),s=Sg(i,e.id),a=Sx(.25/e.props.scale),l=x$(this,e,(0,h.G67)()),{w:d,h:c,richText:u,url:p}=r,f=r5(u);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(h.ULM,{children:(0,b.jsx)(Cx,{shape:e,shouldScale:!0,forceSolid:a,strokeColor:l.strokeColor,strokeWidth:l.strokeWidth,fillColor:l.fillColor,patternFillFallbackColor:l.patternFillFallbackColor,customGeoTypes:this.options.customGeoTypes})}),(s||!f)&&(0,b.jsx)(h.hDc,{style:{overflow:"hidden",width:d,height:c+r.growY},children:(0,b.jsx)(Sy,{shapeId:t,type:n,fontFamily:l.labelFontFamily,fontSize:l.labelFontSize,lineHeight:l.labelLineHeight,padding:l.labelPadding,textAlign:l.labelHorizontalAlign,verticalAlign:l.labelVerticalAlign,richText:u,isSelected:o,labelColor:l.labelColor,wrap:!0,showTextOutline:this.options.showTextOutline,style:1!==e.props.scale?{transform:`scale(${e.props.scale})`,transformOrigin:"top left",width:e.props.w/e.props.scale,height:(e.props.h+r.growY)/e.props.scale}:void 0})}),p&&(0,b.jsx)(SK,{url:p})]})}getIndicatorPath(e){let t=this.editor.getEfficientZoomLevel()<.25/e.props.scale,{dash:n,scale:r}=e.props,i=x$(this,e);return m5(e,i.strokeWidth,this.options.customGeoTypes).toPath2D({style:"draw"===n?"draw":"solid",strokeWidth:1,passes:1,randomSeed:e.id,offset:0,roundness:i.strokeRoundness*r,forceSolid:t})}toSvg(e,t){let n,r=x$(this,e,t.colorMode),{richText:i,fill:o,scale:s,growY:a,w:l,h:d}=e.props,c={...e,props:{...e.props,w:l/s,h:(d+a)/s,growY:0}};if(t.addExportDef(St(o)),!r5(i)){let e=new h.azJ(0,0,c.props.w,(d+a)/s);n=(0,b.jsx)(Sb,{fontSize:r.labelFontSize,fontFamily:r.labelFontFamily,lineHeight:r.labelLineHeight,textAlign:r.labelHorizontalAlign,verticalAlign:r.labelVerticalAlign,labelColor:r.labelColor,padding:r.labelPadding,showTextOutline:this.options.showTextOutline,bounds:e,richText:i})}return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(Cx,{shouldScale:!1,shape:c,forceSolid:!1,strokeColor:r.strokeColor,strokeWidth:r.strokeWidth,fillColor:r.fillColor,patternFillFallbackColor:r.patternFillFallbackColor,customGeoTypes:this.options.customGeoTypes}),n]})}getCanvasSvgDefs(){return[Sr()]}onResize(e,{handle:t,newPoint:n,scaleX:r,scaleY:i,initialShape:o}){let s=this.getUnscaledGeoProps(o.props),a=s.w*r,l=(s.h+s.growY)*i,d=0,c=0,u=x$(this,e);if(!r5(e.props.richText)){var p;let t,n=Math.abs(a),r=Math.abs(l),i=(p=this.editor,CT.get(p))?.get(e.id);if(i)t=i;else{let i=Math.max(n,u.minSizeWithLabel),o=Math.max(r,u.minSizeWithLabel);t=this.measureUnscaledLabelSize({...e,props:{...e.props,w:i*e.props.scale,h:o*e.props.scale}})}let o=Math.max(n,t.w),s=Math.max(r,t.h);d=o-n,c=s-r,a=o*Math.sign(a||1),l=s*Math.sign(l||1)}let f=a*e.props.scale,g=l*e.props.scale,m=new h.l2P(0,0);r<0&&(m.x+=f),("left"===t||"top_left"===t||"bottom_left"===t)&&(m.x+=r<0?d:-d),i<0&&(m.y+=g),("top"===t||"top_left"===t||"top_right"===t)&&(m.y+=i<0?c:-c);let{x:y,y:b}=m.rot(e.rotation).add(n);return{x:y,y:b,props:{w:Math.max(Math.abs(f),1),h:Math.max(Math.abs(g),1),growY:0,...m0(o.props,{scaleX:r,scaleY:i})}}}onBeforeCreate(e){let{props:t}=e;if(r5(t.richText))return 0!==t.growY?{...e,props:{...t,growY:0}}:void 0;let n=t.h/t.scale,r=this.getUnscaledLabelSize(e).h,i=this.calculateGrowY(n,r,t.growY/t.scale);if(null!==i)return{...e,props:{...t,growY:i*t.scale}}}onBeforeUpdate(e,t){let{props:n}=e,{props:r}=t;if((0,h.n4T)(n.richText,r.richText)&&n.font===r.font&&n.size===r.size)return;let i=r5(n.richText),o=r5(r.richText);if(i&&o)return;if(o)return 0!==r.growY?{...t,props:{...r,growY:0}}:void 0;let s=this.getUnscaledGeoProps(n),a=this.getUnscaledLabelSize(t),{scale:l}=r;if(i&&!o){let e=this.expandShapeForFirstLabel(t,s.w,s.h,a);return{...t,props:{...r,w:e.w*l,h:e.h*l,growY:0}}}let d=t.props.w/l,c=a.w>d,u=this.calculateGrowY(s.h,a.h,s.growY);if(null!==u||c)return{...t,props:{...r,growY:(u??s.growY)*l,w:Math.max(d,a.w)*l}}}onDoubleClick(e){if(this.editor.inputs.getAltKey())switch(e.props.geo){case"rectangle":return{...e,props:{geo:"check-box"}};case"check-box":return{...e,props:{geo:"rectangle"}}}let t=m2(e.props.geo,this.options.customGeoTypes);if(t?.onDoubleClick){let n=t.onDoubleClick(e);if(n)return{...e,props:{...e.props,...n.props}}}}getInterpolatedProps(e,t,n){return{...n>.5?t.props:e.props,w:(0,h.CcK)(e.props.w,t.props.w,n),h:(0,h.CcK)(e.props.h,t.props.h,n),scale:(0,h.CcK)(e.props.scale,t.props.scale,n)}}getUnscaledGeoProps(e){let{w:t,h:n,growY:r,scale:i}=e;return{w:t/i,h:n/i,growY:r/i}}calculateGrowY(e,t,n){return t>e?t-e:n>0?0:null}expandShapeForFirstLabel(e,t,n,r){let i=Math.max(t,r.w),o=Math.max(n,r.h),s=x$(this,e);if(t<s.minSizeWithLabel&&n<s.minSizeWithLabel){let e=Math.max(i=Math.max(i,s.minSizeWithLabel),o=Math.max(o,s.minSizeWithLabel));i=e,o=e}return{w:i,h:o}}_labelSizesForGeoCache=new h.laH;getUnscaledLabelSize(e){var t;let n=(t=this.editor,CT.get(t))?.get(e.id);return n||this._labelSizesForGeoCache.get(e,()=>this.measureUnscaledLabelSize(e))}measureUnscaledLabelSize(e){let t=x$(this,e),n=r2(this.editor,e.props.richText),r=this.editor.textMeasure.measureHtml(n,{...er,fontFamily:t.labelFontFamily,fontSize:t.labelFontSize,lineHeight:t.labelLineHeight,minWidth:t.labelMinWidth,maxWidth:Math.max(0,Math.ceil(t.labelMinWidth+t.labelExtraPadding),Math.ceil(e.props.w/e.props.scale-2*t.labelPadding))});return{w:r.w+2*t.labelPadding,h:r.h+2*t.labelPadding}}}let CT=new WeakMap;function CE(e,t){t?CT.set(e,t):CT.delete(e)}class CI extends h.inY{static type="highlight";static props=h.M60;static migrations=h.REO;options={maxPointsPerShape:600,getDefaultDisplayValues(e,t,n,r){let{color:i,size:o}=t.props,s=n.colors[r];return{strokeColor:!h.bGJ.forceSrgb.get()&&h.$Gt.get().supportsP3ColorSpace?(0,h.FHQ)(s,i,"highlightP3"):(0,h.FHQ)(s,i,"highlightSrgb"),strokeWidth:n.fontSize*eo[o]*1.12,underlayOpacity:.82,overlayOpacity:.35}},getCustomDisplayValues:()=>({})};hideResizeHandles(e){return C_(e)}hideRotateHandle(e){return C_(e)}hideSelectionBoundsFg(e){return C_(e)}getDefaultProps(){return{segments:[],color:"black",size:"m",isComplete:!1,isPen:!1,scale:1,scaleX:1,scaleY:1}}getGeometry(e){let t=x$(this,e).strokeWidth*e.props.scale;if(C_(e))return new h.PUi({x:-t/2,y:-t/2,radius:t/2,isFilled:!0});let n=y(e.props.segments,e.props.scaleX,e.props.scaleY),r=g({strokeWidth:t,showAsComplete:e.props.isComplete||(0,h.HVh)(e.props.segments)?.type==="straight"});return new h.dxv({points:vm(n,r),isFilled:!0})}component(e){let t=x$(this,e),n=t.strokeWidth*e.props.scale,r=CA(this.editor,n);return(0,b.jsx)(h.ULM,{children:(0,b.jsx)(CM,{shape:e,forceSolid:r,strokeWidth:n,opacity:t.overlayOpacity,strokeColor:t.strokeColor})})}backgroundComponent(e){let t=x$(this,e,(0,h.G67)()),n=t.strokeWidth*e.props.scale,r=CA(this.editor,n);return(0,b.jsx)(h.ULM,{children:(0,b.jsx)(CM,{shape:e,forceSolid:r,strokeWidth:n,opacity:t.underlayOpacity,strokeColor:t.strokeColor})})}getIndicatorPath(e){var t,n,r,i;let o,s,a,l,d=x$(this,e).strokeWidth*e.props.scale,c=this.editor.getEfficientZoomLevel(),{strokePoints:u,sw:p}=(t=e,n=d,r=d/c<1.5,o=y(t.props.segments,t.props.scaleX,t.props.scaleY),s=t.props.isComplete||(0,h.HVh)(t.props.segments)?.type==="straight",a=n,r||t.props.isPen||1!==o.length||(a+=(0,h.She)(t.id)()*(n/6)),{strokePoints:SJ(o,g({strokeWidth:a,showAsComplete:s})),sw:a}),f=y(e.props.segments,e.props.scaleX,e.props.scaleY);return new Path2D(u.length<2?(i=f[0],l=p/2,`M ${i.x} ${i.y} m -${l}, 0 a ${l},${l} 0 1,0 ${2*l},0 a ${l},${l} 0 1,0 -${2*l},0`):S8(u,!1))}toSvg(e,t){let n=x$(this,e,t.colorMode),r=n.strokeWidth*e.props.scale,i=1/e.props.scale;return(0,b.jsx)("g",{transform:`scale(${i})`,children:(0,b.jsx)(CM,{forceSolid:r<1.5,strokeWidth:r,shape:e,opacity:n.overlayOpacity,strokeColor:n.strokeColor})})}toBackgroundSvg(e,t){let n=x$(this,e,t.colorMode),r=n.strokeWidth*e.props.scale,i=1/e.props.scale;return(0,b.jsx)("g",{transform:`scale(${i})`,children:(0,b.jsx)(CM,{forceSolid:r<1.5,strokeWidth:r,shape:e,opacity:n.underlayOpacity,strokeColor:n.strokeColor})})}onResize(e,t){let n=t.scaleX*e.props.scaleX,r=t.scaleY*e.props.scaleY;if(0!==n&&0!==r)return{props:{scaleX:n,scaleY:r}}}getInterpolatedProps(e,t,n){return{...n>.5?t.props:e.props,...t.props,segments:Ct(e.props.segments,t.props.segments,n),scale:(0,h.CcK)(e.props.scale,t.props.scale,n)}}}function C_(e){let t=e.props.segments[0];return 1===e.props.segments.length&&h.K6A.isSinglePoint(t.path,t.dim)}function CM({strokeWidth:e,forceSolid:t,shape:n,opacity:r,strokeColor:i}){var o;let s=y(n.props.segments,n.props.scaleX,n.props.scaleY),a=e;t||n.props.isPen||1!==s.length||(a+=(0,h.She)(n.id)()*(a/6));let l=SJ(s,g({strokeWidth:a,showAsComplete:n.props.isComplete||(0,h.HVh)(n.props.segments)?.type==="straight"})),d=l.length>1?S8(l,!1):(o=s[0],`M ${o.x} ${o.y} m -0.1, 0 a 0.1,0.1 0 1,0 0.2,0 a 0.1,0.1 0 1,0 -0.2,0`);return(0,b.jsx)("path",{d:d,strokeLinecap:"round",fill:"none",pointerEvents:"all",stroke:i,strokeWidth:a,opacity:r})}function CA(e,t){return(0,h.hau)("forceSolid",()=>t/e.getEfficientZoomLevel()<1.5,[e,t])}function Cj(){return(0,b.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:[(0,b.jsx)("path",{d:"M3,11 L3,3 11,3",strokeWidth:"2"}),(0,b.jsx)("path",{d:"M19,27 L27,27 L27,19",strokeWidth:"2"}),(0,b.jsx)("path",{d:"M27,3 L3,27",strokeWidth:"2"})]})}function CO({shapeId:e,assetId:t,width:n}){let r=(0,h.hGv)(),i=(0,h.Jf5)(),o=(0,h.lsV)(),[s,a]=(0,C.useState)(()=>({asset:t?r.getAsset(t)??null:null,url:null})),l=(0,C.useRef)(!1),d=(0,C.useRef)(null),c=(0,C.useRef)(!1),u=(0,C.useRef)(null);return(0,C.useEffect)(()=>{let s,p=d.current!==t;if(d.current=t,p&&(c.current=!0),!t)return;let f=!1,g=(0,h.wvh)("update state",()=>{if(!i&&e&&r.getCulledShapes().has(e))return;let d=r.getAsset(t);if(!d)return void a(e=>({...e,asset:null,url:null}));if(!d.props.src){let e=r.getTemporaryAssetPreview(d.id);if(e){u.current!==e&&(u.current=e,a(t=>({...t,isPlaceholder:!0,url:e})),o());return}}let h=i?i.scale*(n/d.props.w):r.getEfficientZoomLevel()*(n/d.props.w);function p(e,t){f||u.current!==t&&(l.current=!0,u.current=t,a({asset:e,url:t}),o())}if(l.current&&!c.current){let e=0,n=()=>{++e>31.25&&(CD(r,t,h,i,e=>p(d,e)),s?.())};s?.(),r.on("tick",n),s=()=>r.off("tick",n)}else s?.(),CD(r,t,h,i,e=>p(d,e)),c.current=!1});return()=>{g(),s?.(),f=!0}},[r,t,i,o,e,n]),s}function CD(e,t,n,r,i){e.resolveAssetUrl(t,{screenScale:n,shouldResolveToOriginal:!!r&&null===r.pixelRatio,dpr:r?.pixelRatio??void 0}).then(e=>{i(e)})}let CL=["image/png","image/webp","image/gif","image/avif"];function CF(e,t,n){let r=e.alphaDataGetter();if(!r)return!1;let{nx:i,ny:o}=function(e,t,n){let r=Math.max(0,Math.min(1,(t.x-n.minX)/n.w)),i=Math.max(0,Math.min(1,(t.y-n.minY)/n.h));if(e.crop){let{topLeft:t,bottomRight:n}=e.crop;r=t.x+r*(n.x-t.x),i=t.y+i*(n.y-t.y)}return e.flipX&&(r=1-r),e.flipY&&(i=1-i),{nx:r,ny:i}}(e,t,n);return function(e,t,n,r=10){let i=Math.min(Math.floor(t*e.width),e.width-1),o=Math.min(Math.floor(n*e.height),e.height-1);return e.alphas[o*e.width+i]<r}(r,i,o)}let CR=new h.Qnm(100),Cz=new Set,CN=null;function C$(e){return CR.get(e)??null}function CB(e){return{alphaDataGetter:e.alphaDataGetter,crop:e.crop,flipX:e.flipX,flipY:e.flipY}}class CH extends h.krb{alphaConfig;constructor(e){super(e),this.alphaConfig=CB(e)}hitTestPoint(e,t=0,n=!1){return!!super.hitTestPoint(e,t,n)&&!CF(this.alphaConfig,e,this.bounds)}ignoreHit(e){return CF(this.alphaConfig,e,this.bounds)}}class CU extends h.pPP{alphaConfig;constructor(e){super(e),this.alphaConfig=CB(e)}hitTestPoint(e,t=0,n=!1){return!!super.hitTestPoint(e,t,n)&&!CF(this.alphaConfig,e,this.bounds)}ignoreHit(e){return CF(this.alphaConfig,e,this.bounds)}}async function CW(e){let t=await (0,h.hdJ)(e),n=await t.blob();return h.SmQ.blobToDataUrl(n)}let CK=new h.laH;class CV extends h.A8{static type="image";static props=h.lXb;static migrations=h.UcL;static handledAssetTypes=["image"];options={getDefaultDisplayValues:()=>({}),getCustomDisplayValues:()=>({})};isAspectRatioLocked(e){return!0}canCrop(e){return!0}isExportBoundsContainer(){return!0}getDefaultProps(){return{w:100,h:100,assetId:null,playing:!0,url:"",crop:null,flipX:!1,flipY:!1,altText:""}}createShapeForAsset(e,t){return{id:(0,h.n6Y)(),type:"image",x:t.x,y:t.y,opacity:1,props:{assetId:e.id,w:e.props.w,h:e.props.h}}}getGeometry(e){let t=e.props.assetId?this.editor.getAsset(e.props.assetId):null,n=t&&"mimeType"in t.props?t.props.mimeType:null,r=null!=n&&CL.includes(n),i=t&&"src"in t.props?t.props.src:null;return e.props.crop?.isCircle?r&&i?new CU({width:e.props.w,height:e.props.h,isFilled:!0,alphaDataGetter:()=>C$(i),crop:e.props.crop,flipX:e.props.flipX,flipY:e.props.flipY}):new h.pPP({width:e.props.w,height:e.props.h,isFilled:!0}):r&&i?new CH({width:e.props.w,height:e.props.h,isFilled:!0,alphaDataGetter:()=>C$(i),crop:e.props.crop,flipX:e.props.flipX,flipY:e.props.flipY}):new h.krb({width:e.props.w,height:e.props.h,isFilled:!0})}getAriaDescriptor(e){return e.props.altText}onResize(e,t){let n=(0,h.mfH)(e,t),{scaleX:r,scaleY:i}=t;if(n={...n,props:{...n.props,...m0(t.initialShape.props,t)}},!e.props.crop)return n;let o=r<0,s=i<0,{topLeft:a,bottomRight:l}=e.props.crop;return n.props.crop={topLeft:{x:o?1-l.x:a.x,y:s?1-l.y:a.y},bottomRight:{x:o?1-a.x:l.x,y:s?1-a.y:l.y},isCircle:e.props.crop.isCircle},n}component(e){return(0,b.jsx)(CY,{shape:e})}getIndicatorPath(e){if(this.editor.getCroppingShapeId()===e.id)return;let t=new Path2D;if(e.props.crop?.isCircle){let n=e.props.w/2,r=e.props.h/2;t.ellipse(n,r,n,r,0,0,2*Math.PI)}else t.rect(0,0,e.props.w,e.props.h);return t}async toSvg(e,t){let n=e.props;if(!n.assetId)return null;let r=this.editor.getAsset(n.assetId);if(!r)return null;let{w:i}=Q(e.props,n.crop),o=await CK.get(r,async()=>{let e=await t.resolveAssetUrl(r.id,i);if(!e)return null;if((e.startsWith("blob:")||e.startsWith("http")||e.startsWith("/")||e.startsWith("./"))&&(e=await CW(e)||""),CG(this.editor,r.id)){let{promise:t}=CZ(e);e=await t}return e});return o?(0,b.jsx)(CJ,{shape:e,src:o}):null}onDoubleClickEdge(e){let t=e.props;if(!t||this.editor.getCroppingShapeId()!==e.id)return;let n=(0,h.pN9)(t.crop)||{topLeft:{x:0,y:0},bottomRight:{x:1,y:1}},{w:r,h:i}=Q(e.props,n),o=new h.l2P(n.topLeft.x*r,n.topLeft.y*i).rot(e.rotation),s={id:e.id,type:e.type,x:e.x-o.x,y:e.y-o.y,props:{crop:{topLeft:{x:0,y:0},bottomRight:{x:1,y:1}},w:r,h:i}};this.editor.updateShapes([s])}getInterpolatedProps(e,t,n){return{...n>.5?t.props:e.props,w:(0,h.CcK)(e.props.w,t.props.w,n),h:(0,h.CcK)(e.props.h,t.props.h,n),crop:function(e,t){if(null===e.props.crop&&null===t.props.crop)return null;let r=e.props.crop?.topLeft||{x:0,y:0},i=e.props.crop?.bottomRight||{x:1,y:1},o=t.props.crop?.topLeft||{x:0,y:0},s=t.props.crop?.bottomRight||{x:1,y:1};return{topLeft:{x:(0,h.CcK)(r.x,o.x,n),y:(0,h.CcK)(r.y,o.y,n)},bottomRight:{x:(0,h.CcK)(i.x,s.x,n),y:(0,h.CcK)(i.y,s.y,n)}}}(e,t)}}}let CY=(0,C.memo)(function({shape:e}){let t=(0,h.hGv)(),{w:n}=Q(e.props,e.props.crop),{asset:r,url:i}=CO({shapeId:e.id,assetId:e.props.assetId,width:n}),o=P(),[s,a]=(0,C.useState)(""),[l,d]=(0,C.useState)(null),c=r&&CG(t,r.id);(0,C.useEffect)(()=>{if(i&&c){let{promise:e,cancel:t}=CZ(i);return e.then(e=>{a(e),d(i)}),()=>{t()}}},[t,c,o,i]);let u=r&&"mimeType"in r.props?r.props.mimeType:null,p=null!=u&&CL.includes(u),f=r&&"src"in r.props?r.props.src:null;(0,C.useEffect)(()=>{i&&p&&function(e,t){if("u"<typeof OffscreenCanvas)return;let n=t??e;if(CR.has(n)||Cz.has(n))return;Cz.add(n);let r=(0,h._V3)();r.crossOrigin="anonymous",r.onload=async()=>{Cz.delete(n);let{width:e,height:t}=r;if(0===e||0===t)return;let i=Math.min(1,256/Math.max(e,t)),o=Math.max(1,Math.round(e*i)),s=Math.max(1,Math.round(t*i)),a=null;try{a=await createImageBitmap(r,{resizeWidth:o,resizeHeight:s,resizeQuality:"low"})}catch{}let l=(CN?(CN.width=o,CN.height=s):CN=new OffscreenCanvas(o,s),CN).getContext("2d");l&&(a?(l.drawImage(a,0,0),a.close()):l.drawImage(r,0,0,o,s),CR.set(n,{width:o,height:s,alphas:function(e,t,n){let r=new Uint32Array(e.getImageData(0,0,t,n).data.buffer),i=new Uint8Array(t*n);for(let e=0;e<i.length;e++)i[e]=r[e]>>>24;return i}(l,o,s)}))},r.onerror=()=>{Cz.delete(n)},r.src=e}(i,f??void 0)},[i,p,f]);let g=(0,h.hau)("show crop preview",()=>e.id===t.getOnlySelectedShapeId()&&t.getCroppingShapeId()===e.id&&t.isIn("select.crop"),[t,e.id]),m=o&&(r?.props.mimeType?.includes("video")||c),y=Cq(e),x=i===l?null:i,w=m?s:l;if(!i&&!r?.props.src)return(0,b.jsxs)(h.hDc,{id:e.id,style:{overflow:"hidden",width:e.props.w,height:e.props.h,color:"var(--tl-color-text-3)",backgroundColor:"var(--tl-color-low)",border:"1px solid var(--tl-color-low-border)"},children:[(0,b.jsx)("div",{className:ik("tl-image-container",r&&"tl-image-container-loading"),style:y,children:r?null:(0,b.jsx)(Cj,{})}),"url"in e.props&&e.props.url&&(0,b.jsx)(SK,{url:e.props.url})]});let v=c?"anonymous":void 0;return(0,b.jsxs)(b.Fragment,{children:[g&&w&&(0,b.jsx)("div",{style:y,children:(0,b.jsx)("img",{className:"tl-image",style:{...CX(e),opacity:.1},crossOrigin:v,src:w,referrerPolicy:"strict-origin-when-cross-origin",draggable:!1,alt:""})}),(0,b.jsxs)(h.hDc,{id:e.id,style:{overflow:"hidden",width:e.props.w,height:e.props.h,borderRadius:e.props.crop?.isCircle?"50%":void 0},children:[(0,b.jsxs)("div",{className:ik("tl-image-container"),style:y,children:[w&&(0,b.jsx)("img",{className:"tl-image",style:CX(e),crossOrigin:v,src:w,referrerPolicy:"strict-origin-when-cross-origin",draggable:!1,alt:e.props.altText},w),x&&(0,b.jsx)("img",{className:"tl-image",style:CX(e),crossOrigin:v,src:x,referrerPolicy:"strict-origin-when-cross-origin",draggable:!1,alt:e.props.altText,onLoad:()=>d(x)},x)]}),e.props.url&&(0,b.jsx)(SK,{url:e.props.url})]})]})});function CG(e,t){let n=t?e.getAsset(t):void 0;return!!n&&("mimeType"in n.props&&h.K4L.isAnimatedImageType(n?.props.mimeType)||"isAnimated"in n.props&&n.props.isAnimated)}function Cq(e){let t=e.props.crop,n=t?.topLeft;if(!n)return{width:e.props.w,height:e.props.h};let{w:r,h:i}=Q(e.props,t),o=-n.x*r,s=-n.y*i;return{transform:`translate(${o}px, ${s}px)`,width:r,height:i}}function CX(e,t){let n,r,{flipX:i,flipY:o,crop:s}=e.props;if(!i&&!o)return;if(s){let{w:t,h:i}=Q(e.props,s),o=s.bottomRight.x-s.topLeft.x,a=s.bottomRight.y-s.topLeft.y;n=(0,h.wwY)(s.topLeft.x,[0,1-o],[0,t-e.props.w]),r=(0,h.wwY)(s.topLeft.y,[0,1-a],[0,i-e.props.h])}let a=`scale(${i?-1:1}, ${o?-1:1})`,l=t?`translate(${(i?t.width:0)-(n||0)}px,
|
|
126
|
+
${(o?t.height:0)-(r||0)}px)`:"";return{transform:`${l} ${a}`,transformOrigin:t?"0 0":"center center"}}function CJ({shape:e,src:t}){let n=(0,h.LsA)(),r=Cq(e),i=e.props.crop;if(!r.transform||!i)return(0,b.jsx)("image",{href:t,width:e.props.w,height:e.props.h,"aria-label":e.props.altText,style:CX(e,{width:e.props.w,height:e.props.h})});{let{transform:o,width:s,height:a}=r,l=(i.bottomRight.x-i.topLeft.x)*s,d=(i.bottomRight.y-i.topLeft.y)*a,c=[new h.l2P(0,0),new h.l2P(l,0),new h.l2P(l,d),new h.l2P(0,d)],u=CX(e,{width:s,height:a});return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("defs",{children:(0,b.jsx)("clipPath",{id:n,children:i.isCircle?(0,b.jsx)("ellipse",{cx:l/2,cy:d/2,rx:l/2,ry:d/2}):(0,b.jsx)("polygon",{points:c.map(e=>`${e.x},${e.y}`).join(" ")})})}),(0,b.jsx)("g",{clipPath:`url(#${n})`,children:(0,b.jsx)("image",{href:t,width:s,height:a,"aria-label":e.props.altText,style:u?{...u}:{transform:o}})})]})}}function CZ(e){let t=!1;return{promise:new Promise(n=>{let r=(0,h._V3)();r.onload=()=>{if(t)return;let e=(0,h.jLo)().createElement("canvas");e.width=r.width,e.height=r.height;let i=e.getContext("2d");i&&(i.drawImage(r,0,0),n(e.toDataURL()))},r.crossOrigin="anonymous",r.src=e}),cancel:()=>t=!0}}let CQ=new h.laH;class C0 extends h.inY{static type="line";static props=h.e9l;static migrations=h.bT0;options={getDefaultDisplayValues(e,t,n,r){let{color:i,size:o}=t.props;return{strokeColor:(0,h.FHQ)(n.colors[r],i,"solid"),strokeWidth:n.strokeWidth*ei[o]}},getCustomDisplayValues:()=>({})};hideResizeHandles(e){return!0}hideRotateHandle(e){return!0}hideSelectionBoundsFg(e){return!0}hideSelectionBoundsBg(e){return!0}hideInMinimap(){return!0}getDefaultProps(){let[e,t]=(0,h.uud)(2);return{dash:"draw",size:"m",color:"black",spline:"line",points:{[e]:{id:e,index:e,x:0,y:0},[t]:{id:t,index:t,x:.1,y:.1}},scale:1}}getGeometry(e){let t=C3(e).toGeometry();return(0,h.vAR)(t instanceof v),t}getHandles(e){return CQ.get(e.props,()=>{let t=this.getGeometry(e),n=C1(e),r=n.map(e=>({...e,id:e.id,type:"vertex",canSnap:!0}));for(let e=0;e<n.length-1;e++){let i=(0,h.HEt)(n[e].index,n[e+1].index),o=t.getSegments()[e].interpolateAlongEdge(.5);r.push({id:i,type:"create",index:i,x:o.x,y:o.y,canSnap:!0})}return r.sort(h.Ky)})}onResize(e,t){let{scaleX:n,scaleY:r}=t;return{props:{points:(0,h._Hz)(e.props.points,(e,{id:t,index:i,x:o,y:s})=>({id:t,index:i,x:o*n,y:s*r}))}}}onBeforeCreate(e){let{props:{points:t}}=e,n=Object.keys(t);if(n.length<2)return;let r=t[n[0]];if(n.every(e=>{let n=t[e];return n.x===r.x&&n.y===r.y})){let r=n[n.length-1];return t[r]={...t[r],x:t[r].x+.1,y:t[r].y+.1},e}}onHandleDrag(e,{handle:t}){let n=(0,h.Y8F)(new h.l2P(t.x,t.y),this.editor);return{...e,props:{...e.props,points:{...e.props.points,[t.id]:{id:t.id,index:t.index,x:n.x,y:n.y}}}}}onHandleDragStart(e,{handle:t}){if("create"===t.type)return{...e,props:{...e.props,points:{...e.props.points,[t.index]:{id:t.index,index:t.index,x:t.x,y:t.y}}}}}component(e){let t=x$(this,e,(0,h.G67)());return(0,b.jsx)(h.ULM,{style:{minWidth:50,minHeight:50},children:(0,b.jsx)(C5,{shape:e,strokeColor:t.strokeColor,strokeWidth:t.strokeWidth})})}getIndicatorPath(e){let t=x$(this,e).strokeWidth*e.props.scale,n=C3(e),{dash:r}=e.props;return n.toPath2D({style:"draw"===r?"draw":"solid",strokeWidth:1,passes:1,randomSeed:e.id,offset:0,roundness:2*t})}toSvg(e,t){let n=x$(this,e,t.colorMode);return(0,b.jsx)(C5,{shouldScale:!0,shape:e,strokeColor:n.strokeColor,strokeWidth:n.strokeWidth})}getHandleSnapGeometry(e){let t=C1(e);return{points:t,getSelfSnapPoints:n=>{let r=this.getHandles(e).filter(e=>"vertex"===e.type).findIndex(e=>e.id===n.id);return t.filter((e,t)=>Math.abs(t-r)>1).map(h.l2P.From)},getSelfSnapOutline:t=>{let n=this.getHandles(e).filter(e=>"vertex"===e.type).findIndex(e=>e.id===t.id),r=this.getGeometry(e).getSegments().filter((e,t)=>t!==n-1&&t!==n);return r.length?new h.IQE({children:r}):null}}}getInterpolatedProps(e,t,n){let r=C1(e),i=C1(t),o=[],s=[],a=h.as9;if(r.length>i.length)for(let e=0;e<r.length;e++)o[e]={...r[e]},void 0===i[e]?s[e]={...i[i.length-1],id:a}:s[e]={...i[e],id:a},a=(0,h.AQy)(a);else if(i.length>r.length)for(let e=0;e<i.length;e++)s[e]={...i[e]},void 0===r[e]?o[e]={...r[r.length-1],id:a}:o[e]={...r[e],id:a},a=(0,h.AQy)(a);else for(let e=0;e<i.length;e++)o[e]=r[e],s[e]=i[e];return{...n>.5?t.props:e.props,points:Object.fromEntries(o.map((e,t)=>{let r=s[t];return[e.id,{...e,x:(0,h.CcK)(e.x,r.x,n),y:(0,h.CcK)(e.y,r.y,n)}]})),scale:(0,h.CcK)(e.props.scale,t.props.scale,n)}}}function C1(e){let t=Object.values(e.props.points).sort(h.Ky);return t.filter((e,n)=>0===n||e.index!==t[n-1].index)}let C2=new h.laH;function C3(e){return C2.get(e,()=>{let t=C1(e).map(h.l2P.From);switch(e.props.spline){case"cubic":return x.cubicSplineThroughPoints(t,{endOffsets:0});case"line":return x.lineThroughPoints(t,{endOffsets:0})}})}function C5({shape:e,shouldScale:t=!1,forceSolid:n=!1,strokeColor:r,strokeWidth:i}){let o=C3(e),{dash:s}=e.props,a=1/e.props.scale,l=i*e.props.scale;return o.toSvg({style:s,strokeWidth:l,forceSolid:n,randomSeed:e.id,props:{transform:`scale(${t?a:1})`,stroke:r,fill:"none"}})}let C6=Object.freeze({start:"start",middle:"center",end:"end","start-legacy":"start","end-legacy":"end","middle-legacy":"center"}),C4=Object.freeze({start:"start",middle:"middle",end:"end"});class C8 extends h.inY{static type="note";static props=h.SWg;static migrations=h.fq3;options={resizeMode:"none",getDefaultDisplayValues(e,t,n,r){let{color:i,labelColor:o,font:s,size:a,align:l,verticalAlign:d}=t.props,c=n.colors[r];return{noteWidth:200,noteHeight:200,noteBackgroundColor:(0,h.FHQ)(c,i,"noteFill"),borderColor:c.noteBorder,borderWidth:2,labelColor:"black"===o?(0,h.FHQ)(c,i,"noteText"):(0,h.FHQ)(c,o,"fill"),labelFontFamily:ed(n,s),labelFontSize:n.fontSize*es[a],labelLineHeight:n.lineHeight,labelFontWeight:er.fontWeight,labelFontVariant:er.fontVariant,labelFontStyle:er.fontStyle,labelPadding:16,labelHorizontalAlign:C6[l],labelVerticalAlign:C4[d]}},getCustomDisplayValues:()=>({})};canEdit(e){return!0}hideResizeHandles(e){let{resizeMode:t}=this.options;switch(t){case"none":return!0;case"scale":return!1;default:throw(0,h.h6G)(t)}}isAspectRatioLocked(e){return"scale"===this.options.resizeMode}hideSelectionBoundsFg(e){return!1}getDefaultProps(){return{color:"black",richText:(0,h.TP3)(""),size:"m",font:"draw",align:"middle",verticalAlign:"middle",labelColor:"black",growY:0,fontSizeAdjustment:1,url:"",scale:1,textLastEditedBy:null}}getGeometry(e){let{labelHeight:t,labelWidth:n}=this.getLabelSize(e),{scale:r}=e.props,i=x$(this,e),o=t*r,s=n*r,a=i.noteWidth*r,l=C9(e,i.noteHeight);return new h.IQE({children:[new h.krb({width:a,height:l,isFilled:!0}),new h.krb({x:"start"===i.labelHorizontalAlign?0:"end"===i.labelHorizontalAlign?a-s:(a-s)/2,y:"start"===i.labelVerticalAlign?0:"end"===i.labelVerticalAlign?l-o:(l-o)/2,width:s,height:o,isFilled:!0,isLabel:!0,excludeFromShapeBounds:!0})]})}getHandles(e){let{scale:t}=e.props;if(this.editor.getInstanceState().isCoarsePointer)return[];let n=this.editor.getEfficientZoomLevel();if(n*t<.25)return[];let r=x$(this,e),i=C9(e,r.noteHeight),o=r.noteWidth*t,s=0/n*t;return n*t<.5?[{id:"bottom",index:"a3",type:"clone",x:o/2,y:i+s}]:[{id:"top",index:"a1",type:"clone",x:o/2,y:-s},{id:"right",index:"a2",type:"clone",x:o+s,y:i/2},{id:"bottom",index:"a3",type:"clone",x:o/2,y:i+s},{id:"left",index:"a4",type:"clone",x:-s,y:i/2}]}onResize(e,t){let{resizeMode:n}=this.options;switch(n){case"none":return;case"scale":return(0,h.d5$)(e,t);default:throw(0,h.h6G)(n)}}getText(e){return r4(this.editor,e.props.richText)}getReferencedUserIds(e){return e.props.textLastEditedBy?[e.props.textLastEditedBy]:[]}getFontFaces(e){let t=r5(e.props.richText)?[]:(0,h.EYW)(this.editor,e.props.richText,{family:`tldraw_${e.props.font}`,weight:"normal",style:"normal"});if(e.props.textLastEditedBy&&!r5(e.props.richText))return[...t,rq.tldraw_sans.normal.normal];let n=rJ(this.editor.getCurrentTheme(),e.props.font);return n?[...n,...t]:t.length?t:h.Mlv}component(e){var t,n,r,i;let o,s,a,l,d,c,u,p,f,{id:g,type:m,props:y}=e,{scale:x,richText:w,fontSizeAdjustment:v,textLastEditedBy:S}=y,k=(t=g,o=(0,h.hGv)(),s=(0,C.useContext)(z),(0,C.useCallback)(e=>{let n=o.getShape(t);if(!n)return;let r="Tab"===e.key,i=(e.metaKey||e.ctrlKey)&&"Enter"===e.key;if(r&&r6(o))return void e.preventDefault();if(r||i){var a;e.preventDefault();let l=o.getShapePageTransform(t),d=l.rotation(),c=!!(s?.dir==="rtl"||(a=r4(o,n.props.richText),r7.test(a))),u=x$(o.getShapeUtil(n),n),p=(r?u.noteWidth+o.options.adjacentShapeMargin:u.noteHeight+o.options.adjacentShapeMargin+(i&&!e.shiftKey?n.props.growY:0))*n.props.scale,f=new h.l2P(r?e.shiftKey!=c?-1:1:0,i?e.shiftKey?-1:1:0).mul(p).add(new h.l2P(u.noteWidth/2,u.noteHeight/2).mul(n.props.scale)).rot(d).add(l.point()),g=vZ(o,{shape:n,center:f,pageRotation:d,noteWidth:u.noteWidth,noteHeight:u.noteHeight});g&&E(o,g,{selectAll:!0})}},[t,o,s?.dir])),P=(0,h.hau)("shape rotation",()=>this.editor.getShapePageTransform(g)?.rotation()??0,[this.editor]),T=x$(this,e,(0,h.G67)()),I=T.noteWidth*x,_=C9(e,T.noteHeight),M=Sx(.25/x),A=e.id===this.editor.getOnlySelectedShapeId(),j=Sg(this.editor,e.id),O=r5(w),D=(0,h.hau)("attribution",()=>{if(!S||O)return null;let e=this.editor.getAttributionDisplayName(S);return e?{short:e.split(" ")[0],full:e}:null},[S,O,this.editor]);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{id:g,className:"tl-note__container",style:{width:I,height:_,backgroundColor:T.noteBackgroundColor,borderBottom:M?`${T.borderWidth*x}px solid ${T.borderColor}`:"none",boxShadow:M?"none":(n=e.id,r=P,i=x,l=Math.abs((a=(0,h.She)(n))())+.5,d=Math.cos(r),c=5*i,u=4*i,p=6*i,f=7*i,`0px ${Math.max(0,c-l)}px ${c}px -${c}px rgba(15, 23, 31, .6),
|
|
127
|
+
0px ${(u+l*f)*Math.max(0,d)}px ${p+l*f}px -${u+l*p}px rgba(15, 23, 31, ${(.3+.1*l).toFixed(2)}),
|
|
128
|
+
0px ${48*i}px ${10*i}px -${10*i}px inset rgba(15, 23, 44, ${((.022+.005*a())*((1+d)/2)).toFixed(2)})`)},children:[D&&(0,b.jsx)(aH,{content:D.full,side:"bottom",children:(0,b.jsx)("div",{className:"tl-note__attribution",style:{"--note-attribution-scale":x,fontSize:11*x,color:T.labelColor,opacity:.6},children:D.short})}),(A||j||!O)&&(0,b.jsx)(Sy,{shapeId:g,type:m,fontFamily:T.labelFontFamily,fontSize:(v??1)*T.labelFontSize,lineHeight:T.labelLineHeight,textAlign:T.labelHorizontalAlign,verticalAlign:T.labelVerticalAlign,richText:w,isSelected:A,labelColor:T.labelColor,wrap:!0,padding:T.labelPadding,hasCustomTabBehavior:!0,showTextOutline:!1,onKeyDown:k,style:1!==x?{transform:`scale(${x})`,transformOrigin:"top left",width:T.noteWidth,height:T.noteHeight+e.props.growY}:void 0})]}),"url"in e.props&&e.props.url&&(0,b.jsx)(SK,{url:e.props.url})]})}getIndicatorPath(e){let{scale:t}=e.props,n=x$(this,e),r=new Path2D;return r.rect(0,0,n.noteWidth*t,C9(e,n.noteHeight)),r}toSvg(e,t){let n=x$(this,e,t.colorMode),r=new h.azJ(0,0,n.noteWidth,n.noteHeight+e.props.growY),i=`note-shadow-${e.id.replace(/:/g,"_")}`;t.addExportDef({key:i,getElement:()=>(0,b.jsxs)("filter",{id:i,x:"-10%",y:"-10%",width:"130%",height:"150%",children:[(0,b.jsx)("feMorphology",{in:"SourceAlpha",operator:"erode",radius:"3",result:"erode1"}),(0,b.jsx)("feGaussianBlur",{in:"erode1",stdDeviation:"3",result:"blur1"}),(0,b.jsx)("feOffset",{in:"blur1",dy:"3",result:"offsetBlur1"}),(0,b.jsx)("feComponentTransfer",{in:"offsetBlur1",result:"shadow1",children:(0,b.jsx)("feFuncA",{type:"linear",slope:"0.5"})}),(0,b.jsx)("feMorphology",{in:"SourceAlpha",operator:"erode",radius:"10",result:"erode2"}),(0,b.jsx)("feGaussianBlur",{in:"erode2",stdDeviation:"6",result:"blur2"}),(0,b.jsx)("feOffset",{in:"blur2",dy:"6",result:"offsetBlur2"}),(0,b.jsx)("feComponentTransfer",{in:"offsetBlur2",result:"shadow2",children:(0,b.jsx)("feFuncA",{type:"linear",slope:"0.5"})}),(0,b.jsxs)("feMerge",{children:[(0,b.jsx)("feMergeNode",{in:"shadow1"}),(0,b.jsx)("feMergeNode",{in:"shadow2"}),(0,b.jsx)("feMergeNode",{in:"SourceGraphic"})]})]})});let{textLastEditedBy:o}=e.props,s=o&&!r5(e.props.richText)?this.editor.getAttributionDisplayName(o)?.split(" ")[0]??null:null;return(0,b.jsxs)(b.Fragment,{children:[t.isDarkMode?null:(0,b.jsx)("rect",{rx:1,width:n.noteWidth,height:r.h,fill:n.noteBackgroundColor,filter:`url(#${i})`}),(0,b.jsx)("rect",{rx:1,width:n.noteWidth,height:r.h,fill:n.noteBackgroundColor}),(0,b.jsx)(Sb,{fontSize:(e.props.fontSizeAdjustment??1)*n.labelFontSize,fontFamily:n.labelFontFamily,lineHeight:n.labelLineHeight,textAlign:n.labelHorizontalAlign,verticalAlign:n.labelVerticalAlign,richText:e.props.richText,labelColor:n.labelColor,bounds:r,padding:n.labelPadding,showTextOutline:!1}),s&&(0,b.jsx)("foreignObject",{x:0,y:0,width:n.noteWidth,height:r.h,className:"tl-export-embed-styles",children:(0,b.jsx)("div",{style:{position:"relative",width:"100%",height:"100%"},children:(0,b.jsx)("div",{className:"tl-note__attribution",style:{fontSize:11,color:n.labelColor,opacity:.6},children:s})})})]})}onBeforeCreate(e){return this.getNoteSizeAdjustments(e)}onBeforeDuplicate(e,t){if(!r5(t.props.richText))return{...t,props:{...t.props,textLastEditedBy:this.editor.getAttributionUserId()}}}onBeforeUpdate(e,t){let n=!(0,h.n4T)(e.props.richText,t.props.richText);if(!n&&e.props.font===t.props.font&&e.props.size===t.props.size)return;let r=t;return n&&(r=r5(t.props.richText)?{...r,props:{...r.props,textLastEditedBy:null}}:{...r,props:{...r.props,textLastEditedBy:this.editor.getAttributionUserId()}}),this.getNoteSizeAdjustments(r)??(n?r:void 0)}getInterpolatedProps(e,t,n){return{...n>.5?t.props:e.props,scale:(0,h.CcK)(e.props.scale,t.props.scale,n)}}getNoteSizeAdjustments(e){let t=x$(this,e),{labelHeight:n,fontSizeAdjustment:r}=this.getLabelSize(e),i=Math.max(0,n-t.noteHeight);if(i!==e.props.growY||r!==e.props.fontSizeAdjustment)return{...e,props:{...e.props,growY:i,fontSizeAdjustment:r}}}_labelSizesForNoteCache=new h.laH;getLabelSize(e){return this._labelSizesForNoteCache.get(e,()=>this.measureNoteLabelSize(e))}measureNoteLabelSize(e){let t=x$(this,e),{richText:n}=e.props;if(r5(n))return{labelHeight:(0,h.OVI)(t.labelFontSize,t.labelLineHeight)+2*t.labelPadding,labelWidth:100,fontSizeAdjustment:1};let r=t.labelFontSize,i=r,o=0,s=t.noteHeight,a=t.noteWidth;do{i=Math.min(r,r-o);let e=r2(this.editor,n),l=this.editor.textMeasure.measureHtml(e,{...er,lineHeight:t.labelLineHeight,fontFamily:t.labelFontFamily,fontSize:i,maxWidth:t.noteWidth-2*t.labelPadding-1,disableOverflowWrapBreaking:!0,measureScrollWidth:!0});if(s=l.h+2*t.labelPadding,a=l.w+2*t.labelPadding,i<=14){let e=r2(this.editor,n),r=this.editor.textMeasure.measureHtml(e,{...er,lineHeight:t.labelLineHeight,fontFamily:t.labelFontFamily,fontSize:i,maxWidth:t.noteWidth-2*t.labelPadding-1});s=r.h+2*t.labelPadding,a=r.w+2*t.labelPadding;break}if(l.scrollWidth.toFixed(0)===l.w.toFixed(0))break}while(o++<50);return{labelHeight:s,labelWidth:a,fontSizeAdjustment:i===r?1:i/r}}}function C9(e,t){return(t+e.props.growY)*e.props.scale}let C7=(0,h.uYT)("text size",(e,t)=>{e.fonts.trackFontsForShape(t);let n=x$(e.getShapeUtil(t),t);return kt(e,t.props,n)},{areRecordsEqual:(e,t)=>e.props===t.props});class ke extends h.inY{static type="text";static props=h.xjg;static migrations=h.E4k;options={extraArrowHorizontalPadding:10,showTextOutline:!0,getDefaultDisplayValues(e,t,n,r){let{color:i,font:o,size:s}=t.props;return{color:(0,h.FHQ)(n.colors[r],i,"solid"),fontFamily:ed(n,o),fontSize:n.fontSize*eo[s],lineHeight:n.lineHeight,fontWeight:er.fontWeight,fontStyle:er.fontStyle,fontVariant:er.fontVariant}},getCustomDisplayValues:()=>({})};getDefaultProps(){return{color:"black",size:"m",w:8,font:"draw",textAlign:"start",autoSize:!0,scale:1,richText:(0,h.TP3)("")}}getMinDimensions(e){return C7.get(this.editor,e.id)}getGeometry(e,t){let{scale:n}=e.props,{width:r,height:i}=this.getMinDimensions(e),o=t?.context??"none";return new h.krb({x:("@tldraw/arrow-without-arrowhead"===o?-this.options.extraArrowHorizontalPadding:0)*n,width:(r+("@tldraw/arrow-without-arrowhead"===o?2*this.options.extraArrowHorizontalPadding:0))*n,height:i*n,isFilled:!0,isLabel:!0})}getFontFaces(e){let t=rJ(this.editor.getCurrentTheme(),e.props.font);return t||(0,h.EYW)(this.editor,e.props.richText,{family:`tldraw_${e.props.font}`,weight:"normal",style:"normal"})}getText(e){return r4(this.editor,e.props.richText)}canEdit(e){return!0}isAspectRatioLocked(e){return!0}component(e){var t;let n,{id:r,props:{richText:i,scale:o,textAlign:s}}=e,{width:a,height:l}=this.getMinDimensions(e),d=e.id===this.editor.getOnlySelectedShapeId(),c=x$(this,e,(0,h.G67)()),u=(t=r,n=(0,h.hGv)(),(0,C.useCallback)(e=>{n.getEditingShapeId()===t&&"Enter"===e.key&&(e.ctrlKey||e.metaKey)&&n.complete()},[n,t]));return(0,b.jsx)(Sy,{shapeId:r,classNamePrefix:"tl-text-shape",type:"text",fontFamily:c.fontFamily,fontSize:c.fontSize,lineHeight:c.lineHeight,textAlign:"middle"===s?"center":s,verticalAlign:"middle",richText:i,labelColor:c.color,isSelected:d,textWidth:a,textHeight:l,showTextOutline:this.options.showTextOutline,style:{transform:`scale(${o})`,transformOrigin:"top left"},wrap:!0,onKeyDown:u})}getIndicatorPath(e){if(e.props.autoSize&&this.editor.getEditingShapeId()===e.id)return;let t=this.editor.getShapeGeometry(e).bounds,n=new Path2D;return n.rect(0,0,t.width,t.height),n}toSvg(e,t){let n=this.editor.getShapeGeometry(e).bounds,r=n.width/(e.props.scale??1),i=n.height/(e.props.scale??1),o=x$(this,e,t.colorMode),s=Math.ceil(.3*o.fontSize),a=new h.azJ(-s,-s,r+2*s,i+2*s);return(0,b.jsx)(Sb,{fontSize:o.fontSize,fontFamily:o.fontFamily,lineHeight:o.lineHeight,textAlign:"middle"===e.props.textAlign?"center":e.props.textAlign,verticalAlign:"middle",richText:e.props.richText,labelColor:o.color,bounds:a,padding:s,showTextOutline:this.options.showTextOutline})}onResize(e,t){let{newPoint:n,initialBounds:r,initialShape:i,scaleX:o,handle:s}=t;if("scale_shape"===t.mode||"right"!==s&&"left"!==s)return{id:e.id,type:e.type,...(0,h.d5$)(e,t)};{let t=Math.max(1,Math.abs(r.width*o)),{x:s,y:a}=o<0?h.l2P.Sub(n,h.l2P.FromAngle(e.rotation).mul(t)):n;return{id:e.id,type:e.type,x:s,y:a,props:{w:t/i.props.scale,autoSize:!1}}}}onEditEnd(e){0===r4(this.editor,e.props.richText).trimEnd().length&&this.editor.deleteShapes([e.id])}onBeforeUpdate(e,t){let n;if(!t.props.autoSize)return;let r=e.props.size!==t.props.size||e.props.textAlign!==t.props.textAlign||e.props.font!==t.props.font||1!==e.props.scale&&1===t.props.scale,i=!(0,h.n4T)(e.props.richText,t.props.richText);if(!r&&!i)return;let o=this.getMinDimensions(e),s=x$(this,t),a=kt(this.editor,t.props,s),l=o.width*e.props.scale,d=o.height*e.props.scale,c=a.width*t.props.scale,u=a.height*t.props.scale;switch(t.props.textAlign){case"middle":n=new h.l2P((c-l)/2,i?0:(u-d)/2);break;case"end":n=new h.l2P(c-l,i?0:(u-d)/2);break;default:if(i)break;n=new h.l2P(0,(u-d)/2)}if(!n)return{...t,props:{...t.props,w:c}};{n.rot(t.rotation);let{x:e,y:r}=t;return{...t,x:e-n.x,y:r-n.y,props:{...t.props,w:c}}}}}function kt(e,t,n){let{richText:r,w:i}=t,o=t.autoSize?null:Math.max(16,Math.floor(i)),s=r2(e,r),a=e.textMeasure.measureHtml(s,{lineHeight:n.lineHeight,fontWeight:n.fontWeight,fontStyle:n.fontStyle,padding:"0px",fontFamily:n.fontFamily,fontSize:n.fontSize,maxWidth:o});return{width:o??Math.max(16,a.w+1),height:Math.max(n.fontSize,a.h)}}let kn=new h.laH;class kr extends h.A8{static type="video";static props=h.ZMy;static migrations=h.w9f;static handledAssetTypes=["video"];options={autoplay:!0,getDefaultDisplayValues:()=>({}),getCustomDisplayValues:()=>({})};canEdit(e){return!0}isAspectRatioLocked(e){return!0}getDefaultProps(){return{w:100,h:100,assetId:null,autoplay:this.options.autoplay,url:"",altText:"",time:0,playing:!0}}createShapeForAsset(e,t){return{id:(0,h.n6Y)(),type:"video",x:t.x,y:t.y,opacity:1,props:{assetId:e.id,w:e.props.w,h:e.props.h}}}getAriaDescriptor(e){return e.props.altText}component(e){return(0,b.jsx)(ki,{shape:e})}getIndicatorPath(e){let t=new Path2D;return t.rect(0,0,e.props.w,e.props.h),t}async toSvg(e,t){let n=e.props;if(!n.assetId)return null;let r=this.editor.getAsset(n.assetId);if(!r)return null;let i=await kn.get(r,async()=>{let e=await t.resolveAssetUrl(r.id,n.w);if(!e)return null;let i=await h.K4L.loadVideo(e,this.editor.getContainerDocument());return await h.K4L.getVideoFrameAsDataUrl(i,0)});return i?(0,b.jsx)("image",{href:i,width:n.w,height:n.h,"aria-label":e.props.altText}):null}}let ki=(0,C.memo)(function({shape:e}){let t=(0,h.hGv)(),n=t.getShapeGeometry(e).bounds.w*t.getEfficientZoomLevel()>=110,r=(0,h._As)(e.id),i=P(),{Spinner:o}=(0,h.BSi)(),{asset:s,url:a}=CO({shapeId:e.id,assetId:e.props.assetId,width:e.props.w}),l=(0,C.useRef)(null),[d,c]=(0,C.useState)(!1),u=(0,C.useCallback)(e=>{e.currentTarget&&c(!0)},[]),[p,f]=(0,C.useState)(!1);return(0,C.useEffect)(()=>{let e=l.current?.ownerDocument??t.getContainerDocument(),n=()=>f(e.fullscreenElement===l.current);return e.addEventListener("fullscreenchange",n),()=>e.removeEventListener("fullscreenchange",n)}),(0,C.useEffect)(()=>{let e=l.current;e&&r&&e.ownerDocument.activeElement!==e&&e.focus()},[r,d]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(h.hDc,{id:e.id,style:{color:"var(--tl-color-text-3)",backgroundColor:s?"transparent":"var(--tl-color-low)",border:s?"none":"1px solid var(--tl-color-low-border)"},children:(0,b.jsx)("div",{className:"tl-counter-scaled",children:(0,b.jsx)("div",{className:"tl-video-container",children:s?o&&!s.props.src?(0,b.jsx)(o,{}):a?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("video",{ref:l,style:r?{pointerEvents:"all"}:d?void 0:{display:"none"},className:ik("tl-video",`tl-video-shape-${e.id.split(":")[1]}`,{"tl-video-is-fullscreen":p}),width:"100%",height:"100%",draggable:!1,playsInline:!0,autoPlay:e.props.autoplay&&!i,muted:!0,loop:!0,disableRemotePlayback:!0,disablePictureInPicture:!0,controls:r&&n,onLoadedData:u,hidden:!d,"aria-label":e.props.altText,children:(0,b.jsx)("source",{src:a})},a),!d&&o&&(0,b.jsx)(o,{})]}):null:(0,b.jsx)(Cj,{})})})}),"url"in e.props&&e.props.url&&(0,b.jsx)(SK,{url:e.props.url})]})}),ko=[ke,Sq,Cn,CP,C8,C0,Cb,S$,CI,Cl,CV,kr];class ks extends h.YM5{static id="erasing";static trackPerformance=!0;info={};scribbleId="id";markId="";excludedShapeIds=new Set;_erasingShapeIds=[];onEnter(e){this.markId=this.editor.markHistoryStoppingPoint("erase scribble begin"),this.info=e;let t=this.editor.inputs.getOriginPagePoint();this.excludedShapeIds=new Set(this.editor.getCurrentPageShapes().filter(e=>{if(this.editor.isShapeOrAncestorLocked(e))return!0;if(this.editor.isShapeOfType(e,"group")||this.editor.isShapeFrameLike(e)){let n=this.editor.getPointInShapeSpace(e,t);return this.editor.getShapeGeometry(e).bounds.containsPoint(n)}return!1}).map(e=>e.id)),this._erasingShapeIds=this.editor.getShapesAtPoint(t).filter(e=>!this.excludedShapeIds.has(e.id)).map(e=>e.id),this.editor.setErasingShapes([...new Set([...this.editor.getErasingShapeIds(),...this._erasingShapeIds])]);let n=this.editor.scribbles.addScribble({color:"muted-1",size:12});this.scribbleId=n.id,this.update()}pushPointToScribble(){let{x:e,y:t}=this.editor.inputs.getCurrentPagePoint();this.editor.scribbles.addPoint(this.scribbleId,e,t)}onExit(){this.editor.setErasingShapes([]),this.editor.scribbles.stop(this.scribbleId)}onPointerMove(){this.update()}onPointerUp(e){this.complete(e)}onCancel(){this.cancel()}onComplete(){this.complete()}update(){let{editor:e,excludedShapeIds:t}=this,n=e.getErasingShapeIds(),r=e.inputs.getCurrentPagePoint(),i=e.inputs.getPreviousPagePoint();this.pushPointToScribble();let o=new Set(n),s=this.editor.getHitTestMargin(),a=h.azJ.FromPoints([i,r]).expandBy(s),l=e.getShapeIdsInsideBounds(a);if(0===l.size)return void e.setErasingShapes(Array.from(o));for(let n of e.getCurrentPageRenderingShapesSorted().filter(e=>l.has(e.id))){if(e.isShapeOfType(n,"group"))continue;let a=e.getShapeMask(n.id);if(a&&!(0,h.s3y)(r,a))continue;let l=e.getShapeGeometry(n),d=e.getShapePageTransform(n);if(!l||!d)continue;let c=d.clone().invert(),u=c.applyToPoint(i),p=c.applyToPoint(r),{bounds:f}=l;if(!(f.minX-s>Math.max(u.x,p.x)||f.minY-s>Math.max(u.y,p.y)||f.maxX+s<Math.min(u.x,p.x)||f.maxY+s<Math.min(u.y,p.y))){if(l.hitTestLineSegment(u,p,s)){let r=e.getOutermostSelectableShape(n);t.has(r.id)?o.add(e.getOutermostSelectableShape(n,e=>!t.has(e.id)).id):o.add(r.id)}this._erasingShapeIds=[...o]}}this.editor.setErasingShapes(this._erasingShapeIds.filter(e=>!t.has(e)))}complete(e){let{editor:t}=this;t.deleteShapes(t.getCurrentPageState().erasingShapeIds),this.parent.transition("idle",e),this._erasingShapeIds=[]}cancel(){let{editor:e}=this;e.bailToMark(this.markId),this.parent.transition("idle",this.info)}}class ka extends h.YM5{static id="idle";onEnter(e){(e?.accelKey??this.editor.inputs.getAccelKey())||this.parent.maybeReturnToOriginatingTool()}onKeyUp(e){(0,h.gu7)(e)||this.parent.maybeReturnToOriginatingTool()}onPointerDown(e){this.parent.transition("pointing",e)}onCancel(){let e=this.parent.info.onInteractionEnd;this.editor.setCurrentTool(e??"select")}}class kl extends h.YM5{static id="pointing";onEnter(e){let t=e.accelKey,n=this.editor.getCurrentPageRenderingShapesSorted(),r=this.editor.inputs.getCurrentPagePoint(),i=new Set,o=i.size;for(let e=n.length,s=e-1;s>=0;s--){let e=n[s];if(!(this.editor.isShapeOrAncestorLocked(e)||this.editor.isShapeOfType(e,"group"))&&this.editor.isPointInShape(e,r,{hitInside:!1,margin:this.editor.getHitTestMargin()})){let n=this.editor.getOutermostSelectableShape(e);if(this.editor.isShapeFrameLike(n)&&i.size>o||(i.add(n.id),t))break}}this.editor.setErasingShapes([...i])}onLongPress(e){e.accelKey||this.startErasing(e)}onExit(e,t){"erasing"!==t&&this.editor.setErasingShapes([])}onPointerMove(e){this.editor.inputs.getIsDragging()&&this.startErasing(e)}onPointerUp(e){this.complete(e)}onCancel(){this.cancel()}onComplete(){this.complete()}onInterrupt(){this.cancel()}startErasing(e){this.parent.transition("erasing",e)}complete(e){let t=this.editor.getErasingShapeIds();t.length&&(this.editor.markHistoryStoppingPoint("erase end"),this.editor.deleteShapes(t)),this.parent.transition("idle",e)}cancel(){this.parent.transition("idle")}}class kd extends h.YM5{static id="eraser";static initial="idle";static isLockable=!1;static children(){return[ka,kl,ks]}info={};onEnter(e={}){this.info=e,e.onInteractionEnd&&this.setCurrentToolIdMask(e.onInteractionEnd),this.editor.setCursor({type:"cross",rotation:0})}onExit(){this.setCurrentToolIdMask(void 0),this.info={}}maybeReturnToOriginatingTool(){let{onInteractionEnd:e}=this.info;e&&this.editor.setCurrentTool(e)}}class kc extends h.YM5{static id="dragging";static trackPerformance=!0;initialCamera=new h.l2P;onEnter(){this.initialCamera=h.l2P.From(this.editor.getCamera()),this.update()}onPointerMove(){this.update()}onPointerDown(){this.parent.transition("idle")}onPointerUp(){this.complete()}onInterrupt(){this.parent.transition("idle")}onCancel(){this.parent.transition("idle")}onComplete(){this.complete()}update(){let{initialCamera:e,editor:t}=this,n=t.inputs.getCurrentScreenPoint(),r=t.inputs.getOriginScreenPoint(),i=h.l2P.Sub(n,r).div(t.getZoomLevel());0!==i.len2()&&t.setCamera(e.clone().add(i))}complete(){let{editor:e}=this,t=e.inputs.getPointerVelocity(),n=Math.min(t.len(),2);n>.1&&this.editor.slideCamera({speed:n,direction:{x:t.x,y:t.y,z:0}}),this.parent.transition("idle")}}class ku extends h.YM5{static id="idle";onEnter(){this.editor.setCursor({type:"grab",rotation:0})}onPointerDown(e){this.parent.transition("pointing",e)}onCancel(){this.editor.setCurrentTool("select")}}class kh extends h.YM5{static id="one_finger_zooming";anchorScreenPoint=new h.l2P;initialCamera=new h.l2P;initialZoom=1;originScreenY=0;onEnter(e){let t=this.editor.getCamera();this.initialCamera=h.l2P.From(t),this.initialZoom=t.z,this.anchorScreenPoint=this.editor.inputs.getOriginScreenPoint().clone(),this.originScreenY=this.editor.inputs.getCurrentScreenPoint().y,this.editor.setCursor({type:"grab",rotation:0})}onPointerMove(e){this.editor.menus.clearOpenMenus();let t=this.editor.inputs.getCurrentScreenPoint().y,n=Math.pow(2,-((this.originScreenY-t)*1)/200),r=this.clampZoom(this.initialZoom*n),{x:i,y:o}=this.initialCamera,{x:s,y:a}=this.anchorScreenPoint;this.editor.setCamera(new h.l2P(i+s/r-s/this.initialZoom,o+a/r-a/this.initialZoom,r),{immediate:!0})}onPointerUp(e){this.complete()}onCancel(){this.parent.transition("idle")}onInterrupt(){this.parent.transition("idle")}complete(){let e=this.editor.inputs.getPointerVelocity(),t=Math.min(e.len(),2);t>.1&&this.editor.slideCamera({speed:t,direction:{x:0,y:0,z:.01*Math.sign(e.y)}}),this.parent.transition("idle")}clampZoom(e){let{zoomSteps:t}=this.editor.getCameraOptions(),n=this.editor.getBaseZoom(),r=t[0]*n,i=(0,h.HVh)(t)*n;return(0,h.qE8)(e,r,i)}}class kp extends h.YM5{static id="pointing";onEnter(){this.editor.stopCameraAnimation(),this.editor.setCursor({type:"grabbing",rotation:0})}onLongPress(){this.startDragging()}onPointerMove(){this.editor.inputs.getIsDragging()&&this.startDragging()}startDragging(){this.parent.transition("dragging")}onPointerUp(){this.complete()}onCancel(){this.complete()}onComplete(){this.complete()}onInterrupt(){this.complete()}complete(){this.parent.transition("idle")}}class kf extends h.YM5{static id="hand";static initial="idle";static isLockable=!1;static children(){return[ku,kp,kc,kh]}onDoubleClick(e){switch(e.phase){case"settle-down":this.editor.getInstanceState().isCoarsePointer&&this.transition("one_finger_zooming",e);break;case"settle-up":{let e=this.editor.inputs.getCurrentScreenPoint();this.editor.zoomIn(e,{animation:{duration:220,easing:h.Z4H.easeOutQuint}})}}}}class kg extends h.YM5{static id="idle";onPointerDown(){let e=this.parent.getSessionId(),t=this.editor.scribbles.addScribbleToSession(e,{color:"laser",opacity:.7,size:4,taper:!1});this.parent.transition("lasering",{sessionId:e,scribbleId:t.id})}}class km extends h.YM5{static id="lasering";static trackPerformance=!0;scribbleId="";sessionId="";onEnter(e){this.sessionId=e.sessionId,this.scribbleId=e.scribbleId,this.pushPointToScribble()}onPointerMove(){this.pushPointToScribble()}pushPointToScribble(){let{x:e,y:t}=this.editor.inputs.getCurrentPagePoint();this.editor.scribbles.addPointToSession(this.sessionId,this.scribbleId,e,t)}onTick(){this.editor.scribbles.extendSession(this.sessionId)}onPointerUp(){this.complete()}onCancel(){this.onComplete()}onComplete(){this.complete()}complete(){this.editor.scribbles.complete(this.scribbleId),this.parent.transition("idle")}}class ky extends h.YM5{static id="laser";static initial="idle";static children(){return[kg,km]}static isLockable=!1;sessionId=null;onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onExit(){this.sessionId=null}onCancel(){this.sessionId&&this.editor.scribbles.isSessionActive(this.sessionId)?(this.editor.scribbles.clearSession(this.sessionId),this.sessionId=null,this.transition("idle")):this.editor.setCurrentTool("select")}getSessionId(){return this.sessionId&&this.editor.scribbles.isSessionActive(this.sessionId)||(this.sessionId=this.editor.scribbles.startSession({selfConsume:!1,idleTimeoutMs:this.editor.options.laserDelayMs,fadeMode:"grouped",fadeEasing:"ease-in"})),this.sessionId}}class kb extends h.YM5{static id="brushing";static trackPerformance=!0;info={};initialSelectedShapeIds=[];excludedShapeIds=new Set;isWrapMode=!1;viewportDidChange=!1;cleanupViewportChangeReactor(){}onEnter(e){let{editor:t}=this,n=t.inputs.getAltKey();this.isWrapMode=t.user.getIsWrapMode(),this.viewportDidChange=!1;let r=!0;if(this.cleanupViewportChangeReactor=(0,h.wvh)("viewport change while brushing",()=>{t.getViewportPageBounds(),r||this.viewportDidChange||(this.viewportDidChange=!0)}),n)return void this.parent.transition("scribble_brushing",e);let i=t.options.selectLockedShapes;this.excludedShapeIds=new Set(t.getCurrentPageShapes().filter(e=>t.isShapeOfType(e,"group")||!i&&t.isShapeOrAncestorLocked(e)).map(e=>e.id)),this.info=e,this.initialSelectedShapeIds=t.getSelectedShapeIds().slice(),this.hitTestShapes(),r=!1}onExit(){this.initialSelectedShapeIds=[],this.editor.updateInstanceState({brush:null}),this.cleanupViewportChangeReactor()}onTick({elapsed:e}){let{editor:t}=this;!t.inputs.getIsDragging()||t.inputs.getIsPanning()||t.edgeScrollManager.updateEdgeScrolling(e)}onPointerMove(){this.hitTestShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(e){this.editor.setSelectedShapes(this.initialSelectedShapeIds),this.parent.transition("idle",e)}onKeyDown(e){this.editor.inputs.getAltKey()?this.parent.transition("scribble_brushing",e):this.hitTestShapes()}onKeyUp(){this.hitTestShapes()}complete(){this.hitTestShapes(),this.parent.transition("idle")}hitTestShapes(){let e,t,n,r,i,o,{editor:s,excludedShapeIds:a,isWrapMode:l}=this,d=s.inputs.getOriginPagePoint(),c=s.inputs.getCurrentPagePoint(),u=s.inputs.getShiftKey(),p=s.inputs.getCtrlKey(),f=new Set(u?this.initialSelectedShapeIds:[]),g=l?!p:p,m=h.azJ.FromPoints([d,c]),{corners:y}=m,b=s.getViewportPageBounds().contains(m),x=s.getCurrentPageId(),w=s.getShapeIdsInsideBounds(m);if(0===w.size){let e=s.getInstanceState().brush;e&&m.equals(e)||s.updateInstanceState({brush:{...m.toJson()}});let t=s.getSelectedShapeIds();(t.length!==f.size||t.some(e=>!f.has(e)))&&s.setSelectedShapes(Array.from(f));return}let v=(b&&!this.viewportDidChange?s.getCurrentPageRenderingShapesSorted():s.getCurrentPageShapesSorted()).filter(e=>w.has(e.id));for(let l=0,d=v.length;l<d;l++){if(n=v[l],!(a.has(n.id)||f.has(n.id))&&(r=s.getShapePageBounds(n))){if(m.contains(r)){this.handleHit(n,c,x,f,y);continue}if(!(g||s.isShapeFrameLike(n))&&m.collides(r)){if(!(i=s.getShapePageTransform(n)))continue;o=i.clone().invert().applyToPoints(y);let r=s.getShapeGeometry(n);for(let i=0;i<4;i++)if(e=o[i],t=o[(i+1)%4],r.hitTestLineSegment(e,t,0)){this.handleHit(n,c,x,f,y);break}}}}let S=s.getInstanceState().brush;S&&m.equals(S)||s.updateInstanceState({brush:{...m.toJson()}});let C=s.getSelectedShapeIds();(C.length!==f.size||C.some(e=>!f.has(e)))&&s.setSelectedShapes(Array.from(f))}onInterrupt(){this.editor.updateInstanceState({brush:null})}handleHit(e,t,n,r,i){if(e.parentId===n)return void r.add(e.id);let o=this.editor.getOutermostSelectableShape(e),s=this.editor.getShapeMask(o.id);(!s||(0,h.Rx2)(s,i)||(0,h.s3y)(t,s))&&r.add(o.id)}}let kx={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"};class kw extends h.YM5{static id="pointing_resize_handle";info={};updateCursor(){let e=kx[this.info.handle];this.editor.setCursor({type:e,rotation:this.editor.getSelectionRotation()})}onEnter(e){this.info=e,"string"==typeof e.onInteractionEnd&&this.parent.setCurrentToolIdMask(e.onInteractionEnd),this.updateCursor()}onExit(){this.parent.setCurrentToolIdMask(void 0)}onPointerMove(){this.editor.inputs.getIsDragging()&&this.startResizing()}onLongPress(){this.startResizing()}startResizing(){this.editor.getIsReadonly()||this.parent.transition("resizing",this.info)}onPointerUp(){this.complete()}onDoubleClick(e){this.editor.inputs.getShiftKey()||"down"!==e.phase||e.ctrlKey||e.shiftKey||(this.parent.transition("idle"),this.parent.getCurrent()?.handleEvent(e))}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}complete(){let{onInteractionEnd:e}=this.info;e?"string"==typeof e?this.editor.setCurrentTool(e,{}):e():this.parent.transition("idle")}cancel(){let{onInteractionEnd:e}=this.info;e?"string"==typeof e?this.editor.setCurrentTool(e,{}):e():this.parent.transition("idle")}}class kv extends h.YM5{static id="cropping";static trackPerformance=!0;info={};markId="";snapshot={};onEnter(e){this.info=e,"string"==typeof e.onInteractionEnd&&this.parent.setCurrentToolIdMask(e.onInteractionEnd),this.markId=this.editor.markHistoryStoppingPoint("cropping"),this.snapshot=this.createSnapshot(),this.updateShapes()}onPointerMove(){this.updateShapes()}onKeyDown(){this.updateShapes()}onKeyUp(){this.updateShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(){this.cancel()}onExit(){this.parent.setCurrentToolIdMask(void 0),this.editor.snaps.clearIndicators()}updateCursor(){if(!this.editor.getSelectedShapes()[0])return;let e=kx[this.info.handle];this.editor.setCursor({type:e,rotation:this.editor.getSelectionRotation()})}updateShapes(){let{editor:e}=this,{shape:t,cursorHandleOffset:n,initialSelectionPageBounds:r,selectionRotation:i}=this.snapshot;if(!t)return;let o=e.getShapeUtil(t.type);if(!o)return;let s=e.inputs.getShiftKey(),a=e.inputs.getAltKey(),l=(0,h.gu7)(e.inputs),d=e.inputs.getCurrentPagePoint().clone().sub(n),c=e.inputs.getOriginPagePoint().clone().sub(n);if(e.getInstanceState().isGridMode&&!l){let{gridSize:t}=e.getDocumentSettings();d.snapToGrid(t)}e.snaps.clearIndicators();let u=e.user.getIsSnapMode()?!l:l,p=!1;if(u&&r&&i%h.sKG==0){let{nudge:t}=e.snaps.shapeBounds.snapResizeShapes({dragDelta:h.l2P.Sub(d,c),initialSelectionPageBounds:r,handle:(0,h.Wj6)(this.info.handle,i),isAspectRatioLocked:s,isResizingFromCenter:a});d.add(t),p=!0}let f=d.clone().sub(c).rot(-t.rotation),g=t.props.crop??X(),m=Q(t.props,g),y=(o.onCrop?.bind(o)??function(e,t,n={}){let{handle:r,change:i,crop:o,aspectRatioLocked:s,isResizingFromCenter:a}=t,{w:l,h:d}=t.uncroppedSize,{minWidth:c=8,minHeight:u=8}=n;if(l<c||d<u||0===i.x&&0===i.y)return;let p=new h.azJ(o.topLeft.x*l,o.topLeft.y*d,(o.bottomRight.x-o.topLeft.x)*l,(o.bottomRight.y-o.topLeft.y)*d),f=p.aspectRatio,g=p.clone(),m="top_left"===r||"bottom_left"===r||"left"===r,y="top_right"===r||"bottom_right"===r||"right"===r,b="top_left"===r||"top_right"===r||"top"===r,x="bottom_left"===r||"bottom_right"===r||"bottom"===r;if(a){let e=p.midX,t=p.midY,n=p.w/2,r=p.h/2;if(m?n=e-(p.x+i.x):y&&(n=p.maxX+i.x-e),b?r=t-(p.y+i.y):x&&(r=p.maxY+i.y-t),s){let i;i=(m||y)&&(b||x)?n/r>f?n:r*f:m||y?n:r*f;let o=Math.max(c/2,u/2*f),s=Math.min(e,l-e,t*f,(d-t)*f);if(s<o)return;r=(n=(0,h.qE8)(i,o,s))/f}else{if(m||y){let t=Math.min(e,l-e);if(t<c/2)return;n=(0,h.qE8)(n,c/2,t)}if(b||x){let e=Math.min(t,d-t);if(e<u/2)return;r=(0,h.qE8)(r,u/2,e)}}g.x=e-n,g.y=t-r,g.w=2*n,g.h=2*r}else{if(m)g.x=(0,h.qE8)(g.x+i.x,0,p.maxX-c),g.w=p.maxX-g.x;else if(y){let e=(0,h.qE8)(g.maxX+i.x,p.x+c,l);g.w=e-g.x}if(b)g.y=(0,h.qE8)(g.y+i.y,0,p.maxY-u),g.h=p.maxY-g.y;else if(x){let e=(0,h.qE8)(g.maxY+i.y,p.y+u,d);g.h=e-g.y}}if(s&&!a)switch(g.aspectRatio>f?g.h=g.w/f:g.w=g.h*f,r){case"top_left":g.x=p.maxX-g.w,g.y=p.maxY-g.h,g.x<=0&&(g.x=0,g.w=p.maxX-g.x,g.h=g.w/f,g.y=p.maxY-g.h),g.y<=0&&(g.y=0,g.h=p.maxY-g.y,g.w=g.h*f,g.x=p.maxX-g.w);break;case"top_right":g.x=p.x,g.y=p.maxY-g.h,g.maxX>=l&&(g.w=l-p.x,g.h=g.w/f,g.y=p.maxY-g.h),g.y<=0&&(g.y=0,g.h=p.maxY-g.y,g.w=g.h*f);break;case"bottom_left":g.x=p.maxX-g.w,g.y=p.y,g.x<=0&&(g.x=0,g.w=p.maxX-g.x,g.h=g.w/f),g.maxY>=d&&(g.h=d-p.y,g.w=g.h*f,g.x=p.maxX-g.w);break;case"bottom_right":g.x=p.x,g.y=p.y,g.maxX>=l&&(g.w=l-p.x,g.h=g.w/f),g.maxY>=d&&(g.h=d-p.y,g.w=g.h*f);break;case"top":g.h=p.maxY-g.y,g.w=g.h*f,g.x-=(g.w-p.w)/2,g.x<=0&&(g.w=2*p.midX,g.h=g.w/f,g.x=0),g.maxX>=l&&(g.w=2*(l-p.midX),g.h=g.w/f,g.x=l-g.w),g.y=p.maxY-g.h;break;case"right":g.w=g.maxX-p.x,g.h=g.w/f,g.y-=(g.h-p.h)/2,g.y<=0&&(g.h=2*p.midY,g.w=g.h*f,g.y=0),g.maxY>=d&&(g.h=2*(d-p.midY),g.w=g.h*f,g.y=d-g.h);break;case"bottom":g.h=g.maxY-p.y,g.w=g.h*f,g.x-=(g.w-p.w)/2,g.x<=0&&(g.w=2*p.midX,g.h=g.w/f,g.x=0),g.maxX>=l&&(g.w=2*(l-p.midX),g.h=g.w/f,g.x=l-g.w);break;case"left":g.w=p.maxX-g.x,g.h=g.w/f,g.y-=(g.h-p.h)/2,g.y<=0&&(g.h=2*p.midY,g.w=g.h*f,g.y=0),g.maxY>=d&&(g.h=2*(d-p.midY),g.w=g.h*f,g.y=d-g.h),g.x=p.maxX-g.w}let w={topLeft:{x:g.x/l,y:g.y/d},bottomRight:{x:g.maxX/l,y:g.maxY/d}};if(null!=o.isCircle&&(w.isCircle=o.isCircle),w.topLeft.x===o.topLeft.x&&w.topLeft.y===o.topLeft.y&&w.bottomRight.x===o.bottomRight.x&&w.bottomRight.y===o.bottomRight.y)return;let v=new h.l2P(g.x-o.topLeft.x*l,g.y-o.topLeft.y*d).rot(e.rotation).add(e);return{id:e.id,type:e.type,x:v.x,y:v.y,props:{...e.props,w:g.w,h:g.h,crop:w}}})(t,{handle:this.info.handle,change:f,crop:g,uncroppedSize:m,initialShape:this.snapshot.shape,aspectRatioLocked:s,isResizingFromCenter:a});y&&e.updateShapes([{id:t.id,type:t.type,...y}]),p&&r&&this.reconcileSnapIndicators(r,h.l2P.Sub(d,c),(0,h.Wj6)(this.info.handle,i),s,a),y&&this.updateCursor()}reconcileSnapIndicators(e,t,n,r,i){let{editor:o}=this;if(!o.snaps.getIndicators().length)return;let s=o.getShapePageBounds(this.snapshot.shape.id);if(!s)return;let{box:a}=h.azJ.Resize(e,n,i?2*t.x:t.x,i?2*t.y:t.y,r);i&&(a.center=e.center),(Math.abs(s.minX-a.minX)>1||Math.abs(s.maxX-a.maxX)>1||Math.abs(s.minY-a.minY)>1||Math.abs(s.maxY-a.maxY)>1)&&o.snaps.clearIndicators()}complete(){this.updateShapes(),(0,h.IeP)(this.editor,[this.snapshot.shape.id]);let{onInteractionEnd:e}=this.info;e?"string"==typeof e?this.editor.setCurrentTool(e,this.info):e():(this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle"))}cancel(){this.editor.bailToMark(this.markId);let{onInteractionEnd:e}=this.info;e?"string"==typeof e?this.editor.setCurrentTool(e,this.info):e():(this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle"))}createSnapshot(){let e=this.editor.getSelectionRotation(),t=this.editor.inputs.getOriginPagePoint(),n=this.editor.getOnlySelectedShape(),r=this.editor.getSelectionRotatedPageBounds(),i=h.l2P.RotWith(r.getHandlePoint(this.info.handle),r.point,e);return{shape:n,cursorHandleOffset:h.l2P.Sub(t,i),initialSelectionPageBounds:this.editor.getSelectionPageBounds(),selectionRotation:e}}}class kS extends h.YM5{static id="pointing_crop_handle";info={};onEnter(e){this.info=e,"string"==typeof e.onInteractionEnd&&this.parent.setCurrentToolIdMask(e.onInteractionEnd);let t=this.editor.getSelectedShapes()[0];if(!t)return;let n=kx[this.info.handle];this.editor.setCursor({type:n,rotation:this.editor.getSelectionRotation()}),this.editor.setCroppingShape(t.id)}onExit(){this.editor.setCursor({type:"default",rotation:0}),this.parent.setCurrentToolIdMask(void 0)}onPointerMove(){this.editor.inputs.getIsDragging()&&this.startCropping()}onLongPress(){this.startCropping()}startCropping(){this.editor.getIsReadonly()||this.parent.transition("cropping",{...this.info,onInteractionEnd:this.info.onInteractionEnd})}onPointerUp(){let{onInteractionEnd:e}=this.info;e?"string"==typeof e?this.editor.setCurrentTool(e,this.info):e():(this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle"))}onDoubleClick(e){this.editor.inputs.getShiftKey()||"down"!==e.phase||e.ctrlKey||e.shiftKey||(this.parent.transition("idle"),this.parent.getCurrent()?.handleEvent(e))}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){let{onInteractionEnd:e}=this.info;e?"string"==typeof e?this.editor.setCurrentTool(e,this.info):e():(this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle"))}}function kC(e,t=!1){let n=e.inputs.getCurrentPagePoint();return e.getShapeAtPoint(n,{hitInside:!1,hitLabels:t,hitLocked:e.options.selectLockedShapes,margin:e.getHitTestMargin(),renderingOnly:!0})??e.getSelectedShapeAtPoint(n)}function kk(e){if(e.isDisposed)return!1;let t=e.inputs.getCurrentPagePoint(),n=e.getHitTestMargin(),r=e.overlays.getOverlayAtPoint(t,n),i=e.overlays.getHoveredOverlayId();if(r){e.overlays.setHoveredOverlay(r.id),e.setHoveredShape(null);let t=e.overlays.getOverlayUtil(r).getCursor(r);return t&&e.setCursor({type:t,rotation:e.getSelectionRotation()}),!0}return i&&e.setCursor({type:"default",rotation:0}),e.overlays.setHoveredOverlay(null),!1}function kP(e,t,n){if(!t)throw Error("Needs to translate a cropped shape!");let{crop:r}=t.props;if(!r)return;let i=e.inputs.getShiftKey()?Math.abs(n.x)<Math.abs(n.y)?"x":"y":null;"x"===i?n.x=0:"y"===i&&(n.y=0),n.rot(-t.rotation);let{w:o,h:s}=Q(t.props,r),a=r.bottomRight.x-r.topLeft.x,l=r.bottomRight.y-r.topLeft.y,d=(0,h.pN9)(r);return d.topLeft.x=(0,h.qE8)(d.topLeft.x-n.x/o,0,1-a),d.topLeft.y=(0,h.qE8)(d.topLeft.y-n.y/s,0,1-l),d.bottomRight.x=d.topLeft.x+a,d.bottomRight.y=d.topLeft.y+l,{id:t.id,type:t.type,props:{crop:d}}}class kT extends h.YM5{static id="idle";onEnter(){this.editor.setCursor({type:"default",rotation:0});let e=this.editor.getOnlySelectedShape();e&&this.editor.setCroppingShape(e.id),kk(this.editor)}onExit(){this.editor.setCursor({type:"default",rotation:0})}onPointerMove(){kk(this.editor)}onCancel(){this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle",{})}onPointerDown(e){if(e.accelKey){this.cancel(),this.editor.root.handleEvent(e);return}switch(e.target){case"canvas":{let t=this.editor.inputs.getCurrentPagePoint(),n=this.editor.overlays.getOverlayAtPoint(t,this.editor.getHitTestMargin());if(n){let t=n.props.overlayType;if("resize_handle"===t||"rotate_handle"===t||"mobile_rotate"===t)return void this.onPointerDown({...e,target:"selection",handle:n.props.handle})}let r=kC(this.editor);if(r&&!this.editor.isShapeOfType(r,"group"))return void this.onPointerDown({...e,shape:r,target:"shape"});this.cancel(),this.editor.root.handleEvent(e);break}case"shape":if(e.shape.id===this.editor.getCroppingShapeId())return void this.editor.setCurrentTool("select.crop.pointing_crop",e);this.editor.getShapeUtil(e.shape)?.canCrop(e.shape)?(this.editor.setCroppingShape(e.shape.id),this.editor.setSelectedShapes([e.shape.id]),this.editor.setCurrentTool("select.crop.pointing_crop",e)):(this.cancel(),this.editor.root.handleEvent(e));break;case"selection":switch(e.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",{...e,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",{...e,onInteractionEnd:"select.crop.idle"});break;default:this.cancel()}}}onDoubleClick(e){if(this.editor.inputs.getShiftKey()||"down"!==e.phase)return;let t=this.editor.getCroppingShapeId();if(!t)return;let n=this.editor.getShape(t);if(!n)return;let r=this.editor.getShapeUtil(n);if(r){if("canvas"===e.target){let t=this.editor.inputs.getCurrentPagePoint(),n=this.editor.overlays.getOverlayAtPoint(t,this.editor.getHitTestMargin());if(n){let t=n.props.overlayType;if("resize_handle"===t||"rotate_handle"===t||"mobile_rotate"===t)return void this.onDoubleClick({...e,target:"selection",handle:n.props.handle})}}if("selection"===e.target)return void r.onDoubleClickEdge?.(n,e);this.cancel(),this.editor.root.handleEvent(e)}}onKeyDown(){this.nudgeCroppingImage(!1)}onKeyRepeat(){this.nudgeCroppingImage(!0)}onKeyUp(e){"Enter"===e.key&&(this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle",{}))}cancel(){this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle",{})}nudgeCroppingImage(e=!1){let{editor:{inputs:{keys:t}}}=this,n=t.has("ShiftLeft"),r=new h.l2P(0,0);if(t.has("ArrowLeft")&&(r.x+=1),t.has("ArrowRight")&&(r.x-=1),t.has("ArrowUp")&&(r.y+=1),t.has("ArrowDown")&&(r.y-=1),r.equals(new h.l2P(0,0)))return;n&&r.mul(10);let i=this.editor.getShape(this.editor.getCroppingShapeId());if(!i)return;let o=kP(this.editor,i,r);o&&(e||this.editor.markHistoryStoppingPoint("translate crop"),this.editor.updateShapes([o]))}}class kE extends h.YM5{static id="pointing_crop";onCancel(){this.editor.setCurrentTool("select.crop.idle",{})}onPointerMove(e){this.editor.inputs.getIsDragging()&&this.startDragging(e)}onLongPress(e){this.startDragging(e)}onPointerUp(e){this.editor.setCurrentTool("select.crop.idle",e)}onDoubleClick(e){this.editor.inputs.getShiftKey()||"down"!==e.phase||e.ctrlKey||e.shiftKey||(this.parent.transition("idle"),this.parent.getCurrent()?.handleEvent(e))}startDragging(e){this.editor.setCurrentTool("select.crop.translating_crop",e)}}class kI extends h.YM5{static id="translating_crop";info={};markId="";snapshot={};onEnter(e){this.info=e,this.snapshot=this.createSnapshot(),this.markId=this.editor.markHistoryStoppingPoint("translating_crop"),this.editor.setCursor({type:"move",rotation:0}),this.updateShapes()}onExit(){this.editor.setCursor({type:"default",rotation:0})}onPointerMove(){this.updateShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(){this.cancel()}onKeyDown(e){switch(e.key){case"Alt":case"Shift":return void this.updateShapes()}}onKeyUp(e){switch(e.key){case"Enter":return void this.complete();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(){return{shape:this.editor.getOnlySelectedShape()}}updateShapes(){let e=this.snapshot.shape;if(!e)return;let t=this.editor.inputs.getOriginPagePoint(),n=this.editor.inputs.getCurrentPagePoint().clone().sub(t),r=kP(this.editor,e,n);r&&this.editor.updateShapes([r])}}class k_ extends h.YM5{static id="crop";static initial="idle";static children(){return[kT,kI,kE,kS,kv]}markId="";onEnter(){this.didExit=!1,this.markId=this.editor.markHistoryStoppingPoint("crop")}didExit=!1;onExit(){this.didExit||(this.didExit=!0,this.editor.getMarkIdMatching(this.markId)===this.markId&&this.editor.squashToMark(this.markId))}onCancel(){this.didExit||(this.didExit=!0,this.editor.bailToMark(this.markId))}}class kM extends h.YM5{static id="dragging_handle";static trackPerformance=!0;shapeId;initialHandle;initialAdjacentHandle;initialPagePoint;markId;initialPageTransform;initialPageRotation;info;isPrecise=!1;isPreciseId=null;pointingId=null;onEnter(e){let{shape:t,isCreating:n,creatingMarkId:r,handle:i}=e;if(this.info=e,"string"==typeof e.onInteractionEnd&&this.parent.setCurrentToolIdMask(e.onInteractionEnd),this.shapeId=t.id,this.markId="",n)if(r)this.markId=r;else{let e=this.editor.getMarkIdMatching(`creating:${this.editor.getOnlySelectedShapeId()}`);e&&(this.markId=e)}else this.markId=this.editor.markHistoryStoppingPoint("dragging handle");this.initialHandle=(0,h.pN9)(i),this.initialPageTransform=this.editor.getShapePageTransform(t),this.initialPageRotation=this.initialPageTransform.rotation(),this.initialPagePoint=this.editor.inputs.getOriginPagePoint().clone(),this.editor.setCursor({type:n?"cross":"grabbing",rotation:0});let o=this.editor.getShapeHandles(t).sort(h.Ky),s=o.findIndex(t=>t.id===e.handle.id);if(this.initialAdjacentHandle=null,e.handle.snapReferenceHandleId){let t=o.find(t=>t.id===e.handle.snapReferenceHandleId);t&&(this.initialAdjacentHandle=t)}if(!this.initialAdjacentHandle){for(let t=s+1;t<o.length;t++){let n=o[t];if("vertex"===n.type&&"middle"!==n.id&&n.id!==e.handle.id){this.initialAdjacentHandle=n;break}}if(!this.initialAdjacentHandle)for(let t=o.length-1;t>=0;t--){let n=o[t];if("vertex"===n.type&&"middle"!==n.id&&n.id!==e.handle.id){this.initialAdjacentHandle=n;break}}}if(this.editor.isShapeOfType(t,"arrow")){let n=fE(this.editor,t)[e.handle.id];this.isPrecise=!1,n&&(this.isPrecise=n.props.isPrecise,this.isPrecise?this.isPreciseId=n.toId:this.resetExactTimeout())}let a={handle:this.initialHandle,isPrecise:this.isPrecise,isCreatingShape:!!this.info.isCreating,initial:t},l=this.editor.getShapeUtil(t),d=l.onHandleDragStart?.(t,a);d&&this.editor.updateShapes([{...d,id:t.id,type:t.type}]),this.update(),this.editor.select(this.shapeId)}exactTimeout=-1;resetExactTimeout(){let e=this.editor.getShapeUtil("arrow").options.pointingPreciseTimeout;-1!==this.exactTimeout&&this.clearExactTimeout(),this.exactTimeout=this.editor.timers.setTimeout(()=>{this.getIsActive()&&!this.isPrecise&&(this.isPrecise=!0,this.isPreciseId=this.pointingId,this.update()),this.exactTimeout=-1},e)}clearExactTimeout(){-1!==this.exactTimeout&&(clearTimeout(this.exactTimeout),this.exactTimeout=-1)}onPointerMove(){this.update()}onKeyDown(){this.update()}onKeyUp(){this.update()}onPointerUp(){this.complete()}onComplete(){this.update(),this.complete()}onCancel(){this.cancel()}onExit(){this.parent.setCurrentToolIdMask(void 0),wT(this.editor),this.editor.snaps.clearIndicators(),this.editor.setCursor({type:"default",rotation:0})}complete(){this.editor.snaps.clearIndicators(),(0,h.IeP)(this.editor,[this.shapeId]);let e=this.editor.getShape(this.shapeId);if(e){let t=this.editor.getShapeUtil(e),n={handle:this.initialHandle,isPrecise:this.isPrecise,isCreatingShape:!!this.info.isCreating,initial:this.info.shape},r=t.onHandleDragEnd?.(e,n);r&&this.editor.updateShapes([{...r,id:e.id}])}let{onInteractionEnd:t}=this.info;if(t){if("string"!=typeof t)return void t?.();else if(this.editor.getInstanceState().isToolLocked&&t)return void this.editor.setCurrentTool(t,{shapeId:this.shapeId})}this.parent.transition("idle")}cancel(){let e=this.editor.getShape(this.shapeId);if(e){let t=this.editor.getShapeUtil(e),n={handle:this.initialHandle,isPrecise:this.isPrecise,isCreatingShape:!!this.info.isCreating,initial:this.info.shape};t.onHandleDragCancel?.(e,n)}this.editor.bailToMark(this.markId),this.editor.snaps.clearIndicators();let{onInteractionEnd:t}=this.info;t?"string"==typeof t?this.editor.setCurrentTool(t,{shapeId:this.shapeId}):t?.():this.parent.transition("idle")}update(){let{editor:e,shapeId:t,initialPagePoint:n}=this,{initialHandle:r,initialPageRotation:i,initialAdjacentHandle:o}=this,s=this.editor.user.getIsSnapMode(),{snaps:a}=e,l=e.inputs.getCurrentPagePoint(),d=e.inputs.getShiftKey(),c=e.inputs.getCtrlKey(),u=e.inputs.getAltKey(),p=e.inputs.getPointerVelocity(),f=this.info.shape,g=e.getShape(t);if(!g)return;let m=e.getShapeUtil(g),y=e.isShapeOfType(g,"arrow")?fE(e,g)[r.id]:void 0,b=l.clone().sub(n).rot(-i).add(r);if(d&&o&&"middle"!==r.id){let e=h.l2P.Angle(o,b),t=(0,h.cL9)(e,24);b=h.l2P.RotWith(b,o,t-e)}e.snaps.clearIndicators();let x={...r,x:b.x,y:b.y},w=!1;if(r.canSnap&&r.snapType?(0,h.mcG)("canSnap is deprecated. Cannot use both canSnap and snapType together - snapping disabled. Please use only snapType."):w=r.canSnap||void 0!==r.snapType,w&&(s?!c:c)){if(!e.getShapePageTransform(g.id))throw Error("Expected a page transform");let n=a.handles.snapHandle({currentShapeId:t,handle:x});n&&(n.nudge.rot(-e.getShapeParentTransform(g).rotation()),b.add(n.nudge),x={...r,x:b.x,y:b.y})}let v=m.onHandleDrag?.(g,{handle:x,isPrecise:this.isPrecise||u,isCreatingShape:!!this.info.isCreating,initial:f}),S={id:g.id,type:g.type,...v};if("vertex"===r.type&&this.editor.isShapeOfType(g,"arrow")){let t=fE(e,g)[r.id];t?y?.toId!==t.toId&&(this.pointingId=t.toId,this.isPrecise=.5>p.len()||u,this.isPreciseId=this.isPrecise?t.toId:null,this.resetExactTimeout()):y&&(this.pointingId=null,this.isPrecise=!1,this.isPreciseId=null,this.resetExactTimeout())}v&&e.updateShapes([S])}}function kA(e){return e.isLabel?[e]:e instanceof h.IQE?e.children.filter(e=>e.isLabel):[]}class kj extends h.YM5{static id="editing_shape";hitLabelOnShapeForPointerUp=null;info={};didPointerDownOnEditingShape=!1;isTextInputFocused(){let e=this.editor.getContainer(),t=this.editor.getContainerDocument();return e.contains(t.activeElement)&&(0,h.ghB)(!1,t)}onEnter(e){let t=this.editor.getEditingShape();if(!t)throw Error("Entered editing state without an editing shape");this.hitLabelOnShapeForPointerUp=null,this.didPointerDownOnEditingShape=!1,this.info=e,e.isCreatingTextWhileToolLocked&&this.parent.setCurrentToolIdMask("text"),this.editor.setCursor({type:"default",rotation:0}),v6(this.editor),this.editor.select(t)}onExit(){let e=!!this.editor.getEditingShapeId();this.editor.setEditingShape(null),v4(this.editor),this.info.isCreatingTextWhileToolLocked&&e&&(this.parent.setCurrentToolIdMask(void 0),this.editor.setCurrentTool("text",{}))}onPointerMove(e){if(this.hitLabelOnShapeForPointerUp&&this.editor.inputs.getIsDragging()){if(this.editor.getIsReadonly()||this.hitLabelOnShapeForPointerUp.isLocked)return;this.editor.select(this.hitLabelOnShapeForPointerUp),this.parent.transition("translating",e),this.hitLabelOnShapeForPointerUp=null;return}if(this.didPointerDownOnEditingShape&&this.editor.inputs.isDragging){if(this.editor.getIsReadonly())return;let t=this.editor.getEditingShape();if(!t||t.isLocked)return;if(!this.isTextInputFocused()){this.editor.select(t),this.parent.transition("translating",e),this.didPointerDownOnEditingShape=!1;return}this.didPointerDownOnEditingShape=!1}switch(e.target){case"shape":case"canvas":return void v6(this.editor)}}onPointerDown(e){switch(this.hitLabelOnShapeForPointerUp=null,this.didPointerDownOnEditingShape=!1,e.target){case"canvas":{let t=kC(this.editor,!0);if(t)return void this.onPointerDown({...e,shape:t,target:"shape"});break}case"shape":{let{shape:t}=e,n=this.editor.getEditingShape();if(!n)throw Error("Expected an editing shape!");let r=kA(this.editor.getShapeUtil(t).getGeometry(t)),i=1===r.length?r[0]:void 0,o=this.editor.isShapeOfType(n,"text")&&""===r4(this.editor,n.props.richText).trim();if(i&&!o){let e=this.editor.getPointInShapeSpace(t,this.editor.inputs.getCurrentPagePoint());if(i.bounds.containsPoint(e,0)&&i.hitTestPoint(e))if(t.id===n.id){this.didPointerDownOnEditingShape=!0;return}else{this.hitLabelOnShapeForPointerUp=t,this.editor.markHistoryStoppingPoint("editing on pointer up"),this.editor.select(t.id);return}}else{if(t.id!==n.id)return void this.parent.transition("pointing_shape",e);this.editor.isShapeFrameLike(t)&&(this.editor.setEditingShape(null),this.parent.transition("idle",e));return}}}this.parent.transition("idle",e),this.editor.root.handleEvent(e)}onPointerUp(e){if(this.didPointerDownOnEditingShape&&(this.didPointerDownOnEditingShape=!1,!this.isTextInputFocused()))return void this.editor.getRichTextEditor()?.commands.focus("all");let t=this.hitLabelOnShapeForPointerUp;if(!t)return;this.hitLabelOnShapeForPointerUp=null;let n=this.editor.getShapeUtil(t);if(t.isLocked)return;if(this.editor.getIsReadonly()&&!n.canEditInReadonly(t))return void this.parent.transition("pointing_shape",e);this.editor.select(t.id);let r=this.editor.getEditingShape(),i=r&&r.id!==t.id;this.editor.setEditingShape(t.id);let o=h.YZA.isIos||h.YZA.isAndroid;o&&i?o&&i&&this.editor.emit("select-all-text",{shapeId:t.id}):this.editor.emit("place-caret",{shapeId:t.id,point:e.point}),v6(this.editor)}onComplete(e){this.editor.getContainer().focus(),this.parent.transition("idle",e)}onCancel(e){this.editor.getContainer().focus(),this.parent.transition("idle",e)}}let kO=["Delete","Backspace","[","]","Enter"," ","Shift","Tab"];class kD extends h.YM5{static id="idle";selectedShapesOnKeyDown=[];onEnter(){this.parent.setCurrentToolIdMask(void 0),this.editor.setCursor({type:"default",rotation:0}),kk(this.editor)||v6(this.editor),this.selectedShapesOnKeyDown=[]}onExit(){this.editor.updateInstanceState({isChangingStyle:!1}),v4(this.editor)}onPointerMove(){kk(this.editor)||v6(this.editor),(0,h.PmD)(()=>this.editor.getInstanceState()).isChangingStyle&&this.editor.updateInstanceState({isChangingStyle:!1})}onPointerDown(e){switch(e.target){case"canvas":{let t=this.editor.inputs.getCurrentPagePoint(),n=this.editor.overlays.getOverlayAtPoint(t,this.editor.getHitTestMargin());if(n)return void this.onPointerDown({...e,target:"overlay",overlay:n});let r=kC(this.editor);if(r&&(this.editor.options.selectLockedShapes||!r.isLocked))return void this.onPointerDown({...e,shape:r,target:"shape"});let i=this.editor.getSelectedShapeIds(),o=this.editor.getOnlySelectedShape();if((i.length>1||o&&!this.editor.getShapeUtil(o).hideSelectionBoundsBg(o))&&kz(this.editor,t))return void this.onPointerDown({...e,target:"selection"});this.parent.transition("pointing_canvas",e);break}case"overlay":{let{overlay:t}=e,n=this.editor.overlays.getOverlayUtil(t);if(n.onPointerDown&&!1!==n.onPointerDown(t,e))return;let r=t.props.overlayType;if("shape_handle"===t.type){let n=this.editor.getShape(t.props.shapeId);n&&this.onPointerDown({...e,target:"handle",shape:n,handle:t.props.handle})}else switch(r){case"rotate_handle":case"mobile_rotate":case"resize_handle":this.onPointerDown({...e,target:"selection",handle:t.props.handle});break;default:this.onPointerDown({...e,target:"selection"})}break}case"shape":{let{shape:t}=e;if(!this.editor.options.selectLockedShapes&&this.editor.isShapeOrAncestorLocked(t)){this.parent.transition("pointing_canvas",e);break}this.parent.transition("pointing_shape",e);break}case"handle":if(this.editor.getIsReadonly())break;this.editor.inputs.getAltKey()?this.parent.transition("pointing_shape",e):this.parent.transition("pointing_handle",e);break;case"selection":switch(e.handle){case"mobile_rotate":case"top_left_rotate":case"top_right_rotate":case"bottom_left_rotate":case"bottom_right_rotate":if(e.accelKey){this.parent.transition("brushing",e);break}this.parent.transition("pointing_rotate_handle",e);break;case"top":case"right":case"bottom":case"left":case"top_left":case"top_right":case"bottom_left":case"bottom_right":{let t=this.editor.getOnlySelectedShape();if(e.ctrlKey&&this.editor.canCropShape(t))this.parent.transition("crop.pointing_crop_handle",e);else{if(e.accelKey){this.parent.transition("brushing",e);break}this.parent.transition("pointing_resize_handle",e)}break}default:{let t=this.editor.getHoveredShape();if(t&&!this.editor.getSelectedShapeIds().includes(t.id)&&(this.editor.options.selectLockedShapes||!t.isLocked))return void this.onPointerDown({...e,shape:t,target:"shape"});this.parent.transition("pointing_selection",e)}}}}onDoubleClick(e){if(!this.editor.inputs.getShiftKey()&&"down"===e.phase&&!e.ctrlKey&&!e.shiftKey)switch(e.target){case"canvas":{let t=this.editor.inputs.getCurrentPagePoint(),n=this.editor.overlays.getOverlayAtPoint(t,this.editor.getHitTestMargin());if(n){if("shape_handle"===n.type){let t=this.editor.getShape(n.props.shapeId);if(t)return void this.onDoubleClick({...e,target:"handle",shape:t,handle:n.props.handle})}let t=n.props.overlayType;if("resize_handle"===t||"rotate_handle"===t||"mobile_rotate"===t)return void this.onDoubleClick({...e,target:"selection",handle:n.props.handle})}let r=this.editor.getHoveredShape(),i=r&&!this.editor.isShapeOfType(r,"group")?r:this.editor.getSelectedShapeAtPoint(t)??this.editor.getShapeAtPoint(t,{margin:this.editor.getHitTestMargin(),hitInside:!1});if(i)return void this.onDoubleClick({...e,shape:i,target:"shape"});this.editor.inputs.getShiftKey()||this.handleDoubleClickOnCanvas(e);break}case"selection":{let t=this.editor.getOnlySelectedShape();if(t){let n=this.editor.getShapeUtil(t),r="right"===e.handle||"left"===e.handle||"top"===e.handle||"bottom"===e.handle,i="top_left"===e.handle||"top_right"===e.handle||"bottom_right"===e.handle||"bottom_left"===e.handle;if(this.editor.getIsReadonly()){this.editor.canEditShape(t,{type:i?"double-click-corner":r?"double-click-edge":"double-click"})&&this.startEditingShape(t,e,!0);break}if(r){let r=n.onDoubleClickEdge?.(t,e);if(r){this.editor.markHistoryStoppingPoint("double click edge"),this.editor.updateShapes([r]),(0,h.IeP)(this.editor,[t.id]);return}}if(i){let r=n.onDoubleClickCorner?.(t,e);if(r){this.editor.markHistoryStoppingPoint("double click corner"),this.editor.updateShapes([r]),(0,h.IeP)(this.editor,[t.id]);return}}if(this.editor.canCropShape(t))return void this.parent.transition("crop",e);this.editor.canEditShape(t)&&this.startEditingShape(t,e,!0)}break}case"shape":{let{shape:t}=e,n=this.editor.getSelectedShapeIds();if(this.editor.isShapeOfType(t,"group")||this.editor.getOutermostSelectableShape(t).id!==t.id){let e=this.editor.getOutermostSelectableShape(t,e=>!n.includes(e.id));n.includes(e.id)||(this.editor.markHistoryStoppingPoint("drilling into group on double click"),this.editor.select(e.id));return}let r=this.editor.getShapeUtil(t);if("video"!==t.type&&"embed"!==t.type&&this.editor.getIsReadonly())break;if(r.onDoubleClick){let e=r.onDoubleClick?.(t);if(e)return void this.editor.updateShapes([e])}if(r.canCrop(t)&&!this.editor.isShapeOrAncestorLocked(t)){this.editor.markHistoryStoppingPoint("select and crop"),this.editor.select(e.shape?.id),this.parent.transition("crop",e);return}this.editor.canEditShape(t)?this.startEditingShape(t,e,!0):this.handleDoubleClickOnCanvas(e);break}case"handle":{if(this.editor.getIsReadonly())break;let{shape:t,handle:n}=e,r=this.editor.getShapeUtil(t),i=r.onDoubleClickHandle?.(t,n);i?this.editor.updateShapes([i]):this.editor.canEditShape(t)&&this.startEditingShape(t,e,!0)}}}onRightClick(e){switch(e.target){case"canvas":{let t=this.editor.getSelectedShapeIds(),n=this.editor.getOnlySelectedShape(),r=this.editor.inputs.getCurrentPagePoint();if((t.length>1||n&&!this.editor.getShapeUtil(n).hideSelectionBoundsBg(n))&&kz(this.editor,r))return void this.onRightClick({...e,target:"selection"});let i=this.editor.getHoveredShape(),o=i&&!this.editor.isShapeOfType(i,"group")?i:this.editor.getShapeAtPoint(r,{margin:this.editor.getHitTestMargin(),hitInside:!1,hitLabels:!0,hitLocked:!0,hitFrameInside:!0,renderingOnly:!0});if(o)return void this.onRightClick({...e,shape:o,target:"shape"});this.editor.selectNone();break}case"shape":{let{selectedShapeIds:t}=this.editor.getCurrentPageState(),{shape:n}=e,r=this.editor.getOutermostSelectableShape(n,e=>!t.includes(e.id));t.includes(r.id)||this.editor.findShapeAncestor(r,e=>t.includes(e.id))||(this.editor.markHistoryStoppingPoint("selecting shape"),this.editor.setSelectedShapes([r.id]))}}}onCancel(){this.editor.getFocusedGroupId()!==this.editor.getCurrentPageId()&&this.editor.getSelectedShapeIds().length>0?this.editor.popFocusedGroupId():(this.editor.markHistoryStoppingPoint("clearing selection"),this.editor.selectNone())}onKeyDown(e){switch(this.selectedShapesOnKeyDown=this.editor.getSelectedShapes(),e.code){case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":if(e.accelKey)return void(e.shiftKey?"ArrowDown"===e.code?this.editor.selectFirstChildShape():"ArrowUp"===e.code&&this.editor.selectParentShape():this.editor.selectAdjacentShape(e.code.replace("Arrow","").toLowerCase()));this.nudgeSelectedShapes(!1);return}if(h.bGJ.editOnType.get()&&!kO.includes(e.key)&&!e.altKey&&!e.ctrlKey){let t=this.editor.getOnlySelectedShape();if(t&&this.editor.isShapeOfType(t,"note")&&this.editor.canEditShape(t))return void this.startEditingShape(t,{...e,target:"shape",shape:t},!0)}}onKeyRepeat(e){switch(e.code){case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":if(e.accelKey)return void this.editor.selectAdjacentShape(e.code.replace("Arrow","").toLowerCase());this.nudgeSelectedShapes(!0);break;case"Tab":this.editor.getSelectedShapes().length&&!e.altKey&&this.editor.selectAdjacentShape(e.shiftKey?"prev":"next")}}onKeyUp(e){switch(e.key){case"Enter":{if(!this.selectedShapesOnKeyDown.length)return;let t=this.editor.getSelectedShapes();if(t.every(e=>this.editor.isShapeOfType(e,"group")))return void this.editor.setSelectedShapes(t.flatMap(e=>this.editor.getSortedChildIdsForParent(e.id)));let n=this.editor.getOnlySelectedShape();if(n&&this.editor.canEditShape(n,{type:"press_enter"}))return void this.startEditingShape(n,{...e,target:"shape",shape:n},!0);this.editor.canCropShape(n)&&this.parent.transition("crop",e);break}case"Tab":this.editor.getSelectedShapes().length&&!e.altKey&&this.editor.selectAdjacentShape(e.shiftKey?"prev":"next")}}startEditingShape(e,t,n){let{editor:r}=this;this.editor.markHistoryStoppingPoint("editing shape"),T(e)?E(r,e,{selectAll:n}):r.setEditingShape(e),this.parent.transition("editing_shape",t)}isOverArrowLabelTest(e){return!!e&&SI(this.editor,e)}handleDoubleClickOnCanvas(e){if(this.editor.getIsReadonly()||!this.editor.options.createTextOnCanvasDoubleClick)return;this.editor.markHistoryStoppingPoint("creating text shape");let t=(0,h.n6Y)(),{x:n,y:r}=this.editor.inputs.getCurrentPagePoint();this.editor.createShapes([{id:t,type:"text",x:n,y:r,props:{richText:(0,h.TP3)(""),autoSize:!0}}]);let i=this.editor.getShape(t);!i||this.editor.canEditShape(i)&&E(this.editor,t,{info:e})}nudgeSelectedShapes(e=!1){let{editor:{inputs:{keys:t}}}=this,n=t.has("ShiftLeft"),r=new h.l2P(0,0);if(t.has("ArrowLeft")&&(r.x-=1),t.has("ArrowRight")&&(r.x+=1),t.has("ArrowUp")&&(r.y-=1),t.has("ArrowDown")&&(r.y+=1),r.equals(new h.l2P(0,0)))return;e||this.editor.markHistoryStoppingPoint("nudge shapes"),this.editor.updateInstanceState({isChangingStyle:!0});let{gridSize:i}=this.editor.getDocumentSettings(),o=this.editor.getInstanceState().isGridMode?n?i*kR:i:n?kL:kF,s=this.editor.getSelectedShapeIds();this.editor.nudgeShapes(s,r.mul(o)),(0,h.IeP)(this.editor,s)}}let kL=10,kF=1,kR=5;function kz(e,t){let n=e.getSelectionRotatedPageBounds();if(!n)return!1;let r=e.getSelectionRotation();return r?(0,h.s3y)(t,n.corners.map(e=>h.l2P.RotWith(e,n.point,r))):n.containsPoint(t)}class kN extends h.YM5{static id="pointing_arrow_label";shapeId="";markId="";wasAlreadySelected=!1;didDrag=!1;didCtrlOnEnter=!1;info={};updateCursor(){this.editor.setCursor({type:"grabbing",rotation:0})}onEnter(e){let{shape:t}=e;"string"==typeof e.onInteractionEnd&&this.parent.setCurrentToolIdMask(e.onInteractionEnd),this.info=e,this.shapeId=t.id,this.didDrag=!1,this.didCtrlOnEnter=e.accelKey,this.wasAlreadySelected=this.editor.getOnlySelectedShapeId()===t.id,this.updateCursor();let n=this.editor.getShapeGeometry(t).children[1];if(!n)throw Error(`Expected to find an arrow label geometry for shape: ${t.id}`);let r=this.editor.inputs.getCurrentPagePoint(),i=this.editor.getPointInShapeSpace(t,r);if(this._labelDragOffset=h.l2P.Sub(n.center,i),this.markId=this.editor.markHistoryStoppingPoint("label-drag start"),e.shiftKey||e.accelKey){let e=this.editor.getSelectedShapeIds();this.editor.setSelectedShapes([...e,this.shapeId]);return}this.editor.setSelectedShapes([this.shapeId])}onExit(){this.parent.setCurrentToolIdMask(void 0),this.editor.setCursor({type:"default",rotation:0})}_labelDragOffset=new h.l2P(0,0);onPointerMove(){if(!this.editor.inputs.getIsDragging())return;if(this.didCtrlOnEnter)return void this.parent.transition("brushing",this.info);let e=this.editor.getShape(this.shapeId);if(!e)return;let t=this.editor.getShapeUtil("arrow").options,n=Sv(this.editor,e),r=this.editor.getShapePageTransform(e.id),i=this.editor.getPointInShapeSpace(e,this.editor.inputs.getCurrentPagePoint()).add(this._labelDragOffset),o=SE(this.editor,e),s=n.uninterpolateAlongEdge(i);isNaN(s)&&(s=o);let a=r.applyToPoint(n.interpolateAlongEdge(s)),l=r.applyToPoint(n.interpolateAlongEdge(o));h.l2P.DistMin(a,l,t.labelCenterSnapDistance/this.editor.getZoomLevel())&&(s=o),this.didDrag=!0,this.editor.updateShape({id:e.id,type:e.type,props:{labelPosition:s}})}onPointerUp(){let e=this.editor.getShape(this.shapeId);e&&(this.didDrag||!this.wasAlreadySelected?this.complete():this.editor.canEditShape(e)&&E(this.editor,e.id))}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}complete(){let{onInteractionEnd:e}=this.info;e?"string"==typeof e?this.editor.setCurrentTool(e,{}):e():this.parent.transition("idle")}cancel(){this.editor.bailToMark(this.markId);let{onInteractionEnd:e}=this.info;e?"string"==typeof e?this.editor.setCurrentTool(e,{}):e():this.parent.transition("idle")}}function k$(e,t){let n=e.getSelectedShapeIds(),r=e.inputs.getCurrentPagePoint(),{shiftKey:i,altKey:o,accelKey:s}=t,a=i||s,l=e.options.selectLockedShapes,d=e.getShapeAtPoint(r,{hitInside:!1,margin:e.getHitTestMargin(),hitLabels:!0,hitLocked:l,renderingOnly:!0,filter:e=>l||!e.isLocked});if(d){let t=e.getOutermostSelectableShape(d);if(a&&!o)e.cancelDoubleClick(),n.includes(t.id)?(e.markHistoryStoppingPoint("deselecting shape"),e.deselect(t)):(e.markHistoryStoppingPoint("shift selecting shape"),e.setSelectedShapes([...n,t.id]));else{let r;(r=t===d||t.id===e.getFocusedGroupId()||n.includes(t.id)?d:t)&&!n.includes(r.id)&&(e.markHistoryStoppingPoint("selecting shape"),e.select(r.id))}}else{if(a)return;n.length>0&&(e.markHistoryStoppingPoint("selecting none"),e.selectNone());let t=e.getFocusedGroupId();if((0,h.vc4)(t)){let n=e.getShape(t);e.isPointInShape(n,r,{margin:0,hitInside:!0})||e.setFocusedGroup(null)}}}class kB extends h.YM5{static id="pointing_canvas";onEnter(e){!(e.shiftKey||e.accelKey)&&this.editor.getSelectedShapeIds().length>0&&(this.editor.markHistoryStoppingPoint("selecting none"),this.editor.selectNone())}onPointerMove(e){this.editor.inputs.getIsDragging()&&this.parent.transition("brushing",e)}onPointerUp(e){k$(this.editor,e),this.complete()}onDoubleClick(e){this.editor.inputs.getShiftKey()||"down"!==e.phase||e.ctrlKey||e.shiftKey||(this.parent.transition("idle"),this.parent.getCurrent()?.handleEvent(e))}onComplete(){this.complete()}onInterrupt(){this.parent.transition("idle")}complete(){this.parent.transition("idle")}}class kH extends h.YM5{static id="pointing_handle";didCtrlOnEnter=!1;info={};isDoubleClick=!1;onEnter(e){this.info=e,this.isDoubleClick=!1,this.didCtrlOnEnter=e.accelKey;let{shape:t}=e;if(this.editor.isShapeOfType(t,"arrow")){let n=fE(this.editor,t),r=n[e.handle.id],i=n["start"===e.handle.id?"end":"start"],o=this.editor.getShapePageTransform(t.id);r&&wE({editor:this.editor,pointInPageSpace:o.applyToPoint(e.handle),arrow:t,isPrecise:r.props.isPrecise,currentBinding:r,oppositeBinding:i})}this.editor.setCursor({type:"grabbing",rotation:0})}onExit(){this.editor.setHintingShapes([]),this.editor.setCursor({type:"default",rotation:0})}onPointerUp(){let{shape:e,handle:t}=this.info;if(this.isDoubleClick){this.parent.transition("idle"),this.parent.getCurrent()?.handleEvent({...this.info,type:"click",name:"double_click",phase:"down"});return}if(this.editor.isShapeOfType(e,"note")){let{editor:n}=this,r=kU(n,e,t,!1);if(r)return void E(n,r,{selectAll:!0})}this.parent.transition("idle",this.info)}onDoubleClick(e){this.editor.inputs.getShiftKey()||"down"!==e.phase||e.ctrlKey||e.shiftKey||(this.isDoubleClick=!0)}onPointerMove(e){let{editor:t}=this;t.inputs.getIsDragging()&&(this.didCtrlOnEnter?this.parent.transition("brushing",e):this.startDraggingHandle())}onLongPress(){this.startDraggingHandle()}startDraggingHandle(){let{editor:e}=this;if(e.getIsReadonly())return;let{shape:t,handle:n}=this.info;if(e.isShapeOfType(t,"note")){let r=x$(e.getShapeUtil(t),t),i=kU(e,t,n,!0);if(i){let n=e.getPointInParentSpace(i,e.inputs.getOriginPagePoint()).sub(h.l2P.Rot(new h.l2P(r.noteWidth/2,r.noteHeight/2).mul(t.props.scale),i.rotation));e.updateShape({...i,x:n.x,y:n.y}),e.setHoveredShape(i.id).select(i.id).setCurrentTool("select.translating",{...this.info,target:"shape",shape:e.getShape(i),onInteractionEnd:"note",isCreating:!0,onCreate:()=>{E(e,i,{selectAll:!0})}});return}}this.parent.transition("dragging_handle",this.info)}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){this.parent.transition("idle")}}function kU(e,t,n,r){let i=x$(e.getShapeUtil(t),t),o=e.getShapePageTransform(t.id),s=o.point(),a=o.rotation(),l=vX(e,{pagePoint:s,pageRotation:a,growY:t.props.growY*t.props.scale,extraHeight:0,scale:t.props.scale,noteWidth:i.noteWidth,noteHeight:i.noteHeight})[n.index];if(l)return vZ(e,{shape:t,center:l,pageRotation:a,noteWidth:i.noteWidth,noteHeight:i.noteHeight,forceNew:r})}class kW extends h.YM5{static id="pointing_rotate_handle";info={};updateCursor(){this.editor.setCursor({type:kx[this.info.handle],rotation:this.editor.getSelectionRotation()})}onEnter(e){this.info=e,"string"==typeof e.onInteractionEnd&&this.parent.setCurrentToolIdMask(e.onInteractionEnd),this.updateCursor()}onExit(){this.parent.setCurrentToolIdMask(void 0),this.editor.setCursor({type:"default",rotation:0})}onPointerMove(){this.editor.inputs.getIsDragging()&&this.startRotating()}onLongPress(){this.startRotating()}startRotating(){this.editor.getIsReadonly()||this.parent.transition("rotating",this.info)}onPointerUp(){this.complete()}onDoubleClick(e){this.editor.inputs.getShiftKey()||"down"!==e.phase||e.ctrlKey||e.shiftKey||(this.parent.transition("idle"),this.parent.getCurrent()?.handleEvent(e))}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}complete(){let{onInteractionEnd:e}=this.info;e?"string"==typeof e?this.editor.setCurrentTool(e,{}):e?.():this.parent.transition("idle")}cancel(){let{onInteractionEnd:e}=this.info;e?"string"==typeof e?this.editor.setCurrentTool(e,{}):e():this.parent.transition("idle")}}class kK extends h.YM5{static id="pointing_selection";info={};onEnter(e){this.info=e}onPointerUp(e){k$(this.editor,e),this.parent.transition("idle",e)}onPointerMove(e){this.editor.inputs.getIsDragging()&&this.startTranslating(e)}onLongPress(e){this.startTranslating(e)}startTranslating(e){this.editor.getIsReadonly()||this.parent.transition("translating",e)}onDoubleClick(e){if(this.editor.inputs.getShiftKey()||"down"!==e.phase||e.ctrlKey||e.shiftKey)return;let t=this.editor.getHoveredShape(),n=t&&!this.editor.isShapeOfType(t,"group")?t:this.editor.getShapeAtPoint(this.editor.inputs.getCurrentPagePoint(),{hitInside:!0,margin:0,renderingOnly:!0});if(n){this.parent.transition("idle"),this.parent.getCurrent()?.handleEvent({...e,target:"shape",shape:this.editor.getShape(n)});return}}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){this.parent.transition("idle")}}class kV extends h.YM5{static id="pointing_shape";hitShape={};hitShapeForPointerUp={};isDoubleClick=!1;didCtrlOnEnter=!1;didSelectOnEnter=!1;onEnter(e){let t=this.editor.getSelectedShapeIds(),n=this.editor.getSelectionRotatedPageBounds(),r=this.editor.getFocusedGroupId(),i=this.editor.inputs.getCurrentPagePoint(),{shiftKey:o,altKey:s,accelKey:a}=e;this.hitShape=e.shape,this.isDoubleClick=!1,this.didCtrlOnEnter=a;let l=this.editor.getOutermostSelectableShape(e.shape),d=this.editor.findShapeAncestor(l,e=>t.includes(e.id));if(this.didCtrlOnEnter||this.editor.getShapeUtil(e.shape).onClick||l.id===r||t.includes(l.id)||d||t.length>1&&n?.containsPoint(i)){this.didSelectOnEnter=!1,this.hitShapeForPointerUp=l;return}this.didSelectOnEnter=!0,o&&!s?(this.editor.cancelDoubleClick(),t.includes(l.id)||(this.editor.markHistoryStoppingPoint("shift selecting shape"),this.editor.setSelectedShapes([...t,l.id]))):(this.editor.markHistoryStoppingPoint("selecting shape"),this.editor.setSelectedShapes([l.id]))}onPointerUp(e){let t=this.editor.getSelectedShapeIds(),n=this.editor.getFocusedGroupId(),r=this.editor.inputs.getCurrentPagePoint(),i=e.shiftKey||e.accelKey,o=this.editor.getShapeAtPoint(r,{margin:this.editor.getHitTestMargin(),hitInside:!0,renderingOnly:!0})??this.hitShape;if(!this.editor.getShape(o.id))return void this.parent.transition("idle",e);let s=o?this.editor.getOutermostSelectableShape(o):this.hitShapeForPointerUp;if(s){let r=this.editor.getShapeUtil(s);if(r.onClick){let t=r.onClick?.(s);if(t){this.editor.markHistoryStoppingPoint("shape on click"),this.editor.updateShapes([t]),this.parent.transition("idle",e);return}}if(s.id===n){t.length>0?(this.editor.markHistoryStoppingPoint("clearing shape ids"),this.editor.setSelectedShapes([])):this.editor.popFocusedGroupId(),this.parent.transition("idle",e);return}}if(!this.didSelectOnEnter){let n=this.editor.getOutermostSelectableShape(o,e=>!t.includes(e.id));if(t.includes(n.id))if(i)this.editor.markHistoryStoppingPoint("deselecting on pointer up"),this.editor.deselect(s);else if(t.includes(s.id)){if(1===t.length){let t=kA(this.editor.getShapeUtil(s).getGeometry(s)),n=1===t.length?t[0]:void 0;if(n){let t=this.editor.getPointInShapeSpace(s,r);if(n.bounds.containsPoint(t,0)&&n.hitTestPoint(t))return void this.editor.run(()=>{this.editor.markHistoryStoppingPoint("editing on pointer up"),this.editor.select(s.id),this.editor.canEditShape(s)&&(this.editor.setEditingShape(s.id),this.editor.setCurrentTool("select.editing_shape"),this.isDoubleClick?this.editor.emit("select-all-text",{shapeId:s.id}):this.editor.emit("place-caret",{shapeId:s.id,point:e.point}))})}}this.editor.markHistoryStoppingPoint("selecting on pointer up"),this.editor.select(s.id)}else this.editor.markHistoryStoppingPoint("selecting on pointer up"),this.editor.select(s);else if(i){let e=this.editor.getShapeAncestors(n);this.editor.markHistoryStoppingPoint("shift deselecting on pointer up"),this.editor.setSelectedShapes([...this.editor.getSelectedShapeIds().filter(t=>!e.find(e=>e.id===t)),n.id])}else this.editor.markHistoryStoppingPoint("selecting on pointer up"),this.editor.setSelectedShapes([n.id])}this.parent.transition("idle",e)}onDoubleClick(e){if(this.isDoubleClick=!0,this.editor.inputs.getShiftKey()||"down"!==e.phase||e.ctrlKey||e.shiftKey)return;let{shape:t,...n}=e;this.parent.transition("idle"),this.parent.getCurrent()?.handleEvent({...n,target:"canvas"})}onPointerMove(e){if(this.editor.inputs.getIsDragging()){if(SI(this.editor,this.hitShape))return void this.parent.transition("pointing_arrow_label",{...e,shape:this.hitShape});this.didCtrlOnEnter?this.parent.transition("brushing",e):this.startTranslating(e)}}onLongPress(e){this.startTranslating(e)}startTranslating(e){this.editor.getIsReadonly()||(this.didSelectOnEnter||this.editor.getSelectedShapeIds().length||(this.editor.markHistoryStoppingPoint("selecting shape"),this.editor.setSelectedShapes([this.hitShapeForPointerUp.id])),this.editor.focus(),this.parent.transition("translating",e))}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){this.parent.transition("idle")}}class kY extends h.YM5{static id="resizing";static trackPerformance=!0;info={};markId="";didHoldCommand=!1;creationCursorOffset={x:0,y:0};snapshot={};onEnter(e){let{isCreating:t=!1,creatingMarkId:n,creationCursorOffset:r={x:0,y:0}}=e;this.info=e,this.didHoldCommand=!1,"string"==typeof e.onInteractionEnd&&this.parent.setCurrentToolIdMask(e.onInteractionEnd),this.creationCursorOffset=r;try{this.snapshot=this._createSnapshot()}catch(e){console.error(e),this.cancel();return}if(this.markId="",t)if(n)this.markId=n;else{let e=this.editor.getMarkIdMatching(`creating:${this.editor.getOnlySelectedShapeId()}`);e&&(this.markId=e)}else this.markId=this.editor.markHistoryStoppingPoint("starting resizing");t&&this.editor.setCursor({type:"cross",rotation:0}),this.handleResizeStart(),this.updateShapes()}onTick({elapsed:e}){let{editor:t}=this;!t.inputs.getIsDragging()||t.inputs.getIsPanning()||t.edgeScrollManager.updateEdgeScrolling(e)}onPointerMove(){this.updateShapes()}onKeyDown(){this.updateShapes()}onKeyUp(){this.updateShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(){this.cancel()}cancel(){let{shapeSnapshots:e}=this.snapshot;e.forEach(({shape:e})=>{let t=this.editor.getShape(e.id);if(t){let n=this.editor.getShapeUtil(e);n.onResizeCancel?.(e,t)}}),this.editor.bailToMark(this.markId);let{onInteractionEnd:t}=this.info;t?"string"==typeof t?this.editor.setCurrentTool(t,{}):t():this.parent.transition("idle")}complete(){if((0,h.IeP)(this.editor,this.snapshot.selectedShapeIds),this.handleResizeEnd(),this.info.isCreating&&this.info.onCreate)return void this.info.onCreate?.(this.editor.getOnlySelectedShape());let{onInteractionEnd:e}=this.info;if(e){if("string"!=typeof e)return void e();else if(this.editor.getInstanceState().isToolLocked)return void this.editor.setCurrentTool(e,{})}this.parent.transition("idle")}handleResizeStart(){let{shapeSnapshots:e}=this.snapshot,t=[];e.forEach(({shape:e})=>{let n=this.editor.getShapeUtil(e),r=n.onResizeStart?.(e);r&&t.push(r)}),t.length>0&&this.editor.updateShapes(t)}handleResizeEnd(){let{shapeSnapshots:e}=this.snapshot,t=[];e.forEach(({shape:e})=>{let n=this.editor.getShape(e.id),r=this.editor.getShapeUtil(e),i=r.onResizeEnd?.(e,n);i&&t.push(i)}),t.length>0&&this.editor.updateShapes(t)}updateShapes(){let{editor:e,info:t,snapshot:{frames:n,shapeSnapshots:r,selectionBounds:i,cursorHandleOffset:o,selectedShapeIds:s,selectionRotation:a,canShapesDeform:l,initialSelectionPageBounds:d,resizeLevels:c}}=this,u=e.inputs.getAltKey(),p=e.inputs.getShiftKey()||!l;if(1===r.size){let n=[...r.values()][0];e.isShapeOfType(n.shape,"text")&&(p="left"!==t.handle&&"right"!==t.handle)}let f=(0,h.gu7)(e.inputs),g=e.inputs.getCurrentPagePoint().clone().sub(o).sub(this.creationCursorOffset),m=e.inputs.getOriginPagePoint().clone().sub(o);if(e.getInstanceState().isGridMode&&!f){let{gridSize:t}=e.getDocumentSettings();g.snapToGrid(t)}let y=t.handle,b=kq(y,Math.PI);if(e.snaps.clearIndicators(),(e.user.getIsSnapMode()?!f:f)&&a%h.sKG==0){let{nudge:t}=e.snaps.shapeBounds.snapResizeShapes({dragDelta:h.l2P.Sub(g,m),initialSelectionPageBounds:d,handle:kq(y,a),isAspectRatioLocked:p,isResizingFromCenter:u});g.add(t)}let x=h.l2P.RotWith(u?i.center:i.getHandlePoint(b),i.point,a),w=h.l2P.Sub(g,x).rot(-a),v=h.l2P.Sub(m,x).rot(-a),S=h.l2P.DivV(w,v);Number.isFinite(S.x)||(S.x=1),Number.isFinite(S.y)||(S.y=1);let C="top"===y||"bottom"===y,k="left"===y||"right"===y;for(let t of(p?k?S.y=Math.abs(S.x):C?S.x=Math.abs(S.y):Math.abs(S.x)>Math.abs(S.y)?S.y=Math.abs(S.x)*(S.y<0?-1:1):S.x=Math.abs(S.y)*(S.x<0?-1:1):(C&&(S.x=1),k&&(S.y=1)),this.info.isCreating||this.updateCursor({dragHandle:y,isFlippedX:S.x<0,isFlippedY:S.y<0,rotation:a}),r.size>1&&function(e,t,n,r,i){let o=[];for(let[a,l]of t){var s;let t;if(!e.isShapeOfType(l.shape,"geo"))continue;let d=l.shape;if(r5(d.props.richText)||!(0,h.jwY)(l.pageRotation,r))continue;let c=(0,h.YY0)((l.pageRotation-r)%Math.PI,0);t=i||l.isAspectRatioLocked?Math.max(Math.abs(n.x),Math.abs(n.y)):Math.abs(c?n.x:n.y);let u=(s=d.props,Math.max(Math.abs(s.w/s.scale*t),51)),{html:p,opts:f}=function(e,t){let{richText:n,font:r,size:i,w:o}=t.props,s=e.getCurrentTheme(),a=Cw[i];return{html:r2(e,n),opts:{...er,fontFamily:ed(s,r),fontSize:s.fontSize*es[i],lineHeight:s.lineHeight,minWidth:a,maxWidth:Math.max(0,Math.ceil(a+s.strokeWidth*ei[i]),Math.ceil(o/t.props.scale-32))}}}(e,{...d,props:{...d.props,w:u*d.props.scale}});o.push({id:a,html:p,opts:f})}if(0===o.length)return;let a=e.textMeasure.measureHtmlBatch(o.map(({html:e,opts:t})=>({html:e,opts:t}))),l=new Map;for(let e=0;e<o.length;e++)l.set(o[e].id,{w:a[e].w+32,h:a[e].h+32});CE(e,l)}(this.editor,r,S,a,p),c)){let n=[];for(let i of t){let t=r.get(i),o=e.getResizeShapePartial(i,S,{initialShape:t.shape,initialBounds:t.bounds,initialPageTransform:t.pageTransform,dragHandle:y,mode:1===s.length&&i===s[0]?"resize_bounds":"scale_shape",scaleOrigin:x,isAspectRatioLocked:p,scaleAxisRotation:a,skipStartAndEndCallbacks:!0});o&&n.push(o)}n.length>0&&e.updateShapes(n)}if(f){this.didHoldCommand=!0;let e=[];for(let{id:t,children:i}of n){if(!i.length)continue;let n=r.get(t).shape,o=this.editor.getShape(t);if(!(n&&o))continue;let s=o.x-n.x,a=o.y-n.y,l=new h.l2P(s,a).rot(-n.rotation);if(0!==l.x||0!==l.y)for(let t of i)e.push({id:t.id,type:t.type,x:t.x-l.x,y:t.y-l.y})}e.length>0&&this.editor.updateShapes(e)}else if(this.didHoldCommand){this.didHoldCommand=!1;let e=[];for(let{children:t}of n)for(let n of t)e.push({id:n.id,type:n.type,x:n.x,y:n.y});e.length>0&&this.editor.updateShapes(e)}this.updateEnclosureHints()}updateEnclosureHints(){if(!this.info.isCreating)return;let e=this.editor.getOnlySelectedShape();if(!e||!this.editor.isShapeOfType(e,"frame"))return;let t=vB(this.editor,e),n=this.editor.getHintingShapeIds();t.length===n.length&&t.every((e,t)=>e===n[t])||this.editor.setHintingShapes(t)}updateCursor({dragHandle:e,isFlippedX:t,isFlippedY:n,rotation:r}){let i=this.editor.getInstanceState().cursor,o=i.type;switch(e){case"top_left":case"bottom_right":o="nwse-resize",t!==n&&(o="nesw-resize");break;case"top_right":case"bottom_left":o="nesw-resize",t!==n&&(o="nwse-resize")}(o!==i.type||r!==i.rotation)&&this.editor.setCursor({type:o,rotation:r})}onExit(){this.parent.setCurrentToolIdMask(void 0),this.editor.setCursor({type:"default",rotation:0}),this.editor.snaps.clearIndicators(),CE(this.editor,null),this.info.isCreating&&this.editor.getHintingShapeIds().length>0&&this.editor.setHintingShapes([])}_createSnapshot(){let{editor:e}=this,t=e.getSelectedShapeIds(),n=e.getSelectionRotation(),r=e.inputs.getOriginPagePoint(),i=e.getSelectionRotatedPageBounds();if(!i)throw Error("Resizing but nothing is selected");let o=h.l2P.RotWith(i.getHandlePoint(this.info.handle),i.point,n),s=h.l2P.Sub(r,o),a=new Map,l=[],d=t=>{let n=e.getShape(t);if(!n)return!1;let r=e.getShapeUtil(n);if(r.canResize(n)){let t=e.getShapePageTransform(n);a.set(n.id,{shape:n,bounds:e.getShapeGeometry(n).bounds,pageTransform:t,pageRotation:h.V8r.Decompose(t).rotation,isAspectRatioLocked:r.isAspectRatioLocked(n)})}if(e.isShapeFrameLike(n)&&l.push({id:n.id,children:(0,h.oE7)(e.getSortedChildIdsForParent(n).map(t=>e.getShape(t)))}),!r.canResizeChildren(n))return!1};t.forEach(t=>{!1!==d(t)&&e.visitDescendants(t,d)});let c=![...a.values()].some(e=>!(0,h.jwY)(e.pageRotation,n)||e.isAspectRatioLocked),u=[],p=new Map,f=t=>{let n=p.get(t);if(void 0!==n)return n;let r=0,i=e.getShape(t)?.parentId;for(;i&&(0,h.vc4)(i);){if(a.has(i)){r=f(i)+1;break}i=e.getShape(i)?.parentId}return p.set(t,r),r};for(let e of a.keys()){let t=f(e);for(;u.length<=t;)u.push([]);u[t].push(e)}return{shapeSnapshots:a,selectionBounds:i,cursorHandleOffset:s,selectionRotation:n,selectedShapeIds:t,canShapesDeform:c,initialSelectionPageBounds:this.editor.getSelectionPageBounds(),frames:l,resizeLevels:u}}}let kG=["top","top_right","right","bottom_right","bottom","bottom_left","left","top_left"];function kq(e,t){let n=Math.round((t%=h.uAR)/(h.PI/4)),r=kG.indexOf(e);return kG[(r+n)%kG.length]}let kX=Math.PI/180;class kJ extends h.YM5{static id="rotating";static trackPerformance=!0;snapshot={};info={};markId="";onEnter(e){this.info=e,"string"==typeof e.onInteractionEnd&&this.parent.setCurrentToolIdMask(e.onInteractionEnd),this.markId=this.editor.markHistoryStoppingPoint("rotate start");let t=(0,h.fHb)({editor:this.editor,ids:this.editor.getSelectedShapeIds()});if(!t)return void this.parent.transition("idle",this.info);this.snapshot=t;let n=this._getRotationFromPointerPosition({snapToNearestDegree:!1});(0,h._Bx)({editor:this.editor,delta:this._getRotationFromPointerPosition({snapToNearestDegree:!1}),snapshot:this.snapshot,stage:"start"}),this.editor.setCursor({type:kx[this.info.handle],rotation:n+this.snapshot.initialShapesRotation})}onExit(){this.editor.setCursor({type:"default",rotation:0}),this.parent.setCurrentToolIdMask(void 0),this.snapshot={}}onPointerMove(){this.update()}onKeyDown(){this.update()}onKeyUp(){this.update()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(){this.cancel()}update(){let e=this._getRotationFromPointerPosition({snapToNearestDegree:!1});(0,h._Bx)({editor:this.editor,delta:e,snapshot:this.snapshot,stage:"update"}),this.editor.setCursor({type:kx[this.info.handle],rotation:e+this.snapshot.initialShapesRotation})}cancel(){let{shapeSnapshots:e}=this.snapshot;e.forEach(({shape:e})=>{let t=this.editor.getShape(e.id);if(t){let n=this.editor.getShapeUtil(e);n.onRotateCancel?.(e,t)}}),this.editor.bailToMark(this.markId);let{onInteractionEnd:t}=this.info;t?"string"==typeof t?this.editor.setCurrentTool(t,this.info):t():this.parent.transition("idle",this.info)}complete(){(0,h._Bx)({editor:this.editor,delta:this._getRotationFromPointerPosition({snapToNearestDegree:!0}),snapshot:this.snapshot,stage:"end"}),(0,h.IeP)(this.editor,this.snapshot.shapeSnapshots.map(e=>e.shape.id));let{onInteractionEnd:e}=this.info;e?"string"==typeof e?this.editor.setCurrentTool(e,this.info):e():this.parent.transition("idle",this.info)}_getRotationFromPointerPosition({snapToNearestDegree:e}){let t=this.editor.inputs.getShiftKey(),n=this.editor.inputs.getCurrentPagePoint(),{initialCursorAngle:r,initialShapesRotation:i,initialPageCenter:o}=this.snapshot,s=i+(o.angle(n)-r);if(t)s=(0,h.cL9)(s,24);else if(e&&(s=Math.round(s/kX)*kX,this.editor.getInstanceState().isCoarsePointer)){let e=(0,h.cL9)(s,4);Math.abs((0,h.qer)(s,e))<(0,h.tRv)(5)&&(s=e)}return s-i}}class kZ extends h.YM5{static id="scribble_brushing";static trackPerformance=!0;hits=new Set;size=0;scribbleId="id";initialSelectedShapeIds=new Set;newlySelectedShapeIds=new Set;onEnter(){this.initialSelectedShapeIds=new Set(this.editor.inputs.getShiftKey()?this.editor.getSelectedShapeIds():[]),this.newlySelectedShapeIds=new Set,this.size=0,this.hits.clear();let e=this.editor.scribbles.addScribble({color:"selection-stroke",opacity:.32,size:12});this.scribbleId=e.id,this.updateScribbleSelection(!0),this.editor.updateInstanceState({brush:null})}onExit(){this.editor.scribbles.stop(this.scribbleId)}onPointerMove(){this.updateScribbleSelection(!0)}onPointerUp(){this.complete()}onKeyDown(){this.updateScribbleSelection(!1)}onKeyUp(){this.editor.inputs.getAltKey()?this.updateScribbleSelection(!1):this.parent.transition("brushing")}onCancel(){this.cancel()}onComplete(){this.complete()}pushPointToScribble(){let{x:e,y:t}=this.editor.inputs.getCurrentPagePoint();this.editor.scribbles.addPoint(this.scribbleId,e,t)}updateScribbleSelection(e){let t,n,r,i,{editor:o}=this,s=this.editor.inputs.getShiftKey(),a=this.editor.inputs.getOriginPagePoint(),l=this.editor.inputs.getPreviousPagePoint(),d=this.editor.inputs.getCurrentPagePoint(),{newlySelectedShapeIds:c,initialSelectedShapeIds:u}=this;e&&this.pushPointToScribble();let p=h.azJ.FromPoints([l,d]).expandBy(0),f=o.getShapeIdsInsideBounds(p);if(0===f.size){let e=o.getSelectedShapeIds(),t=new Set(s?[...c,...u]:[...c]);(e.length!==t.size||e.some(e=>!t.has(e)))&&this.editor.setSelectedShapes(Array.from(t));return}let g=this.editor.getCurrentPageRenderingShapesSorted().filter(e=>f.has(e.id));for(let e=0,s=g.length;e<s;e++){if(t=g[e],o.isShapeOfType(t,"group")||c.has(t.id)||!o.options.selectLockedShapes&&o.isShapeOrAncestorLocked(t)||(n=o.getShapeGeometry(t),o.isShapeFrameLike(t)&&n.bounds.containsPoint(o.getPointInShapeSpace(t,a))))continue;let s=o.getShapePageTransform(t);if(!n||!s)continue;let u=s.clone().invert();r=u.applyToPoint(l),i=u.applyToPoint(d);let{bounds:p}=n;if(!(p.minX-0>Math.max(r.x,i.x)||p.minY-0>Math.max(r.y,i.y)||p.maxX+0<Math.min(r.x,i.x)||p.maxY+0<Math.min(r.y,i.y))&&n.hitTestLineSegment(r,i,0)){let e=this.editor.getOutermostSelectableShape(t),n=this.editor.getShapeMask(e.id);if(n&&null!==(0,h.lqI)(l,d,n)&&!(0,h.s3y)(d,n))continue;c.add(e.id)}}let m=o.getSelectedShapeIds(),y=new Set(s?[...c,...u]:[...c]);(m.length!==y.size||m.some(e=>!y.has(e)))&&this.editor.setSelectedShapes(Array.from(y))}complete(){this.updateScribbleSelection(!0),this.parent.transition("idle")}cancel(){this.editor.setSelectedShapes([...this.initialSelectedShapeIds]),this.parent.transition("idle")}}var kQ=Object.defineProperty,k0=Object.getOwnPropertyDescriptor;class k1{constructor(e){this.editor=e,e.disposables.add(this.dispose)}editor;shapesToActuallyMove=[];draggedOverShapeIds=new Set;initialGroupIds=new Map;initialParentIds=new Map;initialIndices=new Map;initialDraggingOverShape;prevDraggingOverShape;prevPagePoint=new h.l2P;intervalTimerId=-1;startDraggingShapes(e,t,n){let{editor:r}=this;if(-1!==this.intervalTimerId)return;let i=new Set(e),o=new Set;for(let e of i){let t=r.getShapeParent(e);t&&r.isShapeOfType(t,"group")&&!o.has(t)&&o.add(t)}for(let e of o){let t=(0,h.oE7)(r.getSortedChildIdsForParent(e).map(e=>r.getShape(e)));for(let n of(i.add(e),t))i.delete(n)}for(let e of(this.initialParentIds.clear(),i)){let t=r.getShapeParent(e);t&&this.initialParentIds.set(e.id,t.id),this.initialIndices.set(e.id,e.index);let n=r.findShapeAncestor(e,e=>r.isShapeOfType(e,"group"));n&&this.initialGroupIds.set(e.id,n.id)}let s=r.getCurrentPageShapesSorted();this.shapesToActuallyMove=Array.from(i).filter(e=>!e.isLocked).sort((e,t)=>s.indexOf(e)-s.indexOf(t)),this.initialDraggingOverShape=r.getDraggingOverShape(t,this.shapesToActuallyMove),this.prevDraggingOverShape=void 0,this.updateDraggingShapes(t,n);let a=0;this.intervalTimerId=this.editor.timers.setInterval(()=>{++a%3&&this.editor.inputs.getPointerVelocity().len()>.5||this.updateDraggingShapes(r.inputs.getCurrentPagePoint(),n)},e.length>10?320:60)}dropShapes(e){let{editor:t}=this,n=t.inputs.getCurrentPagePoint();this.updateDraggingShapes(n);let r=t.getDraggingOverShape(n,e);if(r){let n=t.getShapeUtil(r),i=k2(t,r,e);i.length>0&&n.onDropShapesOver?.(r,i,{initialDraggingOverShapeId:this.initialDraggingOverShape?.id??null,initialParentIds:this.initialParentIds,initialIndices:this.initialIndices})}this.dispose()}clear(){clearInterval(this.intervalTimerId),this.intervalTimerId=-1,this.initialParentIds.clear(),this.initialIndices.clear(),this.shapesToActuallyMove=[],this.initialDraggingOverShape=void 0,this.prevDraggingOverShape=void 0,this.editor.setHintingShapes([])}dispose(){this.clear()}updateDraggingShapes(e,t){let{editor:n}=this,r=(0,h.oE7)(this.shapesToActuallyMove.map(e=>n.getShape(e)));if(!r.length)return;let i=n.getDraggingOverShape(e,this.shapesToActuallyMove),o=n.inputs.getCurrentPagePoint(),s=!this.prevPagePoint.equals(o);this.prevPagePoint.setTo(o),n.run(()=>{if(this.prevDraggingOverShape?.id===i?.id){if(s&&i&&(0,h.vc4)(i.id)&&!n.inputs.getPreviousPagePoint().equals(o)){let e=n.getShapeUtil(i);e.onDragShapesOver?.(i,r,{initialDraggingOverShapeId:this.initialDraggingOverShape?.id??null,initialParentIds:this.initialParentIds,initialIndices:this.initialIndices})}return}if(this.prevDraggingOverShape){var e,a,l;let t,o=n.getShapeUtil(this.prevDraggingOverShape),s=this.editor.getShape(this.prevDraggingOverShape),d=(e=n,a=s,l=r,t=e.getShapeUtil(a),l.filter(e=>t.canRemoveChildrenOfType(a,e.type)));d.length>0&&o.onDragShapesOut?.(s,d,{nextDraggingOverShapeId:i?.id??null,initialDraggingOverShapeId:this.initialDraggingOverShape?.id??null,initialParentIds:this.initialParentIds,initialIndices:this.initialIndices})}if(i){let e=n.getShapeUtil(i),t=k2(n,i,r);t.length>0?(e.onDragShapesIn?.(i,t,{initialDraggingOverShapeId:this.initialDraggingOverShape?.id??null,prevDraggingOverShapeId:this.prevDraggingOverShape?.id??null,initialParentIds:this.initialParentIds,initialIndices:this.initialIndices}),n.setHintingShapes([i.id])):this.prevDraggingOverShape&&n.setHintingShapes([])}else this.prevDraggingOverShape&&n.setHintingShapes([]);t?.()}),this.prevDraggingOverShape=i}}function k2(e,t,n){let r=e.getShapeUtil(t);return n.filter(e=>r.canReceiveNewChildrenOfType(t,e.type))}((e,t,n)=>{for(var r,i=k0(t,n),o=e.length-1;o>=0;o--)(r=e[o])&&(i=r(t,n,i)||i);return i&&kQ(t,n,i)})([h.oIE],k1.prototype,"dispose");var k3=Object.defineProperty,k5=Object.getOwnPropertyDescriptor;class k6 extends h.YM5{static id="translating";static trackPerformance=!0;info={};selectionSnapshot={};snapshot={};markId="";isCloning=!1;isCreating=!1;onCreate(e){}dragAndDropManager=new k1(this.editor);onEnter(e){let{isCreating:t=!1,creatingMarkId:n,onCreate:r=()=>void 0}=e;if(!this.editor.getSelectedShapeIds()?.length)return void this.parent.transition("idle");if(this.info=e,"string"==typeof e.onInteractionEnd&&this.parent.setCurrentToolIdMask(e.onInteractionEnd),this.isCreating=t,this.markId="",t)if(n)this.markId=n;else{let e=this.editor.getMarkIdMatching(`creating:${this.editor.getOnlySelectedShapeId()}`);e&&(this.markId=e)}else this.markId=this.editor.markHistoryStoppingPoint("translating");this.onCreate=r,this.isCloning=!1,this.info=e,this.editor.setCursor({type:"move",rotation:0}),this.selectionSnapshot=k4(this.editor),!this.isCreating&&this.editor.inputs.getAltKey()&&(this.startCloning(),this.isCloning)||(this.snapshot=this.selectionSnapshot,this.handleStart(),this.updateShapes())}onExit(){this.parent.setCurrentToolIdMask(void 0),this.selectionSnapshot={},this.snapshot={},this.editor.snaps.clearIndicators(),this.editor.setCursor({type:"default",rotation:0}),this.dragAndDropManager.clear()}onTick({elapsed:e}){let{editor:t}=this;!t.inputs.getIsDragging()||t.inputs.getIsPanning()||t.edgeScrollManager.updateEdgeScrolling(e)}onPointerMove(){this.updateShapes()}onKeyDown(){this.editor.inputs.getAltKey()&&!this.isCloning&&(this.startCloning(),this.isCloning)||this.updateShapes()}onKeyUp(){!this.editor.inputs.getAltKey()&&this.isCloning?this.stopCloning():this.updateShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(){this.cancel()}startCloning(){if(this.isCreating)return;let e=Array.from(this.editor.getSelectedShapeIds());this.editor.canCreateShapes(e)&&(this.isCloning=!0,this.reset(),this.markId=this.editor.markHistoryStoppingPoint("translate cloning"),this.editor.duplicateShapes(Array.from(this.editor.getSelectedShapeIds())),this.snapshot=k4(this.editor),this.handleStart(),this.updateShapes())}stopCloning(){this.isCloning=!1,this.snapshot=this.selectionSnapshot,this.reset(),this.markId=this.editor.markHistoryStoppingPoint("translate"),this.updateShapes()}reset(){this.editor.bailToMark(this.markId)}complete(){this.updateShapes(),this.dragAndDropManager.dropShapes(this.snapshot.movingShapes),this.handleEnd(),(0,h.IeP)(this.editor,this.snapshot.movingShapes.map(e=>e.id));let{onInteractionEnd:e}=this.info;if(e){if("string"!=typeof e)return void e();else if(this.editor.getInstanceState().isToolLocked)return void this.editor.setCurrentTool(e)}this.isCreating?this.onCreate?.(this.editor.getOnlySelectedShape()):this.parent.transition("idle")}cancel(){let{movingShapes:e}=this.snapshot;e.forEach(e=>{let t=this.editor.getShape(e.id);if(t){let n=this.editor.getShapeUtil(e);n.onTranslateCancel?.(e,t)}}),this.reset();let{onInteractionEnd:t}=this.info;t?"string"==typeof t?this.editor.setCurrentTool(t):t():this.parent.transition("idle",this.info)}handleStart(){let{movingShapes:e}=this.snapshot,t=[];e.forEach(e=>{let n=this.editor.getShapeUtil(e),r=n.onTranslateStart?.(e);r&&t.push(r)}),t.length>0&&this.editor.updateShapes(t),this.dragAndDropManager.startDraggingShapes((0,h.oE7)(this.snapshot.movingShapes.map(e=>this.editor.getShape(e.id))),this.editor.inputs.getOriginPagePoint(),this.updateParentTransforms),this.editor.setHoveredShape(null)}handleEnd(){let{movingShapes:e}=this.snapshot;if(this.isCloning&&e.length>0){let t=h.l2P.Average(e.map(e=>this.editor.getShapePageTransform(e.id).point())),n=h.l2P.Sub(t,this.selectionSnapshot.averagePagePoint);h.l2P.IsNaN(n)||this.editor.updateInstanceState({duplicateProps:{shapeIds:e.map(e=>e.id),offset:{x:n.x,y:n.y}}})}let t=[];e.forEach(e=>{let n=this.editor.getShape(e.id),r=this.editor.getShapeUtil(e),i=r.onTranslateEnd?.(e,n);i&&t.push(i)}),t.length>0&&this.editor.updateShapes(t)}updateShapes(){let{snapshot:e}=this;this.dragAndDropManager.startDraggingShapes(e.movingShapes,this.editor.inputs.getOriginPagePoint(),this.updateParentTransforms),function({editor:e,snapshot:t}){let{inputs:n}=e,{noteSnapshot:r,noteAdjacentPositions:i,noteCenterOffset:o,initialPageBounds:s,initialSnapPoints:a,shapeSnapshots:l,averagePagePoint:d}=t,c=e.inputs.getShiftKey(),u=e.inputs.getAccelKey(),p=e.getInstanceState().isGridMode,f=e.getDocumentSettings().gridSize,g=h.l2P.Sub(n.getCurrentPagePoint(),n.getOriginPagePoint()),m=c?Math.abs(g.x)<Math.abs(g.y)?"x":"y":null;"x"===m?g.x=0:"y"===m&&(g.y=0),e.snaps.clearIndicators();let y=e.user.getIsSnapMode()?!u:u,b=!1;if(y&&.5>e.inputs.getPointerVelocity().len()){let{nudge:t}=e.snaps.shapeBounds.snapTranslateShapes({dragDelta:g,initialSelectionPageBounds:s,lockedAxis:m,initialSelectionSnapPoints:a});g.add(t)}else if(r&&i&&o){let{scale:t}=r.shape.props,n=r.pagePoint.clone().add(g).add(o.clone().mul(t).rot(r.pageRotation)),s=10/e.getZoomLevel(),a=new h.l2P(0,0);for(let e of i){let t=h.l2P.Sub(n,e),r=t.len();r<s&&(b=!0,s=r,a=t)}g.sub(a)}let x=h.l2P.Add(d,g),w=e.snaps.getIndicators();!p||u||b||0!==w.length||x.snapToGrid(f);let v=h.l2P.Sub(x,d);e.updateShapes((0,h.oE7)(l.map(({shape:e,pagePoint:t,parentTransform:n})=>{let r=h.l2P.Add(t,v),i=n?h.V8r.applyToPoint(n,r):r;return{id:e.id,type:e.type,x:i.x,y:i.y}})))}({editor:this.editor,snapshot:e});let{movingShapes:t}=e,n=[];t.forEach(e=>{let t=this.editor.getShape(e.id),r=this.editor.getShapeUtil(e),i=r.onTranslate?.(e,t);i&&n.push(i)}),n.length>0&&this.editor.updateShapes(n)}updateParentTransforms(){let{editor:e,snapshot:{shapeSnapshots:t}}=this,n=[];t.forEach(t=>{let r=e.getShape(t.shape.id);r&&(n.push(r),t.parentTransform=(0,h.xhT)(r.parentId)?null:h.V8r.Inverse(e.getShapePageTransform(r.parentId)))})}}function k4(e){let t,n,r,i=[],o=[],s=e.getSelectedShapeIds(),a=(0,h.oE7)(s.map(t=>{let n=e.getShape(t);if(!n)return null;i.push(n);let r=e.getShapePageTransform(t),s=r.point(),a=r.rotation();o.push(s);let l=h.tvM.isId(n.parentId)?null:h.V8r.Inverse(e.getShapePageTransform(n.parentId));return{shape:n,pagePoint:s,pageRotation:a,parentTransform:l}})),l=e.getOnlySelectedShape(),d=[];if(l)d=e.snaps.shapeBounds.getSnapPoints(l.id);else{let t=e.getSelectionPageBounds();t&&(d=t.cornersAndCenter.map((e,t)=>({id:"selection:"+t,x:e.x,y:e.y})))}let c=e.inputs.getOriginPagePoint(),u=a.filter(t=>e.isShapeOfType(t.shape,"note")&&e.isPointInShape(t.shape,c));if(0===u.length);else if(1===u.length)n=u[0];else{let t=e.getCurrentPageShapesSorted();n=u.map(e=>({snapshot:e,index:t.findIndex(t=>t.id===e.shape.id)})).sort((e,t)=>t.index-e.index)[0]?.snapshot}if(n){let i=x$(e.getShapeUtil(n.shape),n.shape);t=vJ(e,{rotation:n.pageRotation,scale:n.shape.props.scale,extraHeight:n.shape.props.growY??0,noteWidth:i.noteWidth,noteHeight:i.noteHeight}),r=new h.l2P(i.noteWidth/2,i.noteHeight/2)}return{averagePagePoint:h.l2P.Average(o),movingShapes:i,shapeSnapshots:a,initialPageBounds:e.getSelectionPageBounds(),initialSnapPoints:d,noteAdjacentPositions:t,noteSnapshot:n,noteCenterOffset:r}}((e,t,n)=>{for(var r,i=k5(t,n),o=e.length-1;o>=0;o--)(r=e[o])&&(i=r(t,n,i)||i);return i&&k3(t,n,i)})([h.oIE],k6.prototype,"updateParentTransforms"),n(41463);class k8 extends h.YM5{static id="select";static initial="idle";static isLockable=!1;reactor=void 0;static children(){return[k_,kv,kD,kB,kV,k6,kb,kZ,kS,kK,kw,kj,kY,kJ,kW,kN,kH,kM]}cleanUpDuplicateProps(){let e=this.editor.getSelectedShapeIds(),t=this.editor.getInstanceState();if(!t.duplicateProps)return;let n=new Set(t.duplicateProps.shapeIds);e.length===n.size&&e.every(e=>n.has(e))||this.editor.updateInstanceState({duplicateProps:null})}onEnter(){this.reactor=(0,h.wvh)("clean duplicate props",()=>{try{this.cleanUpDuplicateProps()}catch(e){console.error(e)}})}onExit(){this.reactor?.(),this.editor.getCurrentPageState().editingShapeId&&this.editor.setEditingShape(null)}}class k9 extends h.YM5{static id="idle";info={};onEnter(e){this.info=e}onPointerDown(){this.parent.transition("pointing",this.info)}onKeyDown(e){"Shift"===e.key&&this.parent.transition("zoom_quick",this.info)}}class k7 extends h.YM5{static id="pointing";info={};onEnter(e){this.info=e}onPointerUp(){this.complete()}onPointerMove(){this.editor.inputs.getIsDragging()&&this.parent.transition("zoom_brushing",this.info)}onCancel(){this.cancel()}complete(){let e=this.editor.inputs.getCurrentScreenPoint();this.editor.inputs.getAltKey()?this.editor.zoomOut(e,{animation:{duration:220}}):this.editor.zoomIn(e,{animation:{duration:220}}),this.parent.transition("idle",this.info)}cancel(){this.parent.transition("idle",this.info)}}class Pe extends h.YM5{static id="zoom_brushing";info={};zoomBrush=new h.azJ;onEnter(e){this.info=e,this.update()}onExit(){this.editor.updateInstanceState({zoomBrush:null})}onPointerMove(){this.update()}onPointerUp(){this.complete()}onCancel(){this.cancel()}update(){let e=this.editor.inputs.getOriginPagePoint(),t=this.editor.inputs.getCurrentPagePoint();this.zoomBrush.setTo(h.azJ.FromPoints([e,t])),this.editor.updateInstanceState({zoomBrush:this.zoomBrush.toJson()})}cancel(){this.parent.transition("idle",this.info)}complete(){let{zoomBrush:e}=this,t=8/this.editor.getZoomLevel();if(e.width<t&&e.height<t){let e=this.editor.inputs.getCurrentScreenPoint();this.editor.inputs.getAltKey()?this.editor.zoomOut(e,{animation:{duration:220}}):this.editor.zoomIn(e,{animation:{duration:220}})}else{let t=this.editor.inputs.getAltKey()?this.editor.getZoomLevel()/2:void 0;this.editor.zoomToBounds(e,{targetZoom:t,animation:{duration:220}})}this.parent.transition("idle",this.info)}}class Pt extends h.YM5{static id="zoom_quick";info={};qzState="idle";initialVpb=new h.azJ;initialPp=new h.l2P;overviewZoom=1;cleanupZoomReactor(){}nextVpb=new h.azJ;onEnter(e){let{editor:t}=this;this.info=e,this.qzState="idle",this.initialVpb=t.getViewportPageBounds(),this.initialPp=h.l2P.From(t.inputs.getCurrentPagePoint()),t.setCursor({type:"zoom-in",rotation:0});let n=this.initialVpb,r=t.getCurrentPageBounds(),i=r?h.azJ.Expand(n,r):n.clone(),o=t.getViewportScreenBounds(),s=t.inputs.getCurrentScreenPoint(),a=s.x,l=s.y,{x:d,y:c}=this.initialPp,u=d-i.minX,p=i.maxX-d,f=c-i.minY,g=i.maxY-c,m=t.getCamera().z;u>0&&(m=Math.min(m,a/u)),p>0&&(m=Math.min(m,(o.w-a)/p)),f>0&&(m=Math.min(m,l/f)),g>0&&(m=Math.min(m,(o.h-l)/g)),m*=.85,m=Math.max(t.getCameraOptions().zoomSteps[0],m),this.overviewZoom=m,t.options.quickZoomPreservesScreenBounds&&(this.cleanupZoomReactor=(0,h.wvh)("zoom change in quick zoom",()=>{t.getZoomLevel(),this.updateBrush()}));let{x:y,y:b,z:x}=t.getCamera(),w=x/m;t.setCamera(new h.l2P((y+d)*w-d,(b+c)*w-c,m)),t.options.quickZoomPreservesScreenBounds||this.updateBrush()}onExit(){this.cleanupZoomReactor(),this.zoomToNewViewport(),this.editor.updateInstanceState({zoomBrush:null})}onPointerUp(){let e=this.info.onInteractionEnd?.split(".")[0]??"select";this.editor.setCurrentTool(e)}onCancel(){this.qzState="idle";let e=this.info.onInteractionEnd?.split(".")[0]??"select";this.editor.setCurrentTool(e)}onKeyUp(e){"Shift"===e.key&&this.parent.transition("idle",this.info)}updateBrush(){let{editor:e}=this,t=this.getNextVpb();this.nextVpb.setTo(t),e.updateInstanceState({zoomBrush:t.toJson()})}zoomToNewViewport(){let{editor:e}=this;switch(this.qzState){case"idle":e.zoomToBounds(this.initialVpb,{inset:0});break;case"moving":e.zoomToBounds(this.nextVpb,{inset:0})}}onPointerMove(){"moving"===this.qzState&&this.updateBrush()}onTick(){let{editor:e}=this;if("idle"===this.qzState){let t=e.getZoomLevel();h.l2P.Dist2(e.inputs.getCurrentPagePoint(),this.initialPp)*t>e.options.dragDistanceSquared/t&&(this.qzState="moving",this.updateBrush())}}getNextVpb(){let e,t,{editor:n}=this;if(n.options.quickZoomPreservesScreenBounds){let r=this.overviewZoom/n.getCamera().z;e=this.initialVpb.w*r,t=this.initialVpb.h*r}else e=this.initialVpb.w,t=this.initialVpb.h;let{x:r,y:i}=n.inputs.getCurrentPagePoint(),o=n.getViewportScreenBounds(),s=n.inputs.getCurrentScreenPoint(),{x:a,y:l}=new h.l2P(s.x/o.w,s.y/o.h);return new h.azJ(r-a*e,i-l*t,e,t)}}class Pn extends h.YM5{static id="zoom";static initial="idle";static children(){return[k9,k7,Pe,Pt]}static isLockable=!1;info={};onEnter(e){this.info=e;let t=e.onInteractionEnd?.split(".")[0];this.parent.setCurrentToolIdMask(t),this.updateCursor()}onExit(){this.parent.setCurrentToolIdMask(void 0),this.editor.updateInstanceState({zoomBrush:null,cursor:{type:"default",rotation:0}})}onKeyDown(){this.updateCursor()}onKeyUp(e){this.updateCursor(),"z"===e.key.toLowerCase()&&this.complete()}onInterrupt(){this.complete()}complete(){let e=this.info.onInteractionEnd?.split(".")[0]??"select";this.editor.setCurrentTool(e)}updateCursor(){this.editor.inputs.getAltKey()&&!this.editor.isIn("zoom.zoom_quick")?this.editor.setCursor({type:"zoom-out",rotation:0}):this.editor.setCursor({type:"zoom-in",rotation:0})}}let Pr=C.forwardRef(function({isEditing:e,text:t,handleFocus:n,handleChange:r,handleKeyDown:i,handlePaste:o,handleBlur:s,handleInputPointerDown:a,handleDoubleClick:l},d){let c=(0,h.hGv)();return(0,b.jsx)("textarea",{ref:d,className:"tl-text tl-text-input",name:"text",tabIndex:-1,disabled:!e,readOnly:!e,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",autoSave:"off",placeholder:"",spellCheck:"true",wrap:"off",dir:"auto",defaultValue:t,onFocus:n,onChange:e=>{r({plaintext:e.target.value})},onKeyDown:e=>i(e.nativeEvent),onBlur:s,onTouchEnd:c.markEventAsHandled,onContextMenu:e?e=>e.stopPropagation():void 0,onPointerDown:a,onPaste:o,onDoubleClick:l,onDragStart:h.woC})});C.memo(function({shapeId:e,type:t,text:n,labelColor:r,fontFamily:i,fontSize:o,lineHeight:s,textAlign:a,verticalAlign:l,wrap:d,isSelected:c,padding:u=0,onKeyDown:p,classNamePrefix:f,style:g,textWidth:m,textHeight:y,showTextOutline:x=!0}){let w,v,S,k,P,{rInput:T,isEmpty:E,isEditing:I,isReadyForEditing:_,...M}=(v=(w=Sm(e)).isEditing,S=(0,h.hGv)(),k=(0,C.useRef)(null),P=0===(n||"").trim().length,(0,C.useEffect)(()=>{function t(t){t.shapeId===e&&k.current?.select?.()}return S.on("select-all-text",t),()=>{S.off("select-all-text",t)}},[S,e,v]),(0,C.useEffect)(()=>{v&&(S.getContainerDocument().activeElement!==k.current&&k.current?.focus(),S.getInstanceState().isCoarsePointer&&k.current?.select(),h.YZA.isSafari&&(k.current?.blur(),k.current?.focus()))},[S,v]),{rInput:k,handleKeyDown:(0,C.useCallback)(t=>{S.getEditingShapeId()===e&&"Enter"===t.key&&(t.ctrlKey||t.metaKey)&&S.complete()},[S,e]),handleChange:(0,C.useCallback)(({plaintext:n})=>{if(S.getEditingShapeId()!==e)return;let r=r9.normalizeText(n||"");S.updateShape({id:e,type:t,props:{text:r}})},[S,e,t]),isEmpty:P,...w}),A=r9.normalizeTextForDom(n||""),j=A.length>0,O=Sf(a);if(!I&&!j)return null;let D=f||"tl-text";return(0,b.jsx)("div",{className:`${D}-label tl-text-wrapper tl-plain-text-wrapper`,"aria-hidden":!I,"data-hastext":!E,"data-isediting":I,"data-is-ready-for-editing":_,"data-textwrap":!!d,"data-isselected":c,style:{fontFamily:i,textAlign:a,justifyContent:"center"===a||O?"center":"end"===a?"flex-end":"flex-start",alignItems:"middle"===l?"center":"end"===l?"flex-end":"flex-start",padding:u,...g},children:(0,b.jsxs)("div",{className:`${D}-label__inner tl-text-content__wrapper`,style:{fontSize:o,lineHeight:`${(0,h.OVI)(o,s)}px`,minHeight:`${(0,h.OVI)(o,s)}px`,minWidth:Math.ceil(m||0),color:r,width:m?Math.ceil(m):void 0,height:y?Math.ceil(y):void 0},children:[(0,b.jsx)("div",{className:ik(`${D} tl-text tl-text-content`,x?"tl-text__outline":"tl-text__no-outline"),dir:"auto",children:A.split("\n").map((e,t)=>(0,b.jsx)("div",{dir:"auto",children:e},t))}),(_||c)&&(0,b.jsx)(Pr,{ref:T,text:n,isEditing:I,shapeId:e,...M,handleKeyDown:p??M.handleKeyDown})]})})});let Pi={fonts:{tldraw_mono:`${(0,h.H__)()}/fonts/IBMPlexMono-Medium.woff2`,tldraw_mono_italic:`${(0,h.H__)()}/fonts/IBMPlexMono-MediumItalic.woff2`,tldraw_mono_bold:`${(0,h.H__)()}/fonts/IBMPlexMono-Bold.woff2`,tldraw_mono_italic_bold:`${(0,h.H__)()}/fonts/IBMPlexMono-BoldItalic.woff2`,tldraw_serif:`${(0,h.H__)()}/fonts/IBMPlexSerif-Medium.woff2`,tldraw_serif_italic:`${(0,h.H__)()}/fonts/IBMPlexSerif-MediumItalic.woff2`,tldraw_serif_bold:`${(0,h.H__)()}/fonts/IBMPlexSerif-Bold.woff2`,tldraw_serif_italic_bold:`${(0,h.H__)()}/fonts/IBMPlexSerif-BoldItalic.woff2`,tldraw_sans:`${(0,h.H__)()}/fonts/IBMPlexSans-Medium.woff2`,tldraw_sans_italic:`${(0,h.H__)()}/fonts/IBMPlexSans-MediumItalic.woff2`,tldraw_sans_bold:`${(0,h.H__)()}/fonts/IBMPlexSans-Bold.woff2`,tldraw_sans_italic_bold:`${(0,h.H__)()}/fonts/IBMPlexSans-BoldItalic.woff2`,tldraw_draw:`${(0,h.H__)()}/fonts/Shantell_Sans-Informal_Regular.woff2`,tldraw_draw_italic:`${(0,h.H__)()}/fonts/Shantell_Sans-Informal_Regular_Italic.woff2`,tldraw_draw_bold:`${(0,h.H__)()}/fonts/Shantell_Sans-Informal_Bold.woff2`,tldraw_draw_italic_bold:`${(0,h.H__)()}/fonts/Shantell_Sans-Informal_Bold_Italic.woff2`}};function Po(e){return(0,C.useMemo)(()=>e?{fonts:{...Pi.fonts,...e?.fonts}}:Pi,[e])}let Ps={...Pi,icons:Object.fromEntries(["align-bottom","align-center-horizontal","align-center-vertical","align-left","align-right","align-top","alt","arrow-arc","arrow-cycle","arrow-elbow","arrow-left","arrowhead-arrow","arrowhead-bar","arrowhead-diamond","arrowhead-dot","arrowhead-none","arrowhead-square","arrowhead-triangle-inverted","arrowhead-triangle","blob","bold","bookmark","bring-forward","bring-to-front","broken","bulletList","check-circle","check","chevron-down","chevron-left","chevron-right","chevron-up","chevrons-ne","chevrons-sw","clipboard-copied","clipboard-copy","closed","code","color","comment","corners","crop","cross-2","cross-circle","dash-dashed","dash-dotted","dash-draw","dash-solid","disconnected","discord","distribute-horizontal","distribute-vertical","dot","dots-horizontal","dots-vertical","download","drag-handle-dots","duplicate","edit","external-link","fill-fill","fill-lined-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","heading","help-circle","highlight","horizontal-align-end","horizontal-align-middle","horizontal-align-start","info-circle","italic","leading","link","list","lock","manual","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","strike","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","underline","undo","ungroup","unlock","vertical-align-end","vertical-align-middle","vertical-align-start","warning-triangle","zoom-in","zoom-out"].map(e=>[e,`${(0,h.H__)()}/icons/icon/0_merged.svg#${e}`])),translations:Object.fromEntries(h.Yjb.map(e=>[e.locale,`${(0,h.H__)()}/translations/${e.locale}.json`])),embedIcons:Object.fromEntries(dM.map(e=>[e.type,`${(0,h.H__)()}/embed-icons/${e.type}.png`]))};function Pa(e){return(0,C.useMemo)(()=>e?{fonts:Object.assign({...Ps.fonts},{...e?.fonts}),icons:Object.assign({...Ps.icons},{...e?.icons}),embedIcons:Object.assign({...Ps.embedIcons},{...e?.embedIcons}),translations:Object.assign({...Ps.translations},{...e?.translations})}:Ps,[e])}function Pl(){let{Spinner:e}=(0,h.BSi)();return(0,b.jsx)(h.xxw,{children:e?(0,b.jsx)(e,{}):null})}let Pd=(0,h.u4I)(function({overrides:e,components:t,assetUrls:n,onUiEvent:r,forceMobile:i,mediaMimeTypes:o,children:s}){let a=(0,h.frr)();return(0,b.jsx)(pJ.Provider,{value:o,children:(0,b.jsx)(j,{assetUrls:Pa(n),children:(0,b.jsx)(N,{overrides:p0(e),locale:a?.user.getLocale()??h.TjI.locale,children:(0,b.jsx)(a$,{children:(0,b.jsx)(ht,{onEvent:r,children:(0,b.jsx)(p_,{children:(0,b.jsx)(h2,{context:"tla",children:(0,b.jsx)(_,{children:(0,b.jsx)(dN,{forceMobile:i,children:(0,b.jsx)(xv,{overrides:t,children:(0,b.jsx)(Pc,{overrides:e,children:s})})})})})})})})})})})});function Pc({overrides:e,children:t}){let n,r,i=(n=pZ(),r=pQ(null==e?[]:Array.isArray(e)?e:[e]),(0,C.useMemo)(()=>(function(e,t){let n={};for(let t of e)if(t.translations)for(let[e,r]of(0,h.iAN)(t.translations)){let t=n[e];t||(t=n[e]={}),Object.assign(t,r)}return{actions:(t,n,r)=>{for(let i of e)i.actions&&(n=i.actions(t,n,r));return n},tools:(n,r,i)=>{for(let o of e)o.tools&&(r=o.tools(n,r,{...t,...i}));return r},translations:n}})(r,n),[r,n]));return(0,b.jsx)(xT,{overrides:i.actions,children:(0,b.jsx)(p2,{overrides:i.tools,children:t})})}let Pu=C.memo(function({renderDebugMenuItems:e,children:t,hideUi:n,components:r,...i}){return(0,b.jsx)(Pd,{...i,components:r,children:(0,b.jsx)(Ph,{hideUi:n,renderDebugMenuItems:e,children:t})})}),Ph=C.memo(function({children:e,hideUi:t,...n}){let r,i,o,s,a,l,d,c,u,p;return r=(0,h.hGv)(),i=uz(),o=xE(),s=p3(),a=mR(),l=(0,h.hau)("is focused",()=>r.getInstanceState().isFocused,[r]),(0,C.useEffect)(()=>{if(!l)return;let e=[],t=(t,n,r)=>{let i=function(e){let t=[];for(let n of xs(e)){let e=function(e){let t=e.split("+"),n={key:"",shift:!1,alt:!1,ctrl:!1,meta:!1},r="";for(let e=0;e<t.length;e++){let i=t[e];if(e===t.length-1)r=i;else{let e=b7[i.toLowerCase()];e&&(n[e]=!0)}}if(!r)return null;let i=r.toLowerCase();return xe[i]&&(i=xe[i]),n.key=i,n}(n);e&&t.push(e)}return t}(t);0!==i.length&&e.push({parsed:i,onKeyDown:n,onKeyUp:r})};for(let e of Object.values(o))e.kbd&&(!i||e.readonlyOk)&&(b8.includes(e.id)||t(xo(e.kbd),t=>{(!b9(r)||e.isRequiredA11yAction)&&((0,h.woC)(t),e.onSelect("kbd"))}));for(let e of Object.values(s))!(!e.kbd||!e.readonlyOk&&r.getIsReadonly()||b8.includes(e.id))&&("comment"!==e.id||a)&&t(xo(e.kbd),t=>{b9(r)||((0,h.woC)(t),e.onSelect("kbd"))});t(",",e=>{if(b9(r)||r.inputs.keys.has("Comma"))return;(0,h.woC)(e),r.focus(),r.inputs.keys.add("Comma");let{x:t,y:n,z:i}=r.inputs.getCurrentPagePoint(),o=r.pageToScreen({x:t,y:n}),s={type:"pointer",name:"pointer_down",point:{x:o.x,y:o.y,z:i},shiftKey:e.shiftKey,altKey:e.altKey,ctrlKey:e.metaKey||e.ctrlKey,metaKey:e.metaKey,accelKey:(0,h.gu7)(e),pointerId:0,button:0,isPen:r.getInstanceState().isPenMode,target:"canvas"};r.dispatch(s)},e=>{if(b9(r)||!r.inputs.keys.has("Comma"))return;r.inputs.keys.delete("Comma");let{x:t,y:n,z:i}=r.inputs.getCurrentPagePoint(),o=r.pageToScreen({x:t,y:n}),s={type:"pointer",name:"pointer_up",point:{x:o.x,y:o.y,z:i},shiftKey:e.shiftKey,altKey:e.altKey,ctrlKey:e.metaKey||e.ctrlKey,metaKey:e.metaKey,accelKey:(0,h.gu7)(e),pointerId:0,button:0,isPen:r.getInstanceState().isPenMode,target:"canvas"};r.dispatch(s)});let n=r.getContainerDocument().body,d=new Map,c=t=>{if(xi(t))return;let n=t.code;for(let r of e)if(r.onKeyDown){for(let e of r.parsed)if(xr(t,e)){if(n)if(t.repeat){let e=d.get(n);if(e&&e!==r)return}else d.set(n,r);r.onKeyDown(t);break}}},u=t=>{if(t.code&&d.delete(t.code),!xi(t)){for(let n of e)if(n.onKeyUp){for(let e of n.parsed)if(xr(t,e)){n.onKeyUp(t);break}}}};return n.addEventListener("keydown",c),n.addEventListener("keyup",u),()=>{n.removeEventListener("keydown",c),n.removeEventListener("keyup",u)}},[o,s,i,r,l,a]),c=(d=(0,h.hGv)()).getContainerDocument(),u=hn(),p=(0,h.hau)("editor.isFocused",()=>d.getInstanceState().isFocused,[d]),(0,C.useEffect)(()=>{if(!p)return;let e=async e=>{0===d.getSelectedShapeIds().length||null!==d.getEditingShapeId()||pU(d)||((0,h.woC)(e),await pG(d,{operation:"copy",source:"native"})&&u("copy",{source:"kbd"}))};async function t(e){0===d.getSelectedShapeIds().length||null!==d.getEditingShapeId()||pU(d)||((0,h.woC)(e),await pG(d,{operation:"cut",source:"native"})&&(d.deleteShapes(d.getSelectedShapeIds()),u("cut",{source:"kbd"})))}let n=!1,r=e=>{1===e.button&&(n=!0,d.timers.requestAnimationFrame(()=>{n=!1}))},i=!1,o=e=>{i=e.shiftKey},s=e=>{if(n)return void d.markEventAsHandled(e);if(null!==d.getEditingShapeId()||pU(d))return;if(i){let t=e.clipboardData?.getData("text/plain");if(t?.trim()){let n=d.user.getIsPasteAtCursorMode()?d.inputs.getCurrentPagePoint():d.getViewportPageBounds().center;d.markHistoryStoppingPoint("paste"),id(d,{text:t,point:n}),(0,h.woC)(e),u("paste",{source:"kbd"});return}}let t=d.user.getIsPasteAtCursorMode()?d.inputs.getCurrentPagePoint():void 0;if(d.options.onClipboardPasteRaw?.({editor:d,source:"native-event",event:e,clipboardData:e.clipboardData,point:t})===!1){(0,h.woC)(e),u("paste",{source:"kbd"});return}let r=()=>{e.clipboardData&&pK(d,e.clipboardData,t)},o=d.getContainerWindow(),s=o.navigator;if(s.clipboard?.read){let n=Array.from(e.clipboardData?.files||[]);s.clipboard.read().then(e=>{Array.isArray(e)&&e[0]instanceof o.ClipboardItem&&pV({editor:d,clipboardItems:e,point:t,fallbackFiles:n,clipboardPasteSource:"native-event"})},()=>{r()})}else r();(0,h.woC)(e),u("paste",{source:"kbd"})};return c?.addEventListener("copy",e),c?.addEventListener("cut",t),c?.addEventListener("paste",s),c?.addEventListener("pointerup",r),c?.addEventListener("keydown",o,!0),c?.addEventListener("keyup",o,!0),()=>{c?.removeEventListener("copy",e),c?.removeEventListener("cut",t),c?.removeEventListener("paste",s),c?.removeEventListener("pointerup",r),c?.removeEventListener("keydown",o,!0),c?.removeEventListener("keyup",o,!0)}},[d,u,p,c]),(0,b.jsxs)(b.Fragment,{children:[e,t?null:(0,b.jsx)(Pp,{...n})]})}),Pp=C.memo(function(){let e=(0,h.hGv)(),t=$(),n=d$(),r=uz(),i=(0,h.hau)("focus",()=>e.getInstanceState().isFocusMode,[e]),o=(0,h.hau)("debug",()=>e.getInstanceState().isDebugMode,[e]),s=(0,h.NFA)(),a=B(),l=(0,h.hau)("locale",()=>e.user.getLocale(),[e]);(0,C.useEffect)(()=>{s.dir=a,s.lang=l},[s,a,l]);let{SharePanel:d,TopPanel:c,MenuPanel:u,StylePanel:p,Toolbar:f,HelpMenu:g,NavigationPanel:m,HelperButtons:y,DebugPanel:x,Toasts:w,Dialogs:v,A11y:S,FollowingIndicator:k}=xS();!function(){let e=(0,h.hGv)(),{addToast:t}=pM();(0,C.useEffect)(()=>{function n({name:e,count:r}){t({title:"Maximum shapes reached",description:`You've reached the maximum number of shapes allowed on ${e} (${r}). Please delete some shapes or move to a different page to continue.`,severity:"warning"})}return e.addListener("max-shapes",n),()=>{e.removeListener("max-shapes",n)}},[e,t])}();let P=(0,C.useRef)(!1),T=(0,C.useRef)(-1),[E,I]=(0,C.useState)(!1);(0,h.a1r)("update hide toolbar while delayed",()=>{if(h.YZA.isIos||h.YZA.isAndroid){if(null===e.getEditingShapeId()){P.current&&(P.current=!1,clearTimeout(T.current),h.YZA.isAndroid?T.current=e.timers.setTimeout(()=>{I(!1)},150):I(!1));return}P.current||(P.current=!0,clearTimeout(T.current),I(!0))}},[]);let{"toggle-focus-mode":_}=xE(),{breakpointsAbove:M,breakpointsBelow:A}=(0,C.useMemo)(()=>{let e=[],t=[];for(let r=0;r<dR.length;r++)r<=n?e.push(r):t.push(r);return{breakpointsAbove:e,breakpointsBelow:t}},[n]);return(0,b.jsxs)("div",{className:ik("tlui-layout",{"tlui-layout__mobile":n<5}),role:"document","data-iseditinganything":E,"data-breakpoint":n,"data-breakpoints-above":M.join(" "),"data-breakpoints-below":A.join(" "),children:[(0,b.jsx)(xj,{}),i?(0,b.jsx)("div",{className:"tlui-layout__top",children:(0,b.jsx)(aW,{type:"icon",className:"tlui-focus-button",title:t("focus-mode.toggle-focus-mode"),onClick:()=>_.onSelect("menu"),children:(0,b.jsx)(dm,{icon:"dot"})})}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"tlui-layout__top",children:[(0,b.jsxs)("div",{className:"tlui-layout__top__left",children:[u&&(0,b.jsx)(u,{}),y&&(0,b.jsx)(y,{})]}),(0,b.jsx)("div",{className:"tlui-layout__top__center",children:c&&(0,b.jsx)(c,{})}),(0,b.jsxs)("div",{className:"tlui-layout__top__right",children:[d&&(0,b.jsx)(d,{}),p&&n>=5&&!r&&(0,b.jsx)(p,{})]})]}),(0,b.jsxs)("div",{className:"tlui-layout__bottom",children:[(0,b.jsxs)("div",{className:"tlui-layout__bottom__main",children:[m&&(0,b.jsx)(m,{}),f&&(0,b.jsx)(f,{}),g&&(0,b.jsx)(g,{})]}),o&&x&&(0,b.jsx)(x,{}),S&&(0,b.jsx)(S,{})]})]}),k&&(0,b.jsx)(k,{}),w&&(0,b.jsx)(w,{}),v&&(0,b.jsx)(v,{})]})});function Pf(){let{RichTextToolbar:e,ImageToolbar:t,VideoToolbar:n,CursorChatBubble:r}=xS();return(0,b.jsxs)(b.Fragment,{children:[e&&(0,b.jsx)(e,{}),t&&(0,b.jsx)(t,{}),n&&(0,b.jsx)(n,{}),r&&(0,b.jsx)(r,{})]})}let Pg=[kd,kf,ky,Pn,k8,v7,vN,vW,v0,vG,v$,vF,vK];function Pm(e){let{children:t,maxImageDimension:n,maxAssetSize:r,acceptedImageMimeTypes:i,acceptedVideoMimeTypes:o,onMount:s,components:a={},shapeUtils:l=[],bindingUtils:d=[],assetUtils:c=[],overlayUtils:u=[],tools:p=[],embeds:f,options:g,locale:m,textOptions:y,...x}=e,w=(0,h.dSk)(a),v=a?.InFrontOfTheCanvas,S=(0,C.useMemo)(()=>x.hideUi?v??null:v?()=>(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(Pf,{}),(0,b.jsx)(v,{})]}):Pf,[x.hideUi,v]),k=(0,C.useMemo)(()=>({Spinner:uW,LoadingScreen:Pl,...w,InFrontOfTheCanvas:S}),[w,S]),P=(0,h.H80)(l),T=(0,C.useMemo)(()=>(0,h.OgJ)("type",P,ko),[P]),E=(0,h.H80)(d),I=(0,C.useMemo)(()=>(0,h.OgJ)("type",E,vj),[E]),_=(0,h.H80)(c),M=(0,C.useMemo)(()=>(function(e,t){let{maxImageDimension:n,acceptedImageMimeTypes:r,acceptedVideoMimeTypes:i}=t,o=void 0!==n||void 0!==r,s=void 0!==i;return o||s?e.map(e=>o&&"image"===e.type?e.configure({...void 0!==n&&{maxDimension:n},...void 0!==r&&{supportedMimeTypes:r}}):s&&"video"===e.type?e.configure({...void 0!==i&&{supportedMimeTypes:i}}):e):e})((0,h.OgJ)("type",_,vA),{maxImageDimension:n,acceptedImageMimeTypes:i,acceptedVideoMimeTypes:o}),[_,n,i,o]),A=(0,h.H80)(u),O=(0,C.useMemo)(()=>(0,h.OgJ)("type",A,vO),[A]),D=(0,h.H80)(p),L=(0,C.useMemo)(()=>(0,h.OgJ)("id",D,Pg),[D]),F=(0,h.H80)(i??h.RBp),R=(0,h.H80)(o??h.qSO),z=g?.text??y,$=(0,C.useMemo)(()=>({addFontsFromNode:r8,...z,tipTapConfig:{extensions:rQ,...z?.tipTapConfig}}),[z]),B=(0,C.useMemo)(()=>({...g,text:$}),[g,$]),H=(0,C.useMemo)(()=>[...F,...R],[F,R]),U=Po(x.assetUrls);return T.find(e=>"embed"===e.type)&&f&&Cl.setEmbedDefinitions(f),(0,b.jsx)(j,{assetUrls:Pa(x.assetUrls),children:(0,b.jsx)(N,{overrides:p0(x.overrides),locale:m??x.user?.userPreferences.get().locale??h.TjI.locale,children:(0,b.jsx)(h.O75,{initialState:"select",...x,components:k,shapeUtils:T,bindingUtils:I,assetUtils:M,overlayUtils:O,tools:L,options:B,assetUrls:U,children:(0,b.jsxs)(Pu,{...x,components:k,mediaMimeTypes:H,children:[(0,b.jsx)(Py,{maxImageDimension:n,maxAssetSize:r,acceptedImageMimeTypes:F,acceptedVideoMimeTypes:R,onMount:s}),t]})})})})}function Py({maxImageDimension:e,maxAssetSize:t,acceptedImageMimeTypes:n,acceptedVideoMimeTypes:r,onMount:i}){let o=(0,h.hGv)(),s=pM(),a=$(),l=hn();(0,h.yfR)(()=>{var d;let c,u,p=[];for(let e of(p.push((c=e=>{o.getShapeUtil("embed").resolveAspectRatio(e)},u=o.sideEffects.register({shape:{afterCreate:(e,t)=>{"user"===t&&o.isShapeOfType(e,"embed")&&c(e)},afterChange:(e,t,n)=>{"user"===n&&o.isShapeOfType(t,"embed")&&e.props.url!==t.props.url&&c(t)}},instance:{afterChange:(e,t)=>{e.cameraState!==t.cameraState&&"idle"===t.cameraState&&v6(o)}},instance_page_state:{afterChange:(e,t)=>{if(e.croppingShapeId!==t.croppingShapeId){let n=o.isIn("select.crop");!e.croppingShapeId&&t.croppingShapeId?n||o.setCurrentTool("select.crop.idle"):e.croppingShapeId&&!t.croppingShapeId&&n&&o.setCurrentTool("select.idle")}if(e.editingShapeId!==t.editingShapeId)if(!e.editingShapeId&&t.editingShapeId){if(!o.isIn("select.editing_shape")){let e=o.getEditingShape();e&&"text"===e.type&&o.isInAny("text.pointing","select.resizing")&&o.getInstanceState().isToolLocked?o.setCurrentTool("select.editing_shape",{target:"shape",shape:e,isCreatingTextWhileToolLocked:!0}):o.setCurrentTool("select.editing_shape",{target:"shape",shape:e})}}else e.editingShapeId&&!t.editingShapeId&&o.isIn("select.editing_shape")&&o.setCurrentTool("select.idle")}}}),()=>{u(),v4(o)})),o.fonts.requestFonts(rX),Object.values(o.getThemes())))for(let t of Object.keys(e.fonts)){let n=e.fonts[t];n.faces?.length&&o.fonts.requestFonts(n.faces)}return o.once("edit",()=>l("edit",{source:"unknown"})),d={maxImageDimension:e,maxAssetSize:t,acceptedImageMimeTypes:n,acceptedVideoMimeTypes:r,toasts:s,msg:a},o.registerExternalAssetHandler("file",async e=>ii(o,e,d)),o.registerExternalAssetHandler("url",async e=>is(o,e,d)),o.registerExternalContentHandler("svg-text",async e=>ia(o,e)),o.registerExternalContentHandler("embed",e=>(function(e,{point:t,url:n,embed:r}){let i=t??(e.inputs.getShiftKey()?e.inputs.getCurrentPagePoint():e.getViewportPageBounds().center),{width:o,height:s}=r,a=(0,h.n6Y)(),l=(0,h.Y8F)(new h.l2P(i.x-(o||450)/2,i.y-(s||450)/2),e),d={id:a,type:"embed",x:l.x,y:l.y,props:{w:o,h:s,url:n}};e.canCreateShape(d)&&e.createShape(d).select(a)})(o,e)),o.registerExternalContentHandler("files",async e=>il(o,e,d)),o.registerExternalContentHandler("file-replace",async e=>io(o,e,d)),o.registerExternalContentHandler("text",async e=>id(o,e)),o.registerExternalContentHandler("url",async e=>ic(o,e,d)),o.registerExternalContentHandler("tldraw",async e=>iu(o,e)),o.registerExternalContentHandler("excalidraw",async e=>ih(o,e)),p.push(o.store.props.onMount(o)),p.push(i?.(o)),()=>{p.forEach(e=>e?.())}});let{Canvas:d}=(0,h.BSi)(),{ContextMenu:c}=xS();return c?(0,b.jsx)(c,{}):d?(0,b.jsx)(d,{}):null}let Pb={text:{tipTapConfig:{extensions:rQ},addFontsFromNode:r8}};(0,C.memo)(function(e){let[t,n]=(0,C.useState)(null),[r,i]=(0,C.useState)(null),o=(0,h.H80)(e.shapeUtils??[]),s=(0,C.useMemo)(()=>(0,h.OgJ)("type",o,ko),[o]),a=(0,h.H80)(e.bindingUtils??[]),l=(0,C.useMemo)(()=>(0,h.OgJ)("type",a,vj),[a]),d=(0,h.jXu)({snapshot:e.snapshot,shapeUtils:s,assets:e.assets}),{pageId:c,bounds:u,scale:p,pixelRatio:f,background:g,padding:m,darkMode:y,preserveAspectRatio:x,format:w="svg",licenseKey:v,assetUrls:S,options:k,textOptions:P}=e,T=(0,C.useMemo)(()=>({...Pb,...k,text:{...Pb.text,...k?.text??P}}),[k,P]),E=Po(S);return(0,C.useLayoutEffect)(()=>{if(!r||!d)return;let e=!1,t=r.ownerDocument.createElement("div");r.appendChild(t),r.classList.add("tl-container","tl-theme__light");let i=new h.KE6({store:d,shapeUtils:s,bindingUtils:l,tools:[],getContainer:()=>t,licenseKey:v,fontAssetUrls:E.fonts,options:T});c&&i.setCurrentPage(c);let o=i.getCurrentPageShapeIds();return async function(){let t=await i.toImage([...o],{bounds:u,scale:p,background:g,padding:m,darkMode:y,preserveAspectRatio:x,format:w});!t||e||(n(URL.createObjectURL(t.blob)),i.dispose())}(),()=>{e=!0}},[w,r,d,s,l,c,u,p,g,m,y,x,v,f,E,T]),(0,C.useEffect)(()=>()=>{t&&URL.revokeObjectURL(t)},[t]),(0,b.jsx)("div",{ref:i,style:{position:"relative",width:"100%",height:"100%"},children:t&&(0,b.jsx)("img",{src:t,referrerPolicy:"strict-origin-when-cross-origin",style:{width:"100%",height:"100%"}})})}),(0,C.memo)(function({children:e}){let t=$(),n=d$(),r=(0,C.useRef)(null);(0,h.I9L)(r);let i=e??(0,b.jsx)(mu,{});return n<4?null:(0,b.jsx)("div",{ref:r,className:"tlui-help-menu",children:(0,b.jsxs)(hi,{id:"help menu",children:[(0,b.jsx)(ho,{children:(0,b.jsx)(aW,{type:"help",title:t("help-menu.title"),"data-testid":"help-menu.button",children:(0,b.jsx)(dm,{icon:"question-mark",small:!0})})}),(0,b.jsx)(hs,{side:"top",align:"end",alignOffset:0,sideOffset:8,children:(0,b.jsx)(dU,{type:"menu",sourceId:"help-menu",children:i})})]})})});var Px=Object.defineProperty,Pw=(e,t)=>Px(e,"name",{value:t,configurable:!0}),Pv=[" ","Enter","ArrowUp","ArrowDown"],PS="Select",[PC,Pk,PP]=dY(PS),[PT,PE]=iz(PS,[PP,sI]),PI=sI(),[P_,PM]=PT(PS),[PA,Pj]=PT(PS);Pw(function(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:o,value:s,defaultValue:a,onValueChange:l,dir:d,name:c,autoComplete:u,disabled:h,required:p,form:f,internal_do_not_use_render:g}=e,m=PI(t),[y,x]=C.useState(null),[w,v]=C.useState(null),[S,k]=C.useState(!1),P=d6(d),[T,E]=s5({prop:r,defaultProp:i??!1,onChange:o,caller:PS}),[I,_]=s5({prop:s,defaultProp:a,onChange:l,caller:PS}),M=C.useRef(null),A=C.useRef(I);C.useEffect(()=>{let e=f?y?.ownerDocument.getElementById(f):y?.form;if(e instanceof HTMLFormElement){let t=Pw(()=>_(A.current),"reset");return e.addEventListener("reset",t),()=>e.removeEventListener("reset",t)}},[f,y,_]);let j=!y||!!f||!!y.closest("form"),[O,D]=C.useState(new Set),L=of(),F=Array.from(O).map(e=>e.props.value).join(";"),R=C.useCallback(e=>{D(t=>new Set(t).add(e))},[]),z=C.useCallback(e=>{D(t=>{let n=new Set(t);return n.delete(e),n})},[]),N={required:p,trigger:y,onTriggerChange:x,valueNode:w,onValueNodeChange:v,valueNodeHasChildren:S,onValueNodeHasChildrenChange:k,contentId:L,value:I,onValueChange:_,open:T,onOpenChange:E,dir:P,triggerPointerDownPosRef:M,disabled:h,name:c,autoComplete:u,form:f,nativeOptions:O,nativeSelectKey:F,isFormControl:j};return(0,b.jsx)(sA,{...m,children:(0,b.jsx)(P_,{scope:t,...N,children:(0,b.jsx)(PC.Provider,{scope:t,children:(0,b.jsx)(PA,{scope:t,onNativeOptionAdd:R,onNativeOptionRemove:z,children:PV(g)?g(N):n})})})})},"SelectProvider");var PO=C.forwardRef(Pw(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,o=PI(n),s=PM("SelectTrigger",n),a=s.disabled||r,l=iL(t,s.onTriggerChange),d=Pk(n),c=C.useRef("touch"),[u,h,p]=PG(e=>{let t=d().filter(e=>!e.disabled),n=t.find(e=>e.value===s.value),r=Pq(t,e,n);void 0!==r&&s.onValueChange(r.value)}),f=Pw(e=>{a||(s.onOpenChange(!0),p()),e&&(s.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},"handleOpen");return(0,b.jsx)(sj,{asChild:!0,...o,children:(0,b.jsx)(i5.button,{type:"button",role:"combobox","aria-controls":s.open?s.contentId:void 0,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":"none",dir:s.dir,"data-state":s.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":PY(s.value)?"":void 0,...i,ref:l,onClick:iI(i.onClick,e=>{e.currentTarget.focus(),"mouse"!==c.current&&f(e)}),onPointerDown:iI(i.onPointerDown,e=>{c.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(f(e),e.preventDefault())}),onKeyDown:iI(i.onKeyDown,e=>{let t=""!==u.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||h(e.key),(!t||" "!==e.key)&&Pv.includes(e.key)&&(f(),e.preventDefault())})})})},"SelectTrigger")),PD=C.forwardRef(Pw(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,b.jsx)(i5.span,{"aria-hidden":!0,...i,ref:t,children:r||"▼"})},"SelectIcon")),[PL,PF]=PT("SelectPortal",{forceMount:void 0}),PR="SelectContent",[Pz,PN]=PT(PR);iU("SelectContent.RemoveScroll");var[P$,PB]=PT(PR,{}),[PH,PU]=PT("SelectGroup"),[PW,PK]=PT("SelectItem");function PV(e){return"function"==typeof e}function PY(e){return""===e||void 0===e}function PG(e){let t=i4(e),n=C.useRef(""),r=C.useRef(0),i=C.useCallback(e=>{t(n.current+e)},[t]),o=C.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return C.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,o]}function Pq(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,o=PX(e,Math.max(i,0));1===r.length&&(o=o.filter(e=>e!==n));let s=o.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return s!==n?s:void 0}function PX(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Pw(PV,"isFunction"),Pw(PY,"shouldShowPlaceholder"),Pw(PG,"useTypeaheadSearch"),Pw(Pq,"findNextItem"),Pw(PX,"wrapArray"),C.forwardRef(function({children:e,className:t},n){return(0,b.jsxs)(PO,{ref:n,className:ik("tlui-button tlui-select__trigger",t),children:[e,(0,b.jsx)(PD,{className:"tlui-select__chevron",children:(0,b.jsx)(df,{icon:"chevron-down",label:"",small:!0})})]})}),n(13248);let PJ=h.T.object({schemaVersion:h.T.literal(1),storeVersion:h.T.positiveInteger,recordVersions:h.T.dict(h.T.string,h.T.object({version:h.T.positiveInteger,subTypeVersions:h.T.dict(h.T.string,h.T.positiveInteger).optional(),subTypeKey:h.T.string.optional()}))}),PZ=h.T.object({schemaVersion:h.T.literal(2),sequences:h.T.dict(h.T.string,h.T.positiveInteger)});h.T.object({tldrawFileFormatVersion:h.T.nonZeroInteger,schema:h.T.numberUnion("schemaVersion",{1:PJ,2:PZ}),records:h.T.arrayOf(h.T.object({id:h.T.string,typeName:h.T.string}).allowUnknownProperties())}),(0,h.lFJ)("tldraw","5.3.2","esm")},92599:(e,t,n)=>{"use strict";n.d(t,{b:()=>s});var r=n(24167);function i(e,t){if(!t)return!1;switch(e.type){case"mixed":return"mixed"===t.type;case"shared":return"shared"===t.type&&e.value===t.value;default:throw(0,r.h6)(e)}}class o{map;constructor(e){this.map=new Map(e)}get(e){return this.map.get(e)}getAsKnownValue(e){let t=this.get(e);if(t&&"mixed"!==t.type)return t.value}get size(){return this.map.size}equals(e){if(this.size!==e.size)return!1;let t=new Set;for(let[n,r]of this){if(!i(r,e.get(n)))return!1;t.add(n)}for(let[n,r]of e)if(!t.has(n)&&!i(r,this.get(n)))return!1;return!0}keys(){return this.map.keys()}values(){return this.map.values()}entries(){return this.map.entries()}[Symbol.iterator](){return this.map[Symbol.iterator]()}}class s extends o{set(e,t){this.map.set(e,t)}applyValue(e,t){let n=this.get(e);if(!n)return void this.set(e,{type:"shared",value:t});switch(n.type){case"mixed":return;case"shared":n.value!==t&&this.set(e,{type:"mixed"});return;default:(0,r.h6)(n,"type")}}}},93097:(e,t,n)=>{"use strict";n.d(t,{k:()=>s});var r=n(59830),i=n(46195),o=n(31428);class s extends o.d{_x;_y;_w;_h;constructor(e){const{x:t=0,y:n=0,width:r,height:o}=e;super({...e,points:[new i.l(t,n),new i.l(t+r,n),new i.l(t+r,n+o),new i.l(t,n+o)]}),this._x=t,this._y=n,this._w=r,this._h=o}getBounds(){return new r.az(this._x,this._y,this._w,this._h)}getSvgPathData(){let{_x:e,_y:t,_w:n,_h:r}=this;return this.negativeZeroFix(),`M${e},${t} h${n} v${r} h${-n}z`}negativeZeroFix(){this._x=a(this._x),this._y=a(this._y),this._w=a(this._w),this._h=a(this._h)}}function a(e){return Object.is(e,-0)?0:e}},93286:(e,t,n)=>{"use strict";n.d(t,{$C:()=>E,AQ:()=>k,G8:()=>o,IM:()=>y,KM:()=>m,Mg:()=>A,PI:()=>s,QX:()=>u,VM:()=>f,WM:()=>M,YY:()=>h,_B:()=>j,cL:()=>w,dw:()=>d,g6:()=>T,jw:()=>v,nv:()=>C,oj:()=>L,qE:()=>c,qe:()=>b,rT:()=>p,rg:()=>g,rq:()=>D,s3:()=>_,sK:()=>a,tR:()=>S,uA:()=>l,ul:()=>i,yD:()=>x,ye:()=>P,yi:()=>O});var r=n(46195);function i(e){return`${M(e.x)},${M(e.y)} `}function o(e,t){return`${M((e.x+t.x)/2)},${M((e.y+t.y)/2)} `}let s=Math.PI,a=s/2,l=2*s,d=Math.sin;function c(e,t,n){return Math.max(t,void 0!==n?Math.min(e,n):e)}function u(e,t=1e10){return e?Math.round(e*t)/t:0}function h(e,t,n=1e-6){return Math.abs(e-t)<=n}function p(e,t,n=1e-6){return e<t||h(e,t,n)}function f(e,t){let n=Math.pow(e-t,2)/Math.pow(e+t,2);return s*(e+t)*(1+3*n/(10+Math.sqrt(4-3*n)))}function g(e){return(e%=l)<0?e+=l:0===e&&(e=0),e}function m(e,t){return(e=g(e))>(t=g(t))&&(t+=l),t-e}function y(e,t){return l-m(e,t)}function b(e,t){let n=(t-e)%l;return 2*n%l-n}function x(e){return(l+e)%l}function w(e,t){let n=l/t,r=Math.floor((x(e)+n/2)/n)*n%l;return r<s&&(r+=l),r>s&&(r-=l),r}function v(e,t){return e===t||h(e%(Math.PI/2)-t%(Math.PI/2),0)}function S(e){return e*s/180}function C(e){return 180*e/s}function k(e,t,n){return new r.l(e.x,e.y).add(r.l.FromAngle(n,t))}function P(e,t,n){let i=e/2,o=t/2,s=[],d=1/0,c=-1/0,u=1/0,h=-1/0;for(let e=0;e<n;e++){let t=-a+l/n*e,p=i+i*Math.cos(t),f=o+o*Math.sin(t);p<d&&(d=p),f<u&&(u=f),p>c&&(c=p),f>h&&(h=f),s.push(new r.l(p,f))}let p=c-d,f=h-u;if(0!=e-p||0!=t-f)for(let n=0;n<s.length;n++){let r=s[n];r.x=(r.x-d)/p*e,r.y=(r.y-u)/f*t}return s}function T(e,t,n,r){return e<r&&n<t}function E(e,t,n,r){let i=Math.max(e,n),o=Math.min(t,r);return i<=o?[i,o]:null}function I(e,t,n){return(t.x-e.x)*(n.y-e.y)-(n.x-e.x)*(t.y-e.y)}function _(e,t){let n,r,i=0;for(let o=0;o<t.length;o++){if((n=t[o]).x===e.x&&n.y===e.y)return!0;r=t[(o+1)%t.length],n.y<=e.y?r.y>e.y&&I(n,r,e)>0&&(i+=1):r.y<=e.y&&0>I(n,r,e)&&(i-=1)}return 0!==i}function M(e){return Math.round(1e4*e)/1e4}function A(e){return Math.round(100*e)/100}function j(e){return Math.abs(e)<Number.MAX_SAFE_INTEGER}function O(e,t,n,r){let i;if(Math.abs(e)>s){i=b(t,r);let o=b(r,n);return Math.abs(i)<Math.abs(o)?i/e:(e-o)/e}{let n=(i=b(t,r))/e;return Math.sign(i)!==Math.sign(e)?+(Math.abs(n)>.5):n}}function D(e,t,n,r){let i=(t-e)%l*2%l-(t-e)%l;return r?(l-Math.abs(i))*(n?1:-1):i}function L(e,t,n){let i=-2*(e.x*(t.y-n.y)-e.y*(t.x-n.x)+t.x*n.y-n.x*t.y),o=((e.x*e.x+e.y*e.y)*(n.y-t.y)+(t.x*t.x+t.y*t.y)*(e.y-n.y)+(n.x*n.x+n.y*n.y)*(t.y-e.y))/i,s=((e.x*e.x+e.y*e.y)*(t.x-n.x)+(t.x*t.x+t.y*t.y)*(n.x-e.x)+(n.x*n.x+n.y*n.y)*(e.x-t.x))/i;return Number.isFinite(o)&&Number.isFinite(s)?new r.l(o,s):null}},93647:(e,t,n)=>{"use strict";let r,i,o,s;n.d(t,{xGO:()=>nt,srS:()=>u.sr,roz:()=>u.ro,qfG:()=>u.qf,Kx3:()=>u.Kx,$mH:()=>eZ,QVi:()=>tl,A8:()=>e6,B$v:()=>e4,mbh:()=>eQ,azJ:()=>t4.az,PUi:()=>nn,iON:()=>ni,RBp:()=>a.RB,qSO:()=>a.qS,sdu:()=>u.sd,ive:()=>u.iv,Pe6:()=>u.Pe,u8f:()=>u.u8,yes:()=>u.ye,yMj:()=>u.yM,Sg3:()=>u.Sg,z6X:()=>ej,nM1:()=>u.nM,YUb:()=>u.YU,Z4H:()=>t8.Z,Mlv:()=>l.Ml,AoN:()=>no.A,KE6:()=>ez.K,bZT:()=>nI,pPP:()=>ns,SmQ:()=>a.Sm,tg8:()=>u.tg,vqJ:()=>ne.vq,MI8:()=>ne.MI,IQE:()=>U.I,sKG:()=>O.sK,hDc:()=>eL,_V3:()=>a._V,Yjb:()=>u.Yj,eBK:()=>u.eB,xxw:()=>nT,Qnm:()=>a.Qn,V8r:()=>nl.V,K4L:()=>a.K4,bU:()=>e7,PI:()=>O.PI,uAR:()=>O.uA,tvM:()=>u.tv,dxv:()=>na.d,Hes:()=>nr.H,krb:()=>e2.k,Q7C:()=>a.Q7,BV:()=>eJ.BV,dwc:()=>O.dw,ULM:()=>eF.U,inY:()=>e3.i,bDP:()=>nF.b,YM5:()=>ti.Y,T:()=>h.T,O75:()=>nx,xXO:()=>eW.xX,l2P:()=>I.l,laH:()=>a.l,as9:()=>a.as,ghB:()=>x.gh,_Bx:()=>nL._,YY0:()=>O.YY,jwY:()=>O.jw,g8l:()=>u.g8,P_i:()=>u.P_,udf:()=>u.ud,FXh:()=>u.FX,vAR:()=>a.vA,Z1O:()=>a.Z1,eUv:()=>l.eU,K6A:()=>u.K6,oIE:()=>a.oI,Esp:()=>u.Es,VtT:()=>u.Vt,hNn:()=>u.hN,aWX:()=>u.aW,rgm:()=>O.rg,oj6:()=>O.oj,qE8:()=>O.qE,KMq:()=>O.KM,oE7:()=>a.oE,EWP:()=>l.EW,IM4:()=>O.IM,BNi:()=>u.BN,uYT:()=>c.uY,n6Y:()=>u.n6,sg1:()=>a.sg,bGJ:()=>j.bG,TjI:()=>eW.Tj,tRv:()=>O.tR,deR:()=>u.de,KBL:()=>u.KB,oOb:()=>x.oO,upp:()=>u.up,Pwo:()=>u.Pw,h6G:()=>a.h6,ofH:()=>j.of,hdJ:()=>a.hd,SpZ:()=>u.Sp,X24:()=>u.X2,s4L:()=>u.s4,X8F:()=>u.X8,Xzd:()=>a.Xz,FHQ:()=>e1.F,H__:()=>t$.H,C$h:()=>a.C$,EYW:()=>nD,zMQ:()=>a.zM,jLo:()=>x.jL,CMG:()=>x.CM,Gwq:()=>a.Gw,xpx:()=>a.xp,AQy:()=>a.AQ,SBu:()=>a.SB,HEt:()=>a.HE,uud:()=>a.uu,MTM:()=>a.MT,tjK:()=>e9,g50:()=>a.g5,mDw:()=>M.mD,EK8:()=>tn.E,AQe:()=>O.AQ,yGT:()=>C,yeN:()=>O.ye,fHb:()=>nL.f,JDT:()=>n_,qnK:()=>t7,W$r:()=>eE,REO:()=>u.RE,M60:()=>u.M6,h1I:()=>u.h1,_8g:()=>u._8,UcL:()=>u.Uc,lXb:()=>u.lX,OpZ:()=>t9.Op,vrM:()=>t9.vr,lqI:()=>t9.lq,Fg_:()=>a.Fg,gu7:()=>w.g,KHk:()=>F,O9V:()=>a.O9,n4T:()=>a.n4,Ao2:()=>a.Ao,GYP:()=>u.GY,xhT:()=>u.xh,_Bd:()=>O._B,vc4:()=>u.vc,IeP:()=>nM.I,HVh:()=>a.HV,CcK:()=>a.Cc,bT0:()=>u.bT,e9l:()=>u.e9,_Hz:()=>a._H,Y8F:()=>ta,OgJ:()=>a.Og,wql:()=>a.wq,wwY:()=>a.ww,lQ1:()=>a.lQ,jaC:()=>_,fq3:()=>u.fq,SWg:()=>u.SW,iAN:()=>a.iA,_ed:()=>a._e,w$g:()=>a.w$,Ics:()=>a.Ic,D1x:()=>eT,s3y:()=>O.s3,Rx2:()=>t9.Rx,woC:()=>x.wo,$Cz:()=>O.$C,wvh:()=>l.wv,lFJ:()=>a.lF,hPm:()=>x.hP,mfH:()=>e5,d5$:()=>tr,OVI:()=>e0.O,eHF:()=>u.eH,She:()=>a.Sh,Wj6:()=>t4.Wj,yCG:()=>a.yC,ni0:()=>L.ni,Yz5:()=>a.Yz,YYG:()=>x.YY,qer:()=>O.qe,cL9:()=>O.cL,Ky:()=>a.Ky,APM:()=>tt,pN9:()=>a.pN,oX2:()=>L.oX,E4k:()=>u.E4,xjg:()=>u.xj,nFR:()=>a.nF,YZA:()=>y.Y,$Gt:()=>y.$,NlK:()=>tc.N,slq:()=>tu.s,WMC:()=>O.WM,Mg8:()=>O.Mg,TP3:()=>u.TP,u4I:()=>d.u4,hLc:()=>l.hL,sbv:()=>tL,NF7:()=>a.NF,PmD:()=>l.Pm,fpl:()=>d.fp,G67:()=>th,NFA:()=>T.NF,lsV:()=>td.ls,hGv:()=>k.hG,BSi:()=>b.B,_q_:()=>tk._,ofB:()=>tP,_As:()=>tT,VKK:()=>t6,frr:()=>k.fr,YgL:()=>t0,yfR:()=>nE,I9L:()=>tD,oKA:()=>tF,xQ_:()=>tR,lXS:()=>d.lX,a1r:()=>d.a1,H80:()=>tS.H,dSk:()=>tS.d,Xhk:()=>L.Xh,Jf5:()=>td.Jf,jXu:()=>tz,LsA:()=>L.Ls,hau:()=>d.h,jhO:()=>u.jh,EOG:()=>u.EO,w9f:()=>u.w9,ZMy:()=>u.ZM,mcG:()=>a.mc});var a=n(24167),l=n(83102),d=n(27394),c=n(54530),u=n(81467),h=n(22690),p=n(95155);function f(){return(0,p.jsx)("div",{className:"tl-background"})}var g=n(69730),m=n(12115),y=n(13982),b=n(67877),x=n(16038),w=n(50139);function v(e){return 2===e.button||y.Y.isDarwin&&0===e.button&&e.ctrlKey&&!e.metaKey}function S(e){return v(e)?2:e.button}function C(e,t){return e.markEventAsHandled(t),{point:{x:t.clientX,y:t.clientY,z:t.pressure},shiftKey:t.shiftKey,altKey:t.altKey,ctrlKey:t.metaKey||t.ctrlKey,metaKey:t.metaKey,accelKey:(0,w.g)(t),pointerId:t.pointerId,button:S(t),isPen:"pen"===t.pointerType}}var k=n(67863);function P(){let e=(0,k.hG)(),t=e.getContainerDocument(),n=(0,d.h)("current tool",()=>e.getCurrentTool(),[e]),r=(0,m.useMemo)(function(){let t=!1;return{onPointerDown:function(n){if(e.wasEventAlreadyHandled(n))return;let r=S(n);if(t=2===r,2===r&&!e.options.rightClickPanning)return void e.dispatch({type:"pointer",target:"canvas",name:"right_click",...C(e,n)});if(0!==r&&1!==r&&2!==r&&5!==r)return;let i="pen"===n.pointerType&&y.Y.isTouchDevice;(0,x.YY)(n.currentTarget,n),e.dispatch({type:"pointer",target:"canvas",name:"pointer_down",...C(e,n),isPenDirect:i})},onPointerUp:function(n){if(e.wasEventAlreadyHandled(n))return;let r=t?2:S(n);if(0!==r&&1!==r&&2!==r&&5!==r)return;let i=e.options.rightClickPanning,o=i&&2===r&&e.inputs.getIsPanning();if((0,x.hP)(n.currentTarget,n),e.dispatch({type:"pointer",target:"canvas",name:"pointer_up",...C(e,n),button:r}),i&&2===r&&!o){let e=new PointerEvent("contextmenu",{bubbles:!0,clientX:n.clientX,clientY:n.clientY,button:2,buttons:0,pointerId:n.pointerId,pointerType:n.pointerType,isPrimary:n.isPrimary});n.currentTarget.dispatchEvent(e)}t=!1},onPointerEnter:function(t){if(e.wasEventAlreadyHandled(t)||e.getInstanceState().isPenMode&&"pen"!==t.pointerType)return;let n="mouse"===t.pointerType||"pen"===t.pointerType;e.updateInstanceState({isHoveringCanvas:!!n||null})},onPointerLeave:function(t){if(e.wasEventAlreadyHandled(t)||e.getInstanceState().isPenMode&&"pen"!==t.pointerType)return;let n="mouse"===t.pointerType||"pen"===t.pointerType;e.updateInstanceState({isHoveringCanvas:!n&&null})},onDragOver:function(t){e.wasEventAlreadyHandled(t)||(0,x.wo)(t)},onDrop:async function t(t){if(e.wasEventAlreadyHandled(t))return;(0,x.wo)(t),t.stopPropagation();let n=e.screenToPage({x:t.clientX,y:t.clientY});if(e.options.experimental__onDropOnCanvas&&e.options.experimental__onDropOnCanvas({point:n,event:t}))return;if(t.dataTransfer?.files?.length){let r=Array.from(t.dataTransfer.files);await e.putExternalContent({type:"files",files:r,point:n});return}let r=t.dataTransfer.getData("url");if(r)return void await e.putExternalContent({type:"url",url:r,point:n})},onTouchStart:function(t){e.wasEventAlreadyHandled(t)||(e.markEventAsHandled(t),(0,x.wo)(t))},onTouchEnd:function(t){if(e.wasEventAlreadyHandled(t)||(e.markEventAsHandled(t),!(t.target instanceof e.getContainerWindow().HTMLElement)))return;let n=e.getEditingShapeId();n&&t.target.closest(`[data-shape-id="${n}"]`)||"A"===t.target.tagName||(0,x.oO)(t.target,!1)||(0,x.wo)(t)},onClick:function(t){e.wasEventAlreadyHandled(t)||t.stopPropagation()},onContextMenu:function(t){e.options.rightClickPanning&&t.nativeEvent.isTrusted&&v(t)&&(0,x.wo)(t)}}},[e]);return(0,m.useEffect)(()=>{let r,i;function o(t){if(!e.wasEventAlreadyHandled(t)){if(e.markEventAsHandled(t),t.clientX!==r||t.clientY!==i)for(let o of(r=t.clientX,i=t.clientY,!y.Y.isIos&&n.useCoalescedEvents&&t.getCoalescedEvents?t.getCoalescedEvents():[t]))e.dispatch({type:"pointer",target:"canvas",name:"pointer_move",...C(e,o)})}}return t.body.addEventListener("pointermove",o),()=>{t.body.removeEventListener("pointermove",o)}},[e,n,t]),r}var T=n(87767);function E(e){return e.menus.hasOpenMenus()||(0,x.gh)(!0,e.getContainerDocument())}var I=n(46195);function _(e){let{deltaY:t,deltaX:n}=e,r=0;return e.ctrlKey||e.altKey||e.metaKey?r=(Math.abs(t)>10?10*Math.sign(t):t)/100:!e.shiftKey||y.Y.isDarwin||y.Y.isIos||(n=t,t=0),{x:-n,y:-t,z:-r}}var M=n(48077),A=n(26065),j=n(11421),O=n(93286);function D(e){let{x:t,y:n,z:r}=e.getCamera(),i=r>=1?(0,a.ww)(r,[1,8],[.125,.5],!0):(0,a.ww)(r,[.1,1],[-2,.125],!0);return`scale(${(0,O.WM)(r)}) translate(${(0,O.WM)(t+i)}px,${(0,O.WM)(n+i)}px)`}var L=n(73352);function F(e,t,n){return!(e.x<t.minX-12/n||e.y<t.minY-16/n||e.x>t.maxX-12/n||e.y>t.maxY-16/n)}let R=(0,d.u4)(function(){let e=(0,k.hG)(),{CollaboratorCursor:t}=(0,b.B)(),n=(0,m.useRef)(null);(0,m.useLayoutEffect)(()=>{let t=n.current;t&&(0,x.$h)(t,"transform",D(e))}),(0,d.lX)("position collaborators layer",function(){let t=D(e);(0,x.$h)(n.current,"transform",t)},[e]);let r=e.getVisibleCollaboratorsOnCurrentPage();return 0!==r.length&&t?(0,p.jsxs)("div",{className:"tl-collaborators",children:[(0,p.jsx)("svg",{className:"tl-svg-context","aria-hidden":"true",children:(0,p.jsx)("defs",{children:(0,p.jsx)(N,{})})}),(0,p.jsx)("div",{ref:n,className:"tl-html-layer",children:r.map(e=>(0,p.jsx)(z,{latestPresence:e},e.userId))})]}):null}),z=(0,d.u4)(function({latestPresence:e}){let t=(0,k.hG)(),{CollaboratorCursor:n}=(0,b.B)(),{userId:r,chatMessage:i,userName:o,cursor:s,color:a}=e,l=(0,d.h)("cursor in viewport",()=>!!s&&F(s,t.getViewportPageBounds(),t.getZoomLevel()),[t,s]),c=t.getZoomLevel();return s&&l&&n?(0,p.jsx)(n,{className:"tl-collaborator__cursor",userId:r,point:s,color:a,zoom:c,name:"New User"!==o?o:null,chatMessage:i??""}):null});function N(){return(0,p.jsxs)("g",{id:(0,L.Xh)("cursor"),children:[(0,p.jsxs)("g",{fill:"rgba(0,0,0,.2)",transform:"translate(-11,-11)",children:[(0,p.jsx)("path",{d:"m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z"}),(0,p.jsx)("path",{d:"m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z"})]}),(0,p.jsxs)("g",{fill:"white",transform:"translate(-12,-12)",children:[(0,p.jsx)("path",{d:"m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z"}),(0,p.jsx)("path",{d:"m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z"})]}),(0,p.jsxs)("g",{fill:"currentColor",transform:"translate(-12,-12)",children:[(0,p.jsx)("path",{d:"m19.751 24.4155-1.844.774-3.1-7.374 1.841-.775z"}),(0,p.jsx)("path",{d:"m13 10.814v11.188l2.969-2.866.428-.139h4.768z"})]})]})}var $=n(47650);function B(){let e=(0,k.hG)(),t=(0,d.h)("is menu open",()=>e.menus.hasAnyOpenMenus(),[e]),[n,r]=(0,m.useState)(!1),i=P(),o=(0,m.useRef)({isDown:!1,isDragging:!1,button:0,start:new I.l}),s=(0,m.useRef)(null);(0,m.useEffect)(()=>()=>{s.current?.(),s.current=null},[]);let a=(0,m.useCallback)(()=>{s.current?.();let t=e.getContainerDocument(),n=e=>{e.isTrusted&&(s.current?.(),s.current=null,e.preventDefault(),e.stopImmediatePropagation())},r=()=>t.removeEventListener("contextmenu",n,!0);s.current=r,t.addEventListener("contextmenu",n,!0),t.defaultView?.setTimeout(()=>{s.current===r&&(r(),s.current=null)},0)},[e]),l=(0,m.useCallback)(t=>{let n=S(t);if(0===n||2===n){if((0,$.flushSync)(()=>r(!0)),(0,x.YY)(t.currentTarget,t),o.current={isDown:!0,isDragging:!1,button:n,start:new I.l(t.clientX,t.clientY)},2===n){if(!e.options.rightClickPanning){a(),e.menus.clearOpenMenus();return}let n=e.getContainer().querySelector(".tl-canvas")??t.currentTarget;i.onPointerDown?.({...t,currentTarget:n}),a();return}e.menus.clearOpenMenus()}},[i,e,a]),c=(0,m.useCallback)(t=>{let n=o.current;if(n.isDown){if(2!==n.button&&!n.isDragging){if(I.l.Dist2(n.start,new I.l(t.clientX,t.clientY))<=e.options.dragDistanceSquared)return;n.isDragging=!0,e.dispatch({type:"pointer",target:"canvas",name:"pointer_down",...C(e,{...t,clientX:n.start.x,clientY:n.start.y})})}e.dispatch({type:"pointer",target:"canvas",name:"pointer_move",...C(e,t)})}},[e]),u=(0,m.useCallback)(t=>{let n=2===o.current.button&&!o.current.isDragging;if(e.dispatch({type:"pointer",target:"canvas",name:"pointer_up",...C(e,t),button:2===o.current.button?2:S(t)}),n&&e.options.rightClickPanning){let n=e.getContainer().querySelector(".tl-canvas"),r=n?.parentElement??t.currentTarget;e.timers.requestAnimationFrame(()=>{r.dispatchEvent(new PointerEvent("contextmenu",{bubbles:!0,clientX:t.clientX,clientY:t.clientY,button:2,buttons:0,pointerId:t.pointerId,pointerType:t.pointerType,isPrimary:t.isPrimary}))})}(0,x.hP)(t.currentTarget,t),r(!1),o.current={isDown:!1,isDragging:!1,button:0,start:new I.l(t.clientX,t.clientY)}},[e]);return(t||n)&&(0,p.jsx)("div",{className:"tlui-menu-click-capture","data-testid":"menu-click-capture.content",...i,onPointerDown:l,onPointerMove:c,onPointerUp:u,onContextMenu:e=>{e.preventDefault(),e.stopPropagation()}})}var H=n(22036),U=n(75567);let W=(0,m.memo)(function(){let e=(0,k.hG)(),t=(0,m.useRef)(null);return(0,m.useEffect)(()=>{let n=(0,l.EW)("canvas overlays render inputs",()=>{let t=e.getInstanceState(),n=e.getCamera();return{dpr:t.devicePixelRatio,w:t.screenBounds.w,h:t.screenBounds.h,cx:n.x,cy:n.y,zoom:n.z}},{isEqual:(e,t)=>e.dpr===t.dpr&&e.w===t.w&&e.h===t.h&&e.cx===t.cx&&e.cy===t.cy&&e.zoom===t.zoom}),r=new l.VM("canvas overlays render",()=>{let r=t.current;if(!r)return;let i=r.getContext("2d");if(!i)return;let{dpr:o,w:s,h:a,cx:l,cy:d,zoom:c}=n.get(),u=Math.ceil(s*o),h=Math.ceil(a*o);(r.width!==u||r.height!==h)&&(r.width=u,r.height=h,r.style.width=`${s}px`,r.style.height=`${a}px`),i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,r.width,r.height);let p=o*c;for(let{util:t,overlays:n}of(i.setTransform(p,0,0,p,p*l,p*d),e.overlays.getActiveOverlayEntries()))i.save(),t.render(i,n),i.restore();if(j.bG.debugGeometry.get()){let t=e.inputs.getCurrentPagePoint();for(let n of e.getRenderingShapes()){let r=e.getShape(n.id);if(!r||"group"===r.type)continue;let o=e.getShapeGeometry(r),s=e.getShapePageTransform(r);if(!s)continue;i.save(),i.transform(s.a,s.b,s.c,s.d,s.e,s.f),i.strokeStyle=o.debugColor??"red",i.lineWidth=2/c,i.fillStyle="none",function e(t,n){if(n instanceof U.I){let r=t.strokeStyle;for(let i of n.children)i.debugColor&&(t.strokeStyle=i.debugColor),e(t,i),t.strokeStyle=r;for(let i of n.ignoredChildren)i.debugColor&&(t.strokeStyle=i.debugColor),e(t,i),t.strokeStyle=r;return}let r=n.vertices;if(!(r.length<2)){t.beginPath(),t.moveTo(r[0].x,r[0].y);for(let e=1;e<r.length;e++)t.lineTo(r[e].x,r[e].y);n.isClosed&&t.closePath(),t.stroke()}}(i,o);let{vertices:a}=o;for(let e=0;e<a.length;e++){let t=a[e],n=a.length>1?120+80*e/(a.length-1):160;i.fillStyle=`hsl(${n}, 100%, 50%)`,i.strokeStyle="black",i.lineWidth=1/c,i.beginPath(),i.arc(t.x,t.y,2/c,0,2*Math.PI),i.fill(),i.stroke()}let l=e.getPointInShapeSpace(r,t),d=Math.abs(o.distanceToPoint(l,!0))*c;if(d<150){let e=o.nearestPoint(l);i.strokeStyle=0>o.distanceToPoint(l,!0)?"goldenrod":"dodgerblue",i.lineWidth=2/c,i.globalAlpha=1-d/150,i.beginPath(),i.moveTo(e.x,e.y),i.lineTo(l.x,l.y),i.stroke(),i.globalAlpha=1}i.restore()}for(let{overlays:t}of(i.save(),i.strokeStyle="magenta",i.fillStyle="rgba(255, 0, 255, 0.1)",i.lineWidth=1/c,e.overlays.getActiveOverlayEntries()))for(let n of t){let t=e.overlays.getOverlayGeometry(n);if(!t)continue;let r=t.vertices;if(!(r.length<2)){i.beginPath(),i.moveTo(r[0].x,r[0].y);for(let e=1;e<r.length;e++)i.lineTo(r[e].x,r[e].y);for(let e of(t.isClosed&&(i.closePath(),i.fill()),i.stroke(),r))i.beginPath(),i.arc(e.x,e.y,2/c,0,2*Math.PI),i.fill()}}i.restore()}});return r.attach(),r.execute(),()=>r.detach()},[e]),(0,p.jsx)("canvas",{ref:t,className:"tl-canvas-overlays"})});function K({className:e}){let t,n,r,i,o,s,c,u,h=(0,k.hG)(),{Background:f,SvgDefs:v}=(0,b.B)(),S=(0,m.useRef)(null),C=(0,m.useRef)(null),A=(0,T.NF)();t=(0,k.hG)(),(0,m.useLayoutEffect)(()=>{let e=(0,a.nF)(()=>{!S.current||S.current.ownerDocument.body&&t.updateViewportScreenBounds(S.current)},200,{trailing:!0}),n=t.timers.setInterval(e,1e3),r=t.getContainerWindow();r.addEventListener("resize",e);let i=new ResizeObserver(t=>{t[0].contentRect&&e()}),o=S.current,s=null;return o&&(i.observe(o),(s=(e=>{let t=e.ownerDocument,n=(0,M.mD)(e),r=e.parentElement;for(;r&&r!==t.body;){let{overflowY:e}=n.getComputedStyle(r);if(r.scrollHeight>r.clientHeight&&("auto"===e||"scroll"===e||"overlay"===e))return r;r=r.parentElement}return t})(o)).addEventListener("scroll",e)),()=>{clearInterval(n),r.removeEventListener("resize",e),i.disconnect(),s?.removeEventListener("scroll",e),e.cancel()}},[t,S]),n=(0,k.hG)(),r=(0,T.NF)(),i=(0,d.h)("isEditing",()=>n.getEditingShapeId(),[n]),o=(0,d.h)("isFocused",()=>n.getIsFocused(),[n]),(0,m.useEffect)(()=>{if(r)return r.addEventListener("dragover",e),r.addEventListener("drop",e),()=>{r.removeEventListener("dragover",e),r.removeEventListener("drop",e)};function e(e){if(e.isSpecialRedispatchedEvent)return;(0,x.wo)(e),e.stopPropagation();let t=r.querySelector(".tl-canvas");if(!t)return;let n=new DragEvent(e.type,e);n.isSpecialRedispatchedEvent=!0,t.dispatchEvent(n)}},[r]),(0,m.useEffect)(()=>{let e=n.getContainerWindow();if(!("matchMedia"in e))return;let t=null,r=()=>{null!=t&&t();let i=`(resolution: ${e.devicePixelRatio}dppx)`,o=e.matchMedia(i),s=e=>{"change"===e.type&&r()};o.addEventListener?o.addEventListener("change",r):o.addListener&&o.addListener(s),t=()=>{o.removeEventListener?o.removeEventListener("change",r):o.removeListener&&o.removeListener(s)},n.updateInstanceState({devicePixelRatio:e.devicePixelRatio})};return r(),()=>{t?.()}},[n]),(0,m.useEffect)(()=>{if(!o)return;let e=e=>{if(e.altKey&&(n.isIn("zoom")||!n.getPath().endsWith(".idle"))&&!E(n)&&(0,x.wo)(e),n.wasEventAlreadyHandled(e))return;n.markEventAsHandled(e);let t=!!n.getSelectedShapeIds().length;switch(e.key){case"=":case"-":case"0":if(e.metaKey||e.ctrlKey)return void(0,x.wo)(e);break;case"Tab":if(E(n))return;t&&!i&&(0,x.wo)(e);break;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":if(E(n))return;t&&(e.metaKey||e.ctrlKey)&&(0,x.wo)(e);break;case",":return;case"Escape":if((n.getEditingShape()||n.getSelectedShapeIds().length>0)&&(0,x.wo)(e),n.menus.getOpenMenus().length>0)return;n.inputs.keys.has("Escape")||(n.inputs.keys.add("Escape"),n.cancel(),r.focus());return;default:if(E(n))return}let o={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,metaKey:e.metaKey,accelKey:(0,w.g)(e)};n.dispatch(o)},t=e=>{if(n.wasEventAlreadyHandled(e)||(n.markEventAsHandled(e),E(n)||","===e.key))return;let t={type:"keyboard",name:"key_up",key:e.key,code:e.code,shiftKey:e.shiftKey,altKey:e.altKey,ctrlKey:e.metaKey||e.ctrlKey,metaKey:e.metaKey,accelKey:(0,w.g)(e)};n.dispatch(t)};function s(e){if(r.contains(e.target)){let t=e.touches[0].clientX,r=e.touches[0].radiusX||0,i=n.getContainerWindow().innerWidth;(t-r<10||t+r>i-10)&&(e.target?.tagName==="BUTTON"&&e.target?.click(),(0,x.wo)(e))}}let a=e=>{r.contains(e.target)&&(e.ctrlKey||e.metaKey)&&(0,x.wo)(e)};r.addEventListener("touchstart",s,{passive:!1}),r.addEventListener("wheel",a,{passive:!1});let l=r.ownerDocument;return l.addEventListener("gesturestart",x.wo),l.addEventListener("gesturechange",x.wo),l.addEventListener("gestureend",x.wo),r.addEventListener("keydown",e),r.addEventListener("keyup",t),()=>{r.removeEventListener("touchstart",s),r.removeEventListener("wheel",a),l.removeEventListener("gesturestart",x.wo),l.removeEventListener("gesturechange",x.wo),l.removeEventListener("gestureend",x.wo),r.removeEventListener("keydown",e),r.removeEventListener("keyup",t)}},[n,r,o,i]),s=(0,k.hG)(),(0,d.a1)("coarse pointer change",()=>{let e=y.$.get().isCoarsePointer;e!==(0,l.Pm)(()=>s.getInstanceState().isCoarsePointer)&&s.updateInstanceState({isCoarsePointer:e})},[s]),c=(0,k.hG)(),m.useEffect(()=>{let e=S.current;if(!e)return;let t="not sure";function n(e){if(!c.getInstanceState().isFocused)return;t="not sure";let n=c.getEditingShapeId();if(n){let e=c.getShape(n);if(e&&c.getShapeUtil(e).canScroll(e)){let e=c.getShapePageBounds(n);if(e?.containsPoint(c.inputs.getCurrentPagePoint()))return}}(0,x.wo)(e),e.stopPropagation();let r=_(e);if(0===r.x&&0===r.y)return;let i={type:"wheel",name:"wheel",delta:r,point:new I.l(e.clientX,e.clientY),shiftKey:e.shiftKey,altKey:e.altKey,ctrlKey:e.metaKey||e.ctrlKey,metaKey:e.metaKey,accelKey:(0,w.g)(e)};c.dispatch(i)}let r=1,i=1,o=0,s=new I.l,a=new I.l,l=[];function d(){let e=c.getBaseZoom(),{zoomSteps:t,zoomSpeed:n}=c.getCameraOptions(),r=t[0]*e,i=t[t.length-1]*e;return{min:r**(1/n),max:i**(1/n)}}function u(){let{zoomSpeed:e}=c.getCameraOptions();return c.getZoomLevel()**(1/e)}let h=1,p=1;function f(e){if(e&&(t="zooming"),"zooming"===t)return;let n=Math.abs(o-r),i=I.l.Dist(s,a);switch(t){case"not sure":n>24?t="zooming":i>16&&(t="panning");break;case"panning":n>64&&(t="zooming")}}function g(e,t,n,r,i){c.dispatch({type:"pinch",name:e,point:{x:t.x,y:t.y,z:r},delta:n,shiftKey:i.shiftKey,altKey:i.altKey,ctrlKey:i.metaKey||i.ctrlKey,metaKey:i.metaKey,accelKey:(0,w.g)(i)})}function m(e,t){return{origin:{x:(e.clientX+t.clientX)/2,y:(e.clientY+t.clientY)/2},distance:Math.hypot(t.clientX-e.clientX,t.clientY-e.clientY)}}function b(n){if((n.target===e||e?.contains(n.target))&&2===(l=Array.from(n.touches)).length){t="not sure";let{origin:e,distance:d}=m(l[0],l[1]);a.x=e.x,a.y=e.y,s.x=e.x,s.y=e.y,r=Math.max(d,1),o=d,i=c.getZoomLevel(),h=p=u(),g("pinch_start",e,{x:0,y:0},c.getZoomLevel(),n)}}function v(e){if((l=Array.from(e.touches)).length<2)return;let{origin:n,distance:s}=m(l[0],l[1]);o=s;let u=n.x-a.x,y=n.y-a.y;a.x=n.x,a.y=n.y,f(!1);let b=d(),x=s/r*p;switch(h=Math.min(b.max,Math.max(b.min,x)),t){case"zooming":g("pinch",n,{x:u,y:y},h**c.getCameraOptions().zoomSpeed,e);break;case"panning":g("pinch",n,{x:u,y:y},i,e)}}function C(e){let n=l.length>=2;if(l=Array.from(e.touches),n&&l.length<2){let n=h**c.getCameraOptions().zoomSpeed,r={...a};t="not sure",c.timers.requestAnimationFrame(()=>{g("pinch_end",r,{x:r.x,y:r.y},n,e)})}}let k=1;function P(n){(n.target===e||e?.contains(n.target))&&((0,x.wo)(n),n.stopPropagation(),t="not sure",h=k=u(),i=c.getZoomLevel(),a.x=n.clientX,a.y=n.clientY,s.x=n.clientX,s.y=n.clientY,r=1,o=1,g("pinch_start",{x:n.clientX,y:n.clientY},{x:0,y:0},c.getZoomLevel(),n))}function T(t){if(!(t.target===e||e?.contains(t.target)))return;(0,x.wo)(t),t.stopPropagation();let n=t.clientX-a.x,i=t.clientY-a.y;a.x=t.clientX,a.y=t.clientY;let s=d(),l=k*t.scale;h=Math.min(s.max,Math.max(s.min,l)),o=t.scale*r,f(!0);let u=h**c.getCameraOptions().zoomSpeed;g("pinch",{x:t.clientX,y:t.clientY},{x:n,y:i},u,t)}function E(n){if(!(n.target===e||e?.contains(n.target)))return;(0,x.wo)(n),n.stopPropagation();let r=h**c.getCameraOptions().zoomSpeed;t="not sure",c.timers.requestAnimationFrame(()=>{g("pinch_end",{x:n.clientX,y:n.clientY},{x:n.clientX,y:n.clientY},r,n)})}e.addEventListener("wheel",n,{passive:!1});let M=!y.Y.isIos&&"GestureEvent"in window;return M?(e.addEventListener("gesturestart",P),e.addEventListener("gesturechange",T),e.addEventListener("gestureend",E)):(e.addEventListener("touchstart",b),e.addEventListener("touchmove",v),e.addEventListener("touchend",C),e.addEventListener("touchcancel",C)),()=>{e.removeEventListener("wheel",n),M?(e.removeEventListener("gesturestart",P),e.removeEventListener("gesturechange",T),e.removeEventListener("gestureend",E)):(e.removeEventListener("touchstart",b),e.removeEventListener("touchmove",v),e.removeEventListener("touchend",C),e.removeEventListener("touchcancel",C))}},[c,S]),u=(0,k.hG)(),(0,m.useEffect)(()=>{let e=S.current;if(!e)return;let t=u.getContainerWindow(),n=e=>{if(e instanceof t.PointerEvent&&"pen"===e.pointerType){u.markEventAsHandled(e);let{target:n}=e;(0,x.oO)(n instanceof t.Element?n:null,!1)||u.isIn("select.editing_shape")||(0,x.wo)(e)}};return e.addEventListener("touchstart",n),e.addEventListener("touchend",n),()=>{e.removeEventListener("touchstart",n),e.removeEventListener("touchend",n)}},[u,S]),(0,d.lX)("update canvas state data attributes",()=>{let e=S.current;e&&(e.setAttribute("data-iseditinganything",null===h.getEditingShapeId()?"false":"true"),e.setAttribute("data-isselectinganything",0===h.getSelectedShapeIds().length?"false":"true"))},[h]);let O=(0,m.useRef)({lodDisableTextOutline:!1,canUpdateTextOutline:!0});(0,d.lX)("set text outline",function(){if(O.current.canUpdateTextOutline)if(y.Y.isSafari)A.style.setProperty("--tl-text-outline","none"),O.current.canUpdateTextOutline=!1;else{let e=h.getEfficientZoomLevel()<h.options.textShadowLod;e!==O.current.lodDisableTextOutline&&A.style.setProperty("--tl-text-outline",e?"none":"var(--tl-text-outline-reference)"),O.current.lodDisableTextOutline=e}},[h,A]),(0,d.lX)("position layers",function(){(0,x.$h)(C.current,"transform",D(h))},[h,A]);let L=P(),F=(0,d.h)("shapeSvgDefs",()=>{let e=new Map;for(let t of(0,a.Ic)(h.shapeUtils)){if(!t)return;for(let{key:n,component:r}of t.getCanvasSvgDefs())e.has(n)||e.set(n,(0,p.jsx)(r,{},n))}return[...e.values()]},[h]),z=(0,d.h)("debug_shapes",()=>j.bG.hideShapes.get(),[j.bG]),N=(0,d.h)("isGridMode",()=>h.getInstanceState().isGridMode,[h]),{Grid:$}=(0,b.B)();return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{ref:S,draggable:!1,className:g("tl-canvas",e),"data-testid":"canvas",...L,children:[(0,p.jsx)("svg",{className:"tl-svg-context","aria-hidden":"true",children:(0,p.jsxs)("defs",{children:[F,v&&(0,p.jsx)(v,{})]})}),f&&(0,p.jsx)("div",{className:"tl-background__wrapper",children:(0,p.jsx)(f,{})}),N&&$&&(0,p.jsx)(Y,{}),(0,p.jsxs)("div",{ref:C,className:"tl-html-layer tl-shapes",draggable:!1,children:[(0,p.jsx)(Z,{}),z?null:(0,p.jsx)(G,{canvasRef:S})]}),(0,p.jsx)(W,{}),(0,p.jsx)(Q,{})]}),(0,p.jsx)(V,{}),(0,p.jsx)(R,{}),(0,p.jsx)(B,{})]})}function V(){let e=(0,k.hG)(),{InFrontOfTheCanvas:t}=(0,b.B)();return t?(0,p.jsx)("div",{className:"tl-canvas__in-front",onPointerDown:e.markEventAsHandled,onPointerUp:e.markEventAsHandled,onTouchStart:e.markEventAsHandled,onTouchEnd:e.markEventAsHandled,children:(0,p.jsx)(t,{})}):null}function Y(){let e=(0,k.hG)(),t=(0,d.h)("gridSize",()=>e.getDocumentSettings().gridSize,[e]),{x:n,y:r,z:i}=(0,d.h)("camera",()=>e.getCamera(),[e]),{Grid:o}=(0,b.B)();return o?(0,p.jsx)(o,{x:n,y:r,z:i,size:t}):null}function G({canvasRef:e}){let t=(0,k.hG)(),n=(0,d.h)("debug svg",()=>j.bG.debugSvg.get(),[j.bG]),r=(0,d.h)("rendering shapes",()=>t.getRenderingShapes(),[t]);return(0,p.jsxs)(A.n,{children:[r.map(e=>n?(0,p.jsxs)(m.Fragment,{children:[(0,p.jsx)(H.yp,{...e}),(0,p.jsx)(J,{id:e.id,mode:"iframe"})]},e.id+"_fragment"):(0,p.jsx)(H.yp,{...e},e.id+"_shape")),(0,p.jsx)(X,{}),y.Y.isSafari&&(0,p.jsx)(q,{canvasRef:e})]})}function q({canvasRef:e}){let t=(0,k.hG)(),n=(0,m.useRef)(new Set);return(0,d.lX)("reflow for culled shapes",()=>{let r=t.getCulledShapes();if(n.current===r)return;n.current=r;let i=e.current;i&&i.offsetHeight},[t,e]),null}function X(){let e=(0,k.hG)(),{updateCulling:t}=(0,A.R)();return(0,d.lX)("update shape culling",()=>{t(e.getCulledShapes())},[e,t]),null}function J({id:e,mode:t}){let n=(0,k.hG)(),[r,i]=(0,m.useState)(null),o=(0,d.h)("is in root",()=>{let t=n.getShape(e);return t?.parentId===n.getCurrentPageId()},[n,e]);return((0,m.useEffect)(()=>{if(!o)return;let t=null,r=(0,l.wv)("shape to svg",async()=>{let r=Math.random();t=r;let o=n.getShape(e),s=10*!(o&&n.isShapeFrameLike(o)),a=n.getShapePageBounds(e);if(!a)return;a=a.clone().expandBy(s);let l=await n.getSvgString([e],{padding:s});t===r&&l&&i({src:`data:image/svg+xml;utf8,${encodeURIComponent(l.svg)}`,bounds:a})});return()=>{t=null,r()}},[n,e,o]),o&&r)?"iframe"===t?(0,p.jsx)("iframe",{src:r.src,width:r.bounds.width,height:r.bounds.height,referrerPolicy:"no-referrer",style:{position:"absolute",top:0,left:0,border:"none",transform:`translate(${r.bounds.x}px, ${r.bounds.maxY+12}px)`,outline:"1px solid black",maxWidth:"none"}}):(0,p.jsx)("img",{src:r.src,width:r.bounds.width,height:r.bounds.height,referrerPolicy:"no-referrer",style:{position:"absolute",top:0,left:0,transform:`translate(${r.bounds.x}px, ${r.bounds.maxY+12}px)`,outline:"1px solid black",maxWidth:"none"}}):null}function Z(){let{OnTheCanvas:e}=(0,b.B)();return e?(0,p.jsx)(e,{}):null}function Q(){let e=(0,k.hG)(),t=(0,d.h)("camera state",()=>e.getCameraState(),[e]);return(0,p.jsx)("div",{className:g("tl-hit-test-blocker",{"tl-hit-test-blocker__hidden":"idle"===t})})}let ee=(0,m.memo)(function({className:e,zoom:t,point:n,color:r,name:i,chatMessage:o}){var s,a,l;let d,c,u=(0,m.useRef)(null);s=n?.x,a=n?.y,l=1/t,d=void 0,c=void 0,(0,m.useLayoutEffect)(()=>{let e=u.current;if(!e||void 0===s)return;let t=`translate(${s}px, ${a}px)`;void 0!==l&&(t+=` scale(${l})`),void 0!==d&&void 0!==c&&(t+=` translate(${d}px, ${c}px)`),e.style.transform=t},[d,c,u,void 0,l,s,a]);let h=(0,L.Xh)("cursor");return n?(0,p.jsxs)("div",{ref:u,className:g("tl-collaborators__item",e),children:[(0,p.jsx)("svg",{className:"tl-cursor","aria-hidden":"true",children:(0,p.jsx)("use",{href:`#${h}`,color:r})}),o?(0,p.jsxs)(p.Fragment,{children:[i&&(0,p.jsx)("div",{className:"tl-nametag-title",style:{color:r},children:i}),(0,p.jsx)("div",{className:"tl-nametag-chat",style:{backgroundColor:r},children:o})]}):i&&(0,p.jsx)("div",{className:"tl-nametag",style:{backgroundColor:r},children:i})]}):null}),et=new WeakMap,en=new WeakMap,er=new WeakMap,ei=new WeakMap,eo=new WeakMap,es={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return en.get(e);if("objectStoreNames"===t)return e.objectStoreNames||er.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return ea(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function ea(e){if(e instanceof IDBRequest){let t;return(t=new Promise((t,n)=>{let r=()=>{e.removeEventListener("success",i),e.removeEventListener("error",o)},i=()=>{t(ea(e.result)),r()},o=()=>{n(e.error),r()};e.addEventListener("success",i),e.addEventListener("error",o)})).then(t=>{t instanceof IDBCursor&&et.set(t,e)}).catch(()=>{}),eo.set(t,e),t}if(ei.has(e))return ei.get(e);let t=function(e){if("function"==typeof e)return e!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(i||(i=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(el(this),t),ea(et.get(this))}:function(...t){return ea(e.apply(el(this),t))}:function(t,...n){let r=e.call(el(this),t,...n);return er.set(r,t.sort?t.sort():[t]),ea(r)};return e instanceof IDBTransaction&&function(e){if(en.has(e))return;let t=new Promise((t,n)=>{let r=()=>{e.removeEventListener("complete",i),e.removeEventListener("error",o),e.removeEventListener("abort",o)},i=()=>{t(),r()},o=()=>{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",i),e.addEventListener("error",o),e.addEventListener("abort",o)});en.set(e,t)}(e),(r||(r=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])).some(t=>e instanceof t)?new Proxy(e,es):e}(e);return t!==e&&(ei.set(e,t),eo.set(t,e)),t}let el=e=>eo.get(e);function ed(e,t,{blocked:n,upgrade:r,blocking:i,terminated:o}={}){let s=indexedDB.open(e,t),a=ea(s);return r&&s.addEventListener("upgradeneeded",e=>{r(ea(s.result),e.oldVersion,e.newVersion,ea(s.transaction),e)}),n&&s.addEventListener("blocked",e=>n(e.oldVersion,e.newVersion,e)),a.then(e=>{o&&e.addEventListener("close",()=>o()),i&&e.addEventListener("versionchange",e=>i(e.oldVersion,e.newVersion,e))}).catch(()=>{}),a}function ec(e,{blocked:t}={}){let n=indexedDB.deleteDatabase(e);return t&&n.addEventListener("blocked",e=>t(e.oldVersion,e)),ea(n).then(()=>void 0)}let eu=["get","getKey","getAll","getAllKeys","count"],eh=["put","add","delete","clear"],ep=new Map;function ef(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&"string"==typeof t))return;if(ep.get(t))return ep.get(t);let n=t.replace(/FromIndex$/,""),r=t!==n,i=eh.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(i||eu.includes(n)))return;let o=async function(e,...t){let o=this.transaction(e,i?"readwrite":"readonly"),s=o.store;return r&&(s=s.index(t.shift())),(await Promise.all([s[n](...t),i&&o.done]))[0]};return ep.set(t,o),o}es={...s=es,get:(e,t,n)=>ef(e,t)||s.get(e,t,n),has:(e,t)=>!!ef(e,t)||s.has(e,t)};let eg="TLDRAW_DB_NAME_INDEX_v2",em="records",ey="schema",eb="session_state",ex="assets";async function ew(e){var t;let n,r="TLDRAW_DOCUMENT_v2"+e;return t=r,(n=new Set(eC())).add(t),(0,a.Yz)(eg,JSON.stringify([...n])),await ed(r,4,{upgrade(e){e.objectStoreNames.contains(em)||e.createObjectStore(em),e.objectStoreNames.contains(ey)||e.createObjectStore(ey),e.objectStoreNames.contains(eb)||e.createObjectStore(eb),e.objectStoreNames.contains(ex)||e.createObjectStore(ex)}})}async function ev(e){let t=window.indexedDB.databases?(await window.indexedDB.databases()).map(e=>e.name):eC(),n="TLDRAW_ASSET_STORE_v1"+e;if(!t.find(e=>e===n))return;let r=await ed(n,1,{upgrade(e){e.objectStoreNames.contains("assets")||e.createObjectStore("assets")}});if(!r.objectStoreNames.contains("assets"))return;let i=r.transaction(["assets"],"readonly"),o=i.objectStore("assets"),s=await o.getAllKeys(),a=await Promise.all(s.map(async e=>[e,await o.get(e)]));await i.done;let l=await ew(e),d=l.transaction([ex],"readwrite"),c=d.objectStore(ex);for(let[e,t]of a)c.put(t,e);await d.done,r.close(),l.close(),await ec(n)}class eS{getDbPromise;isClosed=!1;pendingTransactionSet=new Set;static connectedInstances=new Set;constructor(e){eS.connectedInstances.add(this),this.getDbPromise=(async()=>(await ev(e),await ew(e)))()}getDb(){return this.getDbPromise}pending(){return Promise.allSettled([this.getDbPromise,...this.pendingTransactionSet]).then(a.lQ)}async close(){this.isClosed||(this.isClosed=!0,await this.pending(),(await this.getDb()).close(),eS.connectedInstances.delete(this))}tx(e,t,n){let r=(async()=>{(0,a.vA)(!this.isClosed,"db is closed");let r=(await this.getDb()).transaction(t,e),i=r.done.catch(e=>{if(!this.isClosed)throw e});try{return await n(r)}finally{this.isClosed?r.abort():await i}})();return this.pendingTransactionSet.add(r),r.finally(()=>this.pendingTransactionSet.delete(r)),r}async load({sessionId:e}={}){return await this.tx("readonly",[em,ey,eb],async t=>{let n=t.objectStore(em),r=t.objectStore(ey),i=t.objectStore(eb),o=e?(await i.get(e))?.snapshot:null;if(!o){let e=await i.getAll();o=e.sort((e,t)=>e.updatedAt-t.updatedAt).pop()?.snapshot}return{records:await n.getAll(),schema:await r.get(ey),sessionStateSnapshot:o}})}async storeChanges({schema:e,changes:t,sessionId:n,sessionStateSnapshot:r}){await this.tx("readwrite",[em,ey,eb],async i=>{let o=i.objectStore(em),s=i.objectStore(ey),a=i.objectStore(eb);for(let[e,n]of Object.entries(t.added))await o.put(n,e);for(let[e,n]of Object.values(t.updated))await o.put(n,n.id);for(let e of Object.keys(t.removed))await o.delete(e);s.put(e.serialize(),ey),r&&n?a.put({snapshot:r,updatedAt:Date.now(),id:n},n):(r||n)&&console.error("sessionStateSnapshot and instanceId must be provided together")})}async storeSnapshot({schema:e,snapshot:t,sessionId:n,sessionStateSnapshot:r}){await this.tx("readwrite",[em,ey,eb],async i=>{let o=i.objectStore(em),s=i.objectStore(ey),a=i.objectStore(eb);for(let[e,n]of(await o.clear(),Object.entries(t)))await o.put(n,e);s.put(e.serialize(),ey),r&&n?a.put({snapshot:r,updatedAt:Date.now(),id:n},n):(r||n)&&console.error("sessionStateSnapshot and instanceId must be provided together")})}async pruneSessions(){await this.tx("readwrite",[eb],async e=>{let t=e.objectStore(eb),n=(await t.getAll()).sort((e,t)=>e.updatedAt-t.updatedAt);if(n.length<10)return void await e.done;for(let{id:e}of n.slice(0,n.length-10))await t.delete(e)})}async getAsset(e){return await this.tx("readonly",[ex],async t=>{let n=t.objectStore(ex);return await n.get(e)})}async storeAsset(e,t){await this.tx("readwrite",[ex],async n=>{let r=n.objectStore(ex);await r.put(t,e)})}async removeAssets(e){await this.tx("readwrite",[ex],async t=>{let n=t.objectStore(ex);for(let t of e)await n.delete(t)})}}function eC(){let e=JSON.parse((0,a.zM)(eg)||"[]")??[];return Array.isArray(e)?e:[]}async function ek({shouldReload:e=!0}={}){for(let e of((0,a.D6)(),eS.connectedInstances))await e.close();await Promise.all(eC().map(e=>ec(e))),(0,a.sw)(),e&&window.location.reload()}let eP={openWindow:(e,t,n=!1)=>window.open(e,t,n?"noopener":"noopener noreferrer"),refreshPage(){window.location.reload()},hardReset:async()=>await ek({shouldReload:!0})};function eT(e,t="_blank",n){return eP.openWindow(e,t,n)}function eE(){eP.hardReset()}var eI=n(1015);let e_=function({error:e,editor:t}){let n=(0,m.useRef)(null),[r,i]=(0,m.useState)(!1),[o,s]=(0,m.useState)(!1),[l,c]=(0,m.useState)(!1),u=null;try{u=(0,b.B)().Canvas??null}catch{}let h=e instanceof Error?e.message:String(e),f=e instanceof Error?e.stack:null,y=(0,d.h)("isDarkMode",()=>{try{if(t)return t.user.getIsDarkMode()}catch{}return null},[t]),[w,v]=(0,m.useState)(null);(0,m.useLayoutEffect)(()=>{null!==y&&v(y);let e=n.current?.parentElement,t=!1;for(;e;){if(e.classList.contains("tl-theme__dark")||e.classList.contains("tl-theme__light")){t=!0;break}e=e.parentElement}t?v(null):"u">typeof window&&(0,x.CM)().matchMedia&&v((0,x.CM)().matchMedia("(prefers-color-scheme: dark)").matches)},[y]),(0,m.useEffect)(()=>{if(o){let e=t?.timers.setTimeout(()=>{s(!1)},2e3);return()=>clearTimeout(e)}},[o,t]);let S=async()=>{eE()},C=new URL("https://github.com/tldraw/tldraw/issues/new");return C.searchParams.set("title",h),C.searchParams.set("labels","bug"),C.searchParams.set("body",`Hey, I ran into an error while using tldraw:
|
|
129
|
+
|
|
130
|
+
\`\`\`js
|
|
131
|
+
${f??h}
|
|
132
|
+
\`\`\`
|
|
133
|
+
|
|
134
|
+
My browser: ${navigator.userAgent}`),(0,p.jsxs)("div",{ref:n,className:g("tl-container tl-error-boundary",null===w?"":w?"tl-theme__dark":"tl-theme__light"),children:[(0,p.jsx)("div",{className:"tl-error-boundary__overlay"}),t&&(0,p.jsx)(eI.t,{onError:a.lQ,fallback:()=>null,children:(0,p.jsx)(k.zz,{editor:t,children:(0,p.jsx)("div",{className:"tl-overlay tl-error-boundary__canvas",children:u?(0,p.jsx)(u,{}):null})})}),(0,p.jsx)("div",{className:g("tl-modal","tl-error-boundary__content",{"tl-error-boundary__content__expanded":r&&!l}),children:l?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("h2",{children:"Are you sure?"}),(0,p.jsx)("p",{children:"Resetting your data will delete your drawing and cannot be undone."}),(0,p.jsxs)("div",{className:"tl-error-boundary__content__actions",children:[(0,p.jsx)("button",{className:"tlui-button",onClick:()=>c(!1),children:"Cancel"}),(0,p.jsx)("button",{className:"tlui-button tl-error-boundary__reset",onClick:S,children:"Reset data"})]})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("h2",{children:"Something went wrong"}),(0,p.jsx)("p",{children:"Please refresh your browser."}),(0,p.jsx)("p",{children:"If the issue continues after refreshing, you may need to reset the tldraw data stored on your device."}),(0,p.jsxs)("p",{children:[(0,p.jsx)("strong",{children:"Note:"})," Resetting will erase your current project and any unsaved work."]}),!1,r&&(0,p.jsxs)(p.Fragment,{children:["Message:",(0,p.jsx)("h4",{children:(0,p.jsx)("code",{children:h})}),"Stack trace:",(0,p.jsxs)("div",{className:"tl-error-boundary__content__error",children:[(0,p.jsx)("pre",{children:(0,p.jsx)("code",{children:f??h})}),(0,p.jsx)("button",{className:"tlui-button",onClick:()=>{let e=(0,M.TW)(n.current),t=e.createElement("textarea");t.value=f??h,e.body.appendChild(t),t.select(),e.execCommand("copy"),t.remove(),s(!0)},children:o?"Copied!":"Copy"})]})]}),(0,p.jsxs)("div",{className:"tl-error-boundary__content__actions",children:[(0,p.jsx)("button",{className:"tlui-button",onClick:()=>i(!r),children:r?"Hide details":"Show details"}),(0,p.jsxs)("div",{className:"tl-error-boundary__content__actions__group",children:[(0,p.jsx)("button",{className:"tlui-button tl-error-boundary__reset",onClick:()=>c(!0),children:"Reset data"}),(0,p.jsx)("button",{className:"tlui-button tl-error-boundary__refresh",onClick:()=>{eP.refreshPage()},children:"Refresh Page"})]})]})]})})]})};function eM({x:e,y:t,z:n,size:r}){let i=(0,L.Ls)("grid"),{gridSteps:o}=(0,k.hG)().options;return(0,p.jsxs)("svg",{className:"tl-grid",version:"1.1",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[(0,p.jsx)("defs",{children:o.map(({min:o,mid:s,step:l},d)=>{let c=l*r*n,u=.5+e*n,h=.5+t*n,f=u>0?u%c:c+u%c,g=h>0?h%c:c+h%c,m=n<s?(0,a.ww)(n,[o,s],[0,1]):1;return(0,p.jsx)("pattern",{id:(0,L.oX)(i,`${l}`),width:c,height:c,patternUnits:"userSpaceOnUse",children:(0,p.jsx)("circle",{className:"tl-grid-dot",cx:f,cy:g,r:1,opacity:m})},d)})}),o.map(({step:e},t)=>(0,p.jsx)("rect",{width:"100%",height:"100%",fill:`url(#${i}_${e})`},t))]})}let eA=(0,m.forwardRef)(function({children:e,shape:t,isBackground:n,...r},i){let o="fill"in t.props&&"none"!==t.props.fill;return(0,p.jsx)("div",{ref:i,"data-shape-type":t.type,"data-shape-is-filled":n?void 0:o,"data-shape-id":t.id,draggable:!1,...r,className:g("tl-shape",n&&"tl-shape-background",r.className),children:e})});function ej(e){return(0,p.jsx)("svg",{width:16,height:16,viewBox:"0 0 16 16","aria-hidden":"false",...e,className:g("tl-spinner",e.className),children:(0,p.jsxs)("g",{strokeWidth:2,fill:"none",fillRule:"evenodd",children:[(0,p.jsx)("circle",{strokeOpacity:.25,cx:8,cy:8,r:7,stroke:"currentColor"}),(0,p.jsx)("path",{strokeLinecap:"round",d:"M15 8c0-4.5-4.5-7-7-7",stroke:"currentColor"})]})})}let eO=(0,m.createContext)(null);function eD({host:e,children:t}){return(0,p.jsx)(eO.Provider,{value:e,children:t})}function eL({children:e,className:t="",...n}){return(0,p.jsx)("div",{...n,className:g("tl-html-container",t),children:e})}var eF=n(20172),eR=n(43631),ez=n(94833),eN=n(31832),e$=n(36649),eB=n(52800),eH=n(43336),eU=n(97986),eW=n(97156);let eK=e=>e.props.src,eV={currentUser:(0,l.EW)("defaultCurrentUser",()=>{let e=(0,eW.oE)();return e.id?u.XA.create({id:(0,u.dB)(e.id),name:e.name??"",color:e.color??eW.Tj.color}):null})},eY={upload:async(e,t)=>({src:await a.Sm.blobToDataUrl(t)})};function eG({initialData:e,defaultName:t="",id:n,assets:r=eY,users:i=eV,onMount:o,collaboration:s,themes:l,...d}={}){let h=(0,eN.P)(l);(0,u.Mc)(h),(0,u.AF)(h);let p="schema"in d&&d.schema?d.schema:(0,u.Wt)({shapes:"shapeUtils"in d&&d.shapeUtils?eq((0,eH.u)(d.shapeUtils)):void 0,bindings:"bindingUtils"in d&&d.bindingUtils?eq((0,eB.t)(d.bindingUtils)):void 0,assets:"assetUtils"in d&&d.assetUtils?eq((0,e$.U)(d.assetUtils)):void 0,records:"records"in d?d.records:void 0,migrations:"migrations"in d?d.migrations:void 0}),f=new c.il({id:n,schema:p,initialData:e,props:{defaultName:t,assets:{upload:r.upload,resolve:r.resolve??eK,remove:r.remove??(()=>Promise.resolve())},users:{currentUser:i.currentUser,resolve:i.resolve??(0,u.gP)(e=>{let t=i.currentUser.get();return t&&t.id===(0,u.dB)(e)?t:null})},onMount:e=>{(0,a.vA)(e instanceof ez.K),o?.(e)},collaboration:s}});if(d.snapshot){if(e)throw Error("Cannot provide both initialData and snapshot");(0,eU.N)(f,d.snapshot,{forceOverwriteSessionState:!0})}return f}function eq(e){return Object.fromEntries(e.map(e=>[e.type,{props:e.props,migrations:e.migrations}]))}var eX=n(59466),eJ=n(15727);class eZ{constructor(e){this.editor=e}editor;static configure(e){return class extends this{options={...this.options,...e}}}options={};static props;static migrations;static type;getSupportedMimeTypes(){return[]}acceptsMimeType(e){return this.getSupportedMimeTypes().includes(e)}async getAssetFromFile(e,t){return null}}class eQ{constructor(e){this.editor=e}editor;static props;static migrations;static type}n(32314),n(98626),n(51286),n(8810),n(12318),n(73578),n(58929),n(66122),n(17858),n(2642);var e0=n(43502),e1=n(19743);n(40002),n(79224),n(99714),n(13004);var e2=n(93097),e3=n(26614);function e5(e,t,n={}){let{newPoint:r,handle:i,scaleX:o,scaleY:s}=t,{minWidth:a=1,maxWidth:l=1/0,minHeight:d=1,maxHeight:c=1/0}=n,u=e.props.w*o,h=e.props.h*s,p=new I.l(0,0);if(u>0){if(u<a){switch(i){case"top_left":case"left":case"bottom_left":p.x=u-a;break;case"top":case"bottom":p.x=(u-a)/2;break;default:p.x=0}u=a}}else if(p.x=u,(u=-u)<a){switch(i){case"top_left":case"left":case"bottom_left":p.x=-u;break;default:p.x=-a}u=a}if(h>0){if(h<d){switch(i){case"top_left":case"top":case"top_right":p.y=h-d;break;case"right":case"left":p.y=(h-d)/2;break;default:p.y=0}h=d}}else if(p.y=h,(h=-h)<d){switch(i){case"top_left":case"top":case"top_right":p.y=-h;break;default:p.y=-d}h=d}let{x:f,y:g}=p.rot(e.rotation).add(r);return{...e,x:f,y:g,props:{w:Math.min(l,u),h:Math.min(c,h)}}}class e6 extends e3.i{getGeometry(e){return new e2.k({width:e.props.w,height:e.props.h,isFilled:!0})}onResize(e,t){return e5(e,t)}getHandleSnapGeometry(e){return{points:this.getGeometry(e).bounds.cornersAndCenter}}getInterpolatedProps(e,t,n){return{...t.props,w:(0,a.Cc)(e.props.w,t.props.w,n),h:(0,a.Cc)(e.props.h,t.props.h,n)}}}class e4 extends e6{isFrameLike(e){return!0}providesBackgroundForChildren(){return!0}canReceiveNewChildrenOfType(e,t){return!e.isLocked}canRemoveChildrenOfType(e,t){return!e.isLocked}getClipPath(e){return this.editor.getShapeGeometry(e.id).vertices}shouldClipChild(e){return"arrow"!==e.type}onDragShapesIn(e,t,{initialParentIds:n,initialIndices:r}){let{editor:i}=this;if(t.every(t=>t.parentId===e.id))return;let o=!1,s=t.filter(t=>e.id===n.get(t.id));if(s.length>0){let t=(0,a.oE)(i.getSortedChildIdsForParent(e).map(e=>i.getShape(e)));s.every(e=>!t.find(t=>t.index===e.index))&&(o=!0)}if(!t.some(t=>i.hasAncestor(e,t.id))&&(i.reparentShapes(t,e.id),o))for(let e of s)i.updateShape({id:e.id,type:e.type,index:r.get(e.id)})}onDragShapesOut(e,t,n){let{editor:r}=this;n.nextDraggingOverShapeId||r.reparentShapes(t.filter(t=>t.parentId===e.id),r.getCurrentPageId())}}n(37920);let e8=new WeakMap;function e9(e,t,n){let r=e.editor.getCurrentTheme(),i=n??e.editor.getColorMode(),o=e8.get(t);if(o&&o.theme===r&&o.colorMode===i)return o.values;let s={...e.options.getDefaultDisplayValues(e.editor,t,r,i),...e.options.getCustomDisplayValues(e.editor,t,r,i)};return e8.set(t,{theme:r,colorMode:i,values:s}),s}n(61307);class e7{constructor(e){this.editor=e}editor;static type;options={};static configure(e){return class extends this{options={...this.options,...e}}}getGeometry(e){return null}getCursor(e){}render(e,t){}renderMinimap(e,t,n){}dispose(){}}let te=(0,c.uY)("shapeIndicatorPath",(e,t)=>e.getShapeUtil(t).getIndicatorPath(t),{areRecordsEqual:(e,t)=>e.props===t.props});function tt(e,t,n){if(0===n.length)return;let r=new Path2D;for(let i of n){let n=e.getShape(i);if(!n||n.isLocked)continue;let o=e.getShapePageTransform(n);if(!o)continue;let s=te.get(e,n.id);if(!s)continue;if(s instanceof Path2D){r.addPath(s,o);continue}let{path:a,clipPath:l,additionalPaths:d}=s;if(!l){if(r.addPath(a,o),d)for(let e of d)r.addPath(e,o);continue}if(t.save(),t.transform(o.a,o.b,o.c,o.d,o.e,o.f),t.save(),t.clip(l,"evenodd"),t.stroke(a),t.restore(),d)for(let e of d)t.stroke(e);t.restore()}t.stroke(r)}var tn=n(71136);function tr(e,{initialBounds:t,scaleX:n,scaleY:r,newPoint:i,handle:o}){let s;switch(o){case"bottom_left":case"bottom_right":case"top_left":case"top_right":s=Math.max(.01,Math.max(Math.abs(n),Math.abs(r)));break;case"left":case"right":s=Math.max(.01,Math.abs(n));break;case"bottom":case"top":s=Math.max(.01,Math.abs(r));break;default:throw(0,a.h6)(o)}let l=new I.l(0,0);n<0&&(l.x=-(t.width*s)),r<0&&(l.y=-(t.height*s));let{x:d,y:c}=I.l.Add(i,l.rot(e.rotation));return{x:d,y:c,props:{scale:s*e.props.scale}}}var ti=n(78663);class to extends ti.Y{static id="idle";onPointerDown(e){this.parent.transition("pointing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onCancel(){this.editor.setCurrentTool("select")}}class ts extends ti.Y{static id="pointing";onPointerMove(e){let{editor:t}=this;if(t.inputs.getIsDragging()){let n=t.inputs.getOriginPagePoint(),r=this.parent.shapeType,i=(0,u.n6)(),o=t.markHistoryStoppingPoint(`creating_box:${i}`),s=ta(n,t);if(this.editor.createShapes([{id:i,type:r,x:s.x,y:s.y,props:{w:1,h:1}}]),!t.getShape(i))return void this.cancel();t.select(i);let a=this.parent;this.editor.setCurrentTool("select.resizing",{...e,target:"selection",handle:"bottom_right",isCreating:!0,creatingMarkId:o,creationCursorOffset:{x:1,y:1},onInteractionEnd:this.parent.id,onCreate:a.onCreate?e=>a.onCreate?.(e):void 0})}}onPointerUp(){this.complete()}onLongPress(){this.editor.getInstanceState().isCoarsePointer&&this.cancel()}onCancel(){this.cancel()}onComplete(){this.complete()}onInterrupt(){this.cancel()}complete(){let e=this.editor.inputs.getOriginPagePoint(),t=this.parent.shapeType,n=(0,u.n6)();this.editor.markHistoryStoppingPoint(`creating_box:${n}`),this.editor.createShapes([{id:n,type:t,x:e.x,y:e.y}]);let r=this.editor.getShape(n);if(!r)return void this.cancel();let{w:i,h:o}=r.props,s=new I.l(i/2,o/2),l=this.editor.getShapeParentTransform(r);l&&s.rot(-l.rotation());let d=this.editor.getResizeScaleFactor();1!==d&&(i*=d,o*=d,s.mul(d));let c=(0,a.pN)(r),h=ta(new I.l(r.x-s.x,r.y-s.y),this.editor);c.x=h.x,c.y=h.y,c.props.w=i,c.props.h=o,"scale"in r.props&&(c.props.scale=d),this.editor.updateShape(c),this.editor.setSelectedShapes([n]),this.editor.getInstanceState().isToolLocked?this.parent.transition("idle"):this.editor.setCurrentTool("select.idle")}cancel(){this.parent.transition("idle")}}function ta(e,t){let n=t.getInstanceState().isGridMode,r=t.getDocumentSettings().gridSize;return n?e.clone().snapToGrid(r):e.clone()}class tl extends ti.Y{static id="box";static initial="idle";static children(){return[to,ts]}}n(16398);var td=n(50585);n(19065);var tc=n(84469),tu=n(89658);function th(){let e=(0,k.hG)(),t=(0,td.Jf)();return(0,d.h)("colorMode",()=>t?t.colorMode:e.getColorMode(),[t,e])}let tp="<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'/>",tf="<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'/>",tg='<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 tm(e,t,n,r,i,o=16,s=16){let a=(-n-t)*(O.PI/180),l=Math.sin(a),d=Math.cos(a);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: ${i};'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='${d-l}' dy='${+l+ +d}' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(${t+n} 16 16)${r?" scale(-1,-1) translate(0, -32)":""}' filter='url(%23shadow)'>`+e.replaceAll('"',"'")+`</g></svg>") ${o} ${s}, pointer`}let ty=["default","pointer","cross","comment","move","grab","grabbing","text","zoom-in","zoom-out"],tb={none:()=>"none","ew-resize":(e,t,n)=>tm(tf,e,0,t,n),"ns-resize":(e,t,n)=>tm(tf,e,90,t,n),"nesw-resize":(e,t,n)=>tm(tp,e,0,t,n),"nwse-resize":(e,t,n)=>tm(tp,e,90,t,n),"nwse-rotate":(e,t,n)=>tm(tg,e,0,t,n),"nesw-rotate":(e,t,n)=>tm(tg,e,90,t,n),"senw-rotate":(e,t,n)=>tm(tg,e,180,t,n),"swne-rotate":(e,t,n)=>tm(tg,e,270,t,n)};function tx(){let{Spinner:e}=(0,b.B)();return(0,p.jsx)("div",{className:"tl-loading","aria-busy":"true",tabIndex:0,children:e?(0,p.jsx)(e,{}):null})}let tw=function(){return(0,p.jsx)("div",{className:"tl-shape-error-boundary"})};function tv(){return null}var tS=n(80614);function tC({overrides:e={},children:t}){let n=(0,tS.d)(e),r=(0,m.useMemo)(()=>({Background:f,Canvas:K,CollaboratorCursor:ee,Grid:eM,InFrontOfTheCanvas:null,LoadingScreen:tx,OnTheCanvas:null,ShapeWrapper:eA,Spinner:ej,SvgDefs:tv,ErrorFallback:e_,ShapeErrorFallback:tw,...n}),[n]);return(0,p.jsx)(b.$.Provider,{value:r,children:t})}var tk=n(18314);function tP(e,t,n){let r=(0,m.useRef)(!1),i=(0,m.useCallback)(n=>{r.current=n,n?tc.N.addOpenMenu(e):tc.N.deleteOpenMenu(e),t?.(n)},[e,t]),o=(0,d.h)("is menu open",()=>tc.N.getOpenMenus().includes(e),[e]);return(0,m.useEffect)(()=>(r.current&&(n?.("open-menu"),tc.N.addOpenMenu(e)),()=>{r.current&&(tc.N.deleteOpenMenu(e),tc.N.getOpenMenus().forEach(t=>{t.startsWith(e)&&(n?.("close-menu"),tc.N.deleteOpenMenu(t))}),r.current=!1)}),[e,n]),[o,i]}function tT(e){let t=(0,k.hG)();return(0,d.h)("isEditing",()=>t.getEditingShapeId()===e,[t,e])}let tE=Symbol("UPDATE_INSTANCE_STATE");class tI{onmessage;constructor(e){}postMessage(e){}close(){}}let t_="u"<typeof BroadcastChannel?tI:BroadcastChannel;class tM{constructor(e,{persistenceKey:t,sessionId:n=eX.Os,onLoad:r,onLoadError:i},o=new t_(`tldraw-tab-sync-${t}`)){this.store=e,this.channel=o,"u">typeof window&&(window.tlsync=this),this.persistenceKey=t,this.sessionId=n,this.db=new eS(t),this.disposables.add(()=>this.db.close()),this.serializedSchema=this.store.schema.serialize(),this.$sessionStateSnapshot=(0,eX.e6)(this.store),this.disposables.add(e.listen(({changes:e})=>{this.diffQueue.push(e),this.channel.postMessage({type:"diff",storeId:this.store.id,changes:e,schema:this.serializedSchema}),this.schedulePersist()},{source:"user",scope:"document"})),this.disposables.add(e.listen(()=>{this.diffQueue.push(tE),this.schedulePersist()},{scope:"session"})),this.connect(r,i),this.documentTypes=new Set(Object.values(this.store.schema.types).filter(e=>"document"===e.scope).map(e=>e.typeName))}store;channel;disposables=new Set;diffQueue=[];didDispose=!1;shouldDoFullDBWrite=!0;isReloading=!1;persistenceKey;sessionId;serializedSchema;isDebugging=!1;documentTypes;$sessionStateSnapshot;db;initTime=Date.now();debug(...e){this.isDebugging&&console.debug(...e)}async connect(e,t){let n;this.debug("connecting");try{n=await this.db.load({sessionId:this.sessionId})}catch(e){t(e),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.
|
|
135
|
+
|
|
136
|
+
Keep seeing this message?
|
|
137
|
+
\u2022 If you're using tldraw in a private or "incognito" window, try loading tldraw in a regular window or in a different browser.`);return}if(this.debug("loaded data from store",n,"didDispose",this.didDispose),!this.didDispose)try{if(n){let e=Object.fromEntries(n.records.map(e=>[e.id,e])),r=n.sessionStateSnapshot??(0,eX.WK)(e),i=this.store.schema.migrateStoreSnapshot({store:e,schema:n.schema??this.store.schema.serializeEarliestVersion()});if("error"===i.type){console.error("failed to migrate store",i),t(Error(`Failed to migrate store: ${i.reason}`));return}let o=Object.values(i.value).filter(e=>this.documentTypes.has(e.typeName));o.length>0&&this.store.mergeRemoteChanges(()=>{this.store.put(o,"initialize")}),r&&(0,eX.Jr)(this.store,r,{forceOverwrite:!0})}this.channel.onmessage=({data:e})=>{this.debug("got message",e);let n=this.store.schema.getMigrationsSince(e.schema);if(!n.ok)return Date.now()-this.initTime<5e3?void t(Error("Schema mismatch, please close other tabs and reload the page")):(this.debug("reloading"),this.isReloading=!0,void window?.location?.reload?.());if(n.value.length>0){this.debug("telling them to reload"),this.channel.postMessage({type:"announce",schema:this.serializedSchema}),this.shouldDoFullDBWrite=!0,this.persistIfNeeded();return}"diff"===e.type&&(this.debug("applying diff"),(0,l.hL)(()=>{this.store.mergeRemoteChanges(()=>{this.store.applyDiff(e.changes)})}))},this.channel.postMessage({type:"announce",schema:this.serializedSchema}),this.disposables.add(()=>{this.channel.close()}),e(this)}catch(e){if(this.debug("error loading data from store",e),this.didDispose)return;t(e);return}}close(){this.debug("closing"),this.didDispose=!0,this.disposables.forEach(e=>e()),"u">typeof window&&window.tlsync===this&&delete window.tlsync}isPersisting=!1;didLastWriteError=!1;scheduledPersistTimeout=null;schedulePersist(){this.debug("schedulePersist",this.scheduledPersistTimeout),this.scheduledPersistTimeout||(this.scheduledPersistTimeout=setTimeout(()=>{this.scheduledPersistTimeout=null,this.persistIfNeeded()},this.didLastWriteError?1e4:350))}persistIfNeeded(){this.debug("persistIfNeeded",{isPersisting:this.isPersisting,isReloading:this.isReloading,shouldDoFullDBWrite:this.shouldDoFullDBWrite,diffQueueLength:this.diffQueue.length,storeIsPossiblyCorrupt:this.store.isPossiblyCorrupted()}),this.scheduledPersistTimeout&&(clearTimeout(this.scheduledPersistTimeout),this.scheduledPersistTimeout=null),this.isPersisting||this.isReloading||!this.store.isPossiblyCorrupted()&&(this.shouldDoFullDBWrite||this.diffQueue.length>0)&&this.doPersist()}async doPersist(){if((0,a.vA)(!this.isPersisting,"persist already in progress"),this.didDispose)return;this.isPersisting=!0,this.debug("doPersist start");let e=this.diffQueue;this.diffQueue=[];try{if(this.shouldDoFullDBWrite)this.shouldDoFullDBWrite=!1,await this.db.storeSnapshot({schema:this.store.schema,snapshot:this.store.serialize(),sessionId:this.sessionId,sessionStateSnapshot:this.$sessionStateSnapshot.get()});else{let t=(0,c.Dm)(e.filter(e=>e!==tE));await this.db.storeChanges({changes:t,schema:this.store.schema,sessionId:this.sessionId,sessionStateSnapshot:this.$sessionStateSnapshot.get()})}this.didLastWriteError=!1}catch(e){this.shouldDoFullDBWrite=!0,this.didLastWriteError=!0,console.error("failed to store changes in indexed db",e),window.alert(`Oops! We could not save changes to your browser's storage. We now need to reload the page and try again.
|
|
138
|
+
|
|
139
|
+
Keep seeing this message?
|
|
140
|
+
\u2022 If you're using tldraw in a private or "incognito" window, try loading tldraw in a regular window or in a different browser.
|
|
141
|
+
\u2022 If your hard disk is full, try clearing up some space and then reload the page.`),"u">typeof window&&window.location.reload()}this.isPersisting=!1,this.debug("doPersist end"),this.schedulePersist()}}function tA(e){let t=(0,m.useRef)(e),[n,r]=(0,m.useState)(e);return n!==t.current&&r(t.current),[n,(0,m.useCallback)(e=>{"function"==typeof e?t.current=e(t.current):t.current=e,r(t.current)},[])]}function tj(e){return"auto"===e||"scroll"===e||"overlay"===e}function tO(e){let t=e.scrollHeight>e.clientHeight,n=e.scrollWidth>e.clientWidth;if(!t&&!n)return!1;let r=getComputedStyle(e);return t&&tj(r.overflowY)||n&&tj(r.overflowX)}function tD(e){if(!e)throw Error("usePassThroughWheelEvents must be passed a ref");let t=(0,T.NF)(),n=(0,k.fr)(),r=(0,tk._)(r=>{if(!n?.getInstanceState().isFocused||r.isSpecialRedispatchedEvent)return;let i=e.current;if(i&&function(e,t){if(!(e instanceof Node))return tO(t);let n=e instanceof Element?e:e.parentElement;for(;n;){if(n instanceof HTMLElement&&tO(n))return!0;if(n===t)break;n=n.parentElement}return!1}(r.target,i))return;(0,x.wo)(r);let o=t.querySelector(".tl-canvas");if(!o)return;let s=new WheelEvent("wheel",r);s.isSpecialRedispatchedEvent=!0,o.dispatchEvent(s)}),i=(0,m.useRef)(null);(0,m.useEffect)(()=>{let t=e.current;t!==i.current&&(i.current?.removeEventListener("wheel",r),i.current=t,t?.addEventListener("wheel",r,{passive:!1}))}),(0,m.useEffect)(()=>()=>{i.current?.removeEventListener("wheel",r),i.current=null},[r])}function tL(e){return(0,a.sb)(e)}function tF(){let e=(0,k.hG)(),t=(0,d.HO)("userIds",()=>tL(e.getVisibleCollaborators().map(e=>e.userId)).sort(),{isEqual:(e,t)=>e.join(",")===t.join?.(",")},[e]);return(0,d.h)(t)}function tR(e){let t=(0,k.hG)();return(0,d.h)(`latestPresence:${e}`,()=>t.getCollaborators().find(t=>t.userId===e),[t,e])??null}function tz(e){let[t,n]=(0,m.useState)(()=>({store:eG(e),opts:e}));if(!(0,a.zK)(t.opts,e)){let t={store:eG(e),opts:e};return n(t),t.store}return t.store}var tN=n(13656),t$=n(23919);function tB(e){let t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let t=0,r=e.length;t<r;t++)n[t]=e.charCodeAt(t);return t}let tH={ANNUAL_LICENSE:1,PERPETUAL_LICENSE:2,INTERNAL_LICENSE:4,WITH_WATERMARK:8,EVALUATION_LICENSE:16,NATIVE_LICENSE:32,FEAT_COLLABORATION:64,FEAT_COMMENTING:128},tU=Math.max(...Object.values(tH)),tW={ID:0,HOSTS:1,FLAGS:2,EXPIRY_DATE:3},tK=Object.keys(tW).length,tV="sales@tldraw.com",tY=`${(0,t$.H)()}/watermarks/watermark-track.svg`,tG={collaboration:!1,commenting:!1},tq={collaboration:!0,commenting:!0};class tX{publicKey="MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEHJh0uUfxHtCGyerXmmatE368Hd9rI6LH9oPDQihnaCryRFWEVeOvf9U/SPbyxX74LFyJs5tYeAHq5Nc0Ax25LQ";isDevelopment;isTest;isCryptoAvailable;state=(0,l.eU)("license state","pending");featureFlags=(0,l.eU)("license feature flags",{...tG});verbose=!0;constructor(e,t){this.isTest=!1,this.isDevelopment=this.getIsDevelopment(),this.publicKey=t||this.publicKey,this.isCryptoAvailable=!!crypto.subtle,this.isDevelopment&&this.featureFlags.set({...tq}),this.getLicenseFromKey(e).then(e=>{let t=function(e,t,n){if(!e.isLicenseParseable)return n?"unlicensed":(t("no-key-provided"===e.reason?["No tldraw license key provided!","A license is required for production deployments.",`Please reach out to ${tV} to purchase a license.`]:["Invalid license key. tldraw requires a valid license for production use.",`Please reach out to ${tV} to purchase a license.`]),"unlicensed-production");if(!e.isDomainValid&&!e.isDevelopment)return t(["License key is not valid for this domain.","A license is required for production deployments.",`Please reach out to ${tV} to purchase a license.`]),"unlicensed-production";if(e.isEvaluationLicense)if(e.isEvaluationLicenseExpired)return t(["Your tldraw evaluation license has expired!",`Please reach out to ${tV} to purchase a full license.`]),"expired";else return"licensed";if(e.isPerpetualLicenseExpired||e.isAnnualLicenseExpired)return t(["Your tldraw license has been expired for more than 30 days!",`Please reach out to ${tV} to renew your license.`]),"expired";let r=e.daysSinceExpiry;return r>0&&!e.isEvaluationLicense?(t(["Your tldraw license has expired.",`License expired ${r} days ago.`,`Please reach out to ${tV} to renew your license.`]),"licensed"):e.isLicensedWithWatermark?"licensed-with-watermark":"licensed"}(e,e=>this.outputMessages(e),this.isDevelopment);this.maybeTrack(e,t),(0,l.hL)(()=>{var n,r;this.state.set(t),this.featureFlags.set((n=e,r=t,this.isDevelopment?{...tq}:n.isLicenseParseable&&("licensed"===r||"licensed-with-watermark"===r)?n.isEvaluationLicense?{...tq}:{collaboration:n.isCollaborationEnabled,commenting:n.isCommentingEnabled}:{...tG}))})}).catch(e=>{console.error("License validation failed:",e),this.state.set("unlicensed")})}isFeatureEnabled(e){return this.featureFlags.get()[e]}getIsDevelopment(){let e=window.location.protocol,t=window.location.hostname;return!t.toLowerCase().endsWith(".localhost")&&("http:"===e||"https:"===e&&this.isLoopbackHost(t)||!1)}isLoopbackHost(e){let t=e.toLowerCase().replace(/^\[|\]$/g,"");return"localhost"===t||"::1"===t||/^127(?:\.\d{1,3}){3}$/.test(t)}getTrackType(e,t){return"unlicensed-production"===t?"unlicensed":this.isDevelopment||!e.isLicenseParseable?null:e.isEvaluationLicense?"evaluation":"licensed-with-watermark"===t?"with_watermark":null}maybeTrack(e,t){let n=this.getTrackType(e,t);if(!n)return;let r=new URL(tY);if(r.searchParams.set("version",tN.r),r.searchParams.set("license_type",n),"license"in e){r.searchParams.set("license_id",e.license.id);let t=this.isFlagEnabled(e.license.flags,tH.EVALUATION_LICENSE)?"evaluation":this.isFlagEnabled(e.license.flags,tH.ANNUAL_LICENSE)?"annual":this.isFlagEnabled(e.license.flags,tH.PERPETUAL_LICENSE)?"perpetual":"unknown";r.searchParams.set("sku",t)}r.searchParams.set("url",window.location.href),r.searchParams.set("environment","production"),fetch(r.toString())}async extractLicenseKey(e){let t,n,r,[i,o]=e.split("."),[s,a]=i.split("/");if(!s.startsWith("tldraw-"))throw Error(`Unsupported prefix '${s}'`);let l=await (r=tB(atob(this.publicKey)),crypto.subtle.importKey("spki",new Uint8Array(r),{name:"ECDSA",namedCurve:"P-256"},!0,["verify"]));try{t=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},l,new Uint8Array(tB(atob(o))),new Uint8Array(tB(atob(a))))}catch(e){throw console.error(e),Error("Could not perform signature validation")}if(!t)throw Error("Invalid signature");try{n=JSON.parse(atob(a))}catch{throw Error("Could not parse object")}return n.length>tK&&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."]),{id:n[tW.ID],hosts:n[tW.HOSTS],flags:n[tW.FLAGS],expiryDate:n[tW.EXPIRY_DATE]}}async getLicenseFromKey(e){if(!e)return this.isDevelopment||this.outputNoLicenseKeyProvided(),{isLicenseParseable:!1,reason:"no-key-provided"};if(this.isDevelopment&&!this.isCryptoAvailable)return this.verbose&&(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.")),{isLicenseParseable:!1,reason:"has-key-development-mode"};let t=e.replace(/[\u200B-\u200D\uFEFF]/g,"");t=t.replace(/\r?\n|\r/g,"");try{let e=await this.extractLicenseKey(t),n=new Date(e.expiryDate),r=this.isFlagEnabled(e.flags,tH.ANNUAL_LICENSE),i=this.isFlagEnabled(e.flags,tH.PERPETUAL_LICENSE),o=this.isFlagEnabled(e.flags,tH.EVALUATION_LICENSE),s=r&&this.isAnnualLicenseExpired(n),a=i&&this.isPerpetualLicenseExpired(n),l=this.isFlagEnabled(e.flags,tH.FEAT_COLLABORATION),d=l||this.isFlagEnabled(e.flags,tH.FEAT_COMMENTING),c=i&&!a?0:this.getDaysSinceExpiry(n),u={license:e,isLicenseParseable:!0,isDevelopment:this.isDevelopment,isDomainValid:this.isDomainValid(e),expiryDate:n,isAnnualLicense:r,isAnnualLicenseExpired:s,isPerpetualLicense:i,isPerpetualLicenseExpired:a,isInternalLicense:this.isFlagEnabled(e.flags,tH.INTERNAL_LICENSE),isNativeLicense:this.isNativeLicense(e),isLicensedWithWatermark:this.isFlagEnabled(e.flags,tH.WITH_WATERMARK),isEvaluationLicense:o,isEvaluationLicenseExpired:o&&this.isEvaluationLicenseExpired(n),isCollaborationEnabled:l,isCommentingEnabled:d,daysSinceExpiry:c};return this.outputLicenseInfoIfNeeded(u),u}catch(e){return this.outputInvalidLicenseKey(e.message),{isLicenseParseable:!1,reason:"invalid-license-key"}}}isDomainValid(e){let t=window.location.hostname.toLowerCase();return e.hosts.some(n=>{let r=n.toLowerCase().trim();if(r===t||`www.${r}`===t||r===`www.${t}`||"*"===n)return!0;if(this.isNativeLicense(e))return new RegExp(r).test(window.location.href);if(n.includes("*")){let e=RegExp(r.replace(/\./g,"\\.").replace(/\*/g,".*?")+"$");return e.test(t)||e.test(`www.${t}`)}return"vscode-webview:"===window.location.protocol&&r===new URL(window.location.href).searchParams.get("extensionId")||!1})}isNativeLicense(e){return this.isFlagEnabled(e.flags,tH.NATIVE_LICENSE)}getExpirationDateWithoutGracePeriod(e){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+1))}getExpirationDateWithGracePeriod(e){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+30+1))}isAnnualLicenseExpired(e){let t=this.getExpirationDateWithGracePeriod(e);return new Date>=t}isPerpetualLicenseExpired(e){let t=this.getExpirationDateWithGracePeriod(e),n={major:new Date(tN.p.major),minor:new Date(tN.p.minor)};return n.major>=t||n.minor>=t}getDaysSinceExpiry(e){let t=new Date,n=this.getExpirationDateWithoutGracePeriod(e);return Math.max(0,Math.floor((t.getTime()-n.getTime())/864e5))}isEvaluationLicenseExpired(e){return new Date>=this.getExpirationDateWithoutGracePeriod(e)}isFlagEnabled(e,t){return(e&t)===t}outputNoLicenseKeyProvided(){}outputInvalidLicenseKey(e){this.outputMessages(["Invalid tldraw license key",`Reason: ${e}`])}outputLicenseInfoIfNeeded(e){e.license.flags>=2*tU&&this.outputMessages(["Warning: This tldraw license contains some unknown flags.","This will still work, however, you may want to update tldraw packages to a newer version to get access to new functionality."],"warning")}outputMessages(e,t="error"){if(!this.isTest&&this.verbose){for(let n of(this.outputDelimiter(t),e)){let e="warning"===t?"orange":"crimson";console.log(`%c${n}`,`color: white; background: ${e}; padding: 2px; border-radius: 3px;`)}this.outputDelimiter(t)}}outputDelimiter(e="error"){console.log("%c-------------------------------------------------------------------",`color: white; background: ${"warning"===e?"orange":"crimson"}; padding: 2px; border-radius: 3px;`)}static className="tl-watermark_SEE-LICENSE"}var tJ=n(41463);let tZ=(0,m.createContext)(null);function tQ(){let e=t0();if(!e)throw Error("useLicenseContext must be used inside of the <Tldraw /> or <TldrawEditor /> components, or inside an <EditorProvider /> wrapping an editor created by them");return e}function t0(){let e=(0,m.useContext)(tZ),t=(0,k.fr)();return e??t?.licenseManager??null}function t1(e){return"expired"===e||"unlicensed-production"===e}function t2({licenseKey:e=(void 0!==o?o:o=t5(()=>tJ.env.TLDRAW_LICENSE_KEY)||t5(()=>tJ.env.NEXT_PUBLIC_TLDRAW_LICENSE_KEY)||t5(()=>tJ.env.REACT_APP_TLDRAW_LICENSE_KEY)||t5(()=>tJ.env.GATSBY_TLDRAW_LICENSE_KEY)||t5(()=>tJ.env.VITE_TLDRAW_LICENSE_KEY)||t5(()=>tJ.env.PUBLIC_TLDRAW_LICENSE_KEY)||t5(()=>(void 0).TLDRAW_LICENSE_KEY)||t5(()=>(void 0).NEXT_PUBLIC_TLDRAW_LICENSE_KEY)||t5(()=>(void 0).REACT_APP_TLDRAW_LICENSE_KEY)||t5(()=>(void 0).GATSBY_TLDRAW_LICENSE_KEY)||t5(()=>(void 0).VITE_TLDRAW_LICENSE_KEY)||t5(()=>(void 0).PUBLIC_TLDRAW_LICENSE_KEY)||null)??void 0,children:t}){let[n]=(0,m.useState)(()=>new tX(e)),r=(0,d.h)(n.state),[i,s]=(0,m.useState)(!0);return((0,m.useEffect)(()=>{if(t1(r)&&i){let e=setTimeout(()=>{s(!1)},5e3);return()=>clearTimeout(e)}},[r,i]),t1(r)&&!i)?(0,p.jsx)(t3,{}):(0,p.jsx)(tZ.Provider,{value:n,children:t})}function t3(){return(0,p.jsx)("div",{"data-testid":"tl-license-expired",style:{display:"none"}})}function t5(e){try{return e()}catch{return}}function t6(e,t){return(0,d.h)("licenseFeature",()=>!!e&&e.isFeatureEnabled(t),[e,t])}n(65390);var t4=n(59830),t8=n(58347),t9=n(81962);function t7(e,t=20){return Math.max(8,Math.ceil(e/t))}var ne=n(27164);class nt extends ne.vq{_center;_radius;_start;_end;_largeArcFlag;_sweepFlag;_measure;_angleStart;_angleEnd;constructor(e){super({...e,isFilled:!1,isClosed:!1});const{center:t,sweepFlag:n,largeArcFlag:r,start:i,end:o}=e;if(i.equals(o))throw Error("Arc must have different start and end points.");this._angleStart=I.l.Angle(t,i),this._angleEnd=I.l.Angle(t,o),this._radius=I.l.Dist(t,i),this._measure=(0,O.rq)(this._angleStart,this._angleEnd,n,r),this._start=i,this._end=o,this._sweepFlag=n,this._largeArcFlag=r,this._center=t}nearestPoint(e){let{_center:t,_measure:n,_radius:r,_angleEnd:i,_angleStart:o,_start:s,_end:a}=this,l=(0,O.yi)(n,o,i,t.angle(e));if(l<=0)return s;if(l>=1)return a;let d=e.x-t.x,c=e.y-t.y,u=Math.sqrt(d*d+c*c);if(0===u)return s;let h=r/u;return new I.l(t.x+d*h,t.y+c*h)}hitTestLineSegment(e,t){let{_center:n,_radius:r,_measure:i,_angleStart:o,_angleEnd:s}=this,a=(0,t9.vr)(e,t,n,r);return null!==a&&a.some(e=>{let t=(0,O.yi)(i,o,s,n.angle(e));return t>=0&&t<=1})}getVertices(){let{_center:e,_measure:t,length:n,_radius:r,_angleStart:i}=this,o=[];for(let s=0,a=t7(Math.abs(n));s<a+1;s++){let n=i+s/a*t;o.push((0,O.AQ)(e,r,n))}return o}getSvgPathData(e=!0){let{_start:t,_end:n,_radius:r,_largeArcFlag:i,_sweepFlag:o}=this;return`${e?`M${t.toFixed()}`:""} A${r} ${r} 0 ${i} ${o} ${n.toFixed()}`}getLength(){return Math.abs(this._measure*this._radius)}}class nn extends ne.vq{constructor(e){super({isClosed:!0,...e}),this.config=e;const{x:t=0,y:n=0,radius:r}=e;this._x=t,this._y=n,this._center=new I.l(r+t,r+n),this._radius=r}config;_center;_radius;_x;_y;getBounds(){return new t4.az(this._x,this._y,2*this._radius,2*this._radius)}getVertices(){let{_center:e,_radius:t}=this,n=O.uA*t,r=[];for(let i=0,o=t7(n);i<o;i++){let n=i/o*O.uA;r.push((0,O.AQ)(e,t,n))}return r}nearestPoint(e){let{_center:t,_radius:n}=this,r=e.x-t.x,i=e.y-t.y,o=Math.sqrt(r*r+i*i);if(0===o)return new I.l(t.x+n,t.y);let s=n/o;return new I.l(t.x+r*s,t.y+i*s)}distanceToPoint(e,t=!1){let{_center:n,_radius:r}=this,i=e.x-n.x,o=e.y-n.y,s=Math.sqrt(i*i+o*o)-r;return s<0&&(this.isFilled||t)?s:Math.abs(s)}hitTestPoint(e,t=0,n=!1){let{_center:r,_radius:i}=this,o=e.x-r.x,s=e.y-r.y,a=o*o+s*s;if((this.isFilled||n)&&a<=i*i)return!0;let l=i+t;if(a>l*l)return!1;let d=i-t;return d<=0||a>=d*d}hitTestLineSegment(e,t,n=0){let{_center:r,_radius:i}=this;return null!==(0,t9.vr)(e,t,r,i+n)}getSvgPathData(){let{_center:e,_radius:t}=this;return`M${e.x+t},${e.y} a${t},${t} 0 1,0 ${2*t},0a${t},${t} 0 1,0 -${2*t},0`}}var nr=n(31796);class ni extends nr.H{_a;_b;_c;_d;_resolution;constructor(e){const{start:t,cp1:n,cp2:r,end:i}=e;super({...e,points:[t,i]}),this._a=t,this._b=n,this._c=r,this._d=i,this._resolution=e.resolution??10}getVertices(){let e=[],{_a:t,_b:n,_c:r,_d:i}=this;for(let o=0,s=this._resolution;o<=s;o++){let a=o/s;e.push(new I.l((1-a)*(1-a)*(1-a)*t.x+(1-a)*(1-a)*3*a*n.x+3*(1-a)*(a*a)*r.x+a*a*a*i.x,(1-a)*(1-a)*(1-a)*t.y+(1-a)*(1-a)*3*a*n.y+3*(1-a)*(a*a)*r.y+a*a*a*i.y))}return e}nearestPoint(e){let t,n,r,i=1/0;for(let o of this.segments)r=o.nearestPoint(e),(n=I.l.Dist2(r,e))<i&&(t=r,i=n);if(!t)throw Error("nearest point not found");return t}distanceToPoint(e,t=!1){let{segments:n}=this,r=1/0;for(let t=0;t<n.length;t++){let i=n[t].distanceToPoint(e);i<r&&(r=i)}return r}getSvgPathData(e=!0){let{_a:t,_b:n,_c:r,_d:i}=this;return`${e?`M ${t.toFixed()} `:""} C${n.toFixed()} ${r.toFixed()} ${i.toFixed()}`}static GetAtT(e,t){let{_a:n,_b:r,_c:i,_d:o}=e;return new I.l((1-t)*(1-t)*(1-t)*n.x+(1-t)*(1-t)*3*t*r.x+3*(1-t)*(t*t)*i.x+t*t*t*o.x,(1-t)*(1-t)*(1-t)*n.y+(1-t)*(1-t)*3*t*r.y+3*(1-t)*(t*t)*i.y+t*t*t*o.y)}getLength(e,t=32){let n,r=this._a,i=0;for(let e=1;e<=t;e++)n=ni.GetAtT(this,e/t),i+=I.l.Dist(r,n),r=n;return i}}ne.vq;var no=n(55667);class ns extends ne.vq{constructor(e){super({...e,isClosed:!0}),this.config=e;const{width:t,height:n}=e;this._w=t,this._h=n}config;_w;_h;_edges;get edges(){if(!this._edges){let{vertices:e}=this;this._edges=[];for(let t=0,n=e.length;t<n;t++){let r=e[t],i=e[(t+1)%n];this._edges.push(new no.A({start:r,end:i}))}}return this._edges}getVertices(){let e=Math.max(1,this._w),t=Math.max(1,this._h),n=e/2,r=t/2,i=Math.pow(n-r,2)/Math.pow(n+r,2),o=t7(O.PI*(n+r)*(1+3*i/(10+Math.sqrt(4-3*i)))),s=O.uA/o,a=Math.cos(s),l=Math.sin(s),d=0,c=1,u=0,h=1,p=Array(o);for(let i=0;i<o;i++)p[i]=new I.l((0,O.qE)(n+n*c,0,e),(0,O.qE)(r+r*d,0,t)),u=l*c+a*d,h=a*c-l*d,d=u,c=h;return p}nearestPoint(e){let t,n,r,i=1/0;for(let o of this.edges)r=o.nearestPoint(e),(n=I.l.Dist2(r,e))<i&&(t=r,i=n);if(!t)throw Error("nearest point not found");return t}distanceToPoint(e,t=!1){let{edges:n}=this,r=1/0;for(let t=0;t<n.length;t++){let i=n[t].distanceToPoint(e);i<r&&(r=i)}return this.isClosed&&(this.isFilled||t)&&(0,O.s3)(e,this.vertices)?-r:r}hitTestLineSegment(e,t){return this.edges.some(n=>n.hitTestLineSegment(e,t))}getBounds(){return new t4.az(0,0,this._w,this._h)}getLength(){let{_w:e,_h:t}=this,n=Math.max(0,e/2),r=Math.max(0,t/2);return(0,O.VM)(n,r)}getSvgPathData(e=!1){let{_w:t,_h:n}=this,r=t/2,i=n/2,o=Math.max(0,r),s=Math.max(0,i);return`${e?`M${r-o},${i}`:""} a${o},${s},0,1,1,${2*o},0a${o},${s},0,1,1,-${2*o},0`}}ne.vq;var na=n(31428);ne.vq;var nl=n(54939);let nd=`data:image/svg+xml;utf8,${encodeURIComponent('<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>')}`,nc=`data:image/svg+xml;utf8,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="400" height="1601" fill="none"><path fill="#000" d="M72 1319.8c0-10.73 7.071-20.18 17.372-23.22l215.823-63.62c15.519-4.57 31.078 7.05 31.078 23.22v28.26c0 11.31-7.824 21.1-18.85 23.61l-109.636 24.94c-9.254 2.1-9.487 15.2-.313 17.63l110.784 29.37a24.21 24.21 0 0 1 18.015 23.4v25.64c0 11-7.423 20.62-18.071 23.41l-109.659 28.79c-9.162 2.41-8.986 15.47.236 17.63l108.792 25.46c10.955 2.56 18.702 12.33 18.702 23.57v28.39c0 16.17-15.559 27.79-31.078 23.22l-215.823-63.62c-10.3-3.04-17.372-12.49-17.372-23.22v-32.72c0-10.59 6.883-19.95 16.994-23.11l104.523-32.67c8.547-2.67 8.479-14.79-.096-17.36l-104.17-31.3C79.01 1372.42 72 1363 72 1352.31zM72 572.638V495.43c0-13.336 10.846-24.147 24.225-24.147h215.823c13.379 0 24.225 10.811 24.225 24.147v76.179q0 40.645-15.872 70.228-15.743 29.712-45.422 45.79-29.55 16.206-70.843 16.206-41.292 0-70.971-16.078-29.55-16.077-45.422-45.532Q72 612.767 72 572.638m85.132-29.84c-13.379 0-24.225 10.81-24.225 24.146v3.122q0 19.55 6.323 33.313 6.323 13.89 21.807 21.094 15.485 7.332 43.099 7.331t43.1-7.46q15.484-7.33 21.807-21.608 6.323-14.15 6.323-34.728v-1.064c0-13.336-10.846-24.146-24.225-24.146zM72 285.858c0-13.363 10.846-24.197 24.225-24.197h215.823c13.379 0 24.225 10.834 24.225 24.197v23.27c0 13.364-10.846 24.197-24.225 24.197H154.035c-13.379 0-24.225 10.834-24.225 24.197v58.328c0 13.364-10.846 24.197-24.225 24.197h-9.36C82.845 440.047 72 429.214 72 415.85zM278.463 24.72c0-13.374 10.846-24.216 24.225-24.216h9.36c13.379 0 24.225 10.842 24.225 24.216v181.174c0 13.374-10.846 24.216-24.225 24.216h-9.36c-13.379 0-24.225-10.842-24.225-24.216v-40.108c0-8.359-6.779-15.135-15.141-15.135H96.225c-13.38 0-24.225-10.842-24.225-24.216v-22.256c0-13.374 10.846-24.216 24.225-24.216h167.097c8.362 0 15.141-6.776 15.141-15.135z"/><path fill="#000" fill-rule="evenodd" d="M89.224 1062.13C78.997 1059.04 72 1049.63 72 1038.96v-25.9c0-16.486 16.145-28.147 31.818-22.979l215.823 71.169a24.19 24.19 0 0 1 16.632 22.98v62.97c0 10.45-6.706 19.71-16.632 22.98l-215.823 71.17C88.145 1246.51 72 1234.86 72 1218.37v-25.9c0-10.67 6.997-20.08 17.224-23.17l22.595-6.81a15.13 15.13 0 0 0 10.765-14.48v-64.59a15.13 15.13 0 0 0-10.765-14.48zm98.672 77.53 49.299-14.39c8.601-2.51 8.755-14.62.22-17.35l-49.299-15.75c-5.861-1.88-11.852 2.49-11.852 8.64v30.14c0 6.05 5.817 10.41 11.632 8.71" clip-rule="evenodd"/><path fill="#000" d="M72 773.439c0-13.367 10.846-24.203 24.225-24.203h215.823c13.379 0 24.225 10.836 24.225 24.203v89.762q0 29.395-10.711 51.439-10.71 22.046-30.84 34.293t-48.261 12.248q-28.388 0-47.873-12.635-18.187-11.672-28.056-32.218c-8.303-17.289-11.301-36.661-11.301-55.705v-43.867c0-77.976 138.26 4.16 86.215 4.16h-8.138c-12.334 0-22.332 9.989-22.332 22.311 0 8.269.351 16.6 3.097 24.487q3.225 9.024 10.194 13.794 6.968 4.899 18.194 4.899 11.356 0 18.453-4.899 7.226-4.77 10.581-13.794c2.815-7.188 3.484-14.944 3.484-22.596 0-13.366-10.846-24.202-24.225-24.202h-48.56c-12.036 0-16.288 11.345-21.122 20.272-6.79 12.539-25.841 7.72-25.841-6.536 0-7.586-6.156-13.736-13.749-13.736H96.225C82.845 820.916 72 810.08 72 796.714zm108.66 137.378-10.128 5.511-62.72 34.131C91.67 959.243 72 947.569 72 929.205V906.52a24.2 24.2 0 0 1 12.719-21.299l66.199-35.696a15.82 15.82 0 0 0 8.313-13.921c0-43.012 83.618 41.371 21.429 75.213"/></svg>')}`,nu=(0,m.memo)(function(){let e=tQ(),t=(0,k.hG)(),n=(0,d.h)("is mobile",()=>t.getViewportScreenBounds().width<700,[t]),r=(0,d.h)("watermarkState",()=>e.state.get(),[e]);return["licensed-with-watermark","unlicensed"].includes(r)?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(nf,{}),(0,p.jsx)(np,{src:n?nc:nd,isUnlicensed:"unlicensed"===r})]}):null}),nh=(0,m.memo)(function({isDebugMode:e,isMobile:t}){let n=(0,k.hG)(),r=P(),i=(0,m.useRef)(null);return tD(i),(0,p.jsx)("div",{ref:i,className:tX.className,"data-debug":e,"data-mobile":t,"data-unlicensed":!0,"data-testid":"tl-watermark-unlicensed",draggable:!1,...r,children:(0,p.jsx)("button",{draggable:!1,role:"button",onPointerDown:e=>{n.markEventAsHandled(e),(0,x.wo)(e)},title:"The tldraw SDK requires a license key to work in production. You can get a free 100-day trial license at tldraw.dev/pricing.",onClick:()=>{eP.openWindow("https://tldraw.dev/pricing?utm_source=sdk&utm_medium=organic&utm_campaign=watermark","_blank",!0)},children:"Get a license for production"})})}),np=(0,m.memo)(function({src:e,isUnlicensed:t}){let n=(0,k.hG)(),r=(0,d.h)("debug mode",()=>n.getInstanceState().isDebugMode,[n]),i=(0,d.h)("is mobile",()=>n.getViewportScreenBounds().width<700,[n]),o=P(),s=(0,m.useRef)(null);tD(s);let a=`url('${e}') center 100% / 100% no-repeat`;return t?(0,p.jsx)(nh,{isDebugMode:r,isMobile:i}):(0,p.jsx)("div",{ref:s,className:tX.className,"data-debug":r,"data-mobile":i,"data-testid":"tl-watermark-licensed",draggable:!1,...o,children:(0,p.jsx)("button",{draggable:!1,role:"button",onPointerDown:e=>{n.markEventAsHandled(e),(0,x.wo)(e)},title:"Build infinite canvas applications with the tldraw SDK. Learn more at https://tldraw.dev.",onClick:()=>{eP.openWindow("https://tldraw.dev/?utm_source=sdk&utm_medium=organic&utm_campaign=watermark","_blank")},style:{mask:a,WebkitMask:a}})})}),nf=(0,m.memo)(function(){let e=(0,k.hG)(),t=tX.className,n=`
|
|
142
|
+
/* ------------------- SEE LICENSE -------------------
|
|
143
|
+
The tldraw watermark is part of tldraw's license. It is shown for unlicensed
|
|
144
|
+
or "licensed-with-watermark" users. By using this library, you agree to
|
|
145
|
+
preserve the watermark's behavior, keeping it visible, unobscured, and
|
|
146
|
+
available to user-interaction.
|
|
147
|
+
|
|
148
|
+
To remove the watermark, please purchase a license at tldraw.dev.
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
.${t} {
|
|
152
|
+
position: absolute;
|
|
153
|
+
bottom: max(var(--tl-space-2), env(safe-area-inset-bottom));
|
|
154
|
+
right: max(var(--tl-space-2), env(safe-area-inset-right));
|
|
155
|
+
width: 96px;
|
|
156
|
+
height: 32px;
|
|
157
|
+
display: flex;
|
|
158
|
+
align-items: center;
|
|
159
|
+
justify-content: center;
|
|
160
|
+
z-index: var(--tl-layer-watermark) !important;
|
|
161
|
+
background-color: color-mix(in srgb, var(--tl-color-background) 62%, transparent);
|
|
162
|
+
opacity: 1;
|
|
163
|
+
border-radius: 5px;
|
|
164
|
+
pointer-events: all;
|
|
165
|
+
padding: 2px;
|
|
166
|
+
box-sizing: content-box;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.${t} > button {
|
|
170
|
+
position: absolute;
|
|
171
|
+
width: 96px;
|
|
172
|
+
height: 32px;
|
|
173
|
+
pointer-events: all;
|
|
174
|
+
cursor: inherit;
|
|
175
|
+
color: var(--tl-color-text);
|
|
176
|
+
opacity: .38;
|
|
177
|
+
border: 0;
|
|
178
|
+
padding: 0;
|
|
179
|
+
background-color: currentColor;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.${t}[data-debug='true'] {
|
|
183
|
+
bottom: max(46px, env(safe-area-inset-bottom));
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.${t}[data-mobile='true'] {
|
|
187
|
+
border-radius: 4px 0px 0px 4px;
|
|
188
|
+
right: max(-2px, calc(env(safe-area-inset-right) - 2px));
|
|
189
|
+
width: 8px;
|
|
190
|
+
height: 48px;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.${t}[data-mobile='true'] > button {
|
|
194
|
+
width: 8px;
|
|
195
|
+
height: 32px;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.tl-container[dir='rtl'] .${t} {
|
|
199
|
+
right: auto;
|
|
200
|
+
left: max(var(--tl-space-2), env(safe-area-inset-left));
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.tl-container[dir='rtl'] .${t}[data-mobile='true'] {
|
|
204
|
+
border-radius: 0px 4px 4px 0px;
|
|
205
|
+
left: max(-2px, calc(env(safe-area-inset-left) - 2px));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.${t}[data-unlicensed='true'] > button {
|
|
209
|
+
font-size: 100px;
|
|
210
|
+
position: absolute;
|
|
211
|
+
pointer-events: all;
|
|
212
|
+
cursor: pointer;
|
|
213
|
+
color: var(--tl-color-text);
|
|
214
|
+
opacity: 0.8;
|
|
215
|
+
border: 0;
|
|
216
|
+
padding: 0;
|
|
217
|
+
background-color: transparent;
|
|
218
|
+
font-size: 11px;
|
|
219
|
+
font-weight: 600;
|
|
220
|
+
text-align: center;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.${t}[data-mobile='true'][data-unlicensed='true'] > button {
|
|
224
|
+
display: none;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
@media (hover: hover) {
|
|
228
|
+
.${t} > button {
|
|
229
|
+
pointer-events: none;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.${t}:hover {
|
|
233
|
+
background-color: var(--tl-color-background);
|
|
234
|
+
transition: background-color 0.2s ease-in-out;
|
|
235
|
+
transition-delay: 0.32s;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.${t}:hover > button {
|
|
239
|
+
animation: ${t}_delayed_link 0.2s forwards ease-in-out;
|
|
240
|
+
animation-delay: 0.32s;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.${t} > button:focus-visible {
|
|
244
|
+
opacity: 1;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
@keyframes ${t}_delayed_link {
|
|
249
|
+
0% {
|
|
250
|
+
cursor: inherit;
|
|
251
|
+
opacity: .38;
|
|
252
|
+
pointer-events: none;
|
|
253
|
+
}
|
|
254
|
+
100% {
|
|
255
|
+
cursor: pointer;
|
|
256
|
+
opacity: 1;
|
|
257
|
+
pointer-events: all;
|
|
258
|
+
}
|
|
259
|
+
}`;return(0,p.jsx)("style",{nonce:e.options.nonce,children:n})}),ng=[],nm=[],ny=[],nb=[],nx=(0,m.memo)(function({store:e,components:t,className:n,user:r,options:i,textOptions:o,deepLinks:s,...l}){let d=(0,eN.P)(l.themes);(0,u.Mc)(d),(0,u.AF)(d);let[h,f]=(0,m.useState)(null),[y,b]=(0,m.useState)(null),x=(0,m.useMemo)(()=>r??(0,eR.b)(),[r]),w=t?.ErrorFallback===void 0?e_:t?.ErrorFallback,v=(0,m.useMemo)(()=>{let e=i;return o&&(e={...e,text:e?.text??o}),void 0!==s&&(e={...e,deepLinks:e?.deepLinks??s}),e},[i,o,s]),S={...l,shapeUtils:l.shapeUtils??ng,bindingUtils:l.bindingUtils??nm,assetUtils:l.assetUtils??ny,tools:l.tools??nb,components:t,options:(0,tS.d)(v)};return(0,p.jsxs)("div",{ref:f,"data-tldraw":tN.r,draggable:!1,className:g("tl-container tl-theme__light",n),tabIndex:-1,role:"application","aria-label":i?.branding??"tldraw",children:[(0,p.jsx)(eI.p,{fallback:w,onError:e=>(0,a.TF)(e,{tags:{origin:"react.tldraw-before-app"}}),children:h&&(0,p.jsx)(t2,{licenseKey:l.licenseKey,children:(0,p.jsx)(T.ts,{container:h,children:(0,p.jsx)(eD,{host:y,children:(0,p.jsx)(tC,{overrides:t,children:e?e instanceof c.il?(0,p.jsx)(nC,{...S,store:e,user:x}):(0,p.jsx)(nv,{...S,store:e,user:x}):(0,p.jsx)(nw,{...S,store:e,user:x})})})})})}),(0,p.jsx)("div",{className:"tl-portal-host",ref:b})]})});function nw(e){let{defaultName:t,snapshot:n,initialData:r,shapeUtils:i,bindingUtils:o,assetUtils:s,persistenceKey:l,sessionId:d,user:c,assets:u,users:h,migrations:f,themes:g}=e,y=function(e){let[t,n]=tA({status:"loading"});return e=(0,tS.d)(e),(0,m.useEffect)(()=>{let{persistenceKey:t,sessionId:r,...i}=e;if(!t)return void n({status:"not-synced",store:eG(i)});n({status:"loading"});let o=new a.l,s={upload:async(e,t)=>(await c.db.storeAsset(e.id,t),{src:e.id}),resolve:async e=>e.props.src?e.props.src.startsWith("asset:")?await o.get(e,async()=>{let t=await c.db.getAsset(e.id);return t?URL.createObjectURL(t):null}):e.props.src:null,remove:async e=>{await c.db.removeAssets(e)},...i.assets},l=eG({...i,assets:s}),d=!1,c=new tM(l,{sessionId:r,persistenceKey:t,onLoad(){d||n({store:l,status:"synced-local"})},onLoadError(e){d||n({status:"error",error:e})}});return()=>{d=!0,c.close()}},[e,n]),t}({shapeUtils:i,bindingUtils:o,assetUtils:s,initialData:r,persistenceKey:l,sessionId:d,defaultName:t,snapshot:n,assets:u,users:h,migrations:f,themes:g});return(0,p.jsx)(nv,{...e,store:y,user:c})}let nv=(0,m.memo)(function({store:e,user:t,...n}){let r=(0,T.NF)();(0,m.useLayoutEffect)(()=>{"dark"===t.userPreferences.get().colorScheme&&(r.classList.remove("tl-theme__light"),r.classList.add("tl-theme__dark"))},[r,t]);let{LoadingScreen:i}=(0,b.B)();switch(e.status){case"error":throw e.error;case"loading":return i?(0,p.jsx)(i,{}):null}return(0,p.jsx)(nC,{...n,store:e.store,user:t})}),nS=()=>(0,x.jL)().location.search.includes("tldraw_preserve_focus");function nC({onMount:e,children:t,store:n,tools:r,shapeUtils:i,bindingUtils:o,assetUtils:s,overlayUtils:a,user:l,initialState:d,autoFocus:c=!0,cameraOptions:u,options:h,licenseKey:f,getShapeVisibility:g,colorScheme:y,assetUrls:x,themes:w,initialTheme:v}){let{ErrorFallback:S}=(0,b.B)(),C=(0,T.NF)(),P=tQ(),[E,I]=tA(null),_=(0,m.useRef)(null),M=h?.deepLinks,A=(0,tS.d)(!0===M?{}:M),j=(0,m.useRef)({autoFocus:c&&!nS(),initialState:d,colorScheme:y,cameraOptions:u,deepLinks:A,themes:w,initialTheme:v});(0,m.useLayoutEffect)(()=>{j.current={autoFocus:c&&!nS(),initialState:d,colorScheme:y,cameraOptions:u,deepLinks:A,themes:w,initialTheme:v}},[c,d,y,u,A,w,v]),(0,m.useLayoutEffect)(()=>{let{autoFocus:e,initialState:t,colorScheme:d,cameraOptions:c,deepLinks:u,themes:p,initialTheme:m}=j.current,y=new ez.K({store:n,shapeUtils:i,bindingUtils:o,assetUtils:s,overlayUtils:a,tools:r,getContainer:()=>C,user:l,initialState:t,autoFocus:e,cameraOptions:c,options:h,licenseKey:f,getShapeVisibility:g,colorScheme:d,fontAssetUrls:x?.fonts,themes:p,initialTheme:m});return y.licenseManager=P,y.updateViewportScreenBounds(_.current??C),u&&(u?.getUrl?y.navigateToDeepLink({...u,url:u.getUrl(y)}):y.navigateToDeepLink(u)),I(y),()=>{y.dispose()}},[s,o,y,C,h,a,i,n,r,l,I,f,P,g,x]),(0,m.useLayoutEffect)(()=>{if(E&&A)return E.registerDeepLinkListener(A)},[E,A]),(0,m.useLayoutEffect)(()=>{E&&(u||h?.camera)&&E.setCameraOptions({...u,...h?.camera})},[E,u,h?.camera]),(0,m.useLayoutEffect)(()=>{if(E&&w)for(let e of Object.values(w))E.updateTheme(e)},[E,w]),(0,m.useLayoutEffect)(()=>{E&&v&&E.setCurrentTheme(v)},[E,v]);let O=(0,m.useSyncExternalStore)((0,m.useCallback)(e=>E?(E.on("crash",e),()=>E.off("crash",e)):()=>{},[E]),()=>E?.getCrashingError()??null);(0,m.useEffect)(function(){if(E&&c&&nS()){let n=E.getContainer();return n.addEventListener("pointerdown",e),n.ownerDocument.body.addEventListener("pointerdown",t),()=>{n.removeEventListener("pointerdown",e),n.ownerDocument.body.removeEventListener("pointerdown",t)}}function e(){E&&E.focus()}function t(){E&&E.blur()}},[E,c]);let[D,L]=(0,m.useState)(null),F=D;E!==F?.editor&&(F=null),(0,m.useLayoutEffect)(()=>{if(!E)return;if(0===E.options.maxFontsToLoadBeforeRender)return void L({editor:E,isLoaded:!0});let e=!1;return L({editor:E,isLoaded:!1}),E.fonts.loadRequiredFontsForCurrentPage(E.options.maxFontsToLoadBeforeRender).finally(()=>{e||L({editor:E,isLoaded:!0})}),()=>{e=!0}},[E]);let{Canvas:R,LoadingScreen:z}=(0,b.B)();return E&&F?.isLoaded?(0,p.jsx)(eI.p,{fallback:S,onError:e=>E.annotateError(e,{origin:"react.tldraw",willCrashApp:!0}),children:O?(0,p.jsx)(nP,{crashingError:O}):(0,p.jsx)(k.zz,{editor:E,children:(0,p.jsxs)(nk,{onMount:e,children:[t??(R?(0,p.jsx)(R,{},E.contextId):null),(0,p.jsx)(nu,{})]})})}):(0,p.jsxs)(p.Fragment,{children:[z&&(0,p.jsx)(z,{}),(0,p.jsx)("div",{className:"tl-canvas",ref:_})]})}function nk({children:e,onMount:t}){let n,r,i,o,s,c,u,h,p;return n=(0,k.hG)(),r=(0,T.NF)(),m.useEffect(()=>{let e=e=>r.style.setProperty("--tl-zoom",e.toString()),t=(0,a.sg)(e,100),i=new l.VM("useZoomCss",()=>e(n.getEfficientZoomLevel()));return i.attach(),i.execute(),()=>{i.detach(),t.cancel()}},[n,r]),i=(0,k.hG)(),o=(0,T.NF)(),(0,d.lX)("useCursor",()=>{let{type:e,rotation:t}=i.getInstanceState().cursor;if(ty.includes(e))return void o.style.setProperty("--tl-cursor",`var(--tl-cursor-${e})`);let{cursor:n}=i.getCurrentTheme().colors[i.getColorMode()];o.style.setProperty("--tl-cursor",function(e,t=0,n="black"){return tb[e]((0,O.nv)(t),!1,n)}(e,t,n))},[i,o]),s=(0,k.hG)(),c=(0,T.NF)(),u=th(),h=(0,d.h)(j.bG.forceSrgb),m.useEffect(()=>{"dark"===u?(c.setAttribute("data-color-mode","dark"),c.classList.remove("tl-theme__light"),c.classList.add("tl-theme__dark")):(c.setAttribute("data-color-mode","light"),c.classList.remove("tl-theme__dark"),c.classList.add("tl-theme__light")),h?c.classList.add("tl-theme__force-sRGB"):c.classList.remove("tl-theme__force-sRGB")},[s,c,h,u]),function(){let[e,t]=(0,m.useState)(0);(0,m.useEffect)(()=>t(e=>e+1),[])}(),p=(0,k.hG)(),(0,m.useLayoutEffect)(()=>(0,l.wv)("stateAttribute",()=>{let e=p.getContainer(),t=p.getInstanceState();e.setAttribute("data-state",p.getPath()),e.setAttribute("data-coarse",String(t.isCoarsePointer))}),[p]),nE(e=>{let n=e.store.props.onMount(e),r=t?.(e);return()=>{n?.(),r?.()}}),e}function nP({crashingError:e}){throw e}function nT({children:e}){return(0,p.jsx)("div",{className:"tl-loading","aria-busy":"true",tabIndex:0,children:e})}function nE(e){let t=(0,k.hG)(),n=(0,tk._)(t=>{let n;return t.run(()=>{n=e?.(t),t.emit("mount")},{history:"ignore"}),window.tldrawReady=!0,()=>{n?.(),t.getIsMounted()&&!t.isDisposed&&t.run(()=>t.emit("unmount"),{history:"ignore"})}});m.useLayoutEffect(()=>{if(t)return n?.(t)},[t,n])}n(65009),n(4343);class nI{constructor(e,t){this.name=e,this.getInitialState=t}name;getInitialState;states=new a.l;getAtom(e){return this.states.get(e,()=>(0,l.eU)(this.name,this.getInitialState(e)))}get(e){return this.getAtom(e).get()}update(e,t){return this.getAtom(e).update(t)}set(e,t){return this.getAtom(e).set(t)}}function n_(e,t=!0){let n=e.length;if(n<2)return"";let r=e[0],i=e[1];if(2===n)return`M${(0,O.ul)(r)}L${(0,O.ul)(i)}`;let o="";for(let t=2,s=n-1;t<s;t++)r=e[t],i=e[t+1],o+=(0,O.G8)(r,i);return t?`M${(0,O.G8)(e[0],e[1])}Q${(0,O.ul)(e[1])}${(0,O.G8)(e[1],e[2])}T${o}${(0,O.G8)(e[n-1],e[0])}${(0,O.G8)(e[0],e[1])}Z`:`M${(0,O.ul)(e[0])}Q${(0,O.ul)(e[1])}${(0,O.G8)(e[1],e[2])}${e.length>3?"T":""}${o}L${(0,O.ul)(e[n-1])}`}var nM=n(4599),nA=n(82159),nj=n(27050);let nO=new a.l;function nD(e,t,n){let{tipTapConfig:r,addFontsFromNode:i}=e.getTextOptions();(0,a.vA)(r,"textOptions.tipTapConfig must be set to use rich text"),(0,a.vA)(i,"textOptions.addFontsFromNode must be set to use rich text");let o=nO.get(r,()=>(0,nA._w)(r.extensions??[])),s=nj.bP.fromJSON(o,t),l=new Set;function d(e){l.add(e)}return!function e(t,n){for(let r of(n=i(t,n,d),t.children))e(r,n)}(s,n),Array.from(l)}var nL=n(20026),nF=n(92599);(0,a.lF)("@tldraw/editor","5.3.2","esm")},94449:(e,t,n)=>{e=n.nmd(e);var r,i,o,s="__lodash_hash_undefined__",a="[object Arguments]",l="[object Array]",d="[object Boolean]",c="[object Date]",u="[object Error]",h="[object Function]",p="[object Map]",f="[object Number]",g="[object Object]",m="[object Promise]",y="[object RegExp]",b="[object Set]",x="[object String]",w="[object WeakMap]",v="[object ArrayBuffer]",S="[object DataView]",C=/^\[object .+?Constructor\]$/,k=/^(?:0|[1-9]\d*)$/,P={};P["[object Float32Array]"]=P["[object Float64Array]"]=P["[object Int8Array]"]=P["[object Int16Array]"]=P["[object Int32Array]"]=P["[object Uint8Array]"]=P["[object Uint8ClampedArray]"]=P["[object Uint16Array]"]=P["[object Uint32Array]"]=!0,P[a]=P[l]=P[v]=P[d]=P[S]=P[c]=P[u]=P[h]=P[p]=P[f]=P[g]=P[y]=P[b]=P[x]=P[w]=!1;var T="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,E="object"==typeof self&&self&&self.Object===Object&&self,I=T||E||Function("return this")(),_=t&&!t.nodeType&&t,M=_&&e&&!e.nodeType&&e,A=M&&M.exports===_,j=A&&T.process,O=function(){try{return j&&j.binding&&j.binding("util")}catch(e){}}(),D=O&&O.isTypedArray;function L(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function F(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var R=Array.prototype,z=Function.prototype,N=Object.prototype,$=I["__core-js_shared__"],B=z.toString,H=N.hasOwnProperty,U=(r=/[^.]+$/.exec($&&$.keys&&$.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",W=N.toString,K=RegExp("^"+B.call(H).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),V=A?I.Buffer:void 0,Y=I.Symbol,G=I.Uint8Array,q=N.propertyIsEnumerable,X=R.splice,J=Y?Y.toStringTag:void 0,Z=Object.getOwnPropertySymbols,Q=V?V.isBuffer:void 0,ee=(i=Object.keys,o=Object,function(e){return i(o(e))}),et=eP(I,"DataView"),en=eP(I,"Map"),er=eP(I,"Promise"),ei=eP(I,"Set"),eo=eP(I,"WeakMap"),es=eP(Object,"create"),ea=eI(et),el=eI(en),ed=eI(er),ec=eI(ei),eu=eI(eo),eh=Y?Y.prototype:void 0,ep=eh?eh.valueOf:void 0;function ef(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function eg(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function em(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ey(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new em;++t<n;)this.add(e[t])}function eb(e){var t=this.__data__=new eg(e);this.size=t.size}function ex(e,t){for(var n=e.length;n--;)if(e_(e[n][0],t))return n;return -1}function ew(e){var t;return null==e?void 0===e?"[object Undefined]":"[object Null]":J&&J in Object(e)?function(e){var t=H.call(e,J),n=e[J];try{e[J]=void 0;var r=!0}catch(e){}var i=W.call(e);return r&&(t?e[J]=n:delete e[J]),i}(e):(t=e,W.call(t))}function ev(e){return eF(e)&&ew(e)==a}function eS(e,t,n,r,i,o){var s=1&n,a=e.length,l=t.length;if(a!=l&&!(s&&l>a))return!1;var d=o.get(e);if(d&&o.get(t))return d==t;var c=-1,u=!0,h=2&n?new ey:void 0;for(o.set(e,t),o.set(t,e);++c<a;){var p=e[c],f=t[c];if(r)var g=s?r(f,p,c,t,e,o):r(p,f,c,e,t,o);if(void 0!==g){if(g)continue;u=!1;break}if(h){if(!function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}(t,function(e,t){if(!h.has(t)&&(p===e||i(p,e,n,r,o)))return h.push(t)})){u=!1;break}}else if(!(p===f||i(p,f,n,r,o))){u=!1;break}}return o.delete(e),o.delete(t),u}function eC(e){var t;return t=ez(e),eA(e)?t:function(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}(t,eT(e))}function ek(e,t){var n,r,i=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof t?"string":"hash"]:i.map}function eP(e,t){var n,r=null==e?void 0:e[t];return!(!eL(r)||(n=r,U&&U in n))&&(eO(r)?K:C).test(eI(r))?r:void 0}ef.prototype.clear=function(){this.__data__=es?es(null):{},this.size=0},ef.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=!!t,t},ef.prototype.get=function(e){var t=this.__data__;if(es){var n=t[e];return n===s?void 0:n}return H.call(t,e)?t[e]:void 0},ef.prototype.has=function(e){var t=this.__data__;return es?void 0!==t[e]:H.call(t,e)},ef.prototype.set=function(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=es&&void 0===t?s:t,this},eg.prototype.clear=function(){this.__data__=[],this.size=0},eg.prototype.delete=function(e){var t=this.__data__,n=ex(t,e);return!(n<0)&&(n==t.length-1?t.pop():X.call(t,n,1),--this.size,!0)},eg.prototype.get=function(e){var t=this.__data__,n=ex(t,e);return n<0?void 0:t[n][1]},eg.prototype.has=function(e){return ex(this.__data__,e)>-1},eg.prototype.set=function(e,t){var n=this.__data__,r=ex(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},em.prototype.clear=function(){this.size=0,this.__data__={hash:new ef,map:new(en||eg),string:new ef}},em.prototype.delete=function(e){var t=ek(this,e).delete(e);return this.size-=!!t,t},em.prototype.get=function(e){return ek(this,e).get(e)},em.prototype.has=function(e){return ek(this,e).has(e)},em.prototype.set=function(e,t){var n=ek(this,e),r=n.size;return n.set(e,t),this.size+=+(n.size!=r),this},ey.prototype.add=ey.prototype.push=function(e){return this.__data__.set(e,s),this},ey.prototype.has=function(e){return this.__data__.has(e)},eb.prototype.clear=function(){this.__data__=new eg,this.size=0},eb.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},eb.prototype.get=function(e){return this.__data__.get(e)},eb.prototype.has=function(e){return this.__data__.has(e)},eb.prototype.set=function(e,t){var n=this.__data__;if(n instanceof eg){var r=n.__data__;if(!en||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new em(r)}return n.set(e,t),this.size=n.size,this};var eT=Z?function(e){return null==e?[]:function(e,t){for(var n=-1,r=null==e?0:e.length,i=0,o=[];++n<r;){var s=e[n];t(s,n,e)&&(o[i++]=s)}return o}(Z(e=Object(e)),function(t){return q.call(e,t)})}:function(){return[]},eE=ew;function eI(e){if(null!=e){try{return B.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function e_(e,t){return e===t||e!=e&&t!=t}(et&&eE(new et(new ArrayBuffer(1)))!=S||en&&eE(new en)!=p||er&&eE(er.resolve())!=m||ei&&eE(new ei)!=b||eo&&eE(new eo)!=w)&&(eE=function(e){var t=ew(e),n=t==g?e.constructor:void 0,r=n?eI(n):"";if(r)switch(r){case ea:return S;case el:return p;case ed:return m;case ec:return b;case eu:return w}return t});var eM=ev(function(){return arguments}())?ev:function(e){return eF(e)&&H.call(e,"callee")&&!q.call(e,"callee")},eA=Array.isArray,ej=Q||function(){return!1};function eO(e){if(!eL(e))return!1;var t=ew(e);return t==h||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}function eD(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=0x1fffffffffffff}function eL(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function eF(e){return null!=e&&"object"==typeof e}var eR=D?function(e){return D(e)}:function(e){return eF(e)&&eD(e.length)&&!!P[ew(e)]};function ez(e){return null!=e&&eD(e.length)&&!eO(e)?function(e){var t,n,r=eA(e),i=!r&&eM(e),o=!r&&!i&&ej(e),s=!r&&!i&&!o&&eR(e),a=r||i||o||s,l=a?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],d=l.length;for(var c in e){H.call(e,c)&&!(a&&("length"==c||o&&("offset"==c||"parent"==c)||s&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||(t=c,(n=null==(n=d)?0x1fffffffffffff:n)&&("number"==typeof t||k.test(t))&&t>-1&&t%1==0&&t<n)))&&l.push(c)}return l}(e):function(e){if(n=(t=e)&&t.constructor,t!==("function"==typeof n&&n.prototype||N))return ee(e);var t,n,r=[];for(var i in Object(e))H.call(e,i)&&"constructor"!=i&&r.push(i);return r}(e)}e.exports=function(e,t){return function e(t,n,r,i,o){return t===n||(null!=t&&null!=n&&(eF(t)||eF(n))?function(e,t,n,r,i,o){var s=eA(e),h=eA(t),m=s?l:eE(e),w=h?l:eE(t);m=m==a?g:m,w=w==a?g:w;var C=m==g,k=w==g,P=m==w;if(P&&ej(e)){if(!ej(t))return!1;s=!0,C=!1}if(P&&!C)return o||(o=new eb),s||eR(e)?eS(e,t,n,r,i,o):function(e,t,n,r,i,o,s){switch(n){case S:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)break;e=e.buffer,t=t.buffer;case v:if(e.byteLength!=t.byteLength||!o(new G(e),new G(t)))break;return!0;case d:case c:case f:return e_(+e,+t);case u:return e.name==t.name&&e.message==t.message;case y:case x:return e==t+"";case p:var a=L;case b:var l=1&r;if(a||(a=F),e.size!=t.size&&!l)break;var h=s.get(e);if(h)return h==t;r|=2,s.set(e,t);var g=eS(a(e),a(t),r,i,o,s);return s.delete(e),g;case"[object Symbol]":if(ep)return ep.call(e)==ep.call(t)}return!1}(e,t,m,n,r,i,o);if(!(1&n)){var T=C&&H.call(e,"__wrapped__"),E=k&&H.call(t,"__wrapped__");if(T||E){var I=T?e.value():e,_=E?t.value():t;return o||(o=new eb),i(I,_,n,r,o)}}return!!P&&(o||(o=new eb),function(e,t,n,r,i,o){var s=1&n,a=eC(e),l=a.length;if(l!=eC(t).length&&!s)return!1;for(var d=l;d--;){var c=a[d];if(!(s?c in t:H.call(t,c)))return!1}var u=o.get(e);if(u&&o.get(t))return u==t;var h=!0;o.set(e,t),o.set(t,e);for(var p=s;++d<l;){var f=e[c=a[d]],g=t[c];if(r)var m=s?r(g,f,c,t,e,o):r(f,g,c,e,t,o);if(!(void 0===m?f===g||i(f,g,n,r,o):m)){h=!1;break}p||(p="constructor"==c)}if(h&&!p){var y=e.constructor,b=t.constructor;y!=b&&"constructor"in e&&"constructor"in t&&!("function"==typeof y&&y instanceof y&&"function"==typeof b&&b instanceof b)&&(h=!1)}return o.delete(e),o.delete(t),h}(e,t,n,r,i,o))}(t,n,r,i,e,o):t!=t&&n!=n)}(e,t)}},96116:(e,t,n)=>{var r,i="__lodash_hash_undefined__",o=/^\[object .+?Constructor\]$/,s="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,a="object"==typeof self&&self&&self.Object===Object&&self,l=s||a||Function("return this")();function d(e,t){return!!(e?e.length:0)&&function(e,t){if(t!=t){for(var n=c,r=e.length,i=-1;++i<r;)if(n(e[i],i,e))return i;return -1}for(var o=-1,s=e.length;++o<s;)if(e[o]===t)return o;return -1}(e,t)>-1}function c(e){return e!=e}function u(e,t){return e.has(t)}function h(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var p=Array.prototype,f=Function.prototype,g=Object.prototype,m=l["__core-js_shared__"],y=(r=/[^.]+$/.exec(m&&m.keys&&m.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",b=f.toString,x=g.hasOwnProperty,w=g.toString,v=RegExp("^"+b.call(x).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),S=p.splice,C=O(l,"Map"),k=O(l,"Set"),P=O(Object,"create");function T(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function E(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function I(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function _(e){var t=-1,n=e?e.length:0;for(this.__data__=new I;++t<n;)this.add(e[t])}function M(e,t){for(var n,r,i=e.length;i--;){if(n=e[i][0],n===(r=t)||n!=n&&r!=r)return i}return -1}T.prototype.clear=function(){this.__data__=P?P(null):{}},T.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},T.prototype.get=function(e){var t=this.__data__;if(P){var n=t[e];return n===i?void 0:n}return x.call(t,e)?t[e]:void 0},T.prototype.has=function(e){var t=this.__data__;return P?void 0!==t[e]:x.call(t,e)},T.prototype.set=function(e,t){return this.__data__[e]=P&&void 0===t?i:t,this},E.prototype.clear=function(){this.__data__=[]},E.prototype.delete=function(e){var t=this.__data__,n=M(t,e);return!(n<0)&&(n==t.length-1?t.pop():S.call(t,n,1),!0)},E.prototype.get=function(e){var t=this.__data__,n=M(t,e);return n<0?void 0:t[n][1]},E.prototype.has=function(e){return M(this.__data__,e)>-1},E.prototype.set=function(e,t){var n=this.__data__,r=M(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},I.prototype.clear=function(){this.__data__={hash:new T,map:new(C||E),string:new T}},I.prototype.delete=function(e){return j(this,e).delete(e)},I.prototype.get=function(e){return j(this,e).get(e)},I.prototype.has=function(e){return j(this,e).has(e)},I.prototype.set=function(e,t){return j(this,e).set(e,t),this},_.prototype.add=_.prototype.push=function(e){return this.__data__.set(e,i),this},_.prototype.has=function(e){return this.__data__.has(e)};var A=k&&1/h(new k([,-0]))[1]==1/0?function(e){return new k(e)}:function(){};function j(e,t){var n,r,i=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof t?"string":"hash"]:i.map}function O(e,t){var n,r,i,s=null==e?void 0:e[t];return!(!D(s)||(n=s,y&&y in n))&&("[object Function]"==(i=D(r=s)?w.call(r):"")||"[object GeneratorFunction]"==i||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(s)?v:o).test(function(e){if(null!=e){try{return b.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(s))?s:void 0}function D(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}e.exports=function(e){return e&&e.length?function(e){var t=-1,n=d,r=e.length,i=!0,o=[],s=o;if(r>=200){var a=A(e);if(a)return h(a);i=!1,n=u,s=new _}else s=o;r:for(;++t<r;){var l=e[t],c=l;if(l=0!==l?l:0,i&&c==c){for(var p=s.length;p--;)if(s[p]===c)continue r;o.push(l)}else n(s,c,void 0)||(s!==o&&s.push(c),o.push(l))}return o}(e):[]}},97144:(e,t,n)=>{"use strict";n.d(t,{$f:()=>M,G2:()=>x,I$:()=>k,Im:()=>j,Qv:()=>l,Sd:()=>y,Z1:()=>P,_G:()=>c,_e:()=>p,bh:()=>w,eB:()=>d,eT:()=>m,ec:()=>A,hy:()=>E,iz:()=>T,pC:()=>S,yY:()=>v,y_:()=>O});var r=n(8242),i=n(27050),o=n(76865);let s=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function a(e,t){let{$cursor:n}=e.selection;return n&&(t?t.endOfTextblock("backward",e):!(n.parentOffset>0))?n:null}let l=(e,t,n)=>{let s=a(e,n);if(!s)return!1;let l=f(s);if(!l){let n=s.blockRange(),i=n&&(0,r.jP)(n);return null!=i&&(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let d=l.nodeBefore;if(I(e,l,t,-1))return!0;if(0==s.parent.content.size&&(h(d,"end")||o.nh.isSelectable(d)))for(let n=s.depth;;n--){let a=(0,r.$L)(e.doc,s.before(n),s.after(n),i.Ji.empty);if(a&&a.slice.size<a.to-a.from){if(t){let n=e.tr.step(a);n.setSelection(h(d,"end")?o.LN.findFrom(n.doc.resolve(n.mapping.map(l.pos,-1)),-1):o.nh.create(n.doc,l.pos-d.nodeSize)),t(n.scrollIntoView())}return!0}if(1==n||s.node(n-1).childCount>1)break}return!!d.isAtom&&l.depth==s.depth-1&&(t&&t(e.tr.delete(l.pos-d.nodeSize,l.pos).scrollIntoView()),!0)},d=(e,t,n)=>{let r=a(e,n);if(!r)return!1;let i=f(r);return!!i&&u(e,i,t)},c=(e,t,n)=>{let r=g(e,n);if(!r)return!1;let i=b(r);return!!i&&u(e,i,t)};function u(e,t,n){let s=t.nodeBefore,a=t.pos-1;for(;!s.isTextblock;a--){if(s.type.spec.isolating)return!1;let e=s.lastChild;if(!e)return!1;s=e}let l=t.nodeAfter,d=t.pos+1;for(;!l.isTextblock;d++){if(l.type.spec.isolating)return!1;let e=l.firstChild;if(!e)return!1;l=e}let c=(0,r.$L)(e.doc,a,d,i.Ji.empty);if(!c||c.from!=a||c instanceof r.Ln&&c.slice.size>=d-a)return!1;if(n){let t=e.tr.step(c);t.setSelection(o.U3.create(t.doc,a)),n(t.scrollIntoView())}return!0}function h(e,t,n=!1){for(let r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)break}return!1}let p=(e,t,n)=>{let{$head:r,empty:i}=e.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;s=f(r)}let a=s&&s.nodeBefore;return!!a&&!!o.nh.isSelectable(a)&&(t&&t(e.tr.setSelection(o.nh.create(e.doc,s.pos-a.nodeSize)).scrollIntoView()),!0)};function f(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function g(e,t){let{$cursor:n}=e.selection;return n&&(t?t.endOfTextblock("forward",e):!(n.parentOffset<n.parent.content.size))?n:null}let m=(e,t,n)=>{let s=g(e,n);if(!s)return!1;let a=b(s);if(!a)return!1;let l=a.nodeAfter;if(I(e,a,t,1))return!0;if(0==s.parent.content.size&&(h(l,"start")||o.nh.isSelectable(l))){let n=(0,r.$L)(e.doc,s.before(),s.after(),i.Ji.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(h(l,"start")?o.LN.findFrom(r.doc.resolve(r.mapping.map(a.pos)),1):o.nh.create(r.doc,r.mapping.map(a.pos))),t(r.scrollIntoView())}return!0}}return!!l.isAtom&&a.depth==s.depth-1&&(t&&t(e.tr.delete(a.pos,a.pos+l.nodeSize).scrollIntoView()),!0)},y=(e,t,n)=>{let{$head:r,empty:i}=e.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;s=b(r)}let a=s&&s.nodeAfter;return!!a&&!!o.nh.isSelectable(a)&&(t&&t(e.tr.setSelection(o.nh.create(e.doc,s.pos)).scrollIntoView()),!0)};function b(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}let x=(e,t)=>{let n=e.selection,i=n instanceof o.nh,s;if(i){if(n.node.isTextblock||!(0,r.n9)(e.doc,n.from))return!1;s=n.from}else if(null==(s=(0,r.N0)(e.doc,n.from,-1)))return!1;if(t){let n=e.tr.join(s);i&&n.setSelection(o.nh.create(n.doc,s-e.doc.resolve(s).nodeBefore.nodeSize)),t(n.scrollIntoView())}return!0},w=(e,t)=>{let n=e.selection,i;if(n instanceof o.nh){if(n.node.isTextblock||!(0,r.n9)(e.doc,n.to))return!1;i=n.to}else if(null==(i=(0,r.N0)(e.doc,n.to,1)))return!1;return t&&t(e.tr.join(i).scrollIntoView()),!0},v=(e,t)=>{let{$from:n,$to:i}=e.selection,o=n.blockRange(i),s=o&&(0,r.jP)(o);return null!=s&&(t&&t(e.tr.lift(o,s).scrollIntoView()),!0)},S=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!!n.parent.type.spec.code&&!!n.sameParent(r)&&(t&&t(e.tr.insertText("\n").scrollIntoView()),!0)};function C(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}let k=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),s=n.indexAfter(-1),a=C(i.contentMatchAt(s));if(!a||!i.canReplaceWith(s,s,a))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,a.createAndFill());i.setSelection(o.LN.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},P=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof o.i5||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=C(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,a=e.tr.insert(n,s.createAndFill());a.setSelection(o.U3.create(a.doc,n+1)),t(a.scrollIntoView())}return!0},T=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if((0,r.zy)(e.doc,i))return t&&t(e.tr.split(i).scrollIntoView()),!0}let i=n.blockRange(),o=i&&(0,r.jP)(i);return null!=o&&(t&&t(e.tr.lift(i,o).scrollIntoView()),!0)},E=(e,t)=>{let{$from:n,to:r}=e.selection,i,s=n.sharedDepth(r);return 0!=s&&(i=n.before(s),t&&t(e.tr.setSelection(o.nh.create(e.doc,i))),!0)};function I(e,t,n,s){let a,l,d,c=t.nodeBefore,u=t.nodeAfter,p,f,g=c.type.spec.isolating||u.type.spec.isolating;if(!g&&(a=t.nodeBefore,l=t.nodeAfter,d=t.index(),a&&l&&a.type.compatibleContent(l.type)&&(!a.content.size&&t.parent.canReplace(d-1,d)?(n&&n(e.tr.delete(t.pos-a.nodeSize,t.pos).scrollIntoView()),!0):!!t.parent.canReplace(d,d+1)&&!!(l.isTextblock||(0,r.n9)(e.doc,t.pos))&&(n&&n(e.tr.join(t.pos).scrollIntoView()),!0))))return!0;let m=!g&&t.parent.canReplace(t.index(),t.index()+1);if(m&&(p=(f=c.contentMatchAt(c.childCount)).findWrapping(u.type))&&f.matchType(p[0]||u.type).validEnd){if(n){let o=t.pos+u.nodeSize,s=i.FK.empty;for(let e=p.length-1;e>=0;e--)s=i.FK.from(p[e].create(null,s));s=i.FK.from(c.copy(s));let a=e.tr.step(new r.Wg(t.pos-1,o,t.pos,o,new i.Ji(s,1,0),p.length,!0)),l=a.doc.resolve(o+2*p.length);l.nodeAfter&&l.nodeAfter.type==c.type&&(0,r.n9)(a.doc,l.pos)&&a.join(l.pos),n(a.scrollIntoView())}return!0}let y=u.type.spec.isolating||s>0&&g?null:o.LN.findFrom(t,1),b=y&&y.$from.blockRange(y.$to),x=b&&(0,r.jP)(b);if(null!=x&&x>=t.depth)return n&&n(e.tr.lift(b,x).scrollIntoView()),!0;if(m&&h(u,"start",!0)&&h(c,"end")){let o=c,s=[];for(;s.push(o),!o.isTextblock;)o=o.lastChild;let a=u,l=1;for(;!a.isTextblock;a=a.firstChild)l++;if(o.canReplace(o.childCount,o.childCount,a.content)){if(n){let o=i.FK.empty;for(let e=s.length-1;e>=0;e--)o=i.FK.from(s[e].copy(o));n(e.tr.step(new r.Wg(t.pos-s.length,t.pos+u.nodeSize,t.pos+l,t.pos+u.nodeSize-l,new i.Ji(o,s.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function _(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return!!i.node(s).isTextblock&&(n&&n(t.tr.setSelection(o.U3.create(t.doc,e<0?i.start(s):i.end(s)))),!0)}}let M=_(-1),A=_(1);function j(e,t=null){return function(n,i){let{$from:o,$to:s}=n.selection,a=o.blockRange(s),l=a&&(0,r.oM)(a,e,t);return!!l&&(i&&i(n.tr.wrap(a,l).scrollIntoView()),!0)}}function O(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:o},$to:{pos:s}}=n.selection.ranges[r];n.doc.nodesBetween(o,s,(r,o)=>{if(i)return!1;if(!(!r.isTextblock||r.hasMarkup(e,t)))if(r.type==e)i=!0;else{let t=n.doc.resolve(o),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:o},$to:{pos:s}}=n.selection.ranges[r];i.setBlockType(o,s,e,t)}r(i.scrollIntoView())}return!0}}function D(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}let L=D(s,l,p),F=D(s,m,y),R={Enter:D(S,P,T,(e,t)=>{if(e.selection instanceof o.nh&&e.selection.node.isBlock){let{$from:n}=e.selection;return!!n.parentOffset&&!!(0,r.zy)(e.doc,n.pos)&&(t&&t(e.tr.split(n.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let n=e.tr;!e.selection.empty&&(e.selection instanceof o.U3||e.selection instanceof o.i5)&&n.deleteSelection();let{$from:i}=n.selection,s=n.steps.length,a=[],l,d,c=!1,u=!1;for(let e=i.depth;;e--){if(i.node(e).isBlock){let t;c=i.end(e)==i.pos+(i.depth-e),u=i.start(e)==i.pos-(i.depth-e),d=C(i.node(e-1).contentMatchAt(i.indexAfter(e-1)));a.unshift(t||(c&&d?{type:d}:null)),l=e;break}if(1==e)return!1;a.unshift(null)}let h=i.pos,p=(0,r.zy)(n.doc,h,a.length,a);if(p||(a[0]=d?{type:d}:null,p=(0,r.zy)(n.doc,h,a.length,a)),!p)return!1;if(n.split(h,a.length,a),!c&&u&&i.node(l).type!=d){let e=n.mapping.slice(s),t=e.map(i.before(l)),r=n.doc.resolve(t);d&&i.node(l-1).canReplaceWith(r.index(),r.index()+1,d)&&n.setNodeMarkup(e.map(i.before(l)),d)}return t&&t(n.scrollIntoView()),!0}),"Mod-Enter":k,Backspace:L,"Mod-Backspace":L,"Shift-Backspace":L,Delete:F,"Mod-Delete":F,"Mod-a":(e,t)=>(t&&t(e.tr.setSelection(new o.i5(e.doc))),!0)},z={"Ctrl-h":R.Backspace,"Alt-Backspace":R["Mod-Backspace"],"Ctrl-d":R.Delete,"Ctrl-Alt-Backspace":R["Mod-Delete"],"Alt-Delete":R["Mod-Delete"],"Alt-d":R["Mod-Delete"],"Ctrl-a":M,"Ctrl-e":A};for(let e in R)z[e]=R[e];"u">typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"u">typeof os&&os.platform&&os.platform()},97156:(e,t,n)=>{"use strict";n.d(t,{A2:()=>b,Tj:()=>f,oE:()=>C,xX:()=>h});var r=n(83102),i=n(81467),o=n(24167),s=n(22690),a=n(16038);n(41463);let l="TLDRAW_USER_DATA_v3",d=s.T.object({id:s.T.string,name:s.T.string.nullable().optional(),color:s.T.string.nullable().optional(),locale:s.T.string.nullable().optional(),animationSpeed:s.T.number.nullable().optional(),areKeyboardShortcutsEnabled:s.T.boolean.nullable().optional(),edgeScrollSpeed:s.T.number.nullable().optional(),colorScheme:s.T.literalEnum("light","dark","system").optional(),isSnapMode:s.T.boolean.nullable().optional(),isWrapMode:s.T.boolean.nullable().optional(),isDynamicSizeMode:s.T.boolean.nullable().optional(),isPasteAtCursorMode:s.T.boolean.nullable().optional(),enhancedA11yMode:s.T.boolean.nullable().optional(),inputMode:s.T.literalEnum("trackpad","mouse").nullable().optional(),isZoomDirectionInverted:s.T.boolean.nullable().optional()}),c={AddAnimationSpeed:1,AddIsSnapMode:2,MakeFieldsNullable:3,AddEdgeScrollSpeed:4,AddExcalidrawSelectMode:5,AddDynamicSizeMode:6,AllowSystemColorScheme:7,AddPasteAtCursor:8,AddKeyboardShortcuts:9,AddShowUiLabels:10,AddPointerPeripheral:11,RenameShowUiLabelsToEnhancedA11yMode:12,AddZoomDirectionInverted:13},u=Math.max(...Object.values(c)),h=["#FF802B","#EC5E41","#F2555A","#F04F88","#E34BA9","#BD54C6","#9D5BD2","#7B66DC","#02B1CC","#11B3A3","#39B178","#55B467"];function p(){return h[Math.floor(Math.random()*h.length)]}let f=Object.freeze({name:"",locale:(0,i.jP)(),color:p(),edgeScrollSpeed:1,animationSpeed:+!("u">typeof window&&(0,a.CM)().matchMedia&&(0,a.CM)().matchMedia?.("(prefers-reduced-motion: reduce)")?.matches),areKeyboardShortcutsEnabled:!0,isSnapMode:!1,isWrapMode:!1,isDynamicSizeMode:!1,isPasteAtCursorMode:!1,enhancedA11yMode:!1,colorScheme:"light",inputMode:null,isZoomDirectionInverted:!1});function g(){return{id:(0,o.NF)(),color:p()}}function m(e){if(null===e||"object"!=typeof e||!("version"in e)||!("user"in e)||"number"!=typeof e.version)return g();let t=(0,o.pN)(e);t.version<c.AddAnimationSpeed&&(t.user.animationSpeed=1),t.version<c.AddIsSnapMode&&(t.user.isSnapMode=!1),t.version,c.MakeFieldsNullable,t.version<c.AddEdgeScrollSpeed&&(t.user.edgeScrollSpeed=1),t.version<c.AddExcalidrawSelectMode&&(t.user.isWrapMode=!1),t.version<c.AllowSystemColorScheme&&(!0===t.user.isDarkMode?t.user.colorScheme="dark":!1===t.user.isDarkMode&&(t.user.colorScheme="light"),delete t.user.isDarkMode),t.version<c.AddDynamicSizeMode&&(t.user.isDynamicSizeMode=!1),t.version<c.AddPasteAtCursor&&(t.user.isPasteAtCursorMode=!1),t.version<c.AddKeyboardShortcuts&&(t.user.areKeyboardShortcutsEnabled=!0),t.version<c.AddShowUiLabels&&(t.user.showUiLabels=!1),t.version<c.RenameShowUiLabelsToEnhancedA11yMode&&(t.user.enhancedA11yMode=t.user.showUiLabels,delete t.user.showUiLabels),t.version<c.AddPointerPeripheral&&(t.user.inputMode=null),t.version<c.AddZoomDirectionInverted&&(t.user.isZoomDirectionInverted=!1),t.version=u;try{return d.validate(t.user)}catch{return g()}}let y=(0,r.eU)("globalUserData",null);function b(e){d.validate(e),y.set(e),(0,o.Yz)(l,JSON.stringify({version:u,user:y.get()})),x?.postMessage({type:S,origin:v(),data:{user:C(),version:u}})}let x="u"<typeof BroadcastChannel?null:new BroadcastChannel("tldraw-user-sync");x?.addEventListener("message",e=>{let t=e.data;t?.type===S&&t?.origin!==v()&&y.set(m(t.data))});let w=null;function v(){return null===w&&(w=(0,o.NF)()),w}let S="tldraw-user-preferences-change";function C(){let e=y.get();return e||b(e=m(JSON.parse((0,o.zM)(l)||"null")??null)),e}},97986:(e,t,n)=>{"use strict";n.d(t,{N:()=>s,d:()=>l});var r=n(81467),i=n(24167),o=n(59466);function s(e,t,n){let s={};if("store"in t){let n=e.schema.migrateStoreSnapshot(t);if("success"!==n.type)throw Error("Failed to migrate store snapshot: "+n.reason);s.document={schema:e.schema.serialize(),store:(0,i.J2)(n.value,(t,{typeName:n})=>e.scopedTypes.document.has(n))}}else s=t;let l=(0,r.Pu)(e.get(r.O9)),d=a.get(e,o.e6).get();e.atomic(()=>{s.document&&e.loadStoreSnapshot(s.document),l&&e.update(r.O9,e=>({...e,...l})),d&&(0,o.Jr)(e,d),s.session&&(0,o.Jr)(e,s.session,{forceOverwrite:n?.forceOverwriteSessionState})})}let a=new i.l;function l(e){let t=a.get(e,o.e6).get();if(!t)throw Error("Session state is not ready yet");return{document:e.getStoreSnapshot(),session:t}}},98466:(e,t,n)=>{"use strict";n.d(t,{s:()=>o});var r=n(83102),i=n(26614);function o(e){let t=new Set,n=i.i.prototype.canCull;return(0,r.EW)("notVisibleShapes",function(i){let o=e.getCurrentPageShapeIds(),s=e.getViewportPageBounds(),a=e.getShapeIdsInsideBounds(s);if(a.size===o.size)return(0,r._O)(i)||i.size>0?t:i;let l=new Set;for(let t of o){if(a.has(t))continue;let r=e.store.unsafeGetWithoutCapture(t);if(!r)continue;let i=e.getShapeUtil(r.type);if(i.canCull===n){l.add(t);continue}let o=e.getShape(t);o&&i.canCull(o)&&l.add(t)}if((0,r._O)(i))return l;if(l.size===i.size){let e=!0;for(let t of l)if(!i.has(t)){e=!1;break}if(e)return i}return l})}},98626:(e,t,n)=>{"use strict";n.d(t,{w:()=>o});var r=n(58347),i=n(46195);class o{constructor(e){this.editor=e}editor;_isEdgeScrolling=!1;_edgeScrollDuration=-1;getIsEdgeScrolling(){return this._isEdgeScrolling}updateEdgeScrolling(e){let{editor:t}=this;if(t.getCameraOptions().isLocked)return;let n=this.getEdgeScroll();if(0===n.x&&0===n.y)this._isEdgeScrolling&&(this._isEdgeScrolling=!1,this._edgeScrollDuration=0);else if(this._isEdgeScrolling||(this._isEdgeScrolling=!0,this._edgeScrollDuration=0),this._edgeScrollDuration+=e,this._edgeScrollDuration>t.options.edgeScrollDelay){let e=t.options.edgeScrollEaseDuration>0?r.Z.easeInCubic(Math.min(1,this._edgeScrollDuration/(t.options.edgeScrollDelay+t.options.edgeScrollEaseDuration))):1;this.moveCameraWhenCloseToEdge({x:n.x*e,y:n.y*e})}}getEdgeProximityFactors(e,t,n,r,i){let{editor:o}=this,s=o.options.edgeScrollDistance,a=n?o.options.coarsePointerWidth:0,l=e-a,d=e+a,c=r?0:s,u=i?t:t-s;return l<c?Math.min(1,(c-l)/s):d>u?-Math.min(1,(d-u)/s):0}getEdgeScroll(){let{editor:e}=this,{x:t,y:n}=e.inputs.getCurrentScreenPoint(),r=e.getViewportScreenBounds(),{isCoarsePointer:i,insets:[o,s,a,l]}=e.getInstanceState();return{x:this.getEdgeProximityFactors(t,r.w,i,l,s),y:this.getEdgeProximityFactors(n,r.h,i,o,a)}}moveCameraWhenCloseToEdge(e){if(0===e.x&&0===e.y)return;let{editor:t}=this,n=t.getViewportScreenBounds(),r=n.w<1e3?.612:1,o=n.h<1e3?.612:1,s=t.getZoomLevel(),a=t.user.getEdgeScrollSpeed()*t.options.edgeScrollSpeed,l=a*e.x*r/s,d=a*e.y*o/s,{x:c,y:u,z:h}=t.getCamera();t.setCamera(new i.l(c+l,u+d,h))}}},99017:(e,t,n)=>{e=n.nmd(e);var r,i,o,s="__lodash_hash_undefined__",a="[object Arguments]",l="[object Array]",d="[object Boolean]",c="[object Date]",u="[object Error]",h="[object Function]",p="[object Map]",f="[object Number]",g="[object Object]",m="[object Promise]",y="[object RegExp]",b="[object Set]",x="[object String]",w="[object WeakMap]",v="[object ArrayBuffer]",S="[object DataView]",C=/^\[object .+?Constructor\]$/,k=/^(?:0|[1-9]\d*)$/,P={};P["[object Float32Array]"]=P["[object Float64Array]"]=P["[object Int8Array]"]=P["[object Int16Array]"]=P["[object Int32Array]"]=P["[object Uint8Array]"]=P["[object Uint8ClampedArray]"]=P["[object Uint16Array]"]=P["[object Uint32Array]"]=!0,P[a]=P[l]=P[v]=P[d]=P[S]=P[c]=P[u]=P[h]=P[p]=P[f]=P[g]=P[y]=P[b]=P[x]=P[w]=!1;var T="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,E="object"==typeof self&&self&&self.Object===Object&&self,I=T||E||Function("return this")(),_=t&&!t.nodeType&&t,M=_&&e&&!e.nodeType&&e,A=M&&M.exports===_&&T.process,j=function(){try{return A&&A.binding("util")}catch(e){}}(),O=j&&j.isTypedArray;function D(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}function L(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function F(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var R=Array.prototype,z=Function.prototype,N=Object.prototype,$=I["__core-js_shared__"],B=(r=/[^.]+$/.exec($&&$.keys&&$.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",H=z.toString,U=N.hasOwnProperty,W=N.toString,K=RegExp("^"+H.call(U).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),V=I.Symbol,Y=I.Uint8Array,G=N.propertyIsEnumerable,q=R.splice,X=(i=Object.keys,o=Object,function(e){return i(o(e))}),J=eb(I,"DataView"),Z=eb(I,"Map"),Q=eb(I,"Promise"),ee=eb(I,"Set"),et=eb(I,"WeakMap"),en=eb(Object,"create"),er=ew(J),ei=ew(Z),eo=ew(Q),es=ew(ee),ea=ew(et),el=V?V.prototype:void 0,ed=el?el.valueOf:void 0;function ec(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function eu(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function eh(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ep(e){var t=-1,n=e?e.length:0;for(this.__data__=new eh;++t<n;)this.add(e[t])}function ef(e){this.__data__=new eu(e)}function eg(e,t){for(var n=e.length;n--;)if(ev(e[n][0],t))return n;return -1}function em(e,t,n,r,i,o){var s=2&i,a=e.length,l=t.length;if(a!=l&&!(s&&l>a))return!1;var d=o.get(e);if(d&&o.get(t))return d==t;var c=-1,u=!0,h=1&i?new ep:void 0;for(o.set(e,t),o.set(t,e);++c<a;){var p=e[c],f=t[c];if(r)var g=s?r(f,p,c,t,e,o):r(p,f,c,e,t,o);if(void 0!==g){if(g)continue;u=!1;break}if(h){if(!function(e,t){for(var n=-1,r=e?e.length:0;++n<r;)if(t(e[n],n,e))return!0;return!1}(t,function(e,t){if(!h.has(t)&&(p===e||n(p,e,r,i,o)))return h.add(t)})){u=!1;break}}else if(!(p===f||n(p,f,r,i,o))){u=!1;break}}return o.delete(e),o.delete(t),u}function ey(e,t){var n,r,i=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof t?"string":"hash"]:i.map}function eb(e,t){var n,r=null==e?void 0:e[t];return!(!eT(r)||(n=r,B&&B in n))&&(ek(r)||D(r)?K:C).test(ew(r))?r:void 0}ec.prototype.clear=function(){this.__data__=en?en(null):{}},ec.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},ec.prototype.get=function(e){var t=this.__data__;if(en){var n=t[e];return n===s?void 0:n}return U.call(t,e)?t[e]:void 0},ec.prototype.has=function(e){var t=this.__data__;return en?void 0!==t[e]:U.call(t,e)},ec.prototype.set=function(e,t){return this.__data__[e]=en&&void 0===t?s:t,this},eu.prototype.clear=function(){this.__data__=[]},eu.prototype.delete=function(e){var t=this.__data__,n=eg(t,e);return!(n<0)&&(n==t.length-1?t.pop():q.call(t,n,1),!0)},eu.prototype.get=function(e){var t=this.__data__,n=eg(t,e);return n<0?void 0:t[n][1]},eu.prototype.has=function(e){return eg(this.__data__,e)>-1},eu.prototype.set=function(e,t){var n=this.__data__,r=eg(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},eh.prototype.clear=function(){this.__data__={hash:new ec,map:new(Z||eu),string:new ec}},eh.prototype.delete=function(e){return ey(this,e).delete(e)},eh.prototype.get=function(e){return ey(this,e).get(e)},eh.prototype.has=function(e){return ey(this,e).has(e)},eh.prototype.set=function(e,t){return ey(this,e).set(e,t),this},ep.prototype.add=ep.prototype.push=function(e){return this.__data__.set(e,s),this},ep.prototype.has=function(e){return this.__data__.has(e)},ef.prototype.clear=function(){this.__data__=new eu},ef.prototype.delete=function(e){return this.__data__.delete(e)},ef.prototype.get=function(e){return this.__data__.get(e)},ef.prototype.has=function(e){return this.__data__.has(e)},ef.prototype.set=function(e,t){var n=this.__data__;if(n instanceof eu){var r=n.__data__;if(!Z||r.length<199)return r.push([e,t]),this;n=this.__data__=new eh(r)}return n.set(e,t),this};var ex=function(e){return W.call(e)};function ew(e){if(null!=e){try{return H.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function ev(e,t){return e===t||e!=e&&t!=t}(J&&ex(new J(new ArrayBuffer(1)))!=S||Z&&ex(new Z)!=p||Q&&ex(Q.resolve())!=m||ee&&ex(new ee)!=b||et&&ex(new et)!=w)&&(ex=function(e){var t=W.call(e),n=t==g?e.constructor:void 0,r=n?ew(n):void 0;if(r)switch(r){case er:return S;case ei:return p;case eo:return m;case es:return b;case ea:return w}return t});var eS=Array.isArray;function eC(e){return null!=e&&eP(e.length)&&!ek(e)}function ek(e){var t=eT(e)?W.call(e):"";return t==h||"[object GeneratorFunction]"==t}function eP(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=0x1fffffffffffff}function eT(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function eE(e){return!!e&&"object"==typeof e}var eI=O?function(e){return O(e)}:function(e){return eE(e)&&eP(e.length)&&!!P[W.call(e)]};function e_(e){return eC(e)?function(e){var t,n,r,i,o=eS(e)||eE(n=t=e)&&eC(n)&&U.call(t,"callee")&&(!G.call(t,"callee")||W.call(t)==a)?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],s=o.length,l=!!s;for(var d in e){U.call(e,d)&&!(l&&("length"==d||(r=d,(i=null==(i=s)?0x1fffffffffffff:i)&&("number"==typeof r||k.test(r))&&r>-1&&r%1==0&&r<i)))&&o.push(d)}return o}(e):function(e){if(n=(t=e)&&t.constructor,t!==("function"==typeof n&&n.prototype||N))return X(e);var t,n,r=[];for(var i in Object(e))U.call(e,i)&&"constructor"!=i&&r.push(i);return r}(e)}e.exports=function(e,t,n){var r=(n="function"==typeof n?n:void 0)?n(e,t):void 0;return void 0===r?function e(t,n,r,i,o){return t===n||(null!=t&&null!=n&&(eT(t)||eE(n))?function(e,t,n,r,i,o){var s=eS(e),h=eS(t),m=l,w=l;s||(m=(m=ex(e))==a?g:m),h||(w=(w=ex(t))==a?g:w);var C=m==g&&!D(e),k=w==g&&!D(t),P=m==w;if(P&&!C)return o||(o=new ef),s||eI(e)?em(e,t,n,r,i,o):function(e,t,n,r,i,o,s){switch(n){case S:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)break;e=e.buffer,t=t.buffer;case v:if(e.byteLength!=t.byteLength||!r(new Y(e),new Y(t)))break;return!0;case d:case c:case f:return ev(+e,+t);case u:return e.name==t.name&&e.message==t.message;case y:case x:return e==t+"";case p:var a=L;case b:var l=2&o;if(a||(a=F),e.size!=t.size&&!l)break;var h=s.get(e);if(h)return h==t;o|=1,s.set(e,t);var g=em(a(e),a(t),r,i,o,s);return s.delete(e),g;case"[object Symbol]":if(ed)return ed.call(e)==ed.call(t)}return!1}(e,t,m,n,r,i,o);if(!(2&i)){var T=C&&U.call(e,"__wrapped__"),E=k&&U.call(t,"__wrapped__");if(T||E){var I=T?e.value():e,_=E?t.value():t;return o||(o=new ef),n(I,_,r,i,o)}}return!!P&&(o||(o=new ef),function(e,t,n,r,i,o){var s=2&i,a=e_(e),l=a.length;if(l!=e_(t).length&&!s)return!1;for(var d=l;d--;){var c=a[d];if(!(s?c in t:U.call(t,c)))return!1}var u=o.get(e);if(u&&o.get(t))return u==t;var h=!0;o.set(e,t),o.set(t,e);for(var p=s;++d<l;){var f=e[c=a[d]],g=t[c];if(r)var m=s?r(g,f,c,t,e,o):r(f,g,c,e,t,o);if(!(void 0===m?f===g||n(f,g,r,i,o):m)){h=!1;break}p||(p="constructor"==c)}if(h&&!p){var y=e.constructor,b=t.constructor;y!=b&&"constructor"in e&&"constructor"in t&&!("function"==typeof y&&y instanceof y&&"function"==typeof b&&b instanceof b)&&(h=!1)}return o.delete(e),o.delete(t),h}(e,t,n,r,i,o))}(t,n,e,r,i,o):t!=t&&n!=n)}(e,t,n):!!r}},99714:(e,t,n)=>{"use strict";n.d(t,{_:()=>c});var r=n(24167),i=n(64411),o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=(e,t,n,r)=>{for(var i,a=r>1?void 0:r?s(t,n):t,l=e.length-1;l>=0;l--)(i=e[l])&&(a=(r?i(t,n,a):i(a))||a);return r&&a&&o(t,n,a),a};function l(e,t){let n=Math.ceil(t*e.length)-1;return e[Math.max(0,n)]}function d(e){if(0===e.length)return{avg:0,median:0,p95:0,p99:0,min:0,max:0};let t=[...e].sort((e,t)=>e-t);return{avg:t.reduce((e,t)=>e+t,0)/t.length,median:l(t,.5),p95:l(t,.95),p99:l(t,.99),min:t[0],max:t[t.length-1]}}class c{emitter=new i;editor;activeInteraction=null;activeCamera=null;frameCleanup=null;shapeCreatedCleanup=null;shapeEditedCleanup=null;shapeDeletedCleanup=null;loafObserver=null;constructor(e){this.editor=e}on(e,t){return this.emitter.on(e,t),this._maybeAttachLazyListeners(e),()=>{this.emitter.off(e,t),this._maybeDetachLazyListeners(e)}}once(e,t){let n=(...n)=>{t(...n),this._maybeDetachLazyListeners(e)};return this.emitter.once(e,n),this._maybeAttachLazyListeners(e),()=>{this.emitter.off(e,n),this._maybeDetachLazyListeners(e)}}dispose(){this.activeCamera?.timeout&&clearTimeout(this.activeCamera.timeout),this.activeInteraction=null,this.activeCamera=null,this.frameCleanup?.(),this.frameCleanup=null,this.shapeCreatedCleanup?.(),this.shapeCreatedCleanup=null,this.shapeEditedCleanup?.(),this.shapeEditedCleanup=null,this.shapeDeletedCleanup?.(),this.shapeDeletedCleanup=null,this._stopLoafObserver(),this.emitter.removeAllListeners()}_notifyInteractionStart(e,t){if(0===this.emitter.listenerCount("interaction-start")&&0===this.emitter.listenerCount("interaction-end"))return;this.activeInteraction&&console.warn(`[tldraw] New interaction '${e}' started while '${this.activeInteraction.name}' was still active`);let n={};for(let e of this.editor.getSelectedShapes())n[e.type]=(n[e.type]||0)+1;this.activeInteraction={name:e,path:t,startTime:performance.now(),frameTimes:[],selectedShapeTypes:n,loafEntries:[]};let r={name:e,path:t,timestamp:performance.now()};this.emitter.emit("interaction-start",r)}_notifyInteractionEnd(){let e=this.activeInteraction;if(!e||(this.activeInteraction=null,0===this.emitter.listenerCount("interaction-end")))return;let t=performance.now()-e.startTime,n=d(e.frameTimes),r={name:e.name,path:e.path,duration:t,fps:e.frameTimes.length>0?e.frameTimes.length/t*1e3:0,frameCount:e.frameTimes.length,avgFrameTime:n.avg,medianFrameTime:n.median,p95FrameTime:n.p95,p99FrameTime:n.p99,minFrameTime:n.min,maxFrameTime:n.max,frameTimes:e.frameTimes,shapeCount:this.editor.getCurrentPageShapeIds().size,selectedShapeTypes:e.selectedShapeTypes,longAnimationFrames:e.loafEntries.length>0?e.loafEntries:void 0,zoomLevel:this.editor.getCamera().z,timestamp:performance.now()};this.emitter.emit("interaction-end",r)}_notifyCameraOperation(e){(0!==this.emitter.listenerCount("camera-start")||0!==this.emitter.listenerCount("camera-end"))&&(this.activeCamera?(this.activeCamera.timeout&&clearTimeout(this.activeCamera.timeout),this.activeCamera.type!==e?(this._endCameraSession(),this._startCameraSession(e)):this.activeCamera.timeout=this.editor.timers.setTimeout(()=>this._endCameraSession(),50)):this._startCameraSession(e))}_notifyUndoRedo(e,t,n){0===this.emitter.listenerCount(e)||this.emitter.emit(e,{type:e,undoDepth:t,redoDepth:n})}_startCameraSession(e){if(this.activeCamera={type:e,startTime:performance.now(),frameTimes:[],timeout:this.editor.timers.setTimeout(()=>this._endCameraSession(),50),loafEntries:[]},this.emitter.listenerCount("camera-start")>0){let t={type:e,timestamp:performance.now()};this.emitter.emit("camera-start",t)}}_endCameraSession(){let e=this.activeCamera;if(!e||(this.activeCamera=null,e.timeout&&clearTimeout(e.timeout),0===this.emitter.listenerCount("camera-end")))return;let t=performance.now()-e.startTime,n=d(e.frameTimes),r=this.editor.getViewportScreenBounds(),i=this.editor.getCurrentPageShapeIds().size,o=this.editor.getCulledShapes().size,s={type:e.type,duration:t,fps:e.frameTimes.length>0?e.frameTimes.length/t*1e3:0,frameCount:e.frameTimes.length,avgFrameTime:n.avg,medianFrameTime:n.median,p95FrameTime:n.p95,p99FrameTime:n.p99,minFrameTime:n.min,maxFrameTime:n.max,frameTimes:e.frameTimes,shapeCount:i,viewportWidth:r.w,viewportHeight:r.h,longAnimationFrames:e.loafEntries.length>0?e.loafEntries:void 0,visibleShapeCount:i-o,culledShapeCount:o,zoomLevel:this.editor.getCamera().z,timestamp:performance.now()};this.emitter.emit("camera-end",s)}_onFrame(e){if(this.activeInteraction&&this.activeInteraction.frameTimes.push(e),this.activeCamera&&this.activeCamera.frameTimes.push(e),this.emitter.listenerCount("frame")>0){let t=this.editor.getCurrentPageShapeIds().size,n=this.editor.getCulledShapes().size;this.emitter.emit("frame",{elapsed:e,shapeCount:t,culledShapeCount:n,visibleShapeCount:t-n})}}_onShapesCreated(e){if(0===this.emitter.listenerCount("shapes-created"))return;let t={};for(let n of e)"shape"===n.typeName&&(t[n.type]=(t[n.type]||0)+1);let n=Object.values(t).reduce((e,t)=>e+t,0);if(0===n)return;let r={operation:"create",count:n,shapeTypes:t,timestamp:performance.now()};this.emitter.emit("shapes-created",r)}_onShapesEdited(e){if(0===this.emitter.listenerCount("shapes-updated"))return;let t={};for(let n of e)"shape"===n.typeName&&(t[n.type]=(t[n.type]||0)+1);let n=Object.values(t).reduce((e,t)=>e+t,0);if(0===n)return;let r={operation:"update",count:n,shapeTypes:t,timestamp:performance.now()};this.emitter.emit("shapes-updated",r)}_onShapesDeleted(e){if(0===this.emitter.listenerCount("shapes-deleted"))return;let t={};for(let n of e){let e=this.editor.getShape(n);e&&(t[e.type]=(t[e.type]||0)+1)}let n={operation:"delete",count:e.length,shapeTypes:t,timestamp:performance.now()};this.emitter.emit("shapes-deleted",n)}_startLoafObserver(){if("u">typeof PerformanceObserver){try{let e=PerformanceObserver.supportedEntryTypes;if(!e?.includes("long-animation-frame"))return}catch{return}this.loafObserver=new PerformanceObserver(e=>{let t=null!==this.activeInteraction,n=null!==this.activeCamera;if(t||n)for(let r of e.getEntries()){let e="number"!=typeof r.duration?null:{startTime:r.startTime,duration:r.duration,blockingDuration:r.blockingDuration??0,scripts:(r.scripts??[]).map(e=>({sourceURL:e.sourceURL??"",invoker:e.invoker??"",duration:e.duration??0}))};e&&(t&&this.activeInteraction.loafEntries.push(e),n&&this.activeCamera.loafEntries.push(e))}}),this.loafObserver.observe({type:"long-animation-frame",buffered:!1})}}_stopLoafObserver(){this.loafObserver&&(this.loafObserver.disconnect(),this.loafObserver=null)}_needsFrameListener(){return this.emitter.listenerCount("frame")>0||this.emitter.listenerCount("interaction-start")>0||this.emitter.listenerCount("interaction-end")>0||this.emitter.listenerCount("camera-start")>0||this.emitter.listenerCount("camera-end")>0}_needsLoafObserver(){return this.emitter.listenerCount("interaction-end")>0||this.emitter.listenerCount("camera-end")>0}_maybeAttachLazyListeners(e){!this.frameCleanup&&("frame"===e||"interaction-start"===e||"interaction-end"===e||"camera-start"===e||"camera-end"===e)&&this._needsFrameListener()&&(this.editor.on("frame",this._onFrame),this.frameCleanup=()=>this.editor.off("frame",this._onFrame)),!this.loafObserver&&("interaction-end"===e||"camera-end"===e)&&this._needsLoafObserver()&&this._startLoafObserver(),this.shapeCreatedCleanup||"shapes-created"!==e||(this.editor.on("created-shapes",this._onShapesCreated),this.shapeCreatedCleanup=()=>this.editor.off("created-shapes",this._onShapesCreated)),this.shapeEditedCleanup||"shapes-updated"!==e||(this.editor.on("edited-shapes",this._onShapesEdited),this.shapeEditedCleanup=()=>this.editor.off("edited-shapes",this._onShapesEdited)),this.shapeDeletedCleanup||"shapes-deleted"!==e||(this.editor.on("deleted-shapes",this._onShapesDeleted),this.shapeDeletedCleanup=()=>this.editor.off("deleted-shapes",this._onShapesDeleted))}_maybeDetachLazyListeners(e){this.frameCleanup&&("frame"===e||"interaction-start"===e||"interaction-end"===e||"camera-start"===e||"camera-end"===e)&&!this._needsFrameListener()&&(this.frameCleanup(),this.frameCleanup=null),this.loafObserver&&("interaction-end"===e||"camera-end"===e)&&!this._needsLoafObserver()&&this._stopLoafObserver(),this.shapeCreatedCleanup&&"shapes-created"===e&&0===this.emitter.listenerCount("shapes-created")&&(this.shapeCreatedCleanup(),this.shapeCreatedCleanup=null),this.shapeEditedCleanup&&"shapes-updated"===e&&0===this.emitter.listenerCount("shapes-updated")&&(this.shapeEditedCleanup(),this.shapeEditedCleanup=null),this.shapeDeletedCleanup&&"shapes-deleted"===e&&0===this.emitter.listenerCount("shapes-deleted")&&(this.shapeDeletedCleanup(),this.shapeDeletedCleanup=null)}}a([r.oI],c.prototype,"_onFrame",1),a([r.oI],c.prototype,"_onShapesCreated",1),a([r.oI],c.prototype,"_onShapesEdited",1),a([r.oI],c.prototype,"_onShapesDeleted",1)}}]);
|