@omem-ai/plugin-sdk 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/blocks.js CHANGED
@@ -1,4 +1,5 @@
1
- const P = ["ask", "view"], Z = `
1
+ import { metricsElement as M, mountChart as _ } from "./charts.js";
2
+ const A = ["ask", "view"], q = `
2
3
  .ob { display: grid; gap: 12px; min-width: 0; color: var(--ink); }
3
4
  .ob h3 { margin: 0; font: 600 16px/1.35 var(--serif); }
4
5
  .ob h4 { margin: 4px 0 0; font: 600 14.5px/1.4 var(--serif); }
@@ -18,13 +19,16 @@ const P = ["ask", "view"], Z = `
18
19
  .ob .ob-spacer { flex: 1; }
19
20
  .ob .ob-err { color: var(--danger); font-size: 12.5px; }
20
21
  .ob .ob-value { color: var(--ink-2); overflow-wrap: anywhere; white-space: pre-wrap; }
21
- .ob svg { width: 100%; height: auto; display: block; overflow: visible; }
22
- .ob .ob-axis { stroke: var(--line-strong); stroke-width: 1; }
23
- .ob .ob-grid { stroke: var(--line); stroke-width: 1; }
24
- .ob .ob-tick { fill: var(--muted); font-size: 11px; font-family: var(--sans); }
25
- .ob .ob-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12.5px; color: var(--ink-2); }
26
- .ob .ob-key { display: inline-flex; align-items: center; gap: 6px; }
27
- .ob .ob-key i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
22
+ .ob .ob-chart + *, .ob * + .ob-chart { margin-top: 8px; }
23
+ .ob .ob-callout { --c: var(--accent); display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 10px; align-items: start; padding: 10px 14px; border-radius: 8px; background: var(--sunken); }
24
+ .ob .ob-callout[data-tone="success"] { --c: var(--ok); }
25
+ .ob .ob-callout[data-tone="warning"] { --c: var(--warn); }
26
+ .ob .ob-callout[data-tone="danger"] { --c: var(--danger); }
27
+ .ob .ob-callout[data-tone="neutral"] { --c: var(--muted); }
28
+ .ob .ob-callout-icon { width: 16px; height: 16px; margin-top: 4px; fill: none; stroke: var(--c); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
29
+ .ob .ob-callout-body { display: grid; gap: 2px; min-width: 0; }
30
+ .ob .ob-callout-body > b { color: var(--ink); font-weight: 650; }
31
+ .ob .ob-callout-body .prose > :first-child, .ob .ob-callout-body .prose > :last-child { margin-top: 0; margin-bottom: 0; }
28
32
  .ob details summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
29
33
  .ob .ob-scroll { overflow-x: auto; max-width: 100%; }
30
34
  .ob table { border-collapse: collapse; font-size: 12.5px; margin-top: 6px; }
@@ -33,9 +37,6 @@ const P = ["ask", "view"], Z = `
33
37
  .ob thead th button { all: unset; cursor: pointer; }
34
38
  .ob thead th button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
35
39
  .ob td.num { text-align: right; font-variant-numeric: tabular-nums; }
36
- .ob .ob-metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
37
- .ob .ob-metric { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: grid; gap: 2px; min-width: 0; }
38
- .ob .ob-metric b { font: 600 20px/1.2 var(--sans); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
39
40
  .ob .ob-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
40
41
  .ob .ob-pcard { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: grid; gap: 6px; align-content: start; min-width: 0; background: var(--panel); text-align: left; font: inherit; color: inherit; }
41
42
  .ob button.ob-pcard { cursor: pointer; }
@@ -51,295 +52,301 @@ const P = ["ask", "view"], Z = `
51
52
  .ob .ob-check:last-child { border-bottom: 0; }
52
53
  .ob .ob-rank { list-style: none; margin: 0; padding: 0; }
53
54
  .ob .ob-rank .ob-check { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
54
- .ob { --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #8a63d2; --s6: #6b7a8f; }
55
- @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ob { --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #9b78e0; --s6: #8593a6; } }
56
- :root[data-theme="dark"] .ob { --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #9b78e0; --s6: #8593a6; }
57
- @media (max-width: 520px) { .ob .ob-timeline li { grid-template-columns: minmax(0, 1fr); } }
55
+ .ob .ob-list { list-style: none; margin: 0; padding: 0; display: grid; }
56
+ .ob .ob-list li { display: grid; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--line); min-width: 0; }
57
+ .ob .ob-list li:first-child { padding-top: 2px; }
58
+ .ob .ob-list li:last-child { border-bottom: 0; padding-bottom: 0; }
59
+ .ob .ob-li-head { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
60
+ .ob .ob-li-head .badge { flex: none; height: 19px; font-size: 12px; transform: translateY(-1px); }
61
+ .ob .ob-li-title { font-size: 14px; font-weight: 600; line-height: 1.55; min-width: 0; overflow-wrap: anywhere; }
62
+ .ob .ob-li-title a { color: inherit; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
63
+ .ob .ob-li-title a:hover { text-decoration-color: currentColor; }
64
+ .ob .ob-li-title a::after { content: " ↗"; color: var(--muted); font-weight: 400; }
65
+ .ob .ob-list li > .ob-md, .ob .ob-list li > .ob-md .prose { color: var(--ink-2); font-size: 13px; line-height: 1.65; }
66
+ .ob .ob-list li > .ob-md .prose > :first-child { margin-top: 0; }
67
+ .ob .ob-list li > .ob-md .prose > :last-child { margin-bottom: 0; }
68
+ .ob .ob-group { display: grid; gap: 4px; min-width: 0; }
69
+ .ob .ob-caption { font-size: 13px; font-weight: 650; color: var(--ink-2); }
70
+ .ob .ob-kv { display: grid; grid-template-columns: repeat(var(--kv, 2), minmax(0, 1fr)); gap: 10px 16px; margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--sunken); }
71
+ .ob .ob-kv > div { display: grid; gap: 1px; min-width: 0; }
72
+ .ob .ob-kv dt { color: var(--muted); font-size: 12px; line-height: 1.5; }
73
+ .ob .ob-kv dd { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
74
+ .ob .ob-fold { border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; }
75
+ .ob .ob-fold > summary { padding: 8px 0; color: var(--ink-2); font-size: 13px; font-weight: 600; list-style-position: inside; }
76
+ .ob .ob-fold[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 8px; }
77
+ .ob .ob-fold > .ob-md { padding-bottom: 10px; }
78
+
79
+ .ob .ob-figure { margin: 0; display: grid; gap: 6px; justify-items: start; }
80
+ .ob .ob-figure img { max-width: 100%; max-height: 480px; border-radius: 8px; border: 1px solid var(--line); }
81
+ @media (max-width: 520px) { .ob .ob-timeline li { grid-template-columns: minmax(0, 1fr); } .ob .ob-kv { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
58
82
  `;
59
- function O(t) {
83
+ function C(t) {
60
84
  if (t.getElementById("omem-block-style")) return;
61
- const n = t.createElement("style");
62
- n.id = "omem-block-style", n.textContent = Z, t.head.appendChild(n);
85
+ const a = t.createElement("style");
86
+ a.id = "omem-block-style", a.textContent = q, t.head.appendChild(a);
63
87
  }
64
- function e(t, n, a = {}, ...o) {
65
- const i = t.createElement(n);
66
- for (const [b, c] of Object.entries(a))
67
- c === void 0 || c === !1 || (typeof c == "function" ? i.addEventListener(b.replace(/^on/, ""), c) : i.setAttribute(b, c === !0 ? "" : String(c)));
68
- for (const b of o) b != null && b !== !1 && i.append(typeof b == "string" ? t.createTextNode(b) : b);
69
- return i;
88
+ function e(t, a, o = {}, ...i) {
89
+ const n = t.createElement(a);
90
+ for (const [s, d] of Object.entries(o))
91
+ d === void 0 || d === !1 || (typeof d == "function" ? n.addEventListener(s.replace(/^on/, ""), d) : n.setAttribute(s, d === !0 ? "" : String(d)));
92
+ for (const s of i) s != null && s !== !1 && n.append(typeof s == "string" ? t.createTextNode(s) : s);
93
+ return n;
70
94
  }
71
- const F = "http://www.w3.org/2000/svg";
72
- function E(t, n, a = {}, o) {
73
- const i = t.createElementNS(F, n);
74
- for (const [b, c] of Object.entries(a)) i.setAttribute(b, String(c));
75
- return o !== void 0 && (i.textContent = o), i;
95
+ const D = "http://www.w3.org/2000/svg";
96
+ function S(t, a, o = {}, i) {
97
+ const n = t.createElementNS(D, a);
98
+ for (const [s, d] of Object.entries(o)) n.setAttribute(s, String(d));
99
+ return n;
76
100
  }
77
- const D = /* @__PURE__ */ new WeakMap();
78
- function Q(t) {
79
- for (const n of D.get(t) ?? []) n.disconnect();
80
- D.delete(t);
101
+ const w = /* @__PURE__ */ new WeakMap();
102
+ function z(t) {
103
+ for (const a of w.get(t) ?? []) a();
104
+ w.delete(t);
81
105
  }
82
- function at(t, n, a) {
83
- if (!P.includes(n.kind)) return !1;
84
- if (O(t.ownerDocument), Q(t), n.kind === "view") {
85
- const o = n.data, i = e(t.ownerDocument, "section", { class: "ob card pad", "aria-label": o.title || "展示" });
86
- t.replaceChildren(i), o.title && i.append(e(t.ownerDocument, "h3", {}, o.title));
87
- const b = e(t.ownerDocument, "div", { class: "ob" });
88
- return i.append(b), R(b, o.components, a, t), !0;
106
+ function W(t, a, o) {
107
+ if (!A.includes(a.kind)) return !1;
108
+ if (C(t.ownerDocument), z(t), a.kind === "view") {
109
+ const i = a.data, n = e(t.ownerDocument, "section", { class: "ob card pad", "aria-label": i.title || "展示" });
110
+ t.replaceChildren(n), i.title && n.append(e(t.ownerDocument, "h3", {}, i.title));
111
+ const s = e(t.ownerDocument, "div", { class: "ob" });
112
+ return n.append(s), $(s, i.components, o, t), !0;
89
113
  }
90
- return t.replaceChildren(tt(t, n, a)), !0;
114
+ return t.replaceChildren(K(t, a, o)), !0;
91
115
  }
92
- function R(t, n, a = {}, o = t) {
93
- const i = t.ownerDocument;
94
- O(i), o === t && Q(t), t.classList.add("ob"), t.replaceChildren(...n.map((b) => G(i, b, a, o)));
116
+ function $(t, a, o = {}, i = t) {
117
+ const n = t.ownerDocument;
118
+ C(n), i === t && z(t), t.classList.add("ob"), t.replaceChildren(...a.map((s) => I(n, s, o, i)));
95
119
  }
96
- function G(t, n, a, o) {
97
- switch (n.type) {
120
+ function I(t, a, o, i) {
121
+ switch (a.type) {
98
122
  case "markdown":
99
- return T(t, n.text, a);
123
+ return y(t, a.text, o);
100
124
  case "heading":
101
- return e(t, "h4", {}, n.text);
125
+ return e(t, "h4", {}, a.text);
102
126
  case "table":
103
- return J(t, n);
127
+ return V(t, a);
104
128
  case "chart":
105
- return U(t, n, o);
129
+ return G(t, a, i);
106
130
  case "metric":
107
- return e(t, "div", { class: "ob-metrics" }, ...n.items.map((i) => e(t, "div", { class: "ob-metric" }, e(t, "span", { class: "ob-muted" }, i.label), e(t, "b", {}, `${i.value}${i.unit ?? ""}`), i.change ? e(t, "span", { class: "ob-muted" }, i.change) : null)));
131
+ return M(t, { title: a.title, note: a.note, items: a.items.map(({ label: n, value: s, unit: d, change: f, trend: g, good: c, note: p, spark: r }) => ({ label: n, value: s, unit: d, change: f, trend: g, good: c, note: p, spark: r })) });
132
+ case "callout":
133
+ return Z(t, a, o);
108
134
  case "compare":
109
- return e(t, "div", { class: "ob-field" }, n.title ? e(t, "span", { class: "ob-label" }, n.title) : null, e(t, "div", { class: "ob-cards" }, ...n.items.map((i) => H(t, e(t, "div", { class: "ob-pcard" }), i))));
135
+ return e(t, "div", { class: "ob-field" }, a.title ? e(t, "span", { class: "ob-label" }, a.title) : null, e(t, "div", { class: "ob-cards" }, ...a.items.map((n) => N(t, e(t, "div", { class: "ob-pcard" }), n))));
110
136
  case "page":
111
- return e(t, "p", { class: "ob-muted" }, `交互页“${n.title || n.id}”:在 omem 的问答页里打开`);
137
+ return e(t, "p", { class: "ob-muted" }, `交互页“${a.title || a.id}”:在 omem 的问答页里打开`);
112
138
  case "timeline":
113
- return e(t, "ol", { class: "ob-timeline" }, ...n.items.map((i) => e(t, "li", {}, e(t, "time", {}, i.time), e(t, "div", {}, e(t, "div", { class: "ob-label" }, i.title), i.text ? e(t, "p", { class: "ob-muted ob-text" }, i.text) : null))));
139
+ return e(t, "ol", { class: "ob-timeline" }, ...a.items.map((n) => e(t, "li", {}, e(t, "time", {}, n.time), e(t, "div", {}, e(t, "div", { class: "ob-label" }, n.title), n.text ? e(t, "p", { class: "ob-muted ob-text" }, n.text) : null))));
140
+ case "list":
141
+ return B(t, a, o);
142
+ case "fields":
143
+ return e(t, "dl", { class: "ob-kv", style: `--kv: ${a.items.length <= 4 ? a.items.length : a.items.length % 3 === 0 ? 3 : 4}` }, ...a.items.map((n) => e(t, "div", {}, e(t, "dt", {}, n.label), e(t, "dd", {}, n.value))));
144
+ case "fold": {
145
+ const n = y(t, a.text, o);
146
+ return e(t, "details", { class: "ob-fold", open: !!a.open }, e(t, "summary", {}, a.title), n);
147
+ }
148
+ case "image":
149
+ return e(
150
+ t,
151
+ "figure",
152
+ { class: "ob-figure" },
153
+ L(a.url) ? e(t, "img", { src: a.url, alt: a.alt ?? a.caption ?? "", loading: "lazy", referrerpolicy: "no-referrer" }) : e(t, "p", { class: "ob-muted" }, "(图片地址不可用)"),
154
+ a.caption ? e(t, "figcaption", { class: "ob-muted" }, a.caption) : null
155
+ );
114
156
  }
115
157
  }
116
- function T(t, n, a) {
117
- const o = e(t, "div", { class: "ob-md" });
118
- return a.markdown ? a.markdown(o, n) : (o.classList.add("ob-text"), o.textContent = n), o;
158
+ const L = (t) => !!t && /^https?:\/\//i.test(t), j = { info: "accent", success: "ok", warning: "warn", danger: "danger", neutral: "" };
159
+ function B(t, a, o) {
160
+ const i = a.items.map((n) => {
161
+ const s = L(n.url) ? e(t, "a", { href: n.url, target: "_blank", rel: "noopener" }, n.title) : e(t, "span", {}, n.title), d = n.tag ? e(t, "span", { class: `badge ${j[n.tone ?? "neutral"]}` }, n.tag) : null;
162
+ return e(t, "li", {}, e(t, "div", { class: "ob-li-head" }, d, e(t, "span", { class: "ob-li-title" }, s)), n.text ? y(t, n.text, o) : null);
163
+ });
164
+ return e(t, "div", { class: "ob-group" }, a.title ? e(t, "div", { class: "ob-caption" }, a.title) : null, e(t, "ul", { class: "ob-list" }, ...i));
119
165
  }
120
- function H(t, n, a) {
121
- const o = [
122
- e(t, "span", { class: "ob-label" }, a.title),
123
- a.summary ? e(t, "p", { class: "ob-text" }, a.summary) : null,
124
- a.pros?.length ? e(t, "ul", { "aria-label": "优点" }, ...a.pros.map((i) => e(t, "li", { class: "ob-pro" }, i))) : null,
125
- a.cons?.length ? e(t, "ul", { "aria-label": "代价" }, ...a.cons.map((i) => e(t, "li", { class: "ob-con" }, i))) : null
166
+ function y(t, a, o) {
167
+ const i = e(t, "div", { class: "ob-md" });
168
+ return o.markdown ? o.markdown(i, a) : (i.classList.add("ob-text"), i.textContent = a), i;
169
+ }
170
+ function N(t, a, o) {
171
+ const i = [
172
+ e(t, "span", { class: "ob-label" }, o.title),
173
+ o.summary ? e(t, "p", { class: "ob-text" }, o.summary) : null,
174
+ o.pros?.length ? e(t, "ul", { "aria-label": "优点" }, ...o.pros.map((n) => e(t, "li", { class: "ob-pro" }, n))) : null,
175
+ o.cons?.length ? e(t, "ul", { "aria-label": "代价" }, ...o.cons.map((n) => e(t, "li", { class: "ob-con" }, n))) : null
126
176
  ];
127
- return n.append(...o.filter((i) => !!i)), n;
177
+ return a.append(...i.filter((n) => !!n)), a;
178
+ }
179
+ const E = {
180
+ info: "M8 1.5a6.5 6.5 0 1 1 0 13 6.5 6.5 0 0 1 0-13ZM8 7.2v3.8M8 5v.2",
181
+ success: "M8 1.5a6.5 6.5 0 1 1 0 13 6.5 6.5 0 0 1 0-13ZM5.3 8.2l1.8 1.8 3.6-3.8",
182
+ warning: "M8 2 14.5 13.5h-13ZM8 6.5v3.2M8 11.4v.2",
183
+ danger: "M8 1.5a6.5 6.5 0 1 1 0 13 6.5 6.5 0 0 1 0-13ZM5.9 5.9l4.2 4.2M10.1 5.9l-4.2 4.2"
184
+ };
185
+ function Z(t, a, o) {
186
+ const i = a.tone ?? "info", n = S(t, "svg", { viewBox: "0 0 16 16", class: "ob-callout-icon", "aria-hidden": "true" });
187
+ n.append(S(t, "path", { d: E[i] ?? E.info }));
188
+ const s = { info: "说明", success: "达成", warning: "注意", danger: "风险", neutral: "说明" }[i];
189
+ return e(t, "div", { class: "ob-callout", "data-tone": i, role: "note", "aria-label": s }, n, e(t, "div", { class: "ob-callout-body" }, a.title ? e(t, "b", {}, a.title) : null, y(t, a.text, o)));
128
190
  }
129
- const K = (t) => typeof t == "number" || typeof t == "string" && t.trim() !== "" && Number.isFinite(Number(t));
130
- function J(t, n) {
131
- let a = null;
132
- const o = e(t, "tbody"), i = n.columns.map((f, h) => n.rows.length > 0 && n.rows.every((d) => d[h] === null || d[h] === void 0 || d[h] === "" || K(d[h]))), b = () => {
133
- const f = [...n.rows];
134
- if (a) {
135
- const { col: h, dir: d } = a;
136
- f.sort((s, l) => {
137
- const r = s[h], g = l[h];
138
- return (i[h] ? Number(r ?? -1 / 0) - Number(g ?? -1 / 0) : String(r ?? "").localeCompare(String(g ?? ""), "zh-CN")) * d;
191
+ const O = (t) => typeof t == "number" || typeof t == "string" && t.trim() !== "" && Number.isFinite(Number(t));
192
+ function V(t, a) {
193
+ let o = null;
194
+ const i = e(t, "tbody"), n = a.columns.map((g, c) => a.rows.length > 0 && a.rows.every((p) => p[c] === null || p[c] === void 0 || p[c] === "" || O(p[c]))), s = () => {
195
+ const g = [...a.rows];
196
+ if (o) {
197
+ const { col: c, dir: p } = o;
198
+ g.sort((r, l) => {
199
+ const b = r[c], h = l[c];
200
+ return (n[c] ? Number(b ?? -1 / 0) - Number(h ?? -1 / 0) : String(b ?? "").localeCompare(String(h ?? ""), "zh-CN")) * p;
139
201
  });
140
202
  }
141
- o.replaceChildren(...f.map((h) => e(t, "tr", {}, ...n.columns.map((d, s) => e(t, "td", i[s] ? { class: "num" } : {}, h[s] === null || h[s] === void 0 ? "" : String(h[s]))))));
142
- }, c = n.columns.map((f, h) => {
143
- const d = e(t, "th", { scope: "col", "aria-sort": "none" }), s = e(t, "button", { type: "button", title: "排序" }, f);
144
- return s.addEventListener("click", () => {
145
- a = a?.col === h ? a.dir === 1 ? { col: h, dir: -1 } : null : { col: h, dir: 1 }, C.querySelectorAll("th").forEach((l, r) => l.setAttribute("aria-sort", a?.col === r ? a.dir === 1 ? "ascending" : "descending" : "none")), b();
146
- }), d.append(s), d;
147
- }), C = e(t, "thead", {}, e(t, "tr", {}, ...c));
148
- return b(), e(t, "div", { class: "ob-field" }, n.title ? e(t, "span", { class: "ob-label" }, n.title) : null, e(t, "div", { class: "ob-scroll" }, e(t, "table", {}, C, o)), n.note ? e(t, "p", { class: "ob-muted" }, n.note) : null);
149
- }
150
- function U(t, n, a) {
151
- const o = e(t, "div", { class: "ob-field" });
152
- let i = 0;
153
- const b = () => {
154
- const c = Math.max(280, Math.min(900, Math.round(o.clientWidth || a.clientWidth || 600)));
155
- Math.abs(c - i) < 8 || (i = c, o.replaceChildren(...X(t, n, c)));
156
- };
157
- if (b(), typeof ResizeObserver < "u") {
158
- const c = new ResizeObserver(b);
159
- c.observe(o), D.set(a, [...D.get(a) ?? [], c]);
160
- }
161
- return o;
203
+ i.replaceChildren(...g.map((c) => e(t, "tr", {}, ...a.columns.map((p, r) => e(t, "td", n[r] ? { class: "num" } : {}, c[r] === null || c[r] === void 0 ? "" : String(c[r]))))));
204
+ }, d = a.columns.map((g, c) => {
205
+ const p = e(t, "th", { scope: "col", "aria-sort": "none" }), r = e(t, "button", { type: "button", title: "排序" }, g);
206
+ return r.addEventListener("click", () => {
207
+ o = o?.col === c ? o.dir === 1 ? { col: c, dir: -1 } : null : { col: c, dir: 1 }, f.querySelectorAll("th").forEach((l, b) => l.setAttribute("aria-sort", o?.col === b ? o.dir === 1 ? "ascending" : "descending" : "none")), s();
208
+ }), p.append(r), p;
209
+ }), f = e(t, "thead", {}, e(t, "tr", {}, ...d));
210
+ return s(), e(t, "div", { class: "ob-field" }, a.title ? e(t, "span", { class: "ob-label" }, a.title) : null, e(t, "div", { class: "ob-scroll" }, e(t, "table", {}, f, i)), a.note ? e(t, "p", { class: "ob-muted" }, a.note) : null);
162
211
  }
163
- const q = (t) => Math.abs(t) >= 1e3 ? t.toLocaleString() : String(Math.round(t * 100) / 100), A = (t) => `var(--s${t % 6 + 1})`;
164
- function X(t, n, a) {
165
- const o = e(t, "span", { class: "ob-label" }, `${n.title}${n.unit ? `(${n.unit})` : ""}`), i = n.kind === "pie" ? n.series.slice(0, 1) : n.series, b = e(
166
- t,
167
- "details",
168
- {},
169
- e(t, "summary", {}, "看数据"),
170
- e(t, "div", { class: "ob-scroll" }, e(t, "table", {}, e(t, "thead", {}, e(t, "tr", {}, e(t, "th", {}, ""), ...i.map((u) => e(t, "th", {}, u.name)))), e(t, "tbody", {}, ...n.labels.map((u, y) => e(t, "tr", {}, e(t, "th", {}, u), ...i.map((v) => e(t, "td", { class: "num" }, `${q(v.values[y])}${n.unit ?? ""}`)))))))
171
- ), c = n.note ? e(t, "p", { class: "ob-muted" }, n.note) : null;
172
- if (n.kind === "pie") {
173
- const u = i[0].values.map((S) => Math.max(0, S)), y = u.reduce((S, $) => S + $, 0) || 1, v = 180, M = 80, L = v / 2, k = v / 2, N = E(t, "svg", { viewBox: `0 0 ${v} ${v}`, role: "img", "aria-label": n.title, style: `max-width:${v}px` });
174
- let w = -Math.PI / 2;
175
- u.forEach((S, $) => {
176
- const I = w + S / y * Math.PI * 2, B = I - w > Math.PI ? 1 : 0, V = S >= y ? E(t, "circle", { cx: L, cy: k, r: M, fill: A($) }) : E(t, "path", { d: `M${L},${k} L${L + M * Math.cos(w)},${k + M * Math.sin(w)} A${M},${M} 0 ${B} 1 ${L + M * Math.cos(I)},${k + M * Math.sin(I)} Z`, fill: A($), stroke: "var(--panel)", "stroke-width": 1.5 });
177
- V.append(E(t, "title", {}, `${n.labels[$]}:${q(S)}${n.unit ?? ""}(${Math.round(S / y * 100)}%)`)), N.append(V), w = I;
178
- });
179
- const _ = e(t, "div", { class: "ob-legend" }, ...n.labels.map((S, $) => e(t, "span", { class: "ob-key" }, e(t, "i", { style: `background:${A($)}` }), `${S} ${Math.round(u[$] / y * 100)}%`)));
180
- return [o, N, _, c, b].filter((S) => !!S);
181
- }
182
- const C = 200, f = 36, h = 8, d = 10, s = 26, l = i.flatMap((u) => u.values), r = Math.min(0, ...l), g = Math.max(0, ...l) || 1, p = (u) => d + (C - d - s) * (1 - (u - r) / (g - r)), x = (a - f - h) / n.labels.length, m = E(t, "svg", { viewBox: `0 0 ${a} ${C}`, role: "img", "aria-label": `${n.title}${n.unit ? `(${n.unit})` : ""}` });
183
- for (const u of [r, (r + g) / 2, g])
184
- m.append(E(t, "line", { x1: f, x2: a - h, y1: p(u), y2: p(u), class: "ob-grid" })), m.append(E(t, "text", { x: f - 6, y: p(u) + 4, "text-anchor": "end", class: "ob-tick" }, q(u)));
185
- m.append(E(t, "line", { x1: f, x2: a - h, y1: p(0), y2: p(0), class: "ob-axis" }));
186
- const z = Math.max(1, Math.ceil(n.labels.length / Math.max(2, Math.floor(a / 56))));
187
- if (n.labels.forEach((u, y) => {
188
- y % z === 0 && m.append(E(t, "text", { x: f + x * (y + 0.5), y: C - 8, "text-anchor": "middle", class: "ob-tick" }, u.length > 8 ? u.slice(0, 7) + "…" : u));
189
- }), n.kind === "line")
190
- i.forEach((u, y) => {
191
- const v = u.values.map((M, L) => [f + x * (L + 0.5), p(M)]);
192
- m.append(E(t, "polyline", { points: v.map((M) => M.join(",")).join(" "), fill: "none", stroke: A(y), "stroke-width": 2, "stroke-linejoin": "round", "stroke-linecap": "round" })), v.forEach(([M, L], k) => {
193
- const N = E(t, "circle", { cx: M, cy: L, r: 4, fill: A(y), stroke: "var(--panel)", "stroke-width": 2 });
194
- N.append(E(t, "title", {}, `${n.labels[k]} · ${u.name}:${q(u.values[k])}${n.unit ?? ""}`)), m.append(N);
195
- });
196
- });
197
- else {
198
- const u = i.length, y = 2, v = Math.max(2, Math.min(28, (x * 0.7 - y * (u - 1)) / u));
199
- i.forEach((M, L) => {
200
- M.values.forEach((k, N) => {
201
- const w = f + x * (N + 0.5) - (u * v + y * (u - 1)) / 2 + L * (v + y), _ = p(Math.max(k, 0)), S = Math.max(0, Math.abs(p(k) - p(0))), $ = Math.min(4, v / 2, S), I = k >= 0 ? `M${w},${p(0)} V${_ + $} Q${w},${_} ${w + $},${_} H${w + v - $} Q${w + v},${_} ${w + v},${_ + $} V${p(0)} Z` : `M${w},${p(0)} V${p(k) - $} Q${w},${p(k)} ${w + $},${p(k)} H${w + v - $} Q${w + v},${p(k)} ${w + v},${p(k) - $} V${p(0)} Z`, B = E(t, "path", { d: I, fill: A(L) });
202
- B.append(E(t, "title", {}, `${n.labels[N]} · ${M.name}:${q(k)}${n.unit ?? ""}`)), m.append(B);
203
- });
204
- });
205
- }
206
- const j = i.length > 1 ? e(t, "div", { class: "ob-legend" }, ...i.map((u, y) => e(t, "span", { class: "ob-key" }, e(t, "i", { style: `background:${A(y)}` }), u.name))) : null;
207
- return [o, j, m, c, b].filter((u) => !!u);
212
+ function G(t, a, o) {
213
+ const i = e(t, "div", { class: "ob-chart" }), n = _(i, a);
214
+ return w.set(o, [...w.get(o) ?? [], n]), i;
208
215
  }
209
- function Y(t, n) {
216
+ function T(t, a) {
210
217
  if (!t.show_if) return !0;
211
- const a = n[t.show_if.field], o = Array.isArray(a) ? a.map(String) : a == null || a === "" ? [] : [String(a)];
212
- return t.show_if.in ? t.show_if.in.some((i) => o.includes(i)) : t.show_if.equals !== void 0 ? o.includes(String(t.show_if.equals)) : o.length > 0;
218
+ const o = a[t.show_if.field], i = Array.isArray(o) ? o.map(String) : o == null || o === "" ? [] : [String(o)];
219
+ return t.show_if.in ? t.show_if.in.some((n) => i.includes(n)) : t.show_if.equals !== void 0 ? i.includes(String(t.show_if.equals)) : i.length > 0;
213
220
  }
214
- function W(t) {
215
- const n = {};
216
- for (const a of t)
217
- "default" in a && a.default !== void 0 && (n[a.id] = a.default), a.type === "rank" && (n[a.id] = a.items.map((o) => o.id)), a.type === "table" && (n[a.id] = a.rows.length ? a.rows.map((o) => ({ ...o })) : [{}]);
218
- return n;
221
+ function F(t) {
222
+ const a = {};
223
+ for (const o of t)
224
+ "default" in o && o.default !== void 0 && (a[o.id] = o.default), o.type === "rank" && (a[o.id] = o.items.map((i) => i.id)), o.type === "table" && (a[o.id] = o.rows.length ? o.rows.map((i) => ({ ...i })) : [{}]);
225
+ return a;
219
226
  }
220
- function tt(t, n, a) {
221
- const o = t.ownerDocument, i = n.data, b = n.status === "open", c = e(o, "section", { class: "ob card pad", "aria-label": "需要你回答" });
222
- if (c.append(T(o, i.question, a)), i.view?.length) {
223
- const s = e(o, "div", { class: "ob" });
224
- c.append(s), R(s, i.view, a, t);
227
+ function K(t, a, o) {
228
+ const i = t.ownerDocument, n = a.data, s = a.status === "open", d = e(i, "section", { class: "ob card pad", "aria-label": "需要你回答" });
229
+ if (d.append(y(i, n.question, o)), n.view?.length) {
230
+ const r = e(i, "div", { class: "ob" });
231
+ d.append(r), $(r, n.view, o, t);
225
232
  }
226
- const C = e(o, "span", { class: "ob-err", role: "alert" }), f = async (s, l) => {
227
- l && (l.disabled = !0), C.textContent = "";
233
+ const f = e(i, "span", { class: "ob-err", role: "alert" }), g = async (r, l) => {
234
+ l && (l.disabled = !0), f.textContent = "";
228
235
  try {
229
- await a.submit(s);
230
- } catch (r) {
231
- C.textContent = r.message, l && (l.disabled = !1);
236
+ await o.submit(r);
237
+ } catch (b) {
238
+ f.textContent = b.message, l && (l.disabled = !1);
232
239
  }
233
240
  };
234
- if (!b) {
235
- const s = n.result;
236
- return c.append(e(o, "p", { class: "ob-muted" }, s?.cancelled ? "已失效" : "已回答")), s?.answer && c.append(e(o, "p", { class: "ob-value" }, s.answer)), c;
241
+ if (!s) {
242
+ const r = a.result;
243
+ return d.append(e(i, "p", { class: "ob-muted" }, r?.cancelled ? "已失效" : "已回答")), r?.answer && d.append(e(i, "p", { class: "ob-value" }, r.answer)), d;
237
244
  }
238
- const h = { ...W(i.fields ?? []) }, d = i.allowText ? e(o, i.fields?.length ? "textarea" : "input", { class: i.fields?.length ? "textarea" : "input", rows: 2, placeholder: i.fields?.length ? "补充说明(可不填)" : i.options.length ? "也可以写别的回答" : "你的回答", "aria-label": "文字回答" }) : null;
239
- if (i.fields?.length) {
240
- const s = e(o, "div", { class: "ob" }), l = () => s.replaceChildren(...i.fields.filter((g) => Y(g, h)).map((g) => et(o, n.id, g, h, l)));
241
- l(), c.append(s), d && c.append(d);
242
- const r = e(o, "button", { type: "button", class: "btn primary" }, i.submitLabel || "提交");
243
- return r.addEventListener("click", () => f({ value: h, ...d?.value.trim() ? { text: d.value.trim() } : {} }, r)), c.append(e(o, "div", { class: "ob-foot" }, C, e(o, "span", { class: "ob-spacer" }), r)), c;
245
+ const c = { ...F(n.fields ?? []) }, p = n.allowText ? e(i, n.fields?.length ? "textarea" : "input", { class: n.fields?.length ? "textarea" : "input", rows: 2, placeholder: n.fields?.length ? "补充说明(可不填)" : n.options.length ? "也可以写别的回答" : "你的回答", "aria-label": "文字回答" }) : null;
246
+ if (n.fields?.length) {
247
+ const r = e(i, "div", { class: "ob" }), l = () => r.replaceChildren(...n.fields.filter((h) => T(h, c)).map((h) => R(i, a.id, h, c, l)));
248
+ l(), d.append(r), p && d.append(p);
249
+ const b = e(i, "button", { type: "button", class: "btn primary" }, n.submitLabel || "提交");
250
+ return b.addEventListener("click", () => g({ value: c, ...p?.value.trim() ? { text: p.value.trim() } : {} }, b)), d.append(e(i, "div", { class: "ob-foot" }, f, e(i, "span", { class: "ob-spacer" }), b)), d;
244
251
  }
245
- if (i.options.length && c.append(e(o, "div", { class: "ob-options" }, ...i.options.map((s, l) => {
246
- const r = e(o, "button", { type: "button", class: `btn sm${l === 0 ? " primary" : ""}` }, s.label);
247
- return r.addEventListener("click", () => f({ choice: l, ...d?.value.trim() ? { text: d.value.trim() } : {} }, r)), r;
248
- }))), d) {
249
- const s = e(o, "button", { type: "button", class: "btn sm" }, "回答");
250
- s.addEventListener("click", () => d.value.trim() && f({ text: d.value.trim() }, s)), c.append(e(o, "div", { class: "ob-foot" }, d, s));
252
+ if (n.options.length && d.append(e(i, "div", { class: "ob-options" }, ...n.options.map((r, l) => {
253
+ const b = e(i, "button", { type: "button", class: `btn sm${l === 0 ? " primary" : ""}` }, r.label);
254
+ return b.addEventListener("click", () => g({ choice: l, ...p?.value.trim() ? { text: p.value.trim() } : {} }, b)), b;
255
+ }))), p) {
256
+ const r = e(i, "button", { type: "button", class: "btn sm" }, "回答");
257
+ r.addEventListener("click", () => p.value.trim() && g({ text: p.value.trim() }, r)), d.append(e(i, "div", { class: "ob-foot" }, p, r));
251
258
  }
252
- return c.append(C), c;
259
+ return d.append(f), d;
253
260
  }
254
- function et(t, n, a, o, i) {
255
- const b = `ob-${n}-${a.id}`, c = e(t, "span", { class: "ob-label", id: b }, a.label, a.required ? e(t, "span", { class: "ob-req", "aria-hidden": "true" }, "*") : null), C = a.help ? e(t, "span", { class: "ob-muted" }, a.help) : null, f = (s, l = !1) => {
256
- o[a.id] = s, l && i();
257
- }, h = !0;
258
- let d;
259
- switch (a.type) {
261
+ function R(t, a, o, i, n) {
262
+ const s = `ob-${a}-${o.id}`, d = e(t, "span", { class: "ob-label", id: s }, o.label, o.required ? e(t, "span", { class: "ob-req", "aria-hidden": "true" }, "*") : null), f = o.help ? e(t, "span", { class: "ob-muted" }, o.help) : null, g = (r, l = !1) => {
263
+ i[o.id] = r, l && n();
264
+ }, c = !0;
265
+ let p;
266
+ switch (o.type) {
260
267
  case "textarea":
261
- d = e(t, "textarea", { class: "textarea", rows: 3, placeholder: a.placeholder, "aria-labelledby": b, oninput: (s) => f(s.target.value) }), d.value = String(o[a.id] ?? "");
268
+ p = e(t, "textarea", { class: "textarea", rows: 3, placeholder: o.placeholder, "aria-labelledby": s, oninput: (r) => g(r.target.value) }), p.value = String(i[o.id] ?? "");
262
269
  break;
263
270
  case "text":
264
271
  case "number":
265
272
  case "date":
266
273
  case "datetime": {
267
- const s = a.type === "datetime" ? "datetime-local" : a.type;
268
- d = e(t, "input", { class: "input", type: s, placeholder: "placeholder" in a ? a.placeholder : void 0, min: "min" in a ? a.min : void 0, max: "max" in a ? a.max : void 0, "aria-labelledby": b, oninput: (l) => f(l.target.value), onchange: () => i() }), d.value = String(o[a.id] ?? "");
274
+ const r = o.type === "datetime" ? "datetime-local" : o.type;
275
+ p = e(t, "input", { class: "input", type: r, placeholder: "placeholder" in o ? o.placeholder : void 0, min: "min" in o ? o.min : void 0, max: "max" in o ? o.max : void 0, "aria-labelledby": s, oninput: (l) => g(l.target.value), onchange: () => n() }), p.value = String(i[o.id] ?? "");
269
276
  break;
270
277
  }
271
278
  case "toggle": {
272
- const s = e(t, "button", { type: "button", class: "btn sm ob-opt", "aria-pressed": String(!!o[a.id]), "aria-labelledby": b }, o[a.id] ? "是" : "否");
273
- s.addEventListener("click", () => f(!o[a.id], h)), d = s;
279
+ const r = e(t, "button", { type: "button", class: "btn sm ob-opt", "aria-pressed": String(!!i[o.id]), "aria-labelledby": s }, i[o.id] ? "是" : "否");
280
+ r.addEventListener("click", () => g(!i[o.id], c)), p = r;
274
281
  break;
275
282
  }
276
283
  case "pick":
277
- d = e(t, "div", { class: "ob-cards", role: "radiogroup", "aria-labelledby": b }, ...a.items.map((s) => {
278
- const l = H(t, e(t, "button", { type: "button", role: "radio", class: "ob-pcard", "aria-checked": String(o[a.id] === s.id) }), s);
279
- return l.addEventListener("click", () => f(s.id, h)), l;
284
+ p = e(t, "div", { class: "ob-cards", role: "radiogroup", "aria-labelledby": s }, ...o.items.map((r) => {
285
+ const l = N(t, e(t, "button", { type: "button", role: "radio", class: "ob-pcard", "aria-checked": String(i[o.id] === r.id) }), r);
286
+ return l.addEventListener("click", () => g(r.id, c)), l;
280
287
  }));
281
288
  break;
282
289
  case "rank": {
283
- const s = o[a.id];
284
- d = e(t, "ol", { class: "ob-rank", "aria-labelledby": b }, ...s.map((l, r) => {
285
- const g = a.items.find((x) => x.id === l), p = (x) => {
286
- const m = [...s];
287
- [m[r], m[r + x]] = [m[r + x], m[r]], f(m, !0);
290
+ const r = i[o.id];
291
+ p = e(t, "ol", { class: "ob-rank", "aria-labelledby": s }, ...r.map((l, b) => {
292
+ const h = o.items.find((x) => x.id === l), m = (x) => {
293
+ const u = [...r];
294
+ [u[b], u[b + x]] = [u[b + x], u[b]], g(u, !0);
288
295
  };
289
- return e(t, "li", { class: "ob-check" }, e(t, "span", {}, `${r + 1}. ${g.title}`), e(
296
+ return e(t, "li", { class: "ob-check" }, e(t, "span", {}, `${b + 1}. ${h.title}`), e(
290
297
  t,
291
298
  "span",
292
299
  { class: "ob-options" },
293
- e(t, "button", { type: "button", class: "btn sm", disabled: r === 0, "aria-label": `${g.title} 上移`, onclick: () => p(-1) }, "上移"),
294
- e(t, "button", { type: "button", class: "btn sm", disabled: r === s.length - 1, "aria-label": `${g.title} 下移`, onclick: () => p(1) }, "下移")
300
+ e(t, "button", { type: "button", class: "btn sm", disabled: b === 0, "aria-label": `${h.title} 上移`, onclick: () => m(-1) }, "上移"),
301
+ e(t, "button", { type: "button", class: "btn sm", disabled: b === r.length - 1, "aria-label": `${h.title} 下移`, onclick: () => m(1) }, "下移")
295
302
  ));
296
303
  }));
297
304
  break;
298
305
  }
299
306
  case "table": {
300
- const s = o[a.id], l = e(t, "tr", {}, ...a.columns.map((p) => e(t, "th", {}, p.label)), e(t, "th", {}, "")), r = s.map((p, x) => e(t, "tr", {}, ...a.columns.map((m) => {
301
- const z = m.type === "choice" ? e(t, "select", { class: "input", "aria-label": `第 ${x + 1} 行 ${m.label}` }, e(t, "option", { value: "" }, ""), ...(m.options ?? []).map((j) => e(t, "option", { value: j }, j))) : e(t, "input", { class: "input", type: m.type === "number" ? "number" : "text", "aria-label": `第 ${x + 1} 行 ${m.label}` });
302
- return z.value = p[m.id] == null ? "" : String(p[m.id]), z.addEventListener("input", () => p[m.id] = z.value), e(t, "td", {}, z);
303
- }), e(t, "td", {}, e(t, "button", { type: "button", class: "btn sm", "aria-label": `删除第 ${x + 1} 行`, onclick: () => f(s.filter((m, z) => z !== x), !0) }, "删除")))), g = e(t, "button", { type: "button", class: "btn sm", disabled: s.length >= a.max_rows, onclick: () => f([...s, {}], !0) }, "加一行");
304
- d = e(t, "div", { class: "ob-field" }, e(t, "div", { class: "ob-scroll" }, e(t, "table", { "aria-labelledby": b }, e(t, "thead", {}, l), e(t, "tbody", {}, ...r))), g);
307
+ const r = i[o.id], l = e(t, "tr", {}, ...o.columns.map((m) => e(t, "th", {}, m.label)), e(t, "th", {}, "")), b = r.map((m, x) => e(t, "tr", {}, ...o.columns.map((u) => {
308
+ const v = u.type === "choice" ? e(t, "select", { class: "input", "aria-label": `第 ${x + 1} 行 ${u.label}` }, e(t, "option", { value: "" }, ""), ...(u.options ?? []).map((k) => e(t, "option", { value: k }, k))) : e(t, "input", { class: "input", type: u.type === "number" ? "number" : "text", "aria-label": `第 ${x + 1} 行 ${u.label}` });
309
+ return v.value = m[u.id] == null ? "" : String(m[u.id]), v.addEventListener("input", () => m[u.id] = v.value), e(t, "td", {}, v);
310
+ }), e(t, "td", {}, e(t, "button", { type: "button", class: "btn sm", "aria-label": `删除第 ${x + 1} 行`, onclick: () => g(r.filter((u, v) => v !== x), !0) }, "删除")))), h = e(t, "button", { type: "button", class: "btn sm", disabled: r.length >= o.max_rows, onclick: () => g([...r, {}], !0) }, "加一行");
311
+ p = e(t, "div", { class: "ob-field" }, e(t, "div", { class: "ob-scroll" }, e(t, "table", { "aria-labelledby": s }, e(t, "thead", {}, l), e(t, "tbody", {}, ...b))), h);
305
312
  break;
306
313
  }
307
314
  case "checklist": {
308
- const s = o[a.id] ?? {};
309
- o[a.id] = s, d = e(t, "div", { role: "group", "aria-labelledby": b }, ...a.items.map((l) => {
310
- const r = e(t, "div", { class: "ob-check" }, e(t, "span", {}, l.title), l.detail ? e(t, "span", { class: "ob-muted ob-text" }, l.detail) : null), g = e(t, "div", { class: "ob-options", role: "radiogroup", "aria-label": l.title }, ...a.choices.map((p) => {
311
- const x = e(t, "button", { type: "button", role: "radio", class: "btn sm ob-opt", "aria-checked": String(s[l.id]?.choice === p) }, p);
315
+ const r = i[o.id] ?? {};
316
+ i[o.id] = r, p = e(t, "div", { role: "group", "aria-labelledby": s }, ...o.items.map((l) => {
317
+ const b = e(t, "div", { class: "ob-check" }, e(t, "span", {}, l.title), l.detail ? e(t, "span", { class: "ob-muted ob-text" }, l.detail) : null), h = e(t, "div", { class: "ob-options", role: "radiogroup", "aria-label": l.title }, ...o.choices.map((m) => {
318
+ const x = e(t, "button", { type: "button", role: "radio", class: "btn sm ob-opt", "aria-checked": String(r[l.id]?.choice === m) }, m);
312
319
  return x.addEventListener("click", () => {
313
- s[l.id] = { ...s[l.id], choice: p }, g.querySelectorAll("button").forEach((m) => m.setAttribute("aria-checked", String(m.textContent === p)));
320
+ r[l.id] = { ...r[l.id], choice: m }, h.querySelectorAll("button").forEach((u) => u.setAttribute("aria-checked", String(u.textContent === m)));
314
321
  }), x;
315
322
  }));
316
- if (r.append(g), a.note) {
317
- const p = e(t, "input", { class: "input", placeholder: "备注(可不填)", "aria-label": `${l.title} 的备注` });
318
- p.value = s[l.id]?.note ?? "", p.addEventListener("input", () => s[l.id] = { choice: s[l.id]?.choice ?? "", note: p.value }), r.append(p);
323
+ if (b.append(h), o.note) {
324
+ const m = e(t, "input", { class: "input", placeholder: "备注(可不填)", "aria-label": `${l.title} 的备注` });
325
+ m.value = r[l.id]?.note ?? "", m.addEventListener("input", () => r[l.id] = { choice: r[l.id]?.choice ?? "", note: m.value }), b.append(m);
319
326
  }
320
- return r;
327
+ return b;
321
328
  }));
322
329
  break;
323
330
  }
324
331
  default: {
325
- const s = a.type === "scale" ? ["1", "2", "3", "4", "5"] : a.options, l = a.type === "multi";
326
- d = e(t, "div", { class: "ob-options", role: l ? "group" : "radiogroup", "aria-labelledby": b }, ...s.map((r) => {
327
- const g = o[a.id], p = l ? (g ?? []).includes(r) : String(g ?? "") === r, x = e(t, "button", { type: "button", class: "btn sm ob-opt", ...l ? { "aria-pressed": String(p) } : { role: "radio", "aria-checked": String(p) } }, r);
332
+ const r = o.type === "scale" ? ["1", "2", "3", "4", "5"] : o.options, l = o.type === "multi";
333
+ p = e(t, "div", { class: "ob-options", role: l ? "group" : "radiogroup", "aria-labelledby": s }, ...r.map((b) => {
334
+ const h = i[o.id], m = l ? (h ?? []).includes(b) : String(h ?? "") === b, x = e(t, "button", { type: "button", class: "btn sm ob-opt", ...l ? { "aria-pressed": String(m) } : { role: "radio", "aria-checked": String(m) } }, b);
328
335
  return x.addEventListener("click", () => {
329
336
  if (l) {
330
- const m = new Set(o[a.id] ?? []);
331
- m.has(r) ? m.delete(r) : m.add(r), f([...m], h);
332
- } else f(a.type === "scale" ? Number(r) : r, h);
337
+ const u = new Set(i[o.id] ?? []);
338
+ u.has(b) ? u.delete(b) : u.add(b), g([...u], c);
339
+ } else g(o.type === "scale" ? Number(b) : b, c);
333
340
  }), x;
334
341
  }));
335
342
  }
336
343
  }
337
- return e(t, "div", { class: "ob-field" }, c, C, d);
344
+ return e(t, "div", { class: "ob-field" }, d, f, p);
338
345
  }
339
346
  export {
340
- P as GENERIC_KINDS,
341
- Y as fieldVisible,
342
- W as initialValues,
343
- at as renderBlock,
344
- R as renderView
347
+ A as GENERIC_KINDS,
348
+ T as fieldVisible,
349
+ F as initialValues,
350
+ W as renderBlock,
351
+ $ as renderView
345
352
  };