reactbridge-sdk 0.2.2 → 0.2.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.
package/dist/index.js CHANGED
@@ -2153,39 +2153,11 @@ const AnalyticsWidget = ({ position = 'bottom-right', theme: customTheme, onDire
2153
2153
  isOpen && (React.createElement(AnalyticsDrawer, { isOpen: isOpen, onClose: () => setIsOpen(false), configs: configs, isLoading: isLoading, theme: theme, onDirectiveAction: onDirectiveAction }))));
2154
2154
  };
2155
2155
 
2156
- function styleInject(css, ref) {
2157
- if ( ref === void 0 ) ref = {};
2158
- var insertAt = ref.insertAt;
2159
-
2160
- if (typeof document === 'undefined') { return; }
2161
-
2162
- var head = document.head || document.getElementsByTagName('head')[0];
2163
- var style = document.createElement('style');
2164
- style.type = 'text/css';
2165
-
2166
- if (insertAt === 'top') {
2167
- if (head.firstChild) {
2168
- head.insertBefore(style, head.firstChild);
2169
- } else {
2170
- head.appendChild(style);
2171
- }
2172
- } else {
2173
- head.appendChild(style);
2174
- }
2175
-
2176
- if (style.styleSheet) {
2177
- style.styleSheet.cssText = css;
2178
- } else {
2179
- style.appendChild(document.createTextNode(css));
2180
- }
2181
- }
2182
-
2183
- var css_248z = ".analytics-dashboard{background:var(--rb-color-background,#fff);border:1px solid var(--rb-color-border,#e5e7eb);border-radius:8px;font-family:var(--rb-font-family,-apple-system,BlinkMacSystemFont,\"Segoe UI\",sans-serif);min-height:600px;overflow:hidden;width:100%}.analytics-dashboard-header{align-items:center;background:var(--rb-color-surface,#fff);border-bottom:1px solid var(--rb-color-border,#e5e7eb);display:flex;justify-content:space-between;padding:24px}.analytics-dashboard-title{color:var(--rb-color-text,#111827);font-size:24px;font-weight:700;margin:0}.analytics-dashboard-subtitle{color:var(--rb-color-text-secondary,#6b7280);font-size:14px;margin:4px 0 0}.analytics-dashboard-refresh-btn{align-items:center;background:var(--rb-color-primary,#3b82f6);border:none;border-radius:6px;color:#fff;cursor:pointer;display:flex;font-size:14px;font-weight:500;gap:8px;padding:8px 16px;transition:all .2s}.analytics-dashboard-refresh-btn:hover:not(:disabled){background:var(--rb-color-primary-dark,#2563eb);transform:translateY(-1px)}.analytics-dashboard-refresh-btn:disabled{cursor:not-allowed;opacity:.5}.analytics-dashboard-refresh-btn svg{animation:none}.analytics-dashboard-refresh-btn:disabled svg{animation:spin 1s linear infinite}@keyframes spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}.analytics-dashboard-content{display:flex;min-height:600px}.analytics-dashboard-sidebar{background:var(--rb-color-surface,#fafafa);border-right:1px solid var(--rb-color-border,#e5e7eb);overflow-y:auto;width:320px}.analytics-sidebar-title{color:var(--rb-color-text-secondary,#6b7280);font-size:12px;font-weight:700;letter-spacing:.05em;margin:0;padding:16px 16px 8px;text-transform:uppercase}.analytics-list{padding:8px}.analytics-list-item{background:var(--rb-color-background,#fff);border:1px solid var(--rb-color-border,#e5e7eb);border-radius:6px;cursor:pointer;margin-bottom:4px;padding:12px;text-align:left;transition:all .2s;width:100%}.analytics-list-item:hover:not(.disabled){border-color:var(--rb-color-primary,#3b82f6);box-shadow:0 2px 4px rgba(0,0,0,.05)}.analytics-list-item.active{background:var(--rb-color-primary,#3b82f6);border-color:var(--rb-color-primary,#3b82f6);color:#fff}.analytics-list-item.disabled{cursor:not-allowed;opacity:.5}.analytics-list-item-header{align-items:center;display:flex;justify-content:space-between;margin-bottom:4px}.analytics-list-item-name{font-size:14px;font-weight:600}.analytics-list-item.active .analytics-list-item-name{color:#fff}.analytics-list-item-badge{background:var(--rb-color-error,#ef4444);border-radius:4px;color:#fff;font-size:10px;font-weight:600;padding:2px 6px;text-transform:uppercase}.analytics-list-item-description{color:var(--rb-color-text-secondary,#6b7280);font-size:12px;line-height:1.4;margin:0 0 8px}.analytics-list-item.active .analytics-list-item-description{color:hsla(0,0%,100%,.9)}.analytics-list-item-meta{align-items:center;color:var(--rb-color-text-secondary,#9ca3af);display:flex;font-size:11px;justify-content:space-between}.analytics-list-item.active .analytics-list-item-meta{color:hsla(0,0%,100%,.8)}.analytics-list-item-frequency{font-weight:500;text-transform:capitalize}.analytics-dashboard-main{background:var(--rb-color-background,#fff);flex:1;overflow-y:auto;padding:24px}.analytics-dashboard-empty,.analytics-dashboard-loading,.analytics-dashboard-no-results,.analytics-dashboard-placeholder{align-items:center;color:var(--rb-color-text-secondary,#9ca3af);display:flex;flex-direction:column;justify-content:center;min-height:400px;text-align:center}.analytics-dashboard-empty svg,.analytics-dashboard-loading svg,.analytics-dashboard-no-results svg,.analytics-dashboard-placeholder svg{margin-bottom:16px;opacity:.3}.analytics-dashboard-empty p,.analytics-dashboard-no-results p,.analytics-dashboard-placeholder p{font-size:14px;margin:0}.analytics-dashboard-no-results h3{color:var(--rb-color-text,#111827);font-size:18px;font-weight:600;margin:0 0 8px}.analytics-spinner{animation:spin 1s linear infinite;border:4px solid var(--rb-color-border,#e5e7eb);border-radius:50%;border-top-color:var(--rb-color-primary,#3b82f6);height:40px;margin-bottom:16px;width:40px}.analytics-result-detail{animation:fadeIn .3s ease-in}@keyframes fadeIn{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}.analytics-result-header{border-bottom:1px solid var(--rb-color-border,#e5e7eb);margin-bottom:24px;padding-bottom:16px}.analytics-result-title{color:var(--rb-color-text,#111827);font-size:20px;font-weight:700;margin:0 0 4px}.analytics-result-date{color:var(--rb-color-text-secondary,#6b7280);font-size:13px;margin:0}.analytics-section{margin-bottom:32px}.analytics-section-header{align-items:center;display:flex;justify-content:space-between;margin-bottom:16px}.analytics-section-title{color:var(--rb-color-text,#111827);font-size:16px;font-weight:700;margin:0 0 16px}.analytics-metrics-grid{display:grid;gap:16px;grid-template-columns:repeat(auto-fill,minmax(240px,1fr))}.analytics-metric-card{background:var(--rb-color-surface,#fafafa);border:1px solid var(--rb-color-border,#e5e7eb);border-left-width:4px;border-radius:8px;padding:16px}.analytics-metric-card.status-ok{border-left-color:var(--rb-color-success,#10b981)}.analytics-metric-card.status-warning{border-left-color:#f59e0b}.analytics-metric-card.status-critical{border-left-color:var(--rb-color-error,#ef4444)}.analytics-metric-header{align-items:flex-start;display:flex;justify-content:space-between;margin-bottom:8px}.analytics-metric-name{color:var(--rb-color-text,#111827);font-size:13px;font-weight:600}.analytics-metric-status{border-radius:4px;font-size:10px;font-weight:700;padding:2px 6px;text-transform:uppercase}.analytics-metric-status.status-ok{background:#d1fae5;color:#065f46}.analytics-metric-status.status-warning{background:#fef3c7;color:#92400e}.analytics-metric-status.status-critical{background:#fee2e2;color:#991b1b}.analytics-metric-value{color:var(--rb-color-text,#111827);font-size:24px;font-weight:700;margin-bottom:4px}.analytics-metric-explanation{color:var(--rb-color-text-secondary,#6b7280);font-size:12px;line-height:1.4;margin:0}.analytics-observations-list{display:flex;flex-direction:column;gap:12px}.analytics-observation{background:var(--rb-color-surface,#fafafa);border:1px solid var(--rb-color-border,#e5e7eb);border-left-width:4px;border-radius:8px;padding:16px}.analytics-observation.severity-low{border-left-color:#3b82f6}.analytics-observation.severity-medium{border-left-color:#f59e0b}.analytics-observation.severity-high{border-left-color:var(--rb-color-error,#ef4444)}.analytics-observation-header{display:flex;gap:8px;margin-bottom:8px}.analytics-observation-severity{border-radius:4px;font-size:10px;font-weight:700;padding:2px 6px;text-transform:uppercase}.analytics-observation-severity.severity-low{background:#dbeafe;color:#1e40af}.analytics-observation-severity.severity-medium{background:#fef3c7;color:#92400e}.analytics-observation-severity.severity-high{background:#fee2e2;color:#991b1b}.analytics-observation-scope{color:var(--rb-color-text-secondary,#9ca3af);font-size:11px;text-transform:capitalize}.analytics-observation-text{color:var(--rb-color-text,#111827);font-size:14px;line-height:1.5;margin:0}.analytics-directive-filters{display:flex;gap:8px}.analytics-filter-btn{background:var(--rb-color-surface,#fafafa);border:1px solid var(--rb-color-border,#e5e7eb);border-radius:6px;color:var(--rb-color-text,#111827);cursor:pointer;font-size:12px;font-weight:500;padding:6px 12px;transition:all .2s}.analytics-filter-btn.active,.analytics-filter-btn:hover{border-color:var(--rb-color-primary,#3b82f6)}.analytics-filter-btn.active{background:var(--rb-color-primary,#3b82f6);color:#fff}.analytics-directives-list{display:flex;flex-direction:column;gap:16px}.analytics-directives-empty{color:var(--rb-color-text-secondary,#9ca3af);font-size:14px;padding:32px;text-align:center}.analytics-directive-card{background:var(--rb-color-surface,#fafafa);border:1px solid var(--rb-color-border,#e5e7eb);border-left-width:4px;border-radius:8px;padding:20px}.analytics-directive-card.priority-high{border-left-color:var(--rb-color-error,#ef4444)}.analytics-directive-card.priority-medium{border-left-color:#f59e0b}.analytics-directive-card.priority-low{border-left-color:#3b82f6}.analytics-directive-header{align-items:flex-start;display:flex;justify-content:space-between;margin-bottom:12px}.analytics-directive-priority{border-radius:4px;font-size:10px;font-weight:700;margin-right:8px;padding:3px 8px;text-transform:uppercase}.analytics-directive-priority.priority-high{background:#fee2e2;color:#991b1b}.analytics-directive-priority.priority-medium{background:#fef3c7;color:#92400e}.analytics-directive-priority.priority-low{background:#dbeafe;color:#1e40af}.analytics-directive-action{color:var(--rb-color-text,#111827);font-family:monospace;font-size:14px;font-weight:600}.analytics-directive-status{border-radius:4px;font-size:11px;font-weight:600;padding:4px 8px;text-transform:capitalize}.analytics-directive-status.status-pending{background:#fef3c7;color:#92400e}.analytics-directive-status.status-executed{background:#d1fae5;color:#065f46}.analytics-directive-status.status-declined{background:#f3f4f6;color:#4b5563}.analytics-directive-status.status-failed{background:#fee2e2;color:#991b1b}.analytics-directive-rationale{color:var(--rb-color-text,#374151);font-size:14px;line-height:1.5;margin:0 0 12px}.analytics-directive-parameters{background:var(--rb-color-background,#fff);border:1px solid var(--rb-color-border,#e5e7eb);border-radius:6px;margin-bottom:16px;padding:12px}.analytics-directive-parameters-label{color:var(--rb-color-text-secondary,#6b7280);display:block;font-size:11px;font-weight:600;margin-bottom:8px;text-transform:uppercase}.analytics-directive-parameters-list{display:flex;flex-wrap:wrap;gap:8px}.analytics-directive-parameter{color:var(--rb-color-text-secondary,#6b7280);font-family:monospace;font-size:12px}.analytics-directive-parameter strong{color:var(--rb-color-text,#111827)}.analytics-directive-actions{display:flex;gap:12px}.analytics-directive-btn{border:none;border-radius:6px;cursor:pointer;flex:1;font-size:14px;font-weight:600;padding:10px 20px;transition:all .2s}.analytics-directive-btn.execute{background:var(--rb-color-success,#10b981);color:#fff}.analytics-directive-btn.execute:hover:not(:disabled){background:#059669;box-shadow:0 4px 6px rgba(16,185,129,.2);transform:translateY(-1px)}.analytics-directive-btn.decline{background:var(--rb-color-surface,#f3f4f6);border:1px solid var(--rb-color-border,#e5e7eb);color:var(--rb-color-text,#374151)}.analytics-directive-btn.decline:hover:not(:disabled){background:#e5e7eb}.analytics-directive-btn:disabled{cursor:not-allowed;opacity:.5}@media (max-width:768px){.analytics-dashboard-content{flex-direction:column}.analytics-dashboard-sidebar{border-bottom:1px solid var(--rb-color-border,#e5e7eb);border-right:none;max-height:300px;width:100%}.analytics-metrics-grid{grid-template-columns:1fr}.analytics-directive-actions{flex-direction:column}}";
2184
- styleInject(css_248z,{"insertAt":"top"});
2185
-
2186
- function AnalyticsDashboard({ onDirectiveAction, className = '', showRefresh = true, autoRefreshInterval = 0, }) {
2156
+ function AnalyticsDashboard({ onDirectiveAction, className = "", showRefresh = true, autoRefreshInterval = 0, theme: customTheme, }) {
2157
+ const { theme: contextTheme } = useReactBridgeContext();
2158
+ const theme = customTheme || contextTheme;
2187
2159
  const [selectedAnalytics, setSelectedAnalytics] = React.useState(null);
2188
- const [directiveFilter, setDirectiveFilter] = React.useState('all');
2160
+ const [directiveFilter, setDirectiveFilter] = React.useState("all");
2189
2161
  // Fetch analytics configurations
2190
2162
  const { configs, isLoading: configsLoading, error: configsError, refetch: refetchConfigs, } = useAnalyticsConfigs();
2191
2163
  // Fetch latest result for selected analytics
@@ -2221,108 +2193,362 @@ function AnalyticsDashboard({ onDirectiveAction, className = '', showRefresh = t
2221
2193
  // Refetch result to get updated directive statuses
2222
2194
  refetchResult();
2223
2195
  });
2224
- const filteredDirectives = (result === null || result === void 0 ? void 0 : result.directives.filter(d => {
2225
- if (directiveFilter === 'all')
2196
+ const filteredDirectives = (result === null || result === void 0 ? void 0 : result.directives.filter((d) => {
2197
+ if (directiveFilter === "all")
2226
2198
  return true;
2227
2199
  return d.status === directiveFilter;
2228
2200
  })) || [];
2229
- const selectedConfig = configs === null || configs === void 0 ? void 0 : configs.find(c => c.analyticsType === selectedAnalytics);
2230
- return (React.createElement("div", { className: `rb-analytics-dashboard ${className}` },
2231
- React.createElement("div", { className: "rb-analytics-sidebar" },
2232
- React.createElement("div", { className: "rb-analytics-sidebar-header" },
2233
- React.createElement("h3", null, "Analytics"),
2234
- showRefresh && (React.createElement("button", { onClick: handleRefresh, disabled: configsLoading, className: "rb-analytics-refresh-btn", title: "Refresh" }, "\u21BB"))),
2235
- configsLoading && (React.createElement("div", { className: "rb-analytics-loading" }, "Loading analytics...")),
2236
- configsError && (React.createElement("div", { className: "rb-analytics-error" },
2201
+ const selectedConfig = configs === null || configs === void 0 ? void 0 : configs.find((c) => c.analyticsType === selectedAnalytics);
2202
+ const proposedCount = (result === null || result === void 0 ? void 0 : result.directives.filter((d) => d.status === "proposed").length) || 0;
2203
+ const executedCount = (result === null || result === void 0 ? void 0 : result.directives.filter((d) => d.status === "executed").length) || 0;
2204
+ const declinedCount = (result === null || result === void 0 ? void 0 : result.directives.filter((d) => d.status === "declined").length) || 0;
2205
+ const containerStyle = {
2206
+ display: "flex",
2207
+ gap: theme.spacing.lg,
2208
+ width: "100%",
2209
+ minHeight: "540px",
2210
+ backgroundColor: theme.colors.background,
2211
+ color: theme.colors.text,
2212
+ border: `1px solid ${theme.colors.border}`,
2213
+ borderRadius: theme.borderRadius,
2214
+ boxShadow: theme.boxShadow,
2215
+ padding: theme.spacing.lg,
2216
+ };
2217
+ const sidebarStyle = {
2218
+ width: "320px",
2219
+ borderRight: `1px solid ${theme.colors.border}`,
2220
+ paddingRight: theme.spacing.lg,
2221
+ display: "flex",
2222
+ flexDirection: "column",
2223
+ gap: theme.spacing.sm,
2224
+ };
2225
+ const listItemStyle = (isActive, isDisabled) => ({
2226
+ width: "100%",
2227
+ textAlign: "left",
2228
+ padding: theme.spacing.md,
2229
+ backgroundColor: isActive ? theme.colors.primary : theme.colors.surface,
2230
+ color: isActive ? "#fff" : theme.colors.text,
2231
+ border: `1px solid ${isActive ? theme.colors.primary : theme.colors.border}`,
2232
+ borderRadius: theme.borderRadius,
2233
+ cursor: isDisabled ? "not-allowed" : "pointer",
2234
+ opacity: isDisabled ? 0.6 : 1,
2235
+ transition: "transform 0.15s ease, box-shadow 0.15s ease",
2236
+ boxShadow: isActive ? theme.boxShadow : "none",
2237
+ });
2238
+ const pillStyle = (bg) => ({
2239
+ fontSize: theme.fontSizes.xs,
2240
+ padding: "2px 8px",
2241
+ borderRadius: "999px",
2242
+ backgroundColor: bg,
2243
+ color: "#fff",
2244
+ fontWeight: 600,
2245
+ });
2246
+ const placeholderStyle = {
2247
+ flex: 1,
2248
+ minHeight: "420px",
2249
+ display: "flex",
2250
+ flexDirection: "column",
2251
+ alignItems: "center",
2252
+ justifyContent: "center",
2253
+ gap: theme.spacing.sm,
2254
+ color: theme.colors.textSecondary,
2255
+ textAlign: "center",
2256
+ };
2257
+ const cardStyle = {
2258
+ backgroundColor: theme.colors.surface,
2259
+ border: `1px solid ${theme.colors.border}`,
2260
+ borderRadius: theme.borderRadius,
2261
+ padding: theme.spacing.md,
2262
+ };
2263
+ const statusBadgeStyle = (status) => {
2264
+ const colors = {
2265
+ proposed: { bg: theme.colors.primary, text: "#fff" },
2266
+ executed: { bg: theme.colors.success, text: "#fff" },
2267
+ declined: { bg: theme.colors.error, text: "#fff" },
2268
+ ok: { bg: "#d1fae5", text: "#065f46" },
2269
+ warning: { bg: "#fef3c7", text: "#92400e" },
2270
+ critical: { bg: "#fee2e2", text: "#991b1b" },
2271
+ high: { bg: "#fee2e2", text: "#991b1b" },
2272
+ medium: { bg: "#fef3c7", text: "#92400e" },
2273
+ low: { bg: "#e0ecff", text: "#1e3a8a" },
2274
+ };
2275
+ const palette = colors[status] || {
2276
+ bg: theme.colors.surface,
2277
+ text: theme.colors.text,
2278
+ };
2279
+ return {
2280
+ fontSize: theme.fontSizes.xs,
2281
+ padding: "2px 8px",
2282
+ borderRadius: "999px",
2283
+ backgroundColor: palette.bg,
2284
+ color: palette.text,
2285
+ fontWeight: 700,
2286
+ textTransform: "capitalize",
2287
+ };
2288
+ };
2289
+ const directiveCardStyle = (status) => (Object.assign(Object.assign({}, cardStyle), { borderLeft: `4px solid ${status === "executed"
2290
+ ? theme.colors.success
2291
+ : status === "declined"
2292
+ ? theme.colors.error
2293
+ : theme.colors.primary}`, display: "flex", flexDirection: "column", gap: theme.spacing.sm }));
2294
+ return (React.createElement("div", { className: className, style: containerStyle },
2295
+ React.createElement("div", { style: sidebarStyle },
2296
+ React.createElement("div", { style: {
2297
+ display: "flex",
2298
+ justifyContent: "space-between",
2299
+ alignItems: "center",
2300
+ } },
2301
+ React.createElement("h3", { style: { margin: 0, fontSize: theme.fontSizes.lg } }, "Analytics"),
2302
+ showRefresh && (React.createElement("button", { type: "button", onClick: handleRefresh, disabled: configsLoading, style: {
2303
+ border: `1px solid ${theme.colors.border}`,
2304
+ backgroundColor: theme.colors.surface,
2305
+ color: theme.colors.text,
2306
+ padding: `${theme.spacing.xs} ${theme.spacing.sm}`,
2307
+ borderRadius: theme.borderRadius,
2308
+ cursor: configsLoading ? "not-allowed" : "pointer",
2309
+ } }, configsLoading ? "Refreshing..." : "Refresh"))),
2310
+ configsLoading && (React.createElement("div", { style: placeholderStyle }, "Loading analytics...")),
2311
+ configsError && (React.createElement("div", { style: placeholderStyle },
2237
2312
  "Error loading analytics: ",
2238
2313
  configsError.message)),
2239
- configs && configs.length === 0 && (React.createElement("div", { className: "rb-analytics-empty" }, "No analytics configured. Please configure analytics in your DirectivSys dashboard.")),
2240
- configs && configs.length > 0 && (React.createElement("div", { className: "rb-analytics-list" }, configs.map((config) => (React.createElement("button", { key: config.configId, onClick: () => setSelectedAnalytics(config.analyticsType), className: `rb-analytics-item ${selectedAnalytics === config.analyticsType ? 'active' : ''} ${!config.isEnabled ? 'disabled' : ''}` },
2241
- React.createElement("div", { className: "rb-analytics-item-header" },
2242
- React.createElement("span", { className: "rb-analytics-item-name" }, config.analyticsType),
2243
- !config.isEnabled && (React.createElement("span", { className: "rb-analytics-item-badge disabled" }, "Disabled"))),
2244
- React.createElement("div", { className: "rb-analytics-item-description" }, config.templateDescription),
2245
- React.createElement("div", { className: "rb-analytics-item-footer" },
2246
- React.createElement("span", { className: "rb-analytics-item-frequency" }, config.frequency),
2247
- config.lastExecutedAt && (React.createElement("span", { className: "rb-analytics-item-date" },
2248
- "Last: ",
2249
- new Date(config.lastExecutedAt).toLocaleDateString()))))))))),
2250
- React.createElement("div", { className: "rb-analytics-main" },
2251
- !selectedAnalytics && (React.createElement("div", { className: "rb-analytics-empty-state" },
2252
- React.createElement("h3", null, "No Analytics Selected"),
2253
- React.createElement("p", null, "Select an analytics type from the sidebar to view results."))),
2254
- selectedAnalytics && resultLoading && (React.createElement("div", { className: "rb-analytics-loading" }, "Loading results...")),
2255
- selectedAnalytics && resultError && (React.createElement("div", { className: "rb-analytics-error" },
2314
+ configs && configs.length === 0 && (React.createElement("div", { style: placeholderStyle }, "No analytics configured. Configure analytics in your DirectivSys dashboard.")),
2315
+ configs && configs.length > 0 && (React.createElement("div", { style: {
2316
+ display: "flex",
2317
+ flexDirection: "column",
2318
+ gap: theme.spacing.sm,
2319
+ } }, configs.map((config) => {
2320
+ const isActive = selectedAnalytics === config.analyticsType;
2321
+ return (React.createElement("button", { key: config.configId, type: "button", onClick: () => config.isEnabled &&
2322
+ setSelectedAnalytics(config.analyticsType), style: listItemStyle(isActive, !config.isEnabled), disabled: !config.isEnabled },
2323
+ React.createElement("div", { style: {
2324
+ display: "flex",
2325
+ justifyContent: "space-between",
2326
+ alignItems: "center",
2327
+ marginBottom: theme.spacing.xs,
2328
+ width: "100%",
2329
+ } },
2330
+ React.createElement("span", { style: { fontSize: theme.fontSizes.md, fontWeight: 600 } }, config.analyticsType),
2331
+ !config.isEnabled && (React.createElement("span", { style: pillStyle(theme.colors.textSecondary) }, "Disabled"))),
2332
+ React.createElement("div", { style: {
2333
+ fontSize: theme.fontSizes.sm,
2334
+ color: isActive
2335
+ ? "rgba(255,255,255,0.9)"
2336
+ : theme.colors.textSecondary,
2337
+ marginBottom: theme.spacing.xs,
2338
+ } }, config.templateDescription),
2339
+ React.createElement("div", { style: {
2340
+ display: "flex",
2341
+ justifyContent: "space-between",
2342
+ width: "100%",
2343
+ fontSize: theme.fontSizes.xs,
2344
+ color: isActive
2345
+ ? "rgba(255,255,255,0.8)"
2346
+ : theme.colors.textSecondary,
2347
+ } },
2348
+ React.createElement("span", { style: { textTransform: "capitalize" } }, config.frequency),
2349
+ config.lastExecutedAt && (React.createElement("span", null,
2350
+ "Last:",
2351
+ " ",
2352
+ new Date(config.lastExecutedAt).toLocaleDateString())))));
2353
+ })))),
2354
+ React.createElement("div", { style: {
2355
+ flex: 1,
2356
+ display: "flex",
2357
+ flexDirection: "column",
2358
+ gap: theme.spacing.lg,
2359
+ } },
2360
+ !selectedAnalytics && (React.createElement("div", { style: placeholderStyle },
2361
+ React.createElement("h3", { style: { margin: 0, color: theme.colors.text } }, "No analytics selected"),
2362
+ React.createElement("p", { style: { margin: 0 } }, "Select an analytics type from the left to view results."))),
2363
+ selectedAnalytics && resultLoading && (React.createElement("div", { style: placeholderStyle }, "Loading results...")),
2364
+ selectedAnalytics && resultError && (React.createElement("div", { style: placeholderStyle },
2256
2365
  "Error loading results: ",
2257
2366
  resultError.message)),
2258
- selectedAnalytics && !resultLoading && !result && (React.createElement("div", { className: "rb-analytics-empty-state" },
2259
- React.createElement("h3", null, "No Results Available"),
2260
- React.createElement("p", null, "This analytics has not been executed yet. Results will appear here once the first run completes."))),
2261
- selectedAnalytics && result && (React.createElement("div", { className: "rb-analytics-content" },
2262
- React.createElement("div", { className: "rb-analytics-content-header" },
2263
- React.createElement("div", null,
2264
- React.createElement("h2", null, selectedConfig === null || selectedConfig === void 0 ? void 0 : selectedConfig.analyticsType),
2265
- React.createElement("p", { className: "rb-analytics-content-date" },
2266
- "Generated: ",
2267
- new Date(result.createdAt).toLocaleString()))),
2268
- result.metrics && result.metrics.length > 0 && (React.createElement("div", { className: "rb-analytics-section" },
2269
- React.createElement("h3", { className: "rb-analytics-section-title" }, "Metrics"),
2270
- React.createElement("div", { className: "rb-analytics-metrics-grid" }, result.metrics.map((metric, index) => (React.createElement("div", { key: index, className: `rb-analytics-metric-card status-${metric.status}` },
2271
- React.createElement("div", { className: "rb-analytics-metric-header" },
2272
- React.createElement("span", { className: "rb-analytics-metric-name" }, metric.name),
2273
- React.createElement("span", { className: `rb-analytics-metric-status ${metric.status}` }, metric.status)),
2274
- React.createElement("div", { className: "rb-analytics-metric-value" },
2367
+ selectedAnalytics && !resultLoading && !result && (React.createElement("div", { style: placeholderStyle },
2368
+ React.createElement("h3", { style: { margin: 0, color: theme.colors.text } }, "No results yet"),
2369
+ React.createElement("p", { style: { margin: 0 } }, "This analytics has not run yet. Results will appear after the first run."))),
2370
+ selectedAnalytics && result && (React.createElement("div", { style: {
2371
+ display: "flex",
2372
+ flexDirection: "column",
2373
+ gap: theme.spacing.lg,
2374
+ } },
2375
+ React.createElement("div", { style: {
2376
+ display: "flex",
2377
+ flexDirection: "column",
2378
+ gap: theme.spacing.xs,
2379
+ } },
2380
+ React.createElement("h2", { style: {
2381
+ margin: 0,
2382
+ fontSize: theme.fontSizes.xl,
2383
+ color: theme.colors.text,
2384
+ } }, selectedConfig === null || selectedConfig === void 0 ? void 0 : selectedConfig.analyticsType),
2385
+ React.createElement("p", { style: {
2386
+ margin: 0,
2387
+ color: theme.colors.textSecondary,
2388
+ fontSize: theme.fontSizes.sm,
2389
+ } },
2390
+ "Generated: ",
2391
+ new Date(result.createdAt).toLocaleString())),
2392
+ result.metrics && result.metrics.length > 0 && (React.createElement("div", { style: {
2393
+ display: "flex",
2394
+ flexDirection: "column",
2395
+ gap: theme.spacing.md,
2396
+ } },
2397
+ React.createElement("h3", { style: { margin: 0, fontSize: theme.fontSizes.lg } }, "Metrics"),
2398
+ React.createElement("div", { style: {
2399
+ display: "grid",
2400
+ gridTemplateColumns: "repeat(auto-fill, minmax(220px, 1fr))",
2401
+ gap: theme.spacing.md,
2402
+ } }, result.metrics.map((metric, index) => (React.createElement("div", { key: index, style: Object.assign(Object.assign({}, cardStyle), { borderLeft: `4px solid ${metric.status === "ok"
2403
+ ? theme.colors.success
2404
+ : metric.status === "warning"
2405
+ ? "#f59e0b"
2406
+ : theme.colors.error}` }) },
2407
+ React.createElement("div", { style: {
2408
+ display: "flex",
2409
+ justifyContent: "space-between",
2410
+ alignItems: "center",
2411
+ marginBottom: theme.spacing.xs,
2412
+ } },
2413
+ React.createElement("span", { style: {
2414
+ fontWeight: 600,
2415
+ maxWidth: "100%",
2416
+ overflow: "hidden",
2417
+ textOverflow: "ellipsis",
2418
+ whiteSpace: "nowrap",
2419
+ display: "inline-block",
2420
+ }, title: metric.name }, metric.name),
2421
+ React.createElement("span", { style: statusBadgeStyle(metric.status) }, metric.status)),
2422
+ React.createElement("div", { style: {
2423
+ fontSize: theme.fontSizes.xl,
2424
+ fontWeight: 700,
2425
+ } },
2275
2426
  metric.value,
2276
2427
  " ",
2277
2428
  metric.unit),
2278
- React.createElement("div", { className: "rb-analytics-metric-explanation" }, metric.explanation))))))),
2279
- result.observations && result.observations.length > 0 && (React.createElement("div", { className: "rb-analytics-section" },
2280
- React.createElement("h3", { className: "rb-analytics-section-title" }, "Observations"),
2281
- React.createElement("div", { className: "rb-analytics-observations-list" }, result.observations.map((observation, index) => (React.createElement("div", { key: index, className: `rb-analytics-observation severity-${observation.severity}` },
2282
- React.createElement("div", { className: "rb-analytics-observation-header" },
2283
- React.createElement("span", { className: `rb-analytics-observation-severity ${observation.severity}` }, observation.severity),
2284
- React.createElement("span", { className: "rb-analytics-observation-scope" }, observation.scope)),
2285
- React.createElement("div", { className: "rb-analytics-observation-text" }, observation.text))))))),
2286
- result.directives && result.directives.length > 0 && (React.createElement("div", { className: "rb-analytics-section" },
2287
- React.createElement("div", { className: "rb-analytics-directives-header" },
2288
- React.createElement("h3", { className: "rb-analytics-section-title" }, "Recommended Actions"),
2289
- React.createElement("div", { className: "rb-analytics-directive-filters" },
2290
- React.createElement("button", { onClick: () => setDirectiveFilter('all'), className: directiveFilter === 'all' ? 'active' : '' },
2429
+ React.createElement("div", { style: {
2430
+ color: theme.colors.textSecondary,
2431
+ fontSize: theme.fontSizes.sm,
2432
+ } }, metric.explanation))))))),
2433
+ result.observations && result.observations.length > 0 && (React.createElement("div", { style: {
2434
+ display: "flex",
2435
+ flexDirection: "column",
2436
+ gap: theme.spacing.md,
2437
+ } },
2438
+ React.createElement("h3", { style: { margin: 0, fontSize: theme.fontSizes.lg } }, "Observations"),
2439
+ React.createElement("div", { style: {
2440
+ display: "flex",
2441
+ flexDirection: "column",
2442
+ gap: theme.spacing.sm,
2443
+ } }, result.observations.map((observation, index) => (React.createElement("div", { key: index, style: Object.assign(Object.assign({}, cardStyle), { borderLeft: `4px solid ${observation.severity === "high"
2444
+ ? theme.colors.error
2445
+ : observation.severity === "medium"
2446
+ ? "#f59e0b"
2447
+ : theme.colors.primary}`, display: "flex", flexDirection: "column", gap: theme.spacing.xs }) },
2448
+ React.createElement("div", { style: {
2449
+ display: "flex",
2450
+ gap: theme.spacing.sm,
2451
+ alignItems: "center",
2452
+ } },
2453
+ React.createElement("span", { style: statusBadgeStyle(observation.severity) }, observation.severity),
2454
+ React.createElement("span", { style: {
2455
+ color: theme.colors.textSecondary,
2456
+ fontSize: theme.fontSizes.sm,
2457
+ } }, observation.scope)),
2458
+ React.createElement("div", { style: {
2459
+ color: theme.colors.text,
2460
+ fontSize: theme.fontSizes.sm,
2461
+ } }, observation.text))))))),
2462
+ result.directives && result.directives.length > 0 && (React.createElement("div", { style: {
2463
+ display: "flex",
2464
+ flexDirection: "column",
2465
+ gap: theme.spacing.md,
2466
+ } },
2467
+ React.createElement("div", { style: {
2468
+ display: "flex",
2469
+ justifyContent: "space-between",
2470
+ alignItems: "center",
2471
+ } },
2472
+ React.createElement("h3", { style: { margin: 0, fontSize: theme.fontSizes.lg } }, "Recommended actions"),
2473
+ React.createElement("div", { style: { display: "flex", gap: theme.spacing.xs } },
2474
+ React.createElement("button", { type: "button", onClick: () => setDirectiveFilter("all"), style: Object.assign(Object.assign({}, pillStyle(directiveFilter === "all"
2475
+ ? theme.colors.primary
2476
+ : theme.colors.surface)), { border: `1px solid ${theme.colors.border}`, color: directiveFilter === "all"
2477
+ ? "#fff"
2478
+ : theme.colors.text }) },
2291
2479
  "All (",
2292
2480
  result.directives.length,
2293
2481
  ")"),
2294
- React.createElement("button", { onClick: () => setDirectiveFilter('proposed'), className: directiveFilter === 'proposed' ? 'active' : '' },
2482
+ React.createElement("button", { type: "button", onClick: () => setDirectiveFilter("proposed"), style: Object.assign(Object.assign({}, pillStyle(directiveFilter === "proposed"
2483
+ ? theme.colors.primary
2484
+ : theme.colors.surface)), { border: `1px solid ${theme.colors.border}`, color: directiveFilter === "proposed"
2485
+ ? "#fff"
2486
+ : theme.colors.text }) },
2295
2487
  "Proposed (",
2296
- result.directives.filter(d => d.status === 'proposed').length,
2488
+ proposedCount,
2297
2489
  ")"),
2298
- React.createElement("button", { onClick: () => setDirectiveFilter('executed'), className: directiveFilter === 'executed' ? 'active' : '' },
2490
+ React.createElement("button", { type: "button", onClick: () => setDirectiveFilter("executed"), style: Object.assign(Object.assign({}, pillStyle(directiveFilter === "executed"
2491
+ ? theme.colors.primary
2492
+ : theme.colors.surface)), { border: `1px solid ${theme.colors.border}`, color: directiveFilter === "executed"
2493
+ ? "#fff"
2494
+ : theme.colors.text }) },
2299
2495
  "Executed (",
2300
- result.directives.filter(d => d.status === 'executed').length,
2496
+ executedCount,
2301
2497
  ")"),
2302
- React.createElement("button", { onClick: () => setDirectiveFilter('declined'), className: directiveFilter === 'declined' ? 'active' : '' },
2498
+ React.createElement("button", { type: "button", onClick: () => setDirectiveFilter("declined"), style: Object.assign(Object.assign({}, pillStyle(directiveFilter === "declined"
2499
+ ? theme.colors.primary
2500
+ : theme.colors.surface)), { border: `1px solid ${theme.colors.border}`, color: directiveFilter === "declined"
2501
+ ? "#fff"
2502
+ : theme.colors.text }) },
2303
2503
  "Declined (",
2304
- result.directives.filter(d => d.status === 'declined').length,
2504
+ declinedCount,
2305
2505
  ")"))),
2306
- filteredDirectives.length === 0 && (React.createElement("div", { className: "rb-analytics-empty-state" },
2307
- React.createElement("p", null, "No directives match the selected filter."))),
2308
- React.createElement("div", { className: "rb-analytics-directives-list" }, filteredDirectives.map((directive) => (React.createElement("div", { key: directive.directiveId, className: `rb-analytics-directive status-${directive.status}` },
2309
- React.createElement("div", { className: "rb-analytics-directive-header" },
2310
- React.createElement("div", null,
2311
- React.createElement("span", { className: "rb-analytics-directive-action" }, directive.action),
2312
- React.createElement("span", { className: `rb-analytics-directive-priority priority-${directive.priority}` },
2506
+ filteredDirectives.length === 0 && (React.createElement("div", { style: placeholderStyle }, "No directives match the selected filter.")),
2507
+ React.createElement("div", { style: {
2508
+ display: "flex",
2509
+ flexDirection: "column",
2510
+ gap: theme.spacing.sm,
2511
+ } }, filteredDirectives.map((directive) => (React.createElement("div", { key: directive.directiveId, style: directiveCardStyle(directive.status) },
2512
+ React.createElement("div", { style: {
2513
+ display: "flex",
2514
+ justifyContent: "space-between",
2515
+ alignItems: "center",
2516
+ gap: theme.spacing.sm,
2517
+ flexWrap: "wrap",
2518
+ } },
2519
+ React.createElement("div", { style: {
2520
+ display: "flex",
2521
+ flexDirection: "column",
2522
+ gap: theme.spacing.xs,
2523
+ } },
2524
+ React.createElement("span", { style: { fontWeight: 700 } }, directive.action),
2525
+ React.createElement("span", { style: {
2526
+ color: theme.colors.textSecondary,
2527
+ fontSize: theme.fontSizes.sm,
2528
+ } },
2313
2529
  "Priority: ",
2314
2530
  directive.priority)),
2315
- React.createElement("span", { className: `rb-analytics-directive-status ${directive.status}` }, directive.status)),
2316
- React.createElement("div", { className: "rb-analytics-directive-rationale" }, directive.rationale),
2317
- directive.parameters && directive.parameters.length > 0 && (React.createElement("div", { className: "rb-analytics-directive-parameters" },
2318
- React.createElement("strong", null, "Parameters:"),
2319
- React.createElement("ul", null, directive.parameters.map((param, index) => (React.createElement("li", { key: index },
2531
+ React.createElement("span", { style: statusBadgeStyle(directive.status) }, directive.status)),
2532
+ React.createElement("div", { style: {
2533
+ color: theme.colors.text,
2534
+ fontSize: theme.fontSizes.sm,
2535
+ } }, directive.rationale),
2536
+ directive.parameters &&
2537
+ directive.parameters.length > 0 && (React.createElement("div", { style: {
2538
+ color: theme.colors.textSecondary,
2539
+ fontSize: theme.fontSizes.sm,
2540
+ } },
2541
+ React.createElement("strong", { style: { color: theme.colors.text } }, "Parameters:"),
2542
+ React.createElement("ul", { style: {
2543
+ margin: `${theme.spacing.xs} 0 0 16px`,
2544
+ padding: 0,
2545
+ } }, directive.parameters.map((param, index) => (React.createElement("li", { key: index, style: { marginBottom: theme.spacing.xs } },
2320
2546
  React.createElement("code", null, param.name),
2321
2547
  ": ",
2322
2548
  param.value)))))),
2323
- directive.status === 'proposed' && (React.createElement("div", { className: "rb-analytics-directive-actions" },
2324
- React.createElement("button", { onClick: () => handleDirectiveAction(directive, 'execute'), disabled: isProcessing, className: "rb-analytics-directive-btn execute" }, isProcessing ? 'Processing...' : 'Execute'),
2325
- React.createElement("button", { onClick: () => handleDirectiveAction(directive, 'decline'), disabled: isProcessing, className: "rb-analytics-directive-btn decline" }, "Decline"))))))))))))));
2549
+ directive.status === "proposed" && (React.createElement("div", { style: { display: "flex", gap: theme.spacing.sm } },
2550
+ React.createElement("button", { type: "button", onClick: () => handleDirectiveAction(directive, "execute"), disabled: isProcessing, style: Object.assign(Object.assign({}, pillStyle(theme.colors.success)), { border: "none", cursor: isProcessing ? "not-allowed" : "pointer" }) }, isProcessing ? "Processing..." : "Execute"),
2551
+ React.createElement("button", { type: "button", onClick: () => handleDirectiveAction(directive, "decline"), disabled: isProcessing, style: Object.assign(Object.assign({}, pillStyle(theme.colors.error)), { border: "none", cursor: isProcessing ? "not-allowed" : "pointer" }) }, "Decline"))))))))))))));
2326
2552
  }
2327
2553
 
2328
2554
  exports.AnalyticsAPI = AnalyticsAPI;