@contractspec/example.analytics-dashboard 3.9.9 → 3.9.10

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.
Files changed (112) hide show
  1. package/dist/browser/dashboard/dashboard.enum.js +1 -34
  2. package/dist/browser/dashboard/dashboard.operation.js +1 -289
  3. package/dist/browser/dashboard/dashboard.presentation.js +1 -200
  4. package/dist/browser/dashboard/dashboard.schema.js +1 -126
  5. package/dist/browser/dashboard/dashboard.test-spec.js +1 -213
  6. package/dist/browser/dashboard/index.js +1 -299
  7. package/dist/browser/dashboard.feature.js +1 -683
  8. package/dist/browser/datasource/posthog-datasource.js +4 -289
  9. package/dist/browser/docs/analytics-dashboard.docblock.js +5 -49
  10. package/dist/browser/docs/index.js +5 -49
  11. package/dist/browser/events.js +1 -81
  12. package/dist/browser/example.js +1 -42
  13. package/dist/browser/handlers/analytics.handlers.js +4 -278
  14. package/dist/browser/handlers/index.js +7 -571
  15. package/dist/browser/handlers/query.handlers.js +4 -294
  16. package/dist/browser/index.js +12 -2317
  17. package/dist/browser/query/index.js +1 -159
  18. package/dist/browser/query/query.enum.js +1 -11
  19. package/dist/browser/query/query.operation.js +1 -154
  20. package/dist/browser/query/query.presentation.js +1 -122
  21. package/dist/browser/query/query.schema.js +1 -70
  22. package/dist/browser/query/query.test-spec.js +1 -113
  23. package/dist/browser/query-engine/index.js +4 -491
  24. package/dist/browser/seeders/index.js +2 -20
  25. package/dist/browser/ui/AnalyticsDashboard.js +1 -1115
  26. package/dist/browser/ui/AnalyticsDashboard.widgets.js +1 -94
  27. package/dist/browser/ui/AnalyticsQueriesTable.js +1 -188
  28. package/dist/browser/ui/hooks/index.js +1 -660
  29. package/dist/browser/ui/hooks/useAnalyticsData.js +1 -657
  30. package/dist/browser/ui/index.js +5 -1283
  31. package/dist/browser/ui/renderers/analytics.markdown.js +5 -756
  32. package/dist/browser/ui/renderers/index.js +5 -756
  33. package/dist/browser/visualizations/catalog.js +1 -457
  34. package/dist/browser/visualizations/index.js +1 -611
  35. package/dist/browser/visualizations/specs.breakdown.js +1 -140
  36. package/dist/browser/visualizations/specs.performance.js +1 -198
  37. package/dist/browser/visualizations/widgets.js +1 -595
  38. package/dist/dashboard/dashboard.enum.js +1 -34
  39. package/dist/dashboard/dashboard.operation.js +1 -289
  40. package/dist/dashboard/dashboard.presentation.js +1 -200
  41. package/dist/dashboard/dashboard.schema.js +1 -126
  42. package/dist/dashboard/dashboard.test-spec.js +1 -213
  43. package/dist/dashboard/index.js +1 -299
  44. package/dist/dashboard.feature.js +1 -683
  45. package/dist/datasource/posthog-datasource.js +4 -289
  46. package/dist/docs/analytics-dashboard.docblock.js +5 -49
  47. package/dist/docs/index.js +5 -49
  48. package/dist/events.js +1 -81
  49. package/dist/example.js +1 -42
  50. package/dist/handlers/analytics.handlers.js +4 -278
  51. package/dist/handlers/index.js +7 -571
  52. package/dist/handlers/query.handlers.js +4 -294
  53. package/dist/index.js +12 -2317
  54. package/dist/node/dashboard/dashboard.enum.js +1 -34
  55. package/dist/node/dashboard/dashboard.operation.js +1 -289
  56. package/dist/node/dashboard/dashboard.presentation.js +1 -200
  57. package/dist/node/dashboard/dashboard.schema.js +1 -126
  58. package/dist/node/dashboard/dashboard.test-spec.js +1 -213
  59. package/dist/node/dashboard/index.js +1 -299
  60. package/dist/node/dashboard.feature.js +1 -683
  61. package/dist/node/datasource/posthog-datasource.js +4 -289
  62. package/dist/node/docs/analytics-dashboard.docblock.js +5 -49
  63. package/dist/node/docs/index.js +5 -49
  64. package/dist/node/events.js +1 -81
  65. package/dist/node/example.js +1 -42
  66. package/dist/node/handlers/analytics.handlers.js +4 -278
  67. package/dist/node/handlers/index.js +7 -571
  68. package/dist/node/handlers/query.handlers.js +4 -294
  69. package/dist/node/index.js +12 -2317
  70. package/dist/node/query/index.js +1 -159
  71. package/dist/node/query/query.enum.js +1 -11
  72. package/dist/node/query/query.operation.js +1 -154
  73. package/dist/node/query/query.presentation.js +1 -122
  74. package/dist/node/query/query.schema.js +1 -70
  75. package/dist/node/query/query.test-spec.js +1 -113
  76. package/dist/node/query-engine/index.js +4 -491
  77. package/dist/node/seeders/index.js +2 -20
  78. package/dist/node/ui/AnalyticsDashboard.js +1 -1115
  79. package/dist/node/ui/AnalyticsDashboard.widgets.js +1 -94
  80. package/dist/node/ui/AnalyticsQueriesTable.js +1 -188
  81. package/dist/node/ui/hooks/index.js +1 -660
  82. package/dist/node/ui/hooks/useAnalyticsData.js +1 -657
  83. package/dist/node/ui/index.js +5 -1283
  84. package/dist/node/ui/renderers/analytics.markdown.js +5 -756
  85. package/dist/node/ui/renderers/index.js +5 -756
  86. package/dist/node/visualizations/catalog.js +1 -457
  87. package/dist/node/visualizations/index.js +1 -611
  88. package/dist/node/visualizations/specs.breakdown.js +1 -140
  89. package/dist/node/visualizations/specs.performance.js +1 -198
  90. package/dist/node/visualizations/widgets.js +1 -595
  91. package/dist/query/index.js +1 -159
  92. package/dist/query/query.enum.js +1 -11
  93. package/dist/query/query.operation.js +1 -154
  94. package/dist/query/query.presentation.js +1 -122
  95. package/dist/query/query.schema.js +1 -70
  96. package/dist/query/query.test-spec.js +1 -113
  97. package/dist/query-engine/index.js +4 -491
  98. package/dist/seeders/index.js +2 -20
  99. package/dist/ui/AnalyticsDashboard.js +1 -1115
  100. package/dist/ui/AnalyticsDashboard.widgets.js +1 -94
  101. package/dist/ui/AnalyticsQueriesTable.js +1 -188
  102. package/dist/ui/hooks/index.js +1 -660
  103. package/dist/ui/hooks/useAnalyticsData.js +1 -657
  104. package/dist/ui/index.js +5 -1283
  105. package/dist/ui/renderers/analytics.markdown.js +5 -756
  106. package/dist/ui/renderers/index.js +5 -756
  107. package/dist/visualizations/catalog.js +1 -457
  108. package/dist/visualizations/index.js +1 -611
  109. package/dist/visualizations/specs.breakdown.js +1 -140
  110. package/dist/visualizations/specs.performance.js +1 -198
  111. package/dist/visualizations/widgets.js +1 -595
  112. package/package.json +10 -10
@@ -1,1116 +1,2 @@
1
1
  // @bun
2
- // src/visualizations/specs.breakdown.ts
3
- import { defineVisualization } from "@contractspec/lib.contracts-spec/visualizations";
4
- var QUERY_REF = { key: "analytics.query.execute", version: "1.0.0" };
5
- var META = {
6
- version: "1.0.0",
7
- domain: "analytics",
8
- stability: "experimental",
9
- owners: ["@example.analytics-dashboard"],
10
- tags: ["analytics", "dashboard", "visualization"]
11
- };
12
- var ChannelMixVisualization = defineVisualization({
13
- meta: {
14
- ...META,
15
- key: "analytics.visualization.channel-mix",
16
- title: "Channel Mix",
17
- description: "Session distribution across acquisition channels.",
18
- goal: "Explain which channels currently drive the largest share of traffic.",
19
- context: "Marketing attribution dashboard."
20
- },
21
- source: { primary: QUERY_REF, resultPath: "data" },
22
- visualization: {
23
- kind: "pie",
24
- nameDimension: "channel",
25
- valueMeasure: "sessions",
26
- dimensions: [
27
- {
28
- key: "channel",
29
- label: "Channel",
30
- dataPath: "channel",
31
- type: "category"
32
- }
33
- ],
34
- measures: [{ key: "sessions", label: "Sessions", dataPath: "sessions" }],
35
- table: { caption: "Sessions by acquisition channel." }
36
- }
37
- });
38
- var EngagementHeatmapVisualization = defineVisualization({
39
- meta: {
40
- ...META,
41
- key: "analytics.visualization.engagement-heatmap",
42
- title: "Engagement Heatmap",
43
- description: "Average engagement score by weekday and time band.",
44
- goal: "Reveal the highest-engagement time windows for product activity.",
45
- context: "Usage analytics dashboard."
46
- },
47
- source: { primary: QUERY_REF, resultPath: "data" },
48
- visualization: {
49
- kind: "heatmap",
50
- xDimension: "timeBand",
51
- yDimension: "weekday",
52
- valueMeasure: "engagementScore",
53
- dimensions: [
54
- {
55
- key: "timeBand",
56
- label: "Time Band",
57
- dataPath: "timeBand",
58
- type: "category"
59
- },
60
- {
61
- key: "weekday",
62
- label: "Weekday",
63
- dataPath: "weekday",
64
- type: "category"
65
- }
66
- ],
67
- measures: [
68
- {
69
- key: "engagementScore",
70
- label: "Engagement",
71
- dataPath: "engagementScore"
72
- }
73
- ],
74
- table: { caption: "Engagement score by weekday and time band." }
75
- }
76
- });
77
- var ConversionFunnelVisualization = defineVisualization({
78
- meta: {
79
- ...META,
80
- key: "analytics.visualization.conversion-funnel",
81
- title: "Conversion Funnel",
82
- description: "Progression through the main acquisition funnel.",
83
- goal: "Show where the product is losing the largest share of prospects.",
84
- context: "Growth dashboard."
85
- },
86
- source: { primary: QUERY_REF, resultPath: "data" },
87
- visualization: {
88
- kind: "funnel",
89
- nameDimension: "stage",
90
- valueMeasure: "users",
91
- sort: "descending",
92
- dimensions: [
93
- { key: "stage", label: "Stage", dataPath: "stage", type: "category" }
94
- ],
95
- measures: [{ key: "users", label: "Users", dataPath: "users" }],
96
- table: { caption: "Users per conversion stage." }
97
- }
98
- });
99
- var AccountCoverageGeoVisualization = defineVisualization({
100
- meta: {
101
- ...META,
102
- key: "analytics.visualization.account-coverage-geo",
103
- title: "Account Coverage",
104
- description: "High-value accounts plotted on a slippy-map surface.",
105
- goal: "Locate where active commercial concentration is strongest.",
106
- context: "Territory coverage dashboard."
107
- },
108
- source: { primary: QUERY_REF, resultPath: "data" },
109
- visualization: {
110
- kind: "geo",
111
- mode: "slippy-map",
112
- variant: "scatter",
113
- nameDimension: "city",
114
- latitudeDimension: "latitude",
115
- longitudeDimension: "longitude",
116
- valueMeasure: "accounts",
117
- dimensions: [
118
- { key: "city", label: "City", dataPath: "city", type: "category" },
119
- {
120
- key: "latitude",
121
- label: "Latitude",
122
- dataPath: "latitude",
123
- type: "latitude"
124
- },
125
- {
126
- key: "longitude",
127
- label: "Longitude",
128
- dataPath: "longitude",
129
- type: "longitude"
130
- }
131
- ],
132
- measures: [{ key: "accounts", label: "Accounts", dataPath: "accounts" }],
133
- table: { caption: "Account concentration by city." }
134
- }
135
- });
136
-
137
- // src/visualizations/specs.performance.ts
138
- import { defineVisualization as defineVisualization2 } from "@contractspec/lib.contracts-spec/visualizations";
139
- var QUERY_REF2 = { key: "analytics.query.execute", version: "1.0.0" };
140
- var META2 = {
141
- version: "1.0.0",
142
- domain: "analytics",
143
- stability: "experimental",
144
- owners: ["@example.analytics-dashboard"],
145
- tags: ["analytics", "dashboard", "visualization"]
146
- };
147
- var RevenueMetricVisualization = defineVisualization2({
148
- meta: {
149
- ...META2,
150
- key: "analytics.visualization.revenue-metric",
151
- title: "Revenue Snapshot",
152
- description: "Current recurring revenue with prior-period comparison.",
153
- goal: "Highlight the headline commercial metric for the dashboard.",
154
- context: "Executive revenue overview."
155
- },
156
- source: { primary: QUERY_REF2, resultPath: "data" },
157
- visualization: {
158
- kind: "metric",
159
- measure: "totalRevenue",
160
- comparisonMeasure: "priorRevenue",
161
- dimensions: [
162
- { key: "period", label: "Period", dataPath: "period", type: "time" }
163
- ],
164
- measures: [
165
- {
166
- key: "totalRevenue",
167
- label: "Revenue",
168
- dataPath: "totalRevenue",
169
- format: "currency"
170
- },
171
- {
172
- key: "priorRevenue",
173
- label: "Prior Revenue",
174
- dataPath: "priorRevenue",
175
- format: "currency"
176
- }
177
- ],
178
- sparkline: { dimension: "period", measure: "totalRevenue" },
179
- table: { caption: "Revenue trend and prior period values." }
180
- }
181
- });
182
- var RevenueTrendVisualization = defineVisualization2({
183
- meta: {
184
- ...META2,
185
- key: "analytics.visualization.revenue-trend",
186
- title: "Revenue Trend",
187
- description: "Monthly revenue progression for the current quarter.",
188
- goal: "Track whether revenue growth is accelerating or stalling.",
189
- context: "Quarterly commercial dashboard."
190
- },
191
- source: { primary: QUERY_REF2, resultPath: "data" },
192
- visualization: {
193
- kind: "cartesian",
194
- variant: "line",
195
- xDimension: "date",
196
- yMeasures: ["revenue"],
197
- dimensions: [
198
- { key: "date", label: "Month", dataPath: "date", type: "time" }
199
- ],
200
- measures: [
201
- {
202
- key: "revenue",
203
- label: "Revenue",
204
- dataPath: "revenue",
205
- format: "currency",
206
- color: "#0f766e"
207
- }
208
- ],
209
- thresholds: [
210
- { key: "target", value: 140000, label: "Target", color: "#dc2626" }
211
- ],
212
- table: { caption: "Monthly revenue values." }
213
- }
214
- });
215
- var RegionalRevenueVisualization = defineVisualization2({
216
- meta: {
217
- ...META2,
218
- key: "analytics.visualization.regional-revenue",
219
- title: "Regional Revenue",
220
- description: "Revenue split by sales territory.",
221
- goal: "Compare the strongest and weakest performing territories.",
222
- context: "Territory planning and commercial comparison."
223
- },
224
- source: { primary: QUERY_REF2, resultPath: "data" },
225
- visualization: {
226
- kind: "cartesian",
227
- variant: "bar",
228
- xDimension: "region",
229
- yMeasures: ["revenue"],
230
- dimensions: [
231
- { key: "region", label: "Region", dataPath: "region", type: "category" }
232
- ],
233
- measures: [
234
- {
235
- key: "revenue",
236
- label: "Revenue",
237
- dataPath: "revenue",
238
- format: "currency",
239
- color: "#1d4ed8"
240
- }
241
- ],
242
- table: { caption: "Revenue by region." }
243
- }
244
- });
245
- var RetentionAreaVisualization = defineVisualization2({
246
- meta: {
247
- ...META2,
248
- key: "analytics.visualization.retention-area",
249
- title: "Retention Curve",
250
- description: "Weekly retention progression across the active cohort.",
251
- goal: "Show whether user retention remains above the desired floor.",
252
- context: "Product health dashboard."
253
- },
254
- source: { primary: QUERY_REF2, resultPath: "data" },
255
- visualization: {
256
- kind: "cartesian",
257
- variant: "area",
258
- xDimension: "week",
259
- yMeasures: ["retentionRate"],
260
- dimensions: [
261
- { key: "week", label: "Week", dataPath: "week", type: "category" }
262
- ],
263
- measures: [
264
- {
265
- key: "retentionRate",
266
- label: "Retention",
267
- dataPath: "retentionRate",
268
- format: "percentage",
269
- color: "#16a34a"
270
- }
271
- ],
272
- thresholds: [
273
- { key: "floor", value: 0.5, label: "Floor", color: "#f59e0b" }
274
- ],
275
- table: { caption: "Weekly retention rate." }
276
- }
277
- });
278
- var PipelineScatterVisualization = defineVisualization2({
279
- meta: {
280
- ...META2,
281
- key: "analytics.visualization.pipeline-scatter",
282
- title: "Pipeline Velocity",
283
- description: "Deal-cycle length against win rate for active accounts.",
284
- goal: "Spot outliers where the sales cycle is long but conversion remains weak.",
285
- context: "Commercial operations dashboard."
286
- },
287
- source: { primary: QUERY_REF2, resultPath: "data" },
288
- visualization: {
289
- kind: "cartesian",
290
- variant: "scatter",
291
- xDimension: "cycleDays",
292
- yMeasures: ["winRate"],
293
- dimensions: [
294
- {
295
- key: "cycleDays",
296
- label: "Cycle Days",
297
- dataPath: "cycleDays",
298
- type: "number"
299
- }
300
- ],
301
- measures: [
302
- {
303
- key: "winRate",
304
- label: "Win Rate",
305
- dataPath: "winRate",
306
- format: "percentage",
307
- color: "#7c3aed"
308
- },
309
- {
310
- key: "arr",
311
- label: "ARR",
312
- dataPath: "arr",
313
- format: "currency"
314
- }
315
- ],
316
- series: [
317
- {
318
- key: "pipeline",
319
- label: "Accounts",
320
- measure: "winRate",
321
- type: "scatter",
322
- color: "#7c3aed"
323
- }
324
- ],
325
- table: { caption: "Sales cycle and win rate per account." }
326
- }
327
- });
328
-
329
- // src/visualizations/catalog.ts
330
- import { VisualizationRegistry } from "@contractspec/lib.contracts-spec/visualizations";
331
- var AnalyticsVisualizationSpecs = [
332
- RevenueMetricVisualization,
333
- RevenueTrendVisualization,
334
- RegionalRevenueVisualization,
335
- RetentionAreaVisualization,
336
- PipelineScatterVisualization,
337
- ChannelMixVisualization,
338
- EngagementHeatmapVisualization,
339
- ConversionFunnelVisualization,
340
- AccountCoverageGeoVisualization
341
- ];
342
- var AnalyticsVisualizationRegistry = new VisualizationRegistry([
343
- ...AnalyticsVisualizationSpecs
344
- ]);
345
- var AnalyticsVisualizationRefs = AnalyticsVisualizationSpecs.map((spec) => refOf(spec));
346
- var AnalyticsVisualizationSpecMap = new Map(AnalyticsVisualizationSpecs.map((spec) => [
347
- visualizationRefKey(spec.meta),
348
- spec
349
- ]));
350
- var AnalyticsVisualizationSampleData = {
351
- [visualizationRefKey(RevenueMetricVisualization.meta)]: {
352
- data: [
353
- { period: "2025-11-01", totalRevenue: 112000, priorRevenue: 103000 },
354
- { period: "2025-12-01", totalRevenue: 119000, priorRevenue: 110000 },
355
- { period: "2026-01-01", totalRevenue: 126500, priorRevenue: 116000 },
356
- { period: "2026-02-01", totalRevenue: 133000, priorRevenue: 124000 },
357
- { period: "2026-03-01", totalRevenue: 145500, priorRevenue: 133000 }
358
- ]
359
- },
360
- [visualizationRefKey(RevenueTrendVisualization.meta)]: {
361
- data: [
362
- { date: "2025-11-01", revenue: 112000 },
363
- { date: "2025-12-01", revenue: 119000 },
364
- { date: "2026-01-01", revenue: 126500 },
365
- { date: "2026-02-01", revenue: 133000 },
366
- { date: "2026-03-01", revenue: 145500 }
367
- ]
368
- },
369
- [visualizationRefKey(RegionalRevenueVisualization.meta)]: {
370
- data: [
371
- { region: "North America", revenue: 210000 },
372
- { region: "EMEA", revenue: 174000 },
373
- { region: "APAC", revenue: 132000 },
374
- { region: "LATAM", revenue: 88000 }
375
- ]
376
- },
377
- [visualizationRefKey(RetentionAreaVisualization.meta)]: {
378
- data: [
379
- { week: "Week 1", retentionRate: 0.71 },
380
- { week: "Week 2", retentionRate: 0.66 },
381
- { week: "Week 3", retentionRate: 0.62 },
382
- { week: "Week 4", retentionRate: 0.58 },
383
- { week: "Week 5", retentionRate: 0.55 },
384
- { week: "Week 6", retentionRate: 0.53 }
385
- ]
386
- },
387
- [visualizationRefKey(PipelineScatterVisualization.meta)]: {
388
- data: [
389
- { cycleDays: 18, winRate: 0.31, arr: 82000 },
390
- { cycleDays: 26, winRate: 0.44, arr: 65000 },
391
- { cycleDays: 33, winRate: 0.27, arr: 91000 },
392
- { cycleDays: 14, winRate: 0.56, arr: 47000 },
393
- { cycleDays: 21, winRate: 0.48, arr: 59000 },
394
- { cycleDays: 39, winRate: 0.22, arr: 114000 }
395
- ]
396
- },
397
- [visualizationRefKey(ChannelMixVisualization.meta)]: {
398
- data: [
399
- { channel: "Direct", sessions: 4200 },
400
- { channel: "Organic Search", sessions: 3600 },
401
- { channel: "Paid Search", sessions: 2100 },
402
- { channel: "Partner", sessions: 1400 },
403
- { channel: "Referral", sessions: 900 }
404
- ]
405
- },
406
- [visualizationRefKey(EngagementHeatmapVisualization.meta)]: {
407
- data: [
408
- { weekday: "Mon", timeBand: "09:00", engagementScore: 74 },
409
- { weekday: "Mon", timeBand: "13:00", engagementScore: 82 },
410
- { weekday: "Tue", timeBand: "09:00", engagementScore: 69 },
411
- { weekday: "Tue", timeBand: "13:00", engagementScore: 88 },
412
- { weekday: "Wed", timeBand: "09:00", engagementScore: 77 },
413
- { weekday: "Wed", timeBand: "13:00", engagementScore: 91 },
414
- { weekday: "Thu", timeBand: "09:00", engagementScore: 72 },
415
- { weekday: "Thu", timeBand: "13:00", engagementScore: 86 },
416
- { weekday: "Fri", timeBand: "09:00", engagementScore: 65 },
417
- { weekday: "Fri", timeBand: "13:00", engagementScore: 79 }
418
- ]
419
- },
420
- [visualizationRefKey(ConversionFunnelVisualization.meta)]: {
421
- data: [
422
- { stage: "Visited Site", users: 12000 },
423
- { stage: "Started Trial", users: 4200 },
424
- { stage: "Activated Workspace", users: 2400 },
425
- { stage: "Requested Demo", users: 980 },
426
- { stage: "Closed Won", users: 310 }
427
- ]
428
- },
429
- [visualizationRefKey(AccountCoverageGeoVisualization.meta)]: {
430
- data: [
431
- { city: "Paris", latitude: 48.8566, longitude: 2.3522, accounts: 48 },
432
- { city: "London", latitude: 51.5072, longitude: -0.1276, accounts: 62 },
433
- { city: "New York", latitude: 40.7128, longitude: -74.006, accounts: 71 },
434
- { city: "Toronto", latitude: 43.6532, longitude: -79.3832, accounts: 36 },
435
- {
436
- city: "Singapore",
437
- latitude: 1.3521,
438
- longitude: 103.8198,
439
- accounts: 29
440
- }
441
- ]
442
- }
443
- };
444
- function refOf(spec) {
445
- return { key: spec.meta.key, version: spec.meta.version };
446
- }
447
- function visualizationRefKey(ref) {
448
- return `${ref.key}.v${ref.version}`;
449
- }
450
-
451
- // src/visualizations/widgets.ts
452
- var LEGACY_VISUALIZATION_REFS = {
453
- METRIC: refOf(RevenueMetricVisualization),
454
- LINE_CHART: refOf(RevenueTrendVisualization),
455
- BAR_CHART: refOf(RegionalRevenueVisualization),
456
- AREA_CHART: refOf(RetentionAreaVisualization),
457
- SCATTER_PLOT: refOf(PipelineScatterVisualization),
458
- PIE_CHART: refOf(ChannelMixVisualization),
459
- HEATMAP: refOf(EngagementHeatmapVisualization),
460
- FUNNEL: refOf(ConversionFunnelVisualization),
461
- MAP: refOf(AccountCoverageGeoVisualization)
462
- };
463
- function createExampleWidgets(dashboardId) {
464
- return [
465
- widget(dashboardId, "widget_revenue_metric", "Revenue Snapshot", "METRIC", 0, 0, 4, 2, {
466
- layout: "single",
467
- bindings: [binding(RevenueMetricVisualization, 200)]
468
- }),
469
- widget(dashboardId, "widget_revenue_trend", "Revenue Trend", "LINE_CHART", 4, 0, 8, 4, {
470
- layout: "single",
471
- bindings: [binding(RevenueTrendVisualization)]
472
- }),
473
- widget(dashboardId, "widget_regional_revenue", "Regional Revenue", "BAR_CHART", 0, 2, 6, 4, {
474
- layout: "single",
475
- bindings: [binding(RegionalRevenueVisualization)]
476
- }),
477
- widget(dashboardId, "widget_channel_mix", "Channel Mix", "PIE_CHART", 6, 2, 6, 4, {
478
- layout: "single",
479
- bindings: [binding(ChannelMixVisualization)]
480
- }),
481
- widget(dashboardId, "widget_retention", "Retention Curve", "AREA_CHART", 0, 6, 6, 4, {
482
- layout: "single",
483
- bindings: [binding(RetentionAreaVisualization)]
484
- }),
485
- widget(dashboardId, "widget_pipeline", "Pipeline Velocity", "SCATTER_PLOT", 6, 6, 6, 4, {
486
- layout: "single",
487
- bindings: [binding(PipelineScatterVisualization)]
488
- }),
489
- widget(dashboardId, "widget_heatmap", "Engagement Heatmap", "HEATMAP", 0, 10, 8, 4, {
490
- layout: "single",
491
- bindings: [binding(EngagementHeatmapVisualization)]
492
- }),
493
- widget(dashboardId, "widget_funnel", "Conversion Funnel", "FUNNEL", 8, 10, 4, 4, {
494
- layout: "single",
495
- bindings: [binding(ConversionFunnelVisualization)]
496
- }),
497
- widget(dashboardId, "widget_geo", "Account Coverage", "MAP", 0, 14, 12, 5, {
498
- layout: "single",
499
- bindings: [binding(AccountCoverageGeoVisualization, 360)]
500
- }),
501
- widget(dashboardId, "widget_comparison", "Commercial Comparison", "EMBED", 0, 19, 12, 6, {
502
- layout: "comparison",
503
- description: "Compare regional distribution, channel balance, and funnel shape.",
504
- bindings: [
505
- binding(RegionalRevenueVisualization, 240),
506
- binding(ChannelMixVisualization, 240),
507
- binding(ConversionFunnelVisualization, 240)
508
- ]
509
- }),
510
- widget(dashboardId, "widget_timeline", "Growth Timeline", "EMBED", 0, 25, 12, 6, {
511
- layout: "timeline",
512
- description: "Track revenue and retention over the same reporting cadence.",
513
- bindings: [
514
- binding(RevenueTrendVisualization, 220),
515
- binding(RetentionAreaVisualization, 220)
516
- ]
517
- })
518
- ];
519
- }
520
- function resolveAnalyticsWidget(widget) {
521
- const config = parseWidgetConfig(widget);
522
- const bindings = config.bindings.map((binding) => {
523
- const spec = AnalyticsVisualizationSpecMap.get(visualizationRefKey(binding.ref));
524
- if (!spec)
525
- return null;
526
- return {
527
- key: `${widget.id}:${visualizationRefKey(binding.ref)}`,
528
- spec,
529
- data: binding.data,
530
- title: binding.title ?? spec.meta.title,
531
- description: binding.description ?? spec.meta.description,
532
- height: binding.height
533
- };
534
- }).filter((binding) => Boolean(binding));
535
- if (!bindings.length)
536
- return null;
537
- return {
538
- id: widget.id,
539
- name: widget.name,
540
- description: config.description,
541
- layout: config.layout,
542
- gridX: widget.gridX,
543
- gridY: widget.gridY,
544
- gridWidth: widget.gridWidth,
545
- gridHeight: widget.gridHeight,
546
- bindings
547
- };
548
- }
549
- function parseWidgetConfig(widget) {
550
- if (isAnalyticsWidgetConfig(widget.config)) {
551
- return widget.config;
552
- }
553
- const legacyRef = LEGACY_VISUALIZATION_REFS[widget.type];
554
- return legacyRef ? {
555
- layout: "single",
556
- bindings: [
557
- {
558
- ref: legacyRef,
559
- data: AnalyticsVisualizationSampleData[visualizationRefKey(legacyRef)]
560
- }
561
- ]
562
- } : { layout: "single", bindings: [] };
563
- }
564
- function binding(spec, height = 280) {
565
- return {
566
- ref: refOf(spec),
567
- data: AnalyticsVisualizationSampleData[visualizationRefKey(spec.meta)],
568
- height
569
- };
570
- }
571
- function widget(dashboardId, id, name, type, gridX, gridY, gridWidth, gridHeight, config) {
572
- const now = new Date;
573
- return {
574
- id,
575
- dashboardId,
576
- name,
577
- type,
578
- gridX,
579
- gridY,
580
- gridWidth,
581
- gridHeight,
582
- config,
583
- createdAt: now,
584
- updatedAt: now
585
- };
586
- }
587
- function isAnalyticsWidgetConfig(value) {
588
- if (!value || typeof value !== "object")
589
- return false;
590
- const candidate = value;
591
- return (candidate.layout === "single" || candidate.layout === "comparison" || candidate.layout === "timeline") && Array.isArray(candidate.bindings);
592
- }
593
- // src/ui/AnalyticsDashboard.widgets.tsx
594
- import {
595
- ComparisonView,
596
- TimelineView,
597
- VisualizationCard,
598
- VisualizationGrid
599
- } from "@contractspec/lib.design-system";
600
- import { jsxDEV } from "react/jsx-dev-runtime";
601
- "use client";
602
- function AnalyticsWidgetBoard({
603
- dashboardName,
604
- widgets
605
- }) {
606
- if (!widgets.length) {
607
- return /* @__PURE__ */ jsxDEV("div", {
608
- className: "rounded-lg border border-dashed p-10 text-center text-muted-foreground",
609
- children: [
610
- 'No visualization widgets configured for "',
611
- dashboardName,
612
- '".'
613
- ]
614
- }, undefined, true, undefined, this);
615
- }
616
- return /* @__PURE__ */ jsxDEV("div", {
617
- children: [
618
- /* @__PURE__ */ jsxDEV("h3", {
619
- className: "mb-4 font-semibold text-lg",
620
- children: [
621
- 'Widgets in "',
622
- dashboardName,
623
- '"'
624
- ]
625
- }, undefined, true, undefined, this),
626
- /* @__PURE__ */ jsxDEV(VisualizationGrid, {
627
- children: widgets.map((widget2) => /* @__PURE__ */ jsxDEV("div", {
628
- className: gridSpanClass(widget2.gridWidth),
629
- children: renderVisualizationWidget(widget2)
630
- }, widget2.id, false, undefined, this))
631
- }, undefined, false, undefined, this)
632
- ]
633
- }, undefined, true, undefined, this);
634
- }
635
- function renderVisualizationWidget(widget2) {
636
- const footer = /* @__PURE__ */ jsxDEV("span", {
637
- className: "text-muted-foreground text-xs",
638
- children: [
639
- "Position: (",
640
- widget2.gridX,
641
- ", ",
642
- widget2.gridY,
643
- ") \u2022 ",
644
- widget2.gridWidth,
645
- "x",
646
- widget2.gridHeight
647
- ]
648
- }, undefined, true, undefined, this);
649
- if (widget2.layout === "comparison") {
650
- return /* @__PURE__ */ jsxDEV(ComparisonView, {
651
- description: widget2.description,
652
- items: widget2.bindings.map((binding3) => ({ ...binding3, footer })),
653
- title: widget2.name
654
- }, undefined, false, undefined, this);
655
- }
656
- if (widget2.layout === "timeline") {
657
- return /* @__PURE__ */ jsxDEV(TimelineView, {
658
- description: widget2.description,
659
- items: widget2.bindings.map((binding3) => ({ ...binding3, footer })),
660
- title: widget2.name
661
- }, undefined, false, undefined, this);
662
- }
663
- const binding2 = widget2.bindings[0];
664
- if (!binding2)
665
- return null;
666
- return /* @__PURE__ */ jsxDEV(VisualizationCard, {
667
- data: binding2.data,
668
- description: widget2.description ?? binding2.description,
669
- footer,
670
- height: binding2.height,
671
- spec: binding2.spec,
672
- title: widget2.name
673
- }, undefined, false, undefined, this);
674
- }
675
- function gridSpanClass(gridWidth) {
676
- if (gridWidth >= 12)
677
- return "md:col-span-2 xl:col-span-3";
678
- if (gridWidth >= 8)
679
- return "xl:col-span-2";
680
- if (gridWidth >= 6)
681
- return "md:col-span-2";
682
- return "";
683
- }
684
-
685
- // src/ui/AnalyticsQueriesTable.tsx
686
- import { DataTable } from "@contractspec/lib.design-system";
687
- import { useContractTable } from "@contractspec/lib.presentation-runtime-react";
688
- import { Badge } from "@contractspec/lib.ui-kit-web/ui/badge";
689
- import { HStack, VStack } from "@contractspec/lib.ui-kit-web/ui/stack";
690
- import { Text } from "@contractspec/lib.ui-kit-web/ui/text";
691
- import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
692
- "use client";
693
- var QUERY_TYPE_COLORS = {
694
- SQL: "default",
695
- METRIC: "secondary",
696
- AGGREGATION: "secondary",
697
- CUSTOM: "outline"
698
- };
699
- function formatJson(value) {
700
- return JSON.stringify(value, null, 2);
701
- }
702
- function AnalyticsQueriesTable({ queries }) {
703
- const controller = useContractTable({
704
- data: queries,
705
- columns: [
706
- {
707
- id: "query",
708
- header: "Query",
709
- label: "Query",
710
- accessor: (query) => query.name,
711
- cell: ({ item }) => /* @__PURE__ */ jsxDEV2(VStack, {
712
- gap: "xs",
713
- children: [
714
- /* @__PURE__ */ jsxDEV2(Text, {
715
- className: "font-medium text-sm",
716
- children: item.name
717
- }, undefined, false, undefined, this),
718
- /* @__PURE__ */ jsxDEV2(Text, {
719
- className: "text-muted-foreground text-xs",
720
- children: [
721
- "Updated ",
722
- item.updatedAt.toLocaleDateString()
723
- ]
724
- }, undefined, true, undefined, this)
725
- ]
726
- }, undefined, true, undefined, this),
727
- size: 240,
728
- minSize: 180,
729
- canSort: true,
730
- canPin: true,
731
- canResize: true
732
- },
733
- {
734
- id: "description",
735
- header: "Description",
736
- label: "Description",
737
- accessor: (query) => query.description ?? "",
738
- cell: ({ value }) => /* @__PURE__ */ jsxDEV2(Text, {
739
- className: "line-clamp-2 text-muted-foreground text-sm",
740
- children: String(value || "No description")
741
- }, undefined, false, undefined, this),
742
- size: 300,
743
- minSize: 220,
744
- canSort: false,
745
- canHide: true,
746
- canResize: true
747
- },
748
- {
749
- id: "type",
750
- header: "Type",
751
- label: "Type",
752
- accessorKey: "type",
753
- cell: ({ value }) => /* @__PURE__ */ jsxDEV2(Badge, {
754
- variant: QUERY_TYPE_COLORS[String(value)],
755
- children: String(value)
756
- }, undefined, false, undefined, this),
757
- size: 150,
758
- canSort: true,
759
- canHide: true,
760
- canResize: true
761
- },
762
- {
763
- id: "cacheTtlSeconds",
764
- header: "Cache TTL",
765
- label: "Cache TTL",
766
- accessorKey: "cacheTtlSeconds",
767
- cell: ({ value }) => `${String(value)}s`,
768
- align: "right",
769
- size: 140,
770
- canSort: true,
771
- canResize: true
772
- },
773
- {
774
- id: "isShared",
775
- header: "Shared",
776
- label: "Shared",
777
- accessorKey: "isShared",
778
- cell: ({ value }) => /* @__PURE__ */ jsxDEV2(Badge, {
779
- variant: value ? "default" : "outline",
780
- children: value ? "Shared" : "Private"
781
- }, undefined, false, undefined, this),
782
- size: 140,
783
- canSort: true,
784
- canHide: true,
785
- canResize: true
786
- }
787
- ],
788
- initialState: {
789
- pagination: { pageIndex: 0, pageSize: 3 },
790
- columnVisibility: { description: false },
791
- columnPinning: { left: ["query"], right: [] }
792
- },
793
- renderExpandedContent: (query) => /* @__PURE__ */ jsxDEV2(VStack, {
794
- gap: "sm",
795
- className: "py-2",
796
- children: [
797
- /* @__PURE__ */ jsxDEV2(VStack, {
798
- gap: "xs",
799
- children: [
800
- /* @__PURE__ */ jsxDEV2(Text, {
801
- className: "font-medium text-sm",
802
- children: "Description"
803
- }, undefined, false, undefined, this),
804
- /* @__PURE__ */ jsxDEV2(Text, {
805
- className: "text-muted-foreground text-sm",
806
- children: query.description ?? "No description"
807
- }, undefined, false, undefined, this)
808
- ]
809
- }, undefined, true, undefined, this),
810
- query.sql ? /* @__PURE__ */ jsxDEV2(VStack, {
811
- gap: "xs",
812
- children: [
813
- /* @__PURE__ */ jsxDEV2(Text, {
814
- className: "font-medium text-sm",
815
- children: "SQL"
816
- }, undefined, false, undefined, this),
817
- /* @__PURE__ */ jsxDEV2("pre", {
818
- className: "overflow-auto rounded-md bg-muted/40 p-3 text-xs",
819
- children: query.sql
820
- }, undefined, false, undefined, this)
821
- ]
822
- }, undefined, true, undefined, this) : null,
823
- /* @__PURE__ */ jsxDEV2(VStack, {
824
- gap: "xs",
825
- children: [
826
- /* @__PURE__ */ jsxDEV2(Text, {
827
- className: "font-medium text-sm",
828
- children: "Definition"
829
- }, undefined, false, undefined, this),
830
- /* @__PURE__ */ jsxDEV2("pre", {
831
- className: "overflow-auto rounded-md bg-muted/40 p-3 text-xs",
832
- children: formatJson(query.definition)
833
- }, undefined, false, undefined, this)
834
- ]
835
- }, undefined, true, undefined, this)
836
- ]
837
- }, undefined, true, undefined, this),
838
- getCanExpand: () => true
839
- });
840
- return /* @__PURE__ */ jsxDEV2(DataTable, {
841
- controller,
842
- title: "Saved Queries",
843
- description: "Client-mode table using the shared ContractSpec controller and renderer.",
844
- toolbar: /* @__PURE__ */ jsxDEV2(HStack, {
845
- gap: "sm",
846
- className: "flex-wrap",
847
- children: [
848
- /* @__PURE__ */ jsxDEV2(Text, {
849
- className: "text-muted-foreground text-sm",
850
- children: [
851
- queries.length,
852
- " queries"
853
- ]
854
- }, undefined, true, undefined, this),
855
- /* @__PURE__ */ jsxDEV2(Text, {
856
- className: "text-muted-foreground text-sm",
857
- children: [
858
- queries.filter((query) => query.isShared).length,
859
- " shared"
860
- ]
861
- }, undefined, true, undefined, this)
862
- ]
863
- }, undefined, true, undefined, this),
864
- emptyState: /* @__PURE__ */ jsxDEV2("div", {
865
- className: "rounded-md border border-dashed p-8 text-center text-muted-foreground text-sm",
866
- children: "No queries saved"
867
- }, undefined, false, undefined, this)
868
- }, undefined, false, undefined, this);
869
- }
870
-
871
- // src/ui/hooks/useAnalyticsData.ts
872
- import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
873
- import { useCallback, useEffect, useState } from "react";
874
- "use client";
875
- function useAnalyticsData(projectId = "local-project") {
876
- const { handlers } = useTemplateRuntime();
877
- const analytics = handlers.analytics;
878
- const [dashboards, setDashboards] = useState([]);
879
- const [queries, setQueries] = useState([]);
880
- const [selectedDashboard, setSelectedDashboard] = useState(null);
881
- const [widgets, setWidgets] = useState([]);
882
- const [loading, setLoading] = useState(true);
883
- const [error, setError] = useState(null);
884
- const fetchData = useCallback(async () => {
885
- try {
886
- setLoading(true);
887
- setError(null);
888
- const [dashResult, queryResult] = await Promise.all([
889
- analytics.listDashboards({ projectId, limit: 100 }),
890
- analytics.listQueries({ projectId, limit: 100 })
891
- ]);
892
- setDashboards(dashResult.dashboards);
893
- setQueries(queryResult.queries);
894
- if (dashResult.dashboards.length > 0 && !selectedDashboard) {
895
- const first = dashResult.dashboards[0];
896
- if (first) {
897
- setSelectedDashboard(first);
898
- const dashboardWidgets = await analytics.getWidgets(first.id);
899
- setWidgets(dashboardWidgets.length > 0 ? dashboardWidgets : createExampleWidgets(first.id));
900
- }
901
- }
902
- } catch (err) {
903
- setError(err instanceof Error ? err : new Error("Failed to load analytics"));
904
- } finally {
905
- setLoading(false);
906
- }
907
- }, [analytics, projectId, selectedDashboard]);
908
- useEffect(() => {
909
- fetchData();
910
- }, [fetchData]);
911
- const selectDashboard = useCallback(async (dashboard) => {
912
- setSelectedDashboard(dashboard);
913
- const dashboardWidgets = await analytics.getWidgets(dashboard.id);
914
- setWidgets(dashboardWidgets.length > 0 ? dashboardWidgets : createExampleWidgets(dashboard.id));
915
- }, [analytics]);
916
- const stats = {
917
- totalDashboards: dashboards.length,
918
- publishedDashboards: dashboards.filter((d) => d.status === "PUBLISHED").length,
919
- totalQueries: queries.length,
920
- sharedQueries: queries.filter((q) => q.isShared).length
921
- };
922
- return {
923
- dashboards,
924
- queries,
925
- selectedDashboard,
926
- widgets,
927
- loading,
928
- error,
929
- stats,
930
- refetch: fetchData,
931
- selectDashboard
932
- };
933
- }
934
-
935
- // src/ui/AnalyticsDashboard.tsx
936
- import {
937
- Button,
938
- ErrorState,
939
- LoaderBlock,
940
- StatCard,
941
- StatCardGroup
942
- } from "@contractspec/lib.design-system";
943
- import { useMemo, useState as useState2 } from "react";
944
- import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
945
- "use client";
946
- var STATUS_COLORS = {
947
- PUBLISHED: "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",
948
- DRAFT: "bg-gray-100 text-gray-700 dark:bg-gray-900/30 dark:text-gray-400",
949
- ARCHIVED: "bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"
950
- };
951
- function AnalyticsDashboard() {
952
- const [activeTab, setActiveTab] = useState2("dashboards");
953
- const {
954
- dashboards,
955
- queries,
956
- selectedDashboard,
957
- widgets,
958
- loading,
959
- error,
960
- stats,
961
- refetch,
962
- selectDashboard
963
- } = useAnalyticsData();
964
- const tabs = [
965
- { id: "dashboards", label: "Dashboards", icon: "\uD83D\uDCCA" },
966
- { id: "queries", label: "Queries", icon: "\uD83D\uDD0D" }
967
- ];
968
- const resolvedWidgets = useMemo(() => widgets.map((widget2) => resolveAnalyticsWidget(widget2)).filter((widget2) => Boolean(widget2)), [widgets]);
969
- if (loading) {
970
- return /* @__PURE__ */ jsxDEV3(LoaderBlock, {
971
- label: "Loading Analytics..."
972
- }, undefined, false, undefined, this);
973
- }
974
- if (error) {
975
- return /* @__PURE__ */ jsxDEV3(ErrorState, {
976
- title: "Failed to load Analytics",
977
- description: error.message,
978
- onRetry: refetch,
979
- retryLabel: "Retry"
980
- }, undefined, false, undefined, this);
981
- }
982
- return /* @__PURE__ */ jsxDEV3("div", {
983
- className: "space-y-6",
984
- children: [
985
- /* @__PURE__ */ jsxDEV3("div", {
986
- className: "flex items-center justify-between",
987
- children: [
988
- /* @__PURE__ */ jsxDEV3("h2", {
989
- className: "font-bold text-2xl",
990
- children: "Analytics Dashboard"
991
- }, undefined, false, undefined, this),
992
- /* @__PURE__ */ jsxDEV3(Button, {
993
- onClick: () => alert("Create dashboard modal"),
994
- children: [
995
- /* @__PURE__ */ jsxDEV3("span", {
996
- className: "mr-2",
997
- children: "+"
998
- }, undefined, false, undefined, this),
999
- " New Dashboard"
1000
- ]
1001
- }, undefined, true, undefined, this)
1002
- ]
1003
- }, undefined, true, undefined, this),
1004
- /* @__PURE__ */ jsxDEV3(StatCardGroup, {
1005
- children: [
1006
- /* @__PURE__ */ jsxDEV3(StatCard, {
1007
- label: "Dashboards",
1008
- value: stats.totalDashboards,
1009
- hint: `${stats.publishedDashboards} published`
1010
- }, undefined, false, undefined, this),
1011
- /* @__PURE__ */ jsxDEV3(StatCard, {
1012
- label: "Queries",
1013
- value: stats.totalQueries,
1014
- hint: `${stats.sharedQueries} shared`
1015
- }, undefined, false, undefined, this),
1016
- /* @__PURE__ */ jsxDEV3(StatCard, {
1017
- label: "Widgets",
1018
- value: widgets.length,
1019
- hint: "on current dashboard"
1020
- }, undefined, false, undefined, this)
1021
- ]
1022
- }, undefined, true, undefined, this),
1023
- /* @__PURE__ */ jsxDEV3("nav", {
1024
- className: "flex gap-1 rounded-lg bg-muted p-1",
1025
- role: "tablist",
1026
- children: tabs.map((tab) => /* @__PURE__ */ jsxDEV3(Button, {
1027
- type: "button",
1028
- role: "tab",
1029
- "aria-selected": activeTab === tab.id,
1030
- onClick: () => setActiveTab(tab.id),
1031
- className: `flex flex-1 items-center justify-center gap-2 rounded-md px-4 py-2 font-medium text-sm transition-colors ${activeTab === tab.id ? "bg-background text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"}`,
1032
- children: [
1033
- /* @__PURE__ */ jsxDEV3("span", {
1034
- children: tab.icon
1035
- }, undefined, false, undefined, this),
1036
- tab.label
1037
- ]
1038
- }, tab.id, true, undefined, this))
1039
- }, undefined, false, undefined, this),
1040
- /* @__PURE__ */ jsxDEV3("div", {
1041
- className: "min-h-[400px]",
1042
- role: "tabpanel",
1043
- children: [
1044
- activeTab === "dashboards" && /* @__PURE__ */ jsxDEV3("div", {
1045
- className: "space-y-6",
1046
- children: [
1047
- /* @__PURE__ */ jsxDEV3("div", {
1048
- className: "grid gap-4 sm:grid-cols-2 lg:grid-cols-3",
1049
- children: [
1050
- dashboards.map((dashboard) => /* @__PURE__ */ jsxDEV3("div", {
1051
- onClick: () => selectDashboard(dashboard),
1052
- className: `cursor-pointer rounded-lg border border-border bg-card p-4 transition-all ${selectedDashboard?.id === dashboard.id ? "ring-2 ring-primary" : "hover:bg-muted/50"}`,
1053
- role: "button",
1054
- tabIndex: 0,
1055
- onKeyDown: (e) => {
1056
- if (e.key === "Enter" || e.key === " ")
1057
- selectDashboard(dashboard);
1058
- },
1059
- children: [
1060
- /* @__PURE__ */ jsxDEV3("div", {
1061
- className: "mb-2 flex items-center justify-between",
1062
- children: [
1063
- /* @__PURE__ */ jsxDEV3("h3", {
1064
- className: "font-medium",
1065
- children: dashboard.name
1066
- }, undefined, false, undefined, this),
1067
- /* @__PURE__ */ jsxDEV3("span", {
1068
- className: `inline-flex rounded-full px-2 py-0.5 font-medium text-xs ${STATUS_COLORS[dashboard.status] ?? ""}`,
1069
- children: dashboard.status
1070
- }, undefined, false, undefined, this)
1071
- ]
1072
- }, undefined, true, undefined, this),
1073
- /* @__PURE__ */ jsxDEV3("p", {
1074
- className: "mb-3 text-muted-foreground text-sm",
1075
- children: dashboard.description
1076
- }, undefined, false, undefined, this),
1077
- /* @__PURE__ */ jsxDEV3("div", {
1078
- className: "flex items-center justify-between text-muted-foreground text-xs",
1079
- children: [
1080
- /* @__PURE__ */ jsxDEV3("span", {
1081
- children: [
1082
- "/",
1083
- dashboard.slug
1084
- ]
1085
- }, undefined, true, undefined, this),
1086
- dashboard.isPublic && /* @__PURE__ */ jsxDEV3("span", {
1087
- className: "text-green-600 dark:text-green-400",
1088
- children: "\uD83C\uDF10 Public"
1089
- }, undefined, false, undefined, this)
1090
- ]
1091
- }, undefined, true, undefined, this)
1092
- ]
1093
- }, dashboard.id, true, undefined, this)),
1094
- dashboards.length === 0 && /* @__PURE__ */ jsxDEV3("div", {
1095
- className: "col-span-full flex h-64 items-center justify-center text-muted-foreground",
1096
- children: "No dashboards created yet"
1097
- }, undefined, false, undefined, this)
1098
- ]
1099
- }, undefined, true, undefined, this),
1100
- selectedDashboard ? /* @__PURE__ */ jsxDEV3(AnalyticsWidgetBoard, {
1101
- dashboardName: selectedDashboard.name,
1102
- widgets: resolvedWidgets
1103
- }, undefined, false, undefined, this) : null
1104
- ]
1105
- }, undefined, true, undefined, this),
1106
- activeTab === "queries" && /* @__PURE__ */ jsxDEV3(AnalyticsQueriesTable, {
1107
- queries
1108
- }, undefined, false, undefined, this)
1109
- ]
1110
- }, undefined, true, undefined, this)
1111
- ]
1112
- }, undefined, true, undefined, this);
1113
- }
1114
- export {
1115
- AnalyticsDashboard
1116
- };
2
+ import{defineVisualization as g}from"@contractspec/lib.contracts-spec/visualizations";var l={key:"analytics.query.execute",version:"1.0.0"},u={version:"1.0.0",domain:"analytics",stability:"experimental",owners:["@example.analytics-dashboard"],tags:["analytics","dashboard","visualization"]},O=g({meta:{...u,key:"analytics.visualization.channel-mix",title:"Channel Mix",description:"Session distribution across acquisition channels.",goal:"Explain which channels currently drive the largest share of traffic.",context:"Marketing attribution dashboard."},source:{primary:l,resultPath:"data"},visualization:{kind:"pie",nameDimension:"channel",valueMeasure:"sessions",dimensions:[{key:"channel",label:"Channel",dataPath:"channel",type:"category"}],measures:[{key:"sessions",label:"Sessions",dataPath:"sessions"}],table:{caption:"Sessions by acquisition channel."}}}),D=g({meta:{...u,key:"analytics.visualization.engagement-heatmap",title:"Engagement Heatmap",description:"Average engagement score by weekday and time band.",goal:"Reveal the highest-engagement time windows for product activity.",context:"Usage analytics dashboard."},source:{primary:l,resultPath:"data"},visualization:{kind:"heatmap",xDimension:"timeBand",yDimension:"weekday",valueMeasure:"engagementScore",dimensions:[{key:"timeBand",label:"Time Band",dataPath:"timeBand",type:"category"},{key:"weekday",label:"Weekday",dataPath:"weekday",type:"category"}],measures:[{key:"engagementScore",label:"Engagement",dataPath:"engagementScore"}],table:{caption:"Engagement score by weekday and time band."}}}),M=g({meta:{...u,key:"analytics.visualization.conversion-funnel",title:"Conversion Funnel",description:"Progression through the main acquisition funnel.",goal:"Show where the product is losing the largest share of prospects.",context:"Growth dashboard."},source:{primary:l,resultPath:"data"},visualization:{kind:"funnel",nameDimension:"stage",valueMeasure:"users",sort:"descending",dimensions:[{key:"stage",label:"Stage",dataPath:"stage",type:"category"}],measures:[{key:"users",label:"Users",dataPath:"users"}],table:{caption:"Users per conversion stage."}}}),q=g({meta:{...u,key:"analytics.visualization.account-coverage-geo",title:"Account Coverage",description:"High-value accounts plotted on a slippy-map surface.",goal:"Locate where active commercial concentration is strongest.",context:"Territory coverage dashboard."},source:{primary:l,resultPath:"data"},visualization:{kind:"geo",mode:"slippy-map",variant:"scatter",nameDimension:"city",latitudeDimension:"latitude",longitudeDimension:"longitude",valueMeasure:"accounts",dimensions:[{key:"city",label:"City",dataPath:"city",type:"category"},{key:"latitude",label:"Latitude",dataPath:"latitude",type:"latitude"},{key:"longitude",label:"Longitude",dataPath:"longitude",type:"longitude"}],measures:[{key:"accounts",label:"Accounts",dataPath:"accounts"}],table:{caption:"Account concentration by city."}}});import{defineVisualization as z}from"@contractspec/lib.contracts-spec/visualizations";var v={key:"analytics.query.execute",version:"1.0.0"},w={version:"1.0.0",domain:"analytics",stability:"experimental",owners:["@example.analytics-dashboard"],tags:["analytics","dashboard","visualization"]},S=z({meta:{...w,key:"analytics.visualization.revenue-metric",title:"Revenue Snapshot",description:"Current recurring revenue with prior-period comparison.",goal:"Highlight the headline commercial metric for the dashboard.",context:"Executive revenue overview."},source:{primary:v,resultPath:"data"},visualization:{kind:"metric",measure:"totalRevenue",comparisonMeasure:"priorRevenue",dimensions:[{key:"period",label:"Period",dataPath:"period",type:"time"}],measures:[{key:"totalRevenue",label:"Revenue",dataPath:"totalRevenue",format:"currency"},{key:"priorRevenue",label:"Prior Revenue",dataPath:"priorRevenue",format:"currency"}],sparkline:{dimension:"period",measure:"totalRevenue"},table:{caption:"Revenue trend and prior period values."}}}),C=z({meta:{...w,key:"analytics.visualization.revenue-trend",title:"Revenue Trend",description:"Monthly revenue progression for the current quarter.",goal:"Track whether revenue growth is accelerating or stalling.",context:"Quarterly commercial dashboard."},source:{primary:v,resultPath:"data"},visualization:{kind:"cartesian",variant:"line",xDimension:"date",yMeasures:["revenue"],dimensions:[{key:"date",label:"Month",dataPath:"date",type:"time"}],measures:[{key:"revenue",label:"Revenue",dataPath:"revenue",format:"currency",color:"#0f766e"}],thresholds:[{key:"target",value:140000,label:"Target",color:"#dc2626"}],table:{caption:"Monthly revenue values."}}}),A=z({meta:{...w,key:"analytics.visualization.regional-revenue",title:"Regional Revenue",description:"Revenue split by sales territory.",goal:"Compare the strongest and weakest performing territories.",context:"Territory planning and commercial comparison."},source:{primary:v,resultPath:"data"},visualization:{kind:"cartesian",variant:"bar",xDimension:"region",yMeasures:["revenue"],dimensions:[{key:"region",label:"Region",dataPath:"region",type:"category"}],measures:[{key:"revenue",label:"Revenue",dataPath:"revenue",format:"currency",color:"#1d4ed8"}],table:{caption:"Revenue by region."}}}),p=z({meta:{...w,key:"analytics.visualization.retention-area",title:"Retention Curve",description:"Weekly retention progression across the active cohort.",goal:"Show whether user retention remains above the desired floor.",context:"Product health dashboard."},source:{primary:v,resultPath:"data"},visualization:{kind:"cartesian",variant:"area",xDimension:"week",yMeasures:["retentionRate"],dimensions:[{key:"week",label:"Week",dataPath:"week",type:"category"}],measures:[{key:"retentionRate",label:"Retention",dataPath:"retentionRate",format:"percentage",color:"#16a34a"}],thresholds:[{key:"floor",value:0.5,label:"Floor",color:"#f59e0b"}],table:{caption:"Weekly retention rate."}}}),I=z({meta:{...w,key:"analytics.visualization.pipeline-scatter",title:"Pipeline Velocity",description:"Deal-cycle length against win rate for active accounts.",goal:"Spot outliers where the sales cycle is long but conversion remains weak.",context:"Commercial operations dashboard."},source:{primary:v,resultPath:"data"},visualization:{kind:"cartesian",variant:"scatter",xDimension:"cycleDays",yMeasures:["winRate"],dimensions:[{key:"cycleDays",label:"Cycle Days",dataPath:"cycleDays",type:"number"}],measures:[{key:"winRate",label:"Win Rate",dataPath:"winRate",format:"percentage",color:"#7c3aed"},{key:"arr",label:"ARR",dataPath:"arr",format:"currency"}],series:[{key:"pipeline",label:"Accounts",measure:"winRate",type:"scatter",color:"#7c3aed"}],table:{caption:"Sales cycle and win rate per account."}}});import{VisualizationRegistry as Hm}from"@contractspec/lib.contracts-spec/visualizations";var b=[S,C,A,p,I,O,D,M,q],Bm=new Hm([...b]),Wm=b.map((m)=>B(m)),i=new Map(b.map((m)=>[X(m.meta),m])),o={[X(S.meta)]:{data:[{period:"2025-11-01",totalRevenue:112000,priorRevenue:103000},{period:"2025-12-01",totalRevenue:119000,priorRevenue:110000},{period:"2026-01-01",totalRevenue:126500,priorRevenue:116000},{period:"2026-02-01",totalRevenue:133000,priorRevenue:124000},{period:"2026-03-01",totalRevenue:145500,priorRevenue:133000}]},[X(C.meta)]:{data:[{date:"2025-11-01",revenue:112000},{date:"2025-12-01",revenue:119000},{date:"2026-01-01",revenue:126500},{date:"2026-02-01",revenue:133000},{date:"2026-03-01",revenue:145500}]},[X(A.meta)]:{data:[{region:"North America",revenue:210000},{region:"EMEA",revenue:174000},{region:"APAC",revenue:132000},{region:"LATAM",revenue:88000}]},[X(p.meta)]:{data:[{week:"Week 1",retentionRate:0.71},{week:"Week 2",retentionRate:0.66},{week:"Week 3",retentionRate:0.62},{week:"Week 4",retentionRate:0.58},{week:"Week 5",retentionRate:0.55},{week:"Week 6",retentionRate:0.53}]},[X(I.meta)]:{data:[{cycleDays:18,winRate:0.31,arr:82000},{cycleDays:26,winRate:0.44,arr:65000},{cycleDays:33,winRate:0.27,arr:91000},{cycleDays:14,winRate:0.56,arr:47000},{cycleDays:21,winRate:0.48,arr:59000},{cycleDays:39,winRate:0.22,arr:114000}]},[X(O.meta)]:{data:[{channel:"Direct",sessions:4200},{channel:"Organic Search",sessions:3600},{channel:"Paid Search",sessions:2100},{channel:"Partner",sessions:1400},{channel:"Referral",sessions:900}]},[X(D.meta)]:{data:[{weekday:"Mon",timeBand:"09:00",engagementScore:74},{weekday:"Mon",timeBand:"13:00",engagementScore:82},{weekday:"Tue",timeBand:"09:00",engagementScore:69},{weekday:"Tue",timeBand:"13:00",engagementScore:88},{weekday:"Wed",timeBand:"09:00",engagementScore:77},{weekday:"Wed",timeBand:"13:00",engagementScore:91},{weekday:"Thu",timeBand:"09:00",engagementScore:72},{weekday:"Thu",timeBand:"13:00",engagementScore:86},{weekday:"Fri",timeBand:"09:00",engagementScore:65},{weekday:"Fri",timeBand:"13:00",engagementScore:79}]},[X(M.meta)]:{data:[{stage:"Visited Site",users:12000},{stage:"Started Trial",users:4200},{stage:"Activated Workspace",users:2400},{stage:"Requested Demo",users:980},{stage:"Closed Won",users:310}]},[X(q.meta)]:{data:[{city:"Paris",latitude:48.8566,longitude:2.3522,accounts:48},{city:"London",latitude:51.5072,longitude:-0.1276,accounts:62},{city:"New York",latitude:40.7128,longitude:-74.006,accounts:71},{city:"Toronto",latitude:43.6532,longitude:-79.3832,accounts:36},{city:"Singapore",latitude:1.3521,longitude:103.8198,accounts:29}]}};function B(m){return{key:m.meta.key,version:m.meta.version}}function X(m){return`${m.key}.v${m.version}`}var Lm={METRIC:B(S),LINE_CHART:B(C),BAR_CHART:B(A),AREA_CHART:B(p),SCATTER_PLOT:B(I),PIE_CHART:B(O),HEATMAP:B(D),FUNNEL:B(M),MAP:B(q)};function r(m){return[k(m,"widget_revenue_metric","Revenue Snapshot","METRIC",0,0,4,2,{layout:"single",bindings:[H(S,200)]}),k(m,"widget_revenue_trend","Revenue Trend","LINE_CHART",4,0,8,4,{layout:"single",bindings:[H(C)]}),k(m,"widget_regional_revenue","Regional Revenue","BAR_CHART",0,2,6,4,{layout:"single",bindings:[H(A)]}),k(m,"widget_channel_mix","Channel Mix","PIE_CHART",6,2,6,4,{layout:"single",bindings:[H(O)]}),k(m,"widget_retention","Retention Curve","AREA_CHART",0,6,6,4,{layout:"single",bindings:[H(p)]}),k(m,"widget_pipeline","Pipeline Velocity","SCATTER_PLOT",6,6,6,4,{layout:"single",bindings:[H(I)]}),k(m,"widget_heatmap","Engagement Heatmap","HEATMAP",0,10,8,4,{layout:"single",bindings:[H(D)]}),k(m,"widget_funnel","Conversion Funnel","FUNNEL",8,10,4,4,{layout:"single",bindings:[H(M)]}),k(m,"widget_geo","Account Coverage","MAP",0,14,12,5,{layout:"single",bindings:[H(q,360)]}),k(m,"widget_comparison","Commercial Comparison","EMBED",0,19,12,6,{layout:"comparison",description:"Compare regional distribution, channel balance, and funnel shape.",bindings:[H(A,240),H(O,240),H(M,240)]}),k(m,"widget_timeline","Growth Timeline","EMBED",0,25,12,6,{layout:"timeline",description:"Track revenue and retention over the same reporting cadence.",bindings:[H(C,220),H(p,220)]})]}function s(m){let $=Km(m),N=$.bindings.map((J)=>{let W=i.get(X(J.ref));if(!W)return null;return{key:`${m.id}:${X(J.ref)}`,spec:W,data:J.data,title:J.title??W.meta.title,description:J.description??W.meta.description,height:J.height}}).filter((J)=>Boolean(J));if(!N.length)return null;return{id:m.id,name:m.name,description:$.description,layout:$.layout,gridX:m.gridX,gridY:m.gridY,gridWidth:m.gridWidth,gridHeight:m.gridHeight,bindings:N}}function Km(m){if(km(m.config))return m.config;let $=Lm[m.type];return $?{layout:"single",bindings:[{ref:$,data:o[X($)]}]}:{layout:"single",bindings:[]}}function H(m,$=280){return{ref:B(m),data:o[X(m.meta)],height:$}}function k(m,$,N,J,W,U,E,_,Q){let V=new Date;return{id:$,dashboardId:m,name:N,type:J,gridX:W,gridY:U,gridWidth:E,gridHeight:_,config:Q,createdAt:V,updatedAt:V}}function km(m){if(!m||typeof m!=="object")return!1;let $=m;return($.layout==="single"||$.layout==="comparison"||$.layout==="timeline")&&Array.isArray($.bindings)}import{ComparisonView as Um,TimelineView as Qm,VisualizationCard as Ym,VisualizationGrid as Fm}from"@contractspec/lib.design-system";import{jsx as R,jsxs as n}from"react/jsx-runtime";function mm({dashboardName:m,widgets:$}){if(!$.length)return n("div",{className:"rounded-lg border border-dashed p-10 text-center text-muted-foreground",children:['No visualization widgets configured for "',m,'".']});return n("div",{children:[n("h3",{className:"mb-4 font-semibold text-lg",children:['Widgets in "',m,'"']}),R(Fm,{children:$.map((N)=>R("div",{className:Om(N.gridWidth),children:_m(N)},N.id))})]})}function _m(m){let $=n("span",{className:"text-muted-foreground text-xs",children:["Position: (",m.gridX,", ",m.gridY,") \u2022 ",m.gridWidth,"x",m.gridHeight]});if(m.layout==="comparison")return R(Um,{description:m.description,items:m.bindings.map((J)=>({...J,footer:$})),title:m.name});if(m.layout==="timeline")return R(Qm,{description:m.description,items:m.bindings.map((J)=>({...J,footer:$})),title:m.name});let N=m.bindings[0];if(!N)return null;return R(Ym,{data:N.data,description:m.description??N.description,footer:$,height:N.height,spec:N.spec,title:m.name})}function Om(m){if(m>=12)return"md:col-span-2 xl:col-span-3";if(m>=8)return"xl:col-span-2";if(m>=6)return"md:col-span-2";return""}import{DataTable as Mm}from"@contractspec/lib.design-system";import{useContractTable as Cm}from"@contractspec/lib.presentation-runtime-react";import{Badge as Nm}from"@contractspec/lib.ui-kit-web/ui/badge";import{HStack as Am,VStack as x}from"@contractspec/lib.ui-kit-web/ui/stack";import{Text as Y}from"@contractspec/lib.ui-kit-web/ui/text";import{jsx as L,jsxs as F}from"react/jsx-runtime";var pm={SQL:"default",METRIC:"secondary",AGGREGATION:"secondary",CUSTOM:"outline"};function Dm(m){return JSON.stringify(m,null,2)}function $m({queries:m}){let $=Cm({data:m,columns:[{id:"query",header:"Query",label:"Query",accessor:(N)=>N.name,cell:({item:N})=>F(x,{gap:"xs",children:[L(Y,{className:"font-medium text-sm",children:N.name}),F(Y,{className:"text-muted-foreground text-xs",children:["Updated ",N.updatedAt.toLocaleDateString()]})]}),size:240,minSize:180,canSort:!0,canPin:!0,canResize:!0},{id:"description",header:"Description",label:"Description",accessor:(N)=>N.description??"",cell:({value:N})=>L(Y,{className:"line-clamp-2 text-muted-foreground text-sm",children:String(N||"No description")}),size:300,minSize:220,canSort:!1,canHide:!0,canResize:!0},{id:"type",header:"Type",label:"Type",accessorKey:"type",cell:({value:N})=>L(Nm,{variant:pm[String(N)],children:String(N)}),size:150,canSort:!0,canHide:!0,canResize:!0},{id:"cacheTtlSeconds",header:"Cache TTL",label:"Cache TTL",accessorKey:"cacheTtlSeconds",cell:({value:N})=>`${String(N)}s`,align:"right",size:140,canSort:!0,canResize:!0},{id:"isShared",header:"Shared",label:"Shared",accessorKey:"isShared",cell:({value:N})=>L(Nm,{variant:N?"default":"outline",children:N?"Shared":"Private"}),size:140,canSort:!0,canHide:!0,canResize:!0}],initialState:{pagination:{pageIndex:0,pageSize:3},columnVisibility:{description:!1},columnPinning:{left:["query"],right:[]}},renderExpandedContent:(N)=>F(x,{gap:"sm",className:"py-2",children:[F(x,{gap:"xs",children:[L(Y,{className:"font-medium text-sm",children:"Description"}),L(Y,{className:"text-muted-foreground text-sm",children:N.description??"No description"})]}),N.sql?F(x,{gap:"xs",children:[L(Y,{className:"font-medium text-sm",children:"SQL"}),L("pre",{className:"overflow-auto rounded-md bg-muted/40 p-3 text-xs",children:N.sql})]}):null,F(x,{gap:"xs",children:[L(Y,{className:"font-medium text-sm",children:"Definition"}),L("pre",{className:"overflow-auto rounded-md bg-muted/40 p-3 text-xs",children:Dm(N.definition)})]})]}),getCanExpand:()=>!0});return L(Mm,{controller:$,title:"Saved Queries",description:"Client-mode table using the shared ContractSpec controller and renderer.",toolbar:F(Am,{gap:"sm",className:"flex-wrap",children:[F(Y,{className:"text-muted-foreground text-sm",children:[m.length," queries"]}),F(Y,{className:"text-muted-foreground text-sm",children:[m.filter((N)=>N.isShared).length," shared"]})]}),emptyState:L("div",{className:"rounded-md border border-dashed p-8 text-center text-muted-foreground text-sm",children:"No queries saved"})})}import{useTemplateRuntime as qm}from"@contractspec/lib.example-shared-ui";import{useCallback as Gm,useEffect as Sm,useState as y}from"react";function Jm(m="local-project"){let{handlers:$}=qm(),N=$.analytics,[J,W]=y([]),[U,E]=y([]),[_,Q]=y(null),[V,T]=y([]),[t,j]=y(!0),[G,f]=y(null),d=Gm(async()=>{try{j(!0),f(null);let[P,h]=await Promise.all([N.listDashboards({projectId:m,limit:100}),N.listQueries({projectId:m,limit:100})]);if(W(P.dashboards),E(h.queries),P.dashboards.length>0&&!_){let c=P.dashboards[0];if(c){Q(c);let a=await N.getWidgets(c.id);T(a.length>0?a:r(c.id))}}}catch(P){f(P instanceof Error?P:Error("Failed to load analytics"))}finally{j(!1)}},[N,m,_]);Sm(()=>{d()},[d]);let Zm=Gm(async(P)=>{Q(P);let h=await N.getWidgets(P.id);T(h.length>0?h:r(P.id))},[N]),Pm={totalDashboards:J.length,publishedDashboards:J.filter((P)=>P.status==="PUBLISHED").length,totalQueries:U.length,sharedQueries:U.filter((P)=>P.isShared).length};return{dashboards:J,queries:U,selectedDashboard:_,widgets:V,loading:t,error:G,stats:Pm,refetch:d,selectDashboard:Zm}}import{Button as Xm,ErrorState as Im,LoaderBlock as Vm,StatCard as e,StatCardGroup as ym}from"@contractspec/lib.design-system";import{useMemo as Em,useState as Tm}from"react";import{jsx as Z,jsxs as K}from"react/jsx-runtime";var fm={PUBLISHED:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",DRAFT:"bg-gray-100 text-gray-700 dark:bg-gray-900/30 dark:text-gray-400",ARCHIVED:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"};function Y2(){let[m,$]=Tm("dashboards"),{dashboards:N,queries:J,selectedDashboard:W,widgets:U,loading:E,error:_,stats:Q,refetch:V,selectDashboard:T}=Jm(),t=[{id:"dashboards",label:"Dashboards",icon:"\uD83D\uDCCA"},{id:"queries",label:"Queries",icon:"\uD83D\uDD0D"}],j=Em(()=>U.map((G)=>s(G)).filter((G)=>Boolean(G)),[U]);if(E)return Z(Vm,{label:"Loading Analytics..."});if(_)return Z(Im,{title:"Failed to load Analytics",description:_.message,onRetry:V,retryLabel:"Retry"});return K("div",{className:"space-y-6",children:[K("div",{className:"flex items-center justify-between",children:[Z("h2",{className:"font-bold text-2xl",children:"Analytics Dashboard"}),K(Xm,{onClick:()=>alert("Create dashboard modal"),children:[Z("span",{className:"mr-2",children:"+"})," New Dashboard"]})]}),K(ym,{children:[Z(e,{label:"Dashboards",value:Q.totalDashboards,hint:`${Q.publishedDashboards} published`}),Z(e,{label:"Queries",value:Q.totalQueries,hint:`${Q.sharedQueries} shared`}),Z(e,{label:"Widgets",value:U.length,hint:"on current dashboard"})]}),Z("nav",{className:"flex gap-1 rounded-lg bg-muted p-1",role:"tablist",children:t.map((G)=>K(Xm,{type:"button",role:"tab","aria-selected":m===G.id,onClick:()=>$(G.id),className:`flex flex-1 items-center justify-center gap-2 rounded-md px-4 py-2 font-medium text-sm transition-colors ${m===G.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[Z("span",{children:G.icon}),G.label]},G.id))}),K("div",{className:"min-h-[400px]",role:"tabpanel",children:[m==="dashboards"&&K("div",{className:"space-y-6",children:[K("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[N.map((G)=>K("div",{onClick:()=>T(G),className:`cursor-pointer rounded-lg border border-border bg-card p-4 transition-all ${W?.id===G.id?"ring-2 ring-primary":"hover:bg-muted/50"}`,role:"button",tabIndex:0,onKeyDown:(f)=>{if(f.key==="Enter"||f.key===" ")T(G)},children:[K("div",{className:"mb-2 flex items-center justify-between",children:[Z("h3",{className:"font-medium",children:G.name}),Z("span",{className:`inline-flex rounded-full px-2 py-0.5 font-medium text-xs ${fm[G.status]??""}`,children:G.status})]}),Z("p",{className:"mb-3 text-muted-foreground text-sm",children:G.description}),K("div",{className:"flex items-center justify-between text-muted-foreground text-xs",children:[K("span",{children:["/",G.slug]}),G.isPublic&&Z("span",{className:"text-green-600 dark:text-green-400",children:"\uD83C\uDF10 Public"})]})]},G.id)),N.length===0&&Z("div",{className:"col-span-full flex h-64 items-center justify-center text-muted-foreground",children:"No dashboards created yet"})]}),W?Z(mm,{dashboardName:W.name,widgets:j}):null]}),m==="queries"&&Z($m,{queries:J})]})]})}export{Y2 as AnalyticsDashboard};