{
  "version": 3,
  "sources": ["../../src/app/ai/agents/evals2/scenarios/component/convertComponentMaxWidth.eval.ts"],
  "sourcesContent": ["import { assert } from \"@framerjs/shared\"\nimport type { VekterEngine } from \"document/VekterEngine.ts\"\nimport type {\n\tCodeComponentNode,\n\tLoadedSmartComponentNode,\n\tLoadedWebPageNode,\n} from \"document/models/CanvasTree/index.ts\"\nimport type { NodeID } from \"document/models/CanvasTree/nodes/NodeID.ts\"\nimport {\n\tisCodeComponentNode,\n\tisSmartComponentNode,\n\tisWebPageNode,\n} from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { createCSSDimension } from \"document/models/CanvasTree/traits/utils/CSSDimension.ts\"\nimport { CREATE_COMPONENT_FROM_FRAME_TOOL_NAME } from \"../../../tools/toolNames.ts\"\nimport { agentEvalAsset } from \"../../harness/asset.ts\"\nimport { createEvalExportZipFixture } from \"../../harness/fixture.ts\"\n\nconst requestId = \"NUucNrr1d\"\nconst originalNavigationFrameId: NodeID = \"uhALqim6w\"\nconst expectedMaxWidths = [\"900px\", \"760px\", \"390px\"]\n\nfunction findNavigationComponent(engine: VekterEngine): LoadedSmartComponentNode | undefined {\n\treturn engine.tree.root.children\n\t\t.filter((node): node is LoadedSmartComponentNode => isSmartComponentNode(node) && node.isLoaded())\n\t\t.find(component => component.baseVariantId === originalNavigationFrameId || component.name === \"Navigation\")\n}\n\nfunction getLoadedWebPage(engine: VekterEngine): LoadedWebPageNode {\n\tconst pages = engine.tree.root.children.filter(\n\t\t(node): node is LoadedWebPageNode => isWebPageNode(node) && node.isLoaded(),\n\t)\n\tassert(pages.length === 1, `Expected one loaded web page, found ${pages.length}.`)\n\tconst [page] = pages\n\tassert(page, \"Expected a loaded web page.\")\n\treturn page\n}\n\nfunction getComponentInstances(engine: VekterEngine, component: LoadedSmartComponentNode): CodeComponentNode[] {\n\tconst page = getLoadedWebPage(engine)\n\treturn Array.from(page.walk()).filter(\n\t\t(node): node is CodeComponentNode =>\n\t\t\tisCodeComponentNode(node) && node.codeComponentIdentifier === component.instanceIdentifier,\n\t)\n}\n\nfunction normalizeMaxWidth(maxWidth: CodeComponentNode[\"maxWidth\"]): string | undefined {\n\tif (typeof maxWidth === \"number\") return createCSSDimension(maxWidth, \"px\")\n\treturn maxWidth\n}\n\nevaluation(\n\t\"Component: Conversion Preserves Max Width\",\n\tcreateEvalExportZipFixture(\n\t\t\"component-conversion-preserves-max-width\",\n\t\tagentEvalAsset(\"../checklist/checklist-behavior.fixture.zip\"),\n\t\t{ runtimeTarget: \"cli\" },\n\t),\n\t{\n\t\tid: \"component-conversion-preserves-max-width\",\n\t\trequestId,\n\t\tstepIndex: 0,\n\t\tmaxSteps: 3,\n\t\trunOnStepFinish: true,\n\t\tstopWhenPassed: true,\n\t},\n\t({ agent, engine, report, tools }) => {\n\t\tconst request = agent.chatMessages.at(-1)\n\n\t\treport.correctness.required(\"continues captured component request\", () => {\n\t\t\texpect(request?.id).toBe(requestId)\n\t\t})\n\t\treport.correctness.required(\"uses the component creation tool for the navigation\", () => {\n\t\t\tconst componentFromCall = tools.firstCall(\n\t\t\t\tCREATE_COMPONENT_FROM_FRAME_TOOL_NAME,\n\t\t\t\tcall => call.input.id === originalNavigationFrameId,\n\t\t\t)\n\t\t\texpect(componentFromCall).toBeDefined()\n\t\t})\n\t\treport.correctness.required(\"creates a loaded Navigation component\", () => {\n\t\t\texpect(findNavigationComponent(engine)).toBeDefined()\n\t\t})\n\t\treport.correctness.required(\"creates at least two Navigation component variants\", () => {\n\t\t\tconst component = findNavigationComponent(engine)\n\t\t\tassert(component, \"Expected a Navigation component.\")\n\t\t\texpect(component.getTopLevelVariants().length).toBeGreaterThanOrEqual(2)\n\t\t})\n\t\treport.correctness.scored(\"keeps max width on replacement component instances\", () => {\n\t\t\tconst component = findNavigationComponent(engine)\n\t\t\tassert(component, \"Expected a Navigation component.\")\n\t\t\tconst maxWidths = getComponentInstances(engine, component).map(instance => normalizeMaxWidth(instance.maxWidth))\n\n\t\t\texpect(maxWidths).toEqual(expect.arrayContaining(expectedMaxWidths))\n\t\t})\n\t\treport.correctness.scored(\"does not produce command errors\", () => {\n\t\t\texpect(tools.commandErrors()).toHaveLength(0)\n\t\t})\n\t},\n)\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,IAAM,YAAY;AAClB,IAAM,4BAAoC;AAC1C,IAAM,oBAAoB,CAAC,SAAS,SAAS,OAAO;AAEpD,SAAS,wBAAwB,QAA4D;AAC5F,SAAO,OAAO,KAAK,KAAK,SACtB,OAAO,CAAC,SAA2C,qBAAqB,IAAI,KAAK,KAAK,SAAS,CAAC,EAChG,KAAK,eAAa,UAAU,kBAAkB,6BAA6B,UAAU,SAAS,YAAY;AAC7G;AAEA,SAAS,iBAAiB,QAAyC;AAClE,QAAM,QAAQ,OAAO,KAAK,KAAK,SAAS;AAAA,IACvC,CAAC,SAAoC,cAAc,IAAI,KAAK,KAAK,SAAS;AAAA,EAC3E;AACA,SAAO,MAAM,WAAW,GAAG,uCAAuC,MAAM,MAAM,GAAG;AACjF,QAAM,CAAC,IAAI,IAAI;AACf,SAAO,MAAM,6BAA6B;AAC1C,SAAO;AACR;AAEA,SAAS,sBAAsB,QAAsB,WAA0D;AAC9G,QAAM,OAAO,iBAAiB,MAAM;AACpC,SAAO,MAAM,KAAK,KAAK,KAAK,CAAC,EAAE;AAAA,IAC9B,CAAC,SACA,oBAAoB,IAAI,KAAK,KAAK,4BAA4B,UAAU;AAAA,EAC1E;AACD;AAEA,SAAS,kBAAkB,UAA6D;AACvF,MAAI,OAAO,aAAa,SAAU,QAAO,mBAAmB,UAAU,IAAI;AAC1E,SAAO;AACR;AAEA;AAAA,EACC;AAAA,EACA;AAAA,IACC;AAAA,IACA,eAAe,6CAA6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