made-refine 0.2.2 → 0.2.4
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.
- package/README.md +1 -1
- package/dist/index.d.mts +24 -6
- package/dist/index.d.ts +24 -6
- package/dist/index.js +1741 -865
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1742 -866
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/{utils-BHGlXxF7.d.mts → utils-C7RBdUAE.d.mts} +8 -1
- package/dist/{utils-BHGlXxF7.d.ts → utils-C7RBdUAE.d.ts} +8 -1
- package/dist/utils.d.mts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +9 -0
- package/dist/utils.js.map +1 -1
- package/dist/utils.mjs +8 -0
- package/dist/utils.mjs.map +1 -1
- package/package.json +1 -1
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils.ts","../src/utils/css-value.ts"],"sourcesContent":["import type {\n CSSPropertyValue,\n SpacingProperties,\n BorderRadiusProperties,\n BorderStyle,\n BorderProperties,\n FlexProperties,\n SizingProperties,\n SizingValue,\n SizingMode,\n SpacingPropertyKey,\n BorderRadiusPropertyKey,\n BorderPropertyKey,\n FlexPropertyKey,\n SizingPropertyKey,\n TypographyPropertyKey,\n TypographyProperties,\n ElementInfo,\n ReactComponentFrame,\n ElementLocator,\n DomSourceLocation,\n ColorValue,\n ColorProperties,\n ColorPropertyKey,\n MeasurementLine,\n Guideline,\n DropIndicator,\n SessionEdit,\n Comment,\n} from './types'\n\nexport { parsePropertyValue, formatPropertyValue } from './utils/css-value'\nimport { parsePropertyValue } from './utils/css-value'\n\nexport function clamp(value: number, min: number, max: number): number {\n if (!Number.isFinite(value)) return min\n if (max < min) return min\n return Math.max(min, Math.min(max, value))\n}\n\ndeclare global {\n interface Window {\n __DIRECT_EDIT_DEVTOOLS__?: {\n getFiberForElement: (element: HTMLElement) => unknown | null\n hasHook?: boolean\n }\n }\n}\n\nexport function getComputedStyles(element: HTMLElement): {\n spacing: SpacingProperties\n borderRadius: BorderRadiusProperties\n flex: FlexProperties\n} {\n const computed = window.getComputedStyle(element)\n\n return {\n spacing: {\n paddingTop: parsePropertyValue(computed.paddingTop),\n paddingRight: parsePropertyValue(computed.paddingRight),\n paddingBottom: parsePropertyValue(computed.paddingBottom),\n paddingLeft: parsePropertyValue(computed.paddingLeft),\n marginTop: parsePropertyValue(computed.marginTop),\n marginRight: parsePropertyValue(computed.marginRight),\n marginBottom: parsePropertyValue(computed.marginBottom),\n marginLeft: parsePropertyValue(computed.marginLeft),\n gap: parsePropertyValue(computed.gap || '0px'),\n },\n borderRadius: {\n borderTopLeftRadius: parsePropertyValue(computed.borderTopLeftRadius),\n borderTopRightRadius: parsePropertyValue(computed.borderTopRightRadius),\n borderBottomRightRadius: parsePropertyValue(computed.borderBottomRightRadius),\n borderBottomLeftRadius: parsePropertyValue(computed.borderBottomLeftRadius),\n },\n flex: {\n display: computed.display,\n flexDirection: computed.flexDirection as FlexProperties['flexDirection'],\n justifyContent: computed.justifyContent,\n alignItems: computed.alignItems,\n },\n }\n}\n\nexport function getComputedBorderStyles(element: HTMLElement): BorderProperties {\n const computed = window.getComputedStyle(element)\n\n const topStyle = computed.borderTopStyle as BorderStyle\n const rightStyle = computed.borderRightStyle as BorderStyle\n const bottomStyle = computed.borderBottomStyle as BorderStyle\n const leftStyle = computed.borderLeftStyle as BorderStyle\n\n const topWidth = parsePropertyValue(computed.borderTopWidth)\n const rightWidth = parsePropertyValue(computed.borderRightWidth)\n const bottomWidth = parsePropertyValue(computed.borderBottomWidth)\n const leftWidth = parsePropertyValue(computed.borderLeftWidth)\n\n return {\n borderTopStyle: topStyle,\n borderTopWidth: topWidth,\n borderRightStyle: rightStyle,\n borderRightWidth: rightWidth,\n borderBottomStyle: bottomStyle,\n borderBottomWidth: bottomWidth,\n borderLeftStyle: leftStyle,\n borderLeftWidth: leftWidth,\n }\n}\n\n/** CSS properties captured before editing so resetToOriginal can restore them. */\nexport const ORIGINAL_STYLE_PROPS = [\n 'padding-top',\n 'padding-right',\n 'padding-bottom',\n 'padding-left',\n 'padding',\n 'margin-top',\n 'margin-right',\n 'margin-bottom',\n 'margin-left',\n 'margin',\n 'gap',\n 'border-radius',\n 'border-top-left-radius',\n 'border-top-right-radius',\n 'border-bottom-right-radius',\n 'border-bottom-left-radius',\n 'border',\n 'border-style',\n 'border-width',\n 'border-top-style',\n 'border-top-width',\n 'border-right-style',\n 'border-right-width',\n 'border-bottom-style',\n 'border-bottom-width',\n 'border-left-style',\n 'border-left-width',\n 'display',\n 'flex-direction',\n 'justify-content',\n 'align-items',\n 'width',\n 'height',\n 'background-color',\n 'color',\n 'border-color',\n 'outline-color',\n 'outline-style',\n 'outline-width',\n 'box-shadow',\n 'font-family',\n 'font-weight',\n 'font-size',\n 'line-height',\n 'letter-spacing',\n 'text-align',\n] as const\n\nexport function getOriginalInlineStyles(element: HTMLElement): Record<string, string> {\n const styles: Record<string, string> = {}\n\n for (const prop of ORIGINAL_STYLE_PROPS) {\n const value = element.style.getPropertyValue(prop)\n if (value) {\n styles[prop] = value\n }\n }\n\n return styles\n}\n\nconst spacingScale: Record<number, string> = { 0: '0', 1: 'px', 2: '0.5', 4: '1', 8: '2', 12: '3', 16: '4', 20: '5', 24: '6', 32: '8' }\n\nconst tailwindClassMap: Record<string, { prefix: string; scale: Record<number, string> }> = {\n padding: { prefix: 'p', scale: spacingScale },\n 'padding-inline': { prefix: 'px', scale: spacingScale },\n 'padding-block': { prefix: 'py', scale: spacingScale },\n 'padding-top': { prefix: 'pt', scale: spacingScale },\n 'padding-right': { prefix: 'pr', scale: spacingScale },\n 'padding-bottom': { prefix: 'pb', scale: spacingScale },\n 'padding-left': { prefix: 'pl', scale: spacingScale },\n margin: { prefix: 'm', scale: spacingScale },\n 'margin-inline': { prefix: 'mx', scale: spacingScale },\n 'margin-block': { prefix: 'my', scale: spacingScale },\n 'margin-top': { prefix: 'mt', scale: spacingScale },\n 'margin-right': { prefix: 'mr', scale: spacingScale },\n 'margin-bottom': { prefix: 'mb', scale: spacingScale },\n 'margin-left': { prefix: 'ml', scale: spacingScale },\n gap: { prefix: 'gap', scale: spacingScale },\n 'border-width': {\n prefix: 'border',\n scale: { 0: '0', 1: '', 2: '2', 4: '4', 8: '8' },\n },\n 'border-top-width': {\n prefix: 'border-t',\n scale: { 0: '0', 1: '', 2: '2', 4: '4', 8: '8' },\n },\n 'border-right-width': {\n prefix: 'border-r',\n scale: { 0: '0', 1: '', 2: '2', 4: '4', 8: '8' },\n },\n 'border-bottom-width': {\n prefix: 'border-b',\n scale: { 0: '0', 1: '', 2: '2', 4: '4', 8: '8' },\n },\n 'border-left-width': {\n prefix: 'border-l',\n scale: { 0: '0', 1: '', 2: '2', 4: '4', 8: '8' },\n },\n 'border-radius': {\n prefix: 'rounded',\n scale: { 0: 'none', 2: 'sm', 4: '', 6: 'md', 8: 'lg', 12: 'xl', 16: '2xl', 24: '3xl', 9999: 'full' },\n },\n 'border-top-left-radius': {\n prefix: 'rounded-tl',\n scale: { 0: 'none', 2: 'sm', 4: '', 6: 'md', 8: 'lg', 12: 'xl', 16: '2xl', 24: '3xl', 9999: 'full' },\n },\n 'border-top-right-radius': {\n prefix: 'rounded-tr',\n scale: { 0: 'none', 2: 'sm', 4: '', 6: 'md', 8: 'lg', 12: 'xl', 16: '2xl', 24: '3xl', 9999: 'full' },\n },\n 'border-bottom-right-radius': {\n prefix: 'rounded-br',\n scale: { 0: 'none', 2: 'sm', 4: '', 6: 'md', 8: 'lg', 12: 'xl', 16: '2xl', 24: '3xl', 9999: 'full' },\n },\n 'border-bottom-left-radius': {\n prefix: 'rounded-bl',\n scale: { 0: 'none', 2: 'sm', 4: '', 6: 'md', 8: 'lg', 12: 'xl', 16: '2xl', 24: '3xl', 9999: 'full' },\n },\n}\n\nconst flexDirectionMap: Record<string, string> = {\n row: 'flex-row',\n 'row-reverse': 'flex-row-reverse',\n column: 'flex-col',\n 'column-reverse': 'flex-col-reverse',\n}\n\nconst justifyContentMap: Record<string, string> = {\n 'flex-start': 'justify-start',\n 'flex-end': 'justify-end',\n center: 'justify-center',\n 'space-between': 'justify-between',\n 'space-around': 'justify-around',\n 'space-evenly': 'justify-evenly',\n start: 'justify-start',\n end: 'justify-end',\n}\n\nconst alignItemsMap: Record<string, string> = {\n 'flex-start': 'items-start',\n 'flex-end': 'items-end',\n center: 'items-center',\n baseline: 'items-baseline',\n stretch: 'items-stretch',\n start: 'items-start',\n end: 'items-end',\n}\n\nfunction getExactScaleValue(value: number, scale: Record<number, string>): string | null {\n if (Object.prototype.hasOwnProperty.call(scale, value)) {\n return scale[value]\n }\n return null\n}\n\nfunction normalizeTailwindArbitraryValue(value: string): string {\n return value.trim().replace(/\\s+/g, '_')\n}\n\nfunction normalizeShadowForComparison(value: string): string {\n return value\n .trim()\n .toLowerCase()\n .replace(/\\s*\\/\\s*/g, '/')\n .replace(/\\(\\s+/g, '(')\n .replace(/\\s+\\)/g, ')')\n .replace(/\\s*,\\s*/g, ',')\n .replace(/\\s+/g, ' ')\n}\n\nconst tailwindShadowClassValues: Array<{ className: string; css: string }> = [\n { className: 'shadow-2xs', css: '0 1px rgb(0 0 0 / 0.05)' },\n { className: 'shadow-xs', css: '0 1px 2px 0 rgb(0 0 0 / 0.05)' },\n { className: 'shadow', css: '0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)' },\n { className: 'shadow-sm', css: '0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)' },\n { className: 'shadow-md', css: '0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)' },\n { className: 'shadow-lg', css: '0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)' },\n { className: 'shadow-xl', css: '0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)' },\n { className: 'shadow-2xl', css: '0 25px 50px -12px rgb(0 0 0 / 0.25)' },\n { className: 'shadow-inner', css: 'inset 0 2px 4px 0 rgb(0 0 0 / 0.05)' },\n]\n\nexport function stylesToTailwind(styles: Record<string, string>): string {\n const classes: string[] = []\n\n for (const [prop, value] of Object.entries(styles)) {\n if (tailwindClassMap[prop]) {\n const parsed = parsePropertyValue(value)\n const mapping = tailwindClassMap[prop]\n if (value === 'auto') {\n classes.push(`${mapping.prefix}-auto`)\n continue\n }\n if (parsed.unit === 'px') {\n const exactScale = getExactScaleValue(parsed.numericValue, mapping.scale)\n if (exactScale !== null) {\n if (exactScale === '') {\n classes.push(mapping.prefix)\n } else {\n classes.push(`${mapping.prefix}-${exactScale}`)\n }\n continue\n }\n }\n classes.push(`${mapping.prefix}-[${value}]`)\n continue\n }\n\n if (prop === 'flex-direction' && flexDirectionMap[value]) {\n classes.push(flexDirectionMap[value])\n continue\n }\n\n if (prop === 'justify-content' && justifyContentMap[value]) {\n classes.push(justifyContentMap[value])\n continue\n }\n\n if (prop === 'align-items' && alignItemsMap[value]) {\n classes.push(alignItemsMap[value])\n continue\n }\n\n if (prop === 'display') {\n if (value === 'flex') classes.push('flex')\n else if (value === 'inline-flex') classes.push('inline-flex')\n else if (value === 'grid') classes.push('grid')\n else if (value === 'block') classes.push('block')\n else if (value === 'inline-block') classes.push('inline-block')\n else if (value === 'none') classes.push('hidden')\n continue\n }\n\n if (prop === 'width') {\n if (value === '100%') classes.push('w-full')\n else if (value === 'fit-content') classes.push('w-fit')\n else if (value === 'auto') classes.push('w-auto')\n else classes.push(`w-[${value}]`)\n continue\n }\n\n if (prop === 'height') {\n if (value === '100%') classes.push('h-full')\n else if (value === 'fit-content') classes.push('h-fit')\n else if (value === 'auto') classes.push('h-auto')\n else classes.push(`h-[${value}]`)\n continue\n }\n\n if (prop === 'background-color') {\n const colorValue = parseColorValue(value)\n classes.push(colorToTailwind('backgroundColor', colorValue))\n continue\n }\n\n if (prop === 'color') {\n const colorValue = parseColorValue(value)\n classes.push(colorToTailwind('color', colorValue))\n continue\n }\n\n if (prop === 'border-color') {\n const colorValue = parseColorValue(value)\n classes.push(colorToTailwind('borderColor', colorValue))\n continue\n }\n\n if (prop === 'border-style') {\n const styleMap: Record<string, string> = {\n none: 'border-none',\n solid: 'border-solid',\n dashed: 'border-dashed',\n dotted: 'border-dotted',\n double: 'border-double',\n }\n classes.push(styleMap[value] || `[border-style:${value}]`)\n continue\n }\n\n // Tailwind has no per-side border-style utilities — consolidate when all sides match\n if (prop === 'border-top-style' || prop === 'border-right-style' || prop === 'border-bottom-style' || prop === 'border-left-style') {\n const allPresent =\n 'border-top-style' in styles &&\n 'border-right-style' in styles &&\n 'border-bottom-style' in styles &&\n 'border-left-style' in styles\n if (allPresent) {\n // Only emit once (from border-top-style) when all four sides are present\n if (prop === 'border-top-style') {\n const allSame =\n styles['border-top-style'] === styles['border-right-style'] &&\n styles['border-top-style'] === styles['border-bottom-style'] &&\n styles['border-top-style'] === styles['border-left-style']\n if (allSame) {\n const styleMap: Record<string, string> = {\n none: 'border-none',\n solid: 'border-solid',\n dashed: 'border-dashed',\n dotted: 'border-dotted',\n double: 'border-double',\n }\n classes.push(styleMap[value] || `[border-style:${value}]`)\n } else {\n // Sides differ — emit each side individually\n classes.push(`[border-top-style:${styles['border-top-style']}]`)\n classes.push(`[border-right-style:${styles['border-right-style']}]`)\n classes.push(`[border-bottom-style:${styles['border-bottom-style']}]`)\n classes.push(`[border-left-style:${styles['border-left-style']}]`)\n }\n }\n } else {\n // Emit arbitrary-property syntax for individual side styles\n classes.push(`[${prop}:${value}]`)\n }\n continue\n }\n\n if (prop === 'outline-color') {\n const colorValue = parseColorValue(value)\n classes.push(colorToTailwind('outlineColor', colorValue))\n continue\n }\n\n if (prop === 'box-shadow') {\n const trimmed = value.trim()\n if (trimmed === 'none' || trimmed === '') {\n classes.push('shadow-none')\n } else {\n const normalized = normalizeShadowForComparison(trimmed)\n const preset = tailwindShadowClassValues.find(\n (entry) => normalizeShadowForComparison(entry.css) === normalized\n )\n if (preset) classes.push(preset.className)\n else classes.push(`shadow-[${normalizeTailwindArbitraryValue(value)}]`)\n }\n continue\n }\n\n if (prop === 'font-size') {\n classes.push(`text-[${value}]`)\n continue\n }\n\n if (prop === 'font-weight') {\n const weightMap: Record<string, string> = {\n '100': 'font-thin',\n '200': 'font-extralight',\n '300': 'font-light',\n '400': 'font-normal',\n '500': 'font-medium',\n '600': 'font-semibold',\n '700': 'font-bold',\n '800': 'font-extrabold',\n '900': 'font-black',\n }\n classes.push(weightMap[value] || `font-[${value}]`)\n continue\n }\n\n if (prop === 'line-height') {\n classes.push(`leading-[${value}]`)\n continue\n }\n\n if (prop === 'letter-spacing') {\n classes.push(`tracking-[${value}]`)\n continue\n }\n\n if (prop === 'text-align') {\n const alignMap: Record<string, string> = {\n left: 'text-left',\n center: 'text-center',\n right: 'text-right',\n justify: 'text-justify',\n }\n if (alignMap[value]) classes.push(alignMap[value])\n continue\n }\n\n if (prop === 'font-family') {\n classes.push(`font-[${value.replace(/\\s+/g, '_')}]`)\n continue\n }\n }\n\n return classes.join(' ')\n}\n\nexport const propertyToCSSMap: Record<SpacingPropertyKey, string> = {\n paddingTop: 'padding-top',\n paddingRight: 'padding-right',\n paddingBottom: 'padding-bottom',\n paddingLeft: 'padding-left',\n marginTop: 'margin-top',\n marginRight: 'margin-right',\n marginBottom: 'margin-bottom',\n marginLeft: 'margin-left',\n gap: 'gap',\n}\n\nexport const borderRadiusPropertyToCSSMap: Record<BorderRadiusPropertyKey, string> = {\n borderTopLeftRadius: 'border-top-left-radius',\n borderTopRightRadius: 'border-top-right-radius',\n borderBottomRightRadius: 'border-bottom-right-radius',\n borderBottomLeftRadius: 'border-bottom-left-radius',\n}\n\nexport const borderPropertyToCSSMap: Record<BorderPropertyKey, string> = {\n borderTopStyle: 'border-top-style',\n borderTopWidth: 'border-top-width',\n borderRightStyle: 'border-right-style',\n borderRightWidth: 'border-right-width',\n borderBottomStyle: 'border-bottom-style',\n borderBottomWidth: 'border-bottom-width',\n borderLeftStyle: 'border-left-style',\n borderLeftWidth: 'border-left-width',\n}\n\nexport const flexPropertyToCSSMap: Record<FlexPropertyKey, string> = {\n display: 'display',\n flexDirection: 'flex-direction',\n justifyContent: 'justify-content',\n alignItems: 'align-items',\n}\n\nexport const sizingPropertyToCSSMap: Record<SizingPropertyKey, string> = {\n width: 'width',\n height: 'height',\n}\n\nexport const typographyPropertyToCSSMap: Record<TypographyPropertyKey, string> = {\n fontFamily: 'font-family',\n fontWeight: 'font-weight',\n fontSize: 'font-size',\n lineHeight: 'line-height',\n letterSpacing: 'letter-spacing',\n textAlign: 'text-align',\n textVerticalAlign: 'align-items',\n}\n\nconst TEXT_ELEMENT_TAGS = new Set([\n 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6',\n 'span', 'label', 'a', 'strong', 'em', 'small',\n 'blockquote', 'li', 'td', 'th', 'caption', 'figcaption',\n 'legend', 'dt', 'dd', 'abbr', 'cite', 'code', 'pre',\n])\n\nfunction hasDirectNonWhitespaceText(element: HTMLElement): boolean {\n return Array.from(element.childNodes).some(\n (node) => node.nodeType === Node.TEXT_NODE && Boolean(node.textContent?.trim())\n )\n}\n\nexport function isTextElement(element: HTMLElement): boolean {\n const tagName = element.tagName.toLowerCase()\n if (TEXT_ELEMENT_TAGS.has(tagName)) {\n return true\n }\n if (hasDirectNonWhitespaceText(element)) {\n return true\n }\n if (element.children.length === 0 && element.textContent?.trim()) {\n return true\n }\n return false\n}\n\nexport function getComputedTypography(element: HTMLElement): TypographyProperties {\n const computed = window.getComputedStyle(element)\n\n let textVerticalAlign: TypographyProperties['textVerticalAlign'] = 'flex-start'\n if (computed.display === 'flex' || computed.display === 'inline-flex') {\n const alignItems = computed.alignItems\n if (alignItems === 'center') textVerticalAlign = 'center'\n else if (alignItems === 'flex-end' || alignItems === 'end') textVerticalAlign = 'flex-end'\n }\n\n // Handle \"normal\" keyword for line-height (use font-size as approximation)\n const lineHeight = computed.lineHeight === 'normal'\n ? { numericValue: parseFloat(computed.fontSize) * 1.2, unit: 'px' as const, raw: `${Math.round(parseFloat(computed.fontSize) * 1.2)}px` }\n : parsePropertyValue(computed.lineHeight)\n\n // Handle letter-spacing: convert px to em for consistent editing\n const fontSize = parseFloat(computed.fontSize)\n let letterSpacing: CSSPropertyValue\n if (computed.letterSpacing === 'normal') {\n letterSpacing = { numericValue: 0, unit: 'em' as const, raw: '0em' }\n } else {\n const parsed = parsePropertyValue(computed.letterSpacing)\n if (parsed.unit === 'px' && fontSize > 0) {\n const emValue = Math.round((parsed.numericValue / fontSize) * 100) / 100\n letterSpacing = { numericValue: emValue, unit: 'em' as const, raw: `${emValue}em` }\n } else {\n letterSpacing = parsed\n }\n }\n\n return {\n fontFamily: computed.fontFamily,\n fontWeight: computed.fontWeight,\n fontSize: parsePropertyValue(computed.fontSize),\n lineHeight,\n letterSpacing,\n textAlign: computed.textAlign as TypographyProperties['textAlign'],\n textVerticalAlign,\n }\n}\n\nexport function detectSizingMode(\n element: HTMLElement,\n dimension: 'width' | 'height'\n): SizingMode {\n const computed = window.getComputedStyle(element)\n const inlineValue = element.style[dimension]\n\n if (inlineValue === '100%') return 'fill'\n if (inlineValue === 'auto' || inlineValue === 'fit-content') return 'fit'\n\n const computedValue = computed[dimension]\n\n if (computedValue === '100%') return 'fill'\n if (\n computedValue === 'auto' ||\n computedValue === 'fit-content' ||\n computedValue === 'max-content'\n ) {\n return 'fit'\n }\n\n const parent = element.parentElement\n if (parent) {\n const parentComputed = window.getComputedStyle(parent)\n if (parentComputed.display === 'flex' || parentComputed.display === 'inline-flex') {\n const flexGrow = computed.flexGrow\n if (flexGrow !== '0') {\n return 'fill'\n }\n }\n }\n\n if (dimension === 'width') {\n if (computed.display === 'block' && !inlineValue) {\n return 'fill'\n }\n if (\n computed.display === 'inline-block' ||\n computed.display === 'inline-flex' ||\n computed.display === 'inline'\n ) {\n return 'fit'\n }\n }\n\n if (dimension === 'height') {\n if (!inlineValue) {\n return 'fit'\n }\n }\n\n return 'fixed'\n}\n\nexport function getSizingValue(element: HTMLElement, dimension: 'width' | 'height'): SizingValue {\n const mode = detectSizingMode(element, dimension)\n const rect = element.getBoundingClientRect()\n const numericValue = Math.round(dimension === 'width' ? rect.width : rect.height)\n\n return {\n mode,\n value: {\n numericValue,\n unit: 'px',\n raw: `${numericValue}px`,\n },\n }\n}\n\nexport function getComputedSizing(element: HTMLElement): SizingProperties {\n return {\n width: getSizingValue(element, 'width'),\n height: getSizingValue(element, 'height'),\n }\n}\n\nexport function sizingValueToCSS(sizing: SizingValue): string {\n switch (sizing.mode) {\n case 'fill':\n return '100%'\n case 'fit':\n return 'fit-content'\n case 'fixed':\n return `${sizing.value.numericValue}${sizing.value.unit}`\n }\n}\n\nexport function sizingToTailwind(dimension: 'width' | 'height', sizing: SizingValue): string {\n const prefix = dimension === 'width' ? 'w' : 'h'\n\n switch (sizing.mode) {\n case 'fill':\n return `${prefix}-full`\n case 'fit':\n return `${prefix}-fit`\n case 'fixed':\n return `${prefix}-[${sizing.value.numericValue}${sizing.value.unit}]`\n }\n}\n\nfunction parseHexColor(hex: string): ColorValue {\n const raw = hex\n let h = hex.replace('#', '')\n\n // Expand shorthand (#RGB -> #RRGGBB)\n if (h.length === 3) {\n h = h\n .split('')\n .map((c) => c + c)\n .join('')\n }\n\n // Handle 8-digit hex with alpha\n if (h.length === 8) {\n const alpha = Math.round((parseInt(h.slice(6, 8), 16) / 255) * 100)\n return { hex: h.slice(0, 6).toUpperCase(), alpha, raw }\n }\n\n return { hex: h.toUpperCase(), alpha: 100, raw }\n}\n\nfunction parseRgbChannel(value: string): number | null {\n const token = value.trim()\n if (!token) return null\n\n if (token.endsWith('%')) {\n const numeric = parseFloat(token.slice(0, -1))\n if (!Number.isFinite(numeric)) return null\n return Math.round((Math.max(0, Math.min(100, numeric)) / 100) * 255)\n }\n\n const numeric = parseFloat(token)\n if (!Number.isFinite(numeric)) return null\n return Math.round(Math.max(0, Math.min(255, numeric)))\n}\n\nfunction parseRgbAlpha(value: string | undefined): number | null {\n if (value == null || value.trim() === '') return 1\n const token = value.trim()\n\n if (token.endsWith('%')) {\n const numeric = parseFloat(token.slice(0, -1))\n if (!Number.isFinite(numeric)) return null\n return Math.max(0, Math.min(100, numeric)) / 100\n }\n\n const numeric = parseFloat(token)\n if (!Number.isFinite(numeric)) return null\n return Math.max(0, Math.min(1, numeric))\n}\n\nfunction parseRgbaColor(rgba: string): ColorValue {\n const raw = rgba.trim()\n const fnMatch = raw.match(/^rgba?\\((.*)\\)$/i)\n if (!fnMatch) {\n return { hex: '000000', alpha: 100, raw: rgba }\n }\n\n const body = fnMatch[1].trim()\n let channelTokens: [string, string, string] | null = null\n let alphaToken: string | undefined\n\n const commaParts = body.split(',').map((part) => part.trim()).filter(Boolean)\n if (commaParts.length === 3 || commaParts.length === 4) {\n channelTokens = [commaParts[0], commaParts[1], commaParts[2]]\n alphaToken = commaParts[3]\n } else {\n const slashParts = body.split('/')\n if (slashParts.length === 1 || slashParts.length === 2) {\n const channels = slashParts[0].trim().split(/\\s+/).filter(Boolean)\n if (channels.length === 3) {\n channelTokens = [channels[0], channels[1], channels[2]]\n alphaToken = slashParts[1]?.trim()\n }\n }\n }\n\n if (!channelTokens) {\n return { hex: '000000', alpha: 100, raw: rgba }\n }\n\n const r = parseRgbChannel(channelTokens[0])\n const g = parseRgbChannel(channelTokens[1])\n const b = parseRgbChannel(channelTokens[2])\n const a = parseRgbAlpha(alphaToken)\n\n if (r === null || g === null || b === null || a === null) {\n return { hex: '000000', alpha: 100, raw: rgba }\n }\n\n const hex = [r, g, b]\n .map((v) => v.toString(16).padStart(2, '0'))\n .join('')\n .toUpperCase()\n const alpha = Math.round(a * 100)\n\n return { hex, alpha, raw: rgba }\n}\n\nfunction parseNamedColor(name: string): ColorValue {\n // Use a temporary canvas to convert named colors\n const ctx = document.createElement('canvas').getContext('2d')\n if (!ctx) {\n return { hex: '000000', alpha: 100, raw: name }\n }\n\n ctx.fillStyle = name\n const computed = ctx.fillStyle\n\n if (computed.startsWith('#')) {\n return parseHexColor(computed)\n }\n return parseRgbaColor(computed)\n}\n\nexport function parseColorValue(cssValue: string): ColorValue {\n const raw = cssValue.trim()\n\n // Handle transparent\n if (raw === 'transparent') {\n return { hex: '000000', alpha: 0, raw }\n }\n\n // Handle hex colors\n if (raw.startsWith('#')) {\n return parseHexColor(raw)\n }\n\n // Handle rgb/rgba\n if (raw.startsWith('rgb')) {\n return parseRgbaColor(raw)\n }\n\n // Fallback: use canvas to convert named colors\n return parseNamedColor(raw)\n}\n\nconst TRANSPARENT_COLOR: ColorValue = { hex: '000000', alpha: 0, raw: 'transparent' }\n\nexport function getComputedBoxShadow(element: HTMLElement): string {\n const computed = window.getComputedStyle(element)\n const value = computed.boxShadow.trim()\n return value || 'none'\n}\n\nexport function getComputedColorStyles(element: HTMLElement): ColorProperties {\n const computed = window.getComputedStyle(element)\n\n const borderSides = [\n { style: computed.borderTopStyle, width: computed.borderTopWidth, color: computed.borderTopColor },\n { style: computed.borderRightStyle, width: computed.borderRightWidth, color: computed.borderRightColor },\n { style: computed.borderBottomStyle, width: computed.borderBottomWidth, color: computed.borderBottomColor },\n { style: computed.borderLeftStyle, width: computed.borderLeftWidth, color: computed.borderLeftColor },\n ]\n const visibleBorderSide = borderSides.find(\n (side) => side.style !== 'none' && side.style !== 'hidden' && parseFloat(side.width) > 0\n )\n const hasBorder = Boolean(visibleBorderSide)\n const hasOutline =\n computed.outlineStyle !== 'none' && parseFloat(computed.outlineWidth) > 0\n\n return {\n backgroundColor: parseColorValue(computed.backgroundColor),\n color: parseColorValue(computed.color),\n borderColor: hasBorder && visibleBorderSide ? parseColorValue(visibleBorderSide.color) : TRANSPARENT_COLOR,\n outlineColor: hasOutline ? parseColorValue(computed.outlineColor) : TRANSPARENT_COLOR,\n }\n}\n\nexport interface AllComputedStyles {\n spacing: SpacingProperties\n borderRadius: BorderRadiusProperties\n border: BorderProperties\n flex: FlexProperties\n sizing: SizingProperties\n color: ColorProperties\n boxShadow: string\n typography: TypographyProperties\n}\n\nexport function getAllComputedStyles(element: HTMLElement): AllComputedStyles {\n const { spacing, borderRadius, flex } = getComputedStyles(element)\n return {\n spacing,\n borderRadius,\n border: getComputedBorderStyles(element),\n flex,\n sizing: getComputedSizing(element),\n color: getComputedColorStyles(element),\n boxShadow: getComputedBoxShadow(element),\n typography: getComputedTypography(element),\n }\n}\n\nexport const colorPropertyToCSSMap: Record<ColorPropertyKey, string> = {\n backgroundColor: 'background-color',\n color: 'color',\n borderColor: 'border-color',\n outlineColor: 'outline-color',\n}\n\nconst colorTailwindPrefixMap: Record<ColorPropertyKey, string> = {\n backgroundColor: 'bg',\n color: 'text',\n borderColor: 'border',\n outlineColor: 'outline',\n}\n\nexport function colorToTailwind(\n property: ColorPropertyKey,\n colorValue: ColorValue\n): string {\n const prefix = colorTailwindPrefixMap[property]\n\n // Use arbitrary hex value\n if (colorValue.alpha === 100) {\n return `${prefix}-[#${colorValue.hex}]`\n }\n return `${prefix}-[#${colorValue.hex}]/${colorValue.alpha}`\n}\n\nexport function getElementInfo(element: HTMLElement): ElementInfo {\n const computed = window.getComputedStyle(element)\n const parentElement = element.parentElement\n\n const isFlexContainer = computed.display === 'flex' || computed.display === 'inline-flex'\n\n let isFlexItem = false\n if (parentElement) {\n const parentComputed = window.getComputedStyle(parentElement)\n isFlexItem = parentComputed.display === 'flex' || parentComputed.display === 'inline-flex'\n }\n\n return {\n tagName: element.tagName.toLowerCase(),\n id: element.id || null,\n classList: Array.from(element.classList),\n isFlexContainer,\n isFlexItem,\n isTextElement: isTextElement(element),\n parentElement,\n hasChildren: element.children.length > 0,\n }\n}\n\ninterface DimensionDisplay {\n width: string\n height: string\n}\n\nfunction isFitSizing(element: HTMLElement, dimension: 'width' | 'height'): boolean {\n const computed = window.getComputedStyle(element)\n const inlineValue = element.style[dimension]\n\n if (inlineValue === 'auto') return true\n\n const computedValue = computed[dimension]\n\n if (!inlineValue) {\n const parent = element.parentElement\n if (parent) {\n const parentComputed = window.getComputedStyle(parent)\n if (parentComputed.display === 'flex' || parentComputed.display === 'inline-flex') {\n const flexBasis = computed.flexBasis\n const flexGrow = computed.flexGrow\n if (flexBasis === 'auto' && flexGrow === '0') {\n return true\n }\n }\n }\n\n if (dimension === 'width') {\n if (computed.display === 'block' && !inlineValue) {\n return false\n }\n if (\n computed.display === 'inline-block' ||\n computed.display === 'inline-flex' ||\n computed.display === 'inline'\n ) {\n return true\n }\n }\n\n if (dimension === 'height') {\n return !inlineValue\n }\n }\n\n if (computedValue.includes('fit-content') || computedValue.includes('max-content')) {\n return true\n }\n\n return false\n}\n\nexport function getDimensionDisplay(element: HTMLElement): DimensionDisplay {\n const rect = element.getBoundingClientRect()\n const width = Math.round(rect.width)\n const height = Math.round(rect.height)\n\n const widthIsFit = isFitSizing(element, 'width')\n const heightIsFit = isFitSizing(element, 'height')\n\n return {\n width: widthIsFit ? `Fit ${width}` : `${width}`,\n height: heightIsFit ? `Fit ${height}` : `${height}`,\n }\n}\n\n\nexport function calculateParentMeasurements(element: HTMLElement, container?: HTMLElement): MeasurementLine[] {\n const parent = container ?? element.parentElement\n if (!parent) return []\n\n const elementRect = element.getBoundingClientRect()\n const parentRect = parent.getBoundingClientRect()\n\n // Use clientLeft/clientTop for reliable border widths, clientWidth/clientHeight\n // for inner dimensions (handles scrollbars correctly)\n const paddingBoxLeft = parentRect.left + parent.clientLeft\n const paddingBoxTop = parentRect.top + parent.clientTop\n const paddingBoxRight = parentRect.left + parent.clientLeft + parent.clientWidth\n const paddingBoxBottom = parentRect.top + parent.clientTop + parent.clientHeight\n\n let parentInnerLeft: number\n let parentInnerTop: number\n let parentInnerRight: number\n let parentInnerBottom: number\n\n if (container) {\n // Ancestor case: measure from padding-box (inside border, outside padding).\n // The ancestor's padding doesn't directly position the child — intermediate\n // elements do — so the visually correct edge is inside the border only.\n parentInnerLeft = paddingBoxLeft\n parentInnerTop = paddingBoxTop\n parentInnerRight = paddingBoxRight\n parentInnerBottom = paddingBoxBottom\n } else {\n // Direct parent case: measure from content-box (inside border and padding).\n // The parent's padding IS the gap between its edge and the child's layout area.\n const parentStyles = window.getComputedStyle(parent)\n parentInnerLeft = paddingBoxLeft + (parseFloat(parentStyles.paddingLeft) || 0)\n parentInnerTop = paddingBoxTop + (parseFloat(parentStyles.paddingTop) || 0)\n parentInnerRight = paddingBoxRight - (parseFloat(parentStyles.paddingRight) || 0)\n parentInnerBottom = paddingBoxBottom - (parseFloat(parentStyles.paddingBottom) || 0)\n }\n\n const measurements: MeasurementLine[] = []\n\n const topDistance = Math.round(elementRect.top - parentInnerTop)\n if (topDistance > 0) {\n const midX = elementRect.left + elementRect.width / 2\n measurements.push({\n direction: 'vertical',\n x1: midX,\n y1: parentInnerTop,\n x2: midX,\n y2: elementRect.top,\n distance: topDistance,\n labelPosition: { x: midX, y: (parentInnerTop + elementRect.top) / 2 },\n })\n }\n\n const bottomDistance = Math.round(parentInnerBottom - elementRect.bottom)\n if (bottomDistance > 0) {\n const midX = elementRect.left + elementRect.width / 2\n measurements.push({\n direction: 'vertical',\n x1: midX,\n y1: elementRect.bottom,\n x2: midX,\n y2: parentInnerBottom,\n distance: bottomDistance,\n labelPosition: { x: midX, y: (elementRect.bottom + parentInnerBottom) / 2 },\n })\n }\n\n const leftDistance = Math.round(elementRect.left - parentInnerLeft)\n if (leftDistance > 0) {\n const midY = elementRect.top + elementRect.height / 2\n measurements.push({\n direction: 'horizontal',\n x1: parentInnerLeft,\n y1: midY,\n x2: elementRect.left,\n y2: midY,\n distance: leftDistance,\n labelPosition: { x: (parentInnerLeft + elementRect.left) / 2, y: midY },\n })\n }\n\n const rightDistance = Math.round(parentInnerRight - elementRect.right)\n if (rightDistance > 0) {\n const midY = elementRect.top + elementRect.height / 2\n measurements.push({\n direction: 'horizontal',\n x1: elementRect.right,\n y1: midY,\n x2: parentInnerRight,\n y2: midY,\n distance: rightDistance,\n labelPosition: { x: (elementRect.right + parentInnerRight) / 2, y: midY },\n })\n }\n\n return measurements\n}\n\nexport function calculateElementMeasurements(\n from: HTMLElement,\n to: HTMLElement\n): MeasurementLine[] {\n const fromRect = from.getBoundingClientRect()\n const toRect = to.getBoundingClientRect()\n const measurements: MeasurementLine[] = []\n\n const horizontalOverlap =\n fromRect.left < toRect.right && fromRect.right > toRect.left\n const verticalOverlap =\n fromRect.top < toRect.bottom && fromRect.bottom > toRect.top\n\n if (verticalOverlap) {\n const overlapTop = Math.max(fromRect.top, toRect.top)\n const overlapBottom = Math.min(fromRect.bottom, toRect.bottom)\n const midY = (overlapTop + overlapBottom) / 2\n\n if (fromRect.right <= toRect.left) {\n const distance = Math.round(toRect.left - fromRect.right)\n measurements.push({\n direction: 'horizontal',\n x1: fromRect.right,\n y1: midY,\n x2: toRect.left,\n y2: midY,\n distance,\n labelPosition: { x: (fromRect.right + toRect.left) / 2, y: midY },\n })\n } else if (fromRect.left >= toRect.right) {\n const distance = Math.round(fromRect.left - toRect.right)\n measurements.push({\n direction: 'horizontal',\n x1: toRect.right,\n y1: midY,\n x2: fromRect.left,\n y2: midY,\n distance,\n labelPosition: { x: (toRect.right + fromRect.left) / 2, y: midY },\n })\n }\n }\n\n if (horizontalOverlap) {\n const overlapLeft = Math.max(fromRect.left, toRect.left)\n const overlapRight = Math.min(fromRect.right, toRect.right)\n const midX = (overlapLeft + overlapRight) / 2\n\n if (fromRect.bottom <= toRect.top) {\n const distance = Math.round(toRect.top - fromRect.bottom)\n measurements.push({\n direction: 'vertical',\n x1: midX,\n y1: fromRect.bottom,\n x2: midX,\n y2: toRect.top,\n distance,\n labelPosition: { x: midX, y: (fromRect.bottom + toRect.top) / 2 },\n })\n } else if (fromRect.top >= toRect.bottom) {\n const distance = Math.round(fromRect.top - toRect.bottom)\n measurements.push({\n direction: 'vertical',\n x1: midX,\n y1: toRect.bottom,\n x2: midX,\n y2: fromRect.top,\n distance,\n labelPosition: { x: midX, y: (toRect.bottom + fromRect.top) / 2 },\n })\n }\n }\n\n if (!horizontalOverlap && !verticalOverlap) {\n const fromCenterX = fromRect.left + fromRect.width / 2\n const fromCenterY = fromRect.top + fromRect.height / 2\n const toCenterX = toRect.left + toRect.width / 2\n const toCenterY = toRect.top + toRect.height / 2\n\n const hDistance = toCenterX > fromCenterX\n ? Math.round(toRect.left - fromRect.right)\n : Math.round(fromRect.left - toRect.right)\n\n if (hDistance > 0) {\n const startX = toCenterX > fromCenterX ? fromRect.right : fromRect.left\n const endX = toCenterX > fromCenterX ? toRect.left : toRect.right\n const y = (fromCenterY + toCenterY) / 2\n measurements.push({\n direction: 'horizontal',\n x1: startX,\n y1: y,\n x2: endX,\n y2: y,\n distance: hDistance,\n labelPosition: { x: (startX + endX) / 2, y },\n })\n }\n\n const vDistance = toCenterY > fromCenterY\n ? Math.round(toRect.top - fromRect.bottom)\n : Math.round(fromRect.top - toRect.bottom)\n\n if (vDistance > 0) {\n const x = (fromCenterX + toCenterX) / 2\n const startY = toCenterY > fromCenterY ? fromRect.bottom : fromRect.top\n const endY = toCenterY > fromCenterY ? toRect.top : toRect.bottom\n measurements.push({\n direction: 'vertical',\n x1: x,\n y1: startY,\n x2: x,\n y2: endY,\n distance: vDistance,\n labelPosition: { x, y: (startY + endY) / 2 },\n })\n }\n }\n\n return measurements\n}\n\nconst GUIDELINE_PROXIMITY = 80\n\nexport function calculateGuidelineMeasurements(\n element: HTMLElement,\n guidelines: Guideline[],\n mousePosition?: { x: number; y: number } | null,\n): MeasurementLine[] {\n if (guidelines.length === 0) return []\n\n const rect = element.getBoundingClientRect()\n const scrollX = window.scrollX\n const scrollY = window.scrollY\n const measurements: MeasurementLine[] = []\n\n for (const g of guidelines) {\n if (g.orientation === 'horizontal') {\n const gy = g.position - scrollY\n const midX = rect.left + rect.width / 2\n\n // Only show when mouse is near this guideline's Y position\n if (mousePosition && Math.abs(mousePosition.y - gy) > GUIDELINE_PROXIMITY) continue\n\n if (gy < rect.top) {\n const distance = Math.round(rect.top - gy)\n if (distance > 0) {\n measurements.push({\n direction: 'vertical',\n x1: midX,\n y1: gy,\n x2: midX,\n y2: rect.top,\n distance,\n labelPosition: { x: midX, y: (gy + rect.top) / 2 },\n })\n }\n } else if (gy > rect.bottom) {\n const distance = Math.round(gy - rect.bottom)\n if (distance > 0) {\n measurements.push({\n direction: 'vertical',\n x1: midX,\n y1: rect.bottom,\n x2: midX,\n y2: gy,\n distance,\n labelPosition: { x: midX, y: (rect.bottom + gy) / 2 },\n })\n }\n }\n } else {\n const gx = g.position - scrollX\n const midY = rect.top + rect.height / 2\n\n // Only show when mouse is near this guideline's X position\n if (mousePosition && Math.abs(mousePosition.x - gx) > GUIDELINE_PROXIMITY) continue\n\n if (gx < rect.left) {\n const distance = Math.round(rect.left - gx)\n if (distance > 0) {\n measurements.push({\n direction: 'horizontal',\n x1: gx,\n y1: midY,\n x2: rect.left,\n y2: midY,\n distance,\n labelPosition: { x: (gx + rect.left) / 2, y: midY },\n })\n }\n } else if (gx > rect.right) {\n const distance = Math.round(gx - rect.right)\n if (distance > 0) {\n measurements.push({\n direction: 'horizontal',\n x1: rect.right,\n y1: midY,\n x2: gx,\n y2: midY,\n distance,\n labelPosition: { x: (rect.right + gx) / 2, y: midY },\n })\n }\n }\n }\n }\n\n return measurements\n}\n\nexport function isFlexContainer(element: HTMLElement): boolean {\n const computed = window.getComputedStyle(element)\n return computed.display === 'flex' || computed.display === 'inline-flex'\n}\n\nexport function getFlexDirection(\n element: HTMLElement\n): 'row' | 'row-reverse' | 'column' | 'column-reverse' {\n const computed = window.getComputedStyle(element)\n return computed.flexDirection as 'row' | 'row-reverse' | 'column' | 'column-reverse'\n}\n\nexport function detectChildrenDirection(\n container: HTMLElement,\n exclude: HTMLElement | null\n): { axis: 'horizontal' | 'vertical'; reversed: boolean } {\n const computed = window.getComputedStyle(container)\n\n // Flex: trust CSS for accuracy (especially reverse)\n if (computed.display === 'flex' || computed.display === 'inline-flex') {\n const dir = computed.flexDirection\n return {\n axis: (dir === 'row' || dir === 'row-reverse') ? 'horizontal' : 'vertical',\n reversed: dir === 'row-reverse' || dir === 'column-reverse',\n }\n }\n\n // Non-flex: examine first two visible, in-flow children\n const visible: HTMLElement[] = []\n for (const c of container.children) {\n if (!(c instanceof HTMLElement) || c === exclude) continue\n const cs = window.getComputedStyle(c)\n if (cs.display === 'none' || cs.position === 'absolute' || cs.position === 'fixed') continue\n visible.push(c)\n if (visible.length === 2) break\n }\n\n if (visible.length < 2) return { axis: 'vertical', reversed: false }\n\n const first = visible[0].getBoundingClientRect()\n const second = visible[1].getBoundingClientRect()\n const yOverlap = first.bottom - 2 > second.top && second.bottom - 2 > first.top\n\n if (yOverlap) {\n return { axis: 'horizontal', reversed: second.right < first.left }\n }\n return { axis: 'vertical', reversed: second.bottom < first.top }\n}\n\nfunction htmlChildren(el: HTMLElement): HTMLElement[] {\n return Array.from(el.children).filter(\n (child): child is HTMLElement => child instanceof HTMLElement\n )\n}\n\n/** Walk up from `element` to find the nearest flex/inline-flex ancestor, stopping at `boundary`. */\nfunction findFlexAncestor(\n element: HTMLElement,\n boundary: HTMLElement | null,\n): { flexParent: HTMLElement; child: HTMLElement } | null {\n let current: HTMLElement | null = element\n while (current && current !== document.body) {\n const parent: HTMLElement | null = current.parentElement\n if (!parent) break\n const display = getComputedStyle(parent).display\n if (display === 'flex' || display === 'inline-flex') {\n return { flexParent: parent, child: current }\n }\n if (boundary && parent === boundary) break\n current = parent\n }\n return null\n}\n\nexport function computeHoverHighlight(\n elementUnder: HTMLElement | null,\n selectedElement: HTMLElement | null,\n): { flexContainer: HTMLElement; children: HTMLElement[] } | null {\n if (\n !elementUnder ||\n elementUnder === document.body ||\n elementUnder === document.documentElement ||\n elementUnder.closest('[data-direct-edit]') ||\n elementUnder.closest('[data-direct-edit-host]') ||\n elementUnder === selectedElement\n ) {\n return null\n }\n\n // When hovering descendants of the selected element, stop walk-up at the boundary\n const boundary = selectedElement?.contains(elementUnder) ? selectedElement : null\n\n const ownDisplay = getComputedStyle(elementUnder).display\n if (ownDisplay === 'flex' || ownDisplay === 'inline-flex') {\n return { flexContainer: elementUnder, children: htmlChildren(elementUnder) }\n }\n\n const found = findFlexAncestor(elementUnder, boundary)\n if (found) {\n return { flexContainer: found.flexParent, children: htmlChildren(found.flexParent) }\n }\n\n return { flexContainer: elementUnder, children: [] }\n}\n\nexport function resolveElementTarget(\n elementUnder: HTMLElement,\n selectedElement: HTMLElement | null,\n): HTMLElement {\n const boundary = selectedElement?.contains(elementUnder) ? selectedElement : null\n const found = findFlexAncestor(elementUnder, boundary)\n if (found && found.flexParent === boundary) return elementUnder\n return found?.child ?? elementUnder\n}\n\n/** Finds the text-owning element at a point within `boundary` using browser caret hit-testing. */\nexport function findTextOwnerAtPoint(\n boundary: HTMLElement,\n clientX: number,\n clientY: number,\n): HTMLElement | null {\n const doc = document as Document & {\n caretPositionFromPoint?: (x: number, y: number) => { offsetNode: Node } | null\n caretRangeFromPoint?: (x: number, y: number) => Range | null\n }\n\n const caretNode =\n doc.caretPositionFromPoint?.(clientX, clientY)?.offsetNode\n ?? doc.caretRangeFromPoint?.(clientX, clientY)?.startContainer\n ?? null\n if (!caretNode || caretNode.nodeType !== Node.TEXT_NODE) return null\n\n const textNode = caretNode as Text\n if (!(textNode.nodeValue ?? '').trim()) return null\n\n const owner = textNode.parentElement\n if (!owner || !boundary.contains(owner)) return null\n if (owner.closest('[data-direct-edit]') || owner.closest('[data-direct-edit-host]')) return null\n\n // Guard against caret APIs returning nearby text nodes.\n const range = document.createRange()\n range.selectNodeContents(textNode)\n const hitsText = Array.from(range.getClientRects()).some(\n (r) => clientX >= r.left && clientX <= r.right && clientY >= r.top && clientY <= r.bottom\n )\n range.detach?.()\n return hitsText ? owner : null\n}\n\n/** Fallback text hit-testing by scanning text nodes and rendered rects within `boundary`. */\nexport function findTextOwnerByRangeScan(\n boundary: HTMLElement,\n clientX: number,\n clientY: number,\n): HTMLElement | null {\n const walker = document.createTreeWalker(boundary, NodeFilter.SHOW_TEXT)\n let current: Node | null = walker.nextNode()\n\n while (current) {\n const textNode = current as Text\n if ((textNode.nodeValue ?? '').trim()) {\n const owner = textNode.parentElement\n if (\n owner &&\n boundary.contains(owner) &&\n !owner.closest('[data-direct-edit]') &&\n !owner.closest('[data-direct-edit-host]')\n ) {\n const range = document.createRange()\n range.selectNodeContents(textNode)\n const hitsText = Array.from(range.getClientRects()).some(\n (r) => clientX >= r.left && clientX <= r.right && clientY >= r.top && clientY <= r.bottom\n )\n range.detach?.()\n if (hitsText) return owner\n }\n }\n current = walker.nextNode()\n }\n\n return null\n}\n\n/** Wrap the direct text node under the point into a span so it becomes independently selectable. */\nexport function ensureDirectTextSpanAtPoint(\n parent: HTMLElement,\n clientX: number,\n clientY: number,\n): HTMLElement | null {\n const directTextNodes = Array.from(parent.childNodes).filter(\n (node): node is Text => node.nodeType === Node.TEXT_NODE && Boolean(node.textContent?.trim())\n )\n\n for (const textNode of directTextNodes) {\n const range = document.createRange()\n range.selectNodeContents(textNode)\n const hitsText = Array.from(range.getClientRects()).some(\n (r) => clientX >= r.left && clientX <= r.right && clientY >= r.top && clientY <= r.bottom\n )\n range.detach?.()\n\n if (!hitsText) continue\n\n const span = document.createElement('span')\n span.setAttribute('data-direct-edit-generated', 'text-span')\n span.textContent = textNode.textContent ?? ''\n parent.replaceChild(span, textNode)\n return span\n }\n\n return null\n}\n\n/** When elementFromPoint returns the selected element (bare text, padding, gap),\n * find the best child element to drill into at the given coordinates. */\nexport function findChildAtPoint(\n parent: HTMLElement,\n clientX: number,\n clientY: number,\n): HTMLElement | null {\n const children = htmlChildren(parent)\n if (children.length === 0) return null\n\n // Direct hit: child whose bbox contains the click\n const hit = children.find((child) => {\n const r = child.getBoundingClientRect()\n return clientX >= r.left && clientX <= r.right && clientY >= r.top && clientY <= r.bottom\n })\n if (hit) return hit\n\n // Single-child fallback should not steal clicks from parent's direct text.\n if (children.length === 1 && !hasDirectNonWhitespaceText(parent)) return children[0]\n\n return null\n}\n\nexport function elementFromPointWithoutOverlays(x: number, y: number): HTMLElement | null {\n const host = document.querySelector<HTMLElement>('[data-direct-edit-host]')\n if (host) host.style.display = 'none'\n const el = document.elementFromPoint(x, y) as HTMLElement | null\n if (host) host.style.display = ''\n return el\n}\n\nfunction isLayoutContainer(element: HTMLElement): boolean {\n const display = window.getComputedStyle(element).display\n return (\n display === 'flex' ||\n display === 'inline-flex' ||\n display === 'grid' ||\n display === 'inline-grid'\n )\n}\n\nfunction isBlockContainer(element: HTMLElement): boolean {\n const display = window.getComputedStyle(element).display\n return display === 'block' || display === 'flow-root'\n || display === 'inline-block' || display === 'list-item'\n}\n\nfunction skipElement(el: HTMLElement, exclude: HTMLElement | null): boolean {\n if (exclude && exclude.contains(el)) return true\n if (el === document.body || el === document.documentElement) return true\n if (el.closest('[data-direct-edit]') || el.closest('[data-direct-edit-host]')) return true\n return false\n}\n\nfunction findContainerViaTraversal(x: number, y: number, exclude: HTMLElement | null): HTMLElement | null {\n const el = elementFromPointWithoutOverlays(x, y)\n if (!el) return null\n let current: HTMLElement | null = el\n while (current) {\n if (!skipElement(current, exclude)) {\n if (isLayoutContainer(current) || isBlockContainer(current)) return current\n }\n current = current.parentElement\n }\n return null\n}\n\nexport function findContainerAtPoint(\n x: number,\n y: number,\n exclude: HTMLElement | null,\n preferredParent?: HTMLElement | null\n): HTMLElement | null {\n const host = document.querySelector<HTMLElement>('[data-direct-edit-host]')\n if (host) host.style.display = 'none'\n\n const elements = document.elementsFromPoint(x, y) as HTMLElement[]\n\n if (host) host.style.display = ''\n\n // Find most specific container (front-to-back = most nested first)\n for (const el of elements) {\n if (skipElement(el, exclude)) continue\n if (isLayoutContainer(el) || isBlockContainer(el)) return el\n }\n\n // Fallback: preferredParent for gap/padding areas\n if (preferredParent && (isLayoutContainer(preferredParent) || isBlockContainer(preferredParent))) {\n for (const el of elements) {\n if (el === preferredParent) return preferredParent\n }\n }\n\n // Last resort: walk up DOM\n return findContainerViaTraversal(x, y, exclude)\n}\n\nexport function calculateDropPosition(\n container: HTMLElement,\n pointerX: number,\n pointerY: number,\n draggedElement: HTMLElement\n): { insertBefore: HTMLElement | null; indicator: DropIndicator } | null {\n const { axis, reversed: isReversed } = detectChildrenDirection(container, draggedElement)\n const isHorizontal = axis === 'horizontal'\n\n const children = Array.from(container.children).filter(\n (child) => child !== draggedElement && child instanceof HTMLElement\n ) as HTMLElement[]\n\n if (children.length === 0) {\n const containerRect = container.getBoundingClientRect()\n return {\n insertBefore: null,\n indicator: {\n x: containerRect.left + 4,\n y: containerRect.top + 4,\n width: isHorizontal ? 1 : containerRect.width - 8,\n height: isHorizontal ? containerRect.height - 8 : 1,\n },\n }\n }\n\n const containerRect = container.getBoundingClientRect()\n let insertBefore: HTMLElement | null = null\n let indicatorPosition = 0\n\n for (let i = 0; i < children.length; i++) {\n const child = children[i]\n const rect = child.getBoundingClientRect()\n const midpoint = isHorizontal\n ? rect.left + rect.width / 2\n : rect.top + rect.height / 2\n\n const pointer = isHorizontal ? pointerX : pointerY\n\n const beforeMidpoint = isReversed ? pointer > midpoint : pointer < midpoint\n\n if (beforeMidpoint) {\n insertBefore = child\n indicatorPosition = isHorizontal ? rect.left : rect.top\n break\n }\n }\n\n if (!insertBefore) {\n const lastChild = children[children.length - 1]\n const lastRect = lastChild.getBoundingClientRect()\n indicatorPosition = isHorizontal ? lastRect.right : lastRect.bottom\n }\n\n const indicator: DropIndicator = isHorizontal\n ? {\n x: indicatorPosition,\n y: containerRect.top + 4,\n width: 2,\n height: containerRect.height - 8,\n }\n : {\n x: containerRect.left + 4,\n y: indicatorPosition,\n width: containerRect.width - 8,\n height: 2,\n }\n\n return { insertBefore, indicator }\n}\n\n// Accesses React fiber internals to find the component stack. This is an undocumented\n// API that could change between React versions, but is a common pattern for dev tools.\n// Returns an empty array gracefully if React internals are unavailable.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction getFiberForElement(element: HTMLElement): any | null {\n if (typeof window !== 'undefined') {\n const devtools = window.__DIRECT_EDIT_DEVTOOLS__\n if (devtools?.getFiberForElement) {\n const fiber = devtools.getFiberForElement(element)\n if (fiber) return fiber as any\n }\n }\n\n const fiberKey = Object.keys(element).find(\n (key) => key.startsWith('__reactFiber$') || key.startsWith('__reactInternalInstance$')\n )\n\n if (!fiberKey) return null\n return (element as any)[fiberKey] || null\n}\n\ntype ParsedStackFrame = {\n functionName?: string\n fileName?: string\n lineNumber?: number\n columnNumber?: number\n source?: string\n isServer?: boolean\n}\n\nconst STACK_SOURCE_FILE_EXTENSION_REGEX = /\\.(jsx|tsx|ts|js)$/\nconst STACK_BUNDLED_FILE_PATTERN_REGEX =\n /(\\.min|bundle|chunk|vendor|vendors|runtime|polyfill|polyfills)\\.(js|mjs|cjs)$|(chunk|bundle|vendor|vendors|runtime|polyfill|polyfills|framework|app|main|index)[-_.][A-Za-z0-9_-]{4,}\\.(js|mjs|cjs)$|[\\da-f]{8,}\\.(js|mjs|cjs)$|[-_.][\\da-f]{20,}\\.(js|mjs|cjs)$|\\/dist\\/|\\/build\\/|\\/.next\\/|\\/out\\/|\\/node_modules\\/|\\.webpack\\.|\\.vite\\.|\\.turbopack\\./i\nconst FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\\S+:\\d+/\nconst SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\\[native code\\])?$/\nconst SERVER_FRAME_MARKER = '(at Server)'\n\nconst STACK_INTERNAL_SCHEME_PREFIXES = [\n 'rsc://',\n 'about://React/',\n 'React/Server/',\n 'file:///',\n 'webpack://',\n 'webpack-internal://',\n 'node:',\n 'turbopack://',\n '/app-pages-browser/',\n] as const\n\nfunction formatOwnerDebugStack(stack: string): string {\n if (!stack) return ''\n\n const lines = stack.split('\\n')\n const filtered: string[] = []\n\n for (const line of lines) {\n const trimmed = line.trim()\n if (!trimmed) continue\n if (trimmed === 'Error: react-stack-top-frame') continue\n if (\n trimmed.includes('react_stack_bottom_frame') ||\n trimmed.includes('react-stack-bottom-frame')\n ) {\n continue\n }\n filtered.push(line)\n }\n\n if (filtered.length > 0 && filtered[0].includes('fakeJSXCallSite')) {\n filtered.shift()\n }\n\n return filtered.join('\\n')\n}\n\nfunction extractStackLocation(urlLike: string): [string, number | undefined, number | undefined] {\n if (!urlLike.includes(':')) return [urlLike, undefined, undefined]\n\n const isWrappedLocation = urlLike.startsWith('(') && /:\\d+\\)$/.test(urlLike)\n const sanitizedResult = isWrappedLocation ? urlLike.slice(1, -1) : urlLike\n const parts = /(.+?)(?::(\\d+))?(?::(\\d+))?$/.exec(sanitizedResult)\n if (!parts) return [sanitizedResult, undefined, undefined]\n\n return [\n parts[1],\n parts[2] !== undefined ? Number(parts[2]) : undefined,\n parts[3] !== undefined ? Number(parts[3]) : undefined,\n ]\n}\n\nfunction parseV8StackLine(line: string): ParsedStackFrame | null {\n let currentLine = line\n if (currentLine.includes('(eval ')) {\n currentLine = currentLine\n .replace(/eval code/g, 'eval')\n .replace(/(\\(eval at [^()]*)|(,.*$)/g, '')\n }\n\n let sanitizedLine = currentLine\n .replace(/^\\s+/, '')\n .replace(/\\(eval code/g, '(')\n .replace(/^.*?\\s+/, '')\n const locationMatch = sanitizedLine.match(/ (\\(.+\\)$)/)\n if (locationMatch) {\n sanitizedLine = sanitizedLine.replace(locationMatch[0], '')\n }\n\n const [fileName, lineNumber, columnNumber] = extractStackLocation(\n locationMatch ? locationMatch[1] : sanitizedLine\n )\n const functionName = locationMatch && sanitizedLine ? sanitizedLine : undefined\n if (fileName === 'eval' || fileName === '<anonymous>') {\n return {\n functionName,\n }\n }\n\n return {\n functionName,\n fileName,\n lineNumber,\n columnNumber,\n source: currentLine,\n isServer: currentLine.includes(SERVER_FRAME_MARKER) || fileName.startsWith('rsc://'),\n }\n}\n\nfunction parseFFOrSafariStackLine(line: string): ParsedStackFrame | null {\n let currentLine = line\n if (currentLine.includes(' > eval')) {\n currentLine = currentLine.replace(\n / line (\\d+)(?: > eval line \\d+)* > eval:\\d+:\\d+/g,\n ':$1'\n )\n }\n\n const trimmed = currentLine.trim()\n if (!trimmed || SAFARI_NATIVE_CODE_REGEXP.test(trimmed)) {\n return null\n }\n\n if (!trimmed.includes('@') && !trimmed.includes(':')) {\n return {\n functionName: trimmed,\n source: currentLine,\n isServer: trimmed.includes(SERVER_FRAME_MARKER),\n }\n }\n\n const atIndex = trimmed.lastIndexOf('@')\n if (atIndex === -1) {\n return null\n }\n const maybeFunctionName = trimmed.slice(0, atIndex)\n const location = trimmed.slice(atIndex + 1)\n const [fileName, lineNumber, columnNumber] = extractStackLocation(location)\n\n return {\n functionName: maybeFunctionName || undefined,\n fileName,\n lineNumber,\n columnNumber,\n source: currentLine,\n isServer: currentLine.includes(SERVER_FRAME_MARKER) || fileName.startsWith('rsc://'),\n }\n}\n\nfunction parseInStackLine(line: string): ParsedStackFrame | null {\n const functionName = line\n .replace(/^\\s*in\\s+/, '')\n .replace(/\\s*\\(at .*\\)$/, '')\n .trim()\n if (!functionName) return null\n\n return {\n functionName,\n source: line,\n isServer: line.includes(SERVER_FRAME_MARKER),\n }\n}\n\nfunction parseDebugStack(stack: string): ParsedStackFrame[] {\n const frames: ParsedStackFrame[] = []\n for (const rawLine of stack.split('\\n')) {\n if (FIREFOX_SAFARI_STACK_REGEXP.test(rawLine)) {\n const parsed = parseFFOrSafariStackLine(rawLine)\n if (parsed) frames.push(parsed)\n continue\n }\n\n if (/^\\s*at\\s+/.test(rawLine)) {\n const parsed = parseV8StackLine(rawLine)\n if (parsed) frames.push(parsed)\n continue\n }\n\n if (/^\\s*in\\s+/.test(rawLine)) {\n const parsed = parseInStackLine(rawLine)\n if (parsed) frames.push(parsed)\n }\n }\n\n return frames\n}\n\nfunction normalizeStackFileName(fileName: string): string {\n if (!fileName) return ''\n\n let normalized = fileName\n const isHttpUrl = normalized.startsWith('http://') || normalized.startsWith('https://')\n if (isHttpUrl) {\n try {\n normalized = new URL(normalized).pathname\n } catch {\n // Fall through and use the original string.\n }\n }\n\n let didStripPrefix = true\n while (didStripPrefix) {\n didStripPrefix = false\n for (const prefix of STACK_INTERNAL_SCHEME_PREFIXES) {\n if (normalized.startsWith(prefix)) {\n normalized = normalized.slice(prefix.length)\n if (prefix === 'file:///') {\n normalized = `/${normalized.replace(/^\\/+/, '')}`\n }\n didStripPrefix = true\n break\n }\n }\n }\n\n normalized = normalized\n .replace(/^\\/\\(app-pages-browser\\)\\//, '/')\n .replace(/^\\/\\.\\//, '/')\n .replace(/^\\.\\//, '')\n\n const queryIndex = normalized.indexOf('?')\n if (queryIndex !== -1) {\n normalized = normalized.slice(0, queryIndex)\n }\n\n return normalized\n}\n\nfunction isSourceStackFile(fileName: string): boolean {\n const normalizedFileName = normalizeStackFileName(fileName)\n if (!normalizedFileName) return false\n if (!STACK_SOURCE_FILE_EXTENSION_REGEX.test(normalizedFileName)) return false\n return !STACK_BUNDLED_FILE_PATTERN_REGEX.test(normalizedFileName)\n}\n\ntype EnrichedServerFrame = {\n fileName: string\n lineNumber?: number\n columnNumber?: number\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction buildFunctionNameToRscFramesMap(fiber: any): Map<string, EnrichedServerFrame[]> {\n const functionNameToRscFrames = new Map<string, EnrichedServerFrame[]>()\n const visited = new Set<any>()\n let current = fiber\n\n while (current && !visited.has(current)) {\n visited.add(current)\n const rawStack = current?._debugStack?.stack\n const stack = typeof rawStack === 'string' ? formatOwnerDebugStack(rawStack) : ''\n if (stack) {\n const frames = parseDebugStack(stack)\n for (const frame of frames) {\n if (!frame.functionName || !frame.fileName) continue\n if (!frame.fileName.startsWith('rsc://')) continue\n\n const normalized = normalizeStackFileName(frame.fileName)\n if (!normalized) continue\n\n const existing = functionNameToRscFrames.get(frame.functionName) ?? []\n const duplicate = existing.some(\n (candidate) =>\n candidate.fileName === normalized &&\n candidate.lineNumber === frame.lineNumber &&\n candidate.columnNumber === frame.columnNumber\n )\n if (!duplicate) {\n existing.push({\n fileName: normalized,\n lineNumber: frame.lineNumber,\n columnNumber: frame.columnNumber,\n })\n functionNameToRscFrames.set(frame.functionName, existing)\n }\n }\n }\n\n current = current._debugOwner ?? current.return ?? null\n }\n\n return functionNameToRscFrames\n}\n\nfunction enrichServerFrame(\n frame: ParsedStackFrame,\n functionNameToRscFrames: Map<string, EnrichedServerFrame[]>,\n functionNameToUsageIndex: Map<string, number>,\n): ParsedStackFrame {\n if (!frame.functionName) return frame\n\n const available = functionNameToRscFrames.get(frame.functionName)\n if (!available) return frame\n\n const usageIndex = functionNameToUsageIndex.get(frame.functionName) ?? 0\n const resolved = available[usageIndex % available.length]\n functionNameToUsageIndex.set(frame.functionName, usageIndex + 1)\n\n return {\n ...frame,\n fileName: resolved.fileName,\n lineNumber: resolved.lineNumber,\n columnNumber: resolved.columnNumber,\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction getSourceFromDebugStack(fiber: any):\n | {\n fileName?: string\n lineNumber?: number\n columnNumber?: number\n }\n | null {\n const rawStack = fiber?._debugStack?.stack\n if (typeof rawStack !== 'string' || rawStack.length === 0) {\n return null\n }\n\n const formattedStack = formatOwnerDebugStack(rawStack)\n if (!formattedStack) return null\n\n const stackFrames = parseDebugStack(formattedStack)\n const functionNameToRscFrames = buildFunctionNameToRscFramesMap(fiber)\n const functionNameToUsageIndex = new Map<string, number>()\n\n for (const frame of stackFrames) {\n const maybeEnriched = frame.isServer\n ? enrichServerFrame(frame, functionNameToRscFrames, functionNameToUsageIndex)\n : frame\n if (!maybeEnriched.fileName) continue\n\n const normalizedFileName = normalizeStackFileName(maybeEnriched.fileName)\n if (!normalizedFileName) continue\n\n if (isSourceStackFile(normalizedFileName)) {\n return {\n fileName: normalizedFileName,\n lineNumber: maybeEnriched.lineNumber,\n columnNumber: maybeEnriched.columnNumber,\n }\n }\n }\n\n return null\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction getSourceFromFiber(fiber: any):\n | {\n fileName?: string\n lineNumber?: number\n columnNumber?: number\n }\n | null {\n const debugSource = fiber?._debugSource\n if (debugSource?.fileName) return debugSource\n\n const owner = fiber?._debugOwner\n const ownerPending = owner?.pendingProps?.__source\n if (ownerPending?.fileName) return ownerPending\n\n const ownerMemo = owner?.memoizedProps?.__source\n if (ownerMemo?.fileName) return ownerMemo\n\n const pending = fiber?.pendingProps?.__source\n if (pending?.fileName) return pending\n\n const memo = fiber?.memoizedProps?.__source\n if (memo?.fileName) return memo\n\n const fromDebugStack = getSourceFromDebugStack(fiber)\n if (fromDebugStack?.fileName) return fromDebugStack\n\n return null\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction buildFrame(fiber: any): ReactComponentFrame | null {\n const type = fiber?.type\n if (typeof type !== 'function' && typeof type !== 'object') return null\n\n const name = type?.displayName || type?.name || null\n if (!name || name === 'Fragment') return null\n\n const frame: ReactComponentFrame = { name }\n const source = getSourceFromFiber(fiber)\n if (source?.fileName) {\n frame.file = source.fileName\n if (typeof source.lineNumber === 'number') {\n frame.line = source.lineNumber\n }\n if (typeof source.columnNumber === 'number') {\n frame.column = source.columnNumber\n }\n }\n\n return frame\n}\n\nfunction shouldIncludeFrame(\n frame: ReactComponentFrame,\n lastFrame: ReactComponentFrame | null\n): boolean {\n if (!lastFrame) return true\n if (frame.name !== lastFrame.name) return true\n if (!lastFrame.file && frame.file) return true\n if (lastFrame.file && frame.file && lastFrame.line == null && frame.line != null) return true\n if (\n lastFrame.file &&\n frame.file &&\n lastFrame.line != null &&\n frame.line != null &&\n lastFrame.column == null &&\n frame.column != null\n ) {\n return true\n }\n return false\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction getOwnerStack(fiber: any): ReactComponentFrame[] {\n const frames: ReactComponentFrame[] = []\n let current = fiber\n let lastFrame: ReactComponentFrame | null = null\n\n while (current) {\n const frame = buildFrame(current)\n if (frame && shouldIncludeFrame(frame, lastFrame)) {\n frames.push(frame)\n lastFrame = frame\n }\n current = current._debugOwner\n }\n\n return frames\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction getRenderStack(fiber: any): ReactComponentFrame[] {\n const frames: ReactComponentFrame[] = []\n let current = fiber\n let lastFrame: ReactComponentFrame | null = null\n\n while (current) {\n const frame = buildFrame(current)\n if (frame && shouldIncludeFrame(frame, lastFrame)) {\n frames.push(frame)\n lastFrame = frame\n }\n current = current.return\n }\n\n return frames\n}\n\nfunction getReactComponentStack(element: HTMLElement): ReactComponentFrame[] {\n const fiber = getFiberForElement(element)\n if (!fiber) return []\n\n const ownerStack = getOwnerStack(fiber)\n if (ownerStack.length > 0) {\n return ownerStack\n }\n\n return getRenderStack(fiber)\n}\n\nexport function getElementDisplayName(element: HTMLElement): string {\n return element.tagName.toLowerCase()\n}\n\nconst STABLE_ATTRIBUTES = ['data-testid', 'data-qa', 'data-cy', 'aria-label', 'role'] as const\nconst MAX_SELECTOR_DEPTH = 24\nconst CONTEXT_ALLOWED_ATTRIBUTES = new Set([\n 'id',\n 'class',\n 'href',\n 'src',\n 'alt',\n 'aria-label',\n 'role',\n 'data-testid',\n 'data-qa',\n 'data-cy',\n 'data-direct-edit-target',\n])\n\nfunction escapeCssIdentifier(value: string): string {\n if (typeof CSS !== 'undefined' && typeof CSS.escape === 'function') {\n return CSS.escape(value)\n }\n return value.replace(/[^a-zA-Z0-9_-]/g, (char) => `\\\\${char}`)\n}\n\nfunction escapeAttributeValue(value: string): string {\n return value.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')\n}\n\nfunction isUniqueSelector(selector: string): boolean {\n if (typeof document === 'undefined') return false\n try {\n return document.querySelectorAll(selector).length === 1\n } catch {\n return false\n }\n}\n\nfunction getUniqueIdSelector(element: HTMLElement): string | null {\n if (!element.id) return null\n const selector = `#${escapeCssIdentifier(element.id)}`\n return isUniqueSelector(selector) ? selector : null\n}\n\nfunction getStableAttributeSelector(element: HTMLElement): string | null {\n const tagName = element.tagName.toLowerCase()\n for (const attr of STABLE_ATTRIBUTES) {\n const value = element.getAttribute(attr)\n if (!value) continue\n const selector = `${tagName}[${attr}=\"${escapeAttributeValue(value)}\"]`\n if (isUniqueSelector(selector)) {\n return selector\n }\n }\n return null\n}\n\nfunction getNthOfTypeSelector(element: HTMLElement): string {\n const tagName = element.tagName.toLowerCase()\n const classes = Array.from(element.classList)\n .filter((className) => className && !className.startsWith('direct-edit'))\n .slice(0, 2)\n const classSelector = classes.map((className) => `.${escapeCssIdentifier(className)}`).join('')\n\n let nthOfType = ''\n const parent = element.parentElement\n if (parent) {\n const siblings = Array.from(parent.children).filter(\n (child) => (child as HTMLElement).tagName.toLowerCase() === tagName\n )\n if (siblings.length > 1) {\n const index = siblings.indexOf(element) + 1\n nthOfType = `:nth-of-type(${index})`\n }\n }\n\n return `${tagName}${classSelector}${nthOfType}`\n}\n\nfunction buildDomSelector(element: HTMLElement): string {\n if (typeof document === 'undefined') {\n return element.tagName.toLowerCase()\n }\n if (element.closest('[data-direct-edit]')) return ''\n\n const uniqueId = getUniqueIdSelector(element)\n if (uniqueId) return uniqueId\n\n const stableAttribute = getStableAttributeSelector(element)\n if (stableAttribute) return stableAttribute\n\n const segments: string[] = []\n let current: HTMLElement | null = element\n let depth = 0\n\n while (current && current !== document.body && depth < MAX_SELECTOR_DEPTH) {\n if (current.hasAttribute('data-direct-edit')) {\n current = current.parentElement\n continue\n }\n\n if (depth > 0) {\n const parentId = getUniqueIdSelector(current)\n if (parentId) {\n segments.unshift(parentId)\n break\n }\n const parentStableAttr = getStableAttributeSelector(current)\n if (parentStableAttr) {\n segments.unshift(parentStableAttr)\n break\n }\n }\n\n segments.unshift(getNthOfTypeSelector(current))\n current = current.parentElement\n depth += 1\n }\n\n return segments.join(' > ')\n}\n\nfunction stripDirectEditNodes(root: Element) {\n const nodes = root.querySelectorAll('[data-direct-edit]')\n nodes.forEach((node) => node.remove())\n}\n\nfunction sanitizeContextNode(root: HTMLElement) {\n const nodes: HTMLElement[] = [root, ...Array.from(root.querySelectorAll<HTMLElement>('*'))]\n for (const node of nodes) {\n for (const attr of Array.from(node.attributes)) {\n if (!CONTEXT_ALLOWED_ATTRIBUTES.has(attr.name)) {\n node.removeAttribute(attr.name)\n }\n }\n }\n}\n\nfunction buildTargetHtml(element: HTMLElement): string {\n const tagName = element.tagName.toLowerCase()\n const attrs: string[] = []\n const allowList = [\n 'id',\n 'class',\n 'href',\n 'src',\n 'alt',\n 'aria-label',\n 'role',\n 'data-testid',\n ]\n const maxAttrLength = 48\n\n for (const attr of allowList) {\n const value = element.getAttribute(attr)\n if (!value) continue\n const trimmed = value.length > maxAttrLength ? `${value.slice(0, maxAttrLength - 3)}...` : value\n attrs.push(`${attr}=\"${escapeAttributeValue(trimmed)}\"`)\n }\n\n const text = getTextPreview(element)\n const attrString = attrs.length > 0 ? ` ${attrs.join(' ')}` : ''\n\n if (text) {\n return `<${tagName}${attrString}>\\n ${escapeHtml(text)}\\n</${tagName}>`\n }\n\n return `<${tagName}${attrString}></${tagName}>`\n}\n\nfunction formatSourcePath(file: string): string {\n const normalized = file\n .replace(/\\\\/g, '/')\n .replace(/^webpack:\\/\\/\\//, '')\n .replace(/^webpack:\\/\\//, '')\n .replace(/^webpack-internal:\\/\\//, '')\n .replace(/^rsc:\\/\\/React\\/Server\\//, '')\n .replace(/^about:\\/\\/React\\//, '')\n .replace(/^file:\\/\\//, '')\n .replace(/^\\/\\(app-pages-browser\\)\\//, '/')\n .replace(/^\\/app-pages-browser\\//, '/')\n .replace(/^_N_E\\//, '')\n .replace(/^\\.\\/+/, '')\n const packagesIndex = normalized.indexOf('/packages/')\n if (packagesIndex !== -1) {\n return `/[project]${normalized.slice(packagesIndex)}`\n }\n const appIndex = normalized.indexOf('/app/')\n if (appIndex !== -1) {\n return `/[project]${normalized.slice(appIndex)}`\n }\n const srcIndex = normalized.indexOf('/src/')\n if (srcIndex !== -1) {\n return `/[project]${normalized.slice(srcIndex)}`\n }\n return normalized\n}\n\nfunction formatSourceLocation(file: string, line?: number, column?: number): string {\n const formatted = formatSourcePath(file)\n if (typeof line === 'number') {\n const columnSuffix = typeof column === 'number' ? `:${column}` : ''\n return `${formatted}:${line}${columnSuffix}`\n }\n return formatted\n}\n\nfunction isUserlandSource(file: string): boolean {\n const normalized = file.replace(/\\\\/g, '/')\n if (\n normalized.includes('node_modules') ||\n normalized.includes('next/dist') ||\n normalized.includes('react') ||\n normalized.includes('react-dom') ||\n normalized.includes('direct-edit')\n ) {\n return false\n }\n return (\n normalized.includes('/app/') ||\n normalized.includes('/src/') ||\n normalized.includes('/packages/') ||\n normalized.startsWith('./')\n )\n}\n\nfunction getPrimaryFrame(locator: ElementLocator): ReactComponentFrame | null {\n for (const frame of locator.reactStack) {\n if (frame.file && isUserlandSource(frame.file)) {\n return frame\n }\n }\n for (const frame of locator.reactStack) {\n if (frame.file) {\n return frame\n }\n }\n return locator.reactStack[0] ?? null\n}\n\nfunction escapeHtml(value: string): string {\n return value\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''')\n}\n\nfunction buildDomContextHtml(\n element: HTMLElement,\n options?: { siblingCount?: number }\n): string {\n const parent = element.parentElement\n if (!parent) {\n const clone = element.cloneNode(true) as HTMLElement\n clone.setAttribute('data-direct-edit-target', 'true')\n stripDirectEditNodes(clone)\n sanitizeContextNode(clone)\n return clone.outerHTML\n }\n\n const parentClone = parent.cloneNode(false) as HTMLElement\n const siblings = Array.from(parent.children) as HTMLElement[]\n const selectedIndex = siblings.indexOf(element)\n const siblingCount = options?.siblingCount ?? 1\n let slice = siblings\n\n if (siblingCount >= 0 && selectedIndex >= 0) {\n const start = Math.max(0, selectedIndex - siblingCount)\n const end = Math.min(siblings.length, selectedIndex + siblingCount + 1)\n slice = siblings.slice(start, end)\n }\n\n for (const sibling of slice) {\n if (sibling.closest('[data-direct-edit]')) continue\n const clone = sibling.cloneNode(true) as HTMLElement\n if (sibling === element) {\n clone.setAttribute('data-direct-edit-target', 'true')\n }\n stripDirectEditNodes(clone)\n sanitizeContextNode(clone)\n parentClone.appendChild(clone)\n }\n\n sanitizeContextNode(parentClone)\n return parentClone.outerHTML\n}\n\nfunction normalizePreviewWhitespace(value: string): string {\n return value.replace(/\\s+/g, ' ').trim()\n}\n\nfunction isWordLikeChar(char: string): boolean {\n return /[A-Za-z0-9]/.test(char)\n}\n\nfunction getFallbackTextPreview(element: HTMLElement): string {\n const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT)\n const tokens: string[] = []\n let previousRaw = ''\n let previousParent: HTMLElement | null = null\n\n for (let node = walker.nextNode(); node; node = walker.nextNode()) {\n const textNode = node as Text\n const raw = textNode.textContent ?? ''\n const normalized = normalizePreviewWhitespace(raw)\n if (!normalized) continue\n\n if (tokens.length > 0) {\n const hasExplicitWhitespace = /^\\s/.test(raw) || /\\s$/.test(previousRaw)\n const prevLast = previousRaw.slice(-1)\n const nextFirst = normalized[0]\n const shouldInsertHeuristicSpace =\n previousParent !== textNode.parentElement &&\n isWordLikeChar(prevLast) &&\n isWordLikeChar(nextFirst)\n\n if (hasExplicitWhitespace || shouldInsertHeuristicSpace) {\n tokens.push(' ')\n }\n }\n\n tokens.push(normalized)\n previousRaw = raw\n previousParent = textNode.parentElement\n }\n\n return tokens.join('')\n}\n\nfunction getTextPreview(element: HTMLElement): string {\n const innerTextCandidate = normalizePreviewWhitespace(element.innerText ?? '')\n const text = innerTextCandidate || getFallbackTextPreview(element)\n if (text.length <= 120) {\n return text\n }\n return `${text.slice(0, 117)}...`\n}\n\nfunction parseDomSource(element: HTMLElement): DomSourceLocation | null {\n const value = element.getAttribute('data-direct-edit-source')\n if (!value) return null\n\n let file = value\n let line: number | undefined\n let column: number | undefined\n\n const lastColon = value.lastIndexOf(':')\n if (lastColon !== -1) {\n const maybeColumn = Number(value.slice(lastColon + 1))\n if (!Number.isNaN(maybeColumn)) {\n column = maybeColumn\n file = value.slice(0, lastColon)\n\n const prevColon = file.lastIndexOf(':')\n if (prevColon !== -1) {\n const maybeLine = Number(file.slice(prevColon + 1))\n if (!Number.isNaN(maybeLine)) {\n line = maybeLine\n file = file.slice(0, prevColon)\n }\n }\n }\n }\n\n return { file, line, column }\n}\n\nexport function getElementLocator(element: HTMLElement): ElementLocator {\n const elementInfo = getElementInfo(element)\n let domSource = parseDomSource(element)\n\n // Fallback: get source from the element's own React fiber when\n // the Vite plugin attribute is not present\n if (!domSource) {\n const seenFibers = new Set<any>()\n let fiber = getFiberForElement(element)\n while (fiber && !seenFibers.has(fiber)) {\n seenFibers.add(fiber)\n const fiberSource = getSourceFromFiber(fiber)\n if (fiberSource?.fileName) {\n domSource = {\n file: fiberSource.fileName,\n line: fiberSource.lineNumber,\n column: fiberSource.columnNumber,\n }\n break\n }\n fiber = fiber._debugOwner ?? fiber.return ?? null\n }\n }\n\n return {\n reactStack: getReactComponentStack(element),\n domSelector: buildDomSelector(element),\n domContextHtml: buildDomContextHtml(element),\n targetHtml: buildTargetHtml(element),\n textPreview: getTextPreview(element),\n tagName: elementInfo.tagName,\n id: elementInfo.id,\n classList: elementInfo.classList,\n domSource: domSource ?? undefined,\n }\n}\n\ninterface ExportChange {\n property: string\n value: string\n tailwind: string\n}\n\nfunction getLocatorHeader(locator: ElementLocator): { componentLabel: string; formattedSource: string | null } {\n const primaryFrame = getPrimaryFrame(locator)\n const componentLabel = primaryFrame?.name ? primaryFrame.name : locator.tagName\n const formattedSource = locator.domSource?.file\n ? formatSourceLocation(locator.domSource.file, locator.domSource.line, locator.domSource.column)\n : primaryFrame?.file\n ? formatSourceLocation(primaryFrame.file, primaryFrame.line, primaryFrame.column)\n : null\n return { componentLabel, formattedSource }\n}\n\nfunction buildLocatorContextLines(locator: ElementLocator): string[] {\n const lines: string[] = []\n const { componentLabel, formattedSource } = getLocatorHeader(locator)\n const target = (locator.targetHtml || locator.domContextHtml || '').trim()\n const context = locator.domContextHtml?.trim() || ''\n const selector = locator.domSelector?.trim()\n const text = locator.textPreview?.trim()\n\n lines.push(`@<${componentLabel}>`)\n lines.push('')\n if (target) {\n lines.push('target:')\n lines.push(target)\n }\n if (context && context !== target) {\n lines.push('context:')\n lines.push(context)\n }\n lines.push(`in ${formattedSource ?? '(file not available)'}`)\n if (selector) {\n lines.push(`selector: ${selector}`)\n }\n if (text) {\n lines.push(`text: ${text}`)\n }\n\n return lines\n}\n\nexport function buildElementContext(locator: ElementLocator): string {\n return buildLocatorContextLines(locator).join('\\n')\n}\n\nconst spacingGroups = [\n { top: 'padding-top', right: 'padding-right', bottom: 'padding-bottom', left: 'padding-left', all: 'padding', inline: 'padding-inline', block: 'padding-block' },\n { top: 'margin-top', right: 'margin-right', bottom: 'margin-bottom', left: 'margin-left', all: 'margin', inline: 'margin-inline', block: 'margin-block' },\n] as const\n\nexport function collapseSpacingShorthands(styles: Record<string, string>): Record<string, string> {\n const result = { ...styles }\n\n for (const group of spacingGroups) {\n const hasTop = group.top in result\n const hasRight = group.right in result\n const hasBottom = group.bottom in result\n const hasLeft = group.left in result\n const hasAllSides = hasTop && hasRight && hasBottom && hasLeft\n\n if (hasAllSides) {\n delete result[group.all]\n delete result[group.inline]\n delete result[group.block]\n }\n\n const top = result[group.top]\n const right = result[group.right]\n const bottom = result[group.bottom]\n const left = result[group.left]\n\n const horizontalMatch = hasLeft && hasRight && left === right\n const verticalMatch = hasTop && hasBottom && top === bottom\n\n if (horizontalMatch && verticalMatch) {\n delete result[group.top]\n delete result[group.right]\n delete result[group.bottom]\n delete result[group.left]\n if (top === left) {\n result[group.all] = top\n } else {\n result[group.inline] = left\n result[group.block] = top\n }\n } else if (horizontalMatch) {\n // Only horizontal pair matches\n delete result[group.left]\n delete result[group.right]\n result[group.inline] = left\n } else if (verticalMatch) {\n // Only vertical pair matches\n delete result[group.top]\n delete result[group.bottom]\n result[group.block] = top\n }\n }\n\n return result\n}\n\nfunction collapseFourSideShorthand(\n result: Record<string, string>,\n sides: { top: string; right: string; bottom: string; left: string; all: string }\n): void {\n if (!(sides.top in result && sides.right in result && sides.bottom in result && sides.left in result)) return\n\n // Side-specific values are the source of truth when all four are present.\n delete result[sides.all]\n\n const top = result[sides.top]\n const right = result[sides.right]\n const bottom = result[sides.bottom]\n const left = result[sides.left]\n const allEqual = top === right && top === bottom && top === left\n if (!allEqual) return\n\n delete result[sides.top]\n delete result[sides.right]\n delete result[sides.bottom]\n delete result[sides.left]\n result[sides.all] = top\n}\n\nexport function collapseExportShorthands(styles: Record<string, string>): Record<string, string> {\n const result = collapseSpacingShorthands(styles)\n\n collapseFourSideShorthand(result, {\n top: 'border-top-style',\n right: 'border-right-style',\n bottom: 'border-bottom-style',\n left: 'border-left-style',\n all: 'border-style',\n })\n\n collapseFourSideShorthand(result, {\n top: 'border-top-width',\n right: 'border-right-width',\n bottom: 'border-bottom-width',\n left: 'border-left-width',\n all: 'border-width',\n })\n\n collapseFourSideShorthand(result, {\n top: 'border-top-left-radius',\n right: 'border-top-right-radius',\n bottom: 'border-bottom-right-radius',\n left: 'border-bottom-left-radius',\n all: 'border-radius',\n })\n\n return result\n}\n\nexport function buildEditExport(\n locator: ElementLocator,\n pendingStyles: Record<string, string>,\n textEdit?: { originalText: string; newText: string } | null\n): string\nexport function buildEditExport(\n element: HTMLElement | null,\n elementInfo: ElementInfo,\n computedSpacing: SpacingProperties | null,\n computedBorderRadius: BorderRadiusProperties | null,\n computedFlex: FlexProperties | null,\n computedSizing: SizingProperties | null,\n pendingStyles: Record<string, string>\n): string\nexport function buildEditExport(\n arg1: ElementLocator | HTMLElement | null,\n arg2: ElementInfo | Record<string, string>,\n arg3?: SpacingProperties | null | { originalText: string; newText: string },\n arg4?: BorderRadiusProperties | null,\n arg5?: FlexProperties | null,\n arg6?: SizingProperties | null,\n arg7?: Record<string, string>\n): string {\n const isLocator = Boolean(arg1 && typeof arg1 === 'object' && 'domSelector' in arg1)\n if (!isLocator) {\n void arg4\n void arg5\n void arg6\n }\n const pendingStyles = (isLocator ? (arg2 as Record<string, string>) : arg7) || {}\n const textEdit = isLocator && arg3 && typeof arg3 === 'object' && 'originalText' in arg3\n ? (arg3 as { originalText: string; newText: string })\n : null\n let locator: ElementLocator\n\n if (isLocator) {\n locator = arg1 as ElementLocator\n } else {\n const element = arg1 as HTMLElement | null\n const elementInfo = arg2 as ElementInfo\n locator = element\n ? getElementLocator(element)\n : {\n reactStack: [],\n domSelector: elementInfo.id ? `#${elementInfo.id}` : elementInfo.tagName,\n domContextHtml: `<${elementInfo.tagName}${elementInfo.id ? ` id=\"${elementInfo.id}\"` : ''} data-direct-edit-target=\"true\"></${elementInfo.tagName}>`,\n targetHtml: `<${elementInfo.tagName}${elementInfo.id ? ` id=\"${elementInfo.id}\"` : ''}></${elementInfo.tagName}>`,\n textPreview: '',\n tagName: elementInfo.tagName,\n id: elementInfo.id,\n classList: elementInfo.classList,\n }\n }\n\n const changes: ExportChange[] = []\n\n const collapsedStyles = collapseExportShorthands(pendingStyles)\n for (const [property, value] of Object.entries(collapsedStyles)) {\n const tailwindClass = stylesToTailwind({ [property]: value })\n changes.push({\n property,\n value,\n tailwind: tailwindClass,\n })\n }\n\n const lines = buildLocatorContextLines(locator)\n lines.push('')\n if (changes.length > 0) {\n lines.push('edits:')\n for (const change of changes) {\n const tailwind = change.tailwind ? ` (${change.tailwind})` : ''\n lines.push(`${change.property}: ${change.value}${tailwind}`)\n }\n }\n\n if (textEdit) {\n lines.push('text content changed:')\n lines.push(`from: \"${textEdit.originalText}\"`)\n lines.push(`to: \"${textEdit.newText}\"`)\n }\n\n return lines.join('\\n')\n}\n\nexport function buildCommentExport(\n locator: ElementLocator,\n commentText: string,\n replies?: Array<{ text: string; createdAt: number }>\n): string {\n const lines = buildLocatorContextLines(locator)\n lines.push('')\n lines.push(`comment: ${commentText}`)\n if (replies && replies.length > 0) {\n for (const reply of replies) {\n lines.push(`reply: ${reply.text}`)\n }\n }\n\n return lines.join('\\n')\n}\n\nfunction formatPosition(\n siblingBefore: string | null,\n siblingAfter: string | null\n): string {\n if (siblingBefore && siblingAfter) return `after <${siblingBefore}>`\n if (siblingBefore && !siblingAfter) return `after <${siblingBefore}> (last)`\n if (!siblingBefore && siblingAfter) return `before <${siblingAfter}> (first)`\n return '(only child)'\n}\n\nfunction formatMoveSummary(move: NonNullable<SessionEdit['move']>): string {\n const fromPosition = formatPosition(move.fromSiblingBefore, move.fromSiblingAfter)\n const toPosition = formatPosition(move.toSiblingBefore, move.toSiblingAfter)\n if (move.fromParentName === move.toParentName) {\n return `in <${move.toParentName}>, from ${fromPosition} to ${toPosition}`\n }\n return `from <${move.fromParentName}> ${fromPosition} to <${move.toParentName}> ${toPosition}`\n}\n\nfunction formatMoveSelector(\n selector: string | null | undefined,\n fallback: '(none)' | '(unknown)'\n): string {\n const normalized = selector?.trim()\n return normalized ? normalized : fallback\n}\n\nfunction formatMoveSource(\n source: DomSourceLocation | null | undefined,\n fallback: '(none)' | '(unknown)'\n): string {\n if (!source?.file) return fallback\n return formatSourceLocation(source.file, source.line, source.column)\n}\n\nfunction buildMoveExportLines(move: NonNullable<SessionEdit['move']>): string[] {\n return [\n 'moved:',\n `summary: ${formatMoveSummary(move)}`,\n `from_parent_selector: ${formatMoveSelector(move.fromParentSelector, '(unknown)')}`,\n `from_before_selector: ${formatMoveSelector(move.fromSiblingBeforeSelector, '(none)')}`,\n `from_after_selector: ${formatMoveSelector(move.fromSiblingAfterSelector, '(none)')}`,\n `from_parent_source: ${formatMoveSource(move.fromParentSource, '(unknown)')}`,\n `from_before_source: ${formatMoveSource(move.fromSiblingBeforeSource, '(none)')}`,\n `from_after_source: ${formatMoveSource(move.fromSiblingAfterSource, '(none)')}`,\n `to_parent_selector: ${formatMoveSelector(move.toParentSelector, '(unknown)')}`,\n `to_before_selector: ${formatMoveSelector(move.toSiblingBeforeSelector, '(none)')}`,\n `to_after_selector: ${formatMoveSelector(move.toSiblingAfterSelector, '(none)')}`,\n `to_parent_source: ${formatMoveSource(move.toParentSource, '(unknown)')}`,\n `to_before_source: ${formatMoveSource(move.toSiblingBeforeSource, '(none)')}`,\n `to_after_source: ${formatMoveSource(move.toSiblingAfterSource, '(none)')}`,\n ]\n}\n\nexport function buildSessionExport(edits: SessionEdit[], comments: Comment[] = []): string {\n const blocks: string[] = []\n\n for (const edit of edits) {\n let block = buildEditExport(edit.locator, edit.pendingStyles, edit.textEdit)\n if (edit.move) {\n block += `\\n${buildMoveExportLines(edit.move).join('\\n')}`\n }\n blocks.push(block)\n }\n\n for (const comment of comments) {\n blocks.push(buildCommentExport(comment.locator, comment.text, comment.replies))\n }\n\n return blocks.join('\\n\\n---\\n\\n')\n}\n\nexport type {\n ElementInfo,\n CSSPropertyValue,\n SpacingProperties,\n BorderRadiusProperties,\n BorderStyle,\n BorderProperties,\n FlexProperties,\n DirectEditState,\n SpacingPropertyKey,\n BorderRadiusPropertyKey,\n BorderPropertyKey,\n FlexPropertyKey,\n MeasurementLine,\n MeasurementState,\n ColorValue,\n ColorProperties,\n ColorPropertyKey,\n SizingProperties,\n SizingPropertyKey,\n SizingMode,\n SizingValue,\n TypographyProperties,\n TypographyPropertyKey,\n ReactComponentFrame,\n ElementLocator,\n DragState,\n DropTarget,\n DropIndicator,\n} from './types'\n","import type { CSSPropertyValue } from '../types'\n\nexport function parsePropertyValue(value: string): CSSPropertyValue {\n const raw = value.trim()\n const match = raw.match(/^(-?\\d*\\.?\\d+)(px|rem|em|%)?$/)\n\n if (match) {\n return {\n numericValue: parseFloat(match[1]),\n unit: (match[2] as CSSPropertyValue['unit']) || 'px',\n raw,\n }\n }\n\n return {\n numericValue: 0,\n unit: 'px',\n raw,\n }\n}\n\nexport function formatPropertyValue(value: CSSPropertyValue): string {\n if (value.raw === 'auto' || value.raw === 'inherit' || value.raw === 'initial') {\n return value.raw\n }\n return `${value.numericValue}${value.unit}`\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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K;AAAA,EACnB;AAEA,aAAW,WAAW,UAAU;AAC9B,WAAO,KAAK,mBAAmB,QAAQ,SAAS,QAAQ,MAAM,QAAQ,OAAO,CAAC;AAAA,EAChF;AAEA,SAAO,OAAO,KAAK,aAAa;AAClC;","names":["numeric","isFlexContainer","containerRect"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils.ts","../src/utils/css-value.ts"],"sourcesContent":["import type {\n CSSPropertyValue,\n SpacingProperties,\n BorderRadiusProperties,\n BorderStyle,\n BorderProperties,\n FlexProperties,\n SizingProperties,\n SizingValue,\n SizingMode,\n SpacingPropertyKey,\n BorderRadiusPropertyKey,\n BorderPropertyKey,\n FlexPropertyKey,\n SizingPropertyKey,\n TypographyPropertyKey,\n TypographyProperties,\n ElementInfo,\n ReactComponentFrame,\n ElementLocator,\n DomSourceLocation,\n ColorValue,\n ColorProperties,\n ColorPropertyKey,\n MeasurementLine,\n Guideline,\n DropIndicator,\n SessionEdit,\n Comment,\n} from './types'\n\nexport { parsePropertyValue, formatPropertyValue } from './utils/css-value'\nimport { parsePropertyValue } from './utils/css-value'\n\nexport function clamp(value: number, min: number, max: number): number {\n if (!Number.isFinite(value)) return min\n if (max < min) return min\n return Math.max(min, Math.min(max, value))\n}\n\nexport function isInputFocused(): boolean {\n let active: Element | null = document.activeElement\n while (active?.shadowRoot?.activeElement) {\n active = active.shadowRoot.activeElement\n }\n return (\n active instanceof HTMLInputElement ||\n active instanceof HTMLTextAreaElement ||\n (active instanceof HTMLElement && active.isContentEditable)\n )\n}\n\ndeclare global {\n interface Window {\n __DIRECT_EDIT_DEVTOOLS__?: {\n getFiberForElement: (element: HTMLElement) => unknown | null\n hasHook?: boolean\n }\n }\n}\n\nexport function getComputedStyles(element: HTMLElement): {\n spacing: SpacingProperties\n borderRadius: BorderRadiusProperties\n flex: FlexProperties\n} {\n const computed = window.getComputedStyle(element)\n\n return {\n spacing: {\n paddingTop: parsePropertyValue(computed.paddingTop),\n paddingRight: parsePropertyValue(computed.paddingRight),\n paddingBottom: parsePropertyValue(computed.paddingBottom),\n paddingLeft: parsePropertyValue(computed.paddingLeft),\n marginTop: parsePropertyValue(computed.marginTop),\n marginRight: parsePropertyValue(computed.marginRight),\n marginBottom: parsePropertyValue(computed.marginBottom),\n marginLeft: parsePropertyValue(computed.marginLeft),\n gap: parsePropertyValue(computed.gap || '0px'),\n },\n borderRadius: {\n borderTopLeftRadius: parsePropertyValue(computed.borderTopLeftRadius),\n borderTopRightRadius: parsePropertyValue(computed.borderTopRightRadius),\n borderBottomRightRadius: parsePropertyValue(computed.borderBottomRightRadius),\n borderBottomLeftRadius: parsePropertyValue(computed.borderBottomLeftRadius),\n },\n flex: {\n display: computed.display,\n flexDirection: computed.flexDirection as FlexProperties['flexDirection'],\n justifyContent: computed.justifyContent,\n alignItems: computed.alignItems,\n },\n }\n}\n\nexport function getComputedBorderStyles(element: HTMLElement): BorderProperties {\n const computed = window.getComputedStyle(element)\n\n const topStyle = computed.borderTopStyle as BorderStyle\n const rightStyle = computed.borderRightStyle as BorderStyle\n const bottomStyle = computed.borderBottomStyle as BorderStyle\n const leftStyle = computed.borderLeftStyle as BorderStyle\n\n const topWidth = parsePropertyValue(computed.borderTopWidth)\n const rightWidth = parsePropertyValue(computed.borderRightWidth)\n const bottomWidth = parsePropertyValue(computed.borderBottomWidth)\n const leftWidth = parsePropertyValue(computed.borderLeftWidth)\n\n return {\n borderTopStyle: topStyle,\n borderTopWidth: topWidth,\n borderRightStyle: rightStyle,\n borderRightWidth: rightWidth,\n borderBottomStyle: bottomStyle,\n borderBottomWidth: bottomWidth,\n borderLeftStyle: leftStyle,\n borderLeftWidth: leftWidth,\n }\n}\n\n/** CSS properties captured before editing so resetToOriginal can restore them. */\nexport const ORIGINAL_STYLE_PROPS = [\n 'padding-top',\n 'padding-right',\n 'padding-bottom',\n 'padding-left',\n 'padding',\n 'margin-top',\n 'margin-right',\n 'margin-bottom',\n 'margin-left',\n 'margin',\n 'gap',\n 'border-radius',\n 'border-top-left-radius',\n 'border-top-right-radius',\n 'border-bottom-right-radius',\n 'border-bottom-left-radius',\n 'border',\n 'border-style',\n 'border-width',\n 'border-top-style',\n 'border-top-width',\n 'border-right-style',\n 'border-right-width',\n 'border-bottom-style',\n 'border-bottom-width',\n 'border-left-style',\n 'border-left-width',\n 'display',\n 'flex-direction',\n 'justify-content',\n 'align-items',\n 'width',\n 'height',\n 'background-color',\n 'color',\n 'border-color',\n 'outline-color',\n 'outline-style',\n 'outline-width',\n 'box-shadow',\n 'font-family',\n 'font-weight',\n 'font-size',\n 'line-height',\n 'letter-spacing',\n 'text-align',\n] as const\n\nexport function getOriginalInlineStyles(element: HTMLElement): Record<string, string> {\n const styles: Record<string, string> = {}\n\n for (const prop of ORIGINAL_STYLE_PROPS) {\n const value = element.style.getPropertyValue(prop)\n if (value) {\n styles[prop] = value\n }\n }\n\n return styles\n}\n\nconst spacingScale: Record<number, string> = { 0: '0', 1: 'px', 2: '0.5', 4: '1', 8: '2', 12: '3', 16: '4', 20: '5', 24: '6', 32: '8' }\n\nconst tailwindClassMap: Record<string, { prefix: string; scale: Record<number, string> }> = {\n padding: { prefix: 'p', scale: spacingScale },\n 'padding-inline': { prefix: 'px', scale: spacingScale },\n 'padding-block': { prefix: 'py', scale: spacingScale },\n 'padding-top': { prefix: 'pt', scale: spacingScale },\n 'padding-right': { prefix: 'pr', scale: spacingScale },\n 'padding-bottom': { prefix: 'pb', scale: spacingScale },\n 'padding-left': { prefix: 'pl', scale: spacingScale },\n margin: { prefix: 'm', scale: spacingScale },\n 'margin-inline': { prefix: 'mx', scale: spacingScale },\n 'margin-block': { prefix: 'my', scale: spacingScale },\n 'margin-top': { prefix: 'mt', scale: spacingScale },\n 'margin-right': { prefix: 'mr', scale: spacingScale },\n 'margin-bottom': { prefix: 'mb', scale: spacingScale },\n 'margin-left': { prefix: 'ml', scale: spacingScale },\n gap: { prefix: 'gap', scale: spacingScale },\n 'border-width': {\n prefix: 'border',\n scale: { 0: '0', 1: '', 2: '2', 4: '4', 8: '8' },\n },\n 'border-top-width': {\n prefix: 'border-t',\n scale: { 0: '0', 1: '', 2: '2', 4: '4', 8: '8' },\n },\n 'border-right-width': {\n prefix: 'border-r',\n scale: { 0: '0', 1: '', 2: '2', 4: '4', 8: '8' },\n },\n 'border-bottom-width': {\n prefix: 'border-b',\n scale: { 0: '0', 1: '', 2: '2', 4: '4', 8: '8' },\n },\n 'border-left-width': {\n prefix: 'border-l',\n scale: { 0: '0', 1: '', 2: '2', 4: '4', 8: '8' },\n },\n 'border-radius': {\n prefix: 'rounded',\n scale: { 0: 'none', 2: 'sm', 4: '', 6: 'md', 8: 'lg', 12: 'xl', 16: '2xl', 24: '3xl', 9999: 'full' },\n },\n 'border-top-left-radius': {\n prefix: 'rounded-tl',\n scale: { 0: 'none', 2: 'sm', 4: '', 6: 'md', 8: 'lg', 12: 'xl', 16: '2xl', 24: '3xl', 9999: 'full' },\n },\n 'border-top-right-radius': {\n prefix: 'rounded-tr',\n scale: { 0: 'none', 2: 'sm', 4: '', 6: 'md', 8: 'lg', 12: 'xl', 16: '2xl', 24: '3xl', 9999: 'full' },\n },\n 'border-bottom-right-radius': {\n prefix: 'rounded-br',\n scale: { 0: 'none', 2: 'sm', 4: '', 6: 'md', 8: 'lg', 12: 'xl', 16: '2xl', 24: '3xl', 9999: 'full' },\n },\n 'border-bottom-left-radius': {\n prefix: 'rounded-bl',\n scale: { 0: 'none', 2: 'sm', 4: '', 6: 'md', 8: 'lg', 12: 'xl', 16: '2xl', 24: '3xl', 9999: 'full' },\n },\n}\n\nconst flexDirectionMap: Record<string, string> = {\n row: 'flex-row',\n 'row-reverse': 'flex-row-reverse',\n column: 'flex-col',\n 'column-reverse': 'flex-col-reverse',\n}\n\nconst justifyContentMap: Record<string, string> = {\n 'flex-start': 'justify-start',\n 'flex-end': 'justify-end',\n center: 'justify-center',\n 'space-between': 'justify-between',\n 'space-around': 'justify-around',\n 'space-evenly': 'justify-evenly',\n start: 'justify-start',\n end: 'justify-end',\n}\n\nconst alignItemsMap: Record<string, string> = {\n 'flex-start': 'items-start',\n 'flex-end': 'items-end',\n center: 'items-center',\n baseline: 'items-baseline',\n stretch: 'items-stretch',\n start: 'items-start',\n end: 'items-end',\n}\n\nfunction getExactScaleValue(value: number, scale: Record<number, string>): string | null {\n if (Object.prototype.hasOwnProperty.call(scale, value)) {\n return scale[value]\n }\n return null\n}\n\nfunction normalizeTailwindArbitraryValue(value: string): string {\n return value.trim().replace(/\\s+/g, '_')\n}\n\nfunction normalizeShadowForComparison(value: string): string {\n return value\n .trim()\n .toLowerCase()\n .replace(/\\s*\\/\\s*/g, '/')\n .replace(/\\(\\s+/g, '(')\n .replace(/\\s+\\)/g, ')')\n .replace(/\\s*,\\s*/g, ',')\n .replace(/\\s+/g, ' ')\n}\n\nconst tailwindShadowClassValues: Array<{ className: string; css: string }> = [\n { className: 'shadow-2xs', css: '0 1px rgb(0 0 0 / 0.05)' },\n { className: 'shadow-xs', css: '0 1px 2px 0 rgb(0 0 0 / 0.05)' },\n { className: 'shadow', css: '0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)' },\n { className: 'shadow-sm', css: '0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)' },\n { className: 'shadow-md', css: '0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)' },\n { className: 'shadow-lg', css: '0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)' },\n { className: 'shadow-xl', css: '0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)' },\n { className: 'shadow-2xl', css: '0 25px 50px -12px rgb(0 0 0 / 0.25)' },\n { className: 'shadow-inner', css: 'inset 0 2px 4px 0 rgb(0 0 0 / 0.05)' },\n]\n\nexport function stylesToTailwind(styles: Record<string, string>): string {\n const classes: string[] = []\n\n for (const [prop, value] of Object.entries(styles)) {\n if (tailwindClassMap[prop]) {\n const parsed = parsePropertyValue(value)\n const mapping = tailwindClassMap[prop]\n if (value === 'auto') {\n classes.push(`${mapping.prefix}-auto`)\n continue\n }\n if (parsed.unit === 'px') {\n const exactScale = getExactScaleValue(parsed.numericValue, mapping.scale)\n if (exactScale !== null) {\n if (exactScale === '') {\n classes.push(mapping.prefix)\n } else {\n classes.push(`${mapping.prefix}-${exactScale}`)\n }\n continue\n }\n }\n classes.push(`${mapping.prefix}-[${value}]`)\n continue\n }\n\n if (prop === 'flex-direction' && flexDirectionMap[value]) {\n classes.push(flexDirectionMap[value])\n continue\n }\n\n if (prop === 'justify-content' && justifyContentMap[value]) {\n classes.push(justifyContentMap[value])\n continue\n }\n\n if (prop === 'align-items' && alignItemsMap[value]) {\n classes.push(alignItemsMap[value])\n continue\n }\n\n if (prop === 'display') {\n if (value === 'flex') classes.push('flex')\n else if (value === 'inline-flex') classes.push('inline-flex')\n else if (value === 'grid') classes.push('grid')\n else if (value === 'block') classes.push('block')\n else if (value === 'inline-block') classes.push('inline-block')\n else if (value === 'none') classes.push('hidden')\n continue\n }\n\n if (prop === 'width') {\n if (value === '100%') classes.push('w-full')\n else if (value === 'fit-content') classes.push('w-fit')\n else if (value === 'auto') classes.push('w-auto')\n else classes.push(`w-[${value}]`)\n continue\n }\n\n if (prop === 'height') {\n if (value === '100%') classes.push('h-full')\n else if (value === 'fit-content') classes.push('h-fit')\n else if (value === 'auto') classes.push('h-auto')\n else classes.push(`h-[${value}]`)\n continue\n }\n\n if (prop === 'background-color') {\n const colorValue = parseColorValue(value)\n classes.push(colorToTailwind('backgroundColor', colorValue))\n continue\n }\n\n if (prop === 'color') {\n const colorValue = parseColorValue(value)\n classes.push(colorToTailwind('color', colorValue))\n continue\n }\n\n if (prop === 'border-color') {\n const colorValue = parseColorValue(value)\n classes.push(colorToTailwind('borderColor', colorValue))\n continue\n }\n\n if (prop === 'border-style') {\n const styleMap: Record<string, string> = {\n none: 'border-none',\n solid: 'border-solid',\n dashed: 'border-dashed',\n dotted: 'border-dotted',\n double: 'border-double',\n }\n classes.push(styleMap[value] || `[border-style:${value}]`)\n continue\n }\n\n // Tailwind has no per-side border-style utilities — consolidate when all sides match\n if (prop === 'border-top-style' || prop === 'border-right-style' || prop === 'border-bottom-style' || prop === 'border-left-style') {\n const allPresent =\n 'border-top-style' in styles &&\n 'border-right-style' in styles &&\n 'border-bottom-style' in styles &&\n 'border-left-style' in styles\n if (allPresent) {\n // Only emit once (from border-top-style) when all four sides are present\n if (prop === 'border-top-style') {\n const allSame =\n styles['border-top-style'] === styles['border-right-style'] &&\n styles['border-top-style'] === styles['border-bottom-style'] &&\n styles['border-top-style'] === styles['border-left-style']\n if (allSame) {\n const styleMap: Record<string, string> = {\n none: 'border-none',\n solid: 'border-solid',\n dashed: 'border-dashed',\n dotted: 'border-dotted',\n double: 'border-double',\n }\n classes.push(styleMap[value] || `[border-style:${value}]`)\n } else {\n // Sides differ — emit each side individually\n classes.push(`[border-top-style:${styles['border-top-style']}]`)\n classes.push(`[border-right-style:${styles['border-right-style']}]`)\n classes.push(`[border-bottom-style:${styles['border-bottom-style']}]`)\n classes.push(`[border-left-style:${styles['border-left-style']}]`)\n }\n }\n } else {\n // Emit arbitrary-property syntax for individual side styles\n classes.push(`[${prop}:${value}]`)\n }\n continue\n }\n\n if (prop === 'outline-color') {\n const colorValue = parseColorValue(value)\n classes.push(colorToTailwind('outlineColor', colorValue))\n continue\n }\n\n if (prop === 'box-shadow') {\n const trimmed = value.trim()\n if (trimmed === 'none' || trimmed === '') {\n classes.push('shadow-none')\n } else {\n const normalized = normalizeShadowForComparison(trimmed)\n const preset = tailwindShadowClassValues.find(\n (entry) => normalizeShadowForComparison(entry.css) === normalized\n )\n if (preset) classes.push(preset.className)\n else classes.push(`shadow-[${normalizeTailwindArbitraryValue(value)}]`)\n }\n continue\n }\n\n if (prop === 'font-size') {\n classes.push(`text-[${value}]`)\n continue\n }\n\n if (prop === 'font-weight') {\n const weightMap: Record<string, string> = {\n '100': 'font-thin',\n '200': 'font-extralight',\n '300': 'font-light',\n '400': 'font-normal',\n '500': 'font-medium',\n '600': 'font-semibold',\n '700': 'font-bold',\n '800': 'font-extrabold',\n '900': 'font-black',\n }\n classes.push(weightMap[value] || `font-[${value}]`)\n continue\n }\n\n if (prop === 'line-height') {\n classes.push(`leading-[${value}]`)\n continue\n }\n\n if (prop === 'letter-spacing') {\n classes.push(`tracking-[${value}]`)\n continue\n }\n\n if (prop === 'text-align') {\n const alignMap: Record<string, string> = {\n left: 'text-left',\n center: 'text-center',\n right: 'text-right',\n justify: 'text-justify',\n }\n if (alignMap[value]) classes.push(alignMap[value])\n continue\n }\n\n if (prop === 'font-family') {\n classes.push(`font-[${value.replace(/\\s+/g, '_')}]`)\n continue\n }\n }\n\n return classes.join(' ')\n}\n\nexport const propertyToCSSMap: Record<SpacingPropertyKey, string> = {\n paddingTop: 'padding-top',\n paddingRight: 'padding-right',\n paddingBottom: 'padding-bottom',\n paddingLeft: 'padding-left',\n marginTop: 'margin-top',\n marginRight: 'margin-right',\n marginBottom: 'margin-bottom',\n marginLeft: 'margin-left',\n gap: 'gap',\n}\n\nexport const borderRadiusPropertyToCSSMap: Record<BorderRadiusPropertyKey, string> = {\n borderTopLeftRadius: 'border-top-left-radius',\n borderTopRightRadius: 'border-top-right-radius',\n borderBottomRightRadius: 'border-bottom-right-radius',\n borderBottomLeftRadius: 'border-bottom-left-radius',\n}\n\nexport const borderPropertyToCSSMap: Record<BorderPropertyKey, string> = {\n borderTopStyle: 'border-top-style',\n borderTopWidth: 'border-top-width',\n borderRightStyle: 'border-right-style',\n borderRightWidth: 'border-right-width',\n borderBottomStyle: 'border-bottom-style',\n borderBottomWidth: 'border-bottom-width',\n borderLeftStyle: 'border-left-style',\n borderLeftWidth: 'border-left-width',\n}\n\nexport const flexPropertyToCSSMap: Record<FlexPropertyKey, string> = {\n display: 'display',\n flexDirection: 'flex-direction',\n justifyContent: 'justify-content',\n alignItems: 'align-items',\n}\n\nexport const sizingPropertyToCSSMap: Record<SizingPropertyKey, string> = {\n width: 'width',\n height: 'height',\n}\n\nexport const typographyPropertyToCSSMap: Record<TypographyPropertyKey, string> = {\n fontFamily: 'font-family',\n fontWeight: 'font-weight',\n fontSize: 'font-size',\n lineHeight: 'line-height',\n letterSpacing: 'letter-spacing',\n textAlign: 'text-align',\n textVerticalAlign: 'align-items',\n}\n\nconst TEXT_ELEMENT_TAGS = new Set([\n 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6',\n 'span', 'label', 'a', 'strong', 'em', 'small',\n 'blockquote', 'li', 'td', 'th', 'caption', 'figcaption',\n 'legend', 'dt', 'dd', 'abbr', 'cite', 'code', 'pre',\n])\n\nfunction hasDirectNonWhitespaceText(element: HTMLElement): boolean {\n return Array.from(element.childNodes).some(\n (node) => node.nodeType === Node.TEXT_NODE && Boolean(node.textContent?.trim())\n )\n}\n\nexport function isTextElement(element: HTMLElement): boolean {\n const tagName = element.tagName.toLowerCase()\n if (TEXT_ELEMENT_TAGS.has(tagName)) {\n return true\n }\n if (hasDirectNonWhitespaceText(element)) {\n return true\n }\n if (element.children.length === 0 && element.textContent?.trim()) {\n return true\n }\n return false\n}\n\nexport function getComputedTypography(element: HTMLElement): TypographyProperties {\n const computed = window.getComputedStyle(element)\n\n let textVerticalAlign: TypographyProperties['textVerticalAlign'] = 'flex-start'\n if (computed.display === 'flex' || computed.display === 'inline-flex') {\n const alignItems = computed.alignItems\n if (alignItems === 'center') textVerticalAlign = 'center'\n else if (alignItems === 'flex-end' || alignItems === 'end') textVerticalAlign = 'flex-end'\n }\n\n // Handle \"normal\" keyword for line-height (use font-size as approximation)\n const lineHeight = computed.lineHeight === 'normal'\n ? { numericValue: parseFloat(computed.fontSize) * 1.2, unit: 'px' as const, raw: `${Math.round(parseFloat(computed.fontSize) * 1.2)}px` }\n : parsePropertyValue(computed.lineHeight)\n\n // Handle letter-spacing: convert px to em for consistent editing\n const fontSize = parseFloat(computed.fontSize)\n let letterSpacing: CSSPropertyValue\n if (computed.letterSpacing === 'normal') {\n letterSpacing = { numericValue: 0, unit: 'em' as const, raw: '0em' }\n } else {\n const parsed = parsePropertyValue(computed.letterSpacing)\n if (parsed.unit === 'px' && fontSize > 0) {\n const emValue = Math.round((parsed.numericValue / fontSize) * 100) / 100\n letterSpacing = { numericValue: emValue, unit: 'em' as const, raw: `${emValue}em` }\n } else {\n letterSpacing = parsed\n }\n }\n\n return {\n fontFamily: computed.fontFamily,\n fontWeight: computed.fontWeight,\n fontSize: parsePropertyValue(computed.fontSize),\n lineHeight,\n letterSpacing,\n textAlign: computed.textAlign as TypographyProperties['textAlign'],\n textVerticalAlign,\n }\n}\n\nexport function detectSizingMode(\n element: HTMLElement,\n dimension: 'width' | 'height'\n): SizingMode {\n const computed = window.getComputedStyle(element)\n const inlineValue = element.style[dimension]\n\n if (inlineValue === '100%') return 'fill'\n if (inlineValue === 'auto' || inlineValue === 'fit-content') return 'fit'\n\n const computedValue = computed[dimension]\n\n if (computedValue === '100%') return 'fill'\n if (\n computedValue === 'auto' ||\n computedValue === 'fit-content' ||\n computedValue === 'max-content'\n ) {\n return 'fit'\n }\n\n const parent = element.parentElement\n if (parent) {\n const parentComputed = window.getComputedStyle(parent)\n if (parentComputed.display === 'flex' || parentComputed.display === 'inline-flex') {\n const flexGrow = computed.flexGrow\n if (flexGrow !== '0') {\n return 'fill'\n }\n }\n }\n\n if (dimension === 'width') {\n if (computed.display === 'block' && !inlineValue) {\n return 'fill'\n }\n if (\n computed.display === 'inline-block' ||\n computed.display === 'inline-flex' ||\n computed.display === 'inline'\n ) {\n return 'fit'\n }\n }\n\n if (dimension === 'height') {\n if (!inlineValue) {\n return 'fit'\n }\n }\n\n return 'fixed'\n}\n\nexport function getSizingValue(element: HTMLElement, dimension: 'width' | 'height'): SizingValue {\n const mode = detectSizingMode(element, dimension)\n const rect = element.getBoundingClientRect()\n const numericValue = Math.round(dimension === 'width' ? rect.width : rect.height)\n\n return {\n mode,\n value: {\n numericValue,\n unit: 'px',\n raw: `${numericValue}px`,\n },\n }\n}\n\nexport function getComputedSizing(element: HTMLElement): SizingProperties {\n return {\n width: getSizingValue(element, 'width'),\n height: getSizingValue(element, 'height'),\n }\n}\n\nexport function sizingValueToCSS(sizing: SizingValue): string {\n switch (sizing.mode) {\n case 'fill':\n return '100%'\n case 'fit':\n return 'fit-content'\n case 'fixed':\n return `${sizing.value.numericValue}${sizing.value.unit}`\n }\n}\n\nexport function sizingToTailwind(dimension: 'width' | 'height', sizing: SizingValue): string {\n const prefix = dimension === 'width' ? 'w' : 'h'\n\n switch (sizing.mode) {\n case 'fill':\n return `${prefix}-full`\n case 'fit':\n return `${prefix}-fit`\n case 'fixed':\n return `${prefix}-[${sizing.value.numericValue}${sizing.value.unit}]`\n }\n}\n\nfunction parseHexColor(hex: string): ColorValue {\n const raw = hex\n let h = hex.replace('#', '')\n\n // Expand shorthand (#RGB -> #RRGGBB)\n if (h.length === 3) {\n h = h\n .split('')\n .map((c) => c + c)\n .join('')\n }\n\n // Handle 8-digit hex with alpha\n if (h.length === 8) {\n const alpha = Math.round((parseInt(h.slice(6, 8), 16) / 255) * 100)\n return { hex: h.slice(0, 6).toUpperCase(), alpha, raw }\n }\n\n return { hex: h.toUpperCase(), alpha: 100, raw }\n}\n\nfunction parseRgbChannel(value: string): number | null {\n const token = value.trim()\n if (!token) return null\n\n if (token.endsWith('%')) {\n const numeric = parseFloat(token.slice(0, -1))\n if (!Number.isFinite(numeric)) return null\n return Math.round((Math.max(0, Math.min(100, numeric)) / 100) * 255)\n }\n\n const numeric = parseFloat(token)\n if (!Number.isFinite(numeric)) return null\n return Math.round(Math.max(0, Math.min(255, numeric)))\n}\n\nfunction parseRgbAlpha(value: string | undefined): number | null {\n if (value == null || value.trim() === '') return 1\n const token = value.trim()\n\n if (token.endsWith('%')) {\n const numeric = parseFloat(token.slice(0, -1))\n if (!Number.isFinite(numeric)) return null\n return Math.max(0, Math.min(100, numeric)) / 100\n }\n\n const numeric = parseFloat(token)\n if (!Number.isFinite(numeric)) return null\n return Math.max(0, Math.min(1, numeric))\n}\n\nfunction parseRgbaColor(rgba: string): ColorValue {\n const raw = rgba.trim()\n const fnMatch = raw.match(/^rgba?\\((.*)\\)$/i)\n if (!fnMatch) {\n return { hex: '000000', alpha: 100, raw: rgba }\n }\n\n const body = fnMatch[1].trim()\n let channelTokens: [string, string, string] | null = null\n let alphaToken: string | undefined\n\n const commaParts = body.split(',').map((part) => part.trim()).filter(Boolean)\n if (commaParts.length === 3 || commaParts.length === 4) {\n channelTokens = [commaParts[0], commaParts[1], commaParts[2]]\n alphaToken = commaParts[3]\n } else {\n const slashParts = body.split('/')\n if (slashParts.length === 1 || slashParts.length === 2) {\n const channels = slashParts[0].trim().split(/\\s+/).filter(Boolean)\n if (channels.length === 3) {\n channelTokens = [channels[0], channels[1], channels[2]]\n alphaToken = slashParts[1]?.trim()\n }\n }\n }\n\n if (!channelTokens) {\n return { hex: '000000', alpha: 100, raw: rgba }\n }\n\n const r = parseRgbChannel(channelTokens[0])\n const g = parseRgbChannel(channelTokens[1])\n const b = parseRgbChannel(channelTokens[2])\n const a = parseRgbAlpha(alphaToken)\n\n if (r === null || g === null || b === null || a === null) {\n return { hex: '000000', alpha: 100, raw: rgba }\n }\n\n const hex = [r, g, b]\n .map((v) => v.toString(16).padStart(2, '0'))\n .join('')\n .toUpperCase()\n const alpha = Math.round(a * 100)\n\n return { hex, alpha, raw: rgba }\n}\n\nfunction parseNamedColor(name: string): ColorValue {\n // Use a temporary canvas to convert named colors\n const ctx = document.createElement('canvas').getContext('2d')\n if (!ctx) {\n return { hex: '000000', alpha: 100, raw: name }\n }\n\n ctx.fillStyle = name\n const computed = ctx.fillStyle\n\n if (computed.startsWith('#')) {\n return parseHexColor(computed)\n }\n return parseRgbaColor(computed)\n}\n\nexport function parseColorValue(cssValue: string): ColorValue {\n const raw = cssValue.trim()\n\n // Handle transparent\n if (raw === 'transparent') {\n return { hex: '000000', alpha: 0, raw }\n }\n\n // Handle hex colors\n if (raw.startsWith('#')) {\n return parseHexColor(raw)\n }\n\n // Handle rgb/rgba\n if (raw.startsWith('rgb')) {\n return parseRgbaColor(raw)\n }\n\n // Fallback: use canvas to convert named colors\n return parseNamedColor(raw)\n}\n\nconst TRANSPARENT_COLOR: ColorValue = { hex: '000000', alpha: 0, raw: 'transparent' }\n\nexport function getComputedBoxShadow(element: HTMLElement): string {\n const computed = window.getComputedStyle(element)\n const value = computed.boxShadow.trim()\n return value || 'none'\n}\n\nexport function getComputedColorStyles(element: HTMLElement): ColorProperties {\n const computed = window.getComputedStyle(element)\n\n const borderSides = [\n { style: computed.borderTopStyle, width: computed.borderTopWidth, color: computed.borderTopColor },\n { style: computed.borderRightStyle, width: computed.borderRightWidth, color: computed.borderRightColor },\n { style: computed.borderBottomStyle, width: computed.borderBottomWidth, color: computed.borderBottomColor },\n { style: computed.borderLeftStyle, width: computed.borderLeftWidth, color: computed.borderLeftColor },\n ]\n const visibleBorderSide = borderSides.find(\n (side) => side.style !== 'none' && side.style !== 'hidden' && parseFloat(side.width) > 0\n )\n const hasBorder = Boolean(visibleBorderSide)\n const hasOutline =\n computed.outlineStyle !== 'none' && parseFloat(computed.outlineWidth) > 0\n\n return {\n backgroundColor: parseColorValue(computed.backgroundColor),\n color: parseColorValue(computed.color),\n borderColor: hasBorder && visibleBorderSide ? parseColorValue(visibleBorderSide.color) : TRANSPARENT_COLOR,\n outlineColor: hasOutline ? parseColorValue(computed.outlineColor) : TRANSPARENT_COLOR,\n }\n}\n\nexport interface AllComputedStyles {\n spacing: SpacingProperties\n borderRadius: BorderRadiusProperties\n border: BorderProperties\n flex: FlexProperties\n sizing: SizingProperties\n color: ColorProperties\n boxShadow: string\n typography: TypographyProperties\n}\n\nexport function getAllComputedStyles(element: HTMLElement): AllComputedStyles {\n const { spacing, borderRadius, flex } = getComputedStyles(element)\n return {\n spacing,\n borderRadius,\n border: getComputedBorderStyles(element),\n flex,\n sizing: getComputedSizing(element),\n color: getComputedColorStyles(element),\n boxShadow: getComputedBoxShadow(element),\n typography: getComputedTypography(element),\n }\n}\n\nexport const colorPropertyToCSSMap: Record<ColorPropertyKey, string> = {\n backgroundColor: 'background-color',\n color: 'color',\n borderColor: 'border-color',\n outlineColor: 'outline-color',\n}\n\nconst colorTailwindPrefixMap: Record<ColorPropertyKey, string> = {\n backgroundColor: 'bg',\n color: 'text',\n borderColor: 'border',\n outlineColor: 'outline',\n}\n\nexport function colorToTailwind(\n property: ColorPropertyKey,\n colorValue: ColorValue\n): string {\n const prefix = colorTailwindPrefixMap[property]\n\n // Use arbitrary hex value\n if (colorValue.alpha === 100) {\n return `${prefix}-[#${colorValue.hex}]`\n }\n return `${prefix}-[#${colorValue.hex}]/${colorValue.alpha}`\n}\n\nexport function getElementInfo(element: HTMLElement): ElementInfo {\n const computed = window.getComputedStyle(element)\n const parentElement = element.parentElement\n\n const isFlexContainer = computed.display === 'flex' || computed.display === 'inline-flex'\n\n let isFlexItem = false\n if (parentElement) {\n const parentComputed = window.getComputedStyle(parentElement)\n isFlexItem = parentComputed.display === 'flex' || parentComputed.display === 'inline-flex'\n }\n\n return {\n tagName: element.tagName.toLowerCase(),\n id: element.id || null,\n classList: Array.from(element.classList),\n isFlexContainer,\n isFlexItem,\n isTextElement: isTextElement(element),\n parentElement,\n hasChildren: element.children.length > 0,\n }\n}\n\ninterface DimensionDisplay {\n width: string\n height: string\n}\n\nfunction isFitSizing(element: HTMLElement, dimension: 'width' | 'height'): boolean {\n const computed = window.getComputedStyle(element)\n const inlineValue = element.style[dimension]\n\n if (inlineValue === 'auto') return true\n\n const computedValue = computed[dimension]\n\n if (!inlineValue) {\n const parent = element.parentElement\n if (parent) {\n const parentComputed = window.getComputedStyle(parent)\n if (parentComputed.display === 'flex' || parentComputed.display === 'inline-flex') {\n const flexBasis = computed.flexBasis\n const flexGrow = computed.flexGrow\n if (flexBasis === 'auto' && flexGrow === '0') {\n return true\n }\n }\n }\n\n if (dimension === 'width') {\n if (computed.display === 'block' && !inlineValue) {\n return false\n }\n if (\n computed.display === 'inline-block' ||\n computed.display === 'inline-flex' ||\n computed.display === 'inline'\n ) {\n return true\n }\n }\n\n if (dimension === 'height') {\n return !inlineValue\n }\n }\n\n if (computedValue.includes('fit-content') || computedValue.includes('max-content')) {\n return true\n }\n\n return false\n}\n\nexport function getDimensionDisplay(element: HTMLElement): DimensionDisplay {\n const rect = element.getBoundingClientRect()\n const width = Math.round(rect.width)\n const height = Math.round(rect.height)\n\n const widthIsFit = isFitSizing(element, 'width')\n const heightIsFit = isFitSizing(element, 'height')\n\n return {\n width: widthIsFit ? `Fit ${width}` : `${width}`,\n height: heightIsFit ? `Fit ${height}` : `${height}`,\n }\n}\n\n\nexport function calculateParentMeasurements(element: HTMLElement, container?: HTMLElement): MeasurementLine[] {\n const parent = container ?? element.parentElement\n if (!parent) return []\n\n const elementRect = element.getBoundingClientRect()\n const parentRect = parent.getBoundingClientRect()\n\n // Use clientLeft/clientTop for reliable border widths, clientWidth/clientHeight\n // for inner dimensions (handles scrollbars correctly)\n const paddingBoxLeft = parentRect.left + parent.clientLeft\n const paddingBoxTop = parentRect.top + parent.clientTop\n const paddingBoxRight = parentRect.left + parent.clientLeft + parent.clientWidth\n const paddingBoxBottom = parentRect.top + parent.clientTop + parent.clientHeight\n\n let parentInnerLeft: number\n let parentInnerTop: number\n let parentInnerRight: number\n let parentInnerBottom: number\n\n if (container) {\n // Ancestor case: measure from padding-box (inside border, outside padding).\n // The ancestor's padding doesn't directly position the child — intermediate\n // elements do — so the visually correct edge is inside the border only.\n parentInnerLeft = paddingBoxLeft\n parentInnerTop = paddingBoxTop\n parentInnerRight = paddingBoxRight\n parentInnerBottom = paddingBoxBottom\n } else {\n // Direct parent case: measure from content-box (inside border and padding).\n // The parent's padding IS the gap between its edge and the child's layout area.\n const parentStyles = window.getComputedStyle(parent)\n parentInnerLeft = paddingBoxLeft + (parseFloat(parentStyles.paddingLeft) || 0)\n parentInnerTop = paddingBoxTop + (parseFloat(parentStyles.paddingTop) || 0)\n parentInnerRight = paddingBoxRight - (parseFloat(parentStyles.paddingRight) || 0)\n parentInnerBottom = paddingBoxBottom - (parseFloat(parentStyles.paddingBottom) || 0)\n }\n\n const measurements: MeasurementLine[] = []\n\n const topDistance = Math.round(elementRect.top - parentInnerTop)\n if (topDistance > 0) {\n const midX = elementRect.left + elementRect.width / 2\n measurements.push({\n direction: 'vertical',\n x1: midX,\n y1: parentInnerTop,\n x2: midX,\n y2: elementRect.top,\n distance: topDistance,\n labelPosition: { x: midX, y: (parentInnerTop + elementRect.top) / 2 },\n })\n }\n\n const bottomDistance = Math.round(parentInnerBottom - elementRect.bottom)\n if (bottomDistance > 0) {\n const midX = elementRect.left + elementRect.width / 2\n measurements.push({\n direction: 'vertical',\n x1: midX,\n y1: elementRect.bottom,\n x2: midX,\n y2: parentInnerBottom,\n distance: bottomDistance,\n labelPosition: { x: midX, y: (elementRect.bottom + parentInnerBottom) / 2 },\n })\n }\n\n const leftDistance = Math.round(elementRect.left - parentInnerLeft)\n if (leftDistance > 0) {\n const midY = elementRect.top + elementRect.height / 2\n measurements.push({\n direction: 'horizontal',\n x1: parentInnerLeft,\n y1: midY,\n x2: elementRect.left,\n y2: midY,\n distance: leftDistance,\n labelPosition: { x: (parentInnerLeft + elementRect.left) / 2, y: midY },\n })\n }\n\n const rightDistance = Math.round(parentInnerRight - elementRect.right)\n if (rightDistance > 0) {\n const midY = elementRect.top + elementRect.height / 2\n measurements.push({\n direction: 'horizontal',\n x1: elementRect.right,\n y1: midY,\n x2: parentInnerRight,\n y2: midY,\n distance: rightDistance,\n labelPosition: { x: (elementRect.right + parentInnerRight) / 2, y: midY },\n })\n }\n\n return measurements\n}\n\nexport function calculateElementMeasurements(\n from: HTMLElement,\n to: HTMLElement\n): MeasurementLine[] {\n const fromRect = from.getBoundingClientRect()\n const toRect = to.getBoundingClientRect()\n const measurements: MeasurementLine[] = []\n\n const horizontalOverlap =\n fromRect.left < toRect.right && fromRect.right > toRect.left\n const verticalOverlap =\n fromRect.top < toRect.bottom && fromRect.bottom > toRect.top\n\n if (verticalOverlap) {\n const overlapTop = Math.max(fromRect.top, toRect.top)\n const overlapBottom = Math.min(fromRect.bottom, toRect.bottom)\n const midY = (overlapTop + overlapBottom) / 2\n\n if (fromRect.right <= toRect.left) {\n const distance = Math.round(toRect.left - fromRect.right)\n measurements.push({\n direction: 'horizontal',\n x1: fromRect.right,\n y1: midY,\n x2: toRect.left,\n y2: midY,\n distance,\n labelPosition: { x: (fromRect.right + toRect.left) / 2, y: midY },\n })\n } else if (fromRect.left >= toRect.right) {\n const distance = Math.round(fromRect.left - toRect.right)\n measurements.push({\n direction: 'horizontal',\n x1: toRect.right,\n y1: midY,\n x2: fromRect.left,\n y2: midY,\n distance,\n labelPosition: { x: (toRect.right + fromRect.left) / 2, y: midY },\n })\n }\n }\n\n if (horizontalOverlap) {\n const overlapLeft = Math.max(fromRect.left, toRect.left)\n const overlapRight = Math.min(fromRect.right, toRect.right)\n const midX = (overlapLeft + overlapRight) / 2\n\n if (fromRect.bottom <= toRect.top) {\n const distance = Math.round(toRect.top - fromRect.bottom)\n measurements.push({\n direction: 'vertical',\n x1: midX,\n y1: fromRect.bottom,\n x2: midX,\n y2: toRect.top,\n distance,\n labelPosition: { x: midX, y: (fromRect.bottom + toRect.top) / 2 },\n })\n } else if (fromRect.top >= toRect.bottom) {\n const distance = Math.round(fromRect.top - toRect.bottom)\n measurements.push({\n direction: 'vertical',\n x1: midX,\n y1: toRect.bottom,\n x2: midX,\n y2: fromRect.top,\n distance,\n labelPosition: { x: midX, y: (toRect.bottom + fromRect.top) / 2 },\n })\n }\n }\n\n if (!horizontalOverlap && !verticalOverlap) {\n const fromCenterX = fromRect.left + fromRect.width / 2\n const fromCenterY = fromRect.top + fromRect.height / 2\n const toCenterX = toRect.left + toRect.width / 2\n const toCenterY = toRect.top + toRect.height / 2\n\n const hDistance = toCenterX > fromCenterX\n ? Math.round(toRect.left - fromRect.right)\n : Math.round(fromRect.left - toRect.right)\n\n if (hDistance > 0) {\n const startX = toCenterX > fromCenterX ? fromRect.right : fromRect.left\n const endX = toCenterX > fromCenterX ? toRect.left : toRect.right\n const y = (fromCenterY + toCenterY) / 2\n measurements.push({\n direction: 'horizontal',\n x1: startX,\n y1: y,\n x2: endX,\n y2: y,\n distance: hDistance,\n labelPosition: { x: (startX + endX) / 2, y },\n })\n }\n\n const vDistance = toCenterY > fromCenterY\n ? Math.round(toRect.top - fromRect.bottom)\n : Math.round(fromRect.top - toRect.bottom)\n\n if (vDistance > 0) {\n const x = (fromCenterX + toCenterX) / 2\n const startY = toCenterY > fromCenterY ? fromRect.bottom : fromRect.top\n const endY = toCenterY > fromCenterY ? toRect.top : toRect.bottom\n measurements.push({\n direction: 'vertical',\n x1: x,\n y1: startY,\n x2: x,\n y2: endY,\n distance: vDistance,\n labelPosition: { x, y: (startY + endY) / 2 },\n })\n }\n }\n\n return measurements\n}\n\nconst GUIDELINE_PROXIMITY = 80\n\nexport function calculateGuidelineMeasurements(\n element: HTMLElement,\n guidelines: Guideline[],\n mousePosition?: { x: number; y: number } | null,\n): MeasurementLine[] {\n if (guidelines.length === 0) return []\n\n const rect = element.getBoundingClientRect()\n const scrollX = window.scrollX\n const scrollY = window.scrollY\n const measurements: MeasurementLine[] = []\n\n for (const g of guidelines) {\n if (g.orientation === 'horizontal') {\n const gy = g.position - scrollY\n const midX = rect.left + rect.width / 2\n\n // Only show when mouse is near this guideline's Y position\n if (mousePosition && Math.abs(mousePosition.y - gy) > GUIDELINE_PROXIMITY) continue\n\n if (gy < rect.top) {\n const distance = Math.round(rect.top - gy)\n if (distance > 0) {\n measurements.push({\n direction: 'vertical',\n x1: midX,\n y1: gy,\n x2: midX,\n y2: rect.top,\n distance,\n labelPosition: { x: midX, y: (gy + rect.top) / 2 },\n })\n }\n } else if (gy > rect.bottom) {\n const distance = Math.round(gy - rect.bottom)\n if (distance > 0) {\n measurements.push({\n direction: 'vertical',\n x1: midX,\n y1: rect.bottom,\n x2: midX,\n y2: gy,\n distance,\n labelPosition: { x: midX, y: (rect.bottom + gy) / 2 },\n })\n }\n }\n } else {\n const gx = g.position - scrollX\n const midY = rect.top + rect.height / 2\n\n // Only show when mouse is near this guideline's X position\n if (mousePosition && Math.abs(mousePosition.x - gx) > GUIDELINE_PROXIMITY) continue\n\n if (gx < rect.left) {\n const distance = Math.round(rect.left - gx)\n if (distance > 0) {\n measurements.push({\n direction: 'horizontal',\n x1: gx,\n y1: midY,\n x2: rect.left,\n y2: midY,\n distance,\n labelPosition: { x: (gx + rect.left) / 2, y: midY },\n })\n }\n } else if (gx > rect.right) {\n const distance = Math.round(gx - rect.right)\n if (distance > 0) {\n measurements.push({\n direction: 'horizontal',\n x1: rect.right,\n y1: midY,\n x2: gx,\n y2: midY,\n distance,\n labelPosition: { x: (rect.right + gx) / 2, y: midY },\n })\n }\n }\n }\n }\n\n return measurements\n}\n\nexport function isFlexContainer(element: HTMLElement): boolean {\n const computed = window.getComputedStyle(element)\n return computed.display === 'flex' || computed.display === 'inline-flex'\n}\n\nexport function getFlexDirection(\n element: HTMLElement\n): 'row' | 'row-reverse' | 'column' | 'column-reverse' {\n const computed = window.getComputedStyle(element)\n return computed.flexDirection as 'row' | 'row-reverse' | 'column' | 'column-reverse'\n}\n\nexport function detectChildrenDirection(\n container: HTMLElement,\n exclude: HTMLElement | null\n): { axis: 'horizontal' | 'vertical'; reversed: boolean } {\n const computed = window.getComputedStyle(container)\n\n // Flex: trust CSS for accuracy (especially reverse)\n if (computed.display === 'flex' || computed.display === 'inline-flex') {\n const dir = computed.flexDirection\n return {\n axis: (dir === 'row' || dir === 'row-reverse') ? 'horizontal' : 'vertical',\n reversed: dir === 'row-reverse' || dir === 'column-reverse',\n }\n }\n\n // Non-flex: examine first two visible, in-flow children\n const visible: HTMLElement[] = []\n for (const c of container.children) {\n if (!(c instanceof HTMLElement) || c === exclude) continue\n const cs = window.getComputedStyle(c)\n if (cs.display === 'none' || cs.position === 'absolute' || cs.position === 'fixed') continue\n visible.push(c)\n if (visible.length === 2) break\n }\n\n if (visible.length < 2) return { axis: 'vertical', reversed: false }\n\n const first = visible[0].getBoundingClientRect()\n const second = visible[1].getBoundingClientRect()\n const yOverlap = first.bottom - 2 > second.top && second.bottom - 2 > first.top\n\n if (yOverlap) {\n return { axis: 'horizontal', reversed: second.right < first.left }\n }\n return { axis: 'vertical', reversed: second.bottom < first.top }\n}\n\nfunction htmlChildren(el: HTMLElement): HTMLElement[] {\n return Array.from(el.children).filter(\n (child): child is HTMLElement => child instanceof HTMLElement\n )\n}\n\n/** Walk up from `element` to find the nearest flex/inline-flex ancestor, stopping at `boundary`. */\nfunction findFlexAncestor(\n element: HTMLElement,\n boundary: HTMLElement | null,\n): { flexParent: HTMLElement; child: HTMLElement } | null {\n let current: HTMLElement | null = element\n while (current && current !== document.body) {\n const parent: HTMLElement | null = current.parentElement\n if (!parent) break\n const display = getComputedStyle(parent).display\n if (display === 'flex' || display === 'inline-flex') {\n return { flexParent: parent, child: current }\n }\n if (boundary && parent === boundary) break\n current = parent\n }\n return null\n}\n\nexport function computeHoverHighlight(\n elementUnder: HTMLElement | null,\n selectedElement: HTMLElement | null,\n): { flexContainer: HTMLElement; children: HTMLElement[] } | null {\n if (\n !elementUnder ||\n elementUnder === document.body ||\n elementUnder === document.documentElement ||\n elementUnder.closest('[data-direct-edit]') ||\n elementUnder.closest('[data-direct-edit-host]') ||\n elementUnder === selectedElement\n ) {\n return null\n }\n\n // When hovering descendants of the selected element, stop walk-up at the boundary\n const boundary = selectedElement?.contains(elementUnder) ? selectedElement : null\n\n const ownDisplay = getComputedStyle(elementUnder).display\n if (ownDisplay === 'flex' || ownDisplay === 'inline-flex') {\n return { flexContainer: elementUnder, children: htmlChildren(elementUnder) }\n }\n\n const found = findFlexAncestor(elementUnder, boundary)\n if (found) {\n return { flexContainer: found.flexParent, children: htmlChildren(found.flexParent) }\n }\n\n return { flexContainer: elementUnder, children: [] }\n}\n\nexport function resolveElementTarget(\n elementUnder: HTMLElement,\n selectedElement: HTMLElement | null,\n): HTMLElement {\n const boundary = selectedElement?.contains(elementUnder) ? selectedElement : null\n const found = findFlexAncestor(elementUnder, boundary)\n if (found && found.flexParent === boundary) return elementUnder\n return found?.child ?? elementUnder\n}\n\n/** Finds the text-owning element at a point within `boundary` using browser caret hit-testing. */\nexport function findTextOwnerAtPoint(\n boundary: HTMLElement,\n clientX: number,\n clientY: number,\n): HTMLElement | null {\n const doc = document as Document & {\n caretPositionFromPoint?: (x: number, y: number) => { offsetNode: Node } | null\n caretRangeFromPoint?: (x: number, y: number) => Range | null\n }\n\n const caretNode =\n doc.caretPositionFromPoint?.(clientX, clientY)?.offsetNode\n ?? doc.caretRangeFromPoint?.(clientX, clientY)?.startContainer\n ?? null\n if (!caretNode || caretNode.nodeType !== Node.TEXT_NODE) return null\n\n const textNode = caretNode as Text\n if (!(textNode.nodeValue ?? '').trim()) return null\n\n const owner = textNode.parentElement\n if (!owner || !boundary.contains(owner)) return null\n if (owner.closest('[data-direct-edit]') || owner.closest('[data-direct-edit-host]')) return null\n\n // Guard against caret APIs returning nearby text nodes.\n const range = document.createRange()\n range.selectNodeContents(textNode)\n const hitsText = Array.from(range.getClientRects()).some(\n (r) => clientX >= r.left && clientX <= r.right && clientY >= r.top && clientY <= r.bottom\n )\n range.detach?.()\n return hitsText ? owner : null\n}\n\n/** Fallback text hit-testing by scanning text nodes and rendered rects within `boundary`. */\nexport function findTextOwnerByRangeScan(\n boundary: HTMLElement,\n clientX: number,\n clientY: number,\n): HTMLElement | null {\n const walker = document.createTreeWalker(boundary, NodeFilter.SHOW_TEXT)\n let current: Node | null = walker.nextNode()\n\n while (current) {\n const textNode = current as Text\n if ((textNode.nodeValue ?? '').trim()) {\n const owner = textNode.parentElement\n if (\n owner &&\n boundary.contains(owner) &&\n !owner.closest('[data-direct-edit]') &&\n !owner.closest('[data-direct-edit-host]')\n ) {\n const range = document.createRange()\n range.selectNodeContents(textNode)\n const hitsText = Array.from(range.getClientRects()).some(\n (r) => clientX >= r.left && clientX <= r.right && clientY >= r.top && clientY <= r.bottom\n )\n range.detach?.()\n if (hitsText) return owner\n }\n }\n current = walker.nextNode()\n }\n\n return null\n}\n\n/** Wrap the direct text node under the point into a span so it becomes independently selectable. */\nexport function ensureDirectTextSpanAtPoint(\n parent: HTMLElement,\n clientX: number,\n clientY: number,\n): HTMLElement | null {\n const directTextNodes = Array.from(parent.childNodes).filter(\n (node): node is Text => node.nodeType === Node.TEXT_NODE && Boolean(node.textContent?.trim())\n )\n\n for (const textNode of directTextNodes) {\n const range = document.createRange()\n range.selectNodeContents(textNode)\n const hitsText = Array.from(range.getClientRects()).some(\n (r) => clientX >= r.left && clientX <= r.right && clientY >= r.top && clientY <= r.bottom\n )\n range.detach?.()\n\n if (!hitsText) continue\n\n const span = document.createElement('span')\n span.setAttribute('data-direct-edit-generated', 'text-span')\n span.textContent = textNode.textContent ?? ''\n parent.replaceChild(span, textNode)\n return span\n }\n\n return null\n}\n\n/** When elementFromPoint returns the selected element (bare text, padding, gap),\n * find the best child element to drill into at the given coordinates. */\nexport function findChildAtPoint(\n parent: HTMLElement,\n clientX: number,\n clientY: number,\n): HTMLElement | null {\n const children = htmlChildren(parent)\n if (children.length === 0) return null\n\n // Direct hit: child whose bbox contains the click\n const hit = children.find((child) => {\n const r = child.getBoundingClientRect()\n return clientX >= r.left && clientX <= r.right && clientY >= r.top && clientY <= r.bottom\n })\n if (hit) return hit\n\n // Single-child fallback should not steal clicks from parent's direct text.\n if (children.length === 1 && !hasDirectNonWhitespaceText(parent)) return children[0]\n\n return null\n}\n\nexport function elementFromPointWithoutOverlays(x: number, y: number): HTMLElement | null {\n const host = document.querySelector<HTMLElement>('[data-direct-edit-host]')\n if (host) host.style.display = 'none'\n const el = document.elementFromPoint(x, y) as HTMLElement | null\n if (host) host.style.display = ''\n return el\n}\n\nfunction isLayoutContainer(element: HTMLElement): boolean {\n const display = window.getComputedStyle(element).display\n return (\n display === 'flex' ||\n display === 'inline-flex' ||\n display === 'grid' ||\n display === 'inline-grid'\n )\n}\n\nfunction isBlockContainer(element: HTMLElement): boolean {\n const display = window.getComputedStyle(element).display\n return display === 'block' || display === 'flow-root'\n || display === 'inline-block' || display === 'list-item'\n}\n\nfunction skipElement(el: HTMLElement, exclude: HTMLElement | null): boolean {\n if (exclude && exclude.contains(el)) return true\n if (el === document.body || el === document.documentElement) return true\n if (el.closest('[data-direct-edit]') || el.closest('[data-direct-edit-host]')) return true\n return false\n}\n\nfunction findContainerViaTraversal(x: number, y: number, exclude: HTMLElement | null): HTMLElement | null {\n const el = elementFromPointWithoutOverlays(x, y)\n if (!el) return null\n let current: HTMLElement | null = el\n while (current) {\n if (!skipElement(current, exclude)) {\n if (isLayoutContainer(current) || isBlockContainer(current)) return current\n }\n current = current.parentElement\n }\n return null\n}\n\nexport function findContainerAtPoint(\n x: number,\n y: number,\n exclude: HTMLElement | null,\n preferredParent?: HTMLElement | null\n): HTMLElement | null {\n const host = document.querySelector<HTMLElement>('[data-direct-edit-host]')\n if (host) host.style.display = 'none'\n\n const elements = document.elementsFromPoint(x, y) as HTMLElement[]\n\n if (host) host.style.display = ''\n\n // Find most specific container (front-to-back = most nested first)\n for (const el of elements) {\n if (skipElement(el, exclude)) continue\n if (isLayoutContainer(el) || isBlockContainer(el)) return el\n }\n\n // Fallback: preferredParent for gap/padding areas\n if (preferredParent && (isLayoutContainer(preferredParent) || isBlockContainer(preferredParent))) {\n for (const el of elements) {\n if (el === preferredParent) return preferredParent\n }\n }\n\n // Last resort: walk up DOM\n return findContainerViaTraversal(x, y, exclude)\n}\n\nexport function calculateDropPosition(\n container: HTMLElement,\n pointerX: number,\n pointerY: number,\n draggedElement: HTMLElement\n): { insertBefore: HTMLElement | null; indicator: DropIndicator } | null {\n const { axis, reversed: isReversed } = detectChildrenDirection(container, draggedElement)\n const isHorizontal = axis === 'horizontal'\n\n const children = Array.from(container.children).filter(\n (child) => child !== draggedElement && child instanceof HTMLElement\n ) as HTMLElement[]\n\n if (children.length === 0) {\n const containerRect = container.getBoundingClientRect()\n return {\n insertBefore: null,\n indicator: {\n x: containerRect.left + 4,\n y: containerRect.top + 4,\n width: isHorizontal ? 1 : containerRect.width - 8,\n height: isHorizontal ? containerRect.height - 8 : 1,\n },\n }\n }\n\n const containerRect = container.getBoundingClientRect()\n let insertBefore: HTMLElement | null = null\n let indicatorPosition = 0\n\n for (let i = 0; i < children.length; i++) {\n const child = children[i]\n const rect = child.getBoundingClientRect()\n const midpoint = isHorizontal\n ? rect.left + rect.width / 2\n : rect.top + rect.height / 2\n\n const pointer = isHorizontal ? pointerX : pointerY\n\n const beforeMidpoint = isReversed ? pointer > midpoint : pointer < midpoint\n\n if (beforeMidpoint) {\n insertBefore = child\n indicatorPosition = isHorizontal ? rect.left : rect.top\n break\n }\n }\n\n if (!insertBefore) {\n const lastChild = children[children.length - 1]\n const lastRect = lastChild.getBoundingClientRect()\n indicatorPosition = isHorizontal ? lastRect.right : lastRect.bottom\n }\n\n const indicator: DropIndicator = isHorizontal\n ? {\n x: indicatorPosition,\n y: containerRect.top + 4,\n width: 2,\n height: containerRect.height - 8,\n }\n : {\n x: containerRect.left + 4,\n y: indicatorPosition,\n width: containerRect.width - 8,\n height: 2,\n }\n\n return { insertBefore, indicator }\n}\n\n// Accesses React fiber internals to find the component stack. This is an undocumented\n// API that could change between React versions, but is a common pattern for dev tools.\n// Returns an empty array gracefully if React internals are unavailable.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction getFiberForElement(element: HTMLElement): any | null {\n if (typeof window !== 'undefined') {\n const devtools = window.__DIRECT_EDIT_DEVTOOLS__\n if (devtools?.getFiberForElement) {\n const fiber = devtools.getFiberForElement(element)\n if (fiber) return fiber as any\n }\n }\n\n const fiberKey = Object.keys(element).find(\n (key) => key.startsWith('__reactFiber$') || key.startsWith('__reactInternalInstance$')\n )\n\n if (!fiberKey) return null\n return (element as any)[fiberKey] || null\n}\n\ntype ParsedStackFrame = {\n functionName?: string\n fileName?: string\n lineNumber?: number\n columnNumber?: number\n source?: string\n isServer?: boolean\n}\n\nconst STACK_SOURCE_FILE_EXTENSION_REGEX = /\\.(jsx|tsx|ts|js)$/\nconst STACK_BUNDLED_FILE_PATTERN_REGEX =\n /(\\.min|bundle|chunk|vendor|vendors|runtime|polyfill|polyfills)\\.(js|mjs|cjs)$|(chunk|bundle|vendor|vendors|runtime|polyfill|polyfills|framework|app|main|index)[-_.][A-Za-z0-9_-]{4,}\\.(js|mjs|cjs)$|[\\da-f]{8,}\\.(js|mjs|cjs)$|[-_.][\\da-f]{20,}\\.(js|mjs|cjs)$|\\/dist\\/|\\/build\\/|\\/.next\\/|\\/out\\/|\\/node_modules\\/|\\.webpack\\.|\\.vite\\.|\\.turbopack\\./i\nconst FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\\S+:\\d+/\nconst SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\\[native code\\])?$/\nconst SERVER_FRAME_MARKER = '(at Server)'\n\nconst STACK_INTERNAL_SCHEME_PREFIXES = [\n 'rsc://',\n 'about://React/',\n 'React/Server/',\n 'file:///',\n 'webpack://',\n 'webpack-internal://',\n 'node:',\n 'turbopack://',\n '/app-pages-browser/',\n] as const\n\nfunction formatOwnerDebugStack(stack: string): string {\n if (!stack) return ''\n\n const lines = stack.split('\\n')\n const filtered: string[] = []\n\n for (const line of lines) {\n const trimmed = line.trim()\n if (!trimmed) continue\n if (trimmed === 'Error: react-stack-top-frame') continue\n if (\n trimmed.includes('react_stack_bottom_frame') ||\n trimmed.includes('react-stack-bottom-frame')\n ) {\n continue\n }\n filtered.push(line)\n }\n\n if (filtered.length > 0 && filtered[0].includes('fakeJSXCallSite')) {\n filtered.shift()\n }\n\n return filtered.join('\\n')\n}\n\nfunction extractStackLocation(urlLike: string): [string, number | undefined, number | undefined] {\n if (!urlLike.includes(':')) return [urlLike, undefined, undefined]\n\n const isWrappedLocation = urlLike.startsWith('(') && /:\\d+\\)$/.test(urlLike)\n const sanitizedResult = isWrappedLocation ? urlLike.slice(1, -1) : urlLike\n const parts = /(.+?)(?::(\\d+))?(?::(\\d+))?$/.exec(sanitizedResult)\n if (!parts) return [sanitizedResult, undefined, undefined]\n\n return [\n parts[1],\n parts[2] !== undefined ? Number(parts[2]) : undefined,\n parts[3] !== undefined ? Number(parts[3]) : undefined,\n ]\n}\n\nfunction parseV8StackLine(line: string): ParsedStackFrame | null {\n let currentLine = line\n if (currentLine.includes('(eval ')) {\n currentLine = currentLine\n .replace(/eval code/g, 'eval')\n .replace(/(\\(eval at [^()]*)|(,.*$)/g, '')\n }\n\n let sanitizedLine = currentLine\n .replace(/^\\s+/, '')\n .replace(/\\(eval code/g, '(')\n .replace(/^.*?\\s+/, '')\n const locationMatch = sanitizedLine.match(/ (\\(.+\\)$)/)\n if (locationMatch) {\n sanitizedLine = sanitizedLine.replace(locationMatch[0], '')\n }\n\n const [fileName, lineNumber, columnNumber] = extractStackLocation(\n locationMatch ? locationMatch[1] : sanitizedLine\n )\n const functionName = locationMatch && sanitizedLine ? sanitizedLine : undefined\n if (fileName === 'eval' || fileName === '<anonymous>') {\n return {\n functionName,\n }\n }\n\n return {\n functionName,\n fileName,\n lineNumber,\n columnNumber,\n source: currentLine,\n isServer: currentLine.includes(SERVER_FRAME_MARKER) || fileName.startsWith('rsc://'),\n }\n}\n\nfunction parseFFOrSafariStackLine(line: string): ParsedStackFrame | null {\n let currentLine = line\n if (currentLine.includes(' > eval')) {\n currentLine = currentLine.replace(\n / line (\\d+)(?: > eval line \\d+)* > eval:\\d+:\\d+/g,\n ':$1'\n )\n }\n\n const trimmed = currentLine.trim()\n if (!trimmed || SAFARI_NATIVE_CODE_REGEXP.test(trimmed)) {\n return null\n }\n\n if (!trimmed.includes('@') && !trimmed.includes(':')) {\n return {\n functionName: trimmed,\n source: currentLine,\n isServer: trimmed.includes(SERVER_FRAME_MARKER),\n }\n }\n\n const atIndex = trimmed.lastIndexOf('@')\n if (atIndex === -1) {\n return null\n }\n const maybeFunctionName = trimmed.slice(0, atIndex)\n const location = trimmed.slice(atIndex + 1)\n const [fileName, lineNumber, columnNumber] = extractStackLocation(location)\n\n return {\n functionName: maybeFunctionName || undefined,\n fileName,\n lineNumber,\n columnNumber,\n source: currentLine,\n isServer: currentLine.includes(SERVER_FRAME_MARKER) || fileName.startsWith('rsc://'),\n }\n}\n\nfunction parseInStackLine(line: string): ParsedStackFrame | null {\n const functionName = line\n .replace(/^\\s*in\\s+/, '')\n .replace(/\\s*\\(at .*\\)$/, '')\n .trim()\n if (!functionName) return null\n\n return {\n functionName,\n source: line,\n isServer: line.includes(SERVER_FRAME_MARKER),\n }\n}\n\nfunction parseDebugStack(stack: string): ParsedStackFrame[] {\n const frames: ParsedStackFrame[] = []\n for (const rawLine of stack.split('\\n')) {\n if (FIREFOX_SAFARI_STACK_REGEXP.test(rawLine)) {\n const parsed = parseFFOrSafariStackLine(rawLine)\n if (parsed) frames.push(parsed)\n continue\n }\n\n if (/^\\s*at\\s+/.test(rawLine)) {\n const parsed = parseV8StackLine(rawLine)\n if (parsed) frames.push(parsed)\n continue\n }\n\n if (/^\\s*in\\s+/.test(rawLine)) {\n const parsed = parseInStackLine(rawLine)\n if (parsed) frames.push(parsed)\n }\n }\n\n return frames\n}\n\nfunction normalizeStackFileName(fileName: string): string {\n if (!fileName) return ''\n\n let normalized = fileName\n const isHttpUrl = normalized.startsWith('http://') || normalized.startsWith('https://')\n if (isHttpUrl) {\n try {\n normalized = new URL(normalized).pathname\n } catch {\n // Fall through and use the original string.\n }\n }\n\n let didStripPrefix = true\n while (didStripPrefix) {\n didStripPrefix = false\n for (const prefix of STACK_INTERNAL_SCHEME_PREFIXES) {\n if (normalized.startsWith(prefix)) {\n normalized = normalized.slice(prefix.length)\n if (prefix === 'file:///') {\n normalized = `/${normalized.replace(/^\\/+/, '')}`\n }\n didStripPrefix = true\n break\n }\n }\n }\n\n normalized = normalized\n .replace(/^\\/\\(app-pages-browser\\)\\//, '/')\n .replace(/^\\/\\.\\//, '/')\n .replace(/^\\.\\//, '')\n\n const queryIndex = normalized.indexOf('?')\n if (queryIndex !== -1) {\n normalized = normalized.slice(0, queryIndex)\n }\n\n return normalized\n}\n\nfunction isSourceStackFile(fileName: string): boolean {\n const normalizedFileName = normalizeStackFileName(fileName)\n if (!normalizedFileName) return false\n if (!STACK_SOURCE_FILE_EXTENSION_REGEX.test(normalizedFileName)) return false\n return !STACK_BUNDLED_FILE_PATTERN_REGEX.test(normalizedFileName)\n}\n\ntype EnrichedServerFrame = {\n fileName: string\n lineNumber?: number\n columnNumber?: number\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction buildFunctionNameToRscFramesMap(fiber: any): Map<string, EnrichedServerFrame[]> {\n const functionNameToRscFrames = new Map<string, EnrichedServerFrame[]>()\n const visited = new Set<any>()\n let current = fiber\n\n while (current && !visited.has(current)) {\n visited.add(current)\n const rawStack = current?._debugStack?.stack\n const stack = typeof rawStack === 'string' ? formatOwnerDebugStack(rawStack) : ''\n if (stack) {\n const frames = parseDebugStack(stack)\n for (const frame of frames) {\n if (!frame.functionName || !frame.fileName) continue\n if (!frame.fileName.startsWith('rsc://')) continue\n\n const normalized = normalizeStackFileName(frame.fileName)\n if (!normalized) continue\n\n const existing = functionNameToRscFrames.get(frame.functionName) ?? []\n const duplicate = existing.some(\n (candidate) =>\n candidate.fileName === normalized &&\n candidate.lineNumber === frame.lineNumber &&\n candidate.columnNumber === frame.columnNumber\n )\n if (!duplicate) {\n existing.push({\n fileName: normalized,\n lineNumber: frame.lineNumber,\n columnNumber: frame.columnNumber,\n })\n functionNameToRscFrames.set(frame.functionName, existing)\n }\n }\n }\n\n current = current._debugOwner ?? current.return ?? null\n }\n\n return functionNameToRscFrames\n}\n\nfunction enrichServerFrame(\n frame: ParsedStackFrame,\n functionNameToRscFrames: Map<string, EnrichedServerFrame[]>,\n functionNameToUsageIndex: Map<string, number>,\n): ParsedStackFrame {\n if (!frame.functionName) return frame\n\n const available = functionNameToRscFrames.get(frame.functionName)\n if (!available) return frame\n\n const usageIndex = functionNameToUsageIndex.get(frame.functionName) ?? 0\n const resolved = available[usageIndex % available.length]\n functionNameToUsageIndex.set(frame.functionName, usageIndex + 1)\n\n return {\n ...frame,\n fileName: resolved.fileName,\n lineNumber: resolved.lineNumber,\n columnNumber: resolved.columnNumber,\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction getSourceFromDebugStack(fiber: any):\n | {\n fileName?: string\n lineNumber?: number\n columnNumber?: number\n }\n | null {\n const rawStack = fiber?._debugStack?.stack\n if (typeof rawStack !== 'string' || rawStack.length === 0) {\n return null\n }\n\n const formattedStack = formatOwnerDebugStack(rawStack)\n if (!formattedStack) return null\n\n const stackFrames = parseDebugStack(formattedStack)\n const functionNameToRscFrames = buildFunctionNameToRscFramesMap(fiber)\n const functionNameToUsageIndex = new Map<string, number>()\n\n for (const frame of stackFrames) {\n const maybeEnriched = frame.isServer\n ? enrichServerFrame(frame, functionNameToRscFrames, functionNameToUsageIndex)\n : frame\n if (!maybeEnriched.fileName) continue\n\n const normalizedFileName = normalizeStackFileName(maybeEnriched.fileName)\n if (!normalizedFileName) continue\n\n if (isSourceStackFile(normalizedFileName)) {\n return {\n fileName: normalizedFileName,\n lineNumber: maybeEnriched.lineNumber,\n columnNumber: maybeEnriched.columnNumber,\n }\n }\n }\n\n return null\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction getSourceFromFiber(fiber: any):\n | {\n fileName?: string\n lineNumber?: number\n columnNumber?: number\n }\n | null {\n const debugSource = fiber?._debugSource\n if (debugSource?.fileName) return debugSource\n\n const owner = fiber?._debugOwner\n const ownerPending = owner?.pendingProps?.__source\n if (ownerPending?.fileName) return ownerPending\n\n const ownerMemo = owner?.memoizedProps?.__source\n if (ownerMemo?.fileName) return ownerMemo\n\n const pending = fiber?.pendingProps?.__source\n if (pending?.fileName) return pending\n\n const memo = fiber?.memoizedProps?.__source\n if (memo?.fileName) return memo\n\n const fromDebugStack = getSourceFromDebugStack(fiber)\n if (fromDebugStack?.fileName) return fromDebugStack\n\n return null\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction buildFrame(fiber: any): ReactComponentFrame | null {\n const type = fiber?.type\n if (typeof type !== 'function' && typeof type !== 'object') return null\n\n const name = type?.displayName || type?.name || null\n if (!name || name === 'Fragment') return null\n\n const frame: ReactComponentFrame = { name }\n const source = getSourceFromFiber(fiber)\n if (source?.fileName) {\n frame.file = source.fileName\n if (typeof source.lineNumber === 'number') {\n frame.line = source.lineNumber\n }\n if (typeof source.columnNumber === 'number') {\n frame.column = source.columnNumber\n }\n }\n\n return frame\n}\n\nfunction shouldIncludeFrame(\n frame: ReactComponentFrame,\n lastFrame: ReactComponentFrame | null\n): boolean {\n if (!lastFrame) return true\n if (frame.name !== lastFrame.name) return true\n if (!lastFrame.file && frame.file) return true\n if (lastFrame.file && frame.file && lastFrame.line == null && frame.line != null) return true\n if (\n lastFrame.file &&\n frame.file &&\n lastFrame.line != null &&\n frame.line != null &&\n lastFrame.column == null &&\n frame.column != null\n ) {\n return true\n }\n return false\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction getOwnerStack(fiber: any): ReactComponentFrame[] {\n const frames: ReactComponentFrame[] = []\n let current = fiber\n let lastFrame: ReactComponentFrame | null = null\n\n while (current) {\n const frame = buildFrame(current)\n if (frame && shouldIncludeFrame(frame, lastFrame)) {\n frames.push(frame)\n lastFrame = frame\n }\n current = current._debugOwner\n }\n\n return frames\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction getRenderStack(fiber: any): ReactComponentFrame[] {\n const frames: ReactComponentFrame[] = []\n let current = fiber\n let lastFrame: ReactComponentFrame | null = null\n\n while (current) {\n const frame = buildFrame(current)\n if (frame && shouldIncludeFrame(frame, lastFrame)) {\n frames.push(frame)\n lastFrame = frame\n }\n current = current.return\n }\n\n return frames\n}\n\nfunction getReactComponentStack(element: HTMLElement): ReactComponentFrame[] {\n const fiber = getFiberForElement(element)\n if (!fiber) return []\n\n const ownerStack = getOwnerStack(fiber)\n if (ownerStack.length > 0) {\n return ownerStack\n }\n\n return getRenderStack(fiber)\n}\n\nexport function getElementDisplayName(element: HTMLElement): string {\n return element.tagName.toLowerCase()\n}\n\nconst STABLE_ATTRIBUTES = ['data-testid', 'data-qa', 'data-cy', 'aria-label', 'role'] as const\nconst MAX_SELECTOR_DEPTH = 24\nconst CONTEXT_ALLOWED_ATTRIBUTES = new Set([\n 'id',\n 'class',\n 'href',\n 'src',\n 'alt',\n 'aria-label',\n 'role',\n 'data-testid',\n 'data-qa',\n 'data-cy',\n 'data-direct-edit-target',\n])\n\nfunction escapeCssIdentifier(value: string): string {\n if (typeof CSS !== 'undefined' && typeof CSS.escape === 'function') {\n return CSS.escape(value)\n }\n return value.replace(/[^a-zA-Z0-9_-]/g, (char) => `\\\\${char}`)\n}\n\nfunction escapeAttributeValue(value: string): string {\n return value.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')\n}\n\nfunction isUniqueSelector(selector: string): boolean {\n if (typeof document === 'undefined') return false\n try {\n return document.querySelectorAll(selector).length === 1\n } catch {\n return false\n }\n}\n\nfunction getUniqueIdSelector(element: HTMLElement): string | null {\n if (!element.id) return null\n const selector = `#${escapeCssIdentifier(element.id)}`\n return isUniqueSelector(selector) ? selector : null\n}\n\nfunction getStableAttributeSelector(element: HTMLElement): string | null {\n const tagName = element.tagName.toLowerCase()\n for (const attr of STABLE_ATTRIBUTES) {\n const value = element.getAttribute(attr)\n if (!value) continue\n const selector = `${tagName}[${attr}=\"${escapeAttributeValue(value)}\"]`\n if (isUniqueSelector(selector)) {\n return selector\n }\n }\n return null\n}\n\nfunction getNthOfTypeSelector(element: HTMLElement): string {\n const tagName = element.tagName.toLowerCase()\n const classes = Array.from(element.classList)\n .filter((className) => className && !className.startsWith('direct-edit'))\n .slice(0, 2)\n const classSelector = classes.map((className) => `.${escapeCssIdentifier(className)}`).join('')\n\n let nthOfType = ''\n const parent = element.parentElement\n if (parent) {\n const siblings = Array.from(parent.children).filter(\n (child) => (child as HTMLElement).tagName.toLowerCase() === tagName\n )\n if (siblings.length > 1) {\n const index = siblings.indexOf(element) + 1\n nthOfType = `:nth-of-type(${index})`\n }\n }\n\n return `${tagName}${classSelector}${nthOfType}`\n}\n\nfunction buildDomSelector(element: HTMLElement): string {\n if (typeof document === 'undefined') {\n return element.tagName.toLowerCase()\n }\n if (element.closest('[data-direct-edit]')) return ''\n\n const uniqueId = getUniqueIdSelector(element)\n if (uniqueId) return uniqueId\n\n const stableAttribute = getStableAttributeSelector(element)\n if (stableAttribute) return stableAttribute\n\n const segments: string[] = []\n let current: HTMLElement | null = element\n let depth = 0\n\n while (current && current !== document.body && depth < MAX_SELECTOR_DEPTH) {\n if (current.hasAttribute('data-direct-edit')) {\n current = current.parentElement\n continue\n }\n\n if (depth > 0) {\n const parentId = getUniqueIdSelector(current)\n if (parentId) {\n segments.unshift(parentId)\n break\n }\n const parentStableAttr = getStableAttributeSelector(current)\n if (parentStableAttr) {\n segments.unshift(parentStableAttr)\n break\n }\n }\n\n segments.unshift(getNthOfTypeSelector(current))\n current = current.parentElement\n depth += 1\n }\n\n return segments.join(' > ')\n}\n\nfunction stripDirectEditNodes(root: Element) {\n const nodes = root.querySelectorAll('[data-direct-edit]')\n nodes.forEach((node) => node.remove())\n}\n\nfunction sanitizeContextNode(root: HTMLElement) {\n const nodes: HTMLElement[] = [root, ...Array.from(root.querySelectorAll<HTMLElement>('*'))]\n for (const node of nodes) {\n for (const attr of Array.from(node.attributes)) {\n if (!CONTEXT_ALLOWED_ATTRIBUTES.has(attr.name)) {\n node.removeAttribute(attr.name)\n }\n }\n }\n}\n\nfunction buildTargetHtml(element: HTMLElement): string {\n const tagName = element.tagName.toLowerCase()\n const attrs: string[] = []\n const allowList = [\n 'id',\n 'class',\n 'href',\n 'src',\n 'alt',\n 'aria-label',\n 'role',\n 'data-testid',\n ]\n const maxAttrLength = 48\n\n for (const attr of allowList) {\n const value = element.getAttribute(attr)\n if (!value) continue\n const trimmed = value.length > maxAttrLength ? `${value.slice(0, maxAttrLength - 3)}...` : value\n attrs.push(`${attr}=\"${escapeAttributeValue(trimmed)}\"`)\n }\n\n const text = getTextPreview(element)\n const attrString = attrs.length > 0 ? ` ${attrs.join(' ')}` : ''\n\n if (text) {\n return `<${tagName}${attrString}>\\n ${escapeHtml(text)}\\n</${tagName}>`\n }\n\n return `<${tagName}${attrString}></${tagName}>`\n}\n\nfunction formatSourcePath(file: string): string {\n const normalized = file\n .replace(/\\\\/g, '/')\n .replace(/^webpack:\\/\\/\\//, '')\n .replace(/^webpack:\\/\\//, '')\n .replace(/^webpack-internal:\\/\\//, '')\n .replace(/^rsc:\\/\\/React\\/Server\\//, '')\n .replace(/^about:\\/\\/React\\//, '')\n .replace(/^file:\\/\\//, '')\n .replace(/^\\/\\(app-pages-browser\\)\\//, '/')\n .replace(/^\\/app-pages-browser\\//, '/')\n .replace(/^_N_E\\//, '')\n .replace(/^\\.\\/+/, '')\n const packagesIndex = normalized.indexOf('/packages/')\n if (packagesIndex !== -1) {\n return `/[project]${normalized.slice(packagesIndex)}`\n }\n const appIndex = normalized.indexOf('/app/')\n if (appIndex !== -1) {\n return `/[project]${normalized.slice(appIndex)}`\n }\n const srcIndex = normalized.indexOf('/src/')\n if (srcIndex !== -1) {\n return `/[project]${normalized.slice(srcIndex)}`\n }\n return normalized\n}\n\nfunction formatSourceLocation(file: string, line?: number, column?: number): string {\n const formatted = formatSourcePath(file)\n if (typeof line === 'number') {\n const columnSuffix = typeof column === 'number' ? `:${column}` : ''\n return `${formatted}:${line}${columnSuffix}`\n }\n return formatted\n}\n\nfunction isUserlandSource(file: string): boolean {\n const normalized = file.replace(/\\\\/g, '/')\n if (\n normalized.includes('node_modules') ||\n normalized.includes('next/dist') ||\n normalized.includes('react') ||\n normalized.includes('react-dom') ||\n normalized.includes('direct-edit')\n ) {\n return false\n }\n return (\n normalized.includes('/app/') ||\n normalized.includes('/src/') ||\n normalized.includes('/packages/') ||\n normalized.startsWith('./')\n )\n}\n\nfunction getPrimaryFrame(locator: ElementLocator): ReactComponentFrame | null {\n for (const frame of locator.reactStack) {\n if (frame.file && isUserlandSource(frame.file)) {\n return frame\n }\n }\n for (const frame of locator.reactStack) {\n if (frame.file) {\n return frame\n }\n }\n return locator.reactStack[0] ?? null\n}\n\nfunction escapeHtml(value: string): string {\n return value\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''')\n}\n\nfunction buildDomContextHtml(\n element: HTMLElement,\n options?: { siblingCount?: number }\n): string {\n const parent = element.parentElement\n if (!parent) {\n const clone = element.cloneNode(true) as HTMLElement\n clone.setAttribute('data-direct-edit-target', 'true')\n stripDirectEditNodes(clone)\n sanitizeContextNode(clone)\n return clone.outerHTML\n }\n\n const parentClone = parent.cloneNode(false) as HTMLElement\n const siblings = Array.from(parent.children) as HTMLElement[]\n const selectedIndex = siblings.indexOf(element)\n const siblingCount = options?.siblingCount ?? 1\n let slice = siblings\n\n if (siblingCount >= 0 && selectedIndex >= 0) {\n const start = Math.max(0, selectedIndex - siblingCount)\n const end = Math.min(siblings.length, selectedIndex + siblingCount + 1)\n slice = siblings.slice(start, end)\n }\n\n for (const sibling of slice) {\n if (sibling.closest('[data-direct-edit]')) continue\n const clone = sibling.cloneNode(true) as HTMLElement\n if (sibling === element) {\n clone.setAttribute('data-direct-edit-target', 'true')\n }\n stripDirectEditNodes(clone)\n sanitizeContextNode(clone)\n parentClone.appendChild(clone)\n }\n\n sanitizeContextNode(parentClone)\n return parentClone.outerHTML\n}\n\nfunction normalizePreviewWhitespace(value: string): string {\n return value.replace(/\\s+/g, ' ').trim()\n}\n\nfunction isWordLikeChar(char: string): boolean {\n return /[A-Za-z0-9]/.test(char)\n}\n\nfunction getFallbackTextPreview(element: HTMLElement): string {\n const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT)\n const tokens: string[] = []\n let previousRaw = ''\n let previousParent: HTMLElement | null = null\n\n for (let node = walker.nextNode(); node; node = walker.nextNode()) {\n const textNode = node as Text\n const raw = textNode.textContent ?? ''\n const normalized = normalizePreviewWhitespace(raw)\n if (!normalized) continue\n\n if (tokens.length > 0) {\n const hasExplicitWhitespace = /^\\s/.test(raw) || /\\s$/.test(previousRaw)\n const prevLast = previousRaw.slice(-1)\n const nextFirst = normalized[0]\n const shouldInsertHeuristicSpace =\n previousParent !== textNode.parentElement &&\n isWordLikeChar(prevLast) &&\n isWordLikeChar(nextFirst)\n\n if (hasExplicitWhitespace || shouldInsertHeuristicSpace) {\n tokens.push(' ')\n }\n }\n\n tokens.push(normalized)\n previousRaw = raw\n previousParent = textNode.parentElement\n }\n\n return tokens.join('')\n}\n\nfunction getTextPreview(element: HTMLElement): string {\n const innerTextCandidate = normalizePreviewWhitespace(element.innerText ?? '')\n const text = innerTextCandidate || getFallbackTextPreview(element)\n if (text.length <= 120) {\n return text\n }\n return `${text.slice(0, 117)}...`\n}\n\nfunction parseDomSource(element: HTMLElement): DomSourceLocation | null {\n const value = element.getAttribute('data-direct-edit-source')\n if (!value) return null\n\n let file = value\n let line: number | undefined\n let column: number | undefined\n\n const lastColon = value.lastIndexOf(':')\n if (lastColon !== -1) {\n const maybeColumn = Number(value.slice(lastColon + 1))\n if (!Number.isNaN(maybeColumn)) {\n column = maybeColumn\n file = value.slice(0, lastColon)\n\n const prevColon = file.lastIndexOf(':')\n if (prevColon !== -1) {\n const maybeLine = Number(file.slice(prevColon + 1))\n if (!Number.isNaN(maybeLine)) {\n line = maybeLine\n file = file.slice(0, prevColon)\n }\n }\n }\n }\n\n return { file, line, column }\n}\n\nexport function getElementLocator(element: HTMLElement): ElementLocator {\n const elementInfo = getElementInfo(element)\n let domSource = parseDomSource(element)\n\n // Fallback: get source from the element's own React fiber when\n // the Vite plugin attribute is not present\n if (!domSource) {\n const seenFibers = new Set<any>()\n let fiber = getFiberForElement(element)\n while (fiber && !seenFibers.has(fiber)) {\n seenFibers.add(fiber)\n const fiberSource = getSourceFromFiber(fiber)\n if (fiberSource?.fileName) {\n domSource = {\n file: fiberSource.fileName,\n line: fiberSource.lineNumber,\n column: fiberSource.columnNumber,\n }\n break\n }\n fiber = fiber._debugOwner ?? fiber.return ?? null\n }\n }\n\n return {\n reactStack: getReactComponentStack(element),\n domSelector: buildDomSelector(element),\n domContextHtml: buildDomContextHtml(element),\n targetHtml: buildTargetHtml(element),\n textPreview: getTextPreview(element),\n tagName: elementInfo.tagName,\n id: elementInfo.id,\n classList: elementInfo.classList,\n domSource: domSource ?? undefined,\n }\n}\n\ninterface ExportChange {\n property: string\n value: string\n tailwind: string\n}\n\nfunction getLocatorHeader(locator: ElementLocator): { componentLabel: string; formattedSource: string | null } {\n const primaryFrame = getPrimaryFrame(locator)\n const componentLabel = primaryFrame?.name ? primaryFrame.name : locator.tagName\n const formattedSource = locator.domSource?.file\n ? formatSourceLocation(locator.domSource.file, locator.domSource.line, locator.domSource.column)\n : primaryFrame?.file\n ? formatSourceLocation(primaryFrame.file, primaryFrame.line, primaryFrame.column)\n : null\n return { componentLabel, formattedSource }\n}\n\nfunction buildLocatorContextLines(locator: ElementLocator): string[] {\n const lines: string[] = []\n const { componentLabel, formattedSource } = getLocatorHeader(locator)\n const target = (locator.targetHtml || locator.domContextHtml || '').trim()\n const context = locator.domContextHtml?.trim() || ''\n const selector = locator.domSelector?.trim()\n const text = locator.textPreview?.trim()\n\n lines.push(`@<${componentLabel}>`)\n lines.push('')\n if (target) {\n lines.push('target:')\n lines.push(target)\n }\n if (context && context !== target) {\n lines.push('context:')\n lines.push(context)\n }\n lines.push(`in ${formattedSource ?? '(file not available)'}`)\n if (selector) {\n lines.push(`selector: ${selector}`)\n }\n if (text) {\n lines.push(`text: ${text}`)\n }\n\n return lines\n}\n\nexport function buildElementContext(locator: ElementLocator): string {\n return buildLocatorContextLines(locator).join('\\n')\n}\n\nconst spacingGroups = [\n { top: 'padding-top', right: 'padding-right', bottom: 'padding-bottom', left: 'padding-left', all: 'padding', inline: 'padding-inline', block: 'padding-block' },\n { top: 'margin-top', right: 'margin-right', bottom: 'margin-bottom', left: 'margin-left', all: 'margin', inline: 'margin-inline', block: 'margin-block' },\n] as const\n\nexport function collapseSpacingShorthands(styles: Record<string, string>): Record<string, string> {\n const result = { ...styles }\n\n for (const group of spacingGroups) {\n const hasTop = group.top in result\n const hasRight = group.right in result\n const hasBottom = group.bottom in result\n const hasLeft = group.left in result\n const hasAllSides = hasTop && hasRight && hasBottom && hasLeft\n\n if (hasAllSides) {\n delete result[group.all]\n delete result[group.inline]\n delete result[group.block]\n }\n\n const top = result[group.top]\n const right = result[group.right]\n const bottom = result[group.bottom]\n const left = result[group.left]\n\n const horizontalMatch = hasLeft && hasRight && left === right\n const verticalMatch = hasTop && hasBottom && top === bottom\n\n if (horizontalMatch && verticalMatch) {\n delete result[group.top]\n delete result[group.right]\n delete result[group.bottom]\n delete result[group.left]\n if (top === left) {\n result[group.all] = top\n } else {\n result[group.inline] = left\n result[group.block] = top\n }\n } else if (horizontalMatch) {\n // Only horizontal pair matches\n delete result[group.left]\n delete result[group.right]\n result[group.inline] = left\n } else if (verticalMatch) {\n // Only vertical pair matches\n delete result[group.top]\n delete result[group.bottom]\n result[group.block] = top\n }\n }\n\n return result\n}\n\nfunction collapseFourSideShorthand(\n result: Record<string, string>,\n sides: { top: string; right: string; bottom: string; left: string; all: string }\n): void {\n if (!(sides.top in result && sides.right in result && sides.bottom in result && sides.left in result)) return\n\n // Side-specific values are the source of truth when all four are present.\n delete result[sides.all]\n\n const top = result[sides.top]\n const right = result[sides.right]\n const bottom = result[sides.bottom]\n const left = result[sides.left]\n const allEqual = top === right && top === bottom && top === left\n if (!allEqual) return\n\n delete result[sides.top]\n delete result[sides.right]\n delete result[sides.bottom]\n delete result[sides.left]\n result[sides.all] = top\n}\n\nexport function collapseExportShorthands(styles: Record<string, string>): Record<string, string> {\n const result = collapseSpacingShorthands(styles)\n\n collapseFourSideShorthand(result, {\n top: 'border-top-style',\n right: 'border-right-style',\n bottom: 'border-bottom-style',\n left: 'border-left-style',\n all: 'border-style',\n })\n\n collapseFourSideShorthand(result, {\n top: 'border-top-width',\n right: 'border-right-width',\n bottom: 'border-bottom-width',\n left: 'border-left-width',\n all: 'border-width',\n })\n\n collapseFourSideShorthand(result, {\n top: 'border-top-left-radius',\n right: 'border-top-right-radius',\n bottom: 'border-bottom-right-radius',\n left: 'border-bottom-left-radius',\n all: 'border-radius',\n })\n\n return result\n}\n\nexport function buildEditExport(\n locator: ElementLocator,\n pendingStyles: Record<string, string>,\n textEdit?: { originalText: string; newText: string } | null\n): string\nexport function buildEditExport(\n element: HTMLElement | null,\n elementInfo: ElementInfo,\n computedSpacing: SpacingProperties | null,\n computedBorderRadius: BorderRadiusProperties | null,\n computedFlex: FlexProperties | null,\n computedSizing: SizingProperties | null,\n pendingStyles: Record<string, string>\n): string\nexport function buildEditExport(\n arg1: ElementLocator | HTMLElement | null,\n arg2: ElementInfo | Record<string, string>,\n arg3?: SpacingProperties | null | { originalText: string; newText: string },\n arg4?: BorderRadiusProperties | null,\n arg5?: FlexProperties | null,\n arg6?: SizingProperties | null,\n arg7?: Record<string, string>\n): string {\n const isLocator = Boolean(arg1 && typeof arg1 === 'object' && 'domSelector' in arg1)\n if (!isLocator) {\n void arg4\n void arg5\n void arg6\n }\n const pendingStyles = (isLocator ? (arg2 as Record<string, string>) : arg7) || {}\n const textEdit = isLocator && arg3 && typeof arg3 === 'object' && 'originalText' in arg3\n ? (arg3 as { originalText: string; newText: string })\n : null\n let locator: ElementLocator\n\n if (isLocator) {\n locator = arg1 as ElementLocator\n } else {\n const element = arg1 as HTMLElement | null\n const elementInfo = arg2 as ElementInfo\n locator = element\n ? getElementLocator(element)\n : {\n reactStack: [],\n domSelector: elementInfo.id ? `#${elementInfo.id}` : elementInfo.tagName,\n domContextHtml: `<${elementInfo.tagName}${elementInfo.id ? ` id=\"${elementInfo.id}\"` : ''} data-direct-edit-target=\"true\"></${elementInfo.tagName}>`,\n targetHtml: `<${elementInfo.tagName}${elementInfo.id ? ` id=\"${elementInfo.id}\"` : ''}></${elementInfo.tagName}>`,\n textPreview: '',\n tagName: elementInfo.tagName,\n id: elementInfo.id,\n classList: elementInfo.classList,\n }\n }\n\n const changes: ExportChange[] = []\n\n const collapsedStyles = collapseExportShorthands(pendingStyles)\n for (const [property, value] of Object.entries(collapsedStyles)) {\n const tailwindClass = stylesToTailwind({ [property]: value })\n changes.push({\n property,\n value,\n tailwind: tailwindClass,\n })\n }\n\n const lines = buildLocatorContextLines(locator)\n lines.push('')\n if (changes.length > 0) {\n lines.push('edits:')\n for (const change of changes) {\n const tailwind = change.tailwind ? ` (${change.tailwind})` : ''\n lines.push(`${change.property}: ${change.value}${tailwind}`)\n }\n }\n\n if (textEdit) {\n lines.push('text content changed:')\n lines.push(`from: \"${textEdit.originalText}\"`)\n lines.push(`to: \"${textEdit.newText}\"`)\n }\n\n return lines.join('\\n')\n}\n\nexport function buildCommentExport(\n locator: ElementLocator,\n commentText: string,\n replies?: Array<{ text: string; createdAt: number }>\n): string {\n const lines = buildLocatorContextLines(locator)\n lines.push('')\n lines.push(`comment: ${commentText}`)\n if (replies && replies.length > 0) {\n for (const reply of replies) {\n lines.push(`reply: ${reply.text}`)\n }\n }\n\n return lines.join('\\n')\n}\n\nfunction formatPosition(\n siblingBefore: string | null,\n siblingAfter: string | null\n): string {\n if (siblingBefore && siblingAfter) return `after <${siblingBefore}>`\n if (siblingBefore && !siblingAfter) return `after <${siblingBefore}> (last)`\n if (!siblingBefore && siblingAfter) return `before <${siblingAfter}> (first)`\n return '(only child)'\n}\n\nfunction formatMoveSummary(move: NonNullable<SessionEdit['move']>): string {\n const fromPosition = formatPosition(move.fromSiblingBefore, move.fromSiblingAfter)\n const toPosition = formatPosition(move.toSiblingBefore, move.toSiblingAfter)\n if (move.fromParentName === move.toParentName) {\n return `in <${move.toParentName}>, from ${fromPosition} to ${toPosition}`\n }\n return `from <${move.fromParentName}> ${fromPosition} to <${move.toParentName}> ${toPosition}`\n}\n\nfunction formatMoveSelector(\n selector: string | null | undefined,\n fallback: '(none)' | '(unknown)'\n): string {\n const normalized = selector?.trim()\n return normalized ? normalized : fallback\n}\n\nfunction formatMoveSource(\n source: DomSourceLocation | null | undefined,\n fallback: '(none)' | '(unknown)'\n): string {\n if (!source?.file) return fallback\n return formatSourceLocation(source.file, source.line, source.column)\n}\n\nfunction buildMoveExportLines(move: NonNullable<SessionEdit['move']>): string[] {\n return [\n 'moved:',\n `summary: ${formatMoveSummary(move)}`,\n `from_parent_selector: ${formatMoveSelector(move.fromParentSelector, '(unknown)')}`,\n `from_before_selector: ${formatMoveSelector(move.fromSiblingBeforeSelector, '(none)')}`,\n `from_after_selector: ${formatMoveSelector(move.fromSiblingAfterSelector, '(none)')}`,\n `from_parent_source: ${formatMoveSource(move.fromParentSource, '(unknown)')}`,\n `from_before_source: ${formatMoveSource(move.fromSiblingBeforeSource, '(none)')}`,\n `from_after_source: ${formatMoveSource(move.fromSiblingAfterSource, '(none)')}`,\n `to_parent_selector: ${formatMoveSelector(move.toParentSelector, '(unknown)')}`,\n `to_before_selector: ${formatMoveSelector(move.toSiblingBeforeSelector, '(none)')}`,\n `to_after_selector: ${formatMoveSelector(move.toSiblingAfterSelector, '(none)')}`,\n `to_parent_source: ${formatMoveSource(move.toParentSource, '(unknown)')}`,\n `to_before_source: ${formatMoveSource(move.toSiblingBeforeSource, '(none)')}`,\n `to_after_source: ${formatMoveSource(move.toSiblingAfterSource, '(none)')}`,\n ]\n}\n\nexport function buildSessionExport(edits: SessionEdit[], comments: Comment[] = []): string {\n const blocks: string[] = []\n\n for (const edit of edits) {\n let block = buildEditExport(edit.locator, edit.pendingStyles, edit.textEdit)\n if (edit.move) {\n block += `\\n${buildMoveExportLines(edit.move).join('\\n')}`\n }\n blocks.push(block)\n }\n\n for (const comment of comments) {\n blocks.push(buildCommentExport(comment.locator, comment.text, comment.replies))\n }\n\n return blocks.join('\\n\\n---\\n\\n')\n}\n\nexport type {\n ElementInfo,\n CSSPropertyValue,\n SpacingProperties,\n BorderRadiusProperties,\n BorderStyle,\n BorderProperties,\n FlexProperties,\n DirectEditState,\n SpacingPropertyKey,\n BorderRadiusPropertyKey,\n BorderPropertyKey,\n FlexPropertyKey,\n MeasurementLine,\n MeasurementState,\n ColorValue,\n ColorProperties,\n ColorPropertyKey,\n SizingProperties,\n SizingPropertyKey,\n SizingMode,\n SizingValue,\n TypographyProperties,\n TypographyPropertyKey,\n ReactComponentFrame,\n ElementLocator,\n DragState,\n DropTarget,\n DropIndicator,\n} from './types'\n","import type { CSSPropertyValue } from '../types'\n\nexport function parsePropertyValue(value: string): CSSPropertyValue {\n const raw = value.trim()\n const match = raw.match(/^(-?\\d*\\.?\\d+)(px|rem|em|%)?$/)\n\n if (match) {\n return {\n numericValue: parseFloat(match[1]),\n unit: (match[2] as CSSPropertyValue['unit']) || 'px',\n raw,\n }\n }\n\n return {\n numericValue: 0,\n unit: 'px',\n raw,\n }\n}\n\nexport function formatPropertyValue(value: CSSPropertyValue): string {\n if (value.raw === 'auto' || value.raw === 'inherit' || value.raw === 'initial') {\n return value.raw\n }\n return `${value.numericValue}${value.unit}`\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,SAAS,mBAAmB,OAAiC;AAClE,QAAM,MAAM,MAAM,KAAK;AACvB,QAAM,QAAQ,IA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