package d2isometricimg

import (
	

	
)

// A static SVG uses the same time-zero snapshot as the native PNG renderer.
// The retained source tree remains immutable, including its animation tracks.
func nativeVectorInitialNode( *d2scene.Node) (*d2scene.Node, error) {
	if len(.Animations) == 0 {
		return , nil
	}
	 := *
	.Filters = append([]d2scene.Filter(nil), .Filters...)
	for ,  := range .Animations {
		if len(.Keyframes) == 0 {
			return nil, fmt.Errorf("native SVG animation has no keyframes")
		}
		 := .Keyframes[0].Value
		switch .Property {
		case d2scene.AnimateOpacity:
			.Opacity = .Number
		case d2scene.AnimateTransform:
			.Transform = .Transform
		case d2scene.AnimateDropShadow:
			if .TargetIndex < 0 || .TargetIndex >= len(.Filters) {
				return nil, fmt.Errorf("native SVG shadow animation target is invalid")
			}
			.Filters[.TargetIndex] = .Shadow
		default:
			,  := nativeVectorInitialPaint(.Primitive, .Property, )
			if  != nil {
				return nil, 
			}
			.Primitive = 
		}
	}
	return &, nil
}

func nativeVectorInitialPaint( d2scene.Primitive,  d2scene.AnimationProperty,  d2scene.AnimationValue) (d2scene.Primitive, error) {
	var  *d2scene.Paint
	var  **d2scene.Stroke
	switch p := .(type) {
	case *d2scene.Path:
		if  != nil {
			return (*, , )
		}
	case *d2scene.Rect:
		if  != nil {
			return (*, , )
		}
	case *d2scene.Ellipse:
		if  != nil {
			return (*, , )
		}
	case *d2scene.TextRun:
		if  != nil {
			return (*, , )
		}
	case d2scene.Path:
		,  = &.Fill, &.Stroke
		 = &
	case d2scene.Rect:
		,  = &.Fill, &.Stroke
		 = &
	case d2scene.Ellipse:
		,  = &.Fill, &.Stroke
		 = &
	case d2scene.TextRun:
		,  = &.Fill, &.Stroke
		 = &
	}
	if  == nil {
		return nil, fmt.Errorf("native SVG animated paint has no painted primitive")
	}
	if  == d2scene.AnimateFillColor {
		* = d2scene.SolidPaint{Color: .Color}
		return , nil
	}
	if  == nil || * == nil {
		return nil, fmt.Errorf("native SVG animated stroke is missing")
	}
	 := **
	switch  {
	case d2scene.AnimateStrokeColor:
		.Paint = d2scene.SolidPaint{Color: .Color}
	case d2scene.AnimateStrokeDashOffset:
		.DashOffset = .Number
	default:
		return nil, fmt.Errorf("native SVG unsupported animation property %d", )
	}
	* = &
	return , nil
}