{
  "version": 3,
  "sources": ["../../src/document/models/CanvasTree/utils/homeNode.ts", "../../src/document/models/CanvasTree/utils/verifyHomeNodePostProcess.ts", "../../../../services/src/generated/typescript/service-runtime/ColorSamplerHelper.ts", "../../../../services/src/generated/typescript/ColorSampler.ts", "../../../../../node_modules/@framerjs/framer-events/lib/esm/generated/PreviewShown.js", "../../src/document/VekterTool.ts", "../../src/document/utils/nodesAreSimilar.ts", "../../src/utils/cursorIcons.ts", "../../src/utils/cursor.ts", "../../src/document/models/Snapping.ts", "../../src/document/components/tools/utils/SnapTool.ts", "../../src/document/components/tools/MoveTool.ts", "../../src/prosemirror/loader.ts", "../../src/document/stores/FormsStore.ts", "../../src/document/utils/isPreviewableNode.ts", "../../src/code-generation/utils/generateComponentsForNavigationChain.ts", "../../src/preview-module/utils/entryNodeForNodeToRender.ts", "../../src/preview-module/utils/isScreenNode.ts", "../../src/document/components/chrome/preview/getRenderInfoForPreviewItem.ts", "../../src/document/models/CanvasTree/traits/WithVectorSetItems.ts", "../../src/document/preview/targetModuleRevisionsForNodeIds.ts", "../../src/document/preview/togglePreviewVisibleWithoutEngineDependency.ts", "../../src/document/preview/togglePreviewVisible.ts", "../../src/document/models/CanvasTree/traits/utils/getDimensionOrVariantDimensionType.ts", "../../src/web/pages/project/lib/ChooseFileService.ts", "../../src/document/stores/AnalyticsStore.ts", "../../src/document/LayoutCache.ts", "../../src/document/stores/ContextMenuStore.ts", "../../src/document/stores/VectorsStore.ts", "../../src/document/models/CanvasTree/traits/utils/reduceFormInputStyles.ts", "../../src/document/models/controlProps/getReducedControlProps.ts", "../../src/document/components/utils/getEditableCollectionVariableInfo.ts", "../../src/utils/scroll-into-view-if-needed/index.ts", "../../src/utils/scroll-into-view-if-needed/computeScrollIntoView.ts", "../../../../../node_modules/prosemirror-codemark/src/utils.ts", "../../../../../node_modules/prosemirror-codemark/src/inputRules.ts", "../../../../../node_modules/prosemirror-codemark/src/actions.ts", "../../../../../node_modules/prosemirror-codemark/src/plugin.ts", "../../../../../node_modules/prosemirror-codemark/src/index.ts", "../../src/prosemirror/commands.ts", "../../src/prosemirror/inputRules.ts", "../../src/prosemirror/plugins/preserveInlineStylesPlugin.ts", "../../src/document/components/tools/getUnloadedFontsForRichTextNode.ts", "../../src/document/components/utils/getMetricsInteractionSourceForScopeType.ts", "../../src/document/components/chrome/richTextEditor/richTextEditorModules.ts", "../../src/document/components/utils/handleProseMirrorPaste.ts", "../../src/prosemirror/addMedia.ts", "../../src/prosemirror/sanitizeGoogleDocs.ts", "../../src/prosemirror/serialization/domWithEngineAndHooks.ts", "../../src/prosemirror/plugins/pastePlugin.ts", "../../src/document/components/tools/richTextEditUtils.ts", "../../src/document/components/chrome/shared/ColorPicker/types.ts", "../../src/utils/clipboard/getCopiedAssets.ts", "../../src/prosemirror/getAssetReferences.ts", "../../src/document/components/tools/utils/collectImages.ts", "../../src/utils/clipboard/getClipboardData.ts", "../../src/utils/isLightOrDarkColor.ts", "../../src/utils/createCollectionItem.ts", "../../src/document/models/CanvasTree/nodes/utils/privateDraftCollectionItemHasUserData.ts", "../../src/document/components/chrome/localization/getLocalizedFallback.ts", "../../src/document/components/chrome/richTextEditor/CodeBlockView/themes/themes.ts", "../../../../../node_modules/alien-signals/esm/system.mjs", "../../../../../node_modules/alien-signals/esm/index.mjs", "../../src/document/components/chrome/localization/getLocalizationSourcesForNode.ts", "../../src/document/components/tools/utils/sampleColor.ts", "../../src/document/models/CanvasTree/nodes/utils/migrateTextNode.ts", "../../src/document/utils/migrateTextToRichTextNode.ts", "../../src/document/components/tools/gradient/utils.ts", "../../src/document/components/chrome/shared/utils/flashElement.styles.ts", "../../src/document/components/chrome/shared/utils/flashElement.ts", "../../src/document/components/chrome/shared/utils/flashPanel.ts", "../../src/document/components/chrome/properties/panels/utils/highlightPanel.ts", "../../src/document/components/chrome/shared/utils/dispatchMouseDown.ts", "../../src/utils/breadcrumbCollectionId.ts", "../../src/utils/editVariable.ts", "../../src/utils/clipboard/helpers/isFramerLayersClipboardData.ts", "../../src/utils/chunkArray.ts", "../../src/utils/clipboard/helpers/isInsertableNodeClassFromCopyTree.ts", "../../src/utils/clipboard/helpers/promptToReplaceSelectedNodeIfMatched.ts", "../../src/utils/clipboard/helpers/tree.ts", "../../src/utils/clipboard/helpers/layers.ts", "../../src/utils/getNegatedLabel.ts", "../../src/document/components/chrome/siteSettings/metadataPlaceholders.ts"],
  "sourcesContent": ["import { isDeviceNode } from \"document/models/CanvasTree/traits/utils/hardCodedCodeComponentIdentifierChecks.ts\"\n/**\n * Helper functions for dealing with the \"home nodes\" of the document.\n *\n * There's one home node per page, which serves as the entrypoint for that\n * page. We do this per page instead of one per project, so that each page can\n * become an isolated navigation flow.\n *\n * Only certain ground nodes can become home nodes.\n *\n * Home nodes are stored on the PageNode, under homeNodeId. The helper functions\n * in this module acknowledge that this value may become invalid, e.g., if\n * the corresponding node gets deleted, or moved to a different page, or nested\n * inside another node. The exported functions will try to return a valid\n * \"fallback\" node in such situations. The resetHomeNode function can also be\n * used to put the document back into a consistent state.\n */\nimport type { AnyCanvasPageNode, CanvasNode, CanvasTree } from \"../index.ts\"\nimport type { MaybeCanvasNode } from \"../nodes/CanvasNode.ts\"\nimport type { CanvasPageNode } from \"../nodes/CanvasPageNode.ts\"\nimport type { MaybeNodeID } from \"../nodes/NodeID.ts\"\nimport { isCodeComponentNode, isShapeContainerNode, isTextNode } from \"../nodes/utils/nodeCheck.ts\"\n\nfunction getUnsafeHomeNodeId(page: AnyCanvasPageNode): MaybeNodeID {\n\treturn page.homeNodeId\n}\n\n/**\n * Returns the CanvasNode referenced by PageNode.homeNodeId. This will not\n * check the validity of the homeNodeId.\n */\nfunction getUnsafeHomeNode(tree: CanvasTree, page: AnyCanvasPageNode): CanvasNode | null {\n\tconst homeNodeId = getUnsafeHomeNodeId(page)\n\treturn homeNodeId ? tree.getNode(homeNodeId) : null\n}\n\n/**\n * Returns true if the node provided is the home node for the given page. It\n * should be noted that this function behaves consistently with getHomeNode()\n * and will check the validity of the PageNode.homeNodeId in determining\n * the result.\n */\nexport function isHomeNode(tree: CanvasTree, page: CanvasPageNode, node: CanvasNode): boolean {\n\tconst homeNode = getHomeNode(tree, page)\n\treturn !!homeNode && homeNode.id === node.id\n}\n\nexport function canBeHomeNode(page: AnyCanvasPageNode, node: MaybeCanvasNode): boolean {\n\treturn node?.parentid === page.id && !isTextNode(node)\n}\n\nexport function hasValidHomeNode(tree: CanvasTree, page: CanvasPageNode): boolean {\n\tconst homeNode = tree.get(page.homeNodeId)\n\treturn canBeHomeNode(page, homeNode)\n}\n\nexport function setHomeNode(tree: CanvasTree, page: AnyCanvasPageNode, node: CanvasNode | null): void {\n\tif (node && !canBeHomeNode(page, node)) {\n\t\treturn\n\t}\n\n\tconst currentHomeNodeId = getUnsafeHomeNodeId(page)\n\tif ((node && node.id === currentHomeNodeId) || node === currentHomeNodeId) {\n\t\treturn\n\t}\n\n\tpage.set({ homeNodeId: node ? node.id : null })\n}\n\nexport function getFallbackHomeNode(tree: CanvasTree, page: AnyCanvasPageNode): CanvasNode | null {\n\t// If the current home node got moved (and potentially nested), but is still\n\t// on the same page, let's first consider its ground node for the new home node\n\tconst homeNode = tree.get(page.homeNodeId)\n\tif (homeNode) {\n\t\tconst groundNode = tree.getGroundNodeFor(homeNode)\n\t\tif (canBeHomeNode(page, groundNode)) return groundNode\n\t}\n\n\t// TODO Check and handle shallow/fully loaded scope state\n\tif (!page.isLoaded()) return null\n\n\t// Set the first viable node in the Layers panel as the fallback home node\n\tfor (let i = page.children.length - 1; i >= 0; i--) {\n\t\tconst groundNode = page.children.at(i)\n\t\tif (!groundNode) continue\n\t\tif (canBeFallbackHomeNode(page, groundNode)) return groundNode\n\t}\n\treturn null\n}\n\n// Ignore Graphics & Code Components when picking a fallback. These\n// can still be set manually if needed.\nfunction canBeFallbackHomeNode(page: AnyCanvasPageNode, node: MaybeCanvasNode): boolean {\n\tif (!node) return false\n\tif (!canBeHomeNode(page, node)) return false\n\tif (isShapeContainerNode(node)) return false\n\tif (isCodeComponentNode(node) && !isDeviceNode(node)) return false\n\treturn true\n}\n\n/**\n * Returns a CanvasNode to be used as the home node for a page. This\n * will be the node referenced by the PageNode.homeNodeId if valid otherwise\n * it will fallback to the next appropriate node.\n */\nexport function getHomeNode(tree: CanvasTree, page: CanvasPageNode): CanvasNode | null {\n\tconst node = getUnsafeHomeNode(tree, page)\n\treturn canBeHomeNode(page, node) ? node : getFallbackHomeNode(tree, page)\n}\n\nexport function resetHomeNode(tree: CanvasTree, page: AnyCanvasPageNode): void {\n\tconst fallbackNode = getFallbackHomeNode(tree, page)\n\tsetHomeNode(tree, page, fallbackNode)\n}\n", "import { getLogger } from \"@framerjs/shared\"\nimport type { VekterTool } from \"document/VekterTool.ts\"\n/**\n * Pull this module out so that /preview-next doesn't have to import\n * VekterEngine via the MoveTool module...\n */\nimport type { CanvasTree } from \"document/models/CanvasTree/CanvasTree.ts\"\nimport { Tools } from \"document/stores/ToolEnum.ts\"\nimport type { CanvasPageNode } from \"../nodes/CanvasPageNode.ts\"\nimport { hasValidHomeNode, resetHomeNode } from \"./homeNode.ts\"\n\nexport function verifyHomeNodePostProcess(tree: CanvasTree, page: CanvasPageNode, tool?: VekterTool) {\n\t// Home node may get temporarily nested while the user is still\n\t// dragging, so let's avoid resetting till MoveTool triggers on drop\n\tif (!(tool && tool.enum === Tools.Move) && !hasValidHomeNode(tree, page)) {\n\t\tresetHomeNode(tree, page)\n\t\tgetLogger(\"app\").debug(\"updated home node:\", page.id, page.homeNodeId)\n\t}\n}\n", "/*\n ****\n ******\n ******\n ******\n ****** \u267B\uFE0F Runtime helper generated by the Services build process from .d.ts. Do not modify. See the Services README for more information.\n ****** See '../' for service types.\n ******\n ******\n ******\n ****\n */\n\n// The generated service helper may or may not use some of the runtime exports. For simplicity, we import all of them.\nimport {\n\tService,\n\tServiceManager,\n\tServiceChannel,\n\tServiceMessageHelper,\n\tServiceRuntimePrivate,\n\tServiceValue,\n\tServiceStream,\n\tServiceStreamOptions,\n\tUnsafeJSON,\n\tfloat,\n\tinteger,\n\toneway,\n} from \"../../../runtime/index.ts\"\n\nimport type { ColorSampler } from \"../ColorSampler.ts\"\n\nconst { onewayMethodTemplate, voidMethodTemplate, valueMethodTemplate, streamMethodTemplate } = ServiceRuntimePrivate\n\nexport namespace ColorSamplerHelper {\n\ttype Interface = ColorSampler.Interface\n\n\texport const service: Service<Interface> = {\n\t\tid: \"__ColorSampler__\",\n\t\tfingerprint: \"2f07b191423077f3239a93a5dec7e417\",\n\t\tmethods: {\n\t\t\tsampleColor: {},\n\t\t},\n\t\tnewOutgoingWrapper: (helper: ServiceMessageHelper): Interface => {\n\t\t\treturn {\n\t\t\t\tsampleColor: valueMethodTemplate.bind(/* this: */ -1, \"sampleColor\", /* accepts argument: */ false, helper),\n\t\t\t} as Interface\n\t\t},\n\t}\n}\n", "/*\n **********\n *********\n ********\n *******\n ****** \u267B\uFE0F Generated by the Services build process from .d.ts. Do not modify. See the Services README for more information.\n *****\n ****\n ***\n **\n */\n\n// The generated namespace may or may not use some of the runtime exports. For simplicity, we import all of them.\nimport type {\n\tService,\n\tServiceChannel,\n\tServiceMessageHelper,\n\tServiceRuntimePrivate,\n\tServiceValue,\n\tServiceStream,\n\tServiceStreamOptions,\n\tUnsafeJSON,\n\tfloat,\n\tinteger,\n\toneway,\n} from \"../../runtime/index.ts\"\nimport { ServiceManager } from \"../../runtime/index.ts\"\n\n// The generated namespace may or may not use some of the global types. For simplicity, we import all of them.\nimport type {\n\tPoint,\n\tSize,\n\tRect,\n\tUser,\n\tColor,\n\tMenuAction,\n\tMenuValidationResult,\n\tMenuDispatchResult,\n\tMenuActionState,\n\tArea,\n\tContextMenu,\n\tMenuOptionIconCrossOrigin,\n\tMenuOptionIcon,\n\tMenuItemOptions,\n\tContextMenuResult,\n} from \"./Global.ts\"\n\n// Import the service implementation\nimport { ColorSamplerHelper } from \"./service-runtime/ColorSamplerHelper.ts\"\n\nimport type { SharedService } from \"./SharedService.ts\"\n\nexport namespace ColorSampler {\n\t/**\n\t * ColorSampler is not documented.\n\t */\n\texport interface Interface {\n\t\tsampleColor(): Promise<Color>\n\t}\n\n\t/*\n\t * Using the service\n\t */\n\n\texport const service: Service<Interface> = ColorSamplerHelper.service\n\n\texport function on(channel: ServiceChannel): SharedService<Interface> {\n\t\t// Note: capture the shared service manager here so testing behavior is predictable\n\t\tconst sharedServices = ServiceManager.shared()\n\t\treturn {\n\t\t\texpect: () => sharedServices.expectWithoutDiscovery(service, channel),\n\t\t\tdiscover: options => sharedServices.discover(service, channel, options),\n\t\t\tregister: implementation => sharedServices.register({ channel, service, implementation }),\n\t\t}\n\t}\n\n\texport async function unregister(implementation: Interface): Promise<void> {\n\t\tvoid ServiceManager.shared().unregister(implementation)\n\t}\n}\n", "import { triggerEvent } from \"../listeners\";\nfunction createPreviewShownEvent(payload) {\n  console.warn(\"[DEPRECATED] Use triggerPreviewShownEvent instead of createPreviewShownEvent.\");\n  return {\n    ...payload,\n    event: \"preview_shown\"\n  };\n}\nconst meta = {\n  track: true\n};\nfunction triggerPreviewShownEvent(payload) {\n  const event = {\n    ...payload,\n    event: \"preview_shown\"\n  };\n  triggerEvent(event, meta);\n}\nexport {\n  createPreviewShownEvent,\n  triggerPreviewShownEvent\n};\n", "import type { VekterEngine } from \"document/VekterEngine.ts\"\nimport { Tools } from \"document/stores/ToolStore.ts\"\nimport { withClassDiscriminator } from \"utils/withClassDiscriminator.ts\"\n\n/* eslint-disable @typescript-eslint/no-use-before-define */\n// can only change the state of the VekterEngine in the update() method\n// which is always called between start() and stop() no other tool manipulates\n// Drawables as long as this tool has not been stopped()\nexport class VekterTool extends withClassDiscriminator(\"VekterTool\") {\n\treadonly enum: Tools = Tools.Unknown\n\treadonly wantsAutoscrolling?: boolean = false\n\treadonly engine: VekterEngine\n\n\tstart(): void {}\n\tstop(): void {}\n\tcancel?(): void {}\n\tupdate(): void {}\n\n\tonKeyDown?: (event: KeyboardEvent) => void\n\tonKeyPress?: (event: KeyboardEvent) => void\n\tonKeyUp?: (event: KeyboardEvent) => void\n\n\tselectAll?(): void\n\tundo?(): void\n\tredo?(): void\n\n\tdisplaySelectionBox?: boolean = false\n\tdisplaySelectionHandles?: boolean = false\n\tdisplayPaddingHandles?: boolean = false\n\tdisplayGapHandles?: boolean = false\n\tdisplayViewportHandle?: boolean = false\n\tdisplayViewportLabel?: boolean = false\n\tcmsBadge?: \"visible\" | \"hidden\" | \"disabled\" = \"hidden\"\n\n\t/** Optionally keep track of the previous tool that triggered this tool */\n\tfromTool?: Tools = undefined\n\n\tdeleteAction?(): void\n\t// Must be implemented when implementing `deleteAction`\n\tcanDelete?(): boolean\n\n\tconstructor(engine: VekterEngine, _options?: unknown) {\n\t\tsuper()\n\t\tthis.engine = engine\n\t}\n}\n\nexport interface VekterToolClass {\n\tnew (engine: VekterEngine, options?: unknown): VekterTool\n}\n", "import type { CanvasNode } from \"document/models/CanvasTree/index.ts\"\nimport { isEqual } from \"library/index.ts\"\n\nexport function nodesAreSimilar(nodeA: CanvasNode, nodeB: CanvasNode): boolean {\n\tif (nodeA === nodeB) {\n\t\treturn true\n\t}\n\tif (nodeA.constructor !== nodeB.constructor) {\n\t\treturn false\n\t}\n\tconst nodeAKeys = nodeA.keys()\n\tfor (const key of nodeAKeys) {\n\t\t// NOTE: This is very fragile!\n\t\tswitch (key) {\n\t\t\tcase \"id\":\n\t\t\tcase \"left\":\n\t\t\tcase \"right\":\n\t\t\tcase \"top\":\n\t\t\tcase \"bottom\":\n\t\t\tcase \"widthFactor\":\n\t\t\tcase \"heightFactor\":\n\t\t\tcase \"centerAnchorX\":\n\t\t\tcase \"centerAnchorY\":\n\t\t\tcase \"children\":\n\t\t\tcase \"parentid\":\n\t\t\tcase \"styledText\":\n\t\t\tcase \"cache\":\n\t\t\tcase \"update\":\n\t\t\tcase \"mutable\":\n\t\t\tcase \"isMaster\":\n\t\t\tcase \"originalid\":\n\t\t\tcase \"replicaInfo\":\n\t\t\tcase \"duplicatedFrom\":\n\t\t\t\tcontinue\n\t\t}\n\t\tif (key.startsWith(\"_\")) {\n\t\t\tcontinue\n\t\t}\n\t\tlet valueA = nodeA[key]\n\t\tlet valueB = nodeB[key]\n\n\t\tif (key === \"rotation\") {\n\t\t\tvalueA = valueA ?? 0\n\t\t\tvalueB = valueB ?? 0\n\t\t}\n\n\t\tif (!isEqual(valueA, valueB)) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n", "import cursorAdd from \"./cursors/cursor-add.png\"\nimport cursorAdd2x from \"./cursors/cursor-add@2x.png\"\nimport cursorComment from \"./cursors/cursor-comment.png\"\nimport cursorComment2x from \"./cursors/cursor-comment@2x.png\"\nimport cursorDisconnect from \"./cursors/cursor-disconnect.png\"\nimport cursorDisconnect2x from \"./cursors/cursor-disconnect@2x.png\"\nimport cursorFeedback from \"./cursors/cursor-feedback.png\"\nimport cursorFeedback2x from \"./cursors/cursor-feedback@2x.png\"\n// Grab Cursors\nimport cursorGrab from \"./cursors/cursor-grab.png\"\nimport cursorGrab2x from \"./cursors/cursor-grab@2x.png\"\nimport cursorGrabbing from \"./cursors/cursor-grabbing.png\"\nimport cursorGrabbing2x from \"./cursors/cursor-grabbing@2x.png\"\nimport cursorInsert from \"./cursors/cursor-insert.png\"\nimport cursorInsert2x from \"./cursors/cursor-insert@2x.png\"\nimport cursorRemove from \"./cursors/cursor-remove.png\"\nimport cursorRemove2x from \"./cursors/cursor-remove@2x.png\"\nimport cursorSwap from \"./cursors/cursor-swap.png\"\nimport cursorSwap2x from \"./cursors/cursor-swap@2x.png\"\nimport cursorVectorAdd from \"./cursors/cursor-vector-add.png\"\nimport cursorVectorAdd2x from \"./cursors/cursor-vector-add@2x.png\"\nimport cursorVectorPoint from \"./cursors/cursor-vector-point.png\"\nimport cursorVectorPoint2x from \"./cursors/cursor-vector-point@2x.png\"\nimport cursorVector from \"./cursors/cursor-vector.png\"\nimport cursorVector2x from \"./cursors/cursor-vector@2x.png\"\nimport cursorZoomIn from \"./cursors/cursor-zoom-in.png\"\nimport cursorZoomIn2x from \"./cursors/cursor-zoom-in@2x.png\"\nimport cursorZoomOut from \"./cursors/cursor-zoom-out.png\"\nimport cursorZoomOut2x from \"./cursors/cursor-zoom-out@2x.png\"\n// Resize Cursors\nimport resizeEastWest from \"./cursors/resize-east-west.png\"\nimport resizeEastWest2x from \"./cursors/resize-east-west@2x.png\"\nimport resizeEast from \"./cursors/resize-east.png\"\nimport resizeEast2x from \"./cursors/resize-east@2x.png\"\nimport resizeNESW from \"./cursors/resize-nesw.png\"\nimport resizeNESW2x from \"./cursors/resize-nesw@2x.png\"\nimport resizeNorthEast from \"./cursors/resize-north-east.png\"\nimport resizeNorthEast2x from \"./cursors/resize-north-east@2x.png\"\nimport resizeNorthSouth from \"./cursors/resize-north-south.png\"\nimport resizeNorthSouth2x from \"./cursors/resize-north-south@2x.png\"\nimport resizeNorthWest from \"./cursors/resize-north-west.png\"\nimport resizeNorthWest2x from \"./cursors/resize-north-west@2x.png\"\nimport resizeNorth from \"./cursors/resize-north.png\"\nimport resizeNorth2x from \"./cursors/resize-north@2x.png\"\nimport resizeNWSE from \"./cursors/resize-nwse.png\"\nimport resizeNWSE2x from \"./cursors/resize-nwse@2x.png\"\nimport resizeSouthEast from \"./cursors/resize-south-east.png\"\nimport resizeSouthEast2x from \"./cursors/resize-south-east@2x.png\"\nimport resizeSouthWest from \"./cursors/resize-south-west.png\"\nimport resizeSouthWest2x from \"./cursors/resize-south-west@2x.png\"\nimport resizeSouth from \"./cursors/resize-south.png\"\nimport resizeSouth2x from \"./cursors/resize-south@2x.png\"\nimport resizeWest from \"./cursors/resize-west.png\"\nimport resizeWest2x from \"./cursors/resize-west@2x.png\"\n// Touch Cursors\nimport touchActive from \"./cursors/touch-active.png\"\nimport touchActive2x from \"./cursors/touch-active@2x.png\"\nimport touch from \"./cursors/touch.png\"\nimport touch2x from \"./cursors/touch@2x.png\"\n\nexport type CursorIconName = keyof typeof cursorIcons\n\nexport const cursorIcons = {\n\t\"cursor-add\": [cursorAdd, cursorAdd2x],\n\t\"cursor-disconnect\": [cursorDisconnect, cursorDisconnect2x],\n\t\"cursor-comment\": [cursorComment, cursorComment2x],\n\t\"cursor-feedback\": [cursorFeedback, cursorFeedback2x],\n\t\"cursor-grab\": [cursorGrab, cursorGrab2x],\n\t\"cursor-grabbing\": [cursorGrabbing, cursorGrabbing2x],\n\t\"cursor-insert\": [cursorInsert, cursorInsert2x],\n\t\"cursor-remove\": [cursorRemove, cursorRemove2x],\n\t\"cursor-swap\": [cursorSwap, cursorSwap2x],\n\t\"cursor-vector-add\": [cursorVectorAdd, cursorVectorAdd2x],\n\t\"cursor-vector-point\": [cursorVectorPoint, cursorVectorPoint2x],\n\t\"cursor-vector\": [cursorVector, cursorVector2x],\n\t\"cursor-zoom-in\": [cursorZoomIn, cursorZoomIn2x],\n\t\"cursor-zoom-out\": [cursorZoomOut, cursorZoomOut2x],\n\t\"resize-nesw\": [resizeNESW, resizeNESW2x],\n\t\"resize-nwse\": [resizeNWSE, resizeNWSE2x],\n\t\"resize-north-east\": [resizeNorthEast, resizeNorthEast2x],\n\t\"resize-north-west\": [resizeNorthWest, resizeNorthWest2x],\n\t\"resize-south-east\": [resizeSouthEast, resizeSouthEast2x],\n\t\"resize-south-west\": [resizeSouthWest, resizeSouthWest2x],\n\t\"resize-east-west\": [resizeEastWest, resizeEastWest2x],\n\t\"resize-west\": [resizeWest, resizeWest2x],\n\t\"resize-east\": [resizeEast, resizeEast2x],\n\t\"resize-north-south\": [resizeNorthSouth, resizeNorthSouth2x],\n\t\"resize-north\": [resizeNorth, resizeNorth2x],\n\t\"resize-south\": [resizeSouth, resizeSouth2x],\n\t\"touch-active\": [touchActive, touchActive2x],\n\ttouch: [touch, touch2x],\n}\n", "import { assert } from \"@framerjs/shared\"\nimport { isFirefox } from \"@framerjs/shared/src/environment.ts\"\nimport type { ConstrainedAxes } from \"document/models/CanvasTree/traits/WithSizeConstraints.ts\"\nimport type { FramePoint, FramePoints } from \"document/models/FramePoint.ts\"\nimport { Polygon } from \"library/index.ts\"\nimport { Point } from \"library/render/types/Point.ts\"\nimport type { MirroredCursorAxes } from \"./constrainedResizingCursor.ts\"\nimport { CursorIndex } from \"./constrainedResizingCursor.ts\"\nimport type { CursorIconName } from \"./cursorIcons.ts\"\nimport { cursorIcons } from \"./cursorIcons.ts\"\nimport { isNumber } from \"./typeChecks.ts\"\n\nexport const cursorImage = (name: CursorIconName, offset: number | Point = 16): string => {\n\tconst offsetX = isNumber(offset) ? offset : offset.x\n\tconst offsetY = isNumber(offset) ? offset : offset.y\n\tconst [imagePath, imagePath2x] = cursorIcons[name]\n\n\tif (isFirefox()) {\n\t\treturn `url(${imagePath}) ${offsetX} ${offsetY}, auto`\n\t}\n\n\treturn `-webkit-image-set(url(${imagePath}) 1x, url(${imagePath2x}) 2x) ${offsetX} ${offsetY}, default`\n}\n\nconst vectorCursorOffset: Point = { x: 6, y: 2 }\n\nexport const pathExtensionCursor = cursorImage(\"cursor-vector\", vectorCursorOffset)\n\nexport const pathCurveSplitCursor = cursorImage(\"cursor-vector-add\", vectorCursorOffset)\n\nexport const pathClosingCursor = cursorImage(\"cursor-vector-point\", vectorCursorOffset)\n\nexport const disconnectCursor = cursorImage(\"cursor-disconnect\", { x: 5, y: 5 })\n\nexport const addCursor = cursorImage(\"cursor-add\", { x: 5, y: 5 })\n\nexport const removeCursor = cursorImage(\"cursor-remove\", { x: 5, y: 5 })\n\nexport const swapCursor = cursorImage(\"cursor-swap\", { x: 5, y: 5 })\n\nexport const feedbackCursor = cursorImage(\"cursor-feedback\", { x: 15, y: 15 })\n\nexport const commentCursor = cursorImage(\"cursor-comment\", { x: 15, y: 15 })\n\nconst insertCursorOffset = { x: 16, y: 16 }\n\nexport const insertCursor = cursorImage(\"cursor-insert\", insertCursorOffset)\n\nexport const zoomInCursor = cursorImage(\"cursor-zoom-in\", insertCursorOffset)\n\nexport const zoomOutCursor = cursorImage(\"cursor-zoom-out\", insertCursorOffset)\n\nexport const grabbingCursor = cursorImage(\"cursor-grabbing\", insertCursorOffset)\n\nconst getFlippedHandleIndex = (index: number, invertedAxes: MirroredCursorAxes) => {\n\tswitch (index) {\n\t\tcase 0: {\n\t\t\tif (invertedAxes.x && invertedAxes.y) return 8\n\t\t\tif (invertedAxes.x) return 6\n\t\t\tif (invertedAxes.y) return 2\n\t\t\tbreak\n\t\t}\n\n\t\tcase 1: {\n\t\t\tif (invertedAxes.x) return 7\n\t\t\tbreak\n\t\t}\n\t\tcase 2: {\n\t\t\tif (invertedAxes.x && invertedAxes.y) return 6\n\t\t\tif (invertedAxes.x) return 8\n\t\t\tif (invertedAxes.y) return 0\n\t\t\tbreak\n\t\t}\n\t\tcase 3: {\n\t\t\tif (invertedAxes.y) return 5\n\t\t\tbreak\n\t\t}\n\t\tcase 5: {\n\t\t\tif (invertedAxes.y) return 3\n\t\t\tbreak\n\t\t}\n\t\tcase 6: {\n\t\t\tif (invertedAxes.x && invertedAxes.y) return 2\n\t\t\tif (invertedAxes.x) return 0\n\t\t\tif (invertedAxes.y) return 8\n\t\t\tbreak\n\t\t}\n\t\tcase 7: {\n\t\t\tif (invertedAxes.x) return 1\n\t\t\tbreak\n\t\t}\n\t\tcase 8: {\n\t\t\tif (invertedAxes.x && invertedAxes.y) return 0\n\t\t\tif (invertedAxes.x) return 2\n\t\t\tif (invertedAxes.y) return 6\n\t\t\tbreak\n\t\t}\n\t\tdefault:\n\t\t\tbreak\n\t}\n\n\treturn index\n}\n\nconst getDiagonalHandleIndex = (index: number) => {\n\treturn 8 - index\n}\n\nconst rotationForResizeCursor = (handle: FramePoint, framePoints: FramePoints, invertedAxes: MirroredCursorAxes) => {\n\tconst { fx, fy } = handle\n\tconst handleIndex = framePoints.findIndex(framePoint => framePoint.fx === fx && framePoint.fy === fy)\n\tconst activeIndex = getFlippedHandleIndex(handleIndex, invertedAxes)\n\tconst activeHandle = framePoints[activeIndex]\n\tassert(activeHandle, \"handle must be defined\", activeHandle, framePoints)\n\n\tconst oppositeHandleIndex = getDiagonalHandleIndex(activeIndex)\n\tconst oppositeHandle = framePoints[oppositeHandleIndex]\n\tassert(oppositeHandle, \"handle must be defined\", oppositeHandle, framePoints)\n\n\treturn Point.angleFromX(oppositeHandle, activeHandle)\n}\n\nconst getCursorDirection = (handleIndex: number) => {\n\tswitch (handleIndex) {\n\t\tcase 0:\n\t\t\treturn CursorIndex.NorthWest\n\t\tcase 1:\n\t\t\treturn CursorIndex.North\n\t\tcase 2:\n\t\t\treturn CursorIndex.NorthEast\n\t\tcase 3:\n\t\t\treturn CursorIndex.West\n\t\tcase 5:\n\t\t\treturn CursorIndex.East\n\t\tcase 6:\n\t\t\treturn CursorIndex.SouthWest\n\t\tcase 7:\n\t\t\treturn CursorIndex.South\n\t\tcase 8:\n\t\t\treturn CursorIndex.SouthEast\n\t}\n}\n\nconst resizeCursorEast = (rotation: number) => {\n\treturn `url(\"data:image/svg+xml,<svg width='32' height='32' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'><defs><path fill-rule='evenodd' clip-rule='evenodd' d='M16 9C17.103 9 18 9.897 18 11V21C18 22.103 17.103 23 16 23C14.897 23 14 22.103 14 21V11C14 9.897 14.897 9 16 9ZM21.3564 12.2148C21.5684 12.2148 21.7824 12.2658 21.9734 12.3608L26.7354 14.7438C27.2064 14.9788 27.4994 15.4518 27.5004 15.9788C27.5004 16.5068 27.2074 16.9808 26.7364 17.2158L21.9744 19.5988C21.7834 19.6948 21.5694 19.7458 21.3564 19.7458C20.5934 19.7458 19.9734 19.1248 19.9734 18.3618V13.5978C19.9734 13.2188 20.1234 12.8648 20.3964 12.6028C20.6554 12.3528 20.9974 12.2148 21.3564 12.2148Z' id='b'/><filter x='-50%25' y='-50%25' width='200%25' height='200%25' filterUnits='objectBoundingBox' id='a'><feGaussianBlur stdDeviation='1' in='SourceAlpha' result='shadowBlurOuter1'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.4 0' in='shadowBlurOuter1'/></filter></defs><g fill='none' fill-rule='evenodd'><g transform='translate(0, 1)'><use fill='%23000' filter='url(%23a)' xlink:href='%23b' transform='rotate(${rotation} 0 0)' transform-origin='center center'/></g><g transform='rotate(${rotation} 0 0)' transform-origin='center center'><use fill='%23FFF' xlink:href='%23b'/><path fill-rule='evenodd' clip-rule='evenodd' d='M16 10C16.552 10 17 10.448 17 11V21C17 21.552 16.552 22 16 22C15.448 22 15 21.552 15 21V11C15 10.448 15.448 10 16 10ZM26.2884 15.638L21.5274 13.256C21.2734 13.129 20.9734 13.314 20.9734 13.598V18.362C20.9734 18.647 21.2734 18.832 21.5274 18.705L26.2884 16.322C26.5704 16.181 26.5704 15.779 26.2884 15.638Z' fill='%23000'/></g></g></svg>\") 16 16, pointer`\n}\n\nconst resizeCursorEastWest = (rotation: number) => {\n\treturn `url(\"data:image/svg+xml,<svg width='32' height='32' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'><defs><path d='m20.252 20.196 5.006-2.898a1.5 1.5 0 0 0 0-2.596l-5.006-2.898A1.5 1.5 0 0 0 18 13.102v5.796a1.5 1.5 0 0 0 2.252 1.298Zm-8.504 0-5.006-2.898a1.5 1.5 0 0 1 0-2.596l5.006-2.898A1.5 1.5 0 0 1 14 13.102v5.796a1.5 1.5 0 0 1-2.111 1.37l-.14-.072Z' id='b'/><filter x='-50%25' y='-50%25' width='200%25' height='200%25' filterUnits='objectBoundingBox' id='a'><feGaussianBlur stdDeviation='1' in='SourceAlpha' result='shadowBlurOuter1'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.4 0' in='shadowBlurOuter1'/></filter></defs><g fill='none' fill-rule='evenodd'><g transform='translate(0, 1)'><use fill='%23000' filter='url(%23a)' xlink:href='%23b' transform='rotate(${rotation} 0 0)' transform-origin='center center'/></g><g transform='rotate(${rotation} 0 0)' transform-origin='center center'><use fill='%23FFF' xlink:href='%23b'/><path d='m19.75 19.317 5-2.884a.5.5 0 0 0 0-.866l-5-2.884a.5.5 0 0 0-.75.433v5.768a.5.5 0 0 0 .67.47l.08-.037Zm-7.5 0-5-2.884a.5.5 0 0 1 0-.866l5-2.884a.5.5 0 0 1 .75.433v5.768a.5.5 0 0 1-.75.433Z' fill='%23000'/></g></g></svg>\") 16 16, pointer`\n}\n\nconst flip = (angle: number) => angle + 180\n\nconst resizeCursor = (handleIndex: number, constraints: ConstrainedAxes | null, rotation: number) => {\n\tif (constraints) {\n\t\tconst lockedX = constraints.x.max && constraints.x.min\n\t\tconst lockedY = constraints.y.max && constraints.y.min\n\t\tconst cursorDirection = getCursorDirection(handleIndex)\n\n\t\tconst vertical = cursorDirection === CursorIndex.North || cursorDirection === CursorIndex.South\n\t\tconst horizontal = cursorDirection === CursorIndex.West || cursorDirection === CursorIndex.East\n\t\tif (vertical && lockedY) return\n\t\tif (horizontal && lockedX) return\n\n\t\tif (horizontal && constraints.x.max) return resizeCursorEast(flip(rotation))\n\t\tif (horizontal && constraints.x.min) return resizeCursorEast(rotation)\n\n\t\tif (vertical && constraints.y.max) return resizeCursorEast(flip(rotation))\n\t\tif (vertical && constraints.y.min) return resizeCursorEast(rotation)\n\n\t\tconst diagonal =\n\t\t\tcursorDirection === CursorIndex.NorthWest ||\n\t\t\tcursorDirection === CursorIndex.SouthWest ||\n\t\t\tcursorDirection === CursorIndex.NorthEast ||\n\t\t\tcursorDirection === CursorIndex.SouthEast\n\n\t\tif (diagonal && constraints.x.max && constraints.y.max) return resizeCursorEast(flip(rotation))\n\t\tif (diagonal && constraints.x.min && constraints.y.min) return resizeCursorEast(rotation)\n\t}\n\n\treturn resizeCursorEastWest(rotation)\n}\n\nexport const resizing = (\n\thandle: FramePoint,\n\tframePoints: FramePoints,\n\tconstraints: ConstrainedAxes | null,\n\tinvertedAxes: MirroredCursorAxes = {},\n): string | undefined => {\n\tconst handleIndex = framePoints.findIndex(framePoint => framePoint.fx === handle.fx && framePoint.fy === handle.fy)\n\tif (handleIndex < -1) return\n\n\treturn resizeCursor(handleIndex, constraints, rotationForResizeCursor(handle, framePoints, invertedAxes))\n}\n\nconst getSiblingRotationHandlesIndexes = (handleIndex: number) => {\n\tswitch (handleIndex) {\n\t\tcase 0:\n\t\t\treturn [6, 2]\n\t\tcase 2:\n\t\t\treturn [0, 8]\n\t\tcase 8:\n\t\t\treturn [2, 6]\n\t\tcase 6:\n\t\t\treturn [8, 0]\n\t\tdefault:\n\t\t\treturn [8, 0]\n\t}\n}\n\n/**\n * Imagine drawing a line that travels through the corner dividing the inner corner angle in half, the rotation we need\n * is the angle (\u03B1) between the extension of the line and the x axis.\n *\n *                     x\n *                    x\n *                   x \u03B1\n *  \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510 \u2500 \u2500 \u2500 \u2500 \u2500\n *  \u2502             x \u2502\n *  \u2502            x  \u2502\n *  \u2502           x   \u2502\n *  \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n\n */\nconst rotationForRotationCursor = (handle: FramePoint, framePoints: FramePoints) => {\n\tconst { fx, fy } = handle\n\tconst handleIndex = framePoints.findIndex(framePoint => framePoint.fx === fx && framePoint.fy === fy)\n\tconst latestHandle = framePoints[handleIndex]\n\tassert(latestHandle, \"handle must be defined\", latestHandle, framePoints)\n\n\tconst [prevIndex, nextIndex] = getSiblingRotationHandlesIndexes(handleIndex)\n\tconst prevHandle = framePoints[prevIndex]\n\tconst nextHandle = framePoints[nextIndex]\n\tassert(prevHandle && nextHandle, \"handle must be defined\", prevIndex, nextIndex, framePoints)\n\n\tconst prevEdgeAngle = Point.angleFromX(latestHandle, prevHandle)\n\tconst nextEdgeAngle = Point.angleFromX(latestHandle, nextHandle)\n\tconst angleBetweenEdges = Math.abs(prevEdgeAngle - nextEdgeAngle)\n\tconst halfAngle = (angleBetweenEdges > 180 ? 360 - angleBetweenEdges : angleBetweenEdges) / 2\n\n\tconst directionEdge = [framePoints[0], framePoints[4], framePoints[2]]\n\t// The rect can be flipped by rotate X/Y, we need to pick the base edge differently\n\tconst baseEdgeAngle = Polygon.isClockwise(directionEdge) ? prevEdgeAngle : nextEdgeAngle\n\tconst middleAngle = baseEdgeAngle + halfAngle\n\tconst oppositeMiddleAngle = middleAngle - 180\n\n\treturn oppositeMiddleAngle\n}\n\nexport const rotationCursorSouthNorth = (rotation: number) => {\n\treturn `url(\"data:image/svg+xml,<svg width='32' height='32' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'><defs><path d='M13.6614 7.0093L13.8655 7.04543L18.2004 8.12942C19.3315 8.41227 19.7211 9.82063 18.8967 10.645L18.2864 11.2544C20.3261 13.9396 20.3266 17.6871 18.2873 20.3726L18.8967 20.982C19.7212 21.8064 19.3315 23.2158 18.2004 23.4986L13.8655 24.5816C12.767 24.8562 11.7719 23.8616 12.0461 22.7632L13.1301 18.4282L13.1955 18.2251C13.586 17.2529 14.8727 16.9582 15.6457 17.731L16.1321 18.2173C17.0452 16.7509 17.0457 14.8749 16.1321 13.4087L15.6457 13.896C14.8213 14.7204 13.413 14.3308 13.1301 13.1997L12.0461 8.86477C11.7887 7.83475 12.6477 6.89604 13.6614 7.0093Z' id='b'/><filter x='-50%25' y='-50%25' width='200%25' height='200%25' filterUnits='objectBoundingBox' id='a'><feGaussianBlur stdDeviation='1' in='SourceAlpha' result='shadowBlurOuter1'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.4 0' in='shadowBlurOuter1'/></filter></defs><g fill='none' fill-rule='evenodd'><g transform='translate(0, 1)'><use fill='%23000' filter='url(%23a)' xlink:href='%23b' transform='rotate(${rotation} 0 0)' transform-origin='center center'/></g><g transform='rotate(${rotation} 0 0)' transform-origin='center center'><use fill='%23FFF' xlink:href='%23b'/><path d='M14.1003 12.957L13.0166 8.62221C12.9251 8.25602 13.2568 7.92432 13.6229 8.01587L17.9578 9.09958C18.3348 9.19384 18.4649 9.66339 18.19 9.9382L14.9389 13.1893C14.6641 13.4641 14.1946 13.3341 14.1003 12.957Z' fill='%23000'/><path d='M16.6495 10.9417C19.5422 13.5453 19.5422 18.0823 16.6495 20.6858L15.9795 19.9417C18.431 17.7354 18.431 13.8922 15.9795 11.6858L16.6495 10.9417Z' fill='%23000'/><path d='M14.1003 18.6705L13.0166 23.0053C12.9251 23.3715 13.2568 23.7032 13.6229 23.6116L17.9578 22.5279C18.3348 22.4337 18.4649 21.9641 18.19 21.6893L14.9389 18.4382C14.6641 18.1634 14.1946 18.2934 14.1003 18.6705Z' fill='%23000'/></g></g></svg>\") 16 16, pointer`\n}\n\nexport const rotating = (handle: FramePoint, framePoints: FramePoints) => {\n\treturn rotationCursorSouthNorth(rotationForRotationCursor(handle, framePoints))\n}\n", "import { roundedPoint } from \"document/components/tools/pathEdit/utils/index.ts\"\nimport { PointRounding } from \"document/stores/PathSelectionStore.ts\"\nimport { Line } from \"library/render/types/Line.ts\"\nimport { Point } from \"library/render/types/Point.ts\"\nimport { Rect } from \"library/render/types/Rect.ts\"\n\ntype Location = Rect | Point\n\nexport interface OrthogonalLines {\n\tx: Set<number>\n\ty: Set<number>\n}\n\nexport interface SiblingDistances {\n\tverticalDistances: ReadonlyMap<number, Rect[]>\n\thorizontalDistances: ReadonlyMap<number, Rect[]>\n\tsiblingFrames: Rect[]\n}\n\nexport interface SnapInfo {\n\tpoint: Partial<Point>\n\tsnapLines: OrthogonalLines\n}\n\ninterface LinesInRange {\n\tx: SnapOptions\n\ty: SnapOptions\n}\n\ntype SnapOption = [number, Set<number>] | undefined\n\ninterface SnapResult {\n\tx: SnapOption\n\ty: SnapOption\n}\n\n// key: snap value -> lines\ntype SnapOptions = Map<number, Set<number>>\n\nexport const snappingThreshold = (zoom: number) => {\n\treturn Math.max(0.5, 4 / zoom)\n}\n\nconst constraintSnappingThreshold = (zoom: number) => {\n\treturn Math.max(0.5, 16 / zoom)\n}\n\nexport const snappingData = (boundingBoxes: Rect[], zoom?: number, pathEditModeActive?: boolean) => {\n\tconst xDirection = new Set<number>()\n\tconst yDirection = new Set<number>()\n\n\tboundingBoxes.forEach(box => {\n\t\tif (zoom !== undefined) {\n\t\t\tconst renderedWidth = box.width * zoom\n\t\t\tconst renderedHeight = box.height * zoom\n\t\t\tif (renderedWidth < 12 && renderedHeight < 12) {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tconst pointRounding = pathEditModeActive ? PointRounding.Half : PointRounding.Full\n\t\tconst { x: minX, y: minY } = roundedPoint({ x: box.x, y: box.y }, pointRounding)\n\t\tconst { x: midX, y: midY } = roundedPoint({ x: box.x + box.width / 2, y: box.y + box.height / 2 }, pointRounding)\n\t\tconst { x: maxX, y: maxY } = roundedPoint({ x: box.x + box.width, y: box.y + box.height }, pointRounding)\n\n\t\txDirection.add(minX).add(midX).add(maxX)\n\t\tyDirection.add(minY).add(midY).add(maxY)\n\t})\n\treturn { x: xDirection, y: yDirection }\n}\n\nconst snapLinesInRange = (values: Set<number>, isVertical: boolean, location: Location, threshold: number) => {\n\tlet result: SnapOptions = new Map()\n\n\tconst min: number = isVertical ? location.x : location.y\n\tlet mid: number | null = null\n\tlet max: number | null = null\n\n\tif (typeof location[\"width\"] === \"number\" && typeof location[\"height\"] === \"number\") {\n\t\tconst { width, height } = location as Rect\n\t\tmid = isVertical ? location.x + width / 2 : location.y + height / 2\n\t\tmax = isVertical ? location.x + width : location.y + height\n\t}\n\n\tvalues.forEach((value: number) => {\n\t\tconst minPointDistance = Math.abs(min - value)\n\t\tconst midPointDistance = Math.abs((mid || 0) - value)\n\t\tconst maxPointDistance = Math.abs((max || 0) - value)\n\t\tlet frameValue: number | null = null\n\t\tif (minPointDistance < threshold) {\n\t\t\tframeValue = value\n\t\t} else if (mid !== null && midPointDistance < threshold) {\n\t\t\tframeValue = value - Math.abs(mid - min)\n\t\t} else if (max !== null && maxPointDistance < threshold) {\n\t\t\tframeValue = value - Math.abs(max - min)\n\t\t}\n\t\tif (frameValue !== null) {\n\t\t\tconst fallbackResult = new Set<number>()\n\t\t\tconst existingResult = result.get(frameValue) ?? fallbackResult\n\t\t\tresult = result.set(frameValue, existingResult.add(value))\n\t\t}\n\t})\n\treturn result\n}\n\nconst linesInRange = (lines: OrthogonalLines, location: Location, threshold: number): LinesInRange => {\n\tconst xOptions = snapLinesInRange(lines.x, true, location, threshold)\n\tconst yOptions = snapLinesInRange(lines.y, false, location, threshold)\n\treturn { x: xOptions, y: yOptions }\n}\n\nconst pickBestFromSnapOptions = (options: SnapOptions, excludeValue?: number) => {\n\tlet bestSize = 0\n\tlet best: SnapOption | undefined\n\n\toptions.forEach((value: Set<number>, key: number) => {\n\t\tif (excludeValue !== undefined && key === excludeValue) {\n\t\t\treturn\n\t\t}\n\t\tif (value.size > bestSize) {\n\t\t\tbestSize = value.size\n\t\t\tbest = [key, value]\n\t\t}\n\t})\n\treturn best\n}\n\nconst pickBest = (lines: LinesInRange, excludePoint?: Point): SnapResult => {\n\tconst x = pickBestFromSnapOptions(lines.x, excludePoint ? excludePoint.x : undefined)\n\tconst y = pickBestFromSnapOptions(lines.y, excludePoint ? excludePoint.y : undefined)\n\treturn { x, y }\n}\n\nconst extendLinesWithExtraBoundingBoxes = (lines: OrthogonalLines, extraBoundingBoxes?: Rect[]) => {\n\tif (!extraBoundingBoxes) {\n\t\treturn lines\n\t}\n\tconst extra = snappingData(extraBoundingBoxes)\n\n\treturn {\n\t\tx: new Set([...lines.x, ...extra.x]),\n\t\ty: new Set([...lines.y, ...extra.y]),\n\t}\n}\n\nexport const snap = <L extends Location>(\n\tlines: OrthogonalLines,\n\tzoom: number,\n\tlocation: L,\n\texcludePoint?: Point,\n\textraBoundingBoxes?: Rect[],\n): SnapInfo => {\n\tlines = extendLinesWithExtraBoundingBoxes(lines, extraBoundingBoxes)\n\tconst threshold = snappingThreshold(zoom)\n\tconst inRange = linesInRange(lines, location, threshold)\n\tconst best = pickBest(inRange, excludePoint)\n\n\tconst [x, xLines] = best.x ? best.x : [undefined, new Set<number>()]\n\tconst [y, yLines] = best.y ? best.y : [undefined, new Set<number>()]\n\n\treturn {\n\t\tpoint: { x, y },\n\t\tsnapLines: { x: xLines, y: yLines },\n\t}\n}\n\nconst findIntersection = (\n\toptions: readonly number[],\n\tthreshold: number,\n\tpoint: Point,\n\tconstraint: Line,\n\tisOrthogonal: boolean,\n\ttoLine: (num: number) => Line,\n): Point | null => {\n\tlet intersection: Point | null = null\n\toptions.forEach((value: number) => {\n\t\tconst line = toLine(value)\n\t\tintersection = Line.intersection(line, constraint)\n\t\tif (intersection === null) {\n\t\t\treturn\n\t\t}\n\t\tif (isOrthogonal) {\n\t\t\treturn false\n\t\t}\n\t\tconst distance = Point.distance(intersection, point)\n\t\tif (distance <= threshold) {\n\t\t\treturn false\n\t\t} else {\n\t\t\tintersection = null\n\t\t}\n\t})\n\treturn intersection\n}\n\nexport const snapWithConstraint = (\n\tlines: OrthogonalLines,\n\tzoom: number,\n\tpoint: Point,\n\tconstraint: Line,\n\textraBoundingBoxes?: Rect[],\n\teasySnap = false,\n): SnapInfo => {\n\tlines = extendLinesWithExtraBoundingBoxes(lines, extraBoundingBoxes)\n\tconst threshold = snappingThreshold(zoom)\n\tconst inRange = linesInRange(lines, point, threshold)\n\tconst isOrthogonal = Line.isOrthogonal(constraint) || easySnap\n\tconst intersectionTreshold = constraintSnappingThreshold(zoom)\n\n\tlet intersection: Point | null = null\n\tconst emptySnapX = new Set<number>()\n\tconst emptySnapY = new Set<number>()\n\n\tintersection = findIntersection(\n\t\tArray.from(inRange.x.keys()),\n\t\tintersectionTreshold,\n\t\tpoint,\n\t\tconstraint,\n\t\tisOrthogonal,\n\t\tnum => {\n\t\t\treturn Line({ x: num, y: 0 }, { x: num, y: 100 })\n\t\t},\n\t)\n\n\tif (intersection !== null) {\n\t\treturn {\n\t\t\tpoint: intersection,\n\t\t\tsnapLines: { x: emptySnapX.add(intersection.x), y: emptySnapY },\n\t\t}\n\t} // else\n\n\tintersection = findIntersection(\n\t\tArray.from(inRange.y.keys()),\n\t\tintersectionTreshold,\n\t\tpoint,\n\t\tconstraint,\n\t\tisOrthogonal,\n\t\tnum => {\n\t\t\treturn Line({ x: 0, y: num }, { x: 100, y: num })\n\t\t},\n\t)\n\n\tif (intersection !== null) {\n\t\treturn {\n\t\t\tpoint: intersection,\n\t\t\tsnapLines: { x: emptySnapX, y: emptySnapY.add(intersection.y) },\n\t\t}\n\t} // else\n\n\t// project point on constraint\n\tconst perpendicularLine = Line.perpendicular(constraint, point)\n\tintersection = Line.intersection(constraint, perpendicularLine)\n\n\tif (intersection === null) {\n\t\tintersection = point\n\t}\n\n\treturn {\n\t\tpoint: intersection,\n\t\tsnapLines: { x: emptySnapX, y: emptySnapY },\n\t}\n}\n\nexport interface DistanceSnapResult {\n\tdistanceSnap: Partial<Point>\n\tdistanceFramesX: Rect[]\n\tdistanceFramesY: Rect[]\n\thorizontalDistanceFrames: Rect[]\n\tverticalDistanceFrames: Rect[]\n}\n\nexport const snapDistance = (\n\tsiblingInfo: SiblingDistances,\n\tsnappedLocation: Partial<Point>,\n\tlocation: Rect | Point,\n\tzoom: number,\n) => {\n\tconst distanceSnap = { ...snappedLocation }\n\tconst distanceFramesX: Rect[] = []\n\tconst distanceFramesY: Rect[] = []\n\tconst horizontalDistanceFrames: Rect[] = []\n\tconst verticalDistanceFrames: Rect[] = []\n\n\tconst threshold = snappingThreshold(zoom)\n\tconst { x, y } = location\n\tconst height = \"height\" in location ? location.height : 0\n\tconst width = \"width\" in location ? location.width : 0\n\tconst maxX = x + width\n\tconst maxY = y + height\n\tconst frame = { x, y, width, height }\n\n\tsiblingInfo.siblingFrames.forEach(siblingRect => {\n\t\tsiblingInfo.horizontalDistances.forEach((frames: Rect[], distance: number) => {\n\t\t\tlet overlappingDistancesFrames = frames.filter(distanceFrame => {\n\t\t\t\treturn Rect.overlapVertically(frame, distanceFrame)\n\t\t\t})\n\t\t\tif (overlappingDistancesFrames.length === 0) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (Rect.overlapVertically(frame, siblingRect)) {\n\t\t\t\tif (Math.abs(siblingRect.x - distance - maxX) < threshold) {\n\t\t\t\t\tconst horizontalDistanceFrame = {\n\t\t\t\t\t\tx: siblingRect.x - distance,\n\t\t\t\t\t\ty: siblingRect.y,\n\t\t\t\t\t\twidth: distance,\n\t\t\t\t\t\theight: siblingRect.height,\n\t\t\t\t\t}\n\t\t\t\t\toverlappingDistancesFrames = overlappingDistancesFrames.filter(distFrame => {\n\t\t\t\t\t\treturn !Rect.overlapHorizontally(distFrame, horizontalDistanceFrame)\n\t\t\t\t\t})\n\t\t\t\t\tif (overlappingDistancesFrames.length === 0) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tif (Rect.doesNotIntersect(horizontalDistanceFrame, siblingInfo.siblingFrames)) {\n\t\t\t\t\t\tconst resultingX = siblingRect.x - distance - width\n\t\t\t\t\t\tif (distanceSnap.x === undefined || distanceSnap.x === resultingX) {\n\t\t\t\t\t\t\tdistanceFramesX.push(...overlappingDistancesFrames)\n\t\t\t\t\t\t\thorizontalDistanceFrames.push(horizontalDistanceFrame)\n\t\t\t\t\t\t\tdistanceSnap.x = resultingX\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (Math.abs(Rect.maxX(siblingRect) + distance - x) < threshold) {\n\t\t\t\t\tconst horizontalDistanceFrame = {\n\t\t\t\t\t\tx: Rect.maxX(siblingRect),\n\t\t\t\t\t\ty: siblingRect.y,\n\t\t\t\t\t\twidth: distance,\n\t\t\t\t\t\theight: siblingRect.height,\n\t\t\t\t\t}\n\t\t\t\t\toverlappingDistancesFrames = overlappingDistancesFrames.filter(distFrame => {\n\t\t\t\t\t\treturn !Rect.overlapHorizontally(distFrame, horizontalDistanceFrame)\n\t\t\t\t\t})\n\t\t\t\t\tif (overlappingDistancesFrames.length === 0) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tif (Rect.doesNotIntersect(horizontalDistanceFrame, siblingInfo.siblingFrames)) {\n\t\t\t\t\t\tconst resultingX = Rect.maxX(siblingRect) + distance\n\t\t\t\t\t\tif (distanceSnap.x === undefined || distanceSnap.x === resultingX) {\n\t\t\t\t\t\t\tdistanceFramesX.push(...overlappingDistancesFrames)\n\t\t\t\t\t\t\thorizontalDistanceFrames.push(horizontalDistanceFrame)\n\t\t\t\t\t\t\tdistanceSnap.x = resultingX\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t\tsiblingInfo.verticalDistances.forEach((frames: Rect[], distance: number) => {\n\t\t\tlet overlappingDistancesFrames = frames.filter(distanceFrame => {\n\t\t\t\treturn Rect.overlapHorizontally(frame, distanceFrame)\n\t\t\t})\n\t\t\tif (overlappingDistancesFrames.length === 0) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (Rect.overlapHorizontally(frame, siblingRect)) {\n\t\t\t\tif (Math.abs(siblingRect.y - distance - maxY) < threshold) {\n\t\t\t\t\tconst verticalDistanceFrame = {\n\t\t\t\t\t\ty: siblingRect.y - distance,\n\t\t\t\t\t\tx: siblingRect.x,\n\t\t\t\t\t\theight: distance,\n\t\t\t\t\t\twidth: siblingRect.width,\n\t\t\t\t\t}\n\t\t\t\t\toverlappingDistancesFrames = overlappingDistancesFrames.filter(distFrame => {\n\t\t\t\t\t\treturn !Rect.overlapVertically(distFrame, verticalDistanceFrame)\n\t\t\t\t\t})\n\t\t\t\t\tif (overlappingDistancesFrames.length === 0) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tif (Rect.doesNotIntersect(verticalDistanceFrame, siblingInfo.siblingFrames)) {\n\t\t\t\t\t\tconst resultingY = siblingRect.y - distance - height\n\t\t\t\t\t\tif (distanceSnap.y === undefined || distanceSnap.y === resultingY) {\n\t\t\t\t\t\t\tdistanceFramesY.push(...overlappingDistancesFrames)\n\t\t\t\t\t\t\tverticalDistanceFrames.push(verticalDistanceFrame)\n\t\t\t\t\t\t\tdistanceSnap.y = resultingY\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (Math.abs(Rect.maxY(siblingRect) + distance - y) < threshold) {\n\t\t\t\t\tconst verticalDistanceFrame = {\n\t\t\t\t\t\ty: Rect.maxY(siblingRect),\n\t\t\t\t\t\tx: siblingRect.x,\n\t\t\t\t\t\theight: distance,\n\t\t\t\t\t\twidth: siblingRect.width,\n\t\t\t\t\t}\n\t\t\t\t\toverlappingDistancesFrames = overlappingDistancesFrames.filter(distFrame => {\n\t\t\t\t\t\treturn !Rect.overlapVertically(distFrame, verticalDistanceFrame)\n\t\t\t\t\t})\n\t\t\t\t\tif (overlappingDistancesFrames.length === 0) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tif (Rect.doesNotIntersect(verticalDistanceFrame, siblingInfo.siblingFrames)) {\n\t\t\t\t\t\tconst resultingY = Rect.maxY(siblingRect) + distance\n\t\t\t\t\t\tif (distanceSnap.y === undefined || distanceSnap.y === resultingY) {\n\t\t\t\t\t\t\tdistanceFramesY.push(...overlappingDistancesFrames)\n\t\t\t\t\t\t\tverticalDistanceFrames.push(verticalDistanceFrame)\n\t\t\t\t\t\t\tdistanceSnap.y = resultingY\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t})\n\n\treturn {\n\t\tdistanceSnap,\n\t\tdistanceFramesX,\n\t\tdistanceFramesY,\n\t\thorizontalDistanceFrames,\n\t\tverticalDistanceFrames,\n\t}\n}\n", "import { assert } from \"@framerjs/document-migrations/src/utils/assert.ts\"\nimport type { VekterEngine } from \"document/VekterEngine.ts\"\nimport type { CanvasNode, CanvasTree, MaybeNodeID, NodeID } from \"document/models/CanvasTree/index.ts\"\nimport { FrameNode, isVectorNode } from \"document/models/CanvasTree/index.ts\"\nimport type { ReadonlyChildList } from \"document/models/CanvasTree/nodes/ChildList.ts\"\nimport { isShapeContainerNode, isShapeGroupNode } from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { nodeIsInActiveOverlay } from \"document/models/CanvasTree/nodes/utils/overlayHelpers.ts\"\nimport type { WithChildren } from \"document/models/CanvasTree/traits/WithChildren.ts\"\nimport { isValidGuideNode, withGuides } from \"document/models/CanvasTree/traits/WithGuides.ts\"\nimport { orthogonalLinesForOverlayGrid, withOverlayGrid } from \"document/models/CanvasTree/traits/WithOverlayGrid.ts\"\nimport { withRotation } from \"document/models/CanvasTree/traits/WithRotation.ts\"\nimport { getAbsoluteOffset } from \"document/models/CanvasTree/traits/utils/getAbsoluteOffset.ts\"\nimport { isPositionFixed } from \"document/models/CanvasTree/traits/utils/positionTypeHelpers.ts\"\nimport {\n\tcanNodeProvideViewportRect,\n\tgetViewportHeight,\n} from \"document/models/CanvasTree/traits/utils/viewportHelpers.ts\"\nimport { convertFrameToCanvas } from \"document/models/CanvasTree/utils/geometry.ts\"\nimport type { DistanceSnapResult, OrthogonalLines, SnapInfo } from \"document/models/Snapping.ts\"\nimport * as Snapping from \"document/models/Snapping.ts\"\nimport { snapDistance } from \"document/models/Snapping.ts\"\nimport { Tools } from \"document/stores/ToolEnum.ts\"\nimport type { Line } from \"library/render/types/Line.ts\"\nimport type { Point } from \"library/render/types/Point.ts\"\nimport { Rect } from \"library/render/types/Rect.ts\"\nimport { isNumber } from \"utils/typeChecks.ts\"\nimport { uniquePairs } from \"./uniquePairs.ts\"\n\nexport class SnapTool {\n\tsnapX: number[] | null = null\n\tsnapY: number[] | null = null\n\tsnapConstraint: Line | null = null\n\tdistanceFramesX: Rect[] = []\n\tdistanceFramesY: Rect[] = []\n\n\tsnappingZoom: number = -1\n\tsnappingFrame: Rect = { x: 0, y: 0, width: 0, height: 0 }\n\tlinesCache = new Map<MaybeNodeID, Snapping.OrthogonalLines>()\n\tdistanceCache = new Map<MaybeNodeID, Snapping.SiblingDistances>()\n\n\tsnapForShapes: boolean = false\n\n\tconstructor(\n\t\tpublic engine: VekterEngine,\n\t\tpublic excludedNodes: NodeID[],\n\t) {}\n\n\tstart() {\n\t\tthis.snapForShapes =\n\t\t\tthis.engine.stores.toolStore.shapeToolActive ||\n\t\t\tthis.engine.stores.selectionStore.nodes.every(node => isVectorNode(node))\n\t}\n\n\tstop() {\n\t\tthis.engine.stores.snapLinesStore.clear()\n\t}\n\n\tvalidateCaches() {\n\t\tconst { canvasStore } = this.engine.stores\n\t\tconst visibleCanvasFrame = canvasStore.getCanvasVisibleRect()\n\t\tif (this.snappingZoom !== canvasStore.zoom || !Rect.equals(this.snappingFrame, visibleCanvasFrame)) {\n\t\t\tthis.snappingZoom = canvasStore.zoom\n\t\t\tthis.snappingFrame = visibleCanvasFrame\n\t\t\tthis.linesCache = new Map<NodeID, Snapping.OrthogonalLines>()\n\t\t\tthis.distanceCache = new Map<MaybeNodeID, Snapping.SiblingDistances>()\n\t\t}\n\t}\n\n\tsnap(\n\t\tlocation: Rect | Point,\n\t\tenabled: boolean,\n\t\tframeIds: MaybeNodeID[],\n\t\tcommonParent?: MaybeNodeID,\n\t\tconstraint?: Line,\n\t\texcludePoint?: Point,\n\t\tincludeBoundingBoxes?: Rect[],\n\t\tviewportLine: boolean = false,\n\t): Point {\n\t\tconst { snapLinesStore, canvasStore } = this.engine.stores\n\n\t\tif (enabled === false) {\n\t\t\tthis.snapX = null\n\t\t\tthis.snapY = null\n\t\t\tthis.snapConstraint = null\n\t\t\tthis.distanceFramesX = []\n\t\t\tthis.distanceFramesY = []\n\t\t\tsnapLinesStore.clear()\n\t\t\treturn location\n\t\t}\n\n\t\tthis.validateCaches()\n\n\t\tconst orthogonalLines = this.getOrthogonalLines(frameIds, viewportLine)\n\t\tlet snapInfo: SnapInfo\n\n\t\tif (constraint) {\n\t\t\tsnapInfo = Snapping.snapWithConstraint(\n\t\t\t\torthogonalLines,\n\t\t\t\tcanvasStore.zoom,\n\t\t\t\tlocation,\n\t\t\t\tconstraint,\n\t\t\t\tincludeBoundingBoxes,\n\t\t\t\tthis.snapForShapes,\n\t\t\t)\n\t\t} else {\n\t\t\tsnapInfo = Snapping.snap(orthogonalLines, canvasStore.zoom, location, excludePoint, includeBoundingBoxes)\n\t\t}\n\n\t\tconst snapY = Array.from(snapInfo.snapLines.y)\n\t\tconst snapX = Array.from(snapInfo.snapLines.x)\n\t\tconst snapConstraint = constraint !== undefined ? constraint : null\n\n\t\tlet distanceSnapResult: DistanceSnapResult | null = null\n\n\t\tif (commonParent !== undefined && constraint === undefined) {\n\t\t\tconst siblingInfo = this.getSiblingDistances(commonParent)\n\t\t\tdistanceSnapResult = snapDistance(siblingInfo, snapInfo.point, location, canvasStore.zoom)\n\t\t}\n\n\t\tif (distanceSnapResult && distanceSnapResult.distanceSnap.x !== undefined) {\n\t\t\tsnapInfo.point.x = distanceSnapResult.distanceSnap.x\n\t\t}\n\t\tif (distanceSnapResult && distanceSnapResult.distanceSnap.y !== undefined) {\n\t\t\tsnapInfo.point.y = distanceSnapResult.distanceSnap.y\n\t\t}\n\n\t\tconst resultingLocation = {\n\t\t\tx: isNumber(snapInfo.point.x) ? snapInfo.point.x : location.x,\n\t\t\ty: isNumber(snapInfo.point.y) ? snapInfo.point.y : location.y,\n\t\t}\n\n\t\tif (distanceSnapResult !== null) {\n\t\t\tdistanceSnapResult.horizontalDistanceFrames.forEach(frame => {\n\t\t\t\tconst height = \"height\" in location ? location.height : 0\n\t\t\t\tconst minY = Math.min(frame.y, resultingLocation.y)\n\t\t\t\tconst maxY = Math.max(Rect.maxY(frame), resultingLocation.y + height)\n\t\t\t\tdistanceSnapResult.distanceFramesX.push({ ...frame, y: minY, height: maxY - minY })\n\t\t\t})\n\n\t\t\tdistanceSnapResult.verticalDistanceFrames.forEach(frame => {\n\t\t\t\tconst width = \"width\" in location ? location.width : 0\n\t\t\t\tconst minX = Math.min(frame.x, resultingLocation.x)\n\t\t\t\tconst maxX = Math.max(Rect.maxX(frame), resultingLocation.x + width)\n\t\t\t\tdistanceSnapResult.distanceFramesY.push({ ...frame, x: minX, width: maxX - minX })\n\t\t\t})\n\t\t}\n\n\t\tconst distanceFramesX = distanceSnapResult ? distanceSnapResult.distanceFramesX : []\n\t\tconst distanceFramesY = distanceSnapResult ? distanceSnapResult.distanceFramesY : []\n\n\t\tthis.snapX = snapX\n\t\tthis.snapY = snapY\n\t\tsnapLinesStore.x = new Set(snapX)\n\t\tsnapLinesStore.y = new Set(snapY)\n\t\tthis.snapConstraint = snapConstraint\n\t\tthis.distanceFramesX = distanceFramesX\n\t\tthis.distanceFramesY = distanceFramesY\n\t\treturn resultingLocation\n\t}\n\n\t// Helpers\n\tgetOrthogonalLines(frameIds: MaybeNodeID[], viewportLine: boolean = false): Snapping.OrthogonalLines {\n\t\tconst { tree } = this.engine\n\t\tconst { canvasStore, scopeStore, persistedUserDefaults, overlayStore } = this.engine.stores\n\t\tconst { active: activeScope } = scopeStore\n\t\tconst visibleCanvasFrame = canvasStore.getCanvasVisibleRect()\n\t\tconst pathEditModeActive = this.engine.tool.enum === Tools.Path\n\n\t\tconst snapToHalfPixels = this.snapForShapes || pathEditModeActive\n\n\t\t// only snap to guides if rulers are enabled\n\t\tconst { displayRulers } = persistedUserDefaults\n\t\tconst lines: OrthogonalLines =\n\t\t\tdisplayRulers && withGuides(activeScope)\n\t\t\t\t? { x: new Set(activeScope.guidesX), y: new Set(activeScope.guidesY) }\n\t\t\t\t: { x: new Set<number>(), y: new Set<number>() }\n\n\t\tframeIds.forEach(frameId => {\n\t\t\tconst guidesInFrames: OrthogonalLines = { x: new Set<number>(), y: new Set<number>() }\n\t\t\tconst overlayGridsInFrames: OrthogonalLines = { x: new Set<number>(), y: new Set<number>() }\n\t\t\tif (!this.linesCache.has(frameId)) {\n\t\t\t\tlet nodes: CanvasNode[] = []\n\t\t\t\tconst excludedNodes = [...this.excludedNodes]\n\n\t\t\t\tconst frameNodes = activeScope.getGroundNodesOfType(FrameNode, node => !excludedNodes.includes(node.id))\n\n\t\t\t\tif (!frameId) {\n\t\t\t\t\texcludedNodes.push(...frameNodes.map(node => node.id))\n\t\t\t\t\tnodes.push(...tree.getSubtreeNodes(activeScope.id, excludedNodes))\n\t\t\t\t\tnodes.push(...frameNodes)\n\t\t\t\t} else {\n\t\t\t\t\tnodes.push(...tree.getSubtreeNodes(frameId, excludedNodes))\n\t\t\t\t\tconst frameNode = tree.getNode(frameId)\n\n\t\t\t\t\t// Collect snapping lines for guides\n\t\t\t\t\tif (displayRulers && frameNode && isValidGuideNode(frameNode)) {\n\t\t\t\t\t\tconst nextGuidesX: readonly number[] = frameNode.guidesX.map(offset => {\n\t\t\t\t\t\t\treturn getAbsoluteOffset(tree, frameNode, \"x\", offset)\n\t\t\t\t\t\t})\n\n\t\t\t\t\t\tguidesInFrames.x = new Set(nextGuidesX)\n\n\t\t\t\t\t\tconst nextGuidesY: readonly number[] = frameNode.guidesY.map(offset => {\n\t\t\t\t\t\t\treturn getAbsoluteOffset(tree, frameNode, \"y\", offset)\n\t\t\t\t\t\t})\n\n\t\t\t\t\t\tguidesInFrames.y = new Set(nextGuidesY)\n\t\t\t\t\t}\n\n\t\t\t\t\t// Collect snapping lines for overlay grid\n\t\t\t\t\tif (\n\t\t\t\t\t\tpersistedUserDefaults.displayGrids &&\n\t\t\t\t\t\tframeNode &&\n\t\t\t\t\t\t(!withRotation(frameNode) || frameNode.resolveValue(\"rotation\") === 0) &&\n\t\t\t\t\t\twithOverlayGrid(frameNode) &&\n\t\t\t\t\t\tframeNode.overlayGrid\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst x: number[] = []\n\t\t\t\t\t\tconst y: number[] = []\n\n\t\t\t\t\t\tconst nodeRect = convertFrameToCanvas(tree, frameNode)\n\n\t\t\t\t\t\tif (!frameNode.overlayGrid) return\n\n\t\t\t\t\t\tconst overlayGridLines = orthogonalLinesForOverlayGrid(frameNode.overlayGrid, nodeRect)\n\n\t\t\t\t\t\tif (frameNode.overlayGrid?.type === \"column\") {\n\t\t\t\t\t\t\toverlayGridLines.forEach(guide => x.push(getAbsoluteOffset(tree, frameNode, \"x\", guide)))\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (frameNode.overlayGrid?.type === \"row\") {\n\t\t\t\t\t\t\toverlayGridLines.forEach(guide => y.push(getAbsoluteOffset(tree, frameNode, \"y\", guide)))\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\toverlayGridsInFrames.x = new Set(x)\n\t\t\t\t\t\toverlayGridsInFrames.y = new Set(y)\n\t\t\t\t\t}\n\n\t\t\t\t\t// Collect snapping lines for viewport\n\t\t\t\t\tif (viewportLine && frameNode && canNodeProvideViewportRect(frameNode)) {\n\t\t\t\t\t\tconst frame = Rect.atOrigin(tree.getRect(frameNode))\n\t\t\t\t\t\tframe.height = getViewportHeight(frameNode, frame)\n\t\t\t\t\t\tconst corners = Rect.cornerPoints(frame)\n\t\t\t\t\t\tconst convertedCorners = corners.map(corner => tree.convertPointToCanvas(frameNode, corner, true))\n\t\t\t\t\t\tconst rect = Rect.boundingRectFromPoints(convertedCorners)\n\n\t\t\t\t\t\tguidesInFrames.y.add(rect.y + rect.height)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Filter nodes that should be ignored.\n\t\t\t\tnodes = nodes.filter(node => {\n\t\t\t\t\t// If we are currently editing layers in an overlay, filter\n\t\t\t\t\t// out nodes that are not in an overlay.\n\t\t\t\t\tif (overlayStore.editModeActive) {\n\t\t\t\t\t\t// Relative overlays should snap to their triggers\n\t\t\t\t\t\tif (overlayStore.activeRelativeOverlayTriggers.has(node.id)) return true\n\t\t\t\t\t\tif (!nodeIsInActiveOverlay(node, overlayStore.activeOverlays)) return false\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!node.isVisible()) return false\n\n\t\t\t\t\t// Skip hidden and auto sizing graphic containers when generating snapping data\n\t\t\t\t\tif (isShapeGroupNode(node)) return false\n\t\t\t\t\tif (isShapeContainerNode(node)) return !node.sizeToFit\n\t\t\t\t\treturn true\n\t\t\t\t})\n\n\t\t\t\tconst boundingBoxes = nodes\n\t\t\t\t\t.map(node => convertFrameToCanvas(tree, node))\n\t\t\t\t\t.filter(canvasFrame => {\n\t\t\t\t\t\treturn Rect.intersects(canvasFrame, visibleCanvasFrame)\n\t\t\t\t\t})\n\n\t\t\t\tconst snapLines = Snapping.snappingData(boundingBoxes, canvasStore.zoom, snapToHalfPixels)\n\n\t\t\t\tconst allLines = {\n\t\t\t\t\tx: new Set([...snapLines.x, ...guidesInFrames.x, ...overlayGridsInFrames.x]),\n\t\t\t\t\ty: new Set([...snapLines.y, ...guidesInFrames.y, ...overlayGridsInFrames.y]),\n\t\t\t\t}\n\t\t\t\tthis.linesCache = this.linesCache.set(frameId, allLines)\n\t\t\t}\n\n\t\t\tconst cachedLines = this.linesCache.get(frameId)\n\t\t\tif (cachedLines) {\n\t\t\t\tlines.x = new Set([...lines.x, ...cachedLines.x])\n\t\t\t\tlines.y = new Set([...lines.y, ...cachedLines.y])\n\t\t\t}\n\t\t})\n\n\t\treturn lines\n\t}\n\n\tgetSiblingDistances(commonParent: MaybeNodeID): Snapping.SiblingDistances {\n\t\tconst { tree } = this.engine\n\t\tconst visibleCanvasFrame = this.engine.stores.canvasStore.getCanvasVisibleRect()\n\n\t\tif (!this.distanceCache.has(commonParent)) {\n\t\t\tlet siblings: CanvasNode[] | ReadonlyChildList<CanvasNode> = []\n\n\t\t\tif (!commonParent) {\n\t\t\t\tconst groundNodes = this.engine.stores.scopeStore.active.getGroundNodes()\n\t\t\t\tif (groundNodes) siblings = groundNodes\n\t\t\t} else {\n\t\t\t\tconst parent = tree.getNode(commonParent) as CanvasNode & WithChildren\n\t\t\t\tsiblings = parent.children\n\t\t\t}\n\n\t\t\tconst excludedNodes = [...this.excludedNodes]\n\n\t\t\tconst siblingFrames = siblings\n\t\t\t\t.filter(sibling => !excludedNodes.includes(sibling.id))\n\t\t\t\t.map(sibling => {\n\t\t\t\t\treturn Rect.pixelAligned(convertFrameToCanvas(tree, sibling))\n\t\t\t\t})\n\t\t\t\t.filter(canvasFrame => {\n\t\t\t\t\treturn Rect.intersects(visibleCanvasFrame, canvasFrame)\n\t\t\t\t})\n\t\t\tconst pairs = uniquePairs(siblingFrames)\n\n\t\t\tlet verticalDistances = new Map<number, Rect[]>()\n\t\t\tlet horizontalDistances = new Map<number, Rect[]>()\n\n\t\t\tconst addDistance = (input: Map<number, Rect[]>, value: number, frame: Rect) => {\n\t\t\t\tconst existingResult = input.get(value) ?? []\n\t\t\t\treturn input.set(value, [...existingResult, frame])\n\t\t\t}\n\n\t\t\tpairs.forEach(([frameA, frameB]) => {\n\t\t\t\tconst aMaxY = Rect.maxY(frameA)\n\t\t\t\tconst bMaxY = Rect.maxY(frameB)\n\t\t\t\tconst aMaxX = Rect.maxX(frameA)\n\t\t\t\tconst bMaxX = Rect.maxX(frameB)\n\n\t\t\t\tif (Rect.overlapHorizontally(frameA, frameB)) {\n\t\t\t\t\tconst x = Math.min(frameA.x, frameB.x)\n\t\t\t\t\tconst maxX = Math.max(aMaxX, bMaxX)\n\t\t\t\t\tconst width = maxX - x\n\t\t\t\t\tif (aMaxY < frameB.y) {\n\t\t\t\t\t\tconst height = frameB.y - aMaxY\n\t\t\t\t\t\tconst frame = { y: aMaxY, x, width, height }\n\t\t\t\t\t\tif (Rect.doesNotIntersect(frame, siblingFrames)) {\n\t\t\t\t\t\t\tverticalDistances = addDistance(verticalDistances, height, frame)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (bMaxY < frameA.y) {\n\t\t\t\t\t\tconst height = frameA.y - bMaxY\n\t\t\t\t\t\tconst frame = { y: bMaxY, x, width, height }\n\t\t\t\t\t\tif (Rect.doesNotIntersect(frame, siblingFrames)) {\n\t\t\t\t\t\t\tverticalDistances = addDistance(verticalDistances, height, frame)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (Rect.overlapVertically(frameA, frameB)) {\n\t\t\t\t\tconst y = Math.min(frameA.y, frameB.y)\n\t\t\t\t\tconst maxY = Math.max(aMaxY, bMaxY)\n\t\t\t\t\tconst height = maxY - y\n\t\t\t\t\tif (aMaxX < frameB.x) {\n\t\t\t\t\t\tconst width = frameB.x - aMaxX\n\t\t\t\t\t\tconst frame = { x: aMaxX, y, width, height }\n\t\t\t\t\t\tif (Rect.doesNotIntersect(frame, siblingFrames)) {\n\t\t\t\t\t\t\thorizontalDistances = addDistance(horizontalDistances, width, frame)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (bMaxX < frameA.x) {\n\t\t\t\t\t\tconst width = frameA.x - bMaxX\n\t\t\t\t\t\tconst frame = { x: bMaxX, y, width, height }\n\t\t\t\t\t\tif (Rect.doesNotIntersect(frame, siblingFrames)) {\n\t\t\t\t\t\t\thorizontalDistances = addDistance(horizontalDistances, width, frame)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tthis.distanceCache = this.distanceCache.set(commonParent, {\n\t\t\t\tverticalDistances,\n\t\t\t\thorizontalDistances,\n\t\t\t\tsiblingFrames,\n\t\t\t})\n\t\t}\n\n\t\tconst distances = this.distanceCache.get(commonParent)\n\t\tassert(distances, \"cant read distances\")\n\n\t\treturn distances\n\t}\n}\n\nexport function shouldSnapToViewportLine(tree: CanvasTree, selection: NodeID[]): boolean {\n\tif (selection.length !== 1) return false\n\tconst singleNode = tree.get(selection[0])\n\treturn Boolean(singleNode && isPositionFixed(singleNode))\n}\n", "import type { ComponentLoader } from \"@framerjs/framer-runtime\"\nimport { assert, isEmptyObject } from \"@framerjs/shared\"\nimport { experiments } from \"app/experiments.ts\"\nimport { translateXYToPoint } from \"canvas-sandbox/layout-measuring/projection.ts\"\nimport type { CollectorContext } from \"code-generation/utils/collector.ts\"\nimport { isVisibleInOtherVariants } from \"code-generation/utils/isOnlyVisibleInCurrentVariant.ts\"\nimport {\n\tapplyOverridesToReplicasOfDuplicatedPrimaryChild,\n\tupdateNodeWhenMovedIntoVariant,\n\tupdateNodeWhenMovedOutOfVariant,\n\tupdateNodeWhenReparentedInVariant,\n} from \"code-generation/utils/variantEditingHelpers.ts\"\nimport type { LayoutCache } from \"document/LayoutCache.ts\"\nimport type { VekterEngine } from \"document/VekterEngine.ts\"\nimport { VekterTool } from \"document/VekterTool.ts\"\nimport type { CanvasNode, CanvasTree, MaybeNodeID, NodeID } from \"document/models/CanvasTree/index.ts\"\nimport { NullID, isTreeNode, isVectorNode, isEqual as nodesAreEqual } from \"document/models/CanvasTree/index.ts\"\nimport type { PlaceholderAttributes, PlaceholderItem } from \"document/models/CanvasTree/nodes/CanvasNodeCache.ts\"\nimport type { GridComponentNode, StackComponentNode } from \"document/models/CanvasTree/nodes/FrameNode.ts\"\nimport {\n\tisBooleanShapeNode,\n\tisCanvasPageNode,\n\tisDataRepeater,\n\tisFrameNode,\n\tisGridComponent,\n\tisOverlayNode,\n\tisShapeContainerNode,\n\tisShapeGroupNode,\n\tisSlotNode,\n\tisStackComponent,\n\tisStackOrGridComponent,\n} from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { nodeIsInOverlay } from \"document/models/CanvasTree/nodes/utils/overlayHelpers.ts\"\nimport { getChildren } from \"document/models/CanvasTree/traits/WithChildren.ts\"\nimport { hasFloatingPosition } from \"document/models/CanvasTree/traits/WithFloatingPosition.ts\"\nimport { type WithGridItemSize, withGridItemSize } from \"document/models/CanvasTree/traits/WithGridItemSize.ts\"\nimport { withItemsOrder } from \"document/models/CanvasTree/traits/WithItemsOrder.ts\"\nimport { hasAnyLayout, hasColumnMasonryLayout, hasGridLayout } from \"document/models/CanvasTree/traits/WithLayout.ts\"\nimport type { WithPins } from \"document/models/CanvasTree/traits/WithPins.ts\"\nimport { isPinnable } from \"document/models/CanvasTree/traits/WithPins.ts\"\nimport { withPositionType } from \"document/models/CanvasTree/traits/WithPositionType.ts\"\nimport { withRotation } from \"document/models/CanvasTree/traits/WithRotation.ts\"\nimport { withShape } from \"document/models/CanvasTree/traits/WithShape.ts\"\nimport type { WithSize } from \"document/models/CanvasTree/traits/WithSize.ts\"\nimport { withSize } from \"document/models/CanvasTree/traits/WithSize.ts\"\nimport type { WithSizeDimensionType } from \"document/models/CanvasTree/traits/WithSizeDimensionType.ts\"\nimport {\n\ttype IsReplicaChild,\n\ttype IsReplicaOrReplicaChild,\n\tisMasterChild,\n\tisReplica,\n\tisReplicaChild,\n\tisReplicaOrReplicaChild,\n} from \"document/models/CanvasTree/traits/WithTemplate.ts\"\nimport { creates3dContext } from \"document/models/CanvasTree/traits/WithTransforms.ts\"\nimport {\n\tisReplicaVariantChild,\n\tisReplicaVariantOrReplicaVariantChild,\n} from \"document/models/CanvasTree/traits/WithVariant.ts\"\nimport { collectGridItemLayout } from \"document/models/CanvasTree/traits/collectStyles/collectGridItemLayout.ts\"\nimport { acceptsChild } from \"document/models/CanvasTree/traits/utils/acceptsChild.ts\"\nimport { doesHeightFitImage, doesWidthFitImage } from \"document/models/CanvasTree/traits/utils/doesDimensionFitImage.ts\"\nimport { getChildrenRects } from \"document/models/CanvasTree/traits/utils/getChildrenRects.ts\"\nimport {\n\tisPositionAbsolute,\n\tisPositionFixed,\n\tisPositionRelative,\n\tpositionTypeUpdateForNewParent,\n} from \"document/models/CanvasTree/traits/utils/positionTypeHelpers.ts\"\nimport { getRootFontSize } from \"document/models/CanvasTree/traits/utils/rootFontSizeHelpers.ts\"\nimport { convertCornerPointsToCanvas, convertFrameToCanvas } from \"document/models/CanvasTree/utils/geometry.ts\"\nimport { getConstraintsLocked } from \"document/models/CanvasTree/utils/getConstraintsLocked.ts\"\nimport { isHomeNode } from \"document/models/CanvasTree/utils/homeNode.ts\"\nimport { verifyHomeNodePostProcess } from \"document/models/CanvasTree/utils/verifyHomeNodePostProcess.ts\"\nimport { Matrix } from \"document/models/Matrix.ts\"\nimport { shouldGuessPinToBottom } from \"document/models/shouldGuessPinToBottom.ts\"\nimport { shouldGuessPinToRight } from \"document/models/shouldGuessPinToRight.ts\"\nimport type { MouseStore } from \"document/stores/MouseStore.ts\"\nimport { type NodeWithPlaceholders, Tools } from \"document/stores/ToolStore.ts\"\nimport { isSortableNode, updateIdIndexInItemsOrder } from \"document/utils/itemsOrderOverrideHelpers.ts\"\nimport { nodesAreSimilar } from \"document/utils/nodesAreSimilar.ts\"\nimport type { StackDirection } from \"library/components/Stack/types.ts\"\nimport { DimensionType } from \"library/render/types/Constraints.ts\"\nimport type { Line } from \"library/render/types/Line.ts\"\nimport { Point } from \"library/render/types/Point.ts\"\nimport { Polygon } from \"library/render/types/Polygon.ts\"\nimport { Rect } from \"library/render/types/Rect.ts\"\nimport type { Size } from \"library/render/types/Size.ts\"\nimport type { CSSProperties } from \"react\"\nimport type { TextDirection } from \"text/types.ts\"\nimport * as Cursor from \"utils/cursor.ts\"\nimport {\n\tgetParentDataRepeater,\n\tgetRepeatedItemIdUpdate,\n\tgetRepeatedItemOfDataRepeater,\n\tisRepeatedItem,\n} from \"utils/repeaterUtils.ts\"\nimport { isNull, isNumber } from \"utils/typeChecks.ts\"\nimport { withClassDiscriminator } from \"utils/withClassDiscriminator.ts\"\nimport { record } from \"web/lib/tracker.ts\"\nimport { getIsViewOnly } from \"web/pages/project/permissions/isViewOnly.ts\"\nimport { isSkewedQuadrilateralPoints } from \"../utils/isSkewedQuadrilateralPoints.ts\"\nimport { SnapTool, shouldSnapToViewportLine } from \"./utils/SnapTool.ts\"\nimport type { WrapInsertionInfo } from \"./utils/stackInsertionHelpers.ts\"\nimport {\n\tgetStackOrGridInRange,\n\tgetStackOrGridInsertionIndexAndLine,\n\tnodeListsIntersect,\n\twrapStackBeforeInsertion,\n} from \"./utils/stackInsertionHelpers.ts\"\nimport { RenamedIds, updateNodeConnections } from \"./utils/updateNodeConnections.ts\"\n\nfunction getRenderInstanceCount(node: CanvasNode): number {\n\treturn 1 + (node.cache.secondaryRenderInstances?.size ?? 0)\n}\n\nexport function isMoveTool(tool: VekterTool): tool is MoveTool {\n\treturn tool instanceof MoveTool\n}\ninterface ChildBeginState {\n\tframe: Rect\n\tcanvasFrame: Rect\n}\n\nexport type MoveToolBeginState = {\n\trect: Rect\n\tuntransformedPointUnderMouse: Point\n\tcanvasPointUnderMouse: Point\n\tmatrix: DOMMatrixReadOnly\n\tchildren: Map<NodeID, ChildBeginState>\n\tunableToMove: boolean // parent directed nodes cannot be manipulated if a replica, only if original\n\tstartFromStackOrGrid: boolean\n\tstartSizeProps: Partial<Size & WithSizeDimensionType>\n\tconstraintsLocked: boolean\n\tplaceholderAttributes: PlaceholderAttributes | undefined\n\tdisableReparenting: boolean\n\trepeaterId: MaybeNodeID\n} & ({ parent: CanvasNode; index: number } | { parent: null; index: undefined })\n\ntype NodesBeginState = Map<CanvasNode, MoveToolBeginState>\ntype TargetIds = Map<CanvasNode, NodeID>\ntype HighlightedParents = Set<NodeID>\n\nexport interface MoveToolOptions {\n\treorderNode?: CanvasNode\n\tdirectionLock?: StackDirection\n\treorderOffset?: Point\n\tmoveToolDidExitWithoutMoving?: () => void\n}\n\nexport class MoveTool extends withClassDiscriminator(\"MoveTool\", VekterTool) {\n\toverride readonly enum = Tools.Move\n\toverride readonly wantsAutoscrolling = true\n\n\tprivate isCancelled: boolean = false\n\n\t// FIXME: !s are unsafe; they are assigned in `.start()`, but not in the constructor,\n\t// so there\u2019s a period of time where these fields are undefined\n\tnodesBeginState!: NodesBeginState\n\tparentsWithPlaceholders!: NodeWithPlaceholders[]\n\tstartVisualIndexIfSequentialSiblings: number | undefined\n\tstartVisibleRelativeNodeCount = 0\n\tstartCanvasRect!: Rect\n\thasMoved = false\n\tmaxSize!: Size\n\tnodesInMoveToolBaseFontSize: Record<NodeID, number> = {}\n\n\t// Rendering\n\thighlightedParents: HighlightedParents = new Set()\n\tshouldHighLightParents: boolean = true\n\n\t// Snapping\n\t// \uD83D\uDC13\uD83E\uDD5A Hierarchy changes depend on snapping, but snapping needs to know about the latest common parent and ground node ancestors\n\t// Because of this circular dependency we keep track of the common parent and top level frames at the end of the last update\n\tcommonParentAfterLastUpdate: MaybeNodeID | undefined\n\ttopLevelFrameNodesAfterLastUpdate: MaybeNodeID[] = []\n\tsnapper!: SnapTool\n\tisSkewed!: boolean\n\n\tcloneCache = new Map<NodeID, CanvasNode>() // we are resetting the tree state at every frame, but we don't want to create copies with new ids every time\n\trenamedIds = new RenamedIds()\n\n\t// Parent directed\n\tcanMoveToStackOrGrid = false\n\tactiveStackOrGrid: StackComponentNode | GridComponentNode | null = null\n\tcommonStackOrGridParentAtStart: StackComponentNode | GridComponentNode | null = null\n\tactiveStackOrGridInsertion: number | null | undefined\n\tstackOrGridInsertionLine: Line | null = null\n\n\t// Lifecycle\n\n\toverride displaySelectionBox = true\n\toverride cmsBadge: \"visible\" | \"hidden\" | \"disabled\" = \"visible\"\n\toverride displaySelectionHandles = true\n\n\t/**\n\t * A number used to identify the starting history state in the tree. MoveTool rewinds to this\n\t * state and then applies updates from there, guaranteeing linear, forward logic.\n\t */\n\tstateToken!: number\n\n\t// We exit the move tool if the scope changes for some reason.\n\tscopeIdAtStart: MaybeNodeID\n\n\tconstructor(\n\t\tengine: VekterEngine,\n\t\treadonly options?: MoveToolOptions,\n\t) {\n\t\tsuper(engine)\n\t\tthis.displaySelectionHandles = !options?.reorderNode\n\t}\n\n\tprivate selectionIds() {\n\t\tif (this.options?.reorderNode) {\n\t\t\treturn [this.options.reorderNode.id]\n\t\t}\n\n\t\treturn this.engine.stores.selectionStore.ids\n\t}\n\n\toverride start() {\n\t\tconst { engine } = this\n\t\tconst { tree, componentLoader } = engine\n\t\tconst { scopeStore, mouseStore, modulesStore } = engine.stores\n\t\tconst selection = this.selectionIds()\n\n\t\tthis.snapper = new SnapTool(engine, selection)\n\n\t\tconst withoutDescendants = tree.withoutDescendants(tree.getNodes(selection))\n\t\tthis.nodesBeginState = getNodesBeginState(\n\t\t\ttree,\n\t\t\tcomponentLoader,\n\t\t\twithoutDescendants,\n\t\t\tmouseStore.latest.canvasMousePosition,\n\t\t)\n\n\t\tthis.parentsWithPlaceholders = getParentsWithPlaceholders(this.nodesBeginState)\n\t\tthis.commonStackOrGridParentAtStart = getCommonStackOrGridParentAtStart(tree, withoutDescendants)\n\t\tthis.startVisualIndexIfSequentialSiblings = getStartVisualIndexIfSequentialSiblings(\n\t\t\tthis.nodesBeginState,\n\t\t\tthis.commonStackOrGridParentAtStart,\n\t\t)\n\t\tthis.startVisibleRelativeNodeCount = getStartVisibleRelativeNodeCount(this.nodesBeginState)\n\t\tthis.maxSize = getMaxSize(this.nodesBeginState)\n\t\tthis.startCanvasRect = Rect.merge(...withoutDescendants.map(node => convertFrameToCanvas(tree, node)))\n\t\tthis.canMoveToStackOrGrid = selectionCanMoveToStackAndGrid(withoutDescendants, tree)\n\t\tthis.nodesInMoveToolBaseFontSize = withoutDescendants.reduce((acc: Record<NodeID, number>, node) => {\n\t\t\tconst fontSize = getRootFontSize(scopeStore.active, tree, modulesStore, node.id)\n\t\t\tif (isNumber(fontSize)) acc[node.id] = fontSize\n\t\t\treturn acc\n\t\t}, {})\n\t\tconst singleSelectedNode = withoutDescendants[0]\n\n\t\t// Temporarily disable snapping for skewed nodes. In the future we will\n\t\t// bring this back with support for drawing lines and snapping the correct\n\t\t// lines for transformed shapes.\n\t\tthis.isSkewed =\n\t\t\twithoutDescendants.length === 1 &&\n\t\t\t!!singleSelectedNode &&\n\t\t\tisSkewedQuadrilateralPoints(convertCornerPointsToCanvas(tree, singleSelectedNode))\n\n\t\tengine.beginUndoGroup()\n\t\tengine.stores.treeStore.setHighlight(null)\n\n\t\tthis.scopeIdAtStart = engine.stores.scopeStore.activeId\n\t\tthis.stateToken = engine.getStateToken()\n\n\t\tthis.shouldHighLightParents = !withoutDescendants.every(hasFloatingPosition)\n\t}\n\n\toverride cancel() {\n\t\tconst { engine } = this\n\t\tthis.removePlaceholders()\n\t\tthis.activeStackOrGrid = null\n\t\tengine.discardUndoGroup()\n\t\tthis.isCancelled = true\n\t}\n\n\toverride stop() {\n\t\tconst { engine } = this\n\n\t\tif (!this.isCancelled) {\n\t\t\tthis.toolUpdate(true)\n\t\t\tengine.endUndoGroup()\n\t\t}\n\n\t\tif (!this.hasMoved) {\n\t\t\tthis.options?.moveToolDidExitWithoutMoving?.()\n\t\t}\n\n\t\tthis.snapper.stop()\n\t}\n\n\tprivate resetToBeginState() {\n\t\tthis.engine.resetTreeAndSelectionWithToken(this.stateToken)\n\t}\n\n\toverride update() {\n\t\tconst { engine } = this\n\t\tconst { mouseStore, mouseCursorStore, scopeStore } = engine.stores\n\t\tconst { canvasMouseDownPosition, canvasMiddleMouseButtonDownPosition } = mouseStore\n\n\t\tif (!canvasMouseDownPosition || canvasMiddleMouseButtonDownPosition) {\n\t\t\tengine.exitTool()\n\t\t\treturn\n\t\t}\n\n\t\tif (this.scopeIdAtStart !== scopeStore.activeId) {\n\t\t\tthis.removePlaceholders()\n\t\t\t// Clear the mouse down state, like engine.cancelTool would do, so the highlight tool is\n\t\t\t// not immediately triggered by the highlight tool.\n\t\t\tmouseStore.setMouseDown(false)\n\t\t\tengine.exitTool()\n\t\t\treturn\n\t\t}\n\n\t\tthis.toolUpdate()\n\n\t\tif (this.options?.reorderNode) mouseCursorStore.current = Cursor.grabbingCursor\n\n\t\tif (this.nodesBeginState.size === 0) {\n\t\t\tengine.exitTool()\n\t\t\treturn\n\t\t}\n\t}\n\n\tprivate validateNodesBeginState() {\n\t\tconst { engine } = this\n\n\t\t// Make sure all the nodes still exist, in multi-user scenarios they might get deleted.\n\t\tthis.nodesBeginState.forEach((_, node) => {\n\t\t\tif (!engine.tree.has(node.id)) {\n\t\t\t\tthis.nodesBeginState.delete(node)\n\t\t\t}\n\t\t})\n\t}\n\n\tprivate validateNodesInMoveToolBaseFontSize() {\n\t\tconst { engine } = this\n\t\tconst nodeRootFontSizeKeys = Object.keys(this.nodesInMoveToolBaseFontSize)\n\t\tconst isMapValid = nodeRootFontSizeKeys.every(nodeId => {\n\t\t\tconst fontSize = this.nodesInMoveToolBaseFontSize[nodeId]\n\t\t\treturn engine.tree.has(nodeId) && isNumber(fontSize)\n\t\t})\n\n\t\t// If everything is valid, keep the same reference for the map, as we do not want\n\t\t// to trigger a sandbox update.\n\t\tif (isMapValid) return\n\n\t\t// Only create new object if we need to remove items. This is necessary when\n\t\t// parsing how the previous value & current values have changed in `CanvasSandboxApp`,\n\t\t// as they are checked by reference and not object value equality.\n\t\tthis.nodesInMoveToolBaseFontSize = nodeRootFontSizeKeys.reduce((acc: Record<NodeID, number>, nodeId) => {\n\t\t\tconst fontSize = this.nodesInMoveToolBaseFontSize[nodeId]\n\t\t\tif (!engine.tree.has(nodeId) || !isNumber(fontSize)) return acc\n\t\t\tacc[nodeId] = fontSize\n\t\t\treturn acc\n\t\t}, {})\n\t}\n\n\tprivate noInputChange() {\n\t\tconst { previous, latest } = this.engine.stores.mouseStore\n\t\tconst { altKey, cmdKey, ctrlKey, spacebar, canvasMousePosition } = latest\n\t\treturn (\n\t\t\tcanvasMousePosition.x === previous.canvasMousePosition.x &&\n\t\t\tcanvasMousePosition.y === previous.canvasMousePosition.y &&\n\t\t\taltKey === previous.altKey &&\n\t\t\tcmdKey === previous.cmdKey &&\n\t\t\tctrlKey === previous.ctrlKey &&\n\t\t\tspacebar === previous.spacebar\n\t\t)\n\t}\n\n\t// Every update we track when the alt key was last down. If the move tool stops shortly after\n\t// releasing the alt key we still count it as making duplicates. This helps people who release\n\t// alt and mouse \"at the same time\".\n\tlastAltKeyDownTime = 0\n\tprivate shouldCopy(final: boolean) {\n\t\tif (this.engine.stores.mouseStore.latest.altKey) {\n\t\t\tthis.lastAltKeyDownTime = performance.now()\n\t\t\treturn true\n\t\t}\n\n\t\tif (final) return performance.now() - this.lastAltKeyDownTime < 200\n\t\treturn false\n\t}\n\n\tprivate addReorderOffsetIfNeeded(mouse: Point): Point {\n\t\tif (!this.options?.reorderOffset) return mouse\n\t\treturn Point.add(mouse, this.options.reorderOffset)\n\t}\n\n\tprivate getMouseWithReorderOffset(): Point {\n\t\treturn this.addReorderOffsetIfNeeded(this.engine.stores.mouseStore.latest.canvasMousePosition)\n\t}\n\n\tprivate getPreviousMouseWithReorderOffset(): Point {\n\t\treturn this.addReorderOffsetIfNeeded(this.engine.stores.mouseStore.previous.canvasMousePosition)\n\t}\n\n\t/**\n\t * When we are moving a replica, we either:\n\t * 1) Clone the primary variant and apply the overrides from the replica.\n\t * 2) Clone the replica and then hide the initial replica.\n\t * However, for `rem` font size, it relies on an external value on its breakpoint.\n\t * Thus, we add a key for the original node ID and assign it to the root font size of the\n\t * replica that is currently being dragged in order to show the same calculated `rem` font\n\t * size. We must generate a new object reference in this case so that it's picked up by\n\t * the SandboxRenderer, which checks for a new object reference.\n\t *\n\t * We must pass this method down in order to update the class property to trigger\n\t * an update for the `SandboxRenderer`.\n\t */\n\tprivate updateNodesInMoveToolBaseFontSize = (sourceId: NodeID, targetId: NodeID) => {\n\t\tif (sourceId === targetId) return\n\n\t\tconst fontSize = this.nodesInMoveToolBaseFontSize[sourceId]\n\t\tif (!isNumber(fontSize)) return\n\n\t\tthis.nodesInMoveToolBaseFontSize = {\n\t\t\t...this.nodesInMoveToolBaseFontSize,\n\t\t\t[targetId]: fontSize,\n\t\t}\n\t}\n\n\tprivate toolUpdate(final: boolean = false) {\n\t\tconst { engine } = this\n\t\tconst isReorder = Boolean(this.options?.reorderNode)\n\t\t// Don't do anything if the mouse hasn't moved to avoid moving the node\n\t\t// when selecting it.\n\t\tif (final && !this.hasMoved) {\n\t\t\t// In the case where a user has clicked the stack reorder tool, but\n\t\t\t// hasn't live sorted, set the selection to the node as a workflow\n\t\t\t// improvement. It may be the parent of the selection.\n\t\t\tif (this.options?.reorderNode) engine.stores.selectionStore.set(this.options.reorderNode)\n\t\t\treturn\n\t\t}\n\n\t\tconst { tree } = engine\n\t\tconst {\n\t\t\tscopeStore,\n\t\t\teffectStore,\n\t\t\tmouseStore,\n\t\t\tdocumentSettingsStore,\n\t\t\ttoolStore,\n\t\t\tchromeStore,\n\t\t\tselectionStore,\n\t\t\tcanvasStore,\n\t\t} = engine.stores\n\n\t\tconst { previous, latest } = mouseStore\n\t\tconst { altKey, cmdKey, ctrlKey, spacebar, canvasMousePosition } = latest\n\n\t\t// Don't edit if the scope changed.\n\t\tif (this.scopeIdAtStart !== scopeStore.activeId) return\n\n\t\t// FIXME: This tool handles selection for non-selectable nodes (see isSelectable.ts)\n\t\t// and for selecting nodes by clicking on the Screen Title. This should not be handled by Move.\n\t\tif (\n\t\t\tunableToMoveAll(this.nodesBeginState) ||\n\t\t\tgetIsViewOnly(engine, \"canDesign\") ||\n\t\t\tchromeStore.isPreviewingLocaleOnCanvas\n\t\t) {\n\t\t\treturn\n\t\t}\n\n\t\tconst delta = getMouseDelta(mouseStore, this.options?.directionLock)\n\t\tif (!delta || (!this.hasMoved && delta.x === 0 && delta.y === 0)) {\n\t\t\treturn\n\t\t}\n\n\t\tthis.hasMoved = true\n\n\t\t// When a real move starts, exit the effect preview and TODO: close any\n\t\t// open popout windows.\n\t\teffectStore.exitPreview()\n\n\t\tif (!final && this.noInputChange()) {\n\t\t\treturn\n\t\t}\n\n\t\tthis.resetToBeginState()\n\t\tstabilizeDraggedRepeatedItems(this.engine.tree, this.nodesBeginState)\n\t\tthis.validateNodesBeginState()\n\t\tthis.validateNodesInMoveToolBaseFontSize()\n\n\t\tconst targetIds: TargetIds = new Map()\n\t\tconst moveFromAnywhereEnabled = altKey && cmdKey\n\n\t\tthis.displaySelectionHandles = false\n\t\tthis.highlightedParents.clear()\n\t\tthis.removePlaceholders(true)\n\n\t\tconst isCopyMode = this.shouldCopy(final) && !moveFromAnywhereEnabled\n\t\tconst isBetterStackGridItemMovingOn = experiments.isOn(\"betterStackGridItemMoving\")\n\t\tif (isCopyMode) {\n\t\t\tcreateCopies(engine, this.nodesBeginState, targetIds, this.cloneCache, this.renamedIds)\n\t\t}\n\n\t\tconst selectedNodes = tree.getNodes(this.selectionIds())\n\t\tconst areAllNodesPositionAbsolute = selectedNodes.every(node => isPositionAbsolute(node))\n\t\tconst isPositionAbsoluteAlreadyOrForced =\n\t\t\tareAllNodesPositionAbsolute || (ctrlKey && selectedNodes.every(withPositionType))\n\n\t\tif (isBetterStackGridItemMovingOn && (isCopyMode || isPositionAbsoluteAlreadyOrForced)) {\n\t\t\t// In case we just entered the copy / absolute position mode. Remove this when cleaning\n\t\t\t// up the experiment, as removePlaceholders above will do this unconditionally.\n\t\t\ttoolStore.nodesWithPlaceholders = null\n\t\t}\n\n\t\tconst frame = Rect.offset(this.startCanvasRect, delta)\n\n\t\tconst areAllStackOrGridChildrenFixedOrAbsolute =\n\t\t\tBoolean(this.commonStackOrGridParentAtStart) &&\n\t\t\t(areAllNodesPositionAbsolute || selectedNodes.every(node => isPositionFixed(node) || isPositionAbsolute(node)))\n\n\t\tconst { visualInsertionIndex, insertionLine, activeStackOrGrid, isLiveSorting, wrap } = getStackOrGridInsertionInfo(\n\t\t\tengine,\n\t\t\tthis.getMouseWithReorderOffset(),\n\t\t\tthis.getPreviousMouseWithReorderOffset(),\n\t\t\tselectedNodes,\n\t\t\tthis.nodesBeginState,\n\t\t\tthis.canMoveToStackOrGrid,\n\t\t\tisReorder,\n\t\t\tthis.commonStackOrGridParentAtStart,\n\t\t\tthis.maxSize,\n\t\t\tthis.activeStackOrGridInsertion,\n\t\t\tisPositionAbsoluteAlreadyOrForced,\n\t\t\tareAllStackOrGridChildrenFixedOrAbsolute,\n\t\t\tspacebar,\n\t\t\tcmdKey,\n\t\t\tmoveFromAnywhereEnabled,\n\t\t)\n\n\t\tthis.activeStackOrGridInsertion = visualInsertionIndex\n\t\tthis.stackOrGridInsertionLine = insertionLine\n\n\t\tthis.activeStackOrGrid = activeStackOrGrid\n\n\t\tif (isBetterStackGridItemMovingOn) {\n\t\t\tconst isInsertionDifferentFromCurrentState =\n\t\t\t\tisCopyMode ||\n\t\t\t\t!this.activeStackOrGrid ||\n\t\t\t\t!this.commonStackOrGridParentAtStart ||\n\t\t\t\tthis.activeStackOrGrid.id !== this.commonStackOrGridParentAtStart.id ||\n\t\t\t\tvisualInsertionIndex === null ||\n\t\t\t\tthis.startVisualIndexIfSequentialSiblings === undefined ||\n\t\t\t\tvisualInsertionIndex < this.startVisualIndexIfSequentialSiblings ||\n\t\t\t\tvisualInsertionIndex > this.startVisualIndexIfSequentialSiblings + this.startVisibleRelativeNodeCount\n\n\t\t\tif (!isInsertionDifferentFromCurrentState) {\n\t\t\t\tthis.activeStackOrGridInsertion = null\n\t\t\t\tthis.stackOrGridInsertionLine = null\n\t\t\t}\n\n\t\t\tif (this.activeStackOrGrid && this.activeStackOrGridInsertion !== null) {\n\t\t\t\tconst selectionIds = new Set(this.selectionIds())\n\t\t\t\tconst activeStackRepeater = isDataRepeater(this.activeStackOrGrid) ? this.activeStackOrGrid : undefined\n\t\t\t\tlet rectIndex = 0\n\t\t\t\tlet placeholderCount = 0\n\t\t\t\tlet trailingNonSortableCount = 0\n\t\t\t\tlet secondaryInstanceCount = 0\n\t\t\t\tlet isBetweenRenderInstances = false\n\t\t\t\tfor (const child of this.activeStackOrGrid.getChildrenInVisualOrder()) {\n\t\t\t\t\tconst renderInstanceCount =\n\t\t\t\t\t\tactiveStackRepeater && isRepeatedItem(engine.tree, child, activeStackRepeater)\n\t\t\t\t\t\t\t? getRenderInstanceCount(child)\n\t\t\t\t\t\t\t: 1\n\t\t\t\t\tfor (let renderInstanceIndex = 0; renderInstanceIndex < renderInstanceCount; renderInstanceIndex += 1) {\n\t\t\t\t\t\tif (this.activeStackOrGridInsertion === rectIndex) {\n\t\t\t\t\t\t\tisBetweenRenderInstances = renderInstanceIndex > 0\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (renderInstanceIndex > 0) {\n\t\t\t\t\t\t\tsecondaryInstanceCount += 1\n\t\t\t\t\t\t} else if (!child.isVisible() || !isPositionRelative(child, this.activeStackOrGrid)) {\n\t\t\t\t\t\t\ttrailingNonSortableCount += 1\n\t\t\t\t\t\t\tthis.activeStackOrGridInsertion += 1\n\t\t\t\t\t\t} else if (selectionIds.has(child.id)) {\n\t\t\t\t\t\t\tplaceholderCount += 1\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttrailingNonSortableCount = 0\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\trectIndex += 1\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this.activeStackOrGridInsertion === rectIndex) break\n\t\t\t\t}\n\n\t\t\t\tif (isBetweenRenderInstances) {\n\t\t\t\t\tthis.activeStackOrGridInsertion = null\n\t\t\t\t\tthis.stackOrGridInsertionLine = null\n\t\t\t\t} else {\n\t\t\t\t\tif (!isCopyMode && !final) {\n\t\t\t\t\t\tthis.activeStackOrGridInsertion -= placeholderCount\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.activeStackOrGridInsertion -= trailingNonSortableCount\n\t\t\t\t\tthis.activeStackOrGridInsertion -= secondaryInstanceCount\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// In copy mode, the originals themselves are the placeholders. This applies to every\n\t\t\t// placeholder-related piece of logic in this tool.\n\t\t\t//\n\t\t\t// In absolute position mode it's more useful to see the final layout, so you know where\n\t\t\t// the dragged items will end up in relation to the relative ones, but there's no\n\t\t\t// insertion index to worry about when all dragged items are absolute, so we just don't\n\t\t\t// show placeholders and stop at that.\n\t\t\tif (!isCopyMode && !isPositionAbsoluteAlreadyOrForced) {\n\t\t\t\ttoolStore.nodesWithPlaceholders = this.parentsWithPlaceholders\n\t\t\t}\n\n\t\t\tif (this.parentsWithPlaceholders.length > 0 && !final) {\n\t\t\t\tif (!isCopyMode && !isPositionAbsoluteAlreadyOrForced) {\n\t\t\t\t\tfor (const { id, placeholders } of this.parentsWithPlaceholders) {\n\t\t\t\t\t\tconst parent = tree.getNode(id)\n\t\t\t\t\t\tif (!parent) continue\n\t\t\t\t\t\tparent.cache.placeholders = placeholders\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.makeGroundNodes(targetIds)\n\t\t\t}\n\t\t} else {\n\t\t\tif (isLiveSorting && !final) {\n\t\t\t\tthis.makeGroundNodes(targetIds)\n\t\t\t}\n\n\t\t\t// Delete ToolStore.updateDragAndDropPlaceholder when cleaning up the experiment\n\t\t\ttoolStore.updateDragAndDropPlaceholder(this.activeStackOrGrid)\n\t\t}\n\n\t\tconst { activeNodes, extraSnapRects } = activeNodesAndSnapRects(tree, this.nodesBeginState, targetIds, cmdKey)\n\n\t\tconst velocity = Point.distance(previous.canvasMousePosition, canvasMousePosition) * canvasStore.zoom\n\n\t\tconst snappingEnabled =\n\t\t\t!this.isSkewed && (velocity < 10 && areAllStackOrGridChildrenFixedOrAbsolute ? true : !this.activeStackOrGrid)\n\n\t\tthis.snapper.excludedNodes = this.selectionIds()\n\t\tconst snapPoint = this.snapper.snap(\n\t\t\tframe,\n\t\t\tsnappingEnabled,\n\t\t\tthis.topLevelFrameNodesAfterLastUpdate,\n\t\t\tthis.commonParentAfterLastUpdate,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\textraSnapRects,\n\t\t\tshouldSnapToViewportLine(tree, this.selectionIds()),\n\t\t)\n\n\t\tconst snappedDelta = Point.pixelAligned(Point.subtract(this.startCanvasRect, snapPoint))\n\n\t\tconst newSelection = new Set(this.selectionIds())\n\n\t\t// we insert the node into a stack in the final update\n\t\tif (\n\t\t\t!final ||\n\t\t\t!this.activeStackOrGrid ||\n\t\t\tareAllStackOrGridChildrenFixedOrAbsolute ||\n\t\t\tisPositionAbsoluteAlreadyOrForced\n\t\t) {\n\t\t\tfor (const [staleNode, beginState] of this.nodesBeginState) {\n\t\t\t\tconst { unableToMove, startFromStackOrGrid, disableReparenting } = beginState\n\n\t\t\t\tif (unableToMove) continue\n\n\t\t\t\t// When creating duplicates this looks up the copy\n\t\t\t\tconst targetId = targetIds.get(staleNode) ?? staleNode.id\n\t\t\t\tconst node = tree.get(targetId)\n\t\t\t\tif (!node) continue\n\n\t\t\t\tconst isCopyOfReplicaChild = targetId !== staleNode.id && isReplicaChild(staleNode)\n\n\t\t\t\tconst startingParentNode = tree.current(beginState.parent)\n\t\t\t\tconst startingRect = beginState.rect\n\n\t\t\t\t// Using the node's starting parent, determine the current\n\t\t\t\t// position of the node relative to its starting parent, if it\n\t\t\t\t// were moved so that the point under the mouse at the start of\n\t\t\t\t// the drag projected to the current mouse position.\n\t\t\t\tconst untransformedDeltaInStartingParent = translateXYToPoint(\n\t\t\t\t\tgetMatrix(engine.tree, startingParentNode),\n\t\t\t\t\tbeginState.untransformedPointUnderMouse,\n\t\t\t\t\tPoint.subtract(beginState.canvasPointUnderMouse, snappedDelta),\n\t\t\t\t)\n\n\t\t\t\t// Create a rect that factors in that translation in\n\t\t\t\t// untransformed space. If the parent doesn't change, this will\n\t\t\t\t// be the next position of the node.\n\t\t\t\tlet translatedNodeRect: Rect = {\n\t\t\t\t\t...startingRect,\n\t\t\t\t\t...Point.pixelAligned(Point.add(startingRect, untransformedDeltaInStartingParent), startingRect),\n\t\t\t\t}\n\n\t\t\t\t// Create an aggregate matrix that factors in the new position\n\t\t\t\t// so that we can convert the untransformed rect's new position\n\t\t\t\t// to the canvas. This will allow us to determine if there is a\n\t\t\t\t// better parent for it's new position. We translate before\n\t\t\t\t// multiplying the beginState matrix to ensure that points\n\t\t\t\t// converted through it reflect the position after the drag.\n\t\t\t\tconst matrix = getMatrixForDescendants(engine.tree, startingParentNode)\n\t\t\t\t\t.translate(untransformedDeltaInStartingParent.x, untransformedDeltaInStartingParent.y)\n\t\t\t\t\t.multiply(beginState.matrix)\n\n\t\t\t\tconst newParent = this.getNewParent(\n\t\t\t\t\tnode,\n\t\t\t\t\tstartingParentNode,\n\t\t\t\t\t// Check what parent would best contain the transformed\n\t\t\t\t\t// canvas points of our moved node at it's new position.\n\t\t\t\t\tRect.pointsAtOrigin(translatedNodeRect).map(point => Matrix.convertPoint(matrix, point)),\n\t\t\t\t\ttranslatedNodeRect,\n\t\t\t\t\tisCopyOfReplicaChild,\n\t\t\t\t\tstartFromStackOrGrid,\n\t\t\t\t\tdisableReparenting || areAllStackOrGridChildrenFixedOrAbsolute,\n\t\t\t\t\tfinal,\n\t\t\t\t)\n\n\t\t\t\tconst isCopying = staleNode.id !== targetId\n\t\t\t\tconst nodeToReposition = this.reparentNode(node, newParent, newSelection, isCopying, isLiveSorting, -1, true)\n\n\t\t\t\tif (this.shouldHighLightParents) {\n\t\t\t\t\tthis.highlightedParents = addToHighlightedParents(this.highlightedParents, newParent, this.activeStackOrGrid)\n\t\t\t\t}\n\n\t\t\t\t// If the parent has changed as a result of the movement,\n\t\t\t\t// recalculate what offset (this time relative to the new\n\t\t\t\t// parent's aggregate matrix) that would move the node to a\n\t\t\t\t// point where it projects to the mouse.\n\t\t\t\tif (newParent?.id !== beginState.parent?.id) {\n\t\t\t\t\tconst unTransformedDelta = translateXYToPoint(\n\t\t\t\t\t\tgetMatrix(engine.tree, newParent),\n\t\t\t\t\t\tbeginState.untransformedPointUnderMouse,\n\t\t\t\t\t\tPoint.subtract(beginState.canvasPointUnderMouse, snappedDelta),\n\t\t\t\t\t)\n\t\t\t\t\ttranslatedNodeRect = {\n\t\t\t\t\t\t...startingRect,\n\t\t\t\t\t\t...Point.pixelAligned(Point.add(startingRect, unTransformedDelta), startingRect),\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst update = this.getUpdatedNodeConstraints(\n\t\t\t\t\ttree,\n\t\t\t\t\tnodeToReposition,\n\t\t\t\t\ttranslatedNodeRect,\n\t\t\t\t\tbeginState,\n\t\t\t\t\tnewParent,\n\t\t\t\t\tisPositionAbsoluteAlreadyOrForced,\n\t\t\t\t)\n\n\t\t\t\tnodeToReposition.set(update)\n\n\t\t\t\tcounterOffsetChildren(engine, nodeToReposition, beginState, translatedNodeRect)\n\t\t\t}\n\t\t}\n\n\t\t// Do a final update after exiting the move tool\n\t\tif (final) {\n\t\t\tengine.tree.beginAllowPartialScopeAccess()\n\t\t\tverifyHomeNodePostMove(engine, this.nodesBeginState, targetIds)\n\t\t\tverifyOverlaysPostMove(engine, this.nodesBeginState, targetIds)\n\t\t\tengine.tree.endAllowPartialScopeAccess()\n\n\t\t\tthis.removePlaceholders()\n\t\t\tif (this.activeStackOrGrid && !areAllStackOrGridChildrenFixedOrAbsolute && !isPositionAbsoluteAlreadyOrForced) {\n\t\t\t\tthis.insertSelectionIntoStackOrGrid(targetIds, newSelection, isLiveSorting, wrap)\n\t\t\t}\n\n\t\t\thandleDuplicationMetrics(targetIds, engine.tree)\n\t\t\tif (!isReorder) selectionStore.set(newSelection)\n\n\t\t\tif (targetIds.size > 0) {\n\t\t\t\tconst lastDuplicationMap: Map<NodeID, NodeID> = new Map()\n\t\t\t\tfor (const [node, cloneId] of targetIds.entries()) {\n\t\t\t\t\tlastDuplicationMap.set(node.id, cloneId)\n\t\t\t\t}\n\t\t\t\tdocumentSettingsStore.lastDuplicationMap = lastDuplicationMap\n\t\t\t}\n\n\t\t\tthis.renamedIds.clear()\n\n\t\t\treturn\n\t\t}\n\n\t\tif (!isReorder) selectionStore.set(newSelection)\n\n\t\tthis.commonParentAfterLastUpdate = getCommonParent(tree, activeNodes)\n\t\tthis.topLevelFrameNodesAfterLastUpdate = tree.getTopLevelFrameNodes(activeNodes)\n\t}\n\n\tprivate getUpdatedNodeConstraints(\n\t\ttree: CanvasTree,\n\t\tnode: CanvasNode,\n\t\tnodeRect: Rect,\n\t\tbeginState: MoveToolBeginState,\n\t\tnewParent: CanvasNode | null,\n\t\tforceAbsolutePosition: boolean | undefined,\n\t) {\n\t\tconst sameParent = beginState.parent ? beginState.parent.id === newParent?.id : newParent === null\n\t\tconst keepCurrentConstraints = shouldKeepCurrentConstraints(beginState, sameParent)\n\n\t\t/**\n\t\t * At this point we might just have reparented, cache might not have\n\t\t * been updated yet, so don't use the cached viewport/parent rect.\n\t\t *\n\t\t * When alt-dragging a node, the created replica clone might not have\n\t\t * been rebuilt, thus the node in targetIds points to the original node.\n\t\t * However, when updating the constraints, we should refer to the\n\t\t * newParent given (rather than the given node's parent) in case the\n\t\t * node is a replica child.\n\t\t */\n\t\tconst allowCache = false\n\t\tconst parentSizeInfo = tree.getParentSizeInfo(node, newParent, true, allowCache)\n\t\tconst props = node.updateForRect({\n\t\t\trect: nodeRect,\n\t\t\tparentSizeInfo,\n\t\t\tupdateSize: false,\n\t\t\tconstraintsLocked: getConstraintsLocked(node, keepCurrentConstraints),\n\t\t\tshouldGuessPinToBottom: shouldGuessPinToBottom(tree, node),\n\t\t\tshouldGuessPinToRight: shouldGuessPinToRight(tree, node, newParent),\n\t\t})\n\n\t\tif (!keepCurrentConstraints && isPinnable(node)) {\n\t\t\tprops.constraintsLocked = false\n\t\t}\n\n\t\tif (forceAbsolutePosition) {\n\t\t\tprops.position = \"absolute\"\n\t\t} else {\n\t\t\tObject.assign(props, positionTypeUpdateForNewParent(node, newParent))\n\t\t}\n\t\treturn props\n\t}\n\n\tprivate getNewParent(\n\t\tnode: CanvasNode,\n\t\tstartingParentNode: CanvasNode | null,\n\t\tpoints: Point[],\n\t\tsize: Size,\n\t\tisCopyOfReplicaChild: boolean,\n\t\tstartFromStackOrGridParent: boolean,\n\t\tdisableReparenting: boolean,\n\t\tfinal: boolean,\n\t): CanvasNode | null {\n\t\tconst { engine } = this\n\t\t// When moving a fixed or absolute position stack child, never\n\t\t// re-parent. We only want to reposition inside the current stack, and\n\t\t// we don't want to move the layer to the canvas for live-sorting.\n\t\tif (disableReparenting) return startingParentNode\n\t\t// When live sorting a stack child, it's moved to a ground node at the\n\t\t// start of the move tool. While we are live sorting, we need to\n\t\t// continue to assume the parent is null until the final frame.\n\t\tif (this.activeStackOrGrid) return final ? this.activeStackOrGrid : NullID\n\n\t\tconst { tree } = engine\n\t\tconst { mouseStore } = engine.stores\n\t\tconst { cmdKey, altKey, spacebar, canvasMousePosition } = mouseStore.latest\n\t\tconst moveFromAnywhereEnabled = altKey && cmdKey\n\n\t\tconst originalParentIsVector = startingParentNode && isVectorNode(startingParentNode)\n\t\tconst isSymbolChild = node.originalid && !isReplica(node) && !isReplicaVariantChild(node)\n\n\t\tconst allowReparenting =\n\t\t\t!spacebar && (!cmdKey || moveFromAnywhereEnabled) && !originalParentIsVector && !isSymbolChild\n\n\t\tlet newParent: CanvasNode | null = startingParentNode\n\n\t\tif (allowReparenting || isCopyOfReplicaChild) {\n\t\t\tnewParent = findNewParent(engine, node, points, this.selectionIds(), canvasMousePosition, altKey)\n\n\t\t\t// Don't drag copied ground node into itself or equal sized ground nodes\n\t\t\tif (altKey && newParent && tree.isGroundNode(newParent)) {\n\t\t\t\tconst newParentSize = tree.getRect(newParent.draftOrCurrent())\n\t\t\t\tconst newParentSmallerThanCurrentNode = newParentSize.width <= size.width && newParentSize.height <= size.height\n\t\t\t\tif (newParentSmallerThanCurrentNode || newParent.id === node.duplicatedFrom?.[node.duplicatedFrom.length - 1]) {\n\t\t\t\t\tnewParent = null\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Be sure node is fully dragged outside of original parent\n\t\t\t// Copies of replica children are never allowed to stay in their original parent\n\t\t\tif (\n\t\t\t\t!isCopyOfReplicaChild &&\n\t\t\t\tshouldStayInOriginalParent(tree, points, startingParentNode, newParent, startFromStackOrGridParent)\n\t\t\t) {\n\t\t\t\tnewParent = startingParentNode\n\t\t\t}\n\t\t}\n\t\treturn newParent\n\t}\n\n\tprivate reparentNode(\n\t\tnode: CanvasNode,\n\t\tnewParent: CanvasNode | null,\n\t\tnewSelection: Set<NodeID>,\n\t\tisCopying: boolean,\n\t\tisLiveSorting: boolean,\n\t\tinsertionIndex: number,\n\t\tcheckCloneCache: boolean,\n\t): CanvasNode {\n\t\tconst { engine } = this\n\t\tconst currentParent = engine.tree.getParent(node.id)\n\t\tif (nodesAreEqual(newParent, currentParent) && insertionIndex === -1 && !isCopying) return node\n\n\t\tif (isReplicaChild(node) && newParent && isReplicaOrReplicaChild(newParent)) {\n\t\t\treturn this.reparentNodeInsideVariant(node, newParent, insertionIndex)\n\t\t} else if (isReplicaChild(node)) {\n\t\t\treturn this.moveNodeOutOfVariant(node, newParent, insertionIndex, newSelection, isLiveSorting, checkCloneCache)\n\t\t} else if (newParent && isReplicaOrReplicaChild(newParent)) {\n\t\t\treturn this.moveNodeIntoVariant(node, newParent, insertionIndex, newSelection)\n\t\t}\n\n\t\tengine.moveNode(node.id, newParent ? newParent.id : NullID, insertionIndex)\n\n\t\t// Make sure layers dragged into a regular grid have the right gridItemFillCellHeight and\n\t\t// gridItemFillCellWidth values.\n\t\tif (isGridComponent(newParent) && withGridItemSize(node)) {\n\t\t\tconst update: Partial<WithGridItemSize> = {}\n\n\t\t\tif (doesWidthFitImage(node)) {\n\t\t\t\t// Nodes with widthType of \"fit-image\" shouldn't have gridItemFillCellWidth because they\n\t\t\t\t// always fit the intrinsic width of the image, see collectBackgroundImage.ts.\n\t\t\t\tif (node.gridItemFillCellWidth === true) {\n\t\t\t\t\tupdate.gridItemFillCellWidth = false\n\t\t\t\t}\n\t\t\t} else if (node.gridItemFillCellWidth === undefined) {\n\t\t\t\t// Otherwise, we want nodes dragged into a grid to fill the cell width.\n\t\t\t\tupdate.gridItemFillCellWidth = true\n\t\t\t}\n\n\t\t\tif (doesHeightFitImage(node)) {\n\t\t\t\t// Nodes with heightType of \"fit-image\" have gridItemFillCellHeight:false because they\n\t\t\t\t// always fit the intrinsic height of the image, see collectBackgroundImage.ts.\n\t\t\t\tif (node.gridItemFillCellHeight === true) {\n\t\t\t\t\tupdate.gridItemFillCellHeight = false\n\t\t\t\t}\n\t\t\t} else if (hasColumnMasonryLayout(newParent)) {\n\t\t\t\t// Nodes inside a column masonry layout shouldn't have gridItemFillCellHeight.\n\t\t\t\t// TODO: Also clean all relevant grid item properties when moving into a masonry grid\n\t\t\t\tif (node.gridItemFillCellHeight === true) {\n\t\t\t\t\tupdate.gridItemFillCellHeight = undefined\n\t\t\t\t}\n\t\t\t} else if (node.gridItemFillCellHeight === undefined) {\n\t\t\t\t// Otherwise, we want nodes dragged into a grid to fill the cell height.\n\t\t\t\tupdate.gridItemFillCellHeight = true\n\t\t\t}\n\n\t\t\tif (!isEmptyObject(update)) {\n\t\t\t\tnode.set(update)\n\t\t\t}\n\t\t}\n\n\t\treturn node\n\t}\n\n\tprivate reparentNodeInsideVariant(\n\t\tnode: CanvasNode & IsReplicaChild,\n\t\tnewParent: CanvasNode & IsReplicaOrReplicaChild,\n\t\tinsertionIndex: number,\n\t): CanvasNode {\n\t\tconst { engine } = this\n\t\tupdateNodeWhenReparentedInVariant(engine, node, newParent)\n\t\tengine.moveNode(node.originalid, newParent.originalid, insertionIndex)\n\n\t\treturn node\n\t}\n\n\tprivate moveNodeOutOfVariant(\n\t\tnode: CanvasNode & IsReplicaChild,\n\t\tnewParent: CanvasNode | null,\n\t\tinsertionIndex: number,\n\t\tnewSelection: Set<NodeID>,\n\t\tisLiveSorting: boolean,\n\t\tcheckCloneCache: boolean,\n\t): CanvasNode {\n\t\tconst { engine } = this\n\t\tconst originalNode = engine.tree.getNode(node.originalid)\n\t\tassert(originalNode, \"original node must exist\")\n\n\t\t// If the node is also visible in other variants, we hide the current node,\n\t\t// and drag out a clone instead.\n\t\tif (\n\t\t\t!experiments.isOn(\"betterStackGridItemMoving\") &&\n\t\t\t(!isVisibleInOtherVariants(engine.tree, node) || isLiveSorting)\n\t\t) {\n\t\t\tthis.updateNodesInMoveToolBaseFontSize(node.id, originalNode.id)\n\t\t\tupdateNodeWhenMovedOutOfVariant(engine, node, originalNode, newSelection)\n\t\t\tengine.moveNode(originalNode.id, newParent ? newParent.id : NullID, insertionIndex)\n\t\t} else if (checkCloneCache) {\n\t\t\tconst clone = this.cloneCache.get(node.id) ?? engine.cloneNode(node, false, false)\n\t\t\tthis.cloneCache.set(node.id, clone)\n\n\t\t\tconst newNode = clone.cloneWithIds()\n\t\t\tengine.stores.scopeStore.insertNode(newNode, newParent ? newParent.id : NullID, insertionIndex)\n\n\t\t\tthis.updateNodesInMoveToolBaseFontSize(node.id, newNode.id)\n\n\t\t\tengine.tree.current(node)?.set({ visible: false })\n\t\t\tnewSelection.delete(node.id)\n\t\t\tnewSelection.add(newNode.id)\n\t\t\treturn newNode\n\t\t}\n\n\t\treturn originalNode\n\t}\n\n\tprivate moveNodeIntoVariant(\n\t\tnode: CanvasNode,\n\t\tnewParent: CanvasNode & IsReplicaOrReplicaChild,\n\t\tinsertionIndex: number,\n\t\tnewSelection: Set<NodeID>,\n\t): CanvasNode {\n\t\tconst { engine } = this\n\t\tconst originalNewParent = engine.tree.getNode(newParent.originalid)\n\t\tassert(originalNewParent, \"original node of the new parent should exist\")\n\t\tengine.moveNode(node.id, originalNewParent?.id ?? NullID, insertionIndex)\n\n\t\tconst replicaNodeId = updateNodeWhenMovedIntoVariant(\n\t\t\tengine,\n\t\t\tnode,\n\t\t\tnewParent,\n\t\t\toriginalNewParent,\n\t\t\tnewSelection,\n\t\t\tthis.renamedIds,\n\t\t)\n\n\t\tthis.updateNodesInMoveToolBaseFontSize(node.id, replicaNodeId)\n\n\t\treturn node\n\t}\n\n\tprivate insertSelectionIntoStackOrGrid(\n\t\ttargetIds: TargetIds,\n\t\tnewSelection: Set<NodeID>,\n\t\tisLiveSorting: boolean,\n\t\twrap: WrapInsertionInfo | undefined,\n\t) {\n\t\tif (isNull(this.activeStackOrGrid) || !isNumber(this.activeStackOrGridInsertion)) return\n\n\t\tconst { engine } = this\n\t\tconst sortingNodeIds = Array.from(this.nodesBeginState.keys()).map(_node => {\n\t\t\treturn targetIds.get(_node) ?? _node.id\n\t\t})\n\n\t\t// This is the starting reference for the stack or grid, which can get updated throughout\n\t\t// this method.\n\t\tlet stackOrGrid: StackComponentNode | GridComponentNode = this.activeStackOrGrid\n\n\t\tconst isBetterStackGridItemMovingOn = experiments.isOn(\"betterStackGridItemMoving\")\n\n\t\t// insertion indexes are based on visible rects only, so we need to convert\n\t\t// the visual index to an actual child index, which will account for any\n\t\t// hidden children\n\t\tlet insertionIndex = isBetterStackGridItemMovingOn\n\t\t\t? this.activeStackOrGridInsertion\n\t\t\t: convertVisualInsertionIndexToChildIndex(this.activeStackOrGridInsertion, stackOrGrid, sortingNodeIds)\n\n\t\tif (wrap && isStackComponent(stackOrGrid)) {\n\t\t\tconst newParent = wrapStackBeforeInsertion(engine, stackOrGrid, wrap)\n\t\t\tif (newParent) stackOrGrid = newParent\n\t\t}\n\n\t\tconst isGrid = isGridComponent(stackOrGrid)\n\n\t\tfor (const [staleNode, beginState] of this.nodesBeginState) {\n\t\t\tconst targetId = targetIds.get(staleNode) ?? staleNode.id\n\t\t\tconst node = engine.tree.getNode(targetId)\n\t\t\tif (!node) continue\n\t\t\tassert(!isNull(stackOrGrid), \"stackOrGrid must be a valid node\")\n\n\t\t\tconst isCopying = staleNode.id !== targetId\n\t\t\t// When sorting (and not cloning) in a stack/grid, we don't make the\n\t\t\t// node a ground node in the final update, therefore here we only update\n\t\t\t// the itemsOrder if sorting in a replica variant stack/grid, don't\n\t\t\t// reparent the original node.\n\n\t\t\tif (\n\t\t\t\tisBetterStackGridItemMovingOn &&\n\t\t\t\t!isCopying &&\n\t\t\t\tbeginState.parent &&\n\t\t\t\tbeginState.parent.id === stackOrGrid.id &&\n\t\t\t\tbeginState.index < this.activeStackOrGridInsertion\n\t\t\t) {\n\t\t\t\tinsertionIndex -= 1\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t(isBetterStackGridItemMovingOn ? node.parentid === stackOrGrid.id : isLiveSorting) &&\n\t\t\t\t!isCopying &&\n\t\t\t\tisReplicaVariantOrReplicaVariantChild(stackOrGrid) &&\n\t\t\t\tisSortableNode(node)\n\t\t\t) {\n\t\t\t\tupdateIdIndexInItemsOrder(node.getPrimaryId(), stackOrGrid, insertionIndex)\n\t\t\t\tinsertionIndex += 1\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconst nodeToUpdate = this.reparentNode(\n\t\t\t\tnode,\n\t\t\t\tstackOrGrid,\n\t\t\t\tnewSelection,\n\t\t\t\tisCopying,\n\t\t\t\tisLiveSorting,\n\t\t\t\tinsertionIndex,\n\t\t\t\ttrue,\n\t\t\t)\n\n\t\t\t// getUpdatedNodeConstraints isn't called for stack-/grid-related operations in final\n\t\t\t// mode, so we need to do update the position here ourselves.\n\t\t\tconst positionTypeUpdate = positionTypeUpdateForNewParent(nodeToUpdate, stackOrGrid)\n\t\t\tif (withPositionType(nodeToUpdate) && positionTypeUpdate) {\n\t\t\t\tnodeToUpdate.set(positionTypeUpdate)\n\t\t\t}\n\n\t\t\tif (isPinnable(nodeToUpdate)) {\n\t\t\t\tconst update: Partial<typeof nodeToUpdate> = {\n\t\t\t\t\ttop: 0,\n\t\t\t\t\tleft: 0,\n\t\t\t\t\tright: null,\n\t\t\t\t\tbottom: null,\n\t\t\t\t\t...beginState.startSizeProps,\n\t\t\t\t}\n\n\t\t\t\t// convert fraction and relative dimensions to fixed when the target stack is auto-sized\n\t\t\t\t// on those dimensions, unless the element is only sorted\n\t\t\t\tconst movingToNewParent = !beginState.parent || beginState.parent.id !== stackOrGrid.id\n\t\t\t\tif (movingToNewParent) {\n\t\t\t\t\tconst widthIsFractionOrPercentage =\n\t\t\t\t\t\tupdate.widthType === DimensionType.FractionOfFreeSpace || update.widthType === DimensionType.Percentage\n\n\t\t\t\t\tconst heightIsFractionOrPercentage =\n\t\t\t\t\t\tupdate.heightType === DimensionType.FractionOfFreeSpace || update.heightType === DimensionType.Percentage\n\n\t\t\t\t\tif (widthIsFractionOrPercentage && (isGrid || stackOrGrid.widthType === DimensionType.Auto)) {\n\t\t\t\t\t\tupdate.width = beginState.rect.width\n\t\t\t\t\t\tupdate.widthType = DimensionType.FixedNumber\n\t\t\t\t\t}\n\t\t\t\t\tif (heightIsFractionOrPercentage && (isGrid || stackOrGrid.heightType === DimensionType.Auto)) {\n\t\t\t\t\t\tupdate.height = beginState.rect.height\n\t\t\t\t\t\tupdate.heightType = DimensionType.FixedNumber\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tnodeToUpdate.set(update)\n\t\t\t} else {\n\t\t\t\tnodeToUpdate.set(beginState.startSizeProps as Partial<typeof nodeToUpdate>)\n\t\t\t}\n\n\t\t\tinsertionIndex += 1\n\t\t}\n\t}\n\n\tprivate makeGroundNodes(targetIds: TargetIds) {\n\t\tfor (const [staleNode] of this.nodesBeginState) {\n\t\t\tconst targetId = targetIds.get(staleNode) ?? staleNode.id\n\t\t\tconst node = this.engine.tree.getNode(targetId)\n\t\t\tif (!node) continue\n\t\t\tconst isCopying = staleNode.id !== targetId\n\t\t\tthis.reparentNode(node, null, new Set(), isCopying, false, -1, false)\n\t\t}\n\t}\n\n\tprivate removePlaceholders(skipToolStoreReset = false) {\n\t\tif (!skipToolStoreReset) {\n\t\t\tthis.engine.stores.toolStore.nodesWithPlaceholders = null\n\t\t}\n\n\t\t// Drop `skipToolStoreReset` when cleaning up the experiment, reset unconditionally\n\t\tif (experiments.isOn(\"betterStackGridItemMoving\")) {\n\t\t\tfor (const { id } of this.parentsWithPlaceholders) {\n\t\t\t\tconst parent = this.engine.tree.getNode(id)\n\t\t\t\tif (!parent) continue\n\t\t\t\tparent.cache.placeholders = null\n\t\t\t}\n\t\t} else {\n\t\t\tif (!this.activeStackOrGrid) return\n\t\t\tthis.activeStackOrGrid.cache.placeholders = null\n\t\t}\n\t}\n}\n\nfunction getMouseDelta(mouseStore: MouseStore, directionLock?: StackDirection) {\n\tconst { canvasMousePosition, shiftKey } = mouseStore.latest\n\tconst previous = mouseStore.previous\n\treturn previous.canvasMouseDownPosition\n\t\t? getDelta(previous.canvasMouseDownPosition, canvasMousePosition, shiftKey, directionLock)\n\t\t: undefined\n}\n\nfunction getDelta(mouseDownPoint: Point, mousePoint: Point, shiftKey: boolean, directionLock?: StackDirection) {\n\tconst result = Point.pixelAligned(Point.subtract(mousePoint, mouseDownPoint))\n\tif (directionLock) {\n\t\tif (directionLock === \"horizontal\") {\n\t\t\tresult.y = 0\n\t\t} else {\n\t\t\tresult.x = 0\n\t\t}\n\t} else if (shiftKey) {\n\t\tif (Math.abs(result.x) > Math.abs(result.y)) {\n\t\t\tresult.y = 0\n\t\t} else {\n\t\t\tresult.x = 0\n\t\t}\n\t}\n\n\treturn result\n}\n\nfunction getCommonParent(tree: CanvasTree, nodes: CanvasNode[]): MaybeNodeID | undefined {\n\tconst parentNodes = nodes.map(node => {\n\t\treturn node ? tree.getParent(node.id) : undefined\n\t})\n\tconst commonParent = new Set(parentNodes).size === 1\n\tif (!commonParent) {\n\t\treturn undefined\n\t}\n\tconst parentNode = parentNodes[0]\n\tif (parentNode) {\n\t\treturn parentNode.id\n\t}\n\t// parentNode is canvas\n\treturn NullID\n}\n\nfunction isValidParent(\n\tengine: VekterEngine,\n\tnode: CanvasNode,\n\tpotentialParent: CanvasNode,\n\tselection: NodeID[],\n\tactiveScopeId: NodeID,\n\tisDuplicating: boolean,\n) {\n\tconst { tree } = engine\n\tif (!isTreeNode(potentialParent) || withShape(potentialParent)) return false\n\n\tif (isStackOrGridComponent(potentialParent)) return false\n\tif (!acceptsChild(tree, potentialParent, node, activeScopeId, engine.componentLoader)) return false\n\n\tconst ancestors = tree.getAncestors(potentialParent.id)\n\tancestors.push(potentialParent.id)\n\n\tconst ancestorInSelection = nodeListsIntersect(ancestors, selection)\n\tif (ancestorInSelection) return false\n\n\tconst nodeIsAncestorOfPotentialParent = ancestors.some(ancestorId => ancestorId === node.id)\n\tif (nodeIsAncestorOfPotentialParent) return false\n\n\t// Make sure we don't drag the copy into the original\n\tif (isDuplicating && nodesAreSimilar(node, potentialParent)) return false\n\treturn true\n}\n\nfunction findNewParent(\n\tengine: VekterEngine,\n\tnode: CanvasNode,\n\tpoints: Point[],\n\tselection: NodeID[],\n\tmouse: Point,\n\tisDuplicating: boolean,\n) {\n\tconst { tree } = engine\n\tconst activeScope = engine.stores.scopeStore.active\n\tconst potentialParents = tree.getPotentialParents(\n\t\tactiveScope,\n\t\tengine.stores.overlayStore.activeOverlays,\n\t\tpoints,\n\t\tmouse,\n\t\tengine.componentLoader,\n\t\tnode,\n\t)\n\tconst sortedPotentialParents = tree.sortVisually(potentialParents).reverse()\n\tconst newParent = sortedPotentialParents.find(potentialParent =>\n\t\tisValidParent(engine, node, potentialParent, selection, activeScope.id, isDuplicating),\n\t)\n\n\treturn newParent || NullID\n}\n\nfunction shouldStayInOriginalParent(\n\ttree: CanvasTree,\n\tpoints: Point[],\n\toriginalParent: CanvasNode | null,\n\tnewParent: CanvasNode | null,\n\tstartFromStackOrGridParent: boolean,\n) {\n\tif (startFromStackOrGridParent || !originalParent || !newParent) return false\n\n\tconst movingToNewParent = !nodesAreEqual(newParent, originalParent)\n\tif (!movingToNewParent) return false\n\n\tconst newParentIsAncestor =\n\t\t!newParent ||\n\t\ttree.getAncestors(originalParent.id).find((ancestorId: NodeID) => {\n\t\t\treturn newParent !== null && ancestorId === newParent.id\n\t\t})\n\n\tif (!newParentIsAncestor) return false\n\n\tconst parentPoints = convertCornerPointsToCanvas(tree, originalParent)\n\treturn Polygon.intersects(parentPoints, points)\n}\n\nfunction addToHighlightedParents(\n\thighlightedParents: HighlightedParents,\n\tnewParent: CanvasNode | null,\n\tactiveStackOrGrid: CanvasNode | null,\n) {\n\tconst highlightNode = activeStackOrGrid || newParent\n\tif (\n\t\t!highlightNode ||\n\t\tisVectorNode(highlightNode) ||\n\t\t(isShapeContainerNode(highlightNode) && highlightNode.sizeToFit)\n\t) {\n\t\treturn highlightedParents\n\t}\n\treturn highlightedParents.add(highlightNode.id)\n}\n\nfunction getParentOffset(node: CanvasNode, beginState: MoveToolBeginState, nodeRect: Rect) {\n\tlet parentDelta = {\n\t\tx: beginState.rect.x - nodeRect.x,\n\t\ty: beginState.rect.y - nodeRect.y,\n\t}\n\n\tif (withRotation(node)) {\n\t\tconst rotation = node.resolveValue(\"rotation\")\n\t\tconst matrix = new DOMMatrix().rotateSelf(0, 0, -rotation)\n\t\tparentDelta = Matrix.convertPoint(matrix, parentDelta)\n\t}\n\n\treturn parentDelta\n}\n\nfunction counterOffsetChildren(\n\tengine: VekterEngine,\n\tnode: CanvasNode,\n\tbeginState: MoveToolBeginState,\n\tparentRect: Rect,\n) {\n\tconst { tree } = engine\n\tconst { cmdKey, altKey } = engine.stores.mouseStore.latest\n\tconst moveFromAnywhereEnabled = altKey && cmdKey\n\tif (!cmdKey || moveFromAnywhereEnabled) return\n\n\tbeginState.children.forEach((childBeginState: ChildBeginState, childId: NodeID) => {\n\t\tif (beginState.startFromStackOrGrid) return\n\t\tconst childNode = tree.getNode(childId)\n\t\tif (!childNode) return\n\n\t\tconst parentOffset = getParentOffset(node, beginState, parentRect)\n\t\tconst childFrame = Rect.offset(childBeginState.frame, parentOffset)\n\t\tconst childProps = childNode.updateForRect({\n\t\t\trect: childFrame,\n\t\t\tparentSizeInfo: tree.getParentSizeInfo(childNode, node),\n\t\t\tconstraintsLocked: getConstraintsLocked(childNode),\n\t\t\tshouldGuessPinToBottom: shouldGuessPinToBottom(tree, childNode),\n\t\t\tshouldGuessPinToRight: shouldGuessPinToRight(tree, childNode, tree.getParent(childNode.id)),\n\t\t})\n\t\tremoveAutoAndFractionDimensionsFromUpdate(childNode, childProps)\n\t\tengine.tree.get(childId)?.set(childProps)\n\t})\n}\n\nfunction removeAutoAndFractionDimensionsFromUpdate(node: CanvasNode, update: Partial<WithPins & WithSize>) {\n\tif (!isPinnable(node)) return update\n\n\tif (node.widthType === DimensionType.Auto || node.widthType === DimensionType.FractionOfFreeSpace) {\n\t\tdelete update.width\n\t\tdelete update.widthType\n\t}\n\tif (node.heightType === DimensionType.Auto || node.heightType === DimensionType.FractionOfFreeSpace) {\n\t\tdelete update.height\n\t\tdelete update.heightType\n\t}\n\treturn update\n}\n\nfunction getSmallestDistanceIndex(distances: number[]) {\n\tlet smallestDistance = Infinity\n\tlet smallestIndex = 0\n\tfor (let i = 0, il = distances.length; i < il; i++) {\n\t\t// biome-ignore lint/style/noNonNullAssertion: loop\n\t\tconst currentDistance = distances[i]!\n\t\tif (currentDistance >= smallestDistance) continue\n\t\tsmallestDistance = currentDistance\n\t\tsmallestIndex = i\n\t}\n\treturn smallestIndex\n}\n\n// Copies\n\nfunction createCopies(\n\tengine: VekterEngine,\n\tnodesBeginState: NodesBeginState,\n\ttargetIds: TargetIds,\n\tcloneCache: Map<NodeID, CanvasNode>,\n\trenamedIds: RenamedIds,\n) {\n\tnodesBeginState.forEach((_, node: CanvasNode) => {\n\t\t// Do not copy floating layers\n\t\tif (hasFloatingPosition(node)) return\n\n\t\t// do not copy shapes inside instances\n\t\t// otherwise we'll need to create a new shape container and insert it to the root\n\t\tif (isVectorNode(node) && isReplicaChild(node)) {\n\t\t\treturn\n\t\t}\n\n\t\tconst clone = cloneCache.get(node.id) ?? engine.cloneNode(node, false, false, renamedIds)\n\t\tcloneCache.set(node.id, clone)\n\n\t\tconst newNode = clone.cloneWithIds()\n\t\tengine.stores.scopeStore.insertNode(newNode, node.parentid)\n\t\trenamedIds.set(node.id, newNode.id)\n\t\ttargetIds = targetIds.set(node, newNode.id)\n\n\t\tif (isMasterChild(node)) {\n\t\t\tapplyOverridesToReplicasOfDuplicatedPrimaryChild(engine, node, renamedIds)\n\t\t}\n\t})\n\n\tconst copiedNodes = Array.from(targetIds.values())\n\tfor (const id of copiedNodes) {\n\t\tconst node = engine.tree.getNode(id)\n\t\tconst parent = engine.tree.getParent(id)\n\t\tconst inOverlay = !!parent && (isOverlayNode(parent) || nodeIsInOverlay(parent))\n\n\t\tif (node) {\n\t\t\tupdateNodeConnections(engine.tree, engine.componentLoader, node, renamedIds, inOverlay)\n\t\t}\n\t}\n\n\tengine.stores.selectionStore.set(copiedNodes)\n}\n\n// Live sorting and insertion\n\nfunction selectionCanMoveToStackAndGrid(nodes: CanvasNode[], tree: CanvasTree) {\n\treturn nodes.every(node => !isVectorInGroup(node, tree))\n}\n\nfunction getCommonStackOrGridParentAtStart(\n\ttree: CanvasTree,\n\tnodes: CanvasNode[],\n): StackComponentNode | GridComponentNode | null {\n\tlet commonParent: StackComponentNode | GridComponentNode | null = null\n\n\tfor (let i = 0, il = nodes.length; i < il; i++) {\n\t\tconst node = nodes[i]\n\t\tif (!node) return null\n\t\tconst parent = tree.getParent(node.id)\n\t\tif (!parent) return null\n\t\tif (!commonParent) {\n\t\t\tif (!isStackComponent(parent) && !isGridComponent(parent)) return null\n\t\t\tcommonParent = parent\n\t\t} else if (commonParent.id !== parent.id) {\n\t\t\treturn null\n\t\t}\n\t}\n\treturn commonParent\n}\n\nfunction unableToMoveAll(nodesBeginState: NodesBeginState) {\n\tfor (const beginState of nodesBeginState.values()) {\n\t\tif (!beginState.unableToMove) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfunction getParentsWithPlaceholders(nodesBeginState: NodesBeginState): NodeWithPlaceholders[] {\n\tconst parentsWithPlaceholders = new Map<CanvasNode, PlaceholderItem[]>()\n\tfor (const [, beginState] of nodesBeginState) {\n\t\tif (!beginState.parent || !beginState.placeholderAttributes) continue\n\t\tconst placeholders = parentsWithPlaceholders.get(beginState.parent) ?? []\n\t\tplaceholders.push({ index: beginState.index, attributes: beginState.placeholderAttributes })\n\t\tparentsWithPlaceholders.set(beginState.parent, placeholders)\n\t}\n\n\treturn Array.from(parentsWithPlaceholders, ([parent, placeholders]) => ({ id: parent.id, placeholders }))\n}\n\nfunction getStartVisualIndexIfSequentialSiblings(\n\tnodesBeginState: NodesBeginState,\n\tparent: StackComponentNode | GridComponentNode | null,\n): number | undefined {\n\tif (!parent) return\n\n\tconst visibleRelativeIndices = new Set<number>()\n\tlet minVisibleRelativeIndex: number | undefined\n\tfor (const [node, beginState] of nodesBeginState) {\n\t\tif (!beginState.parent) return\n\n\t\t// Insertion code doesn't consider hidden and non-relative nodes\n\t\tif (!node.isVisible()) continue\n\t\tif (!isPositionRelative(node, parent)) continue\n\n\t\tvisibleRelativeIndices.add(beginState.index)\n\t\tif (minVisibleRelativeIndex === undefined || beginState.index < minVisibleRelativeIndex) {\n\t\t\tminVisibleRelativeIndex = beginState.index\n\t\t}\n\t}\n\n\tif (minVisibleRelativeIndex === undefined) return\n\n\tconst children = withItemsOrder(parent) ? parent.getChildrenInVisualOrder() : getChildren(parent)\n\tlet visualOffset = 0\n\tfor (let index = 0; index < children.length; index += 1) {\n\t\tconst child = children.at(index)\n\t\tassert(child)\n\n\t\tif (!child.isVisible() || !isPositionRelative(child, parent)) {\n\t\t\tif (index < minVisibleRelativeIndex) {\n\t\t\t\tvisualOffset += 1\n\t\t\t}\n\n\t\t\tcontinue\n\t\t}\n\n\t\t// Means we haven't reached the first selected node yet\n\t\tif (index < minVisibleRelativeIndex) continue\n\n\t\t// Means the selection isn't sequential\n\t\tif (!visibleRelativeIndices.has(index)) return\n\n\t\tvisibleRelativeIndices.delete(index)\n\n\t\t// Means we visited all selected nodes and none of them failed\n\t\tif (visibleRelativeIndices.size === 0) return minVisibleRelativeIndex - visualOffset\n\t}\n}\n\nfunction getStartVisibleRelativeNodeCount(nodesBeginState: NodesBeginState): number {\n\tlet count = 0\n\tfor (const [node, beginState] of nodesBeginState) {\n\t\tif (!beginState.parent) continue\n\t\tif (!node.isVisible()) continue\n\t\tif (!isPositionRelative(node, beginState.parent)) continue\n\t\tcount += 1\n\t}\n\n\treturn count\n}\n\nfunction getMaxSize(nodesBeginState: NodesBeginState): Size {\n\tlet maxWidth = 0\n\tlet maxHeight = 0\n\tnodesBeginState.forEach((beginState: MoveToolBeginState) => {\n\t\tconst { width, height } = beginState.rect\n\t\tif (width > maxWidth) maxWidth = width\n\t\tif (height > maxHeight) maxHeight = height\n\t})\n\treturn { width: maxWidth, height: maxHeight }\n}\n\nfunction mouseWithinOriginalGroundNode(\n\tengine: VekterEngine,\n\tmouse: Point,\n\tcommonStackOrGridParentAtStart: StackComponentNode | GridComponentNode,\n): boolean {\n\tconst latestCommonStackOrGrid = engine.tree.get(commonStackOrGridParentAtStart.id)\n\tif (!latestCommonStackOrGrid) return false\n\tconst groundNode = engine.tree.getGroundNodeFor(latestCommonStackOrGrid)\n\tconst groundNodeCanvasRect = convertFrameToCanvas(engine.tree, groundNode)\n\treturn Rect.containsPoint(groundNodeCanvasRect, mouse)\n}\n\ninterface ParentStackOrGridInsertionInfo {\n\tvisualInsertionIndex: number | null\n\tinsertionLine: Line | null\n\tactiveStackOrGrid: StackComponentNode | GridComponentNode | null\n\tisLiveSorting: boolean\n\twrap?: WrapInsertionInfo\n}\n\nfunction getStackOrGridInsertionInfo(\n\tengine: VekterEngine,\n\tmouse: Point,\n\tpreviousMouse: Point,\n\tselectedNodes: CanvasNode[],\n\tnodesBeginState: NodesBeginState,\n\tcanMoveToStackOrGrid: boolean,\n\tisReordering: boolean,\n\tcommonStackOrGridParentAtStart: StackComponentNode | GridComponentNode | null,\n\tmaxSize: Size,\n\tpreviousInsertionIndex: number | null | undefined,\n\tisPositionAbsoluteAlreadyOrForced: boolean | undefined,\n\tareAllStackOrGridChildrenFixedOrAbsolute: boolean,\n\tspacebar: boolean,\n\tcmdKey: boolean,\n\tmoveFromAnywhereEnabled: boolean,\n): ParentStackOrGridInsertionInfo {\n\t// The selected nodes can be removed by async edits. Return early if the\n\t// nodes no longer exist.\n\tif (selectedNodes.length === 0) {\n\t\treturn {\n\t\t\tvisualInsertionIndex: null,\n\t\t\tinsertionLine: null,\n\t\t\tactiveStackOrGrid: null,\n\t\t\tisLiveSorting: false,\n\t\t}\n\t}\n\n\tif (areAllStackOrGridChildrenFixedOrAbsolute) {\n\t\t// If every node is position fixed or absolute, we never want to re-parent, but we do want\n\t\t// to enable snapping.\n\t\treturn {\n\t\t\tvisualInsertionIndex: null,\n\t\t\tinsertionLine: null,\n\t\t\tactiveStackOrGrid: commonStackOrGridParentAtStart,\n\t\t\tisLiveSorting: false,\n\t\t}\n\t}\n\n\tlet activeStackOrGrid: StackComponentNode | GridComponentNode | null = null\n\tconst isBetterStackGridItemMovingOn = experiments.isOn(\"betterStackGridItemMoving\")\n\n\t// Cmd is synonymous to Spacebar when it comes to stack/grid items, as otherwise sorting\n\t// behavior would be unreasonably surprising, with child positions preserved.\n\tif (isReordering || (cmdKey && !moveFromAnywhereEnabled) || spacebar) {\n\t\tactiveStackOrGrid = commonStackOrGridParentAtStart\n\t} else if (\n\t\t!isBetterStackGridItemMovingOn &&\n\t\tcommonStackOrGridParentAtStart &&\n\t\tmouseWithinOriginalGroundNode(engine, mouse, commonStackOrGridParentAtStart)\n\t) {\n\t\tactiveStackOrGrid = commonStackOrGridParentAtStart\n\t} else if (canMoveToStackOrGrid) {\n\t\tactiveStackOrGrid = getStackOrGridInRange(engine, mouse, selectedNodes, commonStackOrGridParentAtStart)\n\t}\n\n\tif (!activeStackOrGrid || isPositionAbsoluteAlreadyOrForced) {\n\t\treturn {\n\t\t\tvisualInsertionIndex: null,\n\t\t\tinsertionLine: null,\n\t\t\tactiveStackOrGrid,\n\t\t\tisLiveSorting: false,\n\t\t}\n\t}\n\n\t// Delete everything live-sorting-related when cleaning up the experiment\n\tconst isLiveSorting = !isBetterStackGridItemMovingOn && commonStackOrGridParentAtStart?.id === activeStackOrGrid.id\n\n\tif (isLiveSorting) {\n\t\t// live sorting\n\t\tconst visualInsertionIndex = getLiveSortingIndex(\n\t\t\tengine.tree,\n\t\t\tengine.stores.layoutCache,\n\t\t\tmouse,\n\t\t\tpreviousMouse,\n\t\t\tnodesBeginState,\n\t\t\tactiveStackOrGrid,\n\t\t\tengine.tree.convertPointToNode(activeStackOrGrid, mouse),\n\t\t\tpreviousInsertionIndex,\n\t\t)\n\n\t\treturn {\n\t\t\tvisualInsertionIndex,\n\t\t\tinsertionLine: null,\n\t\t\tactiveStackOrGrid,\n\t\t\tisLiveSorting,\n\t\t}\n\t} else {\n\t\t// insertion indicator\n\t\tconst {\n\t\t\tinsertionIndex: visualInsertionIndex,\n\t\t\tinsertionLine,\n\t\t\twrap,\n\t\t} = getStackOrGridInsertionIndexAndLine(activeStackOrGrid, engine, mouse, maxSize, {\n\t\t\tallowWrapping: commonStackOrGridParentAtStart?.id !== activeStackOrGrid.id,\n\t\t})\n\n\t\treturn {\n\t\t\tvisualInsertionIndex,\n\t\t\tinsertionLine,\n\t\t\tactiveStackOrGrid,\n\t\t\tisLiveSorting,\n\t\t\twrap,\n\t\t}\n\t}\n}\n\nfunction convertVisualInsertionIndexToChildIndex(\n\tindex: number,\n\tnode: StackComponentNode | GridComponentNode,\n\tsortingNodeIds: NodeID[],\n) {\n\tlet actualIndex = 0\n\tlet visualIndex = 0\n\tfor (const child of node.getChildrenInVisualOrder()) {\n\t\tif (visualIndex === index) break\n\t\tif (sortingNodeIds.includes(child.id)) continue\n\t\tif (child.isVisible()) visualIndex++\n\t\tactualIndex++\n\t}\n\treturn actualIndex\n}\n\nfunction getInsertionPlaceholderItems(nodesBeginState: NodesBeginState, insertionIndex: number): PlaceholderItem[] {\n\tconst placeholderItems: PlaceholderItem[] = []\n\n\tlet index = insertionIndex\n\tfor (const beginState of nodesBeginState.values()) {\n\t\t// PlaceholderAttributes may be undefined in the case where the begin state node is position\n\t\t// fixed or absolute in a stack or grid.\n\t\tif (!beginState.placeholderAttributes) continue\n\t\tplaceholderItems.push({ index, attributes: beginState.placeholderAttributes })\n\t\tindex += 1\n\t}\n\n\treturn placeholderItems\n}\n\nfunction stackIndexAllowed(\n\tisHorizontal: boolean,\n\tindex: number,\n\tpreviousIndex: number,\n\tchildrenRects: Rect[],\n\tmouseDelta: Point,\n\thorizontalLayoutDirection: NonNullable<TextDirection>,\n\tstackWrapEnabled: boolean,\n): boolean {\n\tconst indexDelta = index - previousIndex\n\tif (indexDelta === 0) return true\n\n\tif (!stackWrapEnabled) {\n\t\t// Only change index if the index delta is in the same direction as\n\t\t// the mouse delta\n\t\tif (isHorizontal) {\n\t\t\tif (horizontalLayoutDirection === \"ltr\") {\n\t\t\t\treturn Math.sign(mouseDelta.x) === Math.sign(indexDelta)\n\t\t\t} else {\n\t\t\t\treturn Math.sign(mouseDelta.x) !== Math.sign(indexDelta)\n\t\t\t}\n\t\t} else {\n\t\t\treturn Math.sign(mouseDelta.y) === Math.sign(indexDelta)\n\t\t}\n\t}\n\n\tconst currentRect = childrenRects[previousIndex]\n\tconst targetRect = childrenRects[index]\n\n\tif (!currentRect || !targetRect) {\n\t\treturn true\n\t}\n\n\tconst lineSegment1 = isHorizontal\n\t\t? { a: currentRect.y, b: Rect.maxY(currentRect) }\n\t\t: { a: currentRect.x, b: Rect.maxX(currentRect) }\n\tconst lineSegment2 = isHorizontal\n\t\t? { a: targetRect.y, b: Rect.maxY(targetRect) }\n\t\t: { a: targetRect.x, b: Rect.maxX(targetRect) }\n\n\tconst isNextIndexOnSameRow = lineSegment1.b - lineSegment2.a >= 0 && lineSegment2.b - lineSegment1.a >= 0\n\n\tif (isNextIndexOnSameRow) {\n\t\treturn true\n\t}\n\n\t// 1 = next row is after current, -1 = is before current\n\tconst rowIndexSign = lineSegment2.a >= lineSegment1.b ? 1 : -1\n\n\tif (isHorizontal) {\n\t\treturn Math.sign(mouseDelta.y) === rowIndexSign\n\t} else {\n\t\treturn Math.sign(mouseDelta.x) === rowIndexSign\n\t}\n}\n\nfunction getSmallestDistanceIndexModifier(\n\ttargetIndex: number,\n\tstackOrGrid: StackComponentNode | GridComponentNode,\n): number {\n\t// Children rects don't include absolutely positioned children, since they\n\t// don't contribute to the size of the stack, and don't impact sorting.\n\t// However, this means that the \"smallest distance index\" based on children\n\t// rects will be a number less any siblings that come before the target\n\t// index that are absolutely positioned. This function adds the count of\n\t// those nodes back to the index.\n\tconst children = getOrderedChildren(stackOrGrid)\n\tlet modifier = 0\n\tfor (let i = 0; i <= targetIndex; i++) {\n\t\tconst child = children.at(i)\n\t\t// child can be undefined.\n\t\tif (child && !isPositionRelative(child, stackOrGrid)) modifier++\n\t}\n\n\treturn modifier\n}\n\nexport function getLiveSortingIndex(\n\ttree: CanvasTree,\n\tlayoutCache: LayoutCache,\n\tmouse: Point,\n\tpreviousMouse: Point,\n\tnodesBeginState: NodesBeginState,\n\tstackOrGrid: StackComponentNode | GridComponentNode,\n\tlocalPoint: Point,\n\tpreviousInsertionIndex: number | null | undefined,\n): number | null {\n\tlet rects = getChildrenRects(stackOrGrid, layoutCache)\n\tif (!rects) return 0\n\n\tconst repeatedItemNode = getRepeatedItemOfDataRepeater(tree, stackOrGrid)\n\n\tif (repeatedItemNode) {\n\t\trects = skipRepeaterItemRects(stackOrGrid, repeatedItemNode, rects)\n\t}\n\n\tconst distances = rects.map(rect => Point.distance(Rect.center(rect), localPoint))\n\tlet index = getSmallestDistanceIndex(distances)\n\tindex = index + getSmallestDistanceIndexModifier(index, stackOrGrid)\n\n\tlet actualIndex = index\n\n\tconst isGrid = hasGridLayout(stackOrGrid)\n\tconst isHorizontal = isGrid || stackOrGrid.stackDirection === \"horizontal\"\n\tconst stackWrapEnabled = isGrid || Boolean(stackOrGrid.stackWrapEnabled)\n\n\tconst mouseDelta = Point.subtract(mouse, previousMouse)\n\tconst hasMoved = previousInsertionIndex !== undefined\n\n\t// When the node is dragged outside of the container bounds, the index will\n\t// always be null\n\tconst hasMovedOutsideContainerBounds = previousInsertionIndex === null\n\n\tif (hasMoved && !hasMovedOutsideContainerBounds) {\n\t\t// We're moving within the node bounds\n\t\tconst previousIndex = previousInsertionIndex\n\t\tconst horizontalLayoutDirection = tree.root.getHorizontalLayoutDirection()\n\n\t\tconst shouldChangeIndex = stackIndexAllowed(\n\t\t\tisHorizontal,\n\t\t\tindex,\n\t\t\tpreviousIndex,\n\t\t\trects,\n\t\t\tmouseDelta,\n\t\t\thorizontalLayoutDirection,\n\t\t\tstackWrapEnabled,\n\t\t)\n\t\tactualIndex = shouldChangeIndex ? index : previousIndex\n\t} else if (hasMovedOutsideContainerBounds) {\n\t\t// We're moving from outside of the node in. If we're moving towards the\n\t\t// last child, we should be inserting a child at the very end, but since\n\t\t// that child doesn't exist, yet (we haven't inserted it at this point),\n\t\t// we have to use heuristics to decide whether we should insert _after_\n\t\t// the nearest index computed above, or stay at it. The following code\n\t\t// decides based on the direction of mouse movement: if we're moving\n\t\t// from outside of the node towards the last child, we assume we'll need\n\t\t// to insert. If not, we'll stay put.\n\t\tconst maxIndex = stackOrGrid.children.filter(child => child.isVisible()).length\n\t\tif ((isHorizontal && mouseDelta.x < 0) || (!isHorizontal && mouseDelta.y < 0)) {\n\t\t\tactualIndex = maxIndex\n\t\t}\n\t}\n\n\tstackOrGrid.cache.placeholders = getInsertionPlaceholderItems(nodesBeginState, actualIndex)\n\n\treturn actualIndex\n}\n\n// Updates\n\nfunction activeNodesAndSnapRects(\n\ttree: CanvasTree,\n\tnodesBeginState: NodesBeginState,\n\ttargetIds: TargetIds,\n\tcmdKey: boolean,\n) {\n\tconst extraSnapRects: Rect[] = []\n\tconst activeNodes = Array.from(nodesBeginState.keys())\n\n\tif (targetIds.size > 0) {\n\t\t// Add original nodes to snap rects\n\t\textraSnapRects.push(...activeNodes.map(node => convertFrameToCanvas(tree, node)))\n\t\tactiveNodes.length = 0\n\n\t\t// Add duplicated nodes to active nodes list\n\t\tfor (const [_, targetId] of targetIds) {\n\t\t\tconst node = tree.getNode(targetId)\n\t\t\tif (node) activeNodes.push(node)\n\t\t}\n\t}\n\n\tif (cmdKey) {\n\t\tconst childCanvasRects = getChildCanvasRects(nodesBeginState)\n\t\textraSnapRects.push(...childCanvasRects)\n\t}\n\n\treturn { activeNodes, extraSnapRects }\n}\n\nfunction getChildCanvasRects(nodesBeginState: NodesBeginState): Rect[] {\n\tconst childCanvasRects: Rect[] = []\n\tnodesBeginState.forEach(beginState => {\n\t\tbeginState.children.forEach(childState => {\n\t\t\tchildCanvasRects.push(childState.canvasFrame)\n\t\t})\n\t})\n\treturn childCanvasRects\n}\n\nfunction getOrderedChildren(node: CanvasNode) {\n\treturn withItemsOrder(node) ? node.getChildrenInVisualOrder() : getChildren(node)\n}\n\n// Start State\n\nfunction getChildBeginState(tree: CanvasTree, node: CanvasNode): Map<NodeID, ChildBeginState> {\n\tconst childBeginState = new Map<NodeID, ChildBeginState>()\n\n\tif (isVectorNode(node)) return childBeginState\n\tconst children = getOrderedChildren(node)\n\n\tconst movingStackOrGridNode = hasAnyLayout(node)\n\tfor (const child of children) {\n\t\tif (movingStackOrGridNode && !isPositionRelative(child, node)) continue\n\t\tconst childFrame = tree.getRect(child)\n\t\tconst childCanvasFrame = convertFrameToCanvas(tree, child)\n\t\tchildBeginState.set(child.id, {\n\t\t\tframe: childFrame,\n\t\t\tcanvasFrame: childCanvasFrame,\n\t\t})\n\t}\n\n\treturn childBeginState\n}\n\nfunction getStartSize(node: CanvasNode) {\n\tconst startSizeProps: Partial<Size & WithSizeDimensionType> = {}\n\tif (withSize(node)) {\n\t\tstartSizeProps.width = node.width\n\t\tstartSizeProps.height = node.height\n\t}\n\tif (isPinnable(node)) {\n\t\tstartSizeProps.widthType = node.widthType\n\t\tstartSizeProps.heightType = node.heightType\n\t}\n\treturn startSizeProps\n}\n\nfunction getNodesBeginState(\n\ttree: CanvasTree,\n\tcomponentLoader: ComponentLoader,\n\twithoutDescendants: CanvasNode[],\n\tmouse: Point,\n): NodesBeginState {\n\tconst sortedNodes = tree.sortVisually(withoutDescendants)\n\tconst nodesBeginState: NodesBeginState = new Map()\n\n\tsortedNodes.forEach(node => {\n\t\tconst beginState = getBeginState(tree, componentLoader, node, mouse)\n\t\tnodesBeginState.set(node, beginState)\n\t})\n\n\treturn nodesBeginState\n}\n\nfunction stabilizeDraggedRepeatedItems(tree: CanvasTree, nodesBeginState: NodesBeginState) {\n\tfor (const [node, beginState] of nodesBeginState) {\n\t\tif (!beginState.repeaterId) continue\n\n\t\tconst repeater = tree.get(beginState.repeaterId)\n\t\tif (!isDataRepeater(repeater)) continue\n\t\tif (repeater.repeatedItemId !== undefined) continue\n\n\t\trepeater.set(getRepeatedItemIdUpdate(node.id))\n\t}\n}\n\n/**\n * Get the matrix of the parent of the moved node, falling back to an identity\n * for convenience. We can always use the matrix provided because we are finding\n * a point in the parent's space. If we were trying to determine a point in the\n * moved node's space, we may have to convert this matrix to a flat projection\n * matrix.\n */\nfunction getMatrix(tree: CanvasTree, parent: CanvasNode | null): DOMMatrixReadOnly {\n\tif (parent) return tree.transformMatrixToNode(parent)\n\treturn Matrix.identity()\n}\n\nfunction getMatrixForDescendants(tree: CanvasTree, parent: CanvasNode | null): DOMMatrixReadOnly {\n\tif (parent) {\n\t\tconst matrix = tree.transformMatrixToNode(parent)\n\t\tif (creates3dContext(parent)) return matrix\n\t\treturn Matrix.flatProjectionMatrix(matrix)\n\t}\n\treturn Matrix.identity()\n}\n\nexport function getBeginState(\n\ttree: CanvasTree,\n\tcomponentLoader: ComponentLoader,\n\tnode: CanvasNode,\n\tmouse: Point,\n): MoveToolBeginState {\n\tconst parent = tree.getParent(node.id)\n\tconst startFromStackOrGrid = Boolean(parent && hasAnyLayout(parent))\n\tconst unableToMove =\n\t\t(startFromStackOrGrid && isReplicaChild(node) && !isReplicaVariantChild(node)) ||\n\t\tisSlotNode(node) ||\n\t\t!isSortableNode(node)\n\tconst rect = tree.getRect(node)\n\n\tlet placeholderAttributes: PlaceholderAttributes | undefined\n\n\tif (isPositionRelative(node, parent)) {\n\t\tplaceholderAttributes = {\n\t\t\twidth: rect.width,\n\t\t\theight: rect.height,\n\t\t}\n\t\tif (isGridComponent(parent)) {\n\t\t\tconst gridItemStyle: CSSProperties = {}\n\t\t\tconst context: CollectorContext = { componentLoader }\n\t\t\tcollectGridItemLayout(node, gridItemStyle, context)\n\t\t\tif (withGridItemSize(node)) {\n\t\t\t\tif (node.gridItemFillCellWidth) gridItemStyle.width = \"100%\"\n\t\t\t\tif (node.gridItemFillCellHeight && (experiments.isOn(\"gridBentoFit\") || parent.gridRowHeightType !== \"fit\")) {\n\t\t\t\t\tgridItemStyle.height = \"100%\"\n\t\t\t\t}\n\t\t\t}\n\t\t\tplaceholderAttributes.style = gridItemStyle\n\t\t}\n\t}\n\n\t// Determine the delta in untransformed space that would move the top right\n\t// point to the position where it would project through the matrix to the\n\t// mouse point. This is the untransformed point we want to stay under the\n\t// mouse, even as it moves due to perspective projection.\n\tconst untransformedPointUnderMouse = translateXYToPoint(getMatrix(tree, parent), { x: 0, y: 0 }, mouse)\n\n\tconst isRepeated = isRepeatedItem(tree, node)\n\tconst repeater = isRepeated ? getParentDataRepeater(tree, node) : undefined\n\tconst repeaterId = repeater && !isReplicaOrReplicaChild(repeater) ? repeater.id : undefined\n\n\tconst base = {\n\t\trect,\n\t\tmatrix: node.originAdjustedMatrix(null, rect),\n\t\tuntransformedPointUnderMouse,\n\t\t// Then project that point through the matrix to the canvas. This allows us\n\t\t// to compare it with the mouse point to determine a final delta.\n\t\tcanvasPointUnderMouse: parent\n\t\t\t? tree.convertPointToCanvas(parent, untransformedPointUnderMouse)\n\t\t\t: untransformedPointUnderMouse,\n\t\tchildren: getChildBeginState(tree, node),\n\t\tstartFromStackOrGrid,\n\t\tunableToMove,\n\t\tstartSizeProps: getStartSize(node),\n\t\tconstraintsLocked: isPinnable(node) ? node.constraintsLocked : false,\n\t\tplaceholderAttributes,\n\t\tdisableReparenting: hasFloatingPosition(node),\n\t\trepeaterId,\n\t}\n\n\tif (!parent) return { ...base, parent: null, index: undefined }\n\n\tconst children = getOrderedChildren(parent)\n\tconst index = children.indexOf(node)\n\n\treturn { ...base, parent, index: index === -1 ? 0 : index }\n}\n\nfunction isVectorInGroup(node: CanvasNode, tree: CanvasTree) {\n\tif (!isVectorNode(node)) return false\n\tconst parent = tree.getParent(node.id)\n\treturn isShapeGroupNode(parent) || isBooleanShapeNode(parent)\n}\n\nfunction shouldKeepCurrentConstraints(beginState: MoveToolBeginState, sameParentAsStart: boolean) {\n\treturn sameParentAsStart ? beginState.constraintsLocked : false\n}\n\nfunction verifyHomeNodePostMove(engine: VekterEngine, nodesBeginState: NodesBeginState, targetIds: TargetIds) {\n\tnodesBeginState.forEach((_, selectedNode: CanvasNode) => {\n\t\tconst node = engine.tree.getNode(targetIds.get(selectedNode) ?? selectedNode.id) || selectedNode\n\t\tconst activeScope = engine.stores.scopeStore.active\n\n\t\tif (isCanvasPageNode(activeScope) && isHomeNode(engine.tree, activeScope, node)) {\n\t\t\tverifyHomeNodePostProcess(engine.tree, activeScope)\n\t\t}\n\t})\n}\n\nfunction handleDuplicationMetrics(targetIds: TargetIds, tree: CanvasTree) {\n\tconst isDuplicating = targetIds.size > 0\n\tif (!isDuplicating) return\n\n\tlet duplicationFrameCount = 0\n\n\tfor (const duplicatedNodeId of targetIds.values()) {\n\t\tconst duplicatedNodeRoot = tree.getNode(duplicatedNodeId)\n\t\tif (!duplicatedNodeRoot) continue\n\t\tfor (const n of duplicatedNodeRoot.walk()) {\n\t\t\tif (isFrameNode(n)) {\n\t\t\t\tduplicationFrameCount++\n\t\t\t}\n\t\t}\n\t}\n\tif (duplicationFrameCount > 0) {\n\t\trecord(\"layout_frame\", { source: \"duplication\", count: duplicationFrameCount })\n\t}\n}\n\n// Check if the nodes we have inserted have been inserted into an overlay. If\n// they have cleanup any overlay descendants of our inserted nodes, removing\n// their show overlay action as well.\nfunction verifyOverlaysPostMove(engine: VekterEngine, nodesBeginState: NodesBeginState, targetIds: TargetIds) {\n\tnodesBeginState.forEach((_, selectedNode: CanvasNode) => {\n\t\tconst node = engine.tree.getNode(targetIds.get(selectedNode) ?? selectedNode.id) || selectedNode\n\t\tconst parent = engine.tree.getParent(node.id)\n\t\tif (!parent) return\n\n\t\tif (nodeIsInOverlay(parent) || nodeIsInOverlay(node) || isOverlayNode(parent)) {\n\t\t\tfor (const { node: n, skipChildren } of node.walkWithSkipChildren()) {\n\t\t\t\tif (isOverlayNode(n)) {\n\t\t\t\t\tengine.stores.overlayStore.cleanupOverlay(engine.stores.selectionStore, n.id, n.parentid, false)\n\t\t\t\t\tengine.tree.removeNode(n)\n\t\t\t\t\tskipChildren()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t})\n}\n\nfunction skipRepeaterItemRects(\n\tnode: StackComponentNode | GridComponentNode,\n\trepeatedItemNode: CanvasNode,\n\trects: Rect[],\n): Rect[] {\n\tif (rects.length === 0) return rects\n\n\tconst repeatedItemIndex = node.children.findIndex(child => child.id === repeatedItemNode.id)\n\tassert(repeatedItemIndex >= 0, \"Must have repeated item node as child\")\n\n\tconst repeatedItemCount = rects.length - node.children.length + 1\n\n\tconst rect = rects[repeatedItemIndex]\n\tassert(rect, \"Must have a rect\")\n\n\treturn [...rects.slice(0, repeatedItemIndex), rect, ...rects.slice(repeatedItemIndex + repeatedItemCount)]\n}\n", "import { LazyValue } from \"library/modules/LazyValue.ts\"\n\nexport type ProseMirror = typeof import(\"prosemirror-commands\") &\n\ttypeof import(\"prosemirror-dropcursor\") &\n\ttypeof import(\"prosemirror-gapcursor\") &\n\ttypeof import(\"prosemirror-history\") &\n\ttypeof import(\"prosemirror-inputrules\") &\n\ttypeof import(\"prosemirror-keymap\") &\n\ttypeof import(\"prosemirror-view\") &\n\ttypeof import(\"prosemirror-schema-list\") &\n\ttypeof import(\"prosemirror-suggest\")\n\nconst proseMirror = new LazyValue(async () => {\n\tconst modules = await Promise.all([\n\t\timport(\"prosemirror-commands\"),\n\t\timport(\"prosemirror-dropcursor\"),\n\t\timport(\"prosemirror-gapcursor\"),\n\t\timport(\"prosemirror-history\"),\n\t\timport(\"prosemirror-inputrules\"),\n\t\timport(\"prosemirror-keymap\"),\n\t\timport(\"prosemirror-view\"),\n\t\timport(\"prosemirror-schema-list\"),\n\t\timport(\"prosemirror-suggest\"),\n\t])\n\n\treturn Object.assign({}, ...modules) as ProseMirror\n})\n\nexport function preloadProseMirror() {\n\tvoid proseMirror.preload()\n}\n\nexport async function importProseMirror() {\n\treturn proseMirror.readMaybeAsync()\n}\n\nexport function useImportProseMirror(): ProseMirror {\n\treturn proseMirror.use()\n}\n", "import { ApiError, ProjectLicenseType } from \"@framerjs/app-shared\"\nimport { assertNever, getLogger, unhandledError } from \"@framerjs/shared\"\nimport { experimentIsOnOrForceEnabled } from \"app/experiments.ts\"\nimport { EngineStore } from \"document/EngineStore.ts\"\nimport type { CanvasTree } from \"document/models/CanvasTree/CanvasTree.ts\"\nimport type { NodeChangesReader } from \"document/models/CanvasTree/TreeUpdater.ts\"\nimport type { NodeID } from \"document/models/CanvasTree/index.ts\"\nimport type { FormContainerConfigSource } from \"document/models/CanvasTree/nodes/CanvasNodeCache.ts\"\nimport { ERROR_LIST_NODE_ID, ErrorListNode } from \"document/models/CanvasTree/nodes/ErrorListNode.ts\"\nimport { ErrorNode, ErrorNodeType } from \"document/models/CanvasTree/nodes/ErrorNode.ts\"\nimport { randomID } from \"document/models/CanvasTree/nodes/NodeID.ts\"\nimport { isCanvasPageNode } from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { isFormContainer, withFormContainer } from \"document/models/CanvasTree/traits/forms/WithFormContainer.ts\"\nimport {\n\ttype FormConfig,\n\ttype FormConfigAntispam,\n\ttype FormConfigAntispamConfig,\n\ttype FormConfigAntispamError,\n\ttype FormConfigAntispamResponse,\n\ttype FormConfigDestination,\n\ttype ServerFormConfigDestination,\n\ttype AntispamFiltering,\n\ttype SpamProtectionMode,\n\tcreateAntispam,\n\tgetAvailableAntispamProviders,\n\tisCaptchaAntispam,\n\tisFormConfigVerifiedEmailDestination,\n\tnormalizeAntispamConfigsForSpamProtectionAdvanced,\n} from \"document/models/CanvasTree/traits/forms/formConfig.ts\"\nimport { ModalType } from \"document/utils/ModalType.ts\"\nimport { addBeforeUnloadHandler } from \"document/utils/beforeUnloadHandler.ts\"\nimport { environment } from \"environment/index.ts\"\nimport { isArray, isObject, isString } from \"utils/typeChecks.ts\"\nimport { apiFetcher } from \"web/lib/apiFetcher.ts\"\nimport { toast } from \"web/lib/toaster.ts\"\nimport type { ChromeStore } from \"./ChromeStore.ts\"\nimport type { ModalStore } from \"./ModalStore.ts\"\nimport type { ProjectStore } from \"./ProjectStore.ts\"\nimport type { TreeStore } from \"./TreeStore.ts\"\nimport { parseFormErrorReason } from \"./formErrorReason.ts\"\n\nconst log = getLogger(\"FormsStore\")\n\ntype SaveId = string\ntype TemporarySaveIdToken = string\n\nconst EMAIL_RECIPIENTS_ERROR_REASON = \"too_many_email_recipients\"\nconst EMAIL_RECIPIENTS_TOAST_KEY = \"email_recipients_toast\"\n\nfunction isEmailRecipientsError(error: string): boolean {\n\treturn parseFormErrorReason(error).reason === EMAIL_RECIPIENTS_ERROR_REASON\n}\n\nfunction getAntispamForRequest(\n\tantispam: FormConfigAntispam,\n\tcanUseSpamProtectionAdvanced: boolean,\n): FormConfigAntispam {\n\tif (!experimentIsOnOrForceEnabled(\"formAntispam\")) return createAntispam()\n\n\treturn createAntispam(\n\t\tnormalizeAntispamConfigsForSpamProtectionAdvanced(\n\t\t\tantispam.configs,\n\t\t\tgetAvailableAntispamProviders({\n\t\t\t\tformAntispamEnabled: true,\n\t\t\t\trecaptchaEnabled: experimentIsOnOrForceEnabled(\"formRecaptchaV3\"),\n\t\t\t}),\n\t\t\tcanUseSpamProtectionAdvanced,\n\t\t),\n\t)\n}\n\nfunction isFormConfigResponse(response: unknown): response is {\n\tconfig: {\n\t\tid: string\n\t\tdestinations: FormConfigDestination[]\n\t\tantispam?: FormConfigAntispamResponse\n\t}\n} {\n\tif (!response) return false\n\tif (!isObject(response)) return false\n\tif (!(\"config\" in response)) return false\n\tif (!isObject(response.config)) return false\n\tif (!(\"id\" in response.config)) return false\n\tif (!isString(response.config.id)) return false\n\tif (!(\"destinations\" in response.config)) return false\n\tif (!isArray(response.config.destinations)) return false\n\tif (!response.config.destinations.every(isFormConfigDestination)) return false\n\tif (\"antispam\" in response.config && response.config.antispam !== undefined) {\n\t\tif (!isFormConfigAntispamResponse(response.config.antispam)) return false\n\t}\n\n\treturn true\n}\n\nfunction isFormConfigDestination(destination: unknown): destination is FormConfigDestination {\n\tif (!isObject(destination)) return false\n\tif (!(\"type\" in destination)) return false\n\tif (!isString(destination.type)) return false\n\tif (!(\"id\" in destination)) return false\n\tif (!isString(destination.id)) return false\n\n\treturn true\n}\n\nfunction isSpamProtectionMode(mode: unknown): mode is SpamProtectionMode {\n\treturn mode === \"disabled\" || mode === \"basic\" || mode === \"advanced\"\n}\n\nfunction isAntispamFiltering(filtering: unknown): filtering is AntispamFiltering {\n\treturn filtering === \"block\" || filtering === \"pass\"\n}\n\nfunction isFormConfigAntispamConfig(antispam: unknown): antispam is FormConfigAntispamConfig {\n\tif (!isObject(antispam)) return false\n\tif (!(\"provider\" in antispam)) return false\n\tif (!isString(antispam.provider)) return false\n\tif (!(\"filtering\" in antispam)) return false\n\tif (!isAntispamFiltering(antispam.filtering)) return false\n\n\tswitch (antispam.provider) {\n\t\tcase \"spam_protection\":\n\t\t\treturn \"mode\" in antispam && isSpamProtectionMode(antispam.mode)\n\t\tcase \"recaptcha_v3\":\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nfunction stringOrUndefined(value: unknown): string | undefined {\n\tif (isString(value)) return value\n\treturn undefined\n}\n\nfunction parseServerDestination(destination: ServerFormConfigDestination): FormConfigDestination {\n\tswitch (destination.type) {\n\t\tcase \"email\":\n\t\t\treturn {\n\t\t\t\ttype: \"verifiedEmail\",\n\t\t\t\tid: destination.id,\n\t\t\t\temails: destination.emails?.split(\",\").map(email => ({ email: email.trim(), verified: true })),\n\t\t\t\tsubject: stringOrUndefined(destination.subject),\n\t\t\t\tbody: stringOrUndefined(destination.body),\n\t\t\t\tname: stringOrUndefined(destination.name),\n\t\t\t}\n\t\tcase \"verifiedEmail\":\n\t\t\treturn {\n\t\t\t\ttype: \"verifiedEmail\",\n\t\t\t\tid: destination.id,\n\t\t\t\temails: destination.emails,\n\t\t\t\tsubject: stringOrUndefined(destination.subject),\n\t\t\t\tbody: stringOrUndefined(destination.body),\n\t\t\t\tname: stringOrUndefined(destination.name),\n\t\t\t}\n\t\tcase \"webhook\":\n\t\t\treturn {\n\t\t\t\ttype: \"webhook\",\n\t\t\t\tid: destination.id,\n\t\t\t\twebhookUrl: stringOrUndefined(destination.webhookUrl),\n\t\t\t\tsecret: stringOrUndefined(destination.secret),\n\t\t\t\tfallbackEmail: stringOrUndefined(destination.fallbackEmail),\n\t\t\t}\n\t\tcase \"googlesheet\":\n\t\t\treturn {\n\t\t\t\ttype: \"googlesheet\",\n\t\t\t\tid: destination.id,\n\t\t\t\tdocumentName: stringOrUndefined(destination.documentName),\n\t\t\t\tdocumentId: stringOrUndefined(destination.documentId),\n\t\t\t\tfallbackEmail: stringOrUndefined(destination.fallbackEmail),\n\t\t\t}\n\t\tdefault:\n\t\t\tassertNever(destination)\n\t}\n}\n\ninterface FormConfigErrorDetail {\n\treadonly data?: string\n\treadonly reason: string\n}\n\ninterface FormConfigPersistRequest {\n\tprojectId: string\n\tdestinations: readonly FormConfigDestination[]\n\tantispam: FormConfigAntispam\n\tid: NodeID\n}\n\ntype FormConfigAntispamConfigResponse = FormConfigAntispamConfig & {\n\terror?: FormConfigAntispamError\n}\n\nfunction isFormConfigAntispamError(error: unknown): error is FormConfigAntispamError {\n\tif (!isObject(error)) return false\n\tif (!(\"reason\" in error)) return false\n\tif (!isString(error.reason)) return false\n\tif (\"data\" in error && error.data !== undefined && !isString(error.data)) return false\n\treturn true\n}\n\nfunction isFormConfigAntispamResponse(antispam: unknown): antispam is FormConfigAntispamResponse {\n\tif (!isObject(antispam)) return false\n\tif (!(\"configs\" in antispam)) return false\n\tif (!isArray(antispam.configs)) return false\n\tif (!antispam.configs.every(isFormConfigAntispamConfig)) return false\n\tif (\"errors\" in antispam && antispam.errors !== undefined) {\n\t\tif (!isArray(antispam.errors)) return false\n\t\tif (!antispam.errors.every(isFormConfigAntispamError)) return false\n\t}\n\treturn true\n}\n\nfunction parseFormConfigDestinations(\n\tserverDestinations: readonly (FormConfigDestination & { errors?: readonly FormConfigErrorDetail[] })[],\n) {\n\tconst errors: string[] = []\n\tconst destinations: FormConfigDestination[] = []\n\n\tfor (const serverDestination of serverDestinations) {\n\t\tconst destination = parseServerDestination(serverDestination)\n\t\tdestinations.push(destination)\n\t\t// Push the error reason to a list of errors. Currently we are not using\n\t\t// this message in the UI, only saying there is some destination issue,\n\t\t// but it may be helpful for engineers to debug or we may want to use it\n\t\t// in future.\n\t\tif (serverDestination.errors) {\n\t\t\terrors.push(...serverDestination.errors.map(e => `${destination.type}: ${e.reason}`))\n\t\t}\n\t}\n\n\treturn { destinations, errors }\n}\n\nfunction parseFormConfigAntispamConfig(serverAntispam: FormConfigAntispamConfigResponse): {\n\tantispamConfig: FormConfigAntispamConfig\n\terror?: string\n} {\n\tconst { provider, error } = serverAntispam\n\tconst errorString = error ? `${provider}: ${error.reason}` : undefined\n\n\tconst filtering =\n\t\t\"filtering\" in serverAntispam && isAntispamFiltering(serverAntispam.filtering) ? serverAntispam.filtering : \"pass\"\n\n\tconst secretKey =\n\t\t\"secretKey\" in serverAntispam && isString(serverAntispam.secretKey)\n\t\t\t? serverAntispam.secretKey\n\t\t\t: \"secret\" in serverAntispam && isString(serverAntispam.secret)\n\t\t\t\t? serverAntispam.secret\n\t\t\t\t: \"\"\n\n\tswitch (provider) {\n\t\tcase \"spam_protection\":\n\t\t\treturn {\n\t\t\t\tantispamConfig: {\n\t\t\t\t\tprovider: \"spam_protection\",\n\t\t\t\t\tmode: \"mode\" in serverAntispam && isSpamProtectionMode(serverAntispam.mode) ? serverAntispam.mode : \"basic\",\n\t\t\t\t\tfiltering,\n\t\t\t\t},\n\t\t\t\terror: errorString,\n\t\t\t}\n\t\tcase \"recaptcha_v3\":\n\t\t\treturn {\n\t\t\t\tantispamConfig: {\n\t\t\t\t\tprovider: \"recaptcha_v3\",\n\t\t\t\t\tsiteKey: \"siteKey\" in serverAntispam && isString(serverAntispam.siteKey) ? serverAntispam.siteKey : \"\",\n\t\t\t\t\tsecretKey,\n\t\t\t\t\tthreshold:\n\t\t\t\t\t\t\"threshold\" in serverAntispam && typeof serverAntispam.threshold === \"number\"\n\t\t\t\t\t\t\t? serverAntispam.threshold\n\t\t\t\t\t\t\t: 0.5,\n\t\t\t\t\tfiltering,\n\t\t\t\t},\n\t\t\t\terror: errorString,\n\t\t\t}\n\t\tdefault:\n\t\t\tassertNever(provider)\n\t}\n}\n\nfunction parseFormConfigAntispamConfigs(serverAntispam: readonly FormConfigAntispamConfigResponse[]) {\n\tconst errors: string[] = []\n\tconst antispamConfigs: FormConfigAntispamConfig[] = []\n\n\tfor (const item of serverAntispam) {\n\t\tconst { antispamConfig, error } = parseFormConfigAntispamConfig(item)\n\t\tantispamConfigs.push(antispamConfig)\n\t\tif (error) errors.push(error)\n\t}\n\n\treturn { antispamConfigs, errors }\n}\n\nfunction formatAntispamPayloadError(error: FormConfigAntispamError): string {\n\treturn `antispam: ${error.reason}`\n}\n\nfunction parseFormConfigAntispamResponse(antispam: unknown): {\n\treadonly antispam: FormConfigAntispam\n\treadonly errors: readonly string[]\n} {\n\tif (isFormConfigAntispamResponse(antispam)) {\n\t\treturn {\n\t\t\tantispam: createAntispam(antispam.configs),\n\t\t\terrors: antispam.errors?.map(formatAntispamPayloadError) ?? [],\n\t\t}\n\t}\n\n\treturn { antispam: createAntispam(), errors: [] }\n}\n\ninterface FormConfigWithSaveId extends Pick<FormConfig, \"destinations\" | \"antispam\"> {\n\tsaveId: SaveId | undefined\n}\n\nexport class FormsStore extends EngineStore {\n\t#nodeChangesReader: NodeChangesReader\n\n\t#pendingUpdates = new Map<string, FormConfigPersistRequest>()\n\n\t/** Track nodes for which we've already prompted, to avoid showing multiple modals. */\n\t#shownTooManyRecipientsPrompt = new Set<NodeID>()\n\n\tconstructor(\n\t\tprivate readonly treeStore: TreeStore,\n\t\tprivate readonly chromeStore: ChromeStore,\n\t\tprivate readonly modalStore: ModalStore,\n\t\tprivate readonly projectStore: ProjectStore,\n\t\tabortSignal?: AbortSignal,\n\t) {\n\t\tsuper()\n\n\t\tthis.#nodeChangesReader = this.treeStore.timeline.openNodeChangesReader()\n\n\t\taddBeforeUnloadHandler(\n\t\t\t{\n\t\t\t\tcheck: () => {\n\t\t\t\t\tif (environment.isTest) return false\n\t\t\t\t\t// If user is a viewer, there cannot be local changes that require\n\t\t\t\t\t// persistence, so return early and don't block closing the tab.\n\t\t\t\t\tif (this.chromeStore.userIsViewer) return false\n\t\t\t\t\treturn this.#pendingUpdates.size > 0\n\t\t\t\t},\n\t\t\t\teffect: () => {\n\t\t\t\t\tlog.debug(\"Showing pending form updates: \", this.#pendingUpdates.size)\n\t\t\t\t\tfor (const [_tokenId, formConfig] of this.#pendingUpdates) {\n\t\t\t\t\t\tlog.debug(formConfig)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t\tabortSignal,\n\t\t)\n\t}\n\n\t#formConfigs = new Map<SaveId | TemporarySaveIdToken, FormConfigWithSaveId>()\n\t#nodeIdSaveIdOverrides = new Map<NodeID, TemporarySaveIdToken>()\n\n\t/**\n\t * For rendering. Will be bumped when we want to render.\n\t */\n\tformConfigsVersion: number = 0\n\n\t/**\n\t * Record a configuration to memory. Maintaining max 50 (arbitrary)\n\t * configurations.\n\t */\n\tprivate setConfig(\n\t\toriginalId: NodeID,\n\t\tsaveId: SaveId | TemporarySaveIdToken,\n\t\tconfig: FormConfigWithSaveId,\n\t\ttoken?: TemporarySaveIdToken,\n\t) {\n\t\tthis.#formConfigs.set(saveId, config)\n\t\tif (token) this.#formConfigs.delete(token)\n\n\t\t// If there is an in-memory override for this save, we need to\n\t\t// remove it. If there is no override, or it's already been changed\n\t\t// to a new token, we don't need to do anything.\n\t\tconst existingOverrideId = this.#nodeIdSaveIdOverrides.get(originalId)\n\t\tif (existingOverrideId === token) this.#nodeIdSaveIdOverrides.delete(originalId)\n\n\t\t// trim the in-memory configs if it's getting too big\n\t\tif (this.#formConfigs.size > 50) {\n\t\t\tconst oldestKey = [...this.#formConfigs.keys()].pop()\n\t\t\tif (oldestKey) this.#formConfigs.delete(oldestKey)\n\t\t}\n\t}\n\n\tgetLocalFormConfig(originalId: NodeID, saveId: SaveId | undefined): FormConfigWithSaveId | undefined {\n\t\tconst id = this.#nodeIdSaveIdOverrides.get(originalId) ?? saveId\n\t\tif (id) return this.#formConfigs.get(id)\n\t}\n\n\t/**\n\t * Re-fetch all cached form configs from the server, bypassing the\n\t * in-memory cache. Used when the backend notifies us that form config\n\t * data has changed (e.g. an email verification status update).\n\t */\n\tasync refreshAllFormConfigs(): Promise<void> {\n\t\tconst formNodes: { nodeId: NodeID; saveId: SaveId }[] = []\n\t\tfor (const nodeId of this.treeStore.treeIndex.formContainerNodeIds) {\n\t\t\tconst node = this.treeStore.tree.get(nodeId)\n\t\t\tif (node && isFormContainer(node) && node.formSaveId) {\n\t\t\t\tformNodes.push({ nodeId: node.id, saveId: node.formSaveId })\n\t\t\t}\n\t\t}\n\n\t\tconst results = await Promise.allSettled(\n\t\t\tformNodes.map(async ({ nodeId, saveId }) => {\n\t\t\t\tconst result = await this.fetchFormConfigForNodeSaveId(nodeId, saveId)\n\t\t\t\treturn result ? { nodeId, saveId, result } : undefined\n\t\t\t}),\n\t\t)\n\n\t\tlet didUpdate = false\n\t\tconst errorUpdates: { nodeId: NodeID; errors: string[]; destinations: readonly FormConfigDestination[] }[] = []\n\t\tfor (const entry of results) {\n\t\t\tif (entry.status !== \"fulfilled\" || !entry.value) continue\n\t\t\tconst { nodeId, saveId, result } = entry.value\n\t\t\tthis.#formConfigs.set(saveId, result)\n\t\t\terrorUpdates.push({ nodeId, errors: result.errors, destinations: result.destinations })\n\t\t\tdidUpdate = true\n\t\t}\n\n\t\tif (errorUpdates.length > 0) {\n\t\t\tthis.scheduler.processWhenReady(() => {\n\t\t\t\tfor (const { nodeId, errors } of errorUpdates) {\n\t\t\t\t\tthis.persistFormErrors(nodeId, errors)\n\t\t\t\t}\n\t\t\t\t// Show at most one modal at a time, for the first form with too many recipients.\n\t\t\t\tfor (const { nodeId, destinations } of errorUpdates) {\n\t\t\t\t\tif (this.shouldPromptTruncateRecipients(destinations)) {\n\t\t\t\t\t\tthis.promptTruncateToFirstRecipient(nodeId, destinations)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\n\t\tif (didUpdate) this.render()\n\t}\n\n\t/**\n\t * Update the local form configuration in the store for a specific node and\n\t * saveId. If the config is already in memory, we don't make a network\n\t * request or trigger a render.\n\t */\n\tasync requestLatestFormConfig(originalId: NodeID, saveId: SaveId | undefined): Promise<void> {\n\t\tconst config = this.getLocalFormConfig(originalId, saveId)\n\t\tif (config) return\n\n\t\tconst latestNode = this.treeStore.tree.get(originalId)\n\n\t\tif (!isFormContainer(latestNode)) return\n\t\tif (!latestNode.formSaveId) return\n\n\t\tconst result = await this.fetchFormConfigForNodeSaveId(originalId, latestNode.formSaveId)\n\t\tif (!result) return\n\n\t\tthis.setConfig(latestNode.id, latestNode.formSaveId, result)\n\n\t\tthis.scheduler.processWhenReady(() => {\n\t\t\tthis.persistFormErrors(originalId, result.errors)\n\t\t\tif (this.shouldPromptTruncateRecipients(result.destinations)) {\n\t\t\t\tthis.promptTruncateToFirstRecipient(originalId, result.destinations)\n\t\t\t}\n\t\t})\n\n\t\tthis.render()\n\t}\n\n\tprivate async persistFormConfig(\n\t\toriginalId: NodeID,\n\t\tprojectId: string,\n\t\t{ destinations, antispam }: FormConfigWithSaveId,\n\t) {\n\t\tconst canUseSpamProtectionAdvanced = this.projectStore.featureFlags?.canUseSpamProtectionAdvanced === \"on\"\n\t\tconst antispamForRequest = getAntispamForRequest(antispam, canUseSpamProtectionAdvanced)\n\t\tconst config = { projectId, destinations, antispam: antispamForRequest, id: originalId }\n\n\t\tconst token = randomID()\n\t\tthis.#pendingUpdates.set(token, config)\n\t\tlog.debug(\"Form config pending update: \", token, config)\n\n\t\ttry {\n\t\t\tconst requestBody = {\n\t\t\t\tprojectId,\n\t\t\t\tdestinations: destinations.map(serializeDestinationForServer),\n\t\t\t\tantispam: antispamForRequest,\n\t\t\t\tid: originalId,\n\t\t\t}\n\n\t\t\tconst response = await apiFetcher.putRaw(`/forms/forms/${projectId}/${originalId}`, JSON.stringify(requestBody))\n\n\t\t\tconst body = await response.json()\n\n\t\t\tif (!isFormConfigResponse(body)) {\n\t\t\t\tthis.#pendingUpdates.delete(token)\n\t\t\t\treturn {\n\t\t\t\t\tsaveId: undefined,\n\t\t\t\t\tdestinations,\n\t\t\t\t\tantispam: antispamForRequest,\n\t\t\t\t\terrors: [],\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst { destinations: serverDestinations, errors: destinationErrors } = parseFormConfigDestinations(\n\t\t\t\tbody.config.destinations,\n\t\t\t)\n\t\t\tconst { antispam: serverAntispam, errors: antispamErrors } = parseFormConfigAntispamResponse(body.config.antispam)\n\t\t\tconst { antispamConfigs, errors: antispamItemErrors } = parseFormConfigAntispamConfigs(serverAntispam.configs)\n\n\t\t\treturn {\n\t\t\t\ttoken,\n\t\t\t\tsaveId: body.config.id,\n\t\t\t\tdestinations: serverDestinations,\n\t\t\t\tantispam: createAntispam(antispamConfigs),\n\t\t\t\terrors: [...destinationErrors, ...antispamErrors, ...antispamItemErrors],\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthis.#pendingUpdates.delete(token)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tprivate async fetchFormConfigForNodeSaveId(\n\t\toriginalId: NodeID,\n\t\tsaveId: SaveId,\n\t\tprojectId: string | undefined = this.projectStore.projectId,\n\t): Promise<(FormConfigWithSaveId & { errors: string[] }) | undefined> {\n\t\tif (!projectId) return\n\n\t\ttry {\n\t\t\tconst response = await apiFetcher.getRaw(`/forms/forms/${projectId}/${originalId}/configs/${saveId}`)\n\t\t\tconst body = await response.json()\n\t\t\tif (!isFormConfigResponse(body)) return\n\t\t\tconst { destinations, errors: destinationErrors } = parseFormConfigDestinations(body.config.destinations)\n\t\t\tconst serverAntispamResponse = parseFormConfigAntispamResponse(body.config.antispam)\n\t\t\tconst { antispamConfigs, errors: antispamItemErrors } = parseFormConfigAntispamConfigs(\n\t\t\t\tserverAntispamResponse.antispam.configs,\n\t\t\t)\n\t\t\treturn {\n\t\t\t\tdestinations,\n\t\t\t\tsaveId,\n\t\t\t\terrors: [...destinationErrors, ...serverAntispamResponse.errors, ...antispamItemErrors],\n\t\t\t\tantispam: createAntispam(antispamConfigs),\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (error instanceof ApiError && error.isForbidden()) {\n\t\t\t\t// A 403 means forms are not available on the current plan.\n\t\t\t\t// We return an empty config so the form panel can degrade gracefully.\n\t\t\t\treturn { destinations: [], saveId, errors: [], antispam: createAntispam() }\n\t\t\t}\n\n\t\t\tif (error instanceof ApiError && error.status === 404) {\n\t\t\t\t// If the form config does not exist (because the project was\n\t\t\t\t// duplicated for example), we return an empty config so that users\n\t\t\t\t// can still edit the form (as opposed to seeing the spinner).\n\t\t\t\treturn { destinations: [], saveId, errors: [], antispam: createAntispam() }\n\t\t\t}\n\n\t\t\t// @TODO - Handle other errors with a visual state. Right now the\n\t\t\t// panel will just show a spinner indefinitely.\n\t\t\tunhandledError(error)\n\t\t\treturn\n\t\t}\n\t}\n\n\t/**\n\t * Returns true when the user is on a free plan and a verified-email destination has more\n\t * than one recipient address \u2014 the condition under which we need to prompt for truncation.\n\t */\n\tprivate shouldPromptTruncateRecipients(destinations: readonly FormConfigDestination[]): boolean {\n\t\tif (this.projectStore.projectLicenseType !== ProjectLicenseType.FreeSite) return false\n\t\treturn destinations.some(d => isFormConfigVerifiedEmailDestination(d) && (d.emails?.length ?? 0) > 1)\n\t}\n\n\t/**\n\t * When a form config GET response returns multiple email recipients for a free-plan user,\n\t * prompt the user to confirm that we'll truncate to just the first address and send the\n\t * update back to the server. Only shows once per node to avoid repeated interruptions.\n\t */\n\tprivate promptTruncateToFirstRecipient(originalId: NodeID, destinations: readonly FormConfigDestination[]) {\n\t\tif (this.#shownTooManyRecipientsPrompt.has(originalId)) return\n\t\tthis.#shownTooManyRecipientsPrompt.add(originalId)\n\n\t\tconst emailDestination = destinations.find(isFormConfigVerifiedEmailDestination)\n\t\tconst firstEmail = emailDestination?.emails?.[0]\n\t\tif (!emailDestination || !firstEmail) return\n\n\t\tconst truncatedDestinations = destinations.map(d =>\n\t\t\tisFormConfigVerifiedEmailDestination(d) && d.id === emailDestination.id ? { ...d, emails: [firstEmail] } : d,\n\t\t)\n\n\t\t// TODO: revisit whether we need a custom modal without the cancel button.\n\t\t// Or, we can repeatedly show this modal and not use #shownTooManyRecipientsPrompt\n\t\tthis.modalStore.push({\n\t\t\ttype: ModalType.Confirmation,\n\t\t\ttitle: \"Too many email recipients\",\n\t\t\tdescription: `This form has multiple email recipients, but your plan only allows one. We\u2019ll use \"${firstEmail.email}\" as the only recipient. You can update this in the form settings.`,\n\t\t\tconfirmLabel: \"Confirm\",\n\t\t\tsource: \"automatic\",\n\t\t\thasBackdrop: true,\n\t\t\tonConfirm: async () => {\n\t\t\t\tvoid this.updateFormConfig(this.treeStore.tree, originalId, { destinations: truncatedDestinations }).catch(\n\t\t\t\t\tunhandledError,\n\t\t\t\t)\n\t\t\t},\n\t\t})\n\t}\n\n\tprivate render() {\n\t\tthis.formConfigsVersion++\n\t}\n\n\t/**\n\t * Update the in-memory form config for a node, persisting it to the server, and recording the\n\t * promise that will result in an updated save id.\n\t *\n\t * When {@link scheduleWithChangeset} is set (e.g. during an agent stream), the post-persist\n\t * tree mutation runs through it instead of {@link BaseEngineScheduler.processWhenReadyAsync},\n\t * so it stays on the turn changeset.\n\t */\n\tasync updateFormConfig(\n\t\ttree: CanvasTree,\n\t\toriginalId: NodeID,\n\t\tupdate: Partial<Pick<FormConfig, \"destinations\" | \"antispam\">>,\n\t\tscheduleWithChangeset?: (task: () => void) => Promise<void>,\n\t) {\n\t\tconst node = tree.get(originalId)\n\t\tif (!node || node.originalid || !isFormContainer(node)) return\n\n\t\tconst existingConfig = this.getLocalFormConfig(originalId, node.formSaveId)\n\t\tconst config: FormConfigWithSaveId = {\n\t\t\tdestinations: update.destinations ?? existingConfig?.destinations ?? [],\n\t\t\tantispam: update.antispam ?? existingConfig?.antispam ?? createAntispam(),\n\t\t\tsaveId: node.formSaveId,\n\t\t}\n\n\t\tconst temporarySaveIdToken = this.setTemporaryConfig(originalId, config)\n\n\t\t// Persist the form config to the server.\n\t\tconst projectId = this.projectStore.projectId\n\n\t\ttry {\n\t\t\tconst { token, saveId, destinations, antispam, errors } = await this.persistFormConfig(\n\t\t\t\toriginalId,\n\t\t\t\tprojectId,\n\t\t\t\tconfig,\n\t\t\t)\n\t\t\tif (!saveId) return\n\n\t\t\tconst processAsync = scheduleWithChangeset ?? (task => this.scheduler.processWhenReadyAsync(task))\n\n\t\t\t// Trigger a rerender with the latest destinations.\n\t\t\tawait processAsync(() => {\n\t\t\t\tconst latestNode = this.treeStore.tree.get(originalId)\n\t\t\t\tif (!latestNode || !isFormContainer(latestNode)) return\n\t\t\t\t// Avoid unnecessary rerenders if the save id is the same.\n\t\t\t\tif (latestNode.formSaveId === saveId) return\n\n\t\t\t\tthis.setConfig(node.id, saveId, { destinations, antispam, saveId }, temporarySaveIdToken)\n\n\t\t\t\tthis.#pendingUpdates.delete(token)\n\t\t\t\tlog.debug(\"Fulfilled update: \", token)\n\n\t\t\t\t// Update the tree with the latest saveId.\n\t\t\t\tconst captchaAntispam = antispam.configs.find(isCaptchaAntispam)\n\t\t\t\tlatestNode.set({\n\t\t\t\t\tformSaveId: saveId,\n\t\t\t\t\tformCaptchaProvider: captchaAntispam?.provider,\n\t\t\t\t\tformCaptchaSiteKey: captchaAntispam?.siteKey,\n\t\t\t\t})\n\t\t\t\tthis.persistFormErrors(originalId, errors)\n\n\t\t\t\tif (errors.some(isEmailRecipientsError)) {\n\t\t\t\t\ttoast({\n\t\t\t\t\t\tkey: `${EMAIL_RECIPIENTS_TOAST_KEY}_${originalId}`,\n\t\t\t\t\t\ttype: \"add\",\n\t\t\t\t\t\tvariant: \"error\",\n\t\t\t\t\t\ttext: \"Forms can have a maximum of 3 email recipients.\",\n\t\t\t\t\t\tduration: Infinity,\n\t\t\t\t\t})\n\t\t\t\t} else {\n\t\t\t\t\ttoast({ type: \"remove\", key: `${EMAIL_RECIPIENTS_TOAST_KEY}_${originalId}` })\n\t\t\t\t}\n\t\t\t})\n\t\t} catch (error) {\n\t\t\t// A 403 means forms are not available on the current plan.\n\t\t\t// The UI already gates the form builder, so we just suppress the error.\n\t\t\tif (error instanceof ApiError && error.isForbidden()) return\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tprivate persistFormErrors(originalId: NodeID, errors: string[]) {\n\t\tconst errorsToRemove: NodeID[] = []\n\n\t\tconst list = this.treeStore.tree.get<ErrorListNode>(ERROR_LIST_NODE_ID)\n\t\tconst scopeId = this.treeStore.treeIndex.getScopeIdFor(originalId)\n\t\tif (!scopeId) return\n\n\t\t// Always remove the form errors for this form. If we have new errors,\n\t\t// those replace existing ones, if we have no errors, that means we can\n\t\t// resolve existing ones.\n\t\tlist?.children?.forEach(error => {\n\t\t\tif (error.scopeId !== scopeId) return\n\t\t\tif (error.nodeId !== originalId) return\n\t\t\tif (error.type !== ErrorNodeType.Form) return\n\t\t\terrorsToRemove.push(error.id)\n\t\t})\n\n\t\t// Add an error node for each reason. We aren't showing the reason, just\n\t\t// a warning for the entire form, but we may in future, for now, this\n\t\t// will be helpful for engineers to debug errors.\n\t\tconst errorsToAdd: ErrorNode[] = errors.map(\n\t\t\treason => new ErrorNode({ type: ErrorNodeType.Form, scopeId, nodeId: originalId, reason }),\n\t\t)\n\n\t\tif (errorsToAdd.length === 0 && errorsToRemove.length === 0) return\n\n\t\t// Only ensure the list node when we definitely have errors to add or\n\t\t// remove to ensure we don't add the list node without cause.\n\t\tconst listNode = ErrorListNode.ensure(this.treeStore.tree)\n\t\terrorsToRemove.forEach(nodeId => this.treeStore.tree.remove(nodeId))\n\t\terrorsToAdd.forEach(error => this.treeStore.tree.insertNode(error, listNode.id))\n\t}\n\n\tpostProcess(tree: CanvasTree) {\n\t\tif (tree.isViewOnly) return\n\n\t\t// Ensure error nodes are updated to the correct scope and sourceNodeId.\n\t\tconst list = tree.get<ErrorListNode>(ERROR_LIST_NODE_ID)\n\t\tconst updates: (() => void)[] = []\n\t\tlist?.children?.forEach(error => {\n\t\t\tif (error.type !== ErrorNodeType.Form) return\n\n\t\t\tconst node = tree.get(error.nodeId)\n\t\t\tconst currentScopeId = this.treeStore.treeIndex.getScopeIdFor(node?.id)\n\t\t\tconst currentScopeNode = tree.get(currentScopeId)\n\t\t\tif (!node || !currentScopeNode || currentScopeId === error.scopeId) return\n\n\t\t\t// FormErrors can only exist in Web Pages, Smart Components, and\n\t\t\t// Prototype Screens. Only prototype screens have a unique\n\t\t\t// sourceNodeId.\n\t\t\tconst sourceNodeId = isCanvasPageNode(currentScopeNode)\n\t\t\t\t? this.treeStore.treeIndex.getGroundNodeIdFor(node.id)\n\t\t\t\t: currentScopeNode.id\n\n\t\t\t// If the node that caused the error has been moved to a new scope,\n\t\t\t// update it.\n\t\t\tupdates.push(() => error.set({ scopeId: currentScopeId, sourceNodeId }))\n\t\t})\n\n\t\tif (updates.length > 0) this.scheduler.processWhenReady(() => updates.forEach(update => update()))\n\n\t\tconst changedNodes = this.#nodeChangesReader.read()\n\n\t\tconst pendingUpdates: Promise<\n\t\t\t(FormConfigWithSaveId & { nodeId: NodeID; temporarySaveIdToken: string }) | undefined\n\t\t>[] = []\n\n\t\t// Attempt to update the form configs for all newly cloned forms that don't have a saveId and have a source save\n\t\t// id in their cache.\n\t\tfor (const [id, changes] of changedNodes) {\n\t\t\tif (changes.length === 0) continue\n\n\t\t\tconst node = tree.get(id)\n\t\t\tif (!node || node.originalid) continue\n\t\t\tif (!withFormContainer(node) || !node.cache.formContainerConfigSource) continue\n\n\t\t\tconst {\n\t\t\t\tsaveId: sourceSaveId,\n\t\t\t\tprojectId: sourceProjectId,\n\t\t\t\tnodeId: sourceNodeId,\n\t\t\t} = node.cache.formContainerConfigSource\n\n\t\t\tnode.cache.formContainerConfigSource = undefined\n\n\t\t\t// If the node has a saveId, that means changes may have been made to the form config in the meantime, so\n\t\t\t// we don't need to update it.\n\t\t\tif (node.formSaveId) continue\n\n\t\t\tpendingUpdates.push(this.copyFormConfigWithSaveId(node.id, sourceNodeId, sourceSaveId, sourceProjectId))\n\t\t}\n\n\t\t// Avoid unnecessary rerenders on every frame.\n\t\tif (pendingUpdates.length === 0) return\n\n\t\tPromise.allSettled(pendingUpdates)\n\t\t\t.then(results => {\n\t\t\t\tthis.scheduler.processWhenReady(() => {\n\t\t\t\t\tfor (const result of results) {\n\t\t\t\t\t\tif (result.status !== \"fulfilled\") continue\n\t\t\t\t\t\tif (!result.value) continue\n\t\t\t\t\t\tconst { saveId, destinations, nodeId, temporarySaveIdToken, antispam } = result.value\n\t\t\t\t\t\tif (!saveId) continue\n\n\t\t\t\t\t\tconst latestNode = tree.get(nodeId)\n\t\t\t\t\t\tif (!latestNode || !isFormContainer(latestNode)) continue\n\t\t\t\t\t\tif (latestNode.formSaveId) continue\n\n\t\t\t\t\t\tthis.setConfig(latestNode.id, saveId, { destinations, saveId, antispam }, temporarySaveIdToken)\n\n\t\t\t\t\t\tthis.treeStore.tree.lineage.setEditReason(\"formsstore\")\n\t\t\t\t\t\tconst captchaAntispam = antispam.configs.find(isCaptchaAntispam)\n\t\t\t\t\t\tlatestNode.set({\n\t\t\t\t\t\t\tformSaveId: saveId,\n\t\t\t\t\t\t\tformCaptchaProvider: captchaAntispam?.provider,\n\t\t\t\t\t\t\tformCaptchaSiteKey: captchaAntispam?.siteKey,\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t}, \"nonUserEvent\")\n\t\t\t})\n\t\t\t.catch(unhandledError)\n\t}\n\n\tprivate async copyFormConfigWithSaveId(\n\t\toriginalId: NodeID,\n\t\tsourceNodeId: NodeID,\n\t\tsourceSaveId: SaveId,\n\t\tsourceProjectId: string | undefined,\n\t): Promise<(FormConfigWithSaveId & { nodeId: NodeID; temporarySaveIdToken: string }) | undefined> {\n\t\tconst currentProjectId = this.projectStore.projectId\n\n\t\t// Get either the in-memory form config or the one from the server.\n\t\tconst formConfig =\n\t\t\tthis.#formConfigs.get(sourceSaveId) ??\n\t\t\t(await this.fetchFormConfigForNodeSaveId(sourceNodeId, sourceSaveId, sourceProjectId))\n\t\tif (!formConfig) return\n\n\t\tconst temporarySaveIdToken = this.setTemporaryConfig(originalId, formConfig)\n\n\t\ttry {\n\t\t\t// Persist the form config to the server.\n\t\t\tconst { saveId, destinations, antispam } = await this.persistFormConfig(originalId, currentProjectId, formConfig)\n\t\t\treturn { saveId, destinations, nodeId: originalId, temporarySaveIdToken, antispam }\n\t\t} catch (error) {\n\t\t\t// A 403 means forms are not available on the current plan.\n\t\t\t// The UI already gates the form builder, so we just suppress the error.\n\t\t\tif (error instanceof ApiError && error.isForbidden()) return undefined\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t// Optimistically update the in-memory form config and triggers a rerender.\n\tprivate setTemporaryConfig(originalId: NodeID, config: FormConfigWithSaveId) {\n\t\t// Optimistically update the in-memory form config.\n\t\tconst temporarySaveIdToken = randomID()\n\t\tthis.setConfig(originalId, temporarySaveIdToken, config)\n\n\t\tthis.#nodeIdSaveIdOverrides.set(originalId, temporarySaveIdToken)\n\t\tthis.render()\n\n\t\treturn temporarySaveIdToken\n\t}\n}\n\nexport function createFormConfigSource(\n\toriginalId: NodeID,\n\tsaveId: SaveId | undefined,\n\tprojectId: string | undefined,\n): FormContainerConfigSource | undefined {\n\tif (!saveId) return\n\treturn {\n\t\tnodeId: originalId,\n\t\tsaveId,\n\t\tprojectId,\n\t}\n}\n\nfunction serializeDestinationForServer(destination: FormConfigDestination): FormConfigDestination {\n\tif (isFormConfigVerifiedEmailDestination(destination)) {\n\t\treturn {\n\t\t\t...destination,\n\t\t\temails: destination.emails?.map(email => ({ email: email.email })),\n\t\t}\n\t}\n\treturn destination\n}\n", "/* eslint-disable jsx-a11y/click-events-have-key-events */\n\nimport type { CanvasNode, CanvasTree } from \"document/models/CanvasTree/index.ts\"\nimport { isCodeComponentNode } from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { isVariant } from \"document/models/CanvasTree/traits/WithVariant.ts\"\nimport { isValidModuleSourceNode } from \"./moduleSourceNodeHelpers.ts\"\n\n/**\n * Determines if the node can be preview by the module preview.\n * @returns true if there is a module that can be used to preview this node.\n */\nexport function isPreviewableNode(node: CanvasNode, tree: CanvasTree): boolean {\n\treturn isVariant(node) || isValidModuleSourceNode(node, tree) || isCodeComponentNode(node)\n}\n", "import type { ComponentLoader } from \"@framerjs/framer-runtime\"\nimport type { ModuleExportIdentifierString } from \"@framerjs/shared\"\nimport { ModuleType, localModuleIdentifierForStableName } from \"@framerjs/shared\"\nimport type { CanvasNode } from \"document/models/CanvasTree/index.ts\"\nimport { type CodeGenerationStore, GenerationCondition } from \"document/stores/CodeGenerationStore.ts\"\nimport type { ModulesStore } from \"document/stores/ModulesStore.ts\"\nimport type { TreeStore } from \"document/stores/TreeStore.ts\"\nimport { collectNodesInPrototypeNavigationChain } from \"export/collectNodesInPrototypeNavigationChain.ts\"\nimport { waitForLoadingComponentsWithTimeout } from \"./waitForLoadingComponentsWithTimeout.ts\"\n\nasync function generateComponentForScreen(screenNode: CanvasNode, codeGenerationStore: CodeGenerationStore) {\n\tawait codeGenerationStore.updateComponent(screenNode.id, GenerationCondition.Changed)\n}\n\n// By default only waits for the first screen to be generated, waitForAll, will wait for all screens\nexport async function generateScreensForNavigationChain(\n\tentryNode: CanvasNode,\n\t{\n\t\tcodeGenerationStore,\n\t\tmodulesStore,\n\t\ttreeStore,\n\t}: { codeGenerationStore: CodeGenerationStore; modulesStore: ModulesStore; treeStore: TreeStore },\n\tcomponentLoader: ComponentLoader,\n\toptions: {\n\t\twaitForAll?: boolean // TODO: Maybe we should remove this\n\t\tpersist?: boolean\n\t} = {},\n): Promise<void> {\n\tconst { waitForAll = true, persist = true } = options\n\tconst nodesInNavigationChain = collectNodesInPrototypeNavigationChain(treeStore.tree, componentLoader, entryNode)\n\tconst generationPromises: Promise<void>[] = []\n\n\tconst identifiers: ModuleExportIdentifierString[] = []\n\tfor (const child of nodesInNavigationChain) {\n\t\tidentifiers.push(localModuleIdentifierForStableName(ModuleType.Screen, child.id, \"default\").value)\n\n\t\t// Skip the entry node. We will create a specific promise for it after\n\t\t// this loop. This allows us to wait for only the entry node to be\n\t\t// updated.\n\t\tif (child === entryNode) continue\n\n\t\tgenerationPromises.push(generateComponentForScreen(child, codeGenerationStore))\n\t}\n\n\tconst entryPromise = generateComponentForScreen(entryNode, codeGenerationStore)\n\tgenerationPromises.push(entryPromise)\n\n\tawait Promise.all(waitForAll ? generationPromises : [entryPromise])\n\tif (persist) await codeGenerationStore.persistence.process()\n\n\treturn waitForLoadingComponentsWithTimeout(componentLoader, identifiers, modulesStore)\n}\n", "import { assert } from \"@framerjs/shared\"\nimport type { CanvasNode, CanvasTree, ScopeNode } from \"document/models/CanvasTree/index.ts\"\nimport {\n\tisCodeComponentNode,\n\tisDesignPageNode,\n\tisFrameNode,\n\tisSmartComponentNode,\n\tisVectorSetNode,\n\tisWebPageNode,\n} from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { withBreakpointVariants } from \"document/models/CanvasTree/traits/WithBreakpointVariants.ts\"\nimport { isBreakpointVariant, isVariant } from \"document/models/CanvasTree/traits/WithVariant.ts\"\nimport { withVectorSetItem } from \"document/models/CanvasTree/traits/WithVectorSetItem.ts\"\nimport { getWebPageForInstance, isWebPageInstance } from \"document/models/CanvasTree/traits/utils/isWebPageInstance.ts\"\n\ninterface EntryNodeInfo {\n\tentryNode: CanvasNode\n\tentryScopeNode?: ScopeNode\n}\n\nexport function entryNodeForNodeToRender(nodeToRender: CanvasNode, tree: CanvasTree): EntryNodeInfo {\n\tif (isCodeComponentNode(nodeToRender) && isWebPageInstance(tree, nodeToRender)) {\n\t\tconst webPage = getWebPageForInstance(tree, nodeToRender)\n\t\tassert(isWebPageNode(webPage), \"PreviewRenderer: WebPage Scope node must exist and be a WebPageNode\")\n\t\tassert(webPage.isLoaded(), \"PreviewRenderer: WebPage Scope node must fully loaded\")\n\n\t\treturn { entryNode: webPage.getPrimaryVariant(), entryScopeNode: webPage }\n\t}\n\t// TODO Check and handle shallow/fully loaded scope state\n\tif (isWebPageNode(nodeToRender) && nodeToRender.isLoaded()) {\n\t\treturn { entryNode: nodeToRender.getPrimaryVariant(), entryScopeNode: nodeToRender }\n\t}\n\n\tif (isFrameNode(nodeToRender)) {\n\t\tconst groundNode = tree.getGroundNodeFor(nodeToRender)\n\t\tconst scope = tree.getScopeNodeFor(groundNode)\n\t\tif (isDesignPageNode(scope)) return { entryNode: groundNode, entryScopeNode: scope }\n\t}\n\n\tif (isBreakpointVariant(nodeToRender)) {\n\t\tconst scopeWithBreakpoints = tree.getScopeNodeFor(nodeToRender)\n\t\tassert(\n\t\t\twithBreakpointVariants(scopeWithBreakpoints),\n\t\t\t\"PreviewRenderer: Scope node must exist and be a node supports breakpoint variants\",\n\t\t)\n\t\t// TODO Check and handle shallow/fully loaded scope state\n\t\tassert(scopeWithBreakpoints.isLoaded(), \"PreviewRenderer: Scope node with breakpoint variants must be fully loaded\")\n\t\treturn { entryNode: scopeWithBreakpoints.getPrimaryVariant(), entryScopeNode: scopeWithBreakpoints }\n\t}\n\tif (isVariant(nodeToRender) && !isBreakpointVariant(nodeToRender)) {\n\t\tconst smartComponentNode = tree.getScopeNodeFor(nodeToRender)\n\t\tassert(\n\t\t\tisSmartComponentNode(smartComponentNode),\n\t\t\t\"PreviewRenderer: Smart Component Scope node must exist and be a SmartComponentNode\",\n\t\t)\n\t\treturn { entryNode: nodeToRender, entryScopeNode: smartComponentNode }\n\t}\n\n\tif (withVectorSetItem(nodeToRender) && nodeToRender.isVectorSetItem) {\n\t\tconst vectorSetNode = tree.getScopeNodeFor(nodeToRender)\n\t\tassert(isVectorSetNode(vectorSetNode), \"PreviewRenderer: Scope node must exist and be a VectorSetNode\")\n\n\t\treturn { entryNode: nodeToRender, entryScopeNode: vectorSetNode }\n\t}\n\n\treturn { entryNode: nodeToRender }\n}\n", "import type { CanvasNode, CanvasTree } from \"document/models/CanvasTree/index.ts\"\nimport { isCanvasPageNode, isCodeComponentNode } from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\n\nexport function isScreenNode(tree: CanvasTree, nodeToRender: CanvasNode): boolean {\n\tconst groundNode = tree.getGroundNodeFor(nodeToRender)\n\tconst scopeNode = tree.getScopeNodeFor(groundNode)\n\treturn isCanvasPageNode(scopeNode) && !isCodeComponentNode(groundNode)\n}\n", "import type { ComponentLoader } from \"@framerjs/framer-runtime\"\nimport type { ModulePreviewSandbox, UnsafeJSON } from \"@framerjs/framer-services\"\nimport {\n\tassert,\n\tModuleType,\n\tassertNever,\n\tgetLogger,\n\tisEmptyObject,\n\tisModuleExportIdentifier,\n\tlocalModuleIdentifierForStableName,\n} from \"@framerjs/shared\"\nimport { flattenComponentFontBundles } from \"code-generation/utils/flattenComponentFonts.ts\"\nimport { getRawWebPagePath } from \"document/components/utils/getWebPagePath.ts\"\nimport type { AnyWebPageNode, CanvasTree, NodeID } from \"document/models/CanvasTree/index.ts\"\nimport type { AnyLayoutTemplateNode } from \"document/models/CanvasTree/nodes/LayoutTemplateNode.ts\"\nimport {\n\tisCodeComponentNode,\n\tisDesignPageNode,\n\tisLayoutTemplateNode,\n\tisSmartComponentNode,\n\tisVectorSetNode,\n\tisWebPageNode,\n} from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { hasLayoutTemplate } from \"document/models/CanvasTree/traits/WithLayoutTemplate.ts\"\nimport { getWebPageScrollTargets } from \"document/models/CanvasTree/traits/WithScrollTarget.ts\"\nimport type { ControlProps } from \"document/models/controlProps/ControlProp.ts\"\nimport type { PreviewItem } from \"document/preview/PreviewItem.ts\"\nimport type { ChromeStore } from \"document/stores/ChromeStore.ts\"\nimport type { ModulesStore } from \"document/stores/ModulesStore.ts\"\nimport type { PreviewStore } from \"document/stores/PreviewStore.ts\"\nimport type { TreeStore } from \"document/stores/TreeStore.ts\"\nimport { collectNodesInPrototypeNavigationChain } from \"export/collectNodesInPrototypeNavigationChain.ts\"\nimport { collectPageEffects } from \"export/collectPageEffects.ts\"\nimport type { ComponentFont, Locale, LocaleId } from \"library/index.ts\"\nimport { ControlType } from \"library/render/types/PropertyControls.ts\"\nimport { getLayoutTemplatePlaceholderIdentifier } from \"preview-module/components/LayoutTemplatePreviewPlaceholder.tsx\"\nimport { objectToKeyValueArray } from \"preview-module/utils/arrayToObject.ts\"\nimport { entryNodeForNodeToRender } from \"preview-module/utils/entryNodeForNodeToRender.ts\"\nimport { isScreenNode } from \"preview-module/utils/isScreenNode.ts\"\nimport { getAssetResolverWithHash } from \"renderer/getAssetResolver.ts\"\nimport {\n\tcollectCollectionUtilsForReferencedCollections,\n\tgetCollectionUtilForNode,\n} from \"utils/getCollectionUtilForNode.ts\"\nimport { unsafeGetRouterLocaleUtils } from \"utils/getRouterLocales.ts\"\n\nconst log = getLogger(\"renderInfoForPreviewItem\")\n\nexport function getVekterLocales(tree: CanvasTree) {\n\tconst defaultLocale = tree.root.getDefaultLocale()\n\tconst rootLocales = tree.root.locales\n\tconst locales = [defaultLocale]\n\tif (rootLocales) locales.push(...rootLocales)\n\treturn locales\n}\n\nfunction renderInfoFor(\n\tmodulesStore: ModulesStore,\n\tpreviewStore: PreviewStore,\n\tscopeNode: AnyWebPageNode | AnyLayoutTemplateNode,\n\tcollectionItemNodeId: NodeID | undefined,\n\tinitialLocaleId: LocaleId,\n\ttree: CanvasTree,\n\tcomponentLoader: ComponentLoader,\n): ModulePreviewSandbox.RenderInfo {\n\tconst routes: ModulePreviewSandbox.Route[] = []\n\tconst collectionUtils: ModulePreviewSandbox.CollectionUtil[] = []\n\n\tconst pageEffects = {\n\t\tglobal: tree.root.globalPageEffect,\n\t\troutes: {},\n\t}\n\tconst fontsToLoad = new Set<ComponentFont>()\n\n\tconst vekterLocales = getVekterLocales(tree)\n\tconst routerLocales = unsafeGetRouterLocaleUtils.vekterLocalesToRouterLocales(vekterLocales, {\n\t\tincludeDrafts: true,\n\t})\n\tconst locale = routerLocales.find(otherLocale => otherLocale.id === initialLocaleId)\n\n\tfor (const scope of tree.root.children) {\n\t\tif (!isLayoutTemplateNode(scope) && !isWebPageNode(scope)) continue\n\n\t\tif (isLayoutTemplateNode(scope)) {\n\t\t\troutes.push({\n\t\t\t\tid: scope.id,\n\t\t\t\tmoduleIdentifier: getLayoutTemplatePlaceholderIdentifier(),\n\t\t\t\tlayoutTemplate: { moduleIdentifier: scope.instanceIdentifier },\n\t\t\t})\n\t\t}\n\n\t\tif (isWebPageNode(scope)) {\n\t\t\t// TODO Check and handle shallow/fully loaded scope state\n\t\t\tconst elements = scope.isLoaded() ? objectToKeyValueArray(getWebPageScrollTargets(scope)) : []\n\t\t\tconst pagePath = getRawWebPagePath(tree, scope)\n\n\t\t\tconst collectionUtil = getCollectionUtilForNode(modulesStore, scope)\n\t\t\tif (collectionUtil) {\n\t\t\t\tcollectionUtils.push(collectionUtil)\n\t\t\t}\n\n\t\t\tcollectCollectionUtilsForReferencedCollections(modulesStore, scope, util => {\n\t\t\t\tcollectionUtils.push(util)\n\t\t\t})\n\n\t\t\troutes.push({\n\t\t\t\tid: scope.id,\n\t\t\t\tmoduleIdentifier: scope.instanceIdentifier,\n\t\t\t\tcollectionId: collectionUtil?.collectionId,\n\t\t\t\tpath: pagePath,\n\t\t\t\telements,\n\t\t\t\tlayoutTemplate: getRouteLayoutTemplate(componentLoader, scope, locale),\n\t\t\t\tabTestingParentId: scope.abTestingParentId,\n\t\t\t})\n\n\t\t\t// TODO Check and handle shallow/fully loaded scope state\n\t\t\tif (scope.isLoaded()) {\n\t\t\t\tcollectPageEffects(pageEffects, scope)\n\t\t\t}\n\t\t}\n\n\t\tconst component = componentLoader.componentForIdentifier(scope.instanceIdentifier)\n\t\tconst fontBundles = component?.fonts\n\t\tif (!fontBundles) {\n\t\t\tlog.debug(\"Did not find fonts for component:\", scope.instanceIdentifier)\n\t\t\t// When the component is not loaded yet, we skip it here, and it\n\t\t\t// will be loaded within the WebPagePreview itself\n\t\t\tcontinue\n\t\t}\n\t\tfor (const font of flattenComponentFontBundles(fontBundles)) {\n\t\t\tfontsToLoad.add(font)\n\t\t}\n\t}\n\n\tconst pathSlugs = collectionItemNodeId\n\t\t? previewStore.getPathSlugs(scopeNode.id, collectionItemNodeId, locale)\n\t\t: undefined\n\n\tconst initialUnresolvedPathSlugs: ModulePreviewSandbox.UnresolvedSlug[] = []\n\n\tconst unresolvedSlugs = pathSlugs?.unresolvedSlugs\n\tfor (const variableId in unresolvedSlugs) {\n\t\tconst unresolvedSlug = unresolvedSlugs[variableId]\n\t\tassert(unresolvedSlug)\n\n\t\tinitialUnresolvedPathSlugs.push({\n\t\t\tvariableId,\n\t\t\tcollectionId: unresolvedSlug.collectionId,\n\t\t\tcollectionItemId: unresolvedSlug.collectionItemId,\n\t\t})\n\t}\n\n\tconst initialPathVariables = pathSlugs?.pathVariables ? objectToKeyValueArray(pathSlugs.pathVariables) : []\n\n\tlog.debug(\"renderInfoFor\", {\n\t\twebPageNode: scopeNode,\n\t\tcollectionItemNodeId,\n\t\tinitialUnresolvedPathSlugs,\n\t})\n\n\treturn {\n\t\tkind: \"webpage\",\n\t\troutes,\n\t\tcollectionUtils,\n\t\tlocales: vekterLocales,\n\t\tinitialPathVariables,\n\t\tpageEffects: pageEffects as UnsafeJSON,\n\t\tpreloadFonts: Array.from(fontsToLoad),\n\t\tinitialRoute: scopeNode.id,\n\t\tinitialUnresolvedPathSlugs,\n\t\tinitialLocaleId,\n\t\tadaptLayoutToTextDirection: tree.root.adaptLayoutToTextDirection,\n\t}\n}\n\nfunction getRouteLayoutTemplate(\n\tcomponentLoader: ComponentLoader,\n\tscope: AnyWebPageNode,\n\tlocale: Locale | undefined,\n): ModulePreviewSandbox.RouteLayoutTemplate | undefined {\n\tif (!hasLayoutTemplate(scope)) return undefined\n\n\tconst props = scope.getResolvedControlPropValues(componentLoader, getAssetResolverWithHash(), undefined, locale)\n\treturn {\n\t\tmoduleIdentifier: scope.layoutTemplateIdentifier,\n\t\tprops: !isEmptyObject(props) ? (props as UnsafeJSON) : undefined,\n\t\trichTextControlKeys: scope.getRichTextControlKeys(componentLoader),\n\t\tvectorSetItemControls: scope.getComponentVectorSetChildren(componentLoader),\n\t}\n}\n\nexport function getRenderInfoForPreviewItem(\n\tcomponentLoader: ComponentLoader,\n\t{\n\t\ttreeStore,\n\t\tchromeStore,\n\t\tpreviewStore,\n\t\tmodulesStore,\n\t}: {\n\t\ttreeStore: TreeStore\n\t\tchromeStore: ChromeStore\n\t\tpreviewStore: PreviewStore\n\t\tmodulesStore: ModulesStore\n\t},\n\tpreviewItem: PreviewItem | undefined,\n): ModulePreviewSandbox.RenderInfo {\n\tif (!previewItem) {\n\t\treturn { kind: \"empty\" }\n\t}\n\n\tswitch (previewItem.type) {\n\t\tcase \"component\": {\n\t\t\tassert(\n\t\t\t\tisModuleExportIdentifier(previewItem.componentId),\n\t\t\t\t\"Previewing component should provide module identifier\",\n\t\t\t\tpreviewItem.componentId,\n\t\t\t)\n\t\t\treturn {\n\t\t\t\tkind: \"module\",\n\t\t\t\tlayout: \"component\",\n\t\t\t\tmoduleIdentifier: previewItem.componentId,\n\t\t\t\tlocales: getVekterLocales(treeStore.tree),\n\t\t\t\tinitialLocaleId: chromeStore.canvasLocaleId,\n\t\t\t\tadaptLayoutToTextDirection: treeStore.tree.root.adaptLayoutToTextDirection,\n\t\t\t}\n\t\t}\n\t\tcase \"node\": {\n\t\t\tconst node = treeStore.tree.get(previewItem.nodeId)\n\t\t\tassert(node, \"Previewing node should provide correct node id\", previewItem.nodeId)\n\t\t\tconst entryNodeInfo = entryNodeForNodeToRender(node, treeStore.tree)\n\n\t\t\tconst entryScopeNode = entryNodeInfo.entryScopeNode\n\n\t\t\tif (isLayoutTemplateNode(entryScopeNode)) {\n\t\t\t\treturn renderInfoFor(\n\t\t\t\t\tmodulesStore,\n\t\t\t\t\tpreviewStore,\n\t\t\t\t\tentryScopeNode,\n\t\t\t\t\tpreviewItem.collectionItemNodeId,\n\t\t\t\t\tchromeStore.canvasLocaleId,\n\t\t\t\t\ttreeStore.tree,\n\t\t\t\t\tcomponentLoader,\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tif (isDesignPageNode(entryScopeNode)) {\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"module\",\n\t\t\t\t\tmoduleIdentifier: localModuleIdentifierForStableName(ModuleType.Design, node.id, \"default\").value,\n\t\t\t\t\tlayout: \"design-screen\",\n\t\t\t\t\tlocales: getVekterLocales(treeStore.tree),\n\t\t\t\t\tinitialLocaleId: chromeStore.canvasLocaleId,\n\t\t\t\t\tadaptLayoutToTextDirection: treeStore.tree.root.adaptLayoutToTextDirection,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (isWebPageNode(entryNodeInfo.entryScopeNode)) {\n\t\t\t\treturn renderInfoFor(\n\t\t\t\t\tmodulesStore,\n\t\t\t\t\tpreviewStore,\n\t\t\t\t\tentryNodeInfo.entryScopeNode,\n\t\t\t\t\tpreviewItem.collectionItemNodeId,\n\t\t\t\t\tchromeStore.canvasLocaleId,\n\t\t\t\t\ttreeStore.tree,\n\t\t\t\t\tcomponentLoader,\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tif (isSmartComponentNode(entryNodeInfo.entryScopeNode)) {\n\t\t\t\tconst controlProps: UnsafeJSON = {\n\t\t\t\t\tvariant: { type: ControlType.Enum, value: entryNodeInfo.entryNode.id },\n\t\t\t\t} satisfies ControlProps\n\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"module\",\n\t\t\t\t\tmoduleIdentifier: entryNodeInfo.entryScopeNode.instanceIdentifier,\n\t\t\t\t\tcontrolProps,\n\t\t\t\t\tlayout: \"component\",\n\t\t\t\t\tlocales: getVekterLocales(treeStore.tree),\n\t\t\t\t\tinitialLocaleId: chromeStore.canvasLocaleId,\n\t\t\t\t\tadaptLayoutToTextDirection: treeStore.tree.root.adaptLayoutToTextDirection,\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (isVectorSetNode(entryNodeInfo.entryScopeNode)) {\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"module\",\n\t\t\t\t\tmoduleIdentifier: localModuleIdentifierForStableName(ModuleType.Vector, entryNodeInfo.entryNode.id, \"default\")\n\t\t\t\t\t\t.value,\n\t\t\t\t\tlayout: \"component\",\n\t\t\t\t\tlocales: getVekterLocales(treeStore.tree),\n\t\t\t\t\tinitialLocaleId: chromeStore.canvasLocaleId,\n\t\t\t\t\tadaptLayoutToTextDirection: treeStore.tree.root.adaptLayoutToTextDirection,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (isCodeComponentNode(entryNodeInfo.entryNode)) {\n\t\t\t\tconst component = componentLoader.reactComponentForIdentifier(entryNodeInfo.entryNode.codeComponentIdentifier)\n\n\t\t\t\tconst controlProps = component\n\t\t\t\t\t? (entryNodeInfo.entryNode.getControlProps(component.properties) as unknown as UnsafeJSON)\n\t\t\t\t\t: {}\n\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"module\",\n\t\t\t\t\tmoduleIdentifier: entryNodeInfo.entryNode.codeComponentIdentifier,\n\t\t\t\t\tcontrolProps,\n\t\t\t\t\tlayout: \"component\",\n\t\t\t\t\tlocales: getVekterLocales(treeStore.tree),\n\t\t\t\t\tinitialLocaleId: chromeStore.canvasLocaleId,\n\t\t\t\t\tadaptLayoutToTextDirection: treeStore.tree.root.adaptLayoutToTextDirection,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (isScreenNode(treeStore.tree, entryNodeInfo.entryNode)) {\n\t\t\t\tconst groundNode = treeStore.tree.getGroundNodeFor(entryNodeInfo.entryNode)\n\n\t\t\t\t// Collect the modules of the screens that are in the navigation\n\t\t\t\t// chain, so they can be provided in the preview based on their\n\t\t\t\t// id\n\t\t\t\tconst nodesInNavigationChain = collectNodesInPrototypeNavigationChain(\n\t\t\t\t\ttreeStore.tree,\n\t\t\t\t\tcomponentLoader,\n\t\t\t\t\tentryNodeInfo.entryNode,\n\t\t\t\t)\n\t\t\t\tconst routes: ModulePreviewSandbox.Route[] = []\n\t\t\t\tfor (const navigationNode of nodesInNavigationChain) {\n\t\t\t\t\tconst navigationGroundNode = treeStore.tree.getGroundNodeFor(navigationNode)\n\t\t\t\t\tconst navigationModuleIdentifier = localModuleIdentifierForStableName(\n\t\t\t\t\t\tModuleType.Screen,\n\t\t\t\t\t\tnavigationGroundNode.id,\n\t\t\t\t\t\t\"default\",\n\t\t\t\t\t).value\n\t\t\t\t\troutes.push({ id: navigationGroundNode.id, moduleIdentifier: navigationModuleIdentifier })\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"prototype\",\n\t\t\t\t\trouteId: groundNode.id,\n\t\t\t\t\troutes,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthrow new Error(`Unsupported node for preview: ${node.id}`)\n\t\t}\n\t\tdefault:\n\t\t\tassertNever(previewItem)\n\t}\n}\n", "import type { CanvasNode } from \"../nodes/CanvasNode.ts\"\nimport type { IsVectorSetItem } from \"./WithVectorSetItem.ts\"\n\nexport interface WithVectorSetItems {\n\tgetVectorSetItems<T extends CanvasNode>(): (T & IsVectorSetItem)[]\n}\n\nconst withVectorSetItemsKey: keyof WithVectorSetItems = \"getVectorSetItems\"\n\nexport function withVectorSetItems<T extends CanvasNode>(node: T): node is T & WithVectorSetItems {\n\treturn withVectorSetItemsKey in node\n}\n", "import type { ModulePreviewSandbox } from \"@framerjs/framer-services\"\nimport { ModuleType, localModuleIdentifier } from \"@framerjs/shared\"\nimport type { CanvasTree, MaybeNodeID } from \"document/models/CanvasTree/index.ts\"\nimport { usesModuleRevision } from \"document/models/CanvasTree/traits/WithModuleRevision.ts\"\nimport { localModuleIdsForSourceNode } from \"document/utils/moduleSourceNodeHelpers.ts\"\n\nexport function targetModuleRevisionsForNodeIds(\n\ttree: CanvasTree,\n\tids: MaybeNodeID[],\n): ModulePreviewSandbox.TargetModuleRevision[] {\n\tconst nodesWithRevision = tree.getNodesWithTrait(ids, node => usesModuleRevision(node, tree))\n\treturn nodesWithRevision.flatMap(node => {\n\t\tif (node.moduleSourceRevision === undefined) return []\n\t\tconst identifiers = localModuleIdsForSourceNode(node, tree).filter(\n\t\t\t// Filter out draft collections, because they will be covered by the main collection\n\t\t\t// itself.\n\t\t\tid => !id.includes(ModuleType.DraftCollection),\n\t\t)\n\t\tconst moduleRevision = node.moduleSourceRevision\n\t\treturn identifiers.map(identifier => {\n\t\t\treturn {\n\t\t\t\t// This assumes that all framer source nodes are default exports\n\t\t\t\tmoduleIdentifier: localModuleIdentifier(identifier, \"default\").value,\n\t\t\t\tmoduleRevision,\n\t\t\t}\n\t\t})\n\t})\n}\n", "import type { PreviewShownSource } from \"@framerjs/framer-events\"\nimport { triggerPreviewShownEvent } from \"@framerjs/framer-events\"\nimport type { ComponentLoader } from \"@framerjs/framer-runtime\"\nimport {\n\tassert,\n\tModuleType,\n\tassertNever,\n\tisLocalModuleIdentifier,\n\tlocalModuleIdForStableName,\n\tparseModuleIdentifier,\n\tunhandledError,\n} from \"@framerjs/shared\"\nimport { generateScreensForNavigationChain } from \"code-generation/utils/generateComponentsForNavigationChain.ts\"\nimport type { VekterEngine } from \"document/VekterEngine.ts\"\nimport { getRenderInfoForPreviewItem } from \"document/components/chrome/preview/getRenderInfoForPreviewItem.ts\"\nimport type { MaybeNodeID, NodeID } from \"document/models/CanvasTree/index.ts\"\nimport { isCanvasPageNode, isDesignPageNode } from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { withReplicaVariants } from \"document/models/CanvasTree/traits/WithReplicaVariants.ts\"\nimport { isVectorSetItem } from \"document/models/CanvasTree/traits/WithVectorSetItem.ts\"\nimport { withVectorSetItems } from \"document/models/CanvasTree/traits/WithVectorSetItems.ts\"\nimport type { ChromeStore } from \"document/stores/ChromeStore.ts\"\nimport { GenerationCondition } from \"document/stores/CodeGenerationStore.ts\"\nimport type { ModulesStore } from \"document/stores/ModulesStore.ts\"\nimport type { PreviewStore } from \"document/stores/PreviewStore.ts\"\nimport type { TreeStore } from \"document/stores/TreeStore.ts\"\nimport { ActiveMainView } from \"document/utils/ActiveEditorType.ts\"\nimport type { PreviewItem } from \"./PreviewItem.ts\"\nimport { targetModuleRevisionsForNodeIds } from \"./targetModuleRevisionsForNodeIds.ts\"\n\nexport function isPreviewVisible(chromeStore: ChromeStore): boolean {\n\tconst codeEditorActive = chromeStore.mainView === ActiveMainView.CodeEditor\n\tif (codeEditorActive) {\n\t\treturn chromeStore.codeEditorPreviewVisible\n\t} else {\n\t\treturn chromeStore.mainView === ActiveMainView.Preview\n\t}\n}\n\nexport interface TogglePreviewVisibleOptions {\n\tvisible?: boolean\n\tfullscreen?: boolean\n\tshownOnLaunch?: boolean\n\tsource?: PreviewShownSource\n}\n\n// When calling this you probably need the plain `togglePreviewVisible`. This\n// version is only there to avoid causing circular dependencies when calling it\n// inside a context where the engine is already available.\nexport function togglePreviewVisibleWithoutEngineDependency(\n\tengine: VekterEngine,\n\toptions: TogglePreviewVisibleOptions = {},\n) {\n\tconst { previewStore, fullsizePreviewStore, loadingStore, chromeStore, treeStore, modulesStore } = engine.stores\n\tif (!loadingStore.hasMinimalEditableData) return\n\n\tconst { visible, shownOnLaunch, source = \"unknown\" } = options\n\n\tconst wasVisible = isPreviewVisible(chromeStore)\n\tconst isVisible = typeof visible === \"boolean\" ? visible : !wasVisible\n\tchromeStore.setPreviewVisible(isVisible)\n\n\tif (!wasVisible && isVisible) {\n\t\tpreviewStore.addActiveSession()\n\n\t\t// Prepare the preview item and update the preview size first. If we couldn't find a local\n\t\t// module to preview, wait for code generation to complete before setting the item.\n\t\tconst item = previewStore.computePreviewItem()\n\n\t\tif (!item) {\n\t\t\t// Nothing to preview. Revert so the empty preview overlay doesn't\n\t\t\t// get stuck open (the sandbox won't send didContentUnmount for an\n\t\t\t// already-empty renderInfo, leaving isVisibleAfterReactRender stuck).\n\t\t\tpreviewStore.removeActiveSession()\n\t\t\tchromeStore.setPreviewVisible(false)\n\t\t\treturn\n\t\t}\n\n\t\tif (\n\t\t\t!previewItemAfterCodeGeneration(\n\t\t\t\tengine.componentLoader,\n\t\t\t\t{ treeStore, previewStore, chromeStore, modulesStore },\n\t\t\t\titem,\n\t\t\t)\n\t\t) {\n\t\t\tpreviewStore.item = item\n\t\t} else if (item?.type === \"node\") {\n\t\t\tconst node = treeStore.tree.get(item.nodeId)\n\t\t\tassert(node, \"Did not find previewNode\", item.nodeId)\n\t\t\t// Update the preview size preemptively if the preview item is set later, so that we\n\t\t\t// don't render an incorrect size.\n\t\t\tfullsizePreviewStore.updatePreviewSize(node)\n\t\t}\n\n\t\tif (options.fullscreen !== undefined) {\n\t\t\tfullsizePreviewStore.isPreviewUIVisible = !options.fullscreen\n\t\t}\n\n\t\ttriggerCodeGeneration(engine, item)\n\t\t\t.then(ids => {\n\t\t\t\t// Don't update if preview was closed during code generation.\n\t\t\t\tif (!previewStore.isActive) return\n\t\t\t\tpreviewStore.targetModuleRevisions = targetModuleRevisionsForNodeIds(treeStore.tree, ids)\n\t\t\t})\n\t\t\t.catch(unhandledError)\n\t\t\t.finally(() => {\n\t\t\t\t// Don't set the item if preview was closed during code generation,\n\t\t\t\t// as that would leave the preview visually stuck open while the\n\t\t\t\t// chrome has already returned to the canvas.\n\t\t\t\tif (!previewStore.isActive) return\n\t\t\t\t// In case we didn't set the item when it hadn't been generated yet, set it now to update the preview.\n\t\t\t\tpreviewStore.item = item\n\t\t\t})\n\n\t\ttriggerPreviewShownEvent({ shown_on_launch: shownOnLaunch, source })\n\t} else if (wasVisible && !isVisible) {\n\t\tpreviewStore.removeActiveSession()\n\n\t\tpreviewStore.stickyPreviewItem = false\n\t\tpreviewStore.item = undefined\n\t} else if (!isVisible && previewStore.item !== undefined) {\n\t\t// Recovery: if the preview is supposed to be hidden but still has an\n\t\t// item (e.g. due to a previous race condition), clear it so the iframe\n\t\t// can paint null and the preview overlay finally hides.\n\t\tpreviewStore.item = undefined\n\t}\n}\n\n/**\n * If we are previewing a local module, and the local module cannot be found, wait for code generation to complete.\n */\nfunction previewItemAfterCodeGeneration(\n\tcomponentLoader: ComponentLoader,\n\tstores: { treeStore: TreeStore; chromeStore: ChromeStore; previewStore: PreviewStore; modulesStore: ModulesStore },\n\tpreviewItem: PreviewItem | undefined,\n): boolean {\n\tif (!previewItem || previewItem.type !== \"node\") return false\n\n\tconst { modulesStore } = stores\n\n\tconst renderInfo = getRenderInfoForPreviewItem(componentLoader, stores, previewItem)\n\tswitch (renderInfo.kind) {\n\t\tcase \"module\": {\n\t\t\tconst parsed = parseModuleIdentifier(renderInfo.moduleIdentifier)\n\t\t\t// Waiting for code generation wouldn't help with external modules, so no need to wait.\n\t\t\tif (!isLocalModuleIdentifier(parsed)) return false\n\t\t\treturn !modulesStore.getModuleEntryByLocalId(parsed.localId)\n\t\t}\n\t\tcase \"webpage\": {\n\t\t\tconst localId = localModuleIdForStableName(ModuleType.Screen, renderInfo.initialRoute)\n\t\t\treturn !modulesStore.getModuleEntryByLocalId(localId)\n\t\t}\n\t\tcase \"prototype\": {\n\t\t\tconst localId = localModuleIdForStableName(ModuleType.Prototype, renderInfo.routeId)\n\t\t\treturn !modulesStore.getModuleEntryByLocalId(localId)\n\t\t}\n\t\tcase \"empty\":\n\t\t\treturn false\n\t\tdefault:\n\t\t\tassertNever(renderInfo)\n\t}\n}\n\nasync function triggerCodeGeneration(engine: VekterEngine, item: PreviewItem | undefined): Promise<MaybeNodeID[]> {\n\tif (!item) return []\n\tconst previewItemId = await updatePreviewItem(engine, item)\n\tconst { codeGenerationStore } = engine.stores\n\t// If there were other nodes in the queue, wait for them to be generated, this ensures things\n\t// like style preset changes are reflected when we open the preview.\n\tconst queue = await codeGenerationStore.generateAndUpdateQueuedComponents()\n\t// If there were serialisations started before we awaited generating the queue,  generations\n\t// that were long running - like changes to a linked cms collection - may still not have\n\t// completed. Make sure they finish before previewing.\n\tawait codeGenerationStore.serialization.idle()\n\n\treturn [previewItemId, ...queue]\n}\n\nasync function updatePreviewItem(engine: VekterEngine, item: PreviewItem): Promise<NodeID | undefined> {\n\tconst { componentLoader, stores } = engine\n\tconst { codeGenerationStore, treeStore, modulesStore } = stores\n\tif (item.type === \"component\") {\n\t\tif (!codeGenerationStore.canSerialize(item.componentId)) return\n\t\tawait codeGenerationStore.updateComponent(item.componentId, GenerationCondition.Changed)\n\t\treturn undefined\n\t} else if (item.collectionItemNodeId) {\n\t\tconst collection = treeStore.tree.getParent(item.collectionItemNodeId)\n\t\tif (!collection || !codeGenerationStore.canSerialize(collection.id)) return\n\t\tawait codeGenerationStore.updateComponent(collection.id, GenerationCondition.Changed)\n\t\treturn collection.id\n\t} else {\n\t\tconst tree = treeStore.tree\n\t\tconst previewNode = tree.get(item.nodeId)\n\t\tassert(previewNode, \"Did not find previewNode\", item.nodeId)\n\t\tconst scopeNode = tree.getCanvasScopeNodeFor(previewNode)\n\t\tassert(scopeNode, \"Tried triggering code generation for non canvas scope node:\", previewNode.id)\n\t\tif (withVectorSetItems(scopeNode)) {\n\t\t\tif (!isVectorSetItem(previewNode) || !codeGenerationStore.canSerialize(previewNode.id)) return\n\t\t\tawait codeGenerationStore.updateComponent(previewNode.id, GenerationCondition.Changed)\n\t\t\treturn previewNode.id\n\t\t}\n\t\tif (withReplicaVariants(scopeNode)) {\n\t\t\tif (!codeGenerationStore.canSerialize(scopeNode.id)) return\n\t\t\tawait codeGenerationStore.updateComponent(scopeNode.id, GenerationCondition.Changed)\n\t\t\treturn scopeNode.id\n\t\t} else if (isCanvasPageNode(scopeNode)) {\n\t\t\tif (!codeGenerationStore.canSerialize(previewNode.id)) return\n\t\t\tawait generateScreensForNavigationChain(\n\t\t\t\tpreviewNode,\n\t\t\t\t{ codeGenerationStore, treeStore, modulesStore },\n\t\t\t\tcomponentLoader,\n\t\t\t)\n\t\t\treturn previewNode.id\n\t\t} else if (isDesignPageNode(scopeNode)) {\n\t\t\tif (!codeGenerationStore.canSerialize(previewNode.id)) return\n\t\t\tawait codeGenerationStore.updateComponent(previewNode.id, GenerationCondition.Changed)\n\t\t\treturn previewNode.id\n\t\t} else {\n\t\t\tassertNever(scopeNode)\n\t\t}\n\t}\n}\n", "import type { VekterEngine } from \"document/VekterEngine.ts\"\nimport { ActiveMainView } from \"document/utils/ActiveEditorType.ts\"\nimport { isPreviewableNode } from \"document/utils/isPreviewableNode.ts\"\nimport { ScopeType } from \"document/utils/scopeType.ts\"\nimport type { TogglePreviewVisibleOptions } from \"./togglePreviewVisibleWithoutEngineDependency.ts\"\nimport {\n\tisPreviewVisible,\n\ttogglePreviewVisibleWithoutEngineDependency,\n} from \"./togglePreviewVisibleWithoutEngineDependency.ts\"\n\n/** @todo: remove engine dependency. It is required only for isViewOnly, so only name is being checked */\nexport function togglePreviewVisible(engine: VekterEngine, options: TogglePreviewVisibleOptions = {}) {\n\tconst {\n\t\tpreviewStore,\n\t\tchromeStore,\n\t\tsiteSettingsStore,\n\t\tcontentManagementStore,\n\t\tscopeStore,\n\t\tselectionStore,\n\t\ttreeStore,\n\t} = engine.stores\n\tconst shouldShow = options.visible !== undefined ? options.visible : !isPreviewVisible(chromeStore)\n\n\tif (shouldShow) {\n\t\tif (chromeStore.displayMinimalUI && !previewStore.forceOverCanvasPreviewRender) return\n\t\tif (siteSettingsStore.isOpen) return\n\t\tif (chromeStore.mainView === ActiveMainView.ContentManagement) {\n\t\t\tconst collectionItemIdBasedOnCurrentSelection =\n\t\t\t\tcontentManagementStore.getCollectionItemIdBasedOnCurrentSelection()\n\n\t\t\t// If no preview collection item id it means we have no selection nor an active collection item in the overlay\n\t\t\tif (!collectionItemIdBasedOnCurrentSelection) return\n\t\t\tif (!previewStore.getPreviewItemForCollectionItem(collectionItemIdBasedOnCurrentSelection)) return\n\t\t}\n\t\tif (scopeStore.scopeType === ScopeType.DesignPage) {\n\t\t\tif (selectionStore.ids.length === 0) return\n\t\t\tconst groundNode = selectionStore.commonGroundNode\n\t\t\tif (groundNode && !isPreviewableNode(groundNode, treeStore.tree)) return\n\t\t}\n\t}\n\n\ttogglePreviewVisibleWithoutEngineDependency(engine, options)\n}\n", "import type { ComponentLoader } from \"@framerjs/framer-runtime\"\nimport { supportsAutoSizing, supportsFixedSizing } from \"@framerjs/framer-runtime/crossorigin\"\nimport type { CanvasNode } from \"document/models/CanvasTree/nodes/CanvasNode.ts\"\nimport type CodeComponentNode from \"document/models/CanvasTree/nodes/CodeComponentNode.ts\"\nimport type { WithPins } from \"document/models/CanvasTree/traits/WithPins.ts\"\nimport { isAutoSizedOnAnyDimension } from \"document/models/CanvasTree/traits/utils/autoSizeHelpers.ts\"\nimport { DimensionType } from \"library/render/types/Constraints.ts\"\nimport { isCodeComponentNode } from \"../../nodes/utils/nodeCheck.ts\"\n\nexport function getDimensionOrVariantDimensionType(componentLoader: ComponentLoader, node: CanvasNode & WithPins) {\n\tlet widthType = node.widthType\n\tlet heightType = node.heightType\n\n\tif (isCodeComponentNode(node)) {\n\t\twidthType = getSupportedDimensionType(componentLoader, node, \"width\")\n\t\theightType = getSupportedDimensionType(componentLoader, node, \"height\")\n\t\tif (isAutoSizedOnAnyDimension(node)) {\n\t\t\tconst currentVariantSize = node.getCurrentVariantSize(componentLoader)\n\t\t\tif (currentVariantSize) {\n\t\t\t\tif (node.widthType === DimensionType.Auto) {\n\t\t\t\t\twidthType = currentVariantSize.widthType\n\t\t\t\t}\n\n\t\t\t\tif (node.heightType === DimensionType.Auto) {\n\t\t\t\t\theightType = currentVariantSize.heightType\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\twidthType,\n\t\theightType,\n\t}\n}\n\nexport function getSupportedDimensionType(\n\tcomponentLoader: ComponentLoader,\n\tnode: CodeComponentNode,\n\tdimension: \"width\" | \"height\",\n): DimensionType {\n\tconst supportedLayout = node.getSupportedLayout(componentLoader)[dimension]\n\tlet dimensionType = dimension === \"width\" ? node.widthType : node.heightType\n\tif (dimensionType === DimensionType.Auto) {\n\t\tif (!supportsAutoSizing(supportedLayout) && supportsFixedSizing(supportedLayout)) {\n\t\t\tdimensionType = DimensionType.FixedNumber\n\t\t}\n\t} else {\n\t\tif (supportsAutoSizing(supportedLayout) && !supportsFixedSizing(supportedLayout)) {\n\t\t\tdimensionType = DimensionType.Auto\n\t\t}\n\t}\n\treturn dimensionType\n}\n", "import type { AssetService } from \"@framerjs/assets\"\nimport { getLogger, unhandledError } from \"@framerjs/shared\"\nimport type { BaseEngine } from \"document/base-engine/BaseEngine.ts\"\nimport type { AllowedFileTypes } from \"library/render/types/PropertyControls.ts\"\nimport { lookup as lookupMediaType } from \"mrmime\"\nimport { isPromiseFulfilled } from \"utils/typeChecks.ts\"\nimport { BatchAssetUploader } from \"web/lib/BatchAssetUploader.ts\"\nimport { batchUploadImages } from \"web/lib/batchUploaderUtils.tsx\"\nimport * as supportedImages from \"web/lib/images/supportedFormats.ts\"\nimport MIMEType from \"whatwg-mimetype\"\nimport type { FilePickerRef } from \"../../../components/FilePicker.tsx\"\nimport type { FileUploadResult, ImageUploadResult, VideoUploadResult } from \"./UploadService.ts\"\nimport { isImageUploadResult } from \"./UploadService.ts\"\nimport { createService } from \"./createService.ts\"\n\nconst log = getLogger(\"ChooseFileService\")\n\nclass ChooseFileService {\n\tconstructor(\n\t\tprivate readonly engine: BaseEngine,\n\t\tprivate assetService: AssetService,\n\t\tprivate filePickerRef: React.RefObject<FilePickerRef>,\n\t) {\n\t\tthis.assetUploader = new BatchAssetUploader(this.engine)\n\t}\n\n\tprivate readonly assetUploader: BatchAssetUploader\n\n\tasync pickFile({ allowedFileTypes, multiple }: { allowedFileTypes?: AllowedFileTypes; multiple?: boolean } = {}) {\n\t\tconst picker = this.filePickerRef.current\n\t\tif (!picker) return null\n\n\t\tconst allowsAnyFileType = !allowedFileTypes || allowedFileTypes.includes(\"*\") || allowedFileTypes.includes(\"*/*\")\n\t\tconst acceptedFileTypes = allowsAnyFileType\n\t\t\t? undefined\n\t\t\t: allowedFileTypes?.flatMap(fileType => {\n\t\t\t\t\tconst acceptedMediaType = MIMEType.parse(fileType)?.essence\n\t\t\t\t\tconst acceptedMediaTypeFromExtension = lookupMediaType(fileType)\n\t\t\t\t\tconst acceptedFileExtension = fileType.startsWith(\".\") ? fileType : `.${fileType}`\n\t\t\t\t\tif (acceptedMediaType) {\n\t\t\t\t\t\treturn [acceptedMediaType]\n\t\t\t\t\t} else if (acceptedMediaTypeFromExtension) {\n\t\t\t\t\t\t// Some browsers do not have a good list of extensions (e.g. for audio/mp4 missing .m4a and only having .mp4), so the extension itself must be passed too\n\t\t\t\t\t\treturn [acceptedMediaTypeFromExtension, acceptedFileExtension]\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn [acceptedFileExtension]\n\t\t\t\t\t}\n\t\t\t\t})\n\n\t\tconst result = await picker.show(acceptedFileTypes, multiple)\n\t\tif (!result.isFiles()) return null\n\n\t\treturn result.value\n\t}\n\n\tasync pickImage({\n\t\tallowedFileTypes = supportedImages.extensions,\n\t\tmultiple,\n\t}: { allowedFileTypes?: AllowedFileTypes; multiple?: boolean } = {}) {\n\t\treturn this.pickFile({ allowedFileTypes, multiple })\n\t}\n\n\tasync uploadFile(file: File): Promise<FileUploadResult | ImageUploadResult | VideoUploadResult> {\n\t\treturn this.assetUploader.add(file)\n\t}\n\n\tasync pickAndUploadImage(\n\t\toptions: { allowedFileTypes?: AllowedFileTypes; multiple?: boolean; maxUploads?: number } = {},\n\t): Promise<ImageUploadResult[]> {\n\t\ttry {\n\t\t\tconst files = await this.pickImage(options)\n\t\t\tif (!files) return []\n\n\t\t\tif (files.length === 1) {\n\t\t\t\tconst info = await this.assetUploader.add(files[0])\n\t\t\t\tif (!info) return []\n\n\t\t\t\tawait this.assetService.refresh().catch(unhandledError)\n\n\t\t\t\tif (isImageUploadResult(info)) {\n\t\t\t\t\treturn [info]\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn await batchUploadImages(this.engine, files, options.maxUploads)\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tlog.warn(\"Failed to upload file:\", e)\n\t\t}\n\t\treturn []\n\t}\n\n\tasync pickAndUploadFile(options?: {\n\t\tallowedFileTypes?: AllowedFileTypes\n\t}): Promise<FileUploadResult | ImageUploadResult | VideoUploadResult | undefined> {\n\t\tconst [result] = await this.pickAndUploadFiles({ ...options, multiple: false, maxUploads: 1 })\n\t\treturn result\n\t}\n\n\tasync pickAndUploadFiles(options?: {\n\t\tallowedFileTypes?: AllowedFileTypes\n\t\tmultiple?: boolean\n\t\tmaxUploads?: number\n\t}): Promise<(FileUploadResult | ImageUploadResult | VideoUploadResult | undefined)[]> {\n\t\ttry {\n\t\t\tconst files = await this.pickFile(options)\n\t\t\tif (!files) return []\n\n\t\t\treturn await this.uploadFiles(files, { maxUploads: options?.maxUploads })\n\t\t} catch (e) {\n\t\t\tlog.warn(\"Failed to upload file:\", e)\n\t\t}\n\t\treturn []\n\t}\n\n\tasync uploadFiles(\n\t\tfiles: FileList | File[],\n\t\toptions?: {\n\t\t\tmaxUploads?: number\n\t\t},\n\t): Promise<(FileUploadResult | ImageUploadResult | VideoUploadResult | undefined)[]> {\n\t\tconst filesToUpload =\n\t\t\ttypeof options?.maxUploads === \"number\" ? Array.from(files).slice(0, options.maxUploads) : Array.from(files)\n\t\tconst results = await Promise.allSettled(filesToUpload.map(file => this.uploadFile(file)))\n\n\t\tfor (const result of results) {\n\t\t\tif (isPromiseFulfilled(result)) continue\n\t\t\tlog.warn(\"Failed to upload file:\", result.reason)\n\t\t}\n\n\t\treturn results.map(result => (isPromiseFulfilled(result) ? result.value : undefined))\n\t}\n\n\t// You can use this as a high-level API, if you want more control you can use the BatchAssetUploader directly.\n\tasync addImages(images?: FileList | File[]): Promise<ImageUploadResult[]> {\n\t\tif (!images?.length) return []\n\t\t// Wait for uploads to complete.\n\t\tconst results = await Promise.all(Array.from(images, image => this.assetUploader.add(image)))\n\t\tconst imageResults = results.filter(isImageUploadResult)\n\t\tif (imageResults.length === 0) return imageResults\n\t\t// Refresh the assets service before returning the results.\n\t\tawait this.engine.stores.assetStore.assetService?.refresh().catch(unhandledError)\n\t\treturn imageResults\n\t}\n}\n\nconst { service, resolve } = createService<ChooseFileService>()\nexport { service as chooseFileService }\n\nexport function initChooseFileService(\n\tengine: BaseEngine,\n\tassetService: AssetService,\n\tfilePickerRef: React.RefObject<FilePickerRef>,\n): void {\n\tresolve(new ChooseFileService(engine, assetService, filePickerRef))\n}\n", "import { assert, unhandledError } from \"@framerjs/shared\"\nimport { EngineStore } from \"document/EngineStore.ts\"\nimport type {\n\tAnalyticsFunnelGroupByOption,\n\tAnalyticsSectionFilterOption,\n\tAnalyticsSectionFilters,\n\tDevicesData,\n\tDevicesSectionKeys,\n\tGeographyData,\n\tGeographySectionKeys,\n\tPagesData,\n\tPagesSectionKeys,\n\tSiteStatPoint,\n\tSourcesData,\n\tSourcesSectionKeys,\n\tTopFieldRow,\n\tTrackingIdsSectionKeys,\n} from \"document/components/chrome/analytics/types.ts\"\nimport {\n\ttype DateRangePreset,\n\tgetDateRangeForPreset,\n} from \"document/components/chrome/analytics/utils/dateRangePreset.ts\"\nimport {\n\ttype AbTestDropOff,\n\ttype AnalyticsAbTestRequestParams,\n\ttype AnalyticsFunnelRequestParams,\n\ttype AnalyticsOverviewParams,\n\ttype SessionResponse,\n\ttype TopFieldName,\n\tfetchAbTestConversionRate,\n\tfetchAbTestDropOff,\n\tfetchFunnelConversionRate,\n\tfetchFunnelDropOff,\n\tfetchLiveVisitors,\n\tfetchSessionStats,\n\tfetchSiteStats,\n\tfetchTopField,\n\tfetchTopFields,\n} from \"document/components/chrome/analytics/utils/fetchUtils.ts\"\nimport type {\n\tAbTestConversionRatePoint,\n\tFunnelConversionRatePoint,\n} from \"document/components/chrome/analytics/utils/funnel-stats/getFunnelConversionRate.ts\"\nimport type { FunnelDropOffStep } from \"document/components/chrome/analytics/utils/funnel-stats/getFunnelDropOffs.ts\"\nimport type { AbTestQuery } from \"document/components/chrome/analytics/utils/getAbTestQuery.ts\"\nimport { getDayRelativeToToday } from \"document/components/chrome/analytics/utils/getDayRelativeToToday.ts\"\nimport type { FunnelQuery } from \"document/components/chrome/analytics/utils/getFunnelQuery.ts\"\nimport type { NodeID } from \"document/models/CanvasTree/index.ts\"\nimport { ActiveMainView } from \"document/utils/ActiveEditorType.ts\"\nimport { isEqual } from \"library/render/utils/isEqual.ts\"\nimport { Pages } from \"web/lib/tracker.ts\"\nimport type { ChromeStore } from \"./ChromeStore.ts\"\n\nexport enum AnalyticsTabNames {\n\toverview = \"overview\",\n\tfunnel = \"funnel\",\n\tabtest = \"abtest\",\n}\n\nexport type AnalyticsTab =\n\t| { tab: AnalyticsTabNames.overview }\n\t| { tab: AnalyticsTabNames.funnel; id: NodeID }\n\t| { tab: AnalyticsTabNames.abtest; id: NodeID }\n\n/**\n * Used to automatically emit ui_impression tracking events when the user\n * navigates to the given tab. Use `null` to explicitly opt a tab out of this,\n * for example, if you don't want to track a particular tab, or if you want to\n * do some custom tracking.\n */\nexport const analyticsImpressionTrackingPages: Record<AnalyticsTabNames, Pages | null> = {\n\t[AnalyticsTabNames.overview]: Pages.analyticsOverview,\n\t[AnalyticsTabNames.funnel]: Pages.analyticsFunnel,\n\t[AnalyticsTabNames.abtest]: Pages.analyticsAbTest,\n}\n\nexport function isAnalyticsTabName(value: string): value is AnalyticsTabNames {\n\treturn value in AnalyticsTabNames\n}\n\n// Minimum date that we allow to be selected in the date picker.\n// This is the date since when we have complete data in Tinybird.\nconst analyticsMinDayHardLimit = \"2024-11-01\"\n\n// Fallback for when resourceLimits hasn't loaded yet\nconst defaultAnalyticsRangeInDays = 30\n\nconst defaultPreset: DateRangePreset = \"Last 30 days\"\nexport const defaultSourcesFacet: SourcesSectionKeys = \"referrer\"\nexport const defaultDevicesFacet: DevicesSectionKeys = \"device\"\nexport const defaultGeographyFacet: GeographySectionKeys = \"countryCode\"\nconst defaultTrackingIdsFacet: TrackingIdsSectionKeys = \"trackingId\"\nconst defaultPagesFacet: PagesSectionKeys = \"pathname\"\n\ntype LoadingKey = {\n\t[K in keyof AnalyticsStore]: K extends `${string}Loading` ? K : never\n}[keyof AnalyticsStore]\n\nexport class AnalyticsStore extends EngineStore {\n\tconstructor(\n\t\tprivate projectId: string,\n\t\tprivate chromeStore: ChromeStore,\n\t\tprivate getAnalyticsRangeInDays: () => number | null | undefined,\n\t) {\n\t\tsuper()\n\t\tthis.setDateRangeFromPreset(defaultPreset)\n\t}\n\n\tprivate _active: AnalyticsTab | null = null\n\tget active(): AnalyticsTab | null {\n\t\treturn this._active\n\t}\n\tasync setActiveTab(nextTab: AnalyticsTab | null) {\n\t\t// NOTE: Setting the same tab twice results in a bug that causes the active tab requests to be cancelled and not made again.\n\t\t// This condition prevents that to happen.\n\t\tif (isEqual(this._active, nextTab)) return\n\n\t\tif (\n\t\t\t(this._active === null || this._active.tab === AnalyticsTabNames.abtest) &&\n\t\t\tnextTab?.tab !== AnalyticsTabNames.abtest\n\t\t) {\n\t\t\t// The A/B test tab doesn't use a date picker but the test startedAt and stoppedAt\n\t\t\tthis.setDateRangeFromPreset(defaultPreset)\n\t\t}\n\t\tif (this._active !== null && nextTab === null) {\n\t\t\tthis.reset()\n\t\t}\n\n\t\tthis._active = nextTab\n\n\t\tif (nextTab?.tab === AnalyticsTabNames.overview) {\n\t\t\t// The data for the funnel tab is fetched from the FunnelOverview component\n\t\t\t// but for the overview, it is fetched here\n\t\t\tthis.fetchTab()\n\t\t}\n\n\t\tthis.chromeStore.onChangeAnalyticsVisible(Boolean(nextTab), this.isRightPanelVisible)\n\t}\n\n\t/** Hide the right panel on the overview screen */\n\tget isRightPanelVisible(): boolean {\n\t\treturn this._active ? this._active.tab !== AnalyticsTabNames.overview : false\n\t}\n\n\tget isOpen(): boolean {\n\t\treturn this.chromeStore.mainView === ActiveMainView.Analytics\n\t}\n\topen = (tab: AnalyticsTab = { tab: AnalyticsTabNames.overview }) => {\n\t\tif (this.isOpen && isEqual(this._active, tab)) return\n\t\tthis.setActiveTab(tab).catch(unhandledError)\n\t}\n\tclose = () => {\n\t\tthis.setActiveTab(null).catch(unhandledError)\n\t}\n\n\tget minDay() {\n\t\tconst rangeInDays = this.getAnalyticsRangeInDays()\n\n\t\t// null means unlimited\n\t\tif (rangeInDays === null) {\n\t\t\treturn analyticsMinDayHardLimit\n\t\t}\n\n\t\tconst effectiveRange = rangeInDays ?? defaultAnalyticsRangeInDays\n\t\treturn getDayRelativeToToday(-effectiveRange)\n\t}\n\n\tget maxDay() {\n\t\treturn getDayRelativeToToday(0)\n\t}\n\n\tprivate _preset: DateRangePreset | undefined = defaultPreset\n\tset preset(preset: DateRangePreset | undefined) {\n\t\tif (preset === this._preset) return\n\n\t\tthis._preset = preset\n\t\tif (!preset) return\n\n\t\tthis.setDateRangeFromPreset(preset)\n\n\t\tthis.fetchTab({ liveVisitors: false })\n\t}\n\tget preset() {\n\t\treturn this._preset\n\t}\n\n\tprivate _funnelQuery: FunnelQuery | undefined = undefined\n\tset funnelQuery(funnelQuery: FunnelQuery) {\n\t\tif (funnelQuery === this._funnelQuery) return\n\t\tthis._funnelQuery = funnelQuery\n\t\tthis.fetchTab()\n\t}\n\tget funnelQuery(): FunnelQuery | undefined {\n\t\treturn this._funnelQuery\n\t}\n\n\tprivate _abTestQuery: AbTestQuery | undefined\n\tset abTestQuery(abTestQuery: AbTestQuery) {\n\t\tif (abTestQuery === this._abTestQuery) return\n\t\tthis._abTestQuery = abTestQuery\n\t\tthis.fetchTab()\n\t}\n\tget abTestQuery(): AbTestQuery | undefined {\n\t\treturn this._abTestQuery\n\t}\n\n\tprivate setDateRangeFromPreset(preset: DateRangePreset) {\n\t\tconst [fromDay, toDay] = getDateRangeForPreset(preset)\n\t\tthis._fromDay = fromDay\n\t\tthis._toDay = toDay\n\t}\n\n\t/** `yyyy-MM-dd`, in the local time zone */\n\t// Safely using a non-null assertion operator (`!`) here because this field\n\t// is initialized in the constructor via this.setDateRangeFromPreset()\n\tprivate _fromDay!: string\n\tset fromDay(fromDay: string) {\n\t\tconst minDay = this.minDay\n\t\tif (fromDay < minDay) fromDay = minDay\n\t\tif (fromDay > this.toDay) fromDay = this.toDay\n\n\t\tif (fromDay === this._fromDay) return\n\n\t\tthis._fromDay = fromDay\n\t\tthis._preset = undefined\n\n\t\tthis.fetchTab({ liveVisitors: false })\n\t}\n\tget fromDay() {\n\t\treturn this._fromDay\n\t}\n\n\t/** `yyyy-MM-dd`, in the local time zone */\n\t// Safely using a non-null assertion operator (`!`) here because this field\n\t// is initialized in the constructor via this.setDateRangeFromPreset()\n\tprivate _toDay!: string\n\tset toDay(toDay: string) {\n\t\tconst maxDay = this.maxDay\n\t\tif (toDay > maxDay) toDay = maxDay\n\t\tif (toDay < this.fromDay) toDay = this.fromDay\n\n\t\tif (toDay === this._toDay) return\n\n\t\tthis._toDay = toDay\n\t\tthis._preset = undefined\n\n\t\tthis.fetchTab({ liveVisitors: false })\n\t}\n\tget toDay() {\n\t\treturn this._toDay\n\t}\n\n\tfilters: AnalyticsSectionFilters = {}\n\taddFilter = (key: AnalyticsSectionFilterOption, value: string, valueLabel: string) => {\n\t\tif (this.filters[key]?.value === value) return\n\n\t\tthis.filters = {\n\t\t\t...this.filters,\n\t\t\t[key]: { label: valueLabel, value, valueLabel },\n\t\t}\n\n\t\tthis.fetchTab()\n\t}\n\tremoveFilter = (key: AnalyticsSectionFilterOption) => {\n\t\tconst { [key]: _, ...rest } = this.filters\n\t\tthis.filters = rest\n\n\t\tthis.fetchTab()\n\t}\n\n\tprivate _groupBy: AnalyticsFunnelGroupByOption | undefined\n\tset groupBy(groupBy: AnalyticsFunnelGroupByOption | undefined) {\n\t\tif (groupBy === this._groupBy) return\n\n\t\tthis._groupBy = groupBy\n\t\tthis.fetchTab({ liveVisitors: false })\n\t}\n\tget groupBy() {\n\t\treturn this._groupBy\n\t}\n\n\tfetchTab({ liveVisitors = true }: { liveVisitors?: boolean } = {}) {\n\t\tconst tab = this._active?.tab ?? AnalyticsTabNames.overview\n\n\t\tswitch (tab) {\n\t\t\tcase AnalyticsTabNames.overview:\n\t\t\t\tthis.fetchEverything({ liveVisitors })\n\t\t\t\tbreak\n\t\t\tcase AnalyticsTabNames.funnel:\n\t\t\t\tvoid this.fetchFunnelDropOff()\n\t\t\t\tvoid this.fetchFunnelConversionRate()\n\t\t\t\tbreak\n\t\t\tcase AnalyticsTabNames.abtest: {\n\t\t\t\tvoid this.fetchAbTestStats()\n\t\t\t\tvoid this.fetchAbTestConversionRate()\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tfetchEverything({ liveVisitors = true }: { liveVisitors?: boolean } = {}) {\n\t\tvoid this.fetchSiteStats()\n\n\t\t// Session stats (bounce rate, avg session time) are not meaningful when filtering by tracking ID\n\t\tif (!this.filters.trackingId) {\n\t\t\tvoid this.fetchSession()\n\t\t}\n\n\t\tif (liveVisitors) void this.fetchLiveVisitors()\n\n\t\tvoid this.fetchAllTopFields()\n\t}\n\n\t#abortController = new AbortController()\n\tprivate reset() {\n\t\tthis._preset = defaultPreset\n\t\tthis.filters = {}\n\n\t\tthis.siteStatsLoading = false\n\t\tthis.siteStats = undefined\n\n\t\tthis.sessionLoading = false\n\t\tthis.session = undefined\n\n\t\tthis.liveVisitorsLoading = false\n\t\tthis.liveVisitors = undefined\n\n\t\tthis._sourcesSelectedFacet = defaultSourcesFacet\n\t\tthis.sourcesLoading = false\n\t\tthis.sources = undefined\n\n\t\tthis._pagesSelectedFacet = defaultPagesFacet\n\t\tthis.pagesLoading = false\n\t\tthis.pages = undefined\n\n\t\tthis._geographySelectedFacet = defaultGeographyFacet\n\t\tthis.geographyLoading = false\n\t\tthis.geography = undefined\n\n\t\tthis._devicesSelectedFacet = defaultDevicesFacet\n\t\tthis.devicesLoading = false\n\t\tthis.devices = undefined\n\n\t\tthis._trackingIdsSelectedFacet = defaultTrackingIdsFacet\n\t\tthis.trackingIdsLoading = false\n\t\tthis.trackingIds = undefined\n\n\t\tthis.funnelDropOffLoading = false\n\t\tthis.funnelDropOff = undefined\n\n\t\tthis.abTestStatsLoading = false\n\t\tthis.abTestStats = undefined\n\n\t\tthis.groupBy = undefined\n\n\t\tthis._abTestQuery = undefined\n\t\tthis._funnelQuery = undefined\n\n\t\t// Abort any in-progress requests.\n\t\tthis.#abortController.abort()\n\t\t// An aborted controller can't be re-used, so we create a new one for future requests.\n\t\tthis.#abortController = new AbortController()\n\t}\n\n\tprivate getOverviewParams(): AnalyticsOverviewParams {\n\t\tconst fromDay = this._fromDay\n\t\tconst toDay = this._toDay\n\t\tassert(fromDay !== undefined, \"fromDay is not set\")\n\t\tassert(toDay !== undefined, \"toDay is not set\")\n\t\treturn {\n\t\t\tfromDay,\n\t\t\ttoDay,\n\t\t\tfilters: this.filters,\n\t\t}\n\t}\n\n\tprivate getFunnelParams(): AnalyticsFunnelRequestParams {\n\t\tassert(this._funnelQuery, \"funnelQuery is not set\")\n\t\tconst fromDay = this._fromDay\n\t\tconst toDay = this._toDay\n\t\tassert(fromDay !== undefined, \"fromDay is not set\")\n\t\tassert(toDay !== undefined, \"toDay is not set\")\n\t\treturn {\n\t\t\tfromDay,\n\t\t\ttoDay,\n\t\t\tgroupBy: this._groupBy,\n\t\t\t...this._funnelQuery,\n\t\t}\n\t}\n\n\tprivate getAbTestParams(): AnalyticsAbTestRequestParams {\n\t\tassert(this._abTestQuery, \"abTestQuery is not set\")\n\t\treturn this._abTestQuery\n\t}\n\n\t/**\n\t * Fetches data using the given `requestFn`, while handling the loading state and aborting the request. If the\n\t * request doesn't get aborted, it'll call the `postProcessFn` with the response.\n\t */\n\tprivate async fetch<P, T>(\n\t\tloadingKey: LoadingKey | LoadingKey[],\n\t\tparams: P,\n\t\trequestFn: (projectId: string, params: P, signal: AbortSignal) => Promise<T>,\n\t\tpostProcessFn: (response: T) => void,\n\t) {\n\t\tconst loadingKeys = typeof loadingKey === \"string\" ? [loadingKey] : loadingKey\n\t\tfor (const key of loadingKeys) {\n\t\t\tthis[key] = true\n\t\t}\n\t\tconst signal = this.#abortController.signal\n\t\ttry {\n\t\t\tconst response = await requestFn(this.projectId, params, signal)\n\t\t\tif (!signal.aborted) {\n\t\t\t\tpostProcessFn(response)\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (error instanceof DOMException && error.name === \"AbortError\") {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthrow error\n\t\t} finally {\n\t\t\tif (!signal.aborted) {\n\t\t\t\tfor (const key of loadingKeys) {\n\t\t\t\t\tthis[key] = false\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tliveVisitorsLoading = false\n\tliveVisitors: number | undefined\n\tasync fetchLiveVisitors() {\n\t\treturn this.fetch(\"liveVisitorsLoading\", this.getOverviewParams(), fetchLiveVisitors, response => {\n\t\t\tthis.liveVisitors = response.liveSessions\n\t\t})\n\t}\n\n\tfunnelDropOffLoading = false\n\tfunnelDropOff: FunnelDropOffStep[] | undefined\n\tasync fetchFunnelDropOff() {\n\t\treturn this.fetch(\"funnelDropOffLoading\", this.getFunnelParams(), fetchFunnelDropOff, response => {\n\t\t\tthis.funnelDropOff = response ? Array.from(response.values())[0] : undefined\n\t\t})\n\t}\n\n\tfunnelConversionRateLoading = false\n\tfunnelConversionRate: FunnelConversionRatePoint[] | undefined\n\tasync fetchFunnelConversionRate() {\n\t\treturn this.fetch(\"funnelConversionRateLoading\", this.getFunnelParams(), fetchFunnelConversionRate, response => {\n\t\t\tthis.funnelConversionRate = response ? Array.from(response.values())[0] : undefined\n\t\t})\n\t}\n\n\tabTestStatsLoading = false\n\tabTestStats: AbTestDropOff | undefined\n\tasync fetchAbTestStats() {\n\t\treturn this.fetch(\"abTestStatsLoading\", this.getAbTestParams(), fetchAbTestDropOff, response => {\n\t\t\tthis.abTestStats = response\n\t\t})\n\t}\n\n\tabTestConversionRateLoading = false\n\tabTestConversionRate: readonly AbTestConversionRatePoint[] | undefined\n\tasync fetchAbTestConversionRate() {\n\t\treturn this.fetch(\"abTestConversionRateLoading\", this.getAbTestParams(), fetchAbTestConversionRate, response => {\n\t\t\tthis.abTestConversionRate = response\n\t\t})\n\t}\n\n\tsiteStatsLoading = false\n\tsiteStats:\n\t\t| { fromDay: string; toDay: string; stats: SiteStatPoint[]; totalPageviews: number; totalUniques: number }\n\t\t| undefined\n\tprivate fetchSiteStats() {\n\t\tconst params = this.getOverviewParams()\n\t\treturn this.fetch(\"siteStatsLoading\", params, fetchSiteStats, response => {\n\t\t\tthis.siteStats = {\n\t\t\t\tfromDay: params.fromDay,\n\t\t\t\ttoDay: params.toDay,\n\t\t\t\tstats: response.stats,\n\t\t\t\ttotalPageviews: response.totalPageviews ?? 0,\n\t\t\t\ttotalUniques: response.totalUniques ?? 0,\n\t\t\t}\n\t\t})\n\t}\n\n\tsessionLoading = false\n\tsession: SessionResponse | undefined\n\tprivate async fetchSession() {\n\t\treturn this.fetch(\"sessionLoading\", this.getOverviewParams(), fetchSessionStats, response => {\n\t\t\tthis.session = response\n\t\t})\n\t}\n\n\t/** Facet selected by the user. Might differ from the `sources.facet` while the new sources are still loading. */\n\tprivate _sourcesSelectedFacet: SourcesSectionKeys = defaultSourcesFacet\n\tset sourcesSelectedFacet(facet: SourcesSectionKeys) {\n\t\tthis._sourcesSelectedFacet = facet\n\t\tvoid this.fetchSources()\n\t}\n\tget sourcesSelectedFacet() {\n\t\treturn this._sourcesSelectedFacet\n\t}\n\n\tsourcesLoading = false\n\tsources: SourcesData | undefined\n\tprivate async fetchSources() {\n\t\tconst facet = this._sourcesSelectedFacet\n\t\treturn this.fetch(\n\t\t\t\"sourcesLoading\",\n\t\t\tthis.getOverviewParams(),\n\t\t\t(projectId, params, signal) => fetchTopField(projectId, facet, params, signal),\n\t\t\tresponse => {\n\t\t\t\tthis.sources = { facet, data: response[facet] ?? [] }\n\t\t\t},\n\t\t)\n\t}\n\n\t/** Facet selected by the user. Might differ from the `pages.facet` while the new pages are still loading. */\n\tprivate _pagesSelectedFacet: PagesSectionKeys = defaultPagesFacet\n\tset pagesSelectedFacet(facet: PagesSectionKeys) {\n\t\tthis._pagesSelectedFacet = facet\n\t\tvoid this.fetchPages()\n\t}\n\tget pagesSelectedFacet() {\n\t\treturn this._pagesSelectedFacet\n\t}\n\n\tpagesLoading = false\n\tpages: PagesData | undefined\n\tprivate async fetchPages() {\n\t\t// entryPage/exitPage don't make sense when filtering by tracking ID\n\t\tconst facet =\n\t\t\tthis.filters.trackingId && (this._pagesSelectedFacet === \"entryPage\" || this._pagesSelectedFacet === \"exitPage\")\n\t\t\t\t? \"pathname\"\n\t\t\t\t: this._pagesSelectedFacet\n\t\treturn this.fetch(\n\t\t\t\"pagesLoading\",\n\t\t\tthis.getOverviewParams(),\n\t\t\t(projectId, params, signal) => fetchTopField(projectId, facet, params, signal),\n\t\t\tresponse => {\n\t\t\t\tthis.pages = { facet, data: response[facet] ?? [] }\n\t\t\t},\n\t\t)\n\t}\n\n\t/** Facet selected by the user. Might differ from the `geography.facet` while the new geography data is still loading. */\n\tprivate _geographySelectedFacet: GeographySectionKeys = defaultGeographyFacet\n\tset geographySelectedFacet(facet: GeographySectionKeys) {\n\t\tthis._geographySelectedFacet = facet\n\t\tvoid this.fetchGeography()\n\t}\n\tget geographySelectedFacet() {\n\t\treturn this._geographySelectedFacet\n\t}\n\n\tgeographyLoading = false\n\tgeography: GeographyData | undefined\n\tprivate async fetchGeography() {\n\t\tconst facet = this._geographySelectedFacet\n\t\treturn this.fetch(\n\t\t\t\"geographyLoading\",\n\t\t\tthis.getOverviewParams(),\n\t\t\t(projectId, params, signal) => fetchTopField(projectId, facet, params, signal),\n\t\t\tresponse => {\n\t\t\t\tthis.geography = { facet, data: response[facet] ?? [] }\n\t\t\t},\n\t\t)\n\t}\n\n\t/** Facet selected by the user. Might differ from the `devices.facet` while the new devices are still loading. */\n\tprivate _devicesSelectedFacet: DevicesSectionKeys = defaultDevicesFacet\n\tset devicesSelectedFacet(facet: DevicesSectionKeys) {\n\t\tthis._devicesSelectedFacet = facet\n\t\tvoid this.fetchDevices()\n\t}\n\tget devicesSelectedFacet() {\n\t\treturn this._devicesSelectedFacet\n\t}\n\n\tdevicesLoading = false\n\tdevices: DevicesData | undefined\n\tprivate async fetchDevices() {\n\t\tconst facet = this._devicesSelectedFacet\n\t\treturn this.fetch(\n\t\t\t\"devicesLoading\",\n\t\t\tthis.getOverviewParams(),\n\t\t\t(projectId, params, signal) => fetchTopField(projectId, facet, params, signal),\n\t\t\tresponse => {\n\t\t\t\tthis.devices = { facet, data: response[facet] ?? [] }\n\t\t\t},\n\t\t)\n\t}\n\n\tprivate _trackingIdsSelectedFacet: TrackingIdsSectionKeys = defaultTrackingIdsFacet\n\tset trackingIdsSelectedFacet(facet: TrackingIdsSectionKeys) {\n\t\tthis._trackingIdsSelectedFacet = facet\n\t\tvoid this.fetchTrackingIds()\n\t}\n\tget trackingIdsSelectedFacet() {\n\t\treturn this._trackingIdsSelectedFacet\n\t}\n\n\ttrackingIdsLoading = false\n\ttrackingIds: TopFieldRow[] | undefined\n\tprivate async fetchTrackingIds() {\n\t\tconst facet = this._trackingIdsSelectedFacet\n\t\treturn this.fetch(\n\t\t\t\"trackingIdsLoading\",\n\t\t\tthis.getOverviewParams(),\n\t\t\t(projectId, params, signal) => fetchTopField(projectId, facet, params, signal),\n\t\t\tresponse => {\n\t\t\t\tthis.trackingIds = response[facet] ?? []\n\t\t\t},\n\t\t)\n\t}\n\n\tprivate async fetchAllTopFields() {\n\t\tconst sourcesFacet = this._sourcesSelectedFacet\n\t\t// entryPage/exitPage don't make sense when filtering by tracking ID\n\t\tconst pagesFacet =\n\t\t\tthis.filters.trackingId && (this._pagesSelectedFacet === \"entryPage\" || this._pagesSelectedFacet === \"exitPage\")\n\t\t\t\t? \"pathname\"\n\t\t\t\t: this._pagesSelectedFacet\n\t\tconst devicesFacet = this._devicesSelectedFacet\n\t\tconst geographyFacet = this._geographySelectedFacet\n\t\tconst trackingIdsFacet = this._trackingIdsSelectedFacet\n\n\t\tconst includePages = !(this.filters.collectionItemId || this.filters.routePath)\n\n\t\tconst names: TopFieldName[] = [sourcesFacet, devicesFacet, geographyFacet, trackingIdsFacet]\n\t\tif (includePages) names.push(pagesFacet)\n\n\t\tconst loadingKeys: LoadingKey[] = [\"sourcesLoading\", \"devicesLoading\", \"geographyLoading\", \"trackingIdsLoading\"]\n\t\tif (includePages) loadingKeys.push(\"pagesLoading\")\n\n\t\treturn this.fetch(\n\t\t\tloadingKeys,\n\t\t\tthis.getOverviewParams(),\n\t\t\t(projectId, params, signal) => fetchTopFields(projectId, names, params, signal),\n\t\t\tresponse => {\n\t\t\t\tthis.sources = { facet: sourcesFacet, data: response[sourcesFacet] ?? [] }\n\t\t\t\tif (includePages) {\n\t\t\t\t\tthis.pages = { facet: pagesFacet, data: response[pagesFacet] ?? [] }\n\t\t\t\t}\n\t\t\t\tthis.geography = { facet: geographyFacet, data: response[geographyFacet] ?? [] }\n\t\t\t\tthis.devices = { facet: devicesFacet, data: response[devicesFacet] ?? [] }\n\t\t\t\tthis.trackingIds = response[trackingIdsFacet] ?? []\n\t\t\t},\n\t\t)\n\t}\n}\n", "import type { LayoutMeasurement } from \"canvas-sandbox/layout-measuring/LayoutMeasureQueue.ts\"\nimport type { CanvasTree } from \"document/models/CanvasTree/CanvasTree.ts\"\nimport type { NodeChange } from \"document/models/CanvasTree/TreeDiff.ts\"\nimport type { NodeID } from \"document/models/CanvasTree/index.ts\"\nimport { isEqual } from \"library/index.ts\"\nimport { Rect } from \"library/render/types/Rect.ts\"\nimport type { Size } from \"library/render/types/Size.ts\"\nimport { type RenderId, getNodeIdFromRenderId } from \"./utils/RenderId.ts\"\n\nexport interface LayoutTemplateDOMInfo extends Rect {\n\toriginX?: number\n\toriginY?: number\n\tzIndex?: number\n\tmatrix?: DOMMatrixReadOnly\n}\n\nexport class LayoutCache {\n\tprivate readonly nodeIdToRenderIdToRect = new Map<NodeID, Map<RenderId, Rect>>()\n\tprivate readonly nodeIdToLayoutTemplateSelectorToRect = new Map<NodeID, Map<string, LayoutTemplateDOMInfo>>()\n\n\t// There's an overlap between content in this map and `nodeIdToRenderIdToRect`. The key\n\t// difference is that `nodeIdToRenderIdToChildrenRects` can contain information about _any_\n\t// child, including placeholders, which don't correspond to nodes in the tree.\n\tprivate readonly nodeIdToRenderIdToChildrenRects = new Map<NodeID, Map<RenderId, Rect[]>>()\n\n\tprocessLayoutMeasurements(layoutMeasurements: readonly LayoutMeasurement[]) {\n\t\tconst changedNodeIds = new Set<NodeID>()\n\t\tconst seen = new Set<NodeID>()\n\t\tfor (const { nodeId, renderId, layoutMetrics, layoutTemplateSelector } of layoutMeasurements) {\n\t\t\tconst { childrenRects, ...rect } = layoutMetrics\n\t\t\t// Clear out any layout template rects for the changed node as they\n\t\t\t// are now stale. We expect following entries in layoutMeasurements\n\t\t\t// to backfill them with accurate rects. @TODO - Try ensuring that\n\t\t\t// all selector measurements are in a single layoutMetrics payload\n\t\t\t// so we can safely replace if the values have changed.\n\t\t\tif (!seen.has(nodeId)) {\n\t\t\t\tthis.nodeIdToLayoutTemplateSelectorToRect.delete(nodeId)\n\t\t\t}\n\t\t\tseen.add(nodeId)\n\n\t\t\tconst previousRect = layoutTemplateSelector\n\t\t\t\t? this.nodeIdToLayoutTemplateSelectorToRect.get(nodeId)?.get(layoutTemplateSelector)\n\t\t\t\t: this.nodeIdToRenderIdToRect.get(nodeId)?.get(renderId)\n\t\t\tconst previousChildrenRects = this.nodeIdToRenderIdToChildrenRects.get(nodeId)?.get(renderId)\n\n\t\t\tif (isEqual(previousRect, rect, true) && childrenRectsSame(previousChildrenRects, childrenRects)) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif (layoutTemplateSelector) {\n\t\t\t\tconst layoutTemplateSelectorToRect =\n\t\t\t\t\tthis.nodeIdToLayoutTemplateSelectorToRect.get(nodeId) ?? new Map<string, LayoutTemplateDOMInfo>()\n\t\t\t\tconst matrix = rect.matrix ? DOMMatrixReadOnly.fromMatrix(rect.matrix) : undefined\n\t\t\t\tlayoutTemplateSelectorToRect.set(layoutTemplateSelector, { ...rect, matrix })\n\t\t\t\tthis.nodeIdToLayoutTemplateSelectorToRect.set(nodeId, layoutTemplateSelectorToRect)\n\t\t\t} else {\n\t\t\t\tconst renderIdToRect = this.nodeIdToRenderIdToRect.get(nodeId) ?? new Map<RenderId, Rect>()\n\t\t\t\trenderIdToRect.set(renderId, Rect.from(rect))\n\t\t\t\tthis.nodeIdToRenderIdToRect.set(nodeId, renderIdToRect)\n\t\t\t}\n\n\t\t\tif (childrenRects) {\n\t\t\t\tconst renderIdToChildrenRects = this.nodeIdToRenderIdToChildrenRects.get(nodeId) ?? new Map<RenderId, Rect[]>()\n\t\t\t\trenderIdToChildrenRects.set(renderId, childrenRects)\n\t\t\t\tthis.nodeIdToRenderIdToChildrenRects.set(nodeId, renderIdToChildrenRects)\n\t\t\t}\n\n\t\t\tchangedNodeIds.add(nodeId)\n\t\t}\n\n\t\treturn changedNodeIds\n\t}\n\n\t/**\n\t * Returns a rect that fits around all children rects of a node.\n\t * @param renderId the container node\n\t */\n\tgetContentSize(renderId: RenderId): Size | undefined {\n\t\tconst rect = this.getRect(renderId)\n\t\tconst childrenRects = this.getChildrenRects(renderId)\n\t\tif (!rect || !childrenRects) return\n\n\t\tconst { width, height } = Rect.merge(...childrenRects)\n\t\treturn { width, height }\n\t}\n\n\t/**\n\t * Returns the rect of a rendering as measured from the DOM.\n\t */\n\tgetRect(renderId: RenderId): Rect | undefined {\n\t\tconst nodeId = getNodeIdFromRenderId(renderId)\n\t\treturn this.nodeIdToRenderIdToRect.get(nodeId)?.get(renderId)\n\t}\n\n\t/**\n\t * Returns the rects of a node as measured from the DOM.\n\t */\n\tgetRects(nodeId: NodeID): Map<RenderId, Rect> | undefined {\n\t\treturn this.nodeIdToRenderIdToRect.get(nodeId)\n\t}\n\n\tgetLayoutTemplateRects(nodeId: NodeID): Map<string, LayoutTemplateDOMInfo> | undefined {\n\t\treturn this.nodeIdToLayoutTemplateSelectorToRect.get(nodeId)\n\t}\n\n\t/**\n\t * Returns the last-measured rects of all children of a node that should be considered for layout purposes. Node that\n\t * those children don't have to correspond to actual nodes in the tree. They may be the children of a code component,\n\t * placeholder nodes from stacks, etc.\n\t *\n\t * @param id the container node\n\t */\n\tgetChildrenRects(renderId: RenderId): Rect[] | undefined {\n\t\tconst nodeId = getNodeIdFromRenderId(renderId)\n\t\treturn this.nodeIdToRenderIdToChildrenRects.get(nodeId)?.get(renderId)\n\t}\n\n\t/**\n\t * Drops any `LayoutCache` entries that the tree change made stale, and\n\t * returns the node IDs that the caller still needs to clean up at the\n\t * `node.cache` layer because they were mutated outside the active scope.\n\t *\n\t * Out-of-scope mutations don't trigger a sandbox render +\n\t * `processLayoutMeasurements` pass, and `updateTreeCacheForVekter` is\n\t * normally invoked scoped to the active scope, so without this the\n\t * snapshot copied into `node.cache.domRects` keeps returning pre-edit\n\t * geometry from `getRawDOMRect` until the user navigates into the\n\t * affected scope.\n\t */\n\tpruneAfterTreeChanges(changes: NodeChange[], tree: CanvasTree, activeScopeId: NodeID): Set<NodeID> {\n\t\tconst outOfScopeMutatedNodeIds = new Set<NodeID>()\n\t\t// TODO removals might miss sub hierarchies, see also: https://github.com/framer/company/issues/26944\n\t\tfor (const change of changes) {\n\t\t\tif (change.removed) {\n\t\t\t\tthis.deleteAllRectsForNode(change.id)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconst parentsChanged = change.to.parentid && change.from?.parentid && change.to.parentid !== change.from.parentid\n\t\t\tif (parentsChanged) {\n\t\t\t\tthis.nodeIdToRenderIdToRect.delete(change.id)\n\t\t\t}\n\n\t\t\t// Check this even when the parent changed \u2014 moving a node from the\n\t\t\t// active scope into another scope (or between two non-active\n\t\t\t// scopes) needs the same snapshot invalidation as a plain\n\t\t\t// out-of-scope attribute mutation, otherwise `node.cache.domRects`\n\t\t\t// keeps the pre-move geometry until the destination scope is\n\t\t\t// opened.\n\t\t\tif (isMutatedOutsideActiveScope(tree, change.id, activeScopeId)) {\n\t\t\t\tthis.deleteAllRectsForNode(change.id)\n\t\t\t\toutOfScopeMutatedNodeIds.add(change.id)\n\t\t\t}\n\t\t}\n\t\treturn outOfScopeMutatedNodeIds\n\t}\n\n\tprivate deleteAllRectsForNode(nodeId: NodeID) {\n\t\tthis.nodeIdToRenderIdToRect.delete(nodeId)\n\t\tthis.nodeIdToRenderIdToChildrenRects.delete(nodeId)\n\t\tthis.nodeIdToLayoutTemplateSelectorToRect.delete(nodeId)\n\t}\n}\n\nfunction isMutatedOutsideActiveScope(tree: CanvasTree, nodeId: NodeID, activeScopeId: NodeID): boolean {\n\tconst node = tree.get(nodeId)\n\tif (!node) return false\n\tconst scope = tree.getScopeNodeFor(node)\n\treturn scope !== null && scope.id !== activeScopeId\n}\n\nfunction childrenRectsSame(previous?: Rect[], current?: readonly Rect[]) {\n\t// Takes care of the case when both previous and current children are\n\t// undefined (the node remained without any measured children)\n\tif (previous === current) return true\n\n\t// Went from no children to one or more, or the reverse\n\tif (previous === undefined || current === undefined) return false\n\n\t// Changed number of children\n\tif (previous.length !== current.length) return false\n\n\t// Same number of children, so we need to check individual rects for equality\n\treturn current.every((rect, index) => Rect.equals(rect, previous[index] ?? null))\n}\n", "import { appAccelerators, appAcceleratorsWindows } from \"app/AppAccelerators.ts\"\nimport type { MenuItemOptions } from \"app/menu.ts\"\nimport { EngineStore } from \"document/EngineStore.ts\"\nimport { validateAction } from \"document/components/actions/ActionResponder.tsx\"\nimport { getContextMenuItemsWithPath } from \"document/utils/getContextMenuItemsWithPath.ts\"\nimport type { ContextMenuState, MenuConfig } from \"menu/ContextMenu.tsx\"\n\nexport class ContextMenuStore extends EngineStore {\n\tmenu: ContextMenuState | null = null\n\tisOpen: boolean = false\n\n\tshow(items: readonly MenuItemOptions[], config: MenuConfig, validation: \"validate\" | \"skipValidation\" = \"validate\") {\n\t\tthis.menu = { items: this.getProcessedItems(items, validation), config, startTime: performance.now() }\n\t\tthis.isOpen = true\n\t}\n\n\tupdateItems(items: readonly MenuItemOptions[], validation: \"validate\" | \"skipValidation\" = \"validate\") {\n\t\tif (!this.menu) return\n\t\tthis.menu = { ...this.menu, items: this.getProcessedItems(items, validation) }\n\t}\n\n\tclose() {\n\t\tthis.scheduler.processWhenReady(() => {\n\t\t\tif (!this.menu) return\n\t\t\tthis.menu.config.onDone?.()\n\t\t\tthis.menu.config.onCancel?.()\n\t\t\tthis.menu = null\n\t\t\tthis.isOpen = false\n\t\t})\n\t}\n\n\tprivate getProcessedItems(\n\t\titems: readonly MenuItemOptions[],\n\t\tvalidation: \"validate\" | \"skipValidation\",\n\t): ContextMenuState[\"items\"] {\n\t\treturn getContextMenuItemsWithPath(\n\t\t\titems,\n\t\t\tvalidation === \"validate\"\n\t\t\t\t? {\n\t\t\t\t\t\tvalidateAction,\n\t\t\t\t\t\tappAccelerators,\n\t\t\t\t\t\tappAcceleratorsWindows,\n\t\t\t\t\t}\n\t\t\t\t: null,\n\t\t)\n\t}\n}\n", "import type { GlobalModuleId } from \"@framerjs/shared\"\nimport { ModuleType, ResolvablePromise } from \"@framerjs/shared\"\nimport type { VectorColor } from \"code-generation/utils/annotations.ts\"\nimport { EngineStore } from \"document/EngineStore.ts\"\nimport type { NodeID } from \"document/models/CanvasTree/index.ts\"\nimport { splitTypeSlashName } from \"modules/utils.ts\"\nimport type { ModulesStore } from \"./ModulesStore.ts\"\n\nexport interface CachedVector {\n\tsvg: string\n\tcolor?: VectorColor\n}\n\n/**\n * Allows reading transient SVG icons before they are compiled or persisted to the service.\n */\nexport class VectorsStore extends EngineStore {\n\t#svgs = new Map<NodeID, CachedVector>()\n\t#pending = new Map<NodeID, ResolvablePromise<CachedVector>>()\n\n\tprivate _forceUpdate = 0\n\n\tconstructor(private readonly modulesStore: ModulesStore) {\n\t\tsuper()\n\t}\n\n\tprivate rerender() {\n\t\tthis._forceUpdate++\n\t}\n\n\t/**\n\t * Mark that a vector is about to be code-generated. This allows the editor to avoid hitting the\n\t * modules service to fetch an icon that will be stale shortly after. Instead wait for the icon\n\t * to be serialized in memory.\n\t */\n\tqueue(id: NodeID) {\n\t\tif (this.#pending.has(id)) return\n\t\tconst promise = new ResolvablePromise<CachedVector>()\n\t\tthis.#pending.set(id, promise)\n\t\tthis.rerender()\n\t}\n\n\tcache(id: NodeID, cachedVector: { svg: string; color?: VectorColor }) {\n\t\tconst promise = this.#pending.get(id)\n\t\tif (promise) promise.resolve(cachedVector)\n\t\tthis.#pending.delete(id)\n\t\tthis.#svgs.set(id, cachedVector)\n\t\tthis.rerender()\n\t}\n\n\t/**\n\t * When a vector is local, allows reading the transient SVG icon before its been compiled and\n\t * until it is persisted to the service.\n\t */\n\tgetByGlobalId(moduleId: GlobalModuleId) {\n\t\tconst localModule = this.modulesStore.getPersistedModuleByGlobalId(moduleId)\n\t\tif (!localModule) return\n\t\tconst id = splitTypeSlashName(localModule.localId)[1]\n\n\t\t// If the vector is queued, return a promise that will resolve when the vector is cached.\n\t\tconst promise = this.#pending.get(id)\n\t\tif (promise) return promise\n\n\t\t// If the vector is cached, return it.\n\t\tconst cached = this.#svgs.get(id)\n\t\tif (cached) return cached\n\n\t\t// If the vector is local, return the transient SVG icon.\n\t\tconst transient = this.modulesStore.forType(ModuleType.Vector).getByStableName(id)?.transientSVGIcon\n\t\tif (transient) return { svg: transient }\n\n\t\t// Otherwise the vector is not transient and we should fetch its svg icon file from the\n\t\t// service.\n\t}\n\n\tdelete(id: NodeID) {\n\t\tthis.#svgs.delete(id)\n\t\tthis.rerender()\n\t}\n}\n", "import { Mixed, isMixed } from \"@framerjs/shared\"\nimport { isDefined, isNumber, isUndefined } from \"utils/typeChecks.ts\"\nimport type { CanvasNode } from \"../../nodes/CanvasNode.ts\"\nimport type { OpenTypeFontFeatures } from \"../../utils/openType.ts\"\nimport { isOpenTypeFeatureTag } from \"../../utils/openType.ts\"\nimport type { VariationAxisTag } from \"../../utils/variableFont.ts\"\nimport type { FontSize, FontSizeUnit } from \"../WithTextStyle.ts\"\nimport type { WithFormInputFontStyles } from \"../forms/WithFormInputTextStyles.ts\"\nimport { withFormInputFontStyles } from \"../forms/WithFormInputTextStyles.ts\"\nimport { parseCSSDimension } from \"./CSSDimension.ts\"\nimport type { NotFound, Reduced, ReducedRecord } from \"./Reduced.ts\"\nimport { isFound, isNotFound } from \"./Reduced.ts\"\nimport { reduceProperty, valuesAreDifferent } from \"./reduceProperty.ts\"\nimport type { FontSelectors, ReducedFontVariationAxes, ReducedOpenTypeFontFeatures } from \"./reduceText.ts\"\n\nexport type ReducedFormInputFontSelectors = FontSelectors | NotFound\n\nexport type ReducedFormInputOpenTypeFontFeatures = ReducedOpenTypeFontFeatures | NotFound\n\nexport type ReducedFormInputVariationAxes = ReducedFontVariationAxes | NotFound\n\nexport interface ReducedFormInputFontStyles extends Omit<\n\tReducedRecord<WithFormInputFontStyles>,\n\t\"formInputFontSize\" | \"formInputFontSelector\" | \"formInputOpenTypeFontFeatures\" | \"formInputVariationAxes\"\n> {\n\tformInputFontSize: Reduced<number>\n\tformInputFontSizeUnit: Reduced<FontSizeUnit>\n\tonlyNodesWithFormInputFontStyles: boolean\n\tformInputFontSelector: ReducedFormInputFontSelectors\n\tformInputOpenTypeFontFeatures: ReducedFormInputOpenTypeFontFeatures\n\tformInputVariationAxes: ReducedFormInputVariationAxes\n}\n\nexport function reduceFormInputFontStyles(node: CanvasNode, result: ReducedFormInputFontStyles) {\n\tif (!withFormInputFontStyles(node)) {\n\t\tresult.onlyNodesWithFormInputFontStyles = false\n\t\treturn\n\t}\n\n\t// Form input styles\n\treduceProperty(\"formInputFontFamily\", result, node)\n\treduceFormInputFontSize(result, node)\n\treduceProperty(\"formInputFontColor\", result, node)\n\treduceProperty(\"formInputFontWeight\", result, node)\n\treduceProperty(\"formInputFontStyle\", result, node)\n\treduceProperty(\"formInputFontLineHeight\", result, node)\n\treduceProperty(\"formInputFontLineHeightUnit\", result, node)\n\treduceProperty(\"formInputFontTextAlignment\", result, node)\n\treduceProperty(\"formInputFontLetterSpacing\", result, node)\n\treduceProperty(\"formInputFontLetterSpacingUnit\", result, node)\n\n\t// Font selector\n\tif (isNotFound(result.formInputFontSelector)) {\n\t\t// Trait is supported so let's initialize the input form font selector\n\t\tresult.formInputFontSelector = new Set()\n\t}\n\n\tif (isDefined(node.formInputFontSelector)) {\n\t\tresult.formInputFontSelector.add(node.formInputFontSelector)\n\t}\n\n\t// Open Type font features\n\tresult.formInputOpenTypeFontFeatures = reduceFormInputOpenTypeFontFeatures(\n\t\tresult.formInputOpenTypeFontFeatures,\n\t\tnode.formInputOpenTypeFontFeatures,\n\t)\n\n\t// Variable font variation settings\n\tresult.formInputVariationAxes = reduceFormInputVariationAxes(\n\t\tresult.formInputVariationAxes,\n\t\tnode.formInputVariationAxes,\n\t)\n}\n\nfunction reduceFormInputFontSize(result: ReducedFormInputFontStyles, node: CanvasNode & WithFormInputFontStyles) {\n\tconst reducedFontSize = result.formInputFontSize\n\tconst reducedFontSizeUnit = result.formInputFontSizeUnit\n\tif (isMixed(reducedFontSize) && isMixed(reducedFontSizeUnit)) return\n\tif (isUndefined(node.formInputFontSize)) return\n\n\tconst [size, unit] = isNumber(node.formInputFontSize)\n\t\t? ([node.formInputFontSize, \"px\"] satisfies FontSize)\n\t\t: parseCSSDimension(node.formInputFontSize)\n\n\tif (isNotFound(reducedFontSizeUnit)) {\n\t\tresult.formInputFontSizeUnit = unit\n\t} else if (valuesAreDifferent(unit, reducedFontSizeUnit)) {\n\t\tresult.formInputFontSizeUnit = Mixed\n\t\t// If the units are not the same, we must set font size to Mixed\n\t\t// as the numbers have different semantic meanings.\n\t\tresult.formInputFontSize = Mixed\n\t\treturn\n\t}\n\tif (isNotFound(reducedFontSize)) {\n\t\tresult.formInputFontSize = size\n\t} else if (valuesAreDifferent(size, reducedFontSize)) {\n\t\tresult.formInputFontSize = Mixed\n\t}\n}\n\nexport function reduceFormInputOpenTypeFontFeatures(\n\treduced: ReducedOpenTypeFontFeatures | NotFound,\n\tcurrent: OpenTypeFontFeatures | undefined,\n): ReducedOpenTypeFontFeatures {\n\tconst remainingOpenTypeFontFeatures = new Set(\n\t\tisFound(reduced) ? (Object.keys(reduced) as OpenTypeFontFeatures) : undefined,\n\t)\n\tconst currentOpenTypeFontFeatures = current ?? []\n\n\tconst features: ReducedOpenTypeFontFeatures = isFound(reduced) ? reduced : {}\n\tfor (const feature of currentOpenTypeFontFeatures) {\n\t\tif (!isOpenTypeFeatureTag(feature)) continue\n\n\t\tconst reducedFeatureValue = features[feature]\n\t\tif (isUndefined(reducedFeatureValue)) {\n\t\t\tfeatures[feature] = isFound(reduced) ? Mixed : true\n\t\t}\n\n\t\tremainingOpenTypeFontFeatures.delete(feature)\n\t}\n\n\t// If there are any features that were recorded by previous\n\t// nodes, but not this one, that means they are all Mixed now.\n\tfor (const feature of remainingOpenTypeFontFeatures) {\n\t\tif (isOpenTypeFeatureTag(feature)) {\n\t\t\tfeatures[feature] = Mixed\n\t\t}\n\t}\n\n\treturn features\n}\n\nexport function reduceFormInputVariationAxes(\n\treduced: ReducedFormInputVariationAxes,\n\tcurrent: Record<VariationAxisTag, number> | undefined,\n): ReducedFontVariationAxes {\n\tconst axes: ReducedFontVariationAxes = isFound(reduced) ? reduced : {}\n\tconst remainingVariationAxes = new Set(Object.keys(axes))\n\n\tif (isDefined(current)) {\n\t\tfor (const axisKey in current) {\n\t\t\tconst currentValue = axes[axisKey]\n\t\t\tremainingVariationAxes.delete(axisKey)\n\n\t\t\tif (isMixed(currentValue)) continue\n\t\t\tif (isUndefined(currentValue)) {\n\t\t\t\taxes[axisKey] = current[axisKey]\n\t\t\t} else if (currentValue !== current[axisKey]) {\n\t\t\t\taxes[axisKey] = Mixed\n\t\t\t}\n\t\t}\n\t}\n\n\t// If there are any features that were recorded by previous\n\t// nodes, but not this one, that means they are all Mixed.\n\tfor (const tag of remainingVariationAxes) {\n\t\taxes[tag] = Mixed\n\t}\n\n\treturn axes\n}\n", "import type {\n\tVerifiedArrayItemControlDescription,\n\tVerifiedControlDescription,\n\tVerifiedObjectPropertyControlDescription,\n\tVerifiedPropertyControls,\n} from \"@framerjs/framer-runtime\"\nimport { assert, Mixed, type ModuleExportIdentifierString, assertNever, isMixed, shouldBeNever } from \"@framerjs/shared\"\nimport type {\n\tArrayItemControlDescription,\n\tObjectPropertyControlDescription,\n\tResponsiveImageControlDescription,\n} from \"library/render/types/PropertyControls.ts\"\nimport { ControlType } from \"library/render/types/PropertyControls.ts\"\nimport type { RelativeNumber } from \"library/render/types/RelativeNumber.ts\"\nimport { isEqual } from \"library/render/utils/isEqual.ts\"\nimport type { Mutable } from \"utils/Mutable.ts\"\nimport { isNull, isString, isUndefined } from \"utils/typeChecks.ts\"\nimport { type ComputedValue, isComputedValue } from \"../CanvasTree/traits/ComputedValue.ts\"\nimport { isDynamicValue } from \"../CanvasTree/traits/DynamicValue.ts\"\nimport {\n\tgetNumericColumnGapFromShorthand,\n\tgetNumericRowGapFromShorthand,\n} from \"../CanvasTree/traits/NumberShorthand.ts\"\nimport type { VariableReference } from \"../CanvasTree/traits/VariableReference.ts\"\nimport type { BorderValues } from \"../CanvasTree/traits/WithBorder.ts\"\nimport {\n\ttype FontSizeUnit,\n\ttype LetterSpacingUnit,\n\ttype LineHeightUnit,\n\ttype TextAlignment,\n\tisFontSizeCSSDimension,\n} from \"../CanvasTree/traits/WithTextStyle.ts\"\nimport { parseCSSDimension } from \"../CanvasTree/traits/utils/CSSDimension.ts\"\nimport { isLinkEqual } from \"../CanvasTree/traits/utils/Link.ts\"\nimport type { Reduced, ReducedRecord } from \"../CanvasTree/traits/utils/Reduced.ts\"\nimport { NotFound, isFound, isNotFound } from \"../CanvasTree/traits/utils/Reduced.ts\"\nimport {\n\treduceFormInputOpenTypeFontFeatures,\n\treduceFormInputVariationAxes,\n} from \"../CanvasTree/traits/utils/reduceFormInputStyles.ts\"\nimport { valuesAreDifferent } from \"../CanvasTree/traits/utils/reduceProperty.ts\"\nimport type { ReducedShadowList } from \"../CanvasTree/traits/utils/reduceShadows.ts\"\nimport { reduceShadowList } from \"../CanvasTree/traits/utils/reduceShadows.ts\"\nimport type {\n\tFontSelectors,\n\tReducedFontVariationAxes,\n\tReducedOpenTypeFontFeatures,\n} from \"../CanvasTree/traits/utils/reduceText.ts\"\nimport { isOpenTypeFeatureTag } from \"../CanvasTree/utils/openType.ts\"\nimport type {\n\tArrayValue,\n\tBooleanControlPropValue,\n\tBorderRadiusControlPropValue,\n\tCollectionReferenceControlPropValue,\n\tColorControlPropValue,\n\tControlProp,\n\tControlProps,\n\tCursorControlPropValue,\n\tCustomCursorControlPropValue,\n\tDateControlPropValue,\n\tEnumControlPropValue,\n\tFileControlPropValue,\n\tGapControlPropValue,\n\tImageControlProp,\n\tImageControlPropValue,\n\tLinkControlPropValue,\n\tLinkRelValuesControlPropValue,\n\tLocationControlPropValue,\n\tMultiCollectionReferenceControlPropValue,\n\tNumberControlPropValue,\n\tPaddingControlPropValue,\n\tPageScopeControlPropValue,\n\tRichTextControlPropValue,\n\tScrollSectionRefControlPropValue,\n\tSlotControlItem,\n\tStringControlPropValue,\n\tTrackingIdControlPropValue,\n\tTransitionControlPropValue,\n} from \"./ControlProp.ts\"\n\nexport interface ReducedArrayControlProp {\n\ttype: ControlType.Array\n\tvalue: Reduced<readonly ReducedArrayItemControlProp[] | ComputedValue>\n}\n\nexport interface ReducedBooleanControlProp {\n\ttype: ControlType.Boolean\n\tvalue: Reduced<BooleanControlPropValue>\n}\n\nexport interface ReducedColorControlProp {\n\ttype: ControlType.Color\n\tvalue: Reduced<ColorControlPropValue>\n}\n\nexport interface ReducedDateControlProp {\n\ttype: ControlType.Date\n\tvalue: Reduced<DateControlPropValue>\n}\n\nexport interface ReducedEnumControlProp {\n\ttype: ControlType.Enum\n\tvalue: Reduced<EnumControlPropValue>\n}\n\nexport interface ReducedFileControlProp {\n\ttype: ControlType.File\n\tvalue: Reduced<FileControlPropValue>\n}\n\nexport interface ReducedFusedNumberControlProp {\n\ttype: ControlType.FusedNumber\n\tsingle: Reduced<number>\n\tfused: [Reduced<number>, Reduced<number>, Reduced<number>, Reduced<number>]\n\tisFused: Reduced<boolean>\n}\n\nexport interface ReducedLinkControlProp {\n\ttype: ControlType.Link\n\tvalue: Reduced<LinkControlPropValue>\n}\n\nexport interface ReducedLinkRelValuesControlProp {\n\ttype: ControlType.LinkRelValues\n\tvalue: Reduced<LinkRelValuesControlPropValue>\n}\n\nexport interface ReducedNumberControlProp {\n\ttype: ControlType.Number\n\tvalue: Reduced<NumberControlPropValue>\n}\n\nexport interface ReducedObjectControlProp {\n\ttype: ControlType.Object\n\tvalue: Reduced<Record<string, ReducedObjectPropertyControlProp> | null>\n}\n\nexport interface ReducedRichTextControlProp {\n\ttype: ControlType.RichText\n\tvalue: Reduced<RichTextControlPropValue>\n}\n\nexport interface ReducedStringControlProp {\n\ttype: ControlType.String\n\tvalue: Reduced<StringControlPropValue>\n}\n\nexport interface ReducedImageControlProp {\n\ttype: ControlType.Image\n\tvalue: Reduced<ImageControlPropValue>\n}\n\nexport interface ReducedTransitionControlProp {\n\ttype: ControlType.Transition\n\tvalue: Reduced<TransitionControlPropValue>\n}\n\nexport interface ReducedBorderControlProp {\n\ttype: ControlType.Border\n\tvalue: VariableReference | ReducedRecord<BorderValues> | null | NotFound\n}\n\nexport interface ReducedBoxShadowControlProp {\n\ttype: ControlType.BoxShadow\n\tvalue: ReducedShadowList\n}\n\nexport interface ReducedResponsiveImageControlProp {\n\ttype: ControlType.ResponsiveImage\n\tvalue: Reduced<ImageControlPropValue>\n\talt: Reduced<string>\n\tpositionX: Reduced<RelativeNumber | undefined>\n\tpositionY: Reduced<RelativeNumber | undefined>\n}\n\nexport type ReducedFontValue = Reduced<\n\t| undefined\n\t| {\n\t\t\tfontSelector: FontSelectors\n\t\t\tfontSizeValue: Reduced<number | undefined>\n\t\t\tfontSizeUnits: Set<FontSizeUnit>\n\t\t\tlineHeightValue: Reduced<number | undefined>\n\t\t\tlineHeightUnits: Set<LineHeightUnit | undefined>\n\t\t\ttextAlignment: Reduced<TextAlignment | undefined>\n\t\t\tletterSpacingValue: Reduced<number | undefined>\n\t\t\tletterSpacingUnits: Set<LetterSpacingUnit | undefined>\n\t\t\topenTypeFontFeatures: ReducedOpenTypeFontFeatures\n\t\t\tvariationAxes: ReducedFontVariationAxes\n\t  }\n>\n\nexport interface ReducedFontControlProp {\n\ttype: ControlType.Font\n\tvalue: ReducedFontValue\n}\n\nexport interface ReducedPageScopeControlProp {\n\ttype: ControlType.PageScope\n\tvalue: Reduced<PageScopeControlPropValue>\n}\nexport interface ReducedScrollSectionRefControlProps {\n\ttype: ControlType.ScrollSectionRef\n\tvalue: Reduced<ScrollSectionRefControlPropValue>\n}\n\nexport interface ReducedCustomCursorControlProps {\n\ttype: ControlType.CustomCursor\n\tvalue: Reduced<CustomCursorControlPropValue>\n}\n\nexport interface ReducedCursorControlProps {\n\ttype: ControlType.Cursor\n\tvalue: Reduced<CursorControlPropValue>\n}\n\nexport interface ReducedGapControlProp {\n\ttype: ControlType.Gap\n\tvalue: Reduced<GapControlPropValue>\n\tcolumnGap: Reduced<number>\n\trowGap: Reduced<number>\n}\n\nexport interface ReducedPaddingControlProp {\n\ttype: ControlType.Padding\n\tvalue: Reduced<PaddingControlPropValue>\n}\n\nexport interface ReducedBorderRadiusControlProp {\n\ttype: ControlType.BorderRadius\n\tvalue: Reduced<BorderRadiusControlPropValue>\n}\n\nexport interface ReducedCollectionReferenceControlProp {\n\ttype: ControlType.CollectionReference\n\tvalue: Reduced<CollectionReferenceControlPropValue>\n}\n\nexport interface ReducedMultiCollectionReferenceControlProp {\n\ttype: ControlType.MultiCollectionReference\n\tvalue: Reduced<MultiCollectionReferenceControlPropValue>\n}\n\nexport interface ReducedTrackingIdControlProp {\n\ttype: ControlType.TrackingId\n\tvalue: Reduced<TrackingIdControlPropValue>\n\ttrackingIdAIPrompt: Reduced<string>\n}\n\nexport interface ReducedVectorSetItemControlProp {\n\ttype: ControlType.VectorSetItem\n\tvalue: Reduced<ModuleExportIdentifierString | VariableReference>\n}\n\nexport interface ReducedLocationControlProp {\n\ttype: ControlType.Location\n\tvalue: Reduced<LocationControlPropValue>\n\ttitle: Reduced<string | undefined>\n\taddress: Reduced<string | undefined>\n}\n\nexport interface ReducedSlotControlProp {\n\ttype: ControlType.Slot\n\tvalue: Reduced<readonly SlotControlItem[]>\n}\n\nexport type ReducedControlProp =\n\t| ReducedArrayControlProp\n\t| ReducedBooleanControlProp\n\t| ReducedColorControlProp\n\t| ReducedSlotControlProp\n\t| ReducedDateControlProp\n\t| ReducedEnumControlProp\n\t| ReducedFileControlProp\n\t| ReducedFusedNumberControlProp\n\t| ReducedLinkControlProp\n\t| ReducedLinkRelValuesControlProp\n\t| ReducedNumberControlProp\n\t| ReducedObjectControlProp\n\t| ReducedRichTextControlProp\n\t| ReducedStringControlProp\n\t| ReducedTransitionControlProp\n\t| ReducedBoxShadowControlProp\n\t| ReducedImageControlProp\n\t| ReducedResponsiveImageControlProp\n\t| ReducedFontControlProp\n\t| ReducedPageScopeControlProp\n\t| ReducedScrollSectionRefControlProps\n\t| ReducedCustomCursorControlProps\n\t| ReducedBorderControlProp\n\t| ReducedCursorControlProps\n\t| ReducedGapControlProp\n\t| ReducedPaddingControlProp\n\t| ReducedBorderRadiusControlProp\n\t| ReducedCollectionReferenceControlProp\n\t| ReducedMultiCollectionReferenceControlProp\n\t| ReducedTrackingIdControlProp\n\t| ReducedVectorSetItemControlProp\n\t| ReducedLocationControlProp\n\nexport type ReducedArrayItemControlProp = Extract<ReducedControlProp, { type: ArrayItemControlDescription[\"type\"] }> & {\n\tid: string\n}\n\ntype ReducedObjectPropertyControlProp = Extract<ReducedControlProp, { type: ObjectPropertyControlDescription[\"type\"] }>\n\nexport type ReducedControlProps = Readonly<Record<string, ReducedControlProp>>\n\nexport const allBorderPropsMixed: ReducedRecord<BorderValues> = {\n\tborderBottom: Mixed,\n\tborderLeft: Mixed,\n\tborderRight: Mixed,\n\tborderTop: Mixed,\n\tborderWidth: Mixed,\n\tborderColor: Mixed,\n\tborderStyle: Mixed,\n\tborderPerSide: Mixed,\n}\n\nfunction getReducedValue<T>(value: T, reducedValue: Reduced<T>): Reduced<T> {\n\tif (isMixed(reducedValue)) {\n\t\treturn Mixed\n\t}\n\tif (isNotFound(reducedValue)) {\n\t\treturn value\n\t}\n\tif (valuesAreDifferent(value, reducedValue)) {\n\t\treturn Mixed\n\t}\n\treturn value\n}\n\nfunction getReducedMultiCollectionReference<T extends MultiCollectionReferenceControlPropValue>(\n\tvalue: T,\n\treducedValue: Reduced<T>,\n): Reduced<T> {\n\tif (isMixed(reducedValue)) {\n\t\treturn Mixed\n\t}\n\tif (isNotFound(reducedValue)) {\n\t\treturn value\n\t}\n\tif (!isEqual(value, reducedValue)) {\n\t\treturn Mixed\n\t}\n\treturn value\n}\n\nfunction getReducedArrayValue<T extends ArrayItemControlDescription[\"type\"]>(\n\treducedItems: Reduced<readonly Extract<ReducedArrayItemControlProp, { type: T }>[]>,\n\titems: readonly Extract<ArrayValue, { type: T }>[],\n\titemControl: VerifiedArrayItemControlDescription | Extract<VerifiedControlDescription, { type: ControlType.Slot }>,\n): readonly Extract<ReducedArrayItemControlProp, { type: T }>[] | Mixed {\n\tassert(isFound(reducedItems))\n\tif (isMixed(reducedItems)) return Mixed\n\tif (reducedItems.length !== items.length) return Mixed\n\treducedItems.forEach((reducedItem, index) => {\n\t\tconst item = items[index]\n\t\tassert(item)\n\t\tconst arrayItemType = reducedItem.type\n\t\tswitch (arrayItemType) {\n\t\t\tcase ControlType.Boolean:\n\t\t\tcase ControlType.Color:\n\t\t\tcase ControlType.Date:\n\t\t\tcase ControlType.Enum:\n\t\t\tcase ControlType.File:\n\t\t\tcase ControlType.Link:\n\t\t\tcase ControlType.Number:\n\t\t\tcase ControlType.Object:\n\t\t\tcase ControlType.RichText:\n\t\t\tcase ControlType.String:\n\t\t\tcase ControlType.Transition:\n\t\t\tcase ControlType.Image:\n\t\t\tcase ControlType.ResponsiveImage:\n\t\t\tcase ControlType.ScrollSectionRef:\n\t\t\tcase ControlType.CustomCursor:\n\t\t\tcase ControlType.Border:\n\t\t\tcase ControlType.Cursor:\n\t\t\tcase ControlType.Location:\n\t\t\t\treduceControlProp(reducedItem, item, itemControl)\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\tassertNever(arrayItemType)\n\t\t}\n\t})\n\treturn reducedItems\n}\n\nexport function reduceControlProp(\n\treducedControlProp: ReducedControlProp,\n\tcontrolProp: ControlProp,\n\tcontrol: VerifiedControlDescription,\n): void {\n\tswitch (reducedControlProp.type) {\n\t\tcase ControlType.Array: {\n\t\t\tassert(controlProp.type === ControlType.Array)\n\t\t\tassert(control.type === ControlType.Array)\n\t\t\tif (isMixed(reducedControlProp.value)) break\n\t\t\tif (isNotFound(reducedControlProp.value)) {\n\t\t\t\tif (isComputedValue(controlProp.value)) {\n\t\t\t\t\treducedControlProp.value = controlProp.value\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t// Sets everything to NotFound, so we don't break after setting this\n\t\t\t\treducedControlProp.value = controlProp.value.map(item => {\n\t\t\t\t\treturn getReducedArrayItemControlProp(control.control, item.id)\n\t\t\t\t})\n\t\t\t}\n\t\t\tif (isComputedValue(controlProp.value)) {\n\t\t\t\treducedControlProp.value = getReducedValue(controlProp.value, reducedControlProp.value)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (isComputedValue(reducedControlProp.value)) {\n\t\t\t\treducedControlProp.value = Mixed\n\t\t\t\tbreak\n\t\t\t}\n\t\t\treducedControlProp.value = getReducedArrayValue(reducedControlProp.value, controlProp.value, control.control)\n\t\t\tbreak\n\t\t}\n\t\tcase ControlType.Slot: {\n\t\t\tassert(controlProp.type === reducedControlProp.type)\n\t\t\tif (isMixed(reducedControlProp.value)) break\n\t\t\tassert(control.type === ControlType.Slot)\n\t\t\tassert(!isDynamicValue(controlProp.value), \"Slots don't support dynamic values\")\n\n\t\t\tif (isNotFound(reducedControlProp.value)) {\n\t\t\t\treducedControlProp.value = controlProp.value\n\t\t\t} else {\n\t\t\t\t// We only render the slot UI for single selected nodes because potential circular\n\t\t\t\t// references are expensive to calculate. When multiple nodes are found the reduced\n\t\t\t\t// control becomes Mixed. In which case we won't render the UI.\n\t\t\t\treducedControlProp.value = Mixed\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\tcase ControlType.Object:\n\t\t\tassert(controlProp.type === reducedControlProp.type)\n\t\t\tif (isMixed(reducedControlProp.value)) break\n\t\t\tassert(control.type === ControlType.Object)\n\n\t\t\tif (isNotFound(reducedControlProp.value)) {\n\t\t\t\tif (controlProp.value === null) {\n\t\t\t\t\treducedControlProp.value = null\n\t\t\t\t} else {\n\t\t\t\t\treducedControlProp.value = {}\n\t\t\t\t\tfor (const key in control.controls) {\n\t\t\t\t\t\tconst objectPropertyControl = control.controls[key]\n\t\t\t\t\t\tassert(objectPropertyControl)\n\t\t\t\t\t\tconst reducedControl = getReducedObjectPropertyControlProp(objectPropertyControl)\n\t\t\t\t\t\tif (!reducedControl) continue\n\t\t\t\t\t\treducedControlProp.value[key] = reducedControl\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (reducedControlProp.value === null || controlProp.value === null) {\n\t\t\t\tif (reducedControlProp.value !== controlProp.value) {\n\t\t\t\t\treducedControlProp.value = Mixed\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tfor (const key in reducedControlProp.value) {\n\t\t\t\tconst objectPropertyControl = control.controls[key]\n\t\t\t\tassert(objectPropertyControl)\n\t\t\t\tconst reducedObjectPropertyControlProp = reducedControlProp.value[key]\n\t\t\t\tassert(reducedObjectPropertyControlProp)\n\t\t\t\tconst objectPropertyControlProp = controlProp.value[key]\n\t\t\t\tassert(\n\t\t\t\t\tobjectPropertyControlProp,\n\t\t\t\t\t\"getControlProps(), should have added these if they were missing from the document data\",\n\t\t\t\t)\n\t\t\t\treduceControlProp(reducedObjectPropertyControlProp, objectPropertyControlProp, objectPropertyControl)\n\t\t\t}\n\t\t\tbreak\n\t\tcase ControlType.Transition:\n\t\t\tassert(controlProp.type === reducedControlProp.type)\n\t\t\tif (isMixed(reducedControlProp.value)) break\n\t\t\tif (isNotFound(reducedControlProp.value)) {\n\t\t\t\treducedControlProp.value = controlProp.value\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (\n\t\t\t\tisDynamicValue(reducedControlProp.value) ||\n\t\t\t\tisDynamicValue(controlProp.value) ||\n\t\t\t\t!reducedControlProp.value ||\n\t\t\t\t!controlProp.value\n\t\t\t) {\n\t\t\t\treducedControlProp.value = getReducedValue(controlProp.value, reducedControlProp.value)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (!isEqual(reducedControlProp.value, controlProp.value)) {\n\t\t\t\treducedControlProp.value = Mixed\n\t\t\t}\n\t\t\tbreak\n\t\tcase ControlType.ResponsiveImage:\n\t\t\tassert(controlProp.type === ControlType.Image)\n\t\t\treducedControlProp.value = getReducedValue(controlProp.value, reducedControlProp.value)\n\t\t\tif (reducedControlProp.type === ControlType.ResponsiveImage) {\n\t\t\t\tconst altText = isString(controlProp.alt) ? controlProp.alt : \"\"\n\t\t\t\treducedControlProp.alt = getReducedValue(altText, reducedControlProp.alt)\n\t\t\t\tconst { positionX, positionY } = controlProp\n\t\t\t\treducedControlProp.positionX = getReducedValue(positionX, reducedControlProp.positionX)\n\t\t\t\treducedControlProp.positionY = getReducedValue(positionY, reducedControlProp.positionY)\n\t\t\t}\n\t\t\tbreak\n\t\tcase ControlType.FusedNumber:\n\t\t\tassert(controlProp.type === reducedControlProp.type)\n\t\t\treducedControlProp.single = getReducedValue(controlProp.value.single, reducedControlProp.single)\n\t\t\treducedControlProp.isFused = getReducedValue(controlProp.isFused, reducedControlProp.isFused)\n\t\t\treducedControlProp.fused[0] = getReducedValue(controlProp.value.fused[0], reducedControlProp.fused[0])\n\t\t\treducedControlProp.fused[1] = getReducedValue(controlProp.value.fused[1], reducedControlProp.fused[1])\n\t\t\treducedControlProp.fused[2] = getReducedValue(controlProp.value.fused[2], reducedControlProp.fused[2])\n\t\t\treducedControlProp.fused[3] = getReducedValue(controlProp.value.fused[3], reducedControlProp.fused[3])\n\t\t\tbreak\n\t\tcase ControlType.Link: {\n\t\t\tassert(controlProp.type === reducedControlProp.type)\n\t\t\tif (isMixed(reducedControlProp.value)) break\n\t\t\tif (isNotFound(reducedControlProp.value)) {\n\t\t\t\treducedControlProp.value = controlProp.value\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (\n\t\t\t\tisDynamicValue(reducedControlProp.value) ||\n\t\t\t\tisDynamicValue(controlProp.value) ||\n\t\t\t\t!reducedControlProp.value ||\n\t\t\t\t!controlProp.value\n\t\t\t) {\n\t\t\t\treducedControlProp.value = getReducedValue(controlProp.value, reducedControlProp.value)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (!isLinkEqual(reducedControlProp.value, controlProp.value)) {\n\t\t\t\treducedControlProp.value = Mixed\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\tcase ControlType.LinkRelValues: {\n\t\t\tassert(controlProp.type === reducedControlProp.type)\n\t\t\tif (isMixed(reducedControlProp.value)) break\n\t\t\tif (isNotFound(reducedControlProp.value)) {\n\t\t\t\treducedControlProp.value = controlProp.value\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (\n\t\t\t\tisDynamicValue(reducedControlProp.value) ||\n\t\t\t\tisDynamicValue(controlProp.value) ||\n\t\t\t\t!reducedControlProp.value ||\n\t\t\t\t!controlProp.value\n\t\t\t) {\n\t\t\t\treducedControlProp.value = getReducedValue(controlProp.value, reducedControlProp.value)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (!isEqual(reducedControlProp.value, controlProp.value)) {\n\t\t\t\treducedControlProp.value = Mixed\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\n\t\tcase ControlType.PageScope:\n\t\t\tassert(controlProp.type === reducedControlProp.type)\n\t\t\tif (isMixed(reducedControlProp.value)) break\n\t\t\tif (isNotFound(reducedControlProp.value)) {\n\t\t\t\treducedControlProp.value = controlProp.value\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (!reducedControlProp.value || !controlProp.value) {\n\t\t\t\treducedControlProp.value = getReducedValue(controlProp.value, reducedControlProp.value)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (!isLinkEqual(reducedControlProp.value, controlProp.value)) {\n\t\t\t\treducedControlProp.value = Mixed\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tbreak\n\t\tcase ControlType.Font: {\n\t\t\tassert(control.type === ControlType.Font)\n\t\t\tassert(controlProp.type === reducedControlProp.type)\n\n\t\t\tif (isMixed(reducedControlProp.value)) break\n\t\t\tif (isNotFound(reducedControlProp.value)) {\n\t\t\t\tif (isUndefined(controlProp.value)) {\n\t\t\t\t\treducedControlProp.value = controlProp.value\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tconst fontSelector = new Set([controlProp.value.fontSelector])\n\t\t\t\tlet fontSizeValue: Reduced<number | undefined> = NotFound\n\t\t\t\tconst fontSizeUnits: Set<FontSizeUnit> = new Set()\n\t\t\t\tconst lineHeightUnits: Set<LineHeightUnit> = new Set()\n\t\t\t\tlet lineHeightValue: Reduced<number | undefined> = NotFound\n\t\t\t\tlet textAlignment: Reduced<TextAlignment | undefined> = NotFound\n\t\t\t\tlet letterSpacingValue: Reduced<number | undefined> = NotFound\n\t\t\t\tconst letterSpacingUnits: Set<LetterSpacingUnit> = new Set()\n\t\t\t\tlet openTypeFontFeatures: ReducedOpenTypeFontFeatures = {}\n\n\t\t\t\tif (control.displayFontSize) {\n\t\t\t\t\tconst [size, unit] = isFontSizeCSSDimension(controlProp.value.fontSize)\n\t\t\t\t\t\t? parseCSSDimension(controlProp.value.fontSize)\n\t\t\t\t\t\t: []\n\t\t\t\t\tfontSizeValue = size\n\t\t\t\t\tif (unit) {\n\t\t\t\t\t\tfontSizeUnits.add(unit)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (control.displayTextAlignment) {\n\t\t\t\t\ttextAlignment = controlProp.value.textAlignment\n\t\t\t\t}\n\t\t\t\tif (control.controls === \"extended\") {\n\t\t\t\t\tconst [lineHeight, lineHeightUnit] = controlProp.value.lineHeight ?? []\n\t\t\t\t\tlineHeightValue = lineHeight\n\t\t\t\t\tif (lineHeightUnit) {\n\t\t\t\t\t\tlineHeightUnits.add(lineHeightUnit)\n\t\t\t\t\t}\n\n\t\t\t\t\tconst [letterSpacing, letterSpacingUnit] = controlProp.value.letterSpacing ?? []\n\t\t\t\t\tletterSpacingValue = letterSpacing\n\t\t\t\t\tif (letterSpacingUnit) {\n\t\t\t\t\t\tletterSpacingUnits.add(letterSpacingUnit)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (controlProp.value.openTypeFontFeatures) {\n\t\t\t\t\topenTypeFontFeatures = (controlProp.value.openTypeFontFeatures ?? []).reduce<ReducedOpenTypeFontFeatures>(\n\t\t\t\t\t\t(acc, featureTag) => {\n\t\t\t\t\t\t\tif (isOpenTypeFeatureTag(featureTag)) {\n\t\t\t\t\t\t\t\tacc[featureTag] = true\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn acc\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{},\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tconst variationAxes: ReducedFontVariationAxes = controlProp.value.variationAxes ?? {}\n\n\t\t\t\treducedControlProp.value = {\n\t\t\t\t\tfontSelector,\n\t\t\t\t\tlineHeightValue,\n\t\t\t\t\tlineHeightUnits,\n\t\t\t\t\tfontSizeValue,\n\t\t\t\t\tfontSizeUnits,\n\t\t\t\t\ttextAlignment,\n\t\t\t\t\tletterSpacingValue,\n\t\t\t\t\tletterSpacingUnits,\n\t\t\t\t\topenTypeFontFeatures,\n\t\t\t\t\tvariationAxes,\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif (isUndefined(reducedControlProp.value)) {\n\t\t\t\tif (!isUndefined(controlProp.value)) {\n\t\t\t\t\treducedControlProp.value = Mixed\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif (isUndefined(controlProp.value)) {\n\t\t\t\treducedControlProp.value = Mixed\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tfontSelector,\n\t\t\t\tlineHeight: [lineHeightValue, lineHeightUnit] = [],\n\t\t\t\tfontSize,\n\t\t\t\ttextAlignment,\n\t\t\t\tletterSpacing: [letterSpacingValue, letterSpacingUnit] = [],\n\t\t\t\topenTypeFontFeatures,\n\t\t\t\tvariationAxes,\n\t\t\t} = controlProp.value\n\t\t\treducedControlProp.value.fontSelector.add(fontSelector)\n\n\t\t\tconst [fontSizeValue, fontSizeUnit] = isFontSizeCSSDimension(fontSize) ? parseCSSDimension(fontSize) : []\n\t\t\tconst isFontSizeMixed =\n\t\t\t\treducedControlProp.value.fontSizeValue !== fontSizeValue ||\n\t\t\t\t(!isUndefined(fontSizeUnit) && !reducedControlProp.value.fontSizeUnits.has(fontSizeUnit))\n\n\t\t\tif (control.displayFontSize && isFontSizeMixed) {\n\t\t\t\treducedControlProp.value.fontSizeValue = Mixed\n\t\t\t\tif (fontSizeUnit) {\n\t\t\t\t\treducedControlProp.value.fontSizeUnits.add(fontSizeUnit)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (control.displayTextAlignment && reducedControlProp.value.textAlignment !== textAlignment) {\n\t\t\t\treducedControlProp.value.textAlignment = Mixed\n\t\t\t}\n\t\t\tif (control.controls === \"extended\") {\n\t\t\t\tif (reducedControlProp.value.lineHeightValue !== lineHeightValue) {\n\t\t\t\t\treducedControlProp.value.lineHeightValue = Mixed\n\t\t\t\t}\n\t\t\t\tif (lineHeightUnit) {\n\t\t\t\t\treducedControlProp.value.lineHeightUnits.add(lineHeightUnit)\n\t\t\t\t}\n\n\t\t\t\tif (reducedControlProp.value.letterSpacingValue !== letterSpacingValue) {\n\t\t\t\t\treducedControlProp.value.letterSpacingValue = Mixed\n\t\t\t\t}\n\t\t\t\tif (letterSpacingUnit) {\n\t\t\t\t\treducedControlProp.value.letterSpacingUnits.add(letterSpacingUnit)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treducedControlProp.value.openTypeFontFeatures = reduceFormInputOpenTypeFontFeatures(\n\t\t\t\treducedControlProp.value.openTypeFontFeatures,\n\t\t\t\topenTypeFontFeatures,\n\t\t\t)\n\n\t\t\treducedControlProp.value.variationAxes = reduceFormInputVariationAxes(\n\t\t\t\treducedControlProp.value.variationAxes,\n\t\t\t\tvariationAxes,\n\t\t\t)\n\n\t\t\tbreak\n\t\t}\n\t\tcase ControlType.CustomCursor:\n\t\tcase ControlType.ScrollSectionRef: {\n\t\t\tassert(controlProp.type === reducedControlProp.type)\n\t\t\t// If the values pass a deep equality check, reuse a reference to\n\t\t\t// the reduced value to ensure getReducedValue doesn't update it to\n\t\t\t// Mixed.\n\t\t\tconst value = isEqual(controlProp.value, reducedControlProp.value) ? reducedControlProp.value : controlProp.value\n\t\t\treducedControlProp.value = getReducedValue(value, reducedControlProp.value)\n\t\t\tbreak\n\t\t}\n\t\tcase ControlType.Location: {\n\t\t\tassert(controlProp.type === reducedControlProp.type)\n\t\t\tconst value = isEqual(controlProp.value, reducedControlProp.value) ? reducedControlProp.value : controlProp.value\n\t\t\treducedControlProp.value = getReducedValue(value, reducedControlProp.value)\n\t\t\treducedControlProp.title = getReducedValue(controlProp.title, reducedControlProp.title)\n\t\t\treducedControlProp.address = getReducedValue(controlProp.address, reducedControlProp.address)\n\t\t\tbreak\n\t\t}\n\t\tcase ControlType.Border: {\n\t\t\tassert(controlProp.type === reducedControlProp.type)\n\n\t\t\tif (isNotFound(reducedControlProp.value)) {\n\t\t\t\tif (isDynamicValue(controlProp.value)) {\n\t\t\t\t\treducedControlProp.value = controlProp.value\n\t\t\t\t} else if (isNull(controlProp.value)) {\n\t\t\t\t\treducedControlProp.value = null\n\t\t\t\t} else {\n\t\t\t\t\treducedControlProp.value = { ...controlProp.value }\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tisDynamicValue(controlProp.value) ||\n\t\t\t\tisDynamicValue(reducedControlProp.value) ||\n\t\t\t\tisNull(controlProp.value) ||\n\t\t\t\tisNull(reducedControlProp.value)\n\t\t\t) {\n\t\t\t\tif (valuesAreDifferent(controlProp.value, reducedControlProp.value)) {\n\t\t\t\t\treducedControlProp.value = allBorderPropsMixed\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tconst reducedValue = reducedControlProp.value\n\n\t\t\treducedValue.borderTop = getReducedValue(controlProp.value.borderTop, reducedValue.borderTop)\n\t\t\treducedValue.borderRight = getReducedValue(controlProp.value.borderRight, reducedValue.borderRight)\n\t\t\treducedValue.borderBottom = getReducedValue(controlProp.value.borderBottom, reducedValue.borderBottom)\n\t\t\treducedValue.borderLeft = getReducedValue(controlProp.value.borderLeft, reducedValue.borderLeft)\n\t\t\treducedValue.borderWidth = getReducedValue(controlProp.value.borderWidth, reducedValue.borderWidth)\n\t\t\treducedValue.borderColor = getReducedValue(controlProp.value.borderColor, reducedValue.borderColor)\n\t\t\treducedValue.borderStyle = getReducedValue(controlProp.value.borderStyle, reducedValue.borderStyle)\n\n\t\t\tbreak\n\t\t}\n\t\tcase ControlType.BoxShadow:\n\t\t\tassert(controlProp.type === reducedControlProp.type)\n\t\t\treducedControlProp.value = reduceShadowList(controlProp.value, reducedControlProp.value)\n\t\t\tbreak\n\t\tcase ControlType.MultiCollectionReference:\n\t\t\tassert(controlProp.type === reducedControlProp.type)\n\t\t\treducedControlProp.value = getReducedMultiCollectionReference(controlProp.value, reducedControlProp.value)\n\t\t\tbreak\n\t\tcase ControlType.Gap: {\n\t\t\tassert(controlProp.type === reducedControlProp.type)\n\t\t\treducedControlProp.value = getReducedValue(controlProp.value, reducedControlProp.value)\n\n\t\t\tif (!isMixed(reducedControlProp.columnGap)) {\n\t\t\t\tconst columnGap = isDynamicValue(controlProp.value)\n\t\t\t\t\t? Mixed\n\t\t\t\t\t: getNumericColumnGapFromShorthand(controlProp.value)\n\t\t\t\tif (isNotFound(reducedControlProp.columnGap)) {\n\t\t\t\t\treducedControlProp.columnGap = columnGap\n\t\t\t\t} else if (valuesAreDifferent(columnGap, reducedControlProp.columnGap)) {\n\t\t\t\t\treducedControlProp.columnGap = Mixed\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!isMixed(reducedControlProp.rowGap)) {\n\t\t\t\tconst rowGap = isDynamicValue(controlProp.value) ? Mixed : getNumericRowGapFromShorthand(controlProp.value)\n\t\t\t\tif (isNotFound(reducedControlProp.rowGap)) {\n\t\t\t\t\treducedControlProp.rowGap = rowGap\n\t\t\t\t} else if (valuesAreDifferent(rowGap, reducedControlProp.rowGap)) {\n\t\t\t\t\treducedControlProp.rowGap = Mixed\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbreak\n\t\t}\n\t\tcase ControlType.Boolean:\n\t\tcase ControlType.Color:\n\t\tcase ControlType.Date:\n\t\tcase ControlType.Enum:\n\t\tcase ControlType.File:\n\t\tcase ControlType.Number:\n\t\tcase ControlType.RichText:\n\t\tcase ControlType.String:\n\t\tcase ControlType.Image:\n\t\tcase ControlType.Cursor:\n\t\tcase ControlType.Padding:\n\t\tcase ControlType.BorderRadius:\n\t\tcase ControlType.CollectionReference:\n\t\tcase ControlType.TrackingId:\n\t\tcase ControlType.VectorSetItem:\n\t\t\tassert(controlProp.type === reducedControlProp.type)\n\t\t\treducedControlProp.value = getReducedValue(controlProp.value, reducedControlProp.value)\n\t\t\tbreak\n\t\tdefault:\n\t\t\tshouldBeNever(reducedControlProp)\n\t}\n}\n\nexport function getReducedControlPropForControl(control: VerifiedControlDescription): ReducedControlProp | null {\n\tswitch (control.type) {\n\t\tcase ControlType.Boolean:\n\t\tcase ControlType.Color:\n\t\tcase ControlType.Date:\n\t\tcase ControlType.Enum:\n\t\tcase ControlType.File:\n\t\tcase ControlType.Link:\n\t\tcase ControlType.LinkRelValues:\n\t\tcase ControlType.Number:\n\t\tcase ControlType.RichText:\n\t\tcase ControlType.String:\n\t\tcase ControlType.Transition:\n\t\tcase ControlType.BoxShadow:\n\t\tcase ControlType.Image:\n\t\tcase ControlType.Object:\n\t\t\t// this line is because typescript only narrow types up to 25 on a switch case\n\t\t\t// https://github.com/microsoft/TypeScript/issues/32749\n\t\t\treturn { type: control.type, value: NotFound }\n\t\tcase ControlType.Array:\n\t\tcase ControlType.Slot:\n\t\tcase ControlType.Font:\n\t\tcase ControlType.PageScope:\n\t\tcase ControlType.ScrollSectionRef:\n\t\tcase ControlType.CustomCursor:\n\t\tcase ControlType.Border:\n\t\tcase ControlType.Cursor:\n\t\tcase ControlType.Padding:\n\t\tcase ControlType.BorderRadius:\n\t\tcase ControlType.CollectionReference:\n\t\tcase ControlType.MultiCollectionReference:\n\t\tcase ControlType.VectorSetItem:\n\t\t\treturn { type: control.type, value: NotFound }\n\t\tcase ControlType.Location:\n\t\t\treturn { type: control.type, value: NotFound, title: NotFound, address: NotFound }\n\t\tcase ControlType.Gap:\n\t\t\treturn { type: control.type, value: NotFound, columnGap: NotFound, rowGap: NotFound }\n\t\tcase ControlType.TrackingId:\n\t\t\treturn { type: control.type, value: NotFound, trackingIdAIPrompt: NotFound }\n\t\tcase ControlType.FusedNumber:\n\t\t\treturn {\n\t\t\t\ttype: ControlType.FusedNumber,\n\t\t\t\tisFused: NotFound,\n\t\t\t\tsingle: NotFound,\n\t\t\t\tfused: [NotFound, NotFound, NotFound, NotFound],\n\t\t\t}\n\t\tcase ControlType.ResponsiveImage:\n\t\t\treturn {\n\t\t\t\ttype: ControlType.ResponsiveImage,\n\t\t\t\tvalue: NotFound,\n\t\t\t\talt: NotFound,\n\t\t\t\tpositionX: NotFound,\n\t\t\t\tpositionY: NotFound,\n\t\t\t}\n\t\t// Event handlers are not reduced because they are only visible for single selected nodes.\n\t\tcase ControlType.EventHandler:\n\t\tcase ControlType.ChangeHandler:\n\t\t\treturn null\n\t\tdefault:\n\t\t\tshouldBeNever(control)\n\t\t\treturn null\n\t}\n}\n\nexport function getReducedResponsiveImageControlProp(\n\tcontrolProp: ImageControlProp | undefined,\n\tcontrol: ResponsiveImageControlDescription,\n): ReducedResponsiveImageControlProp {\n\tconst reducedControlProp = getReducedControlPropForControl(control)\n\tassert(reducedControlProp?.type === ControlType.ResponsiveImage)\n\n\tif (controlProp) {\n\t\treduceControlProp(reducedControlProp, controlProp, control)\n\t}\n\n\treturn reducedControlProp\n}\n\ntype ReducedObjectPropertyControlType = VerifiedObjectPropertyControlDescription[\"type\"] & ReducedControlProp[\"type\"]\n\nconst objectPropertyTypes: Record<ReducedObjectPropertyControlType, true> = {\n\t[ControlType.Number]: true,\n\t[ControlType.Enum]: true,\n\t[ControlType.Boolean]: true,\n\t[ControlType.String]: true,\n\t[ControlType.RichText]: true,\n\t[ControlType.Color]: true,\n\t[ControlType.Image]: true,\n\t[ControlType.ResponsiveImage]: true,\n\t[ControlType.File]: true,\n\t[ControlType.Transition]: true,\n\t[ControlType.Link]: true,\n\t[ControlType.Date]: true,\n\t[ControlType.Object]: true,\n\t[ControlType.Array]: true,\n\t[ControlType.FusedNumber]: true,\n\t[ControlType.Font]: true,\n\t[ControlType.PageScope]: true,\n\t[ControlType.ScrollSectionRef]: true,\n\t[ControlType.CustomCursor]: true,\n\t[ControlType.Border]: true,\n\t[ControlType.Cursor]: true,\n\t[ControlType.BoxShadow]: true,\n\t[ControlType.Gap]: true,\n\t[ControlType.Padding]: true,\n\t[ControlType.BorderRadius]: true,\n\t[ControlType.CollectionReference]: true,\n\t[ControlType.MultiCollectionReference]: true,\n\t[ControlType.TrackingId]: true,\n\t[ControlType.Location]: true,\n}\n\nfunction isObjectPropertyType(type: ReducedControlProp[\"type\"]): type is ReducedObjectPropertyControlType {\n\treturn Object.hasOwn(objectPropertyTypes, type)\n}\n\nfunction isReducedObjectPropertyControlProp(\n\treducedControlProp: ReducedControlProp,\n): reducedControlProp is ReducedObjectPropertyControlProp {\n\treturn isObjectPropertyType(reducedControlProp.type)\n}\n\nfunction getReducedObjectPropertyControlProp(\n\tcontrol: VerifiedObjectPropertyControlDescription,\n): ReducedObjectPropertyControlProp | null {\n\tconst reducedControl = getReducedControlPropForControl(control)\n\tif (!reducedControl) return null\n\tassert(isReducedObjectPropertyControlProp(reducedControl))\n\treturn reducedControl\n}\n\nfunction getReducedArrayItemControlProp(\n\tcontrol: VerifiedArrayItemControlDescription,\n\tid: string,\n): ReducedArrayItemControlProp {\n\tconst controlProp = getReducedControlPropForControl(control)\n\tassert(controlProp)\n\tconst reducedControlProp = controlProp as ReducedArrayItemControlProp\n\treducedControlProp.id = id\n\treturn reducedControlProp\n}\n\nexport function getReducedControlProps(\n\tcontrols: VerifiedPropertyControls,\n\tcontrolPropsList: ControlProps[],\n): ReducedControlProps {\n\tconst result: Mutable<ReducedControlProps> = {}\n\n\tfor (const controlKey in controls) {\n\t\tconst control = controls[controlKey]\n\t\tif (!control) continue\n\t\tconst reducedControl = getReducedControlPropForControl(control)\n\t\tif (!reducedControl) continue\n\t\tresult[controlKey] = reducedControl\n\t}\n\n\tfor (const controlProps of controlPropsList) {\n\t\tfor (const controlKey in controlProps) {\n\t\t\tconst control = controls[controlKey]\n\t\t\tassert(control)\n\t\t\t// Event handlers aren't reduced currently because they are only visible for single\n\t\t\t// selected nodes.\n\t\t\tif (control.type === ControlType.EventHandler) continue\n\t\t\tconst reducedControlProp = result[controlKey]\n\t\t\tassert(reducedControlProp, \"Each control prop should have a corresponding reduced control prop\")\n\t\t\tconst controlProp = controlProps[controlKey]\n\t\t\tassert(controlProp)\n\t\t\treduceControlProp(reducedControlProp, controlProp, control)\n\t\t}\n\t}\n\n\treturn result\n}\n", "import type { ComponentLoader } from \"@framerjs/framer-runtime\"\nimport { assert, isLocalModuleIdentifier } from \"@framerjs/shared\"\nimport type { SandboxRepeaterData } from \"document/SandboxRepeaterData.ts\"\nimport type { CanvasTree, CollectionItemNode, CollectionNode } from \"document/models/CanvasTree/index.ts\"\nimport { isCollectionItemNode } from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport type { VariableReference } from \"document/models/CanvasTree/traits/VariableReference.ts\"\nimport { hasCollectionDataSource } from \"document/models/CanvasTree/traits/WithCollectionDataSource.ts\"\nimport type { VariableDefinition, VariableID } from \"document/models/CanvasTree/traits/WithVariables.ts\"\nimport type { CollectionControlDescription } from \"document/models/controlProps/CollectionControlDescription.ts\"\nimport {\n\ttype CollectionControlProp,\n\tisCollectionControlProp,\n} from \"document/models/controlProps/CollectionControlProp.ts\"\nimport type { CollectionControlType } from \"document/models/controlProps/CollectionControlType.ts\"\nimport type { ControlProp } from \"document/models/controlProps/ControlProp.ts\"\nimport { getControlProp } from \"document/models/controlProps/getControlProps.ts\"\nimport {\n\ttype ReducedControlProp,\n\tgetReducedControlPropForControl,\n\treduceControlProp,\n} from \"document/models/controlProps/getReducedControlProps.ts\"\nimport { resolveEditableCollectionVariableAsPath } from \"utils/collectionReferenceUtils.ts\"\nimport { getCollectionForIdentifier } from \"utils/getCollectionForIdentifier.ts\"\nimport { getFirstRepeaterItemId } from \"utils/getFirstRepeaterItemId.ts\"\n\nexport interface CollectionVariableInfo<ControlType extends CollectionControlType> {\n\tcollectionNode: CollectionNode\n\tcollectionItemNode: CollectionItemNode\n\tvariableDefinition: Extract<VariableDefinition, { type: ControlType }>\n\tcontrolDescription: CollectionControlDescription\n\trawControlProp: CollectionControlProp | undefined\n\tcontrolProp: CollectionControlProp<ControlType>\n\treducedControlProp: ReducedControlProp\n\tvariableId: VariableID\n}\n\nexport function getEditableCollectionVariableInfo<ControlType extends CollectionControlType>(\n\ttree: CanvasTree,\n\tcomponentLoader: ComponentLoader,\n\tsandboxRepeaterData: SandboxRepeaterData,\n\tvariableReference: VariableReference,\n\tvariableType: ControlType,\n\tcollectionItemId: string | undefined,\n): CollectionVariableInfo<ControlType> | undefined {\n\tlet variableId = variableReference.id\n\tif (!variableId) return\n\n\tconst providerNode = tree.getNodeWithTrait(variableReference.providerId, hasCollectionDataSource)\n\tif (!providerNode) return\n\n\tconst dataIdentifier = providerNode.dataIdentifier\n\tif (!isLocalModuleIdentifier(dataIdentifier)) return\n\tlet collectionNode = getCollectionForIdentifier(tree, dataIdentifier)\n\tif (!collectionNode) return\n\tcollectionItemId ??= getFirstRepeaterItemId(providerNode, sandboxRepeaterData)\n\tlet collectionItemNode = tree.getNodeWithTrait(collectionItemId, isCollectionItemNode)\n\tif (!collectionItemNode) return\n\n\t// if variableId is complex, we might want to edit variable in another collection item node\n\tconst targetFoundThroughVariablePath = resolveEditableCollectionVariableAsPath(\n\t\ttree,\n\t\tsandboxRepeaterData,\n\t\tvariableId,\n\t\tcollectionItemNode,\n\t\tcollectionNode,\n\t)\n\tif (targetFoundThroughVariablePath) {\n\t\tcollectionItemNode = targetFoundThroughVariablePath.collectionItemNode\n\t\tcollectionNode = targetFoundThroughVariablePath.collectionNode\n\t\tvariableId = targetFoundThroughVariablePath.variableId\n\t}\n\n\tconst propertyControls = collectionNode.getPropertyControls(tree, componentLoader)\n\tconst controlDescription = propertyControls[variableId]\n\tif (!controlDescription) return\n\n\tconst variableDefinition = collectionNode.getVariable(variableId)\n\tif (!variableDefinition) return\n\n\tconst rawControlProp = collectionItemNode.getControlProp(variableId)\n\tconst { controlProp, reducedControlProp } = getCachedControlProp(controlDescription, rawControlProp)\n\tif (!isCollectionControlProp(controlProp)) return\n\n\tassert(reducedControlProp, \"Reduced control prop should not be null when a collection control prop is present\")\n\n\tif (collectionNode.id !== collectionItemNode.parentid) return\n\tif (collectionNode.managedByPlugin && !variableDefinition.userEditable) return\n\n\tif (variableDefinition.type !== variableType) return\n\tif (controlProp.type !== variableType) return\n\n\treturn {\n\t\tcollectionNode,\n\t\tcollectionItemNode,\n\t\tvariableDefinition,\n\t\tcontrolDescription,\n\t\trawControlProp,\n\t\tcontrolProp,\n\t\treducedControlProp,\n\t\tvariableId,\n\t} as CollectionVariableInfo<ControlType>\n}\n\ninterface CachedControlProp {\n\trawControlProp: CollectionControlProp | undefined\n\tcontrolProp: ControlProp | null\n\treducedControlProp: ReducedControlProp | null\n}\n\n// We need to cache the control prop so we can use `getEditableCollectionVariableInfo` inside\n// `useEngineState`. Otherwise, it would create a new object every time, causing an infinite render\n// loop inside `useSyncExternalStore`.\nconst controlPropCache = new WeakMap<CollectionControlDescription, CachedControlProp>()\n\nfunction getCachedControlProp(\n\tcontrolDescription: CollectionControlDescription,\n\trawControlProp: CollectionControlProp | undefined,\n) {\n\tconst cachedControlProp = controlPropCache.get(controlDescription)\n\tif (cachedControlProp && cachedControlProp.rawControlProp === rawControlProp) {\n\t\tconst { controlProp, reducedControlProp } = cachedControlProp\n\t\treturn { controlProp, reducedControlProp }\n\t}\n\n\tconst controlProp = getControlProp(controlDescription, rawControlProp)\n\n\tconst reducedControlProp = getReducedControlPropForControl(controlDescription)\n\tif (reducedControlProp && controlProp) {\n\t\treduceControlProp(reducedControlProp, controlProp, controlDescription)\n\t}\n\n\tcontrolPropCache.set(controlDescription, {\n\t\trawControlProp,\n\t\tcontrolProp,\n\t\treducedControlProp,\n\t})\n\n\treturn { controlProp, reducedControlProp }\n}\n", "// =============================================================================================================\n// FIXME: this file is copy-pasted from https://github.com/stipsan/scroll-into-view-if-needed\n// it was done because the common-js export of that library doesn't work with our jest setup\n// if we are able to solve the problem with our tests setup, we should use the library directly\n// =============================================================================================================\n\nimport { type RefCallback, type RefObject, useLayoutEffect, useRef } from \"react\"\nimport { computeScrollIntoView } from \"./computeScrollIntoView.ts\"\nimport type { Options as BaseOptions, CustomScrollAction, CustomScrollBehaviorCallback } from \"./types.ts\"\n\ninterface StandardBehaviorOptions extends BaseOptions {\n\tbehavior?: ScrollBehavior\n}\n\ninterface CustomBehaviorOptions<T> extends BaseOptions {\n\tbehavior: CustomScrollBehaviorCallback<T>\n}\n\ninterface Options<T = any> extends BaseOptions {\n\tbehavior?: ScrollBehavior | CustomScrollBehaviorCallback<T>\n}\n\nfunction isOptionsObject<T>(options: any): options is T {\n\treturn options === Object(options) && Object.keys(options).length !== 0\n}\n\nfunction defaultBehavior(actions: CustomScrollAction[], behavior: ScrollBehavior = \"auto\") {\n\tconst canSmoothScroll = \"scrollBehavior\" in document.body.style\n\n\tactions.forEach(({ el, top, left }) => {\n\t\t// scrolling the body breaks the layout of Vekter, rulers for example move out of the viewport\n\t\tif (el === document.body) return\n\n\t\t// browser implements the new Element.prototype.scroll API that supports `behavior`\n\t\t// and guard window.scroll with supportsScrollBehavior\n\t\tif (el.scroll && canSmoothScroll) {\n\t\t\tel.scroll({ top, left, behavior })\n\t\t} else {\n\t\t\tel.scrollTop = top\n\t\t\tel.scrollLeft = left\n\t\t}\n\t})\n}\n\nfunction getOptions(options: any): StandardBehaviorOptions {\n\t// Handle alignToTop for legacy reasons, to be compatible with the spec\n\tif (options === false) {\n\t\treturn { block: \"end\", inline: \"nearest\" }\n\t}\n\n\tif (isOptionsObject<StandardBehaviorOptions>(options)) {\n\t\t// compute.ts ensures the defaults are block: 'center' and inline: 'nearest', to conform to the spec\n\t\treturn options\n\t}\n\n\t// if options = {}, options = true or options = null, based on w3c web platform test\n\treturn { block: \"start\", inline: \"nearest\" }\n}\n\n/**\n * Some people might use both \"auto\" and \"ponyfill\" modes in the same file, so we also provide a named export so\n * that imports in userland code (like if they use native smooth scrolling on some browsers, and the ponyfill for everything else)\n * the named export allows this `import {auto as autoScrollIntoView, ponyfill as smoothScrollIntoView} from ...`\n *\n * @deprecated Use the native Element.scrollIntoView unless you have a good reason to use this\n * ponyfill instead. Note: Safari 15 still doesn't support the smooth behavior.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView\n */\nfunction scrollIntoView<T>(target: Element, options: CustomBehaviorOptions<T>): T\nfunction scrollIntoView(target: Element, options?: Options | boolean): void\nfunction scrollIntoView<T>(target: Element, options?: Options<T> | boolean) {\n\t// Browsers treats targets that aren't in the dom as a no-op and so should we\n\tconst targetIsDetached = !target.ownerDocument.documentElement.contains(target)\n\n\tif (isOptionsObject<CustomBehaviorOptions<T>>(options) && typeof options.behavior === \"function\") {\n\t\treturn options.behavior(targetIsDetached ? [] : computeScrollIntoView(target, options))\n\t}\n\n\t// Don't do anything if using a standard behavior on an element that is not in the document\n\tif (targetIsDetached) {\n\t\treturn\n\t}\n\n\t// @TODO see if it's possible to avoid this assignment\n\tconst computeOptions = getOptions(options)\n\treturn defaultBehavior(computeScrollIntoView(target, computeOptions), computeOptions.behavior)\n}\n\nexport { scrollIntoView }\n\ntype Ref<T> = RefCallback<T> | RefObject<T> | null\n\n/**\n * Scrolls a target element into view if the flag is set to true.\n *\n * Able to handle both callback refs and object refs. Returns a merged callback\n * in case we're using this in a component with a forwarded ref.\n *\n * @param ref - The ref to the target element.\n * @param shouldScroll - Whether to scroll the target element into view.\n * @returns An optional merged callback ref.\n */\nexport function useScrollIntoView<T extends Element>(ref: Ref<T>, shouldScroll: boolean): RefCallback<T> | undefined {\n\tconst localRef = useRef<T | null>(null)\n\tconst isCallbackRef = typeof ref === \"function\"\n\n\tuseLayoutEffect(() => {\n\t\tif (!shouldScroll) return\n\n\t\trequestAnimationFrame(() => {\n\t\t\tconst element = isCallbackRef ? localRef.current : ref && \"current\" in ref ? ref.current : null\n\t\t\tif (element) {\n\t\t\t\tscrollIntoView(element, {\n\t\t\t\t\tscrollMode: \"if-needed\",\n\t\t\t\t\tblock: \"center\",\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}, [shouldScroll, isCallbackRef, ref])\n\n\t// If ref is a callback function (ForwardedRef), return a merged callback\n\tif (isCallbackRef) {\n\t\treturn (node: T | null) => {\n\t\t\tlocalRef.current = node\n\t\t\tref(node)\n\t\t}\n\t}\n}\n", "/* eslint-disable */\n// =============================================================================================================\n// FIXME: this file is copy-pasted from https://github.com/stipsan/compute-scroll-into-view\n// it was done because the common-js export of that library doesn't work with our jest setup\n// if we are able to solve the problem with our tests setup, we should use the library directly\n// =============================================================================================================\n\n// Compute what scrolling needs to be done on required scrolling boxes for target to be in view\n\n// The type names here are named after the spec to make it easier to find more information around what they mean:\n// To reduce churn and reduce things that need be maintained things from the official TS DOM library is used here\n// https://drafts.csswg.org/cssom-view/\n\n// For a definition on what is \"block flow direction\" exactly, check this: https://drafts.csswg.org/css-writing-modes-4/#block-flow-direction\n\n// add support for VisualViewport object currently implemented in chrome\ninterface VisualViewport {\n\theight: number\n\twidth: number\n}\n\ntype ScrollLogicalPosition = \"start\" | \"center\" | \"end\" | \"nearest\"\n// This new option is tracked in this PR, which is the most likely candidate at the time: https://github.com/w3c/csswg-drafts/pull/1805\ntype ScrollMode = \"always\" | \"if-needed\"\n// New option that skips auto-scrolling all nodes with overflow: hidden set\n// See FF implementation: https://hg.mozilla.org/integration/fx-team/rev/c48c3ec05012#l7.18\ntype SkipOverflowHiddenElements = boolean\n\ninterface Options {\n\tblock?: ScrollLogicalPosition\n\tinline?: ScrollLogicalPosition\n\tscrollMode?: ScrollMode\n\tboundary?: CustomScrollBoundary\n\tskipOverflowHiddenElements?: SkipOverflowHiddenElements\n}\n\n// Custom behavior, not in any spec\ntype CustomScrollBoundaryCallback = (parent: Element) => boolean\ntype CustomScrollBoundary = Element | CustomScrollBoundaryCallback | null\ninterface CustomScrollAction {\n\tel: Element\n\ttop: number\n\tleft: number\n}\n\n// @TODO better shadowdom test, 11 = document fragment\nfunction isElement(el: any) {\n\treturn el != null && typeof el === \"object\" && el.nodeType === 1\n}\n\nfunction canOverflow(overflow: string | null, skipOverflowHiddenElements?: boolean) {\n\tif (skipOverflowHiddenElements && overflow === \"hidden\") {\n\t\treturn false\n\t}\n\n\treturn overflow !== \"visible\" && overflow !== \"clip\"\n}\n\nfunction isScrollable(el: Element, skipOverflowHiddenElements?: boolean) {\n\tif (el.clientHeight < el.scrollHeight || el.clientWidth < el.scrollWidth) {\n\t\tconst style = getComputedStyle(el, null)\n\t\treturn (\n\t\t\tcanOverflow(style.overflowY, skipOverflowHiddenElements) ||\n\t\t\tcanOverflow(style.overflowX, skipOverflowHiddenElements)\n\t\t)\n\t}\n\n\treturn false\n}\n/**\n * Find out which edge to align against when logical scroll position is \"nearest\"\n * Interesting fact: \"nearest\" works similarily to \"if-needed\", if the element is fully visible it will not scroll it\n *\n * Legends:\n * \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510 \u250F \u2501 \u2501 \u2501 \u2513\n * \u2502 target \u2502   frame\n * \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 \u2517 \u2501 \u2501 \u2501 \u251B\n */\nfunction alignNearest(\n\tscrollingEdgeStart: number,\n\tscrollingEdgeEnd: number,\n\tscrollingSize: number,\n\tscrollingBorderStart: number,\n\tscrollingBorderEnd: number,\n\telementEdgeStart: number,\n\telementEdgeEnd: number,\n\telementSize: number,\n) {\n\t/**\n\t * If element edge A and element edge B are both outside scrolling box edge A and scrolling box edge B\n\t *\n\t *          \u250C\u2500\u2500\u2510\n\t *        \u250F\u2501\u2502\u2501\u2501\u2502\u2501\u2513\n\t *          \u2502  \u2502\n\t *        \u2503 \u2502  \u2502 \u2503        do nothing\n\t *          \u2502  \u2502\n\t *        \u2517\u2501\u2502\u2501\u2501\u2502\u2501\u251B\n\t *          \u2514\u2500\u2500\u2518\n\t *\n\t *  If element edge C and element edge D are both outside scrolling box edge C and scrolling box edge D\n\t *\n\t *    \u250F \u2501 \u2501 \u2501 \u2501 \u2513\n\t *   \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\t *   \u2502\u2503         \u2503\u2502        do nothing\n\t *   \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n\t *    \u2517 \u2501 \u2501 \u2501 \u2501 \u251B\n\t */\n\tif (\n\t\t(elementEdgeStart < scrollingEdgeStart && elementEdgeEnd > scrollingEdgeEnd) ||\n\t\t(elementEdgeStart > scrollingEdgeStart && elementEdgeEnd < scrollingEdgeEnd)\n\t) {\n\t\treturn 0\n\t}\n\n\t/**\n\t * If element edge A is outside scrolling box edge A and element height is less than scrolling box height\n\t *\n\t *          \u250C\u2500\u2500\u2510\n\t *        \u250F\u2501\u2502\u2501\u2501\u2502\u2501\u2513         \u250F\u2501\u250C\u2501\u2501\u2510\u2501\u2513\n\t *          \u2514\u2500\u2500\u2518             \u2502  \u2502\n\t *  from  \u2503      \u2503     to  \u2503 \u2514\u2500\u2500\u2518 \u2503\n\t *\n\t *        \u2517\u2501 \u2501\u2501 \u2501\u251B         \u2517\u2501 \u2501\u2501 \u2501\u251B\n\t *\n\t * If element edge B is outside scrolling box edge B and element height is greater than scrolling box height\n\t *\n\t *        \u250F\u2501 \u2501\u2501 \u2501\u2513         \u250F\u2501\u250C\u2501\u2501\u2510\u2501\u2513\n\t *                           \u2502  \u2502\n\t *  from  \u2503 \u250C\u2500\u2500\u2510 \u2503     to  \u2503 \u2502  \u2502 \u2503\n\t *          \u2502  \u2502             \u2502  \u2502\n\t *        \u2517\u2501\u2502\u2501\u2501\u2502\u2501\u251B         \u2517\u2501\u2502\u2501\u2501\u2502\u2501\u251B\n\t *          \u2502  \u2502             \u2514\u2500\u2500\u2518\n\t *          \u2502  \u2502\n\t *          \u2514\u2500\u2500\u2518\n\t *\n\t * If element edge C is outside scrolling box edge C and element width is less than scrolling box width\n\t *\n\t *       from                 to\n\t *    \u250F \u2501 \u2501 \u2501 \u2501 \u2513         \u250F \u2501 \u2501 \u2501 \u2501 \u2513\n\t *  \u250C\u2500\u2500\u2500\u2510                 \u250C\u2500\u2500\u2500\u2510\n\t *  \u2502 \u2503 \u2502       \u2503         \u2503   \u2502     \u2503\n\t *  \u2514\u2500\u2500\u2500\u2518                 \u2514\u2500\u2500\u2500\u2518\n\t *    \u2517 \u2501 \u2501 \u2501 \u2501 \u251B         \u2517 \u2501 \u2501 \u2501 \u2501 \u251B\n\t *\n\t * If element edge D is outside scrolling box edge D and element width is greater than scrolling box width\n\t *\n\t *       from                 to\n\t *    \u250F \u2501 \u2501 \u2501 \u2501 \u2513         \u250F \u2501 \u2501 \u2501 \u2501 \u2513\n\t *        \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510   \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\t *    \u2503   \u2502     \u2503     \u2502   \u2503         \u2503 \u2502\n\t *        \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518   \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n\t *    \u2517 \u2501 \u2501 \u2501 \u2501 \u251B         \u2517 \u2501 \u2501 \u2501 \u2501 \u251B\n\t */\n\tif (\n\t\t(elementEdgeStart <= scrollingEdgeStart && elementSize <= scrollingSize) ||\n\t\t(elementEdgeEnd >= scrollingEdgeEnd && elementSize >= scrollingSize)\n\t) {\n\t\treturn elementEdgeStart - scrollingEdgeStart - scrollingBorderStart\n\t}\n\n\t/**\n\t * If element edge B is outside scrolling box edge B and element height is less than scrolling box height\n\t *\n\t *        \u250F\u2501 \u2501\u2501 \u2501\u2513         \u250F\u2501 \u2501\u2501 \u2501\u2513\n\t *\n\t *  from  \u2503      \u2503     to  \u2503 \u250C\u2500\u2500\u2510 \u2503\n\t *          \u250C\u2500\u2500\u2510             \u2502  \u2502\n\t *        \u2517\u2501\u2502\u2501\u2501\u2502\u2501\u251B         \u2517\u2501\u2514\u2501\u2501\u2518\u2501\u251B\n\t *          \u2514\u2500\u2500\u2518\n\t *\n\t * If element edge A is outside scrolling box edge A and element height is greater than scrolling box height\n\t *\n\t *          \u250C\u2500\u2500\u2510\n\t *          \u2502  \u2502\n\t *          \u2502  \u2502             \u250C\u2500\u2500\u2510\n\t *        \u250F\u2501\u2502\u2501\u2501\u2502\u2501\u2513         \u250F\u2501\u2502\u2501\u2501\u2502\u2501\u2513\n\t *          \u2502  \u2502             \u2502  \u2502\n\t *  from  \u2503 \u2514\u2500\u2500\u2518 \u2503     to  \u2503 \u2502  \u2502 \u2503\n\t *                           \u2502  \u2502\n\t *        \u2517\u2501 \u2501\u2501 \u2501\u251B         \u2517\u2501\u2514\u2501\u2501\u2518\u2501\u251B\n\t *\n\t * If element edge C is outside scrolling box edge C and element width is greater than scrolling box width\n\t *\n\t *           from                 to\n\t *        \u250F \u2501 \u2501 \u2501 \u2501 \u2513         \u250F \u2501 \u2501 \u2501 \u2501 \u2513\n\t *  \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510           \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\t *  \u2502     \u2503     \u2502   \u2503       \u2502 \u2503         \u2503\n\t *  \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518           \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n\t *        \u2517 \u2501 \u2501 \u2501 \u2501 \u251B         \u2517 \u2501 \u2501 \u2501 \u2501 \u251B\n\t *\n\t * If element edge D is outside scrolling box edge D and element width is less than scrolling box width\n\t *\n\t *           from                 to\n\t *        \u250F \u2501 \u2501 \u2501 \u2501 \u2513         \u250F \u2501 \u2501 \u2501 \u2501 \u2513\n\t *                \u250C\u2500\u2500\u2500\u2510             \u250C\u2500\u2500\u2500\u2510\n\t *        \u2503       \u2502 \u2503 \u2502       \u2503     \u2502   \u2503\n\t *                \u2514\u2500\u2500\u2500\u2518             \u2514\u2500\u2500\u2500\u2518\n\t *        \u2517 \u2501 \u2501 \u2501 \u2501 \u251B         \u2517 \u2501 \u2501 \u2501 \u2501 \u251B\n\t *\n\t */\n\tif (\n\t\t(elementEdgeEnd > scrollingEdgeEnd && elementSize < scrollingSize) ||\n\t\t(elementEdgeStart < scrollingEdgeStart && elementSize > scrollingSize)\n\t) {\n\t\treturn elementEdgeEnd - scrollingEdgeEnd + scrollingBorderEnd\n\t}\n\n\treturn 0\n}\n\nexport function computeScrollIntoView(target: Element, options: Options): CustomScrollAction[] {\n\tconst { scrollMode, block, inline, boundary, skipOverflowHiddenElements } = options\n\t// Allow using a callback to check the boundary\n\t// The default behavior is to check if the current target matches the boundary element or not\n\t// If undefined it'll check that target is never undefined (can happen as we recurse up the tree)\n\tconst checkBoundary = typeof boundary === \"function\" ? boundary : (node: any) => node !== boundary\n\n\tif (!isElement(target)) {\n\t\tthrow new TypeError(\"Invalid target\")\n\t}\n\n\t// Used to handle the top most element that can be scrolled\n\tconst scrollingElement = document.scrollingElement || document.documentElement\n\n\t// Collect all the scrolling boxes, as defined in the spec: https://drafts.csswg.org/cssom-view/#scrolling-box\n\tconst frames: Element[] = []\n\tlet cursor = target\n\twhile (isElement(cursor) && checkBoundary(cursor)) {\n\t\t// Move cursor to parent\n\t\tcursor = cursor.parentNode as Element\n\n\t\t// Stop when we reach the viewport\n\t\tif (cursor === scrollingElement) {\n\t\t\tframes.push(cursor)\n\t\t\tbreak\n\t\t}\n\n\t\t// Skip document.body if it's not the scrollingElement and documentElement isn't independently scrollable\n\t\tif (cursor === document.body && isScrollable(cursor) && !isScrollable(document.documentElement)) {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Now we check if the element is scrollable, this code only runs if the loop haven't already hit the viewport or a custom boundary\n\t\tif (isScrollable(cursor, skipOverflowHiddenElements)) {\n\t\t\tframes.push(cursor)\n\t\t}\n\t}\n\n\t// Support pinch-zooming properly, making sure elements scroll into the visual viewport\n\t// Browsers that don't support VisualViewport will report the layout viewport dimensions on document.documentElement.clientWidth/Height\n\t// and viewport dimensions on window.innerWidth/Height\n\t// https://www.quirksmode.org/mobile/viewports2.html\n\t// https://bokand.github.io/viewport/index.html\n\tconst viewport = window[\"visualViewport\"] as VisualViewport | undefined\n\tconst viewportWidth = viewport?.width ?? innerWidth\n\tconst viewportHeight = viewport?.height ?? innerHeight\n\n\t// Newer browsers supports scroll[X|Y], page[X|Y]Offset is\n\tconst viewportX = window.scrollX || pageXOffset\n\tconst viewportY = window.scrollY || pageYOffset\n\n\tconst {\n\t\theight: targetHeight,\n\t\twidth: targetWidth,\n\t\ttop: targetTop,\n\t\tright: targetRight,\n\t\tbottom: targetBottom,\n\t\tleft: targetLeft,\n\t} = target.getBoundingClientRect()\n\n\t// These values mutate as we loop through and generate scroll coordinates\n\tlet targetBlock: number =\n\t\tblock === \"start\" || block === \"nearest\" ? targetTop : block === \"end\" ? targetBottom : targetTop + targetHeight / 2 // block === 'center\n\tlet targetInline: number =\n\t\tinline === \"center\" ? targetLeft + targetWidth / 2 : inline === \"end\" ? targetRight : targetLeft // inline === 'start || inline === 'nearest\n\n\t// Collect new scroll positions\n\tconst computations: CustomScrollAction[] = []\n\tfor (const frame of frames) {\n\t\t// @TODO add a shouldScroll hook here that allows userland code to take control\n\n\t\tconst { height, width, top, right, bottom, left } = frame.getBoundingClientRect()\n\n\t\t// If the element is already visible we can end it here\n\t\t// @TODO targetBlock and targetInline should be taken into account to be compliant with https://github.com/w3c/csswg-drafts/pull/1805/files#diff-3c17f0e43c20f8ecf89419d49e7ef5e0R1333\n\t\tif (\n\t\t\tscrollMode === \"if-needed\" &&\n\t\t\ttargetTop >= 0 &&\n\t\t\ttargetLeft >= 0 &&\n\t\t\ttargetBottom <= viewportHeight &&\n\t\t\ttargetRight <= viewportWidth &&\n\t\t\ttargetTop >= top &&\n\t\t\ttargetBottom <= bottom &&\n\t\t\ttargetLeft >= left &&\n\t\t\ttargetRight <= right\n\t\t) {\n\t\t\t// Break the loop and return the computations for things that are not fully visible\n\t\t\treturn computations\n\t\t}\n\n\t\tconst frameStyle = getComputedStyle(frame)\n\t\tconst borderLeft = parseInt(frameStyle.borderLeftWidth, 10)\n\t\tconst borderTop = parseInt(frameStyle.borderTopWidth, 10)\n\t\tconst borderRight = parseInt(frameStyle.borderRightWidth, 10)\n\t\tconst borderBottom = parseInt(frameStyle.borderBottomWidth, 10)\n\n\t\tlet blockScroll: number = 0\n\t\tlet inlineScroll: number = 0\n\n\t\t// The property existance checks for offfset[Width|Height] is because only HTMLElement objects have them, but any Element might pass by here\n\t\t// @TODO find out if the \"as HTMLElement\" overrides can be dropped\n\t\tconst scrollbarWidth =\n\t\t\t\"offsetWidth\" in frame\n\t\t\t\t? (frame as HTMLElement).offsetWidth - (frame as HTMLElement).clientWidth - borderLeft - borderRight\n\t\t\t\t: 0\n\t\tconst scrollbarHeight =\n\t\t\t\"offsetHeight\" in frame\n\t\t\t\t? (frame as HTMLElement).offsetHeight - (frame as HTMLElement).clientHeight - borderTop - borderBottom\n\t\t\t\t: 0\n\n\t\tif (scrollingElement === frame) {\n\t\t\t// Handle viewport logic (document.documentElement or document.body)\n\n\t\t\tif (block === \"start\") {\n\t\t\t\tblockScroll = targetBlock\n\t\t\t} else if (block === \"end\") {\n\t\t\t\tblockScroll = targetBlock - viewportHeight\n\t\t\t} else if (block === \"nearest\") {\n\t\t\t\tblockScroll = alignNearest(\n\t\t\t\t\tviewportY,\n\t\t\t\t\tviewportY + viewportHeight,\n\t\t\t\t\tviewportHeight,\n\t\t\t\t\tborderTop,\n\t\t\t\t\tborderBottom,\n\t\t\t\t\tviewportY + targetBlock,\n\t\t\t\t\tviewportY + targetBlock + targetHeight,\n\t\t\t\t\ttargetHeight,\n\t\t\t\t)\n\t\t\t} else {\n\t\t\t\t// block === 'center' is the default\n\t\t\t\tblockScroll = targetBlock - viewportHeight / 2\n\t\t\t}\n\n\t\t\tif (inline === \"start\") {\n\t\t\t\tinlineScroll = targetInline\n\t\t\t} else if (inline === \"center\") {\n\t\t\t\tinlineScroll = targetInline - viewportWidth / 2\n\t\t\t} else if (inline === \"end\") {\n\t\t\t\tinlineScroll = targetInline - viewportWidth\n\t\t\t} else {\n\t\t\t\t// inline === 'nearest' is the default\n\t\t\t\tinlineScroll = alignNearest(\n\t\t\t\t\tviewportX,\n\t\t\t\t\tviewportX + viewportWidth,\n\t\t\t\t\tviewportWidth,\n\t\t\t\t\tborderLeft,\n\t\t\t\t\tborderRight,\n\t\t\t\t\tviewportX + targetInline,\n\t\t\t\t\tviewportX + targetInline + targetWidth,\n\t\t\t\t\ttargetWidth,\n\t\t\t\t)\n\t\t\t}\n\n\t\t\t// Apply scroll position offsets and ensure they are within bounds\n\t\t\t// @TODO add more test cases to cover this 100%\n\t\t\tblockScroll = Math.max(0, blockScroll + viewportY)\n\t\t\tinlineScroll = Math.max(0, inlineScroll + viewportX)\n\t\t} else {\n\t\t\t// Handle each scrolling frame that might exist between the target and the viewport\n\n\t\t\tif (block === \"start\") {\n\t\t\t\tblockScroll = targetBlock - top - borderTop\n\t\t\t} else if (block === \"end\") {\n\t\t\t\tblockScroll = targetBlock - bottom + borderBottom + scrollbarHeight\n\t\t\t} else if (block === \"nearest\") {\n\t\t\t\tblockScroll = alignNearest(\n\t\t\t\t\ttop,\n\t\t\t\t\tbottom,\n\t\t\t\t\theight,\n\t\t\t\t\tborderTop,\n\t\t\t\t\tborderBottom + scrollbarHeight,\n\t\t\t\t\ttargetBlock,\n\t\t\t\t\ttargetBlock + targetHeight,\n\t\t\t\t\ttargetHeight,\n\t\t\t\t)\n\t\t\t} else {\n\t\t\t\t// block === 'center' is the default\n\t\t\t\tblockScroll = targetBlock - (top + height / 2) + scrollbarHeight / 2\n\t\t\t}\n\n\t\t\tif (inline === \"start\") {\n\t\t\t\tinlineScroll = targetInline - left - borderLeft\n\t\t\t} else if (inline === \"center\") {\n\t\t\t\tinlineScroll = targetInline - (left + width / 2) + scrollbarWidth / 2\n\t\t\t} else if (inline === \"end\") {\n\t\t\t\tinlineScroll = targetInline - right + borderRight + scrollbarWidth\n\t\t\t} else {\n\t\t\t\t// inline === 'nearest' is the default\n\t\t\t\tinlineScroll = alignNearest(\n\t\t\t\t\tleft,\n\t\t\t\t\tright,\n\t\t\t\t\twidth,\n\t\t\t\t\tborderLeft,\n\t\t\t\t\tborderRight + scrollbarWidth,\n\t\t\t\t\ttargetInline,\n\t\t\t\t\ttargetInline + targetWidth,\n\t\t\t\t\ttargetWidth,\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tconst { scrollLeft, scrollTop } = frame\n\t\t\t// Ensure scroll coordinates are not out of bounds while applying scroll offsets\n\t\t\tblockScroll = Math.max(0, Math.min(scrollTop + blockScroll, frame.scrollHeight - height + scrollbarHeight))\n\t\t\tinlineScroll = Math.max(0, Math.min(scrollLeft + inlineScroll, frame.scrollWidth - width + scrollbarWidth))\n\n\t\t\t// Cache the offset so that parent frames can scroll this into view correctly\n\t\t\ttargetBlock += scrollTop - blockScroll\n\t\t\ttargetInline += scrollLeft - inlineScroll\n\t\t}\n\n\t\tcomputations.push({ el: frame, top: blockScroll, left: inlineScroll })\n\t}\n\n\treturn computations\n}\n", null, null, null, null, null, "import { liftListItem } from \"prosemirror-schema-list\"\nimport type { EditorState, Transaction } from \"prosemirror-state\"\nimport { isBlockquoteNode } from \"prosemirror/schema/blockquote.ts\"\nimport type { FramerProseMirrorSchema } from \"prosemirror/schema/index.ts\"\nimport { isListItemNode } from \"prosemirror/schema/list.ts\"\nimport { isTextBlockNode } from \"prosemirror/schema/textBlock.ts\"\nimport { hasTextStylePreset } from \"prosemirror/schema/utils.ts\"\n\n// ProseMirror Keymap Commands\n\ntype Dispatch = (transaction: Transaction) => void\n\nexport const addLineBreakToStyledBlock =\n\t(schema: FramerProseMirrorSchema) => (state: EditorState, dispatch?: Dispatch) => {\n\t\tif (!dispatch) return false\n\t\tconst selection = state.selection\n\t\tconst blockNode = selection.$from.node(1)\n\t\tif (!isTextBlockNode(blockNode)) return false\n\t\tif (!hasTextStylePreset(blockNode)) return false\n\n\t\tconst atEndOfLine = selection.$to.parentOffset === selection.$to.parent.content.size\n\t\tif (atEndOfLine) return false\n\n\t\tconst tag = blockNode.attrs.tag\n\t\tif (tag === \"p\" || tag === \"div\") return false\n\n\t\treturn replaceWithSchemaLineBreak(schema)(state, dispatch)\n\t}\n\n/** @name addLineBreakToUnstyledBlock adds line break elements `<br>` when\n * pressing enter if the previous or current node does not have a\n * TextStylePreset. */\nexport const addLineBreakToUnstyledBlock =\n\t(schema: FramerProseMirrorSchema) => (state: EditorState, dispatch?: Dispatch) => {\n\t\tif (!dispatch) return false\n\n\t\tconst selection = state.selection\n\t\tconst blockNode = selection.$from.node(1)\n\t\tif (!isTextBlockNode(blockNode)) return false\n\t\tif (hasTextStylePreset(blockNode)) return false\n\n\t\t// We only want to add inline `<br>`'s to HTML headlines in order\n\t\t// to preserve semantic HTML.\n\t\tconst tag = blockNode.attrs.tag\n\t\tif (tag === \"p\" || tag === \"div\") return false\n\n\t\treturn replaceWithSchemaLineBreak(schema)(state, dispatch)\n\t}\n\nexport const replaceWithSchemaLineBreak =\n\t(schema: FramerProseMirrorSchema) => (state: EditorState, dispatch?: Dispatch) => {\n\t\tif (!dispatch) return false\n\t\tconst lineBreak = schema.nodes.lineBreak.create()\n\t\tconst transaction = state.tr.replaceSelectionWith(lineBreak).scrollIntoView()\n\n\t\tdispatch(transaction)\n\n\t\treturn true\n\t}\n\nexport const backspaceListItem = (schema: FramerProseMirrorSchema) => (state: EditorState, dispatch?: Dispatch) => {\n\t// This command only works:\n\tconst selection = state.selection\n\t// - Without a range selection\n\tif (selection.from !== selection.to) return false\n\n\tconst listItemNode = selection.$from.node(-1)\n\t// - For list-items\n\tif (!isListItemNode(listItemNode)) return false\n\t// - If list parent is not a blockquote\n\tif (isBlockquoteNode(selection.$from.node(-3))) return false\n\t// - Before the first character\n\tif (selection.$from.parentOffset !== 0) return false\n\t// - In the first paragraph\n\tif (selection.$from.index(-1) !== 0) return false\n\t// - In the first list-item\n\tif (selection.$from.index(-2) !== 0) return false\n\n\treturn liftListItem(schema.nodes.listItem)(\n\t\tstate,\n\t\tdispatch &&\n\t\t\t(transaction => {\n\t\t\t\tif (selection.$from.depth > 3) {\n\t\t\t\t\tconst position = selection.$from.before(-1)\n\t\t\t\t\ttransaction.join(position)\n\t\t\t\t}\n\n\t\t\t\tdispatch(transaction)\n\t\t\t}),\n\t)\n}\n", "import { wrappingInputRule } from \"prosemirror-inputrules\"\nimport type { FramerProseMirrorSchema } from \"prosemirror/schema/index.ts\"\nimport type { NumberedListNode } from \"prosemirror/schema/list.ts\"\n\n/**\n * Rule to turn digit '.' into a numberedList\n */\nexport function numberedListInputRule(schema: FramerProseMirrorSchema) {\n\treturn wrappingInputRule(\n\t\t/^([ai]|\\d+)\\.\\s$/iu,\n\t\tschema.nodes.numberedList,\n\t\tmatch => {\n\t\t\tconst value = match[1]\n\n\t\t\tswitch (value) {\n\t\t\t\tcase \"a\":\n\t\t\t\t\treturn { listStyleType: \"lower-alpha\" }\n\t\t\t\tcase \"A\":\n\t\t\t\t\treturn { listStyleType: \"upper-alpha\" }\n\t\t\t\tcase \"i\":\n\t\t\t\t\treturn { listStyleType: \"lower-roman\" }\n\t\t\t\tcase \"I\":\n\t\t\t\t\treturn { listStyleType: \"upper-roman\" }\n\t\t\t\tdefault:\n\t\t\t\t\treturn { start: Number(value) }\n\t\t\t}\n\t\t},\n\t\t(match, prevNode: NumberedListNode) => prevNode.childCount + prevNode.attrs.start === Number(match[1]),\n\t)\n}\n\n/**\n * Rule to turn -,+,* into a bulletedList\n */\nexport function bulletedListInputRule(schema: FramerProseMirrorSchema) {\n\treturn wrappingInputRule(/^\\s*([-+*])\\s$/u, schema.nodes.bulletedList)\n}\n", "import type { Node as ProseMirrorNode } from \"prosemirror-model\"\nimport type { Transaction } from \"prosemirror-state\"\nimport { AllSelection, Plugin } from \"prosemirror-state\"\nimport { ReplaceStep } from \"prosemirror-transform\"\nimport { isInlineStylesMark } from \"prosemirror/schema/inlineStyles.ts\"\nimport { isProseMirrorTextNode } from \"prosemirror/schema/text.ts\"\nimport { isTextBlockNode } from \"prosemirror/schema/textBlock.ts\"\nimport { hasTextStylePreset } from \"prosemirror/schema/utils.ts\"\n\nexport function preserveInlineStylesPlugin() {\n\treturn new Plugin({\n\t\tappendTransaction(transactions, oldState, newState) {\n\t\t\tlet transaction: Transaction | undefined\n\n\t\t\tconst blockNode = newState.selection.$from.parent\n\n\t\t\t// If the old selection was an `AllSelection`, we need to preserve\n\t\t\t// the inline styles of the text nodes, as well as the block styles\n\t\t\t// of the text block, except if the text block is already styled\n\t\t\t// with `textStylePreset`.\n\t\t\tif (oldState.selection instanceof AllSelection) {\n\t\t\t\tconst replaceTransaction = transactions.find(currentTransaction =>\n\t\t\t\t\tcurrentTransaction.steps.find(step => step instanceof ReplaceStep),\n\t\t\t\t)\n\n\t\t\t\tif (replaceTransaction) {\n\t\t\t\t\tconst oldBlockNode = oldState.doc.firstChild\n\n\t\t\t\t\t// Pasted text normally has text styles presets. We don't\n\t\t\t\t\t// want to override that.\n\t\t\t\t\tconst blockNodeDoesNotHaveTextStylePreset = isTextBlockNode(blockNode) && !hasTextStylePreset(blockNode)\n\n\t\t\t\t\tif (oldBlockNode && isTextBlockNode(oldBlockNode) && blockNodeDoesNotHaveTextStylePreset) {\n\t\t\t\t\t\tconst textNode = findTextNode(oldBlockNode)\n\n\t\t\t\t\t\ttransaction ??= newState.tr\n\n\t\t\t\t\t\tif (textNode) {\n\t\t\t\t\t\t\tconst inlineStylesMark = textNode.marks.find(isInlineStylesMark)\n\n\t\t\t\t\t\t\ttransaction.setNodeMarkup(0, oldBlockNode.type, {\n\t\t\t\t\t\t\t\t...oldBlockNode.attrs,\n\t\t\t\t\t\t\t\tinlineStyles: inlineStylesMark?.attrs.inlineStyles ?? {},\n\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\tfor (const mark of textNode.marks) {\n\t\t\t\t\t\t\t\ttransaction.addMark(0, newState.doc.content.size, mark)\n\t\t\t\t\t\t\t\ttransaction.addStoredMark(mark)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// If there is no text node (it can happen when replacing all selection of empty text)\n\t\t\t\t\t\t\t// check if there are inline styles in block and propagate to transaction so we preserve\n\t\t\t\t\t\t\t// those as well\n\t\t\t\t\t\t\tconst inlineStyles = oldBlockNode.attrs.inlineStyles\n\n\t\t\t\t\t\t\ttransaction.setNodeMarkup(0, oldBlockNode.type, {\n\t\t\t\t\t\t\t\t...oldBlockNode.attrs,\n\t\t\t\t\t\t\t\tinlineStyles,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn transaction\n\t\t},\n\t})\n}\n\nfunction findTextNode(node: ProseMirrorNode) {\n\tfor (let index = 0; index < node.childCount; index++) {\n\t\tconst child = node.child(index)\n\n\t\tif (isProseMirrorTextNode(child)) {\n\t\t\treturn child\n\t\t}\n\t}\n}\n", "import type { CanvasTree, RichTextNode } from \"document/models/CanvasTree/index.ts\"\nimport { isNodeId } from \"document/models/CanvasTree/nodes/NodeID.ts\"\nimport { isTextStylePresetNode } from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { fontStore } from \"library/render/fonts/fontStore.ts\"\n\nexport function getUnloadedFontsForRichTextNode(tree: CanvasTree, node: RichTextNode) {\n\tconst unloadedFonts = node.getFontsForLoading().filter(font => {\n\t\treturn !fontStore.isSelectorLoaded(font)\n\t})\n\n\tconst presetIds = node.getTextStylePresets(false).filter(isNodeId)\n\n\tconst unloadedPresetFonts = tree\n\t\t.getNodesWithTrait(presetIds, isTextStylePresetNode)\n\t\t.filter(preset => !fontStore.isSelectorLoaded(preset.font))\n\t\t.map(preset => preset.font)\n\n\tunloadedFonts.push(...unloadedPresetFonts)\n\n\treturn unloadedFonts\n}\n", "import { MetricsInteractionViews } from \"app/metrics.ts\"\nimport { ScopeType } from \"document/utils/scopeType.ts\"\n\nexport function getMetricsInteractionSourceForScopeType(scopeType: ScopeType): MetricsInteractionViews {\n\tswitch (scopeType) {\n\t\tcase ScopeType.ContentManagement:\n\t\tcase ScopeType.LocalizationGlossary:\n\t\t\treturn MetricsInteractionViews.CMS\n\n\t\tcase ScopeType.CanvasPage:\n\t\tcase ScopeType.DesignPage:\n\t\tcase ScopeType.LayoutTemplate:\n\t\tcase ScopeType.SmartComponent:\n\t\tcase ScopeType.VectorSet:\n\t\tcase ScopeType.WebPage:\n\t\t\treturn MetricsInteractionViews.CANVAS\n\n\t\tcase ScopeType.CustomCode:\n\t\t\treturn MetricsInteractionViews.CODE_PANEL\n\n\t\tcase ScopeType.Routes:\n\t\tcase ScopeType.Analytics:\n\t\t\treturn MetricsInteractionViews.NOT_DEFINED\n\t}\n}\n", "import { type ModuleExportIdentifierString, unhandledError } from \"@framerjs/shared\"\nimport type { BaseEngine } from \"document/base-engine/BaseEngine.ts\"\nimport { getMetricsInteractionSourceForScopeType } from \"document/components/utils/getMetricsInteractionSourceForScopeType.ts\"\nimport type { ControlProps } from \"document/models/controlProps/ControlProp.ts\"\nimport { ControlType } from \"library/render/types/PropertyControls.ts\"\nimport { NodeSelection } from \"prosemirror-state\"\nimport type { EditorView } from \"prosemirror-view\"\nimport type { FramerProseMirrorSchema } from \"prosemirror/schema/index.ts\"\nimport { moduleComponents } from \"utils/moduleComponents.ts\"\nimport { record } from \"web/lib/tracker.ts\"\nimport { addModule, getModuleIdentifierForURL, getPreloadedModuleIdentifier } from \"./moduleUtils.ts\"\n\nexport async function insertModule(\n\tengine: BaseEngine,\n\tschema: FramerProseMirrorSchema & FramerProseMirrorSchema.WithEmbeds,\n\teditorView: EditorView,\n\tidentifier: ModuleExportIdentifierString,\n\tcontrolProps: ControlProps = {},\n) {\n\tawait addModule(engine, identifier)\n\n\tconst editorState = editorView.state\n\tconst transaction = editorState.tr\n\n\ttransaction.replaceRangeWith(\n\t\teditorState.selection.from,\n\t\teditorState.selection.to,\n\t\tschema.nodes.module.create({\n\t\t\tidentifier,\n\t\t\tprops: controlProps,\n\t\t}),\n\t)\n\n\tconst fromPosition = editorState.selection.from === 0 ? 0 : editorState.selection.from - 1\n\ttransaction.setSelection(NodeSelection.create(transaction.doc, fromPosition))\n\teditorView.dispatch(transaction)\n}\n\nexport async function insertModuleURL(\n\tengine: BaseEngine,\n\tschema: FramerProseMirrorSchema & FramerProseMirrorSchema.WithEmbeds,\n\teditorView: EditorView,\n\turl: string,\n\tcontrolProps?: ControlProps,\n): Promise<void> {\n\tconst moduleIdentifier = await getModuleIdentifierForURL(engine, url)\n\tawait insertModule(engine, schema, editorView, moduleIdentifier, controlProps)\n}\n\nexport async function insertYouTube(\n\tengine: BaseEngine,\n\tschema: FramerProseMirrorSchema & FramerProseMirrorSchema.WithEmbeds,\n\teditorView: EditorView,\n\tsaveChanges: VoidFunction | undefined,\n\turl?: string,\n) {\n\trecord(\"collection_record_youtube_add\", {\n\t\tsource: getMetricsInteractionSourceForScopeType(engine.stores.scopeStore.scopeType),\n\t})\n\n\tconst controlProps: ControlProps | undefined = url\n\t\t? {\n\t\t\t\turl: {\n\t\t\t\t\ttype: ControlType.String,\n\t\t\t\t\tvalue: url,\n\t\t\t\t},\n\t\t\t}\n\t\t: undefined\n\n\ttry {\n\t\tconst moduleIdentifier = getPreloadedModuleIdentifier(engine.tree, moduleComponents.youtube)\n\t\tawait insertModule(engine, schema, editorView, moduleIdentifier, controlProps)\n\t\tsaveChanges?.()\n\t} catch (error) {\n\t\tunhandledError(error)\n\t}\n}\n\nexport async function insertVimeo(\n\tengine: BaseEngine,\n\tschema: FramerProseMirrorSchema & FramerProseMirrorSchema.WithEmbeds,\n\teditorView: EditorView,\n\tsaveChanges: VoidFunction | undefined,\n\turl?: string,\n) {\n\trecord(\"collection_record_vimeo_add\", {\n\t\tsource: getMetricsInteractionSourceForScopeType(engine.stores.scopeStore.scopeType),\n\t})\n\n\tconst controlProps: ControlProps | undefined = url\n\t\t? {\n\t\t\t\tvideo: {\n\t\t\t\t\ttype: ControlType.String,\n\t\t\t\t\tvalue: url,\n\t\t\t\t},\n\t\t\t}\n\t\t: undefined\n\n\ttry {\n\t\tconst moduleIdentifier = getPreloadedModuleIdentifier(engine.tree, moduleComponents.vimeo)\n\t\tawait insertModule(engine, schema, editorView, moduleIdentifier, controlProps)\n\t\tsaveChanges?.()\n\t} catch (error) {\n\t\tunhandledError(error)\n\t}\n}\n\nexport async function insertCodeBlock(\n\tengine: BaseEngine,\n\tschema: FramerProseMirrorSchema & FramerProseMirrorSchema.WithEmbeds,\n\teditorView: EditorView,\n\tcode: string = \"\",\n\tonSuccess?: () => unknown,\n) {\n\tconst controlProps: ControlProps = {\n\t\tcode: {\n\t\t\ttype: ControlType.String,\n\t\t\tvalue: code,\n\t\t},\n\t}\n\n\trecord(\"collection_record_codeblock_add\", {\n\t\tsource: getMetricsInteractionSourceForScopeType(engine.stores.scopeStore.scopeType),\n\t})\n\n\ttry {\n\t\tconst moduleIdentifier = getPreloadedModuleIdentifier(engine.tree, moduleComponents.codeblock)\n\t\tawait insertModule(engine, schema, editorView, moduleIdentifier, controlProps)\n\t\tonSuccess?.()\n\t} catch (error) {\n\t\tunhandledError(error)\n\t}\n}\n", "import { unhandledError } from \"@framerjs/shared\"\nimport type { BaseEngine } from \"document/base-engine/BaseEngine.ts\"\nimport type { Node as ProseMirrorNode, Slice } from \"prosemirror-model\"\nimport { AllSelection } from \"prosemirror-state\"\nimport type { EditorView } from \"prosemirror-view\"\n\nexport function handleProseMirrorPaste(\n\tengine: BaseEngine,\n\tview: EditorView,\n\t_event: ClipboardEvent,\n\tunsanitizedSlice: Slice,\n\tsanitizeSlice: (slice: Slice) => Slice,\n\tpreparePaste?: () => Promise<void>,\n) {\n\tif (unsanitizedSlice.content.size === 0) return false\n\n\tconst paste = () => {\n\t\tconst state = view.state\n\t\tconst transaction = state.tr\n\n\t\tconst slice = sanitizeSlice(unsanitizedSlice)\n\n\t\tconst singleNode = sliceSingleNode(slice)\n\n\t\t// Need to add type explicitly because prosemirror-model's types are incorrect.\n\t\tconst blockNode = state.selection.$from.node(1) as ProseMirrorNode | undefined\n\t\tconst blockNodePosition = state.selection.$from.before(1)\n\n\t\t// If the pasted slice consists of inline nodes only,\n\t\t// it cannot replace the current node and instead has to be inserted into it.\n\t\tconst canReplaceBlockNode = !slice.content.child(0).isInline\n\t\t// If the current node under selection is empty or the whole document is selected,\n\t\t// we should replace the node(s) under selection with pasted slice.\n\t\tconst shouldReplaceBlockNode = state.selection instanceof AllSelection || blockNode?.content.size === 0\n\n\t\tif (singleNode) {\n\t\t\t// If the pasted content is a single node, we can just insert it into the current node,\n\t\t\t// and inherit the styles from the current node.\n\t\t\ttransaction.replaceSelectionWith(singleNode, true)\n\t\t} else if (canReplaceBlockNode && shouldReplaceBlockNode) {\n\t\t\tconst toPosition = blockNode ? blockNodePosition + blockNode.nodeSize : state.selection.to\n\t\t\ttransaction.replaceRange(blockNodePosition, toPosition, slice)\n\t\t} else {\n\t\t\ttransaction.replaceSelection(slice)\n\t\t}\n\n\t\t// These lines are copied from the ProseMirror's default implementation.\n\t\t// @see https://github.com/ProseMirror/prosemirror-view/blob/8f246f320801f8e3cac92c97f71ac91e3e327f2f/src/input.js#L561\n\t\ttransaction.scrollIntoView()\n\t\ttransaction.setMeta(\"paste\", true)\n\t\ttransaction.setMeta(\"uiEvent\", \"paste\")\n\n\t\tview.dispatch(transaction)\n\t}\n\n\tif (preparePaste) {\n\t\tvoid preparePaste()\n\t\t\t.catch(error => {\n\t\t\t\tunhandledError(error)\n\t\t\t})\n\t\t\t.then(() => {\n\t\t\t\tengine.scheduler.processWhenReady(paste)\n\t\t\t})\n\t} else {\n\t\tengine.scheduler.processWhenReady(paste)\n\t}\n\n\treturn true\n}\n\nfunction sliceSingleNode(slice: Slice) {\n\treturn slice.openStart === 0 && slice.openEnd === 0 && slice.content.childCount === 1\n\t\t? slice.content.firstChild\n\t\t: null\n}\n", "import type { Asset } from \"@framerjs/assets\"\nimport {\n\tcreateAssetReference,\n\tcreateAssetReferenceForImage,\n\tgetAssetFilename,\n\tparseAssetReference,\n} from \"@framerjs/assets\"\nimport { assert, getLogger } from \"@framerjs/shared\"\nimport type { BaseEngine } from \"document/base-engine/BaseEngine.ts\"\nimport type { Transaction } from \"prosemirror-state\"\nimport type { EditorView } from \"prosemirror-view\"\nimport { isImageNode } from \"prosemirror/schema/image.ts\"\nimport type { FramerProseMirrorSchema } from \"prosemirror/schema/index.ts\"\nimport { BatchAssetUploader } from \"web/lib/BatchAssetUploader.ts\"\nimport { createBatchProgressToast } from \"web/lib/batchUploaderUtils.tsx\"\nimport { type ImageSize, imageSizeToNonZero } from \"web/lib/images/image.ts\"\nimport * as supportedImages from \"web/lib/images/supportedFormats.ts\"\nimport { chooseFileService } from \"web/pages/project/lib/ChooseFileService.ts\"\nimport type { AssetUploadResult } from \"web/pages/project/lib/UploadService.ts\"\n\nconst log = getLogger(\"prosemirror:addMedia\")\n\nexport interface MediaNodeData {\n\tsrc: string\n\ttype: \"image\" | \"video\"\n}\n\ninterface Options {\n\t/**\n\t * How the media is being added\n\t */\n\ttype: \"drop\" | \"paste\" | \"upload\"\n\t/**\n\t * the specific location where the media should be added to the document\n\t */\n\tinsertPosition?: number\n\t/**\n\t * In the case of an html pasted with images in it, ProseMirror will already\n\t * construct the image nodes so we can just update them later.\n\t */\n\tmediaExtractedFromHTML?: boolean\n}\n\ninterface Uploads {\n\tuploadResultTask: () => Promise<AssetUploadResult>\n\ttemporaryURL: string\n\ttype: MediaNodeData[\"type\"]\n}\n\nconst videoTypes = [{ extension: \"mp4\", mimeType: \"video/mp4\" }]\n\nfunction isVideoFile(filename: string): boolean {\n\tfilename = filename.toLowerCase()\n\treturn videoTypes.some(({ extension }) => filename.endsWith(`.${extension}`))\n}\n\nfunction isVideoType(type: string): boolean {\n\treturn type.startsWith(\"video/\")\n}\n\n// Merge supported image types with video types.\nconst supportedMediaFileTypes = [...supportedImages.extensions]\nconst supportedMediaMimeTypes = new Set(supportedImages.mimeTypes)\nfor (const { extension, mimeType } of videoTypes) {\n\tsupportedMediaFileTypes.push(extension)\n\tsupportedMediaMimeTypes.add(mimeType)\n}\n\nexport const failedUploadPlaceholder = \"failed-asset-upload-placeholder\"\n\nconst updateAssetReferencesMetaKey = \"updateAssetReferences\"\nexport function transactionNeedsAssetReferencesUpdate(tr: Transaction) {\n\treturn tr.getMeta(updateAssetReferencesMetaKey)\n}\nexport function setTransactionNeedsAssetReferencesUpdate(tr: Transaction) {\n\treturn tr.setMeta(updateAssetReferencesMetaKey, true)\n}\n\nexport async function addMedia(\n\tengine: BaseEngine,\n\tschema: FramerProseMirrorSchema & FramerProseMirrorSchema.WithMedia,\n\tview: EditorView,\n\tfiles: (MediaNodeData | File)[] | FileList,\n\t{ type, insertPosition, mediaExtractedFromHTML }: Options,\n): Promise<void> {\n\tconst state = view.state\n\tconst transaction = state.tr\n\tconst uploader = new BatchAssetUploader(engine, { silent: mediaExtractedFromHTML })\n\n\tconst uploads: Uploads[] = []\n\tconst imageNodesToAdd: { src: string; isVideo: boolean }[] = []\n\tconst blobURLsToRevoke: string[] = []\n\tfor (const file of files) {\n\t\tif (!(file instanceof File)) {\n\t\t\tconst assetRef = parseAssetReference(file.src)\n\t\t\tif (assetRef) {\n\t\t\t\timageNodesToAdd.push({\n\t\t\t\t\tsrc: file.src,\n\t\t\t\t\tisVideo: isVideoFile(assetRef.originalFilename ?? assetRef.identifier),\n\t\t\t\t})\n\t\t\t\t// No need to upload this file.\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\timageNodesToAdd.push({ src: file.src, isVideo: isVideoFile(file.src) })\n\t\t\tuploads.push({\n\t\t\t\tuploadResultTask: uploader.createTask(file.src, asset => asset),\n\t\t\t\ttemporaryURL: file.src,\n\t\t\t\ttype: file.type,\n\t\t\t})\n\t\t} else {\n\t\t\tconst isVideoFile = isVideoType(file.type)\n\n\t\t\tassert(!mediaExtractedFromHTML, \"we should not receive files if the media is already in a document\")\n\n\t\t\tif (!supportedMediaMimeTypes.has(file.type)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst temporaryURL = URL.createObjectURL(file)\n\t\t\tuploads.push({\n\t\t\t\tuploadResultTask: uploader.createTask(file, asset => asset),\n\t\t\t\ttemporaryURL,\n\t\t\t\ttype: isVideoFile ? \"video\" : \"image\",\n\t\t\t})\n\t\t\timageNodesToAdd.push({ src: temporaryURL, isVideo: isVideoFile })\n\t\t\tblobURLsToRevoke.push(temporaryURL)\n\t\t}\n\t}\n\n\tif (!uploads.length) return Promise.resolve()\n\n\tif (!mediaExtractedFromHTML) {\n\t\tfor (const { src, isVideo } of imageNodesToAdd) {\n\t\t\tconst node = schema.nodes.image.create({ src, type: isVideo ? \"video\" : \"image\" })\n\t\t\tif (insertPosition) {\n\t\t\t\ttransaction.insert(insertPosition, node)\n\t\t\t} else {\n\t\t\t\tstate.selection.replaceWith(transaction, node)\n\t\t\t}\n\t\t}\n\t}\n\n\ttransaction.scrollIntoView()\n\tif (type === \"drop\" || type === \"paste\") {\n\t\ttransaction.setMeta(type, true)\n\t\ttransaction.setMeta(\"uiEvent\", type)\n\t}\n\n\tview.dispatch(transaction)\n\n\tconst runningTasks = uploads.map(upload => upload.uploadResultTask())\n\n\tif (mediaExtractedFromHTML) {\n\t\tcreateBatchProgressToast(uploader, runningTasks).catch(() => {})\n\t}\n\n\tconst settledResults = await Promise.allSettled(runningTasks)\n\n\tconst results = settledResults.map((settledResult, index) => processAssetUploadResult(settledResult, index, uploads))\n\n\tconst assets: Asset[] = []\n\tresults.forEach(result => {\n\t\tif (result.type === \"asset\") return assets.push(result.asset)\n\t})\n\n\tconst replacementMap = new Map<string, ReplacementMapValue>()\n\tuploads.forEach((upload, i) => {\n\t\tconst result = results[i]\n\t\tassert(result, \"Asset upload result must be defined\")\n\t\treplacementMap.set(upload.temporaryURL, result)\n\t})\n\n\treplaceTemporaryBlobs(view, replacementMap)\n\tblobURLsToRevoke.forEach(url => URL.revokeObjectURL(url))\n}\n\nfunction processAssetUploadResult(\n\tsettledResult: PromiseSettledResult<AssetUploadResult>,\n\tindex: number,\n\tuploads: Uploads[],\n): ReplacementMapValue {\n\tswitch (settledResult.status) {\n\t\tcase \"fulfilled\": {\n\t\t\tconst { value: uploadResult } = settledResult\n\t\t\tconst { asset } = uploadResult\n\n\t\t\tif (uploadResult.type === \"image\") {\n\t\t\t\treturn {\n\t\t\t\t\ttype: \"asset\",\n\t\t\t\t\tasset: asset,\n\t\t\t\t\timageSize: uploadResult.imageSize,\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn { type: \"asset\", asset }\n\t\t\t}\n\t\t}\n\t\tcase \"rejected\": {\n\t\t\t// Get the type we stored on the uploads object as a fallback\n\t\t\tconst upload = uploads[index]\n\t\t\tassert(upload, \"Upload must be defined\")\n\t\t\tlog.reportError(new Error(settledResult.reason))\n\n\t\t\treturn { type: \"failed upload\" }\n\t\t}\n\t}\n}\n\nexport async function pickAndAddMedia(\n\tengine: BaseEngine,\n\tschema: FramerProseMirrorSchema & FramerProseMirrorSchema.WithMedia,\n\tview: EditorView,\n\toptions: Options,\n) {\n\tconst files = await chooseFileService.pickFile({ allowedFileTypes: supportedMediaFileTypes })\n\tif (!files) return\n\tconst file = files[0]\n\treturn addMedia(engine, schema, view, [file], options)\n}\n\ntype ReplacementMapValue = { type: \"asset\"; asset: Asset; imageSize?: ImageSize } | { type: \"failed upload\" }\n\nfunction replaceTemporaryBlobs(view: EditorView, replacementMap: Map<string, ReplacementMapValue>) {\n\tconst state = view.state\n\tconst transaction = state.tr\n\tstate.doc.descendants((node, position) => {\n\t\tif (!isImageNode(node)) return\n\t\tconst result = replacementMap.get(node.attrs.src)\n\t\tif (result === undefined) return\n\n\t\tconst attrs = { ...node.attrs }\n\n\t\tif (result.type === \"failed upload\") {\n\t\t\t// We failed to upload the image, since we don't have a stored asset.\n\t\t\tattrs.src = failedUploadPlaceholder\n\t\t} else {\n\t\t\tif (result.imageSize) {\n\t\t\t\tattrs.src = createAssetReferenceForImage({\n\t\t\t\t\tidentifier: getAssetFilename(result.asset),\n\t\t\t\t\tintrinsicSize: {\n\t\t\t\t\t\twidth: result.imageSize.naturalWidth,\n\t\t\t\t\t\theight: result.imageSize.naturalHeight,\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\t// Non-zero as to have something visible\n\t\t\t\tconst nonZeroImageSize = imageSizeToNonZero(result.imageSize)\n\t\t\t\tattrs.pixelWidth = nonZeroImageSize.nonZeroNaturalWidth\n\t\t\t\tattrs.pixelHeight = nonZeroImageSize.nonZeroNaturalHeight\n\t\t\t} else {\n\t\t\t\tattrs.src = createAssetReference(getAssetFilename(result.asset))\n\t\t\t}\n\t\t}\n\n\t\ttransaction.setNodeMarkup(position, node.type, attrs)\n\t\tsetTransactionNeedsAssetReferencesUpdate(transaction)\n\t})\n\tview.dispatch(transaction)\n}\n", "export function sanitizeGoogleDocsHTML<T extends DocumentFragment | Element>(container: T) {\n\tconst content =\n\t\tcontainer.querySelector(\"b[id^='docs-internal-guid']\") ??\n\t\tcontainer.querySelector(\"*[id^='docs-internal-guid']\")?.parentElement\n\tif (!content) return\n\n\tfor (let i = content.children.length - 1; i >= 0; i--) {\n\t\tconst element = content.children[i]\n\t\tif (!element) continue\n\n\t\tif (element instanceof HTMLDivElement) {\n\t\t\tunwrapTable(element)\n\t\t}\n\n\t\twhile (isEmptyElement(element.firstChild)) {\n\t\t\telement.removeChild(element.firstChild)\n\t\t}\n\n\t\twhile (isEmptyElement(element.lastChild)) {\n\t\t\telement.removeChild(element.lastChild)\n\t\t}\n\n\t\tif (element.tagName === \"BR\" || element.childNodes.length === 0) {\n\t\t\telement.remove()\n\t\t}\n\t}\n}\n\nfunction isEmptyElement(element: Node | null): element is Element {\n\treturn element instanceof Element && element.textContent === \"\" && element.querySelectorAll(\"img\").length === 0\n}\n\nfunction unwrapTable(element: HTMLElement) {\n\tconst table = element.querySelector(\"table\")\n\tif (table === null) return\n\tconst rows = table.querySelectorAll(\"tr\")\n\tif (rows.length === 0) return\n\tconst cells = table.querySelectorAll(\"th, td\")\n\tif (cells.length === 0) return\n\telement.replaceWith(table)\n}\n", "import type { BaseEngine } from \"document/base-engine/BaseEngine.ts\"\nimport { DOMSerializer, type Fragment } from \"prosemirror-model\"\nimport type { FramerProseMirrorSchema } from \"../schema/index.ts\"\nimport type { DOMMarkSerializerSpec, DOMNodeSerializerSpec } from \"../types.ts\"\n\n/**\n * Extends the standard DOM serializer to\n * - pass `engine` into every node and mark\u2019s serializer, to enable extra features\n *   like serializing `href`s on links,\n * - execute a callback after serializing a fragment.\n *\n * This serializer is used by plugins like `clipboardPlugin` to serialize DOM\n * that goes into the clipboard.\n */\nexport class DOMSerializerWithEngineAndHooks extends DOMSerializer {\n\tconstructor(\n\t\tengine: BaseEngine,\n\t\tschema: FramerProseMirrorSchema,\n\t\tprivate onAfterSerializeFragment?: (result: HTMLElement | DocumentFragment) => void,\n\t) {\n\t\t// Having to do an `as` because *our* serializers have the additional `engine` param,\n\t\t// but `nodesFromSchema()` types don\u2019t know about that\n\t\tconst nodes = DOMSerializer.nodesFromSchema(schema) as Record<string, DOMNodeSerializerSpec<unknown>>\n\t\tconst marks = DOMSerializer.marksFromSchema(schema) as Record<string, DOMMarkSerializerSpec<unknown>>\n\n\t\tconst nodesWithEngine: DOMSerializer[\"nodes\"] = {}\n\t\tconst marksWithEngine: DOMSerializer[\"marks\"] = {}\n\n\t\tfor (const [name, nodeToDOM] of Object.entries(nodes)) {\n\t\t\tnodesWithEngine[name] = (...args) => nodeToDOM(...args, engine)\n\t\t}\n\t\tfor (const [name, markToDOM] of Object.entries(marks)) {\n\t\t\tmarksWithEngine[name] = (...args) => markToDOM(...args, engine)\n\t\t}\n\n\t\tsuper(nodesWithEngine, marksWithEngine)\n\t}\n\n\toverride serializeFragment(\n\t\tfragment: Fragment,\n\t\toptions?: Record<string, unknown>,\n\t\ttarget: HTMLElement | DocumentFragment = document.createDocumentFragment(),\n\t) {\n\t\tsuper.serializeFragment(fragment, options, target)\n\t\tthis.onAfterSerializeFragment?.(target)\n\t\treturn target\n\t}\n}\n", "import {\n\ttype ExternalModuleExportIdentifier,\n\texternalModuleIdentifier,\n\tisExternalModuleIdentifier,\n\tisModuleExportIdentifier,\n\ttype ModuleExportIdentifierString,\n\tparseModuleIdentifier,\n\ttoLocalIdentifier,\n\tunhandledError,\n} from \"@framerjs/shared\"\nimport { experiments } from \"app/experiments.ts\"\nimport type { BaseEngine } from \"document/base-engine/BaseEngine.ts\"\nimport {\n\tinsertModule,\n\tinsertModuleURL,\n\tinsertVimeo,\n\tinsertYouTube,\n} from \"document/components/chrome/richTextEditor/richTextEditorModules.ts\"\nimport { handleProseMirrorPaste } from \"document/components/utils/handleProseMirrorPaste.ts\"\nimport { LinkStylePresetNode } from \"document/models/CanvasTree/nodes/LinkStylePresetNode.ts\"\nimport { TextStylePresetNode } from \"document/models/CanvasTree/nodes/TextStylePresetNode.ts\"\nimport { isTextStylePresetPrimaryNode } from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { shouldOpenLinkInNewTab } from \"document/models/CanvasTree/traits/WithLink.ts\"\nimport { type RichTextTag, isRichTextTag } from \"document/models/CanvasTree/traits/WithRichTextTag.ts\"\nimport { type LinkToWebPage, createLink, isLinkToURL } from \"document/models/CanvasTree/traits/utils/Link.ts\"\nimport { isModuleURL } from \"modules/utils.ts\"\nimport { Slice } from \"prosemirror-model\"\nimport { AllSelection, Plugin, TextSelection } from \"prosemirror-state\"\nimport { Transform } from \"prosemirror-transform\"\nimport type { EditorView } from \"prosemirror-view\"\nimport { type MediaNodeData, addMedia } from \"prosemirror/addMedia.ts\"\nimport { sanitizeGoogleDocsHTML } from \"prosemirror/sanitizeGoogleDocs.ts\"\nimport { isImageNode } from \"prosemirror/schema/image.ts\"\nimport {\n\ttype FramerProseMirrorSchema,\n\tschemaSupportsEmbeds,\n\tschemaSupportsLinks,\n\tschemaSupportsMedia,\n\tschemaSupportsStyles,\n} from \"prosemirror/schema/index.ts\"\nimport { isInlineStylesMark } from \"prosemirror/schema/inlineStyles.ts\"\nimport { isLinkMark } from \"prosemirror/schema/link.ts\"\nimport { CMS_MODULE_IDENTIFIER_ATTR, CMS_MODULE_TAG, isModuleNode } from \"prosemirror/schema/module.ts\"\nimport { isTextBlockNode } from \"prosemirror/schema/textBlock.ts\"\nimport { DOMSerializerWithEngineAndHooks } from \"prosemirror/serialization/domWithEngineAndHooks.ts\"\nimport { isLikelyMarkdownText, parseRichTextFromMarkdown } from \"prosemirror/serialization/markdown.ts\"\nimport { getDefaultLinkStylePreset, insertLinkStylePreset } from \"utils/linkStylePresetUtils.ts\"\nimport { parseHTML } from \"utils/parseHTML.ts\"\nimport { getWebPageLinkFromURL } from \"utils/resolveLink.ts\"\nimport { getDefaultTextStylePreset, insertTextStylePreset } from \"utils/textStylePresetUtils.ts\"\nimport { isString } from \"utils/typeChecks.ts\"\n\nconst VIMEO_URL_REGEX = /^https?:\\/\\/(?:www\\.)?vimeo\\.com\\/\\d+/u\nconst YOUTUBE_URL_REGEX = /^https?:\\/\\/(?:www\\.)?youtu(?:\\.be|be\\.com)/u\n\nexport function clipboardPlugin({\n\tengine,\n\tschema,\n\tstylePresetGetters,\n\tsupportedTags,\n\tsaveChanges,\n}: {\n\tengine: BaseEngine\n\tschema: FramerProseMirrorSchema\n\tstylePresetGetters?: {\n\t\tgetStylePresetForTag: (tag: RichTextTag) => TextStylePresetNode | undefined\n\t\tgetStylePresetForLink: () => LinkStylePresetNode | undefined\n\t}\n\tsupportedTags?: Set<string> | undefined\n\tsaveChanges?: VoidFunction | undefined\n}) {\n\treturn new Plugin({\n\t\tprops: {\n\t\t\tclipboardSerializer: new DOMSerializerWithEngineAndHooks(\n\t\t\t\tengine,\n\t\t\t\tschema,\n\t\t\t\tcreateClipboardSerializationHook(engine, Boolean(stylePresetGetters)),\n\t\t\t),\n\n\t\t\ttransformPastedHTML(html: string) {\n\t\t\t\tconst container = parseHTML(html)\n\t\t\t\tsanitizeGoogleDocsHTML(container)\n\t\t\t\treturn container.innerHTML\n\t\t\t},\n\n\t\t\ttransformPasted(slice) {\n\t\t\t\treturn replaceExternalModuleIdentifiersInPastedSlice(engine, schema, slice)\n\t\t\t},\n\n\t\t\thandlePaste(view, event, unsanitizedSlice) {\n\t\t\t\tconst plainText = event.clipboardData?.getData(\"text/plain\")\n\t\t\t\tconst richText = event.clipboardData?.getData(\"text/html\")\n\n\t\t\t\tif (schemaSupportsMedia(schema)) {\n\t\t\t\t\tconst { clipboardData } = event\n\t\t\t\t\tif (clipboardData && clipboardData.files.length > 0) {\n\t\t\t\t\t\tvoid addMedia(engine, schema, view, clipboardData.files, {\n\t\t\t\t\t\t\ttype: \"paste\",\n\t\t\t\t\t\t}).finally(saveChanges)\n\t\t\t\t\t\treturn true\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (isString(plainText)) {\n\t\t\t\t\t// If pasting a URL, and some text is selected, make that text a link (a-la Notion)\n\t\t\t\t\tconst linkPrefixes = [\"http:\", \"https:\", \"mailto:\", \"www.\"]\n\t\t\t\t\tconst textHasLink = linkPrefixes.some(linkPrefix => plainText.startsWith(linkPrefix))\n\t\t\t\t\tconst selection = view.state.selection\n\t\t\t\t\tif (textHasLink && selection.from !== selection.to && schemaSupportsLinks(schema)) {\n\t\t\t\t\t\tconst link = getWebPageLinkFromURL(plainText, engine) ?? createLink({ url: plainText })\n\t\t\t\t\t\tconst transaction = view.state.tr\n\n\t\t\t\t\t\ttransaction.addMark(\n\t\t\t\t\t\t\tselection.from,\n\t\t\t\t\t\t\tselection.to,\n\t\t\t\t\t\t\tschema.marks.link.create({\n\t\t\t\t\t\t\t\tlink: link,\n\t\t\t\t\t\t\t\topenInNewTab: shouldOpenLinkInNewTab(link),\n\t\t\t\t\t\t\t\tsmoothScroll: false,\n\t\t\t\t\t\t\t\tclickTrackingId: undefined,\n\t\t\t\t\t\t\t\tlinkStylePreset: undefined,\n\t\t\t\t\t\t\t\trelValues: undefined,\n\t\t\t\t\t\t\t\tpreserveParams: false,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\tview.dispatch(transaction)\n\t\t\t\t\t\treturn true\n\t\t\t\t\t}\n\n\t\t\t\t\t// If pasting a component, render it\n\t\t\t\t\tif (schemaSupportsEmbeds(schema) && experiments.isOn(\"cmsPasteModules\")) {\n\t\t\t\t\t\tconst parsedIdentifier = parseModuleIdentifier(plainText)\n\t\t\t\t\t\tif (isModuleExportIdentifier(parsedIdentifier)) {\n\t\t\t\t\t\t\tinsertModule(engine, schema, view, parsedIdentifier.value).catch(unhandledError)\n\t\t\t\t\t\t\treturn true\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (isModuleURL(plainText)) {\n\t\t\t\t\t\t\tinsertModuleURL(engine, schema, view, plainText).catch(unhandledError)\n\t\t\t\t\t\t\treturn true\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// If pasting a YouTube or Vimeo video, embed it\n\t\t\t\t\tif (schemaSupportsEmbeds(schema)) {\n\t\t\t\t\t\tif (YOUTUBE_URL_REGEX.test(plainText)) {\n\t\t\t\t\t\t\tinsertYouTube(engine, schema, view, saveChanges, plainText).catch(unhandledError)\n\t\t\t\t\t\t\treturn true\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (VIMEO_URL_REGEX.test(plainText)) {\n\t\t\t\t\t\t\tinsertVimeo(engine, schema, view, saveChanges, plainText).catch(unhandledError)\n\t\t\t\t\t\t\treturn true\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn handleProseMirrorPaste(\n\t\t\t\t\tengine,\n\t\t\t\t\tview,\n\t\t\t\t\tevent,\n\t\t\t\t\tunsanitizedSlice,\n\t\t\t\t\tslice => {\n\t\t\t\t\t\t// If the text must match formatting, only remap module identifiers.\n\t\t\t\t\t\tif (stylePresetGetters && richText && mustMatchFormatting(richText)) {\n\t\t\t\t\t\t\treturn replaceExternalModuleIdentifiersInPastedSlice(engine, schema, slice)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// If the plain text looks like markdown, parse it as markdown (ignoring the rich text).\n\t\t\t\t\t\t//\n\t\t\t\t\t\t// The condition of this `if` was a subject of much thought. If you look at other block\n\t\t\t\t\t\t// editors that can parse markdown, you\u2019ll see that\n\t\t\t\t\t\t// - some of them will always attempt to parse Markdown from plain text, even if\n\t\t\t\t\t\t//   rich text includes something else (example: Craft.do)\n\t\t\t\t\t\t// - whereas others will only parse Markdown from plain text if rich text is absent\n\t\t\t\t\t\t//   (example: Notion)\n\t\t\t\t\t\t//\n\t\t\t\t\t\t// We\u2019ve chosen the second implementation. It has benefits and drawbacks.\n\t\t\t\t\t\t// - The drawback is that it doesn\u2019t allow us to copy Markdown from VSCode (which will copy it both\n\t\t\t\t\t\t//   as plain text + as rich text with syntax highlighting).\n\t\t\t\t\t\t// - The benefit is that a lot of rich text content *vaguely* resembles markdown\n\t\t\t\t\t\t//   (close enough that it triggers `isLikelyMarkdownText()`), and if we do interpret it as markdown,\n\t\t\t\t\t\t//   we\u2019ll end up losing actually important formatting: https://framer-team.slack.com/archives/C068W7EDVMY/p1761312699135479\n\t\t\t\t\t\tconst isPlainTextMarkdown = isLikelyMarkdownText(plainText)\n\t\t\t\t\t\tif (plainText && isPlainTextMarkdown && !richText) {\n\t\t\t\t\t\t\tslice = parseRichTextFromMarkdown(plainText, schema)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// To sanitize the pasted slice, we use the Transform API. Normally, Transforms are used\n\t\t\t\t\t\t// to chain several steps that can be \u2318Z\u2019s and \u2318\u21E7Z\u2019d [1]. That is *not* our use case.\n\t\t\t\t\t\t// Instead, we use a Transform because it provides a convenient API for doing high-level\n\t\t\t\t\t\t// operations on a fragment in one line (`.setNodeMarkup`, `.removeMark`, etc.).\n\t\t\t\t\t\t// Once we\u2019re done with the Transform, we convert it back to a Slice, throwing away\n\t\t\t\t\t\t// the whole edit history.\n\t\t\t\t\t\t//\n\t\t\t\t\t\t// [1] https://prosemirror.net/docs/ref/#transform\n\t\t\t\t\t\tconst transform = createTransformFromSlice(schema, slice)\n\n\t\t\t\t\t\tif (schemaSupportsEmbeds(schema)) {\n\t\t\t\t\t\t\treplaceExternalModuleIdentifiersInTransform(engine, schema, transform)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Cache lookups of web page links for the duration of the paste operation,\n\t\t\t\t\t\t// since there might be multiple link marks linking to the same page, and since\n\t\t\t\t\t\t// looking up a web page might incur a tree walk\n\t\t\t\t\t\tconst urlToLinkCache = new Map<string, LinkToWebPage | undefined>()\n\t\t\t\t\t\tconst imageSources: MediaNodeData[] = []\n\t\t\t\t\t\ttransform.doc.descendants((node, position) => {\n\t\t\t\t\t\t\tif (isTextBlockNode(node)) {\n\t\t\t\t\t\t\t\tconst tag = node.attrs.tag\n\t\t\t\t\t\t\t\tconst isSupported = supportedTags?.has(tag) ?? true\n\t\t\t\t\t\t\t\tconst validTag: RichTextTag = isRichTextTag(tag) && isSupported ? tag : \"p\"\n\n\t\t\t\t\t\t\t\ttransform.setNodeMarkup(position, schema.nodes.textBlock, {\n\t\t\t\t\t\t\t\t\t...node.attrs,\n\t\t\t\t\t\t\t\t\tblockStyles: {},\n\t\t\t\t\t\t\t\t\tinlineStyles: {},\n\t\t\t\t\t\t\t\t\ttextStylePreset: undefined,\n\t\t\t\t\t\t\t\t\ttag: validTag,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (isImageNode(node)) {\n\t\t\t\t\t\t\t\timageSources.push({ src: node.attrs.src, type: node.attrs.type })\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfor (const mark of node.marks) {\n\t\t\t\t\t\t\t\tif (!isLinkMark(mark)) continue\n\t\t\t\t\t\t\t\tif (!isLinkToURL(mark.attrs.link)) continue\n\n\t\t\t\t\t\t\t\tconst url = mark.attrs.link.url\n\n\t\t\t\t\t\t\t\tlet webPageLink: LinkToWebPage | undefined\n\t\t\t\t\t\t\t\t// Note that we\u2019re treating `.has()` differently from `.get()` that returns `undefined`\n\t\t\t\t\t\t\t\t// because it\u2019s valid to store `undefined` in the cache.\n\t\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t\t// `.has() === false` means that we didn\u2019t check the URL; `.has() === true` and\n\t\t\t\t\t\t\t\t// `.get() === undefined` means that we did, and the URL did not map to any web page.\n\t\t\t\t\t\t\t\tif (urlToLinkCache.has(url)) {\n\t\t\t\t\t\t\t\t\twebPageLink = urlToLinkCache.get(url)\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\twebPageLink = getWebPageLinkFromURL(url, engine)\n\t\t\t\t\t\t\t\t\turlToLinkCache.set(url, webPageLink)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (!webPageLink) continue\n\n\t\t\t\t\t\t\t\t// No need to remove the previous mark since a node can\u2019t have multiple links at once.\n\t\t\t\t\t\t\t\t// ProseMirror will automatically remove the previous link.\n\t\t\t\t\t\t\t\ttransform.addMark(\n\t\t\t\t\t\t\t\t\tposition,\n\t\t\t\t\t\t\t\t\tposition + node.nodeSize,\n\t\t\t\t\t\t\t\t\tmark.type.create({\n\t\t\t\t\t\t\t\t\t\t...mark.attrs,\n\t\t\t\t\t\t\t\t\t\tlink: webPageLink,\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})\n\n\t\t\t\t\t\tif (imageSources.length && schemaSupportsMedia(schema)) {\n\t\t\t\t\t\t\tvoid addMedia(engine, schema, view, imageSources, {\n\t\t\t\t\t\t\t\ttype: \"paste\",\n\t\t\t\t\t\t\t\tmediaExtractedFromHTML: true,\n\t\t\t\t\t\t\t}).finally(saveChanges)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (schemaSupportsStyles(schema) && stylePresetGetters) {\n\t\t\t\t\t\t\tconst state = view.state\n\t\t\t\t\t\t\tconst selection = state.selection\n\t\t\t\t\t\t\t// We can check if the cursor is in an empty line if the parent node of the\n\t\t\t\t\t\t\t// selection is empty. Even an empty text editor will have at least one\n\t\t\t\t\t\t\t// node.\n\t\t\t\t\t\t\tconst from = selection.$from\n\t\t\t\t\t\t\tconst parentNode = from.parent\n\t\t\t\t\t\t\tconst parentContent = parentNode.textContent\n\t\t\t\t\t\t\tconst isInLineWithText = isTextBlockNode(parentNode) && parentContent.length > 0\n\n\t\t\t\t\t\t\tconst isAllSelection = selection instanceof AllSelection\n\n\t\t\t\t\t\t\t// The heuristic here is: when the user pastes something with \u2318\u21E7V (or right-click \u2192\n\t\t\t\t\t\t\t// \u201CPaste and match style\u201D), we should match the style of the pasted text to the\n\t\t\t\t\t\t\t// surrounding text.\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// HOWEVER, if the pasted text is markdown, we explicitly avoid this heuristic.\n\t\t\t\t\t\t\t// Not only this seems to match the user intent better (if they copied markdown,\n\t\t\t\t\t\t\t// they expect that markdown to use default style presets), but it also prevents\n\t\t\t\t\t\t\t// the surrounding styles (e.g. <p>) overriding and discarding whatever styles we\n\t\t\t\t\t\t\t// parsed from markdown (<h1> <b> <i> etc).\n\t\t\t\t\t\t\tconst pasteHasPlainTextOnly = !richText && plainText && plainText.length > 0\n\t\t\t\t\t\t\tconst matchStyle = pasteHasPlainTextOnly && !isPlainTextMarkdown\n\n\t\t\t\t\t\t\t// The logic for pasting should reflect the following\n\t\t\t\t\t\t\t// behavior: If the cursor is in a line with text, then we\n\t\t\t\t\t\t\t// adapt the styles of the selection to the pasted text.\n\t\t\t\t\t\t\t// Otherwise, we style each text block (p, h1, \u2026) with text\n\t\t\t\t\t\t\t// styles presets.\n\t\t\t\t\t\t\tif (!isInLineWithText && !matchStyle && !isAllSelection) {\n\t\t\t\t\t\t\t\tsanitizePastedSliceToUseStylePresets(\n\t\t\t\t\t\t\t\t\tengine,\n\t\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\t\tstylePresetGetters.getStylePresetForTag,\n\t\t\t\t\t\t\t\t\tstylePresetGetters.getStylePresetForLink,\n\t\t\t\t\t\t\t\t\ttransform,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tsanitizePastedSliceToMatchSurroundingStyles(view, schema, transform)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn createSliceFromTransform(slice, transform)\n\t\t\t\t\t},\n\t\t\t\t\tcreateRichTextModulePastePreparation(engine, schema, unsanitizedSlice),\n\t\t\t\t)\n\t\t\t},\n\t\t},\n\t})\n}\n\nconst FRAMER_MATCH_FORMATTING_COMMENT_STRING = \"framer-match-formatting\"\nconst comment = document.createComment(FRAMER_MATCH_FORMATTING_COMMENT_STRING)\nconst moduleSelector = `${CMS_MODULE_TAG}[${CMS_MODULE_IDENTIFIER_ATTR}]`\n\nfunction createTransformFromSlice(schema: FramerProseMirrorSchema, slice: Slice): Transform {\n\tconst doc = schema.nodes.document.create(undefined)\n\tconst transform = new Transform(doc)\n\ttransform.insert(0, slice.content)\n\treturn transform\n}\n\nfunction createSliceFromTransform(slice: Slice, transform: Transform): Slice {\n\t/**\n\t * If pasting only span text nodes, we need to paste the content of the first child only\n\t * so the document schema is valid (it doesn't allow document to have text nodes as immediate children).\n\t */\n\tconst transformedFragment = slice.content.firstChild?.isInline\n\t\t? transform.doc.content.child(0).content\n\t\t: transform.doc.content\n\n\treturn new Slice(transformedFragment, slice.openStart, slice.openEnd)\n}\n\nfunction replaceExternalModuleIdentifiersInPastedSlice(\n\tengine: BaseEngine,\n\tschema: FramerProseMirrorSchema,\n\tslice: Slice,\n): Slice {\n\tif (!schemaSupportsEmbeds(schema)) return slice\n\n\tconst transform = createTransformFromSlice(schema, slice)\n\tif (!replaceExternalModuleIdentifiersInTransform(engine, schema, transform)) return slice\n\n\treturn createSliceFromTransform(slice, transform)\n}\n\nfunction replaceExternalModuleIdentifiersInTransform(\n\tengine: BaseEngine,\n\tschema: FramerProseMirrorSchema & FramerProseMirrorSchema.WithEmbeds,\n\ttransform: Transform,\n): boolean {\n\tlet didReplace = false\n\n\ttransform.doc.descendants((node, position) => {\n\t\tif (!isModuleNode(node)) return\n\n\t\tconst identifier = getLocalModuleIdentifierForRichTextPaste(engine, node.attrs.identifier)\n\t\tif (!identifier) return\n\n\t\ttransform.setNodeMarkup(position, schema.nodes.module, {\n\t\t\t...node.attrs,\n\t\t\tidentifier,\n\t\t})\n\t\tdidReplace = true\n\t})\n\n\treturn didReplace\n}\n\nfunction createRichTextModulePastePreparation(\n\tengine: BaseEngine,\n\tschema: FramerProseMirrorSchema,\n\tslice: Slice,\n): (() => Promise<void>) | undefined {\n\tconst externalModuleIdentifiers = getExternalModuleIdentifiersForRichTextPaste(engine, schema, slice)\n\tif (externalModuleIdentifiers.length === 0) return\n\n\treturn () =>\n\t\tengine.stores.modulesStore.addExternalModulesToProject(externalModuleIdentifiers, {\n\t\t\tonTreeUpdate() {},\n\t\t})\n}\n\nfunction getExternalModuleIdentifiersForRichTextPaste(\n\tengine: BaseEngine,\n\tschema: FramerProseMirrorSchema,\n\tslice: Slice,\n): ExternalModuleExportIdentifier[] {\n\tif (!schemaSupportsEmbeds(schema)) return []\n\n\tconst externalModuleIdentifiers = new Map<string, ExternalModuleExportIdentifier>()\n\tslice.content.descendants(node => {\n\t\tif (!isModuleNode(node)) return\n\n\t\tconst parsedIdentifier = parseModuleIdentifier(node.attrs.identifier)\n\t\tif (!isExternalModuleIdentifier(parsedIdentifier)) return\n\t\tif (engine.stores.modulesStore.getPersistedModuleByGlobalId(parsedIdentifier.moduleId)) return\n\n\t\texternalModuleIdentifiers.set(parsedIdentifier.value, parsedIdentifier)\n\t})\n\n\treturn Array.from(externalModuleIdentifiers.values())\n}\n\nfunction createClipboardSerializationHook(\n\tengine: BaseEngine,\n\tshouldAppendMatchFormattingComment: boolean,\n): (result: HTMLElement | DocumentFragment) => void {\n\treturn (result: HTMLElement | DocumentFragment) => {\n\t\tserializeLocalModuleIdentifiersAsExternal(engine, result)\n\t\tif (shouldAppendMatchFormattingComment) appendFramerMatchFormattingComment(result)\n\t}\n}\n\nfunction serializeLocalModuleIdentifiersAsExternal(engine: BaseEngine, result: HTMLElement | DocumentFragment): void {\n\tif (result instanceof Element && result.matches(moduleSelector)) {\n\t\tserializeLocalModuleIdentifierAsExternal(engine, result)\n\t}\n\n\tfor (const moduleElement of result.querySelectorAll(moduleSelector)) {\n\t\tserializeLocalModuleIdentifierAsExternal(engine, moduleElement)\n\t}\n}\n\nfunction serializeLocalModuleIdentifierAsExternal(engine: BaseEngine, moduleElement: Element): void {\n\tconst identifier = moduleElement.getAttribute(CMS_MODULE_IDENTIFIER_ATTR)\n\tif (!identifier) return\n\n\tconst externalIdentifier = getExternalModuleIdentifierForRichTextCopy(engine, identifier)\n\tif (!externalIdentifier) return\n\n\tmoduleElement.setAttribute(CMS_MODULE_IDENTIFIER_ATTR, externalIdentifier)\n}\n\nfunction getExternalModuleIdentifierForRichTextCopy(\n\tengine: BaseEngine,\n\tidentifier: string,\n): ModuleExportIdentifierString | undefined {\n\tconst parsedIdentifier = parseModuleIdentifier(identifier)\n\tif (!parsedIdentifier || parsedIdentifier.kind !== \"localModuleExport\") return\n\n\tconst persistedModule = engine.stores.modulesStore.getPersistedModuleByLocalId(parsedIdentifier.localId)\n\tif (!persistedModule?.files.module) return\n\n\treturn externalModuleIdentifier(\n\t\tpersistedModule.id,\n\t\tpersistedModule.saveId,\n\t\tpersistedModule.files.module,\n\t\tparsedIdentifier.exportSpecifier,\n\t).value\n}\n\nfunction getLocalModuleIdentifierForRichTextPaste(\n\tengine: BaseEngine,\n\tidentifier: string,\n): ModuleExportIdentifierString | undefined {\n\tconst parsedIdentifier = parseModuleIdentifier(identifier)\n\tif (!parsedIdentifier || parsedIdentifier.kind !== \"externalModuleExport\") return\n\n\tconst persistedModule = engine.stores.modulesStore.getPersistedModuleByGlobalId(parsedIdentifier.moduleId)\n\tif (!persistedModule) return\n\n\treturn toLocalIdentifier(parsedIdentifier, persistedModule.localId).value\n}\n\n/** Returns true when the pasted text was created in Framer and must retain its formatting. */\nfunction mustMatchFormatting(richText: string): boolean {\n\treturn richText.endsWith(`<!--${FRAMER_MATCH_FORMATTING_COMMENT_STRING}-->`)\n}\n\nfunction appendFramerMatchFormattingComment(result: HTMLElement | DocumentFragment): void {\n\tresult.appendChild(comment)\n}\n\nfunction sanitizePastedSliceToUseStylePresets(\n\tengine: BaseEngine,\n\tschema: FramerProseMirrorSchema & FramerProseMirrorSchema.WithStyles,\n\tgetCustomStylePresetForTag: (tag: RichTextTag) => TextStylePresetNode | undefined,\n\tgetCustomStylePresetForLink: () => LinkStylePresetNode | undefined,\n\ttransform: Transform,\n) {\n\ttransform.doc.descendants((node, position) => {\n\t\tif (isTextBlockNode(node)) {\n\t\t\tconst attrs = node.attrs\n\n\t\t\tconst prevPreset = isString(attrs.textStylePreset)\n\t\t\t\t? engine.tree.getNodeWithTrait(attrs.textStylePreset, isTextStylePresetPrimaryNode)\n\t\t\t\t: undefined\n\n\t\t\tconst tag: RichTextTag = isRichTextTag(attrs.tag) ? attrs.tag : \"p\"\n\n\t\t\tconst preset =\n\t\t\t\tprevPreset ??\n\t\t\t\tgetCustomStylePresetForTag(tag) ??\n\t\t\t\tgetDefaultTextStylePreset(engine.tree, tag) ??\n\t\t\t\tTextStylePresetNode.createDefault(tag)\n\n\t\t\tinsertTextStylePreset(engine, preset)\n\n\t\t\ttransform.setNodeMarkup(position, schema.nodes.textBlock, {\n\t\t\t\t...node.attrs,\n\t\t\t\tblockStyles: prevPreset ? node.attrs.blockStyles : {},\n\t\t\t\tinlineStyles: prevPreset ? node.attrs.inlineStyles : {},\n\t\t\t\ttextStylePreset: preset.id,\n\t\t\t})\n\n\t\t\tif (!prevPreset) {\n\t\t\t\ttransform.removeMark(position, node.nodeSize, schema.marks.inlineStyles)\n\t\t\t}\n\t\t}\n\n\t\tif (node.type === schema.nodes.text) {\n\t\t\tconst linkMark = node.marks.find(isLinkMark)\n\n\t\t\tif (linkMark) {\n\t\t\t\tconst linkPreset =\n\t\t\t\t\tgetCustomStylePresetForLink() ?? getDefaultLinkStylePreset(engine.tree) ?? LinkStylePresetNode.createDefault()\n\n\t\t\t\tinsertLinkStylePreset(engine, linkPreset)\n\n\t\t\t\ttransform.addMark(\n\t\t\t\t\tposition,\n\t\t\t\t\tposition + node.nodeSize,\n\t\t\t\t\tlinkMark.type.create({\n\t\t\t\t\t\t...linkMark.attrs,\n\t\t\t\t\t\tlinkStylePreset: linkPreset.id,\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t})\n}\n\nfunction sanitizePastedSliceToMatchSurroundingStyles(\n\tview: EditorView,\n\tschema: FramerProseMirrorSchema & FramerProseMirrorSchema.WithStyles,\n\ttransform: Transform,\n) {\n\tconst state = view.state\n\tlet selection = state.selection\n\n\t// Change selection to first character if the whole text is selected.\n\tif (selection instanceof AllSelection) {\n\t\tconst anchor = state.doc.resolve(1)\n\t\tselection = new TextSelection(anchor)\n\t}\n\n\tconst blockNode = selection.$from.parent\n\tconst isTextBlock = isTextBlockNode(blockNode)\n\tconst marks = selection.$from.marks()\n\tconst inlineStylesMark = marks.find(isInlineStylesMark)\n\n\tif (inlineStylesMark) {\n\t\t// Apply the current node's inline styles to the entire pasted document.\n\t\ttransform.addMark(0, transform.doc.content.size, inlineStylesMark)\n\t} else if (isTextBlock) {\n\t\t// Apply the inline styles of the target paragraph\n\t\tconst newMark = schema.marks.inlineStyles.create({ inlineStyles: blockNode.attrs.inlineStyles })\n\t\ttransform.addMark(0, transform.doc.content.size, newMark)\n\t} else {\n\t\t// If not there, just clear the inline styles in the pasted document.\n\t\ttransform.removeMark(0, transform.doc.content.size, schema.marks.inlineStyles)\n\t}\n\n\ttransform.doc.descendants((node, position) => {\n\t\tif (!isTextBlockNode(node)) return\n\t\tconst attrs = isTextBlock ? blockNode.attrs : node.attrs\n\n\t\ttransform.setNodeMarkup(position, schema.nodes.textBlock, attrs)\n\t})\n}\n", "import type { BaseEngine } from \"document/base-engine/BaseEngine.ts\"\nimport type { CanvasTree, RichTextNode } from \"document/models/CanvasTree/index.ts\"\nimport type { TextStylePresetNode } from \"document/models/CanvasTree/nodes/TextStylePresetNode.ts\"\nimport { isTextStylePresetPrimaryNode } from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport type { RichTextTag } from \"document/models/CanvasTree/traits/WithRichTextTag.ts\"\nimport { clipboardPlugin } from \"prosemirror/plugins/pastePlugin.ts\"\nimport type { FramerProseMirrorSchema } from \"prosemirror/schema/index.ts\"\n\ninterface RichTextPastePluginArgs {\n\treadonly engine: BaseEngine\n\treadonly schema: FramerProseMirrorSchema\n\treadonly nodeId: string | undefined\n\treadonly getRichTextNode: () => RichTextNode | null\n}\n\n// creates the appropriate paste plugin configuration for rich text editing\nexport function createRichTextPastePlugin({ engine, schema, nodeId, getRichTextNode }: RichTextPastePluginArgs) {\n\treturn clipboardPlugin({\n\t\tengine,\n\t\tschema,\n\t\tstylePresetGetters: {\n\t\t\tgetStylePresetForTag: (tag: RichTextTag) => {\n\t\t\t\tconst richTextNode = getRichTextNode()\n\t\t\t\tif (!richTextNode) return undefined\n\t\t\t\treturn (\n\t\t\t\t\tgetUsedTextStylePreset(engine.tree, richTextNode, tag) ??\n\t\t\t\t\trichTextNode.getNodeTextStylePreset(engine.tree, tag) ??\n\t\t\t\t\tundefined\n\t\t\t\t)\n\t\t\t},\n\t\t\tgetStylePresetForLink: () => {\n\t\t\t\treturn getRichTextNode()?.getNodeLinkStylePreset(engine.tree) ?? undefined\n\t\t\t},\n\t\t},\n\t})\n}\n\nfunction getUsedTextStylePreset(\n\ttree: CanvasTree,\n\trichTextNode: RichTextNode,\n\ttag: RichTextTag,\n): TextStylePresetNode | undefined {\n\tfor (const presetId of richTextNode.getTextStylePresets(false)) {\n\t\tconst preset = tree.getNodeWithTrait(presetId, isTextStylePresetPrimaryNode)\n\t\tif (preset && preset.tag === tag) return preset\n\t}\n}\n", "import type { ColorStyleTokenNode } from \"document/models/CanvasTree/nodes/ColorStyleTokenNode.ts\"\n\nexport type ColorModel = \"RGB\" | \"HSL\" | \"HEX\" | \"P3\"\n\nexport const allColorModels: ColorModel[] = [\"RGB\", \"HSL\", \"HEX\", \"P3\"]\n\nexport function isColorModel(value: any): value is ColorModel {\n\treturn allColorModels.some(colorModel => colorModel === value)\n}\n\nexport interface ColorPickerPackage {\n\tpackageIdentifier: string\n\tdisplayName: string\n\ttokens: { [id: string]: ColorStyleTokenNode }\n\ttokensCount: number\n\tisEditable: boolean\n\tisLocal: boolean\n}\n\nexport interface ColorPickerTokenPackages {\n\t[pkgId: string]: ColorPickerPackage\n}\n", "import { parseAssetReference, splitExtension } from \"@framerjs/assets\"\n\nexport function getCopiedAssets(images: Iterable<string>) {\n\tconst assets = new Set<string>()\n\tfor (const image of images) {\n\t\tconst asset = getCopiedAsset(image)\n\t\tif (!asset) continue\n\n\t\tassets.add(asset)\n\t}\n\treturn Array.from(assets)\n}\n\nexport function getCopiedAsset(image: string): string | undefined {\n\t// TODO: The assets on web need to be looked up by key, so we need to\n\t// strip the extension from the images. Better would be to use the\n\t// information of the AssetService to lookup the assets by filename.\n\tconst ref = parseAssetReference(image)\n\n\tif (ref) {\n\t\t// We don't consider package assets part of the copied assets.\n\t\tif (ref.packageIdentifier) return\n\n\t\treturn splitExtension(ref.identifier)[0]\n\t}\n\n\treturn splitExtension(image)[0]\n}\n", "import { isAssetReference } from \"@framerjs/assets\"\n\nexport function getRichTextAssetReferences(html: string) {\n\tconst matches = html.matchAll(/data-framer-asset=\"(?<asset>[^\"]+)\"/gu)\n\n\treturn Array.from(matches)\n\t\t.map(match => match.groups?.asset)\n\t\t.filter(isAssetReference)\n}\n", "import type { AnyComponentLoader } from \"@framerjs/framer-runtime\"\nimport { assert, assertNever } from \"@framerjs/shared\"\nimport type { CanvasNode } from \"document/models/CanvasTree/index.ts\"\nimport { isCodeComponentNode, isCollectionItemNode } from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { isVariableReference } from \"document/models/CanvasTree/traits/VariableReference.ts\"\nimport { withFill, withFillImageAlts, withOptionalFill } from \"document/models/CanvasTree/traits/WithFill.ts\"\nimport { toImageSrc } from \"document/models/CanvasTree/traits/utils/applyValueTransform.ts\"\nimport type { ControlProp } from \"document/models/controlProps/ControlProp.ts\"\nimport { ControlType } from \"library/render/types/PropertyControls.ts\"\nimport { getRichTextAssetReferences } from \"prosemirror/getAssetReferences.ts\"\nimport { isObject, isReadonlyArray, isString } from \"utils/typeChecks.ts\"\n\nfunction collectImagesForNode(componentLoader: AnyComponentLoader, node: CanvasNode, images: Set<string>) {\n\t// Collect images from fill.\n\tif (withFill(node) && !(withOptionalFill(node) && !node.fillEnabled) && node.fillType === \"image\" && node.fillImage) {\n\t\tconst resolvedImage = node.resolveValue(\"fillImage\")\n\n\t\tconst imageSrc = toImageSrc(resolvedImage)\n\n\t\tif (isString(imageSrc)) {\n\t\t\timages.add(imageSrc)\n\t\t}\n\t}\n\n\t// Collect images from fill image alternatives (used by kits for multiple image options).\n\tif (withFillImageAlts(node) && node.fillImageAlts) {\n\t\tfor (const alt of node.fillImageAlts) {\n\t\t\tif (!alt) continue\n\t\t\tconst imageSrc = toImageSrc(alt.image)\n\t\t\tif (isString(imageSrc)) {\n\t\t\t\timages.add(imageSrc)\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction collectImagesFromControlProp(controlProp: ControlProp) {\n\t\tswitch (controlProp.type) {\n\t\t\tcase ControlType.Image: {\n\t\t\t\tlet value: unknown = controlProp.value\n\n\t\t\t\tif (isVariableReference(controlProp.value)) {\n\t\t\t\t\tvalue = node.cache.getVariableReferenceValue(controlProp.value)\n\t\t\t\t}\n\n\t\t\t\tif (isString(value) && value.length > 0) {\n\t\t\t\t\timages.add(value)\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tcase ControlType.RichText: {\n\t\t\t\tif (isString(controlProp.value)) {\n\t\t\t\t\tconst assetReferences = getRichTextAssetReferences(controlProp.value)\n\t\t\t\t\tfor (const assetReference of assetReferences) {\n\t\t\t\t\t\timages.add(assetReference)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tcase ControlType.Object: {\n\t\t\t\tif (isObject(controlProp.value)) {\n\t\t\t\t\tconst objectProperties = Object.values(controlProp.value)\n\t\t\t\t\tfor (const objectProperty of objectProperties) {\n\t\t\t\t\t\tcollectImagesFromControlProp(objectProperty)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tcase ControlType.Array: {\n\t\t\t\tif (!isReadonlyArray(controlProp.value)) break\n\t\t\t\tfor (const arrayItem of controlProp.value) {\n\t\t\t\t\tcollectImagesFromControlProp(arrayItem)\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tcase ControlType.Boolean:\n\t\t\tcase ControlType.Color:\n\t\t\tcase ControlType.Date:\n\t\t\tcase ControlType.Enum:\n\t\t\tcase ControlType.EventHandler:\n\t\t\tcase ControlType.File:\n\t\t\tcase ControlType.FusedNumber:\n\t\t\tcase ControlType.Link:\n\t\t\tcase ControlType.LinkRelValues:\n\t\t\tcase ControlType.Number:\n\t\t\tcase ControlType.String:\n\t\t\tcase ControlType.Transition:\n\t\t\tcase ControlType.Font:\n\t\t\tcase ControlType.PageScope:\n\t\t\tcase ControlType.ScrollSectionRef:\n\t\t\tcase ControlType.CustomCursor:\n\t\t\tcase ControlType.Border:\n\t\t\tcase ControlType.Cursor:\n\t\t\tcase ControlType.BoxShadow:\n\t\t\tcase ControlType.Slot:\n\t\t\tcase ControlType.Gap:\n\t\t\tcase ControlType.Padding:\n\t\t\tcase ControlType.BorderRadius:\n\t\t\tcase ControlType.CollectionReference:\n\t\t\tcase ControlType.MultiCollectionReference:\n\t\t\tcase ControlType.TrackingId:\n\t\t\tcase ControlType.VectorSetItem:\n\t\t\tcase ControlType.Location:\n\t\t\t\tbreak\n\n\t\t\tdefault:\n\t\t\t\tassertNever(controlProp)\n\t\t}\n\t}\n\n\t// Collect images set to property controls.\n\tif (isCodeComponentNode(node)) {\n\t\tconst component = componentLoader.reactComponentForIdentifier(node.codeComponentIdentifier)\n\t\tif (component) {\n\t\t\tconst controlProps = node.getControlProps(component.properties)\n\t\t\tfor (const controlKey in controlProps) {\n\t\t\t\tconst controlProp = controlProps[controlKey]\n\t\t\t\tassert(controlProp)\n\t\t\t\tcollectImagesFromControlProp(controlProp)\n\t\t\t}\n\t\t}\n\t}\n\n\tif (isCollectionItemNode(node)) {\n\t\tconst controlProps = node.getControlProps()\n\t\tfor (const controlKey in controlProps) {\n\t\t\tconst controlProp = controlProps[controlKey]\n\t\t\tassert(controlProp)\n\t\t\tcollectImagesFromControlProp(controlProp)\n\t\t}\n\t}\n}\n\nexport function collectImagesFromSubtree(\n\tcomponentLoader: AnyComponentLoader,\n\tfromNode: CanvasNode,\n\timages: Set<string>,\n) {\n\tfor (const node of fromNode.walk()) {\n\t\tcollectImagesForNode(componentLoader, node, images)\n\t}\n}\n", "import type { ComponentLoader } from \"@framerjs/framer-runtime\"\nimport { assert } from \"@framerjs/shared\"\nimport type { VekterEngine } from \"document/VekterEngine.ts\"\nimport { collectImagesFromSubtree } from \"document/components/tools/utils/collectImages.ts\"\nimport { ContextAction, canCopyNode } from \"document/components/utils/contextActions.ts\"\nimport { getRawWebPagePath } from \"document/components/utils/getWebPagePath.ts\"\nimport type { CanvasNode, CodeComponentNode, NodeID, ScopeNode } from \"document/models/CanvasTree/index.ts\"\nimport { CanvasTree, isDrawableNode, isScopeNode } from \"document/models/CanvasTree/index.ts\"\nimport type { MaybeNodeID } from \"document/models/CanvasTree/nodes/NodeID.ts\"\nimport { randomID } from \"document/models/CanvasTree/nodes/NodeID.ts\"\nimport { RootNode } from \"document/models/CanvasTree/nodes/RootNode.ts\"\nimport {\n\tTemplateHelper,\n\tduplicatedFromForNode,\n\tisGeneratedReplicaChildId,\n} from \"document/models/CanvasTree/nodes/TemplateHelper.ts\"\nimport { isCodeComponentNode, isRootNode, isWebPageNode } from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { withCodeOverride } from \"document/models/CanvasTree/traits/WithCodeOverride.ts\"\nimport { isPinnable } from \"document/models/CanvasTree/traits/WithPins.ts\"\nimport { withPosition } from \"document/models/CanvasTree/traits/WithPosition.ts\"\nimport type { ReplicaInfo, ReplicaOverrides } from \"document/models/CanvasTree/traits/WithTemplate.ts\"\nimport { isReplica, isReplicaOrReplicaChild, withTemplate } from \"document/models/CanvasTree/traits/WithTemplate.ts\"\nimport { withVariableProvider } from \"document/models/CanvasTree/traits/WithVariableProvider.ts\"\nimport {\n\tisBreakpointVariant,\n\tisPrimaryBreakpointVariant,\n\tisVariant,\n} from \"document/models/CanvasTree/traits/WithVariant.ts\"\nimport { convertFrameToCanvas } from \"document/models/CanvasTree/utils/geometry.ts\"\nimport { CodeError, getNodeError } from \"document/models/CanvasTree/utils/getNodeError.ts\"\nimport type { HistoryStore } from \"document/stores/HistoryStore.ts\"\nimport type { LoadedExternalModulesStore } from \"document/stores/LoadedExternalModulesStore.ts\"\nimport type { ModulesStore } from \"document/stores/ModulesStore.ts\"\nimport type { ProviderID } from \"document/utils/VariableProviderInfo.ts\"\nimport type { Size } from \"library/index.ts\"\nimport { Rect } from \"library/render/types/Rect.ts\"\nimport type { FramerLayersClipboardData } from \"utils/clipboard/helpers/types.ts\"\nimport { commonValue } from \"utils/commonValue.ts\"\nimport { isNumber, isString } from \"utils/typeChecks.ts\"\nimport { record } from \"web/lib/tracker.ts\"\nimport { getCopiedAssets } from \"./getCopiedAssets.ts\"\nimport type {\n\tClipboardLayers,\n\tNodeIDToBoolean,\n\tNodeIDToFrame,\n\tNodeIDToReplicaInfo,\n\tSerializableMap,\n\tVariableValueByProviderEntries,\n\tVariableValueEntries,\n} from \"./helpers/types.ts\"\nimport {\n\ttype CollectedCollections,\n\tcollectClipboardModuleData,\n\tcollectCollections,\n\tcollectColorTokenNodes,\n\tcollectOverridesForBreakpoints,\n\tcollectStylePresetNodes,\n\tgetWebPagePropsForCopiedBreakpoint,\n\tunsafeMakeMutable,\n} from \"./utils.ts\"\n\nexport function getClipboardRootTree(): CanvasTree {\n\tconst clipboardRoot = new RootNode({ id: \"clipboard\" })\n\tconst copyTree = CanvasTree.createByAdoptingRoot(clipboardRoot)\n\treturn copyTree\n}\n\nexport const getClipboardData = (engine: VekterEngine, nodeIds: Iterable<NodeID>): FramerLayersClipboardData => {\n\tconst { treeStore, modulesStore, loadedExternalModulesStore, projectStore, historyStore } = engine.stores\n\tconst tree = treeStore.tree\n\t// Keep ids, check for duplicates when pasting\n\tconst copyTree = getClipboardRootTree()\n\tconst images = new Set<string>()\n\tconst renamedIds: Record<NodeID, NodeID> = {}\n\tconst breakpointOverrides = new Map<number, ReplicaOverrides>()\n\tconst variableValueByProviderEntries: VariableValueByProviderEntries = []\n\tconst webPagePathByWebPageId: ClipboardLayers[\"webPagePathByWebPageId\"] = {}\n\n\t// Note that parts of the same tree may recur in this array because they were individually selected.\n\tconst selectedNodes = tree.getNodes(nodeIds)\n\tconst topLevelNodes = tree.withoutDescendants(selectedNodes.filter(node => canCopyNode(node)))\n\tconst sortedTopLevelNodes = tree.sortVisually(topLevelNodes)\n\tconst frames = sortedTopLevelNodes.map(node => convertFrameToCanvas(tree, node))\n\tconst boundingBox = Rect.merge(...frames)\n\tconst topLevelNodeParentIds = sortedTopLevelNodes.map(node => node.parentid)\n\tconst commonParentId = commonValue(topLevelNodeParentIds)\n\tconst commonParent = isString(commonParentId) ? tree.get(commonParentId) : null\n\tconst noCommonParentAcceptsConstraints = !commonParent || isRootNode(commonParent) || isScopeNode(commonParent)\n\tconst topLevelNodeIdToScopeNode = getTopLevelNodeIdToScopeMap(tree, selectedNodes)\n\tconst scopeNodes = [...topLevelNodeIdToScopeNode.values()]\n\tconst scopeNode = scopeNodes.length === 1 ? (scopeNodes[0] ?? null) : null\n\n\tconst collectedCollections: CollectedCollections = new Map()\n\tconst nonSelectedVariableProvidersInScope: Set<ProviderID> = new Set()\n\n\tsortedTopLevelNodes.forEach(topLevelNode => {\n\t\tfor (const node of topLevelNode.walk()) {\n\t\t\tcollectCollections(tree, node, collectedCollections)\n\t\t}\n\n\t\tfor (const ancestor of topLevelNode.ancestors()) {\n\t\t\tif (!withVariableProvider(ancestor)) continue\n\t\t\tif (!ancestor.getVariableSourceIdentifier()) continue\n\t\t\tnonSelectedVariableProvidersInScope.add(ancestor.id)\n\t\t}\n\t})\n\n\tfor (const providerId of nonSelectedVariableProvidersInScope) {\n\t\tconst provider = tree.getNodeWithTrait(providerId, withVariableProvider)\n\t\tif (!provider) continue\n\n\t\tconst variableValueMap = provider.getProvidedValueMap(\n\t\t\ttree,\n\t\t\tundefined,\n\t\t\tengine.componentLoader,\n\t\t\ttreeStore.sandboxRepeaterData,\n\t\t\tengine.componentLoader.activeBundleHash,\n\t\t)\n\t\tif (!variableValueMap) continue\n\n\t\tconst variableValueEntries: VariableValueEntries = Array.from(variableValueMap)\n\t\tif (variableValueEntries.length === 0) continue\n\n\t\tvariableValueByProviderEntries.push([providerId, variableValueEntries])\n\t}\n\n\t// Breakpoints don't contain data sources; scope nodes do.\n\t// If the user copied the primary breakpoint, they will need its collections.\n\tconst primaryBreakpointVariant = sortedTopLevelNodes.find(isPrimaryBreakpointVariant)\n\tif (scopeNode && primaryBreakpointVariant) {\n\t\tcollectCollections(tree, scopeNode, collectedCollections)\n\t}\n\n\tfor (const [, collectedCollection] of collectedCollections) {\n\t\tif (sortedTopLevelNodes.includes(collectedCollection)) continue\n\t\tsortedTopLevelNodes.push(collectedCollection)\n\t}\n\n\tconst originalFrames: NodeIDToFrame = {}\n\tconst stylePresetNodes: SerializableMap = {}\n\tconst colorTokenNodes: SerializableMap = {}\n\n\tlet primaryIntrinsicSize: Size | undefined\n\tsortedTopLevelNodes.forEach(topLevelNode => {\n\t\tconst originalFrame = tree.getRect(topLevelNode)\n\t\tconst copyOfTopLevelNode = topLevelNode.cloneWithIds({ parentid: null })\n\t\tassert(tree.get(copyOfTopLevelNode.id), \"Node does not exist in tree\")\n\n\t\t// TODO Check and handle shallow/fully loaded scope state\n\t\tif (isWebPageNode(topLevelNode) && topLevelNode.isLoaded()) {\n\t\t\tconst primary = tree.get(topLevelNode.baseVariantId)\n\t\t\tif (primary) {\n\t\t\t\tprimaryIntrinsicSize = tree.getRect(primary)\n\t\t\t}\n\t\t\tconst variantNodes = topLevelNode.getTopLevelVariants()\n\t\t\tvariantNodes.forEach(variantNode => {\n\t\t\t\toriginalFrames[variantNode.id] = tree.getRect(variantNode)\n\t\t\t})\n\t\t\twebPagePathByWebPageId[copyOfTopLevelNode.id] = getRawWebPagePath(tree, topLevelNode)\n\t\t}\n\n\t\tfor (const copyOfNode of copyOfTopLevelNode.walk()) {\n\t\t\tcleanupBrokenCodeOverrides(tree, engine.componentLoader, loadedExternalModulesStore, modulesStore, copyOfNode)\n\n\t\t\t// Collects `StylePreset` in the serialized map\n\t\t\t// `stylePresetNodes`. We collect them during this walk to\n\t\t\t// avoid unnecessary iterations.\n\t\t\tcollectStylePresetNodes(tree, stylePresetNodes, copyOfNode)\n\t\t\tcollectOverridesForBreakpoints(tree, breakpointOverrides, copyOfNode)\n\n\t\t\tconst node = tree.get(copyOfNode.id)\n\t\t\tif (node) {\n\t\t\t\tcollectColorTokenNodes(tree, node, colorTokenNodes, renamedIds)\n\t\t\t}\n\n\t\t\t// cleanup originalid here, later we will collect masters and replicas\n\t\t\tcleanupOriginalAndGeneratedId(copyOfNode, topLevelNode, renamedIds)\n\t\t}\n\n\t\tif (isPinnable(copyOfTopLevelNode)) {\n\t\t\tcopyOfTopLevelNode.constraintsLocked = false\n\t\t}\n\n\t\tif (noCommonParentAcceptsConstraints) {\n\t\t\t// Reset all constraints because we don't want to use them on\n\t\t\t// paste. We need to use the original node as we change the ids\n\t\t\t// of the copied nodes in the for loop above.\n\t\t\tconst update = getResetConstraintsUpdate(tree, topLevelNode, boundingBox)\n\t\t\tcopyOfTopLevelNode.assign(update)\n\n\t\t\tcopyTree.insertNode(copyOfTopLevelNode)\n\t\t} else {\n\t\t\tcopyTree.insertNode(copyOfTopLevelNode)\n\t\t\toriginalFrames[copyOfTopLevelNode.id] = originalFrame\n\t\t}\n\n\t\tcollectImagesFromSubtree(engine.componentLoader, copyOfTopLevelNode, images)\n\t})\n\n\t// Collect all master replicas that are in the copyTree, and strip that\n\t// data from the copyNodes themselves.\n\tconst { masters, replicas } = collectAndCleanupTemplateData(copyTree)\n\n\tfor (const copyOfNode of copyTree.root.walk()) {\n\t\tif (isCodeComponentNode(copyOfNode)) {\n\t\t\tcleanupBrokenCodeComponents(\n\t\t\t\ttree,\n\t\t\t\tengine.componentLoader,\n\t\t\t\tloadedExternalModulesStore,\n\t\t\t\tmodulesStore,\n\t\t\t\tcopyTree,\n\t\t\t\tcopyOfNode,\n\t\t\t)\n\t\t}\n\t}\n\n\tconst committedCopyTree = copyTree.commit(engine.componentLoader)\n\n\tconst { moduleData } = collectClipboardModuleData(\n\t\tmodulesStore,\n\t\ttree,\n\t\tcommittedCopyTree.root,\n\t\tscopeNode,\n\t\tcollectedCollections,\n\t)\n\n\t// When copying from history, collect the data we need for paste to replace. We use the tree instead of copyTree\n\t// because we need a whole picture of the tree for replicaInfo, plus we need to get the template data that's\n\t// been cleaned up in the copyTree.\n\tconst historyData = getHistoryData(historyStore, tree, topLevelNodes)\n\n\tif (historyData) {\n\t\tconst size = committedCopyTree.size() - 1 // Don't count the root node.\n\t\trecord(\"historic_document_copy\", { size })\n\t}\n\n\tconst webPagePropsForCopiedBreakpoint = scopeNode ? getWebPagePropsForCopiedBreakpoint(scopeNode) : undefined\n\n\tif (webPagePropsForCopiedBreakpoint?.id && webPagePropsForCopiedBreakpoint.pagePath) {\n\t\twebPagePathByWebPageId[webPagePropsForCopiedBreakpoint.id] = webPagePropsForCopiedBreakpoint.pagePath\n\t}\n\n\tconst layers: ClipboardLayers = {\n\t\ttree: committedCopyTree.toJS(),\n\t\toriginalFrames,\n\t\tmasters,\n\t\treplicas,\n\t\trenamedIds,\n\t\twebPagePathByWebPageId,\n\t\twebPagePropsForCopiedBreakpoint,\n\t\tbreakpointOverrides: [...breakpointOverrides.entries()],\n\t\tvariableValueInfo: scopeNode\n\t\t\t? {\n\t\t\t\t\tscopeId: scopeNode.id,\n\t\t\t\t\tvariableValuesByProvider: variableValueByProviderEntries,\n\t\t\t\t}\n\t\t\t: undefined,\n\t\tstylePresetNodes,\n\t\tcolorTokenNodes,\n\t\tmoduleData,\n\t\tprimaryIntrinsicSize,\n\t\thistoryData,\n\t}\n\n\treturn { layers, assets: getCopiedAssets(images), sourceProjectId: projectStore.projectId }\n}\n\nfunction getHistoryData(\n\thistoryStore: HistoryStore,\n\ttree: CanvasTree,\n\ttopLevelNodes: CanvasNode[],\n): { treeVersion: number; originalId?: MaybeNodeID; replicaInfo?: ReplicaInfo } | undefined {\n\tconst treeVersion = historyStore.activeTreeVersion\n\tif (!isNumber(treeVersion)) return\n\n\tconst [node] = topLevelNodes\n\tif (topLevelNodes.length !== 1 || !node) return { treeVersion }\n\n\tconst replicaInfo = getReplicaInfoFromNodeOrAncestor(tree, node)\n\treturn { treeVersion, originalId: node.originalid, replicaInfo }\n}\n\nfunction getReplicaInfoFromNodeOrAncestor(tree: CanvasTree, node: CanvasNode): ReplicaInfo | undefined {\n\tif (!isReplicaOrReplicaChild(node)) return\n\n\tif (isReplica(node)) return node.replicaInfo\n\tconst replica = TemplateHelper.getReplicaForTemplateNode(tree, node)\n\treturn replica?.replicaInfo\n}\n\nexport function cleanupBrokenCodeOverrides(\n\ttree: CanvasTree,\n\tcomponentLoader: ComponentLoader,\n\tloadedExternalModulesStore: LoadedExternalModulesStore,\n\tmodulesStore: ModulesStore,\n\tnode: CanvasNode,\n) {\n\tif (!withCodeOverride(node)) return\n\n\tconst nodeError = getNodeError(node, componentLoader, tree, loadedExternalModulesStore, modulesStore)\n\tif (!nodeError) return\n\tconst { kind } = nodeError\n\tif (kind !== \"code\") return\n\tconst { codeError } = nodeError\n\tif (codeError !== CodeError.OverrideMissingExport && codeError !== CodeError.OverrideMissingFile) return\n\n\t// Remove code override\n\tnode.set({\n\t\tcodeOverrideEnabled: false,\n\t\tcodeOverrideIdentifier: undefined,\n\t})\n}\n\nfunction cleanupBrokenCodeComponents(\n\tcurrentTree: CanvasTree,\n\tcomponentLoader: ComponentLoader,\n\tloadedExternalModulesStore: LoadedExternalModulesStore,\n\tmodulesStore: ModulesStore,\n\tnextTree: CanvasTree,\n\tnode: CodeComponentNode,\n) {\n\tconst nodeError = getNodeError(node, componentLoader, currentTree, loadedExternalModulesStore, modulesStore)\n\tif (nodeError && nodeError.kind === \"code\" && nodeError.codeError === CodeError.CodeComponentMissing) {\n\t\tnextTree.removeNode(node)\n\t}\n}\n\nfunction cleanupOriginalAndGeneratedId(\n\tcopyOfNode: CanvasNode,\n\ttopLevelNode: CanvasNode,\n\trenamedIds: Record<string, string>,\n) {\n\tconst originalid = copyOfNode.originalid\n\tif (!originalid) return\n\n\tcopyOfNode.originalid = null\n\n\t// Give ids that are `generateReplicaChildId(owner, originalid)`\n\t// a new id. Otherwise: copy a child of a replica, drag child\n\t// out of master, paste, drag child back -> crash\n\tif (!isGeneratedReplicaChildId(copyOfNode.id, originalid)) return\n\t// Since we reset id for Design Components, we need to preserve\n\t// the source node id to use for writing duplicatedFrom, so we\n\t// set it early here.\n\tunsafeMakeMutable(copyOfNode).duplicatedFrom = isVariant(topLevelNode)\n\t\t? null\n\t\t: duplicatedFromForNode(copyOfNode.duplicatedFrom, copyOfNode.id)\n\n\tconst newId = randomID()\n\trenamedIds[originalid] = newId\n\tunsafeMakeMutable(copyOfNode).id = newId\n\n\tcopyOfNode.children?.forEach(c => (c.parentid = copyOfNode.id))\n}\n\nfunction getResetConstraintsUpdate(tree: CanvasTree, node: CanvasNode, boundingBox: Rect) {\n\tconst parent = tree.getNodeParent(node)\n\n\tif (!isDrawableNode(node)) return {}\n\n\tif (withPosition(node)) {\n\t\tconst update = ContextAction.convertNodeToNewParentUpdate(tree, node, parent, null)\n\t\tif (update.x !== undefined) {\n\t\t\tupdate.x -= boundingBox.x\n\t\t}\n\t\tif (update.y !== undefined) {\n\t\t\tupdate.y -= boundingBox.y\n\t\t}\n\t\treturn update\n\t}\n\n\tif (isPinnable(node)) {\n\t\tconst update = ContextAction.convertNodeToNewParentUpdate(tree, node, parent, null)\n\t\tif (isNumber(update.left)) {\n\t\t\tupdate.left -= boundingBox.x\n\t\t}\n\t\tif (isNumber(update.top)) {\n\t\t\tupdate.top -= boundingBox.y\n\t\t}\n\t\treturn update\n\t}\n\n\treturn ContextAction.convertNodeToNewParentUpdate(tree, node, parent, null)\n}\n\nexport function collectAndCleanupTemplateData(\n\tcopyTree: CanvasTree,\n\tpreserveMasters: boolean = false,\n): {\n\tmasters: NodeIDToBoolean\n\treplicas: NodeIDToReplicaInfo\n} {\n\tconst masters: NodeIDToBoolean = {}\n\tconst replicas: NodeIDToReplicaInfo = {}\n\tfor (const copyOfNode of copyTree.root.walk()) {\n\t\tassert(!copyOfNode.originalid, \"copyTree should not have nodes with originalid anymore\")\n\t\tif (withTemplate(copyOfNode) && copyOfNode.isMaster) {\n\t\t\tmasters[copyOfNode.id] = true\n\t\t\t// When copying a SmartComponentNode (the entire scope), we want to preserve the masters.\n\t\t\tconst filter = preserveMasters ? isVariant : isBreakpointVariant\n\t\t\tif (!filter(copyOfNode)) copyOfNode.isMaster = false\n\t\t}\n\t\tif (copyOfNode.replicaInfo) {\n\t\t\treplicas[copyOfNode.id] = copyOfNode.replicaInfo\n\t\t\tcopyOfNode.replicaInfo = null\n\t\t}\n\t}\n\n\treturn { masters, replicas }\n}\n\nfunction getTopLevelNodeIdToScopeMap(tree: CanvasTree, topLevelNodes: CanvasNode[]) {\n\tconst scopeNodes = new Map<NodeID, ScopeNode>()\n\n\tfor (const node of topLevelNodes) {\n\t\tconst scopeNode = tree.getScopeNodeFor(node)\n\t\tif (!scopeNode) continue\n\t\tscopeNodes.set(node.id, scopeNode)\n\t}\n\treturn scopeNodes\n}\n", "import { Color, P3Color } from \"library/render/types/Color/Color.ts\"\nimport { isNumber } from \"utils/typeChecks.ts\"\n\nfunction getColorBrightness(color: string | number): number | undefined {\n\tconst parsed = Color.isP3String(color) ? P3Color.fromString(color) : Color(color)\n\tif (!parsed) return undefined\n\n\treturn parsed.r * 0.299 + parsed.g * 0.587 + parsed.b * 0.114 + (1 - parsed.a) * 255\n}\n\nexport function isLightOrDarkColor(color: string | number): \"light\" | \"dark\" | undefined {\n\tconst brightness = getColorBrightness(color)\n\tif (!isNumber(brightness)) return undefined\n\treturn brightness > 128 ? \"light\" : \"dark\"\n}\n", "import { assert } from \"@framerjs/shared\"\nimport { experiments } from \"app/experiments.ts\"\nimport type { VekterEngine } from \"document/VekterEngine.ts\"\nimport { CollectionItemNode, type CollectionNode, type NodeID } from \"document/models/CanvasTree/index.ts\"\nimport { isCollectionNode } from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport type { AddReferenceAction } from \"document/utils/contentManagementOverlayStack.ts\"\nimport { getItemNodeFromStackElement } from \"document/utils/contentManagementOverlayStack.ts\"\nimport { ControlType } from \"library/render/types/PropertyControls.ts\"\nimport { record } from \"web/lib/tracker.ts\"\nimport { shouldEnableDraftStatusForNewEntity } from \"./shouldEnableDraftStatusForNewEntity.ts\"\n\ninterface CreateCollectionItemOptions {\n\tcollectionId: NodeID\n\tengine: VekterEngine\n\tsaveAction?: AddReferenceAction\n\tsource: string\n}\n\nexport function createCollectionItemWhenReady(options: CreateCollectionItemOptions) {\n\toptions.engine.scheduler.processWhenReady(() => {\n\t\tcreateCollectionItem(options)\n\t})\n}\n\nexport function createCollectionItem({ collectionId, engine, saveAction, source }: CreateCollectionItemOptions) {\n\tconst collection = engine.tree.getNodeWithTrait(collectionId, isCollectionNode)\n\tassert(collection, \"Collection needs to exist to allow creation of new item\")\n\n\tconst { contentManagementStore, treeStore, selectionStore } = engine.stores\n\tconst selectedCollection = engine.tree.getNodeWithTrait(selectionStore.ids[0], isCollectionNode)\n\tif (selectedCollection && selectedCollection.id !== collection.id) {\n\t\tassert(saveAction, \"saveAction is required when creating a nested temporary item\")\n\t}\n\n\tif (experiments.isOn(\"cmsPrivateDraftItems\")) {\n\t\tcreatePrivateDraftCollectionItem({\n\t\t\tcollection,\n\t\t\tengine,\n\t\t\tsaveAction,\n\t\t})\n\t\trecord(\"collection_record_create\", { source })\n\t\treturn\n\t}\n\n\tcontentManagementStore.createTemporaryCollectionItem({\n\t\tcollectionId: collection.id,\n\t\tsaveAction,\n\t})\n\tconst temporaryCollectionItem = getItemNodeFromStackElement({\n\t\ttreeStore,\n\t\tcontentManagementStore,\n\t\tstackElement: contentManagementStore.getActivePrivateDraftCollectionStackElement(),\n\t})\n\tassert(temporaryCollectionItem)\n\n\tsetDefaultDatesForCollectionItem(collection, temporaryCollectionItem)\n\n\tif (shouldEnableDraftStatusForNewEntity(engine)) {\n\t\ttemporaryCollectionItem.set({\n\t\t\tisDraft: true,\n\t\t})\n\t}\n\n\trecord(\"collection_record_create\", { source })\n}\n\nfunction createPrivateDraftCollectionItem({\n\tcollection,\n\tengine,\n\tsaveAction,\n}: {\n\tcollection: CollectionNode\n\tengine: VekterEngine\n\tsaveAction?: AddReferenceAction\n}) {\n\tconst currentUserId = engine.stores.sessionStore.user.id\n\tconst existingPrivateItem = getNewestPrivateCollectionItemForUser(collection, currentUserId)\n\tconst item = existingPrivateItem ?? CollectionItemNode.create({ privateToUserId: currentUserId })\n\n\tif (!existingPrivateItem) {\n\t\tengine.stores.scopeStore.insertNode(item, collection.id, 0)\n\t\tsetDefaultDatesForCollectionItem(collection, item)\n\n\t\tif (shouldEnableDraftStatusForNewEntity(engine)) {\n\t\t\titem.set({\n\t\t\t\tisDraft: true,\n\t\t\t})\n\t\t}\n\t}\n\n\tengine.stores.contentManagementStore.openPrivateDraftCollectionItem({\n\t\tcollectionId: collection.id,\n\t\titemId: item.id,\n\t\tsaveAction,\n\t})\n}\n\nfunction getNewestPrivateCollectionItemForUser(\n\tcollection: CollectionNode,\n\tuserId: string,\n): CollectionItemNode | undefined {\n\tlet newestItem: CollectionItemNode | undefined\n\tlet newestCreatedAt = 0\n\n\tfor (const item of collection.children) {\n\t\tif (item.privateToUserId !== userId) continue\n\n\t\tconst createdAt = getCreatedAtTime(item)\n\t\tif (!newestItem || createdAt > newestCreatedAt) {\n\t\t\tnewestItem = item\n\t\t\tnewestCreatedAt = createdAt\n\t\t}\n\t}\n\n\treturn newestItem\n}\n\nfunction getCreatedAtTime(collectionItem: CollectionItemNode): number {\n\tif (!collectionItem.createdAt) return 0\n\tconst time = new Date(collectionItem.createdAt).getTime()\n\treturn Number.isNaN(time) ? 0 : time\n}\n\nexport function setDefaultDatesForCollectionItem(collection: CollectionNode, collectionItem: CollectionItemNode) {\n\tconst defaultDateSource = getDefaultDateSourceForCollectionItem(collectionItem)\n\n\tfor (const variable of collection.variables) {\n\t\tif (variable.type === ControlType.Date) {\n\t\t\tcollectionItem.setControlProp(variable.id, {\n\t\t\t\ttype: ControlType.Date,\n\t\t\t\tvalue: getDefaultDateValue(defaultDateSource, variable.options?.displayTime),\n\t\t\t})\n\t\t}\n\t}\n}\n\nfunction getDefaultDateSourceForCollectionItem(collectionItem: CollectionItemNode): Date {\n\tif (!collectionItem.createdAt) return new Date()\n\n\tconst createdAt = new Date(collectionItem.createdAt)\n\tif (Number.isNaN(createdAt.getTime())) return new Date()\n\n\treturn createdAt\n}\n\n/**\n * Get the default date value for a collection item, representing the current local date/time in UTC.\n *\n * Our CMS is not aware of timezones. In JavaScript, Date objects always have a time zone. So we just store\n * in UTC and display the UI in UTC, ignoring the time zone.\n * In other words, we treat Date objects as `Temporal.PlainDateTime` instead of `Temporal.Instant`.\n *\n * If we didn't do this conversion and instead stored \"the current UTC time\", there would be corner cases where\n * e.g., users in Los Angeles at \"their 18:00\" would see their new items be created at \"their tomorrow\" by default.\n */\nexport function getDefaultDateValue(now: Date, displayTime: boolean | undefined): string {\n\tif (!displayTime) {\n\t\t// Midnight for date-only fields\n\t\treturn new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate())).toJSON()\n\t}\n\n\t// Current time for date-time fields\n\treturn new Date(\n\t\tDate.UTC(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes(), 0, 0),\n\t).toJSON()\n}\n", "import type { VariableOrDivider } from \"document/models/CanvasTree/traits/WithVariables.ts\"\nimport type { CollectionControlProp } from \"document/models/controlProps/CollectionControlProp.ts\"\nimport type { DateControlProp } from \"document/models/controlProps/ControlProp.ts\"\nimport { ControlType } from \"library/render/types/PropertyControls.ts\"\nimport { getDefaultDateValue } from \"utils/createCollectionItem.ts\"\nimport { isString } from \"utils/typeChecks.ts\"\nimport { hasNonBlankCollectionItemValue } from \"../CollectionItemNode.ts\"\nimport type { CollectionItemNode } from \"../CollectionItemNode.ts\"\nimport type { CollectionNode } from \"../CollectionNode.ts\"\n\nexport function privateDraftCollectionItemHasUserData({\n\tcollection,\n\tcollectionItem,\n}: {\n\tcollection: CollectionNode\n\tcollectionItem: CollectionItemNode\n}): boolean {\n\tif (!collectionItem.hasData()) return false\n\n\tfor (const variable of collection.variables) {\n\t\tif (variable.type === \"divider\") continue\n\n\t\tconst controlProp = collectionItem.getControlProp(variable.id)\n\t\tif (!controlProp || !hasNonBlankCollectionItemValue(controlProp.value)) continue\n\t\tif (isDefaultDateControlProp(collectionItem, controlProp, variable)) continue\n\n\t\treturn true\n\t}\n\n\treturn false\n}\n\nfunction isDefaultDateControlProp(\n\tcollectionItem: CollectionItemNode,\n\tcontrolProp: CollectionControlProp,\n\tvariable: VariableOrDivider,\n): controlProp is DateControlProp {\n\tif (variable.type !== ControlType.Date) return false\n\tif (controlProp.type !== ControlType.Date) return false\n\tif (!isString(controlProp.value)) return false\n\tif (!collectionItem.createdAt) return false\n\n\tconst createdAt = new Date(collectionItem.createdAt)\n\tif (Number.isNaN(createdAt.getTime())) return false\n\n\treturn controlProp.value === getDefaultDateValue(createdAt, variable.options?.displayTime)\n}\n", "import { assert } from \"@framerjs/shared\"\nimport type { Locale } from \"document/models/CanvasTree/traits/WithLocales.ts\"\nimport type { LocalizedTextValue, LocalizedValues, NonNullLocalizedValue } from \"document/models/LocalizedValue.ts\"\nimport { isNonNullLocalizedValue } from \"document/models/LocalizedValue.ts\"\nimport type { LocalizationSource } from \"./getLocalizationSources.ts\"\nimport { isImageSource } from \"./getLocalizationSources.ts\"\nimport type { LocalizationSpecificTarget } from \"./updateLocalizedValue.ts\"\n\nexport function getLocalizedFallback(\n\tsource: LocalizationSource,\n\tactiveLocale: Locale,\n\tlocales: readonly Locale[],\n\ttarget: LocalizationSpecificTarget = \"default\",\n): NonNullLocalizedValue<LocalizedTextValue> | undefined {\n\tif (!activeLocale.fallback) return\n\n\tconst seenFallbacks = new Set<string>()\n\tseenFallbacks.add(activeLocale.id)\n\n\tlet fallback: string | undefined = activeLocale.fallback\n\n\twhile (fallback) {\n\t\tif (seenFallbacks.has(fallback)) return\n\t\tseenFallbacks.add(fallback)\n\n\t\tconst locale = locales.find(({ id }) => id === fallback)\n\t\tif (!locale) return\n\n\t\tlet localizedValues: LocalizedValues<LocalizedTextValue> | undefined = source.localizedValues\n\n\t\tif (target === \"imageSrc\") {\n\t\t\tassert(isImageSource(source))\n\t\t\tlocalizedValues = source.imageLocalizedValues\n\t\t}\n\n\t\tconst localizedValue = localizedValues?.[fallback]\n\t\tif (localizedValue && isNonNullLocalizedValue(localizedValue)) {\n\t\t\treturn localizedValue\n\t\t}\n\n\t\tfallback = locale.fallback\n\t}\n}\n", "import { colors, fonts } from \"@framerjs/fresco/tokens\"\n\nexport interface ThemeSyntaxStyle {\n\tcolor?: string\n\tfontStyle?: \"normal\" | \"italic\"\n\tfontWeight?: \"normal\" | \"bold\" | \"100\" | \"200\" | \"300\" | \"400\" | \"500\" | \"600\" | \"700\" | \"800\" | \"900\"\n\ttextDecoration?: \"none\" | \"underline\" | \"line-through\" | \"underline line-through\"\n}\n\nexport interface Theme {\n\tcolors: {\n\t\tsurface1: string\n\t\tsurface3?: string\n\t\tdisabled?: string\n\t\taccent?: string\n\t\terrorSurface?: string\n\t}\n\tsyntax: {\n\t\tplain: string\n\t\tcomment: string\n\t\tkeyword: string\n\t\ttag: string\n\t\tpunctuation: string\n\t\tdefinition: string\n\t\tproperty: string\n\t\tstatic: string\n\t\tstring: string\n\t}\n\tfont: {\n\t\tmono: string\n\t\tlineHeight: string\n\t}\n\tfontStyle: {\n\t\tcomment: \"normal\" | \"italic\"\n\t\tproperty: \"normal\" | \"italic\"\n\t\tkeyword: \"normal\" | \"italic\"\n\t}\n}\n\nexport const cmsTheme: Theme = {\n\tcolors: {\n\t\tsurface1: colors.cmsCodeBlockSurface1,\n\t\tsurface3: colors.cmsCodeBlockSurface3,\n\t\tdisabled: colors.cmsCodeBlockDisabled,\n\t\taccent: colors.cmsCodeBlockAccent,\n\t\terrorSurface: colors.cmsCodeBlockErrorSurface,\n\t},\n\tsyntax: {\n\t\tplain: colors.cmsCodeBlockPlain,\n\t\tcomment: colors.cmsCodeBlockComment,\n\t\tkeyword: colors.cmsCodeBlockKeyword,\n\t\ttag: colors.cmsCodeBlockTag,\n\t\tpunctuation: colors.cmsCodeBlockPunctuation,\n\t\tdefinition: colors.cmsCodeBlockDefinition,\n\t\tproperty: colors.cmsCodeBlockProperty,\n\t\tstatic: colors.cmsCodeBlockStatic,\n\t\tstring: colors.cmsCodeBlockString,\n\t},\n\tfont: {\n\t\tmono: fonts.family.monospace,\n\t\tlineHeight: \"20px\",\n\t},\n\tfontStyle: {\n\t\tcomment: \"italic\",\n\t\tproperty: \"normal\",\n\t\tkeyword: \"normal\",\n\t},\n}\n\nexport const amethyst: Theme = {\n\tcolors: {\n\t\tsurface1: \"#000000\",\n\t\tsurface3: \"#3b3b4f\",\n\t\tdisabled: \"#858591\",\n\t\taccent: \"#a26cd6\",\n\t\terrorSurface: \"#3b3b4f\",\n\t},\n\tsyntax: {\n\t\tplain: \"#ffffff\",\n\t\tcomment: \"#858591\",\n\t\tkeyword: \"#a26cdd\",\n\t\ttag: \"#f07178\",\n\t\tpunctuation: \"#99c9ff\",\n\t\tdefinition: \"#ffffff\",\n\t\tproperty: \"#99c9ff\",\n\t\tstatic: \"#f78c6c\",\n\t\tstring: \"#57d1b7\",\n\t},\n\tfont: {\n\t\tmono: '\"Fira Mono\", \"DejaVu Sans Mono\", Menlo, Consolas, \"Liberation Mono\", Monaco, \"Lucida Console\", monospace',\n\t\tlineHeight: \"18px\",\n\t},\n\tfontStyle: {\n\t\tcomment: \"italic\",\n\t\tproperty: \"normal\",\n\t\tkeyword: \"normal\",\n\t},\n}\n\nexport const aquaBlue: Theme = {\n\tcolors: {\n\t\tsurface1: \"#f8f9fb\",\n\t\tsurface3: \"#e4e7eb\",\n\t\tdisabled: \"#C5C5C5\",\n\t\taccent: \"#2e7692\",\n\t},\n\tsyntax: {\n\t\tplain: \"#1F2933\",\n\t\tcomment: \"#A7B6C2\",\n\t\tkeyword: \"#1A56DB\",\n\t\ttag: \"#1A56DB\",\n\t\tpunctuation: \"#394b59\",\n\t\tdefinition: \"#A23DAD\",\n\t\tproperty: \"#2e7692\",\n\t\tstatic: \"#1A56DB\",\n\t\tstring: \"#1992D4\",\n\t},\n\tfont: {\n\t\tmono: '\"Fira Mono\", \"DejaVu Sans Mono\", Menlo, Consolas, \"Liberation Mono\", Monaco, \"Lucida Console\", monospace',\n\t\tlineHeight: \"20px\",\n\t},\n\tfontStyle: {\n\t\tcomment: \"italic\",\n\t\tproperty: \"normal\",\n\t\tkeyword: \"normal\",\n\t},\n}\n\nexport const atomDark: Theme = {\n\tcolors: {\n\t\tsurface1: \"#282c34\",\n\t\tsurface3: \"#2c313c\",\n\t\tdisabled: \"#4d4d4d\",\n\t\taccent: \"#c678dd\",\n\t\terrorSurface: \"#ffeceb\",\n\t},\n\tsyntax: {\n\t\tplain: \"#a8b1c2\",\n\t\tcomment: \"#757575\",\n\t\tkeyword: \"#c678dd\",\n\t\ttag: \"#e06c75\",\n\t\tpunctuation: \"#a8b1c2\",\n\t\tdefinition: \"#62aeef\",\n\t\tproperty: \"#d19a66\",\n\t\tstatic: \"#a8b1c2\",\n\t\tstring: \"#98c379\",\n\t},\n\tfont: {\n\t\tmono: '\"Fira Mono\", \"DejaVu Sans Mono\", Menlo, Consolas, \"Liberation Mono\", Monaco, \"Lucida Console\", monospace',\n\t\tlineHeight: \"20px\",\n\t},\n\tfontStyle: {\n\t\tcomment: \"italic\",\n\t\tproperty: \"normal\",\n\t\tkeyword: \"normal\",\n\t},\n}\n\nexport const atomLight: Theme = {\n\tcolors: {\n\t\tsurface1: \"#fafafa\",\n\t},\n\tsyntax: {\n\t\tplain: \"#383a42\",\n\t\tcomment: \"#a0a1a7\",\n\t\tkeyword: \"#a626a4\",\n\t\ttag: \"#e45649\",\n\t\tpunctuation: \"#383a42\",\n\t\tdefinition: \"#c18401\",\n\t\tproperty: \"#4078f2\",\n\t\tstatic: \"#986801\",\n\t\tstring: \"#50a14f\",\n\t},\n\tfont: {\n\t\tmono: '\"Fira Mono\", \"DejaVu Sans Mono\", Menlo, Consolas, \"Liberation Mono\", Monaco, \"Lucida Console\", monospace',\n\t\tlineHeight: \"20px\",\n\t},\n\tfontStyle: {\n\t\tcomment: \"italic\",\n\t\tproperty: \"normal\",\n\t\tkeyword: \"normal\",\n\t},\n}\n\nexport const ayuDark: Theme = {\n\tcolors: {\n\t\tsurface1: \"#0c1017\",\n\t},\n\tsyntax: {\n\t\tcomment: \"#646a72\",\n\t\tdefinition: \"#5ac2ff\",\n\t\tkeyword: \"#ff9040\",\n\t\tplain: \"#bfbdb6\",\n\t\tproperty: \"#ffb454\",\n\t\tpunctuation: \"#bfbdb6\",\n\t\tstatic: \"#d2a6ff\",\n\t\tstring: \"#80d962\",\n\t\ttag: \"#3bbae7\",\n\t},\n\tfont: {\n\t\tmono: '\"Fira Mono\", \"DejaVu Sans Mono\", Menlo, Consolas, \"Liberation Mono\", Monaco, \"Lucida Console\", monospace',\n\t\tlineHeight: \"20px\",\n\t},\n\tfontStyle: {\n\t\tcomment: \"italic\",\n\t\tproperty: \"normal\",\n\t\tkeyword: \"normal\",\n\t},\n}\n\nexport const ayuLight: Theme = {\n\tcolors: {\n\t\tsurface1: \"#fafafa\",\n\t},\n\tsyntax: {\n\t\tcomment: \"#aaaeb1\",\n\t\tdefinition: \"#3b9ee6\",\n\t\tkeyword: \"#fa8e3e\",\n\t\tplain: \"#5c6166\",\n\t\tproperty: \"#f2ae49\",\n\t\tpunctuation: \"#5c6167\",\n\t\tstatic: \"#a37acc\",\n\t\tstring: \"#87b300\",\n\t\ttag: \"#56b4d5\",\n\t},\n\tfont: {\n\t\tmono: '\"Fira Mono\", \"DejaVu Sans Mono\", Menlo, Consolas, \"Liberation Mono\", Monaco, \"Lucida Console\", monospace',\n\t\tlineHeight: \"20px\",\n\t},\n\tfontStyle: {\n\t\tcomment: \"italic\",\n\t\tproperty: \"normal\",\n\t\tkeyword: \"normal\",\n\t},\n}\n\nexport const cobalt2: Theme = {\n\tcolors: {\n\t\tsurface1: \"#193549\",\n\t\tsurface3: \"#1f4662\",\n\t\tdisabled: \"#C5C5C5\",\n\t\taccent: \"#ffc600\",\n\t\terrorSurface: \"#0d3a58\",\n\t},\n\tsyntax: {\n\t\tplain: \"#ffffff\",\n\t\tcomment: \"#0088ff\",\n\t\tkeyword: \"#ff9d00\",\n\t\ttag: \"#9effff\",\n\t\tpunctuation: \"#e1efff\",\n\t\tdefinition: \"#ffc600\",\n\t\tproperty: \"#ffc600\",\n\t\tstatic: \"#ffee80\",\n\t\tstring: \"#a5ff90\",\n\t},\n\tfont: {\n\t\tmono: '\"Operator Mono\", \"Fira Mono\", \"DejaVu Sans Mono\", Menlo, Consolas, \"Liberation Mono\", Monaco, \"Lucida Console\", monospace',\n\t\tlineHeight: \"20px\",\n\t},\n\tfontStyle: {\n\t\tcomment: \"italic\",\n\t\tproperty: \"normal\",\n\t\tkeyword: \"normal\",\n\t},\n}\n\nexport const cyberpunk: Theme = {\n\tcolors: {\n\t\tsurface1: \"#051c30\",\n\t\tsurface3: \"#042f40\",\n\t\tdisabled: \"#C5C5C5\",\n\t\taccent: \"#fdf500\",\n\t\terrorSurface: \"#051c30\",\n\t},\n\tsyntax: {\n\t\tplain: \"#ffffff\",\n\t\tcomment: \"#1ac5b0\",\n\t\tkeyword: \"#fdf500\",\n\t\ttag: \"#ffc600\",\n\t\tpunctuation: \"#afd7fa\",\n\t\tdefinition: \"#ffc600\",\n\t\tproperty: \"#fdf500\",\n\t\tstatic: \"#e455ae\",\n\t\tstring: \"#37ebf3\",\n\t},\n\tfont: {\n\t\tmono: '\"Fira Mono\", \"DejaVu Sans Mono\", Menlo, Consolas, \"Liberation Mono\", Monaco, \"Lucida Console\", monospace',\n\t\tlineHeight: \"20px\",\n\t},\n\tfontStyle: {\n\t\tcomment: \"italic\",\n\t\tproperty: \"normal\",\n\t\tkeyword: \"normal\",\n\t},\n}\n\nexport const dracula: Theme = {\n\tcolors: {\n\t\tsurface1: \"#282a36\",\n\t\tsurface3: \"#44475a\",\n\t\tdisabled: \"#6272a4\",\n\t\taccent: \"#bd93f9\",\n\t\terrorSurface: \"#44475a\",\n\t},\n\tsyntax: {\n\t\tplain: \"#f8f8f2\",\n\t\tcomment: \"#6272a4\",\n\t\tkeyword: \"#ff79c6\",\n\t\ttag: \"#ff79c6\",\n\t\tpunctuation: \"#ff79c6\",\n\t\tdefinition: \"#f8f8f2\",\n\t\tproperty: \"#50fa7b\",\n\t\tstatic: \"#bd93f9\",\n\t\tstring: \"#f1fa8c\",\n\t},\n\tfont: {\n\t\tmono: '\"Fira Mono\", \"DejaVu Sans Mono\", Menlo, Consolas, \"Liberation Mono\", Monaco, \"Lucida Console\", monospace',\n\t\tlineHeight: \"20px\",\n\t},\n\tfontStyle: {\n\t\tcomment: \"italic\",\n\t\tproperty: \"normal\",\n\t\tkeyword: \"normal\",\n\t},\n}\n\nexport const framerDark: Theme = {\n\tcolors: {\n\t\tsurface1: \"#161820\",\n\t\tsurface3: \"#2f2f2f\",\n\t\tdisabled: \"#4d4d4d\",\n\t\taccent: \"#0099ff\",\n\t\terrorSurface: \"#ffe0e8\",\n\t},\n\tsyntax: {\n\t\tplain: \"#eeeeee\",\n\t\tcomment: \"#666666\",\n\t\tkeyword: \"#00BBFF\",\n\t\ttag: \"#00BBFF\",\n\t\tpunctuation: \"#999999\",\n\t\tdefinition: \"#ffcc66\",\n\t\tproperty: \"#77dddd\",\n\t\tstatic: \"#ff8866\",\n\t\tstring: \"#bb88ff\",\n\t},\n\tfont: {\n\t\tmono: '\"Fira Mono\", \"DejaVu Sans Mono\", Menlo, Consolas, \"Liberation Mono\", Monaco, \"Lucida Console\", monospace',\n\t\tlineHeight: \"20px\",\n\t},\n\tfontStyle: {\n\t\tcomment: \"italic\",\n\t\tproperty: \"normal\",\n\t\tkeyword: \"normal\",\n\t},\n}\n\nexport const framerLight: Theme = {\n\tcolors: {\n\t\tsurface1: \"#fafafa\",\n\t\tsurface3: \"#f3f3f3\",\n\t\tdisabled: \"#c5c5c5\",\n\t\taccent: \"#0099ff\",\n\t\terrorSurface: \"#ffe0e8\",\n\t},\n\tsyntax: {\n\t\tplain: \"#666666\",\n\t\tcomment: \"#bbbbbb\",\n\t\tkeyword: \"#0099ff\",\n\t\ttag: \"#0099ff\",\n\t\tpunctuation: \"#bbbbbb\",\n\t\tdefinition: \"#FFAA00\",\n\t\tproperty: \"#33cccc\",\n\t\tstatic: \"#ff8866\",\n\t\tstring: \"#8855ff\",\n\t},\n\tfont: {\n\t\tmono: '\"Fira Mono\", \"DejaVu Sans Mono\", Menlo, Consolas, \"Liberation Mono\", Monaco, \"Lucida Console\", monospace',\n\t\tlineHeight: \"20px\",\n\t},\n\tfontStyle: {\n\t\tcomment: \"italic\",\n\t\tproperty: \"normal\",\n\t\tkeyword: \"normal\",\n\t},\n}\n\nexport const freeCodeCamp: Theme = {\n\tcolors: {\n\t\tsurface1: \"#2a2a40\",\n\t\tsurface3: \"#3b3b4f\",\n\t\tdisabled: \"#858591\",\n\t\taccent: \"#dbb8ff\",\n\t\terrorSurface: \"#3b3b4f\",\n\t},\n\tsyntax: {\n\t\tplain: \"#ffffff\",\n\t\tcomment: \"#858591\",\n\t\tkeyword: \"#dbb8ff\",\n\t\ttag: \"#f07178\",\n\t\tpunctuation: \"#99c9ff\",\n\t\tdefinition: \"#ffffff\",\n\t\tproperty: \"#99c9ff\",\n\t\tstatic: \"#f78c6c\",\n\t\tstring: \"#acd157\",\n\t},\n\tfont: {\n\t\tmono: '\"Fira Mono\", \"DejaVu Sans Mono\", Menlo, Consolas, \"Liberation Mono\", Monaco, \"Lucida Console\", monospace',\n\t\tlineHeight: \"20px\",\n\t},\n\tfontStyle: {\n\t\tcomment: \"italic\",\n\t\tproperty: \"normal\",\n\t\tkeyword: \"normal\",\n\t},\n}\n\nexport const githubDark: Theme = {\n\tcolors: {\n\t\tsurface1: \"#0d1117\",\n\t\tsurface3: framerDark.colors?.surface3,\n\t\tdisabled: framerDark.colors?.disabled,\n\t\taccent: framerDark.colors?.accent,\n\t\terrorSurface: framerDark.colors?.errorSurface,\n\t},\n\tsyntax: {\n\t\tcomment: \"#8b949e\",\n\t\tdefinition: \"#d2a8ff\",\n\t\tkeyword: \"#ff7b72\",\n\t\tplain: \"#e6edf3\",\n\t\tproperty: \"#79c0ff\",\n\t\tpunctuation: \"#e6edf3\",\n\t\tstatic: \"#7ee787\",\n\t\tstring: \"#a5d6ff\",\n\t\ttag: \"#7ee787\",\n\t},\n\tfont: {\n\t\tmono: '\"Fira Mono\", \"DejaVu Sans Mono\", Menlo, Consolas, \"Liberation Mono\", Monaco, \"Lucida Console\", monospace',\n\t\tlineHeight: \"20px\",\n\t},\n\tfontStyle: {\n\t\tcomment: \"italic\",\n\t\tproperty: \"normal\",\n\t\tkeyword: \"normal\",\n\t},\n}\n\nexport const githubLight: Theme = {\n\tcolors: {\n\t\tsurface1: \"#ffffff\",\n\t\tsurface3: \"#f5f5f5\",\n\t\tdisabled: \"#d1d4d8\",\n\t\taccent: \"#24292e\",\n\t},\n\tsyntax: {\n\t\tkeyword: \"#d73a49\",\n\t\tproperty: \"#005cc5\",\n\t\tplain: \"#24292e\",\n\t\tstatic: \"#032f62\",\n\t\tstring: \"#032f62\",\n\t\tdefinition: \"#6f42c1\",\n\t\tpunctuation: \"#24292e\",\n\t\ttag: \"#22863a\",\n\t\tcomment: \"#6a737d\",\n\t},\n\tfont: {\n\t\tmono: '\"Fira Mono\", \"DejaVu Sans Mono\", Menlo, Consolas, \"Liberation Mono\", Monaco, \"Lucida Console\", monospace',\n\t\tlineHeight: \"20px\",\n\t},\n\tfontStyle: {\n\t\tcomment: \"normal\",\n\t\tproperty: \"normal\",\n\t\tkeyword: \"normal\",\n\t},\n}\n\nexport const levelUp: Theme = {\n\tcolors: {\n\t\tsurface1: \"#191324\",\n\t\tsurface3: \"#524763\",\n\t\tdisabled: \"#aaaaaa\",\n\t\taccent: \"#82d8d8\",\n\t\terrorSurface: \"#191324\",\n\t},\n\tsyntax: {\n\t\tplain: \"#ffffff\",\n\t\tcomment: \"#82d8d8\",\n\t\tkeyword: \"#e54b4b\",\n\t\ttag: \"#ff26be\",\n\t\tpunctuation: \"#9588aa\",\n\t\tdefinition: \"#82d8d8\",\n\t\tproperty: \"#82d8d8\",\n\t\tstatic: \"#82d8d8\",\n\t\tstring: \"#a8fe39\",\n\t},\n\tfont: {\n\t\tmono: '\"MonoLisa\", \"Fira Mono\", \"DejaVu Sans Mono\", Menlo, Consolas, \"Liberation Mono\", Monaco, \"Lucida Console\", monospace',\n\t\tlineHeight: \"20px\",\n\t},\n\tfontStyle: {\n\t\tcomment: \"italic\",\n\t\tproperty: \"normal\",\n\t\tkeyword: \"normal\",\n\t},\n}\n\nexport const monokaiPro: Theme = {\n\tcolors: {\n\t\tsurface1: \"#2D2A2E\",\n\t\tsurface3: \"#484747\",\n\t\tdisabled: \"#444344\",\n\t\taccent: \"#FFD866\",\n\t\terrorSurface: \"#c24038\",\n\t},\n\tsyntax: {\n\t\tplain: \"rgb(252, 252, 250)\",\n\t\tcomment: \"#757575\",\n\t\tkeyword: \"rgb(255, 97, 136)\",\n\t\ttag: \"rgb(120, 220, 232)\",\n\t\tpunctuation: \"rgb(147, 146, 147)\",\n\t\tdefinition: \"rgb(169, 220, 118)\",\n\t\tproperty: \"rgb(120, 220, 232)\",\n\t\tstatic: \"rgb(171, 157, 242)\",\n\t\tstring: \"rgb(255, 216, 102)\",\n\t},\n\tfont: {\n\t\tmono: '\"Fira Mono\", \"DejaVu Sans Mono\", Menlo, Consolas, \"Liberation Mono\", Monaco, \"Lucida Console\", monospace',\n\t\tlineHeight: \"20px\",\n\t},\n\tfontStyle: {\n\t\tcomment: \"italic\",\n\t\tproperty: \"italic\",\n\t\tkeyword: \"normal\",\n\t},\n}\n\nexport const magic: Theme = {\n\tcolors: {\n\t\tsurface1: \"#f6f6f8\",\n\t\tsurface3: \"#f6f6f8\",\n\t\tdisabled: \"#C5C5C5\",\n\t\taccent: \"#ffa600\",\n\t\terrorSurface: \"#ffeceb\",\n\t},\n\tsyntax: {\n\t\tplain: \"#151515\",\n\t\tcomment: \"#cacacd\",\n\t\tkeyword: \"#ffa600\",\n\t\ttag: \"#ff9a4d\",\n\t\tpunctuation: \"#ffb3b3\",\n\t\tdefinition: \"#ff6f00\",\n\t\tproperty: \"#9900ff\",\n\t\tstatic: \"#FF453A\",\n\t\tstring: \"#f53524\",\n\t},\n\tfont: {\n\t\tmono: '\"Roboto Mono\", monospace',\n\t\tlineHeight: \"24px\",\n\t},\n\tfontStyle: {\n\t\tcomment: \"italic\",\n\t\tproperty: \"normal\",\n\t\tkeyword: \"normal\",\n\t},\n}\n\nexport const neoCyan: Theme = {\n\tcolors: {\n\t\tsurface1: \"#2b3935\",\n\t\tsurface3: \"#524763\",\n\t\tdisabled: \"#aaaaaa\",\n\t\taccent: \"#82d8d8\",\n\t\terrorSurface: \"#191324\",\n\t},\n\tsyntax: {\n\t\tplain: \"#ffffff\",\n\t\tcomment: \"#82d8d8\",\n\t\tkeyword: \"#e54b4b\",\n\t\ttag: \"#ff26be\",\n\t\tpunctuation: \"#9588aa\",\n\t\tdefinition: \"#82d8d8\",\n\t\tproperty: \"#82d8d8\",\n\t\tstatic: \"#82d8d8\",\n\t\tstring: \"#a8fe39\",\n\t},\n\tfont: {\n\t\tmono: '\"MonoLisa\", \"Fira Mono\", \"DejaVu Sans Mono\", Menlo, Consolas, \"Liberation Mono\", Monaco, \"Lucida Console\", monospace',\n\t\tlineHeight: \"18px\",\n\t},\n\tfontStyle: {\n\t\tcomment: \"italic\",\n\t\tproperty: \"normal\",\n\t\tkeyword: \"normal\",\n\t},\n}\n\nexport const nightOwl: Theme = {\n\tcolors: {\n\t\tsurface1: \"#011627\",\n\t\tsurface3: \"#112331\",\n\t\tdisabled: \"#4D4D4D\",\n\t\taccent: \"#c5e4fd\",\n\t\terrorSurface: \"#811e18\",\n\t},\n\tsyntax: {\n\t\tplain: \"#d6deeb\",\n\t\tcomment: \"#999999\",\n\t\tkeyword: \"#c792ea\",\n\t\ttag: \"#7fdbca\",\n\t\tpunctuation: \"#7fdbca\",\n\t\tdefinition: \"#82aaff\",\n\t\tproperty: \"#addb67\",\n\t\tstatic: \"#f78c6c\",\n\t\tstring: \"#ecc48d\",\n\t},\n\tfont: {\n\t\tmono: '\"Fira Mono\", \"DejaVu Sans Mono\", Menlo, Consolas, \"Liberation Mono\", Monaco, \"Lucida Console\", monospace',\n\t\tlineHeight: \"20px\",\n\t},\n\tfontStyle: {\n\t\tcomment: \"italic\",\n\t\tproperty: \"italic\",\n\t\tkeyword: \"italic\",\n\t},\n}\n\nexport const sandpackDark: Theme = {\n\tcolors: {\n\t\tsurface1: \"#151515\",\n\t\tsurface3: \"#2F2F2F\",\n\t\tdisabled: \"#4D4D4D\",\n\t\taccent: \"#90e86f\",\n\t\terrorSurface: \"#b08df8\",\n\t},\n\tsyntax: {\n\t\tplain: \"#f0fdaf\",\n\t\tcomment: \"#757575\",\n\t\tkeyword: \"#e5fd78\",\n\t\ttag: \"#f0fdaf\",\n\t\tpunctuation: \"#ffffff\",\n\t\tdefinition: \"#eeeeee\",\n\t\tproperty: \"#90e86f\",\n\t\tstatic: \"#ffffff\",\n\t\tstring: \"#dafecf\",\n\t},\n\tfont: {\n\t\tmono: '\"Fira Mono\", \"DejaVu Sans Mono\", Menlo, Consolas, \"Liberation Mono\", Monaco, \"Lucida Console\", monospace',\n\t\tlineHeight: \"20px\",\n\t},\n\tfontStyle: {\n\t\tcomment: \"italic\",\n\t\tproperty: \"normal\",\n\t\tkeyword: \"normal\",\n\t},\n}\n\nexport const sandpackLight: Theme = {\n\tcolors: {\n\t\tsurface1: \"#ffffff\",\n\t\tsurface3: \"#F3F3F3\",\n\t\tdisabled: \"#C5C5C5\",\n\t\taccent: \"#3973E0\",\n\t\terrorSurface: \"#FCF1F0\",\n\t},\n\tsyntax: {\n\t\tplain: \"#151515\",\n\t\tcomment: \"#999\",\n\t\tkeyword: \"#7C5AE3\",\n\t\ttag: \"#0971F1\",\n\t\tpunctuation: \"#3B3B3B\",\n\t\tdefinition: \"#85A600\",\n\t\tproperty: \"#3B3B3B\",\n\t\tstatic: \"#3B3B3B\",\n\t\tstring: \"#2E6BD0\",\n\t},\n\tfont: {\n\t\tmono: '\"Fira Mono\", \"DejaVu Sans Mono\", Menlo, Consolas, \"Liberation Mono\", Monaco, \"Lucida Console\", monospace',\n\t\tlineHeight: \"20px\",\n\t},\n\tfontStyle: {\n\t\tcomment: \"italic\",\n\t\tproperty: \"normal\",\n\t\tkeyword: \"normal\",\n\t},\n}\n", "export const ReactiveFlags = {\n    None: 0,\n    Mutable: 1,\n    Watching: 2,\n    RecursedCheck: 4,\n    Recursed: 8,\n    Dirty: 16,\n    Pending: 32,\n};\nexport function createReactiveSystem({ update, notify, unwatched, }) {\n    return {\n        link,\n        unlink,\n        propagate,\n        checkDirty,\n        shallowPropagate,\n    };\n    function link(dep, sub, version) {\n        const prevDep = sub.depsTail;\n        if (prevDep !== undefined && prevDep.dep === dep) {\n            return;\n        }\n        const nextDep = prevDep !== undefined ? prevDep.nextDep : sub.deps;\n        if (nextDep !== undefined && nextDep.dep === dep) {\n            nextDep.version = version;\n            sub.depsTail = nextDep;\n            return;\n        }\n        const prevSub = dep.subsTail;\n        if (prevSub !== undefined && prevSub.version === version && prevSub.sub === sub) {\n            return;\n        }\n        const newLink = sub.depsTail\n            = dep.subsTail\n                = {\n                    version,\n                    dep,\n                    sub,\n                    prevDep,\n                    nextDep,\n                    prevSub,\n                    nextSub: undefined,\n                };\n        if (nextDep !== undefined) {\n            nextDep.prevDep = newLink;\n        }\n        if (prevDep !== undefined) {\n            prevDep.nextDep = newLink;\n        }\n        else {\n            sub.deps = newLink;\n        }\n        if (prevSub !== undefined) {\n            prevSub.nextSub = newLink;\n        }\n        else {\n            dep.subs = newLink;\n        }\n    }\n    function unlink(link, sub = link.sub) {\n        const dep = link.dep;\n        const prevDep = link.prevDep;\n        const nextDep = link.nextDep;\n        const nextSub = link.nextSub;\n        const prevSub = link.prevSub;\n        if (nextDep !== undefined) {\n            nextDep.prevDep = prevDep;\n        }\n        else {\n            sub.depsTail = prevDep;\n        }\n        if (prevDep !== undefined) {\n            prevDep.nextDep = nextDep;\n        }\n        else {\n            sub.deps = nextDep;\n        }\n        if (nextSub !== undefined) {\n            nextSub.prevSub = prevSub;\n        }\n        else {\n            dep.subsTail = prevSub;\n        }\n        if (prevSub !== undefined) {\n            prevSub.nextSub = nextSub;\n        }\n        else if ((dep.subs = nextSub) === undefined) {\n            unwatched(dep);\n        }\n        return nextDep;\n    }\n    function propagate(link) {\n        let next = link.nextSub;\n        let stack;\n        top: do {\n            const sub = link.sub;\n            let flags = sub.flags;\n            if (!(flags & (4 | 8 | 16 | 32))) {\n                sub.flags = flags | 32;\n            }\n            else if (!(flags & (4 | 8))) {\n                flags = 0;\n            }\n            else if (!(flags & 4)) {\n                sub.flags = (flags & ~8) | 32;\n            }\n            else if (!(flags & (16 | 32)) && isValidLink(link, sub)) {\n                sub.flags = flags | (8 | 32);\n                flags &= 1;\n            }\n            else {\n                flags = 0;\n            }\n            if (flags & 2) {\n                notify(sub);\n            }\n            if (flags & 1) {\n                const subSubs = sub.subs;\n                if (subSubs !== undefined) {\n                    const nextSub = (link = subSubs).nextSub;\n                    if (nextSub !== undefined) {\n                        stack = { value: next, prev: stack };\n                        next = nextSub;\n                    }\n                    continue;\n                }\n            }\n            if ((link = next) !== undefined) {\n                next = link.nextSub;\n                continue;\n            }\n            while (stack !== undefined) {\n                link = stack.value;\n                stack = stack.prev;\n                if (link !== undefined) {\n                    next = link.nextSub;\n                    continue top;\n                }\n            }\n            break;\n        } while (true);\n    }\n    function checkDirty(link, sub) {\n        let stack;\n        let checkDepth = 0;\n        let dirty = false;\n        top: do {\n            const dep = link.dep;\n            const flags = dep.flags;\n            if (sub.flags & 16) {\n                dirty = true;\n            }\n            else if ((flags & (1 | 16)) === (1 | 16)) {\n                if (update(dep)) {\n                    const subs = dep.subs;\n                    if (subs.nextSub !== undefined) {\n                        shallowPropagate(subs);\n                    }\n                    dirty = true;\n                }\n            }\n            else if ((flags & (1 | 32)) === (1 | 32)) {\n                if (link.nextSub !== undefined || link.prevSub !== undefined) {\n                    stack = { value: link, prev: stack };\n                }\n                link = dep.deps;\n                sub = dep;\n                ++checkDepth;\n                continue;\n            }\n            if (!dirty) {\n                const nextDep = link.nextDep;\n                if (nextDep !== undefined) {\n                    link = nextDep;\n                    continue;\n                }\n            }\n            while (checkDepth--) {\n                const firstSub = sub.subs;\n                const hasMultipleSubs = firstSub.nextSub !== undefined;\n                if (hasMultipleSubs) {\n                    link = stack.value;\n                    stack = stack.prev;\n                }\n                else {\n                    link = firstSub;\n                }\n                if (dirty) {\n                    if (update(sub)) {\n                        if (hasMultipleSubs) {\n                            shallowPropagate(firstSub);\n                        }\n                        sub = link.sub;\n                        continue;\n                    }\n                    dirty = false;\n                }\n                else {\n                    sub.flags &= ~32;\n                }\n                sub = link.sub;\n                const nextDep = link.nextDep;\n                if (nextDep !== undefined) {\n                    link = nextDep;\n                    continue top;\n                }\n            }\n            return dirty;\n        } while (true);\n    }\n    function shallowPropagate(link) {\n        do {\n            const sub = link.sub;\n            const flags = sub.flags;\n            if ((flags & (32 | 16)) === 32) {\n                sub.flags = flags | 16;\n                if ((flags & (2 | 4)) === 2) {\n                    notify(sub);\n                }\n            }\n        } while ((link = link.nextSub) !== undefined);\n    }\n    function isValidLink(checkLink, sub) {\n        let link = sub.depsTail;\n        while (link !== undefined) {\n            if (link === checkLink) {\n                return true;\n            }\n            link = link.prevDep;\n        }\n        return false;\n    }\n}\n", "import { createReactiveSystem } from './system.mjs';\nlet cycle = 0;\nlet batchDepth = 0;\nlet notifyIndex = 0;\nlet queuedLength = 0;\nlet activeSub;\nconst queued = [];\nconst { link, unlink, propagate, checkDirty, shallowPropagate, } = createReactiveSystem({\n    update(node) {\n        if (node.depsTail !== undefined) {\n            return updateComputed(node);\n        }\n        else {\n            return updateSignal(node);\n        }\n    },\n    notify(effect) {\n        let insertIndex = queuedLength;\n        let firstInsertedIndex = insertIndex;\n        do {\n            queued[insertIndex++] = effect;\n            effect.flags &= ~2;\n            effect = effect.subs?.sub;\n            if (effect === undefined || !(effect.flags & 2)) {\n                break;\n            }\n        } while (true);\n        queuedLength = insertIndex;\n        while (firstInsertedIndex < --insertIndex) {\n            const left = queued[firstInsertedIndex];\n            queued[firstInsertedIndex++] = queued[insertIndex];\n            queued[insertIndex] = left;\n        }\n    },\n    unwatched(node) {\n        if (!(node.flags & 1)) {\n            effectScopeOper.call(node);\n        }\n        else if (node.depsTail !== undefined) {\n            node.depsTail = undefined;\n            node.flags = 1 | 16;\n            purgeDeps(node);\n        }\n    },\n});\nexport function getActiveSub() {\n    return activeSub;\n}\nexport function setActiveSub(sub) {\n    const prevSub = activeSub;\n    activeSub = sub;\n    return prevSub;\n}\nexport function getBatchDepth() {\n    return batchDepth;\n}\nexport function startBatch() {\n    ++batchDepth;\n}\nexport function endBatch() {\n    if (!--batchDepth) {\n        flush();\n    }\n}\nexport function isSignal(fn) {\n    return fn.name === 'bound ' + signalOper.name;\n}\nexport function isComputed(fn) {\n    return fn.name === 'bound ' + computedOper.name;\n}\nexport function isEffect(fn) {\n    return fn.name === 'bound ' + effectOper.name;\n}\nexport function isEffectScope(fn) {\n    return fn.name === 'bound ' + effectScopeOper.name;\n}\nexport function signal(initialValue) {\n    return signalOper.bind({\n        currentValue: initialValue,\n        pendingValue: initialValue,\n        subs: undefined,\n        subsTail: undefined,\n        flags: 1,\n    });\n}\nexport function computed(getter) {\n    return computedOper.bind({\n        value: undefined,\n        subs: undefined,\n        subsTail: undefined,\n        deps: undefined,\n        depsTail: undefined,\n        flags: 0,\n        getter: getter,\n    });\n}\nexport function effect(fn) {\n    const e = {\n        fn,\n        subs: undefined,\n        subsTail: undefined,\n        deps: undefined,\n        depsTail: undefined,\n        flags: 2 | 4,\n    };\n    const prevSub = setActiveSub(e);\n    if (prevSub !== undefined) {\n        link(e, prevSub, 0);\n    }\n    try {\n        e.fn();\n    }\n    finally {\n        activeSub = prevSub;\n        e.flags &= ~4;\n    }\n    return effectOper.bind(e);\n}\nexport function effectScope(fn) {\n    const e = {\n        deps: undefined,\n        depsTail: undefined,\n        subs: undefined,\n        subsTail: undefined,\n        flags: 0,\n    };\n    const prevSub = setActiveSub(e);\n    if (prevSub !== undefined) {\n        link(e, prevSub, 0);\n    }\n    try {\n        fn();\n    }\n    finally {\n        activeSub = prevSub;\n    }\n    return effectScopeOper.bind(e);\n}\nexport function trigger(fn) {\n    const sub = {\n        deps: undefined,\n        depsTail: undefined,\n        flags: 2,\n    };\n    const prevSub = setActiveSub(sub);\n    try {\n        fn();\n    }\n    finally {\n        activeSub = prevSub;\n        let link = sub.deps;\n        while (link !== undefined) {\n            const dep = link.dep;\n            link = unlink(link, sub);\n            const subs = dep.subs;\n            if (subs !== undefined) {\n                sub.flags = 0;\n                propagate(subs);\n                shallowPropagate(subs);\n            }\n        }\n        if (!batchDepth) {\n            flush();\n        }\n    }\n}\nfunction updateComputed(c) {\n    ++cycle;\n    c.depsTail = undefined;\n    c.flags = 1 | 4;\n    const prevSub = setActiveSub(c);\n    try {\n        const oldValue = c.value;\n        return oldValue !== (c.value = c.getter(oldValue));\n    }\n    finally {\n        activeSub = prevSub;\n        c.flags &= ~4;\n        purgeDeps(c);\n    }\n}\nfunction updateSignal(s) {\n    s.flags = 1;\n    return s.currentValue !== (s.currentValue = s.pendingValue);\n}\nfunction run(e) {\n    const flags = e.flags;\n    if (flags & 16\n        || (flags & 32\n            && checkDirty(e.deps, e))) {\n        ++cycle;\n        e.depsTail = undefined;\n        e.flags = 2 | 4;\n        const prevSub = setActiveSub(e);\n        try {\n            e.fn();\n        }\n        finally {\n            activeSub = prevSub;\n            e.flags &= ~4;\n            purgeDeps(e);\n        }\n    }\n    else {\n        e.flags = 2;\n    }\n}\nfunction flush() {\n    try {\n        while (notifyIndex < queuedLength) {\n            const effect = queued[notifyIndex];\n            queued[notifyIndex++] = undefined;\n            run(effect);\n        }\n    }\n    finally {\n        while (notifyIndex < queuedLength) {\n            const effect = queued[notifyIndex];\n            queued[notifyIndex++] = undefined;\n            effect.flags |= 2 | 8;\n        }\n        notifyIndex = 0;\n        queuedLength = 0;\n    }\n}\nfunction computedOper() {\n    const flags = this.flags;\n    if (flags & 16\n        || (flags & 32\n            && (checkDirty(this.deps, this)\n                || (this.flags = flags & ~32, false)))) {\n        if (updateComputed(this)) {\n            const subs = this.subs;\n            if (subs !== undefined) {\n                shallowPropagate(subs);\n            }\n        }\n    }\n    else if (!flags) {\n        this.flags = 1 | 4;\n        const prevSub = setActiveSub(this);\n        try {\n            this.value = this.getter();\n        }\n        finally {\n            activeSub = prevSub;\n            this.flags &= ~4;\n        }\n    }\n    const sub = activeSub;\n    if (sub !== undefined) {\n        link(this, sub, cycle);\n    }\n    return this.value;\n}\nfunction signalOper(...value) {\n    if (value.length) {\n        if (this.pendingValue !== (this.pendingValue = value[0])) {\n            this.flags = 1 | 16;\n            const subs = this.subs;\n            if (subs !== undefined) {\n                propagate(subs);\n                if (!batchDepth) {\n                    flush();\n                }\n            }\n        }\n    }\n    else {\n        if (this.flags & 16) {\n            if (updateSignal(this)) {\n                const subs = this.subs;\n                if (subs !== undefined) {\n                    shallowPropagate(subs);\n                }\n            }\n        }\n        let sub = activeSub;\n        while (sub !== undefined) {\n            if (sub.flags & (1 | 2)) {\n                link(this, sub, cycle);\n                break;\n            }\n            sub = sub.subs?.sub;\n        }\n        return this.currentValue;\n    }\n}\nfunction effectOper() {\n    effectScopeOper.call(this);\n}\nfunction effectScopeOper() {\n    this.depsTail = undefined;\n    this.flags = 0;\n    purgeDeps(this);\n    const sub = this.subs;\n    if (sub !== undefined) {\n        unlink(sub);\n    }\n}\nfunction purgeDeps(sub) {\n    const depsTail = sub.depsTail;\n    let dep = depsTail !== undefined ? depsTail.nextDep : sub.deps;\n    while (dep !== undefined) {\n        dep = unlink(dep, sub);\n    }\n}\n", "import type { BaseEngine } from \"document/base-engine/BaseEngine.ts\"\nimport type { CanvasNode } from \"document/models/CanvasTree/index.ts\"\nimport { isScopeNode } from \"document/models/CanvasTree/nodes/ScopeNode.ts\"\nimport {\n\tisCollectionItemNode,\n\tisCollectionNode,\n\tisRootNode,\n\tisRouteSegmentNode,\n} from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { hasCollectionDataSource } from \"document/models/CanvasTree/traits/WithCollectionDataSource.ts\"\nimport { isReplicaOrReplicaChild } from \"document/models/CanvasTree/traits/WithTemplate.ts\"\nimport { withVariableProvider } from \"document/models/CanvasTree/traits/WithVariableProvider.ts\"\nimport { getCollectionForIdentifier } from \"utils/getCollectionForIdentifier.ts\"\nimport { getFirstRepeaterItemId } from \"utils/getFirstRepeaterItemId.ts\"\nimport { getRouterLocales } from \"utils/getRouterLocales.ts\"\nimport { forEachVariableReferenceOfNode } from \"utils/updateDynamicValues.ts\"\nimport { type CanvasLocalizationScope, isCanvasLocalizationScope } from \"../QuickActions/utils/LocalizationScope.ts\"\nimport type { LocalizationSource } from \"./getLocalizationSources.ts\"\nimport {\n\tcollectLocalizationSourcesFromCanvasNode,\n\tcollectLocalizationSourcesFromCollectionItemNode,\n\tcollectLocalizationSourcesFromRouteSegmentNode,\n\tcollectTitleAndDescriptionLocalizationSources,\n\tgetCollectionSlugOccurrencesByLocaleId,\n\tgetKeyPathForCollectionItemVariable,\n} from \"./getLocalizationSources.ts\"\n\nexport function getLocalizationSourcesForNode(\n\tnode: CanvasNode,\n\tengine: BaseEngine,\n\tscopeAgnostic: boolean = false,\n): LocalizationSource[] {\n\tconst { scopeStore, treeStore } = engine.stores\n\n\tconst sources: LocalizationSource[] = []\n\n\tif (isScopeNode(node, true) && !node.isLoaded()) return sources\n\n\t// Use the data-only tree when available (CRDT mode); fall back to the real tree otherwise.\n\tconst tree = treeStore.getDataTreeOrPartialTree()\n\n\tconst locales = tree.root.locales\n\tif (!locales || locales.length === 0) return sources\n\n\tconst activeScope = scopeStore.active\n\tconst isCanvasScope = isCanvasLocalizationScope(activeScope)\n\tlet hasCanvasSources = false\n\tlet canvasScopeNode: CanvasLocalizationScope | null = null\n\tif (isCanvasScope) {\n\t\tcanvasScopeNode = activeScope\n\t} else if (scopeAgnostic) {\n\t\tconst maybeCanvasScopeNode = tree.getCanvasScopeNodeFor(node)\n\t\tif (maybeCanvasScopeNode && isCanvasLocalizationScope(maybeCanvasScopeNode)) {\n\t\t\tcanvasScopeNode = maybeCanvasScopeNode\n\t\t}\n\t}\n\n\tif (canvasScopeNode) {\n\t\tconst sourceCount = sources.length\n\t\tcollectLocalizationSourcesFromCanvasNode(\n\t\t\ttree,\n\t\t\tengine.componentLoader,\n\t\t\tcanvasScopeNode,\n\t\t\tnode,\n\t\t\tlocales,\n\t\t\tsources,\n\t\t\t\"canvasHtmlAsTextContentIfPossible\",\n\t\t)\n\t\thasCanvasSources = sources.length > sourceCount\n\t}\n\n\tif (isRootNode(node)) {\n\t\tcollectTitleAndDescriptionLocalizationSources(tree, engine.componentLoader, node, node, locales, sources)\n\t}\n\n\tif (isCollectionItemNode(node)) {\n\t\tconst collectionNode = tree.getNodeWithTrait(node.parentid, isCollectionNode)\n\t\tif (!collectionNode) return sources\n\n\t\tconst slugsByLocaleId = getCollectionSlugOccurrencesByLocaleId(locales, collectionNode)\n\n\t\tcollectLocalizationSourcesFromCollectionItemNode(\n\t\t\ttree,\n\t\t\tengine.componentLoader,\n\t\t\tcollectionNode,\n\t\t\tnode,\n\t\t\tlocales,\n\t\t\tsources,\n\t\t\tslugsByLocaleId,\n\t\t)\n\t}\n\n\tif (isRouteSegmentNode(node) && tree.root.translatePagePaths === \"yes\") {\n\t\tcollectLocalizationSourcesFromRouteSegmentNode(\n\t\t\ttree,\n\t\t\tnode,\n\t\t\tnode,\n\t\t\tlocales,\n\t\t\tgetRouterLocales(tree, \"includeDrafts\"),\n\t\t\tsources,\n\t\t)\n\t}\n\n\tconst variableSourceKeyPaths = new Set<string>()\n\n\tforEachVariableReferenceOfNode(tree, node, \"excludeInherited\", \"readsRawNodeData\", undefined, variableReference => {\n\t\tif (!variableReference.providerId) return\n\n\t\tconst variableProvider = tree.get(variableReference.providerId)\n\t\tif (!hasCollectionDataSource(variableProvider) || !withVariableProvider(variableProvider)) return\n\n\t\tconst collectionNode = getCollectionForIdentifier(tree, variableProvider.dataIdentifier)\n\t\tif (!collectionNode) return\n\n\t\tconst collectionItemId = getFirstRepeaterItemId(variableProvider, treeStore.sandboxRepeaterData)\n\t\tconst collectionItem = tree.get(collectionItemId)\n\t\tif (!isCollectionItemNode(collectionItem)) return\n\n\t\tconst variableSourceKeyPath = getKeyPathForCollectionItemVariable(collectionItem.id, variableReference.id)\n\t\tif (variableSourceKeyPaths.has(variableSourceKeyPath)) return\n\t\tvariableSourceKeyPaths.add(variableSourceKeyPath)\n\n\t\tconst slugsByLocaleId = getCollectionSlugOccurrencesByLocaleId(locales, collectionNode)\n\n\t\tconst collectionItemSources: LocalizationSource[] = []\n\t\tcollectLocalizationSourcesFromCollectionItemNode(\n\t\t\ttree,\n\t\t\tengine.componentLoader,\n\t\t\tcollectionNode,\n\t\t\tcollectionItem,\n\t\t\tlocales,\n\t\t\tcollectionItemSources,\n\t\t\tslugsByLocaleId,\n\t\t)\n\n\t\tconst source = collectionItemSources.find(({ keyPath }) => keyPath === variableSourceKeyPath)\n\t\tif (source) sources.push(source)\n\t})\n\n\t// When clicking text in a non-primary variant that inherits from primary (no localizable overrides),\n\t// fall back to the primary node's localization sources so the sidebar panel appears.\n\tif (!hasCanvasSources && isCanvasScope && isReplicaOrReplicaChild(node)) {\n\t\tconst originalNode = tree.getNode(node.getPrimaryId())\n\t\tif (originalNode) {\n\t\t\tcollectLocalizationSourcesFromCanvasNode(\n\t\t\t\ttree,\n\t\t\t\tengine.componentLoader,\n\t\t\t\tactiveScope,\n\t\t\t\toriginalNode,\n\t\t\t\tlocales,\n\t\t\t\tsources,\n\t\t\t\t\"canvasHtmlAsTextContentIfPossible\",\n\t\t\t)\n\t\t}\n\t}\n\n\treturn sources\n}\n", "import { ColorSampler, localChannel } from \"@framerjs/framer-services\"\nimport type { BaseEngine } from \"document/base-engine/BaseEngine.ts\"\nimport { isVekterEngine } from \"document/useVekterEngine.ts\"\n\nexport async function sampleColor(engine: BaseEngine): Promise<string | undefined> {\n\tconst service = ColorSampler.on(localChannel).expect()\n\n\treturn new Promise<string | undefined>((resolve, reject) => {\n\t\tif (isVekterEngine(engine)) {\n\t\t\tengine.stores.canvasStore.setColorSamplerActive(true)\n\t\t}\n\n\t\tengine.scheduler.runBeforeNextFrame(async () => {\n\t\t\ttry {\n\t\t\t\tconst { color } = await service.sampleColor()\n\n\t\t\t\tengine.scheduler.process(() => {\n\t\t\t\t\tif (isVekterEngine(engine)) {\n\t\t\t\t\t\tengine.stores.canvasStore.setColorSamplerActive(false)\n\t\t\t\t\t}\n\t\t\t\t\tresolve(color)\n\t\t\t\t})\n\t\t\t} catch (error) {\n\t\t\t\tengine.scheduler.process(() => {\n\t\t\t\t\tif (isVekterEngine(engine)) {\n\t\t\t\t\t\tengine.stores.canvasStore.setColorSamplerActive(false)\n\t\t\t\t\t}\n\t\t\t\t\treject(error)\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t})\n}\n", "import { assert } from \"@framerjs/shared\"\nimport type { StyledTextDraft } from \"document/models/StyledText/StyledTextDraft.ts\"\nimport type { RawDraftContentBlock } from \"draft-js\"\nimport { isFramerPageLink } from \"library/modules/framerPageLink.ts\"\nimport { canvasSchemaParams, makeSchema } from \"prosemirror/schema/index.ts\"\nimport type { TextBlockTag } from \"prosemirror/schema/textBlock.ts\"\nimport { parseRichText, serializeRichText } from \"prosemirror/serialization/dom.ts\"\nimport type { StyleTransform } from \"prosemirror/styles.ts\"\nimport { BlockStyles, InlineStyles } from \"prosemirror/styles.ts\"\nimport type { StyleHandler } from \"text\"\nimport { draftStyleDefinitions } from \"text\"\nimport type { CanvasTree } from \"../../CanvasTree.ts\"\nimport { RichTextNode } from \"../RichTextNode.ts\"\nimport { getDefaultPresets } from \"../RichTextNode.utils.ts\"\nimport type { TextNode } from \"../TextNode.ts\"\n\nexport function migrateTextNode(tree: CanvasTree, node: TextNode<any>) {\n\treturn new RichTextNode({\n\t\tname: node.name,\n\t\tlocked: node.locked,\n\n\t\twidth: node.width,\n\t\theight: node.height,\n\t\twidthType: node.widthType,\n\t\theightType: node.heightType,\n\n\t\tconstraintsLocked: node.constraintsLocked,\n\n\t\tleft: node.left,\n\t\tright: node.right,\n\t\ttop: node.top,\n\t\tbottom: node.bottom,\n\n\t\tcenterAnchorX: node.centerAnchorX,\n\t\tcenterAnchorY: node.centerAnchorY,\n\n\t\toverflow: node.overflow,\n\n\t\tvisible: node.visible,\n\t\trotation: node.rotation,\n\t\topacity: node.opacity,\n\t\tshadows: node.shadows,\n\n\t\tposition: node.position,\n\t\tpositionStickyTop: node.positionStickyTop,\n\t\tpositionStickyRight: node.positionStickyRight,\n\t\tpositionStickyBottom: node.positionStickyBottom,\n\t\tpositionStickyLeft: node.positionStickyLeft,\n\n\t\tblur: node.blur,\n\t\tbackgroundBlur: node.backgroundBlur,\n\t\tbrightness: node.brightness,\n\t\tcontrast: node.contrast,\n\t\tgrayscale: node.grayscale,\n\t\thueRotate: node.hueRotate,\n\t\tinvert: node.invert,\n\t\tsaturate: node.saturate,\n\t\tsepia: node.sepia,\n\n\t\ttextVerticalAlignment: node.textVerticalAlignment,\n\n\t\tisTarget: node.isTarget,\n\n\t\tcodeOverrideEnabled: node.codeOverrideEnabled,\n\t\tcodeOverrideIdentifier: node.codeOverrideIdentifier,\n\n\t\texportOptions: node.exportOptions,\n\n\t\tparallaxEnabled: node.parallaxEnabled,\n\t\tparallaxSpeed: node.parallaxSpeed,\n\t\tparallaxAdjustPosition: node.parallaxAdjustPosition,\n\t\tparallaxOffset: node.parallaxOffset,\n\n\t\tstyleAppearEffectEnabled: node.styleAppearEffectEnabled,\n\t\tstyleAppearEffectThreshold: node.styleAppearEffectThreshold,\n\t\tstyleAppearEffectAnimateOnce: node.styleAppearEffectAnimateOnce,\n\t\tstyleAppearEffectOpacity: node.styleAppearEffectOpacity,\n\t\tstyleAppearEffectX: node.styleAppearEffectX,\n\t\tstyleAppearEffectY: node.styleAppearEffectY,\n\t\tstyleAppearEffectScale: node.styleAppearEffectScale,\n\t\tstyleAppearEffectTransition: node.styleAppearEffectTransition,\n\n\t\telementId: node.elementId,\n\t\tscrollMarginTop: node.scrollMarginTop,\n\t\tscrollTargetEnabled: node.scrollTargetEnabled,\n\n\t\tlinkFont: node.linkFont,\n\t\tlinkTextColor: node.linkTextColor,\n\t\tlinkFontSize: node.linkFontSize,\n\t\tlinkTextTransform: node.linkTextTransform,\n\t\tlinkTextDecoration: node.linkTextDecoration,\n\n\t\tlinkHoverFont: node.linkHoverFont,\n\t\tlinkHoverTextColor: node.linkHoverTextColor,\n\t\tlinkHoverFontSize: node.linkHoverFontSize,\n\t\tlinkHoverTextTransform: node.linkHoverTextTransform,\n\t\tlinkHoverTextDecoration: node.linkHoverTextDecoration,\n\n\t\tlinkCurrentFont: node.linkCurrentFont,\n\t\tlinkCurrentTextColor: node.linkCurrentTextColor,\n\t\tlinkCurrentFontSize: node.linkCurrentFontSize,\n\t\tlinkCurrentTextTransform: node.linkCurrentTextTransform,\n\t\tlinkCurrentTextDecoration: node.linkCurrentTextDecoration,\n\n\t\thtml: renderTextNodeToRichText(node),\n\t\ttextContent: node.textContent,\n\n\t\t...getDefaultPresets(tree),\n\t})\n}\n\n// This will render a TextNode to an HTML string that is compatible with ProseMirror.\n// We can't use draftContentStateToHTML as it uses CSS variables that are not supported by our ProseMirror schema.\nexport function renderTextNodeToRichText(node: TextNode<any>) {\n\tconst styledText = node.styledText as StyledTextDraft\n\tconst contentState = styledText.rawContentState\n\n\tconst div = document.createElement(\"div\")\n\n\tfor (const block of contentState.blocks) {\n\t\tconst p = renderContentBlock(node, block)\n\n\t\tfor (const key in BlockStyles.transforms) {\n\t\t\tconst transform: StyleTransform<any, any> = BlockStyles.transforms[key]\n\t\t\tconst nodeValue = node[key]\n\n\t\t\ttransform.toCSS(p.style, nodeValue)\n\t\t}\n\n\t\tdiv.appendChild(p)\n\t}\n\n\tconst schema = makeSchema(canvasSchemaParams)\n\tconst editorState = parseRichText(div.innerHTML, schema)\n\treturn serializeRichText(editorState, schema)\n}\n\nfunction renderContentBlock(node: TextNode<any>, block: RawDraftContentBlock) {\n\tlet tag = node.htmlTextTag ?? (\"p\" as TextBlockTag)\n\tif (tag === \"span\") tag = \"div\"\n\n\tconst tagElement = document.createElement(tag)\n\n\tconst chunks = createContentBlockChunks(block)\n\tfor (const [text, styles] of chunks) {\n\t\tconst spanElement = document.createElement(\"span\")\n\n\t\tspanElement.textContent = text\n\n\t\tfor (const key in InlineStyles.transforms) {\n\t\t\tconst transform: StyleTransform<any, any> = InlineStyles.transforms[key]\n\t\t\tconst draftDefinition: StyleHandler<any> = draftStyleDefinitions[key]\n\n\t\t\tconst draftValue = styles.get(draftDefinition.prefix)\n\n\t\t\tif (typeof draftValue === \"string\") {\n\t\t\t\tconst parsedValue = draftDefinition.parseValue(draftValue)\n\t\t\t\ttransform.toCSS(spanElement.style, parsedValue)\n\t\t\t} else {\n\t\t\t\tconst nodeValue = node[key]\n\t\t\t\ttransform.toCSS(spanElement.style, nodeValue)\n\t\t\t}\n\t\t}\n\n\t\tif (styles.get(\"BOLD\") === \"\") {\n\t\t\tconst strong = document.createElement(\"strong\")\n\t\t\tstrong.append(...spanElement.childNodes)\n\t\t\tspanElement.appendChild(strong)\n\t\t}\n\n\t\tif (styles.get(\"ITALIC\") === \"\") {\n\t\t\tconst em = document.createElement(\"em\")\n\t\t\tem.append(...spanElement.childNodes)\n\t\t\tspanElement.appendChild(em)\n\t\t}\n\n\t\tconst href = node.link ?? styles.get(\"LINK:\")\n\n\t\tif (typeof href === \"string\") {\n\t\t\tconst a = document.createElement(\"a\")\n\n\t\t\tconst isValidLink = href.includes(\":\")\n\t\t\tconst isLinkToElement = href.startsWith(\"#\")\n\t\t\tconst isPageLink = isFramerPageLink(href)\n\n\t\t\tif (isPageLink || isLinkToElement) {\n\t\t\t\ta.href = href\n\t\t\t} else {\n\t\t\t\ta.href = isValidLink ? href : \"https://\" + href\n\t\t\t\ta.target = \"_blank\"\n\t\t\t\ta.rel = \"noopener\"\n\t\t\t}\n\n\t\t\ta.appendChild(spanElement)\n\t\t\ttagElement.appendChild(a)\n\t\t} else {\n\t\t\ttagElement.appendChild(spanElement)\n\t\t}\n\t}\n\n\treturn tagElement\n}\n\nfunction createContentBlockChunks(block: RawDraftContentBlock) {\n\tconst chunks: [string, Map<string, string>][] = []\n\tconst unsortedBoundaries = new Set<number>([0, block.text.length])\n\n\tfor (const style of block.inlineStyleRanges) {\n\t\tunsortedBoundaries.add(style.offset)\n\t\tunsortedBoundaries.add(style.offset + style.length)\n\t}\n\n\tconst sortedBoundaries = Array.from(unsortedBoundaries).sort((a, b) => a - b)\n\n\tfor (let index = 0; index < sortedBoundaries.length - 1; index++) {\n\t\tconst start = sortedBoundaries[index]\n\t\tconst end = sortedBoundaries[index + 1]\n\t\tassert(start !== undefined, \"Start is undefined\")\n\t\tassert(end !== undefined, \"End is undefined\")\n\n\t\tconst text = block.text.slice(start, end)\n\t\tconst styles = new Map<string, string>()\n\n\t\tfor (const style of block.inlineStyleRanges) {\n\t\t\tif (style.offset <= start && style.offset + style.length >= end) {\n\t\t\t\tlet colonIndex = style.style.indexOf(\":\") + 1\n\n\t\t\t\tif (colonIndex === 0) {\n\t\t\t\t\tcolonIndex = style.style.length\n\t\t\t\t}\n\n\t\t\t\tconst prefix = style.style.slice(0, colonIndex)\n\t\t\t\tconst value = style.style.slice(colonIndex)\n\n\t\t\t\tstyles.set(prefix, value)\n\t\t\t}\n\t\t}\n\n\t\tchunks.push([text, styles])\n\t}\n\n\treturn chunks\n}\n", "import { assert } from \"@framerjs/shared\"\nimport type { VekterEngine } from \"document/VekterEngine.ts\"\nimport type { CanvasNode, CanvasTree, NodeID, RichTextNode, TextNode } from \"document/models/CanvasTree/index.ts\"\nimport { TemplateHelper } from \"document/models/CanvasTree/nodes/TemplateHelper.ts\"\nimport type { AnyTextNode } from \"document/models/CanvasTree/nodes/utils/isAnyTextNode.ts\"\nimport { migrateTextNode, renderTextNodeToRichText } from \"document/models/CanvasTree/nodes/utils/migrateTextNode.ts\"\nimport { isRichTextNode, isTextNode } from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { hasLink, withLink } from \"document/models/CanvasTree/traits/WithLink.ts\"\nimport type { IsMaster } from \"document/models/CanvasTree/traits/WithTemplate.ts\"\nimport { getMasterAncestor, isReplica } from \"document/models/CanvasTree/traits/WithTemplate.ts\"\nimport { createLink, isLinkToWebPage } from \"document/models/CanvasTree/traits/utils/Link.ts\"\nimport { isString, isUndefined } from \"utils/typeChecks.ts\"\n\nfunction getOriginalNode(tree: CanvasTree, node: CanvasNode) {\n\tlet originalNode: CanvasNode | null = node\n\n\twhile (originalNode?.originalid) {\n\t\toriginalNode = tree.getNode(originalNode.originalid)\n\t}\n\n\treturn originalNode ?? node\n}\n\nexport function migrateTextToRichTextNode(\n\tengine: VekterEngine,\n\t_textNode: TextNode<any>,\n): { richTextNode: RichTextNode; idToSelect: NodeID } | null {\n\tconst tree = engine.stores.treeStore.getDataTreeOrLoadedTree()\n\tconst textNode = tree.current(_textNode)\n\tassert(textNode, \"Expected text node to be loaded or be a data tree node\")\n\n\t// Make sure replicaInstance are up to date\n\ttree.didNonLinearMove(engine.componentLoader)\n\n\tconst originalNode = getOriginalNode(tree, textNode)\n\tif (!isTextNode(originalNode) || !originalNode.parentid) return null\n\n\tconst parentNode = tree.getNode(originalNode.parentid)\n\tif (!parentNode || !parentNode.children) return null\n\n\tconst nodePosition = parentNode.children.findIndex(child => child.id === originalNode.id)\n\tif (nodePosition < 0) return null\n\n\t// Migrate the TextNode to a RichTextNode and insert it at the same position\n\tconst migratedNode = migrateTextNode(tree, originalNode)\n\ttree.insertNode(migratedNode, parentNode.id, nodePosition)\n\n\tconst textNodeIdToRichTextNodeId = new Map<NodeID, NodeID>()\n\ttextNodeIdToRichTextNodeId.set(originalNode.id, migratedNode.id)\n\n\tfunction migrateReplicas(master: CanvasNode & IsMaster, masterChildNode: CanvasNode) {\n\t\tfor (const id of master.cache.replicaInstances ?? []) {\n\t\t\tconst replicaNode = tree.get(id)\n\t\t\tif (!replicaNode || !isReplica(replicaNode)) continue\n\n\t\t\tTemplateHelper.replicaWithChanges(tree, replicaNode)\n\n\t\t\t// Find the text node in the current replica\n\t\t\tconst textNodeId = replicaNode.id + masterChildNode.id\n\t\t\tconst textNode = tree.getNode(textNodeId)\n\t\t\tif (!textNode || !isTextNode(textNode)) continue\n\n\t\t\t// Find the rich text node in the current replica\n\t\t\tconst richTextNodeId = textNodeId.replace(originalNode.id, migratedNode.id)\n\t\t\tconst richTextNode = tree.get(richTextNodeId)\n\t\t\tif (!richTextNode || !isRichTextNode(richTextNode)) continue\n\n\t\t\ttextNodeIdToRichTextNodeId.set(textNodeId, richTextNodeId)\n\n\t\t\t// Migrate replicas of replicas as well\n\t\t\tconst masterNode = getMasterAncestor(textNode)\n\t\t\tif (masterNode) migrateReplicas(masterNode, textNode)\n\n\t\t\tconst overrides = replicaNode.replicaInfo.overrides\n\n\t\t\t// Migrate the overrides of the TextNode to the RichTextNode\n\t\t\tconst { _deleted = [], ...override } = overrides[masterChildNode.id] ?? {}\n\n\t\t\tconst update: Partial<RichTextNode> = {\n\t\t\t\thtml: renderTextNodeToRichText(textNode),\n\t\t\t}\n\n\t\t\tfor (const key in override) {\n\t\t\t\t// Only migrate properties that are supported by the RichTextNode\n\t\t\t\tif (key in migratedNode && !_deleted.includes(key)) {\n\t\t\t\t\tObject.assign(update, { [key]: override[key] })\n\t\t\t\t}\n\t\t\t}\n\n\t\t\trichTextNode.set(update, tree, false, false)\n\t\t}\n\t}\n\n\t// Migrate all replicas\n\tconst masterNode = getMasterAncestor(originalNode)\n\tif (masterNode) migrateReplicas(masterNode, originalNode)\n\n\t// Remove the old TextNode\n\tengine.deleteNode(originalNode.id)\n\n\t// Migrate scroll targets\n\tif (!engine.stores.treeStore.getDataTree()) {\n\t\tassert(!tree.getService(\"loader\"), \"Tree should be fully loaded\")\n\t}\n\tfor (const node of tree.root.walk()) {\n\t\tif (withLink(node) && hasLink(node)) {\n\t\t\tconst link = node.getLink()\n\t\t\tif (!isLinkToWebPage(link) || !isString(link.hash)) continue\n\n\t\t\tconst richTextNodeId = textNodeIdToRichTextNodeId.get(link.hash)\n\t\t\tif (isUndefined(richTextNodeId)) continue\n\n\t\t\tnode.set({\n\t\t\t\tlink: createLink({\n\t\t\t\t\twebPageId: link.webPageId,\n\t\t\t\t\thash: richTextNodeId,\n\t\t\t\t}),\n\t\t\t})\n\t\t}\n\t}\n\n\t// Select the new RichTextNode\n\tconst selectedId = textNode.id.replace(originalNode.id, migratedNode.id)\n\n\treturn { richTextNode: migratedNode, idToSelect: selectedId }\n}\n\nexport function migrateTextNodes(engine: VekterEngine, nodes: AnyTextNode[]) {\n\tconst result: RichTextNode[] = []\n\n\tfor (const node of nodes) {\n\t\tif (isTextNode(node)) {\n\t\t\tconst migrationInfo = migrateTextToRichTextNode(engine, node)\n\t\t\tconst lookupTree = engine.stores.treeStore.getDataTreeOrPartialTree()\n\t\t\tconst migratedNode = lookupTree.get(migrationInfo?.idToSelect)\n\n\t\t\tif (migratedNode && isRichTextNode(migratedNode)) {\n\t\t\t\tresult.push(migratedNode)\n\t\t\t}\n\t\t} else {\n\t\t\tresult.push(node)\n\t\t}\n\t}\n\n\treturn result\n}\n", "import type { CanvasNode, CanvasTree } from \"document/models/CanvasTree/index.ts\"\nimport { isColorStyleTokenNode } from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { findTokenNode } from \"document/models/CanvasTree/utils/findTokenNode.ts\"\nimport { convertRectToCanvasWithRotation } from \"document/models/CanvasTree/utils/geometry.ts\"\nimport {\n\tfallbackValueFromCSSVariable,\n\tisTokenCSSVariable,\n\ttokenIdFromCSSVariable,\n} from \"document/models/CanvasTree/utils/tokens.ts\"\nimport { isConicGradient } from \"document/models/ConicGradientClass.ts\"\nimport type { ConicGradient, Gradient } from \"document/models/Gradient.ts\"\nimport type { GradientColorStop } from \"document/models/GradientColorStop.ts\"\nimport type { LinearGradient } from \"document/models/LinearGradientClass.ts\"\nimport { isLinearGradient } from \"document/models/LinearGradientClass.ts\"\nimport type { RadialGradient } from \"document/models/RadialGradientClass.ts\"\nimport { isRadialGradient } from \"document/models/RadialGradientClass.ts\"\nimport { interpolate } from \"framer-motion\"\nimport { degreesToRadians } from \"library/index.ts\"\nimport { Line } from \"library/render/types/Line.ts\"\nimport { Point } from \"library/render/types/Point.ts\"\nimport { Rect } from \"library/render/types/Rect.ts\"\nimport type { Size } from \"library/render/types/Size.ts\"\n\ninterface LinearGradientCoordinates {\n\ttype: \"linear\"\n\tstart: Point\n\tend: Point\n\t// Center of the axis, will never change for a linear gradient.\n\tcenter: Point\n\taxis: Line\n\tstartCorner: Point\n\tendCorner: Point\n\tsize: Size\n}\n\ninterface RadialGradientCoordinates {\n\ttype: \"radial\"\n\tstart: Point\n\tend: Point\n\t// Center of the circle.\n\tcenter: Point\n\taxis: Line\n\trotation: number\n\ttopCenter: Point\n\tsize: Size\n}\n\nexport interface ConicGradientCoordinates {\n\ttype: \"conic\"\n\tstart: Point\n\trotation: number\n\tradius: number\n\tcenter: Point\n\tangle: number\n}\n\nexport type GradientCoordinates = LinearGradientCoordinates | RadialGradientCoordinates | ConicGradientCoordinates\n\nexport function gradientCoordinates(\n\ttree: CanvasTree,\n\tnode: CanvasNode,\n\tgradient: Gradient,\n): GradientCoordinates | null {\n\tif (isLinearGradient(gradient)) {\n\t\treturn linearGradientCoordinates(tree, node, gradient)\n\t}\n\tif (isRadialGradient(gradient)) {\n\t\treturn radialGradientCoordinates(tree, node, gradient)\n\t}\n\tif (isConicGradient(gradient)) {\n\t\treturn conicGradientCoordinates(tree, node, gradient)\n\t}\n\treturn null\n}\n\nexport function getPointOnCircleByAngle(angleInDegrees: number, radius: number) {\n\treturn Point(\n\t\tradius * Math.sin(degreesToRadians(angleInDegrees)),\n\t\t// Note that our canvas coordinate system is mirrored from a mathematical coordinate system on the y-axis\n\t\tradius * Math.cos(degreesToRadians(angleInDegrees)) * -1,\n\t)\n}\n\nexport function getGradientStopPoints(coordinates: GradientCoordinates, stops: readonly GradientColorStop[]) {\n\tif (coordinates.type === \"conic\") {\n\t\tconst { angle, radius } = coordinates\n\t\treturn stops.map(stop => {\n\t\t\t// Offset the points by the angle of the gradient.\n\t\t\tconst degrees = angle + stop.position * 360\n\t\t\treturn getPointOnCircleByAngle(degrees, radius)\n\t\t})\n\t}\n\n\treturn stops.map(stop => Line.pointAtPercentDistance(coordinates.axis, stop.position))\n}\n\nfunction radialGradientCoordinates(\n\ttree: CanvasTree,\n\tnode: CanvasNode,\n\tgradient: RadialGradient,\n): RadialGradientCoordinates | null {\n\tconst rect = tree.getRect(node)\n\tconst startX = gradient.centerAnchorX * rect.width\n\tconst startY = gradient.centerAnchorY * rect.height\n\tconst horizontalRadius = gradient.widthFactor * rect.width\n\tconst verticalRadius = gradient.heightFactor * rect.height\n\tconst width = horizontalRadius * 2\n\tconst height = verticalRadius * 2\n\tconst endX = horizontalRadius + startX\n\tconst topCenterY = startY - verticalRadius\n\tconst size = { width, height }\n\n\tconst canvasStart = tree.convertPointToCanvas(node, { x: startX, y: startY })\n\tconst canvasEnd = tree.convertPointToCanvas(node, { x: endX, y: startY })\n\tconst canvasTopCenter = tree.convertPointToCanvas(node, { x: startX, y: topCenterY })\n\tconst { rotation } = convertRectToCanvasWithRotation(tree, node)\n\n\tconst axis = Line(canvasStart, canvasEnd)\n\treturn {\n\t\ttype: \"radial\",\n\t\tstart: canvasStart,\n\t\tend: canvasEnd,\n\t\tcenter: Line.pointAtPercentDistance(axis, 0),\n\t\taxis,\n\t\trotation,\n\t\tsize,\n\t\ttopCenter: canvasTopCenter,\n\t}\n}\n\n/**\n * In our data model, a gradient stores only the relative positions of each stop within 0 to 1 and the gradient's angle.\n * This information alone doesn't provide the exact canvas location for each gradient stop (e.g. for rendering, or for\n * finding interactable gradient stops around the mouse). This function calculates a canvas-relative coordinate for the\n * gradient\uFF0Cusing the provided information alongside the frame's position.\n *\n * How does it accomplish this? Imagine drawing a larger rectangle around the frame, with two sides (orthogonalLine)\n * perpendicular to a line aligned with the gradient angle and travelling through the frame center (angleLine). The\n * points where these two sides intersect angleLine represent the start and end of the gradient axis. So a gradient stop\n * on position 0.5 would be at the center of the axis, and a gradient stop at position 0 would be on the start point,\n * for example.\n *\n *                               (extended angleLine)\n *\n *                               End  \u253C\n *                                   x  x\n *                                  x     x\n *              \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500x\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500x endCorner\n *              \u2502                 x         \u2502\n *              \u2502      angleEnd  \u253C          \u2502\n *              \u2502               x           \u2502\n *              \u2502              x            \u2502\n *              \u2502             \u253C center      \u2502\n *              \u2502            x              \u2502\n *              \u2502           x               \u2502\n *              \u2502          \u253C angleStart     \u2502\n *              \u2502         x                 \u2502\n *  startCorner x\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500x\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n *                x     x\n * (orthogonalLine) x  x\n *                    \u253C\n *                     start\n */\nfunction linearGradientCoordinates(\n\ttree: CanvasTree,\n\tnode: CanvasNode,\n\tgradient: LinearGradient,\n): LinearGradientCoordinates | null {\n\tconst frame = tree.getRect(node)\n\tconst frameCenter = { x: frame.width / 2, y: frame.height / 2 }\n\tconst center = tree.convertPointToCanvas(node, frameCenter)\n\n\t// Think of a circle on the center with an arbitrary radius of 100, get the point on the circle at the angle of the\n\t// gradient. We can draw a line from the center to that point, that would be our angleLine.\n\tconst rad = (gradient.angle * Math.PI) / 180\n\tconst offset = {\n\t\tx: -Math.sin(rad) * 100,\n\t\ty: Math.cos(rad) * 100,\n\t}\n\tconst angleStart = tree.convertPointToCanvas(node, Point.add(frameCenter, offset))\n\tconst angleLine = Line(center, angleStart)\n\n\t// Find the two closest corners to the intersection points that the angleLine would travel through.\n\tconst normalizedAngle = normalizeAngle(gradient.angle)\n\tconst corners = Rect.pointsAtOrigin(frame)\n\tconst cornerIndex = Math.floor(normalizedAngle / 90) + 3\n\tconst corner = corners[cornerIndex % 4]\n\tconst startCorner = tree.convertPointToCanvas(node, corner)\n\tconst corner2 = corners[(cornerIndex + 2) % 4]\n\tconst endCorner = tree.convertPointToCanvas(node, corner2)\n\n\t// Draw a line perpendicular to the angleLine that goes through the startCorner. The intersection of this line and\n\t// the angleLine would be the start of the axis.\n\tconst orthogonalLine = Line.perpendicular(angleLine, startCorner)\n\tconst start = Line.intersection(orthogonalLine, angleLine)\n\tif (!start) {\n\t\treturn null\n\t}\n\n\tconst diff = Point.subtract(center, start)\n\tconst end = Point.add(start, diff, diff)\n\n\t// The size we're calculating is the size of the imaginary rectangle that would contain our frame.\n\tconst widthCorner = corners[(cornerIndex + 1) % 4]\n\tconst widthCornerInCanvas = tree.convertPointToCanvas(node, widthCorner)\n\tconst perpendicularOrthogonal = Line.perpendicular(orthogonalLine, widthCornerInCanvas)\n\tconst perpendicularAngle = Line.perpendicular(angleLine, center)\n\tconst perpendicularStart = Line.intersection(perpendicularOrthogonal, perpendicularAngle)\n\tif (!perpendicularStart) {\n\t\treturn null\n\t}\n\n\tconst size = {\n\t\twidth: Point.distance(perpendicularStart, center) * 2,\n\t\theight: Point.distance(start, end),\n\t}\n\n\treturn {\n\t\ttype: \"linear\",\n\t\tstart,\n\t\tend,\n\t\tcenter,\n\t\taxis: Line(start, end),\n\t\tstartCorner,\n\t\tendCorner,\n\t\tsize,\n\t}\n}\n\nfunction conicGradientCoordinates(\n\ttree: CanvasTree,\n\tnode: CanvasNode,\n\tgradient: ConicGradient,\n): ConicGradientCoordinates | null {\n\tconst frame = tree.getRect(node)\n\n\tconst center = tree.convertPointToCanvas(node, {\n\t\tx: ((frame.width / 2) * gradient.centerAnchorX) / 0.5,\n\t\ty: ((frame.height / 2) * gradient.centerAnchorY) / 0.5,\n\t})\n\n\tconst [top, right] = Rect.midPoints(frame)\n\tconst frameCenter = Rect.center(frame)\n\tconst radiusTop = Point.distance(frameCenter, top)\n\tconst radiusRight = Point.distance(frameCenter, right)\n\tconst radius = Math.min(radiusTop, radiusRight)\n\n\tconst ancestorAngle = tree.totalAncestorRotation(node)\n\tconst angle = normalizeAngle(ancestorAngle + gradient.angle)\n\treturn {\n\t\ttype: \"conic\",\n\t\tstart: Point(frameCenter.x, frameCenter.y - radius),\n\t\tcenter,\n\t\trotation: 0,\n\t\tradius,\n\t\tangle,\n\t}\n}\n\nexport const gradientInRange = (\n\tcoordinates: GradientCoordinates,\n\tgradientStops: readonly GradientColorStop[],\n\tmouse: Point,\n\tmaxDistance: number,\n): boolean => {\n\tconst stopPoints = getGradientStopPoints(coordinates, gradientStops)\n\tconst start = stopPoints[0]!\n\tconst end = stopPoints[stopPoints.length - 1]!\n\n\tif (start.x === end.x && start.y === end.y) {\n\t\tconst distance = Point.distance(mouse, start)\n\t\tif (distance < maxDistance) return true\n\t}\n\n\tconst line = Line(start, end)\n\tconst tangent = Line.perpendicular(line, mouse)\n\tconst intersection = Line.intersection(line, tangent)\n\n\tif (coordinates.type === \"radial\") {\n\t\tconst topCenterDist = Point.distance(mouse, coordinates.topCenter)\n\t\tif (topCenterDist < maxDistance) return true\n\t}\n\n\tif (coordinates.type === \"conic\") {\n\t\treturn Point.distance(mouse, coordinates.center) <= coordinates.radius + 40\n\t}\n\n\tif (!intersection) {\n\t\treturn false\n\t}\n\tconst lineDist = Point.distance(mouse, intersection)\n\tconst startDist = Point.distance(mouse, start)\n\tconst endDist = Point.distance(mouse, end)\n\tconst lineLength = Point.distance(start, end)\n\tif (startDist > lineLength && endDist < startDist) {\n\t\tconst distance = Math.max(endDist, lineDist)\n\t\treturn distance < maxDistance\n\t}\n\tif (endDist > lineLength && startDist < endDist) {\n\t\tconst distance = Math.max(startDist, lineDist)\n\t\treturn distance < maxDistance\n\t}\n\treturn lineDist < maxDistance\n}\n\nfunction findClosestGradientStops(\n\tstops: readonly GradientColorStop[],\n\tposition: number,\n): [GradientColorStop, GradientColorStop] {\n\tconst closestStop = stops.reduce((acc, curr) => {\n\t\tif (Math.abs(acc.position - position) < Math.abs(curr.position - position)) return acc\n\t\treturn curr\n\t})\n\n\tconst closestIndex = stops.findIndex(stop => stop === closestStop)\n\n\tconst nextIndex = closestStop.position - position > 0 ? closestIndex - 1 : closestIndex + 1\n\n\tconst nextStop = stops[nextIndex] ?? closestStop\n\n\treturn [closestStop, nextStop]\n}\n\nexport function interpolateColorAtPosition(\n\ttree: CanvasTree,\n\tstops: readonly GradientColorStop[],\n\tposition: number,\n\tisDarkMode: boolean,\n) {\n\tconst [closestStop, nextStop] = findClosestGradientStops(stops, position)\n\tconst relativePosition = interpolate([closestStop.position, nextStop.position], [0, 1])(position)\n\tconst closestStopColor = resolveStopColor(tree, closestStop, isDarkMode)\n\tconst nextStopColor = resolveStopColor(tree, nextStop, isDarkMode)\n\tconst color = interpolate([0, 1], [closestStopColor, nextStopColor])(relativePosition)\n\n\treturn color\n}\n\nexport function resolveStopColor(tree: CanvasTree, stop: GradientColorStop, isDarkMode: boolean) {\n\tconst color = stop.value\n\tif (!isTokenCSSVariable(color)) {\n\t\treturn color\n\t}\n\tconst tokenId = tokenIdFromCSSVariable(color)\n\tconst token = tokenId ? findTokenNode(tokenId, tree) : null\n\tif (token && isColorStyleTokenNode(token)) {\n\t\treturn token.colorForMode(isDarkMode)\n\t}\n\n\treturn fallbackValueFromCSSVariable(color) || \"transparent\"\n}\n\nexport function resolveGradientStopColors(tree: CanvasTree, stops: readonly GradientColorStop[], isDarkMode: boolean) {\n\treturn stops.map(stop => {\n\t\treturn stop.merge({ value: resolveStopColor(tree, stop, isDarkMode) })\n\t})\n}\n\nexport function getConicGradientStopPositionAtMouse(coordinates: ConicGradientCoordinates, mouse: Point) {\n\tconst line = Line(mouse, coordinates.center)\n\tconst x = coordinates.center.x\n\tconst y = coordinates.center.y - coordinates.radius\n\tconst zero = Line(Point(x, y), coordinates.center)\n\t// Mouse angle relative to the starting point when the gradient angle is 0\n\tconst mouseAngle = Line.intersectionAngle(zero, line)\n\tconst absMouseAngle = normalizeAngle(mouseAngle)\n\n\t// Take the gradient angle into account\n\tconst angle = absMouseAngle - coordinates.angle\n\tconst absAngle = normalizeAngle(angle)\n\n\treturn Math.abs(absAngle / 360)\n}\n\n// export for tests\nexport function normalizeAngle(angleInDegrees: number) {\n\tif (angleInDegrees === 360) return angleInDegrees\n\tconst normalized = angleInDegrees % 360\n\treturn normalized < 0 ? 360 + normalized : normalized\n}\n\nexport function sortGradientStopsInPlace(stops: GradientColorStop[]) {\n\treturn stops.sort((a, b) => a.position - b.position)\n}\n\n// Normalize the positions of the stops to a 0~1 range proportionally.\nexport function normalizeGradientStopPositions(gradientToRemap: Gradient) {\n\tlet normalized = false\n\tconst interpolator = interpolate(\n\t\t[gradientToRemap.stops[0]?.position ?? 0, gradientToRemap.stops[gradientToRemap.stops.length - 1]?.position ?? 1],\n\t\t[0, 1],\n\t)\n\n\tconst nextStops = gradientToRemap.stops.map(stop => {\n\t\tif (stop.position < 0 || stop.position > 1) normalized = true\n\t\treturn stop.merge({ position: interpolator(stop.position) })\n\t})\n\n\treturn normalized ? nextStops : undefined\n}\n", "import \"flashElement.styles_cjtyuv.wyw.css\"; export const topCSSVariable = `--top-flash-inset`;\nexport const rightCSSVariable = `--right-flash-inset`;\nexport const bottomCSSVariable = `--bottom-flash-inset`;\nexport const leftCSSVariable = `--left-flash-inset`;\nexport const borderRadiusVariable = `--flash-radius`;\nexport const flash = \"flash_fh6lfgu\";\nexport const defaultStyle = \"defaultStyle_d8eehx6\";\nexport const warningStyle = \"warningStyle_wdvaq7i\";\nexport const glowStyle = \"glowStyle_ghqxg7a\";", "import * as styles from \"./flashElement.styles.ts\"\n\nexport const defaultStyleBorderWidth = 2\n\nexport enum FlashElementStyle {\n\tDefault = \"default\",\n\tGlow = \"glow\",\n\tWarning = \"warning\",\n}\n\nexport interface FlashElementInset {\n\ttop: number\n\tright: number\n\tbottom: number\n\tleft: number\n}\n\ninterface FlashElementOptions {\n\tstyle?: FlashElementStyle\n\tinset?: FlashElementInset\n\tradius?: number\n}\n\nfunction getFlashStyleClassNames(style: FlashElementStyle = FlashElementStyle.Default): string[] {\n\tswitch (style) {\n\t\tcase FlashElementStyle.Glow:\n\t\t\treturn [styles.glowStyle]\n\t\tcase FlashElementStyle.Default:\n\t\t\treturn [styles.defaultStyle]\n\t\tcase FlashElementStyle.Warning:\n\t\t\treturn [styles.defaultStyle, styles.warningStyle]\n\t}\n}\n\nfunction setCSSVariableNumber(element: HTMLElement, name: string, value?: number): void {\n\telement.style.setProperty(name, `${value ?? 0}px`)\n}\n\n/**\n * Show a flash on top of an element to highlight it to the user.\n */\nexport function flashElement(element: HTMLDivElement, options?: FlashElementOptions) {\n\tsetCSSVariableNumber(element, styles.topCSSVariable, options?.inset?.top)\n\tsetCSSVariableNumber(element, styles.rightCSSVariable, options?.inset?.right)\n\tsetCSSVariableNumber(element, styles.bottomCSSVariable, options?.inset?.bottom)\n\tsetCSSVariableNumber(element, styles.leftCSSVariable, options?.inset?.left)\n\n\tif (options?.radius) setCSSVariableNumber(element, styles.borderRadiusVariable, options.radius)\n\n\telement.addEventListener(\"animationend\", function onAnimationEnd() {\n\t\telement.classList.remove(styles.flash)\n\n\t\telement.classList.remove(...getFlashStyleClassNames(options?.style))\n\t\telement.removeEventListener(\"animationend\", onAnimationEnd)\n\t})\n\telement.classList.add(styles.flash)\n\telement.classList.add(...getFlashStyleClassNames(options?.style))\n}\n", "import { dimensions } from \"@framerjs/fresco/tokens\"\nimport { agentDimensionTokenOverrides } from \"app/agent/utils/dimensions.ts\"\nimport { experiments } from \"app/experiments.ts\"\nimport { FlashElementStyle, defaultStyleBorderWidth, flashElement } from \"./flashElement.ts\"\n\nexport function flashPanel(element: HTMLDivElement) {\n\tconst panelPadding = experiments.isOn(\"agent\")\n\t\t? agentDimensionTokenOverrides.panelPadding\n\t\t: dimensions.values.panelPadding\n\n\tflashElement(element, {\n\t\tstyle: FlashElementStyle.Default,\n\t\tinset: {\n\t\t\ttop: defaultStyleBorderWidth,\n\t\t\tright: -(panelPadding - defaultStyleBorderWidth),\n\t\t\tleft: -(panelPadding - defaultStyleBorderWidth),\n\t\t\tbottom: defaultStyleBorderWidth,\n\t\t},\n\t})\n}\n", "import { flashPanel } from \"document/components/chrome/shared/utils/flashPanel.ts\"\nimport { scrollIntoView } from \"utils/scroll-into-view-if-needed/index.ts\"\n\nexport const enum PanelElementId {\n\tCodeComponentPanel = \"code-component-panel\",\n\tDataRepeaterPanel = \"data-repeater-panel\",\n\tFillPanel = \"fill-panel\",\n\tFormPanel = \"form-panel\",\n\tCodeOverridePanel = \"code-override-panel\",\n\tShaderPanel = \"shader-panel\",\n}\n\ninterface HighlightPanelOptions {\n\tid: PanelElementId\n\tflash: boolean\n}\n\nexport function highlightPanel({ id, flash }: HighlightPanelOptions) {\n\tconst panelElement = document.getElementById(id)\n\n\tif (panelElement instanceof HTMLDivElement) {\n\t\tscrollIntoView(panelElement, {\n\t\t\tscrollMode: \"if-needed\",\n\t\t\tblock: \"start\",\n\t\t})\n\n\t\tif (flash) {\n\t\t\tflashPanel(panelElement)\n\t\t}\n\t}\n}\n", "export function dispatchMouseDown(element: HTMLElement) {\n\tconst event = new MouseEvent(\"mousedown\", {\n\t\tbubbles: true,\n\t\tcancelable: true,\n\t\tview: document.defaultView,\n\t\tdetail: 1,\n\t\tscreenX: 0, // The coordinates within the entire page\n\t\tscreenY: 0,\n\t\tclientX: 0, // The coordinates within the viewport\n\t\tclientY: 0,\n\t\tctrlKey: false,\n\t\taltKey: false,\n\t\tshiftKey: false,\n\t\tmetaKey: false,\n\t\tbutton: 0, // 0 = left, 1 = middle, 2 = right\n\t\trelatedTarget: null,\n\t})\n\telement.dispatchEvent(event)\n}\n", "export const breadcrumbCollectionId = \"breadcrumb-collection\"\n", "import { assert, List, isExternalModuleIdentifier, shouldBeNever } from \"@framerjs/shared\"\nimport { Dictionary } from \"app/dictionary.ts\"\nimport type { VekterEngine } from \"document/VekterEngine.ts\"\nimport { PanelElementId, highlightPanel } from \"document/components/chrome/properties/panels/utils/highlightPanel.ts\"\nimport { dispatchMouseDown } from \"document/components/chrome/shared/utils/dispatchMouseDown.ts\"\nimport { getEntityDefinitionFromCodeComponentIdentifier } from \"document/components/utils/getEntityDefinitionFromCodeComponentIdentifier.ts\"\nimport type {\n\tCanvasNode,\n\tCollectionItemNode,\n\tCollectionNode,\n\tNodeID,\n\tShallowWebPageNode,\n} from \"document/models/CanvasTree/index.ts\"\nimport { CONTENT_MANAGEMENT_ID } from \"document/models/CanvasTree/nodes/ContentManagementNode.ts\"\nimport {\n\tisCollectionItemNode,\n\tisCollectionRepeater,\n\tisDataRepeater,\n\tisWebPageNode,\n} from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { hasCollectionDataSource } from \"document/models/CanvasTree/traits/WithCollectionDataSource.ts\"\nimport { withCollectionOptions } from \"document/models/CanvasTree/traits/WithCollectionOptions.ts\"\nimport { hasRepeatArray } from \"document/models/CanvasTree/traits/WithRepeatArray.ts\"\nimport { hasDataRepeaterArray } from \"document/models/CanvasTree/traits/WithRepeaterDataSource.ts\"\nimport { withVariableProvider } from \"document/models/CanvasTree/traits/WithVariableProvider.ts\"\nimport {\n\ttype VariableID,\n\tisArrayGalleryVariable,\n\tisArrayVariable,\n\twithVariables,\n} from \"document/models/CanvasTree/traits/WithVariables.ts\"\nimport { isStaticArrayControlProp } from \"document/models/controlProps/ControlProp.ts\"\nimport { localeProviderId } from \"document/utils/LocaleVariable.ts\"\nimport { ModalType } from \"document/utils/ModalType.ts\"\nimport type { ArrayItemStackElement } from \"document/utils/contentManagementOverlayStack.ts\"\nimport { ControlType } from \"library/render/types/PropertyControls.ts\"\nimport { getFirstRepeaterItemId } from \"utils/getFirstRepeaterItemId.ts\"\nimport { isReadonlyArray } from \"utils/typeChecks.ts\"\nimport type { DataRepeater } from \"../document/models/CanvasTree/nodes/FrameNode.ts\"\nimport type { ValueTransform } from \"../document/models/CanvasTree/traits/ValueTransform.ts\"\nimport { type VariableReference, isVariableReference } from \"../document/models/CanvasTree/traits/VariableReference.ts\"\nimport { breadcrumbCollectionId } from \"./breadcrumbCollectionId.ts\"\nimport {\n\tisReferenceToTailVariableId,\n\tresolveEditableCollectionVariableAsPath,\n\tseparator,\n} from \"./collectionReferenceUtils.ts\"\nimport { getCollectionForIdentifier } from \"./getCollectionForIdentifier.ts\"\n\ninterface RootVariableProviderInfo {\n\tisReferencedFromArraySource: boolean\n\tvariableProvider: CanvasNode\n\tvariableId: VariableID\n\tarrayItemVariableId?: VariableID\n}\n\nfunction isReferenceToAnyVariableIdSegment(referenceId: VariableID, variableId: VariableID) {\n\tif (isReferenceToTailVariableId(referenceId, variableId)) return true\n\n\t// For array item mappings we may receive paths where the field id appears in a middle segment.\n\treturn referenceId.split(separator).includes(variableId)\n}\n\nfunction getArrayItemVariableIdForCMS({\n\tarrayFieldId,\n\tcandidateVariableIds,\n\tcollectionNode,\n}: {\n\tarrayFieldId: VariableID\n\tcandidateVariableIds: readonly (VariableID | undefined)[]\n\tcollectionNode: CollectionNode\n}): VariableID | undefined {\n\tconst arrayVariable = collectionNode.getVariable(arrayFieldId)\n\tif (!arrayVariable || !isArrayVariable(arrayVariable) || isArrayGalleryVariable(arrayVariable)) return undefined\n\n\tfor (const candidateVariableId of candidateVariableIds) {\n\t\tif (!candidateVariableId) continue\n\n\t\tfor (const itemVariable of arrayVariable.itemVariables) {\n\t\t\tif (itemVariable.type === \"divider\") continue\n\n\t\t\tif (isReferenceToAnyVariableIdSegment(candidateVariableId, itemVariable.id)) {\n\t\t\t\treturn itemVariable.id\n\t\t\t}\n\t\t}\n\t}\n\n\treturn undefined\n}\n\nfunction getRootVariableProviderFromArraySource(\n\tengine: VekterEngine,\n\treferencedVariableId: VariableID,\n\tarrayReference: VariableReference,\n): RootVariableProviderInfo | null {\n\tconst arrayProviderId = arrayReference.providerId\n\tif (!arrayProviderId) return null\n\n\tconst arrayProvider = engine.tree.getNodeWithTrait(arrayProviderId, withVariableProvider)\n\tif (!arrayProvider) return null\n\n\tconst arrayVariableId = arrayReference.id\n\tif (!withVariables(arrayProvider)) {\n\t\treturn {\n\t\t\tisReferencedFromArraySource: true,\n\t\t\tvariableProvider: arrayProvider,\n\t\t\tvariableId: arrayVariableId,\n\t\t}\n\t}\n\n\tconst arrayVariable = arrayProvider.getVariable(arrayVariableId)\n\tif (!arrayVariable || !isArrayVariable(arrayVariable)) {\n\t\treturn {\n\t\t\tisReferencedFromArraySource: true,\n\t\t\tvariableProvider: arrayProvider,\n\t\t\tvariableId: arrayVariableId,\n\t\t}\n\t}\n\n\tconst itemVariable = arrayVariable.itemVariables.find(({ id }) => id === referencedVariableId)\n\tif (!itemVariable || itemVariable.type === \"divider\") {\n\t\treturn {\n\t\t\tisReferencedFromArraySource: true,\n\t\t\tvariableProvider: arrayProvider,\n\t\t\tvariableId: arrayVariable.id,\n\t\t}\n\t}\n\n\tif (isArrayGalleryVariable(arrayVariable)) {\n\t\treturn {\n\t\t\tisReferencedFromArraySource: true,\n\t\t\tvariableProvider: arrayProvider,\n\t\t\tvariableId: arrayVariable.id,\n\t\t}\n\t}\n\n\treturn {\n\t\tisReferencedFromArraySource: true,\n\t\tvariableProvider: arrayProvider,\n\t\tvariableId: arrayVariable.id,\n\t\tarrayItemVariableId: itemVariable.id,\n\t}\n}\n\nfunction getRootVariableProviderAndVariableId(\n\tengine: VekterEngine,\n\tvariableId: VariableID,\n\tproviderId: NodeID,\n): RootVariableProviderInfo | null {\n\tconst variableProvider = engine.tree.getNode(providerId)\n\tif (!variableProvider) return null\n\n\tif (hasRepeatArray(variableProvider)) {\n\t\treturn getRootVariableProviderFromArraySource(engine, variableId, variableProvider.repeatArray)\n\t}\n\n\tif (hasDataRepeaterArray(variableProvider)) {\n\t\treturn getRootVariableProviderFromArraySource(engine, variableId, variableProvider.dataRepeaterArray)\n\t}\n\n\treturn {\n\t\tisReferencedFromArraySource: false,\n\t\tvariableProvider,\n\t\tvariableId,\n\t}\n}\n\nexport function editVariable(engine: VekterEngine, inputVariableId: VariableID, inputProviderId: NodeID) {\n\tconst {\n\t\tchromeStore,\n\t\tmodalStore,\n\t\tvariablesStore,\n\t\tcontentManagementStore,\n\t\tscopeStore,\n\t\tcodeEditorStore,\n\t\tselectionStore,\n\t} = engine.stores\n\tif (inputProviderId === localeProviderId) {\n\t\tchromeStore.setLocalizationsVisible(true)\n\t\treturn\n\t}\n\n\tconst rootVariableProviderAndVariableId = getRootVariableProviderAndVariableId(\n\t\tengine,\n\t\tinputVariableId,\n\t\tinputProviderId,\n\t)\n\tif (!rootVariableProviderAndVariableId) return\n\n\tconst { variableProvider, variableId, arrayItemVariableId, isReferencedFromArraySource } =\n\t\trootVariableProviderAndVariableId\n\n\tconst isOwnVariable = withVariables(variableProvider) && variableProvider.hasVariable(variableId)\n\tif (isOwnVariable) {\n\t\tconst shouldOpenArrayDefaultValue = isReferencedFromArraySource && Boolean(arrayItemVariableId)\n\t\tvariablesStore.selectedVariablePath =\n\t\t\tarrayItemVariableId && !shouldOpenArrayDefaultValue ? [variableId, arrayItemVariableId] : [variableId]\n\t\tmodalStore.set({ type: ModalType.Variables, source: \"variableReference\" })\n\t} else if (\n\t\t(isWebPageNode(variableProvider) || isCollectionRepeater(variableProvider)) &&\n\t\thasCollectionDataSource(variableProvider)\n\t) {\n\t\tconst { dataIdentifier } = variableProvider\n\n\t\tif (isExternalModuleIdentifier(dataIdentifier)) {\n\t\t\tif (chromeStore.isViewOnly) return\n\n\t\t\tmodalStore.set({\n\t\t\t\ttype: ModalType.Confirmation,\n\t\t\t\ttitle: `External ${Dictionary.Collection}`,\n\t\t\t\tdescription: `This is an external ${Dictionary.Collection.toLowerCase()} preview. To edit, choose a collection to swap in or create a local copy of this collection.`,\n\t\t\t\tconfirmLabel: \"View Options\",\n\t\t\t\tsource: \"edit_action\",\n\t\t\t\tonConfirm: () => {\n\t\t\t\t\tchromeStore.chromeIsVisible = true\n\n\t\t\t\t\tif (hasCollectionDataSource(variableProvider)) {\n\t\t\t\t\t\tselectionStore.set(variableProvider.id)\n\t\t\t\t\t\tengine.scheduler.runAtEndOfFrame(() =>\n\t\t\t\t\t\t\thighlightPanel({ id: PanelElementId.DataRepeaterPanel, flash: true }),\n\t\t\t\t\t\t)\n\t\t\t\t\t} else if (isWebPageNode(variableProvider)) {\n\t\t\t\t\t\tengine.scheduler.runAtEndOfFrame(() => {\n\t\t\t\t\t\t\tconst breadcrumbCollectionElement = document.getElementById(breadcrumbCollectionId)\n\t\t\t\t\t\t\tif (!breadcrumbCollectionElement) return\n\t\t\t\t\t\t\t// Open the breadcrumb collection item to show the external collection options\n\t\t\t\t\t\t\tdispatchMouseDown(breadcrumbCollectionElement)\n\t\t\t\t\t\t})\n\t\t\t\t\t} else {\n\t\t\t\t\t\tshouldBeNever(variableProvider)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t})\n\n\t\t\treturn\n\t\t}\n\n\t\tconst collectionNode = getCollectionForIdentifier(engine.tree, dataIdentifier)\n\t\tif (collectionNode) {\n\t\t\tif (isWebPageNode(variableProvider)) {\n\t\t\t\tassert(variableProvider.isLoaded(), \"Web page node should be loaded\")\n\t\t\t}\n\n\t\t\tconst collectionItemAndVariable = getReferencedCollectionItemAndVariable({\n\t\t\t\tcollectionNode,\n\t\t\t\tengine,\n\t\t\t\tvariableId,\n\t\t\t\tvariableProvider,\n\t\t\t})\n\n\t\t\tif (collectionItemAndVariable) {\n\t\t\t\tcontentManagementStore.pushExistingItemToOverlayStack(collectionItemAndVariable.collectionItemNode.id)\n\n\t\t\t\tconst arrayItemFieldId = getArrayItemVariableIdForCMS({\n\t\t\t\t\tarrayFieldId: collectionItemAndVariable.variableId,\n\t\t\t\t\tcandidateVariableIds: [arrayItemVariableId, inputVariableId],\n\t\t\t\t\tcollectionNode: collectionItemAndVariable.collectionNode,\n\t\t\t\t})\n\n\t\t\t\tconst hasSelectedArrayItemField = selectArrayItemFieldInCMS({\n\t\t\t\t\tarrayFieldId: collectionItemAndVariable.variableId,\n\t\t\t\t\tarrayItemFieldId: arrayItemFieldId,\n\t\t\t\t\tcollectionItemNode: collectionItemAndVariable.collectionItemNode,\n\t\t\t\t\tengine,\n\t\t\t\t})\n\n\t\t\t\tcontentManagementStore.setCollectionItemControlToHighlight(\n\t\t\t\t\thasSelectedArrayItemField && arrayItemFieldId ? arrayItemFieldId : collectionItemAndVariable.variableId,\n\t\t\t\t)\n\t\t\t} else {\n\t\t\t\tscopeStore.select(CONTENT_MANAGEMENT_ID, { keepHistory: false })\n\t\t\t\tselectionStore.set(collectionNode)\n\t\t\t\tcontentManagementStore.setCollectionItemControlToHighlight(variableId)\n\t\t\t}\n\n\t\t\treturn\n\t\t}\n\n\t\tconst definition = getEntityDefinitionFromCodeComponentIdentifier(engine.componentLoader, dataIdentifier)\n\t\tif (definition) codeEditorStore.editFile(definition.file)\n\t}\n}\n\nfunction selectArrayItemFieldInCMS({\n\tarrayFieldId,\n\tarrayItemFieldId,\n\tcollectionItemNode,\n\tengine,\n}: {\n\tarrayFieldId: VariableID\n\tarrayItemFieldId: VariableID | undefined\n\tcollectionItemNode: CollectionItemNode\n\tengine: VekterEngine\n}): boolean {\n\tif (!arrayItemFieldId) return false\n\n\tconst arrayControlProp = collectionItemNode.getControlProp(arrayFieldId)\n\tif (!arrayControlProp) return false\n\tif (!isStaticArrayControlProp(arrayControlProp)) return false\n\tif (!isReadonlyArray(arrayControlProp.value)) return false\n\n\tconst firstArrayItem = arrayControlProp.value.find(item => item.type === ControlType.Object)\n\tif (!firstArrayItem) return false\n\n\tconst collectionId = collectionItemNode.parentid\n\tif (!collectionId) return false\n\n\tconst arrayItemOverlay: ArrayItemStackElement = {\n\t\tarrayFieldId,\n\t\tarrayItemId: firstArrayItem.id,\n\t\tcollectionId,\n\t\tcollectionItemId: collectionItemNode.id,\n\t\ttype: \"arrayItem\",\n\t}\n\tengine.stores.chromeStore.setContentManagementOverlayStack(\n\t\tList.push(engine.stores.chromeStore.contentManagementOverlayStack, arrayItemOverlay),\n\t)\n\n\treturn true\n}\n\n/**\n * Returns the collection item and collection variable id that the provided `variableId` is referencing. This item\n * could simply be in `collectionNode`, or could be in a parent collection containing a reference to `collectionNode`.\n */\nfunction getReferencedCollectionItemAndVariable({\n\tcollectionNode,\n\tengine,\n\tvariableId,\n\tvariableProvider,\n}: {\n\tcollectionNode: CollectionNode\n\tengine: VekterEngine\n\tvariableId: string\n\tvariableProvider: ShallowWebPageNode | DataRepeater\n}):\n\t| {\n\t\t\tcollectionItemNode: CollectionItemNode\n\t\t\tcollectionNode: CollectionNode\n\t\t\tvariableId: string\n\t  }\n\t| undefined {\n\tconst parentReference = getReferencedParentCollectionItemAndVariable({\n\t\tengine,\n\t\tvariableProvider,\n\t})\n\tif (parentReference) return parentReference\n\n\tconst variablePath = variableId.split(\".\")\n\tassert(variablePath.length >= 0, \"VariableID must not be empty\")\n\n\tconst collectionItemId = getFirstRepeaterItemId(variableProvider, engine.stores.treeStore.sandboxRepeaterData)\n\tconst collectionItem = engine.tree.getNodeWithTrait(collectionItemId, isCollectionItemNode)\n\tif (!collectionItem) return undefined\n\n\treturn resolveEditableCollectionVariableAsPath(\n\t\tengine.tree,\n\t\tengine.stores.treeStore.sandboxRepeaterData,\n\t\tvariableId,\n\t\tcollectionItem,\n\t\tcollectionNode,\n\t)\n}\n\n/**\n * Looks at the filters applied to the current `variableProvider` to determine they could potentially correspond to a\n * collection reference, and if so, returns the referenced collection item and collection variable id.\n */\nfunction getReferencedParentCollectionItemAndVariable({\n\tengine,\n\tvariableProvider,\n}: {\n\tengine: VekterEngine\n\tvariableProvider: ShallowWebPageNode | DataRepeater\n}): ReturnType<typeof getReferencedCollectionItemAndVariable> {\n\tif (!withCollectionOptions(variableProvider)) return undefined\n\n\t// Out of all filters, take the first transform that references a variable. In the rare case that there are two\n\t// transforms (across all filters) referencing a variable, do nothing because we are unable to determine where to go.\n\tconst [referenceToParentCollection, ...otherReferences] =\n\t\tvariableProvider.collectionFilters?.filters\n\t\t\t.flatMap(filter => (filter?.itemKey !== \"id\" ? [] : filter.transforms))\n\t\t\t.flatMap(transform => getVariableReferenceFromEqualOrIsIncludedIn(transform) ?? []) ?? []\n\n\tif (!referenceToParentCollection?.providerId || otherReferences.length > 0) return undefined\n\n\tconst parentVariableProvider = engine.tree.getNode(referenceToParentCollection.providerId)\n\tif (\n\t\t!parentVariableProvider ||\n\t\t!(isDataRepeater(parentVariableProvider) || isWebPageNode(parentVariableProvider)) ||\n\t\t!parentVariableProvider.dataIdentifier\n\t) {\n\t\treturn undefined\n\t}\n\n\tconst parentCollectionNode = getCollectionForIdentifier(engine.tree, parentVariableProvider.dataIdentifier)\n\tif (!parentCollectionNode) return undefined\n\n\tconst collectionItemId = getFirstRepeaterItemId(parentVariableProvider, engine.stores.treeStore.sandboxRepeaterData)\n\tconst collectionItemNode = engine.tree.get(collectionItemId)\n\tif (!isCollectionItemNode(collectionItemNode)) return undefined\n\n\treturn {\n\t\tcollectionItemNode,\n\t\tcollectionNode: parentCollectionNode,\n\t\tvariableId: referenceToParentCollection.id,\n\t}\n}\n\nfunction getVariableReferenceFromEqualOrIsIncludedIn(transform: ValueTransform) {\n\tif (\n\t\t(transform.name !== \"equals\" && transform.name !== \"isIncludedIn\") ||\n\t\t!isVariableReference(transform.value) ||\n\t\t!transform.value.providerId\n\t) {\n\t\treturn undefined\n\t}\n\n\treturn transform.value\n}\n", "import { isArray, isObject, isString } from \"utils/typeChecks.ts\"\nimport type { FramerLayersClipboardData } from \"./types.ts\"\n\nexport function isFramerLayersClipboardData(data: unknown): data is FramerLayersClipboardData {\n\treturn (\n\t\tisObject(data) &&\n\t\t\"layers\" in data &&\n\t\tisObject(data.layers) &&\n\t\t\"assets\" in data &&\n\t\tisArray(data.assets) &&\n\t\t\"sourceProjectId\" in data &&\n\t\tisString(data.sourceProjectId)\n\t)\n}\n", "import { assert } from \"@framerjs/shared\"\n\nexport function chunkArray<Item>(array: Item[], chunkSize: number) {\n\tassert(chunkSize > 0, \"Invalid chunk size\")\n\n\tconst chunks: Item[][] = []\n\n\tlet from = 0\n\twhile (from < array.length) {\n\t\tconst to = from + chunkSize\n\t\tconst chunk = array.slice(from, to)\n\t\tchunks.push(chunk)\n\t\tfrom = to\n\t}\n\n\treturn chunks\n}\n", "import { assertNever } from \"@framerjs/shared\"\nimport type { CanvasNode } from \"document/models/CanvasTree/index.ts\"\nimport { ClassDiscriminator } from \"utils/withClassDiscriminator.ts\"\n\n/**\n * This is an exhaustive list of all node types that can be inserted into the canvas from a copy tree. Please update the\n * list if you're introducing a new type of node.\n */\nexport function isInsertableNodeClassFromCopyTree(node: CanvasNode) {\n\tswitch (node.__class) {\n\t\tcase ClassDiscriminator.EntityFolderNode:\n\t\tcase ClassDiscriminator.EntityReferenceNode:\n\t\tcase ClassDiscriminator.EntityRootNode:\n\t\tcase ClassDiscriminator.AbTestsEntityTypeRootNode:\n\t\tcase ClassDiscriminator.FunnelsEntityTypeRootNode:\n\t\tcase ClassDiscriminator.LinkEntityTypeRootNode:\n\t\tcase ClassDiscriminator.CMSEntityTypeRootNode:\n\t\tcase ClassDiscriminator.CodeFileEntityTypeRootNode:\n\t\tcase ClassDiscriminator.ColorEntityTypeRootNode:\n\t\tcase ClassDiscriminator.InlineCodeEntityTypeRootNode:\n\t\tcase ClassDiscriminator.TextEntityTypeRootNode:\n\t\tcase ClassDiscriminator.BlockquoteEntityTypeRootNode:\n\t\tcase ClassDiscriminator.ComponentEntityTypeRootNode:\n\t\tcase ClassDiscriminator.LayoutTemplateEntityTypeRootNode:\n\t\tcase ClassDiscriminator.ContentManagementEntityTypeRootNode:\n\t\tcase ClassDiscriminator.VectorSetEntityTypeRootNode:\n\t\t\t// TODO: Figure out if our entity nodes need to be in the copy tree\n\t\t\treturn false\n\t\tcase ClassDiscriminator.ColorStyleTokenListNode:\n\t\tcase ClassDiscriminator.ErrorListNode:\n\t\tcase ClassDiscriminator.RouteSegmentRootNode:\n\t\t\t// Direct children of the root node, they could be added to the copy tree through migrateDocument, but\n\t\t\t// should never be inserted to the tree on paste.\n\t\t\treturn false\n\t\tcase ClassDiscriminator.ComponentPresetNode:\n\t\tcase ClassDiscriminator.InlineCodeStylePresetNode:\n\t\tcase ClassDiscriminator.ImageStylePresetNode:\n\t\tcase ClassDiscriminator.LinkStylePresetNode:\n\t\tcase ClassDiscriminator.BlockquoteStylePresetNode:\n\t\tcase ClassDiscriminator.TableStylePresetNode:\n\t\tcase ClassDiscriminator.PresetsListNode:\n\t\tcase ClassDiscriminator.TextStylePresetNode:\n\t\t\t// Style presets are handled separately in the ClipboardLayers.stylePresetNodes record, they should not end\n\t\t\t// up in the copy tree. Component preset nodes are not copyable at the moment.\n\t\t\treturn false\n\t\tcase ClassDiscriminator.ExternalModuleNode:\n\t\tcase ClassDiscriminator.ExternalModulesListNode:\n\t\tcase ClassDiscriminator.LocalModuleNode:\n\t\tcase ClassDiscriminator.LocalModulesListNode:\n\t\t\t// Modules are handled separately in the ClipboardLayers.moduleData record, they should not end up in the\n\t\t\t// copy tree.\n\t\t\treturn false\n\t\tcase ClassDiscriminator.ErrorNode:\n\t\t\t// Error nodes are only allowed to be created by code-generation.\n\t\t\treturn false\n\t\tcase ClassDiscriminator.BooleanShapeNode:\n\t\tcase ClassDiscriminator.BoxShadow:\n\t\tcase ClassDiscriminator.CanvasNode:\n\t\tcase ClassDiscriminator.CanvasPageNode:\n\t\tcase ClassDiscriminator.DesignPageNode:\n\t\tcase ClassDiscriminator.CanvasScopeNode:\n\t\tcase ClassDiscriminator.CodeComponentNode:\n\t\tcase ClassDiscriminator.CollectionItemNode:\n\t\tcase ClassDiscriminator.CollectionNode:\n\t\tcase ClassDiscriminator.Color:\n\t\tcase ClassDiscriminator.ColorStyleTokenNode:\n\t\tcase ClassDiscriminator.ConicGradient:\n\t\tcase ClassDiscriminator.ContentManagementNode:\n\t\tcase ClassDiscriminator.FormBooleanInputNode:\n\t\tcase ClassDiscriminator.FormPlainTextInputNode:\n\t\tcase ClassDiscriminator.FormSelectNode:\n\t\tcase ClassDiscriminator.FrameNode:\n\t\tcase ClassDiscriminator.GradientColorStop:\n\t\tcase ClassDiscriminator.HeaderRouteNode:\n\t\tcase ClassDiscriminator.LayoutTemplateNode:\n\t\tcase ClassDiscriminator.LinearGradient:\n\t\tcase ClassDiscriminator.MutableNode:\n\t\tcase ClassDiscriminator.OvalShapeNode:\n\t\tcase ClassDiscriminator.OverlayNode:\n\t\tcase ClassDiscriminator.PathNode:\n\t\tcase ClassDiscriminator.PathSegment:\n\t\tcase ClassDiscriminator.PolygonShapeNode:\n\t\tcase ClassDiscriminator.ProxyRouteNode:\n\t\tcase ClassDiscriminator.RadialGradient:\n\t\tcase ClassDiscriminator.RectangleShapeNode:\n\t\tcase ClassDiscriminator.RedirectRouteNode:\n\t\tcase ClassDiscriminator.RewriteRouteNode:\n\t\tcase ClassDiscriminator.RichTextNode:\n\t\tcase ClassDiscriminator.RootNode:\n\t\tcase ClassDiscriminator.RouteNode:\n\t\tcase ClassDiscriminator.RouteLocaleNode:\n\t\tcase ClassDiscriminator.RouteSegmentNode:\n\t\tcase ClassDiscriminator.RoutesNode:\n\t\tcase ClassDiscriminator.ScopeNode:\n\t\tcase ClassDiscriminator.ShaderNode:\n\t\tcase ClassDiscriminator.Shadow:\n\t\tcase ClassDiscriminator.ShapeContainerNode:\n\t\tcase ClassDiscriminator.ShapeGroupNode:\n\t\tcase ClassDiscriminator.SlotNode:\n\t\tcase ClassDiscriminator.SlotPropertyNode:\n\t\tcase ClassDiscriminator.SmartComponentNode:\n\t\tcase ClassDiscriminator.StarShapeNode:\n\t\tcase ClassDiscriminator.StyledTextDraft:\n\t\tcase ClassDiscriminator.SVGNode:\n\t\tcase ClassDiscriminator.TextNode:\n\t\tcase ClassDiscriminator.VectorSetNode:\n\t\tcase ClassDiscriminator.WebPageNode:\n\t\t\treturn true\n\t\tcase ClassDiscriminator.AgentPanelTool:\n\t\tcase ClassDiscriminator.AgentDragSelectTool:\n\t\tcase ClassDiscriminator.AgentSelectTool:\n\t\tcase ClassDiscriminator.AnalyticsScopeNode:\n\t\tcase ClassDiscriminator.ChatTool:\n\t\tcase ClassDiscriminator.CollectionReferenceVariableEditTool:\n\t\tcase ClassDiscriminator.CreateCodeComponentBaseTool:\n\t\tcase ClassDiscriminator.CreateFrameBaseTool:\n\t\tcase ClassDiscriminator.CreateShapeBaseTool:\n\t\tcase ClassDiscriminator.CreateTextTool:\n\t\tcase ClassDiscriminator.CustomCodeScopeNode:\n\t\tcase ClassDiscriminator.CustomCodeNode:\n\t\tcase ClassDiscriminator.BranchesNode:\n\t\tcase ClassDiscriminator.BranchNode:\n\t\tcase ClassDiscriminator.EnumVariableEditTool:\n\t\tcase ClassDiscriminator.ExportOptions:\n\t\tcase ClassDiscriminator.FeedbackTool:\n\t\tcase ClassDiscriminator.FunnelNode:\n\t\tcase ClassDiscriminator.FunnelStepActionNode:\n\t\tcase ClassDiscriminator.FunnelStepNode:\n\t\tcase ClassDiscriminator.GapTool:\n\t\tcase ClassDiscriminator.GradientToolManagerTool:\n\t\tcase ClassDiscriminator.GuideMoveTool:\n\t\tcase ClassDiscriminator.HighlightStackItemTool:\n\t\tcase ClassDiscriminator.HighlightTool:\n\t\tcase ClassDiscriminator.InitialTool:\n\t\tcase ClassDiscriminator.LineAnchorMoveTool:\n\t\tcase ClassDiscriminator.LinkTool:\n\t\tcase ClassDiscriminator.LoadingShieldTool:\n\t\tcase ClassDiscriminator.LocalizationGlossaryItemNode:\n\t\tcase ClassDiscriminator.LocalizationGlossaryNode:\n\t\tcase ClassDiscriminator.MoveTool:\n\t\tcase ClassDiscriminator.PaddingTool:\n\t\tcase ClassDiscriminator.PageLinkTool:\n\t\tcase ClassDiscriminator.PanTool:\n\t\tcase ClassDiscriminator.PathCurveBendTool:\n\t\tcase ClassDiscriminator.PathDefaultTool:\n\t\tcase ClassDiscriminator.PathSegmentAdditionTool:\n\t\tcase ClassDiscriminator.PathSegmentHandleMoveTool:\n\t\tcase ClassDiscriminator.PathSegmentMoveTool:\n\t\tcase ClassDiscriminator.PathSegmentSelectTool:\n\t\tcase ClassDiscriminator.PreviewSettings:\n\t\tcase ClassDiscriminator.RadiusTool:\n\t\tcase ClassDiscriminator.RecoveryTool:\n\t\tcase ClassDiscriminator.ResizeTool:\n\t\tcase ClassDiscriminator.RichTextEditTool:\n\t\tcase ClassDiscriminator.RichTextVariableEditTool:\n\t\tcase ClassDiscriminator.DateVariableEditTool:\n\t\tcase ClassDiscriminator.RotateTool:\n\t\tcase ClassDiscriminator.SampleColorTool:\n\t\tcase ClassDiscriminator.ScaleTool:\n\t\tcase ClassDiscriminator.SelectTool:\n\t\tcase ClassDiscriminator.SlotConnectTool:\n\t\tcase ClassDiscriminator.StringVariableEditTool:\n\t\tcase ClassDiscriminator.TestTool:\n\t\tcase ClassDiscriminator.TextEditTool:\n\t\tcase ClassDiscriminator.VekterGradientTool:\n\t\tcase ClassDiscriminator.VekterPathEngine:\n\t\tcase ClassDiscriminator.VekterTool:\n\t\tcase ClassDiscriminator.ViewportResizeTool:\n\t\tcase ClassDiscriminator.ZoomSelectTool:\n\t\tcase ClassDiscriminator.ZoomTool:\n\t\t\treturn false\n\t\tdefault:\n\t\t\tassertNever(\n\t\t\t\tnode.__class,\n\t\t\t\t\"Unexpected node type, please determine if the node is insertable when introducing a new type\",\n\t\t\t)\n\t}\n}\n", "import { assert } from \"@framerjs/shared\"\nimport type { CanvasNode, CanvasTree, NodeID } from \"document/models/CanvasTree/index.ts\"\nimport { isCodeComponentNode, isShapeContainerNode } from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { getChildren, withChildren } from \"document/models/CanvasTree/traits/WithChildren.ts\"\nimport { isLockedOrLockedByParent } from \"document/models/CanvasTree/traits/WithLock.ts\"\nimport { isMaster, isReplicaOrReplicaChild } from \"document/models/CanvasTree/traits/WithTemplate.ts\"\nimport type { ModalStore } from \"document/stores/ModalStore.ts\"\nimport type { SelectionStore } from \"document/stores/SelectionStore.ts\"\nimport { ModalType } from \"document/utils/ModalType.ts\"\nimport type { ClipboardLayers } from \"./types.ts\"\n\ninterface PasteReplacementPair {\n\tnodeToReplace: CanvasNode\n\treplacement: CanvasNode\n}\n\n/**\n * Check if the node to replace (selected node) has the same id as the replacement (copied node).\n * @private Export only for tests.\n */\nexport function findMatchingPairToReplace(\n\tcandidates: CanvasNode[],\n\tcopyTree: CanvasTree,\n\tlayers: ClipboardLayers,\n): PasteReplacementPair | undefined {\n\tconst { historyData, renamedIds } = layers\n\tif (!historyData) return\n\n\tif (candidates.length !== 1) return\n\tconst [nodeToReplace] = candidates\n\tassert(nodeToReplace, \"nodeToReplace must be defined\")\n\n\tconst copiedNodes = copyTree.root.children\n\tif (copiedNodes.length !== 1) return\n\tconst [replacement] = copiedNodes\n\tassert(replacement, \"replacement must be defined\")\n\n\t// Replacing shape:\n\t// Shape nodes are always wrapped in a shape container node at precommit. When copying a shape node, it will be\n\t// wrapped in a container (which will be removed when pasted in a container), so we check one level deeper in case\n\t// of a shape container.\n\tif (isShapeContainerNode(replacement) && replacement.children.length === 1) {\n\t\tconst [shape] = replacement.children\n\t\tif (shape && shape.id === nodeToReplace.id) {\n\t\t\treturn { nodeToReplace, replacement: shape }\n\t\t}\n\t}\n\n\t// Copied original or replica child node, paste on original node\n\tif (nodeToReplace.id === replacement.id || renamedIds?.[nodeToReplace.id] === replacement.id) {\n\t\treturn { nodeToReplace, replacement }\n\t}\n\n\t// Copied replica child node, paste on replica child node\n\t// If the copied node is a replica/replica child node, we renamed its id and cleared its originalId during copying,\n\t// therefore when pasting we can't look up the node directly, but the data we stored in layers.\n\tconst replicaMatchesReplica =\n\t\thistoryData?.originalId &&\n\t\thistoryData?.replicaInfo &&\n\t\tnodeToReplace.originalid &&\n\t\t(historyData.originalId === nodeToReplace.originalid ||\n\t\t\thistoryData.originalId === renamedIds?.[nodeToReplace.originalid])\n\tif (replicaMatchesReplica && subtreesAreIdentical(nodeToReplace, replacement, renamedIds)) {\n\t\treturn { nodeToReplace, replacement }\n\t}\n}\n\n/**\n * Compare two nodes by checking if the subtrees are exactly the same, by matching each descendant's id, allowing the\n * other props to be different. This is possible when copy-pasting from history.\n */\nfunction subtreesAreIdentical(nodeToReplace: CanvasNode, replacement: CanvasNode, renamedIds?: Record<NodeID, NodeID>) {\n\tif (withChildren(nodeToReplace) && withChildren(replacement)) {\n\t\tconst sameAmount = nodeToReplace.children.length === replacement.children.length\n\t\tif (!sameAmount) {\n\t\t\treturn false\n\t\t}\n\t\tconst unequalChild = getChildren(nodeToReplace).find((childA: CanvasNode, index: number) => {\n\t\t\tconst childB = replacement.children.at(index)\n\t\t\tassert(childB, \"Node child must be defined\")\n\t\t\treturn !subtreesAreIdentical(childA, childB, renamedIds)\n\t\t})\n\t\tif (unequalChild) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\tif (nodeToReplace.__class !== replacement.__class) return false\n\tif (\n\t\tisCodeComponentNode(nodeToReplace) &&\n\t\tisCodeComponentNode(replacement) &&\n\t\tnodeToReplace.codeComponentIdentifier !== replacement.codeComponentIdentifier\n\t) {\n\t\treturn false\n\t}\n\n\tconst isReplicaNode = isReplicaOrReplicaChild(nodeToReplace)\n\tconst idToReplace = isReplicaNode ? nodeToReplace.originalid : nodeToReplace.id\n\t// The replacement has been renamed when copying, so we need to look up the renamedIds map.\n\treturn idToReplace === replacement.id || renamedIds?.[idToReplace] === replacement.id\n}\n\nfunction isNodeReplaceable(node: CanvasNode) {\n\t// @TODO: Don't allow replacing master nodes yet. We need to make product decisions on the expected behaviors for\n\t// the existing replicas when replacing a master node.\n\tif (isMaster(node)) return false\n\tif (isLockedOrLockedByParent(node)) return false\n\treturn true\n}\n\nfunction getReplacementPair(\n\tselectionStore: SelectionStore,\n\tcopyTree: CanvasTree,\n\tlayers: ClipboardLayers,\n): PasteReplacementPair | undefined {\n\tconst { nodeToReplace, replacement } = findMatchingPairToReplace(selectionStore.nodes, copyTree, layers) ?? {}\n\tif (!nodeToReplace || !replacement) return\n\tif (!isNodeReplaceable(nodeToReplace)) return\n\n\treturn { nodeToReplace, replacement }\n}\n\nexport function promptToReplaceSelectedNodeIfMatched(\n\tselectionStore: SelectionStore,\n\tmodalStore: ModalStore,\n\tcopyTree: CanvasTree,\n\tlayers: ClipboardLayers,\n): Promise<PasteReplacementPair | null | \"abort\"> | null {\n\tconst replaceableNodes = getReplacementPair(selectionStore, copyTree, layers)\n\tif (!replaceableNodes) return null\n\n\treturn new Promise<PasteReplacementPair | null | \"abort\">(resolve => {\n\t\tmodalStore.set({\n\t\t\ttype: ModalType.Confirmation,\n\t\t\ttitle: \"Paste From History\",\n\t\t\tdescription: \"Would you like to paste the selection as a new layer or replace the existing one?\",\n\t\t\tconfirmLabel: \"Replace\",\n\t\t\tcancelLabel: \"New Layer\",\n\t\t\tsource: \"clipboard_paste\",\n\t\t\tonConfirm() {\n\t\t\t\tresolve(replaceableNodes)\n\t\t\t},\n\t\t\tonCancel() {\n\t\t\t\tresolve(null)\n\t\t\t},\n\t\t\tonDismiss() {\n\t\t\t\tresolve(\"abort\") // Cancel the paste\n\t\t\t},\n\t\t})\n\t})\n}\n", "import type { ComponentLoader } from \"@framerjs/framer-runtime\"\nimport type { ExternalModuleExportIdentifier } from \"@framerjs/shared\"\nimport { assert, unhandledError } from \"@framerjs/shared\"\nimport type { VekterEngine } from \"document/VekterEngine.ts\"\nimport { createContentManagementNodeIfNeeded } from \"document/components/chrome/contentManagement/utils/createContentManagementNodeIfNeeded.ts\"\nimport { suggestedConstraintsForCopiedNode } from \"document/components/tools/utils/FramesHelper.ts\"\nimport { remapOverrides } from \"document/components/tools/utils/remapOverrides.ts\"\nimport { updateItemsOrder } from \"document/components/tools/utils/updateItemsOrder.ts\"\nimport { RenamedIds, updateNodeConnections } from \"document/components/tools/utils/updateNodeConnections.ts\"\nimport { cloneScopeNodeWithVariants } from \"document/components/unlinking/importExternalSmartComponentOrWebpage.ts\"\nimport { hasEmptyEvents } from \"document/models/CanvasTree/actions/actions.ts\"\nimport type {\n\tAnyNodeUpdate,\n\tAnyScopeNode,\n\tCanvasNode,\n\tCollectionNode,\n\tLoadedScopeNode,\n\tMaybeNodeID,\n\tNodeID,\n\tRichTextNode,\n} from \"document/models/CanvasTree/index.ts\"\nimport {\n\tCanvasPageNode,\n\tCanvasTree,\n\tFrameNode,\n\tNullID,\n\tScopeNode,\n\tWebPageNode,\n\tisVectorNode,\n} from \"document/models/CanvasTree/index.ts\"\nimport { CanvasChildList } from \"document/models/CanvasTree/nodes/ChildList.ts\"\nimport { CONTENT_MANAGEMENT_ID } from \"document/models/CanvasTree/nodes/ContentManagementNode.ts\"\nimport { getContentManagementNode } from \"document/models/CanvasTree/nodes/ContentManagementNode.utils.ts\"\nimport type { InlineCodeStylePresetNode } from \"document/models/CanvasTree/nodes/InlineCodeStylePresetNode.ts\"\nimport type { LinkStylePresetNode } from \"document/models/CanvasTree/nodes/LinkStylePresetNode.ts\"\nimport { isValidNodeId, randomID } from \"document/models/CanvasTree/nodes/NodeID.ts\"\nimport {\n\tTemplateHelper,\n\tcreateDuplicatedFromIfAllowed,\n\tduplicatedFromForNode,\n\tgenerateReplicaChildId,\n\tmergeOverrides,\n} from \"document/models/CanvasTree/nodes/TemplateHelper.ts\"\nimport type { TextStylePresetNode } from \"document/models/CanvasTree/nodes/TextStylePresetNode.ts\"\nimport {\n\tcanvasNodeFromValue,\n\treviveReplicaInfo,\n\treviveReplicaOverrides,\n} from \"document/models/CanvasTree/nodes/canvasNodeFromValue.ts\"\nimport {\n\tisCanvasPageNode,\n\tisCodeComponentNode,\n\tisCollectionNode,\n\tisColorStyleTokenNode,\n\tisDesignPageNode,\n\tisFrameNode,\n\tisInlineCodeStylePresetNode,\n\tisKitPageNode,\n\tisLayoutTemplateNode,\n\tisLinkStylePresetNode,\n\tisOverlayNode,\n\tisRichTextNode,\n\tisShapeContainerNode,\n\tisSmartComponentNode,\n\tisStackComponent,\n\tisTextStylePresetNode,\n\tisVectorSetNode,\n\tisWebPageNode,\n} from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { isFixedOrRelativeOverlay, nodeIsInOverlay } from \"document/models/CanvasTree/nodes/utils/overlayHelpers.ts\"\nimport {\n\tcontainsActiveSmartComponentInstance,\n\tgetSmartComponentOrWebPageForCodeComponent,\n\tisLocalSmartComponentInstance,\n} from \"document/models/CanvasTree/nodes/utils/smartComponentInstanceHelpers.ts\"\nimport { updateReplicaOverrides } from \"document/models/CanvasTree/nodes/utils/updateReplicaOverrides.ts\"\nimport { withBreakpointVariants } from \"document/models/CanvasTree/traits/WithBreakpointVariants.ts\"\nimport { getChildren, withChildren } from \"document/models/CanvasTree/traits/WithChildren.ts\"\nimport {\n\tfloatingPositionDefaults,\n\thasFloatingPosition,\n\twithFloatingPosition,\n} from \"document/models/CanvasTree/traits/WithFloatingPosition.ts\"\nimport { withFrameEvents } from \"document/models/CanvasTree/traits/WithFrameEvents.ts\"\nimport { hasItemsOrderOverride } from \"document/models/CanvasTree/traits/WithItemsOrder.ts\"\nimport type { WithPins } from \"document/models/CanvasTree/traits/WithPins.ts\"\nimport { isPinnable } from \"document/models/CanvasTree/traits/WithPins.ts\"\nimport { withPosition } from \"document/models/CanvasTree/traits/WithPosition.ts\"\nimport { withReplicaVariants } from \"document/models/CanvasTree/traits/WithReplicaVariants.ts\"\nimport type { WithSize } from \"document/models/CanvasTree/traits/WithSize.ts\"\nimport type { WithSizeDimensionType } from \"document/models/CanvasTree/traits/WithSizeDimensionType.ts\"\nimport { withSizeDimensionType } from \"document/models/CanvasTree/traits/WithSizeDimensionType.ts\"\nimport type {\n\tIsReplica,\n\tIsReplicaOrReplicaChild,\n\tReplicaInfo,\n\tReplicaOverrides,\n} from \"document/models/CanvasTree/traits/WithTemplate.ts\"\nimport {\n\tgetMasterAncestor,\n\tisHiddenMaster,\n\tisMaster,\n\tisReplica,\n\tisReplicaOrReplicaChild,\n\twithTemplate,\n} from \"document/models/CanvasTree/traits/WithTemplate.ts\"\nimport { withVariableProvider } from \"document/models/CanvasTree/traits/WithVariableProvider.ts\"\nimport { type VariableDefinition, isVariableDefinition } from \"document/models/CanvasTree/traits/WithVariables.ts\"\nimport {\n\tisBreakpointVariant,\n\tisPrimaryBreakpointVariant,\n\tisPrimaryVariant,\n\tisReplicaVariantOrReplicaVariantChild,\n\tisVariant,\n\twithBreakpoint,\n\twithVariant,\n} from \"document/models/CanvasTree/traits/WithVariant.ts\"\nimport { isVectorSetItem, withVectorSetItemDefaults } from \"document/models/CanvasTree/traits/WithVectorSetItem.ts\"\nimport { isFormContainer } from \"document/models/CanvasTree/traits/forms/WithFormContainer.ts\"\nimport { EagerVariableProviderMap } from \"document/models/CanvasTree/traits/utils/EagerVariableProviderMap.ts\"\nimport { acceptsChild } from \"document/models/CanvasTree/traits/utils/acceptsChild.ts\"\nimport { positionTypeUpdateForNewParent } from \"document/models/CanvasTree/traits/utils/positionTypeHelpers.ts\"\nimport {\n\tcanNodeProvideViewportRect,\n\tgetViewportProviderForNode,\n} from \"document/models/CanvasTree/traits/utils/viewportHelpers.ts\"\nimport { getBoundingFrameForNodes, getViewportRect } from \"document/models/CanvasTree/utils/geometry.ts\"\nimport { getNodeUpdateResolvingDynamicValues } from \"document/models/CanvasTree/utils/getNodeUpdateResolvingDynamicValues.ts\"\nimport {\n\tisTokenCSSVariable,\n\ttokenIdFromCSSVariable,\n\ttokenToCSSVariable,\n} from \"document/models/CanvasTree/utils/tokens.ts\"\nimport { isGradient } from \"document/models/Gradient.ts\"\nimport { isBoxShadow } from \"document/models/Shadow.ts\"\nimport { shouldGuessPinToBottom } from \"document/models/shouldGuessPinToBottom.ts\"\nimport { shouldGuessPinToRight } from \"document/models/shouldGuessPinToRight.ts\"\nimport { createFormConfigSource } from \"document/stores/FormsStore.ts\"\nimport { ExternalComponentInsertType } from \"document/stores/ModulesStore.ts\"\nimport type { TreeIndex } from \"document/stores/TreeIndex.ts\"\nimport { ToastKey } from \"document/utils/ToastKey.ts\"\nimport type { ProviderID } from \"document/utils/VariableProviderInfo.ts\"\nimport { getCompatibleNodeProperties } from \"document/utils/getCompatibleNodeProperties.ts\"\nimport {\n\tautoConvertParentToStackIfNeeded,\n\tisLayoutSection,\n\tmakePrimaryBreakpointAutoSizingIfNeeded,\n} from \"document/utils/layoutSectionHelpers.ts\"\nimport { nodesAreSimilar } from \"document/utils/nodesAreSimilar.ts\"\nimport { isEmptyWebPage, replaceWebPage } from \"document/utils/replaceWebPage.ts\"\nimport type { Size } from \"library/index.ts\"\nimport { Rect, isEqual } from \"library/index.ts\"\nimport { DimensionType } from \"library/render/types/Constraints.ts\"\nimport { Point } from \"library/render/types/Point.ts\"\nimport { getId } from \"utils/getId.ts\"\nimport { isArray, isString } from \"utils/typeChecks.ts\"\nimport { toastProgress } from \"web/lib/toaster.ts\"\nimport { record } from \"web/lib/tracker.ts\"\nimport {\n\tisReplicaWithSize,\n\tpasteInlineCodeStylePresets,\n\tpasteLinkStylePresets,\n\tpasteModules,\n\tpasteTextStylePresets,\n\tunsafeMakeMutable,\n} from \"../utils.ts\"\nimport { isInsertableNodeClassFromCopyTree } from \"./isInsertableNodeClassFromCopyTree.ts\"\nimport { promptToReplaceSelectedNodeIfMatched } from \"./promptToReplaceSelectedNodeIfMatched.ts\"\nimport type {\n\tBreakpointOverrides,\n\tClipboardLayers,\n\tClipboardModuleData,\n\tNodeIDToFrame,\n\tSerializableMap,\n} from \"./types.ts\"\n\nexport const emptyClipboardLayers: ClipboardLayers = {\n\ttree: {},\n\toriginalFrames: {},\n\tmasters: {},\n\treplicas: {},\n\trenamedIds: {},\n\tstylePresetNodes: {},\n}\n\nexport function getRenamedIdsFromClipboardLayers(layers: ClipboardLayers, renamedIds = new RenamedIds()): RenamedIds {\n\tif (layers.renamedIds) {\n\t\tfor (const oldId in layers.renamedIds) {\n\t\t\tconst newId = layers.renamedIds[oldId]\n\t\t\tif (!newId) continue\n\t\t\trenamedIds.set(oldId, newId)\n\t\t}\n\t}\n\n\treturn renamedIds\n}\n\nfunction getExternalModuleIdentifiers(\n\tengine: VekterEngine,\n\tmoduleData: ClipboardModuleData | undefined,\n): ExternalModuleExportIdentifier[] {\n\tif (moduleData) {\n\t\t// filter out local modules\n\t\treturn Object.values(moduleData).filter(m => !engine.stores.modulesStore.getPersistedModuleByGlobalId(m.moduleId))\n\t}\n\treturn []\n}\n\nfunction reviveBreakpointOverrides(breakpointOverrides: BreakpointOverrides): BreakpointOverrides {\n\tconst revivedBreakpointOverrides: BreakpointOverrides = []\n\tfor (const [breakpoint, replicaOverrides] of breakpointOverrides) {\n\t\tconst revivedOverride = reviveReplicaOverrides(replicaOverrides)\n\t\trevivedBreakpointOverrides.push([breakpoint, revivedOverride])\n\t}\n\treturn revivedBreakpointOverrides\n}\n\n// FIXME find better abstractions so we can reduce the number of variables used\n// in the functions below.\nexport async function insertTree({\n\tengine,\n\tlayers,\n\tinsertionScopeNode,\n\tinsertionGroundNodeId,\n\tshouldDetachTextStyles = false,\n\tshouldPasteTextStyles = false,\n\treusePresetWithSameId = false,\n\tcloneWithScopeIds,\n\tsourceProjectId = \"\",\n\tselectAndCenter = true,\n\tonInsertNode,\n\tpasteInfo,\n\trenamedIds,\n}: {\n\tengine: VekterEngine\n\tlayers: ClipboardLayers\n\tinsertionScopeNode: LoadedScopeNode\n\tinsertionGroundNodeId: MaybeNodeID\n\tshouldDetachTextStyles?: boolean\n\tshouldPasteTextStyles?: boolean\n\treusePresetWithSameId?: boolean\n\tcloneWithScopeIds?: boolean\n\tsourceProjectId?: string\n\tselectAndCenter?: boolean\n\tonInsertNode?: (node: CanvasNode) => void\n\tpasteInfo: PasteResult\n\trenamedIds: RenamedIds\n}) {\n\tconst { stylePresetNodes, primaryIntrinsicSize, breakpointOverrides } = layers\n\n\tconst {\n\t\tnewNodes,\n\t\tnodesToRemove,\n\t\tnewSelection,\n\t\tinsertionIndex,\n\t\tnewHomeNodeId,\n\t\tbreakpointVariantIds,\n\t\toverridesByReplicaId,\n\t} = pasteInfo\n\n\t// Track layer creation for Frames\n\tlet frameNodeCount = 0\n\tfor (const node of newNodes) {\n\t\tfor (const child of node.walk()) {\n\t\t\tif (isFrameNode(child)) {\n\t\t\t\tframeNodeCount++\n\t\t\t}\n\t\t}\n\t}\n\tif (frameNodeCount > 0) {\n\t\trecord(\"layout_frame\", { source: \"paste\", count: frameNodeCount })\n\t}\n\n\tfunction applyChanges() {\n\t\tapplyTreeChanges({\n\t\t\tengine,\n\t\t\tnewNodes,\n\t\t\tnodesToRemove,\n\t\t\tinsertionScopeNode,\n\t\t\tindexInParent: insertionIndex,\n\t\t\tnewSelection,\n\t\t\tinsertionGroundNodeId,\n\t\t\tcandidateHomeNodeId: newHomeNodeId,\n\t\t\tstylePresetNodes: stylePresetNodes,\n\t\t\tprimaryIntrinsicSize,\n\t\t\toriginalFrames: layers.originalFrames,\n\t\t\trenamedIds,\n\t\t\tbreakpointOverrides,\n\t\t\tshouldDetachTextStyles,\n\t\t\tshouldPasteTextStyles,\n\t\t\treusePresetWithSameId,\n\t\t\tsourceProjectId,\n\t\t\tsourcePageId: layers.webPagePropsForCopiedBreakpoint?.id,\n\t\t\tbreakpointVariantIds,\n\t\t\toverridesByReplicaId,\n\t\t\tselectAndCenter,\n\t\t\twebPagePathByWebPageId: layers.webPagePathByWebPageId,\n\t\t\tcloneWithScopeIds,\n\t\t\tonInsertNode,\n\t\t})\n\t}\n\n\tconst externalModuleIdentifiers = getExternalModuleIdentifiers(engine, layers.moduleData)\n\n\ttry {\n\t\tawait engine.scheduler.processWhenReadyAsync(() => {\n\t\t\tengine.beginUndoGroup()\n\t\t})\n\n\t\tif (externalModuleIdentifiers.length) {\n\t\t\t// Avoid extra toasts during AI generation\n\t\t\tif (engine.stores.chromeStore.aiGenerationInProgress) {\n\t\t\t\tawait engine.stores.modulesStore.addExternalModulesToProject(externalModuleIdentifiers, {\n\t\t\t\t\tonTreeUpdate: applyChanges,\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\tawait toastProgress(\n\t\t\t\t\t{\n\t\t\t\t\t\tkey: ToastKey.ClipboardLoadingExternalModules,\n\t\t\t\t\t\tprogress: {\n\t\t\t\t\t\t\tvariant: \"progress\",\n\t\t\t\t\t\t\tprimaryText: \"Loading assets.\",\n\t\t\t\t\t\t\tsecondaryText: \"Just a moment\u2026\",\n\t\t\t\t\t\t\tshowCloseButton: \"always\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror: {\n\t\t\t\t\t\t\tvariant: \"error\",\n\t\t\t\t\t\t\tprimaryText: \"Failed to load\",\n\t\t\t\t\t\t\tsecondaryText: \"assets.\",\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tasync () => {\n\t\t\t\t\t\tawait engine.stores.modulesStore.addExternalModulesToProject(externalModuleIdentifiers, {\n\t\t\t\t\t\t\tonTreeUpdate: applyChanges,\n\t\t\t\t\t\t})\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tengine.stores.modulesStore.trackExternalComponentInsert(\n\t\t\t\texternalModuleIdentifiers.map(identifier => identifier.value),\n\t\t\t\tExternalComponentInsertType.paste,\n\t\t\t)\n\t\t} else {\n\t\t\tawait engine.scheduler.processWhenReadyAsync(applyChanges)\n\t\t}\n\t} finally {\n\t\tconst vectorSetItems = newNodes.filter(isVectorSetItem)\n\t\tvoid engine.stores.codeGenerationStore.createVectorSet(vectorSetItems)\n\n\t\tawait engine.scheduler.processWhenReadyAsync(() => {\n\t\t\tengine.endUndoGroup()\n\t\t})\n\t}\n\n\t// If every top-level node of the paste tree is an overlay, show them after\n\t// pasting. Don't use `isFixedOrRelativeOverlayHere` because that may result\n\t// in showing fixed and relative overlays at the same time which we don't\n\t// want to do.\n\tif (newNodes.every(isOverlayNode) || newNodes.every(hasFloatingPosition)) {\n\t\tengine.scheduler.runBeforeNextFrame(() => {\n\t\t\tnewNodes.forEach(node =>\n\t\t\t\tengine.stores.overlayStore.showOverlay(engine.stores.selectionStore, node, node.parentid),\n\t\t\t)\n\t\t})\n\t}\n}\n\nfunction getOldIdByNewId(renamedIds: RenamedIds, newId: NodeID): NodeID {\n\tfor (const [oldId, value] of renamedIds.entries()) {\n\t\tif (value === newId) return getOldIdByNewId(renamedIds, oldId)\n\t}\n\treturn newId\n}\n\ninterface ApplyTreeChanges {\n\tengine: VekterEngine\n\tnewNodes: CanvasNode[]\n\tnodesToRemove: CanvasNode[]\n\tinsertionScopeNode: LoadedScopeNode\n\tindexInParent: number | undefined\n\tnewSelection: string[]\n\tinsertionGroundNodeId: MaybeNodeID\n\tcandidateHomeNodeId: MaybeNodeID\n\trenamedIds: RenamedIds\n\tstylePresetNodes?: SerializableMap\n\tprimaryIntrinsicSize?: Size\n\toriginalFrames: NodeIDToFrame\n\tbreakpointOverrides?: BreakpointOverrides\n\toverridesByReplicaId: Record<NodeID, ReplicaOverrides>\n\tshouldDetachTextStyles?: boolean\n\tshouldPasteTextStyles?: boolean\n\treusePresetWithSameId?: boolean\n\tsourceProjectId: string\n\tsourcePageId?: string\n\tbreakpointVariantIds?: Set<NodeID>\n\tselectAndCenter: boolean\n\twebPagePathByWebPageId?: Record<NodeID, string | undefined>\n\tcloneWithScopeIds?: boolean\n\tonInsertNode?: (node: CanvasNode) => void\n}\n\nfunction getNewTokenVariableString(value: unknown, oldToNewTokenVariableMap: Map<string, string>) {\n\tif (!isTokenCSSVariable(value)) return undefined\n\n\tconst tokenId = tokenIdFromCSSVariable(value)\n\tif (!tokenId) return undefined\n\n\treturn oldToNewTokenVariableMap.get(tokenId)\n}\n\nfunction getVariableIdUpdates(value: unknown, oldToNewTokenVariableMap: Map<string, string>) {\n\tif (isString(value)) {\n\t\treturn getNewTokenVariableString(value, oldToNewTokenVariableMap)\n\t} else if (isBoxShadow(value)) {\n\t\tconst newVar = getNewTokenVariableString(value.color, oldToNewTokenVariableMap)\n\t\tif (newVar) {\n\t\t\tvalue.color = newVar\n\t\t}\n\n\t\treturn value\n\t} else if (isGradient(value)) {\n\t\tconst stops = value.stops.map(colorStop => {\n\t\t\tconst newVar = getNewTokenVariableString(colorStop.value, oldToNewTokenVariableMap)\n\t\t\tif (newVar) {\n\t\t\t\treturn colorStop.merge({ value: newVar })\n\t\t\t}\n\n\t\t\treturn colorStop\n\t\t})\n\n\t\treturn value.updated({ stops })\n\t} else if (isArray(value)) {\n\t\tfor (const item of value) {\n\t\t\tgetVariableIdUpdates(item, oldToNewTokenVariableMap)\n\t\t}\n\n\t\treturn value\n\t}\n\n\treturn undefined\n}\n\nfunction resolveNodeColorTokens(clipboardNode: CanvasNode, oldToNewTokenVariableMap: Map<string, string>) {\n\tconst update: Partial<Record<keyof CanvasNode, unknown>> = {}\n\tlet hasAnyUpdate = false\n\tif (isRichTextNode(clipboardNode)) {\n\t\tclipboardNode.replaceColorTokenVariables(oldToNewTokenVariableMap)\n\t}\n\n\tlet key: keyof CanvasNode\n\tfor (key in clipboardNode) {\n\t\tif (key === \"name\") continue\n\n\t\tconst propValue = clipboardNode[key]\n\t\tconst propUpdates = getVariableIdUpdates(propValue, oldToNewTokenVariableMap)\n\t\tif (propUpdates) {\n\t\t\tupdate[key] = propUpdates\n\t\t\thasAnyUpdate = true\n\t\t}\n\t}\n\n\tif (hasAnyUpdate) {\n\t\tclipboardNode.set(update as Partial<CanvasNode>)\n\t}\n}\n\nfunction applyTreeChanges({\n\tengine,\n\tnewNodes,\n\tnodesToRemove,\n\tinsertionScopeNode,\n\tindexInParent,\n\tnewSelection,\n\tinsertionGroundNodeId,\n\tcandidateHomeNodeId,\n\trenamedIds,\n\tstylePresetNodes,\n\tprimaryIntrinsicSize,\n\toriginalFrames,\n\tbreakpointOverrides = [],\n\tshouldDetachTextStyles,\n\tshouldPasteTextStyles,\n\treusePresetWithSameId,\n\tsourceProjectId,\n\tsourcePageId,\n\tbreakpointVariantIds = new Set(),\n\toverridesByReplicaId,\n\tselectAndCenter,\n\twebPagePathByWebPageId,\n\tcloneWithScopeIds,\n\tonInsertNode,\n}: ApplyTreeChanges) {\n\tconst { tree } = engine\n\n\tconst { scopeStore, canvasStore, codeGenerationStore, selectionStore } = engine.stores\n\n\t// This method might get called after quite a bit of async work. We have to fetch the current\n\t// version of the current scope this work started from. If it no longer exists, we use the now\n\t// active scope.\n\tinsertionScopeNode = engine.tree.current(insertionScopeNode) ?? scopeStore.active\n\n\tconst richTextNodes: RichTextNode[] = []\n\n\tconst deserializedStylePresetNodes = stylePresetNodes\n\t\t? Object.values(stylePresetNodes).map(value => canvasNodeFromValue(value))\n\t\t: undefined\n\n\tconst deserializedTextStylePresetNodes = deserializedStylePresetNodes?.filter(isTextStylePresetNode)\n\tconst deserializedLinkStylePresetNodes = deserializedStylePresetNodes?.filter(isLinkStylePresetNode)\n\tconst deserializedInlineCodeStylePresetNodes = deserializedStylePresetNodes?.filter(isInlineCodeStylePresetNode)\n\n\tlet targetPageId = scopeStore.active.id\n\tlet includesWebPageNode = false\n\tlet pagePartCount = 0\n\n\tconst allOverridesByReplicaId = { ...overridesByReplicaId }\n\n\t// Before inserting new nodes, remove the ones we wanna delete first\n\tconst nodesToRemoveWithoutDescendants = tree.withoutDescendants(nodesToRemove)\n\tfor (const node of nodesToRemoveWithoutDescendants) {\n\t\ttree.removeNode(node)\n\t}\n\n\t// We need to revive any values that could be classes inside of the\n\t// breakpoint overrides\n\tconst sourceBreakpointOverrides = reviveBreakpointOverrides(breakpointOverrides)\n\n\tfor (const node of newNodes) {\n\t\tassert(!isTextStylePresetNode(node), \"Should not paste TextStylePresetNodes\")\n\t\tassert(!isLinkStylePresetNode(node), \"Should not paste LinkStylePresetNodes\")\n\n\t\tif (isWebPageNode(node)) {\n\t\t\tincludesWebPageNode = true\n\t\t\tassert(node.isLoaded(), \"WebPageNode should be fully loaded\")\n\t\t\tconst primary = node.loaded.children?.find(n => n.id === node.baseVariantId)\n\t\t\tassert(primary && isPrimaryVariant(primary), \"should be primary variant\")\n\t\t\t// A CMS page's page path will always be unique because it contains the path variable. Use the name here so\n\t\t\t// we don't paste CMS page with duplicate paths.\n\t\t\tconst preferredPath = webPagePathByWebPageId?.[getOldIdByNewId(renamedIds, node.id)]\n\t\t\tconst newNode = cloneScopeNodeWithVariants(engine, node, primary, \"unlink\", {\n\t\t\t\tinsertionIndex: engine.tree.root.children.findIndex(child => child.id === insertionScopeNode.id) + 1,\n\t\t\t\tintrinsicSize: primaryIntrinsicSize,\n\t\t\t\tenterIsolation: false,\n\t\t\t\trenamedIds,\n\t\t\t\ttextStylePresets: deserializedTextStylePresetNodes,\n\t\t\t\tlinkStylePresets: deserializedLinkStylePresetNodes,\n\t\t\t\tinlineCodeStylePresets: deserializedInlineCodeStylePresetNodes,\n\t\t\t\tpastedPresetMap: new Map(),\n\t\t\t\tshouldPasteTextStyles,\n\t\t\t\treusePresetWithSameId,\n\t\t\t\tpreferredName: preferredPath,\n\t\t\t})\n\n\t\t\ttargetPageId = newNode.id\n\n\t\t\tif (!isKitPageNode(insertionScopeNode) && isEmptyWebPage(insertionScopeNode)) {\n\t\t\t\treplaceWebPage(engine, insertionScopeNode, newNode)\n\t\t\t}\n\n\t\t\tscopeStore.select(newNode.id, { keepHistory: false })\n\t\t\tcontinue\n\t\t}\n\n\t\tif (isLayoutTemplateNode(node) || isSmartComponentNode(node)) {\n\t\t\tassert(node.isLoaded(), node.__class + \" should be fully loaded\")\n\t\t\tconst primary = node.loaded.children?.find(n => n.id === node.baseVariantId)\n\t\t\tassert(primary && isPrimaryVariant(primary), \"should be primary variant\")\n\n\t\t\tconst newNode = cloneScopeNodeWithVariants(engine, node, primary, \"unlink\", {\n\t\t\t\tintrinsicSize: primaryIntrinsicSize,\n\t\t\t\tenterIsolation: false,\n\t\t\t\trenamedIds,\n\t\t\t\ttextStylePresets: deserializedTextStylePresetNodes,\n\t\t\t\tlinkStylePresets: deserializedLinkStylePresetNodes,\n\t\t\t\tinlineCodeStylePresets: deserializedInlineCodeStylePresetNodes,\n\t\t\t\tshouldPasteTextStyles,\n\t\t\t\treusePresetWithSameId,\n\t\t\t\tcloneWithScopeIds,\n\t\t\t})\n\n\t\t\tonInsertNode?.(newNode)\n\t\t\tcontinue\n\t\t}\n\n\t\tif (isCollectionNode(node)) {\n\t\t\tconst contentManagementNode = createContentManagementNodeIfNeeded(engine.tree)\n\t\t\tscopeStore.insertNode(node, contentManagementNode.id)\n\t\t\tscopeStore.select(contentManagementNode.id, { keepHistory: false })\n\t\t\tselectionStore.set(node.id)\n\t\t\tcontinue\n\t\t}\n\n\t\tfor (const n of node.walk()) {\n\t\t\tif (isRichTextNode(n)) {\n\t\t\t\trichTextNodes.push(n)\n\t\t\t}\n\t\t}\n\n\t\tscopeStore.insertNode(node, node.parentid, indexInParent, undefined, insertionScopeNode.id)\n\n\t\tif (isLayoutSection(tree, node)) {\n\t\t\tpagePartCount++\n\t\t}\n\n\t\tconst parentNode = tree.get(node.parentid)\n\t\tif (!parentNode) continue\n\n\t\tconst insertionRect = originalFrames[getOldIdByNewId(renamedIds, node.id)] ?? tree.getRect(node)\n\t\tautoConvertParentToStackIfNeeded(engine, parentNode, node, insertionRect)\n\t\tmakePrimaryBreakpointAutoSizingIfNeeded(engine, parentNode, node, insertionRect)\n\n\t\tconst masterNode = getMasterAncestor(parentNode)\n\t\tif (!masterNode || !isBreakpointVariant(masterNode)) {\n\t\t\tonInsertNode?.(node)\n\t\t\tcontinue\n\t\t}\n\n\t\tconst breakpointNodes = tree.getNodesWithTrait(masterNode.cache.replicaInstances ?? [], isReplicaWithSize)\n\t\tconst closestBreakpointOverrides = collectClosestBreakpointOverridesFromSourceDocument(\n\t\t\ttree,\n\t\t\tnode,\n\t\t\tbreakpointNodes,\n\t\t\tsourceBreakpointOverrides,\n\t\t\trenamedIds,\n\t\t)\n\n\t\t// Merge the overrides, we will update them in one go at the end\n\t\tfor (const [breakpointId, nodeOverridesInBreakpoint] of Object.entries(closestBreakpointOverrides)) {\n\t\t\tconst pendingOverrides = allOverridesByReplicaId[breakpointId]\n\t\t\tif (pendingOverrides) {\n\t\t\t\tallOverridesByReplicaId[breakpointId] = mergeOverrides(pendingOverrides, nodeOverridesInBreakpoint)\n\t\t\t} else {\n\t\t\t\tallOverridesByReplicaId[breakpointId] = nodeOverridesInBreakpoint\n\t\t\t}\n\t\t}\n\n\t\tonInsertNode?.(node)\n\t}\n\n\t// Apply all the replica overrides we collected when pasting.\n\tfor (const [replicaId, overrides] of Object.entries(allOverridesByReplicaId)) {\n\t\tconst replica = tree.get(replicaId)\n\t\tif (!replica || !isReplica(replica)) break\n\t\tupdateReplicaOverrides(tree, replica, overrides)\n\t}\n\n\tconst remappedBreakpointVariantIds = new Set<NodeID>()\n\n\tfor (const oldBreakpointVariantId of breakpointVariantIds) {\n\t\tconst newBreakpointVariantId = renamedIds.get(oldBreakpointVariantId)\n\n\t\tif (newBreakpointVariantId) {\n\t\t\tremappedBreakpointVariantIds.add(newBreakpointVariantId)\n\t\t}\n\t}\n\n\t// Paste `TextStylePresetNodes`, `LinkStylePresetNodes`, and\n\t// `InlineCodeStylePresetNodes` if available.\n\tconst pastedTextStylePresetMap = new Map<string, TextStylePresetNode>()\n\tconst pastedLinkStylePresetMap = new Map<string, LinkStylePresetNode>()\n\tconst pastedInlineCodeStylePresetMap = new Map<string, InlineCodeStylePresetNode>()\n\n\tfor (const node of richTextNodes) {\n\t\tpasteTextStylePresets({\n\t\t\tengine,\n\t\t\tnode,\n\t\t\tstylePresetNodes: deserializedTextStylePresetNodes,\n\t\t\tpastedPresetMap: pastedTextStylePresetMap,\n\t\t\tshouldDetachTextStyles,\n\t\t\tbreakpointVariantIds: remappedBreakpointVariantIds,\n\t\t\tshouldCreateNewPresets: shouldPasteTextStyles,\n\t\t\treusePresetWithSameId,\n\t\t})\n\n\t\tpasteLinkStylePresets({\n\t\t\tengine,\n\t\t\tnode,\n\t\t\tstylePresetNodes: deserializedLinkStylePresetNodes,\n\t\t\tpastedPresetMap: pastedLinkStylePresetMap,\n\t\t})\n\n\t\tpasteInlineCodeStylePresets({\n\t\t\tengine,\n\t\t\tnode,\n\t\t\tstylePresetNodes: deserializedInlineCodeStylePresetNodes,\n\t\t\tpastedPresetMap: pastedInlineCodeStylePresetMap,\n\t\t})\n\t}\n\n\t// Only generate code for unique presets (outside of the loops above for richTextNode * variant)\n\tfor (const clonedPreset of pastedTextStylePresetMap.values()) {\n\t\tif (isReplicaOrReplicaChild(clonedPreset)) continue\n\t\tcodeGenerationStore.createModuleFromComponentSource(clonedPreset).catch(unhandledError)\n\t}\n\tfor (const clonedPreset of pastedLinkStylePresetMap.values()) {\n\t\tif (isReplicaOrReplicaChild(clonedPreset)) continue\n\t\tcodeGenerationStore.createModuleFromComponentSource(clonedPreset).catch(unhandledError)\n\t}\n\tfor (const clonedPreset of pastedInlineCodeStylePresetMap.values()) {\n\t\tif (isReplicaOrReplicaChild(clonedPreset)) continue\n\t\tcodeGenerationStore.createModuleFromComponentSource(clonedPreset).catch(unhandledError)\n\t}\n\n\tdetachInvalidVariants(engine, insertionScopeNode, newNodes)\n\n\tif (candidateHomeNodeId && isCanvasPageNode(insertionScopeNode)) {\n\t\tengine.tree.current(insertionScopeNode)?.set({ homeNodeId: candidateHomeNodeId })\n\t}\n\n\tif (selectAndCenter) {\n\t\tselectionStore.set(newSelection, { sticky: true, switchToLayers: true, switchToProperties: true })\n\n\t\tconst activeScopeId = engine.stores.scopeStore.activeId\n\n\t\t// we need to ensure that bounding boxes,\n\t\t// and position are updated before we scroll to the new nodes, if we don't - the scroll will be off\n\t\tengine.scheduler.runWhenIdle(() => {\n\t\t\tif (activeScopeId !== engine.stores.scopeStore.activeId) return\n\n\t\t\tlet rectToScrollTo: Rect | null = null\n\n\t\t\t// The only case where newSelection !== newNodes is when pasting in\n\t\t\t// a replica variant: the new nodes are inserted into the primary,\n\t\t\t// but the selection is set to the replica nodes. In this case or\n\t\t\t// if we're inserting a webpage the cloned replica nodes are not\n\t\t\t// in the tree yet, we scroll to the active screen instead.\n\t\t\tconst isPastingInReplicaVariants = newSelection[0] !== newNodes[0]?.id\n\t\t\tconst shouldUseScreenBBox = isPastingInReplicaVariants || includesWebPageNode\n\t\t\tif (shouldUseScreenBBox) {\n\t\t\t\tconst screen = insertionGroundNodeId ? engine.tree.getNode(insertionGroundNodeId) : null\n\t\t\t\trectToScrollTo = screen ? getBoundingFrameForNodes(engine.tree, [screen]) : null\n\t\t\t} else {\n\t\t\t\tconst existingNodes = engine.tree.getNodes(newNodes.map(n => n.id))\n\t\t\t\trectToScrollTo = existingNodes.length ? getBoundingFrameForNodes(engine.tree, existingNodes) : null\n\t\t\t}\n\n\t\t\tconst canvasVisibleRect = canvasStore.getCanvasVisibleRectTakingOverlaysIntoAccount()\n\t\t\tif (rectToScrollTo && !Rect.intersects(rectToScrollTo, canvasVisibleRect)) {\n\t\t\t\tcanvasStore.scrollToCenter(Rect.center(rectToScrollTo))\n\t\t\t}\n\t\t})\n\t}\n\n\tengine.tree.didNonLinearMove(engine.componentLoader)\n\n\tif (includesWebPageNode) {\n\t\trecord(\"site_page_paste\", {\n\t\t\tsourceProjectId,\n\t\t\tsourcePageId,\n\t\t\ttargetPageId,\n\t\t})\n\t}\n\n\tif (pagePartCount > 0) {\n\t\trecord(\"site_page_part_paste\", {\n\t\t\tsourceProjectId,\n\t\t\tsourcePageId,\n\t\t\ttargetPageId,\n\t\t\tpartCount: pagePartCount,\n\t\t})\n\t}\n}\n\nfunction collectClosestBreakpointOverridesFromSourceDocument(\n\ttree: CanvasTree,\n\tnode: CanvasNode,\n\treplicaBreakpoints: (CanvasNode & IsReplica & WithSize)[],\n\tsourceBreakpointOverrides: BreakpointOverrides,\n\trenamedIds: RenamedIds,\n): Record<NodeID, ReplicaOverrides> {\n\tconst overridesByBreakpointId: Record<NodeID, ReplicaOverrides> = {}\n\tfor (const breakpointNode of replicaBreakpoints) {\n\t\tTemplateHelper.replicaWithChanges(tree, breakpointNode)\n\t\tlet smallestDelta = Number.POSITIVE_INFINITY\n\t\tlet closestBreakpointOverrides: ReplicaOverrides | undefined\n\t\t// Find the overrides from the source document that are the closest\n\t\t// to the width of the breakpoint of the target document.\n\t\tfor (const [width, overrides] of sourceBreakpointOverrides) {\n\t\t\tconst delta = Math.abs(breakpointNode.width - width)\n\n\t\t\tif (delta < smallestDelta) {\n\t\t\t\tsmallestDelta = delta\n\t\t\t\tclosestBreakpointOverrides = overrides\n\t\t\t}\n\t\t}\n\n\t\tif (!closestBreakpointOverrides) continue\n\n\t\tconst remappedClosestBreakpointOverrdes = remapOverrides(closestBreakpointOverrides, renamedIds, true)\n\t\t// Collect subtree overrides\n\t\tfor (const child of node.walk()) {\n\t\t\tconst overrides = remappedClosestBreakpointOverrdes[child.id]\n\t\t\tif (!overrides) continue\n\n\t\t\tconst breakpointOverrides = overridesByBreakpointId[breakpointNode.id] ?? {}\n\t\t\tbreakpointOverrides[child.id] = overrides\n\t\t\toverridesByBreakpointId[breakpointNode.id] = breakpointOverrides\n\t\t}\n\t}\n\n\treturn overridesByBreakpointId\n}\n\nexport interface PasteResult {\n\tnewNodes: CanvasNode[]\n\tnodesToRemove: CanvasNode[]\n\tnewSelection: NodeID[]\n\tinsertionIndex: number | undefined\n\tnewHomeNodeId: NodeID | undefined\n\tbreakpointVariantIds?: Set<NodeID>\n\toverridesByReplicaId: Record<NodeID, ReplicaOverrides>\n}\n\nexport async function pasteClipboardLayers(\n\tengine: VekterEngine,\n\tlayers: ClipboardLayers,\n\tactiveScope: LoadedScopeNode,\n\tposition: Point,\n\tselection: NodeID[],\n\tactiveScreen: MaybeNodeID,\n\tfromSameProject: boolean,\n\tsourceProjectId: string,\n\ttreeIndex?: TreeIndex,\n\trenamedIds: RenamedIds = getRenamedIdsFromClipboardLayers(layers),\n\treplace?: boolean,\n\tinsertIndex?: number,\n): Promise<PasteResult | null> {\n\tconst copyTree = CanvasTree.fromJS(layers.tree, engine.componentLoader)\n\tassert(copyTree, \"copyTree must exist\")\n\t// While technically these layers were loaded from json data, we don't want to track them as\n\t// such. Notice this is only used for debugging purposes.\n\tfor (const node of copyTree.root.walk()) {\n\t\tnode.cache.loadedFromDocumentJson = false\n\t}\n\n\treturn pasteTree(\n\t\tengine,\n\t\tcopyTree,\n\t\tlayers,\n\t\tactiveScope,\n\t\tposition,\n\t\tselection,\n\t\tactiveScreen,\n\t\tfromSameProject,\n\t\tsourceProjectId,\n\t\ttreeIndex,\n\t\trenamedIds,\n\t\treplace,\n\t\tinsertIndex,\n\t)\n}\n\nfunction getGroundNodes(tree: CanvasTree) {\n\tconst groundNodes: CanvasNode[] = []\n\n\tfor (const node of tree.root.children) {\n\t\tif (isHiddenMaster(node)) continue\n\t\tif (node instanceof ScopeNode) {\n\t\t\tgroundNodes.push(...node.children)\n\t\t} else {\n\t\t\tgroundNodes.push(node)\n\t\t}\n\t}\n\n\treturn groundNodes\n}\n\nfunction findOffset(center: Point, fromTree: CanvasTree, originalFrames: NodeIDToFrame): Point {\n\tconst groundNodes = getGroundNodes(fromTree)\n\tconst originalFrameKeys = Object.keys(originalFrames)\n\tlet boundingBox: Rect\n\n\tif (groundNodes.length === originalFrameKeys.length) {\n\t\t// Use original frames\n\t\tconst frames = Object.values(originalFrames)\n\t\tboundingBox = Rect.merge(...frames)\n\t} else {\n\t\t// Use bounding box from tree\n\t\tboundingBox = Rect.merge(\n\t\t\t...groundNodes.map(node => {\n\t\t\t\treturn fromTree.getRect(node)\n\t\t\t}),\n\t\t)\n\t}\n\n\tconst relativeCenter = Point(boundingBox.width / 2, boundingBox.height / 2)\n\treturn Point.pixelAligned(Point.subtract(Point.subtract(center, relativeCenter), boundingBox))\n}\n\nfunction createWebPageInCopyTreeIfCopyingPrimaryBreakpoint(\n\tcopyTree: CanvasTree,\n\tfromSameProject: boolean,\n\tactiveScope: LoadedScopeNode,\n\twebPageProps?: ClipboardLayers[\"webPagePropsForCopiedBreakpoint\"],\n) {\n\t// We always paste breakpoints as detached frames in a design page.\n\tif (isDesignPageNode(activeScope)) return\n\n\tconst canPasteWebPage = !fromSameProject || isEmptyWebPage(activeScope)\n\tif (!canPasteWebPage) return\n\n\tconst primaryBreakpointNode = copyTree.rootAtStart.children.find(isPrimaryBreakpointVariant)\n\tif (!primaryBreakpointNode) return\n\n\tconst newWebPageNode = copyTree.insertNode(\n\t\tnew WebPageNode({\n\t\t\t...webPageProps,\n\t\t\tbaseVariantId: primaryBreakpointNode.id,\n\t\t}),\n\t)\n\n\tfor (const node of copyTree.rootAtStart.children) {\n\t\tif (node.id === newWebPageNode.id) continue\n\t\tif (isCollectionNode(node)) continue\n\t\tcopyTree.moveNode(node, newWebPageNode.id)\n\t}\n}\n\nfunction applyPositionProps(from: CanvasNode, to: CanvasNode): void {\n\tif (withPosition(from) && withPosition(to)) {\n\t\tto.set({ x: from.x, y: from.y })\n\t}\n\n\tif (isPinnable(from) && isPinnable(to)) {\n\t\tto.set(from.constraintValues())\n\t}\n}\n\nfunction prepareReplaceOriginalNodeWith(\n\tcomponentLoader: ComponentLoader,\n\tcopyTree: CanvasTree,\n\treplacement: CanvasNode,\n\ttree: CanvasTree,\n\tnodeToReplace: CanvasNode,\n\trenamedIds: RenamedIds,\n): { copyTree: CanvasTree; parentId: MaybeNodeID; insertionIndex: number; nodesToRemove: CanvasNode[] } {\n\tassert(!nodeToReplace.originalid, \"A replica node cannot be replaced.\")\n\tassert(!replacement.originalid, \"Cannot replace an original node with a replica node.\")\n\n\t// When replacing a primary node:\n\t// 1. Make a copy reusing the id of the node to replace to swap the replacement in the copy tree.\n\tconst replacementClone = replacement.cloneWithCallback(node => {\n\t\t// The replacement might have been renamed when copying, so we want to get the old id before renamed, which is\n\t\t// the same id as the one in the latest (nodeToReplace).\n\t\tconst oldId = getOldIdByNewId(renamedIds, node.id) ?? node.id\n\t\treturn { id: oldId }\n\t})\n\n\t// 2. Also copy over some layout props to keep the replacement in the same place.\n\tapplyPositionProps(nodeToReplace, replacementClone)\n\n\tconst position = copyTree.getIndex(replacement)\n\tcopyTree.removeNode(replacement)\n\tcopyTree.insertNode(replacementClone, replacement.parentid, position)\n\n\t// 3. Reuse the same parentId and insertionIndex of the replaced node\n\tconst parentId = nodeToReplace.parentid\n\tconst insertionIndex = tree.getIndex(nodeToReplace)\n\n\t// 4. Mark the replaceable node (as well as its descendants) as removable in the current tree, so we leave an empty\n\t// slot for the copied nodes.\n\t// @FIXME: removing the node would reset any stack order overrides in the replicas.\n\tconst nodesToRemove: CanvasNode[] = []\n\tfor (const node of nodeToReplace.walk()) {\n\t\tnodesToRemove.push(node)\n\t}\n\n\t// ensure the copy tree has the latest ids and props for any edits afterwards\n\treturn { copyTree: copyTree.commit(componentLoader), parentId, insertionIndex, nodesToRemove }\n}\n\n// When paste-to-replace a matching replica node, we don't actually replace nodes (because we can't mutate the\n// hierarchy of the subtree), instead, we move over the overrides to make the node look visually identical.\nfunction replaceReplicaNodeWith(\n\tengine: VekterEngine,\n\tcopyTree: CanvasTree,\n\ttree: CanvasTree,\n\tnodeToReplace: CanvasNode & IsReplicaOrReplicaChild,\n\tcopiedReplicaInfo: ReplicaInfo,\n\trenamedIds: RenamedIds,\n) {\n\tconst replica = TemplateHelper.getReplicaForTemplateNode(tree, nodeToReplace)\n\tassert(replica, `Failed to replace replica node: cannot find replica of ${nodeToReplace.id}`)\n\tassert(\n\t\tcopiedReplicaInfo.master === replica.originalid,\n\t\t`Failed to replace replica node: node to replace and replacement have different original ids: ${nodeToReplace.originalid}, ${copiedReplicaInfo.master}`,\n\t)\n\n\t// Go over the children, move over the compatible properties\n\tfor (const node of nodeToReplace.walk()) {\n\t\tassert(\n\t\t\tnode.originalid,\n\t\t\t`Failed to replace replica node: replica descendant ${node.id} does not have an original id.`,\n\t\t)\n\t\tconst replacementId = renamedIds.get(node.originalid)\n\t\tassert(\n\t\t\treplacementId,\n\t\t\t`Failed to replace replica node: replica node should have their id renamed on copy: ${node.originalid}`,\n\t\t)\n\t\tconst replacement = copyTree.get(replacementId)\n\t\tassert(replacement, `Failed to replace replica node: replacement does not exist ${replacementId}`)\n\n\t\t// Get compatible styles\n\t\tconst compatibleProperties: Record<string, unknown> = getCompatibleNodeProperties(\n\t\t\ttree,\n\t\t\tengine.componentLoader,\n\t\t\treplacement,\n\t\t\tnodeToReplace,\n\t\t)\n\t\t// Update the rest of the overrides if not in the compatible properties\n\t\tconst overrides = copiedReplicaInfo.overrides[node.originalid]\n\t\tif (overrides) {\n\t\t\tfor (const [key, value] of Object.entries(overrides)) {\n\t\t\t\tif (key in compatibleProperties) continue\n\t\t\t\tcompatibleProperties[key] = value\n\t\t\t}\n\t\t}\n\t\tengine.scheduler.process(() => {\n\t\t\tnode.set(compatibleProperties)\n\t\t})\n\t}\n}\n\n/**\n * Some nodes require to be fully loaded before\n * nodes can be pased into them.\n *\n * @param parent Parent node that is pasted into\n * @param tree\n * @returns\n */\nasync function preloadShallowScopes(parent: CanvasNode, tree: CanvasTree) {\n\tconst scopesToLoad = new Set<AnyScopeNode>()\n\n\t/**\n\t * If a component (not instance that is on the page) is not\n\t * loaded yet, copying nodes into component can result\n\t * in undefined behavior because the copy logic required\n\t * a property from the component.\n\t *\n\t * One example of this is overlay. We want to create variables\n\t * in the component when overlay is copied to a component. If\n\t * component is not loaded, it would fail to paste the node\n\t * into the component.\n\t */\n\tif (isCodeComponentNode(parent)) {\n\t\tconst smartComponentNode = getSmartComponentOrWebPageForCodeComponent(tree, parent)\n\t\tif (smartComponentNode && !smartComponentNode.loaded) {\n\t\t\tscopesToLoad.add(smartComponentNode)\n\t\t}\n\t}\n\n\treturn tree.loadScopes(Array.from(scopesToLoad))\n}\n\nfunction prepareTokenNodes(\n\ttree: CanvasTree,\n\tlayers: ClipboardLayers,\n\trenamedIds: RenamedIds,\n\tpreparedNodes: CanvasNode[],\n) {\n\tconst oldToNewTokensMap = new Map<string, string>()\n\tif (!layers.colorTokenNodes) {\n\t\treturn { oldToNewTokensMap }\n\t}\n\n\tconst tokenListInRealTree = tree.get(\"colorStyles\")\n\tif (!tokenListInRealTree) {\n\t\treturn { oldToNewTokensMap }\n\t}\n\n\tconst deserializedColorTokenNodes = Object.values(layers.colorTokenNodes).map(node =>\n\t\tcanvasNodeFromValue(node, tokenListInRealTree.id),\n\t)\n\n\tfor (const token of deserializedColorTokenNodes) {\n\t\t// If current token is not a color style token, skip.\n\t\tif (!isColorStyleTokenNode(token)) continue\n\n\t\tconst tokenInTree = tree.get(token.id)\n\t\tif (!tokenInTree) {\n\t\t\t// If the token is not in the tree, clone it with the same id and add it.\n\t\t\tconst clonedNode = token.clone({ id: token.id })\n\t\t\tpreparedNodes.push(clonedNode)\n\t\t\tcontinue\n\t\t}\n\n\t\t// If a color style token of this ID is already in the tree,\n\t\t// and the color values are the same, skip.\n\t\tif (isColorStyleTokenNode(tokenInTree) && tokenInTree.light === token.light && tokenInTree.dark === token.dark) {\n\t\t\tcontinue\n\t\t}\n\n\t\tconst newId = renamedIds.get(token.id)\n\t\tif (!newId) continue\n\n\t\t// If the remapped color token node is already in the tree, then remap the token to the new id.\n\t\tconst clonedNodeMatchingRenamedTokenId = tree.get(newId)\n\t\tif (clonedNodeMatchingRenamedTokenId && isColorStyleTokenNode(clonedNodeMatchingRenamedTokenId)) {\n\t\t\toldToNewTokensMap.set(token.id, tokenToCSSVariable(clonedNodeMatchingRenamedTokenId))\n\t\t\tcontinue\n\t\t}\n\n\t\t// If the color values are not the same, there is a remapped id, and it's not already in the tree,\n\t\t// then we re-create the color token with a new id.\n\t\tconst clonedNode = token.clone({ id: newId })\n\t\tpreparedNodes.push(clonedNode)\n\t\tassert(isColorStyleTokenNode(clonedNode))\n\t\toldToNewTokensMap.set(token.id, tokenToCSSVariable(clonedNode))\n\t}\n\n\treturn { oldToNewTokensMap }\n}\n\nexport async function pasteTree(\n\tengine: VekterEngine,\n\tcopyTree: CanvasTree,\n\tlayers: ClipboardLayers,\n\tactiveScope: LoadedScopeNode,\n\tposition: Point,\n\tselection: readonly NodeID[],\n\tactiveScreen: MaybeNodeID,\n\tfromSameProject: boolean,\n\tsourceProjectId: string | undefined,\n\ttreeIndex?: TreeIndex,\n\trenamedIds: RenamedIds = getRenamedIdsFromClipboardLayers(layers),\n\treplace?: boolean,\n\tinsertIndex?: number,\n): Promise<PasteResult | null> {\n\tif (copyTree === undefined || layers.originalFrames === undefined) {\n\t\treturn null\n\t}\n\n\tconst { componentLoader } = engine\n\tconst { modulesStore, treeStore, selectionStore, modalStore } = engine.stores\n\n\tconst replacementPair = await promptToReplaceSelectedNodeIfMatched(selectionStore, modalStore, copyTree, layers)\n\tif (replacementPair === \"abort\") return null\n\n\t// Track history copy-pasting\n\tif (layers.historyData) {\n\t\tconst size = copyTree.size() - 1\n\t\tconst behind = treeStore.remoteTreeVersion - layers.historyData.treeVersion\n\t\trecord(\"historic_document_paste\", {\n\t\t\tbehind: fromSameProject ? behind : 0,\n\t\t\tsize,\n\t\t\tfromSameProject,\n\t\t\treplace: !!replacementPair,\n\t\t})\n\t}\n\n\t// The tree might have moved on while we're awaiting the async call (can happen due to remote edits, for example),\n\t// therefore we need to get it after the call.\n\tconst tree = treeStore.tree\n\n\tcreateWebPageInCopyTreeIfCopyingPrimaryBreakpoint(\n\t\tcopyTree,\n\t\tfromSameProject,\n\t\tactiveScope,\n\t\tlayers.webPagePropsForCopiedBreakpoint,\n\t)\n\n\tlet parentId: MaybeNodeID = null\n\tlet insertionIndex: number | undefined = undefined\n\tlet nodesToRemove: CanvasNode[] = []\n\tconst overridesByReplicaId: Record<NodeID, ReplicaOverrides> = {}\n\n\tif (replacementPair) {\n\t\tconst { nodeToReplace, replacement } = replacementPair\n\t\tif (\n\t\t\tisReplicaOrReplicaChild(nodeToReplace) &&\n\t\t\tnodeToReplace.originalid === layers.historyData?.originalId &&\n\t\t\tlayers.historyData?.replicaInfo\n\t\t) {\n\t\t\treplaceReplicaNodeWith(engine, copyTree, tree, nodeToReplace, layers.historyData.replicaInfo, renamedIds)\n\t\t\treturn null\n\t\t}\n\n\t\tif (!nodeToReplace.originalid) {\n\t\t\tconst result = prepareReplaceOriginalNodeWith(\n\t\t\t\tengine.componentLoader,\n\t\t\t\tcopyTree,\n\t\t\t\treplacement,\n\t\t\t\ttree,\n\t\t\t\tnodeToReplace,\n\t\t\t\trenamedIds,\n\t\t\t)\n\t\t\tcopyTree = result.copyTree\n\t\t\tparentId = result.parentId\n\t\t\tinsertionIndex = result.insertionIndex\n\t\t\tnodesToRemove = result.nodesToRemove ?? []\n\t\t}\n\t} else {\n\t\tconst groundNodesToPaste = getGroundNodes(copyTree)\n\t\tconst selectionAsParent = getIdIfSelectionCanBeParent(\n\t\t\tengine.componentLoader,\n\t\t\tgroundNodesToPaste,\n\t\t\ttree,\n\t\t\tactiveScope,\n\t\t\tselection,\n\t\t\tactiveScreen,\n\t\t)\n\t\tparentId = selectionAsParent.maybeParentId\n\t\tinsertionIndex = insertIndex ?? selectionAsParent.insertionIndex\n\t}\n\n\tconst parent = tree.get(parentId)\n\n\tcopyTree = pasteModules(engine.componentLoader, modulesStore, copyTree, layers.moduleData)\n\n\t// Support for edit-while-loading.\n\tconst loader = tree.getService(\"loader\")\n\tlet loadingNodeIds: Set<string> | undefined = undefined\n\tif (loader) {\n\t\t// Make sure all referenced smart components are loaded.\n\t\tif (parent) {\n\t\t\tawait preloadShallowScopes(parent, copyTree)\n\t\t}\n\n\t\t// Make sure the CMS data has loaded.\n\t\tawait loader.prioritizeLoadingScope(CONTENT_MANAGEMENT_ID)\n\t\t// And we know all yet-to-be-loaded node ids.\n\t\tloadingNodeIds = await loader.nodeIdsToLoad()\n\t}\n\n\tconst { nodesToInsert, offset, homeNodeId } = await engine.scheduler.processWhenReadyAsync(() => {\n\t\treturn processCopyTree({\n\t\t\tengine,\n\t\t\tcopyTree,\n\t\t\tlayers,\n\t\t\tactiveScope,\n\t\t\tparent,\n\t\t\tposition,\n\t\t\tselection,\n\t\t\ttreeIndex,\n\t\t\treplace,\n\t\t\trenamedIds,\n\t\t})\n\t})\n\n\tconst newSelection: NodeID[] = []\n\tconst preparedNodes: CanvasNode[] = []\n\n\tconst inOverlay = !!parent && (isFixedOrRelativeOverlay(parent) || nodeIsInOverlay(parent))\n\n\t// In the case where we haven't pasted any overlay nodes due to them being unsupported, don't\n\t// change the selection.\n\tif (nodesToInsert.length === 0 && copyTree.rootAtStart.children.every(isOverlayNode)) {\n\t\tnewSelection.push(...selection)\n\t}\n\n\tconst breakpointVariantIds = new Set<NodeID>()\n\n\tconst variableValuesByProviderMap = new Map<ProviderID, EagerVariableProviderMap<unknown>>()\n\tif (layers.variableValueInfo) {\n\t\tfor (const [providerId, variableValueEntries] of layers.variableValueInfo.variableValuesByProvider) {\n\t\t\tvariableValuesByProviderMap.set(providerId, new EagerVariableProviderMap(variableValueEntries))\n\t\t}\n\t}\n\n\t// Delete all resolved variable values that are in scope of the inserted node. Because otherwise\n\t// they would be resolved unnecessarily.\n\tconst insertParent = parent ?? engine.stores.scopeStore.active\n\tconst insertAncestors = [insertParent, ...insertParent.ancestors()]\n\tfor (let i = 0; i < insertAncestors.length; i++) {\n\t\tconst insertAncestor = insertAncestors[i]\n\t\tconst insertAncestorChild = insertAncestors[i - 1]\n\t\tif (!withVariableProvider(insertAncestor)) continue\n\t\tif (!insertAncestor.getVariableSourceIdentifier()) continue\n\n\t\tconst resolvedVariableValuesByScope = variableValuesByProviderMap.get(insertAncestor.id)\n\t\tif (!resolvedVariableValuesByScope) continue\n\n\t\tconst variableValuesInScope = insertAncestor.getProvidedValueMap(\n\t\t\ttree,\n\t\t\tinsertAncestorChild,\n\t\t\tengine.componentLoader,\n\t\t\ttreeStore.sandboxRepeaterData,\n\t\t\tengine.componentLoader.activeBundleHash,\n\t\t)\n\n\t\tif (!variableValuesInScope) continue\n\n\t\t// Remove all variable values that are in the current scope.\n\t\tfor (const [variableId] of variableValuesInScope) {\n\t\t\tresolvedVariableValuesByScope.delete(variableId)\n\t\t}\n\n\t\t// No variables to provide so let's delete the entry from the map.\n\t\tif (resolvedVariableValuesByScope.size === 0) {\n\t\t\tvariableValuesByProviderMap.delete(insertAncestor.id)\n\t\t}\n\t}\n\n\tconst { oldToNewTokensMap } = prepareTokenNodes(tree, layers, renamedIds, preparedNodes)\n\n\tconst fromHistory = layers.historyData !== undefined\n\n\t// We need to update the nodes in two passes. In the first pass we create new identifiers for\n\t// nodes which are already on the canvas.\n\tnodesToInsert.forEach(node => {\n\t\tif (inOverlay && isFixedOrRelativeOverlay(node)) return\n\n\t\tconst {\n\t\t\tpreparedNode,\n\t\t\tidToSelect,\n\t\t\toverridesByReplicaId: nodeOverridesByReplicaId,\n\t\t} = prepareInsertableNode(\n\t\t\tnode.cloneWithIds(),\n\t\t\tparentId,\n\t\t\tactiveScope.id,\n\t\t\tcopyTree,\n\t\t\ttree,\n\t\t\tlayers,\n\t\t\trenamedIds,\n\t\t\tfromSameProject && !fromHistory && !isDesignPageNode(activeScope),\n\t\t\tsourceProjectId,\n\t\t\tloadingNodeIds,\n\t\t\toffset,\n\t\t\tinOverlay,\n\t\t\tnodesToRemove.map(getId),\n\t\t)\n\n\t\tif (isBreakpointVariant(node)) {\n\t\t\tbreakpointVariantIds.add(node.id)\n\t\t}\n\n\t\tfor (const [replicaId, overrides] of Object.entries(nodeOverridesByReplicaId)) {\n\t\t\toverridesByReplicaId[replicaId] = { ...overridesByReplicaId[replicaId], ...overrides }\n\t\t}\n\n\t\tfor (const nodeToResolveVars of preparedNode.walk()) {\n\t\t\tresolveNodeColorTokens(nodeToResolveVars, oldToNewTokensMap)\n\t\t}\n\n\t\tif (layers.variableValueInfo && variableValuesByProviderMap.size > 0) {\n\t\t\tfor (const { node: nodeToResolveVars, skipChildren } of preparedNode.walkWithSkipChildren()) {\n\t\t\t\tif (!nodeToResolveVars.supportsDynamicValues()) {\n\t\t\t\t\tskipChildren()\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tconst update = getNodeUpdateResolvingDynamicValues(\n\t\t\t\t\ttreeStore.tree,\n\t\t\t\t\tlayers.variableValueInfo.scopeId,\n\t\t\t\t\tnodeToResolveVars,\n\t\t\t\t\tvariableValuesByProviderMap,\n\t\t\t\t)\n\n\t\t\t\tif (update) {\n\t\t\t\t\tnodeToResolveVars.set(update)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpreparedNodes.push(preparedNode)\n\t\tnewSelection.push(idToSelect)\n\t})\n\n\t// In the second pass we update all the links and slot ids to reflect the new identifiers we have created.\n\treturn {\n\t\tnewNodes: preparedNodes.map(node => updateNodeConnections(tree, componentLoader, node, renamedIds, inOverlay)),\n\t\tnodesToRemove,\n\t\tnewSelection,\n\t\toverridesByReplicaId,\n\t\tinsertionIndex,\n\t\tnewHomeNodeId: homeNodeId ? renamedIds.get(homeNodeId) : undefined,\n\t\tbreakpointVariantIds,\n\t}\n}\n\n/**\n * Process the copy tree, collect nodes that can be moved over, at the same time track some data (e.g. new home node id,\n * constraints) that we can use when pasting.\n */\nfunction processCopyTree({\n\tengine,\n\tcopyTree,\n\tlayers,\n\tactiveScope,\n\tparent,\n\tposition,\n\tselection,\n\ttreeIndex,\n\treplace,\n\trenamedIds,\n}: {\n\tengine: VekterEngine\n\tcopyTree: CanvasTree\n\tlayers: ClipboardLayers\n\tactiveScope: LoadedScopeNode\n\tparent: CanvasNode | null\n\tposition: Point\n\tselection: readonly NodeID[]\n\ttreeIndex?: TreeIndex\n\treplace?: boolean\n\trenamedIds: RenamedIds\n}): {\n\tnodesToInsert: CanvasNode[]\n\toffset: Point | undefined\n\thomeNodeId: NodeID | null\n} {\n\tconst { tree } = engine\n\tlet offset = parent !== null ? undefined : findOffset(position, copyTree, layers.originalFrames)\n\n\tconst nodesToInsert: CanvasNode[] = []\n\tconst filledRects: Rect[] = []\n\tlet homeNodeId: NodeID | null = null\n\tconst searchForHomeNodeCandidate = isCanvasPageNode(activeScope) && activeScope.homeNodeId === null\n\n\tconst onlyCollectionNodes = copyTree.rootAtStart.children.every(isCollectionNode)\n\n\tfunction collectNodesToInsert(node: CanvasNode) {\n\t\tif (!isInsertableNodeClassFromCopyTree(node)) return\n\n\t\tif (isCollectionNode(node)) {\n\t\t\t// Find a similar/compatible collection node on the canvas.\n\t\t\tconst existingCollectionNode = findCompatibleCollectionNode(tree, node)\n\t\t\tif (!onlyCollectionNodes && existingCollectionNode) {\n\t\t\t\t// If the similar/compatible collection node does not have the same id, we need to rename the node\n\t\t\t\t// when updating node connections.\n\t\t\t\tif (node.id !== existingCollectionNode.id) {\n\t\t\t\t\trenamedIds.set(node.id, existingCollectionNode.id)\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tnodesToInsert.push(node)\n\t\t\treturn\n\t\t}\n\n\t\tif (node instanceof CanvasPageNode) {\n\t\t\treturn node.children.forEach(collectNodesToInsert)\n\t\t}\n\n\t\t// Don't allow pasting instances of the active scope\n\t\tif (containsActiveSmartComponentInstance(node, activeScope.id)) {\n\t\t\treturn\n\t\t}\n\n\t\tif (isFixedOrRelativeOverlay(node)) {\n\t\t\tif (!parent) return\n\n\t\t\t// Don't add overlays to a code component if there are no empty\n\t\t\t// event slots to trigger the overlay from. And we can't make\n\t\t\t// one.\n\t\t\tif (\n\t\t\t\tisCodeComponentNode(parent) &&\n\t\t\t\t!hasEmptyEvents(parent, engine.componentLoader) &&\n\t\t\t\t!isLocalSmartComponentInstance(parent)\n\t\t\t) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// Don't add any overlays to a frame if the frame already has an overlay.\n\t\t\tif (\n\t\t\t\t!replace &&\n\t\t\t\tisFixedOrRelativeOverlay(node) &&\n\t\t\t\twithFrameEvents(parent) &&\n\t\t\t\tparent?.children?.some(isFixedOrRelativeOverlay)\n\t\t\t) {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\t// Track existing homeNodeIds.\n\t\tif (searchForHomeNodeCandidate && !homeNodeId && tree.isGroundNode(node)) {\n\t\t\tconst originalScopeId = treeIndex?.getScopeIdFor(node.id)\n\t\t\tif (originalScopeId) {\n\t\t\t\tconst originalScope = tree.get(originalScopeId)\n\t\t\t\tif (isCanvasPageNode(originalScope) && node.id === originalScope.homeNodeId) {\n\t\t\t\t\thomeNodeId = node.id\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Remove shape container if the node is pasted inside a vector context\n\t\tif (parent && (isShapeContainerNode(parent) || isVectorNode(parent)) && isShapeContainerNode(node)) {\n\t\t\tnode.children.forEach(child => {\n\t\t\t\t// Apply original child offset when stored\n\t\t\t\tconst childOffset = layers.originalFrames[child.id]\n\t\t\t\tif (childOffset && withPosition(child)) {\n\t\t\t\t\tchild = child.set({ x: child.x + childOffset.x, y: child.y + childOffset.y })\n\t\t\t\t}\n\t\t\t\tnodesToInsert.push(child)\n\t\t\t})\n\t\t} else {\n\t\t\t// If we find similar existing node on the canvas, we try to paste it\n\t\t\t// nearby using the same logic as duplication and frame defaults (devices)\n\t\t\tif (!parent && isPinnable(node)) {\n\t\t\t\tlet originalNode: (CanvasNode & WithPins) | undefined\n\n\t\t\t\tconst groundNodes = activeScope.getGroundNodes()\n\n\t\t\t\tif (selection.length === 0) {\n\t\t\t\t\toriginalNode = groundNodes.find(\n\t\t\t\t\t\tgroundNode => groundNode.id === node.id && subtreesAreSimilar(groundNode, node),\n\t\t\t\t\t) as (CanvasNode & WithPins) | undefined\n\t\t\t\t} else if (selection.length === 1) {\n\t\t\t\t\tassert(selection[0], \"Selection must be defined\")\n\t\t\t\t\tconst selectedNode = tree.getNode(selection[0])\n\t\t\t\t\tif (selectedNode && groundNodes.some(groundNode => groundNode.id === selectedNode.id)) {\n\t\t\t\t\t\tif (subtreesAreSimilar(selectedNode, node)) {\n\t\t\t\t\t\t\toriginalNode = selectedNode as CanvasNode & WithPins\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (originalNode) {\n\t\t\t\t\tconst constraints = suggestedConstraintsForCopiedNode(tree, activeScope, originalNode, selection, filledRects)\n\t\t\t\t\tnode = node.set(constraints)\n\t\t\t\t\toffset = { x: 0, y: 0 }\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tnodesToInsert.push(node)\n\t\t}\n\t}\n\n\tcopyTree.rootAtStart.children.forEach(collectNodesToInsert)\n\n\treturn { nodesToInsert, offset, homeNodeId }\n}\n\nfunction prepareInsertableNode(\n\tnode: CanvasNode,\n\tparentid: MaybeNodeID,\n\ttargetScopeId: NodeID,\n\tfromTree: CanvasTree,\n\ttree: CanvasTree,\n\tlayers: ClipboardLayers,\n\trenamedIds: RenamedIds,\n\tattemptToPasteAsReplica: boolean,\n\tsourceProjectId: string | undefined,\n\tloadingNodeIds: Set<string> | undefined,\n\toffset?: Point,\n\tinOverlay?: boolean,\n\tignoreExistingIds?: NodeID[],\n): { preparedNode: CanvasNode; idToSelect: NodeID; overridesByReplicaId: Record<NodeID, ReplicaOverrides> } {\n\tconst originalFrame: Rect | undefined = layers.originalFrames[node.id]\n\t// The node here is constructed from the copy data, thus might not have its cache initialized correctly yet.\n\tconst allowCache = false\n\tlet rect = originalFrame ?? fromTree.getRect(node, true, allowCache)\n\n\tconst adopt = deepAdoptNode(\n\t\ttree,\n\t\tnode,\n\t\tparentid,\n\t\ttargetScopeId,\n\t\tlayers,\n\t\tfromTree,\n\t\trenamedIds,\n\t\tinOverlay ?? false,\n\t\tattemptToPasteAsReplica,\n\t\tignoreExistingIds ?? [],\n\t\tsourceProjectId,\n\t\tloadingNodeIds,\n\t)\n\n\tconst overridesByReplicaId: Record<NodeID, ReplicaOverrides> = {}\n\tlet idToSelect = adopt.id\n\tconst parent = tree.get(parentid)\n\tif (parent && isReplicaOrReplicaChild(parent)) {\n\t\tif (isReplicaVariantOrReplicaVariantChild(parent)) {\n\t\t\tadopt.parentid = parent.originalid\n\t\t\tconst originalParent = tree.get(parent.originalid)\n\n\t\t\tconst replica = TemplateHelper.getReplicaForTemplateNode(tree, parent)\n\t\t\tif (replica) {\n\t\t\t\tidToSelect = generateReplicaChildId(replica.id, adopt.id)\n\t\t\t\t// hide the original node when pasting into a replica, and override the replica node to be visible.\n\t\t\t\tif (originalParent && originalParent.cache.visible === true) {\n\t\t\t\t\tadopt.set({ visible: false })\n\t\t\t\t\tconst overrideUpdates: Record<string, unknown> = { visible: true }\n\t\t\t\t\t// If the previous node has an itemsOrder, we need to remap\n\t\t\t\t\t// the ids to the cloned ones, so the overridden order is\n\t\t\t\t\t// preserved in the pasted replica node.\n\t\t\t\t\tif (hasItemsOrderOverride(adopt)) {\n\t\t\t\t\t\toverrideUpdates.itemsOrder = updateItemsOrder(adopt.itemsOrder, renamedIds)\n\t\t\t\t\t}\n\t\t\t\t\tconst replicaOverrides = overridesByReplicaId[replica.id] ?? {}\n\t\t\t\t\treplicaOverrides[adopt.id] = overrideUpdates\n\t\t\t\t\toverridesByReplicaId[replica.id] = replicaOverrides\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tadopt.parentid = NullID\n\t\t}\n\t\t// make sure that on paste, we don't paste replica's in their own masters\n\t} else if (TemplateHelper.isInMasterOfReplica(tree, parent, adopt)) {\n\t\tadopt.parentid = NullID\n\t}\n\n\tif (isWebPageNode(adopt) || isCollectionNode(adopt)) {\n\t\treturn { preparedNode: adopt, idToSelect, overridesByReplicaId }\n\t}\n\n\t// When pasting a VectorSetItem outside of a VectorSetNode, it should no longer be treated as a\n\t// VectorSetItem. Eg. an Icon copied from an Icon Set into the main canvas should be displayed\n\t// as a Viewbox.\n\tif (isVectorSetItem(adopt)) {\n\t\tconst scopeNode = tree.getScopeNodeFor(parent)\n\t\tif (scopeNode && !isVectorSetNode(scopeNode)) {\n\t\t\t// Remove the VectorSetItem trait so that the node is displayed as a Viewbox.\n\t\t\tadopt.set(withVectorSetItemDefaults)\n\t\t}\n\t}\n\n\tconst newParentViewportProvider = parent ? getViewportProviderForNode(tree, parent.id) : undefined\n\n\tif (!canNodeProvideViewportRect(adopt) && !newParentViewportProvider) {\n\t\tfor (const child of adopt.walk()) {\n\t\t\tif (!withSizeDimensionType(child)) continue\n\t\t\t// The adopted node is special cased in getLayoutUpdate.\n\t\t\tif (child === adopt) continue\n\t\t\tconst updateChild: Partial<WithSizeDimensionType> = {}\n\t\t\tconst updateParent: Partial<WithSizeDimensionType> = {}\n\t\t\t// both viewport and percentage have fraction as the type for width and height, so we don't need to touch them.\n\n\t\t\tif (isPinnable(child) && child.heightType === DimensionType.Viewport) {\n\t\t\t\tupdateChild.heightType = DimensionType.Percentage\n\t\t\t\tif (isPinnable(adopt) && adopt.heightType === DimensionType.Auto) {\n\t\t\t\t\tupdateParent.heightType = DimensionType.FixedNumber\n\t\t\t\t\tadopt.set(updateParent)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (isPinnable(child) && child.widthType === DimensionType.Viewport) {\n\t\t\t\tupdateChild.widthType = DimensionType.Percentage\n\t\t\t\tif (isPinnable(adopt) && adopt.widthType === DimensionType.Auto) {\n\t\t\t\t\tupdateParent.widthType = DimensionType.FixedNumber\n\t\t\t\t\tadopt.set(updateParent)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tchild.set(updateChild)\n\t\t}\n\t}\n\n\tif (!parentid) {\n\t\tif (offset) {\n\t\t\trect = Rect.offset(rect, offset)\n\t\t}\n\n\t\t// when pasting a new node, we can't get the viewport size from the node itself, because the clones don't\n\t\t// have their cache initialized yet. Normally we could rely on the new parent, ground nodes don't have a parent,\n\t\t// they provide their own viewport.\n\t\tconst viewport = getViewportRect(tree, adopt)\n\t\tconst newFrame = adopt.updateForRect({\n\t\t\trect,\n\t\t\tparentSizeInfo: { sizing: null, positioning: null, viewport, layout: null },\n\t\t\tconstraintsLocked: false,\n\t\t\tshouldGuessPinToBottom: true,\n\t\t\tshouldGuessPinToRight: shouldGuessPinToRight(tree, adopt, parent),\n\t\t})\n\n\t\tif (withFloatingPosition(adopt) && adopt.floatingPositionEnabled === true) adopt.set(floatingPositionDefaults)\n\n\t\treturn {\n\t\t\tpreparedNode: adopt.set(newFrame),\n\t\t\tidToSelect,\n\t\t\toverridesByReplicaId,\n\t\t}\n\t}\n\n\tconst layoutUpdate = getLayoutUpdate(tree, adopt, parentid, rect)\n\tif (layoutUpdate) {\n\t\treturn {\n\t\t\tpreparedNode: adopt.set(layoutUpdate),\n\t\t\tidToSelect,\n\t\t\toverridesByReplicaId,\n\t\t}\n\t}\n\n\treturn { preparedNode: adopt, idToSelect, overridesByReplicaId }\n}\n\nfunction getLayoutUpdate(tree: CanvasTree, adopt: CanvasNode, parentid: NodeID, rect: Rect) {\n\tconst update: AnyNodeUpdate = {}\n\tconst newParent = tree.getNode(parentid)\n\n\t// check if new parent supports fractions or percentages\n\tif (isPinnable(adopt)) {\n\t\tconst widthIsFraction = adopt.widthType === DimensionType.FractionOfFreeSpace\n\t\tconst heightIsFraction = adopt.heightType === DimensionType.FractionOfFreeSpace\n\t\tconst widthIsPercentage = adopt.widthType === DimensionType.Percentage\n\t\tconst heightIsPercentage = adopt.heightType === DimensionType.Percentage\n\t\tconst widthIsViewport = adopt.widthType === DimensionType.Viewport\n\t\tconst heightIsViewport = adopt.heightType === DimensionType.Viewport\n\n\t\tif (\n\t\t\twidthIsFraction ||\n\t\t\theightIsFraction ||\n\t\t\twidthIsPercentage ||\n\t\t\theightIsPercentage ||\n\t\t\twidthIsViewport ||\n\t\t\theightIsViewport\n\t\t) {\n\t\t\tconst isStack = isStackComponent(newParent)\n\t\t\tconst isAutoWidth = newParent && isPinnable(newParent) && newParent.widthType === DimensionType.Auto\n\t\t\tconst isAutoHeight = newParent && isPinnable(newParent) && newParent.heightType === DimensionType.Auto\n\n\t\t\tconst newParentSupportsWidthAsFraction = isStack && !isAutoWidth\n\t\t\tconst newParentSupportsHeightAsFraction = isStack && !isAutoHeight\n\t\t\tconst newParentSupportsWidthAsPercentage = !isStack || !isAutoWidth\n\t\t\tconst newParentSupportsHeightAsPercentage = !isStack || !isAutoHeight\n\n\t\t\tconst parentSizeInfo = tree.getParentSizeInfo(adopt, newParent)\n\t\t\tconst updateForOriginalFrame = adopt.updateForRect({\n\t\t\t\trect,\n\t\t\t\tparentSizeInfo,\n\t\t\t\tconstraintsLocked: false,\n\t\t\t\tshouldGuessPinToBottom: shouldGuessPinToBottom(tree, adopt),\n\t\t\t\tshouldGuessPinToRight: shouldGuessPinToRight(tree, adopt, newParent),\n\t\t\t})\n\n\t\t\t// When copy pasting in breakpoints we can convert fractions to percentages.\n\t\t\tif (\n\t\t\t\tnewParent &&\n\t\t\t\tisBreakpointVariant(newParent) &&\n\t\t\t\twidthIsFraction &&\n\t\t\t\t!newParentSupportsWidthAsFraction &&\n\t\t\t\tnewParentSupportsWidthAsPercentage\n\t\t\t) {\n\t\t\t\tupdate.widthType = DimensionType.Percentage\n\t\t\t} else if (\n\t\t\t\t(widthIsFraction && !newParentSupportsWidthAsFraction) ||\n\t\t\t\t(widthIsPercentage && !newParentSupportsWidthAsPercentage)\n\t\t\t) {\n\t\t\t\t// stacks with auto-sized dimensions don't support fractions and percentages\n\t\t\t\t// on those dimensions\n\t\t\t\tupdate.width = updateForOriginalFrame.width\n\t\t\t\tupdate.widthType =\n\t\t\t\t\tupdateForOriginalFrame.widthType === DimensionType.FractionOfFreeSpace\n\t\t\t\t\t\t? DimensionType.FixedNumber\n\t\t\t\t\t\t: updateForOriginalFrame.widthType\n\t\t\t\tupdate.left = updateForOriginalFrame.left\n\t\t\t\tupdate.right = updateForOriginalFrame.right\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t(heightIsFraction && !newParentSupportsHeightAsFraction) ||\n\t\t\t\t(heightIsPercentage && !newParentSupportsHeightAsPercentage)\n\t\t\t) {\n\t\t\t\tupdate.height = updateForOriginalFrame.height\n\t\t\t\tupdate.heightType =\n\t\t\t\t\tupdateForOriginalFrame.heightType === DimensionType.FractionOfFreeSpace\n\t\t\t\t\t\t? DimensionType.FixedNumber\n\t\t\t\t\t\t: updateForOriginalFrame.heightType\n\t\t\t\tupdate.top = updateForOriginalFrame.top\n\t\t\t\tupdate.bottom = updateForOriginalFrame.bottom\n\t\t\t}\n\n\t\t\tconst newViewportProvider = newParent && getViewportProviderForNode(tree, newParent.id)\n\t\t\tif (widthIsViewport && !newViewportProvider) {\n\t\t\t\tupdate.widthType = DimensionType.FixedNumber\n\t\t\t\tupdate.width = updateForOriginalFrame.width\n\t\t\t}\n\n\t\t\tif (heightIsViewport && !newViewportProvider) {\n\t\t\t\tupdate.heightType = DimensionType.FixedNumber\n\t\t\t\tupdate.height = updateForOriginalFrame.height\n\t\t\t}\n\t\t}\n\t}\n\n\tconst positionUpdate = positionTypeUpdateForNewParent(adopt, newParent)\n\tif (positionUpdate) {\n\t\tObject.assign(update, positionUpdate)\n\t}\n\n\tif (Object.keys(update).length === 0) return null\n\treturn update\n}\n\n// makes copies of nodes, maintaining node.id unless they already exist in document\nfunction deepAdoptNode(\n\ttree: CanvasTree,\n\tnode: CanvasNode,\n\tparentid: MaybeNodeID,\n\ttargetScopeId: NodeID,\n\tlayers: ClipboardLayers,\n\tfromTree: CanvasTree,\n\trenamedIds: RenamedIds,\n\tinOverlay: boolean,\n\t/** If truthy, we would try to find if the node is in the tree and is a master. If so, we would\n\t * create a replica of it. If falsy, we detach the node on paste. */\n\tattemptToPasteAsReplica: boolean,\n\t/**\n\t * Keep the same id even if it's already in the tree (we're going to remove the existing node in applyTreeChanges\n\t * before inserting the new ones).\n\t */\n\tignoreExistingIds: NodeID[],\n\tsourceProjectId: string | undefined,\n\tloadingNodeIds: Set<string> | undefined,\n): CanvasNode {\n\tassert(node.mutable, \"Node is not mutable\")\n\tassert(!node.cache.treeLineage, \"Node must not have cache.treeLineage set\")\n\tassert(!node.originalid, \"Node must not have originalid set\")\n\n\tfunction createNodeId(prevId: string) {\n\t\tconst newId = randomID()\n\t\trenamedIds.set(prevId, newId)\n\t\treturn newId\n\t}\n\n\tfunction sanitizeNodeId(nodeToSanitize: CanvasNode) {\n\t\tif (isValidNodeId(nodeToSanitize.id)) return\n\t\tconst write = unsafeMakeMutable(nodeToSanitize)\n\t\twrite.id = createNodeId(nodeToSanitize.id)\n\t}\n\n\tconst isWebPageTree = fromTree.rootAtStart.children.some(\n\t\tchild => isWebPageNode(child) || isLayoutTemplateNode(child) || isSmartComponentNode(child),\n\t)\n\t// Since projects start from a default template, it's possible that a breakpoint or webpage that is copied\n\t// from one project to another has the same id as an existing one. If that's the case, we don't want to\n\t// use the local node. (See https://github.com/framer/company/issues/25551)\n\t// This also applies to copying and pasting entire webpages, regardless of whether they are in the same project or not,\n\t// as we don't want the pasted nodes (e.g breakpoints) to be treated as replicas of an original.\n\tconst original = attemptToPasteAsReplica && !isWebPageTree ? tree.get(node.id) : null\n\tconst originalFromScopeId = tree.getScopeNodeFor(original)?.id\n\tconst replicaInfo = layers.replicas[node.id]\n\t// Only paste as a replica if the original is in the same scope.\n\tif (original && originalFromScopeId === targetScopeId) {\n\t\tif (isMaster(original)) {\n\t\t\t// pasting a copy of a master into the same page, creates a replica\n\t\t\tconst replica = TemplateHelper.create(tree, original, {\n\t\t\t\towner: createNodeId(original.id),\n\t\t\t\tduplicatedFrom: createDuplicatedFromIfAllowed(original),\n\t\t\t})\n\t\t\tif (node instanceof FrameNode) {\n\t\t\t\tassert(isFrameNode(replica))\n\t\t\t\treplica.set(node.constraintValues(), tree)\n\t\t\t}\n\t\t\tnode = replica\n\t\t} else if (isReplica(original)) {\n\t\t\t// pasting a copy of a replica into the same page, creates a replica of it\n\t\t\tconst master = TemplateHelper.getMaster(tree, original)\n\t\t\tnode = adoptReplica(node, layers.replicas[node.id], master, tree, createNodeId(node.id))\n\t\t} else if (replicaInfo) {\n\t\t\t// Node already exist as non-replica in the tree.\n\t\t\t// https://github.com/framer/company/issues/18845\n\t\t\tconst masterId = replicaInfo.master\n\t\t\tlet master = tree.get(masterId)\n\t\t\tif (master) {\n\t\t\t\t// Master is already in the tree\n\t\t\t\tnode = adoptReplica(node, replicaInfo, master, tree, createNodeId(node.id))\n\t\t\t} else if (layers.masters[masterId]) {\n\t\t\t\t// Master is in clipboard\n\t\t\t\tmaster = fromTree.get(masterId)\n\t\t\t\tif (master && withTemplate(master)) {\n\t\t\t\t\tmaster = master.cloneWithIds({ isMaster: true })\n\t\t\t\t\tnode = adoptReplica(node, replicaInfo, master, tree, createNodeId(node.id))\n\t\t\t\t} else {\n\t\t\t\t\tsanitizeNodeId(node)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst write = unsafeMakeMutable(node)\n\t\t\t\twrite.id = createNodeId(write.id)\n\t\t\t\twrite.duplicatedFrom = duplicatedFromForNode(original.duplicatedFrom, original.id)\n\t\t\t}\n\t\t} else {\n\t\t\tconst write = unsafeMakeMutable(node)\n\t\t\twrite.id = createNodeId(write.id)\n\t\t\twrite.duplicatedFrom = duplicatedFromForNode(original.duplicatedFrom, original.id)\n\t\t}\n\t} else if (layers.masters[node.id]) {\n\t\t// pasting from a different document and marked as a master\n\t\t// variants are no longer variants when pasted to other documents\n\t\tif (withVariant(node) && node.isVariant) {\n\t\t\tif (!isWebPageTree) {\n\t\t\t\tnode.isVariant = false\n\t\t\t\tif (withTemplate(node)) node.isMaster = false\n\t\t\t\tconst write = unsafeMakeMutable(node)\n\t\t\t\twrite.id = createNodeId(write.id)\n\t\t\t}\n\t\t} else if (withTemplate(node)) {\n\t\t\tnode.isMaster = true\n\t\t}\n\n\t\tsanitizeNodeId(node)\n\t} else if (replicaInfo) {\n\t\t// pasting from a different document and this node is marked as template with overrides\n\t\t// variants are no longer variants when pasted to other documents\n\t\tif (withVariant(node) && node.isVariant) {\n\t\t\tsanitizeNodeId(node)\n\t\t\tif (isWebPageTree) {\n\t\t\t\tconst masterId = replicaInfo.master\n\t\t\t\tconst master = fromTree.get(masterId)\n\t\t\t\tif (master) {\n\t\t\t\t\t// if master is in our tree, relink the pasted replicas and the master\n\t\t\t\t\tnode = adoptReplica(node, replicaInfo, master, tree, createNodeId(node.id))\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Variants are no longer variants when the source is not a webpage tree (e.g. a\n\t\t\t\t// pasted breakpoint group). Demote fully \u2014 leaving replicaInfo/originalid on a\n\t\t\t\t// non-variant node would make adoptReplica below materialize replica children\n\t\t\t\t// that detachInvalidVariants later orphans, producing change diffs with no\n\t\t\t\t// parentid (crashes the CRDT store).\n\t\t\t\tnode.isVariant = false\n\t\t\t\tif (withBreakpoint(node)) {\n\t\t\t\t\tnode.isBreakpoint = false\n\t\t\t\t}\n\t\t\t\tnode.set({ replicaInfo: null, originalid: null })\n\n\t\t\t\tconst write = unsafeMakeMutable(node)\n\t\t\t\twrite.id = createNodeId(write.id)\n\t\t\t}\n\t\t} else if (withTemplate(node)) {\n\t\t\tconst masterId = replicaInfo.master\n\t\t\tlet master = tree.get(masterId)\n\t\t\tif (master) {\n\t\t\t\t// if master is in our tree, relink the pasted replicas and the master\n\t\t\t\tnode = adoptReplica(node, replicaInfo, master, tree, createNodeId(node.id))\n\t\t\t} else if (layers.masters[masterId]) {\n\t\t\t\t// master is not in our tree, but is in the paste info\n\t\t\t\tmaster = fromTree.get(masterId)\n\t\t\t\tif (master && withTemplate(master)) {\n\t\t\t\t\tmaster = master.cloneWithIds({ isMaster: true })\n\t\t\t\t\tnode = adoptReplica(node, replicaInfo, master, tree, createNodeId(node.id))\n\t\t\t\t} else {\n\t\t\t\t\tsanitizeNodeId(node)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else if ((tree.has(node.id) || loadingNodeIds?.has(node.id)) && !ignoreExistingIds.includes(node.id)) {\n\t\tconst write = unsafeMakeMutable(node)\n\t\twrite.id = createNodeId(write.id)\n\t} else {\n\t\tsanitizeNodeId(node)\n\t}\n\n\tnode.parentid = parentid\n\n\t// When cloning a form container, strip the formSaveId from the cloned node and store it in the cache, so we can\n\t// use it during post-processing to copy the form config.\n\tif (isFormContainer(node) && node.formSaveId) {\n\t\tconst prevOriginalId = getOldIdByNewId(renamedIds, node.getPrimaryId())\n\t\tnode.cache.formContainerConfigSource = createFormConfigSource(prevOriginalId, node.formSaveId, sourceProjectId)\n\t\tnode.formSaveId = undefined\n\t}\n\n\tif (isReplica(node)) return node\n\n\tconst children = node.children\n\tif (children) {\n\t\tconst nextChildren = new CanvasChildList<CanvasNode>()\n\n\t\tfor (const child of children) {\n\t\t\t// Filter child nodes that are not insertable\n\t\t\tif (!isInsertableNodeClassFromCopyTree(child)) continue\n\n\t\t\t// If we are pasting into an overlay, don't add descendant overlay\n\t\t\t// nodes as they are not valid.\n\t\t\tif (inOverlay && isFixedOrRelativeOverlay(child)) continue\n\n\t\t\tnextChildren.push(\n\t\t\t\tdeepAdoptNode(\n\t\t\t\t\ttree,\n\t\t\t\t\tchild,\n\t\t\t\t\tnode.id,\n\t\t\t\t\ttargetScopeId,\n\t\t\t\t\tlayers,\n\t\t\t\t\tfromTree,\n\t\t\t\t\trenamedIds,\n\t\t\t\t\tinOverlay,\n\t\t\t\t\tattemptToPasteAsReplica,\n\t\t\t\t\tignoreExistingIds,\n\t\t\t\t\tsourceProjectId,\n\t\t\t\t\tloadingNodeIds,\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\n\t\tnode.children = nextChildren\n\t}\n\n\treturn node\n}\n\nfunction adoptReplica(\n\tnode: CanvasNode,\n\treplicaInfo: ReplicaInfo | undefined,\n\tmaster: CanvasNode,\n\ttree: CanvasTree,\n\tnewId: string,\n) {\n\tif (!isMaster(master)) {\n\t\treturn node\n\t}\n\n\tconst overrides = reviveReplicaInfo(replicaInfo)?.overrides\n\n\tconst replica = TemplateHelper.create(tree, master, {\n\t\toverrides,\n\t\towner: newId,\n\t\tinheritsFrom: replicaInfo?.inheritsFrom,\n\t\tduplicatedFrom: createDuplicatedFromIfAllowed(node),\n\t})\n\tif (node instanceof FrameNode) {\n\t\tassert(isFrameNode(replica))\n\t\treplica.set(node.constraintValues(), tree)\n\t}\n\treturn replica\n}\n\nexport function getIdIfSelectionCanBeParent(\n\tcomponentLoader: ComponentLoader,\n\tnodesToPaste: CanvasNode[],\n\ttoTree: CanvasTree,\n\tactiveScope: LoadedScopeNode,\n\tselection: readonly NodeID[],\n\tactiveScreen: MaybeNodeID,\n): { maybeParentId: MaybeNodeID; insertionIndex?: number } {\n\tconst sourceGroundNode = nodesToPaste[0]\n\tassert(sourceGroundNode, \"Copy tree must have ground nodes\")\n\n\tconst singleTarget = selection.length === 1\n\tconst targetNode = singleTarget && selection[0] ? toTree.getNode(selection[0]) : null\n\n\tif (nodesToPaste.some(isVariant)) {\n\t\treturn { maybeParentId: NullID }\n\t}\n\n\t// all layers except for frames can be children\n\tif (targetNode) {\n\t\t// if the target node is a non-variant replica, paste the node in the root\n\t\tif (isReplicaOrReplicaChild(targetNode) && !isReplicaVariantOrReplicaVariantChild(targetNode)) {\n\t\t\treturn { maybeParentId: NullID }\n\t\t}\n\n\t\t// Only accept if the node can have children and we\u2019re not pasting into ourselves\n\n\t\tif (isVectorNode(targetNode) || isShapeContainerNode(targetNode)) {\n\t\t\t// All children must be vector nodes or shape containers\n\t\t\tconst anyNonVectorOrContainerNode =\n\t\t\t\tnodesToPaste.find(sourceNode => !isVectorNode(sourceNode) && !isShapeContainerNode(sourceNode)) !== undefined\n\t\t\tif (anyNonVectorOrContainerNode) {\n\t\t\t\treturn { maybeParentId: NullID }\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\tacceptsChild(toTree, targetNode, sourceGroundNode, activeScope.id, componentLoader) &&\n\t\t\t!subtreesAreSimilar(targetNode, sourceGroundNode)\n\t\t) {\n\t\t\tif (targetNode.id !== sourceGroundNode.id) {\n\t\t\t\treturn { maybeParentId: targetNode.id }\n\t\t\t}\n\t\t} else if (canSearchAncestorsForAcceptableParent(sourceGroundNode)) {\n\t\t\t// pick the first acceptable parent from the original parent's ancestors to insert the new node\n\t\t\tconst ancestor = toTree.getParent(targetNode.id)\n\t\t\tif (ancestor && acceptsChild(toTree, ancestor, sourceGroundNode, activeScope.id, componentLoader)) {\n\t\t\t\tconst currentIndexInParent = ancestor.children.indexOf(targetNode)\n\t\t\t\treturn {\n\t\t\t\t\tmaybeParentId: ancestor.id,\n\t\t\t\t\tinsertionIndex: currentIndexInParent === -1 ? undefined : currentIndexInParent + 1,\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else if (activeScreen) {\n\t\tconst activeScreenNode = toTree.getNode(activeScreen)\n\t\tif (activeScreenNode) {\n\t\t\tconst ancestors = activeScreenNode.ancestors()\n\n\t\t\t// Only use activeScreen if it is on the current page\n\t\t\tfor (const ancestor of ancestors) {\n\t\t\t\tif (ancestor.id === activeScope.id) {\n\t\t\t\t\treturn { maybeParentId: activeScreen }\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { maybeParentId: NullID }\n}\n\nfunction canSearchAncestorsForAcceptableParent(targetChild: CanvasNode) {\n\t// we don't want to pick an alternate parent for the overlay because it can end up being\n\t// pasted in an unexpected place.\n\treturn !isFixedOrRelativeOverlay(targetChild)\n}\n\nfunction subtreesAreSimilar(nodeA: CanvasNode, nodeB: CanvasNode) {\n\tif (withChildren(nodeA) && withChildren(nodeB)) {\n\t\tconst sameAmount = nodeA.children.length === nodeB.children.length\n\t\tif (!sameAmount) {\n\t\t\treturn false\n\t\t}\n\t\tconst unequalChild = getChildren(nodeA).find((childA: CanvasNode, index: number) => {\n\t\t\tconst childB = nodeB.children.at(index)\n\t\t\tassert(childB, \"Both nodes must have equal amount of children\")\n\t\t\treturn !subtreesAreSimilar(childA, childB)\n\t\t})\n\t\tif (unequalChild) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn nodesAreSimilar(nodeA, nodeB)\n}\n\nfunction detachInvalidVariants(engine: VekterEngine, activeScope: LoadedScopeNode, newNodes: CanvasNode[]) {\n\tconst activeScopeSupportsVariants = withReplicaVariants(activeScope)\n\tconst activeScopeSupportsBreakpoints = withBreakpointVariants(activeScope)\n\tconst invalidVariants = new Set<CanvasNode>()\n\n\tfor (const node of newNodes) {\n\t\tif (\n\t\t\tisVariant(node) &&\n\t\t\t(!activeScopeSupportsVariants ||\n\t\t\t\t// If the web page already has a primary variant, we can't have another primary\n\t\t\t\t// variant, or replica variant inherited from a different primary variant.\n\t\t\t\tactiveScope.baseVariantId !== node.getPrimaryId())\n\t\t) {\n\t\t\tinvalidVariants.add(node)\n\t\t}\n\n\t\tif (\n\t\t\t// We don't use isBreakpointVariant in case node.isVariant is falsy but node.isBreakpoint is true.\n\t\t\twithBreakpoint(node) &&\n\t\t\tnode.isBreakpoint === true &&\n\t\t\t(!activeScopeSupportsBreakpoints || activeScope.baseVariantId !== node.getPrimaryId())\n\t\t) {\n\t\t\tinvalidVariants.add(node)\n\t\t}\n\n\t\tif (isReplica(node)) {\n\t\t\tconst master = engine.tree.get(node.replicaInfo.master)\n\t\t\tif (!master || master.parentid !== activeScope.id) {\n\t\t\t\tinvalidVariants.add(node)\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const invalidVariant of invalidVariants) {\n\t\tconst latest = engine.tree.current(invalidVariant)\n\t\tif (!latest) return\n\n\t\t// Variants explicitly unset their name in TemplateHelper.create. But if we are detaching\n\t\t// them again, we should preserve it. We can still find it in the overrides or the master.\n\t\tlet name = latest.name\n\t\tif (!name && isReplica(latest)) {\n\t\t\tname = latest.replicaInfo?.overrides?.[latest.originalid]?.name\n\t\t\tif (!name) {\n\t\t\t\tname = engine.tree.get(latest.replicaInfo.master)?.name ?? null\n\t\t\t}\n\t\t}\n\n\t\tlatest.set({\n\t\t\toriginalid: null,\n\t\t\treplicaInfo: null,\n\t\t\tname,\n\t\t})\n\n\t\tif (withVariant(latest)) {\n\t\t\tlatest.set({ isVariant: undefined })\n\t\t}\n\n\t\tif (withBreakpoint(latest)) {\n\t\t\tlatest.set({ isBreakpoint: undefined })\n\t\t}\n\n\t\tfor (const descendant of latest.walk()) {\n\t\t\tengine.tree.current(descendant)?.set({ originalid: null })\n\t\t}\n\t}\n}\n\nfunction findCompatibleCollectionNode(tree: CanvasTree, node: CollectionNode) {\n\tconst nodeWithSameId = tree.getNodeWithTrait(node.id, isCollectionNode)\n\tif (nodeWithSameId && isEqual(nodeWithSameId.variables, node.variables)) return nodeWithSameId\n\n\tconst contentManagementNode = getContentManagementNode(tree)?.loaded\n\tif (!contentManagementNode) return null\n\n\treturn contentManagementNode.children.find(child => isCompatibleCollectionNode(node, child)) ?? null\n}\n\nfunction isCompatibleCollectionNode(node: CollectionNode, otherNode: CollectionNode) {\n\treturn (\n\t\tnode.name === otherNode.name &&\n\t\tnode.variables.every(variable => !isVariableDefinition(variable) || variableExistsInNode(otherNode, variable))\n\t)\n}\n\nfunction variableExistsInNode(node: CollectionNode, variable: VariableDefinition) {\n\treturn node.variables.some(v => v.id === variable.id && v.type === variable.type && v.name === variable.name)\n}\n\nexport const ClipboardHelpersTesting = {\n\tprepareReplaceOriginalNodeWith,\n\tdetachInvalidVariants,\n\tdeepAdoptNode,\n}\n", "import type { ToasterAddAction } from \"@framerjs/fresco\"\nimport type { VekterEngine } from \"document/VekterEngine.ts\"\nimport { RenamedIds } from \"document/components/tools/utils/updateNodeConnections.ts\"\nimport type { CanvasNode, LoadedScopeNode, MaybeNodeID, NodeID } from \"document/models/CanvasTree/index.ts\"\nimport { getContentManagementNode } from \"document/models/CanvasTree/nodes/ContentManagementNode.utils.ts\"\nimport type { Point } from \"library/index.ts\"\nimport { chunkArray } from \"utils/chunkArray.ts\"\nimport { toast } from \"web/lib/toaster.ts\"\nimport { getRenamedIdsFromClipboardLayers, insertTree, pasteClipboardLayers } from \"./tree.ts\"\nimport type { FramerLayersClipboardData } from \"./types.ts\"\n\nexport async function wrapImportAssetsToast(handler: () => Promise<void>) {\n\tconst key = `duplicate-assets${Math.random()}`\n\tconst action: ToasterAddAction = {\n\t\tkey,\n\t\tvariant: \"progress\",\n\t\ttype: \"add\",\n\t\ticon: \"image\",\n\t\tshowCloseButton: \"auto\",\n\t}\n\ttry {\n\t\ttoast({\n\t\t\t...action,\n\t\t\tduration: Infinity,\n\t\t\tprimaryText: \"Importing assets.\",\n\t\t\tsecondaryText: \"Just a moment\u2026\",\n\t\t})\n\t\tawait handler()\n\t\ttoast({ key, type: \"remove\" })\n\t} catch {\n\t\ttoast({\n\t\t\t...action,\n\t\t\tvariant: \"error\",\n\t\t\ticon: \"error\",\n\t\t\tprimaryText: \"Asset import failed.\",\n\t\t\tsecondaryText: \"Please try again.\",\n\t\t})\n\t}\n}\n\nexport async function framerLayersClipboardHandler({\n\tengine,\n\tlayersData,\n\tonInsertNode,\n\tposition,\n\treplace = false,\n\tshouldDetachTextStyles,\n\tshouldPasteTextStyles = false,\n\treusePresetWithSameId = false,\n\tshouldDisplayImportAssetsToast = true,\n\tcloneWithScopeIds = false,\n\tinsertTarget,\n\tinitialRenamedIds = new RenamedIds(),\n}: {\n\tengine: VekterEngine\n\tinsertTarget?: { parentId: NodeID; index?: number }\n\tlayersData: FramerLayersClipboardData | undefined\n\tonInsertNode?: (node: CanvasNode) => void\n\tposition: Point\n\treplace?: boolean\n\tshouldDetachTextStyles?: boolean\n\tshouldPasteTextStyles?: boolean\n\treusePresetWithSameId?: boolean\n\tshouldDisplayImportAssetsToast?: boolean\n\tcloneWithScopeIds?: boolean\n\tinitialRenamedIds?: RenamedIds\n}): Promise<boolean> {\n\tif (!layersData) return false\n\tconst { assetService } = engine.stores.assetStore\n\tif (!assetService) return false\n\n\tconst { layers, sourceProjectId, assets } = layersData\n\n\tif (!layers.masters) {\n\t\tlayers.masters = {}\n\t}\n\n\tif (!layers.replicas) {\n\t\tlayers.replicas = {}\n\t}\n\n\tlet insertionGroundNodeId: MaybeNodeID | undefined\n\tlet insertionNodeIds: NodeID[] | undefined\n\tlet insertionScopeNode: LoadedScopeNode | null | undefined\n\n\t// If there is an insertion target parent id, use it to determine the insertion ground\n\t// node id, node ids, and scope node.\n\tif (insertTarget) {\n\t\tconst node = engine.tree.getNode(insertTarget.parentId)\n\n\t\tif (node) {\n\t\t\tinsertionGroundNodeId = engine.tree.getGroundNodeFor(node).id\n\t\t\tinsertionNodeIds = [node.id]\n\t\t\tinsertionScopeNode = engine.tree.getScopeNodeFor(node)\n\t\t}\n\t}\n\n\tif (!insertionGroundNodeId || !insertionNodeIds || !insertionScopeNode) {\n\t\tinsertionGroundNodeId = engine.stores.selectionStore.commonGroundNodeId\n\t\tinsertionNodeIds = engine.stores.selectionStore.ids\n\t\tinsertionScopeNode = engine.stores.scopeStore.active\n\t}\n\n\tconst projectId = engine.stores.projectStore.projectId\n\tconst fromSameProject = sourceProjectId === projectId\n\n\tconst renamedIds = getRenamedIdsFromClipboardLayers(layers, initialRenamedIds)\n\n\tconst pasteInfo = await pasteClipboardLayers(\n\t\tengine,\n\t\tlayers,\n\t\tinsertionScopeNode,\n\t\tposition,\n\t\tinsertionNodeIds,\n\t\tinsertionGroundNodeId,\n\t\tfromSameProject,\n\t\tsourceProjectId,\n\t\tengine.stores.treeStore.treeIndex,\n\t\trenamedIds,\n\t\treplace,\n\t\tinsertTarget?.index,\n\t)\n\n\tif (!pasteInfo) return false\n\n\tawait getContentManagementNode(engine.tree)?.load()\n\n\tif (!fromSameProject && Array.isArray(assets) && assets.length > 0) {\n\t\t// Duplicate assets in chunks. Otherwise, the server might not\n\t\t// accept the request.\n\t\tconst allChunks = chunkArray(assets, 500).map(chunk => {\n\t\t\treturn assetService.duplicateAssets(chunk, sourceProjectId)\n\t\t})\n\n\t\tif (shouldDisplayImportAssetsToast) {\n\t\t\tawait wrapImportAssetsToast(async () => {\n\t\t\t\tawait Promise.all(allChunks)\n\t\t\t})\n\t\t} else {\n\t\t\tawait Promise.all(allChunks)\n\t\t}\n\t}\n\n\tawait insertTree({\n\t\tengine,\n\t\t// When copying text from one project to another, detach the presets so that the pasted text looks identical to the source text.\n\t\t// See https://github.com/framer/FramerStudio/pull/12855\n\t\tshouldDetachTextStyles: shouldDetachTextStyles ?? !fromSameProject,\n\t\tshouldPasteTextStyles,\n\t\treusePresetWithSameId,\n\t\tcloneWithScopeIds,\n\t\tinsertionGroundNodeId,\n\t\tinsertionScopeNode,\n\t\tlayers,\n\t\tonInsertNode,\n\t\tpasteInfo,\n\t\trenamedIds,\n\t\tselectAndCenter: !insertTarget?.parentId,\n\t\tsourceProjectId,\n\t})\n\treturn true\n}\n", "import { Dictionary } from \"app/dictionary.ts\"\n\nexport function getNegatedLabel(label: string, enabled: boolean = true): string {\n\tif (!enabled) return label\n\treturn `${Dictionary.Not} ${label}`\n}\n", "export const siteTitlePlaceholder = \"My website\"\nexport const pageTitlePlaceholder = \"My page\"\nexport const descriptionPlaceholder = \"My description\"\nexport const hostnamePlaceholder = \"yoursite.url\"\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAS,oBAAoB,MAAsC;AAClE,SAAO,KAAK;AACb;AAMA,SAAS,kBAAkB,MAAkB,MAA4C;AACxF,QAAM,aAAa,oBAAoB,IAAI;AAC3C,SAAO,aAAa,KAAK,QAAQ,UAAU,IAAI;AAChD;AAQO,SAAS,WAAW,MAAkB,MAAsB,MAA2B;AAC7F,QA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,YAAY,WAAW,QAAQ,GAAG,EAAE,IAAI,WAAS;AACtD,aAAO,aAAa,gBAAgB,OAAO,eAAe;AAAA,IAC3D,CAAC;AAED,QAAI,gCAAgC;AACnC,YAAM,sBAAsB,YAAY;AACvC,cAAM,QAAQ,IAAI,SAAS;AAAA,MAC5B,CAAC;AAAA,IACF,OAAO;AACN,YAAM,QAAQ,IAAI,SAAS;AAAA,IAC5B;AAAA,EACD;AAEA,QAAM,WAAW;AAAA,IAChB;AAAA;AAAA;AAAA,IAGA,wBAAwB,0BAA0B,CAAC;AAAA,IACnD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,iBAAiB,CAAC,cAAc;AAAA,IAChC;AAAA,EACD,CAAC;AACD,SAAO;AACR;;;AC/JO,SAAS,gBAAgB,OAAe,UAAmB,MAAc;AAC/E,MAAI,CAAC,QAAS,QAAO;AACrB,SAAO,kBAAiB,IAAI,KAAK;AAClC;;;ACLO,IAAM,uBAAuB;AAE7B,IAAM,yBAAyB;AAC/B,IAAM,sBAAsB;",
  "names": ["ColorSamplerHelper", "ColorSampler", "assert", "isEqual", "log", "log", "MIMEType", "AnalyticsTabNames", "signal", "fontSelector", "fontSizeValue", "lineHeightValue", "textAlignment", "letterSpacingValue", "openTypeFontFeatures", "lineHeightUnit", "letterSpacingUnit", "variationAxes", "controlProp", "reducedControlProp", "meta", "meta", "meta", "log", "isVideoFile", "link", "link", "unlink", "propagate", "checkDirty", "shallowPropagate", "effect", "run", "effect", "service", "resolve", "textNode", "masterNode", "link", "flash", "resolve", "clonedNode"]
}
