// Copyright 2018-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 (
	
	
	

	
	
)

func ( *wrapper) () float64 {
	 := strings.Fields(stringAttribute(.node, "data-offsets", ""))
	 := ".2em"
	if len() != 0 {
		 = [0]
	}
	return layout.Length2Em(, .2, .bbox.Scale, .renderer.pxPerEm)
}

func ( *wrapper) () int {
	 := 1.0
	if ,  := numberAttribute(.node, "selection");  {
		 = 
	}
	 = math.Max(1, math.Min(float64(len(.children)), ))
	return int() - 1
}

func ( *wrapper) () *wrapper {
	 := .actionSelection()
	if  >= 0 &&  < len(.children) {
		return .children[]
	}
	 := mml.NewNode("mrow", nil, nil)
	return .renderer.wrap(, , .scriptLevel, .displayStyle)
}

func ( *wrapper) ( *layout.BBox) {
	.dx = .actionOffsetX()
	.UpdateFrom(.selectedActionChild().outerBBox())
}

func ( *wrapper) () string {
	 := 1.0
	if ,  := numberAttribute(.node, "selection");  {
		 = 
	}
	return strconv.FormatFloat(, 'f', -1, 64)
}

func ( *wrapper) ( *Element) {
	.dx = .actionOffsetX()
	 := .standardSVG()
	 := .selectedActionChild()
	 := .outerBBox()
	 := NewElement("rect").
		SetAttr("width", fixed(.W)).
		SetAttr("height", fixed(.H+.D)).
		SetAttr("y", fixed(-.D)).
		SetAttr("fill", "none").
		SetAttr("pointer-events", "all")
	.Append()
	.toSVG()
	.place(.L*.RScale, 0)

	 := stringAttribute(.node, "actiontype", "toggle")
	switch  {
	case "toggle":
		// LiteElement has no event API.  Keep the exact static marker; click
		// selection and rerendering are intentionally unavailable in D2.
		.SetAttr("data-toggle", .actionSelectionText())
	case "tooltip":
		if len(.children) > 1 && .children[1].node.Kind == "mtext" {
			.Prepend(NewElement("title", Text(nodeText(.children[1].node))))
		}
	case "statusline":
		if len(.children) > 1 && .children[1].node.Kind == "mtext" {
			.SetAttr("data-statusline", nodeText(.children[1].node))
		}
	}
}