react-semaphor 0.1.424 → 0.1.426

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +246 -91
  3. package/dist/appearance/index.cjs +1 -1
  4. package/dist/appearance/index.js +1 -1
  5. package/dist/brand-studio/index.cjs +2 -2
  6. package/dist/brand-studio/index.js +8 -8
  7. package/dist/chunks/{analyze-result-contract-D7pjjYPy.js → analyze-result-contract-DnfF8kBb.js} +434 -427
  8. package/dist/chunks/analyze-result-contract-ege_u6Nl.js +1 -0
  9. package/dist/chunks/{braces-8TRlDwDw.js → braces-BdbUk_r9.js} +1 -1
  10. package/dist/chunks/{braces-D2tStQjF.js → braces-CbO-aIwH.js} +1 -1
  11. package/dist/chunks/calendar-preferences-dialog-C-gN-vlq.js +1 -0
  12. package/dist/chunks/{calendar-preferences-dialog-D5mABNDT.js → calendar-preferences-dialog-tBSngRN-.js} +4 -4
  13. package/dist/chunks/{catalog-field-grounding-CJKAqtiC.js → catalog-field-grounding-AOGwWu0K.js} +11 -11
  14. package/dist/chunks/{switch-2bh3Hka1.js → code-editor-Pod1s6SK.js} +9927 -9098
  15. package/dist/chunks/code-editor-tfzm8LWW.js +138 -0
  16. package/dist/chunks/{common-types-4bjoIgvm.js → common-types-ClkOI-3O.js} +4 -4
  17. package/dist/chunks/comparison-document-migration-BJH1idOd.js +414 -0
  18. package/dist/chunks/comparison-document-migration-b6c3xiWh.js +1 -0
  19. package/dist/chunks/dashboard-JNK2ly_e.js +1402 -0
  20. package/dist/chunks/{index-Dzz6jXSY.js → dashboard-ZoKNg47G.js} +67158 -65267
  21. package/dist/chunks/{dashboard-briefing-launcher-DuWgwtxX.js → dashboard-briefing-launcher-0kR-QThz.js} +11 -6
  22. package/dist/chunks/{dashboard-briefing-launcher-BNDzMjjt.js → dashboard-briefing-launcher-BE-sNAzW.js} +226 -209
  23. package/dist/chunks/dashboard-controls-BUYTVauu.js +36 -0
  24. package/dist/chunks/dashboard-controls-Ce_Bps8f.js +2196 -0
  25. package/dist/chunks/dashboard-date-comparison-definition-BaYxjLi5.js +167 -0
  26. package/dist/chunks/dashboard-date-comparison-definition-DGZr3m-b.js +1 -0
  27. package/dist/chunks/dashboard-input-contract-BFpERluO.js +18 -0
  28. package/dist/chunks/dashboard-input-contract-DV3cshjz.js +1 -0
  29. package/dist/chunks/{dashboard-json-CkTEDNtH.js → dashboard-json-4quaFoSw.js} +16 -15
  30. package/dist/chunks/dashboard-json-81uc8aVR.js +1 -0
  31. package/dist/chunks/date-formatter-BTTYdAik.js +1 -0
  32. package/dist/chunks/date-formatter-D-89jTjG.js +514 -0
  33. package/dist/chunks/{edit-dashboard-visual-CRjVRZLk.js → edit-dashboard-visual-DqQsH7rN.js} +8470 -8520
  34. package/dist/chunks/edit-dashboard-visual-nVRXv1Lq.js +182 -0
  35. package/dist/chunks/{index-CjzRe2su.js → index-CnujJ3fa.js} +3 -3
  36. package/dist/chunks/{index-DRlMUglg.js → index-Dpm_VET4.js} +2 -2
  37. package/dist/chunks/{index-CJdxSyQq.js → index-If0wlXGi.js} +308 -308
  38. package/dist/chunks/index-jSrCwPQz.js +31 -0
  39. package/dist/chunks/{x-CXDkqdur.js → index-xHCrHprY.js} +59 -59
  40. package/dist/chunks/{layout-grid-C0OI-MRn.js → layout-grid-B08pP7v6.js} +1 -1
  41. package/dist/chunks/{layout-grid-CiubineE.js → layout-grid-D5tYJg1-.js} +1 -1
  42. package/dist/chunks/metric-comparison-BKgkMy9r.js +1 -0
  43. package/dist/chunks/metric-comparison-CWweq9RG.js +387 -0
  44. package/dist/chunks/{palette-C4KTXOug.js → palette-C0yjT5Tv.js} +1 -1
  45. package/dist/chunks/{palette-Cp1hqZtm.js → palette-jqaAcwiQ.js} +1 -1
  46. package/dist/chunks/{save-DgMfP0j8.js → save-HCJjjzdX.js} +1 -1
  47. package/dist/chunks/{save-C__QggEE.js → save-Xdc4pnys.js} +1 -1
  48. package/dist/chunks/{search-BHsQIWBV.js → search-DHZCro8B.js} +1 -1
  49. package/dist/chunks/{search-DNCejM7Z.js → search-Dcud9ajy.js} +1 -1
  50. package/dist/chunks/{update-policy-C1pmhLz9.js → update-policy-BgONreNd.js} +1 -1
  51. package/dist/chunks/{update-policy-BCJc0oI5.js → update-policy-CY2k-pJP.js} +9 -9
  52. package/dist/chunks/{use-create-flow-overlay-state-B-bYbtix.js → use-create-flow-overlay-state-CoANTEXS.js} +2 -2
  53. package/dist/chunks/{use-create-flow-overlay-state-B9vArrvr.js → use-create-flow-overlay-state-DUVIsF0y.js} +62 -62
  54. package/dist/chunks/validators-B4VMLX3_.js +1 -0
  55. package/dist/chunks/{validators-PXkij33j.js → validators-Cz-XuORM.js} +123 -119
  56. package/dist/dashboard/index.cjs +1 -1
  57. package/dist/dashboard/index.js +2 -2
  58. package/dist/dashboard-authoring/index.cjs +2 -2
  59. package/dist/dashboard-authoring/index.js +6 -4
  60. package/dist/data-app-builder/index.cjs +6 -6
  61. package/dist/data-app-builder/index.js +5 -5
  62. package/dist/data-app-codegen/index.cjs +1 -1
  63. package/dist/data-app-codegen/index.js +2 -2
  64. package/dist/data-app-codegen-node/index.cjs +1 -1
  65. package/dist/data-app-codegen-node/index.js +3 -3
  66. package/dist/data-app-sdk/index.cjs +1 -1
  67. package/dist/data-app-sdk/index.js +6 -6
  68. package/dist/data-app-sdk-adapters/index.cjs +1 -1
  69. package/dist/data-app-sdk-adapters/index.js +1 -1
  70. package/dist/data-app-sdk-validation/index.cjs +1 -1
  71. package/dist/data-app-sdk-validation/index.js +65 -68
  72. package/dist/format-utils/index.cjs +2 -2
  73. package/dist/format-utils/index.js +59 -58
  74. package/dist/index.cjs +1 -1
  75. package/dist/index.js +19 -19
  76. package/dist/style.css +1 -1
  77. package/dist/surfboard/index.cjs +1 -1
  78. package/dist/surfboard/index.js +3 -3
  79. package/dist/types/analytics-protocol.d.ts +337 -3
  80. package/dist/types/brand-studio.d.ts +2 -2
  81. package/dist/types/briefings.d.ts +65 -41
  82. package/dist/types/dashboard-assistant.d.ts +28 -7
  83. package/dist/types/dashboard-authoring.d.ts +123 -43
  84. package/dist/types/dashboard.d.ts +122 -48
  85. package/dist/types/data-app-builder.d.ts +2 -2
  86. package/dist/types/data-app-sdk.d.ts +1 -1
  87. package/dist/types/format-utils.d.ts +98 -10
  88. package/dist/types/index.js +1 -1
  89. package/dist/types/main.d.ts +264 -100
  90. package/dist/types/shared.d.ts +84 -43
  91. package/dist/types/surfboard.d.ts +124 -49
  92. package/dist/types/types.d.ts +135 -50
  93. package/package.json +2 -1
  94. package/dist/chunks/analyze-result-contract-DpDcImgk.js +0 -1
  95. package/dist/chunks/calendar-preferences-dialog-iokD3HbE.js +0 -1
  96. package/dist/chunks/contracts-CoCOpd_i.js +0 -11
  97. package/dist/chunks/contracts-CtB2VONT.js +0 -1
  98. package/dist/chunks/dashboard-controls-bbEF-AbK.js +0 -52
  99. package/dist/chunks/dashboard-controls-id39vb7G.js +0 -2322
  100. package/dist/chunks/dashboard-json-DVoqS1ks.js +0 -1
  101. package/dist/chunks/date-formatter-B4EBSe9C.js +0 -1
  102. package/dist/chunks/date-formatter-BlhBftA9.js +0 -416
  103. package/dist/chunks/edit-dashboard-visual-CkrxZCcp.js +0 -178
  104. package/dist/chunks/index-S1CGUcSz.js +0 -1406
  105. package/dist/chunks/switch-DMT7qf_R.js +0 -138
  106. package/dist/chunks/validators-DMlVbd1p.js +0 -1
  107. package/dist/chunks/x-B6ghREd2.js +0 -31
@@ -651,6 +651,8 @@ export declare type CancelBriefingRunResponse = {
651
651
  transitionApplied: boolean;
652
652
  };
653
653
 
654
+ declare type CanonicalDurationUnit = 'millisecond' | 'second' | 'minute' | 'hour' | 'day';
655
+
654
656
  export declare type CanonicalFormatSpec = NumericCanonicalFormat | DateCanonicalFormat | DurationCanonicalFormat | StringCanonicalFormat;
655
657
 
656
658
  export declare interface CardConfig {
@@ -714,9 +716,6 @@ export declare interface CardConfig {
714
716
  * Configuration for on-click dashboard filters triggered by this card.
715
717
  */
716
718
  clickFilterInteractions?: ClickFilterInteraction[];
717
- comparisonType?: 'none' | 'previous_period' | 'same_period_last_year' | 'target' | 'start_vs_end';
718
- targetValue?: number;
719
- showComparisonInLegend?: boolean;
720
719
  showTrendline?: boolean;
721
720
  trendlineWindow?: number;
722
721
  trendlineGranularity?: 'day' | 'week' | 'month';
@@ -881,6 +880,33 @@ declare type ColumnType = 'string' | 'number' | 'date';
881
880
 
882
881
  declare type ComparisonOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte';
883
882
 
883
+ declare type ComparisonPresentationSpec = {
884
+ /** Defaults to difference. */
885
+ displayMode?: 'difference' | 'percent_change' | 'both' | 'ratio';
886
+ /** Defaults to true. This controls display, not baseline selection. */
887
+ showComparison?: boolean;
888
+ /** Percent/ratio precision. Defaults to the surface formatter; valid range is 0..6. */
889
+ precision?: number;
890
+ /** Defaults to arrow_badge. */
891
+ indicatorStyle?: 'arrow_badge' | 'arrow' | 'badge' | 'none';
892
+ /** Defaults to true. */
893
+ showColor?: boolean;
894
+ position?: 'left' | 'right' | 'top';
895
+ /** Defaults to false. */
896
+ conditionalLabel?: boolean;
897
+ labelName?: string;
898
+ conditionalLabels?: {
899
+ increase?: string;
900
+ decrease?: string;
901
+ neutral?: string;
902
+ };
903
+ colors?: {
904
+ increase?: string;
905
+ decrease?: string;
906
+ neutral?: string;
907
+ };
908
+ };
909
+
884
910
  declare type ConditionalFormatCondition = {
885
911
  kind: 'comparison';
886
912
  columnId: string;
@@ -1145,11 +1171,17 @@ export declare type DashboardInputScope = {
1145
1171
  sectionIds: string[];
1146
1172
  };
1147
1173
 
1148
- export declare type DashboardInputSlot = {
1174
+ export declare type DashboardInputSlot = ({
1149
1175
  status: 'set';
1150
1176
  value: DashboardInputValue;
1151
- } | {
1177
+ comparisonSelection?: GlobalDateComparisonSelection;
1178
+ }) | ({
1152
1179
  status: 'cleared';
1180
+ comparisonSelection?: GlobalDateComparisonSelection;
1181
+ }) | {
1182
+ status?: never;
1183
+ value?: never;
1184
+ comparisonSelection: GlobalDateComparisonSelection;
1153
1185
  };
1154
1186
 
1155
1187
  export declare type DashboardInputTextContent = Array<{
@@ -1421,7 +1453,6 @@ export declare interface DetailTableBackupConfig {
1421
1453
  function: AggregateFunction;
1422
1454
  pivotLevel: string | 'ALL';
1423
1455
  }>;
1424
- comparisonType?: 'none' | 'previous_period' | 'same_period_last_year' | 'target' | 'start_vs_end';
1425
1456
  }
1426
1457
 
1427
1458
  export declare type Dialect = 'mysql' | 'postgres' | 'bigquery' | 'redshift' | 'snowflake' | 'clickhouse' | 'duckdb' | 'mssql';
@@ -1772,18 +1803,16 @@ export declare type DroppableId = 'droppable-group-by' | 'droppable-metric';
1772
1803
 
1773
1804
  declare type DurationCanonicalFormat = {
1774
1805
  type: 'duration';
1775
- inputUnit?: DurationUnit;
1806
+ inputUnit?: CanonicalDurationUnit;
1776
1807
  outputStyle?: 'compact' | 'digital' | 'long';
1777
- largestUnit?: DurationUnit;
1778
- smallestUnit?: DurationUnit;
1808
+ largestUnit?: CanonicalDurationUnit;
1809
+ smallestUnit?: CanonicalDurationUnit;
1779
1810
  maxUnits?: number;
1780
1811
  prefix?: string;
1781
1812
  suffix?: string;
1782
1813
  negativeStyle?: 'minus' | 'parentheses';
1783
1814
  };
1784
1815
 
1785
- declare type DurationUnit = 'millisecond' | 'second' | 'minute' | 'hour' | 'day';
1786
-
1787
1816
  declare interface DynamicDrillInteraction {
1788
1817
  mode: 'dynamicDrill';
1789
1818
  /**
@@ -2092,7 +2121,8 @@ export declare type FormatSpec = {
2092
2121
  export declare type GetDashboardResponse = {
2093
2122
  dashboard: TDashboard;
2094
2123
  lenses: TLens[];
2095
- filterValues?: TFilterValue[];
2124
+ filterValues?: TFilterValue[] | null;
2125
+ inputValues?: LensInputValuesSnapshot | null;
2096
2126
  defaultLensId?: string;
2097
2127
  assistantProfileId?: string;
2098
2128
  semanticExecutionPayload: SemanticExecutionPayload;
@@ -2109,6 +2139,13 @@ export declare type GetPluginsResponse = {
2109
2139
  }[];
2110
2140
  };
2111
2141
 
2142
+ declare type GlobalDateComparisonSelection = {
2143
+ mode: 'off';
2144
+ } | {
2145
+ mode: 'period';
2146
+ spec: ViewerPeriodComparisonSpec;
2147
+ };
2148
+
2112
2149
  declare type Granularity = 'day' | 'week' | 'month' | 'quarter' | 'year' | 'hour' | 'minute' | 'second';
2113
2150
 
2114
2151
  declare interface GroupByColumn extends BaseColumn {
@@ -2292,6 +2329,11 @@ export declare type KPICardProps = {
2292
2329
  renderFilterInfo?: () => JSX.Element | null;
2293
2330
  };
2294
2331
 
2332
+ export declare type LensInputValuesSnapshot = {
2333
+ generatedAt: string;
2334
+ dashboardInputValues: DashboardInputValues;
2335
+ };
2336
+
2295
2337
  export declare type Level = 'database' | 'schema' | 'table';
2296
2338
 
2297
2339
  declare interface LinkFormat {
@@ -2308,6 +2350,14 @@ export declare type LoadingProps = {
2308
2350
 
2309
2351
  export declare type LogicalOperator = 'AND' | 'OR';
2310
2352
 
2353
+ /**
2354
+ * A comparison input proven to be present in the card's executed filter set.
2355
+ * Ownership and UI coverage must consume this stage, never source inputs.
2356
+ */
2357
+ export declare type MaterializedDashboardDateComparisonInput = ResolvedDashboardDateComparisonInput & {
2358
+ effectiveFilterValue: TFilterValue;
2359
+ };
2360
+
2311
2361
  declare type MatrixAxisLevelDescriptor = {
2312
2362
  instanceId: string;
2313
2363
  fieldKey: string;
@@ -2534,6 +2584,30 @@ declare interface MetricColumn extends BaseColumn {
2534
2584
  aliasTemplate?: string;
2535
2585
  }
2536
2586
 
2587
+ declare type MetricComparisonConfig = {
2588
+ mode: 'off';
2589
+ } | {
2590
+ mode: 'explicit';
2591
+ spec: MetricComparisonSpec;
2592
+ };
2593
+
2594
+ declare type MetricComparisonPolarity = 'higher_is_better' | 'lower_is_better' | 'neutral';
2595
+
2596
+ declare type MetricComparisonSpec = {
2597
+ kind: 'previous_period';
2598
+ offsetPeriods?: number;
2599
+ alignment?: 'calendar' | 'weekday';
2600
+ toDate?: boolean;
2601
+ } | {
2602
+ kind: 'previous_year';
2603
+ offsetYears?: number;
2604
+ alignment?: 'calendar' | 'weekday';
2605
+ toDate?: boolean;
2606
+ } | {
2607
+ kind: 'target';
2608
+ targetValue: number;
2609
+ };
2610
+
2537
2611
  export declare interface MetricField extends Field {
2538
2612
  role: 'metric';
2539
2613
  aggregate?: AggregateFunction;
@@ -2582,9 +2656,10 @@ export declare interface MetricField extends Field {
2582
2656
  * pre-aggregated metric input.
2583
2657
  */
2584
2658
  isPreAggregated?: boolean;
2585
- comparisonType?: 'none' | 'previous_period' | 'same_period_last_year' | 'start_vs_end' | 'target';
2586
- comparisonDisplay?: 'column' | 'inline' | 'hover';
2587
- targetValue?: number;
2659
+ comparison?: MetricComparisonConfig;
2660
+ comparisonPolarity?: MetricComparisonPolarity;
2661
+ /** Governed runtime annotation. When present, authoring polarity is read-only. */
2662
+ semanticComparisonPolarity?: MetricComparisonPolarity;
2588
2663
  }
2589
2664
 
2590
2665
  declare type NoneOptions = {};
@@ -2607,6 +2682,15 @@ export declare type NumberOptions = {
2607
2682
  colorRanges?: ColorRange[];
2608
2683
  };
2609
2684
 
2685
+ /**
2686
+ * Shared format types for export system
2687
+ * IMPORTANT: No React imports allowed in this file
2688
+ *
2689
+ * These types are used by:
2690
+ * - react-semaphor (browser) for client-side exports
2691
+ * - semaphor-app (Next.js) for API routes
2692
+ * - Lambda (Node.js) for async export processing
2693
+ */
2610
2694
  declare type NumericCanonicalFormat = {
2611
2695
  type: 'number' | 'currency' | 'percent' | 'scientific';
2612
2696
  locale?: string;
@@ -2675,6 +2759,7 @@ export declare interface PivotByField extends Field {
2675
2759
 
2676
2760
  export declare interface PivotColumnSchema {
2677
2761
  alias: string;
2762
+ metricAlias?: string;
2678
2763
  metricId: string;
2679
2764
  metricName: string;
2680
2765
  metricLabel?: string;
@@ -2812,6 +2897,20 @@ export declare type RelativeDateFilter = {
2812
2897
 
2813
2898
  export declare type RelativeDateUnit = DateUnit | SubDayDateUnit;
2814
2899
 
2900
+ export declare type ResolvedDashboardDateComparisonInput = {
2901
+ inputId: string;
2902
+ filterId: string;
2903
+ label: string;
2904
+ filter: TFilter;
2905
+ /**
2906
+ * The active value before execution-only canonicalization. Comparison
2907
+ * ownership uses this value as provenance evidence and must fail closed
2908
+ * when its filter or field identity does not match the definition.
2909
+ */
2910
+ filterValue?: TFilterValue;
2911
+ selection: GlobalDateComparisonSelection;
2912
+ };
2913
+
2815
2914
  export declare type ResolvedDashboardInput = {
2816
2915
  id: string;
2817
2916
  kind: 'filter' | 'control';
@@ -2827,6 +2926,7 @@ export declare type ResolvedDashboardInput = {
2827
2926
  control?: ControlDefinition;
2828
2927
  controlValue?: unknown;
2829
2928
  missingRequiredValue?: boolean;
2929
+ comparisonSelection?: GlobalDateComparisonSelection;
2830
2930
  };
2831
2931
 
2832
2932
  export declare type ResolvedDashboardInputContext = {
@@ -2838,6 +2938,8 @@ export declare type ResolvedDashboardInputContext = {
2838
2938
  controlBindings: ControlBinding[];
2839
2939
  controlValues: Record<string, unknown>;
2840
2940
  variablesByName: Record<string, ResolvedDashboardInput>;
2941
+ globalDateComparisonSelection?: GlobalDateComparisonSelection;
2942
+ dateComparisonInputs?: ResolvedDashboardDateComparisonInput[];
2841
2943
  variablesById: Record<string, ResolvedDashboardInput>;
2842
2944
  missingRequiredInputs: ResolvedDashboardInput[];
2843
2945
  };
@@ -2862,6 +2964,8 @@ declare type ResolvedPrimaryDateField = {
2862
2964
  entityName: string;
2863
2965
  entityType: string;
2864
2966
  dataType: string;
2967
+ /** Canonical dataset coordinates stamped by the temporal grounding boundary. */
2968
+ source?: SemaphorSourceRef;
2865
2969
  dateFormat?: string;
2866
2970
  customFormat?: string;
2867
2971
  defaultGranularity?: TimeGranularity;
@@ -3713,6 +3817,11 @@ export declare type TCardContext = {
3713
3817
  };
3714
3818
 
3715
3819
  export declare type TCardPreferences = {
3820
+ comparisonPresentation?: ComparisonPresentationSpec;
3821
+ /** Absence means eligible metrics inherit the Global Date comparison. */
3822
+ inheritGlobalComparison?: false;
3823
+ /** Separate two-metric KPI feature; defaults to false. */
3824
+ metricPairComparisonEnabled?: boolean;
3716
3825
  onClickFilter?: FilterOnClick[];
3717
3826
  filterOnClick?: boolean;
3718
3827
  filterOnClickField?: string;
@@ -3785,43 +3894,14 @@ export declare type TCardPreferences = {
3785
3894
  colorScale?: string;
3786
3895
  };
3787
3896
  kpiVisualOptions?: {
3788
- lowerIsBetter?: boolean;
3789
3897
  countryLogoId?: string;
3790
3898
  valueAlignment?: 'left' | 'center';
3791
3899
  formatOptions?: TFormatOptions;
3792
- metricComparison?: {
3793
- enabled?: boolean;
3794
- calculationType?: 'difference' | 'change' | 'change_difference' | 'ratio';
3795
- formatOptions?: TFormatOptions;
3796
- showArrow?: boolean;
3797
- showColor?: boolean;
3798
- conditionalLabel?: boolean;
3799
- labelName?: string;
3800
- position?: 'left' | 'right' | 'top';
3801
- conditionalLabels?: {
3802
- increase?: string;
3803
- decrease?: string;
3804
- noChange?: string;
3805
- };
3806
- colorConfig?: {
3807
- increase?: 'green' | 'red' | 'neutral' | string;
3808
- decrease?: 'green' | 'red' | 'neutral' | string;
3809
- noChange?: 'green' | 'red' | 'neutral' | string;
3810
- };
3811
- };
3812
- };
3813
- tableVisualOptions?: {
3814
- metricComparison?: {
3815
- calculatedAs?: 'difference' | 'change' | 'change_difference' | 'ratio';
3816
- indicatorStyle?: 'arrow_badge' | 'arrow' | 'badge' | 'none';
3817
- formatOptions?: TFormatOptions;
3818
- colors?: {
3819
- increase?: 'green' | 'red' | 'neutral' | string;
3820
- decrease?: 'green' | 'red' | 'neutral' | string;
3821
- neutral?: 'green' | 'red' | 'neutral' | string;
3822
- };
3823
- lowerIsBetter?: boolean;
3824
- };
3900
+ /**
3901
+ * Presentation-only polarity for a query-backed KPI's manually returned
3902
+ * current/prior value pair. Governed KPIs use per-metric polarity instead.
3903
+ */
3904
+ queryComparisonPolarity?: MetricComparisonPolarity;
3825
3905
  };
3826
3906
  pivotTableOptions?: {
3827
3907
  showRowTotals?: boolean;
@@ -4310,7 +4390,8 @@ export declare type TLens = {
4310
4390
  id: string;
4311
4391
  name: string;
4312
4392
  template?: string;
4313
- filterValues?: TFilterValue[];
4393
+ filterValues?: TFilterValue[] | null;
4394
+ inputValues?: LensInputValuesSnapshot | null;
4314
4395
  isDefault?: boolean;
4315
4396
  shared?: boolean;
4316
4397
  };
@@ -4692,6 +4773,10 @@ export declare interface UserPreference {
4692
4773
  updatedAt: string;
4693
4774
  }
4694
4775
 
4776
+ declare type ViewerPeriodComparisonSpec = Extract<MetricComparisonSpec, {
4777
+ kind: 'previous_period' | 'previous_year';
4778
+ }>;
4779
+
4695
4780
  /**
4696
4781
  * Display mode for visual components - controls which UI elements are shown
4697
4782
  */
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "support@semaphor.cloud"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "0.1.424",
8
+ "version": "0.1.426",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",
@@ -134,6 +134,7 @@
134
134
  "test:ui": "vitest --ui",
135
135
  "test:run": "vitest run",
136
136
  "test:coverage": "vitest run --coverage",
137
+ "verify:metric-comparison-artifact": "node scripts/verify-metric-comparison-artifact.mjs",
137
138
  "deploy": "./scripts/deploy.sh",
138
139
  "deploy:patch": "./scripts/deploy.sh patch",
139
140
  "deploy:minor": "./scripts/deploy.sh minor",
@@ -1 +0,0 @@
1
- "use strict";const e=require("zod"),Ne="SUM";function j(o){return o?o.kind==="semantic"?[o.kind,o.domainId,o.datasetId?`datasetId:${o.datasetId}`:`datasetName:${o.datasetName}`].join(":"):o.kind==="physical"?[o.kind,o.connectionId,o.databaseName||"",o.schemaName||"",o.tableName].join(":"):[o.kind,o.connectionId,o.dialect||"",o.label||""].join(":"):""}function G(o,i){return!o||!i?o===i:o.kind!==i.kind?!1:o.kind==="semantic"&&i.kind==="semantic"?o.domainId!==i.domainId?!1:o.datasetId&&i.datasetId?o.datasetId===i.datasetId:o.datasetName===i.datasetName:j(o)===j(i)}function U(o,i){return o.kind!=="semantic"||i.kind!=="semantic"?o:{...o,datasetName:o.datasetName||i.datasetName,datasetId:o.datasetId||i.datasetId,label:o.label||i.label,connectionId:o.connectionId||i.connectionId}}function Me(o){const i=[];for(const t of o){const s=i.findIndex(n=>G(n,t));if(s===-1){i.push(t);continue}i[s]=U(i[s],t)}return i}function Ke(o,i){return o.name===i.name&&G(o.source,i.source)}function ue(o){return[o.source?j(o.source):"unknown",H(o),o.name].filter(Boolean).join(":")}function H(o){return Te(o.aggregate||Ne)}function Te(o){return o.trim().toUpperCase()}function De(o,i){return{...o,label:o.label||i.label,role:o.role||i.role,dataType:o.dataType||i.dataType,source:o.source&&i.source?U(o.source,i.source):o.source||i.source}}const F={answerSummary:"string",responseDetail:"responseDetail",mode:"string",comparisonType:"string",executionResult:"executionResult",compiledQuery:"unknown",data:"unknown",resultSets:"record",analysisWarnings:"unknownArray",columns:"unknownArray",records:"recordArray",rowCount:"number",rowLimitExceeded:"boolean",output:"string",querySpec:"unknown",metadata:"record",validation:"validationResult",coverage:"coverage",diagnosticFeedback:"diagnosticFeedback",missingFields:"stringArray",warnings:"unknownArray",comparison:"unknown",population:"population",comparisons:"recordArray",fieldsUsed:"compactExecutionFieldArray",primary:"recordArray",contributors:"recordArray",segments:"recordArray",periodChanges:"recordArray",changes:"recordArray",largestNegativeChanges:"recordArray",largestPositiveChanges:"recordArray",drivers:"recordArray",absoluteDeltaDrivers:"recordArray",largestNegativeDrivers:"recordArray",largestPositiveDrivers:"recordArray",periodRows:"recordArray",sql:"unknown",omitted:"stringArray"},C="semaphor-data-app-codegen-summary/v1",Oe="semaphor-data-app-codegen-summary-validator/v2",Be=new Set(["metric","records","matrix","analysis","sql_fallback"]),Pe=new Set(["semaphor.metric","semaphor.records","semaphor.matrix","semaphor.analysis","semaphor.sql"]),Ve=new Set(["SUM","COUNT","AVG","MIN","MAX","MEDIAN","DISTINCT"]),Le=new Set(["absolute_delta","largest_negative","largest_positive","positive_and_negative","all"]),de=new Set(["source","id","label","measures","primaryMeasure","dateField","timeGrain","dimensions","comparison","orderBy","filters","relationshipHint","limit","derivedFields"]),Ge=new Set([...de,"analysis","timeWindow","filters","driverMode","includePopulation","calendarContext","chartTitle","chartType"]),Ue=new Set(["source","id","label","fields","dateField","timeGrain","timeWindow","filters","orderBy","relationshipHint","limit","pagination","totals","derivedFields"]),He=new Set(["source","id","label","filters","relationshipHint","rows","columns","values","totals","sort","expansion","layout","displayLimits"]),Qe=new Set(["source","id","label","sql","defaultParameters","pythonCode","fields","limit","pagination","rationale"]),Ye=new Set(["kpi","line_chart","bar_chart","stacked_bar_chart","pie_chart","donut_chart","area_chart","table","matrix","narrative","text_block","custom"]),We=new Set(["missing_measure","missing_dimension","missing_date","missing_relationship","missing_semantic_role","missing_current_app_state","raw_identifier_filter_options","unsupported_change_intent","ambiguous_field_grounding","bounded_intent_unavailable","invalid_bounded_intent_output","latest_snapshot_selector_not_modeled","unsupported_grain","requires_sql_escape_hatch","unsupported_sdk_capability"]);function Ze(o){return Q(o).ok}function Q(o){const i=[];if(!o||typeof o!="object")return{ok:!1,issues:["Summary must be an object."]};const t=o;return t.schemaVersion!==C&&i.push(`schemaVersion must be ${C}.`),(typeof t.title!="string"||!t.title.trim())&&i.push("title is required."),Array.isArray(t.sources)||i.push("sources must be an array."),Array.isArray(t.inputs)||i.push("inputs must be an array."),Array.isArray(t.views)||i.push("views must be an array."),Array.isArray(t.filterContracts)||i.push("filterContracts must be an array."),(!t.implementationChecklist||typeof t.implementationChecklist!="object")&&i.push("implementationChecklist must be an object."),t.implementationChecklist&&typeof t.implementationChecklist=="object"&&i.push(...Xe(t.implementationChecklist)),Array.isArray(t.sources)&&t.sources.forEach((s,n)=>{i.push(...w(s,`sources.${n}`))}),Array.isArray(t.inputs)&&t.inputs.forEach((s,n)=>{i.push(...et(s,`inputs.${n}`))}),Array.isArray(t.views)&&t.views.forEach((s,n)=>{i.push(...tt(s,`views.${n}`))}),Array.isArray(t.filterContracts)&&t.filterContracts.forEach((s,n)=>{i.push(...ct(s,`filterContracts.${n}`))}),t.unsupportedInsights!==void 0&&(Array.isArray(t.unsupportedInsights)?t.unsupportedInsights.forEach((s,n)=>{i.push(...Et(s,`unsupportedInsights.${n}`))}):i.push("unsupportedInsights must be an array.")),i.push(...Je(t)),{ok:i.length===0,issues:i}}function Je(o){const i=Array.isArray(o.unsupportedInsights)&&o.unsupportedInsights.some(u=>{var l;return oe.has((l=a(u))==null?void 0:l.reason)}),t=Array.isArray(o.views)&&o.views.some(u=>{var d;const l=a((d=a(u))==null?void 0:d.computation);return(l==null?void 0:l.kind)==="unsupported"&&oe.has(l.reason)});if(!i&&!t)return[];const s=[],n=a(o.validation);(n==null?void 0:n.status)!=="blocked"&&s.push("validation.status must be blocked when semantic model repair gaps are present.");const r=a(o.nextRequiredTool);return(r==null?void 0:r.name)!=="semaphor_propose_semantic_model_change"&&s.push("nextRequiredTool.name must be semaphor_propose_semantic_model_change when semantic model repair gaps are present."),s}const oe=new Set(["missing_relationship","raw_identifier_filter_options"]);function w(o,i){const t=a(o);return t?t.kind==="semantic"?typeof t.domainId=="string"&&t.domainId.trim()&&typeof t.datasetName=="string"&&t.datasetName.trim()?[]:[`${i} must include sourceKey or a supported source identity.`]:typeof t.sourceKey=="string"&&t.sourceKey.trim()?[]:t.kind==="physical"&&typeof t.tableName=="string"&&t.tableName.trim()&&typeof t.connectionId=="string"&&t.connectionId.trim()?[]:t.kind==="sql"&&typeof t.connectionId=="string"&&t.connectionId.trim()?[]:[`${i} must include sourceKey or a supported source identity.`]:[`${i} must be an object.`]}function Xe(o){const i=a(o);if(!i)return["implementationChecklist must be an object."];const t=[],s=["requiredDevtools","requiredInputOptions","filterScopeByInput","bindingsByView","validationCommands","browserSmokeChecks"];for(const r of s)r in i||t.push(`implementationChecklist.${r} is required.`);const n=a(i.requiredDevtools);return n?typeof n.mountRootDevtools!="boolean"&&t.push("implementationChecklist.requiredDevtools.mountRootDevtools must be a boolean."):t.push("implementationChecklist.requiredDevtools must be an object."),Array.isArray(i.requiredInputOptions)||t.push("implementationChecklist.requiredInputOptions must be an array."),Array.isArray(i.filterScopeByInput)||t.push("implementationChecklist.filterScopeByInput must be an array."),a(i.bindingsByView)||t.push("implementationChecklist.bindingsByView must be an object."),g(i.validationCommands)||t.push("implementationChecklist.validationCommands must be an array of strings."),g(i.browserSmokeChecks)||t.push("implementationChecklist.browserSmokeChecks must be an array of strings."),t}function et(o,i){const t=a(o);if(!t)return[`${i} must be an object.`];const s=[];return(typeof t.id!="string"||!t.id.trim())&&s.push(`${i}.id is required.`),t.fieldRef&&s.push(...c(t.fieldRef,`${i}.fieldRef`)),s.push(...pe(t.optionQuery,`${i}.optionQuery`)),g(t.appliesToViewIds)||s.push(`${i}.appliesToViewIds must be an array of strings.`),t.bindings!==void 0&&!Array.isArray(t.bindings)&&s.push(`${i}.bindings must be an array.`),Array.isArray(t.bindings)&&t.bindings.forEach((n,r)=>{const u=a(n);if(!u){s.push(`${i}.bindings.${r} must be an object.`);return}g(u.appliesToViewIds)||s.push(`${i}.bindings.${r}.appliesToViewIds must be an array of strings.`),s.push(...c(u.fieldRef,`${i}.bindings.${r}.fieldRef`))}),s}function tt(o,i){const t=a(o);if(!t)return[`${i} must be an object.`];const s=[];if((typeof t.id!="string"||!t.id.trim())&&s.push(`${i}.id is required.`),t.visualSpec!==void 0&&s.push(...kt(t.visualSpec,`${i}.visualSpec`)),t.computation!==void 0&&s.push(...Ct(t.computation,`${i}.computation`)),wt(t))return s.push(...D(t,`${i}`)),t.fields!==void 0&&(Array.isArray(t.fields)?t.fields.forEach((d,b)=>{s.push(...c(d,`${i}.fields.${b}`))}):s.push(`${i}.fields must be an array.`)),t.queryKind!==void 0&&s.push(`${i}.queryKind is not allowed for non-executable views.`),t.sdkBuilder!==void 0&&s.push(`${i}.sdkBuilder is not allowed for non-executable views.`),t.sdkSpec!==void 0&&s.push(`${i}.sdkSpec is not allowed for non-executable views.`),s;if(!Array.isArray(t.fields))return s.push(`${i}.fields must be an array.`),(t.sdkSpec!==void 0||t.sdkBuilder!==void 0)&&s.push(`${i}.fields must be an array for executable views.`),s.push(...D(t,`${i}`)),s;t.fields.forEach((d,b)=>{s.push(...c(d,`${i}.fields.${b}`))}),$(t.queryKind)||s.push(`${i}.queryKind must be a supported codegen query kind.`),t.sdkBuilder!==void 0&&!he(t.sdkBuilder)&&s.push(`${i}.sdkBuilder must be a supported SDK builder.`),t.metricBindingKeys!==void 0&&(Array.isArray(t.metricBindingKeys)?t.metricBindingKeys.some(d=>typeof d!="string"||d.trim().length===0)&&s.push(`${i}.metricBindingKeys must be an array of strings.`):s.push(`${i}.metricBindingKeys must be an array of strings.`));const n=a(t.sdkSpec),r=(n==null?void 0:n.builder)==="semaphor.metric";r&&(!Array.isArray(t.metricBindingKeys)||t.metricBindingKeys.length===0)&&s.push(`${i}.metricBindingKeys is required for metric views.`);const u=it(t);r&&Array.isArray(t.metricBindingKeys)&&u&&JSON.stringify(t.metricBindingKeys)!==JSON.stringify(u)&&s.push(`${i}.metricBindingKeys must match the generated metric field binding keys in order.`);const l=a(t.computation);return(l==null?void 0:l.kind)==="server_query"&&$(t.queryKind)&&$(l.queryKind)&&l.queryKind!==t.queryKind&&s.push(`${i}.computation.queryKind must match queryKind.`),s.push(...pt({value:t.sdkSpec,path:`${i}.sdkSpec`,queryKind:typeof t.queryKind=="string"?t.queryKind:void 0,sdkBuilder:typeof t.sdkBuilder=="string"?t.sdkBuilder:void 0}),...D(t,`${i}`)),s}function it(o){const i=a(o.sdkSpec);if((i==null?void 0:i.builder)!=="semaphor.metric")return;const t=a(i.spec);if(!t)return;const n=[t.primaryMeasure,...Array.isArray(t.measures)?t.measures:[]].map(ot).filter(r=>!!r);return Array.from(new Map(n.map(r=>[r.identity,r.bindingKey])).values())}function ot(o){const i=a(o);if(!i||typeof i.name!="string"||!i.name.trim())return;const t=st(i);return t?{identity:JSON.stringify({source:t,name:i.name,aggregate:ce(i)}),bindingKey:nt(i)}:void 0}function st(o){if(typeof o.sourceKey=="string"&&o.sourceKey.trim())return{sourceKey:o.sourceKey};const i=a(o.source);if(i)return{kind:i.kind,domainId:i.domainId,datasetId:i.datasetId,datasetName:i.datasetName,name:i.name}}function nt(o){return typeof o.sourceKey=="string"&&o.sourceKey.trim()?[o.sourceKey,ce(o),o.name].filter(Boolean).join(":"):ue(o)}function ce(o){return H(o)}function D(o,i){var b;const t=a((b=a(o.visualSpec))==null?void 0:b.tableBehavior),s=a(o.sdkSpec),n=a(s==null?void 0:s.spec),r=typeof(s==null?void 0:s.builder)=="string"?s.builder:void 0,u=r==="semaphor.records"?a(n==null?void 0:n.totals):void 0,l=[];if(!t)return u&&l.push(`${i}.sdkSpec.spec.totals is only allowed when tableBehavior.totals.mode is server.`),l;const d=a(t.totals);return d?(d.mode==="server"&&(r!=="semaphor.records"&&l.push(`${i}.visualSpec.tableBehavior.totals.mode server is only supported for semaphor.records views.`),!u||u.mode!=="server"?l.push(`${i}.sdkSpec.spec.totals.mode must be server when tableBehavior.totals.mode is server.`):l.push(...rt({left:d.measures,right:u.measures,leftPath:`${i}.visualSpec.tableBehavior.totals.measures`,rightPath:`${i}.sdkSpec.spec.totals.measures`}))),d.mode!=="server"&&u&&l.push(`${i}.sdkSpec.spec.totals is only allowed when tableBehavior.totals.mode is server.`),r==="semaphor.sql"&&d.mode!=="none"&&l.push(`${i}.visualSpec.tableBehavior.totals.mode must be none for semaphor.sql views.`),r==="semaphor.sql"&&a(n==null?void 0:n.totals)&&l.push(`${i}.sdkSpec.spec.totals is not supported for semaphor.sql.`),l):(u&&l.push(`${i}.sdkSpec.spec.totals is only allowed when tableBehavior.totals.mode is server.`),l)}function rt({left:o,right:i,leftPath:t,rightPath:s}){if(!Array.isArray(o)||!Array.isArray(i))return[`${s} must match ${t}.`];const n=[];return o.length!==i.length?(n.push(`${s} must match ${t}.`),n):(o.forEach((r,u)=>{at(a(r),a(i[u]))||n.push(`${s}.${u} must match ${t}.${u}.`)}),n)}function at(o,i){return!o||!i?!1:o.name===i.name&&(o.role||"measure")===(i.role||"measure")&&se(o)===se(i)&&lt(o,i)}function se(o){return typeof o.aggregate=="string"?o.aggregate.toUpperCase():"SUM"}function lt(o,i){const t=a(o.source),s=a(i.source);if(ut(t,s))return!1;const n=ne(o),r=ne(i);if(n.size>0||r.size>0){for(const u of n)if(r.has(u))return!0;return!1}return!t||!s||t.kind!==s.kind?!1:t.kind==="semantic"?t.domainId===s.domainId&&t.datasetName===s.datasetName&&(t.datasetId===void 0||s.datasetId===void 0||t.datasetId===s.datasetId):t.kind==="physical"?t.connectionId===s.connectionId&&t.tableName===s.tableName:t.kind==="sql"?t.connectionId===s.connectionId:!1}function ut(o,i){if(!o||!i||o.kind!=="semantic"||i.kind!=="semantic")return!1;const t=typeof o.datasetId=="string"?o.datasetId.trim():"",s=typeof i.datasetId=="string"?i.datasetId.trim():"";return!!(t&&s&&t!==s)}function ne(o){const i=typeof o.sourceKey=="string"?o.sourceKey.trim():"";return i?new Set([i]):dt(a(o.source))}function dt(o){const i=new Set;if(!o)return i;const t=typeof o.sourceKey=="string"?o.sourceKey.trim():"";if(t&&i.add(t),o.kind==="semantic"){const s=typeof o.domainId=="string"?o.domainId:"",n=typeof o.datasetName=="string"?o.datasetName:"",r=typeof o.datasetId=="string"?o.datasetId:"";s&&r&&i.add(`semantic:${s}:datasetId:${r}`),s&&n&&i.add(`semantic:${s}:datasetName:${n}`)}if(o.kind==="physical"){const s=typeof o.connectionId=="string"?o.connectionId:"",n=typeof o.tableName=="string"?o.tableName:"",r=typeof o.databaseName=="string"?o.databaseName:"",u=typeof o.schemaName=="string"?o.schemaName:"";s&&n&&(i.add(["physical",s,r,u,n].join(":")),i.add(`physical:${s}:${n}`))}if(o.kind==="sql"){const s=typeof o.connectionId=="string"?o.connectionId:"",n=typeof o.dialect=="string"?o.dialect:"",r=typeof o.label=="string"?o.label:"";s&&(i.add(["sql",s,n,r].join(":")),i.add(`sql:${s}`))}return i}function ct(o,i){const t=a(o);if(!t)return[`${i} must be an object.`];const s=[];if(t.fieldRef&&s.push(...c(t.fieldRef,`${i}.fieldRef`)),(typeof t.inputId!="string"||!t.inputId.trim())&&s.push(`${i}.inputId is required.`),s.push(...pe(t.optionQuery,`${i}.optionQuery`)),g(t.appliesToViewIds)||s.push(`${i}.appliesToViewIds must be an array of strings.`),g(t.notAppliedToViewIds)||s.push(`${i}.notAppliedToViewIds must be an array of strings.`),!Array.isArray(t.bindings))s.push(`${i}.bindings must be an array.`);else{const n=g(t.appliesToViewIds)?new Set(t.appliesToViewIds):void 0,r=g(t.notAppliedToViewIds)?new Set(t.notAppliedToViewIds):void 0;t.bindings.forEach((u,l)=>{const d=a(u);if(!d){s.push(`${i}.bindings.${l} must be an object.`);return}typeof d.viewId!="string"||!d.viewId?s.push(`${i}.bindings.${l}.viewId is required.`):(n&&!n.has(d.viewId)&&s.push(`${i}.bindings.${l}.viewId must be included in appliesToViewIds.`),r!=null&&r.has(d.viewId)&&s.push(`${i}.bindings.${l}.viewId must not be listed in notAppliedToViewIds.`)),s.push(...c(d.fieldRef,`${i}.bindings.${l}.fieldRef`))})}return s}function pe(o,i){if(o===void 0)return[];const t=a(o);if(!t)return[`${i} must be an object.`];const s=[...h(t.valueFieldRef,`${i}.valueFieldRef`),...h(t.labelFieldRef,`${i}.labelFieldRef`),...h(t.filterFieldRef,`${i}.filterFieldRef`)];return t.builder!=="semaphor.inputOptions"&&s.push(`${i}.builder must be semaphor.inputOptions.`),typeof t.sourceKey!="string"&&t.source===void 0&&s.push(`${i} must include source or sourceKey.`),t.source!==void 0&&s.push(...w(t.source,`${i}.source`)),a(t.valueFieldRef)||s.push(`${i}.valueFieldRef is required.`),a(t.labelFieldRef)||s.push(`${i}.labelFieldRef is required.`),t.limit!==void 0&&(typeof t.limit!="number"||!Number.isInteger(t.limit)||t.limit<=0)&&s.push(`${i}.limit must be a positive integer.`),s}function pt(o){var n;const i=a(o.value);if(!i)return[`${o.path} is required for executable views.`];const t=[];if(!he(i.builder))return t.push(`${o.path}.builder must be a supported SDK builder.`),t;o.sdkBuilder&&i.builder!==o.sdkBuilder&&t.push(`${o.path}.builder must match sdkBuilder.`),o.queryKind&&$(o.queryKind)&&i.builder!==$t(o.queryKind)&&t.push(`${o.path}.builder must match queryKind.`);const s=a(i.spec);if(!s)return t.push(`${o.path}.spec must be an object.`),t;switch(i.builder){case"semaphor.metric":t.push(...v(s,de,`${o.path}.spec`),...A(s,o.path),...O(s.measures,`${o.path}.spec.measures`),...h(s.primaryMeasure,`${o.path}.spec.primaryMeasure`),...h(s.dateField,`${o.path}.spec.dateField`),...B(s.dimensions,`${o.path}.spec.dimensions`),...P(s.orderBy,`${o.path}.spec.orderBy`),..._(s.filters,`${o.path}.spec.filters`));break;case"semaphor.analysis":t.push(...v(s,Ge,`${o.path}.spec`),...A(s,o.path),...O(s.measures,`${o.path}.spec.measures`),...h(s.primaryMeasure,`${o.path}.spec.primaryMeasure`),...h(s.dateField,`${o.path}.spec.dateField`),...B(s.dimensions,`${o.path}.spec.dimensions`),...P(s.orderBy,`${o.path}.spec.orderBy`),..._(s.filters,`${o.path}.spec.filters`),...gt(s,`${o.path}.spec`));break;case"semaphor.records":t.push(...v(s,Ue,`${o.path}.spec`),...A(s,o.path),...O(s.fields,`${o.path}.spec.fields`),...h(s.dateField,`${o.path}.spec.dateField`),...P(s.orderBy,`${o.path}.spec.orderBy`),..._(s.filters,`${o.path}.spec.filters`),...ht(s.totals,`${o.path}.spec.totals`));break;case"semaphor.matrix":t.push(...v(s,He,`${o.path}.spec`),...ft(s,o.path),...yt(s.rows,`${o.path}.spec.rows`),...bt(s.columns,`${o.path}.spec.columns`),...zt(s.values,`${o.path}.spec.values`),...St(s.sort,`${o.path}.spec.sort`),..._(s.filters,`${o.path}.spec.filters`),...mt(s.displayLimits,`${o.path}.spec.displayLimits`));break;case"semaphor.sql":t.push(...v(s,Qe,`${o.path}.spec`),...A(s,o.path)),((n=a(s.source))==null?void 0:n.kind)!=="sql"&&t.push(`${o.path}.spec.source.kind must be sql.`),(typeof s.sql!="string"||!s.sql.trim())&&t.push(`${o.path}.spec.sql is required.`),t.push(...B(s.fields,`${o.path}.spec.fields`));break}return t}function mt(o,i){if(o===void 0)return[];const t=a(o);if(!t)return[`${i} must be an object.`];const s=[];s.push(...re(t.rows,`${i}.rows`),...re(t.columns,`${i}.columns`));for(const n of Object.keys(t))n==="rows"||n==="columns"||s.push(`${i}.${n} is not supported.`);return s}function re(o,i){if(o===void 0)return[];const t=a(o);if(!t)return[`${i} must be an object.`];const s=[];(typeof t.limit!="number"||!Number.isInteger(t.limit)||t.limit<1)&&s.push(`${i}.limit must be a positive integer.`);for(const n of Object.keys(t))n!=="limit"&&s.push(`${i}.${n} is not supported; matrix display limits are count-only in v1.`);return s}function gt(o,i){const t=[];if(o.driverMode!==void 0&&!Le.has(o.driverMode)&&t.push(`${i}.driverMode must be a supported analysis driver mode.`),o.includePopulation!==void 0&&typeof o.includePopulation!="boolean"&&t.push(`${i}.includePopulation must be a boolean.`),o.calendarContext!==void 0){const s=a(o.calendarContext);if(!s)t.push(`${i}.calendarContext must be an object.`);else{s.tz!==void 0&&typeof s.tz!="string"&&t.push(`${i}.calendarContext.tz must be a string.`),s.weekStart!==void 0&&(typeof s.weekStart!="number"||!Number.isInteger(s.weekStart)||s.weekStart<0||s.weekStart>6)&&t.push(`${i}.calendarContext.weekStart must be an integer between 0 and 6.`);const n=s.anchor;if(n!==void 0&&n!=="now"){const r=a(n);(!r||typeof r.iso!="string"||!r.iso.trim())&&t.push(`${i}.calendarContext.anchor must be now or { iso }.`)}}}return t}function ht(o,i){if(o===void 0)return[];const t=a(o);if(!t)return[`${i} must be an object.`];const s=[];return t.mode!=="server"&&s.push(`${i}.mode must be server.`),!Array.isArray(t.measures)||t.measures.length===0?s.push(`${i}.measures must include at least one measure.`):t.measures.forEach((n,r)=>{var u;s.push(...fe(n,`${i}.measures.${r}`)),((u=a(n))==null?void 0:u.role)!=="measure"&&s.push(`${i}.measures.${r}.role must be measure.`)}),s}function v(o,i,t){const s=[];return Object.keys(o).forEach(n=>{i.has(n)||s.push(`${t}.${n} is not supported for this SDK builder.`)}),s}function A(o,i){return a(o.source)?w(o.source,`${i}.spec.source`):[`${i}.spec.source must be an object.`]}function ft(o,i){const t=a(o.source);if(!t)return[`${i}.spec.source must be an object.`];const s=w(o.source,`${i}.spec.source`);return t.kind!=="semantic"&&t.kind!=="physical"&&s.push(`${i}.spec.source.kind must be semantic or physical.`),s}function O(o,i){const t=Y(o,i);return Array.isArray(o)&&o.forEach((s,n)=>{t.push(...c(s,`${i}.${n}`))}),t}function B(o,i){if(o===void 0)return[];if(!Array.isArray(o))return[`${i} must be an array.`];const t=[];return o.forEach((s,n)=>{t.push(...c(s,`${i}.${n}`))}),t}function P(o,i){if(o===void 0)return[];const t=a(o);return t?[...c(t.field,`${i}.field`),...me(t.direction,`${i}.direction`)]:[`${i} must be an object.`]}function yt(o,i){const t=Y(o,i);return Array.isArray(o)&&o.forEach((s,n)=>{const r=a(s);if(!r){t.push(`${i}.${n} must be an object.`);return}t.push(...c(r.field,`${i}.${n}.field`))}),t}function bt(o,i){if(o===void 0)return[];const t=[];return Array.isArray(o)?(o.forEach((s,n)=>{const r=a(s);if(!r){t.push(`${i}.${n} must be an object.`);return}t.push(...c(r.field,`${i}.${n}.field`))}),t):[`${i} must be an array.`]}function zt(o,i){const t=Y(o,i);return Array.isArray(o)&&o.forEach((s,n)=>{const r=a(s);if(!r){t.push(`${i}.${n} must be an object.`);return}t.push(...c(r.field,`${i}.${n}.field`))}),t}function St(o,i){if(o===void 0)return[];if(!Array.isArray(o))return[`${i} must be an array.`];const t=[];return o.forEach((s,n)=>{const r=a(s);if(!r){t.push(`${i}.${n} must be an object.`);return}r.axis!=="row"&&r.axis!=="column"&&t.push(`${i}.${n}.axis must be row or column.`),t.push(...me(r.direction,`${i}.${n}.direction`),...vt(r.by,`${i}.${n}.by`))}),t}function vt(o,i){const t=a(o);if(!t)return[`${i} must be an object.`];switch(t.kind){case"label":return[];case"field":return c(t.field,`${i}.field`);case"value":return typeof t.valueId!="string"||!t.valueId.trim()?[`${i}.valueId is required.`]:[];default:return[`${i}.kind must be label, field, or value.`]}}function me(o,i){return o==="asc"||o==="desc"?[]:[`${i} must be asc or desc.`]}function _(o,i){if(o===void 0)return[];if(!Array.isArray(o))return[`${i} must be an array.`];const t=[];return o.forEach((s,n)=>{const r=a(s);if(!r){t.push(`${i}.${n} must be an object.`);return}t.push(...c(r.field,`${i}.${n}.field`))}),t}function Y(o,i){return!Array.isArray(o)||o.length===0?[`${i} must be a non-empty array.`]:[]}function $t(o){switch(o){case"metric":return"semaphor.metric";case"records":return"semaphor.records";case"matrix":return"semaphor.matrix";case"analysis":return"semaphor.analysis";case"sql_fallback":return"semaphor.sql"}}function wt(o){const i=a(o.computation),t=a(o.visualSpec);return(i==null?void 0:i.kind)==="presentation_only"||(i==null?void 0:i.kind)==="derived"||(i==null?void 0:i.kind)==="unsupported"||o.visual==="text_block"||(t==null?void 0:t.visualType)==="text_block"}function kt(o,i){const t=a(o);if(!t)return[`${i} must be an object.`];const s=[];return Ye.has(t.visualType)||s.push(`${i}.visualType must be a supported visual type.`),t.limit!==void 0&&(typeof t.limit!="number"||!Number.isInteger(t.limit)||t.limit<=0)&&s.push(`${i}.limit must be a positive integer.`),t.tableBehavior!==void 0&&s.push(...It(t.tableBehavior,`${i}.tableBehavior`)),s}function It(o,i){const t=a(o);if(!t)return[`${i} must be an object.`];const s=[];return t.tableMode!=="bounded"&&t.tableMode!=="server_paginated"&&t.tableMode!=="server_windowed"&&s.push(`${i}.tableMode must be a supported table mode.`),s.push(...At(t.height,`${i}.height`),..._t(t.pagination,`${i}.pagination`),...Rt(t.sorting,`${i}.sorting`),...jt(t.totals,`${i}.totals`)),typeof t.serverSideRequired!="boolean"&&s.push(`${i}.serverSideRequired must be a boolean.`),s}function At(o,i){const t=a(o);if(!t)return[`${i} must be an object.`];const s=[];return(typeof t.maxPx!="number"||!Number.isInteger(t.maxPx)||t.maxPx<=0)&&s.push(`${i}.maxPx must be a positive integer.`),t.scroll!=="vertical"&&t.scroll!=="both"&&s.push(`${i}.scroll must be vertical or both.`),typeof t.stickyHeader!="boolean"&&s.push(`${i}.stickyHeader must be a boolean.`),s}function _t(o,i){const t=a(o);if(!t)return[`${i} must be an object.`];const s=[];return t.mode!=="none"&&t.mode!=="server"&&t.mode!=="client_for_bounded_rows"&&s.push(`${i}.mode must be a supported pagination mode.`),t.pageSize!==void 0&&(typeof t.pageSize!="number"||!Number.isInteger(t.pageSize)||t.pageSize<=0)&&s.push(`${i}.pageSize must be a positive integer.`),t.readsFrom!==void 0&&t.readsFrom!=="result.pagination"&&s.push(`${i}.readsFrom must be result.pagination.`),s}function Rt(o,i){const t=a(o);if(!t)return[`${i} must be an object.`];const s=[];return t.mode!=="server"&&t.mode!=="client_for_bounded_rows"&&s.push(`${i}.mode must be a supported sorting mode.`),t.defaultField!==void 0&&(typeof t.defaultField!="string"||!t.defaultField.trim())&&s.push(`${i}.defaultField must be a non-empty string.`),t.defaultDirection!==void 0&&t.defaultDirection!=="asc"&&t.defaultDirection!=="desc"&&s.push(`${i}.defaultDirection must be asc or desc.`),t.resetPageOnChange!==void 0&&typeof t.resetPageOnChange!="boolean"&&s.push(`${i}.resetPageOnChange must be a boolean.`),s}function jt(o,i){const t=a(o);if(!t)return[`${i} must be an object.`];const s=[];return t.mode!=="none"&&t.mode!=="server"&&t.mode!=="local"?(s.push(`${i}.mode must be none, server, or local.`),s):t.mode==="none"?(t.measures!==void 0&&s.push(`${i}.measures is not allowed when mode is none.`),t.label!==void 0&&s.push(`${i}.label is not allowed when mode is none.`),s):t.mode==="server"?(!Array.isArray(t.measures)||t.measures.length===0?s.push(`${i}.measures must include at least one measure when mode is server.`):t.measures.forEach((n,r)=>{var u;s.push(...fe(n,`${i}.measures.${r}`)),((u=a(n))==null?void 0:u.role)!=="measure"&&s.push(`${i}.measures.${r}.role must be measure.`)}),t.label!==void 0&&s.push(`${i}.label is not allowed when mode is server.`),s):(t.mode==="local"&&(t.label!=="Displayed rows"&&t.label!=="Current page"&&s.push(`${i}.label must be Displayed rows or Current page when mode is local.`),t.measures!==void 0&&s.push(`${i}.measures is not allowed when mode is local.`)),s)}function Ct(o,i){const t=a(o);if(!t)return[`${i} must be an object.`];const s=[];switch(t.kind){case"server_query":$(t.queryKind)||s.push(`${i}.queryKind must be a supported codegen query kind.`),t.queryOwnership!==void 0&&t.queryOwnership!=="view_owned"&&t.queryOwnership!=="shared_query"&&s.push(`${i}.queryOwnership must be view_owned or shared_query.`),t.sourceKeys!==void 0&&!g(t.sourceKeys)&&s.push(`${i}.sourceKeys must be an array of strings.`),t.fieldNames!==void 0&&!g(t.fieldNames)&&s.push(`${i}.fieldNames must be an array of strings.`);break;case"derived":(typeof t.upstreamViewId!="string"||!t.upstreamViewId.trim())&&s.push(`${i}.upstreamViewId is required.`),(typeof t.derivation!="string"||!t.derivation.trim())&&s.push(`${i}.derivation is required.`);break;case"presentation_only":break;case"unsupported":(typeof t.reason!="string"||!t.reason.trim())&&s.push(`${i}.reason is required.`),(typeof t.suggestedModelingFix!="string"||!t.suggestedModelingFix.trim())&&s.push(`${i}.suggestedModelingFix is required.`);break;default:s.push(`${i}.kind must be a supported computation kind.`)}return s}function Et(o,i){const t=a(o);if(!t)return[`${i} must be an object.`];const s=[];for(const r of["title","requestedQuestion","suggestedModelingFix"])(typeof t[r]!="string"||!t[r].trim())&&s.push(`${i}.${r} is required.`);return We.has(t.reason)||s.push(`${i}.reason must be a supported unsupported insight reason.`),(t.relationshipCandidate!==void 0||t.nextRepairAction!==void 0)&&t.reason!=="missing_relationship"&&s.push(`${i} relationship repair metadata is only valid for missing_relationship unsupported insights.`),t.diagnostic!==void 0&&s.push(...qt(t.diagnostic,`${i}.diagnostic`,t.reason)),t.relationshipCandidate!==void 0&&s.push(...xt(t.relationshipCandidate,`${i}.relationshipCandidate`)),t.nextRepairAction!==void 0&&s.push(...Ft(t.nextRepairAction,`${i}.nextRepairAction`)),s}function qt(o,i,t){const s=a(o);if(!s)return[`${i} must be an object.`];const n=[],r=new Set(["kind","inputId","inputLabel","optionSource","optionField","missingEvidence"]);Object.keys(s).forEach(l=>{r.has(l)||n.push(`${i}.${l} is not supported; raw identifier diagnostics support only kind, inputId, inputLabel, optionSource, optionField, and missingEvidence.`)}),t!=="raw_identifier_filter_options"&&n.push(`${i} is only valid for raw_identifier_filter_options unsupported insights.`),s.kind!=="raw_identifier_filter_options"&&n.push(`${i}.kind must be raw_identifier_filter_options.`);for(const l of["inputId","inputLabel"])(typeof s[l]!="string"||!s[l].trim())&&n.push(`${i}.${l} must be a non-empty string.`);n.push(...L(s.optionSource,`${i}.optionSource`)),n.push(...ge(s.optionField,`${i}.optionField`));const u=new Set(["display_field","relationship_display_path"]);return!Array.isArray(s.missingEvidence)||s.missingEvidence.length===0?n.push(`${i}.missingEvidence must be a non-empty evidence array.`):s.missingEvidence.forEach((l,d)=>{u.has(l)||n.push(`${i}.missingEvidence.${d} must be display_field or relationship_display_path.`)}),n}function Ft(o,i){const t=a(o);if(!t)return[`${i} must be an object.`];const s=[],n=new Set(["tool","reason"]);return Object.keys(t).forEach(r=>{n.has(r)||s.push(`${i}.${r} is not supported; repair actions support only tool and reason.`)}),t.tool!=="semaphor_propose_semantic_model_change"&&s.push(`${i}.tool must be semaphor_propose_semantic_model_change.`),t.reason!=="missing_relationship"&&s.push(`${i}.reason must be missing_relationship.`),s}function xt(o,i){const t=a(o);if(!t)return[`${i} must be an object.`];const s=[],n=new Set(["source","sourceFields","target","targetFields"]);Object.keys(t).forEach(r=>{n.has(r)||s.push(`${i}.${r} is not supported; relationship candidates support only source, sourceFields, target, and targetFields.`)}),s.push(...L(t.source,`${i}.source`)),s.push(...L(t.target,`${i}.target`));for(const r of["sourceFields","targetFields"]){const u=t[r];if(!Array.isArray(u)||u.length===0){s.push(`${i}.${r} must be a non-empty endpoint field array.`);continue}u.forEach((l,d)=>{s.push(...ge(l,`${i}.${r}.${d}`))})}return s}function ge(o,i){const t=a(o);if(!t)return[`${i} must be an object.`];const s=[],n=new Set(["name","label","role","dataType"]);return Object.keys(t).forEach(r=>{n.has(r)||s.push(`${i}.${r} is not supported; relationship candidate fields are scoped by their endpoint and support only name, label, role, and dataType.`)}),(typeof t.name!="string"||!t.name.trim())&&s.push(`${i}.name must be a non-empty string.`),t.role!==void 0&&(typeof t.role!="string"||!["dimension","measure","date","id","unknown"].includes(t.role))&&s.push(`${i}.role must be dimension, measure, date, id, or unknown.`),t.dataType!==void 0&&(typeof t.dataType!="string"||!["string","number","boolean","date","datetime","unknown"].includes(t.dataType))&&s.push(`${i}.dataType must be string, number, boolean, date, datetime, or unknown.`),s}function L(o,i){const t=a(o);if(!t)return[`${i} must be an object.`];const s=[],n=new Set(["kind","domainId","datasetName","datasetId","label","sourceKey"]);return Object.keys(t).forEach(r=>{n.has(r)||s.push(`${i}.${r} is not supported; relationship candidate sources support only semantic identity fields.`)}),t.kind!=="semantic"&&s.push(`${i} must use semantic source identity.`),(typeof t.domainId!="string"||!t.domainId.trim()||typeof t.datasetName!="string"||!t.datasetName.trim())&&s.push(`${i} must include semantic domainId and datasetName.`),s}function $(o){return Be.has(o)}function he(o){return Pe.has(o)}function h(o,i){return o===void 0?[]:c(o,i)}function c(o,i){const t=a(o);if(!t)return[`${i} must be an object.`];const s=[];return(typeof t.name!="string"||!t.name.trim())&&s.push(`${i}.name is required.`),!t.source&&typeof t.sourceKey!="string"&&s.push(`${i} must include source or sourceKey.`),t.aggregate!==void 0&&!Ve.has(t.aggregate)&&s.push(`${i}.aggregate must be a supported aggregate function.`),s}function fe(o,i){const t=a(o),s=c(o,i);if(!t||typeof t.sourceKey=="string"&&t.sourceKey.trim())return s;if(t.source!==void 0){const r=w(t.source,`${i}.source`);return r.length===0||s.push(...r),s}return s.includes(`${i} must include source or sourceKey.`)||s.push(`${i} must include source or sourceKey.`),s}function a(o){return o&&typeof o=="object"&&!Array.isArray(o)?o:void 0}function g(o){return Array.isArray(o)&&o.every(i=>typeof i=="string")}const p=e.z.record(e.z.string(),e.z.unknown()),x=e.z.array(p),m=e.z.enum(["SUM","COUNT","AVG","MIN","MAX","MEDIAN","DISTINCT"]),N=e.z.enum(["postgres","mysql","mssql","snowflake","clickhouse","bigquery","redshift","duckdb","sqlite","unknown"]),ye=e.z.enum(["hour","day","week","month","quarter","year"]),M=e.z.enum(["dimension","measure","date","id","unknown"]),K=e.z.enum(["string","number","boolean","date","datetime","unknown"]),R=e.z.union([e.z.number(),e.z.string(),e.z.null()]),V=e.z.enum(["millisecond","second","minute","hour","day"]),be=e.z.union([e.z.object({type:e.z.enum(["number","currency","percent","percentage","scientific"]),locale:e.z.string().optional(),minimumFractionDigits:e.z.number().optional(),maximumFractionDigits:e.z.number().optional(),useGrouping:e.z.boolean().optional(),prefix:e.z.string().optional(),suffix:e.z.string().optional(),negativeStyle:e.z.enum(["minus","parentheses"]).optional(),compact:e.z.boolean().optional(),scale:e.z.number().optional(),currency:e.z.string().optional(),percentValueMode:e.z.enum(["fraction","whole"]).optional()}).passthrough(),e.z.object({type:e.z.enum(["date","datetime"]),locale:e.z.string().optional(),pattern:e.z.string().optional(),relative:e.z.boolean().optional(),timezone:e.z.string().optional(),sourceTimezone:e.z.string().optional(),prefix:e.z.string().optional(),suffix:e.z.string().optional()}).passthrough(),e.z.object({type:e.z.literal("duration"),inputUnit:V.optional(),outputStyle:e.z.enum(["compact","digital","long"]).optional(),largestUnit:V.optional(),smallestUnit:V.optional(),maxUnits:e.z.number().optional(),prefix:e.z.string().optional(),suffix:e.z.string().optional(),negativeStyle:e.z.enum(["minus","parentheses"]).optional()}).passthrough(),e.z.object({type:e.z.literal("string"),prefix:e.z.string().optional(),suffix:e.z.string().optional()}).passthrough()]),Nt=e.z.union([e.z.object({kind:e.z.literal("defaultAggregate")}).passthrough(),e.z.object({kind:e.z.literal("blank")}).passthrough(),e.z.object({kind:e.z.literal("labelOnly"),label:e.z.string().optional()}).passthrough(),e.z.object({kind:e.z.literal("customAggregate"),aggregate:m}).passthrough(),e.z.object({kind:e.z.literal("percentOfParent")}).passthrough(),e.z.object({kind:e.z.literal("percentOfGrandTotal")}).passthrough(),e.z.object({kind:e.z.literal("customExpression"),expressionId:e.z.string()}).passthrough()]);function k(o,i){return e.z.object(o).passthrough().superRefine((t,s)=>{for(const n of i)Object.prototype.hasOwnProperty.call(t,n)||s.addIssue({code:"custom",path:[n],message:`Required field "${n}" is missing.`})})}const W=e.z.object({kind:e.z.literal("semantic"),domainId:e.z.string(),datasetName:e.z.string(),datasetId:e.z.string().optional(),label:e.z.string().optional(),connectionId:e.z.string().optional()}).passthrough(),ze=e.z.object({kind:e.z.literal("physical"),connectionId:e.z.string(),connectionType:e.z.string().optional(),tableName:e.z.string(),databaseName:e.z.string().optional(),schemaName:e.z.string().optional(),label:e.z.string().optional(),dialect:N.optional()}).passthrough(),Se=e.z.object({kind:e.z.literal("sql"),connectionId:e.z.string(),dialect:N.optional(),label:e.z.string().optional()}).passthrough(),z=e.z.union([W,ze,Se]),y=e.z.object({name:e.z.string(),label:e.z.string().optional(),role:M.optional(),dataType:K.optional(),source:z.optional(),aggregate:m.optional()}).passthrough(),Mt=e.z.object({kind:e.z.literal("field"),field:y,aggregate:m.optional()}).passthrough(),Z=e.z.object({kind:e.z.literal("derived_field"),name:e.z.string(),label:e.z.string(),description:e.z.string().optional(),resultRole:M,dataType:K,computeStage:e.z.enum(["row","aggregate"]),expression:e.z.string(),expressionLanguage:e.z.literal("semaphor_sql_template").optional(),inputs:e.z.record(Mt),defaultAggregate:m.optional(),aggregationBehavior:e.z.enum(["additive","non_additive","ratio_of_sums","weighted","pre_aggregated","snapshot"]).optional(),aggregationStrategy:e.z.enum(["default","symmetric_aggregate","aggregate_then_join","weighted"]).optional(),format:be.optional(),tags:e.z.array(e.z.string()).optional()}).passthrough(),T=y.and(e.z.object({derivedField:Z.optional()}).passthrough()),Kt=W,Tt=e.z.object({kind:e.z.literal("physical"),connectionId:e.z.string().optional(),connectionType:e.z.string().optional(),tableName:e.z.string(),databaseName:e.z.string().optional(),schemaName:e.z.string().optional(),label:e.z.string().optional(),dialect:N.optional()}).passthrough(),Dt=e.z.object({kind:e.z.literal("sql"),connectionId:e.z.string().optional(),dialect:N.optional(),label:e.z.string().optional()}).passthrough(),Ot=e.z.union([Kt,Tt,Dt]),Bt=e.z.object({key:e.z.string().optional(),name:e.z.string(),label:e.z.string().optional(),role:M.optional(),dataType:K.optional(),source:Ot.optional(),aggregate:m.optional(),derivedField:e.z.never().optional()}).passthrough(),E=e.z.object({key:e.z.string(),name:e.z.string(),label:e.z.string(),role:M.optional(),dataType:K.optional(),aggregate:m.optional(),source:z.optional(),derivedField:Z.optional()}).passthrough(),ve=e.z.object({code:e.z.string(),message:e.z.string().optional(),invalidField:e.z.string().optional(),fieldRole:e.z.enum(["measure","date","dimension","input","source","sql"]).optional(),validMeasureCandidates:e.z.array(e.z.string()).optional(),validDateCandidates:e.z.array(e.z.string()).optional(),validDimensionCandidates:e.z.array(e.z.string()).optional(),recommendedNextStep:e.z.string()}).passthrough(),q=e.z.object({code:e.z.string(),message:e.z.string(),path:e.z.string().optional(),fieldRole:e.z.enum(["measure","date","dimension","input","source","sql"]).optional(),repairHint:ve.optional()}).passthrough(),J=e.z.object({ok:e.z.boolean(),errors:e.z.array(q),warnings:e.z.array(q),repairHints:e.z.array(ve)}).passthrough(),Pt=e.z.object({page:e.z.number(),pageSize:e.z.number(),pageCount:e.z.number(),totalCount:e.z.number(),hasNextPage:e.z.boolean(),hasPrevPage:e.z.boolean()}).passthrough(),I={intentId:e.z.string().optional(),queryPath:e.z.enum(["query_spec","sql","sql_python"]),warnings:e.z.array(e.z.string()).optional(),rowCount:e.z.number().optional(),rowLimitExceeded:e.z.boolean().optional(),limit:e.z.number().optional(),pagination:Pt.optional()},$e=e.z.object({...I,kind:e.z.literal("metric"),primaryValue:R,measures:e.z.record(R).optional(),missingMeasures:e.z.array(e.z.string()).optional(),comparison:e.z.object({kind:e.z.enum(["previous_period","previous_year","target"]),value:R.optional(),delta:e.z.union([e.z.number(),e.z.null()]).optional(),deltaPercent:e.z.union([e.z.number(),e.z.null()]).optional()}).passthrough().optional(),records:x.optional()}).passthrough(),we=e.z.object({...I,kind:e.z.literal("records"),columns:e.z.array(E),records:x,totals:e.z.object({mode:e.z.literal("server"),scope:e.z.literal("filtered_result"),row:e.z.record(e.z.string(),e.z.unknown()),columns:e.z.array(E).optional()}).passthrough().optional()}).passthrough(),ke=e.z.object({...I,kind:e.z.literal("inputOptions"),options:e.z.array(k({label:e.z.string(),value:e.z.unknown(),count:e.z.number().optional(),disambiguation:e.z.array(e.z.string()).optional()},["value"]))}).passthrough(),Ie=e.z.object({...I,kind:e.z.literal("sql"),columns:e.z.array(E),records:x,sqlShape:e.z.object({statementType:e.z.string().optional(),explicitLimit:e.z.number().optional(),hasPythonCode:e.z.boolean().optional()}).passthrough().optional()}).passthrough(),Vt=e.z.object({enabled:e.z.boolean().optional(),position:e.z.enum(["before","after"]).optional(),label:e.z.string().optional()}).passthrough(),ae=e.z.object({id:e.z.enum(["rows","columns"]),levels:e.z.array(e.z.object({instanceId:e.z.string(),fieldKey:e.z.string(),label:e.z.string(),field:y,grain:ye.optional(),subtotal:Vt.optional()}).passthrough()),nodeIds:e.z.array(e.z.string())}).passthrough(),S=k({instanceId:e.z.string(),fieldKey:e.z.string(),value:e.z.unknown(),label:e.z.string()},["value"]),Lt=e.z.union([e.z.object({kind:e.z.literal("label")}).passthrough(),e.z.object({kind:e.z.literal("field"),field:y,aggregate:m.optional()}).passthrough(),e.z.object({kind:e.z.literal("value"),valueId:e.z.string(),rowPath:e.z.array(S).optional(),columnPath:e.z.array(S).optional()}).passthrough()]),Gt=e.z.enum(["present","presentNull","missing","densified"]),Ut=e.z.enum(["value","rowSubtotal","columnSubtotal","subtotalIntersection","rowGrandTotal","columnGrandTotal","matrixGrandTotal"]),Ht=e.z.object({instanceId:e.z.string(),fieldKey:e.z.string(),field:y,role:e.z.enum(["row","column","measure","sort","filter"]),label:e.z.string().optional()}).passthrough(),Qt=e.z.union([e.z.object({kind:e.z.literal("additive"),aggregate:m.optional()}).passthrough(),e.z.object({kind:e.z.literal("semiAdditive"),aggregate:m.optional(),grain:ye.optional()}).passthrough(),e.z.object({kind:e.z.literal("nonAdditive"),aggregate:m.optional()}).passthrough(),e.z.object({kind:e.z.literal("ratio"),numeratorMeasureInstanceId:e.z.string().optional(),denominatorMeasureInstanceId:e.z.string().optional()}).passthrough(),e.z.object({kind:e.z.literal("custom"),expressionId:e.z.string().optional()}).passthrough()]),Yt=e.z.object({instanceId:e.z.string(),fieldKey:e.z.string(),label:e.z.string(),field:y,aggregate:m.optional(),format:be.optional(),totalBehavior:Nt.optional(),semantics:Qt}).passthrough(),Wt=e.z.object({id:e.z.string(),measureId:e.z.string(),aggregate:m.optional(),label:e.z.string().optional(),source:e.z.enum(["measureDefault","rowSubtotal","columnSubtotal","subtotalIntersection","rowGrandTotal","columnGrandTotal","matrixGrandTotal","custom"]),scope:e.z.object({rowLevelId:e.z.string().optional(),columnLevelId:e.z.string().optional(),rowNodeId:e.z.string().optional(),columnNodeId:e.z.string().optional()}).passthrough().optional()}).passthrough(),Zt=e.z.object({kind:e.z.string(),label:e.z.string().optional(),payload:e.z.record(e.z.string(),e.z.unknown()).optional()}).passthrough(),Jt=k({id:e.z.string(),axis:e.z.enum(["row","column"]),path:e.z.array(S),level:e.z.number(),label:e.z.string(),value:e.z.unknown(),parentId:e.z.string().optional(),hasChildren:e.z.boolean(),isExpanded:e.z.boolean().optional(),isSubtotal:e.z.boolean().optional(),isGrandTotal:e.z.boolean().optional(),subtotalFunction:m.optional(),childCount:e.z.number().optional(),actions:e.z.array(Zt).optional()},["value"]),Xt=e.z.object({rowHeaderLevels:e.z.array(e.z.object({id:e.z.string(),label:e.z.string(),fieldInstanceId:e.z.string()}).passthrough()),columnHeaderRows:e.z.array(e.z.object({id:e.z.string(),cells:e.z.array(e.z.object({id:e.z.string(),label:e.z.string(),role:e.z.enum(["rowHeader","columnHeader","measureHeader","subtotal","grandTotal"]),colSpan:e.z.number(),rowSpan:e.z.number(),columnPath:e.z.array(S),measureInstanceId:e.z.string().optional()}).passthrough())}).passthrough()),columns:e.z.array(e.z.object({id:e.z.string(),label:e.z.string(),columnNodeId:e.z.string().optional(),columnPath:e.z.array(S),measureInstanceId:e.z.string(),role:e.z.enum(["value","columnSubtotal","columnGrandTotal"])}).passthrough())}).passthrough(),ei=k({rowId:e.z.string(),columnId:e.z.string().optional(),measureId:e.z.string(),value:e.z.unknown(),formattedValue:e.z.string().optional(),presence:Gt,role:Ut,calculationId:e.z.string().optional()},["value"]),ti=e.z.object({rows:e.z.boolean().optional(),columns:e.z.boolean().optional(),grandTotal:e.z.union([e.z.boolean(),e.z.object({rows:e.z.boolean().optional(),columns:e.z.boolean().optional()}).passthrough()]).optional()}).passthrough(),ii=k({id:e.z.string(),axis:e.z.enum(["row","column"]),targetInstanceId:e.z.string().optional(),direction:e.z.enum(["asc","desc"]),nulls:e.z.enum(["warehouseDefault","first","last"]).optional(),scope:e.z.enum(["global","withinParent"]).optional(),by:Lt},["by"]),oi=e.z.object({rowOffset:e.z.number().optional(),rowLimit:e.z.number().optional(),columnOffset:e.z.number().optional(),columnLimit:e.z.number().optional(),hasMoreRows:e.z.boolean().optional(),hasMoreColumns:e.z.boolean().optional()}).passthrough(),si=e.z.object({axis:e.z.enum(["row","column"]),path:e.z.array(S),depth:e.z.number().optional()}).passthrough(),ni=e.z.object({rowLazyLoading:e.z.boolean().optional(),columnLazyLoading:e.z.boolean().optional(),expandableRowNodeIds:e.z.array(e.z.string()).optional(),expandableColumnNodeIds:e.z.array(e.z.string()).optional(),nextRequests:e.z.array(si).optional()}).passthrough(),ri=e.z.object({domains:e.z.record(e.z.object({min:e.z.number().optional(),max:e.z.number().optional()}).passthrough()).optional(),rules:e.z.array(e.z.record(e.z.string(),e.z.unknown())).optional()}).passthrough(),Ae=e.z.object({...I,kind:e.z.literal("matrix"),schemaVersion:e.z.literal(1),shape:e.z.enum(["hierarchical","pivot"]),capabilities:e.z.array(e.z.string()),executionMetadata:e.z.record(e.z.string(),e.z.unknown()),fieldsById:e.z.record(e.z.string(),Ht),measuresById:e.z.record(e.z.string(),Yt),calculationsById:e.z.record(e.z.string(),Wt).optional(),axes:e.z.object({rows:ae,columns:ae}).passthrough(),nodesById:e.z.record(e.z.string(),Jt),layout:Xt,cells:e.z.array(ei),totals:ti,sort:e.z.array(ii),formattingContext:ri,pageInfo:oi.optional(),expansion:ni.optional()}).passthrough(),_e=e.z.union([$e,we,ke,Ie,Ae]),Re=e.z.object({status:e.z.enum(["not_required","resolved","missing","ambiguous","fanout_risk","unknown"]),requiredSources:e.z.array(z).optional(),relationshipsUsed:e.z.array(e.z.string()).optional(),missingSources:e.z.array(e.z.string()).optional(),warnings:e.z.array(e.z.string()).optional(),message:e.z.string().optional(),recommendedNextStep:e.z.string().optional(),joinPlanSummary:e.z.object({baseSource:z.optional(),joinedSources:e.z.array(z).optional(),joinCount:e.z.number().optional()}).passthrough().optional(),fanoutRisk:e.z.object({status:e.z.enum(["none","warning","error","unknown"]),message:e.z.string().optional()}).passthrough().optional()}).passthrough(),le=e.z.enum(["ambiguous_fields","empty_result","missing_grounded_fields","missing_relationship","no_grounded_query","partial_result","presentation_incomplete","query_validation_failed","unsafe_join"]),X=e.z.object({version:e.z.literal(1),status:e.z.enum(["answered","partial","blocked"]),summary:e.z.string(),answered:e.z.array(e.z.object({slotId:e.z.string().optional(),queryId:e.z.string().optional(),summary:e.z.string(),evidenceIds:e.z.array(e.z.string()).optional(),fieldsUsed:e.z.array(T).optional()}).passthrough()),blocked:e.z.array(e.z.object({slotId:e.z.string().optional(),queryId:e.z.string().optional(),reasonCode:le,message:e.z.string(),missingFields:e.z.array(e.z.string()).optional(),availableFields:e.z.array(e.z.string()).optional(),ambiguousFields:e.z.array(e.z.string()).optional(),missingRelationships:e.z.array(e.z.string()).optional(),evidenceIds:e.z.array(e.z.string()).optional(),neededFromUser:e.z.array(e.z.string()).optional(),recommendedNextStep:e.z.string().optional()}).passthrough()),semanticModelRecommendations:e.z.array(e.z.object({reasonCode:le,message:e.z.string(),recommendedNextStep:e.z.string().optional()}).passthrough()).optional()}).passthrough(),ee=e.z.object({scope:e.z.literal("filtered_query"),measures:e.z.record(R)}).passthrough(),te=e.z.object({answeredObligations:e.z.array(e.z.string()),missingObligations:e.z.array(e.z.string()),warnings:e.z.array(q).optional()}).passthrough(),je=e.z.object({intentId:e.z.string().optional(),queryId:e.z.string().optional(),status:e.z.enum(["answered","partial","failed"]),resultShape:e.z.enum(["metric","records","inputOptions","sql","matrix","period_change","analysis"]).optional(),intent:e.z.unknown().optional(),compiledQuery:e.z.unknown().optional(),fieldsUsed:e.z.array(T).optional(),result:_e.optional(),validation:J,coverage:te.optional(),missingFields:e.z.array(e.z.string()).optional(),warnings:e.z.array(e.z.string()).optional(),relationshipDiagnostics:Re.optional(),diagnosticFeedback:X.optional(),population:ee.optional(),metadata:e.z.record(e.z.string(),e.z.unknown()).optional()}).passthrough();function ai(o){switch(o){case"boolean":return e.z.boolean().optional();case"compactExecutionFieldArray":return e.z.array(Bt).optional();case"coverage":return te.optional();case"diagnosticFeedback":return X.optional();case"executionFieldArray":return e.z.array(T).optional();case"executionResult":return je.optional();case"number":return e.z.number().finite().optional();case"population":return ee.optional();case"record":return p.optional();case"recordArray":return x.optional();case"responseDetail":return e.z.enum(["compact","standard","debug"]).optional();case"string":return e.z.string().optional();case"stringArray":return e.z.array(e.z.string()).optional();case"unknown":return e.z.unknown().optional();case"unknownArray":return e.z.array(e.z.unknown()).optional();case"validationResult":return J.optional()}}const Ce=Object.fromEntries(Object.entries(F).map(([o,i])=>[o,ai(i)])),Ee=e.z.object(Ce).strict(),ie=e.z.object({sourceKey:e.z.string().optional(),kind:e.z.enum(["semantic","physical","sql"]).optional(),domainId:e.z.string().optional(),datasetName:e.z.string().optional(),datasetId:e.z.string().optional(),connectionId:e.z.string().optional(),tableName:e.z.string().optional(),label:e.z.string().optional()}).passthrough(),f=e.z.object({name:e.z.string(),label:e.z.string().optional(),role:e.z.enum(["dimension","measure","date","id","unknown"]).optional(),dataType:e.z.enum(["string","number","boolean","date","datetime","unknown"]).optional(),aggregate:m.optional(),sourceKey:e.z.string().optional(),source:ie.optional()}).passthrough(),qe=e.z.object({id:e.z.string().optional(),builder:e.z.literal("semaphor.inputOptions"),source:ie.optional(),sourceKey:e.z.string().optional(),valueFieldRef:f,labelFieldRef:f,filterFieldRef:f.optional(),population:e.z.unknown().optional(),dependencies:e.z.unknown().optional(),limit:e.z.number().int().positive().optional(),spec:p.optional()}).passthrough(),Fe=e.z.object({appliesToViewIds:e.z.array(e.z.string()).optional(),viewId:e.z.string().optional(),fieldRef:f,relationshipHint:e.z.unknown().optional(),relationshipsUsed:e.z.array(p).optional()}).passthrough(),li=e.z.object({id:e.z.string(),label:e.z.string().optional(),type:e.z.string().optional(),serverSide:e.z.boolean().optional(),fieldRef:f.optional(),optionQuery:qe.optional(),bindings:e.z.array(Fe).optional(),appliesToViewIds:e.z.array(e.z.string()),relationshipHint:e.z.unknown().optional(),relationshipsUsed:e.z.array(p).optional()}).passthrough(),ui=e.z.object({builder:e.z.enum(["semaphor.metric","semaphor.records","semaphor.matrix","semaphor.analysis","semaphor.sql"]),spec:p,fallbackReason:p.optional()}).passthrough(),di=e.z.object({id:e.z.string(),title:e.z.string().optional(),purpose:e.z.string().optional(),sourcePresentation:e.z.object({sourceKeys:e.z.array(e.z.string()).optional(),sourceLabels:e.z.array(e.z.string()).optional()}).passthrough().optional(),visual:e.z.string().optional(),visualSpec:p.optional(),queryKind:e.z.enum(["metric","records","matrix","analysis","sql_fallback"]).optional(),sdkBuilder:e.z.enum(["semaphor.metric","semaphor.records","semaphor.matrix","semaphor.analysis","semaphor.sql"]).optional(),sdkSpec:ui.optional(),fields:e.z.array(f).optional(),computation:p.optional(),uxExpectations:e.z.array(e.z.string()).optional(),validation:p.optional()}).passthrough(),ci=e.z.object({inputId:e.z.string(),label:e.z.string().optional(),type:e.z.string().optional(),serverSide:e.z.boolean().optional(),fieldRef:f.optional(),optionQuery:qe.optional(),bindings:e.z.array(Fe),appliesToViewIds:e.z.array(e.z.string()),notAppliedToViewIds:e.z.array(e.z.string())}).passthrough(),pi=e.z.object({schemaVersion:e.z.literal(C),title:e.z.string(),purpose:e.z.string().optional(),userGoal:e.z.string().optional(),nextStep:e.z.string().optional(),sources:e.z.array(ie),inputs:e.z.array(li),views:e.z.array(di),filterContracts:e.z.array(ci),implementationChecklist:e.z.object({schemaVersion:e.z.string().optional(),requiredDevtools:e.z.object({mountRootDevtools:e.z.boolean(),providerDebugBridge:e.z.string().optional(),panelPosition:e.z.string().optional(),forbidden:e.z.array(e.z.string()).optional()}).passthrough(),requiredInputOptions:e.z.array(p),filterScopeByInput:e.z.array(p),bindingsByView:e.z.record(e.z.string(),e.z.array(p)),validationCommands:e.z.array(e.z.string()),browserSmokeChecks:e.z.array(e.z.string())}).passthrough(),nextRequiredTool:e.z.object({name:e.z.string(),reason:e.z.string().optional()}).optional(),unsupportedInsights:e.z.array(e.z.object({title:e.z.string(),requestedQuestion:e.z.string(),reason:e.z.string(),suggestedModelingFix:e.z.string()}).passthrough()).optional(),assumptions:e.z.array(e.z.string()).optional(),validation:p.optional()}).passthrough().superRefine((o,i)=>{const t=Q(o);for(const s of t.issues)i.addIssue({code:e.z.ZodIssueCode.custom,message:s})}),mi=new Set(Object.keys(F));function gi(){return Object.keys(F)}function xe(o){return mi.has(o)}function hi(o){if(!o||typeof o!="object"||Array.isArray(o))throw new Error("Semaphor analyze result must be an object.");const t=Object.keys(o).filter(s=>!xe(s));if(t.length)throw new Error(`Semaphor analyze result contains unsupported top-level field(s): ${t.join(", ")}.`);return Ee.parse(o)}exports.SEMAPHOR_ANALYZE_RESULT_FIELD_CONTRACT=F;exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION=C;exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION=Oe;exports.getSemaphorAnalyzeResultFieldNames=gi;exports.isSemaphorAnalyzeResultFieldName=xe;exports.isSemaphorDataAppCodegenSummary=Ze;exports.mergeSemaphorSourcesByIdentity=Me;exports.parseSemaphorAnalyzeResult=hi;exports.preferSemaphorFieldRefMetadata=De;exports.preferSemaphorSourceMetadata=U;exports.semaphorAnalyticsCoverageSchema=te;exports.semaphorAnalyticsDiagnosticFeedbackSchema=X;exports.semaphorAnalyticsExecutionResultSchema=je;exports.semaphorAnalyticsPopulationSchema=ee;exports.semaphorAnalyticsResultSchema=_e;exports.semaphorAnalyticsValidationIssueSchema=q;exports.semaphorAnalyticsValidationResultSchema=J;exports.semaphorAnalyzeResultSchema=Ee;exports.semaphorAnalyzeResultShape=Ce;exports.semaphorDataAppCodegenSummarySchema=pi;exports.semaphorDerivedFieldDefinitionSchema=Z;exports.semaphorExecutionFieldRefSchema=T;exports.semaphorFieldRefSchema=y;exports.semaphorFieldRefsMatch=Ke;exports.semaphorInputOptionsResultSchema=ke;exports.semaphorMatrixResultSchema=Ae;exports.semaphorMetricAggregate=H;exports.semaphorMetricMeasureBindingKey=ue;exports.semaphorMetricResultSchema=$e;exports.semaphorPhysicalSourceRefSchema=ze;exports.semaphorRecordsResultSchema=we;exports.semaphorRelationshipDiagnosticsSchema=Re;exports.semaphorResultColumnSchema=E;exports.semaphorSemanticSourceRefSchema=W;exports.semaphorSourceIdentityKey=j;exports.semaphorSourceRefSchema=z;exports.semaphorSourcesReferToSameDataset=G;exports.semaphorSqlResultSchema=Ie;exports.semaphorSqlSourceRefSchema=Se;exports.validateSemaphorDataAppCodegenSummary=Q;
@@ -1 +0,0 @@
1
- "use strict";const e=require("react/jsx-runtime"),l=require("react"),t=require("./index-S1CGUcSz.js"),o=require("./switch-DMT7qf_R.js");require("./x-B6ghREd2.js");require("./analyze-result-contract-DpDcImgk.js");function G(n={}){var y,P,z,A;const{authToken:d,tokenProps:a}=t.useSemaphorContext(),x=n.enabled??!0,m=(d==null?void 0:d.accessToken)??null,f=(a==null?void 0:a.apiServiceUrl)??null,[L,C]=l.useState(!1),[j,b]=l.useState(!1),[h,g]=l.useState(!1),[N,c]=l.useState(null),[v,S]=l.useState(null),k=v||{tz:((P=(y=a==null?void 0:a.params)==null?void 0:y.calendarContext)==null?void 0:P.tz)||null,weekStart:((A=(z=a==null?void 0:a.params)==null?void 0:z.calendarContext)==null?void 0:A.weekStart)??null},p=l.useCallback(async()=>{if(!(!x||!m||!f)){C(!0),c(null);try{const i=await fetch(`${f}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${m}`}});if(!i.ok){const u=await i.json().catch(()=>({}));throw new Error(u.error||"Failed to fetch preferences")}const r=await i.json();S({tz:r.tz,weekStart:r.weekStart,source:r.source,isInherited:r.isInherited,userHasPrefs:r.userHasPrefs,inherited:r.inherited})}catch(i){const r=i instanceof Error?i.message:"Unknown error";c(r)}finally{C(!1)}}},[m,f,x]);l.useEffect(()=>{x&&p()},[x,p]);const T=l.useCallback(async i=>{if(!m||!f)return c("Not authenticated"),!1;b(!0),c(null);try{const r=await fetch(`${f}/v1/user-preferences/calendar`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${m}`},body:JSON.stringify(i)});if(!r.ok){const u=await r.json().catch(()=>({}));throw new Error(u.error||"Failed to update preferences")}return await p(),!0}catch(r){const u=r instanceof Error?r.message:"Unknown error";return c(u),!1}finally{b(!1)}},[m,f,p]),w=l.useCallback(async()=>{if(!m||!f)return c("Not authenticated"),!1;g(!0),c(null);try{const i=await fetch(`${f}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${m}`}});if(!i.ok){const u=await i.json().catch(()=>({}));throw new Error(u.error||"Failed to clear preferences")}const r=await i.text();if(r)try{const u=JSON.parse(r);return S({tz:u.tz,weekStart:u.weekStart,source:u.source,isInherited:u.isInherited??!0,userHasPrefs:!1,inherited:u.inherited}),!0}catch{}return await p(),!0}catch(i){const r=i instanceof Error?i.message:"Unknown error";return c(r),!1}finally{g(!1)}},[m,f,p]);return{preferences:k,isLoading:L,isSaving:j,isClearing:h,error:N,updatePreferences:T,clearPreferences:w,refetch:p}}const E=[{value:"America/New_York",label:"Eastern Time (US & Canada)"},{value:"America/Chicago",label:"Central Time (US & Canada)"},{value:"America/Denver",label:"Mountain Time (US & Canada)"},{value:"America/Los_Angeles",label:"Pacific Time (US & Canada)"},{value:"America/Phoenix",label:"Arizona"},{value:"America/Anchorage",label:"Alaska"},{value:"Pacific/Honolulu",label:"Hawaii"},{value:"Europe/London",label:"London"},{value:"Europe/Paris",label:"Paris, Berlin, Rome"},{value:"Asia/Tokyo",label:"Tokyo"},{value:"Asia/Shanghai",label:"Beijing, Shanghai"},{value:"Asia/Kolkata",label:"Mumbai, New Delhi"},{value:"Australia/Sydney",label:"Sydney"},{value:"UTC",label:"UTC"}],M=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:6,label:"Saturday"}],H="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function W(){try{const n=Intl;if(n.supportedValuesOf)return n.supportedValuesOf("timeZone")}catch{}return E.map(n=>n.value)}function _(n){switch(n){case"tenant":return"tenant";case"organization":return"organization";case"system":return"system";default:return"default"}}function O(n){const d=E.find(a=>a.value===n);return d?d.label:n}function q(n){const d=M.find(a=>a.value===n);return d?d.label:String(n)}function V({open:n,onOpenChange:d}){var D,U,F;const{preferences:a,isLoading:x,isSaving:m,isClearing:f,updatePreferences:L,clearPreferences:C}=G({enabled:n}),j=a.tz||((D=a.inherited)==null?void 0:D.tz)||Intl.DateTimeFormat().resolvedOptions().timeZone,b=a.weekStart??((U=a.inherited)==null?void 0:U.weekStart)??1,[h,g]=l.useState(!a.userHasPrefs),[N,c]=l.useState(!1),[v,S]=l.useState(j),[k,p]=l.useState(b),[T,w]=l.useState(!1),y=l.useMemo(()=>W(),[]),P=l.useMemo(()=>y.filter(s=>!E.some(R=>R.value===s)),[y]),z=l.useMemo(()=>O(v),[v]),A=a.inherited?O(a.inherited.tz):"UTC",i=a.inherited?q(a.inherited.weekStart):"Monday",r=_((F=a.inherited)==null?void 0:F.source);l.useEffect(()=>{if(!n){c(!1);return}N||(a.userHasPrefs!==void 0&&g(!a.userHasPrefs),S(j),p(b))},[n,N,a.userHasPrefs,j,b]);const u=async()=>{if(x){t.ue.error("Preferences are still loading. Please try again.");return}h?await C()?(t.ue.success("Now using default settings. Please refresh the page to apply changes.",{duration:5e3}),d(!1)):t.ue.error("Failed to save preferences. Please try again."):await L({tz:v,weekStart:k})?(t.ue.success("Preferences saved. Please refresh the page to apply changes.",{duration:5e3}),d(!1)):t.ue.error("Failed to save preferences. Please try again.")},$=()=>{d(!1)},I=m||f,B=I||x;return e.jsx(t.Dialog,{open:n,onOpenChange:d,children:e.jsxs(t.DialogContent,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{className:"text-[15px]",children:"Calendar preferences"}),e.jsx(t.DialogDescription,{className:"text-[13px] leading-5",children:"Set your timezone and week-start for date calculations and displays."})]}),e.jsxs("div",{className:"space-y-4 py-1",children:[e.jsxs(t.RadioGroup,{value:h?"defaults":"custom",onValueChange:s=>{c(!0),g(s==="defaults")},className:"space-y-0.5",children:[e.jsxs("label",{htmlFor:"mode-defaults",className:o.cn("flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",h&&"bg-muted/50"),onClick:()=>{c(!0),g(!0)},children:[e.jsx(t.RadioGroupItem,{value:"defaults",id:"mode-defaults",className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-[13px] font-medium text-foreground",children:["Use ",r," defaults"]}),e.jsxs("p",{className:"text-[12px] text-muted-foreground",children:[A,", week starts ",i]})]})]}),e.jsxs("label",{htmlFor:"mode-custom",className:o.cn("flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",!h&&"bg-muted/50"),onClick:()=>{c(!0),g(!1)},children:[e.jsx(t.RadioGroupItem,{value:"custom",id:"mode-custom",className:"mt-0.5"}),e.jsx("p",{className:"flex-1 text-[13px] font-medium text-foreground",children:"Use custom settings"})]})]}),e.jsxs("div",{className:o.cn("space-y-4 border-t border-border/60 pt-4 transition-opacity",h&&"pointer-events-none opacity-50"),children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o.Label,{className:H,children:"Timezone"}),e.jsxs(o.Popover,{open:T,onOpenChange:w,modal:!0,children:[e.jsx(o.PopoverTrigger,{asChild:!0,children:e.jsxs(o.Button,{variant:"outline",size:"xs",role:"combobox","aria-expanded":T,className:"w-full justify-between text-[12px] font-normal",disabled:h,children:[e.jsx("span",{className:"truncate",children:z}),e.jsx(t.ChevronsUpDown,{className:"ml-2 h-3.5 w-3.5 shrink-0 opacity-50"})]})}),e.jsx(o.PopoverContent,{className:"z-50 w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(t.Command,{className:"overflow-visible",children:[e.jsx(t.CommandInput,{placeholder:"Search timezones…"}),e.jsxs(t.CommandList,{children:[e.jsx(t.CommandEmpty,{children:"No timezone found."}),e.jsx(t.CommandGroup,{heading:"Common",children:E.map(s=>e.jsxs(t.CommandItem,{value:`${s.value} ${s.label}`,onSelect:()=>{c(!0),S(s.value),w(!1)},children:[e.jsx(o.Check,{className:o.cn("h-3.5 w-3.5",v===s.value?"opacity-100":"opacity-0")}),e.jsx("span",{className:"flex-1",children:s.label}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:s.value})]},s.value))}),e.jsx(t.CommandSeparator,{}),e.jsx(t.CommandGroup,{heading:"All timezones",children:P.map(s=>e.jsxs(t.CommandItem,{value:s,onSelect:()=>{c(!0),S(s),w(!1)},children:[e.jsx(o.Check,{className:o.cn("h-3.5 w-3.5",v===s?"opacity-100":"opacity-0")}),s]},s))})]})]})})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o.Label,{className:H,children:"Week starts on"}),e.jsx(t.RadioGroup,{value:String(k),onValueChange:s=>{c(!0),p(Number(s))},className:"flex gap-4",disabled:h,children:M.map(s=>e.jsxs("label",{htmlFor:`week-start-${s.value}`,className:o.cn("flex cursor-pointer items-center gap-2 text-[13px]",h&&"cursor-not-allowed"),children:[e.jsx(t.RadioGroupItem,{value:String(s.value),id:`week-start-${s.value}`,disabled:h}),s.label]},s.value))})]})]})]}),e.jsxs(t.DialogFooter,{children:[e.jsx(o.Button,{variant:"outline",size:"xs",onClick:$,disabled:I,children:"Cancel"}),e.jsx(o.Button,{size:"xs",onClick:u,disabled:B,children:I?e.jsxs(e.Fragment,{children:[e.jsx(o.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving…"]}):"Save"})]})]})})}exports.CalendarPreferencesDialog=V;
@@ -1,11 +0,0 @@
1
- const A = [
2
- "lg",
3
- "md",
4
- "sm",
5
- "xs",
6
- "xxs"
7
- ], s = 15;
8
- export {
9
- s as D,
10
- A as a
11
- };
@@ -1 +0,0 @@
1
- "use strict";const A=["lg","md","sm","xs","xxs"];exports.DASHBOARD_AUTHORING_BREAKPOINTS=A;exports.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS=15;