package app

import (
	
	
)

type attributes map[string]string

func ( attributes) ( string,  any) {
	var  string
	switch  {
	case "value":
		 = toString()

	case "style", "allow":
		 = strings.TrimLeft([]+";"+toAttributeValue(), ";")

	case "class":
		 = strings.TrimSpace([] + " " + toAttributeValue())

	case "srcset":
		 = strings.TrimLeft([]+", "+toAttributeValue(), ", ")

	default:
		 = toAttributeValue()
	}

	switch  {
	case "cite",
		"data",
		"download",
		"href",
		"src",
		"value":
		[] = 

	default:
		if  != "" {
			[] = 
		}
	}
}

type attributeURLResolver func(string) string

func toAttributeValue( any) string {
	return strings.TrimSpace(toString())
}

func resolveAttributeURLValue(,  string,  attributeURLResolver) string {
	switch  {
	case "cite",
		"data",
		"href",
		"src":
		return ()

	case "srcset":
		 := strings.Split(, ", ")
		for ,  := range  {
			[] = ()
		}
		return strings.Join(, ", ")

	default:
		return 
	}
}

func setJSAttribute( Value, ,  string) {
	 := func( string) bool {
		,  := strconv.ParseBool()
		return 
	}

	switch  {
	case "value":
		.Set(, )

	case "contenteditable":
		.Set("contentEditable", )

	case "ismap":
		.Set("isMap", ())

	case "readonly":
		.Set("readOnly", ())

	case "async",
		"autofocus",
		"autoplay",
		"checked",
		"default",
		"defer",
		"disabled",
		"hidden",
		"loop",
		"multiple",
		"muted",
		"open",
		"required",
		"reversed",
		"selected":
		.Set(, ())

	default:
		.Call("setAttribute", , )
	}
}

func deleteJSAttribute( Value,  string) {
	.Call("removeAttribute", )
}