//
// Area.swift
// HTMLStandard
//
// Generated on 09/23/2025.
// THIS FILE IS GENERATED. DO NOT EDIT.
//
import Foundation
/// Hyperlink or dead area on an image map
public class Area : HTMLNode, IFlow, IPhrasing {
public enum Shape : String, CaseIterable {
case circle
case default_ = "default"
case poly
case rect
public init?(rawValue: Substring) {
guard
let value = Self.allCases.first(where: { $0.rawValue == rawValue })
else
{ return nil }
self = value
}
public init(expect: Substring) throws {
guard
let value = Self.allCases.first(where: { $0.rawValue == expect })
else
{ throw AppError("Unexpected value for Shape: \(expect)") }
self = value
}
public init(expect: String) throws {
guard let result = Shape(rawValue: expect) else {
throw AppError("Unexpected value for Shape: \(expect)")
}
self = result
}
static func parseList(_ value:String?, _ separator:String = " ") throws -> [Shape] {
guard let value = value else { return [] }
var iterator = value.componentsIterator(separatedBy: separator)
let result = try iterator.map { input in
return try expect(Shape(rawValue: input), "unexpected value for Shape: \(input)")
}
return result
}
}
/// Replacement text for use when images are not available. Text. The actual rules are more complicated than indicated.
public var alt:String? = nil
/// Coordinates for the shape to be created in an image map. Valid list of floating-point numbers. The actual rules are more complicated than indicated.
public var coords:[Float] = []
/// Whether to download the resource instead of navigating to it, and its file name if so.
public var download:String? = nil
/// Address of the hyperlink. Valid URL potentially surrounded by spaces.
public var href:URL? = nil
/// URLs to ping. Set of space-separated tokens consisting of valid non-empty URLs.
public var ping:[URL] = []
/// Referrer policy for fetches initiated by the element. Referrer policy.
public var referrerpolicy:ReferrerPolicy? = nil
/// Relationship between the location in the document containing the hyperlink and the destination resource. Unordered set of unique space-separated tokens. The actual rules are more complicated than indicated.
public var rel:[String] = []
/// The kind of shape to be created in an image map.
public var shape:Shape? = nil
/// Browsing context for hyperlink navigation. Valid browsing context name or keyword.
public var target:String? = nil
public init(_ attributes:[String:String], _ parser:XMLParser? = nil) throws {
var globalAttr = GlobalAttributesBuilder()
for (key, attValue) in attributes {
switch (key) {
case "alt":
alt = attValue
continue
case "coords":
coords = try Float.parseList(attValue, ",")
continue
case "download":
download = attValue
continue
case "href":
href = try URL(expect: attValue)
continue
case "ping":
ping = try URL.parseList(attValue, " ")
continue
case "referrerpolicy":
referrerpolicy = try ReferrerPolicy(expect: attValue)
continue
case "rel":
rel = try String.parseList(attValue, " ")
continue
case "shape":
shape = try Shape(expect: attValue)
continue
case "target":
target = attValue
continue
default: break
}
if globalAttr.trySetGlobalAttribute(key, attValue) {
continue
}
continue
}
super.init(globalAttr)
}
public override func renderAttributes() -> String {
var result = super.renderAttributes()
if let alt = alt {
result += " alt='\(alt)'"
}
result += " coords='\(coords.toStringList(","))'"
if let download = download {
result += " download='\(download)'"
}
if let href = href {
result += " href='\(href.absoluteString)'"
}
result += " ping='\(ping.toStringList(" "))'"
if let referrerpolicy = referrerpolicy {
result += " referrerpolicy='\(referrerpolicy.rawValue)'"
}
result += " rel='\(rel.toStringList(" "))'"
if let shape = shape {
result += " shape='\(shape.rawValue)'"
}
if let target = target {
result += " target='\(target)'"
}
return result
}
override var nodeName: String {
return "area"
}
override var isVoidElement: Bool {
return true
}
}