react-semaphor 0.1.449 → 0.1.453
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/analytics-protocol/index.cjs +1 -1
- package/dist/analytics-protocol/index.js +115 -109
- package/dist/appearance/index.cjs +1 -1
- package/dist/appearance/index.js +1 -1
- package/dist/brand-studio/index.cjs +4 -4
- package/dist/brand-studio/index.js +15 -13
- package/dist/briefings/index.cjs +1 -1
- package/dist/briefings/index.js +39 -2131
- package/dist/chunks/{analyze-result-contract-BHb7sUUW.cjs → analyze-result-contract-Dxw66nUG.cjs} +1 -1
- package/dist/chunks/{analyze-result-contract-T-0Ntzys.js → analyze-result-contract-GHKFwThg.js} +1 -1
- package/dist/chunks/canonical-result-keys-Drc2x-lf.cjs +1 -0
- package/dist/chunks/canonical-result-keys-KLk__J_O.js +466 -0
- package/dist/chunks/color-CJvdlFM_.js +2162 -0
- package/dist/chunks/color-CyB5o13F.cjs +4 -0
- package/dist/chunks/{common-types-CQ6SHfLk.cjs → common-types-Ci66eflG.cjs} +1 -1
- package/dist/chunks/{common-types-B7Jk3Rtj.js → common-types-F6qk6PPS.js} +1 -1
- package/dist/chunks/contracts-CoCOpd_i.js +11 -0
- package/dist/chunks/contracts-CtB2VONT.cjs +1 -0
- package/dist/chunks/{dashboard-briefing-launcher-DCHiEkLE.js → dashboard-briefing-launcher-CFpX0WX3.js} +86 -84
- package/dist/chunks/dashboard-briefing-launcher-mUXWuiOZ.cjs +26 -0
- package/dist/chunks/{dashboard-controls-DwRFCcHV.js → dashboard-controls-BeYAmOJc.js} +15 -13
- package/dist/chunks/{dashboard-controls-CaFioayc.cjs → dashboard-controls-SoNubIu1.cjs} +1 -1
- package/dist/chunks/dashboard-json-BublPnQ4.cjs +1 -0
- package/dist/chunks/{dashboard-json-WoILbfTe.js → dashboard-json-DeLUagVV.js} +25 -23
- package/dist/chunks/edit-dashboard-visual-CrvPcO7A.cjs +172 -0
- package/dist/chunks/{edit-dashboard-visual-ciFhxqaI.js → edit-dashboard-visual-Go0h82DR.js} +6925 -6947
- package/dist/chunks/editor-action-buttons-1Lo0fIh7.cjs +16 -0
- package/dist/chunks/{editor-action-buttons-BPo_45pM.js → editor-action-buttons-BFNtjFzO.js} +41 -39
- package/dist/chunks/format-types-CFHQoIuk.js +1350 -0
- package/dist/chunks/format-types-PSZZ7hG8.cjs +1 -0
- package/dist/chunks/index-B3ZugihZ.js +3713 -0
- package/dist/chunks/{index-CPuawpXJ.js → index-BsH32bn1.js} +47472 -47845
- package/dist/chunks/index-ByFbacH7.cjs +1 -0
- package/dist/chunks/index-CACdoqu3.js +318 -0
- package/dist/chunks/index-DSKR3nKn.js +421 -0
- package/dist/chunks/index-DjiIh_9n.cjs +4 -0
- package/dist/chunks/index-F25jnH0p.cjs +1 -0
- package/dist/chunks/index-q12_nNUS.cjs +1392 -0
- package/dist/chunks/{metric-comparison-97zHGEx5.js → metric-comparison-D0T0MKRK.js} +1 -1
- package/dist/chunks/{metric-comparison-CUAJ8n4y.cjs → metric-comparison-DYR3RXam.cjs} +1 -1
- package/dist/chunks/pivot-header-presentation-DcfPaCiy.cjs +4 -0
- package/dist/chunks/pivot-header-presentation-nk604qc1.js +557 -0
- package/dist/chunks/{pivot-result-identity-CwJWpKI7.js → pivot-result-identity-C43Ai5Kr.js} +1 -1
- package/dist/chunks/{pivot-result-identity-CDLRT-YG.cjs → pivot-result-identity-CRUokNgm.cjs} +1 -1
- package/dist/chunks/pivot-result-lifecycle-4kSe0Hk1.js +1642 -0
- package/dist/chunks/pivot-result-lifecycle-BiJepH5S.cjs +1 -0
- package/dist/chunks/raw-temporal-contract-BF7PjBY9.js +64 -0
- package/dist/chunks/raw-temporal-contract-CxbRFwnd.cjs +1 -0
- package/dist/chunks/report-preferences-dialog-BEVZAE3m.cjs +1 -0
- package/dist/chunks/report-preferences-dialog-BNV7qXYH.js +723 -0
- package/dist/chunks/{report-runtime-context-bCy3CVzK.js → report-runtime-context-BJQDu2fV.js} +1 -1
- package/dist/chunks/{report-runtime-context-C8LZFsqV.cjs → report-runtime-context-DjYqLV-c.cjs} +1 -1
- package/dist/chunks/saved-temporal-bucket-format-DiZdQXOL.js +924 -0
- package/dist/chunks/saved-temporal-bucket-format-Gfbh4IiP.cjs +1 -0
- package/dist/chunks/switch-CjJ6FHYJ.cjs +138 -0
- package/dist/chunks/{switch-BXet-Sno.js → switch-DgLwr7O-.js} +4352 -5249
- package/dist/chunks/temporal-bucket-Dnj8qT9l.cjs +1 -0
- package/dist/chunks/temporal-bucket-FBZGrDCe.js +560 -0
- package/dist/chunks/temporal-bucket-authoring-7hv2laOG.cjs +1 -0
- package/dist/chunks/temporal-bucket-authoring-FIRnJz0e.js +221 -0
- package/dist/chunks/{temporal-bucket-contract-_F6vNhhH.js → temporal-bucket-contract-BQOj6Frl.js} +1 -1
- package/dist/chunks/{temporal-bucket-contract-ChDBWX8I.cjs → temporal-bucket-contract-anl4h-vg.cjs} +1 -1
- package/dist/chunks/{token-types-BHR58aTy.js → token-types-CRpQJ4kv.js} +1 -1
- package/dist/chunks/{token-types-BdQ8kHBm.cjs → token-types-D0i0IUX3.cjs} +1 -1
- package/dist/chunks/{update-policy-BxvYMYz0.cjs → update-policy-C1i9bgsy.cjs} +1 -1
- package/dist/chunks/{update-policy-g0rCQ9BM.js → update-policy-CaJz9aPG.js} +1 -1
- package/dist/chunks/{validators-Cs74WVie.js → validators-DeMXwRON.js} +253 -233
- package/dist/chunks/validators-Dm7Kpz6p.cjs +1 -0
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +2 -2
- package/dist/dashboard-authoring/index.cjs +3 -3
- package/dist/dashboard-authoring/index.js +32 -29
- package/dist/data-app-builder/index.cjs +1 -1
- package/dist/data-app-builder/index.js +2 -2
- package/dist/data-app-codegen/index.cjs +1 -1
- package/dist/data-app-codegen/index.js +2 -2
- package/dist/data-app-codegen-node/index.cjs +1 -1
- package/dist/data-app-codegen-node/index.js +3 -3
- package/dist/data-app-sdk/index.cjs +1 -1
- package/dist/data-app-sdk/index.js +3 -3
- package/dist/data-app-sdk-adapters/index.cjs +1 -1
- package/dist/data-app-sdk-adapters/index.js +2 -2
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +3 -3
- package/dist/format-utils/index.cjs +3 -3
- package/dist/format-utils/index.js +162 -145
- package/dist/index.cjs +1 -1
- package/dist/index.js +157 -155
- package/dist/report-runtime-context/index.cjs +1 -1
- package/dist/report-runtime-context/index.js +2 -2
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +3 -3
- package/dist/types/analytics-protocol.d.ts +37 -0
- package/dist/types/briefings.d.ts +718 -7
- package/dist/types/dashboard-assistant.d.ts +18 -0
- package/dist/types/dashboard-authoring.d.ts +52 -2
- package/dist/types/dashboard.d.ts +128 -0
- package/dist/types/data-app-sdk-validation.d.ts +13 -0
- package/dist/types/data-app-sdk.d.ts +13 -0
- package/dist/types/format-utils.d.ts +190 -3
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.js +4 -4
- package/dist/types/main.d.ts +103 -12
- package/dist/types/shared.d.ts +5 -0
- package/dist/types/surfboard.d.ts +129 -1
- package/dist/types/types.d.ts +98 -6
- package/dist/types/value-format-preferences.d.ts +3 -0
- package/package.json +2 -1
- package/dist/chunks/card-config-utils-15sRtebL.cjs +0 -1
- package/dist/chunks/card-config-utils-BYZ5MJOh.js +0 -16
- package/dist/chunks/dashboard-briefing-launcher-DDgDr2s3.cjs +0 -26
- package/dist/chunks/dashboard-json-CYtvwtvj.cjs +0 -1
- package/dist/chunks/edit-dashboard-visual-DwKcvlsF.cjs +0 -177
- package/dist/chunks/editor-action-buttons-BVmsk0Aj.cjs +0 -16
- package/dist/chunks/format-types-CSv0V7mm.cjs +0 -1
- package/dist/chunks/format-types-DZGgYj39.js +0 -1663
- package/dist/chunks/index-CJdxSyQq.js +0 -2578
- package/dist/chunks/index-DPv8_Ild.cjs +0 -1395
- package/dist/chunks/index-DRlMUglg.cjs +0 -4
- package/dist/chunks/pivot-result-lifecycle-BBabQ_da.js +0 -914
- package/dist/chunks/pivot-result-lifecycle-DPc0ANwk.cjs +0 -4
- package/dist/chunks/presentation-execution-BLfPTGX_.js +0 -637
- package/dist/chunks/presentation-execution-BTV-Q43g.cjs +0 -1
- package/dist/chunks/report-preferences-dialog-D9ZCGh9l.js +0 -691
- package/dist/chunks/report-preferences-dialog-DaqTEcac.cjs +0 -1
- package/dist/chunks/switch-Cjk6G06r.cjs +0 -138
- package/dist/chunks/temporal-bucket-BnPxGrAi.js +0 -446
- package/dist/chunks/temporal-bucket-authoring-CPTwHzvs.cjs +0 -1
- package/dist/chunks/temporal-bucket-authoring-CgOuakGW.js +0 -205
- package/dist/chunks/temporal-bucket-pMnV-4Nj.cjs +0 -1
- package/dist/chunks/temporal-result-owner-6peubmhU.js +0 -443
- package/dist/chunks/temporal-result-owner-f6-i65Fb.cjs +0 -1
- package/dist/chunks/validators-9D4KBqKD.cjs +0 -1
|
@@ -901,6 +901,8 @@ export declare type DashboardProps = {
|
|
|
901
901
|
* points. Ordinary dashboard consumers should leave this unset.
|
|
902
902
|
*/
|
|
903
903
|
interactionExecutionSnapshot?: Record<string, InteractionState>;
|
|
904
|
+
/** Server-resolved immutable presentation snapshot for internal print views. */
|
|
905
|
+
presentationExecutionSnapshot?: PresentationExecutionSnapshot;
|
|
904
906
|
/**
|
|
905
907
|
* Render target for print entry points. Generic dashboard PDF exports also
|
|
906
908
|
* use cardDisplay.mode="print"; document-specific print handling must only
|
|
@@ -1004,6 +1006,11 @@ declare type DefaultDateFilter = RelativeDateFilter | FixedMonthDefaultDateFilte
|
|
|
1004
1006
|
*/
|
|
1005
1007
|
declare interface DetailField extends Omit<Field, 'role' | 'granularity'> {
|
|
1006
1008
|
role: 'detail';
|
|
1009
|
+
/**
|
|
1010
|
+
* Query transport policy for ungrouped temporal values. This marker is
|
|
1011
|
+
* projected into executable config and is never persisted authoring state.
|
|
1012
|
+
*/
|
|
1013
|
+
dateValueMode?: 'canonical' | 'formatted';
|
|
1007
1014
|
dateFormat?: DateFormatValue;
|
|
1008
1015
|
customFormat?: string;
|
|
1009
1016
|
/**
|
|
@@ -1042,7 +1049,7 @@ export declare function DisplayFormatPreferencesFields({ value, inherited, inher
|
|
|
1042
1049
|
export declare type DisplayFormatPreferencesFieldsProps = {
|
|
1043
1050
|
value: ValueFormatPreferences;
|
|
1044
1051
|
inherited: ResolvedValueFormatPreferences;
|
|
1045
|
-
inheritedSources: Pick<ResolvedValueFormatPreferenceSources, 'locale' | 'defaultCurrency'>;
|
|
1052
|
+
inheritedSources: Pick<ResolvedValueFormatPreferenceSources, 'locale' | 'dateStyle' | 'dateTime' | 'defaultCurrency'>;
|
|
1046
1053
|
onChange: (value: ValueFormatPreferences) => void;
|
|
1047
1054
|
disabled?: boolean;
|
|
1048
1055
|
};
|
|
@@ -2101,6 +2108,32 @@ export declare type NumberOptions = {
|
|
|
2101
2108
|
colorRanges?: ColorRange[];
|
|
2102
2109
|
};
|
|
2103
2110
|
|
|
2111
|
+
declare type NumericCanonicalFormat = {
|
|
2112
|
+
type: 'number' | 'currency' | 'percent' | 'scientific';
|
|
2113
|
+
locale?: string;
|
|
2114
|
+
minimumFractionDigits?: number;
|
|
2115
|
+
maximumFractionDigits?: number;
|
|
2116
|
+
useGrouping?: boolean;
|
|
2117
|
+
prefix?: string;
|
|
2118
|
+
suffix?: string;
|
|
2119
|
+
negativeStyle?: 'minus' | 'parentheses';
|
|
2120
|
+
compact?: boolean;
|
|
2121
|
+
scale?: number;
|
|
2122
|
+
currency?: string;
|
|
2123
|
+
percentValueMode?: 'fraction' | 'whole';
|
|
2124
|
+
};
|
|
2125
|
+
|
|
2126
|
+
declare type NumericPresentationTarget = {
|
|
2127
|
+
kind: 'metric';
|
|
2128
|
+
metricId: string;
|
|
2129
|
+
} | {
|
|
2130
|
+
kind: 'column';
|
|
2131
|
+
columnKey: string;
|
|
2132
|
+
} | {
|
|
2133
|
+
kind: 'matrix_measure';
|
|
2134
|
+
measureId: string;
|
|
2135
|
+
};
|
|
2136
|
+
|
|
2104
2137
|
declare type OldFilterValue = string | number | null | (string | number)[] | RangeValue;
|
|
2105
2138
|
|
|
2106
2139
|
declare type Operation = '=' | '>' | '<' | '>=' | '<=' | '!=' | 'in' | 'not in' | 'like' | 'not like' | 'between' | 'not between' | 'is null' | 'is not null';
|
|
@@ -2178,6 +2211,18 @@ export declare type Placeholders = {
|
|
|
2178
2211
|
|
|
2179
2212
|
export declare type PluginType = 'custom' | 'standard';
|
|
2180
2213
|
|
|
2214
|
+
declare type PresentationExecutionSnapshot = {
|
|
2215
|
+
version: 1;
|
|
2216
|
+
reportContext: ReportRuntimeContext;
|
|
2217
|
+
resolvedFormats: ResolvedPresentationEntry[];
|
|
2218
|
+
};
|
|
2219
|
+
|
|
2220
|
+
declare type PresentationScope = {
|
|
2221
|
+
dashboardId: string;
|
|
2222
|
+
cardId?: string;
|
|
2223
|
+
attachmentIndex?: number;
|
|
2224
|
+
};
|
|
2225
|
+
|
|
2181
2226
|
declare interface QueryConfig {
|
|
2182
2227
|
groupByColumns?: GroupByColumn[];
|
|
2183
2228
|
pivotColumns?: GroupByColumn[];
|
|
@@ -2200,6 +2245,13 @@ declare type RangeValue = {
|
|
|
2200
2245
|
gt?: string | number;
|
|
2201
2246
|
};
|
|
2202
2247
|
|
|
2248
|
+
declare type RawTemporalPatternDialect = 'semaphor_tokens' | 'date_fns';
|
|
2249
|
+
|
|
2250
|
+
declare type RawTemporalPresentationTarget = {
|
|
2251
|
+
kind: 'column';
|
|
2252
|
+
columnKey: string;
|
|
2253
|
+
};
|
|
2254
|
+
|
|
2203
2255
|
declare type RelativeDateFilter = {
|
|
2204
2256
|
mode: 'last';
|
|
2205
2257
|
n: number;
|
|
@@ -2308,6 +2360,14 @@ export declare type ResolvedDocumentInput = {
|
|
|
2308
2360
|
exports: Record<string, string | number | boolean | null>;
|
|
2309
2361
|
};
|
|
2310
2362
|
|
|
2363
|
+
declare type ResolvedNumericPresentationEntry = {
|
|
2364
|
+
scope: PresentationScope;
|
|
2365
|
+
target: NumericPresentationTarget;
|
|
2366
|
+
format: NumericCanonicalFormat;
|
|
2367
|
+
};
|
|
2368
|
+
|
|
2369
|
+
declare type ResolvedPresentationEntry = ResolvedNumericPresentationEntry | ResolvedTemporalBucketPresentationEntry | ResolvedRawTemporalPresentationEntry;
|
|
2370
|
+
|
|
2311
2371
|
declare type ResolvedPrimaryDateField = (ResolvedPrimaryDateFieldBase & ({
|
|
2312
2372
|
defaultGranularity?: SemaphorTimeGrain;
|
|
2313
2373
|
format?: undefined;
|
|
@@ -2331,6 +2391,61 @@ declare type ResolvedPrimaryDateFieldBase = {
|
|
|
2331
2391
|
supportedGranularities?: SemaphorTimeGrain[];
|
|
2332
2392
|
};
|
|
2333
2393
|
|
|
2394
|
+
declare type ResolvedRawTemporalFormat = {
|
|
2395
|
+
type: 'raw_temporal';
|
|
2396
|
+
locale: string;
|
|
2397
|
+
calendarTimezone: string;
|
|
2398
|
+
/** Resolved source timezone for timezone-less wall datetimes, when authored. */
|
|
2399
|
+
sourceTimezone?: string;
|
|
2400
|
+
presentation: {
|
|
2401
|
+
mode: 'auto';
|
|
2402
|
+
styles: ResolvedTemporalStyleSet;
|
|
2403
|
+
} | {
|
|
2404
|
+
mode: 'pattern';
|
|
2405
|
+
dialect: RawTemporalPatternDialect;
|
|
2406
|
+
pattern: string;
|
|
2407
|
+
};
|
|
2408
|
+
};
|
|
2409
|
+
|
|
2410
|
+
declare type ResolvedRawTemporalPresentationEntry = {
|
|
2411
|
+
scope: PresentationScope;
|
|
2412
|
+
target: RawTemporalPresentationTarget;
|
|
2413
|
+
format: ResolvedRawTemporalFormat;
|
|
2414
|
+
};
|
|
2415
|
+
|
|
2416
|
+
declare type ResolvedTemporalBucketFormat = {
|
|
2417
|
+
type: 'temporal_bucket';
|
|
2418
|
+
locale: string;
|
|
2419
|
+
presentation: {
|
|
2420
|
+
mode: 'auto';
|
|
2421
|
+
styles: ResolvedTemporalStyleSet;
|
|
2422
|
+
};
|
|
2423
|
+
} | {
|
|
2424
|
+
type: 'temporal_bucket';
|
|
2425
|
+
locale: string;
|
|
2426
|
+
presentation: {
|
|
2427
|
+
mode: 'preset';
|
|
2428
|
+
preset: TemporalBucketPreset;
|
|
2429
|
+
} | {
|
|
2430
|
+
mode: 'pattern';
|
|
2431
|
+
pattern: string;
|
|
2432
|
+
};
|
|
2433
|
+
};
|
|
2434
|
+
|
|
2435
|
+
declare type ResolvedTemporalBucketPresentationEntry = {
|
|
2436
|
+
scope: PresentationScope;
|
|
2437
|
+
target: TemporalBucketPresentationTarget;
|
|
2438
|
+
format: ResolvedTemporalBucketFormat;
|
|
2439
|
+
};
|
|
2440
|
+
|
|
2441
|
+
declare type ResolvedTemporalStyleSet = {
|
|
2442
|
+
dateStyle: LocaleStyle;
|
|
2443
|
+
dateTime: {
|
|
2444
|
+
dateStyle: LocaleStyle;
|
|
2445
|
+
timeStyle: LocaleStyle;
|
|
2446
|
+
};
|
|
2447
|
+
};
|
|
2448
|
+
|
|
2334
2449
|
declare type ResolvedValueFormatPreferences = {
|
|
2335
2450
|
locale: string;
|
|
2336
2451
|
dateStyle: LocaleStyle;
|
|
@@ -3425,6 +3540,19 @@ declare type TemporalBucketPresentation = {
|
|
|
3425
3540
|
pattern: string;
|
|
3426
3541
|
};
|
|
3427
3542
|
|
|
3543
|
+
declare type TemporalBucketPresentationTarget = {
|
|
3544
|
+
kind: 'field';
|
|
3545
|
+
fieldId: string;
|
|
3546
|
+
/** Distinguishes one semantic field used on both pivot axes. */
|
|
3547
|
+
role?: 'groupby' | 'pivotby';
|
|
3548
|
+
} | {
|
|
3549
|
+
kind: 'column';
|
|
3550
|
+
columnKey: string;
|
|
3551
|
+
} | {
|
|
3552
|
+
kind: 'matrix_axis';
|
|
3553
|
+
axisInstanceId: string;
|
|
3554
|
+
};
|
|
3555
|
+
|
|
3428
3556
|
declare type TemporalBucketPreset = (typeof TEMPORAL_BUCKET_PRESETS)[number];
|
|
3429
3557
|
|
|
3430
3558
|
declare type TemporalPrecision = 'minute';
|
package/dist/types/types.d.ts
CHANGED
|
@@ -346,8 +346,7 @@ declare type BriefingFragments = {
|
|
|
346
346
|
|
|
347
347
|
export declare type BriefingJobConfig = {
|
|
348
348
|
kind: BriefingKind;
|
|
349
|
-
|
|
350
|
-
resolvedFormats?: ResolvedPresentationEntry[];
|
|
349
|
+
presentationExecutionSnapshot: PresentationExecutionSnapshot;
|
|
351
350
|
source: BriefingSource;
|
|
352
351
|
body: BriefingBody;
|
|
353
352
|
attachments: BriefingAttachment[];
|
|
@@ -702,7 +701,7 @@ export declare type CancelBriefingRunResponse = {
|
|
|
702
701
|
|
|
703
702
|
declare type CanonicalDurationUnit = 'millisecond' | 'second' | 'minute' | 'hour' | 'day';
|
|
704
703
|
|
|
705
|
-
export declare type CanonicalFormatSpec = NumericCanonicalFormat | DateCanonicalFormat | DurationCanonicalFormat | StringCanonicalFormat | TemporalBucketFormat;
|
|
704
|
+
export declare type CanonicalFormatSpec = NumericCanonicalFormat | DateCanonicalFormat | RawTemporalFormat | DurationCanonicalFormat | StringCanonicalFormat | TemporalBucketFormat;
|
|
706
705
|
|
|
707
706
|
declare type CanonicalPivotResultContract = {
|
|
708
707
|
version: 1;
|
|
@@ -1182,7 +1181,6 @@ export declare type CreateBriefingRequest = {
|
|
|
1182
1181
|
presentation: BriefingPresentation;
|
|
1183
1182
|
limits?: BriefingLimits;
|
|
1184
1183
|
deliveryConfig: BriefingDeliveryConfig | null;
|
|
1185
|
-
resolvedFormats?: ResolvedPresentationEntry[];
|
|
1186
1184
|
};
|
|
1187
1185
|
|
|
1188
1186
|
export declare type CurrencyPresentationBinding = {
|
|
@@ -1408,6 +1406,8 @@ export declare type DashboardProps = {
|
|
|
1408
1406
|
* points. Ordinary dashboard consumers should leave this unset.
|
|
1409
1407
|
*/
|
|
1410
1408
|
interactionExecutionSnapshot?: Record<string, InteractionState>;
|
|
1409
|
+
/** Server-resolved immutable presentation snapshot for internal print views. */
|
|
1410
|
+
presentationExecutionSnapshot?: PresentationExecutionSnapshot;
|
|
1411
1411
|
/**
|
|
1412
1412
|
* Render target for print entry points. Generic dashboard PDF exports also
|
|
1413
1413
|
* use cardDisplay.mode="print"; document-specific print handling must only
|
|
@@ -1544,6 +1544,11 @@ export declare type DeleteBriefingRunResponse = {
|
|
|
1544
1544
|
*/
|
|
1545
1545
|
export declare interface DetailField extends Omit<Field, 'role' | 'granularity'> {
|
|
1546
1546
|
role: 'detail';
|
|
1547
|
+
/**
|
|
1548
|
+
* Query transport policy for ungrouped temporal values. This marker is
|
|
1549
|
+
* projected into executable config and is never persisted authoring state.
|
|
1550
|
+
*/
|
|
1551
|
+
dateValueMode?: 'canonical' | 'formatted';
|
|
1547
1552
|
dateFormat?: DateFormatValue;
|
|
1548
1553
|
customFormat?: string;
|
|
1549
1554
|
/**
|
|
@@ -3143,6 +3148,12 @@ export declare type Placeholders = {
|
|
|
3143
3148
|
|
|
3144
3149
|
export declare type PluginType = 'custom' | 'standard';
|
|
3145
3150
|
|
|
3151
|
+
declare type PresentationExecutionSnapshot = {
|
|
3152
|
+
version: 1;
|
|
3153
|
+
reportContext: ReportRuntimeContext;
|
|
3154
|
+
resolvedFormats: ResolvedPresentationEntry[];
|
|
3155
|
+
};
|
|
3156
|
+
|
|
3146
3157
|
declare type PresentationScope = {
|
|
3147
3158
|
dashboardId: string;
|
|
3148
3159
|
cardId?: string;
|
|
@@ -3220,6 +3231,41 @@ declare type RangeValue = {
|
|
|
3220
3231
|
gt?: string | number;
|
|
3221
3232
|
};
|
|
3222
3233
|
|
|
3234
|
+
/** Normalized authored input for an ungrouped temporal result column. */
|
|
3235
|
+
declare type RawTemporalFormat = {
|
|
3236
|
+
type: 'raw_temporal';
|
|
3237
|
+
/** Authored display timezone; `auto` uses the resolved calendar timezone. */
|
|
3238
|
+
timezone?: string;
|
|
3239
|
+
/** Authored source timezone; `auto` means UTC for timezone-less values. */
|
|
3240
|
+
sourceTimezone?: string;
|
|
3241
|
+
presentation: {
|
|
3242
|
+
mode: 'auto';
|
|
3243
|
+
} | {
|
|
3244
|
+
mode: 'pattern';
|
|
3245
|
+
dialect: RawTemporalPatternDialect;
|
|
3246
|
+
pattern: string;
|
|
3247
|
+
};
|
|
3248
|
+
};
|
|
3249
|
+
|
|
3250
|
+
declare type RawTemporalPatternDialect = 'semaphor_tokens' | 'date_fns';
|
|
3251
|
+
|
|
3252
|
+
declare type RawTemporalPresentationTarget = {
|
|
3253
|
+
kind: 'column';
|
|
3254
|
+
columnKey: string;
|
|
3255
|
+
};
|
|
3256
|
+
|
|
3257
|
+
/** Authoritative meaning of one ungrouped temporal result column. */
|
|
3258
|
+
declare type RawTemporalValueKind = 'date' | 'wall_datetime' | 'instant';
|
|
3259
|
+
|
|
3260
|
+
/**
|
|
3261
|
+
* Result-column metadata for an ungrouped temporal value. This descriptor is
|
|
3262
|
+
* mutually exclusive with grouped `temporalBucket` metadata.
|
|
3263
|
+
*/
|
|
3264
|
+
declare type RawTemporalValueMetadata = {
|
|
3265
|
+
kind: 'raw_temporal';
|
|
3266
|
+
valueKind: RawTemporalValueKind;
|
|
3267
|
+
};
|
|
3268
|
+
|
|
3223
3269
|
export declare type RelativeDateFilter = {
|
|
3224
3270
|
mode: 'last';
|
|
3225
3271
|
n: number;
|
|
@@ -3329,7 +3375,7 @@ declare type ResolvedNumericPresentationEntry = {
|
|
|
3329
3375
|
format: NumericCanonicalFormat;
|
|
3330
3376
|
};
|
|
3331
3377
|
|
|
3332
|
-
declare type ResolvedPresentationEntry = ResolvedNumericPresentationEntry | ResolvedTemporalBucketPresentationEntry;
|
|
3378
|
+
declare type ResolvedPresentationEntry = ResolvedNumericPresentationEntry | ResolvedTemporalBucketPresentationEntry | ResolvedRawTemporalPresentationEntry;
|
|
3333
3379
|
|
|
3334
3380
|
declare type ResolvedPrimaryDateField = (ResolvedPrimaryDateFieldBase & ({
|
|
3335
3381
|
defaultGranularity?: SemaphorTimeGrain;
|
|
@@ -3354,8 +3400,45 @@ declare type ResolvedPrimaryDateFieldBase = {
|
|
|
3354
3400
|
supportedGranularities?: SemaphorTimeGrain[];
|
|
3355
3401
|
};
|
|
3356
3402
|
|
|
3357
|
-
declare type
|
|
3403
|
+
declare type ResolvedRawTemporalFormat = {
|
|
3404
|
+
type: 'raw_temporal';
|
|
3405
|
+
locale: string;
|
|
3406
|
+
calendarTimezone: string;
|
|
3407
|
+
/** Resolved source timezone for timezone-less wall datetimes, when authored. */
|
|
3408
|
+
sourceTimezone?: string;
|
|
3409
|
+
presentation: {
|
|
3410
|
+
mode: 'auto';
|
|
3411
|
+
styles: ResolvedTemporalStyleSet;
|
|
3412
|
+
} | {
|
|
3413
|
+
mode: 'pattern';
|
|
3414
|
+
dialect: RawTemporalPatternDialect;
|
|
3415
|
+
pattern: string;
|
|
3416
|
+
};
|
|
3417
|
+
};
|
|
3418
|
+
|
|
3419
|
+
declare type ResolvedRawTemporalPresentationEntry = {
|
|
3420
|
+
scope: PresentationScope;
|
|
3421
|
+
target: RawTemporalPresentationTarget;
|
|
3422
|
+
format: ResolvedRawTemporalFormat;
|
|
3423
|
+
};
|
|
3424
|
+
|
|
3425
|
+
declare type ResolvedTemporalBucketFormat = {
|
|
3426
|
+
type: 'temporal_bucket';
|
|
3427
|
+
locale: string;
|
|
3428
|
+
presentation: {
|
|
3429
|
+
mode: 'auto';
|
|
3430
|
+
styles: ResolvedTemporalStyleSet;
|
|
3431
|
+
};
|
|
3432
|
+
} | {
|
|
3433
|
+
type: 'temporal_bucket';
|
|
3358
3434
|
locale: string;
|
|
3435
|
+
presentation: {
|
|
3436
|
+
mode: 'preset';
|
|
3437
|
+
preset: TemporalBucketPreset;
|
|
3438
|
+
} | {
|
|
3439
|
+
mode: 'pattern';
|
|
3440
|
+
pattern: string;
|
|
3441
|
+
};
|
|
3359
3442
|
};
|
|
3360
3443
|
|
|
3361
3444
|
declare type ResolvedTemporalBucketPresentationEntry = {
|
|
@@ -3364,6 +3447,14 @@ declare type ResolvedTemporalBucketPresentationEntry = {
|
|
|
3364
3447
|
format: ResolvedTemporalBucketFormat;
|
|
3365
3448
|
};
|
|
3366
3449
|
|
|
3450
|
+
declare type ResolvedTemporalStyleSet = {
|
|
3451
|
+
dateStyle: LocaleStyle;
|
|
3452
|
+
dateTime: {
|
|
3453
|
+
dateStyle: LocaleStyle;
|
|
3454
|
+
timeStyle: LocaleStyle;
|
|
3455
|
+
};
|
|
3456
|
+
};
|
|
3457
|
+
|
|
3367
3458
|
declare type ResolvedValueFormatPreferences = {
|
|
3368
3459
|
locale: string;
|
|
3369
3460
|
dateStyle: LocaleStyle;
|
|
@@ -3797,6 +3888,7 @@ declare type SemaphorResultColumn = {
|
|
|
3797
3888
|
source?: SemaphorFieldRef['source'];
|
|
3798
3889
|
derivedField?: SemaphorDerivedFieldDefinition;
|
|
3799
3890
|
temporalBucket?: TemporalBucketMetadata;
|
|
3891
|
+
rawTemporal?: RawTemporalValueMetadata;
|
|
3800
3892
|
pivotIdentity?: SemaphorPivotResultColumnIdentity;
|
|
3801
3893
|
};
|
|
3802
3894
|
|
|
@@ -41,6 +41,9 @@ export declare const REPORT_PREFERENCE_SOURCES: readonly ["viewer_user", "viewer
|
|
|
41
41
|
|
|
42
42
|
export declare type ReportPreferenceSource = (typeof REPORT_PREFERENCE_SOURCES)[number];
|
|
43
43
|
|
|
44
|
+
/** Viewer preferences that affect temporal presentation without numeric currency policy. */
|
|
45
|
+
export declare type ResolvedTemporalValueFormatPreferences = Pick<ResolvedValueFormatPreferences, 'locale' | 'dateStyle' | 'dateTime'>;
|
|
46
|
+
|
|
44
47
|
export declare type ResolvedValueFormatPreferences = {
|
|
45
48
|
locale: string;
|
|
46
49
|
dateStyle: LocaleStyle;
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"email": "support@semaphor.cloud"
|
|
6
6
|
},
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"version": "0.1.
|
|
8
|
+
"version": "0.1.453",
|
|
9
9
|
"description": "Fully interactive and customizable dashboards for your apps.",
|
|
10
10
|
"keywords": [
|
|
11
11
|
"react",
|
|
@@ -147,6 +147,7 @@
|
|
|
147
147
|
"verify:release-artifacts": "npm run verify:metric-comparison-artifact && npm run verify:temporal-bucket-artifact",
|
|
148
148
|
"verify:metric-comparison-artifact": "node scripts/verify-metric-comparison-artifact.mjs",
|
|
149
149
|
"verify:temporal-bucket-artifact": "node scripts/verify-temporal-bucket-artifact.mjs",
|
|
150
|
+
"verify:temporal-browser": "node scripts/verify-temporal-browser.mjs",
|
|
150
151
|
"deploy": "./scripts/deploy.sh",
|
|
151
152
|
"deploy:patch": "./scripts/deploy.sh patch",
|
|
152
153
|
"deploy:minor": "./scripts/deploy.sh minor",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function a(e){if(!e)return!1;const t=e.groupByColumns&&e.groupByColumns.length>0,n=e.metricColumns&&e.metricColumns.length>0,s=e.pivotByColumns&&e.pivotByColumns.length>0,r=e.detailColumns&&e.detailColumns.length>0;return!!(t||n||s||r)}function i(e,t){var u,l,o;if(t!=null&&t.skipSetupCheck||e.type==="text"||(u=e.customCardPreferences)!=null&&u.url)return!1;const n=!!(e.connectionId||(l=e.dataSource)!=null&&l.connectionId),s=!!((o=e.sql)!=null&&o.trim()),r=a(e.config);return!n||!r&&!s}exports.hasValidCardConfig=a;exports.isCardUnconfigured=i;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
function a(e) {
|
|
2
|
-
if (!e) return !1;
|
|
3
|
-
const t = e.groupByColumns && e.groupByColumns.length > 0, n = e.metricColumns && e.metricColumns.length > 0, s = e.pivotByColumns && e.pivotByColumns.length > 0, r = e.detailColumns && e.detailColumns.length > 0;
|
|
4
|
-
return !!(t || n || s || r);
|
|
5
|
-
}
|
|
6
|
-
function i(e, t) {
|
|
7
|
-
var l, u, o;
|
|
8
|
-
if (t != null && t.skipSetupCheck || e.type === "text" || (l = e.customCardPreferences) != null && l.url)
|
|
9
|
-
return !1;
|
|
10
|
-
const n = !!(e.connectionId || (u = e.dataSource) != null && u.connectionId), s = !!((o = e.sql) != null && o.trim()), r = a(e.config);
|
|
11
|
-
return !n || !r && !s;
|
|
12
|
-
}
|
|
13
|
-
export {
|
|
14
|
-
a as h,
|
|
15
|
-
i
|
|
16
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),x=require("react"),s=require("./index-DPv8_Ild.cjs"),n=require("./switch-Cjk6G06r.cjs"),je=require("./layout-grid-xm8pqtx0.cjs"),K=require("./x-B6ghREd2.cjs"),V=require("./editor-action-buttons-BVmsk0Aj.cjs");require("./validators-9D4KBqKD.cjs");require("./analyze-result-contract-BHb7sUUW.cjs");require("../value-format-preferences/index.cjs");const Re=require("./search-BqqhaMx9.cjs"),Ue=require("./mouse-pointer-2-DX4A_XZw.cjs"),ye=require("./pivot-result-lifecycle-DPc0ANwk.cjs");require("./index-DRlMUglg.cjs");require("./temporal-bucket-authoring-CPTwHzvs.cjs");require("./temporal-result-owner-f6-i65Fb.cjs");require("react-dom");const X=require("../briefings/index.cjs");/**
|
|
2
|
-
* @license lucide-react v0.453.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const Oe=K.createLucideIcon("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/**
|
|
7
|
-
* @license lucide-react v0.453.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const ze=K.createLucideIcon("CalendarRange",[["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M17 14h-6",key:"bkmgh3"}],["path",{d:"M13 18H7",key:"bb0bb7"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 18h.01",key:"1bdyru"}]]);/**
|
|
12
|
-
* @license lucide-react v0.453.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const _e=K.createLucideIcon("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
|
|
17
|
-
* @license lucide-react v0.453.0 - ISC
|
|
18
|
-
*
|
|
19
|
-
* This source code is licensed under the ISC license.
|
|
20
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const we=K.createLucideIcon("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);/**
|
|
22
|
-
* @license lucide-react v0.453.0 - ISC
|
|
23
|
-
*
|
|
24
|
-
* This source code is licensed under the ISC license.
|
|
25
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const $e=K.createLucideIcon("Newspaper",[["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2",key:"7pis2x"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M10 6h8v4h-8V6Z",key:"smlsk5"}]]);function qe(){return e.jsx("div",{className:"space-y-1.5 py-1",children:[...Array(5)].map((t,r)=>e.jsxs("div",{className:"flex animate-pulse items-start gap-3 rounded-xl border border-transparent px-2.5 py-2.5",children:[e.jsx("div",{className:"mt-0.5 h-4 w-4 flex-shrink-0 rounded bg-muted/60"}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"h-4 w-3/5 rounded bg-muted/60"}),e.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40"})]})]},r))})}function He({open:t,onOpenChange:r,onSubmit:l,isCreating:o}){const[a,d]=x.useState(""),[h,p]=x.useState("");x.useEffect(()=>{t||(d(""),p(""))},[t]);const c=()=>{a.trim()&&l({title:a,description:h})},u=i=>{r(i)};return e.jsx(s.Dialog,{open:t,onOpenChange:u,children:e.jsxs(s.DialogContent,{showCloseButton:!1,className:"flex max-w-lg grid-cols-none flex-col gap-0 overflow-hidden rounded-[6px] border-border/60 p-0 shadow-lg",children:[e.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(je.LayoutGrid,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[e.jsx(s.DialogTitle,{className:"truncate text-[13px] font-medium leading-none tracking-normal",children:"New library visual"}),e.jsx("span",{className:"shrink-0 text-[10px] font-medium uppercase leading-none tracking-[0.08em] text-muted-foreground",children:"Visual"})]})]}),e.jsx(n.Button,{size:"xs",variant:"ghost",className:"w-7 px-0 text-muted-foreground hover:text-foreground",onClick:()=>u(!1),"aria-label":"Close",disabled:o,children:e.jsx(K.X,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"space-y-3 px-4 py-3",children:[e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Create a saved visual that can be reused across dashboards."}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(n.Label,{htmlFor:"visual-title",className:"text-[12px]",children:"Name"}),e.jsx(n.Input,{id:"visual-title",size:"sm",placeholder:"Untitled visual",value:a,onChange:i=>d(i.target.value),disabled:o,onKeyDown:i=>{i.key==="Enter"&&!i.shiftKey&&(i.preventDefault(),c())}})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(n.Label,{htmlFor:"visual-description",className:"text-[12px]",children:"Description"}),e.jsx(n.Input,{id:"visual-description",size:"sm",placeholder:"Optional",value:h,onChange:i=>p(i.target.value),disabled:o})]})]}),e.jsxs("div",{className:"flex shrink-0 justify-end gap-2 border-t border-border/60 px-4 py-2.5",children:[e.jsx(n.Button,{size:"xs",variant:"outline",onClick:()=>u(!1),disabled:o,children:"Cancel"}),e.jsx(n.Button,{size:"xs",onClick:c,disabled:!a.trim()||o,children:o?e.jsxs(e.Fragment,{children:[e.jsx(n.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Creating..."]}):"Create library visual"})]})]})})}function Se(t){return t?new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"Unknown"}function Ee(t,r){var o;const l=(o=t.ownership.createdBy)==null?void 0:o.type;return l==="tenant"||l==="organization"&&r}function Ce(t,r){var l,o;return Ee(t,r)?((l=t.ownership.createdBy)==null?void 0:l.name)||((o=t.createdByTenantUserRel)==null?void 0:o.name)||t.lastModifiedBy||"Unknown":"Organization"}function We(t,r){return Ce(t,r).split(/\s+/).filter(Boolean).slice(0,2).map(o=>o.charAt(0).toUpperCase()).join("")||"?"}function Ge(t){const r=(t||"").toLowerCase();return r.includes("table")?n.Table2:r.includes("pie")||r.includes("donut")?s.ChartPie:r.includes("line")?s.ChartLine:r.includes("bar")?n.ChartColumn:je.LayoutGrid}function Xe({visual:t}){const r=t.ownership.status==="public"?"Public":t.ownership.status==="shared"||t.ownership.sharedCount>0?"Shared":"Private";return e.jsx("span",{className:"inline-flex items-center rounded-[4px] border border-border/60 px-1.5 py-px text-[11px] text-muted-foreground",children:r})}function Ke({open:t,onOpenChange:r}){const[l,o]=x.useState(""),[a,d]=x.useState(new Set),[h,p]=x.useState(!1),[c,u]=x.useState(null),[i,g]=x.useState(null),[m,f]=x.useState(!1),[w,y]=x.useState(null),[E,B]=x.useState(null),D=()=>{d(new Set),u(null),g(null),f(!1),y(null)},b=()=>{r(!1),D()},{selectVisual:S}=s.useManagementActions(),{handleAddLibraryVisual:A,handleEditLibraryVisual:T}=V.useVisualUtils(),{isConsoleMode:v}=s.useDashboardPreferences(),{resources:j,isLoading:L,isError:I,createResource:$,updateResource:k,deleteResourceAsync:M,duplicateResource:_,isCreating:oe,isDeleting:q}=s.useVisualManagement(void 0,C=>{p(!1),C&&(S(C),T(C),b())}),{startUpdating:fe,stopUpdating:ie,isUpdating:ge}=s.useResourceUpdateState(),W=j,U=x.useMemo(()=>{const C=l.trim().toLowerCase();return C?W.filter(F=>{var R,Y,J;return((R=F.title)==null?void 0:R.toLowerCase().includes(C))||((Y=F.description)==null?void 0:Y.toLowerCase().includes(C))||((J=F.kind)==null?void 0:J.toLowerCase().includes(C))}):W},[l,W]),Q=x.useMemo(()=>W.filter(C=>a.has(C.id)),[a,W]),ee=Q.filter(C=>C.permissions.canDelete),te=Q.filter(C=>C.permissions.canShare),le=U.length>0&&U.every(C=>a.has(C.id)),ue=U.some(C=>a.has(C.id)),se=C=>{const F=new Set(a);C(F),d(F)},ne=C=>{se(F=>{F.has(C)?F.delete(C):F.add(C)})},G=()=>{d(C=>{const F=new Set(C);return le?U.forEach(R=>F.delete(R.id)):U.forEach(R=>F.add(R.id)),F})},ce=async C=>{(await A(C)).success&&b()},O=async()=>{const C=Q;if(C.length===0)return;let F=!1;for(const R of C)if(!(await A(R)).success){F=!0;break}F||b()},z=C=>{T(C),b()},Z=C=>{B(C),_(C,{onSettled:()=>B(null)})},ae=()=>{if(ee.length===0){s.ue.error("Select a visual you can delete");return}y(null),f(!0)},he=async()=>{const C=w?[w]:ee;try{for(const F of C)await M(F.id);d(F=>{const R=new Set(F);return C.forEach(Y=>R.delete(Y.id)),R}),f(!1),y(null)}catch{}},be=()=>{if(Q.length!==1){s.ue.error("Select one visual to share");return}const[C]=Q;if(!C.permissions.canShare){s.ue.error("You do not have permission to share this visual");return}u(C)},de=({title:C,description:F})=>{if(!i)return;const R={};if(C!==i.title&&(R.title=C),(i.description||"")!==F&&(R.description=F),Object.keys(R).length===0){g(null);return}const Y=Object.keys(R),J=Y.length===1?Y[0]:void 0;fe(i.id,J),k({resourceId:i.id,data:R},{onSuccess:()=>{ie(i.id,J),g(null)},onError:()=>{ie(i.id,J)}})},re=C=>{r(C),C||D()},H=w?1:ee.length;return e.jsxs(e.Fragment,{children:[e.jsx(s.Dialog,{open:t,onOpenChange:re,children:e.jsxs(s.DialogContent,{showCloseButton:!1,className:"flex max-h-[80vh] w-[min(72rem,calc(100vw-2rem))] max-w-none grid-cols-none flex-col gap-0 overflow-hidden rounded-[6px] border-border/60 p-0 shadow-lg",children:[e.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(n.Table2,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[e.jsx(s.DialogTitle,{className:"truncate text-[13px] font-medium leading-none tracking-normal",children:"Visuals library"}),e.jsx("span",{className:"shrink-0 text-[10px] font-medium uppercase leading-none tracking-[0.08em] text-muted-foreground",children:"Add to dashboard"})]})]}),e.jsx(n.Button,{size:"xs",variant:"ghost",className:"w-7 px-0 text-muted-foreground hover:text-foreground",onClick:()=>re(!1),"aria-label":"Close visuals library",children:"×"})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border/60 px-3 py-2",children:[e.jsxs("div",{className:"relative min-w-[12rem] flex-1 md:max-w-md",children:[e.jsx(Re.Search,{className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx("input",{autoFocus:!0,value:l,onChange:C=>o(C.target.value),placeholder:"Search visuals...",className:"h-7 w-full rounded-control border border-input bg-background pl-7 pr-2 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-ring focus:outline-none","aria-label":"Search visuals"})]}),e.jsxs(n.Button,{size:"xs",variant:"outline",className:"ml-auto",onClick:()=>p(!0),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"New library visual"]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:L?e.jsx("div",{className:"p-3",children:e.jsx(qe,{})}):I?e.jsx("div",{className:"flex flex-col items-center gap-2 px-4 py-12 text-center",children:e.jsx("p",{className:"text-[13px] text-destructive",children:"Failed to load visuals"})}):U.length===0?e.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-12 text-center",children:[e.jsx(je.LayoutGrid,{className:"h-5 w-5 text-muted-foreground/60"}),e.jsx("p",{className:"text-[13px] font-medium",children:l?"No visuals found":"No visuals yet"}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:l?"Try a different search.":"Create a saved visual to add it here."})]}):e.jsx(Qe,{visuals:U,selectedIds:a,allFilteredSelected:le,someFilteredSelected:ue,onSelectAll:G,onToggleSelection:ne,onAddVisual:ce,onOpenVisual:z,onEditDetails:g,onShareVisual:u,onDeleteVisual:C=>{y(C),f(!0)},onDuplicateVisual:Z,duplicatingId:E,isDeleting:q,isConsoleMode:v})}),e.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-t border-border/60 px-3 py-2",children:[e.jsx("div",{className:"flex min-w-0 items-center gap-1.5",children:a.size>0&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-[12px] text-muted-foreground",children:[e.jsx("span",{className:"font-medium tabular-nums text-foreground",children:a.size})," ","selected"]}),e.jsx(n.Button,{size:"xs",variant:"ghost",onClick:()=>d(new Set),children:"Clear"}),e.jsxs(n.Button,{size:"xs",variant:"outline",onClick:be,disabled:Q.length!==1||te.length!==1,children:[e.jsx(s.Share2,{className:"h-3.5 w-3.5"}),"Share"]}),e.jsxs(n.Button,{size:"xs",variant:"outline",className:"text-destructive hover:text-destructive",onClick:ae,disabled:ee.length===0,children:[e.jsx(s.Trash2,{className:"h-3.5 w-3.5"}),"Delete ",ee.length||a.size]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(n.Button,{size:"xs",variant:"outline",onClick:()=>re(!1),children:"Close"}),e.jsxs(n.Button,{size:"xs",onClick:O,disabled:a.size===0,children:[e.jsx(n.Check,{className:"h-3.5 w-3.5"}),a.size===0?"Add to dashboard":`Add ${a.size} visual${a.size===1?"":"s"}`]})]})]})]})}),e.jsx(He,{open:h,onOpenChange:p,onSubmit:$,isCreating:oe}),c&&e.jsx(s.ShareDialog,{resource:c,resourceType:s.ResourceType.VISUAL,onClose:()=>u(null)}),i&&e.jsx(s.ResourceEditDialog,{open:!!i,resourceLabel:"Visual",initialTitle:i.title||"",initialDescription:i.description||"",onClose:()=>g(null),onSave:de,isSaving:ge(i.id)}),e.jsx(s.AlertDialog,{open:m,onOpenChange:C=>{!C&&q||(f(C),C||y(null))},children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsxs(s.AlertDialogTitle,{children:["Delete ",H," visual",H===1?"":"s","?"]}),e.jsx(s.AlertDialogDescription,{children:"This cannot be undone. Visuals already added to dashboards may need to be removed from those dashboards separately."})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{disabled:q,children:"Cancel"}),e.jsxs(s.AlertDialogAction,{onClick:C=>{C.preventDefault(),he()},disabled:q||H===0,children:[q?e.jsx(n.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(s.Trash2,{className:"h-3.5 w-3.5"}),q?"Deleting...":"Delete"]})]})]})})]})}function Qe({visuals:t,selectedIds:r,allFilteredSelected:l,someFilteredSelected:o,onSelectAll:a,onToggleSelection:d,onAddVisual:h,onOpenVisual:p,onEditDetails:c,onShareVisual:u,onDeleteVisual:i,onDuplicateVisual:g,duplicatingId:m,isDeleting:f,isConsoleMode:w}){return e.jsxs("div",{className:"min-w-[48rem]",children:[e.jsxs("div",{className:"grid h-9 grid-cols-[2.5rem_minmax(14rem,1.8fr)_minmax(10rem,1fr)_8rem_7rem_5rem_5.5rem] items-center border-b border-border/60 px-3 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:[e.jsx(s.Checkbox,{checked:l?!0:o?"indeterminate":!1,onCheckedChange:a,"aria-label":"Select all visuals"}),e.jsx("span",{children:"Name"}),e.jsx("span",{children:"Created by"}),e.jsx("span",{children:"Updated"}),e.jsx("span",{children:"Visibility"}),e.jsx("span",{className:"text-right",children:"Shared"}),e.jsx("span",{className:"text-right",children:"Actions"})]}),t.map(y=>e.jsx(Ye,{visual:y,selected:r.has(y.id),onToggleSelection:d,onAddVisual:h,onOpenVisual:p,onEditDetails:c,onShareVisual:u,onDeleteVisual:i,onDuplicateVisual:g,duplicatingId:m,isDeleting:f,isConsoleMode:w},y.id))]})}function Ye({visual:t,selected:r,onToggleSelection:l,onAddVisual:o,onOpenVisual:a,onEditDetails:d,onShareVisual:h,onDeleteVisual:p,onDuplicateVisual:c,duplicatingId:u,isDeleting:i,isConsoleMode:g}){var w;const m=Ge(t.kind),f=()=>{o(t)};return e.jsxs("div",{className:n.cn("group grid min-h-12 grid-cols-[2.5rem_minmax(14rem,1.8fr)_minmax(10rem,1fr)_8rem_7rem_5rem_5.5rem] items-center border-b border-border/50 px-3 text-[13px] hover:bg-muted/50",r&&"bg-muted/70"),children:[e.jsx("div",{children:e.jsx(s.Checkbox,{checked:r,onCheckedChange:()=>l(t.id),"aria-label":`Select ${t.title||"visual"}`})}),e.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-2 rounded-[4px] text-left outline-none focus-visible:ring-1 focus-visible:ring-ring",onClick:f,"aria-label":`Add ${t.title||"visual"} to dashboard`,children:[e.jsx(m,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate font-medium text-foreground",title:t.title||"Untitled Visual",children:t.title||"Untitled Visual"}),((w=t.description)==null?void 0:w.trim())&&e.jsx("div",{className:"truncate text-[11px] text-muted-foreground",title:t.description,children:t.description})]})]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-muted text-[9px] font-medium text-muted-foreground",children:We(t,g)}),e.jsx("span",{className:"truncate text-muted-foreground",children:Ce(t,g)})]}),e.jsx("span",{className:"text-muted-foreground",children:Se(t.updatedAt)}),e.jsx(Xe,{visual:t}),e.jsx("span",{className:"text-right tabular-nums text-muted-foreground",children:t.ownership.sharedCount>0?t.ownership.sharedCount:"—"}),e.jsx(Ze,{visual:t,onOpenVisual:a,onEditDetails:d,onShareVisual:h,onDeleteVisual:p,onDuplicateVisual:c,duplicatingId:u,isDeleting:i,isConsoleMode:g})]})}function Ze({visual:t,onOpenVisual:r,onEditDetails:l,onShareVisual:o,onDeleteVisual:a,onDuplicateVisual:d,duplicatingId:h,isDeleting:p,isConsoleMode:c}){return e.jsxs("div",{className:"flex items-center justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",onClick:u=>u.stopPropagation(),children:[e.jsx(n.Button,{size:"xs",variant:"ghost",className:"w-7 px-0",onClick:()=>r(t),"aria-label":"Edit visual",children:e.jsx(s.PenLine,{className:"h-3.5 w-3.5"})}),e.jsxs(s.DropdownMenu,{modal:!1,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(n.Button,{size:"xs",variant:"ghost",className:"w-7 px-0","aria-label":"More actions",children:e.jsx(s.Ellipsis,{className:"h-3.5 w-3.5"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"z-[60] w-44 rounded-[6px] border-border/60 p-1 shadow-sm",children:[e.jsxs(s.DropdownMenuItem,{onClick:()=>r(t),children:[e.jsx(s.PenLine,{className:"h-3.5 w-3.5"}),"Edit visual"]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>d(t.id),disabled:h===t.id,children:[h===t.id?e.jsx(n.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(s.Copy,{className:"h-3.5 w-3.5"}),h===t.id?"Duplicating...":"Duplicate"]}),t.permissions.canEdit&&e.jsxs(s.DropdownMenuItem,{onClick:()=>l(t),children:[e.jsx(s.PenLine,{className:"h-3.5 w-3.5"}),"Edit details"]}),t.permissions.canShare&&e.jsxs(s.DropdownMenuItem,{onClick:()=>o(t),children:[e.jsx(s.Share2,{className:"h-3.5 w-3.5"}),"Share"]}),t.permissions.canDelete&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuSeparator,{}),e.jsxs(s.DropdownMenuItem,{className:"text-destructive focus:bg-destructive/10 focus:text-destructive",onClick:()=>a(t),disabled:p,children:[e.jsx(s.Trash2,{className:"h-3.5 w-3.5"}),p?"Deleting...":"Delete"]})]}),e.jsx(s.DropdownMenuSeparator,{}),e.jsxs("div",{className:"space-y-1 px-2 py-1.5 text-[11px] text-muted-foreground",children:[Ee(t,c)&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(s.User,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:Ce(t,c)})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(s.Calendar,{className:"h-3 w-3"}),e.jsx("span",{children:Se(t.updatedAt)})]})]})]})]})]})}function Je({open:t,onOpenChange:r,isLibraryVisual:l,currentVisualName:o,isSaving:a=!1,destinationMode:d="both",onConfirm:h}){const[p,c]=x.useState(l&&o?`Copy of ${o}`:o||""),[u,i]=x.useState("");x.useEffect(()=>{t&&(c(l&&o?`Copy of ${o}`:o||""),i(""))},[t,l,o]);const g=!!p.trim(),m=d==="local"?{saveToLibrary:!1,saveToCurrentDashboard:!0,badgeType:"local",description:"Creates a local copy on the current dashboard.",actionLabel:"Add to Dashboard (Local)"}:d==="library"?{saveToLibrary:!0,saveToCurrentDashboard:!1,badgeType:"library",description:"Creates a reusable visual in Visual Library.",actionLabel:"Save as Library Visual"}:{saveToLibrary:!0,saveToCurrentDashboard:!0,badgeType:"linked",description:"Creates a new library visual and adds a linked copy to this dashboard.",actionLabel:"Save Copy as Linked Visual"},f=()=>{!g||a||h({name:p.trim(),description:u.trim()||void 0,saveToLibrary:m.saveToLibrary,saveToCurrentDashboard:m.saveToCurrentDashboard})};return e.jsx(s.Dialog,{open:t,onOpenChange:r,children:e.jsxs(s.DialogContent,{className:"sm:max-w-[500px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsxs(s.DialogTitle,{className:"flex items-center gap-2",children:[e.jsx("span",{children:"Save Visual As"}),m.badgeType!=="local"&&e.jsx(V.VisualBadge,{type:m.badgeType,showLabel:!0,className:"px-2 py-0.5"})]}),e.jsx(s.DialogDescription,{children:m.description})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(n.Label,{htmlFor:"name",children:"Name"}),e.jsx(n.Input,{id:"name",value:p,onChange:w=>c(w.target.value),placeholder:"Enter visual name",disabled:a})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(n.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(s.Textarea,{id:"description",value:u,onChange:w=>i(w.target.value),placeholder:"Enter visual description",rows:3,disabled:a})]})]}),e.jsxs(s.DialogFooter,{children:[e.jsx(n.Button,{variant:"outline",onClick:()=>r(!1),disabled:a,children:"Cancel"}),e.jsxs(n.Button,{onClick:f,disabled:!g||a,children:[a&&e.jsx(n.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),m.actionLabel]})]})]})})}function et(){const[t,r]=x.useState(!1),[l,o]=x.useState(!1),[a,d]=x.useState(null),[h,p]=x.useState(null),c=n.useEditorStore(v=>v.frame),u=n.useEditorStore(v=>v.card),i=s.useSelectedVisual(),g=n.useDashboardStore(v=>v.selectedSheetId),m=n.useDashboardStore(v=>v.dashboard),{getUpdatedFrame:f}=V.useVisualUtils(),{selectVisual:w}=s.useManagementActions(),{addFrame:y,setSelectedFrameId:E,setIsVisualEditing:B}=n.useDashboardActions(),D=s.useResolveExistingFrameSemanticExecutionPayload(),b=!!(c!=null&&c.visualId),S=(()=>{var v,j;return((v=c==null?void 0:c.cards)==null?void 0:v.length)===1&&((j=c.cards[0])!=null&&j.title)?c.cards[0].title:i!=null&&i.title?i.title:(u==null?void 0:u.title)||"Untitled Visual"})(),A=s.useCreateVisualWithFrame(v=>{v!=null&&v.id&&(w(v),l&&a&&h&&g&&(async()=>{try{const j={...a,id:n.v4(),visualId:v.id};y(g,j,{position:"end",semanticExecutionPayload:h}),E(j.id),o(!1),d(null),p(null),B(!1)}catch(j){console.error("Failed to promote semantic metadata for saved visual:",j),s.ue.error(j instanceof Error?j.message:"Failed to prepare semantic metadata for the saved visual")}})(),r(!1))});return{saveAsDialogOpen:t,setSaveAsDialogOpen:r,handleSaveAs:async v=>{if(!g){s.ue.error("No sheet selected");return}const j=f(),L=n.getDynamicFrameSaveIssue(j);if(L){s.ue.error(L);return}const $=j.cards.length===1?{...j,cards:j.cards.map(k=>({...k,title:v.name}))}:j;if(v.saveToLibrary){let k=null;if(v.saveToCurrentDashboard)try{k=await D($,{previousFrame:n.findDashboardFrameById(m,$.id)})}catch(_){console.error("Failed to prepare semantic metadata before saving visual:",_),s.ue.error(_ instanceof Error?_.message:"Failed to prepare semantic metadata for the saved visual");return}o(v.saveToCurrentDashboard),d($),p(k);const M={title:v.name,description:v.description,frameObject:$,isPrivate:!1};A.mutate(M)}else if(v.saveToCurrentDashboard){const k={...$,id:n.v4(),visualId:void 0};try{const M=await D($,{previousFrame:n.findDashboardFrameById(m,$.id)});y(g,k,{position:"end",semanticExecutionPayload:M}),E(k.id),s.ue.success("Visual saved to dashboard"),r(!1),B(!1)}catch(M){console.error("Failed to save visual to dashboard:",M),s.ue.error(M instanceof Error?M.message:"Failed to prepare semantic metadata for the visual")}}},isLibraryVisual:b,currentVisualName:S,isSaving:A.isPending}}function tt(t={}){const{isInspectionMode:r}=s.useDashboardInteractionMode(),l=n.useEditorStore(k=>k.frame),o=n.useEditorStore(k=>k.editorContext),a=s.useManagementStore(k=>k.selectedVisual),d=n.useDashboardStore(k=>k.selectedFrameId),h=n.useDashboardStore(k=>k.selectedSheetId),p=n.useDashboardStore(k=>k.dashboard),{setIsVisualEditing:c,updateFrame:u}=n.useDashboardActions(),[i,g]=x.useState(!1),[m,f]=x.useState("both"),w=s.useResolveExistingFrameSemanticExecutionPayload(),y=(o==null?void 0:o.type)==="documentSection",E=!!(l!=null&&l.visualId||a!=null&&a.id),B=!!(l!=null&&l.visualId&&d),D=E&&!B,{saveAsDialogOpen:b,setSaveAsDialogOpen:S,handleSaveAs:A,isLibraryVisual:T,currentVisualName:v,isSaving:j}=et(),{getUpdatedFrame:L}=V.useVisualUtils();if(r)return e.jsxs(e.Fragment,{children:[e.jsx(V.EditorAcceptButton,{className:"rounded-control",variant:"default"}),e.jsx(V.EditorCancelButton,{})]});if(y)return e.jsxs(e.Fragment,{children:[e.jsx(V.EditorAcceptButton,{className:"rounded-control",variant:"default"}),e.jsx(V.EditorCancelButton,{})]});const I=async()=>{if(!h){s.ue.error("No sheet selected");return}if(i)return;g(!0);const k=L(),M=n.getDynamicFrameSaveIssue(k);if(M){g(!1),s.ue.error(M);return}const _={...k,visualId:void 0},oe=n.findDashboardFrameById(p,_.id);try{const q=await w(_,{previousFrame:oe});u(h,_,{semanticExecutionPayload:q})}catch(q){console.error("Failed to apply local semantic metadata:",q),g(!1),s.ue.error(q instanceof Error?q.message:"Failed to prepare semantic metadata for this visual");return}setTimeout(()=>{g(!1),s.ue.success("Changes applied. Visual is now local to this dashboard"),c(!1)},300)},$=k=>{f(k),S(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"inline-flex items-center overflow-hidden rounded-control",children:[!E&&e.jsx(V.EditorAcceptButton,{className:"!rounded-none",variant:"default"}),E&&D&&e.jsx(V.VisualSaveButton,{className:"!rounded-none",variant:"default"}),E&&B&&e.jsx(V.VisualSaveAndApplyButton,{className:"!rounded-none"}),e.jsxs(s.DropdownMenu,{modal:!1,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(n.Button,{variant:"default",size:"xs",className:"w-7 !rounded-none border-l border-primary-foreground/20 px-0","aria-label":"Open visual save options",disabled:j||i,children:e.jsx(K.ChevronDown,{className:"h-3.5 w-3.5"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"min-w-[220px] rounded-control border border-border/60 p-1 shadow-sm",children:[B&&e.jsxs(e.Fragment,{children:[e.jsxs(s.DropdownMenuItem,{onClick:I,disabled:i,children:[e.jsx(n.Check,{className:"h-3.5 w-3.5"}),i?"Applying...":"Apply Locally"]}),e.jsx(s.DropdownMenuSeparator,{})]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>$("local"),disabled:j,children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Add to Dashboard (Local)"]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>$("library"),disabled:j,children:[e.jsx(V.Library,{className:"h-3.5 w-3.5"}),"Save as Library Visual"]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>$("both"),disabled:j,children:[e.jsx(V.Link2,{className:"h-3.5 w-3.5"}),"Save Copy as Linked Visual"]})]})]})]}),e.jsx(V.EditorCancelButton,{}),e.jsx(Je,{open:b,onOpenChange:k=>{j||S(k)},isLibraryVisual:T,currentVisualName:v,isSaving:j,destinationMode:m,onConfirm:A})]})}function st({className:t}){const r=n.useEditorStore(u=>u.isDevMode),l=n.useDashboardStore(u=>u.isVisualEditing),{setIsDevMode:o}=n.useEditorActions(),{config:a}=x.useContext(s.SemaphorContext).tokenProps,d=(a==null?void 0:a.showAdvancedMode)!==!1;if(!l||!d)return null;const h=r?Ue.MousePointer2:s.CodeXml,p=r?"Visual editor":"SQL editor",c=r?"Switch to visual editor":"Switch to SQL editor";return e.jsxs("button",{type:"button","aria-label":c,title:c,onClick:()=>o(!r),className:n.cn("inline-flex h-7 items-center gap-1.5 rounded-control border border-input bg-background px-2 text-[12px] font-medium text-foreground transition-colors hover:bg-muted/40 focus-visible:border-ring focus-visible:outline-none",t),children:[e.jsx(h,{className:"h-3 w-3 text-muted-foreground"}),p]})}function rt({open:t,onOpenChange:r,onSave:l,onDiscard:o,isSaving:a,title:d="Unsaved changes",description:h="You have unsaved changes to this dashboard. What would you like to do?",cancelLabel:p="Cancel",discardLabel:c="Discard",saveLabel:u="Save"}){const i=g=>{!g&&a||r(g)};return e.jsx(s.AlertDialog,{open:t,onOpenChange:i,children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:d}),e.jsx(s.AlertDialogDescription,{children:h})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(n.Button,{type:"button",size:"xs",onClick:o,disabled:a,variant:"ghost",className:"mr-auto text-muted-foreground hover:bg-destructive/10 hover:text-destructive focus-visible:bg-destructive/10 focus-visible:text-destructive",children:c}),e.jsx(s.AlertDialogCancel,{disabled:a,children:p}),e.jsx(n.Button,{type:"button",size:"xs",onClick:l,disabled:a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(n.LoaderCircle,{className:"mr-2 h-3.5 w-3.5 animate-spin"}),"Saving..."]}):u})]})]})})}const nt=1e4,at=15e3,ot=3e4,it=3e4,lt=12e4,Ne=2*60*60*1e3;function ct(t){const r=Date.now()-t.getTime();return r<it?nt:r<lt?at:ot}function dt(){const{authToken:t,tokenProps:r}=s.useSemaphorContext(),l=s.useExportStore(m=>m.activeExports),[o,a]=x.useState(typeof document<"u"?!document.hidden:!0),d=x.useRef(null),h=x.useRef(!1),p=x.useRef(void 0),c=r==null?void 0:r.apiServiceUrl,u=t==null?void 0:t.accessToken,i=x.useCallback(()=>{const m=s.useExportStore.getState().activeExports;return Array.from(m.values()).filter(f=>s.isExportInProgress(f.status))},[]);x.useEffect(()=>{if(typeof document>"u")return;const m=()=>{a(!document.hidden)};return document.addEventListener("visibilitychange",m),()=>{document.removeEventListener("visibilitychange",m)}},[]);const g=x.useCallback(async()=>{if(!c||!u){h.current=!1;return}const m=i();if(m.length===0){h.current=!1;return}const f=Date.now(),w=m.filter(b=>f-b.startedAt.getTime()>Ne);if(w.length>0){const{updateExport:b}=s.useExportStore.getState().actions;for(const S of w)b(S.id,{status:"failed",error:"Export timed out. Please try again or contact support.",lastUpdatedAt:new Date})}const y=m.filter(b=>f-b.startedAt.getTime()<=Ne);if(y.length===0){h.current=!1;return}const E=await Promise.allSettled(y.map(async b=>{try{const S=await s.getExportStatus(c,u,b.id);let A;if(S.status==="completed")try{A=await s.getDownloadUrl(c,u,b.id)}catch(T){console.error(`[useExportPolling] Failed to get download URL for ${b.id}:`,T)}return{id:b.id,status:S.status,progress:S.progress,completedChunks:S.completedChunks,completedAt:S.completedAt?new Date(S.completedAt):void 0,lastUpdatedAt:new Date,fileSize:S.fileSize,error:S.error,downloadUrl:A}}catch(S){return console.error(`[useExportPolling] Failed to poll export ${b.id}:`,S),null}})),{updateExport:B}=s.useExportStore.getState().actions;for(const b of E)b.status==="fulfilled"&&b.value&&B(b.value.id,b.value);const D=i();if(D.length>0&&!document.hidden){const b=D.reduce((A,T)=>T.startedAt<A?T.startedAt:A,D[0].startedAt),S=ct(b);d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{var A;(A=p.current)==null||A.call(p)},S)}else h.current=!1},[c,u,i]);return x.useEffect(()=>{p.current=g},[g]),x.useEffect(()=>{var f;i().length>0&&o&&!h.current&&(h.current=!0,(f=p.current)==null||f.call(p))},[l,o,i]),x.useEffect(()=>{var f;const m=i();o&&m.length>0&&!h.current&&(h.current=!0,(f=p.current)==null||f.call(p))},[o,i]),x.useEffect(()=>{!o&&d.current&&(clearTimeout(d.current),d.current=null,h.current=!1)},[o]),x.useEffect(()=>()=>{d.current&&(clearTimeout(d.current),d.current=null)},[]),{isPolling:h.current,isTabVisible:o,inProgressCount:i().length}}function ut(){const{authToken:t,tokenProps:r}=s.useSemaphorContext(),l=s.useExportStore(p=>p.activeExports),{addExport:o}=s.useExportActions(),a=x.useRef(!1),d=r==null?void 0:r.apiServiceUrl,h=t==null?void 0:t.accessToken;x.useEffect(()=>{if(a.current||!d||!h)return;(async()=>{try{const{exports:c}=await s.getExports(d,h,{status:["pending","processing","chunking","compacting","completed","failed"],limit:20});for(const u of c){if(l.has(u.id))continue;const i=u.totalChunks?Math.round(u.completedChunks/u.totalChunks*100):0;let g;if(u.status==="completed")try{g=await s.getDownloadUrl(d,h,u.id)}catch(f){console.error(`[useExportRecovery] Failed to get download URL for ${u.id}:`,f)}const m={id:u.id,status:u.status,progress:i,title:ht(u),totalRows:u.totalRows,totalChunks:u.totalChunks,completedChunks:u.completedChunks,startedAt:new Date(u.createdAt),lastUpdatedAt:new Date,completedAt:u.completedAt?new Date(u.completedAt):void 0,fileSize:u.fileSize,error:u.error,expiresAt:new Date(u.expiresAt),downloadUrl:g};o(m)}a.current=!0}catch(c){console.error("[useExportRecovery] Failed to recover exports:",c),a.current=!0}})()},[d,h,o,l])}function ht(t){return t.title?t.title:s.isExportInProgress(t.status)?"Export in progress...":t.status==="completed"?"Export completed":t.status==="failed"?"Export failed":"Export"}function Ae({export:t,onRemove:r}){const l=()=>{t.downloadUrl&&window.open(t.downloadUrl,"_blank")},o=p=>{p.stopPropagation(),r==null||r(t.id)},a=()=>{switch(t.status){case"completed":return e.jsx(s.CircleCheck,{className:"mt-0.5 h-5 w-5 shrink-0 text-green-600"});case"failed":return e.jsx(_e,{className:"mt-0.5 h-5 w-5 shrink-0 text-destructive"});default:return e.jsx(n.LoaderCircle,{className:"text-foreground-muted mt-0.5 h-5 w-5 shrink-0 animate-spin"})}},d=s.isExportInProgress(t.status),h=(()=>{switch(t.status){case"pending":return"Queued...";case"processing":return"Processing...";case"chunking":return"Processing...";case"compacting":return"Finalizing...";default:return"Processing..."}})();return e.jsxs("div",{className:"group p-4 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"mb-2 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:[a(),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"mb-1 truncate text-sm font-medium",children:t.title}),t.status==="completed"&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:[t.totalRows.toLocaleString()," rows"]}),t.fileSize&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{children:s.formatFileSize(t.fileSize)})]})]}),d&&e.jsx("div",{className:"text-xs text-muted-foreground",children:h}),t.status==="failed"&&e.jsx("div",{className:"line-clamp-2 text-xs text-destructive",children:t.error||"Export failed"})]})]}),e.jsx(n.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:o,"aria-label":"Remove notification",children:e.jsx(K.X,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"ml-8",children:[t.status==="completed"&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:ye.formatDistanceToNow(t.startedAt,{addSuffix:!0})}),t.downloadUrl&&e.jsxs(n.Button,{size:"sm",variant:"outline",className:"h-8 bg-transparent",onClick:l,children:[e.jsx(s.Download,{className:"mr-1.5 h-3.5 w-3.5"}),"Download"]})]}),d&&e.jsxs("div",{children:[e.jsx(s.Progress,{value:t.progress,className:"h-1.5"}),e.jsxs("span",{className:"mt-1 block text-xs text-muted-foreground",children:[t.progress,"% complete"]})]}),t.status==="failed"&&e.jsx("span",{className:"text-xs text-muted-foreground",children:ye.formatDistanceToNow(t.startedAt,{addSuffix:!0})})]})]})}function ke(){const{authToken:t,tokenProps:r}=s.useSemaphorContext(),l=s.useExportStore(y=>y.activeExports),{clearCompleted:o,removeExport:a,updateExport:d}=s.useExportActions(),[h,p]=x.useState(!1),[c,u]=x.useState(!1),i=Array.from(l.values()).sort((y,E)=>E.startedAt.getTime()-y.startedAt.getTime()),g=i.some(y=>y.status==="completed"||y.status==="failed"),m=x.useCallback(async()=>{const y=r==null?void 0:r.apiServiceUrl,E=t==null?void 0:t.accessToken;if(!(!y||!E)){p(!0);try{const B=Array.from(l.values());await Promise.all(B.map(async D=>{try{const b=await s.getExportStatus(y,E,D.id);let S;if(b.status==="completed")try{S=await s.getDownloadUrl(y,E,D.id)}catch(A){console.error(`Failed to get download URL for ${D.id}:`,A)}d(D.id,{status:b.status,progress:b.progress,completedChunks:b.completedChunks,completedAt:b.completedAt?new Date(b.completedAt):void 0,lastUpdatedAt:new Date,fileSize:b.fileSize,error:b.error,downloadUrl:S})}catch(b){console.error(`Failed to refresh export ${D.id}:`,b)}}))}finally{p(!1)}}},[l,t==null?void 0:t.accessToken,r==null?void 0:r.apiServiceUrl,d]),f=x.useCallback(async()=>{const y=r==null?void 0:r.apiServiceUrl,E=t==null?void 0:t.accessToken;if(!y||!E){o();return}u(!0);try{const B=i.filter(b=>b.status==="completed"||b.status==="failed"),D=await Promise.allSettled(B.map(async b=>(await s.cancelExport(y,E,b.id),b.id)));for(const b of D)b.status==="fulfilled"?a(b.value):console.error("Failed to delete export:",b.reason)}finally{u(!1)}},[i,r==null?void 0:r.apiServiceUrl,t==null?void 0:t.accessToken,o,a]),w=x.useCallback(async y=>{const E=r==null?void 0:r.apiServiceUrl,B=t==null?void 0:t.accessToken;if(E&&B)try{await s.cancelExport(E,B,y),a(y);return}catch(D){console.error(`Failed to cancel export ${y}:`,D)}a(y)},[r==null?void 0:r.apiServiceUrl,t==null?void 0:t.accessToken,a]);return i.length===0?e.jsxs("div",{className:"p-6 text-center",children:[e.jsx(we,{className:"mx-auto mb-2 h-8 w-8 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No active exports"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Large exports will appear here"})]}):e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h4",{className:"font-semibold",children:"Exports"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(n.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:m,disabled:h,title:"Refresh status",children:e.jsx(s.RefreshCw,{className:`h-4 w-4 ${h?"animate-spin":""}`})}),g&&e.jsx(n.Button,{variant:"ghost",size:"sm",className:"h-7 px-2 text-sm",onClick:f,disabled:c,children:c?"Clearing...":"Clear all"})]})]}),e.jsx("div",{className:"max-h-[350px] overflow-y-auto",children:e.jsx("div",{className:"divide-y",children:i.map(y=>e.jsx(Ae,{export:y,onRemove:w},y.id))})})]})}function mt({variant:t}){const r=s.useExportStore(c=>c.activeExports),l=s.useInProgressExportsCount(),o=r.size>0,a=Array.from(r.values()).some(c=>c.status==="completed"||c.status==="failed"),h=l>0?l>9?"9+":String(l):null,p=o;return e.jsxs(n.Popover,{children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:e.jsxs(n.Button,{variant:t??"ghost",size:"xs",className:"relative w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":"Export notifications",children:[e.jsx(s.Bell,{className:"h-3.5 w-3.5"}),p&&e.jsx("span",{className:`absolute flex items-center justify-center rounded-full bg-primary text-primary-foreground ${h?"-right-0.5 -top-0.5 h-3.5 min-w-3.5 px-0.5 text-[9px] font-semibold":"right-1 top-1 h-1.5 w-1.5"}`,children:h})]})}),e.jsx(n.PopoverContent,{className:"w-80 p-0",align:"end",sideOffset:8,children:e.jsx(ke,{})})]})}function xt(t){if(t)return{renamed:t.type==="rename"?{oldId:t.oldId,newId:t.newId}:void 0,removedControlId:t.type==="remove"?t.controlId:void 0,cardBindingsById:t.type==="add"||t.type==="update"?t.cardBindingsById:void 0,affectedBindingControlIds:t.type==="add"||t.type==="update"?t.affectedBindingControlIds:void 0}}function Be({open:t,onOpenChange:r,trigger:l,showTrigger:o=!0,initialMode:a="manage"}){const d=a==="create",{forceClose:h,handleOpenChange:p,isCreateFlowActive:c,preventPassiveDismissDuringCreate:u,resolvedOpen:i,setIsCreateFlowActive:g}=V.useCreateFlowOverlayState({open:t,onOpenChange:r,initialCreateFlowActive:a==="create",dismissMode:o?"passive":"explicit-only"}),m=n.useDashboardStore(j=>j.dashboard),{setDashboardControlsModel:f}=n.useDashboardActions(),{participants:w}=s.useDashboardStructuralParticipants(n.getDashboardCards(m)),y=Array.from(new Map(w.flatMap(j=>j.fieldChoices.map(L=>{var I;return[L.value,{option:L,target:(I=j.fieldTargetMap)==null?void 0:I[L.value]}]}))).values()),E=Array.from(new Map(w.flatMap(j=>j.metricChoices.map(L=>{var I;return[L.value,{option:L,target:(I=j.metricTargetMap)==null?void 0:I[L.value]}]}))).values()),B=n.collectDashboardControlIds({...m||{},controls:[]}),D=s.buildDashboardStructuralParticipantIdsByControlId(m),b=(j,L,I)=>{f(j,L,xt(I))},S=x.useCallback(()=>{if(d){h();return}g(!1)},[d,h,g]),A=e.jsx(V.ControlDefinitionListEditor,{scope:"dashboard",controls:m.controls||[],reservedControlIds:B,defaultValues:m.defaultControlValues||{},usageByControlId:s.buildDashboardControlUsageById(m),availableFieldChoices:y,availableMetricChoices:E,structuralParticipants:w,structuralParticipantIdsByControlId:D,initialCreateFlow:a==="create",onCreateFlowActiveChange:g,onCreateFlowComplete:S,onChange:b,emptyMessage:"No dashboard controls yet."}),T=c?"Add dashboard control":"Dashboard Controls",v=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h4",{className:"text-sm font-medium",children:"Dashboard Controls"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add shared controls viewers can use across the dashboard. Each card can decide how to respond to the same control."})]}),A]});return o?e.jsxs(n.Popover,{open:i,onOpenChange:p,children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:l||e.jsxs(n.Button,{variant:"outline",className:"h-7 px-2",size:"sm",children:[e.jsx(n.SlidersHorizontal,{className:"mr-2 h-4 w-4"}),"Controls"]})}),e.jsx(n.PopoverContent,{className:"w-[620px] max-w-[95vw] space-y-4",align:"end",onEscapeKeyDown:u,onPointerDownOutside:u,children:v})]}):e.jsx(s.Dialog,{open:i,onOpenChange:p,children:e.jsxs(s.DialogContent,{className:"flex max-h-[88vh] flex-col overflow-hidden sm:max-w-[600px]",onEscapeKeyDown:u,onPointerDownOutside:u,children:[e.jsxs(s.DialogHeader,{className:c?"space-y-0":void 0,children:[e.jsx(s.DialogTitle,{className:"text-[15px]",children:T}),e.jsx(s.DialogDescription,{className:c?"sr-only":"text-[13px]",children:c?"Configure and add a shared dashboard control.":"Add shared controls viewers can use across the dashboard. Each card can decide how to respond to the same control."})]}),e.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:A})]})})}const pt=["enum","multi_enum","text","number","boolean","date"];function Ie({open:t,onOpenChange:r,initialMode:l="manage"}){var v;const o=l==="create",{forceClose:a,handleOpenChange:d,isCreateFlowActive:h,preventPassiveDismissDuringCreate:p,resolvedOpen:c,setIsCreateFlowActive:u}=V.useCreateFlowOverlayState({open:t,onOpenChange:r,initialCreateFlowActive:l==="create",dismissMode:"explicit-only"}),i=n.useDashboardStore(j=>j.dashboard),g=n.useDashboardStore(j=>j.selectedSheetId),{setDashboardInputs:m}=n.useDashboardActions(),f=(v=i.sheets)==null?void 0:v.find(j=>j.id===g),w=(f==null?void 0:f.kind)==="document"&&!!f.document,y=x.useMemo(()=>w&&(f!=null&&f.document)?s.getDocumentSheetDashboardInputs(i,f.id):[],[i,w,f==null?void 0:f.document,f==null?void 0:f.id]),E=x.useMemo(()=>y.filter(j=>j.kind==="control"),[y]),B=x.useMemo(()=>E.map(j=>j.control),[E]),D=x.useMemo(()=>gt(B),[B]),b=x.useMemo(()=>ft(i),[i]),S=x.useCallback(()=>{if(o){a();return}u(!1)},[o,a,u]),A=x.useCallback((j,L,I)=>{!w||!(f!=null&&f.document)||m(vt({allInputs:i.inputs||[],documentSheetId:f.id,currentDocumentInputs:y,nextControls:j,nextDefaultValues:L,change:I}))},[i.inputs,y,w,f,m]);if(!w||!(f!=null&&f.document))return null;const T=h?"Add document control":"Document Controls";return e.jsx(s.Dialog,{open:c,onOpenChange:d,children:e.jsxs(s.DialogContent,{className:"flex max-h-[88vh] flex-col overflow-hidden sm:max-w-[600px]",onEscapeKeyDown:p,onPointerDownOutside:p,children:[e.jsxs(s.DialogHeader,{className:h?"space-y-0":void 0,children:[e.jsx(s.DialogTitle,{className:"text-[15px]",children:T}),e.jsx(s.DialogDescription,{className:h?"sr-only":"text-[13px]",children:h?"Configure and add a document-local control input.":"Add document-local control inputs. They are stored on this document sheet and are not dashboard controls."})]}),e.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:e.jsx(V.ControlDefinitionListEditor,{scope:"dashboard",controls:B,reservedControlIds:b,defaultValues:D,usageByControlId:{},availableFieldChoices:[],availableMetricChoices:[],structuralParticipants:[],structuralParticipantIdsByControlId:{},allowedControlTypes:pt,initialCreateFlow:l==="create",onCreateFlowActiveChange:u,onCreateFlowComplete:S,onChange:A,emptyMessage:"No document controls yet."})})]})})}function ft(t){return(t.controls||[]).map(r=>r.id)}function gt(t){const r={};for(const l of t)l.defaultValue!==void 0&&(r[l.id]=l.defaultValue);return r}function bt(t,r){return r?Object.prototype.hasOwnProperty.call(r,t.id)?{...t,defaultValue:r[t.id]}:t.defaultValue===void 0?t:{...t,defaultValue:void 0}:t.defaultValue===void 0?t:{...t,defaultValue:void 0}}function vt({allInputs:t,documentSheetId:r,currentDocumentInputs:l,nextControls:o,nextDefaultValues:a,change:d}){const h=new Map(o.map(m=>[m.id,bt(m,a)])),p=(d==null?void 0:d.type)==="rename"?{oldId:d.oldId,newId:d.newId}:null,c=new Set,u=[];for(const m of l){if(m.kind!=="control"){u.push(m);continue}const f=h.get(m.control.id)||((p==null?void 0:p.oldId)===m.control.id?h.get(p.newId):void 0);if(!f)continue;c.add(f.id);const w=s.createUniqueDashboardInputVariableNameFromName(f.id,[...t,...u].filter(E=>E.id!==m.id)),y=f.id===w?f:{...f,id:w};u.push({...m,label:y.label,variableName:w,requiredAtExecution:y.requiredAtExecution,control:y})}for(const m of h.values())c.has(m.id)||u.push(s.createDashboardControlInputFromControl({control:m,existingInputs:[...t,...u],sheetId:r}));const i=new Set(l.map(m=>m.id));return[...t.filter(m=>!i.has(m.id)),...u]}function Fe({showFilters:t,onShowFiltersChange:r,pickerContent:l,settingsContent:o,size:a="default",className:d,primaryButtonClassName:h,secondaryButtonClassName:p,pickerContentClassName:c,settingsContentClassName:u}){const i=a==="toolbar",[g,m]=x.useState(!1),f=s.useSurfaceAppearance("interactive");return e.jsxs("div",{className:n.cn("relative inline-flex items-stretch overflow-hidden rounded-control border border-input bg-background",i?"h-8":"h-7",d),children:[e.jsxs(n.Popover,{open:t,onOpenChange:r,children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:e.jsxs(n.Button,{variant:"ghost",size:"xs",className:n.cn("h-full rounded-none border-0 bg-transparent pl-2.5 pr-2 shadow-none hover:bg-accent/50 data-[state=open]:bg-accent/60",h),children:[t?e.jsx(V.FilterX,{className:"h-3.5 w-3.5"}):e.jsx(s.Filter,{className:"h-3.5 w-3.5"}),"Filter"]})}),e.jsx(n.PopoverContent,{align:"end",sideOffset:6,className:n.cn("w-auto rounded-card border border-border/60 p-0 shadow-sm",c),style:f.contentStyle,children:l})]}),e.jsxs(n.Popover,{open:g,onOpenChange:m,children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:e.jsx(n.Button,{variant:"ghost",size:"xs",className:n.cn("h-full w-7 rounded-none border-0 border-l border-border/60 bg-transparent px-0 shadow-none hover:bg-accent/50 data-[state=open]:bg-accent/60",p),"aria-label":"Filter and control actions",children:e.jsx(K.ChevronDown,{className:"h-3.5 w-3.5"})})}),e.jsx(n.PopoverContent,{align:"end",sideOffset:6,className:n.cn("w-auto rounded-card border border-border/60 p-0 shadow-sm",u),style:f.contentStyle,children:o(()=>m(!1))})]})]})}function jt(){V.useSyncLegacyEditorState();const t=n.useDashboardStore(c=>c.selectedSheetId),r=n.useDashboardStore(c=>c.selectedFrameId),l=n.useDashboardStore(c=>c.dashboard),o=n.useDashboardStore(c=>c.actions.getSelectedFrame),{setSelectedFrameId:a}=n.useDashboardActions(),{setCard:d}=n.useEditorActions(),h=n.useEditorStore(c=>c.card.dataSource);return x.useEffect(()=>{var u,i;let c=o();if(!c){const g=(u=l==null?void 0:l.sheets)==null?void 0:u.find(f=>f.id===t),m=(i=g==null?void 0:g.frames)==null?void 0:i[0];m&&(a(m.id),c=m)}if(c){const g=c.cards.find(m=>m.id===c.activeCardId);g&&d(g)}},[o,t,r,l,a,d]),{hasEntities:!!(h!=null&&h.selectedEntities&&h.selectedEntities.length>0)}}function Ct(){const t=n.useDashboardStore(c=>c.dashboard),r=n.useDashboardStore(c=>c.semanticExecutionPayload),l=n.useDashboardStore(c=>c.actions.addFilter),{hasEntities:o}=jt(),{isLoading:a}=s.useFilterableFields(),d=x.useMemo(()=>n.getGlobalDateFilterCoverage(t,r),[t,r]),p=!n.getGlobalDateFilter(t.filters)&&d.hasEligibleCards&&!a;return e.jsxs("div",{className:"flex h-[520px] w-[400px] flex-col",children:[p&&e.jsx("div",{className:"border-b border-border/60 p-2",children:e.jsxs("button",{type:"button",onClick:()=>l(n.createDefaultGlobalDateFilter()),title:`Applies to ${d.eligibleCardCount} of ${d.totalCardCount} date-aware cards`,className:"flex w-full items-start gap-2 rounded-[4px] px-2 py-1.5 text-left outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-border",children:[e.jsx(ze,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsxs("span",{className:"flex min-w-0 flex-col",children:[e.jsx("span",{className:"text-[12px] font-medium text-foreground",children:"Add global date filter"}),e.jsx("span",{className:"text-[11px] leading-[1.4] text-muted-foreground",children:"One date range across all date-aware cards."})]})]})}),!o&&e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center px-6 py-8 text-center",children:[e.jsx(s.Database,{className:"mb-3 h-10 w-10 text-muted-foreground/50"}),e.jsx("h3",{className:"mb-1 text-[13px] font-medium text-foreground",children:"No fields configured"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Configure a data source for this card to enable filtering."})]}),o&&e.jsx("div",{className:"flex flex-1 overflow-hidden",children:e.jsx(s.FilterableFieldsPanel,{context:"filter"})})]})}const De=!1;function yt({onAddFilter:t,onAddControl:r,onManageControls:l,onDismiss:o}){const a=n.useDashboardStore(p=>p.dashboard.filterLayout),{setFilterLayout:d}=n.useDashboardActions();a!=null&&a.displayMode;const h=(a==null?void 0:a.toolbarWrap)??!1;return a==null||a.showDownloadButton,e.jsxs("div",{className:"w-[300px]",children:[e.jsxs("div",{className:"p-1",children:[e.jsx(ve,{icon:s.Filter,label:"Add filter",onClick:()=>{t(),o()}}),e.jsx(ve,{icon:n.SlidersHorizontal,label:"Add control",onClick:()=>{r(),o()}}),e.jsx(ve,{icon:s.Pencil,label:"Manage controls",onClick:()=>{l(),o()}})]}),e.jsx("div",{className:"border-t border-border/60"}),e.jsxs("div",{className:"space-y-1 p-2",children:[e.jsx("p",{className:"px-1 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Display"}),De,e.jsx(wt,{id:"filter-display-wrap",label:"Wrap to multiple lines",checked:h,onCheckedChange:p=>d({toolbarWrap:p===!0})}),De]})]})}function ve({icon:t,label:r,onClick:l}){return e.jsxs("button",{type:"button",onClick:l,className:"flex w-full items-center gap-2 rounded-[4px] px-2 py-1.5 text-left text-[13px] text-foreground transition-colors hover:bg-muted/40",children:[e.jsx(t,{className:"h-3.5 w-3.5 text-muted-foreground"}),r]})}function wt({id:t,label:r,checked:l,onCheckedChange:o}){return e.jsxs("div",{className:"flex items-center gap-2 rounded-[4px] px-1 py-1 transition-colors hover:bg-muted/40",children:[e.jsx(s.Checkbox,{id:t,checked:l,onCheckedChange:o}),e.jsx(n.Label,{htmlFor:t,className:"cursor-pointer text-[12px] font-normal leading-[1.3]",children:r})]})}function Nt({size:t,className:r,primaryButtonClassName:l,secondaryButtonClassName:o,pickerContentClassName:a,settingsContentClassName:d}){var T;const[h,p]=x.useState(null),c=n.useDashboardStore(v=>v.dashboard),u=n.useDashboardStore(v=>v.selectedSheetId),i=n.useDashboardStore(v=>v.showFilters),g=s.useAssistantLayoutStore(v=>v.setPanelOpen),m=n.useDashboardStore(v=>v.actions),{setDocumentInspectorTab:f,setShowFilters:w}=m,y=(T=c.sheets)==null?void 0:T.find(v=>v.id===u),E=n.isDocumentSheet(y),B=x.useCallback(v=>{window.setTimeout(()=>{p(v)},0)},[]),D=x.useCallback(v=>{if(E&&u){v&&f(u,"inputs");return}v&&g("dashboard",!1),w(v)},[E,u,f,g,w]),b=x.useCallback(()=>{D(!0)},[D]),S=x.useCallback(()=>{B("create")},[B]),A=x.useCallback(()=>{B("manage")},[B]);return e.jsxs(e.Fragment,{children:[e.jsx(Fe,{showFilters:E?!1:i,onShowFiltersChange:D,pickerContent:e.jsx(Ct,{}),settingsContent:v=>e.jsx(yt,{onAddFilter:b,onAddControl:S,onManageControls:A,onDismiss:v}),size:t,className:r,primaryButtonClassName:l,secondaryButtonClassName:o,pickerContentClassName:a,settingsContentClassName:d}),h?E?e.jsx(Ie,{open:!0,onOpenChange:v=>{v||p(null)},initialMode:h}):e.jsx(Be,{open:!0,onOpenChange:v=>{v||p(null)},showTrigger:!1,initialMode:h}):null]})}function Le({disabled:t,briefingCount:r,className:l,onClick:o}){const a=typeof r=="number"&&r>0;return e.jsxs(n.Button,{type:"button",size:"xs",variant:"outline",disabled:t,className:n.cn("gap-1.5",l),onClick:o,"aria-label":"Reports & briefings",children:[e.jsx($e,{className:"h-3.5 w-3.5"}),"Reports & briefings",a?e.jsx("span",{className:"ml-0.5 rounded-control bg-muted px-1 text-[10px] tabular-nums text-foreground/70",children:r}):null]})}const Dt="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",Te="inline-flex h-7 items-center gap-1.5 rounded-control px-2 text-[12px] text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-50",pe="inline-flex h-7 items-center gap-1.5 rounded-control bg-primary px-3 text-[12px] font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50";function St(t){return t==="dashboard"?"This dashboard":"Project"}function Et(t){if(!t)return"Never";const r=new Date(t);if(Number.isNaN(r.getTime()))return"Unknown";const l=Date.now()-r.getTime(),o=Math.round(l/6e4);if(o<1)return"now";if(o<60)return`${o}m ago`;const a=Math.round(o/60);if(a<24)return`${a}h ago`;const d=Math.round(a/24);if(d<7)return`${d}d ago`;const h=Math.round(d/7);return h<5?`${h}w ago`:`${Math.round(d/30)}mo ago`}function At(t){return t.scheduleExpr?X.describeBriefingSchedule(t.scheduleExpr,t.timezone||"UTC")??"Invalid schedule":"On demand"}function kt(t){if(t.lastRunStatus){const r=t.lastRunStatus.toString().toUpperCase();return r==="SUCCESS"?"Last run completed.":r==="FAILED"?"Last run failed.":`Last run ${t.lastRunStatus.toString().toLowerCase()}`}return null}function Me(t){return t.hasActiveRun?"Running":t.lastRunStatus?`Last run ${t.lastRunStatus.toString().toLowerCase()}`:"Idle"}function Bt(t){return t.source.type==="dashboard"?"This dashboard":"Project"}function It({activeView:t,onChange:r}){return e.jsx("div",{className:"flex shrink-0 items-center gap-1 rounded-control bg-muted p-0.5",role:"tablist","aria-label":"Briefing source view",children:["dashboard","project"].map(l=>{const o=t===l;return e.jsx("button",{type:"button",role:"tab","aria-selected":o,onClick:()=>r(l),className:n.cn("h-6 rounded-[3px] px-2 text-[11px] transition-colors",o?"bg-background font-medium text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:St(l)},l)})})}function Ft({briefings:t,dashboardLabel:r,sourceView:l,error:o,loading:a,onSourceViewChange:d,onClose:h,onEdit:p,onNew:c,canCreate:u,canCreateScheduledReport:i,analyticalBriefingsEnabled:g,onRunNow:m,onTogglePause:f,onDelete:w,selectingId:y,busyId:E,manageBriefingsHref:B,contentKind:D,hideHeader:b=!1}){const S=t.length,A=t.filter(I=>I.status==="ACTIVE").length,T=D==="reports"?S===1?"report":"reports":D==="briefings"?S===1?"briefing":"briefings":S===1?"item":"items",v=t.find(I=>I.hasActiveRun)??null,j=D??"reports & briefings",L=l==="dashboard"?r:`Project ${j}`;return e.jsxs("section",{"aria-label":`Dashboard ${j.replace("&","and")}`,className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:[b?null:e.jsxs("header",{className:"flex items-start justify-between gap-3 border-b border-border px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:Dt,children:j}),e.jsx("h2",{className:"mt-0.5 truncate text-[14px] font-semibold leading-5",children:L})]}),e.jsx("button",{type:"button",onClick:h,className:"rounded-control p-1 text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":`Close ${j.replace("&","and")} panel`,children:e.jsx(K.X,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border px-4 py-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(It,{activeView:l,onChange:d}),e.jsx("div",{className:"flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground",children:a&&S===0?e.jsxs("span",{children:["Loading ",j,"…"]}):S===0?e.jsxs("span",{children:["No ",j," yet"]}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"font-medium text-foreground/80",children:[S," ",T]}),e.jsx("span",{className:"text-border",children:"·"}),e.jsxs("span",{children:[A," active"]})]})})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[a?e.jsx(n.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"}):null,S>0&&u?g&&i?e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsxs("button",{className:pe,children:[e.jsx(s.Plus,{className:"h-3 w-3"})," New"]})}),e.jsxs(s.DropdownMenuContent,{align:"end",children:[e.jsx(s.DropdownMenuItem,{onClick:()=>c("scheduled_report"),children:"Schedule a report"}),e.jsx(s.DropdownMenuItem,{onClick:()=>c("analytical_briefing"),children:"Create analytical briefing"})]})]}):i?e.jsxs("button",{onClick:()=>c("scheduled_report"),className:pe,children:[e.jsx(s.Plus,{className:"h-3 w-3"})," Schedule report"]}):g?e.jsxs("button",{onClick:()=>c("analytical_briefing"),className:pe,children:[e.jsx(s.Plus,{className:"h-3 w-3"})," New briefing"]}):null:null]})]}),v?e.jsxs("div",{className:"flex items-center gap-2 border-b border-border bg-muted/60 px-4 py-2 text-[12px]",children:[e.jsx(n.LoaderCircle,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground"}),e.jsx("span",{className:"font-medium text-foreground",children:v.name}),e.jsx("span",{className:"text-border",children:"·"}),e.jsx("span",{className:"truncate text-muted-foreground",children:Me(v)})]}):null,e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[o?e.jsx("div",{className:"m-4 rounded-card border border-destructive/30 bg-destructive/10 px-3 py-2 text-[12px] text-destructive",children:o}):null,!a&&t.length===0&&!o?e.jsx(Lt,{onNew:c,canCreate:u,canCreateScheduledReport:i,analyticalBriefingsEnabled:g,contentKind:D}):null,t.map(I=>e.jsx(Mt,{briefing:I,isOpening:y===I.id,isBusy:E===I.id,onOpen:()=>p(I.id),onRunNow:()=>m(I),onTogglePause:()=>f(I),onDelete:()=>w(I)},I.id))]}),B?e.jsx("div",{className:"border-t border-border px-4 py-2.5",children:e.jsxs("a",{href:B,className:n.cn(Te,"h-6 px-1 text-[11px]"),children:["Manage all reports & briefings",e.jsx(Oe,{className:"h-3 w-3"})]})}):null]})}function Lt({onNew:t,canCreate:r,canCreateScheduledReport:l,analyticalBriefingsEnabled:o,contentKind:a}){const d=a==="reports"?{title:"No reports yet",description:"Schedule an emailed dashboard or visual report to see it here."}:a==="briefings"?{title:"No briefings yet",description:"Create an analytical briefing to monitor this dashboard and brief your team."}:null;return e.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-8 py-12 text-center",children:[e.jsx(Tt,{className:"mb-5 h-[88px] w-[112px] text-border"}),e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:(d==null?void 0:d.title)??"Have an analyst brief your team"}),e.jsx("p",{className:"mt-1.5 max-w-[320px] text-[12px] leading-5 text-muted-foreground",children:(d==null?void 0:d.description)??"Describe what to watch. An analyst digs into this dashboard and the data behind it, then briefs your team on the cadence you choose."}),r?e.jsxs("div",{className:"mt-4 flex flex-wrap justify-center gap-2",children:[l?e.jsxs("button",{onClick:()=>t("scheduled_report"),className:pe,children:[e.jsx(s.Plus,{className:"h-3 w-3"})," Schedule a report"]}):null,o?e.jsx("button",{onClick:()=>t("analytical_briefing"),className:Te,children:"Create analytical briefing"}):null]}):null]})}function Tt({className:t}){return e.jsxs("svg",{viewBox:"0 0 112 88",fill:"none",xmlns:"http://www.w3.org/2000/svg",role:"presentation","aria-hidden":"true",className:t,children:[e.jsx("rect",{x:"22",y:"6",width:"60",height:"72",rx:"3",stroke:"currentColor",strokeWidth:"1.25"}),e.jsx("line",{x1:"30",y1:"16",x2:"64",y2:"16",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("line",{x1:"30",y1:"21",x2:"52",y2:"21",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",opacity:"0.5"}),e.jsx("circle",{cx:"31",cy:"32",r:"1",fill:"currentColor",opacity:"0.6"}),e.jsx("line",{x1:"35",y1:"32",x2:"72",y2:"32",stroke:"currentColor",strokeWidth:"1",opacity:"0.4",strokeLinecap:"round"}),e.jsx("circle",{cx:"31",cy:"38",r:"1",fill:"currentColor",opacity:"0.6"}),e.jsx("line",{x1:"35",y1:"38",x2:"68",y2:"38",stroke:"currentColor",strokeWidth:"1",opacity:"0.4",strokeLinecap:"round"}),e.jsx("circle",{cx:"31",cy:"44",r:"1",fill:"currentColor",opacity:"0.6"}),e.jsx("line",{x1:"35",y1:"44",x2:"74",y2:"44",stroke:"currentColor",strokeWidth:"1",opacity:"0.4",strokeLinecap:"round"}),e.jsx("rect",{x:"30",y:"64",width:"5",height:"8",rx:"0.5",fill:"currentColor",opacity:"0.55"}),e.jsx("rect",{x:"38",y:"60",width:"5",height:"12",rx:"0.5",fill:"currentColor",opacity:"0.7"}),e.jsx("rect",{x:"46",y:"56",width:"5",height:"16",rx:"0.5",fill:"currentColor",opacity:"0.85"}),e.jsx("rect",{x:"54",y:"62",width:"5",height:"10",rx:"0.5",fill:"currentColor",opacity:"0.6"}),e.jsx("rect",{x:"62",y:"58",width:"5",height:"14",rx:"0.5",fill:"currentColor",opacity:"0.75"}),e.jsx("circle",{cx:"86",cy:"62",r:"10",fill:"var(--background, white)",stroke:"currentColor",strokeWidth:"1.25"}),e.jsx("line",{x1:"93.5",y1:"69.5",x2:"100",y2:"76",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function Mt({briefing:t,isOpening:r,isBusy:l,onOpen:o,onRunNow:a,onTogglePause:d,onDelete:h}){const p=t.status==="PAUSED",c=t.hasActiveRun,u=kt(t),i=Et(t.lastRunAt),g=t.lastRunStatus,m=X.getBriefingPresentation(t),f=g==="SUCCESS"?s.briefingTone.success.dot:g==="FAILED"?s.briefingTone.danger.dot:g?s.briefingTone.warning.dot:s.briefingTone.neutral.dot;return e.jsxs("div",{className:n.cn("group relative border-b border-border/60 px-4 py-3 transition-colors hover:bg-muted/60",p&&"opacity-70"),children:[e.jsxs("div",{role:"button",tabIndex:0,onClick:o,onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),o())},className:"cursor-pointer pr-8",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",children:t.name}),p?e.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:"· Paused"}):null]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-1.5 text-[11px] text-muted-foreground",children:[e.jsx("span",{children:m.typeLabel}),e.jsx("span",{className:"text-border",children:"·"}),e.jsx("span",{children:Bt(t)}),e.jsx("span",{className:"text-border",children:"·"}),e.jsx(s.Clock,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:At(t)}),t.lastRunAt?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-border",children:"·"}),e.jsxs("span",{children:["Last run ",i]})]}):null]}),u||c?e.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 text-[12px] leading-[1.5] text-foreground/80",children:[c?e.jsx(n.LoaderCircle,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground/70"}):e.jsx("span",{className:n.cn("inline-block h-1.5 w-1.5 shrink-0 rounded-full",f)}),e.jsx("span",{className:"truncate",children:c?Me(t):u})]}):null]}),e.jsx("div",{className:"absolute right-3 top-3",children:l?e.jsx(n.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground/70"}):r?e.jsx(n.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground/70"}):e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx("button",{type:"button",onClick:w=>w.stopPropagation(),className:"inline-flex h-6 w-6 items-center justify-center rounded-control text-muted-foreground/70 opacity-60 hover:bg-muted hover:text-foreground/80 focus-visible:opacity-100 group-hover:opacity-100","aria-label":`${m.noun==="report"?"Report":"Briefing"} actions`,children:e.jsx(s.Ellipsis,{className:"h-3.5 w-3.5"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"w-44",children:[e.jsxs(s.DropdownMenuItem,{onClick:o,children:[e.jsx(s.Pencil,{className:"h-3.5 w-3.5"}),"Edit ",m.noun]}),e.jsxs(s.DropdownMenuItem,{onClick:w=>{w.preventDefault(),a()},children:[e.jsx(s.Zap,{className:"h-3.5 w-3.5"}),"Run now"]}),t.scheduleExpr?e.jsx(s.DropdownMenuItem,{onClick:w=>{w.preventDefault(),d()},children:p?e.jsxs(e.Fragment,{children:[e.jsx(s.Play,{className:"h-3.5 w-3.5"}),"Resume"]}):e.jsxs(e.Fragment,{children:[e.jsx(s.Pause,{className:"h-3.5 w-3.5"}),"Pause"]})}):null,e.jsx(s.DropdownMenuSeparator,{}),e.jsxs(s.DropdownMenuItem,{onClick:w=>{w.preventDefault(),h()},className:"text-destructive focus:bg-destructive/10 focus:text-destructive",children:[e.jsx(s.Trash2,{className:"h-3.5 w-3.5"}),"Delete ",m.noun]})]})]})})]})}const Pt=2e3,Vt=20*6e4;function Rt(t){return(t==null?void 0:t.trim())||"This dashboard"}function Ut(t){return t==="This dashboard"?"Watch this dashboard":`Watch ${t}`}function Ot(t,r,l){return r!=="dashboard"?t:t.filter(o=>o.source.type==="dashboard"&&o.source.dashboardId===l)}async function zt(t){const l=[];let o=1,a=0,d=Number.POSITIVE_INFINITY;for(;a<d;){const h=await t.apiClient.listBriefings(t.apiServiceUrl,t.token,{scope:"organization",page:o,pageSize:100});if(l.push(...h.briefings),a+=h.briefings.length,d=h.total,h.briefings.length===0||a>=d)break;o+=1}return l}const _t={listBriefings:s.listBriefings,getBriefing:s.getBriefing,pauseBriefing:s.pauseBriefing,resumeBriefing:s.resumeBriefing,deleteBriefing:s.deleteBriefing,runBriefingNow:s.runBriefingNow};function $t({briefingId:t,initialRun:r,apiServiceUrl:l,token:o,onTerminal:a,onTimeout:d,onExpand:h}){const[p,c]=x.useState(r),{startRun:u}=s.useBriefingRunPolling({apiServiceUrl:l,token:o,intervalMs:Pt,timeoutMs:Vt,fetchRun:({apiServiceUrl:g,token:m,runId:f})=>s.getBriefingRun(g,m,t,f),onRun:g=>{c(g)},onTerminalRun:g=>{a(g)},onTimeout:()=>{d()}}),i=x.useRef(!1);return x.useEffect(()=>{i.current||(i.current=!0,s.isActiveBriefingRunStatus(r.status)?u(r):s.isTerminalBriefingRunStatus(r.status)&&a(r))},[r,a,u]),e.jsx(s.BackgroundRunPill,{run:p,onExpand:h})}function qt(t){return e.jsx(s.BriefingUiCapabilitiesBoundary,{children:e.jsx(Ht,{...t})})}function Ht({dashboardId:t,dashboardTitle:r,apiServiceUrl:l,token:o,disabled:a,className:d,manageBriefingsHref:h,open:p,onOpenChange:c,hideTrigger:u=!1,workflowIntent:i,client:g}){const{authToken:m,tokenProps:f}=s.useSemaphorContext(),w=s.useBriefingUiCapabilities(),y=!i||w.canCreate&&(i==="scheduled_report"||w.analyticalBriefingsEnabled),[E,B]=x.useState(!1),D=p??E,b=N=>{p===void 0&&B(N),c==null||c(N)},[S,A]=x.useState(i?"author":"list"),[T,v]=x.useState(i??"analytical_briefing"),[j,L]=x.useState("dashboard"),[I,$]=x.useState([]),[k,M]=x.useState(null),_=i&&!y&&!k?"list":S,[oe,q]=x.useState(!1),[fe,ie]=x.useState(null),[ge,W]=x.useState(null),[U,Q]=x.useState(null),[ee,te]=x.useState(null),le=x.useRef(null),ue=x.useRef(D);x.useEffect(()=>{const N=D&&!ue.current;ue.current=D,!(!N||!i)&&(M(null),L("dashboard"),v(i),A("author"),te(null))},[D,i]);const[se,ne]=x.useState(null),[G,ce]=x.useState(null),O=l??(f==null?void 0:f.apiServiceUrl),z=o??(m==null?void 0:m.accessToken),Z=x.useMemo(()=>({..._t,...g}),[g]),ae=Rt(r),he=x.useMemo(()=>{const N=Ot(I,j,t);if(!i)return N;const P=i==="scheduled_report"?"report":"briefing";return N.filter(me=>X.getBriefingPresentation(me).noun===P)},[t,I,j,i]),be=x.useMemo(()=>j==="dashboard"?{source:{type:"dashboard",dashboardId:t},label:ae,detail:Ut(ae)}:{source:{type:"project"},label:"This project",detail:"Use any data in this project."},[t,ae,j]),de=!!(O&&z),re=X.getBriefingCreationIntents({canCreate:w.canCreate,analyticalBriefingsEnabled:w.analyticalBriefingsEnabled,scheduledReportAvailable:j==="dashboard"}),H=x.useCallback(async()=>{if(!(!O||!z)){q(!0),te(null);try{$(await zt({apiClient:Z,apiServiceUrl:O,token:z}))}catch(N){te(N instanceof Error?N.message:"Could not load briefings.")}finally{q(!1)}}},[Z,O,z]);x.useEffect(()=>{!D||_!=="list"||!de||H()},[de,_,H,D]);const C=()=>{M(null),L("dashboard"),A("list"),b(!0)},F=N=>{M(null),v(N),A("author")},R=async N=>{if(!(!O||!z)){ie(N),te(null);try{const P=await Z.getBriefing(O,z,N);M(P.briefing),A("author")}catch(P){te(P instanceof Error?P.message:"Could not open briefing.")}finally{ie(null)}}},Y=async N=>{if(!(!O||!z)){W(N.id);try{await Z.runBriefingNow(O,z,N.id,{requestId:Wt()}),H()}catch(P){s.ue.error(P instanceof Error?P.message:"Could not start the run.")}finally{W(null)}}},J=async N=>{if(!O||!z)return;const{noun:P}=X.getBriefingPresentation(N),me=P==="report"?"Report":"Briefing";W(N.id);try{const xe=N.status==="PAUSED"?await Z.resumeBriefing(O,z,N.id):await Z.pauseBriefing(O,z,N.id);s.ue.success(xe.briefing.status==="PAUSED"?`${me} paused`:`${me} resumed`),H()}catch(xe){s.ue.error(xe instanceof Error?xe.message:`Could not update the ${P} status.`)}finally{W(null)}},Pe=async()=>{if(!U||!O||!z)return;const N=U;W(N.id);try{await Z.deleteBriefing(O,z,N.id);const{noun:P}=X.getBriefingPresentation(N);s.ue.success(`${P==="report"?"Report":"Briefing"} deleted`),Q(null),H()}catch(P){s.ue.error(P instanceof Error?P.message:"Could not delete the briefing.")}finally{W(null)}},Ve=he.length;return w.surfaceVisible?e.jsxs(s.Sheet,{open:D,onOpenChange:b,children:[u?null:e.jsx(Le,{disabled:a||!de,briefingCount:Ve,className:d,onClick:C}),e.jsxs(s.SheetContent,{ref:le,side:"right",hideClose:!0,className:"flex h-full w-full flex-col overflow-hidden p-0 outline-none sm:max-w-[560px]",onOpenAutoFocus:N=>{var P;N.preventDefault(),(P=le.current)==null||P.focus({preventScroll:!0})},children:[e.jsxs(s.SheetHeader,{className:"sr-only",children:[e.jsx(s.SheetTitle,{children:"Reports & briefings"}),e.jsx(s.SheetDescription,{children:"Manage reports and briefings for this dashboard."})]}),i?e.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-3 border-b border-border pl-4 pr-3 pt-2",children:[e.jsxs("div",{className:"flex items-center gap-5",role:"tablist","aria-label":i==="scheduled_report"?"Email report workflow":"Analytical briefing workflow",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":_==="author",disabled:!y,className:n.cn("-mb-px border-b-2 px-0.5 pb-2 text-[12px] transition-colors",_==="author"?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground",!y&&"cursor-not-allowed opacity-50"),onClick:()=>{y&&(M(null),v(i),L("dashboard"),A("author"))},children:k?`Edit ${X.getBriefingPresentation(k).noun}`:i==="scheduled_report"?"Schedule report":"Create briefing"}),e.jsx("button",{type:"button",role:"tab","aria-selected":_==="list",className:n.cn("-mb-px border-b-2 px-0.5 pb-2 text-[12px] transition-colors",_==="list"?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),onClick:()=>A("list"),children:i==="scheduled_report"?"Manage reports":"Manage briefings"})]}),e.jsx("button",{type:"button",onClick:()=>b(!1),className:"rounded-control p-1 text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":i==="scheduled_report"?"Close email report workflow":"Close analytical briefing workflow",children:e.jsx(K.X,{className:"h-3.5 w-3.5"})})]}):null,_==="list"?e.jsx(Ft,{briefings:he,dashboardLabel:ae,sourceView:j,error:ee,loading:oe,onSourceViewChange:L,onClose:()=>b(!1),onEdit:N=>{R(N)},onNew:F,canCreate:!i&&re.length>0,canCreateScheduledReport:re.includes("scheduled_report"),analyticalBriefingsEnabled:re.includes("analytical_briefing"),onRunNow:N=>{Y(N)},onTogglePause:N=>{J(N)},onDelete:N=>Q(N),selectingId:fe,busyId:ge,manageBriefingsHref:h,contentKind:i==="scheduled_report"?"reports":i==="analytical_briefing"?"briefings":void 0,hideHeader:!!i}):e.jsx(s.BriefingAuthor,{apiServiceUrl:O,token:z,briefing:k,intent:T,sourceContext:k?void 0:be,title:k?`Edit ${X.getBriefingPresentation(k).noun}`:T==="scheduled_report"?"Schedule report":"Create analytical briefing",hideHeader:!!i,className:"h-full min-h-0 max-w-none border-0 shadow-none",onBack:i?void 0:()=>A("list"),onCancel:()=>b(!1),onDeleted:()=>{const N=k?X.getBriefingPresentation(k).noun:"briefing";s.ue.success(`${N==="report"?"Report":"Briefing"} deleted`),M(null),A("list"),H()},onRunStarted:()=>{},onSaved:N=>{M(N),H()},onMinimizeRun:({briefing:N,run:P})=>{ne({briefing:N,run:P}),b(!1)}})]}),se&&O&&z?e.jsx($t,{briefingId:se.briefing.id,initialRun:se.run,apiServiceUrl:O,token:z,onTerminal:N=>{ce({briefing:se.briefing,run:N}),ne(null),H()},onTimeout:()=>{ne(null),H()},onExpand:()=>{M(se.briefing),A("author"),ne(null),b(!0)}}):null,G?e.jsx("div",{className:"fixed bottom-4 right-4 z-50 w-[360px]",children:e.jsx(s.RunCompletionBanner,{title:G.run.status==="SUCCESS"?`${G.briefing.name} is ready`:`${G.briefing.name} run failed`,durationSeconds:G.run.startedAt&&G.run.completedAt?Math.max(0,Math.floor((new Date(G.run.completedAt).getTime()-new Date(G.run.startedAt).getTime())/1e3)):null,status:G.run.status==="SUCCESS"?"success":"failed",onView:()=>{M(G.briefing),A("author"),ce(null),b(!0)},onDismiss:()=>ce(null)})}):null,e.jsx(s.AlertDialog,{open:!!U,onOpenChange:N=>{N||Q(null)},children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsxs(s.AlertDialogTitle,{children:["Delete"," ",U?X.getBriefingPresentation(U).noun:"briefing","?"]}),e.jsxs(s.AlertDialogDescription,{children:["This permanently deletes ",e.jsx("strong",{children:U==null?void 0:U.name}),". Recipients will stop receiving it."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsxs(s.AlertDialogAction,{className:"bg-destructive/90 hover:bg-destructive",onClick:Pe,children:["Delete"," ",U?X.getBriefingPresentation(U).noun:"briefing"]})]})]})})]}):null}function Wt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`briefing-run-now-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}exports.AdvancedModeToggle=st;exports.DashboardBriefingLauncher=qt;exports.DashboardControlsSettings=Be;exports.DashboardFilterControlsButton=Fe;exports.DashboardFilterControlsLauncher=Nt;exports.DocumentControlsSettings=Ie;exports.ExportNotificationItem=Ae;exports.ExportNotificationList=ke;exports.NotificationBell=mt;exports.UnsavedChangesAlert=rt;exports.VisualEditingControls=tt;exports.VisualsLibraryDialog=Ke;exports.WatchDashboardButton=Le;exports.useExportPolling=dt;exports.useExportRecovery=ut;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),o=require("react"),b=require("./x-B6ghREd2.cjs"),s=require("./switch-Cjk6G06r.cjs");require("./validators-9D4KBqKD.cjs");require("./analyze-result-contract-BHb7sUUW.cjs");require("../value-format-preferences/index.cjs");require("./index-DPv8_Ild.cjs");require("./index-DRlMUglg.cjs");require("./temporal-bucket-authoring-CPTwHzvs.cjs");require("./temporal-result-owner-f6-i65Fb.cjs");require("react-dom");require("../briefings/index.cjs");function S(){const t=s.useDashboardStore(e=>e.dashboard),d=s.useDashboardStore(e=>e.actions.setDashboard),c=s.useDashboardStore(e=>e.showDashboardJSON),h=s.useDashboardStore(e=>e.actions.setShowDashboardJSON),r=o.useMemo(()=>t?JSON.stringify(t,null,2):"",[t]),[l,n]=o.useState(r),i=o.useRef(r);return o.useEffect(()=>{r!==i.current&&(n(r),i.current=r)},[r]),a.jsxs("div",{className:s.cn("relative p-2",{hidden:!c}),children:[a.jsxs(s.Button,{variant:"secondary",size:"sm",className:"absolute right-2 top-2 z-10 h-8",onClick:()=>h(!1),children:[a.jsx(b.X,{className:"mr-2 h-4 w-4"}),"Close"]}),a.jsx("div",{className:"h-[550px] overflow-hidden",children:a.jsx(s.CodeEditor,{value:l,onValueChange:e=>{n(e);try{const u=JSON.parse(e);i.current=JSON.stringify(u,null,2),d(u)}catch{}},language:"json"})})]})}exports.default=S;
|