export let widget_uml_class = (b) => {
let w = attr_or(b, "width", 180)
let h = attr_or(b, "height", 160)
let name = attr_or(b, "label", "ClassName")
let stereotype = attr_or(b, "stereotype", "")
let fields_str = attr_or(b, "fields", "")
let methods_str = attr_or(b, "methods", "")
let color = attr_or(b, "color", "var(--color-link)")
let surface_fill = attr_or(b, "surface_fill", "var(--color-bg)")
let header_fill = attr_or(b, "header_fill", color)
let border_stroke = attr_or(b, "border_stroke", color)
let header_label_fill = attr_or(b, "header_label_fill", "#fff")
let text_fill = attr_or(b, "text_fill", "currentColor")
let muted_fill = attr_or(b, "muted_fill", header_label_fill)
let separator_stroke = attr_or(b, "separator_stroke", border_stroke)
let has_st = stereotype != ""
let hdr_h = has_st ? 40 : 28
let fields = fields_str != "" ? split("|", fields_str) : []
let methods = methods_str != "" ? split("|", methods_str) : []
let nf = len(fields)
let nm = len(methods)
let field_h = (nf * 16) > 16 ? nf * 16 : 16
let frame = [
{ kind = "rect", x = 0, y = 0, width = w, height = h,
fill = surface_fill, stroke = border_stroke, stroke_width = 2 },
{ kind = "rect", x = 0, y = 0, width = w, height = hdr_h, fill = header_fill }
]
let stereo_part = has_st ? [{ kind = "text", x = 0, y = 4, width = w, height = 14,
content = "<<" + stereotype + ">>", font_size = 9, fill = muted_fill, opacity = 0.8 }] : []
let name_y = has_st ? 18 : 4
let name_part = [{ kind = "text", x = 0, y = name_y, width = w, height = 20,
content = name, font_size = 14, fill = header_label_fill }]
let sep1 = [{ kind = "line", x1 = 0, y1 = hdr_h, x2 = w, y2 = hdr_h, stroke = separator_stroke, stroke_width = 1 }]
let field_lines = map(range(0, nf), (i) => {
kind = "text", x = 8, y = hdr_h + 4 + i * 16, width = w - 16, height = 14,
content = trim(fields[i]), font_size = 11, anchor = "start", fill = text_fill
})
let my_start = hdr_h + field_h + 4
let sep2 = [{ kind = "line", x1 = 0, y1 = my_start, x2 = w, y2 = my_start, stroke = separator_stroke, stroke_width = 1 }]
let method_lines = map(range(0, nm), (i) => {
kind = "text", x = 8, y = my_start + 4 + i * 16, width = w - 16, height = 14,
content = trim(methods[i]), font_size = 11, anchor = "start", fill = text_fill
})
concat(concat(concat(concat(concat(concat(frame, stereo_part), name_part), sep1), field_lines), sep2), method_lines)
}