@upstart.gg/vite-plugins 0.1.41 → 0.1.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/upstart-editor-api.d.ts +59 -1
  2. package/dist/upstart-editor-api.d.ts.map +1 -1
  3. package/dist/upstart-editor-api.js +273 -4
  4. package/dist/upstart-editor-api.js.map +1 -1
  5. package/dist/vite-plugin-upstart-attrs.d.ts +2 -1
  6. package/dist/vite-plugin-upstart-attrs.d.ts.map +1 -1
  7. package/dist/vite-plugin-upstart-attrs.js +91 -4
  8. package/dist/vite-plugin-upstart-attrs.js.map +1 -1
  9. package/dist/vite-plugin-upstart-editor/runtime/array-controls.js +342 -0
  10. package/dist/vite-plugin-upstart-editor/runtime/array-controls.js.map +1 -0
  11. package/dist/vite-plugin-upstart-editor/runtime/click-handler.d.ts.map +1 -1
  12. package/dist/vite-plugin-upstart-editor/runtime/click-handler.js +29 -2
  13. package/dist/vite-plugin-upstart-editor/runtime/click-handler.js.map +1 -1
  14. package/dist/vite-plugin-upstart-editor/runtime/form-guard.js +80 -0
  15. package/dist/vite-plugin-upstart-editor/runtime/form-guard.js.map +1 -0
  16. package/dist/vite-plugin-upstart-editor/runtime/hover-overlay.d.ts.map +1 -1
  17. package/dist/vite-plugin-upstart-editor/runtime/hover-overlay.js +2 -1
  18. package/dist/vite-plugin-upstart-editor/runtime/hover-overlay.js.map +1 -1
  19. package/dist/vite-plugin-upstart-editor/runtime/index.d.ts.map +1 -1
  20. package/dist/vite-plugin-upstart-editor/runtime/index.js +26 -4
  21. package/dist/vite-plugin-upstart-editor/runtime/index.js.map +1 -1
  22. package/dist/vite-plugin-upstart-editor/runtime/text-editor.d.ts.map +1 -1
  23. package/dist/vite-plugin-upstart-editor/runtime/text-editor.js +40 -36
  24. package/dist/vite-plugin-upstart-editor/runtime/text-editor.js.map +1 -1
  25. package/dist/vite-plugin-upstart-editor/runtime/types.d.ts +20 -4
  26. package/dist/vite-plugin-upstart-editor/runtime/types.d.ts.map +1 -1
  27. package/package.json +3 -3
  28. package/src/tests/vite-plugin-upstart-attrs.test.ts +412 -0
  29. package/src/upstart-editor-api.ts +314 -5
  30. package/src/vite-plugin-upstart-attrs.ts +154 -4
  31. package/src/vite-plugin-upstart-editor/runtime/array-controls.ts +478 -0
  32. package/src/vite-plugin-upstart-editor/runtime/click-handler.ts +43 -0
  33. package/src/vite-plugin-upstart-editor/runtime/form-guard.ts +121 -0
  34. package/src/vite-plugin-upstart-editor/runtime/hover-overlay.ts +6 -1
  35. package/src/vite-plugin-upstart-editor/runtime/index.ts +20 -4
  36. package/src/vite-plugin-upstart-editor/runtime/text-editor.ts +49 -58
  37. package/src/vite-plugin-upstart-editor/runtime/types.ts +31 -4
@@ -1,7 +1,7 @@
1
1
  import MagicString from "magic-string";
2
+ import { parseSync } from "oxc-parser";
2
3
  import path from "node:path";
3
4
  import { createUnplugin } from "unplugin";
4
- import { parseSync } from "oxc-parser";
5
5
  import { walk } from "zimmerframe";
6
6
  import fs from "node:fs";
7
7
  //#region src/vite-plugin-upstart-attrs.ts
@@ -237,7 +237,27 @@ function transformWithOxc(code, filePath) {
237
237
  attributes.push(`data-upstart-id="${id}"`);
238
238
  attributes.push(`data-upstart-mixed-template="${escapeProp(templateStr.trim())}"`);
239
239
  }
240
- } else if (!hasI18n && hasVisibleTextContent(jsxNode)) attributes.push("data-upstart-editable-text=\"false\"");
240
+ } else if (!hasI18n) {
241
+ const arrayItem = detectArrayLiteralItem(jsxNode, state);
242
+ if (arrayItem) {
243
+ attributes.push("data-upstart-editable-text=\"true\"");
244
+ attributes.push("data-upstart-editable-text-mode=\"plain\"");
245
+ for (const el of arrayItem.elements) editableRegistry.set(el.id, {
246
+ file: state.filePath,
247
+ type: "text",
248
+ startOffset: el.startOffset,
249
+ endOffset: el.endOffset,
250
+ originalContent: el.originalContent,
251
+ quote: el.quote,
252
+ context: { parentTag: tagName || "unknown" }
253
+ });
254
+ const idsArray = `[${arrayItem.elements.map((e) => JSON.stringify(e.id)).join(",")}]`;
255
+ attributes.push(`data-upstart-id={${idsArray}[${arrayItem.indexName}]}`);
256
+ const arrayId = `${state.filePath}:${arrayItem.arrayStart}`;
257
+ attributes.push(`data-upstart-array-id="${arrayId}"`);
258
+ attributes.push(`data-upstart-array-index={${arrayItem.indexName}}`);
259
+ } else if (hasVisibleTextContent(jsxNode)) attributes.push("data-upstart-editable-text=\"false\"");
260
+ }
241
261
  const classNameAttr = opening.attributes.find((attr) => attr.type === "JSXAttribute" && attr.name.type === "JSXIdentifier" && attr.name.name === "className" && attr.value?.type === "Literal" && typeof attr.value.value === "string");
242
262
  if (classNameAttr && classNameAttr.value && hasRange(classNameAttr.value)) {
243
263
  const id = generateId(state.filePath, classNameAttr.value);
@@ -252,6 +272,22 @@ function transformWithOxc(code, filePath) {
252
272
  });
253
273
  attributes.push(`data-upstart-classname-id="${id}"`);
254
274
  }
275
+ if (tagName === "img") {
276
+ const srcAttr = opening.attributes.find((attr) => attr.type === "JSXAttribute" && attr.name.type === "JSXIdentifier" && attr.name.name === "src" && attr.value?.type === "Literal" && typeof attr.value.value === "string");
277
+ if (srcAttr && srcAttr.value && hasRange(srcAttr.value)) {
278
+ const id = generateId(state.filePath, srcAttr.value);
279
+ const srcValue = srcAttr.value.value;
280
+ editableRegistry.set(id, {
281
+ file: state.filePath,
282
+ type: "image",
283
+ startOffset: srcAttr.value.start + 1,
284
+ endOffset: srcAttr.value.end - 1,
285
+ originalContent: srcValue,
286
+ context: { parentTag: tagName || "unknown" }
287
+ });
288
+ attributes.push(`data-upstart-image-id="${id}"`);
289
+ }
290
+ }
255
291
  if (tagName && /^[A-Z]/.test(tagName)) {
256
292
  attributes.push(`data-upstart-file="${escapeProp(state.filePath)}"`);
257
293
  attributes.push(`data-upstart-component="${escapeProp(tagName)}"`);
@@ -374,7 +410,8 @@ function detectAndPatchMapCall(node, state) {
374
410
  return {
375
411
  itemName,
376
412
  indexName,
377
- arrayExpr: exprToString(node.callee.object, state.code)
413
+ arrayExpr: exprToString(node.callee.object, state.code),
414
+ arrayNode: node.callee.object
378
415
  };
379
416
  }
380
417
  let searchPos = lastParam.end;
@@ -385,7 +422,8 @@ function detectAndPatchMapCall(node, state) {
385
422
  return {
386
423
  itemName,
387
424
  indexName,
388
- arrayExpr
425
+ arrayExpr,
426
+ arrayNode: node.callee.object
389
427
  };
390
428
  }
391
429
  function escapeProp(value) {
@@ -709,6 +747,55 @@ function hasVisibleTextContent(jsxElement) {
709
747
  }
710
748
  return false;
711
749
  }
750
+ function detectArrayLiteralItem(jsxElement, state) {
751
+ let identName = null;
752
+ for (const child of jsxElement.children) {
753
+ if (child.type === "JSXText") {
754
+ if (normalizeJSXText(child.value).length > 0) return null;
755
+ continue;
756
+ }
757
+ if (child.type === "JSXExpressionContainer") {
758
+ const expr = child.expression;
759
+ if (!expr || expr.type === "JSXEmptyExpression") continue;
760
+ if (expr.type !== "Identifier") return null;
761
+ if (identName !== null) return null;
762
+ identName = expr.name;
763
+ continue;
764
+ }
765
+ return null;
766
+ }
767
+ if (!identName) return null;
768
+ for (let i = state.loopStack.length - 1; i >= 0; i--) {
769
+ const loop = state.loopStack[i];
770
+ if (loop.itemName !== identName) continue;
771
+ if (!loop.indexName) return null;
772
+ const arr = loop.arrayNode;
773
+ if (!arr || arr.type !== "ArrayExpression") return null;
774
+ const elements = [];
775
+ for (const el of arr.elements) {
776
+ if (!el || el.type !== "Literal" || !hasRange(el)) return null;
777
+ const value = el.value;
778
+ if (typeof value !== "string" && typeof value !== "number") return null;
779
+ const isString = typeof value === "string";
780
+ const startOffset = isString ? el.start + 1 : el.start;
781
+ const endOffset = isString ? el.end - 1 : el.end;
782
+ elements.push({
783
+ id: `${state.filePath}:${el.start}`,
784
+ startOffset,
785
+ endOffset,
786
+ originalContent: state.code.slice(startOffset, endOffset),
787
+ quote: isString ? state.code[el.start] : void 0
788
+ });
789
+ }
790
+ if (elements.length === 0) return null;
791
+ return {
792
+ indexName: loop.indexName,
793
+ arrayStart: arr.start,
794
+ elements
795
+ };
796
+ }
797
+ return null;
798
+ }
712
799
  var vite_plugin_upstart_attrs_default = upstartEditor.vite;
713
800
  //#endregion
714
801
  export { clearRegistry, vite_plugin_upstart_attrs_default as default, getRegistry, transformWithOxc, upstartEditor };
@@ -1 +1 @@
1
- {"version":3,"file":"vite-plugin-upstart-attrs.js","names":[],"sources":["../src/vite-plugin-upstart-attrs.ts"],"sourcesContent":["import { createUnplugin } from \"unplugin\";\nimport { parseSync } from \"oxc-parser\";\nimport { walk } from \"zimmerframe\";\nimport MagicString from \"magic-string\";\nimport path from \"path\";\nimport fs from \"node:fs\";\nimport type {\n Program,\n Node,\n JSXElement,\n JSXOpeningElement,\n JSXAttribute,\n Expression,\n CallExpression,\n} from \"estree-jsx\";\n\ninterface Options {\n enabled: boolean;\n emitRegistry?: boolean;\n}\n\ntype NodeWithRange = Node & { start: number; end: number };\n\nfunction hasRange(node: any): node is NodeWithRange {\n return node && typeof node.start === \"number\" && typeof node.end === \"number\";\n}\n\n// Fast, stable hash function (djb2 variant)\n// Produces a short hex string that's stable across rebuilds\nfunction hashContent(content: string): string {\n let hash = 5381;\n for (let i = 0; i < content.length; i++) {\n hash = ((hash << 5) + hash) ^ content.charCodeAt(i);\n }\n // Convert to unsigned 32-bit and then to hex\n return (hash >>> 0).toString(16);\n}\n\ninterface LoopContext {\n itemName: string;\n indexName: string | null;\n arrayExpr: string;\n}\n\ninterface I18nKeyInfo {\n /** The resolved key with namespace, e.g. \"dashboard:features.title\" */\n fullKey: string;\n /** Just the translation key, e.g. \"features.title\" */\n key: string;\n /** The namespace, e.g. \"dashboard\" */\n namespace: string;\n /** Source expression for i18nKey when dynamic (e.g. \"stat.labelKey\"), null when static */\n keyExpr: string | null;\n /** Source expression for namespace when dynamic, null when static */\n nsExpr: string | null;\n /** Variable names from the `values` prop (e.g. [\"year\"] from values={{ year }}) */\n valueKeys?: string[];\n}\n\n// A segment of a mixed-text element: either static text or a JSX expression\nexport interface EditableSegment {\n type: \"text\" | \"expr\";\n // For \"text\": the raw JSX text value (with whitespace/newlines as in source)\n // For \"expr\": the full expression source including braces, e.g. \"{new Date().getFullYear()}\"\n raw: string;\n}\n\n// Registry entry for editable elements (text, rich-text, className, mixed-text)\nexport interface EditableEntry {\n file: string;\n type: \"text\" | \"rich-text\" | \"className\" | \"mixed-text\";\n startOffset: number;\n endOffset: number;\n originalContent: string;\n // Only present for mixed-text entries\n segments?: EditableSegment[];\n context: { parentTag: string };\n}\n\n// Module-level registry (collected across all files during build)\nconst editableRegistry = new Map<string, EditableEntry>();\n\n// Generate stable ID for editable elements\n// Replace the counter-based ID generation with position-based\nfunction generateId(filePath: string, node: NodeWithRange): string {\n // Use file path + start position for a stable, deterministic ID\n return `${filePath}:${node.start}`;\n}\n\n// Export for testing - get a copy of the current registry\nexport function getRegistry(): Record<string, EditableEntry> {\n return Object.fromEntries(editableRegistry);\n}\n\n// Export for testing - clear registry and counters\nexport function clearRegistry(): void {\n editableRegistry.clear();\n}\n\ninterface TransformState {\n filePath: string;\n code: string;\n s: MagicString;\n loopStack: LoopContext[];\n /** Tracks const varName = \"literal\" declarations for resolving dynamic i18nKey expressions */\n constants: Map<string, string>;\n /** Maps t-function variable names to their default namespace, e.g. { \"t\": \"dashboard\" } */\n tFunctions: Map<string, string>;\n}\n\nexport const upstartEditor = createUnplugin<Options>((options) => {\n if (!options.enabled) {\n return { name: \"upstart-editor-disabled\" };\n }\n\n const emitRegistry = options.emitRegistry ?? true;\n let root = process.cwd();\n let isDevMode = false;\n let devWriteTimer: ReturnType<typeof setTimeout> | null = null;\n\n const flushDevRegistry = () => {\n if (!isDevMode || editableRegistry.size === 0) return;\n const registryDir = path.join(root, \"build\", \"server\");\n const registryPath = path.join(registryDir, \"upstart-registry.json\");\n const registry = {\n version: 1,\n generatedAt: new Date().toISOString(),\n elements: Object.fromEntries(editableRegistry),\n };\n fs.mkdirSync(registryDir, { recursive: true });\n fs.writeFileSync(registryPath, JSON.stringify(registry, null, 2));\n };\n\n const scheduleDevRegistryWrite = () => {\n if (!isDevMode) return;\n if (devWriteTimer) clearTimeout(devWriteTimer);\n devWriteTimer = setTimeout(flushDevRegistry, 150);\n };\n\n return {\n name: \"upstart-editor\",\n enforce: \"pre\",\n\n vite: {\n configResolved(config) {\n root = config.root;\n isDevMode = config.command === \"serve\";\n },\n configureServer(_server) {\n isDevMode = true;\n },\n generateBundle() {\n if (!emitRegistry || editableRegistry.size === 0) {\n return;\n }\n\n const registry = {\n version: 1,\n generatedAt: new Date().toISOString(),\n elements: Object.fromEntries(editableRegistry),\n };\n\n this.emitFile({\n type: \"asset\",\n fileName: \"upstart-registry.json\",\n source: JSON.stringify(registry, null, 2),\n });\n\n // Clear for next build\n editableRegistry.clear();\n },\n },\n\n transformInclude(id) {\n return /\\.(tsx|jsx)$/.test(id) && !id.includes(\"node_modules\");\n },\n\n transform(code, id) {\n // Fast path: skip files without JSX\n if (!code.includes(\"<\")) {\n return null;\n }\n\n try {\n const relativePath = path.relative(root, id);\n const result = transformWithOxc(code, relativePath);\n\n if (!result) {\n return null;\n }\n\n scheduleDevRegistryWrite();\n return {\n code: result.code,\n map: result.map,\n };\n } catch (error) {\n console.error(`Error transforming ${id}:`, error);\n return null;\n }\n },\n };\n});\n\nexport function transformWithOxc(code: string, filePath: string) {\n // Parse with oxc (super fast!)\n const ast = parseSync(filePath, code, {\n sourceType: \"module\",\n });\n\n if (!ast.program) {\n return null;\n }\n\n const s = new MagicString(code);\n const state: TransformState = {\n filePath,\n code,\n s,\n loopStack: [],\n constants: new Map(),\n tFunctions: new Map(),\n };\n\n let modified = false;\n\n // Use zimmerframe to walk and transform the AST\n walk(ast.program as Program, state, {\n _(node: Node, { state, next }: { state: TransformState; next: () => void }) {\n // Track useTranslation() calls to resolve t() function namespaces\n if (node.type === \"VariableDeclaration\") {\n trackUseTranslation(node, state);\n\n // Track const varName = \"literal\" for resolving dynamic i18nKey expressions\n for (const decl of (node as any).declarations) {\n if (\n decl.type === \"VariableDeclarator\" &&\n decl.id?.type === \"Identifier\" &&\n decl.init?.type === \"Literal\" &&\n typeof decl.init.value === \"string\"\n ) {\n state.constants.set(decl.id.name, decl.init.value);\n }\n }\n }\n\n // Handle .map() calls to track loops (must be before JSXElement)\n if (node.type === \"CallExpression\") {\n const mapCallInfo = detectAndPatchMapCall(node as CallExpression, state);\n\n if (mapCallInfo) {\n // Push loop context\n state.loopStack.push(mapCallInfo);\n\n // Continue walking into the callback\n next();\n\n // Pop loop context after traversing\n state.loopStack.pop();\n return;\n }\n }\n\n // Handle JSX elements\n if (node.type === \"JSXElement\") {\n const jsxNode = node as JSXElement;\n const opening = jsxNode.openingElement;\n const tagName = getJSXElementName(opening);\n\n // Skip ALL attribute injection for <Trans> elements.\n // <Trans> renders to a text node at runtime, so DOM attributes are lost.\n // The i18n attributes are promoted to the parent element instead.\n if (tagName === \"Trans\") {\n next();\n return;\n }\n\n const insertPos = getAttributeInsertPosition(opening, state.code);\n\n // Track attributes to inject\n const attributes: string[] = [];\n\n // Compute stable hash from the element's source code (includes all children)\n // This hash changes if ANY part of the element or its children change\n if (hasRange(jsxNode)) {\n const elementSource = state.code.slice(jsxNode.start, jsxNode.end);\n const hash = hashContent(elementSource);\n\n // Collect suffix expressions from all enclosing loops so elements\n // inside .map() get a unique hash per iteration at runtime.\n // detectAndPatchMapCall() attempts to auto-inject an index param when missing.\n // If injection is not possible (no stable source range), fall back to \"0\".\n const loopSuffixes = state.loopStack.map((l) => (l.indexName ? `\\${${l.indexName}}` : \"0\"));\n\n if (loopSuffixes.length > 0) {\n const suffix = loopSuffixes.join(\"-\");\n attributes.push(`data-upstart-hash={\\`${hash}-${suffix}\\`}`);\n } else {\n attributes.push(`data-upstart-hash=\"${hash}\"`);\n }\n }\n\n // --- Editable text detection ---\n // Priority: i18n (true) > non-i18n text (false) > no text (no attribute)\n\n // Step 1: Check for Trans children AND t() calls (editable via i18n, gets \"true\")\n const transChildren = findTransInChildren(jsxNode, state.code, state.constants);\n const tCallChildren = findTCallsInChildren(jsxNode, state.code, state);\n const allI18nKeys = [...transChildren, ...tCallChildren];\n const hasI18n = allI18nKeys.length > 0;\n\n if (hasI18n && !hasMixedNonI18nContent(jsxNode, state.code, state, state.constants)) {\n attributes.push('data-upstart-editable-text=\"true\"');\n attributes.push('data-upstart-editable-text-mode=\"plain\"');\n\n const hasDynamic = allI18nKeys.some((t) => t.keyExpr || t.nsExpr);\n if (hasDynamic) {\n // Build a runtime JSX template expression for dynamic i18n keys\n const parts = allI18nKeys.map((t) => {\n const nsPart = t.nsExpr ? `\\${${t.nsExpr}}` : t.namespace;\n const keyPart = t.keyExpr ? `\\${${t.keyExpr}}` : t.key;\n return `${nsPart}:${keyPart}`;\n });\n attributes.push(`data-upstart-i18n={\\`${parts.join(\",\")}\\`}`);\n } else {\n const keys = allI18nKeys.map((t: I18nKeyInfo) => escapeProp(t.fullKey)).join(\",\");\n attributes.push(`data-upstart-i18n=\"${keys}\"`);\n }\n\n const allValueKeys = [...new Set(allI18nKeys.flatMap((t) => t.valueKeys ?? []))];\n if (allValueKeys.length > 0) {\n attributes.push(`data-i18n-values=\"${allValueKeys.join(\",\")}\"`);\n }\n }\n\n // Step 2a: Text leaf elements — plain text, editable directly in the TSX source\n if (isTextLeafElement(jsxNode)) {\n if (!hasI18n) {\n attributes.push('data-upstart-editable-text=\"true\"');\n attributes.push('data-upstart-editable-text-mode=\"direct\"');\n }\n\n // Find the actual JSXText node to track its location\n const textChild = jsxNode.children.find((c) => c.type === \"JSXText\" && (c as any).value?.trim());\n\n if (textChild && hasRange(textChild)) {\n const id = generateId(state.filePath, textChild);\n const textValue = (textChild as any).value as string;\n\n // Calculate trimmed offsets (exclude leading/trailing whitespace)\n const trimmedStart = textChild.start + (textValue.length - textValue.trimStart().length);\n const trimmedEnd = textChild.end - (textValue.length - textValue.trimEnd().length);\n\n editableRegistry.set(id, {\n file: state.filePath,\n type: \"text\",\n startOffset: trimmedStart,\n endOffset: trimmedEnd,\n originalContent: textValue.trim(),\n context: { parentTag: tagName || \"unknown\" },\n });\n\n attributes.push(`data-upstart-id=\"${id}\"`);\n }\n }\n // Step 2b: Almost-leaf elements — inline formatting tags only, editable via InspectorPanel\n else if (!hasI18n && isAlmostLeafElement(jsxNode)) {\n attributes.push('data-upstart-editable-text=\"true\"');\n attributes.push('data-upstart-editable-text-mode=\"rich-panel\"');\n\n // Track the full children range so the server can overwrite them in the TSX source\n const children = jsxNode.children.filter((c) => hasRange(c));\n const firstChild = children[0];\n const lastChild = children[children.length - 1];\n\n if (firstChild && lastChild && hasRange(firstChild) && hasRange(lastChild)) {\n const id = generateId(state.filePath, firstChild);\n const originalContent = state.code.slice(firstChild.start, lastChild.end);\n\n editableRegistry.set(id, {\n file: state.filePath,\n type: \"rich-text\",\n startOffset: firstChild.start,\n endOffset: lastChild.end,\n originalContent,\n context: { parentTag: tagName || \"unknown\" },\n });\n\n attributes.push(`data-upstart-id=\"${id}\"`);\n }\n }\n // Step 2c: Mixed-text leaf — JSXText + JSXExpressionContainer children only.\n // Expressions become non-editable chips; surrounding text is editable.\n else if (!hasI18n && isMixedTextLeafElement(jsxNode)) {\n attributes.push('data-upstart-editable-text=\"true\"');\n attributes.push('data-upstart-editable-text-mode=\"plain\"');\n\n const rangedChildren = jsxNode.children.filter((c) => hasRange(c));\n const firstChild = rangedChildren[0];\n const lastChild = rangedChildren[rangedChildren.length - 1];\n\n if (firstChild && lastChild && hasRange(firstChild) && hasRange(lastChild)) {\n const segments: EditableSegment[] = [];\n let exprIndex = 0;\n let templateStr = \"\";\n\n for (const child of jsxNode.children) {\n if (child.type === \"JSXText\") {\n const normalized = normalizeJSXText((child as any).value as string);\n segments.push({ type: \"text\", raw: (child as any).value as string });\n templateStr += normalized;\n } else if (child.type === \"JSXExpressionContainer\") {\n const expr = (child as any).expression;\n if (!expr || expr.type === \"JSXEmptyExpression\") continue;\n const raw = hasRange(child) ? state.code.slice(child.start, child.end) : \"\";\n segments.push({ type: \"expr\", raw });\n templateStr += `{{${exprIndex++}}}`;\n }\n }\n\n const id = generateId(state.filePath, firstChild);\n const originalContent = state.code.slice(firstChild.start, lastChild.end);\n\n editableRegistry.set(id, {\n file: state.filePath,\n type: \"mixed-text\",\n startOffset: firstChild.start,\n endOffset: lastChild.end,\n originalContent,\n segments,\n context: { parentTag: tagName || \"unknown\" },\n });\n\n attributes.push(`data-upstart-id=\"${id}\"`);\n attributes.push(`data-upstart-mixed-template=\"${escapeProp(templateStr.trim())}\"`);\n }\n }\n // Step 3: Non-leaf elements with visible text content (expressions, mixed content)\n else if (!hasI18n && hasVisibleTextContent(jsxNode)) {\n attributes.push('data-upstart-editable-text=\"false\"');\n }\n\n // Track className attribute if it's a string literal\n const classNameAttr = opening.attributes.find(\n (attr): attr is JSXAttribute =>\n attr.type === \"JSXAttribute\" &&\n attr.name.type === \"JSXIdentifier\" &&\n attr.name.name === \"className\" &&\n attr.value?.type === \"Literal\" &&\n typeof (attr.value as any).value === \"string\",\n );\n\n if (classNameAttr && classNameAttr.value && hasRange(classNameAttr.value)) {\n const id = generateId(state.filePath, classNameAttr.value);\n const classValue = (classNameAttr.value as any).value as string;\n\n // +1 and -1 to exclude the quotes\n editableRegistry.set(id, {\n file: state.filePath,\n type: \"className\",\n startOffset: classNameAttr.value.start + 1,\n endOffset: classNameAttr.value.end - 1,\n originalContent: classValue,\n context: { parentTag: tagName || \"unknown\" },\n });\n\n attributes.push(`data-upstart-classname-id=\"${id}\"`);\n }\n\n // Process PascalCase components for additional tracking\n if (tagName && /^[A-Z]/.test(tagName)) {\n // File and component tracking\n attributes.push(`data-upstart-file=\"${escapeProp(state.filePath)}\"`);\n attributes.push(`data-upstart-component=\"${escapeProp(tagName)}\"`);\n\n // Loop context tracking\n if (state.loopStack.length > 0) {\n const loop = state.loopStack[state.loopStack.length - 1];\n attributes.push(`data-upstart-loop-item=\"${escapeProp(loop.itemName)}\"`);\n if (loop.indexName) {\n attributes.push(`data-upstart-loop-index={${loop.indexName}}`);\n }\n attributes.push(`data-upstart-loop-array=\"${escapeProp(loop.arrayExpr)}\"`);\n }\n\n // Analyze each prop for data bindings\n for (const attr of opening.attributes) {\n if (attr.type !== \"JSXAttribute\" || attr.name.type !== \"JSXIdentifier\") {\n continue;\n }\n\n const propName = attr.name.name;\n const binding = analyzeBinding(attr.value, state.code);\n\n if (binding) {\n attributes.push(`data-upstart-prop-${propName.toLowerCase()}=\"${escapeProp(binding.path)}\"`);\n\n // Track conditional expressions\n if (binding.isConditional) {\n attributes.push(`data-upstart-conditional-${propName.toLowerCase()}=\"true\"`);\n }\n }\n }\n }\n\n // Inject attributes if any\n if (insertPos !== -1 && attributes.length > 0) {\n const attrString = \" \" + attributes.join(\" \");\n state.s.appendLeft(insertPos, attrString);\n modified = true;\n }\n }\n\n next();\n },\n });\n\n if (!modified) {\n return null;\n }\n\n return {\n code: s.toString(),\n map: s.generateMap({ hires: true }),\n };\n}\n\n// Helper: Get JSX element name\nfunction getJSXElementName(opening: JSXOpeningElement): string | null {\n if (opening.name.type === \"JSXIdentifier\") {\n return opening.name.name;\n }\n\n // Handle JSXMemberExpression like <Foo.Bar>\n if (opening.name.type === \"JSXMemberExpression\") {\n let current = opening.name;\n while (current.property) {\n if (current.property.type === \"JSXIdentifier\") {\n return current.property.name;\n }\n if (current.type === \"JSXMemberExpression\") {\n current = current.property as any;\n } else {\n break;\n }\n }\n }\n\n return null;\n}\n\n// Helper: Find where to insert attributes in JSX opening tag\nfunction getAttributeInsertPosition(opening: JSXOpeningElement, code: string): number {\n // If there are existing attributes, insert before the first one\n if (opening.attributes.length > 0) {\n const firstAttr = opening.attributes[0];\n if (hasRange(firstAttr)) {\n return firstAttr.start;\n }\n }\n\n // Otherwise, insert after the tag name\n if (opening.name.type === \"JSXIdentifier\" && hasRange(opening.name)) {\n return opening.name.end;\n }\n\n if (opening.name.type === \"JSXMemberExpression\" && hasRange(opening.name)) {\n return opening.name.end;\n }\n\n return -1;\n}\n\n// Helper: Analyze a prop value to extract data binding\nfunction analyzeBinding(\n value: JSXAttribute[\"value\"],\n code: string,\n): {\n path: string;\n isConditional?: boolean;\n} | null {\n if (!value) {\n return null;\n }\n\n if (value.type === \"JSXExpressionContainer\") {\n const expr = value.expression;\n\n if (expr.type === \"JSXEmptyExpression\") {\n return null;\n }\n\n return analyzeExpression(expr, code);\n }\n\n return null;\n}\n\n// Helper: Analyze any expression to extract binding info\nfunction analyzeExpression(\n expr: Expression,\n code: string,\n): {\n path: string;\n isConditional?: boolean;\n} | null {\n // Handle member expressions: user.name, product.price, etc.\n if (expr.type === \"MemberExpression\") {\n const path = exprToString(expr, code);\n return { path };\n }\n\n // Handle identifiers: userName, price, etc.\n if (expr.type === \"Identifier\") {\n return { path: expr.name };\n }\n\n // Handle conditional expressions: condition ? value1 : value2\n if (expr.type === \"ConditionalExpression\") {\n // Try to extract from the consequent\n const consequent = analyzeExpression(expr.consequent, code);\n if (consequent) {\n return {\n ...consequent,\n isConditional: true,\n path: exprToString(expr, code),\n };\n }\n }\n\n // Handle logical expressions: value1 && value2, value1 || value2\n if (expr.type === \"LogicalExpression\") {\n const right = analyzeExpression(expr.right, code);\n if (right) {\n return {\n ...right,\n isConditional: true,\n path: exprToString(expr, code),\n };\n }\n }\n\n // For other complex expressions, just return the path\n const exprWithRange = expr as any;\n if (exprWithRange.start !== undefined && exprWithRange.end !== undefined) {\n return {\n path: code.slice(exprWithRange.start, exprWithRange.end),\n };\n }\n\n return null;\n}\n\n// Helper: Convert expression AST to string\nfunction exprToString(expr: Expression, code: string): string {\n // Use the source range to get the actual code\n const exprWithRange = expr as any;\n if (exprWithRange.start !== undefined && exprWithRange.end !== undefined) {\n return code.slice(exprWithRange.start, exprWithRange.end);\n }\n\n // Fallback: reconstruct from AST\n if (expr.type === \"Identifier\") {\n return expr.name;\n }\n\n if (expr.type === \"MemberExpression\") {\n const obj = exprToString(expr.object as Expression, code);\n const prop =\n expr.property.type === \"Identifier\" && !expr.computed\n ? expr.property.name\n : exprToString(expr.property as Expression, code);\n return expr.computed ? `${obj}[${prop}]` : `${obj}.${prop}`;\n }\n\n if (expr.type === \"ConditionalExpression\") {\n const test = exprToString(expr.test, code);\n const consequent = exprToString(expr.consequent, code);\n const alternate = exprToString(expr.alternate, code);\n return `${test} ? ${consequent} : ${alternate}`;\n }\n\n if (expr.type === \"LogicalExpression\") {\n const left = exprToString(expr.left, code);\n const right = exprToString(expr.right, code);\n return `${left} ${expr.operator} ${right}`;\n }\n\n return \"\";\n}\n\n// Helper: Detect .map() calls and auto-inject index parameter if missing\nfunction detectAndPatchMapCall(node: CallExpression, state: TransformState): LoopContext | null {\n // Check if this is a .map() call\n if (\n node.callee.type !== \"MemberExpression\" ||\n node.callee.property.type !== \"Identifier\" ||\n node.callee.property.name !== \"map\"\n ) {\n return null;\n }\n\n const callback = node.arguments[0];\n\n if (!callback) {\n return null;\n }\n\n // Check if callback is an arrow function or function expression\n if (callback.type !== \"ArrowFunctionExpression\" && callback.type !== \"FunctionExpression\") {\n return null;\n }\n\n const params = callback.params;\n const itemParam = params[0];\n const indexParam = params[1];\n\n if (!itemParam) {\n return null;\n }\n\n // Extract parameter names\n const itemName = itemParam.type === \"Identifier\" ? itemParam.name : \"item\";\n let indexName = indexParam?.type === \"Identifier\" ? indexParam.name : null;\n\n // If no index parameter exists in arrow function, auto-inject it\n if (!indexName && callback.type === \"ArrowFunctionExpression\") {\n indexName = \"__i\";\n\n // Find the closing paren of the parameter list safely\n const lastParam = params[params.length - 1];\n\n // ESTree `Pattern` type doesn't guarantee source range fields in typings.\n // Guard before reading offsets.\n if (!hasRange(lastParam)) {\n // Can't patch callback params without a stable source offset.\n // Keep indexName as null so hash suffix generation can handle this case.\n indexName = null;\n return {\n itemName,\n indexName,\n arrayExpr: exprToString(node.callee.object as Expression, state.code),\n };\n }\n\n let searchPos = lastParam.end;\n\n // Find the next ) after the last parameter\n while (searchPos < state.code.length && state.code[searchPos] !== \")\") {\n searchPos++;\n }\n\n if (searchPos < state.code.length && state.code[searchPos] === \")\") {\n // Insert the parameter before the closing paren\n state.s.appendLeft(searchPos, \", __i\");\n }\n }\n\n // Get the array expression\n const arrayExpr = exprToString(node.callee.object as Expression, state.code);\n\n return {\n itemName,\n indexName,\n arrayExpr,\n };\n}\n\n// Helper: Escape prop values for JSX attributes\nfunction escapeProp(value: string): string {\n return value\n .replace(/&/g, \"&amp;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&apos;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\");\n}\n\n// Helper: Track useTranslation() calls to map t-function variable names to their namespace\nfunction trackUseTranslation(node: Node, state: TransformState): void {\n if (node.type !== \"VariableDeclaration\") return;\n\n const decl = node as any;\n for (const declarator of decl.declarations) {\n if (\n declarator.id?.type !== \"ObjectPattern\" ||\n !declarator.init ||\n declarator.init.type !== \"CallExpression\"\n ) {\n continue;\n }\n\n const callExpr = declarator.init;\n if (callExpr.callee?.type !== \"Identifier\" || callExpr.callee.name !== \"useTranslation\") {\n continue;\n }\n\n const namespace = extractUseTranslationNamespace(callExpr);\n\n for (const prop of declarator.id.properties) {\n if (prop.type !== \"Property\") continue;\n if (prop.key?.type !== \"Identifier\" || prop.key.name !== \"t\") continue;\n\n // Handle aliased destructuring: { t: translate } → maps \"translate\" to namespace\n const localName = prop.value?.type === \"Identifier\" ? prop.value.name : \"t\";\n state.tFunctions.set(localName, namespace);\n }\n }\n}\n\n// Helper: Extract namespace from useTranslation() call arguments\nfunction extractUseTranslationNamespace(callExpr: any): string {\n const firstArg = callExpr.arguments?.[0];\n if (!firstArg) return \"translation\";\n\n // String literal: useTranslation(\"dashboard\")\n if (firstArg.type === \"Literal\" && typeof firstArg.value === \"string\") {\n return firstArg.value;\n }\n\n // Array expression: useTranslation([\"dashboard\", \"common\"])\n if (firstArg.type === \"ArrayExpression\" && firstArg.elements?.length > 0) {\n const first = firstArg.elements[0];\n if (first?.type === \"Literal\" && typeof first.value === \"string\") {\n return first.value;\n }\n }\n\n return \"translation\";\n}\n\n// Helper: Resolve a JSX attribute value to a string.\n// Handles string literals directly, and JSXExpressionContainer by resolving\n// Identifier references via the constants map, or returning the expression source for dynamic values.\nfunction resolveJSXAttrValue(\n value: any,\n code: string,\n constants: Map<string, string>,\n): { value: string; expr: string | null } | null {\n if (!value) return null;\n\n if (value.type === \"Literal\" && typeof value.value === \"string\") {\n return { value: value.value, expr: null };\n }\n\n if (value.type === \"JSXExpressionContainer\") {\n const expression = value.expression;\n if (!expression) return null;\n\n // Resolve simple identifiers via constants map (e.g. i18nKey={labelKey} where const labelKey = \"...\")\n if (expression.type === \"Identifier\" && constants.has(expression.name)) {\n return { value: constants.get(expression.name)!, expr: null };\n }\n\n // Dynamic expression — return source text so caller can emit a runtime JSX expression\n if (hasRange(expression)) {\n const src = code.slice(expression.start, expression.end);\n return { value: src, expr: src };\n }\n }\n\n return null;\n}\n\n// Helper: Detect <Trans i18nKey=\"...\" /> component and extract i18n key info\nfunction detectTransComponent(\n jsxElement: JSXElement,\n code: string,\n constants: Map<string, string>,\n): I18nKeyInfo | null {\n const opening = jsxElement.openingElement;\n const tagName = getJSXElementName(opening);\n\n if (tagName !== \"Trans\") return null;\n\n let keyResult: { value: string; expr: string | null } | null = null;\n let nsResult: { value: string; expr: string | null } | null = null;\n let valueKeys: string[] | undefined;\n\n for (const attr of opening.attributes) {\n if (attr.type !== \"JSXAttribute\" || attr.name.type !== \"JSXIdentifier\") continue;\n\n const attrName = attr.name.name;\n\n if (attrName === \"i18nKey\") {\n keyResult = resolveJSXAttrValue(attr.value, code, constants);\n }\n\n if (attrName === \"ns\") {\n nsResult = resolveJSXAttrValue(attr.value, code, constants);\n }\n\n if (attrName === \"values\") {\n const container = attr.value as any;\n if (container?.type === \"JSXExpressionContainer\") {\n const expr = container.expression;\n if (expr?.type === \"ObjectExpression\") {\n const keys: string[] = [];\n for (const prop of expr.properties) {\n // oxc-parser uses estree \"Property\"; Babel uses \"ObjectProperty\"\n if ((prop.type === \"Property\" || prop.type === \"ObjectProperty\") && prop.key) {\n if (prop.key.type === \"Identifier\") keys.push(prop.key.name);\n else if (prop.key.type === \"Literal\" || prop.key.type === \"StringLiteral\")\n keys.push(prop.key.value);\n }\n }\n if (keys.length > 0) valueKeys = keys;\n }\n }\n }\n }\n\n if (!keyResult) {\n return null;\n }\n\n const key = keyResult.value;\n const namespace = nsResult?.value ?? \"translation\";\n const keyExpr = keyResult.expr;\n const nsExpr = nsResult?.expr ?? null;\n\n return {\n fullKey: `${namespace}:${key}`,\n key,\n namespace,\n keyExpr,\n nsExpr,\n valueKeys,\n };\n}\n\n// Helper: Scan an element's direct children for <Trans> components and extract i18n key info.\n// Handles direct <Trans> children and <Trans> inside JSXExpressionContainer (e.g. {show && <Trans>}).\nfunction findTransInChildren(\n jsxElement: JSXElement,\n code: string,\n constants: Map<string, string>,\n): I18nKeyInfo[] {\n const results: I18nKeyInfo[] = [];\n\n for (const child of jsxElement.children) {\n if (child.type === \"JSXElement\") {\n const info = detectTransComponent(child as JSXElement, code, constants);\n if (info) results.push(info);\n }\n\n if (child.type === \"JSXExpressionContainer\") {\n const expr = (child as any).expression;\n if (expr && expr.type !== \"JSXEmptyExpression\") {\n findTransInExpression(expr, code, results, constants);\n }\n }\n }\n\n return results;\n}\n\n// Helper: Recursively search an expression tree for <Trans> JSXElements.\n// Handles LogicalExpression (&&, ||), ConditionalExpression (?:), CallExpression (.map()),\n// ArrowFunctionExpression/FunctionExpression (callbacks), BlockStatement, and direct JSXElement.\nfunction findTransInExpression(\n expr: any,\n code: string,\n results: I18nKeyInfo[],\n constants: Map<string, string>,\n): void {\n if (!expr || !expr.type) return;\n\n if (expr.type === \"JSXElement\") {\n const info = detectTransComponent(expr as JSXElement, code, constants);\n if (info) results.push(info);\n return;\n }\n\n if (expr.type === \"LogicalExpression\") {\n findTransInExpression(expr.left, code, results, constants);\n findTransInExpression(expr.right, code, results, constants);\n return;\n }\n\n if (expr.type === \"ConditionalExpression\") {\n findTransInExpression(expr.consequent, code, results, constants);\n findTransInExpression(expr.alternate, code, results, constants);\n return;\n }\n\n // Handle .map() and other call expressions — recurse into arguments\n if (expr.type === \"CallExpression\") {\n for (const arg of expr.arguments) {\n findTransInExpression(arg, code, results, constants);\n }\n return;\n }\n\n // Handle arrow/function expressions — recurse into body\n if (expr.type === \"ArrowFunctionExpression\" || expr.type === \"FunctionExpression\") {\n findTransInExpression(expr.body, code, results, constants);\n return;\n }\n\n // Handle block bodies (arrow functions with braces)\n if (expr.type === \"BlockStatement\") {\n for (const stmt of expr.body) {\n if (stmt.type === \"ReturnStatement\" && stmt.argument) {\n findTransInExpression(stmt.argument, code, results, constants);\n }\n }\n return;\n }\n}\n\n// Helper: Scan an element's direct children for t() function calls and extract i18n key info.\nfunction findTCallsInChildren(jsxElement: JSXElement, code: string, state: TransformState): I18nKeyInfo[] {\n if (state.tFunctions.size === 0) return [];\n\n const results: I18nKeyInfo[] = [];\n\n for (const child of jsxElement.children) {\n if (child.type === \"JSXExpressionContainer\") {\n const expr = (child as any).expression;\n if (expr && expr.type !== \"JSXEmptyExpression\") {\n findTCallInExpression(expr, code, results, state);\n }\n }\n }\n\n return results;\n}\n\n// Returns true if the element mixes i18n content with non-i18n text/expressions.\n// In that case, inline editing would incorrectly overwrite the translation with\n// the full rendered text (including static parts like \"© 2026 Company.\").\n//\n// Safe patterns (NOT mixed):\n// {showWelcome && <Trans>} — boolean guard around Trans\n// {cond ? <Trans a> : <Trans b>} — ternary between two Trans\n// {\" \"} — whitespace-only literal\n//\n// Mixed patterns (flagged):\n// \"© John Doe.\" + <Trans> — non-whitespace JSXText alongside i18n\n// {year} + <Trans> — text-producing Identifier/MemberExpression alongside i18n\nfunction hasMixedNonI18nContent(\n jsxNode: JSXElement,\n code: string,\n state: TransformState,\n constants: Map<string, string>,\n): boolean {\n for (const child of jsxNode.children) {\n if (child.type === \"JSXText\") {\n if (((child as any).value as string).trim().length > 0) return true;\n } else if (child.type === \"JSXExpressionContainer\") {\n const expr = (child as any).expression;\n if (!expr || expr.type === \"JSXEmptyExpression\") continue;\n // Whitespace-only string literal (e.g. {\" \"}) is harmless\n if (expr.type === \"Literal\" && typeof expr.value === \"string\" && expr.value.trim() === \"\") continue;\n // If expression contains i18n content (t() or Trans), it is not non-i18n text\n const tResults: I18nKeyInfo[] = [];\n findTCallInExpression(expr, code, tResults, state);\n if (tResults.length > 0) continue;\n const transResults: I18nKeyInfo[] = [];\n findTransInExpression(expr, code, transResults, constants);\n if (transResults.length > 0) continue;\n // Flag only expressions that produce visible text (same heuristic as hasVisibleTextContent)\n const type = expr.type;\n if (\n type === \"Identifier\" ||\n type === \"MemberExpression\" ||\n type === \"Literal\" ||\n type === \"TemplateLiteral\"\n ) {\n return true;\n }\n }\n }\n return false;\n}\n\n// Helper: Recursively search an expression tree for t() calls.\n// Handles LogicalExpression (&&, ||), ConditionalExpression (?:), CallExpression (.map()),\n// ArrowFunctionExpression/FunctionExpression (callbacks), BlockStatement, and direct CallExpression.\nfunction findTCallInExpression(expr: any, code: string, results: I18nKeyInfo[], state: TransformState): void {\n if (!expr || !expr.type) return;\n\n if (expr.type === \"CallExpression\") {\n const info = detectTCall(expr, code, state);\n if (info) {\n results.push(info);\n return;\n }\n // Not a t() call — recurse into arguments (for .map() callbacks etc.)\n for (const arg of expr.arguments) {\n findTCallInExpression(arg, code, results, state);\n }\n return;\n }\n\n if (expr.type === \"LogicalExpression\") {\n findTCallInExpression(expr.left, code, results, state);\n findTCallInExpression(expr.right, code, results, state);\n return;\n }\n\n if (expr.type === \"ConditionalExpression\") {\n findTCallInExpression(expr.consequent, code, results, state);\n findTCallInExpression(expr.alternate, code, results, state);\n return;\n }\n\n if (expr.type === \"ArrowFunctionExpression\" || expr.type === \"FunctionExpression\") {\n findTCallInExpression(expr.body, code, results, state);\n return;\n }\n\n if (expr.type === \"BlockStatement\") {\n for (const stmt of expr.body) {\n if (stmt.type === \"ReturnStatement\" && stmt.argument) {\n findTCallInExpression(stmt.argument, code, results, state);\n }\n }\n return;\n }\n}\n\n// Helper: Detect a t(\"key\") call and extract i18n key info.\nfunction detectTCall(callExpr: any, code: string, state: TransformState): I18nKeyInfo | null {\n if (callExpr.callee?.type !== \"Identifier\") return null;\n\n const calleeName = callExpr.callee.name;\n const namespace = state.tFunctions.get(calleeName);\n if (namespace === undefined) return null;\n\n const firstArg = callExpr.arguments?.[0];\n if (!firstArg) return null;\n\n // Static string key: t(\"features.title\")\n if (firstArg.type === \"Literal\" && typeof firstArg.value === \"string\") {\n const key = firstArg.value;\n return { fullKey: `${namespace}:${key}`, key, namespace, keyExpr: null, nsExpr: null };\n }\n\n // Dynamic key — try constant resolution first, then fall back to expression\n if (hasRange(firstArg)) {\n const exprSrc = code.slice(firstArg.start, firstArg.end);\n\n if (firstArg.type === \"Identifier\" && state.constants.has(firstArg.name)) {\n const key = state.constants.get(firstArg.name)!;\n return { fullKey: `${namespace}:${key}`, key, namespace, keyExpr: null, nsExpr: null };\n }\n\n return { fullKey: `${namespace}:${exprSrc}`, key: exprSrc, namespace, keyExpr: exprSrc, nsExpr: null };\n }\n\n return null;\n}\n\n// Helper: Check if element is a \"leaf\" with only static text (no nested elements or expressions)\nfunction isTextLeafElement(jsxElement: JSXElement): boolean {\n let hasText = false;\n\n for (const child of jsxElement.children) {\n if (child.type === \"JSXText\") {\n const textValue = (child as any).value;\n if (textValue?.trim()) {\n hasText = true;\n }\n } else if (\n child.type === \"JSXElement\" ||\n child.type === \"JSXFragment\" ||\n child.type === \"JSXExpressionContainer\" ||\n child.type === \"JSXSpreadChild\"\n ) {\n // Has non-text children, not a leaf element\n return false;\n }\n }\n\n return hasText;\n}\n\n// Inline HTML tags that purely style text without introducing block structure.\n// An element whose children are only JSXText + these tags is an \"almost-leaf\"\n// that can be edited as rich text via the InspectorPanel.\nconst INLINE_FORMATTING_TAGS = new Set([\n \"b\",\n \"i\",\n \"em\",\n \"strong\",\n \"u\",\n \"s\",\n \"del\",\n \"ins\",\n \"mark\",\n \"small\",\n \"sub\",\n \"sup\",\n \"code\",\n \"kbd\",\n \"abbr\",\n \"cite\",\n \"time\",\n \"span\",\n \"a\",\n]);\n\n// Returns true if the element's children are exclusively JSXText nodes and\n// known inline formatting tags (no expressions, no block elements, no fragments).\n// Must have at least one inline tag (otherwise it would be a plain text leaf).\n// The inline child tags must themselves be \"simple\" — only JSXText children,\n// no expressions, no attributes — so that <span className=\"...\">{expr}</span>\n// siblings are not mistaken for plain inline formatting wrappers.\nfunction isAlmostLeafElement(jsxElement: JSXElement): boolean {\n let hasInlineElement = false;\n\n for (const child of jsxElement.children) {\n if (child.type === \"JSXText\") {\n continue;\n }\n if (child.type === \"JSXElement\") {\n const childEl = child as JSXElement;\n const tagName = getJSXElementName(childEl.openingElement);\n if (!tagName || !INLINE_FORMATTING_TAGS.has(tagName.toLowerCase())) return false;\n // The inline child must be truly simple: no attributes and only JSXText children.\n // A <span className=\"...\"> or <span>{expr}</span> is not a simple inline wrapper.\n if (childEl.openingElement.attributes.length > 0) return false;\n for (const grandchild of childEl.children) {\n if (grandchild.type !== \"JSXText\") return false;\n }\n hasInlineElement = true;\n } else {\n return false;\n }\n }\n\n return hasInlineElement;\n}\n\n// Normalise a raw JSX text node value the same way React/Babel does at compile time:\n// - Split by newlines\n// - For non-first lines, strip leading whitespace; for non-last lines, strip trailing whitespace\n// - Remove lines that are entirely whitespace\n// - Join surviving lines, appending a space after each non-last non-empty line\nfunction normalizeJSXText(raw: string): string {\n const lines = raw.split(/\\r\\n|\\n|\\r/);\n const lastNonEmptyIdx = lines.reduce((acc, line, i) => (/[^ \\t]/.test(line) ? i : acc), -1);\n let result = \"\";\n for (let i = 0; i < lines.length; i++) {\n let line = lines[i].replace(/\\t/g, \" \");\n if (i > 0) line = line.replace(/^[ ]+/, \"\");\n if (i < lines.length - 1) line = line.replace(/[ ]+$/, \"\");\n if (!line) continue;\n if (i !== lastNonEmptyIdx) line += \" \";\n result += line;\n }\n return result;\n}\n\n// Returns true if the element's children are exclusively JSXText + JSXExpressionContainer nodes\n// (no nested elements), AND it has at least one of each — making the static text parts editable\n// while expressions are rendered as non-editable chips.\nfunction isMixedTextLeafElement(jsxElement: JSXElement): boolean {\n let hasText = false;\n let hasExpr = false;\n\n for (const child of jsxElement.children) {\n if (child.type === \"JSXText\") {\n if (normalizeJSXText((child as any).value as string).length > 0) hasText = true;\n continue;\n }\n if (child.type === \"JSXExpressionContainer\") {\n const expr = (child as any).expression;\n if (!expr || expr.type === \"JSXEmptyExpression\") continue;\n hasExpr = true;\n continue;\n }\n // JSXElement, JSXFragment, JSXSpreadChild → not a pure mixed-text leaf\n return false;\n }\n\n return hasText && hasExpr;\n}\n\n// Helper: Check if element has any visible text content (static or dynamic).\n// Broader than isTextLeafElement — returns true even if the element has other child types.\n// Detects JSXText with non-whitespace content and expression containers with\n// text-producing expressions (Identifier, MemberExpression, Literal, TemplateLiteral).\n// Skips CallExpression, ConditionalExpression, LogicalExpression (these typically produce elements).\nfunction hasVisibleTextContent(jsxElement: JSXElement): boolean {\n for (const child of jsxElement.children) {\n if (child.type === \"JSXText\") {\n const textValue = (child as any).value;\n if (textValue?.trim()) {\n return true;\n }\n continue;\n }\n\n if (child.type === \"JSXExpressionContainer\") {\n const expr = (child as any).expression;\n if (!expr || expr.type === \"JSXEmptyExpression\") {\n continue;\n }\n if (\n expr.type === \"Identifier\" ||\n expr.type === \"MemberExpression\" ||\n expr.type === \"Literal\" ||\n expr.type === \"TemplateLiteral\"\n ) {\n return true;\n }\n }\n }\n\n return false;\n}\n\nexport default upstartEditor.vite;\n"],"mappings":";;;;;;;AAuBA,SAAS,SAAS,MAAkC;CAClD,OAAO,QAAQ,OAAO,KAAK,UAAU,YAAY,OAAO,KAAK,QAAQ;;AAKvE,SAAS,YAAY,SAAyB;CAC5C,IAAI,OAAO;CACX,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAClC,QAAS,QAAQ,KAAK,OAAQ,QAAQ,WAAW,EAAE;CAGrD,QAAQ,SAAS,GAAG,SAAS,GAAG;;AA6ClC,MAAM,mCAAmB,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"sourcesContent":["import { createUnplugin } from \"unplugin\";\nimport { parseSync } from \"oxc-parser\";\nimport { walk } from \"zimmerframe\";\nimport MagicString from \"magic-string\";\nimport path from \"path\";\nimport fs from \"node:fs\";\nimport type {\n Program,\n Node,\n JSXElement,\n JSXOpeningElement,\n JSXAttribute,\n Expression,\n CallExpression,\n} from \"estree-jsx\";\n\ninterface Options {\n enabled: boolean;\n emitRegistry?: boolean;\n}\n\ntype NodeWithRange = Node & { start: number; end: number };\n\nfunction hasRange(node: any): node is NodeWithRange {\n return node && typeof node.start === \"number\" && typeof node.end === \"number\";\n}\n\n// Fast, stable hash function (djb2 variant)\n// Produces a short hex string that's stable across rebuilds\nfunction hashContent(content: string): string {\n let hash = 5381;\n for (let i = 0; i < content.length; i++) {\n hash = ((hash << 5) + hash) ^ content.charCodeAt(i);\n }\n // Convert to unsigned 32-bit and then to hex\n return (hash >>> 0).toString(16);\n}\n\ninterface LoopContext {\n itemName: string;\n indexName: string | null;\n arrayExpr: string;\n /** The `.map()` callee object AST node — used to edit inline array-literal items in place. */\n arrayNode: Node | null;\n}\n\ninterface I18nKeyInfo {\n /** The resolved key with namespace, e.g. \"dashboard:features.title\" */\n fullKey: string;\n /** Just the translation key, e.g. \"features.title\" */\n key: string;\n /** The namespace, e.g. \"dashboard\" */\n namespace: string;\n /** Source expression for i18nKey when dynamic (e.g. \"stat.labelKey\"), null when static */\n keyExpr: string | null;\n /** Source expression for namespace when dynamic, null when static */\n nsExpr: string | null;\n /** Variable names from the `values` prop (e.g. [\"year\"] from values={{ year }}) */\n valueKeys?: string[];\n}\n\n// A segment of a mixed-text element: either static text or a JSX expression\nexport interface EditableSegment {\n type: \"text\" | \"expr\";\n // For \"text\": the raw JSX text value (with whitespace/newlines as in source)\n // For \"expr\": the full expression source including braces, e.g. \"{new Date().getFullYear()}\"\n raw: string;\n}\n\n// Registry entry for editable elements (text, rich-text, className, mixed-text)\nexport interface EditableEntry {\n file: string;\n type: \"text\" | \"rich-text\" | \"className\" | \"mixed-text\" | \"image\";\n startOffset: number;\n endOffset: number;\n originalContent: string;\n // Only present for mixed-text entries\n segments?: EditableSegment[];\n // For text entries that map to a JS string literal (e.g. an inline array item),\n // the source quote character (\" ' or `). When set, the server escapes the new\n // content for that quote style before writing it back between the quotes.\n quote?: string;\n context: { parentTag: string };\n}\n\n// Module-level registry (collected across all files during build)\nconst editableRegistry = new Map<string, EditableEntry>();\n\n// Generate stable ID for editable elements\n// Replace the counter-based ID generation with position-based\nfunction generateId(filePath: string, node: NodeWithRange): string {\n // Use file path + start position for a stable, deterministic ID\n return `${filePath}:${node.start}`;\n}\n\n// Export for testing - get a copy of the current registry\nexport function getRegistry(): Record<string, EditableEntry> {\n return Object.fromEntries(editableRegistry);\n}\n\n// Export for testing - clear registry and counters\nexport function clearRegistry(): void {\n editableRegistry.clear();\n}\n\ninterface TransformState {\n filePath: string;\n code: string;\n s: MagicString;\n loopStack: LoopContext[];\n /** Tracks const varName = \"literal\" declarations for resolving dynamic i18nKey expressions */\n constants: Map<string, string>;\n /** Maps t-function variable names to their default namespace, e.g. { \"t\": \"dashboard\" } */\n tFunctions: Map<string, string>;\n}\n\nexport const upstartEditor = createUnplugin<Options>((options) => {\n if (!options.enabled) {\n return { name: \"upstart-editor-disabled\" };\n }\n\n const emitRegistry = options.emitRegistry ?? true;\n let root = process.cwd();\n let isDevMode = false;\n let devWriteTimer: ReturnType<typeof setTimeout> | null = null;\n\n const flushDevRegistry = () => {\n if (!isDevMode || editableRegistry.size === 0) return;\n const registryDir = path.join(root, \"build\", \"server\");\n const registryPath = path.join(registryDir, \"upstart-registry.json\");\n const registry = {\n version: 1,\n generatedAt: new Date().toISOString(),\n elements: Object.fromEntries(editableRegistry),\n };\n fs.mkdirSync(registryDir, { recursive: true });\n fs.writeFileSync(registryPath, JSON.stringify(registry, null, 2));\n };\n\n const scheduleDevRegistryWrite = () => {\n if (!isDevMode) return;\n if (devWriteTimer) clearTimeout(devWriteTimer);\n devWriteTimer = setTimeout(flushDevRegistry, 150);\n };\n\n return {\n name: \"upstart-editor\",\n enforce: \"pre\",\n\n vite: {\n configResolved(config) {\n root = config.root;\n isDevMode = config.command === \"serve\";\n },\n configureServer(_server) {\n isDevMode = true;\n },\n generateBundle() {\n if (!emitRegistry || editableRegistry.size === 0) {\n return;\n }\n\n const registry = {\n version: 1,\n generatedAt: new Date().toISOString(),\n elements: Object.fromEntries(editableRegistry),\n };\n\n this.emitFile({\n type: \"asset\",\n fileName: \"upstart-registry.json\",\n source: JSON.stringify(registry, null, 2),\n });\n\n // Clear for next build\n editableRegistry.clear();\n },\n },\n\n transformInclude(id) {\n return /\\.(tsx|jsx)$/.test(id) && !id.includes(\"node_modules\");\n },\n\n transform(code, id) {\n // Fast path: skip files without JSX\n if (!code.includes(\"<\")) {\n return null;\n }\n\n try {\n const relativePath = path.relative(root, id);\n const result = transformWithOxc(code, relativePath);\n\n if (!result) {\n return null;\n }\n\n scheduleDevRegistryWrite();\n return {\n code: result.code,\n map: result.map,\n };\n } catch (error) {\n console.error(`Error transforming ${id}:`, error);\n return null;\n }\n },\n };\n});\n\nexport function transformWithOxc(code: string, filePath: string) {\n // Parse with oxc (super fast!)\n const ast = parseSync(filePath, code, {\n sourceType: \"module\",\n });\n\n if (!ast.program) {\n return null;\n }\n\n const s = new MagicString(code);\n const state: TransformState = {\n filePath,\n code,\n s,\n loopStack: [],\n constants: new Map(),\n tFunctions: new Map(),\n };\n\n let modified = false;\n\n // Use zimmerframe to walk and transform the AST\n walk(ast.program as Program, state, {\n _(node: Node, { state, next }: { state: TransformState; next: () => void }) {\n // Track useTranslation() calls to resolve t() function namespaces\n if (node.type === \"VariableDeclaration\") {\n trackUseTranslation(node, state);\n\n // Track const varName = \"literal\" for resolving dynamic i18nKey expressions\n for (const decl of (node as any).declarations) {\n if (\n decl.type === \"VariableDeclarator\" &&\n decl.id?.type === \"Identifier\" &&\n decl.init?.type === \"Literal\" &&\n typeof decl.init.value === \"string\"\n ) {\n state.constants.set(decl.id.name, decl.init.value);\n }\n }\n }\n\n // Handle .map() calls to track loops (must be before JSXElement)\n if (node.type === \"CallExpression\") {\n const mapCallInfo = detectAndPatchMapCall(node as CallExpression, state);\n\n if (mapCallInfo) {\n // Push loop context\n state.loopStack.push(mapCallInfo);\n\n // Continue walking into the callback\n next();\n\n // Pop loop context after traversing\n state.loopStack.pop();\n return;\n }\n }\n\n // Handle JSX elements\n if (node.type === \"JSXElement\") {\n const jsxNode = node as JSXElement;\n const opening = jsxNode.openingElement;\n const tagName = getJSXElementName(opening);\n\n // Skip ALL attribute injection for <Trans> elements.\n // <Trans> renders to a text node at runtime, so DOM attributes are lost.\n // The i18n attributes are promoted to the parent element instead.\n if (tagName === \"Trans\") {\n next();\n return;\n }\n\n const insertPos = getAttributeInsertPosition(opening, state.code);\n\n // Track attributes to inject\n const attributes: string[] = [];\n\n // Compute stable hash from the element's source code (includes all children)\n // This hash changes if ANY part of the element or its children change\n if (hasRange(jsxNode)) {\n const elementSource = state.code.slice(jsxNode.start, jsxNode.end);\n const hash = hashContent(elementSource);\n\n // Collect suffix expressions from all enclosing loops so elements\n // inside .map() get a unique hash per iteration at runtime.\n // detectAndPatchMapCall() attempts to auto-inject an index param when missing.\n // If injection is not possible (no stable source range), fall back to \"0\".\n const loopSuffixes = state.loopStack.map((l) => (l.indexName ? `\\${${l.indexName}}` : \"0\"));\n\n if (loopSuffixes.length > 0) {\n const suffix = loopSuffixes.join(\"-\");\n attributes.push(`data-upstart-hash={\\`${hash}-${suffix}\\`}`);\n } else {\n attributes.push(`data-upstart-hash=\"${hash}\"`);\n }\n }\n\n // --- Editable text detection ---\n // Priority: i18n (true) > non-i18n text (false) > no text (no attribute)\n\n // Step 1: Check for Trans children AND t() calls (editable via i18n, gets \"true\")\n const transChildren = findTransInChildren(jsxNode, state.code, state.constants);\n const tCallChildren = findTCallsInChildren(jsxNode, state.code, state);\n const allI18nKeys = [...transChildren, ...tCallChildren];\n const hasI18n = allI18nKeys.length > 0;\n\n if (hasI18n && !hasMixedNonI18nContent(jsxNode, state.code, state, state.constants)) {\n attributes.push('data-upstart-editable-text=\"true\"');\n attributes.push('data-upstart-editable-text-mode=\"plain\"');\n\n const hasDynamic = allI18nKeys.some((t) => t.keyExpr || t.nsExpr);\n if (hasDynamic) {\n // Build a runtime JSX template expression for dynamic i18n keys\n const parts = allI18nKeys.map((t) => {\n const nsPart = t.nsExpr ? `\\${${t.nsExpr}}` : t.namespace;\n const keyPart = t.keyExpr ? `\\${${t.keyExpr}}` : t.key;\n return `${nsPart}:${keyPart}`;\n });\n attributes.push(`data-upstart-i18n={\\`${parts.join(\",\")}\\`}`);\n } else {\n const keys = allI18nKeys.map((t: I18nKeyInfo) => escapeProp(t.fullKey)).join(\",\");\n attributes.push(`data-upstart-i18n=\"${keys}\"`);\n }\n\n const allValueKeys = [...new Set(allI18nKeys.flatMap((t) => t.valueKeys ?? []))];\n if (allValueKeys.length > 0) {\n attributes.push(`data-i18n-values=\"${allValueKeys.join(\",\")}\"`);\n }\n }\n\n // Step 2a: Text leaf elements — plain text, editable directly in the TSX source\n if (isTextLeafElement(jsxNode)) {\n if (!hasI18n) {\n attributes.push('data-upstart-editable-text=\"true\"');\n attributes.push('data-upstart-editable-text-mode=\"direct\"');\n }\n\n // Find the actual JSXText node to track its location\n const textChild = jsxNode.children.find((c) => c.type === \"JSXText\" && (c as any).value?.trim());\n\n if (textChild && hasRange(textChild)) {\n const id = generateId(state.filePath, textChild);\n const textValue = (textChild as any).value as string;\n\n // Calculate trimmed offsets (exclude leading/trailing whitespace)\n const trimmedStart = textChild.start + (textValue.length - textValue.trimStart().length);\n const trimmedEnd = textChild.end - (textValue.length - textValue.trimEnd().length);\n\n editableRegistry.set(id, {\n file: state.filePath,\n type: \"text\",\n startOffset: trimmedStart,\n endOffset: trimmedEnd,\n originalContent: textValue.trim(),\n context: { parentTag: tagName || \"unknown\" },\n });\n\n attributes.push(`data-upstart-id=\"${id}\"`);\n }\n }\n // Step 2b: Almost-leaf elements — inline formatting tags only, editable via InspectorPanel\n else if (!hasI18n && isAlmostLeafElement(jsxNode)) {\n attributes.push('data-upstart-editable-text=\"true\"');\n attributes.push('data-upstart-editable-text-mode=\"rich-panel\"');\n\n // Track the full children range so the server can overwrite them in the TSX source\n const children = jsxNode.children.filter((c) => hasRange(c));\n const firstChild = children[0];\n const lastChild = children[children.length - 1];\n\n if (firstChild && lastChild && hasRange(firstChild) && hasRange(lastChild)) {\n const id = generateId(state.filePath, firstChild);\n const originalContent = state.code.slice(firstChild.start, lastChild.end);\n\n editableRegistry.set(id, {\n file: state.filePath,\n type: \"rich-text\",\n startOffset: firstChild.start,\n endOffset: lastChild.end,\n originalContent,\n context: { parentTag: tagName || \"unknown\" },\n });\n\n attributes.push(`data-upstart-id=\"${id}\"`);\n }\n }\n // Step 2c: Mixed-text leaf — JSXText + JSXExpressionContainer children only.\n // Expressions become non-editable chips; surrounding text is editable.\n else if (!hasI18n && isMixedTextLeafElement(jsxNode)) {\n attributes.push('data-upstart-editable-text=\"true\"');\n attributes.push('data-upstart-editable-text-mode=\"plain\"');\n\n const rangedChildren = jsxNode.children.filter((c) => hasRange(c));\n const firstChild = rangedChildren[0];\n const lastChild = rangedChildren[rangedChildren.length - 1];\n\n if (firstChild && lastChild && hasRange(firstChild) && hasRange(lastChild)) {\n const segments: EditableSegment[] = [];\n let exprIndex = 0;\n let templateStr = \"\";\n\n for (const child of jsxNode.children) {\n if (child.type === \"JSXText\") {\n const normalized = normalizeJSXText((child as any).value as string);\n segments.push({ type: \"text\", raw: (child as any).value as string });\n templateStr += normalized;\n } else if (child.type === \"JSXExpressionContainer\") {\n const expr = (child as any).expression;\n if (!expr || expr.type === \"JSXEmptyExpression\") continue;\n const raw = hasRange(child) ? state.code.slice(child.start, child.end) : \"\";\n segments.push({ type: \"expr\", raw });\n templateStr += `{{${exprIndex++}}}`;\n }\n }\n\n const id = generateId(state.filePath, firstChild);\n const originalContent = state.code.slice(firstChild.start, lastChild.end);\n\n editableRegistry.set(id, {\n file: state.filePath,\n type: \"mixed-text\",\n startOffset: firstChild.start,\n endOffset: lastChild.end,\n originalContent,\n segments,\n context: { parentTag: tagName || \"unknown\" },\n });\n\n attributes.push(`data-upstart-id=\"${id}\"`);\n attributes.push(`data-upstart-mixed-template=\"${escapeProp(templateStr.trim())}\"`);\n }\n }\n // Step 2d: Inline array-literal map item — <span>{item}</span> where `item` is the\n // param of a .map() over an inline array of literals. Each instance edits the\n // matching source string literal directly, addressed via the loop index.\n else if (!hasI18n) {\n const arrayItem = detectArrayLiteralItem(jsxNode, state);\n if (arrayItem) {\n attributes.push('data-upstart-editable-text=\"true\"');\n // \"plain\" mode + a data-upstart-id routes saves through editTextDirect while\n // keeping the editor plain-text (no rich HTML written into the string literal).\n attributes.push('data-upstart-editable-text-mode=\"plain\"');\n\n for (const el of arrayItem.elements) {\n editableRegistry.set(el.id, {\n file: state.filePath,\n type: \"text\",\n startOffset: el.startOffset,\n endOffset: el.endOffset,\n originalContent: el.originalContent,\n quote: el.quote,\n context: { parentTag: tagName || \"unknown\" },\n });\n }\n\n // Each rendered instance resolves its own id via the loop index, so the\n // edit targets the correct array element in source.\n const idsArray = `[${arrayItem.elements.map((e) => JSON.stringify(e.id)).join(\",\")}]`;\n attributes.push(`data-upstart-id={${idsArray}[${arrayItem.indexName}]}`);\n\n // Array identity + per-instance index drive the editor's add/delete (×/+)\n // controls, which add or remove elements of the inline array literal.\n const arrayId = `${state.filePath}:${arrayItem.arrayStart}`;\n attributes.push(`data-upstart-array-id=\"${arrayId}\"`);\n attributes.push(`data-upstart-array-index={${arrayItem.indexName}}`);\n } else if (hasVisibleTextContent(jsxNode)) {\n // Step 3: Non-leaf / dynamic text we cannot edit in place.\n attributes.push('data-upstart-editable-text=\"false\"');\n }\n }\n\n // Track className attribute if it's a string literal\n const classNameAttr = opening.attributes.find(\n (attr): attr is JSXAttribute =>\n attr.type === \"JSXAttribute\" &&\n attr.name.type === \"JSXIdentifier\" &&\n attr.name.name === \"className\" &&\n attr.value?.type === \"Literal\" &&\n typeof (attr.value as any).value === \"string\",\n );\n\n if (classNameAttr && classNameAttr.value && hasRange(classNameAttr.value)) {\n const id = generateId(state.filePath, classNameAttr.value);\n const classValue = (classNameAttr.value as any).value as string;\n\n // +1 and -1 to exclude the quotes\n editableRegistry.set(id, {\n file: state.filePath,\n type: \"className\",\n startOffset: classNameAttr.value.start + 1,\n endOffset: classNameAttr.value.end - 1,\n originalContent: classValue,\n context: { parentTag: tagName || \"unknown\" },\n });\n\n attributes.push(`data-upstart-classname-id=\"${id}\"`);\n }\n\n // Track <img src=\"...\"> when src is a string literal → makes the image\n // swappable from the editor (mirrors the className tracking above).\n if (tagName === \"img\") {\n const srcAttr = opening.attributes.find(\n (attr): attr is JSXAttribute =>\n attr.type === \"JSXAttribute\" &&\n attr.name.type === \"JSXIdentifier\" &&\n attr.name.name === \"src\" &&\n attr.value?.type === \"Literal\" &&\n typeof (attr.value as any).value === \"string\",\n );\n\n if (srcAttr && srcAttr.value && hasRange(srcAttr.value)) {\n const id = generateId(state.filePath, srcAttr.value);\n const srcValue = (srcAttr.value as any).value as string;\n\n // +1 / -1 to exclude the surrounding quotes, like className above\n editableRegistry.set(id, {\n file: state.filePath,\n type: \"image\",\n startOffset: srcAttr.value.start + 1,\n endOffset: srcAttr.value.end - 1,\n originalContent: srcValue,\n context: { parentTag: tagName || \"unknown\" },\n });\n\n attributes.push(`data-upstart-image-id=\"${id}\"`);\n }\n }\n\n // Process PascalCase components for additional tracking\n if (tagName && /^[A-Z]/.test(tagName)) {\n // File and component tracking\n attributes.push(`data-upstart-file=\"${escapeProp(state.filePath)}\"`);\n attributes.push(`data-upstart-component=\"${escapeProp(tagName)}\"`);\n\n // Loop context tracking\n if (state.loopStack.length > 0) {\n const loop = state.loopStack[state.loopStack.length - 1];\n attributes.push(`data-upstart-loop-item=\"${escapeProp(loop.itemName)}\"`);\n if (loop.indexName) {\n attributes.push(`data-upstart-loop-index={${loop.indexName}}`);\n }\n attributes.push(`data-upstart-loop-array=\"${escapeProp(loop.arrayExpr)}\"`);\n }\n\n // Analyze each prop for data bindings\n for (const attr of opening.attributes) {\n if (attr.type !== \"JSXAttribute\" || attr.name.type !== \"JSXIdentifier\") {\n continue;\n }\n\n const propName = attr.name.name;\n const binding = analyzeBinding(attr.value, state.code);\n\n if (binding) {\n attributes.push(`data-upstart-prop-${propName.toLowerCase()}=\"${escapeProp(binding.path)}\"`);\n\n // Track conditional expressions\n if (binding.isConditional) {\n attributes.push(`data-upstart-conditional-${propName.toLowerCase()}=\"true\"`);\n }\n }\n }\n }\n\n // Inject attributes if any\n if (insertPos !== -1 && attributes.length > 0) {\n const attrString = \" \" + attributes.join(\" \");\n state.s.appendLeft(insertPos, attrString);\n modified = true;\n }\n }\n\n next();\n },\n });\n\n if (!modified) {\n return null;\n }\n\n return {\n code: s.toString(),\n map: s.generateMap({ hires: true }),\n };\n}\n\n// Helper: Get JSX element name\nfunction getJSXElementName(opening: JSXOpeningElement): string | null {\n if (opening.name.type === \"JSXIdentifier\") {\n return opening.name.name;\n }\n\n // Handle JSXMemberExpression like <Foo.Bar>\n if (opening.name.type === \"JSXMemberExpression\") {\n let current = opening.name;\n while (current.property) {\n if (current.property.type === \"JSXIdentifier\") {\n return current.property.name;\n }\n if (current.type === \"JSXMemberExpression\") {\n current = current.property as any;\n } else {\n break;\n }\n }\n }\n\n return null;\n}\n\n// Helper: Find where to insert attributes in JSX opening tag\nfunction getAttributeInsertPosition(opening: JSXOpeningElement, code: string): number {\n // If there are existing attributes, insert before the first one\n if (opening.attributes.length > 0) {\n const firstAttr = opening.attributes[0];\n if (hasRange(firstAttr)) {\n return firstAttr.start;\n }\n }\n\n // Otherwise, insert after the tag name\n if (opening.name.type === \"JSXIdentifier\" && hasRange(opening.name)) {\n return opening.name.end;\n }\n\n if (opening.name.type === \"JSXMemberExpression\" && hasRange(opening.name)) {\n return opening.name.end;\n }\n\n return -1;\n}\n\n// Helper: Analyze a prop value to extract data binding\nfunction analyzeBinding(\n value: JSXAttribute[\"value\"],\n code: string,\n): {\n path: string;\n isConditional?: boolean;\n} | null {\n if (!value) {\n return null;\n }\n\n if (value.type === \"JSXExpressionContainer\") {\n const expr = value.expression;\n\n if (expr.type === \"JSXEmptyExpression\") {\n return null;\n }\n\n return analyzeExpression(expr, code);\n }\n\n return null;\n}\n\n// Helper: Analyze any expression to extract binding info\nfunction analyzeExpression(\n expr: Expression,\n code: string,\n): {\n path: string;\n isConditional?: boolean;\n} | null {\n // Handle member expressions: user.name, product.price, etc.\n if (expr.type === \"MemberExpression\") {\n const path = exprToString(expr, code);\n return { path };\n }\n\n // Handle identifiers: userName, price, etc.\n if (expr.type === \"Identifier\") {\n return { path: expr.name };\n }\n\n // Handle conditional expressions: condition ? value1 : value2\n if (expr.type === \"ConditionalExpression\") {\n // Try to extract from the consequent\n const consequent = analyzeExpression(expr.consequent, code);\n if (consequent) {\n return {\n ...consequent,\n isConditional: true,\n path: exprToString(expr, code),\n };\n }\n }\n\n // Handle logical expressions: value1 && value2, value1 || value2\n if (expr.type === \"LogicalExpression\") {\n const right = analyzeExpression(expr.right, code);\n if (right) {\n return {\n ...right,\n isConditional: true,\n path: exprToString(expr, code),\n };\n }\n }\n\n // For other complex expressions, just return the path\n const exprWithRange = expr as any;\n if (exprWithRange.start !== undefined && exprWithRange.end !== undefined) {\n return {\n path: code.slice(exprWithRange.start, exprWithRange.end),\n };\n }\n\n return null;\n}\n\n// Helper: Convert expression AST to string\nfunction exprToString(expr: Expression, code: string): string {\n // Use the source range to get the actual code\n const exprWithRange = expr as any;\n if (exprWithRange.start !== undefined && exprWithRange.end !== undefined) {\n return code.slice(exprWithRange.start, exprWithRange.end);\n }\n\n // Fallback: reconstruct from AST\n if (expr.type === \"Identifier\") {\n return expr.name;\n }\n\n if (expr.type === \"MemberExpression\") {\n const obj = exprToString(expr.object as Expression, code);\n const prop =\n expr.property.type === \"Identifier\" && !expr.computed\n ? expr.property.name\n : exprToString(expr.property as Expression, code);\n return expr.computed ? `${obj}[${prop}]` : `${obj}.${prop}`;\n }\n\n if (expr.type === \"ConditionalExpression\") {\n const test = exprToString(expr.test, code);\n const consequent = exprToString(expr.consequent, code);\n const alternate = exprToString(expr.alternate, code);\n return `${test} ? ${consequent} : ${alternate}`;\n }\n\n if (expr.type === \"LogicalExpression\") {\n const left = exprToString(expr.left, code);\n const right = exprToString(expr.right, code);\n return `${left} ${expr.operator} ${right}`;\n }\n\n return \"\";\n}\n\n// Helper: Detect .map() calls and auto-inject index parameter if missing\nfunction detectAndPatchMapCall(node: CallExpression, state: TransformState): LoopContext | null {\n // Check if this is a .map() call\n if (\n node.callee.type !== \"MemberExpression\" ||\n node.callee.property.type !== \"Identifier\" ||\n node.callee.property.name !== \"map\"\n ) {\n return null;\n }\n\n const callback = node.arguments[0];\n\n if (!callback) {\n return null;\n }\n\n // Check if callback is an arrow function or function expression\n if (callback.type !== \"ArrowFunctionExpression\" && callback.type !== \"FunctionExpression\") {\n return null;\n }\n\n const params = callback.params;\n const itemParam = params[0];\n const indexParam = params[1];\n\n if (!itemParam) {\n return null;\n }\n\n // Extract parameter names\n const itemName = itemParam.type === \"Identifier\" ? itemParam.name : \"item\";\n let indexName = indexParam?.type === \"Identifier\" ? indexParam.name : null;\n\n // If no index parameter exists in arrow function, auto-inject it\n if (!indexName && callback.type === \"ArrowFunctionExpression\") {\n indexName = \"__i\";\n\n // Find the closing paren of the parameter list safely\n const lastParam = params[params.length - 1];\n\n // ESTree `Pattern` type doesn't guarantee source range fields in typings.\n // Guard before reading offsets.\n if (!hasRange(lastParam)) {\n // Can't patch callback params without a stable source offset.\n // Keep indexName as null so hash suffix generation can handle this case.\n indexName = null;\n return {\n itemName,\n indexName,\n arrayExpr: exprToString(node.callee.object as Expression, state.code),\n arrayNode: node.callee.object as Node,\n };\n }\n\n let searchPos = lastParam.end;\n\n // Find the next ) after the last parameter\n while (searchPos < state.code.length && state.code[searchPos] !== \")\") {\n searchPos++;\n }\n\n if (searchPos < state.code.length && state.code[searchPos] === \")\") {\n // Insert the parameter before the closing paren\n state.s.appendLeft(searchPos, \", __i\");\n }\n }\n\n // Get the array expression\n const arrayExpr = exprToString(node.callee.object as Expression, state.code);\n\n return {\n itemName,\n indexName,\n arrayExpr,\n arrayNode: node.callee.object as Node,\n };\n}\n\n// Helper: Escape prop values for JSX attributes\nfunction escapeProp(value: string): string {\n return value\n .replace(/&/g, \"&amp;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&apos;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\");\n}\n\n// Helper: Track useTranslation() calls to map t-function variable names to their namespace\nfunction trackUseTranslation(node: Node, state: TransformState): void {\n if (node.type !== \"VariableDeclaration\") return;\n\n const decl = node as any;\n for (const declarator of decl.declarations) {\n if (\n declarator.id?.type !== \"ObjectPattern\" ||\n !declarator.init ||\n declarator.init.type !== \"CallExpression\"\n ) {\n continue;\n }\n\n const callExpr = declarator.init;\n if (callExpr.callee?.type !== \"Identifier\" || callExpr.callee.name !== \"useTranslation\") {\n continue;\n }\n\n const namespace = extractUseTranslationNamespace(callExpr);\n\n for (const prop of declarator.id.properties) {\n if (prop.type !== \"Property\") continue;\n if (prop.key?.type !== \"Identifier\" || prop.key.name !== \"t\") continue;\n\n // Handle aliased destructuring: { t: translate } → maps \"translate\" to namespace\n const localName = prop.value?.type === \"Identifier\" ? prop.value.name : \"t\";\n state.tFunctions.set(localName, namespace);\n }\n }\n}\n\n// Helper: Extract namespace from useTranslation() call arguments\nfunction extractUseTranslationNamespace(callExpr: any): string {\n const firstArg = callExpr.arguments?.[0];\n if (!firstArg) return \"translation\";\n\n // String literal: useTranslation(\"dashboard\")\n if (firstArg.type === \"Literal\" && typeof firstArg.value === \"string\") {\n return firstArg.value;\n }\n\n // Array expression: useTranslation([\"dashboard\", \"common\"])\n if (firstArg.type === \"ArrayExpression\" && firstArg.elements?.length > 0) {\n const first = firstArg.elements[0];\n if (first?.type === \"Literal\" && typeof first.value === \"string\") {\n return first.value;\n }\n }\n\n return \"translation\";\n}\n\n// Helper: Resolve a JSX attribute value to a string.\n// Handles string literals directly, and JSXExpressionContainer by resolving\n// Identifier references via the constants map, or returning the expression source for dynamic values.\nfunction resolveJSXAttrValue(\n value: any,\n code: string,\n constants: Map<string, string>,\n): { value: string; expr: string | null } | null {\n if (!value) return null;\n\n if (value.type === \"Literal\" && typeof value.value === \"string\") {\n return { value: value.value, expr: null };\n }\n\n if (value.type === \"JSXExpressionContainer\") {\n const expression = value.expression;\n if (!expression) return null;\n\n // Resolve simple identifiers via constants map (e.g. i18nKey={labelKey} where const labelKey = \"...\")\n if (expression.type === \"Identifier\" && constants.has(expression.name)) {\n return { value: constants.get(expression.name)!, expr: null };\n }\n\n // Dynamic expression — return source text so caller can emit a runtime JSX expression\n if (hasRange(expression)) {\n const src = code.slice(expression.start, expression.end);\n return { value: src, expr: src };\n }\n }\n\n return null;\n}\n\n// Helper: Detect <Trans i18nKey=\"...\" /> component and extract i18n key info\nfunction detectTransComponent(\n jsxElement: JSXElement,\n code: string,\n constants: Map<string, string>,\n): I18nKeyInfo | null {\n const opening = jsxElement.openingElement;\n const tagName = getJSXElementName(opening);\n\n if (tagName !== \"Trans\") return null;\n\n let keyResult: { value: string; expr: string | null } | null = null;\n let nsResult: { value: string; expr: string | null } | null = null;\n let valueKeys: string[] | undefined;\n\n for (const attr of opening.attributes) {\n if (attr.type !== \"JSXAttribute\" || attr.name.type !== \"JSXIdentifier\") continue;\n\n const attrName = attr.name.name;\n\n if (attrName === \"i18nKey\") {\n keyResult = resolveJSXAttrValue(attr.value, code, constants);\n }\n\n if (attrName === \"ns\") {\n nsResult = resolveJSXAttrValue(attr.value, code, constants);\n }\n\n if (attrName === \"values\") {\n const container = attr.value as any;\n if (container?.type === \"JSXExpressionContainer\") {\n const expr = container.expression;\n if (expr?.type === \"ObjectExpression\") {\n const keys: string[] = [];\n for (const prop of expr.properties) {\n // oxc-parser uses estree \"Property\"; Babel uses \"ObjectProperty\"\n if ((prop.type === \"Property\" || prop.type === \"ObjectProperty\") && prop.key) {\n if (prop.key.type === \"Identifier\") keys.push(prop.key.name);\n else if (prop.key.type === \"Literal\" || prop.key.type === \"StringLiteral\")\n keys.push(prop.key.value);\n }\n }\n if (keys.length > 0) valueKeys = keys;\n }\n }\n }\n }\n\n if (!keyResult) {\n return null;\n }\n\n const key = keyResult.value;\n const namespace = nsResult?.value ?? \"translation\";\n const keyExpr = keyResult.expr;\n const nsExpr = nsResult?.expr ?? null;\n\n return {\n fullKey: `${namespace}:${key}`,\n key,\n namespace,\n keyExpr,\n nsExpr,\n valueKeys,\n };\n}\n\n// Helper: Scan an element's direct children for <Trans> components and extract i18n key info.\n// Handles direct <Trans> children and <Trans> inside JSXExpressionContainer (e.g. {show && <Trans>}).\nfunction findTransInChildren(\n jsxElement: JSXElement,\n code: string,\n constants: Map<string, string>,\n): I18nKeyInfo[] {\n const results: I18nKeyInfo[] = [];\n\n for (const child of jsxElement.children) {\n if (child.type === \"JSXElement\") {\n const info = detectTransComponent(child as JSXElement, code, constants);\n if (info) results.push(info);\n }\n\n if (child.type === \"JSXExpressionContainer\") {\n const expr = (child as any).expression;\n if (expr && expr.type !== \"JSXEmptyExpression\") {\n findTransInExpression(expr, code, results, constants);\n }\n }\n }\n\n return results;\n}\n\n// Helper: Recursively search an expression tree for <Trans> JSXElements.\n// Handles LogicalExpression (&&, ||), ConditionalExpression (?:), CallExpression (.map()),\n// ArrowFunctionExpression/FunctionExpression (callbacks), BlockStatement, and direct JSXElement.\nfunction findTransInExpression(\n expr: any,\n code: string,\n results: I18nKeyInfo[],\n constants: Map<string, string>,\n): void {\n if (!expr || !expr.type) return;\n\n if (expr.type === \"JSXElement\") {\n const info = detectTransComponent(expr as JSXElement, code, constants);\n if (info) results.push(info);\n return;\n }\n\n if (expr.type === \"LogicalExpression\") {\n findTransInExpression(expr.left, code, results, constants);\n findTransInExpression(expr.right, code, results, constants);\n return;\n }\n\n if (expr.type === \"ConditionalExpression\") {\n findTransInExpression(expr.consequent, code, results, constants);\n findTransInExpression(expr.alternate, code, results, constants);\n return;\n }\n\n // Handle .map() and other call expressions — recurse into arguments\n if (expr.type === \"CallExpression\") {\n for (const arg of expr.arguments) {\n findTransInExpression(arg, code, results, constants);\n }\n return;\n }\n\n // Handle arrow/function expressions — recurse into body\n if (expr.type === \"ArrowFunctionExpression\" || expr.type === \"FunctionExpression\") {\n findTransInExpression(expr.body, code, results, constants);\n return;\n }\n\n // Handle block bodies (arrow functions with braces)\n if (expr.type === \"BlockStatement\") {\n for (const stmt of expr.body) {\n if (stmt.type === \"ReturnStatement\" && stmt.argument) {\n findTransInExpression(stmt.argument, code, results, constants);\n }\n }\n return;\n }\n}\n\n// Helper: Scan an element's direct children for t() function calls and extract i18n key info.\nfunction findTCallsInChildren(jsxElement: JSXElement, code: string, state: TransformState): I18nKeyInfo[] {\n if (state.tFunctions.size === 0) return [];\n\n const results: I18nKeyInfo[] = [];\n\n for (const child of jsxElement.children) {\n if (child.type === \"JSXExpressionContainer\") {\n const expr = (child as any).expression;\n if (expr && expr.type !== \"JSXEmptyExpression\") {\n findTCallInExpression(expr, code, results, state);\n }\n }\n }\n\n return results;\n}\n\n// Returns true if the element mixes i18n content with non-i18n text/expressions.\n// In that case, inline editing would incorrectly overwrite the translation with\n// the full rendered text (including static parts like \"© 2026 Company.\").\n//\n// Safe patterns (NOT mixed):\n// {showWelcome && <Trans>} — boolean guard around Trans\n// {cond ? <Trans a> : <Trans b>} — ternary between two Trans\n// {\" \"} — whitespace-only literal\n//\n// Mixed patterns (flagged):\n// \"© John Doe.\" + <Trans> — non-whitespace JSXText alongside i18n\n// {year} + <Trans> — text-producing Identifier/MemberExpression alongside i18n\nfunction hasMixedNonI18nContent(\n jsxNode: JSXElement,\n code: string,\n state: TransformState,\n constants: Map<string, string>,\n): boolean {\n for (const child of jsxNode.children) {\n if (child.type === \"JSXText\") {\n if (((child as any).value as string).trim().length > 0) return true;\n } else if (child.type === \"JSXExpressionContainer\") {\n const expr = (child as any).expression;\n if (!expr || expr.type === \"JSXEmptyExpression\") continue;\n // Whitespace-only string literal (e.g. {\" \"}) is harmless\n if (expr.type === \"Literal\" && typeof expr.value === \"string\" && expr.value.trim() === \"\") continue;\n // If expression contains i18n content (t() or Trans), it is not non-i18n text\n const tResults: I18nKeyInfo[] = [];\n findTCallInExpression(expr, code, tResults, state);\n if (tResults.length > 0) continue;\n const transResults: I18nKeyInfo[] = [];\n findTransInExpression(expr, code, transResults, constants);\n if (transResults.length > 0) continue;\n // Flag only expressions that produce visible text (same heuristic as hasVisibleTextContent)\n const type = expr.type;\n if (\n type === \"Identifier\" ||\n type === \"MemberExpression\" ||\n type === \"Literal\" ||\n type === \"TemplateLiteral\"\n ) {\n return true;\n }\n }\n }\n return false;\n}\n\n// Helper: Recursively search an expression tree for t() calls.\n// Handles LogicalExpression (&&, ||), ConditionalExpression (?:), CallExpression (.map()),\n// ArrowFunctionExpression/FunctionExpression (callbacks), BlockStatement, and direct CallExpression.\nfunction findTCallInExpression(expr: any, code: string, results: I18nKeyInfo[], state: TransformState): void {\n if (!expr || !expr.type) return;\n\n if (expr.type === \"CallExpression\") {\n const info = detectTCall(expr, code, state);\n if (info) {\n results.push(info);\n return;\n }\n // Not a t() call — recurse into arguments (for .map() callbacks etc.)\n for (const arg of expr.arguments) {\n findTCallInExpression(arg, code, results, state);\n }\n return;\n }\n\n if (expr.type === \"LogicalExpression\") {\n findTCallInExpression(expr.left, code, results, state);\n findTCallInExpression(expr.right, code, results, state);\n return;\n }\n\n if (expr.type === \"ConditionalExpression\") {\n findTCallInExpression(expr.consequent, code, results, state);\n findTCallInExpression(expr.alternate, code, results, state);\n return;\n }\n\n if (expr.type === \"ArrowFunctionExpression\" || expr.type === \"FunctionExpression\") {\n findTCallInExpression(expr.body, code, results, state);\n return;\n }\n\n if (expr.type === \"BlockStatement\") {\n for (const stmt of expr.body) {\n if (stmt.type === \"ReturnStatement\" && stmt.argument) {\n findTCallInExpression(stmt.argument, code, results, state);\n }\n }\n return;\n }\n}\n\n// Helper: Detect a t(\"key\") call and extract i18n key info.\nfunction detectTCall(callExpr: any, code: string, state: TransformState): I18nKeyInfo | null {\n if (callExpr.callee?.type !== \"Identifier\") return null;\n\n const calleeName = callExpr.callee.name;\n const namespace = state.tFunctions.get(calleeName);\n if (namespace === undefined) return null;\n\n const firstArg = callExpr.arguments?.[0];\n if (!firstArg) return null;\n\n // Static string key: t(\"features.title\")\n if (firstArg.type === \"Literal\" && typeof firstArg.value === \"string\") {\n const key = firstArg.value;\n return { fullKey: `${namespace}:${key}`, key, namespace, keyExpr: null, nsExpr: null };\n }\n\n // Dynamic key — try constant resolution first, then fall back to expression\n if (hasRange(firstArg)) {\n const exprSrc = code.slice(firstArg.start, firstArg.end);\n\n if (firstArg.type === \"Identifier\" && state.constants.has(firstArg.name)) {\n const key = state.constants.get(firstArg.name)!;\n return { fullKey: `${namespace}:${key}`, key, namespace, keyExpr: null, nsExpr: null };\n }\n\n return { fullKey: `${namespace}:${exprSrc}`, key: exprSrc, namespace, keyExpr: exprSrc, nsExpr: null };\n }\n\n return null;\n}\n\n// Helper: Check if element is a \"leaf\" with only static text (no nested elements or expressions)\nfunction isTextLeafElement(jsxElement: JSXElement): boolean {\n let hasText = false;\n\n for (const child of jsxElement.children) {\n if (child.type === \"JSXText\") {\n const textValue = (child as any).value;\n if (textValue?.trim()) {\n hasText = true;\n }\n } else if (\n child.type === \"JSXElement\" ||\n child.type === \"JSXFragment\" ||\n child.type === \"JSXExpressionContainer\" ||\n child.type === \"JSXSpreadChild\"\n ) {\n // Has non-text children, not a leaf element\n return false;\n }\n }\n\n return hasText;\n}\n\n// Inline HTML tags that purely style text without introducing block structure.\n// An element whose children are only JSXText + these tags is an \"almost-leaf\"\n// that can be edited as rich text via the InspectorPanel.\nconst INLINE_FORMATTING_TAGS = new Set([\n \"b\",\n \"i\",\n \"em\",\n \"strong\",\n \"u\",\n \"s\",\n \"del\",\n \"ins\",\n \"mark\",\n \"small\",\n \"sub\",\n \"sup\",\n \"code\",\n \"kbd\",\n \"abbr\",\n \"cite\",\n \"time\",\n \"span\",\n \"a\",\n]);\n\n// Returns true if the element's children are exclusively JSXText nodes and\n// known inline formatting tags (no expressions, no block elements, no fragments).\n// Must have at least one inline tag (otherwise it would be a plain text leaf).\n// The inline child tags must themselves be \"simple\" — only JSXText children,\n// no expressions, no attributes — so that <span className=\"...\">{expr}</span>\n// siblings are not mistaken for plain inline formatting wrappers.\nfunction isAlmostLeafElement(jsxElement: JSXElement): boolean {\n let hasInlineElement = false;\n\n for (const child of jsxElement.children) {\n if (child.type === \"JSXText\") {\n continue;\n }\n if (child.type === \"JSXElement\") {\n const childEl = child as JSXElement;\n const tagName = getJSXElementName(childEl.openingElement);\n if (!tagName || !INLINE_FORMATTING_TAGS.has(tagName.toLowerCase())) return false;\n // The inline child must be truly simple: no attributes and only JSXText children.\n // A <span className=\"...\"> or <span>{expr}</span> is not a simple inline wrapper.\n if (childEl.openingElement.attributes.length > 0) return false;\n for (const grandchild of childEl.children) {\n if (grandchild.type !== \"JSXText\") return false;\n }\n hasInlineElement = true;\n } else {\n return false;\n }\n }\n\n return hasInlineElement;\n}\n\n// Normalise a raw JSX text node value the same way React/Babel does at compile time:\n// - Split by newlines\n// - For non-first lines, strip leading whitespace; for non-last lines, strip trailing whitespace\n// - Remove lines that are entirely whitespace\n// - Join surviving lines, appending a space after each non-last non-empty line\nfunction normalizeJSXText(raw: string): string {\n const lines = raw.split(/\\r\\n|\\n|\\r/);\n const lastNonEmptyIdx = lines.reduce((acc, line, i) => (/[^ \\t]/.test(line) ? i : acc), -1);\n let result = \"\";\n for (let i = 0; i < lines.length; i++) {\n let line = lines[i].replace(/\\t/g, \" \");\n if (i > 0) line = line.replace(/^[ ]+/, \"\");\n if (i < lines.length - 1) line = line.replace(/[ ]+$/, \"\");\n if (!line) continue;\n if (i !== lastNonEmptyIdx) line += \" \";\n result += line;\n }\n return result;\n}\n\n// Returns true if the element's children are exclusively JSXText + JSXExpressionContainer nodes\n// (no nested elements), AND it has at least one of each — making the static text parts editable\n// while expressions are rendered as non-editable chips.\nfunction isMixedTextLeafElement(jsxElement: JSXElement): boolean {\n let hasText = false;\n let hasExpr = false;\n\n for (const child of jsxElement.children) {\n if (child.type === \"JSXText\") {\n if (normalizeJSXText((child as any).value as string).length > 0) hasText = true;\n continue;\n }\n if (child.type === \"JSXExpressionContainer\") {\n const expr = (child as any).expression;\n if (!expr || expr.type === \"JSXEmptyExpression\") continue;\n hasExpr = true;\n continue;\n }\n // JSXElement, JSXFragment, JSXSpreadChild → not a pure mixed-text leaf\n return false;\n }\n\n return hasText && hasExpr;\n}\n\n// Helper: Check if element has any visible text content (static or dynamic).\n// Broader than isTextLeafElement — returns true even if the element has other child types.\n// Detects JSXText with non-whitespace content and expression containers with\n// text-producing expressions (Identifier, MemberExpression, Literal, TemplateLiteral).\n// Skips CallExpression, ConditionalExpression, LogicalExpression (these typically produce elements).\nfunction hasVisibleTextContent(jsxElement: JSXElement): boolean {\n for (const child of jsxElement.children) {\n if (child.type === \"JSXText\") {\n const textValue = (child as any).value;\n if (textValue?.trim()) {\n return true;\n }\n continue;\n }\n\n if (child.type === \"JSXExpressionContainer\") {\n const expr = (child as any).expression;\n if (!expr || expr.type === \"JSXEmptyExpression\") {\n continue;\n }\n if (\n expr.type === \"Identifier\" ||\n expr.type === \"MemberExpression\" ||\n expr.type === \"Literal\" ||\n expr.type === \"TemplateLiteral\"\n ) {\n return true;\n }\n }\n }\n\n return false;\n}\n\n// Per-element data needed to make an inline array-literal map item editable.\ninterface ArrayLiteralItemInfo {\n /** Loop index variable name used to pick the matching id at runtime, e.g. \"__i\". */\n indexName: string;\n /** Source start offset of the `[` — identifies the array for add/delete operations. */\n arrayStart: number;\n elements: {\n id: string;\n startOffset: number;\n endOffset: number;\n originalContent: string;\n /** Source quote char for string literals (\" ' or `); undefined for numbers. */\n quote?: string;\n }[];\n}\n\n// Detect `<span>{item}</span>` where `item` is the item param of an enclosing\n// `.map()` over an INLINE array literal of string/number literals, e.g.:\n// {[\"TypeScript\", \"React\"].map((item) => <span>{item}</span>)}\n// In that case each rendered instance maps 1:1 (via the loop index) to a source\n// string literal we can edit directly. Returns null for anything not statically\n// resolvable (array from props/variable, transformed item, non-literal elements).\nfunction detectArrayLiteralItem(jsxElement: JSXElement, state: TransformState): ArrayLiteralItemInfo | null {\n // The element's only meaningful child must be a single {identifier} expression.\n let identName: string | null = null;\n for (const child of jsxElement.children) {\n if (child.type === \"JSXText\") {\n if (normalizeJSXText((child as any).value as string).length > 0) return null;\n continue;\n }\n if (child.type === \"JSXExpressionContainer\") {\n const expr = (child as any).expression;\n if (!expr || expr.type === \"JSXEmptyExpression\") continue;\n if (expr.type !== \"Identifier\") return null;\n if (identName !== null) return null; // more than one expression — not a plain item render\n identName = expr.name as string;\n continue;\n }\n // Any nested element/fragment/spread disqualifies.\n return null;\n }\n if (!identName) return null;\n\n // Find the enclosing loop whose item param matches the identifier (innermost first).\n for (let i = state.loopStack.length - 1; i >= 0; i--) {\n const loop = state.loopStack[i];\n if (loop.itemName !== identName) continue;\n // Need a stable per-instance index and an inline array of literals.\n if (!loop.indexName) return null;\n const arr = loop.arrayNode as any;\n if (!arr || arr.type !== \"ArrayExpression\") return null;\n\n const elements: ArrayLiteralItemInfo[\"elements\"] = [];\n for (const el of arr.elements) {\n // Only plain string/number literals can be rewritten in place.\n if (!el || el.type !== \"Literal\" || !hasRange(el)) return null;\n const value = (el as any).value;\n if (typeof value !== \"string\" && typeof value !== \"number\") return null;\n // For strings, the inner range excludes the surrounding quotes so we only\n // overwrite the content (mirrors how <img src> edits work).\n const isString = typeof value === \"string\";\n const startOffset = isString ? el.start + 1 : el.start;\n const endOffset = isString ? el.end - 1 : el.end;\n elements.push({\n id: `${state.filePath}:${el.start}`,\n startOffset,\n endOffset,\n originalContent: state.code.slice(startOffset, endOffset),\n // The opening quote sits at el.start for string literals.\n quote: isString ? state.code[el.start] : undefined,\n });\n }\n if (elements.length === 0) return null;\n return { indexName: lo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