{"version":3,"names":["Align","Auto","FlexStart","Center","FlexEnd","Stretch","Baseline","SpaceBetween","SpaceAround","SpaceEvenly","BoxSizing","BorderBox","ContentBox","Dimension","Width","Height","Direction","Inherit","LTR","RTL","Display","Flex","None","Contents","Edge","Left","Top","Right","Bottom","Start","End","Horizontal","Vertical","All","Errata","StretchFlexBasis","AbsolutePositionWithoutInsetsExcludesPadding","AbsolutePercentAgainstInnerSize","Classic","ExperimentalFeature","WebFlexBasis","FlexDirection","Column","ColumnReverse","Row","RowReverse","Gutter","Justify","MeasureMode","Undefined","Exactly","AtMost","Overflow","Visible","Hidden","Scroll","PositionType","Static","Relative","Absolute","Unit","Point","Percent","Wrap","NoWrap","WrapReverse","UNDEFINED_VALUE","unit","value","NaN","AUTO_VALUE","pointValue","v","percentValue","resolveValue","ownerSize","Number","isNaN","isDefined","n","sameFloat","a","b","defaultStyle","direction","flexDirection","justifyContent","alignItems","alignSelf","alignContent","flexWrap","overflow","display","positionType","flexGrow","flexShrink","flexBasis","margin","Array","fill","padding","border","position","gap","width","height","minWidth","minHeight","maxWidth","maxHeight","EDGE_LEFT","EDGE_TOP","EDGE_RIGHT","EDGE_BOTTOM","resolveEdge","edges","physicalEdge","allowAuto","resolveEdgeRaw","isMarginAuto","hasAnyAutoEdge","i","hasAnyDefinedEdge","resolveEdges4Into","out","eH","eV","eA","eS","eE","pctDenom","isRow","dir","isReverse","crossAxis","leadingEdge","trailingEdge","createConfig","config","pointScaleFactor","errata","useWebDefaults","free","isExperimentalFeatureEnabled","setExperimentalFeatureEnabled","setPointScaleFactor","f","getErrata","setErrata","e","setUseWebDefaults","Node","_flexBasis","_mainSize","_crossSize","_lineIndex","_hasAutoMargin","_hasPosition","_hasPadding","_hasBorder","_hasMargin","_lW","_lH","_lWM","_lHM","_lOW","_lOH","_lFW","_lFH","_lOutW","_lOutH","_hasL","_mW","_mH","_mWM","_mHM","_mOW","_mOH","_mOutW","_mOutH","_hasM","_fbBasis","_fbOwnerW","_fbOwnerH","_fbAvailMain","_fbAvailCross","_fbCrossMode","_fbGen","_hasMeasureGen","_hasMeasure","_cIn","_cOut","_cGen","_cN","_cWr","constructor","style","layout","left","top","parent","children","measureFunc","DEFAULT_CONFIG","isDirty_","isReferenceBaseline_","_yogaLiveNodes","insertChild","child","index","splice","markDirty","removeChild","idx","indexOf","getChild","getChildCount","length","getParent","freeRecursive","c","reset","isDirty","hasNewLayout","markLayoutSeen","setMeasureFunc","fn","unsetMeasureFunc","getComputedLeft","getComputedTop","getComputedWidth","getComputedHeight","getComputedRight","p","getComputedBottom","getComputedLayout","right","bottom","getComputedBorder","edge","getComputedPadding","getComputedMargin","setWidth","parseDimension","setWidthPercent","setWidthAuto","setHeight","setHeightPercent","setHeightAuto","setMinWidth","setMinWidthPercent","setMinHeight","setMinHeightPercent","setMaxWidth","setMaxWidthPercent","setMaxHeight","setMaxHeightPercent","setFlexDirection","setFlexGrow","setFlexShrink","setFlex","undefined","setFlexBasis","setFlexBasisPercent","setFlexBasisAuto","setFlexWrap","wrap","setAlignItems","setAlignSelf","setAlignContent","setJustifyContent","j","setDisplay","d","getDisplay","setPositionType","t","setPosition","setPositionPercent","setPositionAuto","setOverflow","o","setDirection","setBoxSizing","_","setMargin","val","setMarginPercent","setMarginAuto","setPadding","setPaddingPercent","setBorder","setGap","gutter","setGapPercent","getFlexDirection","getJustifyContent","getAlignItems","getAlignSelf","getAlignContent","getFlexGrow","getFlexShrink","getFlexBasis","getFlexWrap","getWidth","getHeight","getOverflow","getPositionType","getDirection","copyStyle","setDirtiedFunc","unsetDirtiedFunc","setIsReferenceBaseline","isReferenceBaseline","setAspectRatio","getAspectRatio","setAlwaysFormsContainingBlock","calculateLayout","ownerWidth","ownerHeight","_direction","_yogaNodesVisited","_yogaMeasureCalls","_yogaCacheHits","_generation","w","h","layoutNode","mar","posL","posT","roundLayout","CACHE_SLOTS","cacheWrite","node","aW","aH","wM","hM","oW","oH","fW","fH","wasDirty","Float64Array","cIn","commitCacheOutputs","performLayout","getYogaCounters","visited","measured","cacheHits","live","availableWidth","availableHeight","widthMode","heightMode","forceWidth","forceHeight","sameGen","pad","bor","paddingBorderWidth","paddingBorderHeight","styleWidth","styleHeight","wMode","hMode","boundAxis","innerW","Math","max","innerH","mainAxis","crossAx","isMainRow","mainSize","crossSize","mainMode","crossMode","mainPadBorder","crossPadBorder","isClippingOverflow","innerMainSize","innerCrossSize","gapMain","resolveGap","flowChildren","absChildren","collectLayoutChildren","ownerW","ownerH","isWrap","gapCross","computeFlexBasis","lines","push","lineStart","lineLen","hypo","outer","childMarginForAxis","withGap","slice","lineCount","isBaseline","isBaselineLayout","lineConsumedMain","lineCrossSizes","lineMaxAscent","maxLineMain","totalLinesCross","li","line","lineGap","lineBasis","availMain","mainOwner","minM","maxM","resolveFlexibleLengths","lineCross","cStyle","childAlign","cMarginCross","childCrossSize","childCrossMode","resolvedCrossStyle","crossLeadE","crossTrailE","hasCrossAutoMargin","cw","ch","maxAscent","maxDescent","resolveChildAlign","mTop","mBot","ascent","calculateBaseline","descent","mainLead","mainTrail","consumed","cm","totalCrossGap","isScroll","contentMain","finalMainSize","min","contentCross","finalCrossSize","actualInnerMain","actualInnerCross","mainLeadEdgePhys","mainTrailEdgePhys","crossLeadEdgePhys","crossTrailEdgePhys","reversed","mainContainerSize","crossLead","lineCrossOffset","betweenLines","freeCross","remCross","add","wrapReverse","crossContainerSize","lineCrossPos","consumedMain","crossStyleDef","target","mainOffset","betweenMain","numAutoMarginsMain","freeMain","remainingMain","autoMarginMainSize","effectiveLineCrossPos","pos","cMargin","cLayoutMargin","autoMainLead","autoMainTrail","autoCrossLead","autoCrossTrail","mMainLead","mMainTrail","mCrossLead","mCrossTrail","mainPos","crossPos","crossFree","relX","relY","relLeft","relRight","relTop","relBottom","layoutAbsoluteChild","parentWidth","parentHeight","cs","posLeft","posRight","posTop","posBottom","rLeft","rRight","rTop","rBottom","paddingBoxW","paddingBoxH","mL","mT","mR","mB","mainRow","alignment","lead","trail","justifyAbsolute","alignAbsolute","justify","leadEdge","trailEdge","childSize","align","availableMain","availableCross","basis","mainStyleDim","resolved","crossStyleDim","crossOwner","crossConstraint","crossConstraintMode","isStretchAlign","mainConstraint","mainConstraintMode","hasMeasureFuncInSubtree","mw","mh","mwMode","mhMode","result","availableInnerMain","totalFlexBasis","frozen","initialFree","clamped","inflexible","unclamped","iter","frozenDelta","totalGrow","totalShrinkScaled","unfrozenCount","remaining","scaled","totalShrink","totalViolation","anyFrozen","baselineChild","axis","r","isWidth","minV","maxV","minU","maxU","owner","m","zeroLayoutRecursive","flow","abs","disp","scale","absLeft","absTop","l","nodeLeft","nodeTop","nodeWidth","nodeHeight","absNodeLeft","absNodeTop","isText","roundValue","absRight","absBottom","hasFracW","isWholeNumber","hasFracH","frac","floor","forceCeil","forceFloor","ceil","isFinite","endsWith","parseFloat","YOGA_INSTANCE","Config","create","destroy","createDefault","createWithConfig","loadYoga","Promise","resolve"],"sources":["yoga.ts"],"sourcesContent":["/**\n * Pure-TypeScript port of yoga-layout (Meta's flexbox engine).\n *\n * This matches the `yoga-layout/load` API surface used by src/ink/layout/yoga.ts.\n * The upstream C++ source is ~2500 lines in CalculateLayout.cpp alone; this port\n * is a simplified single-pass flexbox implementation that covers the subset of\n * features Ink actually uses:\n *   - flex-direction (row/column + reverse)\n *   - flex-grow / flex-shrink / flex-basis\n *   - align-items / align-self (stretch, flex-start, center, flex-end)\n *   - justify-content (all six values)\n *   - margin / padding / border / gap\n *   - width / height / min / max (point, percent, auto)\n *   - position: relative / absolute\n *   - display: flex / none\n *   - measure functions (for text nodes)\n *\n * Also implemented for spec parity (not used by Ink):\n *   - margin: auto (main + cross axis, overrides justify/align)\n *   - multi-pass flex clamping when children hit min/max constraints\n *   - flex-grow/shrink against container min/max when size is indefinite\n *\n * Also implemented for spec parity (not used by Ink):\n *   - flex-wrap: wrap / wrap-reverse (multi-line flex)\n *   - align-content (positions wrapped lines on cross axis)\n *\n * Also implemented for spec parity (not used by Ink):\n *   - display: contents (children lifted to grandparent, box removed)\n *\n * Also implemented for spec parity (not used by Ink):\n *   - baseline alignment (align-items/align-self: baseline)\n *\n * Not implemented (not used by Ink):\n *   - aspect-ratio\n *   - box-sizing: content-box\n *   - RTL direction (Ink always passes Direction.LTR)\n *\n * Upstream: https://github.com/facebook/yoga\n */\n\n/** biome-ignore-all lint/suspicious/noSelfCompare: intentionally used for some weird NaN checks */\n/** biome-ignore-all lint/style/noNonNullAssertion: needed for performance */\n\n/**\n * Yoga enums — ported from yoga-layout/src/generated/YGEnums.ts\n * Kept as `const` objects (not TS enums) per repo convention.\n * Values match upstream exactly so callers don't change.\n */\n\nexport const Align = {\n\tAuto: 0,\n\tFlexStart: 1,\n\tCenter: 2,\n\tFlexEnd: 3,\n\tStretch: 4,\n\tBaseline: 5,\n\tSpaceBetween: 6,\n\tSpaceAround: 7,\n\tSpaceEvenly: 8,\n} as const;\nexport type Align = (typeof Align)[keyof typeof Align];\n\nexport const BoxSizing = {\n\tBorderBox: 0,\n\tContentBox: 1,\n} as const;\nexport type BoxSizing = (typeof BoxSizing)[keyof typeof BoxSizing];\n\nexport const Dimension = {\n\tWidth: 0,\n\tHeight: 1,\n} as const;\nexport type Dimension = (typeof Dimension)[keyof typeof Dimension];\n\nexport const Direction = {\n\tInherit: 0,\n\tLTR: 1,\n\tRTL: 2,\n} as const;\nexport type Direction = (typeof Direction)[keyof typeof Direction];\n\nexport const Display = {\n\tFlex: 0,\n\tNone: 1,\n\tContents: 2,\n} as const;\nexport type Display = (typeof Display)[keyof typeof Display];\n\nexport const Edge = {\n\tLeft: 0,\n\tTop: 1,\n\tRight: 2,\n\tBottom: 3,\n\tStart: 4,\n\tEnd: 5,\n\tHorizontal: 6,\n\tVertical: 7,\n\tAll: 8,\n} as const;\nexport type Edge = (typeof Edge)[keyof typeof Edge];\n\nexport const Errata = {\n\tNone: 0,\n\tStretchFlexBasis: 1,\n\tAbsolutePositionWithoutInsetsExcludesPadding: 2,\n\tAbsolutePercentAgainstInnerSize: 4,\n\tAll: 2147483647,\n\tClassic: 2147483646,\n} as const;\nexport type Errata = (typeof Errata)[keyof typeof Errata];\n\nexport const ExperimentalFeature = {\n\tWebFlexBasis: 0,\n} as const;\nexport type ExperimentalFeature =\n\t(typeof ExperimentalFeature)[keyof typeof ExperimentalFeature];\n\nexport const FlexDirection = {\n\tColumn: 0,\n\tColumnReverse: 1,\n\tRow: 2,\n\tRowReverse: 3,\n} as const;\nexport type FlexDirection = (typeof FlexDirection)[keyof typeof FlexDirection];\n\nexport const Gutter = {\n\tColumn: 0,\n\tRow: 1,\n\tAll: 2,\n} as const;\nexport type Gutter = (typeof Gutter)[keyof typeof Gutter];\n\nexport const Justify = {\n\tFlexStart: 0,\n\tCenter: 1,\n\tFlexEnd: 2,\n\tSpaceBetween: 3,\n\tSpaceAround: 4,\n\tSpaceEvenly: 5,\n} as const;\nexport type Justify = (typeof Justify)[keyof typeof Justify];\n\nexport const MeasureMode = {\n\tUndefined: 0,\n\tExactly: 1,\n\tAtMost: 2,\n} as const;\nexport type MeasureMode = (typeof MeasureMode)[keyof typeof MeasureMode];\n\nexport const Overflow = {\n\tVisible: 0,\n\tHidden: 1,\n\tScroll: 2,\n} as const;\nexport type Overflow = (typeof Overflow)[keyof typeof Overflow];\n\nexport const PositionType = {\n\tStatic: 0,\n\tRelative: 1,\n\tAbsolute: 2,\n} as const;\nexport type PositionType = (typeof PositionType)[keyof typeof PositionType];\n\nexport const Unit = {\n\tUndefined: 0,\n\tPoint: 1,\n\tPercent: 2,\n\tAuto: 3,\n} as const;\nexport type Unit = (typeof Unit)[keyof typeof Unit];\n\nexport const Wrap = {\n\tNoWrap: 0,\n\tWrap: 1,\n\tWrapReverse: 2,\n} as const;\nexport type Wrap = (typeof Wrap)[keyof typeof Wrap];\n\n// --\n// Value types\n\nexport type Value = {\n\tunit: Unit;\n\tvalue: number;\n};\n\nconst UNDEFINED_VALUE: Value = { unit: Unit.Undefined, value: NaN };\nconst AUTO_VALUE: Value = { unit: Unit.Auto, value: NaN };\n\nfunction pointValue(v: number): Value {\n\treturn { unit: Unit.Point, value: v };\n}\nfunction percentValue(v: number): Value {\n\treturn { unit: Unit.Percent, value: v };\n}\n\nfunction resolveValue(v: Value, ownerSize: number): number {\n\tswitch (v.unit) {\n\t\tcase Unit.Point:\n\t\t\treturn v.value;\n\t\tcase Unit.Percent:\n\t\t\treturn Number.isNaN(ownerSize) ? NaN : (v.value * ownerSize) / 100;\n\t\tdefault:\n\t\t\treturn NaN;\n\t}\n}\n\nfunction isDefined(n: number): boolean {\n\treturn !Number.isNaN(n);\n}\n\n// NaN-safe equality for layout-cache input comparison\nfunction sameFloat(a: number, b: number): boolean {\n\treturn a === b || (a !== a && b !== b);\n}\n\n// --\n// Layout result (computed values)\n\ntype Layout = {\n\tleft: number;\n\ttop: number;\n\twidth: number;\n\theight: number;\n\t// Computed per-edge values (resolved to physical edges)\n\tborder: [number, number, number, number]; // left, top, right, bottom\n\tpadding: [number, number, number, number];\n\tmargin: [number, number, number, number];\n};\n\n// --\n// Style (input values)\n\ntype Style = {\n\tdirection: Direction;\n\tflexDirection: FlexDirection;\n\tjustifyContent: Justify;\n\talignItems: Align;\n\talignSelf: Align;\n\talignContent: Align;\n\tflexWrap: Wrap;\n\toverflow: Overflow;\n\tdisplay: Display;\n\tpositionType: PositionType;\n\n\tflexGrow: number;\n\tflexShrink: number;\n\tflexBasis: Value;\n\n\t// 9-edge arrays indexed by Edge enum\n\tmargin: Value[];\n\tpadding: Value[];\n\tborder: Value[];\n\tposition: Value[];\n\n\t// 3-gutter array indexed by Gutter enum\n\tgap: Value[];\n\n\twidth: Value;\n\theight: Value;\n\tminWidth: Value;\n\tminHeight: Value;\n\tmaxWidth: Value;\n\tmaxHeight: Value;\n};\n\nfunction defaultStyle(): Style {\n\treturn {\n\t\tdirection: Direction.Inherit,\n\t\tflexDirection: FlexDirection.Column,\n\t\tjustifyContent: Justify.FlexStart,\n\t\talignItems: Align.Stretch,\n\t\talignSelf: Align.Auto,\n\t\talignContent: Align.FlexStart,\n\t\tflexWrap: Wrap.NoWrap,\n\t\toverflow: Overflow.Visible,\n\t\tdisplay: Display.Flex,\n\t\tpositionType: PositionType.Relative,\n\t\tflexGrow: 0,\n\t\tflexShrink: 1, // CSS default (Ink also defaults to 1 in Box.tsx)\n\t\tflexBasis: AUTO_VALUE,\n\t\tmargin: new Array(9).fill(UNDEFINED_VALUE),\n\t\tpadding: new Array(9).fill(UNDEFINED_VALUE),\n\t\tborder: new Array(9).fill(UNDEFINED_VALUE),\n\t\tposition: new Array(9).fill(UNDEFINED_VALUE),\n\t\tgap: new Array(3).fill(UNDEFINED_VALUE),\n\t\twidth: AUTO_VALUE,\n\t\theight: AUTO_VALUE,\n\t\tminWidth: UNDEFINED_VALUE,\n\t\tminHeight: UNDEFINED_VALUE,\n\t\tmaxWidth: UNDEFINED_VALUE,\n\t\tmaxHeight: UNDEFINED_VALUE,\n\t};\n}\n\n// --\n// Edge resolution — yoga's 9-edge model collapsed to 4 physical edges\n\nconst EDGE_LEFT = 0;\nconst EDGE_TOP = 1;\nconst EDGE_RIGHT = 2;\nconst EDGE_BOTTOM = 3;\n\nfunction resolveEdge(\n\tedges: Value[],\n\tphysicalEdge: number,\n\townerSize: number,\n\t// For margin/position we allow auto; for padding/border auto resolves to 0\n\tallowAuto = false,\n): number {\n\t// Precedence: specific edge > horizontal/vertical > all\n\tlet v = edges[physicalEdge]!;\n\tif (v.unit === Unit.Undefined) {\n\t\tif (physicalEdge === EDGE_LEFT || physicalEdge === EDGE_RIGHT) {\n\t\t\tv = edges[Edge.Horizontal]!;\n\t\t} else {\n\t\t\tv = edges[Edge.Vertical]!;\n\t\t}\n\t}\n\tif (v.unit === Unit.Undefined) {\n\t\tv = edges[Edge.All]!;\n\t}\n\t// Start/End map to Left/Right for LTR (Ink is always LTR)\n\tif (v.unit === Unit.Undefined) {\n\t\tif (physicalEdge === EDGE_LEFT) v = edges[Edge.Start]!;\n\t\tif (physicalEdge === EDGE_RIGHT) v = edges[Edge.End]!;\n\t}\n\tif (v.unit === Unit.Undefined) return 0;\n\tif (v.unit === Unit.Auto) return allowAuto ? NaN : 0;\n\treturn resolveValue(v, ownerSize);\n}\n\nfunction resolveEdgeRaw(edges: Value[], physicalEdge: number): Value {\n\tlet v = edges[physicalEdge]!;\n\tif (v.unit === Unit.Undefined) {\n\t\tif (physicalEdge === EDGE_LEFT || physicalEdge === EDGE_RIGHT) {\n\t\t\tv = edges[Edge.Horizontal]!;\n\t\t} else {\n\t\t\tv = edges[Edge.Vertical]!;\n\t\t}\n\t}\n\tif (v.unit === Unit.Undefined) v = edges[Edge.All]!;\n\tif (v.unit === Unit.Undefined) {\n\t\tif (physicalEdge === EDGE_LEFT) v = edges[Edge.Start]!;\n\t\tif (physicalEdge === EDGE_RIGHT) v = edges[Edge.End]!;\n\t}\n\treturn v;\n}\n\nfunction isMarginAuto(edges: Value[], physicalEdge: number): boolean {\n\treturn resolveEdgeRaw(edges, physicalEdge).unit === Unit.Auto;\n}\n\n// Setter helpers for the _hasAutoMargin / _hasPosition fast-path flags.\n// Unit.Undefined = 0, Unit.Auto = 3.\nfunction hasAnyAutoEdge(edges: Value[]): boolean {\n\tfor (let i = 0; i < 9; i++) if (edges[i]!.unit === 3) return true;\n\treturn false;\n}\nfunction hasAnyDefinedEdge(edges: Value[]): boolean {\n\tfor (let i = 0; i < 9; i++) if (edges[i]!.unit !== 0) return true;\n\treturn false;\n}\n\n// Hot path: resolve all 4 physical edges in one pass, writing into `out`.\n// Equivalent to calling resolveEdge() 4× with allowAuto=false, but hoists the\n// shared fallback lookups (Horizontal/Vertical/All/Start/End) and avoids\n// allocating a fresh 4-array on every layoutNode() call.\nfunction resolveEdges4Into(\n\tedges: Value[],\n\townerSize: number,\n\tout: [number, number, number, number],\n): void {\n\t// Hoist fallbacks once — the 4 per-edge chains share these reads.\n\tconst eH = edges[6]!; // Edge.Horizontal\n\tconst eV = edges[7]!; // Edge.Vertical\n\tconst eA = edges[8]!; // Edge.All\n\tconst eS = edges[4]!; // Edge.Start\n\tconst eE = edges[5]!; // Edge.End\n\tconst pctDenom = Number.isNaN(ownerSize) ? NaN : ownerSize / 100;\n\n\t// Left: edges[0] → Horizontal → All → Start\n\tlet v = edges[0]!;\n\tif (v.unit === 0) v = eH;\n\tif (v.unit === 0) v = eA;\n\tif (v.unit === 0) v = eS;\n\tout[0] = v.unit === 1 ? v.value : v.unit === 2 ? v.value * pctDenom : 0;\n\n\t// Top: edges[1] → Vertical → All\n\tv = edges[1]!;\n\tif (v.unit === 0) v = eV;\n\tif (v.unit === 0) v = eA;\n\tout[1] = v.unit === 1 ? v.value : v.unit === 2 ? v.value * pctDenom : 0;\n\n\t// Right: edges[2] → Horizontal → All → End\n\tv = edges[2]!;\n\tif (v.unit === 0) v = eH;\n\tif (v.unit === 0) v = eA;\n\tif (v.unit === 0) v = eE;\n\tout[2] = v.unit === 1 ? v.value : v.unit === 2 ? v.value * pctDenom : 0;\n\n\t// Bottom: edges[3] → Vertical → All\n\tv = edges[3]!;\n\tif (v.unit === 0) v = eV;\n\tif (v.unit === 0) v = eA;\n\tout[3] = v.unit === 1 ? v.value : v.unit === 2 ? v.value * pctDenom : 0;\n}\n\n// --\n// Axis helpers\n\nfunction isRow(dir: FlexDirection): boolean {\n\treturn dir === FlexDirection.Row || dir === FlexDirection.RowReverse;\n}\nfunction isReverse(dir: FlexDirection): boolean {\n\treturn (\n\t\tdir === FlexDirection.RowReverse || dir === FlexDirection.ColumnReverse\n\t);\n}\nfunction crossAxis(dir: FlexDirection): FlexDirection {\n\treturn isRow(dir) ? FlexDirection.Column : FlexDirection.Row;\n}\nfunction leadingEdge(dir: FlexDirection): number {\n\tswitch (dir) {\n\t\tcase FlexDirection.Row:\n\t\t\treturn EDGE_LEFT;\n\t\tcase FlexDirection.RowReverse:\n\t\t\treturn EDGE_RIGHT;\n\t\tcase FlexDirection.Column:\n\t\t\treturn EDGE_TOP;\n\t\tcase FlexDirection.ColumnReverse:\n\t\t\treturn EDGE_BOTTOM;\n\t}\n}\nfunction trailingEdge(dir: FlexDirection): number {\n\tswitch (dir) {\n\t\tcase FlexDirection.Row:\n\t\t\treturn EDGE_RIGHT;\n\t\tcase FlexDirection.RowReverse:\n\t\t\treturn EDGE_LEFT;\n\t\tcase FlexDirection.Column:\n\t\t\treturn EDGE_BOTTOM;\n\t\tcase FlexDirection.ColumnReverse:\n\t\t\treturn EDGE_TOP;\n\t}\n}\n\n// --\n// Public types\n\nexport type MeasureFunction = (\n\twidth: number,\n\twidthMode: MeasureMode,\n\theight: number,\n\theightMode: MeasureMode,\n) => { width: number; height: number };\n\nexport type Size = { width: number; height: number };\n\n// --\n// Config\n\nexport type Config = {\n\tpointScaleFactor: number;\n\terrata: Errata;\n\tuseWebDefaults: boolean;\n\tfree(): void;\n\tisExperimentalFeatureEnabled(_: ExperimentalFeature): boolean;\n\tsetExperimentalFeatureEnabled(_: ExperimentalFeature, __: boolean): void;\n\tsetPointScaleFactor(factor: number): void;\n\tgetErrata(): Errata;\n\tsetErrata(errata: Errata): void;\n\tsetUseWebDefaults(v: boolean): void;\n};\n\nfunction createConfig(): Config {\n\tconst config: Config = {\n\t\tpointScaleFactor: 1,\n\t\terrata: Errata.None,\n\t\tuseWebDefaults: false,\n\t\tfree() {},\n\t\tisExperimentalFeatureEnabled() {\n\t\t\treturn false;\n\t\t},\n\t\tsetExperimentalFeatureEnabled() {},\n\t\tsetPointScaleFactor(f) {\n\t\t\tconfig.pointScaleFactor = f;\n\t\t},\n\t\tgetErrata() {\n\t\t\treturn config.errata;\n\t\t},\n\t\tsetErrata(e) {\n\t\t\tconfig.errata = e;\n\t\t},\n\t\tsetUseWebDefaults(v) {\n\t\t\tconfig.useWebDefaults = v;\n\t\t},\n\t};\n\treturn config;\n}\n\n// --\n// Node implementation\n\nexport class Node {\n\tstyle: Style;\n\tlayout: Layout;\n\tparent: Node | null;\n\tchildren: Node[];\n\tmeasureFunc: MeasureFunction | null;\n\tconfig: Config;\n\tisDirty_: boolean;\n\tisReferenceBaseline_: boolean;\n\n\t// Per-layout scratch (not public API)\n\t_flexBasis = 0;\n\t_mainSize = 0;\n\t_crossSize = 0;\n\t_lineIndex = 0;\n\t// Fast-path flags maintained by style setters. Per CPU profile, the\n\t// positioning loop calls isMarginAuto 6× and resolveEdgeRaw(position) 4×\n\t// per child per layout pass — ~11k calls for the 1000-node bench, nearly\n\t// all of which return false/undefined since most nodes have no auto\n\t// margins and no position insets. These flags let us skip straight to\n\t// the common case with a single branch.\n\t_hasAutoMargin = false;\n\t_hasPosition = false;\n\t// Same pattern for the 3× resolveEdges4Into calls at the top of every\n\t// layoutNode(). In the 1000-node bench ~67% of those calls operate on\n\t// all-undefined edge arrays (most nodes have no border; only cols have\n\t// padding; only leaf cells have margin) — a single-branch skip beats\n\t// ~20 property reads + ~15 compares + 4 writes of zeros.\n\t_hasPadding = false;\n\t_hasBorder = false;\n\t_hasMargin = false;\n\t// -- Dirty-flag layout cache. Mirrors upstream CalculateLayout.cpp's\n\t// layoutNodeInternal: skip a subtree entirely when it's clean and we're\n\t// asking the same question we cached the answer to. Two slots since\n\t// each node typically sees a measure call (performLayout=false, from\n\t// computeFlexBasis) followed by a layout call (performLayout=true) with\n\t// different inputs per parent pass — a single slot thrashes. Re-layout\n\t// bench (dirty one leaf, recompute root) went 2.7x→1.1x with this:\n\t// clean siblings skip straight through, only the dirty chain recomputes.\n\t_lW = NaN;\n\t_lH = NaN;\n\t_lWM: MeasureMode = 0;\n\t_lHM: MeasureMode = 0;\n\t_lOW = NaN;\n\t_lOH = NaN;\n\t_lFW = false;\n\t_lFH = false;\n\t// _hasL stores INPUTS early (before compute) but layout.width/height are\n\t// mutated by the multi-entry cache and by subsequent compute calls with\n\t// different inputs. Without storing OUTPUTS, a _hasL hit returns whatever\n\t// layout.width/height happened to be left by the last call — the scrollbox\n\t// vpH=33→2624 bug. Store + restore outputs like the multi-entry cache does.\n\t_lOutW = NaN;\n\t_lOutH = NaN;\n\t_hasL = false;\n\t_mW = NaN;\n\t_mH = NaN;\n\t_mWM: MeasureMode = 0;\n\t_mHM: MeasureMode = 0;\n\t_mOW = NaN;\n\t_mOH = NaN;\n\t_mOutW = NaN;\n\t_mOutH = NaN;\n\t_hasM = false;\n\t// Cached computeFlexBasis result. For clean children, basis only depends\n\t// on the container's inner dimensions — if those haven't changed, skip the\n\t// layoutNode(performLayout=false) recursion entirely. This is the hot path\n\t// for scroll: 500-message content container is dirty, its 499 clean\n\t// children each get measured ~20× as the dirty chain's measure/layout\n\t// passes cascade. Basis cache short-circuits at the child boundary.\n\t_fbBasis = NaN;\n\t_fbOwnerW = NaN;\n\t_fbOwnerH = NaN;\n\t_fbAvailMain = NaN;\n\t_fbAvailCross = NaN;\n\t_fbCrossMode: MeasureMode = 0;\n\t// Generation at which _fbBasis was written. Dirty nodes from a PREVIOUS\n\t// generation have stale cache (subtree changed), but within the SAME\n\t// generation the cache is fresh — the dirty chain's measure→layout\n\t// cascade invokes computeFlexBasis ≥2^depth times per calculateLayout on\n\t// fresh-mounted items, and the subtree doesn't change between calls.\n\t// Gating on generation instead of isDirty_ lets fresh mounts (virtual\n\t// scroll) cache-hit after first compute: 105k visits → ~10k.\n\t_fbGen = -1;\n\t// Memoizes hasMeasureFuncInSubtree() within one calculateLayout. The subtree's\n\t// measure-func presence can't change mid-pass (no config/structure mutation\n\t// during layout), so one walk per node per generation suffices.\n\t_hasMeasureGen = -1;\n\t_hasMeasure = false;\n\t// Multi-entry layout cache — stores (inputs → computed w,h) so hits with\n\t// different inputs than _hasL can restore the right dimensions. Upstream\n\t// yoga uses 16; 4 covers Ink's dirty-chain depth. Packed as flat arrays\n\t// to avoid per-entry object allocs. Slot i uses indices [i*8, i*8+8) in\n\t// _cIn (aW,aH,wM,hM,oW,oH,fW,fH) and [i*2, i*2+2) in _cOut (w,h).\n\t_cIn: Float64Array | null = null;\n\t_cOut: Float64Array | null = null;\n\t_cGen = -1;\n\t_cN = 0;\n\t_cWr = 0;\n\n\tconstructor(config?: Config) {\n\t\tthis.style = defaultStyle();\n\t\tthis.layout = {\n\t\t\tleft: 0,\n\t\t\ttop: 0,\n\t\t\twidth: 0,\n\t\t\theight: 0,\n\t\t\tborder: [0, 0, 0, 0],\n\t\t\tpadding: [0, 0, 0, 0],\n\t\t\tmargin: [0, 0, 0, 0],\n\t\t};\n\t\tthis.parent = null;\n\t\tthis.children = [];\n\t\tthis.measureFunc = null;\n\t\tthis.config = config ?? DEFAULT_CONFIG;\n\t\tthis.isDirty_ = true;\n\t\tthis.isReferenceBaseline_ = false;\n\t\t_yogaLiveNodes++;\n\t}\n\n\t// -- Tree\n\n\tinsertChild(child: Node, index: number): void {\n\t\tchild.parent = this;\n\t\tthis.children.splice(index, 0, child);\n\t\tthis.markDirty();\n\t}\n\tremoveChild(child: Node): void {\n\t\tconst idx = this.children.indexOf(child);\n\t\tif (idx >= 0) {\n\t\t\tthis.children.splice(idx, 1);\n\t\t\tchild.parent = null;\n\t\t\tthis.markDirty();\n\t\t}\n\t}\n\tgetChild(index: number): Node {\n\t\treturn this.children[index]!;\n\t}\n\tgetChildCount(): number {\n\t\treturn this.children.length;\n\t}\n\tgetParent(): Node | null {\n\t\treturn this.parent;\n\t}\n\n\t// -- Lifecycle\n\n\tfree(): void {\n\t\tthis.parent = null;\n\t\tthis.children = [];\n\t\tthis.measureFunc = null;\n\t\tthis._cIn = null;\n\t\tthis._cOut = null;\n\t\t_yogaLiveNodes--;\n\t}\n\tfreeRecursive(): void {\n\t\tfor (const c of this.children) c.freeRecursive();\n\t\tthis.free();\n\t}\n\treset(): void {\n\t\tthis.style = defaultStyle();\n\t\tthis.children = [];\n\t\tthis.parent = null;\n\t\tthis.measureFunc = null;\n\t\tthis.isDirty_ = true;\n\t\tthis._hasAutoMargin = false;\n\t\tthis._hasPosition = false;\n\t\tthis._hasPadding = false;\n\t\tthis._hasBorder = false;\n\t\tthis._hasMargin = false;\n\t\tthis._hasL = false;\n\t\tthis._hasM = false;\n\t\tthis._cN = 0;\n\t\tthis._cWr = 0;\n\t\tthis._fbBasis = NaN;\n\t}\n\n\t// -- Dirty tracking\n\n\tmarkDirty(): void {\n\t\tthis.isDirty_ = true;\n\t\tif (this.parent && !this.parent.isDirty_) this.parent.markDirty();\n\t}\n\tisDirty(): boolean {\n\t\treturn this.isDirty_;\n\t}\n\thasNewLayout(): boolean {\n\t\treturn true;\n\t}\n\tmarkLayoutSeen(): void {}\n\n\t// -- Measure function\n\n\tsetMeasureFunc(fn: MeasureFunction | null): void {\n\t\tthis.measureFunc = fn;\n\t\tthis.markDirty();\n\t}\n\tunsetMeasureFunc(): void {\n\t\tthis.measureFunc = null;\n\t\tthis.markDirty();\n\t}\n\n\t// -- Computed layout getters\n\n\tgetComputedLeft(): number {\n\t\treturn this.layout.left;\n\t}\n\tgetComputedTop(): number {\n\t\treturn this.layout.top;\n\t}\n\tgetComputedWidth(): number {\n\t\treturn this.layout.width;\n\t}\n\tgetComputedHeight(): number {\n\t\treturn this.layout.height;\n\t}\n\tgetComputedRight(): number {\n\t\tconst p = this.parent;\n\t\treturn p ? p.layout.width - this.layout.left - this.layout.width : 0;\n\t}\n\tgetComputedBottom(): number {\n\t\tconst p = this.parent;\n\t\treturn p ? p.layout.height - this.layout.top - this.layout.height : 0;\n\t}\n\tgetComputedLayout(): {\n\t\tleft: number;\n\t\ttop: number;\n\t\tright: number;\n\t\tbottom: number;\n\t\twidth: number;\n\t\theight: number;\n\t} {\n\t\treturn {\n\t\t\tleft: this.layout.left,\n\t\t\ttop: this.layout.top,\n\t\t\tright: this.getComputedRight(),\n\t\t\tbottom: this.getComputedBottom(),\n\t\t\twidth: this.layout.width,\n\t\t\theight: this.layout.height,\n\t\t};\n\t}\n\tgetComputedBorder(edge: Edge): number {\n\t\treturn this.layout.border[physicalEdge(edge)]!;\n\t}\n\tgetComputedPadding(edge: Edge): number {\n\t\treturn this.layout.padding[physicalEdge(edge)]!;\n\t}\n\tgetComputedMargin(edge: Edge): number {\n\t\treturn this.layout.margin[physicalEdge(edge)]!;\n\t}\n\n\t// -- Style setters: dimensions\n\n\tsetWidth(v: number | \"auto\" | string | undefined): void {\n\t\tthis.style.width = parseDimension(v);\n\t\tthis.markDirty();\n\t}\n\tsetWidthPercent(v: number): void {\n\t\tthis.style.width = percentValue(v);\n\t\tthis.markDirty();\n\t}\n\tsetWidthAuto(): void {\n\t\tthis.style.width = AUTO_VALUE;\n\t\tthis.markDirty();\n\t}\n\tsetHeight(v: number | \"auto\" | string | undefined): void {\n\t\tthis.style.height = parseDimension(v);\n\t\tthis.markDirty();\n\t}\n\tsetHeightPercent(v: number): void {\n\t\tthis.style.height = percentValue(v);\n\t\tthis.markDirty();\n\t}\n\tsetHeightAuto(): void {\n\t\tthis.style.height = AUTO_VALUE;\n\t\tthis.markDirty();\n\t}\n\tsetMinWidth(v: number | string | undefined): void {\n\t\tthis.style.minWidth = parseDimension(v);\n\t\tthis.markDirty();\n\t}\n\tsetMinWidthPercent(v: number): void {\n\t\tthis.style.minWidth = percentValue(v);\n\t\tthis.markDirty();\n\t}\n\tsetMinHeight(v: number | string | undefined): void {\n\t\tthis.style.minHeight = parseDimension(v);\n\t\tthis.markDirty();\n\t}\n\tsetMinHeightPercent(v: number): void {\n\t\tthis.style.minHeight = percentValue(v);\n\t\tthis.markDirty();\n\t}\n\tsetMaxWidth(v: number | string | undefined): void {\n\t\tthis.style.maxWidth = parseDimension(v);\n\t\tthis.markDirty();\n\t}\n\tsetMaxWidthPercent(v: number): void {\n\t\tthis.style.maxWidth = percentValue(v);\n\t\tthis.markDirty();\n\t}\n\tsetMaxHeight(v: number | string | undefined): void {\n\t\tthis.style.maxHeight = parseDimension(v);\n\t\tthis.markDirty();\n\t}\n\tsetMaxHeightPercent(v: number): void {\n\t\tthis.style.maxHeight = percentValue(v);\n\t\tthis.markDirty();\n\t}\n\n\t// -- Style setters: flex\n\n\tsetFlexDirection(dir: FlexDirection): void {\n\t\tthis.style.flexDirection = dir;\n\t\tthis.markDirty();\n\t}\n\tsetFlexGrow(v: number | undefined): void {\n\t\tthis.style.flexGrow = v ?? 0;\n\t\tthis.markDirty();\n\t}\n\tsetFlexShrink(v: number | undefined): void {\n\t\tthis.style.flexShrink = v ?? 0;\n\t\tthis.markDirty();\n\t}\n\tsetFlex(v: number | undefined): void {\n\t\tif (v === undefined || Number.isNaN(v)) {\n\t\t\tthis.style.flexGrow = 0;\n\t\t\tthis.style.flexShrink = 0;\n\t\t} else if (v > 0) {\n\t\t\tthis.style.flexGrow = v;\n\t\t\tthis.style.flexShrink = 1;\n\t\t\tthis.style.flexBasis = pointValue(0);\n\t\t} else if (v < 0) {\n\t\t\tthis.style.flexGrow = 0;\n\t\t\tthis.style.flexShrink = -v;\n\t\t} else {\n\t\t\tthis.style.flexGrow = 0;\n\t\t\tthis.style.flexShrink = 0;\n\t\t}\n\t\tthis.markDirty();\n\t}\n\tsetFlexBasis(v: number | \"auto\" | string | undefined): void {\n\t\tthis.style.flexBasis = parseDimension(v);\n\t\tthis.markDirty();\n\t}\n\tsetFlexBasisPercent(v: number): void {\n\t\tthis.style.flexBasis = percentValue(v);\n\t\tthis.markDirty();\n\t}\n\tsetFlexBasisAuto(): void {\n\t\tthis.style.flexBasis = AUTO_VALUE;\n\t\tthis.markDirty();\n\t}\n\tsetFlexWrap(wrap: Wrap): void {\n\t\tthis.style.flexWrap = wrap;\n\t\tthis.markDirty();\n\t}\n\n\t// -- Style setters: alignment\n\n\tsetAlignItems(a: Align): void {\n\t\tthis.style.alignItems = a;\n\t\tthis.markDirty();\n\t}\n\tsetAlignSelf(a: Align): void {\n\t\tthis.style.alignSelf = a;\n\t\tthis.markDirty();\n\t}\n\tsetAlignContent(a: Align): void {\n\t\tthis.style.alignContent = a;\n\t\tthis.markDirty();\n\t}\n\tsetJustifyContent(j: Justify): void {\n\t\tthis.style.justifyContent = j;\n\t\tthis.markDirty();\n\t}\n\n\t// -- Style setters: display / position / overflow\n\n\tsetDisplay(d: Display): void {\n\t\tthis.style.display = d;\n\t\tthis.markDirty();\n\t}\n\tgetDisplay(): Display {\n\t\treturn this.style.display;\n\t}\n\tsetPositionType(t: PositionType): void {\n\t\tthis.style.positionType = t;\n\t\tthis.markDirty();\n\t}\n\tsetPosition(edge: Edge, v: number | string | undefined): void {\n\t\tthis.style.position[edge] = parseDimension(v);\n\t\tthis._hasPosition = hasAnyDefinedEdge(this.style.position);\n\t\tthis.markDirty();\n\t}\n\tsetPositionPercent(edge: Edge, v: number): void {\n\t\tthis.style.position[edge] = percentValue(v);\n\t\tthis._hasPosition = true;\n\t\tthis.markDirty();\n\t}\n\tsetPositionAuto(edge: Edge): void {\n\t\tthis.style.position[edge] = AUTO_VALUE;\n\t\tthis._hasPosition = true;\n\t\tthis.markDirty();\n\t}\n\tsetOverflow(o: Overflow): void {\n\t\tthis.style.overflow = o;\n\t\tthis.markDirty();\n\t}\n\tsetDirection(d: Direction): void {\n\t\tthis.style.direction = d;\n\t\tthis.markDirty();\n\t}\n\tsetBoxSizing(_: BoxSizing): void {\n\t\t// Not implemented — Ink doesn't use content-box\n\t}\n\n\t// -- Style setters: spacing\n\n\tsetMargin(edge: Edge, v: number | \"auto\" | string | undefined): void {\n\t\tconst val = parseDimension(v);\n\t\tthis.style.margin[edge] = val;\n\t\tif (val.unit === Unit.Auto) this._hasAutoMargin = true;\n\t\telse this._hasAutoMargin = hasAnyAutoEdge(this.style.margin);\n\t\tthis._hasMargin =\n\t\t\tthis._hasAutoMargin || hasAnyDefinedEdge(this.style.margin);\n\t\tthis.markDirty();\n\t}\n\tsetMarginPercent(edge: Edge, v: number): void {\n\t\tthis.style.margin[edge] = percentValue(v);\n\t\tthis._hasAutoMargin = hasAnyAutoEdge(this.style.margin);\n\t\tthis._hasMargin = true;\n\t\tthis.markDirty();\n\t}\n\tsetMarginAuto(edge: Edge): void {\n\t\tthis.style.margin[edge] = AUTO_VALUE;\n\t\tthis._hasAutoMargin = true;\n\t\tthis._hasMargin = true;\n\t\tthis.markDirty();\n\t}\n\tsetPadding(edge: Edge, v: number | string | undefined): void {\n\t\tthis.style.padding[edge] = parseDimension(v);\n\t\tthis._hasPadding = hasAnyDefinedEdge(this.style.padding);\n\t\tthis.markDirty();\n\t}\n\tsetPaddingPercent(edge: Edge, v: number): void {\n\t\tthis.style.padding[edge] = percentValue(v);\n\t\tthis._hasPadding = true;\n\t\tthis.markDirty();\n\t}\n\tsetBorder(edge: Edge, v: number | undefined): void {\n\t\tthis.style.border[edge] = v === undefined ? UNDEFINED_VALUE : pointValue(v);\n\t\tthis._hasBorder = hasAnyDefinedEdge(this.style.border);\n\t\tthis.markDirty();\n\t}\n\tsetGap(gutter: Gutter, v: number | string | undefined): void {\n\t\tthis.style.gap[gutter] = parseDimension(v);\n\t\tthis.markDirty();\n\t}\n\tsetGapPercent(gutter: Gutter, v: number): void {\n\t\tthis.style.gap[gutter] = percentValue(v);\n\t\tthis.markDirty();\n\t}\n\n\t// -- Style getters (partial — only what tests need)\n\n\tgetFlexDirection(): FlexDirection {\n\t\treturn this.style.flexDirection;\n\t}\n\tgetJustifyContent(): Justify {\n\t\treturn this.style.justifyContent;\n\t}\n\tgetAlignItems(): Align {\n\t\treturn this.style.alignItems;\n\t}\n\tgetAlignSelf(): Align {\n\t\treturn this.style.alignSelf;\n\t}\n\tgetAlignContent(): Align {\n\t\treturn this.style.alignContent;\n\t}\n\tgetFlexGrow(): number {\n\t\treturn this.style.flexGrow;\n\t}\n\tgetFlexShrink(): number {\n\t\treturn this.style.flexShrink;\n\t}\n\tgetFlexBasis(): Value {\n\t\treturn this.style.flexBasis;\n\t}\n\tgetFlexWrap(): Wrap {\n\t\treturn this.style.flexWrap;\n\t}\n\tgetWidth(): Value {\n\t\treturn this.style.width;\n\t}\n\tgetHeight(): Value {\n\t\treturn this.style.height;\n\t}\n\tgetOverflow(): Overflow {\n\t\treturn this.style.overflow;\n\t}\n\tgetPositionType(): PositionType {\n\t\treturn this.style.positionType;\n\t}\n\tgetDirection(): Direction {\n\t\treturn this.style.direction;\n\t}\n\n\t// -- Unused API stubs (present for API parity)\n\n\tcopyStyle(_: Node): void {}\n\tsetDirtiedFunc(_: unknown): void {}\n\tunsetDirtiedFunc(): void {}\n\tsetIsReferenceBaseline(v: boolean): void {\n\t\tthis.isReferenceBaseline_ = v;\n\t\tthis.markDirty();\n\t}\n\tisReferenceBaseline(): boolean {\n\t\treturn this.isReferenceBaseline_;\n\t}\n\tsetAspectRatio(_: number | undefined): void {}\n\tgetAspectRatio(): number {\n\t\treturn NaN;\n\t}\n\tsetAlwaysFormsContainingBlock(_: boolean): void {}\n\n\t// -- Layout entry point\n\n\tcalculateLayout(\n\t\townerWidth: number | undefined,\n\t\townerHeight: number | undefined,\n\t\t_direction?: Direction,\n\t): void {\n\t\t_yogaNodesVisited = 0;\n\t\t_yogaMeasureCalls = 0;\n\t\t_yogaCacheHits = 0;\n\t\t_generation++;\n\t\tconst w = ownerWidth === undefined ? NaN : ownerWidth;\n\t\tconst h = ownerHeight === undefined ? NaN : ownerHeight;\n\t\tlayoutNode(\n\t\t\tthis,\n\t\t\tw,\n\t\t\th,\n\t\t\tisDefined(w) ? MeasureMode.Exactly : MeasureMode.Undefined,\n\t\t\tisDefined(h) ? MeasureMode.Exactly : MeasureMode.Undefined,\n\t\t\tw,\n\t\t\th,\n\t\t\ttrue,\n\t\t);\n\t\t// Root's own position = margin + position insets (yoga applies position\n\t\t// to the root even without a parent container; this matters for rounding\n\t\t// since the root's abs top/left seeds the pixel-grid walk).\n\t\tconst mar = this.layout.margin;\n\t\tconst posL = resolveValue(\n\t\t\tresolveEdgeRaw(this.style.position, EDGE_LEFT),\n\t\t\tisDefined(w) ? w : 0,\n\t\t);\n\t\tconst posT = resolveValue(\n\t\t\tresolveEdgeRaw(this.style.position, EDGE_TOP),\n\t\t\tisDefined(w) ? w : 0,\n\t\t);\n\t\tthis.layout.left = mar[EDGE_LEFT] + (isDefined(posL) ? posL : 0);\n\t\tthis.layout.top = mar[EDGE_TOP] + (isDefined(posT) ? posT : 0);\n\t\troundLayout(this, this.config.pointScaleFactor, 0, 0);\n\t}\n}\n\nconst DEFAULT_CONFIG = createConfig();\n\nconst CACHE_SLOTS = 4;\nfunction cacheWrite(\n\tnode: Node,\n\taW: number,\n\taH: number,\n\twM: MeasureMode,\n\thM: MeasureMode,\n\toW: number,\n\toH: number,\n\tfW: boolean,\n\tfH: boolean,\n\twasDirty: boolean,\n): void {\n\tif (!node._cIn) {\n\t\tnode._cIn = new Float64Array(CACHE_SLOTS * 8);\n\t\tnode._cOut = new Float64Array(CACHE_SLOTS * 2);\n\t}\n\t// First write after a dirty clears stale entries from before the dirty.\n\t// _cGen < _generation means entries are from a previous calculateLayout;\n\t// if wasDirty, the subtree changed since then → old dimensions invalid.\n\t// Clean nodes' old entries stay — same subtree → same result for same\n\t// inputs, so cross-generation caching works (the scroll hot path where\n\t// 499 clean messages cache-hit while one dirty leaf recomputes).\n\tif (wasDirty && node._cGen !== _generation) {\n\t\tnode._cN = 0;\n\t\tnode._cWr = 0;\n\t}\n\t// LRU write index wraps; _cN stays at CACHE_SLOTS so the read scan always\n\t// checks all populated slots (not just those since last wrap).\n\tconst i = node._cWr++ % CACHE_SLOTS;\n\tif (node._cN < CACHE_SLOTS) node._cN = node._cWr;\n\tconst o = i * 8;\n\tconst cIn = node._cIn;\n\tcIn[o] = aW;\n\tcIn[o + 1] = aH;\n\tcIn[o + 2] = wM;\n\tcIn[o + 3] = hM;\n\tcIn[o + 4] = oW;\n\tcIn[o + 5] = oH;\n\tcIn[o + 6] = fW ? 1 : 0;\n\tcIn[o + 7] = fH ? 1 : 0;\n\tnode._cOut![i * 2] = node.layout.width;\n\tnode._cOut![i * 2 + 1] = node.layout.height;\n\tnode._cGen = _generation;\n}\n\n// Store computed layout.width/height into the single-slot cache output fields.\n// _hasL/_hasM inputs are committed at the TOP of layoutNode (before compute);\n// outputs must be committed HERE (after compute) so a cache hit can restore\n// the correct dimensions. Without this, a _hasL hit returns whatever\n// layout.width/height was left by the last call — which may be the intrinsic\n// content height from a heightMode=Undefined measure pass rather than the\n// constrained viewport height from the layout pass. That's the scrollbox\n// vpH=33→2624 bug: scrollTop clamps to 0, viewport goes blank.\nfunction commitCacheOutputs(node: Node, performLayout: boolean): void {\n\tif (performLayout) {\n\t\tnode._lOutW = node.layout.width;\n\t\tnode._lOutH = node.layout.height;\n\t} else {\n\t\tnode._mOutW = node.layout.width;\n\t\tnode._mOutH = node.layout.height;\n\t}\n}\n\n// --\n// Core flexbox algorithm\n\n// Profiling counters — reset per calculateLayout, read via getYogaCounters.\n// Incremented on each calculateLayout(). Nodes stamp _fbGen/_cGen when\n// their cache is written; a cache entry with gen === _generation was\n// computed THIS pass and is fresh regardless of isDirty_ state.\nlet _generation = 0;\nlet _yogaNodesVisited = 0;\nlet _yogaMeasureCalls = 0;\nlet _yogaCacheHits = 0;\nlet _yogaLiveNodes = 0;\nexport function getYogaCounters(): {\n\tvisited: number;\n\tmeasured: number;\n\tcacheHits: number;\n\tlive: number;\n} {\n\treturn {\n\t\tvisited: _yogaNodesVisited,\n\t\tmeasured: _yogaMeasureCalls,\n\t\tcacheHits: _yogaCacheHits,\n\t\tlive: _yogaLiveNodes,\n\t};\n}\n\nfunction layoutNode(\n\tnode: Node,\n\tavailableWidth: number,\n\tavailableHeight: number,\n\twidthMode: MeasureMode,\n\theightMode: MeasureMode,\n\townerWidth: number,\n\townerHeight: number,\n\tperformLayout: boolean,\n\t// When true, ignore style dimension on this axis — the flex container\n\t// has already determined the main size (flex-basis + grow/shrink result).\n\tforceWidth = false,\n\tforceHeight = false,\n): void {\n\t_yogaNodesVisited++;\n\tconst style = node.style;\n\tconst layout = node.layout;\n\n\t// Dirty-flag skip: clean subtree + matching inputs → layout object already\n\t// holds the answer. A cached layout result also satisfies a measure request\n\t// (positions are a superset of dimensions); the reverse does not hold.\n\t// Same-generation entries are fresh regardless of isDirty_ — they were\n\t// computed THIS calculateLayout, the subtree hasn't changed since.\n\t// Previous-generation entries need !isDirty_ (a dirty node's cache from\n\t// before the dirty is stale).\n\t// sameGen bypass only for MEASURE calls — a layout-pass cache hit would\n\t// skip the child-positioning recursion (STEP 5), leaving children at\n\t// stale positions. Measure calls only need w/h which the cache stores.\n\tconst sameGen = node._cGen === _generation && !performLayout;\n\tif (!node.isDirty_ || sameGen) {\n\t\tif (\n\t\t\t!node.isDirty_ &&\n\t\t\tnode._hasL &&\n\t\t\tnode._lWM === widthMode &&\n\t\t\tnode._lHM === heightMode &&\n\t\t\tnode._lFW === forceWidth &&\n\t\t\tnode._lFH === forceHeight &&\n\t\t\tsameFloat(node._lW, availableWidth) &&\n\t\t\tsameFloat(node._lH, availableHeight) &&\n\t\t\tsameFloat(node._lOW, ownerWidth) &&\n\t\t\tsameFloat(node._lOH, ownerHeight)\n\t\t) {\n\t\t\t_yogaCacheHits++;\n\t\t\tlayout.width = node._lOutW;\n\t\t\tlayout.height = node._lOutH;\n\t\t\treturn;\n\t\t}\n\t\t// Multi-entry cache: scan for matching inputs, restore cached w/h on hit.\n\t\t// Covers the scroll case where a dirty ancestor's measure→layout cascade\n\t\t// produces N>1 distinct input combos per clean child — the single _hasL\n\t\t// slot thrashed, forcing full subtree recursion. With 500-message\n\t\t// scrollbox and one dirty leaf, this took dirty-leaf relayout from\n\t\t// 76k layoutNode calls (21.7×nodes) to 4k (1.2×nodes), 6.86ms → 550µs.\n\t\t// Same-generation check covers fresh-mounted (dirty) nodes during\n\t\t// virtual scroll — the dirty chain invokes them ≥2^depth times, first\n\t\t// call writes cache, rest hit: 105k visits → ~10k for 1593-node tree.\n\t\tif (node._cN > 0 && (sameGen || !node.isDirty_)) {\n\t\t\tconst cIn = node._cIn!;\n\t\t\tfor (let i = 0; i < node._cN; i++) {\n\t\t\t\tconst o = i * 8;\n\t\t\t\tif (\n\t\t\t\t\tcIn[o + 2] === widthMode &&\n\t\t\t\t\tcIn[o + 3] === heightMode &&\n\t\t\t\t\tcIn[o + 6] === (forceWidth ? 1 : 0) &&\n\t\t\t\t\tcIn[o + 7] === (forceHeight ? 1 : 0) &&\n\t\t\t\t\tsameFloat(cIn[o]!, availableWidth) &&\n\t\t\t\t\tsameFloat(cIn[o + 1]!, availableHeight) &&\n\t\t\t\t\tsameFloat(cIn[o + 4]!, ownerWidth) &&\n\t\t\t\t\tsameFloat(cIn[o + 5]!, ownerHeight)\n\t\t\t\t) {\n\t\t\t\t\tlayout.width = node._cOut![i * 2]!;\n\t\t\t\t\tlayout.height = node._cOut![i * 2 + 1]!;\n\t\t\t\t\t_yogaCacheHits++;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (\n\t\t\t!node.isDirty_ &&\n\t\t\t!performLayout &&\n\t\t\tnode._hasM &&\n\t\t\tnode._mWM === widthMode &&\n\t\t\tnode._mHM === heightMode &&\n\t\t\tsameFloat(node._mW, availableWidth) &&\n\t\t\tsameFloat(node._mH, availableHeight) &&\n\t\t\tsameFloat(node._mOW, ownerWidth) &&\n\t\t\tsameFloat(node._mOH, ownerHeight)\n\t\t) {\n\t\t\tlayout.width = node._mOutW;\n\t\t\tlayout.height = node._mOutH;\n\t\t\t_yogaCacheHits++;\n\t\t\treturn;\n\t\t}\n\t}\n\t// Commit cache inputs up front so every return path leaves a valid entry.\n\t// Only clear isDirty_ on the LAYOUT pass — the measure pass (computeFlexBasis\n\t// → layoutNode(performLayout=false)) runs before the layout pass in the same\n\t// calculateLayout call. Clearing dirty during measure lets the subsequent\n\t// layout pass hit the STALE _hasL cache from the previous calculateLayout\n\t// (before children were inserted), so ScrollBox content height never grows\n\t// and sticky-scroll never follows new content. A dirty node's _hasL entry is\n\t// stale by definition — invalidate it so the layout pass recomputes.\n\tconst wasDirty = node.isDirty_;\n\tif (performLayout) {\n\t\tnode._lW = availableWidth;\n\t\tnode._lH = availableHeight;\n\t\tnode._lWM = widthMode;\n\t\tnode._lHM = heightMode;\n\t\tnode._lOW = ownerWidth;\n\t\tnode._lOH = ownerHeight;\n\t\tnode._lFW = forceWidth;\n\t\tnode._lFH = forceHeight;\n\t\tnode._hasL = true;\n\t\tnode.isDirty_ = false;\n\t\t// Previous approach cleared _cN here to prevent stale pre-dirty entries\n\t\t// from hitting (long-continuous blank-screen bug). Now replaced by\n\t\t// generation stamping: the cache check requires sameGen || !isDirty_, so\n\t\t// previous-generation entries from a dirty node can't hit. Clearing here\n\t\t// would wipe fresh same-generation entries from an earlier measure call,\n\t\t// forcing recompute on the layout call.\n\t\tif (wasDirty) node._hasM = false;\n\t} else {\n\t\tnode._mW = availableWidth;\n\t\tnode._mH = availableHeight;\n\t\tnode._mWM = widthMode;\n\t\tnode._mHM = heightMode;\n\t\tnode._mOW = ownerWidth;\n\t\tnode._mOH = ownerHeight;\n\t\tnode._hasM = true;\n\t\t// Don't clear isDirty_. For DIRTY nodes, invalidate _hasL so the upcoming\n\t\t// performLayout=true call recomputes with the new child set (otherwise\n\t\t// sticky-scroll never follows new content — the bug from 4557bc9f9c).\n\t\t// Clean nodes keep _hasL: their layout from the previous generation is\n\t\t// still valid, they're only here because an ancestor is dirty and called\n\t\t// with different inputs than cached.\n\t\tif (wasDirty) node._hasL = false;\n\t}\n\n\t// Resolve padding/border/margin against ownerWidth (yoga uses ownerWidth for %)\n\t// Write directly into the pre-allocated layout arrays — avoids 3 allocs per\n\t// layoutNode call and 12 resolveEdge calls (was the #1 hotspot per CPU profile).\n\t// Skip entirely when no edges are set — the 4-write zero is cheaper than\n\t// the ~20 reads + ~15 compares resolveEdges4Into does to produce zeros.\n\tconst pad = layout.padding;\n\tconst bor = layout.border;\n\tconst mar = layout.margin;\n\tif (node._hasPadding) resolveEdges4Into(style.padding, ownerWidth, pad);\n\telse pad[0] = pad[1] = pad[2] = pad[3] = 0;\n\tif (node._hasBorder) resolveEdges4Into(style.border, ownerWidth, bor);\n\telse bor[0] = bor[1] = bor[2] = bor[3] = 0;\n\tif (node._hasMargin) resolveEdges4Into(style.margin, ownerWidth, mar);\n\telse mar[0] = mar[1] = mar[2] = mar[3] = 0;\n\n\tconst paddingBorderWidth = pad[0] + pad[2] + bor[0] + bor[2];\n\tconst paddingBorderHeight = pad[1] + pad[3] + bor[1] + bor[3];\n\n\t// Resolve style dimensions\n\tconst styleWidth = forceWidth ? NaN : resolveValue(style.width, ownerWidth);\n\tconst styleHeight = forceHeight\n\t\t? NaN\n\t\t: resolveValue(style.height, ownerHeight);\n\n\t// If style dimension is defined, it overrides the available size\n\tlet width = availableWidth;\n\tlet height = availableHeight;\n\tlet wMode = widthMode;\n\tlet hMode = heightMode;\n\tif (isDefined(styleWidth)) {\n\t\twidth = styleWidth;\n\t\twMode = MeasureMode.Exactly;\n\t}\n\tif (isDefined(styleHeight)) {\n\t\theight = styleHeight;\n\t\thMode = MeasureMode.Exactly;\n\t}\n\n\t// Apply min/max constraints to the node's own dimensions\n\twidth = boundAxis(style, true, width, ownerWidth, ownerHeight);\n\theight = boundAxis(style, false, height, ownerWidth, ownerHeight);\n\n\t// Measure-func leaf node\n\tif (node.measureFunc && node.children.length === 0) {\n\t\tconst innerW =\n\t\t\twMode === MeasureMode.Undefined\n\t\t\t\t? NaN\n\t\t\t\t: Math.max(0, width - paddingBorderWidth);\n\t\tconst innerH =\n\t\t\thMode === MeasureMode.Undefined\n\t\t\t\t? NaN\n\t\t\t\t: Math.max(0, height - paddingBorderHeight);\n\t\t_yogaMeasureCalls++;\n\t\tconst measured = node.measureFunc(innerW, wMode, innerH, hMode);\n\t\tnode.layout.width =\n\t\t\twMode === MeasureMode.Exactly\n\t\t\t\t? width\n\t\t\t\t: boundAxis(\n\t\t\t\t\t\tstyle,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t(measured.width ?? 0) + paddingBorderWidth,\n\t\t\t\t\t\townerWidth,\n\t\t\t\t\t\townerHeight,\n\t\t\t\t\t);\n\t\tnode.layout.height =\n\t\t\thMode === MeasureMode.Exactly\n\t\t\t\t? height\n\t\t\t\t: boundAxis(\n\t\t\t\t\t\tstyle,\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t(measured.height ?? 0) + paddingBorderHeight,\n\t\t\t\t\t\townerWidth,\n\t\t\t\t\t\townerHeight,\n\t\t\t\t\t);\n\t\tcommitCacheOutputs(node, performLayout);\n\t\t// Write cache even for dirty nodes — fresh-mounted items during virtual\n\t\t// scroll are dirty on first layout, but the dirty chain's measure→layout\n\t\t// cascade invokes them ≥2^depth times per calculateLayout. Writing here\n\t\t// lets the 2nd+ calls hit cache (isDirty_ was cleared in the layout pass\n\t\t// above). Measured: 105k visits → 10k for a 1593-node fresh-mount tree.\n\t\tcacheWrite(\n\t\t\tnode,\n\t\t\tavailableWidth,\n\t\t\tavailableHeight,\n\t\t\twidthMode,\n\t\t\theightMode,\n\t\t\townerWidth,\n\t\t\townerHeight,\n\t\t\tforceWidth,\n\t\t\tforceHeight,\n\t\t\twasDirty,\n\t\t);\n\t\treturn;\n\t}\n\n\t// Leaf node with no children and no measure func\n\tif (node.children.length === 0) {\n\t\tnode.layout.width =\n\t\t\twMode === MeasureMode.Exactly\n\t\t\t\t? width\n\t\t\t\t: boundAxis(style, true, paddingBorderWidth, ownerWidth, ownerHeight);\n\t\tnode.layout.height =\n\t\t\thMode === MeasureMode.Exactly\n\t\t\t\t? height\n\t\t\t\t: boundAxis(style, false, paddingBorderHeight, ownerWidth, ownerHeight);\n\t\tcommitCacheOutputs(node, performLayout);\n\t\t// Write cache even for dirty nodes — fresh-mounted items during virtual\n\t\t// scroll are dirty on first layout, but the dirty chain's measure→layout\n\t\t// cascade invokes them ≥2^depth times per calculateLayout. Writing here\n\t\t// lets the 2nd+ calls hit cache (isDirty_ was cleared in the layout pass\n\t\t// above). Measured: 105k visits → 10k for a 1593-node fresh-mount tree.\n\t\tcacheWrite(\n\t\t\tnode,\n\t\t\tavailableWidth,\n\t\t\tavailableHeight,\n\t\t\twidthMode,\n\t\t\theightMode,\n\t\t\townerWidth,\n\t\t\townerHeight,\n\t\t\tforceWidth,\n\t\t\tforceHeight,\n\t\t\twasDirty,\n\t\t);\n\t\treturn;\n\t}\n\n\t// Container with children — run flexbox algorithm\n\tconst mainAxis = style.flexDirection;\n\tconst crossAx = crossAxis(mainAxis);\n\tconst isMainRow = isRow(mainAxis);\n\n\tconst mainSize = isMainRow ? width : height;\n\tconst crossSize = isMainRow ? height : width;\n\tconst mainMode = isMainRow ? wMode : hMode;\n\tconst crossMode = isMainRow ? hMode : wMode;\n\tconst mainPadBorder = isMainRow ? paddingBorderWidth : paddingBorderHeight;\n\tconst crossPadBorder = isMainRow ? paddingBorderHeight : paddingBorderWidth;\n\n\t// For overflow:scroll/hidden containers, children layout with unconstrained\n\t// main axis — content overflows and the viewport clips it. Children should\n\t// NOT shrink to fit. The container's own size is still constrained (set in\n\t// STEP 4 via mainMode === Exactly).\n\tconst isClippingOverflow =\n\t\tstyle.overflow === Overflow.Scroll || style.overflow === Overflow.Hidden;\n\tconst innerMainSize =\n\t\tisDefined(mainSize) && !isClippingOverflow\n\t\t\t? Math.max(0, mainSize - mainPadBorder)\n\t\t\t: NaN;\n\tconst innerCrossSize = isDefined(crossSize)\n\t\t? Math.max(0, crossSize - crossPadBorder)\n\t\t: NaN;\n\n\t// Resolve gap\n\tconst gapMain = resolveGap(\n\t\tstyle,\n\t\tisMainRow ? Gutter.Column : Gutter.Row,\n\t\tinnerMainSize,\n\t);\n\n\t// Partition children into flow vs absolute. display:contents nodes are\n\t// transparent — their children are lifted into the grandparent's child list\n\t// (recursively), and the contents node itself gets zero layout.\n\tconst flowChildren: Node[] = [];\n\tconst absChildren: Node[] = [];\n\tcollectLayoutChildren(node, flowChildren, absChildren);\n\n\t// ownerW/H are the reference sizes for resolving children's percentage\n\t// values. Per CSS, a % width resolves against the parent's content-box\n\t// width. If this node's width is indefinite, children's % widths are also\n\t// indefinite — do NOT fall through to the grandparent's size.\n\tconst ownerW = isDefined(width) ? width : NaN;\n\tconst ownerH = isDefined(height) ? height : NaN;\n\tconst isWrap = style.flexWrap !== Wrap.NoWrap;\n\tconst gapCross = resolveGap(\n\t\tstyle,\n\t\tisMainRow ? Gutter.Row : Gutter.Column,\n\t\tinnerCrossSize,\n\t);\n\n\t// STEP 1: Compute flex-basis for each flow child and break into lines.\n\t// Single-line (NoWrap) containers always get one line; multi-line containers\n\t// break when accumulated basis+margin+gap exceeds innerMainSize.\n\tfor (const c of flowChildren) {\n\t\tc._flexBasis = computeFlexBasis(\n\t\t\tc,\n\t\t\tmainAxis,\n\t\t\tinnerMainSize,\n\t\t\tinnerCrossSize,\n\t\t\tcrossMode,\n\t\t\townerW,\n\t\t\townerH,\n\t\t);\n\t}\n\tconst lines: Node[][] = [];\n\tif (!isWrap || !isDefined(innerMainSize) || flowChildren.length === 0) {\n\t\tfor (const c of flowChildren) c._lineIndex = 0;\n\t\tlines.push(flowChildren);\n\t} else {\n\t\t// Line-break decisions use the min/max-clamped basis (flexbox spec §9.3.5:\n\t\t// \"hypothetical main size\"), not the raw flex-basis.\n\t\tlet lineStart = 0;\n\t\tlet lineLen = 0;\n\t\tfor (let i = 0; i < flowChildren.length; i++) {\n\t\t\tconst c = flowChildren[i]!;\n\t\t\tconst hypo = boundAxis(c.style, isMainRow, c._flexBasis, ownerW, ownerH);\n\t\t\tconst outer = Math.max(0, hypo) + childMarginForAxis(c, mainAxis, ownerW);\n\t\t\tconst withGap = i > lineStart ? gapMain : 0;\n\t\t\tif (i > lineStart && lineLen + withGap + outer > innerMainSize) {\n\t\t\t\tlines.push(flowChildren.slice(lineStart, i));\n\t\t\t\tlineStart = i;\n\t\t\t\tlineLen = outer;\n\t\t\t} else {\n\t\t\t\tlineLen += withGap + outer;\n\t\t\t}\n\t\t\tc._lineIndex = lines.length;\n\t\t}\n\t\tlines.push(flowChildren.slice(lineStart));\n\t}\n\tconst lineCount = lines.length;\n\tconst isBaseline = isBaselineLayout(node, flowChildren);\n\n\t// STEP 2+3: For each line, resolve flexible lengths and lay out children to\n\t// measure cross sizes. Track per-line consumed main and max cross.\n\tconst lineConsumedMain: number[] = new Array(lineCount);\n\tconst lineCrossSizes: number[] = new Array(lineCount);\n\t// Baseline layout tracks max ascent (baseline + leading margin) per line so\n\t// baseline-aligned items can be positioned at maxAscent - childBaseline.\n\tconst lineMaxAscent: number[] = isBaseline\n\t\t? new Array(lineCount).fill(0)\n\t\t: [];\n\tlet maxLineMain = 0;\n\tlet totalLinesCross = 0;\n\tfor (let li = 0; li < lineCount; li++) {\n\t\tconst line = lines[li]!;\n\t\tconst lineGap = line.length > 1 ? gapMain * (line.length - 1) : 0;\n\t\tlet lineBasis = lineGap;\n\t\tfor (const c of line) {\n\t\t\tlineBasis += c._flexBasis + childMarginForAxis(c, mainAxis, ownerW);\n\t\t}\n\t\t// Resolve flexible lengths against available inner main. For indefinite\n\t\t// containers with min/max, flex against the clamped size.\n\t\tlet availMain = innerMainSize;\n\t\tif (!isDefined(availMain)) {\n\t\t\tconst mainOwner = isMainRow ? ownerWidth : ownerHeight;\n\t\t\tconst minM = resolveValue(\n\t\t\t\tisMainRow ? style.minWidth : style.minHeight,\n\t\t\t\tmainOwner,\n\t\t\t);\n\t\t\tconst maxM = resolveValue(\n\t\t\t\tisMainRow ? style.maxWidth : style.maxHeight,\n\t\t\t\tmainOwner,\n\t\t\t);\n\t\t\tif (isDefined(maxM) && lineBasis > maxM - mainPadBorder) {\n\t\t\t\tavailMain = Math.max(0, maxM - mainPadBorder);\n\t\t\t} else if (isDefined(minM) && lineBasis < minM - mainPadBorder) {\n\t\t\t\tavailMain = Math.max(0, minM - mainPadBorder);\n\t\t\t}\n\t\t}\n\t\tresolveFlexibleLengths(\n\t\t\tline,\n\t\t\tavailMain,\n\t\t\tlineBasis,\n\t\t\tisMainRow,\n\t\t\townerW,\n\t\t\townerH,\n\t\t);\n\n\t\t// Lay out each child in this line to measure cross\n\t\tlet lineCross = 0;\n\t\tfor (const c of line) {\n\t\t\tconst cStyle = c.style;\n\t\t\tconst childAlign =\n\t\t\t\tcStyle.alignSelf === Align.Auto ? style.alignItems : cStyle.alignSelf;\n\t\t\tconst cMarginCross = childMarginForAxis(c, crossAx, ownerW);\n\t\t\tlet childCrossSize = NaN;\n\t\t\tlet childCrossMode: MeasureMode = MeasureMode.Undefined;\n\t\t\tconst resolvedCrossStyle = resolveValue(\n\t\t\t\tisMainRow ? cStyle.height : cStyle.width,\n\t\t\t\tisMainRow ? ownerH : ownerW,\n\t\t\t);\n\t\t\tconst crossLeadE = isMainRow ? EDGE_TOP : EDGE_LEFT;\n\t\t\tconst crossTrailE = isMainRow ? EDGE_BOTTOM : EDGE_RIGHT;\n\t\t\tconst hasCrossAutoMargin =\n\t\t\t\tc._hasAutoMargin &&\n\t\t\t\t(isMarginAuto(cStyle.margin, crossLeadE) ||\n\t\t\t\t\tisMarginAuto(cStyle.margin, crossTrailE));\n\t\t\t// Single-line stretch goes directly to the container cross size.\n\t\t\t// Multi-line wrap measures intrinsic cross (Undefined mode) so\n\t\t\t// flex-grow grandchildren don't expand to the container — the line\n\t\t\t// cross size is determined first, then items are re-stretched.\n\t\t\tif (isDefined(resolvedCrossStyle)) {\n\t\t\t\tchildCrossSize = resolvedCrossStyle;\n\t\t\t\tchildCrossMode = MeasureMode.Exactly;\n\t\t\t} else if (\n\t\t\t\tchildAlign === Align.Stretch &&\n\t\t\t\t!hasCrossAutoMargin &&\n\t\t\t\t!isWrap &&\n\t\t\t\tisDefined(innerCrossSize) &&\n\t\t\t\tcrossMode === MeasureMode.Exactly\n\t\t\t) {\n\t\t\t\tchildCrossSize = Math.max(0, innerCrossSize - cMarginCross);\n\t\t\t\tchildCrossMode = MeasureMode.Exactly;\n\t\t\t} else if (!isWrap && isDefined(innerCrossSize)) {\n\t\t\t\tchildCrossSize = Math.max(0, innerCrossSize - cMarginCross);\n\t\t\t\tchildCrossMode = MeasureMode.AtMost;\n\t\t\t}\n\t\t\tconst cw = isMainRow ? c._mainSize : childCrossSize;\n\t\t\tconst ch = isMainRow ? childCrossSize : c._mainSize;\n\t\t\tlayoutNode(\n\t\t\t\tc,\n\t\t\t\tcw,\n\t\t\t\tch,\n\t\t\t\tisMainRow ? MeasureMode.Exactly : childCrossMode,\n\t\t\t\tisMainRow ? childCrossMode : MeasureMode.Exactly,\n\t\t\t\townerW,\n\t\t\t\townerH,\n\t\t\t\tperformLayout,\n\t\t\t\tisMainRow,\n\t\t\t\t!isMainRow,\n\t\t\t);\n\t\t\tc._crossSize = isMainRow ? c.layout.height : c.layout.width;\n\t\t\tlineCross = Math.max(lineCross, c._crossSize + cMarginCross);\n\t\t}\n\t\t// Baseline layout: line cross size must fit maxAscent + maxDescent of\n\t\t// baseline-aligned children (yoga STEP 8). Only applies to row direction.\n\t\tif (isBaseline) {\n\t\t\tlet maxAscent = 0;\n\t\t\tlet maxDescent = 0;\n\t\t\tfor (const c of line) {\n\t\t\t\tif (resolveChildAlign(node, c) !== Align.Baseline) continue;\n\t\t\t\tconst mTop = resolveEdge(c.style.margin, EDGE_TOP, ownerW);\n\t\t\t\tconst mBot = resolveEdge(c.style.margin, EDGE_BOTTOM, ownerW);\n\t\t\t\tconst ascent = calculateBaseline(c) + mTop;\n\t\t\t\tconst descent = c.layout.height + mTop + mBot - ascent;\n\t\t\t\tif (ascent > maxAscent) maxAscent = ascent;\n\t\t\t\tif (descent > maxDescent) maxDescent = descent;\n\t\t\t}\n\t\t\tlineMaxAscent[li] = maxAscent;\n\t\t\tif (maxAscent + maxDescent > lineCross) {\n\t\t\t\tlineCross = maxAscent + maxDescent;\n\t\t\t}\n\t\t}\n\t\t// layoutNode(c) at line ~1117 above already resolved c.layout.margin[] via\n\t\t// resolveEdges4Into with the same ownerW — read directly instead of\n\t\t// re-resolving through childMarginForAxis → 2× resolveEdge.\n\t\tconst mainLead = leadingEdge(mainAxis);\n\t\tconst mainTrail = trailingEdge(mainAxis);\n\t\tlet consumed = lineGap;\n\t\tfor (const c of line) {\n\t\t\tconst cm = c.layout.margin;\n\t\t\tconsumed += c._mainSize + cm[mainLead]! + cm[mainTrail]!;\n\t\t}\n\t\tlineConsumedMain[li] = consumed;\n\t\tlineCrossSizes[li] = lineCross;\n\t\tmaxLineMain = Math.max(maxLineMain, consumed);\n\t\ttotalLinesCross += lineCross;\n\t}\n\tconst totalCrossGap = lineCount > 1 ? gapCross * (lineCount - 1) : 0;\n\ttotalLinesCross += totalCrossGap;\n\n\t// STEP 4: Determine container dimensions. Per yoga's STEP 9, for both\n\t// AtMost (FitContent) and Undefined (MaxContent) the node sizes to its\n\t// content — AtMost is NOT a hard clamp, items may overflow the available\n\t// space (CSS \"fit-content\" behavior). Only Scroll overflow clamps to the\n\t// available size. Wrap containers that broke into multiple lines under\n\t// AtMost fill the available main size since they wrapped at that boundary.\n\tconst isScroll = style.overflow === Overflow.Scroll;\n\tconst contentMain = maxLineMain + mainPadBorder;\n\tconst finalMainSize =\n\t\tmainMode === MeasureMode.Exactly\n\t\t\t? mainSize\n\t\t\t: mainMode === MeasureMode.AtMost && isScroll\n\t\t\t\t? Math.max(Math.min(mainSize, contentMain), mainPadBorder)\n\t\t\t\t: isWrap && lineCount > 1 && mainMode === MeasureMode.AtMost\n\t\t\t\t\t? mainSize\n\t\t\t\t\t: contentMain;\n\tconst contentCross = totalLinesCross + crossPadBorder;\n\tconst finalCrossSize =\n\t\tcrossMode === MeasureMode.Exactly\n\t\t\t? crossSize\n\t\t\t: crossMode === MeasureMode.AtMost && isScroll\n\t\t\t\t? Math.max(Math.min(crossSize, contentCross), crossPadBorder)\n\t\t\t\t: contentCross;\n\tnode.layout.width = boundAxis(\n\t\tstyle,\n\t\ttrue,\n\t\tisMainRow ? finalMainSize : finalCrossSize,\n\t\townerWidth,\n\t\townerHeight,\n\t);\n\tnode.layout.height = boundAxis(\n\t\tstyle,\n\t\tfalse,\n\t\tisMainRow ? finalCrossSize : finalMainSize,\n\t\townerWidth,\n\t\townerHeight,\n\t);\n\tcommitCacheOutputs(node, performLayout);\n\t// Write cache even for dirty nodes — fresh-mounted items during virtual scroll\n\tcacheWrite(\n\t\tnode,\n\t\tavailableWidth,\n\t\tavailableHeight,\n\t\twidthMode,\n\t\theightMode,\n\t\townerWidth,\n\t\townerHeight,\n\t\tforceWidth,\n\t\tforceHeight,\n\t\twasDirty,\n\t);\n\n\tif (!performLayout) return;\n\n\t// STEP 5: Position lines (align-content) and children (justify-content +\n\t// align-items + auto margins).\n\tconst actualInnerMain =\n\t\t(isMainRow ? node.layout.width : node.layout.height) - mainPadBorder;\n\tconst actualInnerCross =\n\t\t(isMainRow ? node.layout.height : node.layout.width) - crossPadBorder;\n\tconst mainLeadEdgePhys = leadingEdge(mainAxis);\n\tconst mainTrailEdgePhys = trailingEdge(mainAxis);\n\tconst crossLeadEdgePhys = isMainRow ? EDGE_TOP : EDGE_LEFT;\n\tconst crossTrailEdgePhys = isMainRow ? EDGE_BOTTOM : EDGE_RIGHT;\n\tconst reversed = isReverse(mainAxis);\n\tconst mainContainerSize = isMainRow ? node.layout.width : node.layout.height;\n\tconst crossLead = pad[crossLeadEdgePhys]! + bor[crossLeadEdgePhys]!;\n\n\t// Align-content: distribute free cross space among lines. Single-line\n\t// containers use the full cross size for the one line (align-items handles\n\t// positioning within it).\n\tlet lineCrossOffset = crossLead;\n\tlet betweenLines = gapCross;\n\tconst freeCross = actualInnerCross - totalLinesCross;\n\tif (lineCount === 1 && !isWrap && !isBaseline) {\n\t\tlineCrossSizes[0] = actualInnerCross;\n\t} else {\n\t\tconst remCross = Math.max(0, freeCross);\n\t\tswitch (style.alignContent) {\n\t\t\tcase Align.FlexStart:\n\t\t\t\tbreak;\n\t\t\tcase Align.Center:\n\t\t\t\tlineCrossOffset += freeCross / 2;\n\t\t\t\tbreak;\n\t\t\tcase Align.FlexEnd:\n\t\t\t\tlineCrossOffset += freeCross;\n\t\t\t\tbreak;\n\t\t\tcase Align.Stretch:\n\t\t\t\tif (lineCount > 0 && remCross > 0) {\n\t\t\t\t\tconst add = remCross / lineCount;\n\t\t\t\t\tfor (let i = 0; i < lineCount; i++) lineCrossSizes[i]! += add;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase Align.SpaceBetween:\n\t\t\t\tif (lineCount > 1) betweenLines += remCross / (lineCount - 1);\n\t\t\t\tbreak;\n\t\t\tcase Align.SpaceAround:\n\t\t\t\tif (lineCount > 0) {\n\t\t\t\t\tbetweenLines += remCross / lineCount;\n\t\t\t\t\tlineCrossOffset += remCross / lineCount / 2;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase Align.SpaceEvenly:\n\t\t\t\tif (lineCount > 0) {\n\t\t\t\t\tbetweenLines += remCross / (lineCount + 1);\n\t\t\t\t\tlineCrossOffset += remCross / (lineCount + 1);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\t// For wrap-reverse, lines stack from the trailing cross edge. Walk lines in\n\t// order but flip the cross position within the container.\n\tconst wrapReverse = style.flexWrap === Wrap.WrapReverse;\n\tconst crossContainerSize = isMainRow ? node.layout.height : node.layout.width;\n\tlet lineCrossPos = lineCrossOffset;\n\tfor (let li = 0; li < lineCount; li++) {\n\t\tconst line = lines[li]!;\n\t\tconst lineCross = lineCrossSizes[li]!;\n\t\tconst consumedMain = lineConsumedMain[li]!;\n\t\tconst n = line.length;\n\n\t\t// Re-stretch children whose cross is auto and align is stretch, now that\n\t\t// the line cross size is known. Needed for multi-line wrap (line cross\n\t\t// wasn't known during initial measure) AND single-line when the container\n\t\t// cross was not Exactly (initial stretch at ~line 1250 was skipped because\n\t\t// innerCrossSize wasn't defined — the container sized to max child cross).\n\t\tif (isWrap || crossMode !== MeasureMode.Exactly) {\n\t\t\tfor (const c of line) {\n\t\t\t\tconst cStyle = c.style;\n\t\t\t\tconst childAlign =\n\t\t\t\t\tcStyle.alignSelf === Align.Auto ? style.alignItems : cStyle.alignSelf;\n\t\t\t\tconst crossStyleDef = isDefined(\n\t\t\t\t\tresolveValue(\n\t\t\t\t\t\tisMainRow ? cStyle.height : cStyle.width,\n\t\t\t\t\t\tisMainRow ? ownerH : ownerW,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tconst hasCrossAutoMargin =\n\t\t\t\t\tc._hasAutoMargin &&\n\t\t\t\t\t(isMarginAuto(cStyle.margin, crossLeadEdgePhys) ||\n\t\t\t\t\t\tisMarginAuto(cStyle.margin, crossTrailEdgePhys));\n\t\t\t\tif (\n\t\t\t\t\tchildAlign === Align.Stretch &&\n\t\t\t\t\t!crossStyleDef &&\n\t\t\t\t\t!hasCrossAutoMargin\n\t\t\t\t) {\n\t\t\t\t\tconst cMarginCross = childMarginForAxis(c, crossAx, ownerW);\n\t\t\t\t\tconst target = Math.max(0, lineCross - cMarginCross);\n\t\t\t\t\tif (c._crossSize !== target) {\n\t\t\t\t\t\tconst cw = isMainRow ? c._mainSize : target;\n\t\t\t\t\t\tconst ch = isMainRow ? target : c._mainSize;\n\t\t\t\t\t\tlayoutNode(\n\t\t\t\t\t\t\tc,\n\t\t\t\t\t\t\tcw,\n\t\t\t\t\t\t\tch,\n\t\t\t\t\t\t\tMeasureMode.Exactly,\n\t\t\t\t\t\t\tMeasureMode.Exactly,\n\t\t\t\t\t\t\townerW,\n\t\t\t\t\t\t\townerH,\n\t\t\t\t\t\t\tperformLayout,\n\t\t\t\t\t\t\tisMainRow,\n\t\t\t\t\t\t\t!isMainRow,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tc._crossSize = target;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Justify-content + auto margins for this line\n\t\tlet mainOffset = pad[mainLeadEdgePhys]! + bor[mainLeadEdgePhys]!;\n\t\tlet betweenMain = gapMain;\n\t\tlet numAutoMarginsMain = 0;\n\t\tfor (const c of line) {\n\t\t\tif (!c._hasAutoMargin) continue;\n\t\t\tif (isMarginAuto(c.style.margin, mainLeadEdgePhys)) numAutoMarginsMain++;\n\t\t\tif (isMarginAuto(c.style.margin, mainTrailEdgePhys)) numAutoMarginsMain++;\n\t\t}\n\t\tconst freeMain = actualInnerMain - consumedMain;\n\t\tconst remainingMain = Math.max(0, freeMain);\n\t\tconst autoMarginMainSize =\n\t\t\tnumAutoMarginsMain > 0 && remainingMain > 0\n\t\t\t\t? remainingMain / numAutoMarginsMain\n\t\t\t\t: 0;\n\t\tif (numAutoMarginsMain === 0) {\n\t\t\tswitch (style.justifyContent) {\n\t\t\t\tcase Justify.FlexStart:\n\t\t\t\t\tbreak;\n\t\t\t\tcase Justify.Center:\n\t\t\t\t\tmainOffset += freeMain / 2;\n\t\t\t\t\tbreak;\n\t\t\t\tcase Justify.FlexEnd:\n\t\t\t\t\tmainOffset += freeMain;\n\t\t\t\t\tbreak;\n\t\t\t\tcase Justify.SpaceBetween:\n\t\t\t\t\tif (n > 1) betweenMain += remainingMain / (n - 1);\n\t\t\t\t\tbreak;\n\t\t\t\tcase Justify.SpaceAround:\n\t\t\t\t\tif (n > 0) {\n\t\t\t\t\t\tbetweenMain += remainingMain / n;\n\t\t\t\t\t\tmainOffset += remainingMain / n / 2;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase Justify.SpaceEvenly:\n\t\t\t\t\tif (n > 0) {\n\t\t\t\t\t\tbetweenMain += remainingMain / (n + 1);\n\t\t\t\t\t\tmainOffset += remainingMain / (n + 1);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tconst effectiveLineCrossPos = wrapReverse\n\t\t\t? crossContainerSize - lineCrossPos - lineCross\n\t\t\t: lineCrossPos;\n\n\t\tlet pos = mainOffset;\n\t\tfor (const c of line) {\n\t\t\tconst cMargin = c.style.margin;\n\t\t\t// c.layout.margin[] was populated by resolveEdges4Into inside the\n\t\t\t// layoutNode(c) call above (same ownerW). Read resolved values directly\n\t\t\t// instead of re-running the edge fallback chain 4× via resolveEdge.\n\t\t\t// Auto margins resolve to 0 in layout.margin, so autoMarginMainSize\n\t\t\t// substitution still uses the isMarginAuto check against style.\n\t\t\tconst cLayoutMargin = c.layout.margin;\n\t\t\tlet autoMainLead = false;\n\t\t\tlet autoMainTrail = false;\n\t\t\tlet autoCrossLead = false;\n\t\t\tlet autoCrossTrail = false;\n\t\t\tlet mMainLead: number;\n\t\t\tlet mMainTrail: number;\n\t\t\tlet mCrossLead: number;\n\t\t\tlet mCrossTrail: number;\n\t\t\tif (c._hasAutoMargin) {\n\t\t\t\tautoMainLead = isMarginAuto(cMargin, mainLeadEdgePhys);\n\t\t\t\tautoMainTrail = isMarginAuto(cMargin, mainTrailEdgePhys);\n\t\t\t\tautoCrossLead = isMarginAuto(cMargin, crossLeadEdgePhys);\n\t\t\t\tautoCrossTrail = isMarginAuto(cMargin, crossTrailEdgePhys);\n\t\t\t\tmMainLead = autoMainLead\n\t\t\t\t\t? autoMarginMainSize\n\t\t\t\t\t: cLayoutMargin[mainLeadEdgePhys]!;\n\t\t\t\tmMainTrail = autoMainTrail\n\t\t\t\t\t? autoMarginMainSize\n\t\t\t\t\t: cLayoutMargin[mainTrailEdgePhys]!;\n\t\t\t\tmCrossLead = autoCrossLead ? 0 : cLayoutMargin[crossLeadEdgePhys]!;\n\t\t\t\tmCrossTrail = autoCrossTrail ? 0 : cLayoutMargin[crossTrailEdgePhys]!;\n\t\t\t} else {\n\t\t\t\t// Fast path: no auto margins — read resolved values directly.\n\t\t\t\tmMainLead = cLayoutMargin[mainLeadEdgePhys]!;\n\t\t\t\tmMainTrail = cLayoutMargin[mainTrailEdgePhys]!;\n\t\t\t\tmCrossLead = cLayoutMargin[crossLeadEdgePhys]!;\n\t\t\t\tmCrossTrail = cLayoutMargin[crossTrailEdgePhys]!;\n\t\t\t}\n\n\t\t\tconst mainPos = reversed\n\t\t\t\t? mainContainerSize - (pos + mMainLead) - c._mainSize\n\t\t\t\t: pos + mMainLead;\n\n\t\t\tconst childAlign =\n\t\t\t\tc.style.alignSelf === Align.Auto ? style.alignItems : c.style.alignSelf;\n\t\t\tlet crossPos = effectiveLineCrossPos + mCrossLead;\n\t\t\tconst crossFree = lineCross - c._crossSize - mCrossLead - mCrossTrail;\n\t\t\tif (autoCrossLead && autoCrossTrail) {\n\t\t\t\tcrossPos += Math.max(0, crossFree) / 2;\n\t\t\t} else if (autoCrossLead) {\n\t\t\t\tcrossPos += Math.max(0, crossFree);\n\t\t\t} else if (autoCrossTrail) {\n\t\t\t\t// stays at leading\n\t\t\t} else {\n\t\t\t\tswitch (childAlign) {\n\t\t\t\t\tcase Align.FlexStart:\n\t\t\t\t\tcase Align.Stretch:\n\t\t\t\t\t\tif (wrapReverse) crossPos += crossFree;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase Align.Center:\n\t\t\t\t\t\tcrossPos += crossFree / 2;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase Align.FlexEnd:\n\t\t\t\t\t\tif (!wrapReverse) crossPos += crossFree;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase Align.Baseline:\n\t\t\t\t\t\t// Row direction only (isBaselineLayout checked this). Position so\n\t\t\t\t\t\t// the child's baseline aligns with the line's max ascent. Per\n\t\t\t\t\t\t// yoga: top = currentLead + maxAscent - childBaseline + leadingPosition.\n\t\t\t\t\t\tif (isBaseline) {\n\t\t\t\t\t\t\tcrossPos =\n\t\t\t\t\t\t\t\teffectiveLineCrossPos +\n\t\t\t\t\t\t\t\tlineMaxAscent[li]! -\n\t\t\t\t\t\t\t\tcalculateBaseline(c);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Relative position offsets. Fast path: no position insets set →\n\t\t\t// skip 4× resolveEdgeRaw + 4× resolveValue + 4× isDefined.\n\t\t\tlet relX = 0;\n\t\t\tlet relY = 0;\n\t\t\tif (c._hasPosition) {\n\t\t\t\tconst relLeft = resolveValue(\n\t\t\t\t\tresolveEdgeRaw(c.style.position, EDGE_LEFT),\n\t\t\t\t\townerW,\n\t\t\t\t);\n\t\t\t\tconst relRight = resolveValue(\n\t\t\t\t\tresolveEdgeRaw(c.style.position, EDGE_RIGHT),\n\t\t\t\t\townerW,\n\t\t\t\t);\n\t\t\t\tconst relTop = resolveValue(\n\t\t\t\t\tresolveEdgeRaw(c.style.position, EDGE_TOP),\n\t\t\t\t\townerW,\n\t\t\t\t);\n\t\t\t\tconst relBottom = resolveValue(\n\t\t\t\t\tresolveEdgeRaw(c.style.position, EDGE_BOTTOM),\n\t\t\t\t\townerW,\n\t\t\t\t);\n\t\t\t\trelX = isDefined(relLeft)\n\t\t\t\t\t? relLeft\n\t\t\t\t\t: isDefined(relRight)\n\t\t\t\t\t\t? -relRight\n\t\t\t\t\t\t: 0;\n\t\t\t\trelY = isDefined(relTop)\n\t\t\t\t\t? relTop\n\t\t\t\t\t: isDefined(relBottom)\n\t\t\t\t\t\t? -relBottom\n\t\t\t\t\t\t: 0;\n\t\t\t}\n\n\t\t\tif (isMainRow) {\n\t\t\t\tc.layout.left = mainPos + relX;\n\t\t\t\tc.layout.top = crossPos + relY;\n\t\t\t} else {\n\t\t\t\tc.layout.left = crossPos + relX;\n\t\t\t\tc.layout.top = mainPos + relY;\n\t\t\t}\n\t\t\tpos += c._mainSize + mMainLead + mMainTrail + betweenMain;\n\t\t}\n\t\tlineCrossPos += lineCross + betweenLines;\n\t}\n\n\t// STEP 6: Absolute-positioned children\n\tfor (const c of absChildren) {\n\t\tlayoutAbsoluteChild(\n\t\t\tnode,\n\t\t\tc,\n\t\t\tnode.layout.width,\n\t\t\tnode.layout.height,\n\t\t\tpad,\n\t\t\tbor,\n\t\t);\n\t}\n}\n\nfunction layoutAbsoluteChild(\n\tparent: Node,\n\tchild: Node,\n\tparentWidth: number,\n\tparentHeight: number,\n\tpad: [number, number, number, number],\n\tbor: [number, number, number, number],\n): void {\n\tconst cs = child.style;\n\tconst posLeft = resolveEdgeRaw(cs.position, EDGE_LEFT);\n\tconst posRight = resolveEdgeRaw(cs.position, EDGE_RIGHT);\n\tconst posTop = resolveEdgeRaw(cs.position, EDGE_TOP);\n\tconst posBottom = resolveEdgeRaw(cs.position, EDGE_BOTTOM);\n\n\tconst rLeft = resolveValue(posLeft, parentWidth);\n\tconst rRight = resolveValue(posRight, parentWidth);\n\tconst rTop = resolveValue(posTop, parentHeight);\n\tconst rBottom = resolveValue(posBottom, parentHeight);\n\n\t// Absolute children's percentage dimensions resolve against the containing\n\t// block's padding-box (parent size minus border), per CSS §10.1.\n\tconst paddingBoxW = parentWidth - bor[0] - bor[2];\n\tconst paddingBoxH = parentHeight - bor[1] - bor[3];\n\tlet cw = resolveValue(cs.width, paddingBoxW);\n\tlet ch = resolveValue(cs.height, paddingBoxH);\n\n\t// If both left+right defined and width not, derive width\n\tif (!isDefined(cw) && isDefined(rLeft) && isDefined(rRight)) {\n\t\tcw = paddingBoxW - rLeft - rRight;\n\t}\n\tif (!isDefined(ch) && isDefined(rTop) && isDefined(rBottom)) {\n\t\tch = paddingBoxH - rTop - rBottom;\n\t}\n\n\tlayoutNode(\n\t\tchild,\n\t\tcw,\n\t\tch,\n\t\tisDefined(cw) ? MeasureMode.Exactly : MeasureMode.Undefined,\n\t\tisDefined(ch) ? MeasureMode.Exactly : MeasureMode.Undefined,\n\t\tpaddingBoxW,\n\t\tpaddingBoxH,\n\t\ttrue,\n\t);\n\n\t// Margin of absolute child (applied in addition to insets)\n\tconst mL = resolveEdge(cs.margin, EDGE_LEFT, parentWidth);\n\tconst mT = resolveEdge(cs.margin, EDGE_TOP, parentWidth);\n\tconst mR = resolveEdge(cs.margin, EDGE_RIGHT, parentWidth);\n\tconst mB = resolveEdge(cs.margin, EDGE_BOTTOM, parentWidth);\n\n\tconst mainAxis = parent.style.flexDirection;\n\tconst reversed = isReverse(mainAxis);\n\tconst mainRow = isRow(mainAxis);\n\tconst wrapReverse = parent.style.flexWrap === Wrap.WrapReverse;\n\t// alignSelf overrides alignItems for absolute children (same as flow items)\n\tconst alignment =\n\t\tcs.alignSelf === Align.Auto ? parent.style.alignItems : cs.alignSelf;\n\n\t// Position\n\tlet left: number;\n\tif (isDefined(rLeft)) {\n\t\tleft = bor[0] + rLeft + mL;\n\t} else if (isDefined(rRight)) {\n\t\tleft = parentWidth - bor[2] - rRight - child.layout.width - mR;\n\t} else if (mainRow) {\n\t\t// Main axis — justify-content, flipped for reversed\n\t\tconst lead = pad[0] + bor[0];\n\t\tconst trail = parentWidth - pad[2] - bor[2];\n\t\tleft = reversed\n\t\t\t? trail - child.layout.width - mR\n\t\t\t: justifyAbsolute(\n\t\t\t\t\tparent.style.justifyContent,\n\t\t\t\t\tlead,\n\t\t\t\t\ttrail,\n\t\t\t\t\tchild.layout.width,\n\t\t\t\t) + mL;\n\t} else {\n\t\tleft =\n\t\t\talignAbsolute(\n\t\t\t\talignment,\n\t\t\t\tpad[0] + bor[0],\n\t\t\t\tparentWidth - pad[2] - bor[2],\n\t\t\t\tchild.layout.width,\n\t\t\t\twrapReverse,\n\t\t\t) + mL;\n\t}\n\n\tlet top: number;\n\tif (isDefined(rTop)) {\n\t\ttop = bor[1] + rTop + mT;\n\t} else if (isDefined(rBottom)) {\n\t\ttop = parentHeight - bor[3] - rBottom - child.layout.height - mB;\n\t} else if (mainRow) {\n\t\ttop =\n\t\t\talignAbsolute(\n\t\t\t\talignment,\n\t\t\t\tpad[1] + bor[1],\n\t\t\t\tparentHeight - pad[3] - bor[3],\n\t\t\t\tchild.layout.height,\n\t\t\t\twrapReverse,\n\t\t\t) + mT;\n\t} else {\n\t\tconst lead = pad[1] + bor[1];\n\t\tconst trail = parentHeight - pad[3] - bor[3];\n\t\ttop = reversed\n\t\t\t? trail - child.layout.height - mB\n\t\t\t: justifyAbsolute(\n\t\t\t\t\tparent.style.justifyContent,\n\t\t\t\t\tlead,\n\t\t\t\t\ttrail,\n\t\t\t\t\tchild.layout.height,\n\t\t\t\t) + mT;\n\t}\n\n\tchild.layout.left = left;\n\tchild.layout.top = top;\n}\n\nfunction justifyAbsolute(\n\tjustify: Justify,\n\tleadEdge: number,\n\ttrailEdge: number,\n\tchildSize: number,\n): number {\n\tswitch (justify) {\n\t\tcase Justify.Center:\n\t\t\treturn leadEdge + (trailEdge - leadEdge - childSize) / 2;\n\t\tcase Justify.FlexEnd:\n\t\t\treturn trailEdge - childSize;\n\t\tdefault:\n\t\t\treturn leadEdge;\n\t}\n}\n\nfunction alignAbsolute(\n\talign: Align,\n\tleadEdge: number,\n\ttrailEdge: number,\n\tchildSize: number,\n\twrapReverse: boolean,\n): number {\n\t// Wrap-reverse flips the cross axis: flex-start/stretch go to trailing,\n\t// flex-end goes to leading (yoga's absoluteLayoutChild flips the align value\n\t// when the containing block has wrap-reverse).\n\tswitch (align) {\n\t\tcase Align.Center:\n\t\t\treturn leadEdge + (trailEdge - leadEdge - childSize) / 2;\n\t\tcase Align.FlexEnd:\n\t\t\treturn wrapReverse ? leadEdge : trailEdge - childSize;\n\t\tdefault:\n\t\t\treturn wrapReverse ? trailEdge - childSize : leadEdge;\n\t}\n}\n\nfunction computeFlexBasis(\n\tchild: Node,\n\tmainAxis: FlexDirection,\n\tavailableMain: number,\n\tavailableCross: number,\n\tcrossMode: MeasureMode,\n\townerWidth: number,\n\townerHeight: number,\n): number {\n\t// Same-generation cache hit: basis was computed THIS calculateLayout, so\n\t// it's fresh regardless of isDirty_. Covers both clean children (scrolling\n\t// past unchanged messages) AND fresh-mounted dirty children (virtual\n\t// scroll mounts new items — the dirty chain's measure→layout cascade\n\t// invokes this ≥2^depth times, but the child's subtree doesn't change\n\t// between calls within one calculateLayout). For clean children with\n\t// cache from a PREVIOUS generation, also hit if inputs match — isDirty_\n\t// gates since a dirty child's previous-gen cache is stale.\n\tconst sameGen = child._fbGen === _generation;\n\tif (\n\t\t(sameGen || !child.isDirty_) &&\n\t\tchild._fbCrossMode === crossMode &&\n\t\tsameFloat(child._fbOwnerW, ownerWidth) &&\n\t\tsameFloat(child._fbOwnerH, ownerHeight) &&\n\t\tsameFloat(child._fbAvailMain, availableMain) &&\n\t\tsameFloat(child._fbAvailCross, availableCross)\n\t) {\n\t\treturn child._fbBasis;\n\t}\n\tconst cs = child.style;\n\tconst isMainRow = isRow(mainAxis);\n\n\t// Explicit flex-basis\n\tconst basis = resolveValue(cs.flexBasis, availableMain);\n\tif (isDefined(basis)) {\n\t\tconst b = Math.max(0, basis);\n\t\tchild._fbBasis = b;\n\t\tchild._fbOwnerW = ownerWidth;\n\t\tchild._fbOwnerH = ownerHeight;\n\t\tchild._fbAvailMain = availableMain;\n\t\tchild._fbAvailCross = availableCross;\n\t\tchild._fbCrossMode = crossMode;\n\t\tchild._fbGen = _generation;\n\t\treturn b;\n\t}\n\n\t// Style dimension on main axis\n\tconst mainStyleDim = isMainRow ? cs.width : cs.height;\n\tconst mainOwner = isMainRow ? ownerWidth : ownerHeight;\n\tconst resolved = resolveValue(mainStyleDim, mainOwner);\n\tif (isDefined(resolved)) {\n\t\tconst b = Math.max(0, resolved);\n\t\tchild._fbBasis = b;\n\t\tchild._fbOwnerW = ownerWidth;\n\t\tchild._fbOwnerH = ownerHeight;\n\t\tchild._fbAvailMain = availableMain;\n\t\tchild._fbAvailCross = availableCross;\n\t\tchild._fbCrossMode = crossMode;\n\t\tchild._fbGen = _generation;\n\t\treturn b;\n\t}\n\n\t// Need to measure the child to get its natural size\n\tconst crossStyleDim = isMainRow ? cs.height : cs.width;\n\tconst crossOwner = isMainRow ? ownerHeight : ownerWidth;\n\tlet crossConstraint = resolveValue(crossStyleDim, crossOwner);\n\tlet crossConstraintMode: MeasureMode = isDefined(crossConstraint)\n\t\t? MeasureMode.Exactly\n\t\t: MeasureMode.Undefined;\n\tif (!isDefined(crossConstraint) && isDefined(availableCross)) {\n\t\tcrossConstraint = availableCross;\n\t\tcrossConstraintMode =\n\t\t\tcrossMode === MeasureMode.Exactly && isStretchAlign(child)\n\t\t\t\t? MeasureMode.Exactly\n\t\t\t\t: MeasureMode.AtMost;\n\t}\n\n\t// Upstream yoga (YGNodeComputeFlexBasisForChild) passes the available inner\n\t// width with mode AtMost when the subtree will call a measure-func — so text\n\t// nodes don't report unconstrained intrinsic width as flex-basis, which\n\t// would force siblings to shrink and the text to wrap at the wrong width.\n\t// Passing Undefined here made Ink's <Text> inside <Box flexGrow={1}> get\n\t// width = intrinsic instead of available, dropping chars at wrap boundaries.\n\t//\n\t// Two constraints on when this applies:\n\t//   - Width only. Height is never constrained during basis measurement —\n\t//     column containers must measure children at natural height so\n\t//     scrollable content can overflow (constraining height clips ScrollBox).\n\t//   - Subtree has a measure-func. Pure layout subtrees (no measure-func)\n\t//     with flex-grow children would grow into the AtMost constraint,\n\t//     inflating the basis (breaks YGMinMaxDimensionTest flex_grow_in_at_most\n\t//     where a flexGrow:1 child should stay at basis 0, not grow to 100).\n\tlet mainConstraint = NaN;\n\tlet mainConstraintMode: MeasureMode = MeasureMode.Undefined;\n\tif (isMainRow && isDefined(availableMain) && hasMeasureFuncInSubtree(child)) {\n\t\tmainConstraint = availableMain;\n\t\tmainConstraintMode = MeasureMode.AtMost;\n\t}\n\n\tconst mw = isMainRow ? mainConstraint : crossConstraint;\n\tconst mh = isMainRow ? crossConstraint : mainConstraint;\n\tconst mwMode = isMainRow ? mainConstraintMode : crossConstraintMode;\n\tconst mhMode = isMainRow ? crossConstraintMode : mainConstraintMode;\n\n\tlayoutNode(child, mw, mh, mwMode, mhMode, ownerWidth, ownerHeight, false);\n\tconst b = isMainRow ? child.layout.width : child.layout.height;\n\tchild._fbBasis = b;\n\tchild._fbOwnerW = ownerWidth;\n\tchild._fbOwnerH = ownerHeight;\n\tchild._fbAvailMain = availableMain;\n\tchild._fbAvailCross = availableCross;\n\tchild._fbCrossMode = crossMode;\n\tchild._fbGen = _generation;\n\treturn b;\n}\n\nfunction hasMeasureFuncInSubtree(node: Node): boolean {\n\tif (node._hasMeasureGen === _generation) return node._hasMeasure;\n\tlet result = false;\n\tif (node.measureFunc) {\n\t\tresult = true;\n\t} else {\n\t\tfor (const c of node.children) {\n\t\t\tif (hasMeasureFuncInSubtree(c)) {\n\t\t\t\tresult = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tnode._hasMeasureGen = _generation;\n\tnode._hasMeasure = result;\n\treturn result;\n}\n\nfunction resolveFlexibleLengths(\n\tchildren: Node[],\n\tavailableInnerMain: number,\n\ttotalFlexBasis: number,\n\tisMainRow: boolean,\n\townerW: number,\n\townerH: number,\n): void {\n\t// Multi-pass flex distribution per CSS flexbox spec §9.7 \"Resolving Flexible\n\t// Lengths\": distribute free space, detect min/max violations, freeze all\n\t// violators, redistribute among unfrozen children. Repeat until stable.\n\tconst n = children.length;\n\tconst frozen: boolean[] = new Array(n).fill(false);\n\tconst initialFree = isDefined(availableInnerMain)\n\t\t? availableInnerMain - totalFlexBasis\n\t\t: 0;\n\t// Freeze inflexible items at their clamped basis\n\tfor (let i = 0; i < n; i++) {\n\t\tconst c = children[i]!;\n\t\tconst clamped = boundAxis(c.style, isMainRow, c._flexBasis, ownerW, ownerH);\n\t\tconst inflexible =\n\t\t\t!isDefined(availableInnerMain) ||\n\t\t\t(initialFree >= 0 ? c.style.flexGrow === 0 : c.style.flexShrink === 0);\n\t\tif (inflexible) {\n\t\t\tc._mainSize = Math.max(0, clamped);\n\t\t\tfrozen[i] = true;\n\t\t} else {\n\t\t\tc._mainSize = c._flexBasis;\n\t\t}\n\t}\n\t// Iteratively distribute until no violations. Free space is recomputed each\n\t// pass: initial free space minus the delta frozen children consumed beyond\n\t// (or below) their basis.\n\tconst unclamped: number[] = new Array(n);\n\tfor (let iter = 0; iter <= n; iter++) {\n\t\tlet frozenDelta = 0;\n\t\tlet totalGrow = 0;\n\t\tlet totalShrinkScaled = 0;\n\t\tlet unfrozenCount = 0;\n\t\tfor (let i = 0; i < n; i++) {\n\t\t\tconst c = children[i]!;\n\t\t\tif (frozen[i]) {\n\t\t\t\tfrozenDelta += c._mainSize - c._flexBasis;\n\t\t\t} else {\n\t\t\t\ttotalGrow += c.style.flexGrow;\n\t\t\t\ttotalShrinkScaled += c.style.flexShrink * c._flexBasis;\n\t\t\t\tunfrozenCount++;\n\t\t\t}\n\t\t}\n\t\tif (unfrozenCount === 0) break;\n\t\tlet remaining = initialFree - frozenDelta;\n\t\t// Spec §9.7 step 4c: if sum of flex factors < 1, only distribute\n\t\t// initialFree × sum, not the full remaining space (partial flex).\n\t\tif (remaining > 0 && totalGrow > 0 && totalGrow < 1) {\n\t\t\tconst scaled = initialFree * totalGrow;\n\t\t\tif (scaled < remaining) remaining = scaled;\n\t\t} else if (remaining < 0 && totalShrinkScaled > 0) {\n\t\t\tlet totalShrink = 0;\n\t\t\tfor (let i = 0; i < n; i++) {\n\t\t\t\tif (!frozen[i]) totalShrink += children[i]!.style.flexShrink;\n\t\t\t}\n\t\t\tif (totalShrink < 1) {\n\t\t\t\tconst scaled = initialFree * totalShrink;\n\t\t\t\tif (scaled > remaining) remaining = scaled;\n\t\t\t}\n\t\t}\n\t\t// Compute targets + violations for all unfrozen children\n\t\tlet totalViolation = 0;\n\t\tfor (let i = 0; i < n; i++) {\n\t\t\tif (frozen[i]) continue;\n\t\t\tconst c = children[i]!;\n\t\t\tlet t = c._flexBasis;\n\t\t\tif (remaining > 0 && totalGrow > 0) {\n\t\t\t\tt += (remaining * c.style.flexGrow) / totalGrow;\n\t\t\t} else if (remaining < 0 && totalShrinkScaled > 0) {\n\t\t\t\tt +=\n\t\t\t\t\t(remaining * (c.style.flexShrink * c._flexBasis)) / totalShrinkScaled;\n\t\t\t}\n\t\t\tunclamped[i] = t;\n\t\t\tconst clamped = Math.max(\n\t\t\t\t0,\n\t\t\t\tboundAxis(c.style, isMainRow, t, ownerW, ownerH),\n\t\t\t);\n\t\t\tc._mainSize = clamped;\n\t\t\ttotalViolation += clamped - t;\n\t\t}\n\t\t// Freeze per spec §9.7 step 5: if totalViolation is zero freeze all; if\n\t\t// positive freeze min-violators; if negative freeze max-violators.\n\t\tif (totalViolation === 0) break;\n\t\tlet anyFrozen = false;\n\t\tfor (let i = 0; i < n; i++) {\n\t\t\tif (frozen[i]) continue;\n\t\t\tconst v = children[i]!._mainSize - unclamped[i]!;\n\t\t\tif ((totalViolation > 0 && v > 0) || (totalViolation < 0 && v < 0)) {\n\t\t\t\tfrozen[i] = true;\n\t\t\t\tanyFrozen = true;\n\t\t\t}\n\t\t}\n\t\tif (!anyFrozen) break;\n\t}\n}\n\nfunction isStretchAlign(child: Node): boolean {\n\tconst p = child.parent;\n\tif (!p) return false;\n\tconst align =\n\t\tchild.style.alignSelf === Align.Auto\n\t\t\t? p.style.alignItems\n\t\t\t: child.style.alignSelf;\n\treturn align === Align.Stretch;\n}\n\nfunction resolveChildAlign(parent: Node, child: Node): Align {\n\treturn child.style.alignSelf === Align.Auto\n\t\t? parent.style.alignItems\n\t\t: child.style.alignSelf;\n}\n\n// Baseline of a node per CSS Flexbox §8.5 / yoga's YGBaseline. Leaf nodes\n// (no children) use their own height. Containers recurse into the first\n// baseline-aligned child on the first line (or the first flow child if none\n// are baseline-aligned), returning that child's baseline + its top offset.\nfunction calculateBaseline(node: Node): number {\n\tlet baselineChild: Node | null = null;\n\tfor (const c of node.children) {\n\t\tif (c._lineIndex > 0) break;\n\t\tif (c.style.positionType === PositionType.Absolute) continue;\n\t\tif (c.style.display === Display.None) continue;\n\t\tif (\n\t\t\tresolveChildAlign(node, c) === Align.Baseline ||\n\t\t\tc.isReferenceBaseline_\n\t\t) {\n\t\t\tbaselineChild = c;\n\t\t\tbreak;\n\t\t}\n\t\tif (baselineChild === null) baselineChild = c;\n\t}\n\tif (baselineChild === null) return node.layout.height;\n\treturn calculateBaseline(baselineChild) + baselineChild.layout.top;\n}\n\n// A container uses baseline layout only for row direction, when either\n// align-items is baseline or any flow child has align-self: baseline.\nfunction isBaselineLayout(node: Node, flowChildren: Node[]): boolean {\n\tif (!isRow(node.style.flexDirection)) return false;\n\tif (node.style.alignItems === Align.Baseline) return true;\n\tfor (const c of flowChildren) {\n\t\tif (c.style.alignSelf === Align.Baseline) return true;\n\t}\n\treturn false;\n}\n\nfunction childMarginForAxis(\n\tchild: Node,\n\taxis: FlexDirection,\n\townerWidth: number,\n): number {\n\tif (!child._hasMargin) return 0;\n\tconst lead = resolveEdge(child.style.margin, leadingEdge(axis), ownerWidth);\n\tconst trail = resolveEdge(child.style.margin, trailingEdge(axis), ownerWidth);\n\treturn lead + trail;\n}\n\nfunction resolveGap(style: Style, gutter: Gutter, ownerSize: number): number {\n\tlet v = style.gap[gutter]!;\n\tif (v.unit === Unit.Undefined) v = style.gap[Gutter.All]!;\n\tconst r = resolveValue(v, ownerSize);\n\treturn isDefined(r) ? Math.max(0, r) : 0;\n}\n\nfunction boundAxis(\n\tstyle: Style,\n\tisWidth: boolean,\n\tvalue: number,\n\townerWidth: number,\n\townerHeight: number,\n): number {\n\tconst minV = isWidth ? style.minWidth : style.minHeight;\n\tconst maxV = isWidth ? style.maxWidth : style.maxHeight;\n\tconst minU = minV.unit;\n\tconst maxU = maxV.unit;\n\t// Fast path: no min/max constraints set. Per CPU profile this is the\n\t// overwhelmingly common case (~32k calls/layout on the 1000-node bench,\n\t// nearly all with undefined min/max) — skipping 2× resolveValue + 2× isNaN\n\t// that always no-op. Unit.Undefined = 0.\n\tif (minU === 0 && maxU === 0) return value;\n\tconst owner = isWidth ? ownerWidth : ownerHeight;\n\tlet v = value;\n\t// Inlined resolveValue: Unit.Point=1, Unit.Percent=2. `m === m` is !isNaN.\n\tif (maxU === 1) {\n\t\tif (v > maxV.value) v = maxV.value;\n\t} else if (maxU === 2) {\n\t\tconst m = (maxV.value * owner) / 100;\n\t\tif (m === m && v > m) v = m;\n\t}\n\tif (minU === 1) {\n\t\tif (v < minV.value) v = minV.value;\n\t} else if (minU === 2) {\n\t\tconst m = (minV.value * owner) / 100;\n\t\tif (m === m && v < m) v = m;\n\t}\n\treturn v;\n}\n\nfunction zeroLayoutRecursive(node: Node): void {\n\tfor (const c of node.children) {\n\t\tc.layout.left = 0;\n\t\tc.layout.top = 0;\n\t\tc.layout.width = 0;\n\t\tc.layout.height = 0;\n\t\t// Invalidate layout cache — without this, unhide → calculateLayout finds\n\t\t// the child clean (!isDirty_) with _hasL intact, hits the cache at line\n\t\t// ~1086, restores stale _lOutW/_lOutH, and returns early — skipping the\n\t\t// child-positioning recursion. Grandchildren stay at (0,0,0,0) from the\n\t\t// zeroing above and render invisible. isDirty_=true also gates _cN and\n\t\t// _fbBasis via their (sameGen || !isDirty_) checks — _cGen/_fbGen freeze\n\t\t// during hide so sameGen is false on unhide.\n\t\tc.isDirty_ = true;\n\t\tc._hasL = false;\n\t\tc._hasM = false;\n\t\tzeroLayoutRecursive(c);\n\t}\n}\n\nfunction collectLayoutChildren(node: Node, flow: Node[], abs: Node[]): void {\n\t// Partition a node's children into flow and absolute lists, flattening\n\t// display:contents subtrees so their children are laid out as direct\n\t// children of this node (per CSS display:contents spec — the box is removed\n\t// from the layout tree but its children remain, lifted to the grandparent).\n\tfor (const c of node.children) {\n\t\tconst disp = c.style.display;\n\t\tif (disp === Display.None) {\n\t\t\tc.layout.left = 0;\n\t\t\tc.layout.top = 0;\n\t\t\tc.layout.width = 0;\n\t\t\tc.layout.height = 0;\n\t\t\tzeroLayoutRecursive(c);\n\t\t} else if (disp === Display.Contents) {\n\t\t\tc.layout.left = 0;\n\t\t\tc.layout.top = 0;\n\t\t\tc.layout.width = 0;\n\t\t\tc.layout.height = 0;\n\t\t\t// Recurse — nested display:contents lifts all the way up. The contents\n\t\t\t// node's own margin/padding/position/dimensions are ignored.\n\t\t\tcollectLayoutChildren(c, flow, abs);\n\t\t} else if (c.style.positionType === PositionType.Absolute) {\n\t\t\tabs.push(c);\n\t\t} else {\n\t\t\tflow.push(c);\n\t\t}\n\t}\n}\n\nfunction roundLayout(\n\tnode: Node,\n\tscale: number,\n\tabsLeft: number,\n\tabsTop: number,\n): void {\n\tif (scale === 0) return;\n\tconst l = node.layout;\n\tconst nodeLeft = l.left;\n\tconst nodeTop = l.top;\n\tconst nodeWidth = l.width;\n\tconst nodeHeight = l.height;\n\n\tconst absNodeLeft = absLeft + nodeLeft;\n\tconst absNodeTop = absTop + nodeTop;\n\n\t// Upstream YGRoundValueToPixelGrid: text nodes (has measureFunc) floor their\n\t// positions so wrapped text never starts past its allocated column. Width\n\t// uses ceil-if-fractional to avoid clipping the last glyph. Non-text nodes\n\t// use standard round. Matches yoga's PixelGrid.cpp — without this, justify\n\t// center/space-evenly positions are off-by-one vs WASM and flex-shrink\n\t// overflow places siblings at the wrong column.\n\tconst isText = node.measureFunc !== null;\n\tl.left = roundValue(nodeLeft, scale, false, isText);\n\tl.top = roundValue(nodeTop, scale, false, isText);\n\n\t// Width/height rounded via absolute edges to avoid cumulative drift\n\tconst absRight = absNodeLeft + nodeWidth;\n\tconst absBottom = absNodeTop + nodeHeight;\n\tconst hasFracW = !isWholeNumber(nodeWidth * scale);\n\tconst hasFracH = !isWholeNumber(nodeHeight * scale);\n\tl.width =\n\t\troundValue(absRight, scale, isText && hasFracW, isText && !hasFracW) -\n\t\troundValue(absNodeLeft, scale, false, isText);\n\tl.height =\n\t\troundValue(absBottom, scale, isText && hasFracH, isText && !hasFracH) -\n\t\troundValue(absNodeTop, scale, false, isText);\n\n\tfor (const c of node.children) {\n\t\troundLayout(c, scale, absNodeLeft, absNodeTop);\n\t}\n}\n\nfunction isWholeNumber(v: number): boolean {\n\tconst frac = v - Math.floor(v);\n\treturn frac < 0.0001 || frac > 0.9999;\n}\n\nfunction roundValue(\n\tv: number,\n\tscale: number,\n\tforceCeil: boolean,\n\tforceFloor: boolean,\n): number {\n\tlet scaled = v * scale;\n\tlet frac = scaled - Math.floor(scaled);\n\tif (frac < 0) frac += 1;\n\t// Float-epsilon tolerance matches upstream YGDoubleEqual (1e-4)\n\tif (frac < 0.0001) {\n\t\tscaled = Math.floor(scaled);\n\t} else if (frac > 0.9999) {\n\t\tscaled = Math.ceil(scaled);\n\t} else if (forceCeil) {\n\t\tscaled = Math.ceil(scaled);\n\t} else if (forceFloor) {\n\t\tscaled = Math.floor(scaled);\n\t} else {\n\t\t// Round half-up (>= 0.5 goes up), per upstream\n\t\tscaled = Math.floor(scaled) + (frac >= 0.4999 ? 1 : 0);\n\t}\n\treturn scaled / scale;\n}\n\n// --\n// Helpers\n\nfunction parseDimension(v: number | string | undefined): Value {\n\tif (v === undefined) return UNDEFINED_VALUE;\n\tif (v === \"auto\") return AUTO_VALUE;\n\tif (typeof v === \"number\") {\n\t\t// WASM yoga's YGFloatIsUndefined treats NaN and ±Infinity as undefined.\n\t\t// Ink passes height={Infinity} (e.g. LogSelector maxHeight default) and\n\t\t// expects it to mean \"unconstrained\" — storing it as a literal point value\n\t\t// makes the node height Infinity and breaks all downstream layout.\n\t\treturn Number.isFinite(v) ? pointValue(v) : UNDEFINED_VALUE;\n\t}\n\tif (typeof v === \"string\" && v.endsWith(\"%\")) {\n\t\treturn percentValue(parseFloat(v));\n\t}\n\tconst n = parseFloat(v);\n\treturn Number.isNaN(n) ? UNDEFINED_VALUE : pointValue(n);\n}\n\nfunction physicalEdge(edge: Edge): number {\n\tswitch (edge) {\n\t\tcase Edge.Left:\n\t\tcase Edge.Start:\n\t\t\treturn EDGE_LEFT;\n\t\tcase Edge.Top:\n\t\t\treturn EDGE_TOP;\n\t\tcase Edge.Right:\n\t\tcase Edge.End:\n\t\t\treturn EDGE_RIGHT;\n\t\tcase Edge.Bottom:\n\t\t\treturn EDGE_BOTTOM;\n\t\tdefault:\n\t\t\treturn EDGE_LEFT;\n\t}\n}\n\n// --\n// Module API matching yoga-layout/load\n\nexport type Yoga = {\n\tConfig: {\n\t\tcreate(): Config;\n\t\tdestroy(config: Config): void;\n\t};\n\tNode: {\n\t\tcreate(config?: Config): Node;\n\t\tcreateDefault(): Node;\n\t\tcreateWithConfig(config: Config): Node;\n\t\tdestroy(node: Node): void;\n\t};\n};\n\nconst YOGA_INSTANCE: Yoga = {\n\tConfig: {\n\t\tcreate: createConfig,\n\t\tdestroy() {},\n\t},\n\tNode: {\n\t\tcreate: (config?: Config) => new Node(config),\n\t\tcreateDefault: () => new Node(),\n\t\tcreateWithConfig: (config: Config) => new Node(config),\n\t\tdestroy() {},\n\t},\n};\n\nexport function loadYoga(): Promise<Yoga> {\n\treturn Promise.resolve(YOGA_INSTANCE);\n}\n\nexport default YOGA_INSTANCE;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