// Copyright 2017-2022 The MathJax Consortium
// SPDX-License-Identifier: Apache-2.0
// This file is a Go translation and modification of MathJax 3.2.2.

package svg

import (
	

	
)

// mathAlignShift is CommonWrapper.getAlignShift for the math wrapper only.
// The output options currently expose MathJax's default center/zero alignment.
// Keep existing table layout consumers independent of this late root policy.
func ( *wrapper) () (string, float64) {
	 := stringAttribute(.node, "indentalign", "auto")
	 := stringAttribute(.node, "indentalignfirst", "indentalign")
	if  != "indentalign" {
		 = 
	}
	if  == "auto" {
		 = "center"
	}
	 := attribute(.node, "indentshift", "auto")
	 := attribute(.node, "indentshiftfirst", "indentshift")
	if  != "indentshift" {
		 = 
	}
	if  == "auto" {
		// The fixed displayIndent "0" satisfies the primary zero-unit guard,
		// including right alignment. Explicit shifts are never sign-reversed.
		 = "0"
	}
	// getAlignShift passes raw containerWidth, unlike getWrapWidth's em size.
	// The pinned conversion's default container is 80ex in CSS pixels.
	return , layout.Length2Em(, 80*.renderer.options.Ex, .bbox.Scale, .renderer.pxPerEm)
}

// handleMathMinWidth follows SVGmath.handleDisplay's responsive-width branch.
func ( *wrapper) () {
	if .bbox.PWidth != layout.FullWidth || .renderer.table == nil {
		return
	}
	,  := .mathAlignShift()
	 := .renderer.table.outerBBox()
	, ,  := .L, .W, .R
	switch  {
	case "right":
		if  == 0 || math.IsNaN() {
			 = -
		}
		 = math.Max(, -)
	case "left":
		if  == 0 || math.IsNaN() {
			 = 
		}
		 = math.Max(, )
	case "center":
		 += 2 * math.Abs()
	}
	.renderer.minWidth = math.Max(0, ++)
}