@burdenoff/microfe-bigconsole 2026.1119.3 → 2026.1119.4

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.
@@ -5,7 +5,8 @@
5
5
  * seam that will swap to the backend operation from BOFF-3021, and
6
6
  * `CustomWidgetProposalPanel` is the review/approve UI.
7
7
  */
8
- export { CUSTOM_WIDGET_PROPOSAL_VERSION, PROPOSABLE_WIDGET_TYPES, derivePreviewState, isProposableWidgetType, validateProposal, type CustomWidgetProposal, type ProposableWidgetType, type ProposalBinding, type ProposalFieldMapping, type ProposalIssue, type ProposalIssueCode, type ProposalPresentation, type ProposalPreviewState, type ProposalValidation, type ValidateProposalContext, } from './proposalContract';
8
+ export { CUSTOM_WIDGET_PROPOSAL_VERSION, PROPOSABLE_WIDGET_TYPES, derivePreviewState, isProposableWidgetType, mappedFields, validateProposal, withoutNotices, type CustomWidgetProposal, type ProposableWidgetType, type ProposalBinding, type ProposalFieldMapping, type ProposalIssue, type ProposalIssueCode, type ProposalNotice, type ProposalNoticeCode, type ProposalSinkNoticeFields, type ProposalPresentation, type ProposalPreviewState, type ProposalValidation, type ValidateProposalContext, } from './proposalContract';
9
9
  export { localProposalSource, type CustomWidgetProposalSource, type ProposalCandidateParser, type ProposalCandidateSink, type ProposalRequest, } from './proposalSource';
10
+ export { describeProposalPreviewData, type ProposalPreviewData } from './proposalPreviewData';
10
11
  export { CustomWidgetProposalPanel, type CustomWidgetProposalPanelProps } from './CustomWidgetProposalPanel';
11
12
  export { CustomWidgetBuilderSheet, type CustomWidgetBuilderSheetProps } from './CustomWidgetBuilderSheet';
@@ -1,4 +1,5 @@
1
1
  import "./proposalContract.js";
2
2
  import "./proposalSource.js";
3
+ import "./proposalPreviewData.js";
3
4
  import "./CustomWidgetProposalPanel.js";
4
5
  export { CustomWidgetBuilderSheet } from "./CustomWidgetBuilderSheet.js";
@@ -48,8 +48,54 @@ export interface ProposalBinding {
48
48
  /**
49
49
  * Which fields of the parsed rows feed which visual role. Keys are role names
50
50
  * (`xAxisField`, `valueField`, …); values are field names in the parser output.
51
+ * An empty value means "let the renderer detect it" (e.g. retention reads
52
+ * `cohort` / `period` / `value` and their common aliases by default).
51
53
  */
52
54
  export type ProposalFieldMapping = Record<string, string>;
55
+ /** The roles a reviewer actually set, without the empty "auto-detect" ones. */
56
+ export declare function mappedFields(mapping: ProposalFieldMapping): ProposalFieldMapping;
57
+ /** What a sink notice knows about the preselected sink and parser. */
58
+ export interface ProposalSinkNoticeFields {
59
+ /** Stable sink key (for export/import and tests). */
60
+ sinkKey: string;
61
+ /** Display name the DataSink picker shows (falls back to the key). */
62
+ sinkName: string;
63
+ /** Preselected parser, when the sink has one. */
64
+ parserName?: string;
65
+ /** True only when the prompt or widget type named the parser; false when it is the sink's first parser. */
66
+ parserMatched: boolean;
67
+ }
68
+ /**
69
+ * Structured facts about how a proposal was derived, for the reviewer. They
70
+ * carry codes and values rather than prose so the panel can translate them.
71
+ */
72
+ export type ProposalNotice =
73
+ /** The prompt named the sink. */
74
+ ({
75
+ code: 'DATASINK_MATCHED';
76
+ } & ProposalSinkNoticeFields)
77
+ /** Nothing in the prompt matched a sink: the first permitted one was preselected. */
78
+ | ({
79
+ code: 'DATASINK_DEFAULTED';
80
+ } & ProposalSinkNoticeFields)
81
+ /** The workspace has no sink the user may bind to. */
82
+ | {
83
+ code: 'NO_DATASINK';
84
+ }
85
+ /** The prompt asked for a widget type the builder cannot render; another was used. */
86
+ | {
87
+ code: 'WIDGET_TYPE_SUBSTITUTED';
88
+ requestedType: string;
89
+ widgetType: ProposableWidgetType;
90
+ };
91
+ export type ProposalNoticeCode = ProposalNotice['code'];
92
+ /** Notices that describe the generated sink/parser binding. */
93
+ export declare const BINDING_NOTICE_CODES: readonly ProposalNoticeCode[];
94
+ /**
95
+ * Drops notices a human edit has made stale (a generated explanation no longer
96
+ * describes a binding or type the reviewer changed).
97
+ */
98
+ export declare function withoutNotices(proposal: CustomWidgetProposal, codes: readonly ProposalNoticeCode[]): CustomWidgetProposal;
53
99
  /** Presentation settings the reviewer can edit before approving. */
54
100
  export interface ProposalPresentation {
55
101
  title: string;
@@ -72,6 +118,8 @@ export interface CustomWidgetProposal {
72
118
  presentation: ProposalPresentation;
73
119
  /** Optional short plain-language rationale shown to the reviewer. */
74
120
  rationale?: string;
121
+ /** Structured, translatable facts about how the proposal was derived. */
122
+ notices?: ProposalNotice[];
75
123
  }
76
124
  export type ProposalIssueCode = 'UNSUPPORTED_WIDGET_TYPE' | 'MISSING_DATASINK' | 'DATASINK_NOT_PERMITTED' | 'MISSING_PARSER' | 'PARSER_NOT_PERMITTED' | 'FIELD_MISMATCH' | 'MISSING_TITLE' | 'UNSAFE_CONTENT' | 'VERSION_UNSUPPORTED';
77
125
  export interface ProposalIssue {
@@ -99,9 +147,15 @@ export interface ValidateProposalContext {
99
147
  permittedParserIds: readonly string[];
100
148
  /**
101
149
  * Field names present in the parser's actual output, when known. When
102
- * undefined the field mapping is not checked (preview has not resolved yet).
150
+ * undefined the field mapping is not checked (preview has not resolved yet,
151
+ * or the data has a fixed structure the mapping does not apply to).
103
152
  */
104
153
  availableFields?: readonly string[];
154
+ /**
155
+ * Mapping roles left to auto-detection that the renderer could not resolve
156
+ * against the actual data (e.g. retention rows without a cohort column).
157
+ */
158
+ unresolvedRoles?: readonly string[];
105
159
  }
106
160
  /**
107
161
  * Validates a proposal against what the current user is actually permitted to
@@ -9,7 +9,21 @@ var e = [
9
9
  function t(t) {
10
10
  return typeof t == "string" && e.includes(t);
11
11
  }
12
- var n = /* @__PURE__ */ new Set([
12
+ function n(e) {
13
+ return Object.fromEntries(Object.entries(e).filter(([, e]) => e.trim().length > 0));
14
+ }
15
+ var r = [
16
+ "DATASINK_MATCHED",
17
+ "DATASINK_DEFAULTED",
18
+ "NO_DATASINK"
19
+ ];
20
+ function i(e, t) {
21
+ return e.notices?.some((e) => t.includes(e.code)) ? {
22
+ ...e,
23
+ notices: e.notices.filter((e) => !t.includes(e.code))
24
+ } : e;
25
+ }
26
+ var a = /* @__PURE__ */ new Set([
13
27
  "html",
14
28
  "iframeUrl",
15
29
  "script",
@@ -18,27 +32,27 @@ var n = /* @__PURE__ */ new Set([
18
32
  "srcDoc",
19
33
  "onClick"
20
34
  ]);
21
- function r(e) {
35
+ function o(e) {
22
36
  let t = e.trim().toLowerCase().replace(/\s+/g, "");
23
37
  return t.startsWith("javascript:") || t.startsWith("data:text/html") || t.includes("<script") || /\son[a-z]+=/.test(e.toLowerCase());
24
38
  }
25
- function i(e, t, a = "config") {
26
- for (let [o, s] of Object.entries(e)) {
27
- let e = `${a}.${o}`;
28
- n.has(o) ? t.push({
39
+ function s(e, t, n = "config") {
40
+ for (let [r, i] of Object.entries(e)) {
41
+ let e = `${n}.${r}`;
42
+ a.has(r) ? t.push({
29
43
  code: "UNSAFE_CONTENT",
30
44
  severity: "error",
31
- message: `"${o}" is not allowed — generated widgets must use the declarative rendering model.`,
45
+ message: `"${r}" is not allowed — generated widgets must use the declarative rendering model.`,
32
46
  path: e
33
- }) : typeof s == "string" && r(s) ? t.push({
47
+ }) : typeof i == "string" && o(i) ? t.push({
34
48
  code: "UNSAFE_CONTENT",
35
49
  severity: "error",
36
- message: `"${o}" contains executable or remote content, which is not permitted.`,
50
+ message: `"${r}" contains executable or remote content, which is not permitted.`,
37
51
  path: e
38
- }) : s && typeof s == "object" && !Array.isArray(s) && i(s, t, e);
52
+ }) : i && typeof i == "object" && !Array.isArray(i) && s(i, t, e);
39
53
  }
40
54
  }
41
- function a(e, n) {
55
+ function c(e, n) {
42
56
  let r = [];
43
57
  if (e.version !== "1.0" && r.push({
44
58
  code: "VERSION_UNSUPPORTED",
@@ -84,12 +98,21 @@ function a(e, n) {
84
98
  path: `fieldMapping.${n}`
85
99
  });
86
100
  }
87
- return i(e.presentation.config, r), {
101
+ for (let e of n.unresolvedRoles ?? []) {
102
+ let t = `fieldMapping.${e}`;
103
+ r.some((e) => e.path === t) || r.push({
104
+ code: "FIELD_MISMATCH",
105
+ severity: "error",
106
+ message: `No field for ${e} was found in the parser output — pick one.`,
107
+ path: t
108
+ });
109
+ }
110
+ return s(e.presentation.config, r), {
88
111
  issues: r,
89
112
  canApprove: !r.some((e) => e.severity === "error")
90
113
  };
91
114
  }
92
- function o(e, t) {
115
+ function l(e, t) {
93
116
  return t.loading ? "loading" : t.accessError || e.issues.some((e) => e.code === "DATASINK_NOT_PERMITTED" || e.code === "PARSER_NOT_PERMITTED") ? "access-error" : e.issues.some((e) => e.code === "FIELD_MISMATCH") ? "field-mismatch" : t.rowCount ? "valid" : "no-data";
94
117
  }
95
- export { e as PROPOSABLE_WIDGET_TYPES, o as derivePreviewState, t as isProposableWidgetType, a as validateProposal };
118
+ export { r as BINDING_NOTICE_CODES, e as PROPOSABLE_WIDGET_TYPES, l as derivePreviewState, t as isProposableWidgetType, n as mappedFields, c as validateProposal, i as withoutNotices };
@@ -0,0 +1,18 @@
1
+ import { ProposableWidgetType, ProposalFieldMapping } from './proposalContract';
2
+ export interface ProposalPreviewData {
3
+ /**
4
+ * Field names the mapping is checked against. Undefined when nothing is
5
+ * known yet or when the data has a fixed structure the mapping does not
6
+ * apply to (pre-shaped retention, a heatmap matrix).
7
+ */
8
+ fields?: string[];
9
+ /** Auto-detected mapping roles the renderer could not resolve in the data. */
10
+ unresolvedRoles: string[];
11
+ /** Rows the renderer will actually draw. */
12
+ rowCount: number;
13
+ }
14
+ /**
15
+ * Describes resolved preview data for a widget type. Absent data (the preview
16
+ * has not resolved) yields no fields, so the mapping is not checked yet.
17
+ */
18
+ export declare function describeProposalPreviewData(widgetType: ProposableWidgetType, data: unknown, fieldMapping: ProposalFieldMapping): ProposalPreviewData;
@@ -0,0 +1,70 @@
1
+ import { findRows as e } from "../utils/globalFilterMatching.js";
2
+ import { isHeatmapShape as t } from "../utils/widgetSampleShapes.js";
3
+ import { isShapedRetentionData as n, retentionFieldsFromConfig as r, retentionRows as i, tryNormalizeRetention as a } from "../components/widgets/retention/normalizeRetention.js";
4
+ // src/bigconsole/customWidget/proposalPreviewData.ts
5
+ var o = {
6
+ fields: void 0,
7
+ unresolvedRoles: [],
8
+ rowCount: 0
9
+ }, s = /^\d+$/;
10
+ function c(e) {
11
+ return typeof e == "object" && !!e && !Array.isArray(e);
12
+ }
13
+ function l(e) {
14
+ if (!c(e)) return !1;
15
+ let t = Object.keys(e);
16
+ return t.length > 0 && !t.every((e) => s.test(e));
17
+ }
18
+ function u(e) {
19
+ let t = /* @__PURE__ */ new Set();
20
+ for (let n of e) for (let e of Object.keys(n)) t.add(e);
21
+ return [...t];
22
+ }
23
+ function d(e, t) {
24
+ if (n(e)) return {
25
+ fields: void 0,
26
+ unresolvedRoles: [],
27
+ rowCount: a(e).data?.cohorts.length ?? 0
28
+ };
29
+ let s = i(e);
30
+ if (!s) return o;
31
+ let c = s.filter(l);
32
+ if (c.length === 0) return {
33
+ ...o,
34
+ fields: []
35
+ };
36
+ let d = a(s, r(t));
37
+ return d.error?.code === "missing_fields" ? {
38
+ fields: u(c),
39
+ unresolvedRoles: [...d.error.fields],
40
+ rowCount: c.length
41
+ } : {
42
+ fields: u(c),
43
+ unresolvedRoles: [],
44
+ rowCount: d.data?.cohorts.length ?? 0
45
+ };
46
+ }
47
+ function f(n, r, i) {
48
+ if (r == null) return o;
49
+ if (n === "retention") return d(r, i);
50
+ if (n === "heatmap" && t(r) && c(r) && Array.isArray(r.cells)) return {
51
+ fields: void 0,
52
+ unresolvedRoles: [],
53
+ rowCount: r.cells.length
54
+ };
55
+ let a = e(r, n).filter(l);
56
+ return a.length > 0 ? {
57
+ fields: u(a),
58
+ unresolvedRoles: [],
59
+ rowCount: a.length
60
+ } : n === "metric_card" && l(r) ? {
61
+ fields: Object.keys(r),
62
+ unresolvedRoles: [],
63
+ rowCount: 1
64
+ } : {
65
+ fields: c(r) || Array.isArray(r) ? [] : void 0,
66
+ unresolvedRoles: [],
67
+ rowCount: 0
68
+ };
69
+ }
70
+ export { f as describeProposalPreviewData };
@@ -32,10 +32,20 @@ export interface CustomWidgetProposalSource {
32
32
  readonly id: string;
33
33
  propose(request: ProposalRequest): Promise<CustomWidgetProposal>;
34
34
  }
35
+ interface DetectedWidgetType {
36
+ widgetType: ProposableWidgetType;
37
+ /** Set when the prompt asked for a visualisation the builder cannot render. */
38
+ unsupportedRequest?: string;
39
+ }
40
+ /** Exported for tests: the type a prompt asks for, and any unsupported request in it. */
41
+ export declare function detectWidgetType(prompt: string): DetectedWidgetType;
35
42
  /** Keep shared human edits while removing mappings the new renderer cannot use. */
36
43
  export declare function changeProposalWidgetType(proposal: CustomWidgetProposal, widgetType: ProposableWidgetType): CustomWidgetProposal;
44
+ /** Turns the prompt's first sentence into a widget title. Exported for tests. */
45
+ export declare function deriveTitle(prompt: string): string;
37
46
  /**
38
47
  * Derives a proposal from the prompt and the workspace's real, permitted sinks
39
48
  * and parsers. Deterministic, so the review UI and its tests behave predictably.
40
49
  */
41
50
  export declare const localProposalSource: CustomWidgetProposalSource;
51
+ export {};
@@ -1,13 +1,13 @@
1
- import { PROPOSABLE_WIDGET_TYPES as e } from "./proposalContract.js";
1
+ import { PROPOSABLE_WIDGET_TYPES as e, withoutNotices as t } from "./proposalContract.js";
2
2
  // src/bigconsole/customWidget/proposalSource.ts
3
- function t(e) {
3
+ function n(e) {
4
4
  return e.filter((e) => !e.deletedAt && e.isActive !== !1).map(({ id: e, key: t, name: n }) => ({
5
5
  id: e,
6
6
  key: t,
7
7
  name: n
8
8
  }));
9
9
  }
10
- var n = [
10
+ var r = [
11
11
  {
12
12
  type: "funnel_chart",
13
13
  words: [
@@ -38,7 +38,7 @@ var n = [
38
38
  words: [
39
39
  "table",
40
40
  "list of",
41
- "rows",
41
+ "row",
42
42
  "breakdown table",
43
43
  "grid"
44
44
  ]
@@ -66,7 +66,102 @@ var n = [
66
66
  "graph"
67
67
  ]
68
68
  }
69
- ], r = [
69
+ ], i = [
70
+ {
71
+ label: "Sankey diagram",
72
+ words: ["sankey"]
73
+ },
74
+ {
75
+ label: "Treemap",
76
+ words: ["treemap", "tree map"]
77
+ },
78
+ {
79
+ label: "Sunburst chart",
80
+ words: ["sunburst"]
81
+ },
82
+ {
83
+ label: "Gauge",
84
+ words: ["gauge", "speedometer"]
85
+ },
86
+ {
87
+ label: "Scatter plot",
88
+ words: ["scatter", "scatterplot"]
89
+ },
90
+ {
91
+ label: "Bubble chart",
92
+ words: ["bubble chart", "bubble"]
93
+ },
94
+ {
95
+ label: "Radar chart",
96
+ words: ["radar", "spider chart"]
97
+ },
98
+ {
99
+ label: "Candlestick chart",
100
+ words: ["candlestick", "ohlc"]
101
+ },
102
+ {
103
+ label: "Gantt chart",
104
+ words: ["gantt"]
105
+ },
106
+ {
107
+ label: "Timeline",
108
+ words: ["timeline"]
109
+ },
110
+ {
111
+ label: "Waterfall chart",
112
+ words: ["waterfall"]
113
+ },
114
+ {
115
+ label: "Box plot",
116
+ words: [
117
+ "box plot",
118
+ "boxplot",
119
+ "box and whisker"
120
+ ]
121
+ },
122
+ {
123
+ label: "Histogram",
124
+ words: ["histogram"]
125
+ },
126
+ {
127
+ label: "Map",
128
+ words: [
129
+ "choropleth",
130
+ "geo map",
131
+ "world map",
132
+ "geographic map"
133
+ ]
134
+ },
135
+ {
136
+ label: "Word cloud",
137
+ words: [
138
+ "word cloud",
139
+ "wordcloud",
140
+ "tag cloud"
141
+ ]
142
+ },
143
+ {
144
+ label: "Network graph",
145
+ words: [
146
+ "network graph",
147
+ "node graph",
148
+ "force graph",
149
+ "chord diagram"
150
+ ]
151
+ },
152
+ {
153
+ label: "Calendar heatmap",
154
+ words: ["calendar heatmap", "calendar view"]
155
+ },
156
+ {
157
+ label: "Kanban board",
158
+ words: ["kanban"]
159
+ },
160
+ {
161
+ label: "Embedded page",
162
+ words: ["iframe", "embedded page"]
163
+ }
164
+ ], a = [
70
165
  {
71
166
  chartType: "bar",
72
167
  words: ["bar"]
@@ -93,29 +188,68 @@ var n = [
93
188
  ]
94
189
  }
95
190
  ];
96
- function i(e) {
97
- let t = e.toLowerCase();
98
- for (let { type: e, words: r } of n) if (r.some((e) => t.includes(e))) return e;
99
- return "chart";
191
+ function o(e) {
192
+ return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
100
193
  }
101
- function a(e) {
102
- let t = e.toLowerCase();
103
- for (let { chartType: e, words: n } of r) if (n.some((e) => t.includes(e))) return e;
104
- return "line";
194
+ var s = /* @__PURE__ */ new Map();
195
+ function c(e) {
196
+ let t = s.get(e);
197
+ if (t) return t;
198
+ let n = e.trim().split(/\s+/).map(o).join("\\s+"), r = RegExp(`(?<![a-z0-9])${n}(?:e?s)?(?![a-z0-9])`, "i");
199
+ return s.set(e, r), r;
200
+ }
201
+ function l(e, t) {
202
+ return t.some((t) => c(t).test(e));
105
203
  }
106
- function o(e, t) {
107
- if (t.length === 0) return;
108
- let n = e.toLowerCase().split(/[^a-z0-9]+/).filter((e) => e.length > 2), r;
109
- for (let e of t) {
110
- let t = `${e.key} ${e.name ?? ""}`.toLowerCase(), i = n.reduce((e, n) => t.includes(n) ? e + 1 : e, 0);
111
- (!r || i > r.score) && (r = {
112
- sink: e,
113
- score: i
204
+ function u(e) {
205
+ let t = i.find(({ words: t }) => l(e, t));
206
+ return {
207
+ widgetType: r.find(({ words: t }) => l(e, t))?.type ?? "chart",
208
+ unsupportedRequest: t?.label
209
+ };
210
+ }
211
+ function d(e) {
212
+ return a.find(({ words: t }) => l(e, t))?.chartType ?? "line";
213
+ }
214
+ var f = /* @__PURE__ */ new Set(/* @__PURE__ */ "the.and.for.with.from.that.this.these.those.into.per.each.all.any.show.shows.showing.display.create.build.make.add.give.want.need.please.widget.widgets.data.dashboard.view.our.their.what.which.over.how.many.much.are.was.were.has.have.its.via.using.use.loads.load".split("."));
215
+ function p(e) {
216
+ return e.toLowerCase().split(/[^a-z0-9]+/).filter((e) => e.length > 2 && !f.has(e)).map((e) => e.length > 3 && e.endsWith("s") && !e.endsWith("ss") ? e.slice(0, -1) : e);
217
+ }
218
+ function m(e, t) {
219
+ let n = new Set(p(t)), r = 0;
220
+ for (let t of e) n.has(t) && (r += 1);
221
+ return r;
222
+ }
223
+ function h(e, t) {
224
+ let n;
225
+ for (let r of t) {
226
+ let t = m(e, `${r.key} ${r.name ?? ""}`);
227
+ (!n || t > n.score) && (n = {
228
+ sink: r,
229
+ score: t
114
230
  });
115
231
  }
116
- return r?.sink ?? t[0];
232
+ if (n) return {
233
+ sink: n.sink,
234
+ matched: n.score > 0
235
+ };
117
236
  }
118
- function s(e) {
237
+ function g(e, t, n, r) {
238
+ let i = /* @__PURE__ */ new Set([...e, ...p(t.replace(/_/g, " "))]), a;
239
+ for (let e of r) {
240
+ if (e.inputSinkKey !== n) continue;
241
+ let t = m(i, e.name);
242
+ (!a || t > a.score) && (a = {
243
+ parser: e,
244
+ score: t
245
+ });
246
+ }
247
+ if (a) return {
248
+ parser: a.parser,
249
+ matched: a.score > 0
250
+ };
251
+ }
252
+ function _(e) {
119
253
  switch (e) {
120
254
  case "heatmap": return {
121
255
  xAxisField: "column",
@@ -129,8 +263,9 @@ function s(e) {
129
263
  case "metric_card": return { valueField: "value" };
130
264
  case "table": return {};
131
265
  case "retention": return {
132
- cohortField: "cohort",
133
- valueField: "value"
266
+ cohortField: "",
267
+ periodField: "",
268
+ valueField: ""
134
269
  };
135
270
  default: return {
136
271
  xAxisField: "name",
@@ -139,20 +274,20 @@ function s(e) {
139
274
  };
140
275
  }
141
276
  }
142
- function c(t, n) {
143
- if (t.widgetType === n) return t;
144
- let r = s(n), i = Object.fromEntries(Object.entries(r).map(([e, n]) => [e, t.fieldMapping[e] ?? n])), a = new Set(e.flatMap((e) => Object.keys(s(e)))), o = new Set([...a].filter((e) => !Object.hasOwn(r, e)));
277
+ function v(n, r) {
278
+ if (n.widgetType === r) return n;
279
+ let i = t(n, ["WIDGET_TYPE_SUBSTITUTED"]), a = _(r), o = Object.fromEntries(Object.entries(a).map(([e, t]) => [e, n.fieldMapping[e] ?? t])), s = new Set(e.flatMap((e) => Object.keys(_(e)))), c = new Set([...s].filter((e) => !Object.hasOwn(a, e)));
145
280
  return {
146
- ...t,
147
- widgetType: n,
148
- fieldMapping: i,
281
+ ...i,
282
+ widgetType: r,
283
+ fieldMapping: o,
149
284
  presentation: {
150
- ...t.presentation,
151
- config: Object.fromEntries(Object.entries(t.presentation.config).filter(([e]) => !o.has(e)))
285
+ ...i.presentation,
286
+ config: Object.fromEntries(Object.entries(i.presentation.config).filter(([e]) => !c.has(e)))
152
287
  }
153
288
  };
154
289
  }
155
- function l(e, t) {
290
+ function y(e, t) {
156
291
  let n = {
157
292
  showLegend: !0,
158
293
  showTooltip: !0
@@ -160,7 +295,7 @@ function l(e, t) {
160
295
  switch (e) {
161
296
  case "chart": return {
162
297
  ...n,
163
- chartType: a(t),
298
+ chartType: d(t),
164
299
  showGrid: !0
165
300
  };
166
301
  case "funnel_chart": return {
@@ -187,36 +322,47 @@ function l(e, t) {
187
322
  default: return n;
188
323
  }
189
324
  }
190
- function u(e) {
191
- let t = e.trim().replace(/^(please\s+)?(create|build|make|add|show me|show|give me)\s+(an?\s+|the\s+)?/i, "").split(/[.;\n]/)[0].trim();
325
+ var b = /[.!?;](?=\s|$)|\n/;
326
+ function x(e) {
327
+ let t = (e.trim().replace(/^(please\s+)?(create|build|make|add|show me|show|give me)\s+(an?\s+|the\s+)?/i, "").split(b)[0] ?? "").trim();
192
328
  if (!t) return "Custom widget";
193
329
  let n = t.charAt(0).toUpperCase() + t.slice(1);
194
330
  return n.length > 60 ? `${n.slice(0, 57)}…` : n;
195
331
  }
196
- var d = 0, f = {
332
+ var S = 0, C = {
197
333
  id: "local-heuristic-v1",
198
334
  async propose({ prompt: e, sinks: t, parsers: n }) {
199
- let r = i(e), a = o(e, t), c = a ? n.find((e) => e.inputSinkKey === a.key) : void 0;
200
- return d += 1, {
335
+ let { widgetType: r, unsupportedRequest: i } = u(e), a = new Set(p(e)), o = h(a, t), s = o?.sink, c = s ? g(a, r, s.key, n) : void 0, l = c?.parser, d = [];
336
+ return i && d.push({
337
+ code: "WIDGET_TYPE_SUBSTITUTED",
338
+ requestedType: i,
339
+ widgetType: r
340
+ }), o ? d.push({
341
+ code: o.matched ? "DATASINK_MATCHED" : "DATASINK_DEFAULTED",
342
+ sinkKey: o.sink.key,
343
+ sinkName: o.sink.name?.trim() || o.sink.key,
344
+ parserName: l?.name,
345
+ parserMatched: c?.matched ?? !1
346
+ }) : d.push({ code: "NO_DATASINK" }), S += 1, {
201
347
  version: "1.0",
202
- id: `proposal-${d}`,
348
+ id: `proposal-${S}`,
203
349
  sourcePrompt: e,
204
- generatedBy: f.id,
350
+ generatedBy: C.id,
205
351
  widgetType: r,
206
352
  binding: {
207
- dataSinkId: a?.id ?? "",
208
- dataSinkKey: a?.key,
209
- parserId: c?.id,
210
- parserName: c?.name
353
+ dataSinkId: s?.id ?? "",
354
+ dataSinkKey: s?.key,
355
+ parserId: l?.id,
356
+ parserName: l?.name
211
357
  },
212
- fieldMapping: s(r),
358
+ fieldMapping: _(r),
213
359
  presentation: {
214
- title: u(e),
360
+ title: x(e),
215
361
  description: `Generated from: "${e}"`,
216
- config: l(r, e)
362
+ config: y(r, e)
217
363
  },
218
- rationale: a ? `Matched DataSink "${a.key}"${c ? ` and parser "${c.name}"` : " (no parser found for this sink)"}.` : "No DataSink is available in this workspace — create one before saving this widget."
364
+ notices: d
219
365
  };
220
366
  }
221
367
  };
222
- export { c as changeProposalWidgetType, f as localProposalSource, t as selectActiveProposalSinks };
368
+ export { v as changeProposalWidgetType, x as deriveTitle, u as detectWidgetType, C as localProposalSource, n as selectActiveProposalSinks };