{
  "version": 3,
  "sources": ["../../src/canvas-sandbox/CanvasSandboxMessagesIn.ts", "../../src/canvas-sandbox/SandboxUtils.ts"],
  "sourcesContent": ["import type { PartialTreeUpdate } from \"document/models/CanvasTree/PartialTreeSender.ts\"\nimport type { NodeChange } from \"document/models/CanvasTree/TreeDiff.ts\"\nimport type { MaybeNodeID, NodeID } from \"document/models/CanvasTree/index.ts\"\nimport type { ValueNode } from \"document/models/CanvasTree/nodes/canvasNodeFromValue.ts\"\nimport type { RepeatersShowingEmptyState } from \"document/stores/RepeaterStore.ts\"\nimport type { NodeWithPlaceholders } from \"document/stores/ToolStore.ts\"\nimport type { EffectPreviewType } from \"document/utils/EffectPreviewType.ts\"\nimport type { FontPreview } from \"document/utils/FontPreviewTypes.ts\"\nimport type { ActiveLinkStyle } from \"document/utils/activeLinkStylePreset.ts\"\nimport type { Rect } from \"library/render/types/Rect.ts\"\nimport type { LocaleId } from \"library/router/types.ts\"\nimport { isObject } from \"utils/typeChecks.ts\"\n\n// Communication with the iframe is done using postMessage.\n//\n// When using postMessage, it will result in two macro tasks for the browser,\n// and we get no guarantee on when the result of each will be painted. Often the\n// canvas is painted a frame after the vekter UI, while dragging often the\n// previous canvas paint is merged with the next UI paint. This might result in\n// a visible trail and looks like things are laggy, even though there is no drop\n// in framerate.\n\n// Scroll/zoom state\nexport type CanvasTransform =\n\t| [/* offsetX: */ number, /* offsetY: */ number, /* zoom: */ number]\n\t| [\n\t\t\t/* offsetX: */ number,\n\t\t\t/* offsetY: */ number,\n\t\t\t/* zoom: */ number,\n\t\t\t/* liveZoom: */ number | undefined,\n\t\t\t/* inMoveTool: */ boolean,\n\t  ]\n\nexport interface SandboxUpdate {\n\ttype: \"SandboxUpdate\"\n\tupdate: number // engine.update\n\n\tdocument?: DocumentUpdate\n\ttransform?: CanvasTransform\n}\n\n// Document state\nexport interface DocumentUpdate {\n\ttree?: { root: ValueNode }\n\tchanges?: NodeChange[]\n\tpartialTreeUpdate?: PartialTreeUpdate\n\tloadedSomeUserData?: boolean\n\tloadedAllUserData?: boolean\n\tisReadyToRender?: boolean\n\tactiveLocaleId?: LocaleId\n\n\trenderScope?: NodeID\n\trenderNodes?: Record<NodeID, Rect>\n\n\tselection?: NodeID[]\n\tnodesWithPlaceholders?: NodeWithPlaceholders[] | null\n\tnodeInTextEditorId?: MaybeNodeID\n\tnodesInEffectPreview?: NodeID[]\n\tnodesInMoveToolBaseFontSize?: Record<NodeID, number>\n\tactiveEffect?: EffectPreviewType | null\n\tactiveEffectIds?: Set<NodeID> | null\n\tfontPreviewByNodeId?: ReadonlyMap<NodeID, FontPreview>\n\tactiveOverlayNodes?: ReadonlySet<NodeID>\n\tisDarkMode?: boolean\n\tperformanceMode?: boolean\n\toptionalSelectedCollectionItemId?: NodeID\n\trepeatersShowingEmptyState?: RepeatersShowingEmptyState\n\ttimestamp?: number\n\trootFontSize?: number | null\n\tshouldSetMinHeight?: boolean\n\tactiveLinkStyle?: ActiveLinkStyle | null\n\tisPreviewActive?: boolean\n}\n\nexport function isSandboxUpdate(data: unknown): data is SandboxUpdate {\n\treturn isObject(data) && data.type === \"SandboxUpdate\"\n}\n", "import type { SandboxComponentLoader } from \"@framerjs/framer-runtime/sandbox\"\nimport { assert } from \"@framerjs/shared\"\nimport { collectionIdKey } from \"code-generation/components/cms/dataIdKeys.ts\"\nimport { QueryCache, QueryEngine } from \"library/index.ts\"\nimport { BinaryOperator, type Identifier, type Query } from \"library/modules/cms/types.ts\"\nimport type { Json, JsonObject } from \"utils/json.ts\"\n\ninterface QueryParams {\n\tdataIdentifier: string\n\tfields: string[]\n\tcollectionItemId?: string\n}\n\ninterface FetchResult {\n\tstatus: number\n\tdata: Json\n}\n\nexport class SandboxUtils {\n\tprivate readonly queryEngine = new QueryEngine()\n\tprivate readonly queryCache = new QueryCache(this.queryEngine, 25)\n\n\tconstructor(private readonly componentLoader: SandboxComponentLoader) {}\n\n\tasync queryCollection({ dataIdentifier, fields, collectionItemId }: QueryParams) {\n\t\tconst definition = this.componentLoader.dataForIdentifier(dataIdentifier)\n\t\tassert(definition, \"Missing data definition for identifier\")\n\n\t\tconst query: Query = {\n\t\t\tfrom: {\n\t\t\t\ttype: \"Collection\",\n\t\t\t\tdata: definition.class,\n\t\t\t},\n\t\t\tselect: fields.map(getIdentifier),\n\t\t}\n\n\t\tif (collectionItemId) {\n\t\t\tquery.where = {\n\t\t\t\ttype: \"BinaryOperation\",\n\t\t\t\toperator: BinaryOperator.Equals,\n\t\t\t\tleft: {\n\t\t\t\t\ttype: \"Identifier\",\n\t\t\t\t\tname: collectionIdKey,\n\t\t\t\t},\n\t\t\t\tright: {\n\t\t\t\t\ttype: \"LiteralValue\",\n\t\t\t\t\tvalue: collectionItemId,\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\n\t\tconst result = await this.queryCache.get(query, undefined).readMaybeAsync()\n\t\treturn result as JsonObject[]\n\t}\n\n\tasync fetchJSON(url: string): Promise<FetchResult> {\n\t\tconst response = await fetch(url, {\n\t\t\t// We never send any cookies to these requests from the sandbox.\n\t\t\tcredentials: \"omit\",\n\t\t})\n\n\t\tif (!response.ok) {\n\t\t\tthrow new Error(\"Invalid HTTP Status Code: \" + response.status)\n\t\t}\n\n\t\tconst json = await response.json()\n\n\t\treturn {\n\t\t\tstatus: response.status,\n\t\t\tdata: json,\n\t\t}\n\t}\n}\n\nfunction getIdentifier(name: string): Identifier {\n\treturn {\n\t\ttype: \"Identifier\",\n\t\tname,\n\t}\n}\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;AA0EO,SAAS,gBAAgB,MAAsC;AACrE,SAAO,SAAS,IAAI,KAAK,KAAK,SAAS;AACxC;;;AC1DO,IAAM,eAAN,MAAmB;AAAA,EAIzB,YAA6B,iBAAyC;AAAzC;AAH7B,wBAAiB,eAAc,IAAI,YAAY;AAC/C,wBAAiB,cAAa,IAAI,WAAW,KAAK,aAAa,EAAE;AAAA,EAEM;AAAA,EAEvE,MAAM,gBAAgB,EAAE,gBAAgB,QAAQ,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