{
  "version": 3,
  "sources": ["../../src/app/ai/agents/evals2/scenarios/dynamicFilters/helpers.ts"],
  "sourcesContent": ["import { assert } from \"@framerjs/shared\"\nimport type { VekterEngine } from \"document/VekterEngine.ts\"\nimport { isSetVariableValueAction } from \"document/models/CanvasTree/actions/setVariableValueActions.ts\"\nimport type { CodeComponentNode, LoadedSmartComponentNode } from \"document/models/CanvasTree/index.ts\"\nimport type { NodeID } from \"document/models/CanvasTree/nodes/NodeID.ts\"\nimport { isSmartComponentNode } from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport type { ComputedValue } from \"document/models/CanvasTree/traits/ComputedValue.ts\"\nimport { isComputedValue } from \"document/models/CanvasTree/traits/ComputedValue.ts\"\nimport type { ValueTransform } from \"document/models/CanvasTree/traits/ValueTransform.ts\"\nimport { isVariableReference } from \"document/models/CanvasTree/traits/VariableReference.ts\"\nimport type { RawControlProp } from \"document/models/controlProps/RawControlProp.ts\"\nimport { ControlType } from \"library/render/types/PropertyControls.ts\"\n\nexport function findOnlySmartComponent(engine: VekterEngine): LoadedSmartComponentNode | undefined {\n\tconst smartComponents = engine.tree.root.children.filter(\n\t\t(node): node is LoadedSmartComponentNode => isSmartComponentNode(node) && node.isLoaded(),\n\t)\n\tconst smartComponent = smartComponents[0]\n\n\tassert(smartComponent, \"Agent didn't create any smart component\")\n\tassert(smartComponents.length === 1, \"Agent created too many smart components\")\n\n\treturn smartComponent\n}\n\nexport function getVariantComputedValue(instance: CodeComponentNode): ComputedValue | undefined {\n\tconst prop = instance.getRawControlProp(\"variant\")\n\tif (!prop || prop.type !== ControlType.Enum) return undefined\n\treturn isComputedValue(prop.value) ? prop.value : undefined\n}\n\nexport function findSetVariableActionForVariable(instance: CodeComponentNode, variableId: NodeID) {\n\tconst props: Record<string, RawControlProp | undefined> = instance.getRawControlProps()\n\tfor (const prop of Object.values(props)) {\n\t\tif (!prop || prop.type !== ControlType.EventHandler) continue\n\t\tconst value = prop.value\n\t\tif (!Array.isArray(value)) continue\n\t\tfor (const action of value) {\n\t\t\tif (!isSetVariableValueAction(action)) continue\n\t\t\tif (action.controls.variableId.value === variableId) return action\n\t\t}\n\t}\n\treturn undefined\n}\n\nexport function expectVariantComputedValueOnVariable(\n\tinstance: CodeComponentNode,\n\tvariable: { id: string },\n\tproviderId: NodeID,\n): ComputedValue {\n\tconst computed = getVariantComputedValue(instance)\n\tassert(computed, \"Expected variant control to be a computed value.\")\n\texpect(computed.outputType).toBe(ControlType.Enum)\n\tassert(isVariableReference(computed.startValue), \"Expected computed value to start from a variable reference.\")\n\texpect(computed.startValue.id).toBe(variable.id)\n\texpect(computed.startValue.providerId).toBe(providerId)\n\tconst { transforms } = computed\n\tassert(\n\t\ttransforms.length === 2 || (transforms.length === 3 && transforms.at(1)?.name === \"negate\"),\n\t\t`Expected 2 transforms, or 3 with a 'negate' as the middle transform; got ${transforms.length}.`,\n\t)\n\treturn computed\n}\n\nexport function expectConvertFromBooleanEnum(transform: ValueTransform | undefined) {\n\tassert(\n\t\ttransform?.name === \"convertFromBoolean\",\n\t\t`Expected a 'convertFromBoolean' transform, got '${transform?.name}'.`,\n\t)\n\texpect(transform.outputType).toBe(ControlType.Enum)\n\treturn transform\n}\n\nexport function getEffectiveBooleanMapping(computed: ComputedValue) {\n\tconst convert = expectConvertFromBooleanEnum(computed.transforms.at(-1))\n\tconst negated = computed.transforms.length === 3\n\treturn {\n\t\ttruthy: negated ? convert.falsy : convert.truthy,\n\t\tfalsy: negated ? convert.truthy : convert.falsy,\n\t}\n}\n"],
  "mappings": ";;;;;;;;;;;;;AAaO,SAAS,uBAAuB,QAA4D;AAClG,QAAM,kBAAkB,OAAO,KAAK,KAAK,SAAS;AAAA,IACjD,CAAC,SAA2C,qBAAqB,IAAI,KAAK,KAAK,SAAS;AAAA,EACzF;AACA,QAAM,iBAAiB,gBAAgB,CAAC;AAExC,SAAO,gBAAgB,yCAAyC;AAChE,SAAO,gBAAgB,WAAW,GAAG,yCAAyC;AAE9E,SAAO;AAC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