react-semaphor 0.1.348 → 0.1.349

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 (60) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +46 -45
  3. package/dist/brand-studio/index.cjs +1 -1
  4. package/dist/brand-studio/index.js +3 -3
  5. package/dist/chunks/{braces-Ccvdip75.js → braces-CBMh5wmd.js} +1 -1
  6. package/dist/chunks/{braces-DDHkbW1c.js → braces-Cc86y9Ov.js} +1 -1
  7. package/dist/chunks/{calendar-preferences-dialog-CaeYg4gz.js → calendar-preferences-dialog-C2vX2dga.js} +1 -1
  8. package/dist/chunks/{calendar-preferences-dialog-AVORk8vl.js → calendar-preferences-dialog-gMb9JPpz.js} +3 -3
  9. package/dist/chunks/{chevrons-up-down-B9fTSds9.js → chevrons-up-down-CUZL1zaU.js} +1 -1
  10. package/dist/chunks/{chevrons-up-down-pV0i9ptS.js → chevrons-up-down-fg3WME_w.js} +1 -1
  11. package/dist/chunks/{dashboard-briefing-launcher-B7hc62UJ.js → dashboard-briefing-launcher-Cx4NkJil.js} +4 -4
  12. package/dist/chunks/{dashboard-briefing-launcher-GmwoVZDA.js → dashboard-briefing-launcher-DjzTWk1f.js} +1 -1
  13. package/dist/chunks/dashboard-controls-BTz9RgtD.js +57 -0
  14. package/dist/chunks/{dashboard-controls-DOwo-4PX.js → dashboard-controls-Yo3L7krV.js} +129 -119
  15. package/dist/chunks/{dashboard-json-Bjge3tEx.js → dashboard-json-3_OGzDQh.js} +1 -1
  16. package/dist/chunks/{dashboard-json-CqWAmaOX.js → dashboard-json-OLpSyYFR.js} +2 -2
  17. package/dist/chunks/{edit-dashboard-visual-NXdSdqQS.js → edit-dashboard-visual-073yhfDG.js} +6 -6
  18. package/dist/chunks/{edit-dashboard-visual-biDU5oky.js → edit-dashboard-visual-DXzKEyXJ.js} +1 -1
  19. package/dist/chunks/index-Alj8oDV1.js +1410 -0
  20. package/dist/chunks/{index-DhuiooCy.js → index-DTSZ23bE.js} +36067 -35746
  21. package/dist/chunks/{palette-BMXS-AcI.js → palette-C1k347Tb.js} +1 -1
  22. package/dist/chunks/{palette-DKecBucs.js → palette-DP6TXUD8.js} +1 -1
  23. package/dist/chunks/{resource-management-panel-DIt7NxsX.js → resource-management-panel-BvTTEaef.js} +3 -3
  24. package/dist/chunks/{resource-management-panel-MHam0keE.js → resource-management-panel-DLJ6uWYJ.js} +1 -1
  25. package/dist/chunks/source-identity-C-xaeE_I.js +1 -0
  26. package/dist/chunks/source-identity-qAmkNtEK.js +49 -0
  27. package/dist/chunks/{switch-CP7SmEIZ.js → switch-21kU-tcj.js} +2 -2
  28. package/dist/chunks/{switch-DYRgERrC.js → switch-C0S63HAv.js} +1 -1
  29. package/dist/chunks/{use-create-flow-overlay-state-DS5aPcKd.js → use-create-flow-overlay-state-BMr_844V.js} +1 -1
  30. package/dist/chunks/{use-create-flow-overlay-state-p_i0aUhH.js → use-create-flow-overlay-state-gRSXj8dj.js} +3 -3
  31. package/dist/chunks/{use-visual-utils-EazVs86Z.js → use-visual-utils-7w01KGK7.js} +1 -1
  32. package/dist/chunks/{use-visual-utils-PfpWtYcR.js → use-visual-utils-D5zrmYt8.js} +2 -2
  33. package/dist/chunks/{validators-C2eI8fHy.js → validators-B-NiYgGc.js} +178 -224
  34. package/dist/chunks/validators-DlEfynH8.js +1 -0
  35. package/dist/dashboard/index.cjs +1 -1
  36. package/dist/dashboard/index.js +1 -1
  37. package/dist/dashboard-assistant/index.cjs +1 -0
  38. package/dist/dashboard-assistant/index.js +12 -0
  39. package/dist/dashboard-authoring/index.cjs +3 -3
  40. package/dist/dashboard-authoring/index.js +16 -15
  41. package/dist/data-app-builder/index.cjs +1 -1
  42. package/dist/data-app-builder/index.js +1 -1
  43. package/dist/data-app-sdk/index.cjs +1 -1
  44. package/dist/data-app-sdk/index.js +32 -31
  45. package/dist/index.cjs +1 -1
  46. package/dist/index.js +7 -7
  47. package/dist/style.css +1 -1
  48. package/dist/surfboard/index.cjs +1 -1
  49. package/dist/surfboard/index.js +2 -2
  50. package/dist/types/dashboard-assistant.d.ts +1030 -0
  51. package/dist/types/dashboard-authoring.d.ts +1 -1
  52. package/dist/types/dashboard.d.ts +1 -1
  53. package/dist/types/main.d.ts +1 -1
  54. package/dist/types/shared.d.ts +1 -1
  55. package/dist/types/surfboard.d.ts +1 -1
  56. package/dist/types/types.d.ts +1 -1
  57. package/package.json +6 -1
  58. package/dist/chunks/dashboard-controls-Bthl3kl3.js +0 -52
  59. package/dist/chunks/index-D7U5s9Uk.js +0 -1425
  60. package/dist/chunks/validators-BNvNf_tO.js +0 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chunks/validators-BNvNf_tO.js"),t=require("../chunks/catalog-field-grounding-Du6mKDcF.js");function d(e,a={}){const i=o(e),s={connectionId:a.connectionId,connectionType:e,path:["database","schema","table"],labels:{database:"Database",schema:"Schema",table:"Table"},prefixLevels:["database","schema","table"],dialect:"postgres",supportsFilterClause:!0};return i.includes("postgres")?{...s,prefixLevels:["schema","table"],dialect:"postgres"}:i.includes("mysql")?{...s,prefixLevels:["database","table"],dialect:"mysql",supportsFilterClause:!1}:i.includes("mssql")||i.includes("sqlserver")?{...s,dialect:"mssql",supportsFilterClause:!1}:i.includes("redshift")?{...s,prefixLevels:["schema","table"],dialect:"redshift"}:i.includes("snowflake")?{...s,dialect:"snowflake"}:i.includes("clickhouse")?{connectionId:a.connectionId,connectionType:e,path:["database","table"],labels:{database:"Database",table:"Table"},prefixLevels:["database","table"],dialect:"clickhouse",supportsFilterClause:!1}:i==="s3"||i==="api"?{connectionId:a.connectionId,connectionType:e,path:["table"],labels:{table:i==="api"?"API Table":"File Table"},prefixLevels:["table"],dialect:"duckdb",supportsFilterClause:!0}:i==="googlesheets"||i==="fileupload"?{connectionId:a.connectionId,connectionType:e,path:["table"],labels:{table:"Table"},prefixLevels:["table"],dialect:"postgres",supportsFilterClause:!0}:i==="s3tables"?{...s,labels:{database:"Database",schema:"Namespace",table:"Table"},dialect:"duckdb"}:i==="bigquery"?{...s,labels:{database:"Project",schema:"Dataset",table:"Table"},prefixLevels:["schema","table"],dialect:"bigquery",supportsFilterClause:!1}:s}function c(e){const a=o(e);switch(a){case"mysql":case"bigquery":case"redshift":case"snowflake":case"clickhouse":case"duckdb":case"sqlite":return a;case"mssql":case"sqlserver":return"mssql";case"postgres":case"postgresql":return"postgres";default:return"unknown"}}function u(e){return e.capabilities.prefixLevels.every(a=>!!l(e.source,a))}function m(e){const a=e.quoteIdentifier??p;return e.capabilities.prefixLevels.map(i=>l(e.source,i)).filter(i=>!!i).map(i=>a(i,e.capabilities.dialect)).join(".")}function l(e,a){return a==="database"?e.databaseName:a==="schema"?e.schemaName:e.tableName}function p(e,a){return a==="mysql"||a==="bigquery"||a==="clickhouse"||a==="duckdb"?`\`${e.replace(/`/g,"``")}\``:a==="mssql"?`[${e.replace(/]/g,"]]")}]`:`"${e.replace(/"/g,'""')}"`}function o(e){if(typeof e!="string")return"";const a=[];for(const i of e.trim().toLowerCase())b(i)&&a.push(i);return a.join("")}function b(e){const a=e.charCodeAt(0);return a>=48&&a<=57||a>=97&&a<=122}const n={kind:"semantic",domainId:"domain_sales",datasetName:"orders",connectionId:"conn_sales",label:"Orders"},f={revenueKpi:{version:1,kind:"metric",id:"revenue-kpi",label:"Revenue",source:n,metrics:[{name:"revenue",role:"measure"}],primaryMetric:{name:"revenue",role:"measure"},comparison:{kind:"previous_period"},limit:1},revenueTrend:{version:1,kind:"records",id:"revenue-trend",label:"Revenue trend",source:n,fields:[{name:"order_date",role:"date",dataType:"date",label:"Order Date"},{name:"revenue",role:"measure",dataType:"number"}],dateField:{name:"order_date",role:"date",dataType:"date"},timeGrain:"month",limit:100},topCustomersRecords:{version:1,kind:"records",id:"top-customers",label:"Top customers",source:n,fields:[{name:"customer_name",role:"dimension",dataType:"string"},{name:"segment",role:"dimension",dataType:"string"},{name:"revenue",role:"measure",dataType:"number"}],orderBy:{field:{name:"revenue",role:"measure"},direction:"desc"},limit:20},regionInputOptions:{version:1,kind:"inputOptions",id:"region-options",label:"Region options",source:n,field:{name:"region",role:"dimension",dataType:"string"},limit:100},previousPeriodRevenueComparison:{version:1,kind:"metric",id:"revenue-previous-period",label:"Revenue previous period comparison",source:n,metrics:[{name:"revenue",role:"measure"}],primaryMetric:{name:"revenue",role:"measure"},dateField:{name:"order_date",role:"date",dataType:"date"},timeGrain:"week",comparison:{kind:"previous_period"},limit:100},inboundSupplierConcentration:{version:1,kind:"metric",id:"inbound-supplier-concentration",label:"Inbound supplier concentration",source:n,metrics:[{name:"net_tons",role:"measure"},{name:"ticket_value",role:"measure"}],primaryMetric:{name:"net_tons",role:"measure"},dateField:{name:"ticket_date",role:"date",dataType:"date"},timeWindow:{unit:"month",value:6,anchor:"latest_available"},dimensions:[{name:"supplier_id",role:"dimension",dataType:"number"}],filters:[{field:{name:"direction",role:"dimension",dataType:"string"},operator:"=",values:["Inbound"]}],limit:15},boundedSqlRanking:{version:1,kind:"sql",id:"top-customer-ranking-sql",label:"Top customer ranking SQL",source:{kind:"sql",connectionId:"conn_sales",dialect:"postgres"},sql:"SELECT customer_name, SUM(revenue) AS revenue FROM public.orders GROUP BY customer_name ORDER BY revenue DESC LIMIT 20",limit:20,rationale:"Ranking is SQL-natural because it requires ordering grouped aggregate rows.",fields:[{name:"customer_name",role:"dimension",dataType:"string"},{name:"revenue",role:"measure",dataType:"number"}]}};exports.parseSemaphorIsoTimeWindowBoundary=r.parseSemaphorIsoTimeWindowBoundary;exports.preferSemaphorFieldRefMetadata=r.preferSemaphorFieldRefMetadata;exports.preferSemaphorSourceMetadata=r.preferSemaphorSourceMetadata;exports.semaphorFieldRefsMatch=r.semaphorFieldRefsMatch;exports.semaphorSourceIdentityKey=r.semaphorSourceIdentityKey;exports.semaphorSourcesReferToSameDataset=r.semaphorSourcesReferToSameDataset;exports.validateSemaphorAnalyticsIntent=r.validateSemaphorAnalyticsIntent;exports.validateSemaphorAnalyticsRecoveryPlan=r.validateSemaphorAnalyticsRecoveryPlan;exports.validateSemaphorDashboardIntent=r.validateSemaphorDashboardIntent;exports.validateSemaphorOperationIntent=r.validateSemaphorOperationIntent;exports.buildAnalyticsCatalogFieldSummary=t.buildAnalyticsCatalogFieldSummary;exports.getAnalyticsCatalogFieldCandidates=t.getAnalyticsCatalogFieldCandidates;exports.getAnalyticsCatalogFieldName=t.getAnalyticsCatalogFieldName;exports.isAnalyticsCatalogDateField=t.isAnalyticsCatalogDateField;exports.isAnalyticsCatalogDimensionField=t.isAnalyticsCatalogDimensionField;exports.isAnalyticsCatalogMetricField=t.isAnalyticsCatalogMetricField;exports.isAnalyticsDateLikeDataType=t.isAnalyticsDateLikeDataType;exports.isAnalyticsMetricIdentifierField=t.isAnalyticsMetricIdentifierField;exports.isAnalyticsTechnicalIdentifierField=t.isAnalyticsTechnicalIdentifierField;exports.normalizeAnalyticsCatalogDataType=t.normalizeAnalyticsCatalogDataType;exports.normalizeAnalyticsCatalogName=t.normalizeAnalyticsCatalogName;exports.SEMAPHOR_ANALYTICS_INTENT_FIXTURES=f;exports.buildSemaphorQualifiedSourcePath=m;exports.getSemaphorConnectionCapabilities=d;exports.normalizeSemaphorDialect=c;exports.semaphorSourceHasRequiredCoordinates=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../chunks/validators-DlEfynH8.js"),t=require("../chunks/catalog-field-grounding-Du6mKDcF.js"),l=require("../chunks/source-identity-C-xaeE_I.js");function c(e,a={}){const i=d(e),r={connectionId:a.connectionId,connectionType:e,path:["database","schema","table"],labels:{database:"Database",schema:"Schema",table:"Table"},prefixLevels:["database","schema","table"],dialect:"postgres",supportsFilterClause:!0};return i.includes("postgres")?{...r,prefixLevels:["schema","table"],dialect:"postgres"}:i.includes("mysql")?{...r,prefixLevels:["database","table"],dialect:"mysql",supportsFilterClause:!1}:i.includes("mssql")||i.includes("sqlserver")?{...r,dialect:"mssql",supportsFilterClause:!1}:i.includes("redshift")?{...r,prefixLevels:["schema","table"],dialect:"redshift"}:i.includes("snowflake")?{...r,dialect:"snowflake"}:i.includes("clickhouse")?{connectionId:a.connectionId,connectionType:e,path:["database","table"],labels:{database:"Database",table:"Table"},prefixLevels:["database","table"],dialect:"clickhouse",supportsFilterClause:!1}:i==="s3"||i==="api"?{connectionId:a.connectionId,connectionType:e,path:["table"],labels:{table:i==="api"?"API Table":"File Table"},prefixLevels:["table"],dialect:"duckdb",supportsFilterClause:!0}:i==="googlesheets"||i==="fileupload"?{connectionId:a.connectionId,connectionType:e,path:["table"],labels:{table:"Table"},prefixLevels:["table"],dialect:"postgres",supportsFilterClause:!0}:i==="s3tables"?{...r,labels:{database:"Database",schema:"Namespace",table:"Table"},dialect:"duckdb"}:i==="bigquery"?{...r,labels:{database:"Project",schema:"Dataset",table:"Table"},prefixLevels:["schema","table"],dialect:"bigquery",supportsFilterClause:!1}:r}function u(e){const a=d(e);switch(a){case"mysql":case"bigquery":case"redshift":case"snowflake":case"clickhouse":case"duckdb":case"sqlite":return a;case"mssql":case"sqlserver":return"mssql";case"postgres":case"postgresql":return"postgres";default:return"unknown"}}function m(e){return e.capabilities.prefixLevels.every(a=>!!o(e.source,a))}function p(e){const a=e.quoteIdentifier??b;return e.capabilities.prefixLevels.map(i=>o(e.source,i)).filter(i=>!!i).map(i=>a(i,e.capabilities.dialect)).join(".")}function o(e,a){return a==="database"?e.databaseName:a==="schema"?e.schemaName:e.tableName}function b(e,a){return a==="mysql"||a==="bigquery"||a==="clickhouse"||a==="duckdb"?`\`${e.replace(/`/g,"``")}\``:a==="mssql"?`[${e.replace(/]/g,"]]")}]`:`"${e.replace(/"/g,'""')}"`}function d(e){if(typeof e!="string")return"";const a=[];for(const i of e.trim().toLowerCase())f(i)&&a.push(i);return a.join("")}function f(e){const a=e.charCodeAt(0);return a>=48&&a<=57||a>=97&&a<=122}const s={kind:"semantic",domainId:"domain_sales",datasetName:"orders",connectionId:"conn_sales",label:"Orders"},h={revenueKpi:{version:1,kind:"metric",id:"revenue-kpi",label:"Revenue",source:s,metrics:[{name:"revenue",role:"measure"}],primaryMetric:{name:"revenue",role:"measure"},comparison:{kind:"previous_period"},limit:1},revenueTrend:{version:1,kind:"records",id:"revenue-trend",label:"Revenue trend",source:s,fields:[{name:"order_date",role:"date",dataType:"date",label:"Order Date"},{name:"revenue",role:"measure",dataType:"number"}],dateField:{name:"order_date",role:"date",dataType:"date"},timeGrain:"month",limit:100},topCustomersRecords:{version:1,kind:"records",id:"top-customers",label:"Top customers",source:s,fields:[{name:"customer_name",role:"dimension",dataType:"string"},{name:"segment",role:"dimension",dataType:"string"},{name:"revenue",role:"measure",dataType:"number"}],orderBy:{field:{name:"revenue",role:"measure"},direction:"desc"},limit:20},regionInputOptions:{version:1,kind:"inputOptions",id:"region-options",label:"Region options",source:s,field:{name:"region",role:"dimension",dataType:"string"},limit:100},previousPeriodRevenueComparison:{version:1,kind:"metric",id:"revenue-previous-period",label:"Revenue previous period comparison",source:s,metrics:[{name:"revenue",role:"measure"}],primaryMetric:{name:"revenue",role:"measure"},dateField:{name:"order_date",role:"date",dataType:"date"},timeGrain:"week",comparison:{kind:"previous_period"},limit:100},inboundSupplierConcentration:{version:1,kind:"metric",id:"inbound-supplier-concentration",label:"Inbound supplier concentration",source:s,metrics:[{name:"net_tons",role:"measure"},{name:"ticket_value",role:"measure"}],primaryMetric:{name:"net_tons",role:"measure"},dateField:{name:"ticket_date",role:"date",dataType:"date"},timeWindow:{unit:"month",value:6,anchor:"latest_available"},dimensions:[{name:"supplier_id",role:"dimension",dataType:"number"}],filters:[{field:{name:"direction",role:"dimension",dataType:"string"},operator:"=",values:["Inbound"]}],limit:15},boundedSqlRanking:{version:1,kind:"sql",id:"top-customer-ranking-sql",label:"Top customer ranking SQL",source:{kind:"sql",connectionId:"conn_sales",dialect:"postgres"},sql:"SELECT customer_name, SUM(revenue) AS revenue FROM public.orders GROUP BY customer_name ORDER BY revenue DESC LIMIT 20",limit:20,rationale:"Ranking is SQL-natural because it requires ordering grouped aggregate rows.",fields:[{name:"customer_name",role:"dimension",dataType:"string"},{name:"revenue",role:"measure",dataType:"number"}]}};exports.parseSemaphorIsoTimeWindowBoundary=n.parseSemaphorIsoTimeWindowBoundary;exports.validateSemaphorAnalyticsIntent=n.validateSemaphorAnalyticsIntent;exports.validateSemaphorAnalyticsRecoveryPlan=n.validateSemaphorAnalyticsRecoveryPlan;exports.validateSemaphorDashboardIntent=n.validateSemaphorDashboardIntent;exports.validateSemaphorOperationIntent=n.validateSemaphorOperationIntent;exports.buildAnalyticsCatalogFieldSummary=t.buildAnalyticsCatalogFieldSummary;exports.getAnalyticsCatalogFieldCandidates=t.getAnalyticsCatalogFieldCandidates;exports.getAnalyticsCatalogFieldName=t.getAnalyticsCatalogFieldName;exports.isAnalyticsCatalogDateField=t.isAnalyticsCatalogDateField;exports.isAnalyticsCatalogDimensionField=t.isAnalyticsCatalogDimensionField;exports.isAnalyticsCatalogMetricField=t.isAnalyticsCatalogMetricField;exports.isAnalyticsDateLikeDataType=t.isAnalyticsDateLikeDataType;exports.isAnalyticsMetricIdentifierField=t.isAnalyticsMetricIdentifierField;exports.isAnalyticsTechnicalIdentifierField=t.isAnalyticsTechnicalIdentifierField;exports.normalizeAnalyticsCatalogDataType=t.normalizeAnalyticsCatalogDataType;exports.normalizeAnalyticsCatalogName=t.normalizeAnalyticsCatalogName;exports.preferSemaphorFieldRefMetadata=l.preferSemaphorFieldRefMetadata;exports.preferSemaphorSourceMetadata=l.preferSemaphorSourceMetadata;exports.semaphorFieldRefsMatch=l.semaphorFieldRefsMatch;exports.semaphorSourceIdentityKey=l.semaphorSourceIdentityKey;exports.semaphorSourcesReferToSameDataset=l.semaphorSourcesReferToSameDataset;exports.SEMAPHOR_ANALYTICS_INTENT_FIXTURES=h;exports.buildSemaphorQualifiedSourcePath=p;exports.getSemaphorConnectionCapabilities=c;exports.normalizeSemaphorDialect=u;exports.semaphorSourceHasRequiredCoordinates=m;
@@ -1,7 +1,8 @@
1
- import { p as v, g as h, e as g, f as y, s as k, d as C, v as I, b as S, c as T, a as q } from "../chunks/validators-C2eI8fHy.js";
2
- import { j as _, a as A, g as R, c as L, h as D, f as x, i as M, e as N, d as w, b as O, n as E } from "../chunks/catalog-field-grounding-DoEBOXQd.js";
1
+ import { p as v, v as h, b as g, c as y, a as k } from "../chunks/validators-B-NiYgGc.js";
2
+ import { j as I, a as S, g as T, c as q, h as F, f as _, i as A, e as R, d as L, b as D, n as x } from "../chunks/catalog-field-grounding-DoEBOXQd.js";
3
+ import { c as N, p as w, s as O, a as E, b as P } from "../chunks/source-identity-qAmkNtEK.js";
3
4
  function d(e, a = {}) {
4
- const r = n(e), i = {
5
+ const r = n(e), t = {
5
6
  connectionId: a.connectionId,
6
7
  connectionType: e,
7
8
  path: ["database", "schema", "table"],
@@ -15,24 +16,24 @@ function d(e, a = {}) {
15
16
  supportsFilterClause: !0
16
17
  };
17
18
  return r.includes("postgres") ? {
18
- ...i,
19
+ ...t,
19
20
  prefixLevels: ["schema", "table"],
20
21
  dialect: "postgres"
21
22
  } : r.includes("mysql") ? {
22
- ...i,
23
+ ...t,
23
24
  prefixLevels: ["database", "table"],
24
25
  dialect: "mysql",
25
26
  supportsFilterClause: !1
26
27
  } : r.includes("mssql") || r.includes("sqlserver") ? {
27
- ...i,
28
+ ...t,
28
29
  dialect: "mssql",
29
30
  supportsFilterClause: !1
30
31
  } : r.includes("redshift") ? {
31
- ...i,
32
+ ...t,
32
33
  prefixLevels: ["schema", "table"],
33
34
  dialect: "redshift"
34
35
  } : r.includes("snowflake") ? {
35
- ...i,
36
+ ...t,
36
37
  dialect: "snowflake"
37
38
  } : r.includes("clickhouse") ? {
38
39
  connectionId: a.connectionId,
@@ -66,7 +67,7 @@ function d(e, a = {}) {
66
67
  dialect: "postgres",
67
68
  supportsFilterClause: !0
68
69
  } : r === "s3tables" ? {
69
- ...i,
70
+ ...t,
70
71
  labels: {
71
72
  database: "Database",
72
73
  schema: "Namespace",
@@ -74,7 +75,7 @@ function d(e, a = {}) {
74
75
  },
75
76
  dialect: "duckdb"
76
77
  } : r === "bigquery" ? {
77
- ...i,
78
+ ...t,
78
79
  labels: {
79
80
  database: "Project",
80
81
  schema: "Dataset",
@@ -83,7 +84,7 @@ function d(e, a = {}) {
83
84
  prefixLevels: ["schema", "table"],
84
85
  dialect: "bigquery",
85
86
  supportsFilterClause: !1
86
- } : i;
87
+ } : t;
87
88
  }
88
89
  function c(e) {
89
90
  const a = n(e);
@@ -108,17 +109,17 @@ function c(e) {
108
109
  }
109
110
  function u(e) {
110
111
  return e.capabilities.prefixLevels.every(
111
- (a) => !!t(e.source, a)
112
+ (a) => !!s(e.source, a)
112
113
  );
113
114
  }
114
115
  function m(e) {
115
- const a = e.quoteIdentifier ?? l;
116
- return e.capabilities.prefixLevels.map((r) => t(e.source, r)).filter((r) => !!r).map((r) => a(r, e.capabilities.dialect)).join(".");
116
+ const a = e.quoteIdentifier ?? o;
117
+ return e.capabilities.prefixLevels.map((r) => s(e.source, r)).filter((r) => !!r).map((r) => a(r, e.capabilities.dialect)).join(".");
117
118
  }
118
- function t(e, a) {
119
+ function s(e, a) {
119
120
  return a === "database" ? e.databaseName : a === "schema" ? e.schemaName : e.tableName;
120
121
  }
121
- function l(e, a) {
122
+ function o(e, a) {
122
123
  return a === "mysql" || a === "bigquery" || a === "clickhouse" || a === "duckdb" ? `\`${e.replace(/`/g, "``")}\`` : a === "mssql" ? `[${e.replace(/]/g, "]]")}]` : `"${e.replace(/"/g, '""')}"`;
123
124
  }
124
125
  function n(e) {
@@ -126,14 +127,14 @@ function n(e) {
126
127
  return "";
127
128
  const a = [];
128
129
  for (const r of e.trim().toLowerCase())
129
- o(r) && a.push(r);
130
+ l(r) && a.push(r);
130
131
  return a.join("");
131
132
  }
132
- function o(e) {
133
+ function l(e) {
133
134
  const a = e.charCodeAt(0);
134
135
  return a >= 48 && a <= 57 || a >= 97 && a <= 122;
135
136
  }
136
- const s = {
137
+ const i = {
137
138
  kind: "semantic",
138
139
  domainId: "domain_sales",
139
140
  datasetName: "orders",
@@ -145,7 +146,7 @@ const s = {
145
146
  kind: "metric",
146
147
  id: "revenue-kpi",
147
148
  label: "Revenue",
148
- source: s,
149
+ source: i,
149
150
  metrics: [{ name: "revenue", role: "measure" }],
150
151
  primaryMetric: { name: "revenue", role: "measure" },
151
152
  comparison: { kind: "previous_period" },
@@ -156,7 +157,7 @@ const s = {
156
157
  kind: "records",
157
158
  id: "revenue-trend",
158
159
  label: "Revenue trend",
159
- source: s,
160
+ source: i,
160
161
  fields: [
161
162
  { name: "order_date", role: "date", dataType: "date", label: "Order Date" },
162
163
  { name: "revenue", role: "measure", dataType: "number" }
@@ -170,7 +171,7 @@ const s = {
170
171
  kind: "records",
171
172
  id: "top-customers",
172
173
  label: "Top customers",
173
- source: s,
174
+ source: i,
174
175
  fields: [
175
176
  { name: "customer_name", role: "dimension", dataType: "string" },
176
177
  { name: "segment", role: "dimension", dataType: "string" },
@@ -184,7 +185,7 @@ const s = {
184
185
  kind: "inputOptions",
185
186
  id: "region-options",
186
187
  label: "Region options",
187
- source: s,
188
+ source: i,
188
189
  field: { name: "region", role: "dimension", dataType: "string" },
189
190
  limit: 100
190
191
  },
@@ -193,7 +194,7 @@ const s = {
193
194
  kind: "metric",
194
195
  id: "revenue-previous-period",
195
196
  label: "Revenue previous period comparison",
196
- source: s,
197
+ source: i,
197
198
  metrics: [{ name: "revenue", role: "measure" }],
198
199
  primaryMetric: { name: "revenue", role: "measure" },
199
200
  dateField: { name: "order_date", role: "date", dataType: "date" },
@@ -206,7 +207,7 @@ const s = {
206
207
  kind: "metric",
207
208
  id: "inbound-supplier-concentration",
208
209
  label: "Inbound supplier concentration",
209
- source: s,
210
+ source: i,
210
211
  metrics: [
211
212
  { name: "net_tons", role: "measure" },
212
213
  { name: "ticket_value", role: "measure" }
@@ -245,29 +246,29 @@ const s = {
245
246
  };
246
247
  export {
247
248
  p as SEMAPHOR_ANALYTICS_INTENT_FIXTURES,
248
- _ as buildAnalyticsCatalogFieldSummary,
249
+ I as buildAnalyticsCatalogFieldSummary,
249
250
  m as buildSemaphorQualifiedSourcePath,
250
- A as getAnalyticsCatalogFieldCandidates,
251
- R as getAnalyticsCatalogFieldName,
251
+ S as getAnalyticsCatalogFieldCandidates,
252
+ T as getAnalyticsCatalogFieldName,
252
253
  d as getSemaphorConnectionCapabilities,
253
- L as isAnalyticsCatalogDateField,
254
- D as isAnalyticsCatalogDimensionField,
255
- x as isAnalyticsCatalogMetricField,
256
- M as isAnalyticsDateLikeDataType,
257
- N as isAnalyticsMetricIdentifierField,
258
- w as isAnalyticsTechnicalIdentifierField,
259
- O as normalizeAnalyticsCatalogDataType,
260
- E as normalizeAnalyticsCatalogName,
254
+ q as isAnalyticsCatalogDateField,
255
+ F as isAnalyticsCatalogDimensionField,
256
+ _ as isAnalyticsCatalogMetricField,
257
+ A as isAnalyticsDateLikeDataType,
258
+ R as isAnalyticsMetricIdentifierField,
259
+ L as isAnalyticsTechnicalIdentifierField,
260
+ D as normalizeAnalyticsCatalogDataType,
261
+ x as normalizeAnalyticsCatalogName,
261
262
  c as normalizeSemaphorDialect,
262
263
  v as parseSemaphorIsoTimeWindowBoundary,
263
- h as preferSemaphorFieldRefMetadata,
264
- g as preferSemaphorSourceMetadata,
265
- y as semaphorFieldRefsMatch,
264
+ N as preferSemaphorFieldRefMetadata,
265
+ w as preferSemaphorSourceMetadata,
266
+ O as semaphorFieldRefsMatch,
266
267
  u as semaphorSourceHasRequiredCoordinates,
267
- k as semaphorSourceIdentityKey,
268
- C as semaphorSourcesReferToSameDataset,
269
- I as validateSemaphorAnalyticsIntent,
270
- S as validateSemaphorAnalyticsRecoveryPlan,
271
- T as validateSemaphorDashboardIntent,
272
- q as validateSemaphorOperationIntent
268
+ E as semaphorSourceIdentityKey,
269
+ P as semaphorSourcesReferToSameDataset,
270
+ h as validateSemaphorAnalyticsIntent,
271
+ g as validateSemaphorAnalyticsRecoveryPlan,
272
+ y as validateSemaphorDashboardIntent,
273
+ k as validateSemaphorOperationIntent
273
274
  };
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),m=require("react"),d=require("../chunks/switch-DYRgERrC.js"),A=require("../chunks/index-DRlMUglg.js");require("../chunks/index-BxM99sFL.js");const V=require("../chunks/palette-BMXS-AcI.js"),ge=require("../chunks/braces-DDHkbW1c.js");/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),m=require("react"),d=require("../chunks/switch-C0S63HAv.js"),A=require("../chunks/index-DRlMUglg.js");require("../chunks/index-BxM99sFL.js");const V=require("../chunks/palette-C1k347Tb.js"),ge=require("../chunks/braces-Cc86y9Ov.js");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,10 +1,10 @@
1
1
  import { jsxs as d, jsx as r, Fragment as ce } from "react/jsx-runtime";
2
2
  import m from "react";
3
- import { c as $, a as K, P as ge, b as be, B as C, d as fe, U as De, C as Ie, R as me, f as le, S as Je, X as je, J as se, e as Le, T as $e, K as _e, M, N as Ve, O as G, Q as Ue, V as Me, W as Ge, Y as We, L as E, Z as Q, _ as ee, $ as re, a0 as he, a1 as oe, a2 as ae, a3 as xe, a4 as ye, a5 as ke, a6 as ve, a7 as Ce, a8 as He } from "../chunks/switch-CP7SmEIZ.js";
3
+ import { c as $, a as K, P as ge, b as be, B as C, d as fe, U as De, C as Ie, R as me, f as le, S as Je, X as je, J as se, e as Le, T as $e, K as _e, M, N as Ve, O as G, Q as Ue, V as Me, W as Ge, Y as We, L as E, Z as Q, _ as ee, $ as re, a0 as he, a1 as oe, a2 as ae, a3 as xe, a4 as ye, a5 as ke, a6 as ve, a7 as Ce, a8 as He } from "../chunks/switch-21kU-tcj.js";
4
4
  import { r as Ye, v as Xe, A as Ze, a as qe, p as Ke } from "../chunks/index-CJdxSyQq.js";
5
5
  import "../chunks/index-CuHybtft.js";
6
- import { P as W } from "../chunks/palette-DKecBucs.js";
7
- import { B as Qe } from "../chunks/braces-Ccvdip75.js";
6
+ import { P as W } from "../chunks/palette-DP6TXUD8.js";
7
+ import { B as Qe } from "../chunks/braces-CBMh5wmd.js";
8
8
  /**
9
9
  * @license lucide-react v0.453.0 - ISC
10
10
  *
@@ -1,4 +1,4 @@
1
- import { c as a } from "./switch-CP7SmEIZ.js";
1
+ import { c as a } from "./switch-21kU-tcj.js";
2
2
  /**
3
3
  * @license lucide-react v0.453.0 - ISC
4
4
  *
@@ -1,4 +1,4 @@
1
- "use strict";const e=require("./switch-DYRgERrC.js");/**
1
+ "use strict";const e=require("./switch-C0S63HAv.js");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- "use strict";const e=require("react/jsx-runtime"),l=require("react"),t=require("./index-D7U5s9Uk.js"),i=require("./switch-DYRgERrC.js");require("./index-BxM99sFL.js");const G=require("./chevrons-up-down-B9fTSds9.js");function W(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 o=await fetch(`${f}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${m}`}});if(!o.ok){const u=await o.json().catch(()=>({}));throw new Error(u.error||"Failed to fetch preferences")}const r=await o.json();S({tz:r.tz,weekStart:r.weekStart,source:r.source,isInherited:r.isInherited,userHasPrefs:r.userHasPrefs,inherited:r.inherited})}catch(o){const r=o instanceof Error?o.message:"Unknown error";c(r)}finally{C(!1)}}},[m,f,x]);l.useEffect(()=>{x&&p()},[x,p]);const T=l.useCallback(async o=>{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(o)});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 o=await fetch(`${f}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${m}`}});if(!o.ok){const u=await o.json().catch(()=>({}));throw new Error(u.error||"Failed to clear preferences")}const r=await o.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(o){const r=o instanceof Error?o.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 _(){try{const n=Intl;if(n.supportedValuesOf)return n.supportedValuesOf("timeZone")}catch{}return E.map(n=>n.value)}function q(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 V(n){const d=M.find(a=>a.value===n);return d?d.label:String(n)}function Z({open:n,onOpenChange:d}){var D,U,F;const{preferences:a,isLoading:x,isSaving:m,isClearing:f,updatePreferences:L,clearPreferences:C}=W({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(()=>_(),[]),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",o=a.inherited?V(a.inherited.weekStart):"Monday",r=q((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:i.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 ",o]})]})]}),e.jsxs("label",{htmlFor:"mode-custom",className:i.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:i.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(i.Label,{className:H,children:"Timezone"}),e.jsxs(i.Popover,{open:T,onOpenChange:w,modal:!0,children:[e.jsx(i.PopoverTrigger,{asChild:!0,children:e.jsxs(i.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(G.ChevronsUpDown,{className:"ml-2 h-3.5 w-3.5 shrink-0 opacity-50"})]})}),e.jsx(i.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(i.Check,{className:i.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(i.Check,{className:i.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(i.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:i.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(i.Button,{variant:"outline",size:"xs",onClick:$,disabled:I,children:"Cancel"}),e.jsx(i.Button,{size:"xs",onClick:u,disabled:B,children:I?e.jsxs(e.Fragment,{children:[e.jsx(i.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving…"]}):"Save"})]})]})})}exports.CalendarPreferencesDialog=Z;
1
+ "use strict";const e=require("react/jsx-runtime"),l=require("react"),t=require("./index-Alj8oDV1.js"),i=require("./switch-C0S63HAv.js");require("./index-BxM99sFL.js");const G=require("./chevrons-up-down-CUZL1zaU.js");function W(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 o=await fetch(`${f}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${m}`}});if(!o.ok){const u=await o.json().catch(()=>({}));throw new Error(u.error||"Failed to fetch preferences")}const r=await o.json();S({tz:r.tz,weekStart:r.weekStart,source:r.source,isInherited:r.isInherited,userHasPrefs:r.userHasPrefs,inherited:r.inherited})}catch(o){const r=o instanceof Error?o.message:"Unknown error";c(r)}finally{C(!1)}}},[m,f,x]);l.useEffect(()=>{x&&p()},[x,p]);const T=l.useCallback(async o=>{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(o)});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 o=await fetch(`${f}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${m}`}});if(!o.ok){const u=await o.json().catch(()=>({}));throw new Error(u.error||"Failed to clear preferences")}const r=await o.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(o){const r=o instanceof Error?o.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 _(){try{const n=Intl;if(n.supportedValuesOf)return n.supportedValuesOf("timeZone")}catch{}return E.map(n=>n.value)}function q(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 V(n){const d=M.find(a=>a.value===n);return d?d.label:String(n)}function Z({open:n,onOpenChange:d}){var D,U,F;const{preferences:a,isLoading:x,isSaving:m,isClearing:f,updatePreferences:L,clearPreferences:C}=W({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(()=>_(),[]),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",o=a.inherited?V(a.inherited.weekStart):"Monday",r=q((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:i.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 ",o]})]})]}),e.jsxs("label",{htmlFor:"mode-custom",className:i.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:i.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(i.Label,{className:H,children:"Timezone"}),e.jsxs(i.Popover,{open:T,onOpenChange:w,modal:!0,children:[e.jsx(i.PopoverTrigger,{asChild:!0,children:e.jsxs(i.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(G.ChevronsUpDown,{className:"ml-2 h-3.5 w-3.5 shrink-0 opacity-50"})]})}),e.jsx(i.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(i.Check,{className:i.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(i.Check,{className:i.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(i.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:i.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(i.Button,{variant:"outline",size:"xs",onClick:$,disabled:I,children:"Cancel"}),e.jsx(i.Button,{size:"xs",onClick:u,disabled:B,children:I?e.jsxs(e.Fragment,{children:[e.jsx(i.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving…"]}):"Save"})]})]})})}exports.CalendarPreferencesDialog=Z;
@@ -1,9 +1,9 @@
1
1
  import { jsx as r, jsxs as s, Fragment as X } from "react/jsx-runtime";
2
2
  import ee, { useState as h, useCallback as F, useEffect as ae, useMemo as H } from "react";
3
- import { u as re, c as te, d as se, e as ne, f as le, g as oe, R as W, h as O, C as ie, i as ce, j as de, k as ue, l as _, m as R, n as me, o as fe, p as N } from "./index-DhuiooCy.js";
4
- import { a as S, L as G, P as he, b as pe, B as j, d as ge, e as V, f as ve } from "./switch-CP7SmEIZ.js";
3
+ import { u as re, c as te, d as se, e as ne, f as le, g as oe, R as W, h as O, C as ie, i as ce, j as de, k as ue, l as _, m as R, n as me, o as fe, p as N } from "./index-DTSZ23bE.js";
4
+ import { a as S, L as G, P as he, b as pe, B as j, d as ge, e as V, f as ve } from "./switch-21kU-tcj.js";
5
5
  import "./index-CuHybtft.js";
6
- import { C as be } from "./chevrons-up-down-pV0i9ptS.js";
6
+ import { C as be } from "./chevrons-up-down-fg3WME_w.js";
7
7
  function we(n = {}) {
8
8
  var C, A, E, L;
9
9
  const { authToken: c, tokenProps: e } = re(), p = n.enabled ?? !0, d = (c == null ? void 0 : c.accessToken) ?? null, u = (e == null ? void 0 : e.apiServiceUrl) ?? null, [I, k] = h(!1), [y, b] = h(!1), [m, g] = h(!1), [T, o] = h(null), [v, w] = h(null), P = v || {
@@ -1,4 +1,4 @@
1
- "use strict";const e=require("./switch-DYRgERrC.js");/**
1
+ "use strict";const e=require("./switch-C0S63HAv.js");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import { c as o } from "./switch-CP7SmEIZ.js";
1
+ import { c as o } from "./switch-21kU-tcj.js";
2
2
  /**
3
3
  * @license lucide-react v0.453.0 - ISC
4
4
  *
@@ -1,9 +1,9 @@
1
1
  import { jsx as t, jsxs as s, Fragment as se } from "react/jsx-runtime";
2
- import { c as Ie, L as wn, a2 as io, B as ge, f as ne, G as ct, u as H, E as bt, aK as Fr, aa as ba, g as ze, e as Ke, H as xa, a as v, J as Fn, X as Ce, P as Re, b as tt, d as nt, aL as lo, aM as co, aI as ya, aN as va, a3 as Qe, a4 as Ye, a5 as Xe, a6 as Ze, a7 as he, V as uo, aO as Na, aP as wa, a0 as et, T as mo, K as ho, M as Pr, aQ as po } from "./switch-CP7SmEIZ.js";
3
- import { c as ut, d as mt, e as ht, f as pt, g as ft, bc as fo, o as Ca, ag as go, ah as bo, av as ka, bP as xo, p as fe, aw as Cn, y as yo, aN as Pn, aO as Mn, aQ as Bn, aR as je, aV as Sa, aI as Kt, bQ as vo, bR as No, b0 as On, b1 as Vn, b2 as $n, b3 as Un, b4 as _n, b5 as jn, b6 as zn, u as It, $ as ot, aa as Kn, a6 as Aa, a7 as Hn, a0 as Ea, a5 as wo, ac as Co, bK as ko, bS as So, aK as Ao, a8 as Mr, x as Vt, a2 as Eo, bT as Io, bU as Do, bV as To, bW as Lo, bX as Ro, bY as Fo, bZ as Po, b_ as Mo, b$ as Ia, c0 as Bo, c1 as Oo, c2 as Vo, c3 as $o, c4 as Uo, c5 as gt, c6 as _o, bJ as Da, ax as Ta, c7 as jo, c8 as zo, c9 as Ko, ca as Ho, cb as qo, cc as Wo, cd as Go, ce as La, cf as Jo, cg as Qo, ch as Ra, ci as Fa, cj as Pa, ck as Yo, cl as Xo, b9 as Ma, by as Zo, bv as ei, cm as ti, aW as ni, cn as Ba, co as ri, cp as ai, aX as Br, cq as si, cr as oi, cs as kn, ct as ii, cu as li, cv as Oa, cw as qn, cx as di, cy as ci, cz as ui, cA as Va, cB as Dt, cC as $a, az as Sn, b7 as Ua, cD as mi, cE as hi, ay as An, cF as pi, cG as _a, cH as fi, cI as gi, cJ as bi, cK as xi, cL as yi, cM as vi, cN as Ni, cO as wi } from "./index-DhuiooCy.js";
4
- import { V as Ci, E as Or, a as Vr, b as ki, c as Si, L as Ai, d as Ei, C as Ii, u as ja, e as za, f as Di, R as Ti, S as Li } from "./use-create-flow-overlay-state-p_i0aUhH.js";
2
+ import { c as Ie, L as wn, a2 as io, B as ge, f as ne, G as ct, u as H, E as bt, aK as Fr, aa as ba, g as ze, e as Ke, H as xa, a as v, J as Fn, X as Ce, P as Re, b as tt, d as nt, aL as lo, aM as co, aI as ya, aN as va, a3 as Qe, a4 as Ye, a5 as Xe, a6 as Ze, a7 as he, V as uo, aO as Na, aP as wa, a0 as et, T as mo, K as ho, M as Pr, aQ as po } from "./switch-21kU-tcj.js";
3
+ import { c as ut, d as mt, e as ht, f as pt, g as ft, bc as fo, o as Ca, ag as go, ah as bo, av as ka, bO as xo, p as fe, aw as Cn, y as yo, aN as Pn, aO as Mn, aQ as Bn, aR as je, aV as Sa, aI as Kt, bP as vo, bQ as No, b0 as On, b1 as Vn, b2 as $n, b3 as Un, b4 as _n, b5 as jn, b6 as zn, u as It, $ as ot, aa as Kn, a6 as Aa, a7 as Hn, a0 as Ea, a5 as wo, ac as Co, bJ as ko, bR as So, aK as Ao, a8 as Mr, x as Vt, a2 as Eo, bS as Io, bT as Do, bU as To, bV as Lo, bW as Ro, bX as Fo, bY as Po, bZ as Mo, b_ as Ia, b$ as Bo, c0 as Oo, c1 as Vo, c2 as $o, c3 as Uo, c4 as gt, c5 as _o, bI as Da, ax as Ta, c6 as jo, c7 as zo, c8 as Ko, c9 as Ho, ca as qo, cb as Wo, cc as Go, cd as La, ce as Jo, cf as Qo, cg as Ra, ch as Fa, ci as Pa, cj as Yo, ck as Xo, b9 as Ma, by as Zo, bv as ei, cl as ti, aW as ni, cm as Ba, cn as ri, co as ai, aX as Br, cp as si, cq as oi, cr as kn, cs as ii, ct as li, cu as Oa, cv as qn, cw as di, cx as ci, cy as ui, cz as Va, cA as Dt, cB as $a, az as Sn, b7 as Ua, cC as mi, cD as hi, ay as An, cE as pi, cF as _a, cG as fi, cH as gi, cI as bi, cJ as xi, cK as yi, cL as vi, cM as Ni, cN as wi } from "./index-DTSZ23bE.js";
4
+ import { V as Ci, E as Or, a as Vr, b as ki, c as Si, L as Ai, d as Ei, C as Ii, u as ja, e as za, f as Di, R as Ti, S as Li } from "./use-create-flow-overlay-state-gRSXj8dj.js";
5
5
  import Ri, { useState as A, useContext as Fi, useRef as Ee, useCallback as pe, useEffect as ue, useMemo as O } from "react";
6
- import { u as Ka } from "./use-visual-utils-PfpWtYcR.js";
6
+ import { u as Ka } from "./use-visual-utils-D5zrmYt8.js";
7
7
  import "./index-CuHybtft.js";
8
8
  import { l as $r } from "./date-formatter-CzcPZx39.js";
9
9
  import "./index-CJdxSyQq.js";
@@ -1,4 +1,4 @@
1
- "use strict";const e=require("react/jsx-runtime"),a=require("./switch-DYRgERrC.js"),l=require("./index-D7U5s9Uk.js"),le=require("./use-create-flow-overlay-state-DS5aPcKd.js"),h=require("react"),bn=require("./use-visual-utils-EazVs86Z.js");require("./index-BxM99sFL.js");const $s=require("./date-formatter-B4EBSe9C.js");require("./index-DRlMUglg.js");require("react-dom/client");require("react-dom");/**
1
+ "use strict";const e=require("react/jsx-runtime"),a=require("./switch-C0S63HAv.js"),l=require("./index-Alj8oDV1.js"),le=require("./use-create-flow-overlay-state-BMr_844V.js"),h=require("react"),bn=require("./use-visual-utils-7w01KGK7.js");require("./index-BxM99sFL.js");const $s=require("./date-formatter-B4EBSe9C.js");require("./index-DRlMUglg.js");require("react-dom/client");require("react-dom");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -0,0 +1,57 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./switch-C0S63HAv.js"),s=require("./index-Alj8oDV1.js");require("./index-BxM99sFL.js");const v=require("react");require("./index-DRlMUglg.js");require("react-dom/client");const Zt=require("react-dom"),O=require("./dashboard-briefing-launcher-DjzTWk1f.js"),ht=require("./index-D7KJindZ.js"),es=require("./calendar-preferences-dialog-C2vX2dga.js"),ts=require("./use-debounced-dirty-check-XHSwAefL.js"),Re=require("./normalize-dashboard-for-dirty-check-BXRUMVb2.js"),ss=require("./palette-C1k347Tb.js"),rs=require("./braces-Cc86y9Ov.js");function ns(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(a,r,n.get?n:{enumerable:!0,get:()=>t[r]})}}return a.default=t,Object.freeze(a)}const E=ns(v);/**
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 as=i.createLucideIcon("Glasses",[["circle",{cx:"6",cy:"15",r:"4",key:"vux9w4"}],["circle",{cx:"18",cy:"15",r:"4",key:"18o8ve"}],["path",{d:"M14 15a2 2 0 0 0-2-2 2 2 0 0 0-2 2",key:"1ag4bs"}],["path",{d:"M2.5 13 5 7c.7-1.3 1.4-2 3-2",key:"1hm1gs"}],["path",{d:"M21.5 13 19 7c-.7-1.3-1.5-2-3-2",key:"1r31ai"}]]);/**
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 os=i.createLucideIcon("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/**
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 is=i.createLucideIcon("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
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 cs=i.createLucideIcon("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
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 ds=i.createLucideIcon("ShieldX",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/**
27
+ * @license lucide-react v0.453.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const ls=i.createLucideIcon("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/**
32
+ * @license lucide-react v0.453.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const us=i.createLucideIcon("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/**
37
+ * @license lucide-react v0.453.0 - ISC
38
+ *
39
+ * This source code is licensed under the ISC license.
40
+ * See the LICENSE file in the root directory of this source tree.
41
+ */const xt=i.createLucideIcon("UserRound",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]);var Te={exports:{}},_e={};/**
42
+ * @license React
43
+ * use-sync-external-store-shim.production.js
44
+ *
45
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
46
+ *
47
+ * This source code is licensed under the MIT license found in the
48
+ * LICENSE file in the root directory of this source tree.
49
+ */var dt;function ms(){if(dt)return _e;dt=1;var t=v;function a(l,x){return l===x&&(l!==0||1/l===1/x)||l!==l&&x!==x}var r=typeof Object.is=="function"?Object.is:a,n=t.useState,o=t.useEffect,m=t.useLayoutEffect,f=t.useDebugValue;function u(l,x){var p=x(),g=n({inst:{value:p,getSnapshot:x}}),c=g[0].inst,S=g[1];return m(function(){c.value=p,c.getSnapshot=x,b(c)&&S({inst:c})},[l,p,x]),o(function(){return b(c)&&S({inst:c}),l(function(){b(c)&&S({inst:c})})},[l]),f(p),p}function b(l){var x=l.getSnapshot;l=l.value;try{var p=x();return!r(l,p)}catch{return!0}}function y(l,x){return x()}var h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?y:u;return _e.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:h,_e}var Ue={};/**
50
+ * @license React
51
+ * use-sync-external-store-shim.development.js
52
+ *
53
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
54
+ *
55
+ * This source code is licensed under the MIT license found in the
56
+ * LICENSE file in the root directory of this source tree.
57
+ */var lt;function ps(){return lt||(lt=1,process.env.NODE_ENV!=="production"&&function(){function t(p,g){return p===g&&(p!==0||1/p===1/g)||p!==p&&g!==g}function a(p,g){h||o.startTransition===void 0||(h=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var c=g();if(!l){var S=g();m(c,S)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),l=!0)}S=f({inst:{value:c,getSnapshot:g}});var w=S[0].inst,N=S[1];return b(function(){w.value=c,w.getSnapshot=g,r(w)&&N({inst:w})},[p,c,g]),u(function(){return r(w)&&N({inst:w}),p(function(){r(w)&&N({inst:w})})},[p]),y(c),c}function r(p){var g=p.getSnapshot;p=p.value;try{var c=g();return!m(p,c)}catch{return!0}}function n(p,g){return g()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=v,m=typeof Object.is=="function"?Object.is:t,f=o.useState,u=o.useEffect,b=o.useLayoutEffect,y=o.useDebugValue,h=!1,l=!1,x=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?n:a;Ue.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:x,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Ue}process.env.NODE_ENV==="production"?Te.exports=ms():Te.exports=ps();var hs=Te.exports;const De=["light","dark","system"];function xs(){const{theme:t,setTheme:a}=s.useTheme(),r=i.useDashboardStore(f=>f.actions.setDashboardTheme);function n(){const f=De.includes(t)?t:"system",u=De[(De.indexOf(f)+1)%De.length];a(u),r(u)}const o=t==="light"?ls:t==="dark"?cs:is,m=t==="light"?"Theme: light (click for dark)":t==="dark"?"Theme: dark (click for system)":"Theme: system (click for light)";return e.jsx(i.Button,{type:"button",variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground",onClick:n,"aria-label":m,title:m,children:e.jsx(o,{className:"h-3.5 w-3.5",strokeWidth:1.5})})}async function fs(t,a,r,n,o){if(!o)return null;const m=JSON.stringify(r),f=`${t}/v1/lens`;return await i.postRequest(f,o,{name:a,template:m,filterValues:n,operation:"create"})}async function Fe(t,a,r){if(!r)return null;const{id:n,template:o,filterValues:m,isDefault:f,shared:u}=a,b=`${t}/v1/lens`;return await i.postRequest(b,r,{lensId:n,template:o,filterValues:m,isDefault:f,shared:u,operation:"update"})}async function gs(t,a,r){if(!r)return null;const n=`${t}/v1/lens`;return await i.postRequest(n,r,{operation:"delete",lensId:a})}const bs="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function vs({open:t,onOpenChange:a}={}){const[r,n]=v.useState(""),[o,m]=v.useState(!1),f=i.useDashboardStore(D=>D.lenses),{setLenses:u,setSelectedLensId:b}=i.useDashboardActions(),[y,h]=v.useState(!1),[l,x]=v.useState(!1),p=t!==void 0,g=p?t:l,c=D=>{p||x(D),a==null||a(D)},S=i.useDashboardStore(D=>D.dashboard),w=i.useDashboardStore(D=>D.filterValues),{authToken:N,tokenProps:k}=s.useSemaphorContext();async function C(){h(!0);const D=await fs(k.apiServiceUrl,r,S,w,N==null?void 0:N.accessToken);D&&(u([...f||[],D]),b(D.id),c(!1)),h(!1)}return e.jsxs(s.Dialog,{open:g,onOpenChange:c,children:[p?null:e.jsx(s.DialogTrigger,{asChild:!0,children:e.jsxs(i.Button,{variant:"secondary",size:"xs",children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Lens"]})}),e.jsxs(s.DialogContent,{className:"rounded-control border-border/60 sm:max-w-[420px] sm:rounded-control",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{className:"text-[15px]",children:"Create lens"}),e.jsx(s.DialogDescription,{className:"text-[13px] leading-5",children:"Lenses are private by default and are only visible to you."})]}),e.jsxs("div",{className:"space-y-1.5 py-1",children:[e.jsx(i.Label,{htmlFor:"lens-name",className:bs,children:"Name"}),e.jsx(i.Input,{id:"lens-name",size:"xs",value:r,placeholder:"Monthly review, West region, …",onChange:D=>n(D.target.value)}),o&&e.jsx("p",{className:"text-[12px] text-destructive",children:"A lens with this name already exists. Pick a different one."})]}),e.jsxs(s.DialogFooter,{children:[e.jsx(i.Button,{variant:"outline",size:"xs",onClick:()=>c(!1),children:"Cancel"}),e.jsx(i.Button,{size:"xs",type:"submit",onClick:C,disabled:y||!r.trim(),children:y?"Creating…":"Create"})]})]})]})}function ys({includeLabel:t=!1}={}){const a=i.useDashboardStore(h=>h.lenses),r=i.useDashboardStore(h=>h.selectedLensId),{setLenses:n,setSelectedLensId:o}=i.useDashboardActions(),{authToken:m,tokenProps:f}=s.useSemaphorContext();async function u(h){o(h)}async function b(h){if(await gs(f.apiServiceUrl,h,m==null?void 0:m.accessToken)){const x=a==null?void 0:a.filter(p=>p.id!==h);n(x||[]),o("original")}}async function y(h){const l=a==null?void 0:a.map(g=>g.id===h.id?{...g,isDefault:!h.isDefault}:{...g,isDefault:!1});n(l||[]);const x={...h,isDefault:!h.isDefault};await Fe(f.apiServiceUrl,x,m==null?void 0:m.accessToken);const p=a==null?void 0:a.find(g=>g.isDefault);if(p&&p.id!==h.id){const g={...p,isDefault:!1};await Fe(f.apiServiceUrl,g,m==null?void 0:m.accessToken)}}return e.jsxs(e.Fragment,{children:[t?e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuLabel,{className:"px-3",children:"Lenses"}),e.jsx(s.DropdownMenuSeparator,{})]}):null,e.jsxs(s.DropdownMenuRadioGroup,{value:r,onValueChange:u,children:[e.jsx(s.DropdownMenuRadioItem,{value:"original",children:"Original"}),a==null?void 0:a.map(h=>e.jsxs(s.DropdownMenuRadioItem,{className:"group flex justify-between gap-2",value:h.id,children:[e.jsx("p",{children:h.name}),e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(s.House,{onClick:l=>{l.preventDefault(),y(h)},className:i.cn("size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",{invisible:!h.isDefault,"text-green-500":h.isDefault}),strokeWidth:1.5}),e.jsx(s.Cross2Icon,{onClick:l=>{l.preventDefault(),b(h.id)},className:"invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",strokeWidth:1.5})]})]},h.id))]})]})}function js(){const{displayPreferences:t,shouldShowElement:a}=s.useDisplayPreferences(),{currentUser:r,userContext:n}=s.useCurrentUserInfo(),o=v.useMemo(()=>s.getRoleBasedDisplayOverrides(r),[r]),m=v.useMemo(()=>u=>o&&o[u]!==void 0&&o[u]===!1?!1:a(u),[o,a,t]),f=v.useMemo(()=>{var u,b,y,h,l;return{canEdit:((u=n==null?void 0:n.permissions)==null?void 0:u.canEdit)??s.canUserEdit(r),canUseFilters:((b=n==null?void 0:n.permissions)==null?void 0:b.canEdit)??s.canUserUseFilters(r),canManageDashboards:((y=n==null?void 0:n.permissions)==null?void 0:y.canCreateDashboard)??s.canUserManageDashboards(r),canCreateDashboards:((h=n==null?void 0:n.permissions)==null?void 0:h.canCreateDashboard)??s.canUserCreateDashboards(r),canAccessVisuals:((l=n==null?void 0:n.permissions)==null?void 0:l.canEdit)??s.canUserAccessVisuals(r)}},[r,n]);return{displayPreferences:t,shouldShowElement:m,permissions:f,currentUser:r}}function Ss(t,a=[]){let r=[];function n(m,f){const u=E.createContext(f);u.displayName=m+"Context";const b=r.length;r=[...r,f];const y=l=>{var w;const{scope:x,children:p,...g}=l,c=((w=x==null?void 0:x[t])==null?void 0:w[b])||u,S=E.useMemo(()=>g,Object.values(g));return e.jsx(c.Provider,{value:S,children:p})};y.displayName=m+"Provider";function h(l,x){var c;const p=((c=x==null?void 0:x[t])==null?void 0:c[b])||u,g=E.useContext(p);if(g)return g;if(f!==void 0)return f;throw new Error(`\`${l}\` must be used within \`${m}\``)}return[y,h]}const o=()=>{const m=r.map(f=>E.createContext(f));return function(u){const b=(u==null?void 0:u[t])||m;return E.useMemo(()=>({[`__scope${t}`]:{...u,[t]:b}}),[u,b])}};return o.scopeName=t,[n,ws(o,...a)]}function ws(...t){const a=t[0];if(t.length===1)return a;const r=()=>{const n=t.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(m){const f=n.reduce((u,{useScope:b,scopeName:y})=>{const l=b(m)[`__scope${y}`];return{...u,...l}},{});return E.useMemo(()=>({[`__scope${a.scopeName}`]:f}),[f])}};return r.scopeName=a.scopeName,r}var Ds=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],qe=Ds.reduce((t,a)=>{const r=i.createSlot(`Primitive.${a}`),n=E.forwardRef((o,m)=>{const{asChild:f,...u}=o,b=f?r:a;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(b,{...u,ref:m})});return n.displayName=`Primitive.${a}`,{...t,[a]:n}},{});function Ns(){return hs.useSyncExternalStore(Cs,()=>!0,()=>!1)}function Cs(){return()=>{}}var $e="Avatar",[ks]=Ss($e),[Es,ft]=ks($e),gt=E.forwardRef((t,a)=>{const{__scopeAvatar:r,...n}=t,[o,m]=E.useState("idle");return e.jsx(Es,{scope:r,imageLoadingStatus:o,onImageLoadingStatusChange:m,children:e.jsx(qe.span,{...n,ref:a})})});gt.displayName=$e;var bt="AvatarImage",vt=E.forwardRef((t,a)=>{const{__scopeAvatar:r,src:n,onLoadingStatusChange:o=()=>{},...m}=t,f=ft(bt,r),u=Ls(n,m),b=i.useCallbackRef(y=>{o(y),f.onImageLoadingStatusChange(y)});return i.useLayoutEffect2(()=>{u!=="idle"&&b(u)},[u,b]),u==="loaded"?e.jsx(qe.img,{...m,ref:a,src:n}):null});vt.displayName=bt;var yt="AvatarFallback",jt=E.forwardRef((t,a)=>{const{__scopeAvatar:r,delayMs:n,...o}=t,m=ft(yt,r),[f,u]=E.useState(n===void 0);return E.useEffect(()=>{if(n!==void 0){const b=window.setTimeout(()=>u(!0),n);return()=>window.clearTimeout(b)}},[n]),f&&m.imageLoadingStatus!=="loaded"?e.jsx(qe.span,{...o,ref:a}):null});jt.displayName=yt;function ut(t,a){return t?a?(t.src!==a&&(t.src=a),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function Ls(t,{referrerPolicy:a,crossOrigin:r}){const n=Ns(),o=E.useRef(null),m=n?(o.current||(o.current=new window.Image),o.current):null,[f,u]=E.useState(()=>ut(m,t));return i.useLayoutEffect2(()=>{u(ut(m,t))},[m,t]),i.useLayoutEffect2(()=>{const b=l=>()=>{u(l)};if(!m)return;const y=b("loaded"),h=b("error");return m.addEventListener("load",y),m.addEventListener("error",h),a&&(m.referrerPolicy=a),typeof r=="string"&&(m.crossOrigin=r),()=>{m.removeEventListener("load",y),m.removeEventListener("error",h)}},[m,r,a]),f}var St=gt,wt=vt,Dt=jt;const Nt=E.forwardRef(({className:t,...a},r)=>e.jsx(St,{ref:r,className:i.cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...a}));Nt.displayName=St.displayName;const Ms=E.forwardRef(({className:t,...a},r)=>e.jsx(wt,{ref:r,className:i.cn("aspect-square h-full w-full",t),...a}));Ms.displayName=wt.displayName;const Ct=E.forwardRef(({className:t,...a},r)=>e.jsx(Dt,{ref:r,className:i.cn("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...a}));Ct.displayName=Dt.displayName;const Is=async(t,a,r)=>{const n=`${t}/management/v1/groups`;return await i.postRequestRegular(n,a,r)},As=async(t,a,r,n)=>{const o=`${t}/management/v1/groups/${r}`;return i.requestJsonRegular(o,a,"PATCH",n)},Ps=async(t,a,r)=>{const n=`${t}/management/v1/groups/${r}`;await i.requestJsonRegular(n,a,"DELETE")},Os=async(t,a,r,n)=>{const o=`${t}/management/v1/groups/${r}/members`;return await i.postRequestRegular(o,a,n)},Rs=async(t,a,r,n)=>{const o=`${t}/management/v1/groups/${r}/members`;await i.requestJsonRegular(o,a,"DELETE",n)};function _s(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:n=>Is(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",n),onSuccess:()=>{r.invalidateQueries({queryKey:["groups"]}),s.ue.success("Group created successfully")},onError:n=>{console.error("Failed to create group:",n),s.ue.error("Failed to create group",{description:i.getRequestErrorMessage(n,"Failed to create group")})}})}function Us(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:({groupId:n,data:o})=>As(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",n,o),onSuccess:(n,o)=>{r.invalidateQueries({queryKey:["group",o.groupId]}),r.invalidateQueries({queryKey:["groups"]}),s.ue.success("Group updated successfully")},onError:n=>{console.error("Failed to update group:",n),s.ue.error("Failed to update group",{description:i.getRequestErrorMessage(n,"Failed to update group")})}})}function Ts(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:n=>Ps(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",n),onSuccess:(n,o)=>{r.invalidateQueries({queryKey:["groups"]}),r.removeQueries({queryKey:["group",o]}),s.ue.success("Group deleted successfully")},onError:n=>{console.error("Failed to delete group:",n),s.ue.error("Failed to delete group",{description:i.getRequestErrorMessage(n,"Failed to delete group")})}})}function Fs(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:({groupId:n,data:o})=>Os(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",n,o),onSuccess:(n,o)=>{r.invalidateQueries({queryKey:["group",o.groupId]}),r.invalidateQueries({queryKey:["group-members",o.groupId]}),r.invalidateQueries({queryKey:["groups"]}),s.ue.success("Members added successfully")},onError:n=>{console.error("Failed to add group members:",n),s.ue.error("Failed to add members",{description:i.getRequestErrorMessage(n,"Failed to add members")})}})}function qs(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:({groupId:n,data:o})=>Rs(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",n,o),onSuccess:(n,o)=>{r.invalidateQueries({queryKey:["group",o.groupId]}),r.invalidateQueries({queryKey:["group-members",o.groupId]}),r.invalidateQueries({queryKey:["groups"]}),s.ue.success("Members removed successfully")},onError:n=>{console.error("Failed to remove group members:",n),s.ue.error("Failed to remove members",{description:i.getRequestErrorMessage(n,"Failed to remove members")})}})}const $s=[];function Bs({open:t,onOpenChange:a}){var N,k,C;const{tokenProps:r}=s.useSemaphorContext(),{currentUser:n}=s.useCurrentUserInfo(),o=(n==null?void 0:n.type)==="tenant",m=r==null?void 0:r.tenantId,{groups:f,isLoading:u,error:b,refetch:y}=s.useGroups({type:o?"TENANT_GROUP":"all",tenantId:o?m:void 0,includeMembers:!1}),h=b?kt(b,"Unable to load groups."):null,[l,x]=v.useState({kind:"list"}),[p,g]=v.useState(null),c=Ts();v.useEffect(()=>{t||(x({kind:"list"}),g(null))},[t]);const S=l.kind==="members"&&f.find(D=>D.id===l.groupId)||null,w=async()=>{if(p)try{await c.mutateAsync(p.id),g(null),x({kind:"list"}),y()}catch{}};return e.jsx(s.Dialog,{open:t,onOpenChange:a,children:e.jsxs(s.DialogContent,{className:"flex max-h-[640px] w-[720px] max-w-[92vw] flex-col gap-0 overflow-hidden p-0",children:[l.kind==="list"?e.jsxs("div",{className:"shrink-0 border-b border-border px-5 pt-4 pb-3.5",children:[e.jsx(s.DialogTitle,{className:"text-[15px] font-semibold tracking-tight",children:"Group management"}),e.jsx(s.DialogDescription,{className:"mt-1 text-[12px] leading-[1.5] text-muted-foreground",children:"Organize people into groups for shared access."})]}):l.kind==="create"?e.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-5",children:[e.jsx("button",{type:"button",onClick:()=>x({kind:"list"}),"aria-label":"Back",className:"-ml-1 flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:e.jsx(s.ArrowLeft,{className:"h-3.5 w-3.5"})}),e.jsx(s.DialogTitle,{className:"truncate text-[13px] font-medium",children:"New group"}),e.jsx(s.DialogDescription,{className:"sr-only",children:"Create a new group to organize members."})]}):null,l.kind==="list"&&e.jsx(Gs,{groups:f,isLoading:u,errorMessage:h,onRetry:()=>y(),currentUserId:n==null?void 0:n.id,onOpenGroup:D=>x({kind:"members",groupId:D}),onCreate:()=>x({kind:"create"}),onDeleteRequest:D=>g(D)}),l.kind==="members"&&S&&e.jsx(Vs,{group:S,isTenantViewer:o,canEdit:((N=S.permissions)==null?void 0:N.canEdit)??S.createdBy===(n==null?void 0:n.id),canDelete:((k=S.permissions)==null?void 0:k.canDelete)??S.createdBy===(n==null?void 0:n.id),canManageMembers:((C=S.permissions)==null?void 0:C.canManageMembers)??S.createdBy===(n==null?void 0:n.id),onBack:()=>x({kind:"list"}),onMembersChanged:y,onUpdated:y,onRequestDelete:()=>g(S)},S.id),l.kind==="create"&&e.jsx(Ks,{isTenantUser:o,tenantId:m,onCancel:()=>x({kind:"list"}),onCreated:D=>{y(),x({kind:"members",groupId:D})}}),p&&e.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border bg-muted/40 px-5 py-2.5",children:[e.jsxs("div",{className:"min-w-0 text-[12px] text-foreground",children:["Delete ",e.jsx("span",{className:"font-medium",children:p.name}),"?",e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Members lose any access granted via this group."})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>g(null),disabled:c.isPending,className:"h-7 rounded-[5px] px-2.5 text-[12px] font-medium text-foreground/80 hover:bg-background",children:"Cancel"}),e.jsxs("button",{type:"button",onClick:w,disabled:c.isPending,className:"inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-rose-600 px-2.5 text-[12px] font-medium text-white hover:bg-rose-700 disabled:opacity-60",children:[c.isPending?e.jsx(i.LoaderCircle,{className:"h-3 w-3 animate-spin"}):e.jsx(s.Trash2,{className:"h-3 w-3"}),"Delete group"]})]})]})]})})}function Gs({groups:t,isLoading:a,errorMessage:r,onRetry:n,currentUserId:o,onOpenGroup:m,onCreate:f,onDeleteRequest:u}){const[b,y]=v.useState(""),h=v.useMemo(()=>t.filter(l=>!b.trim()||l.name.toLowerCase().includes(b.toLowerCase())||(l.description||"").toLowerCase().includes(b.toLowerCase())),[t,b]);return e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-5 py-2.5",children:[e.jsxs("div",{className:"flex flex-1 items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40",children:[e.jsx(s.Search,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("input",{value:b,onChange:l=>y(l.target.value),placeholder:"Search groups…",className:"h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none"}),b&&e.jsx("button",{type:"button",onClick:()=>y(""),className:"flex h-4 w-4 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:e.jsx(i.X,{className:"h-2.5 w-2.5"})})]}),e.jsxs("button",{type:"button",onClick:f,className:"inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90",children:[e.jsx(s.Plus,{className:"h-3 w-3"}),"New group"]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:a?e.jsx("div",{className:"space-y-px p-3",children:[1,2,3].map(l=>e.jsx("div",{className:"h-12 animate-pulse rounded-[4px] bg-muted/60"},l))}):r?e.jsx(Et,{title:"Can't load groups",message:r,onRetry:n}):h.length===0&&t.length===0?e.jsx(Hs,{onCreate:f}):h.length===0?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-1 py-10 text-center",children:[e.jsxs("div",{className:"text-[12px] text-foreground",children:['No groups match "',b,'"']}),e.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Try a different search."})]}):h.map(l=>{var x;return e.jsx(zs,{group:l,canDelete:((x=l.permissions)==null?void 0:x.canDelete)??l.createdBy===o,onClick:()=>m(l.id),onDelete:()=>u(l)},l.id)})})]})}function zs({group:t,canDelete:a,onClick:r,onDelete:n}){let o="";try{o=ht.format(new Date(t.createdAt),"MMM d, yyyy")}catch{o=""}return e.jsxs("button",{type:"button",onClick:r,className:"group flex w-full items-center gap-3 border-b border-border/60 px-5 py-2.5 text-left hover:bg-accent/40",children:[e.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-[4px] border border-border bg-background text-muted-foreground",children:e.jsx(O.UsersRound,{className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[13px] font-medium text-foreground",children:t.name}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(xt,{className:"h-2.5 w-2.5"}),t.memberCount," member",t.memberCount===1?"":"s"]}),o&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-border",children:"·"}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(s.Calendar,{className:"h-2.5 w-2.5"}),o]})]}),t.description&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-border",children:"·"}),e.jsx("span",{className:"truncate text-muted-foreground",children:t.description})]})]})]}),e.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100",children:[a&&e.jsx("span",{role:"button",tabIndex:0,onClick:m=>{m.stopPropagation(),n()},onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),m.stopPropagation(),n())},"aria-label":`Delete ${t.name}`,className:"flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:e.jsx(s.Trash2,{className:"h-3 w-3"})}),e.jsx(s.ChevronRight,{className:"h-3.5 w-3.5 text-muted-foreground"})]})]})}function Hs({onCreate:t}){return e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-full border border-border bg-muted/40 text-muted-foreground",children:e.jsx(s.Users,{className:"h-4 w-4"})}),e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:"No groups yet"}),e.jsx("div",{className:"max-w-[320px] text-[11.5px] leading-[1.55] text-muted-foreground",children:"Groups let you grant shared access to dashboards. Create one and add members."}),e.jsxs("button",{type:"button",onClick:t,className:"mt-1 inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90",children:[e.jsx(s.Plus,{className:"h-3 w-3"}),"New group"]})]})}function Vs({group:t,isTenantViewer:a,canEdit:r,canDelete:n,canManageMembers:o,onBack:m,onMembersChanged:f,onUpdated:u,onRequestDelete:b}){const{data:y,isLoading:h,error:l,refetch:x}=s.useGroupMembers(t.id),p=(y==null?void 0:y.members)??$s,g=l?kt(l,"Unable to load members for this group."):null,c=t.type==="TENANT_GROUP"?"tenant":"organization",{users:S}=s.useUnifiedUsers({type:c,tenantId:t.tenantId||void 0,active:!0,limit:200}),w=v.useMemo(()=>new Set(p.map(j=>j.userId)),[p]),N=Fs(),k=qs(),C=Us(),[D,W]=v.useState(!1),[B,J]=v.useState(t.name),[re,G]=v.useState(!1),[z,H]=v.useState(t.description||""),[V,ne]=v.useState(""),[ae,oe]=v.useState(!1),ie=v.useMemo(()=>{const j=V.trim().toLowerCase();return S.filter(P=>!w.has(P.id)).filter(P=>!j||(P.name||"").toLowerCase().includes(j)||(P.email||"").toLowerCase().includes(j)).slice(0,50)},[S,w,V]),ce=async()=>{const j=B.trim();if(W(!1),j.length>=3&&j!==t.name)try{await C.mutateAsync({groupId:t.id,data:{name:j}}),u()}catch{}},U=async()=>{const j=z.trim();if(G(!1),j!==(t.description||""))try{await C.mutateAsync({groupId:t.id,data:{description:j}}),u()}catch{}},K=async j=>{if(o){ne(""),oe(!1);try{await N.mutateAsync({groupId:t.id,data:{userIds:[j.id],userType:c==="tenant"?"tenant":"org"}}),x(),f()}catch{}}},Q=async j=>{if(o)try{await k.mutateAsync({groupId:t.id,data:{userIds:[j]}}),x(),f()}catch{}};let T="";try{T=ht.format(new Date(t.createdAt),"MMM d, yyyy")}catch{T=""}return e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-5",children:[e.jsx("button",{type:"button",onClick:m,"aria-label":"Back",className:"-ml-1 flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:e.jsx(s.ArrowLeft,{className:"h-3.5 w-3.5"})}),D?e.jsx("input",{autoFocus:!0,value:B,onChange:j=>J(j.target.value),onBlur:ce,onKeyDown:j=>{j.key==="Enter"&&ce(),j.key==="Escape"&&(J(t.name),W(!1))},className:"h-6 min-w-0 flex-1 rounded-[3px] border border-border bg-background px-1.5 text-[13px] font-medium text-foreground focus:border-foreground/40 focus:outline-none"}):e.jsx("button",{type:"button",onClick:()=>{r&&(J(t.name),W(!0))},title:r?"Click to rename":t.name,disabled:!r,className:"truncate rounded-[3px] px-1 text-[13px] font-medium text-foreground enabled:hover:bg-accent disabled:cursor-default",children:t.name}),e.jsxs("span",{className:"ml-1 inline-flex shrink-0 items-center gap-1 text-[10.5px] text-muted-foreground",children:[e.jsx(xt,{className:"h-2.5 w-2.5"}),p.length," member",p.length===1?"":"s"]})]}),e.jsx("div",{className:"shrink-0 border-b border-border px-5 py-2.5",children:re?e.jsxs("div",{children:[e.jsx("textarea",{autoFocus:!0,rows:2,value:z,onChange:j=>H(j.target.value),maxLength:200,onKeyDown:j=>{j.key==="Escape"&&(H(t.description||""),G(!1)),j.key==="Enter"&&(j.metaKey||j.ctrlKey)&&U()},placeholder:"What is this group for?",className:"block w-full resize-none rounded-[5px] border border-border bg-background px-2 py-1.5 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"}),e.jsxs("div",{className:"mt-1.5 flex items-center justify-between",children:[e.jsxs("span",{className:"text-[10.5px] text-muted-foreground",children:[z.length,"/200 · Esc to cancel · ⌘↩ to save"]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>{H(t.description||""),G(!1)},className:"h-6 rounded-[5px] px-2 text-[11px] font-medium text-foreground/80 hover:bg-accent",children:"Cancel"}),e.jsx("button",{type:"button",onClick:U,className:"inline-flex h-6 items-center rounded-[5px] bg-foreground px-2 text-[11px] font-medium text-background hover:opacity-90",children:"Save"})]})]})]}):e.jsxs("button",{type:"button",onClick:()=>{r&&(H(t.description||""),G(!0))},disabled:!r,title:r?"Click to edit description":void 0,className:"block w-full rounded-[3px] px-1 py-0.5 text-left enabled:hover:bg-accent/40 disabled:cursor-default",children:[t.description?e.jsx("p",{className:"text-[12px] leading-[1.55] text-foreground/90",children:t.description}):e.jsx("p",{className:"text-[12px] leading-[1.55] text-muted-foreground",children:r?"Add a description…":"No description"}),e.jsxs("p",{className:"mt-1 text-[10.5px] text-muted-foreground",children:[T?`Created ${T}`:"Recently created",r?" · You can edit this group":""]})]})}),o&&e.jsx(Qs,{query:V,setQuery:ne,open:ae,setOpen:oe,candidates:ie,showKindChip:!a,onAdd:K,busy:N.isPending}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:h?e.jsx("div",{className:"space-y-px p-3",children:[1,2,3].map(j=>e.jsx("div",{className:"h-10 animate-pulse rounded-[4px] bg-muted/60"},j))}):g?e.jsx(Et,{title:"Can't load members",message:g,onRetry:()=>x()}):p.length===0?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-1 py-10 text-center",children:[e.jsx("div",{className:"text-[12px] text-foreground",children:"No members yet"}),e.jsx("div",{className:"text-[11px] text-muted-foreground",children:o?"Search above to add people to this group.":"This group does not have any members."})]}):p.map(j=>{var P,F,de,le,ue,L;return e.jsxs("div",{className:"group flex items-center gap-2 border-b border-border/60 px-5 py-2",children:[e.jsx(Lt,{name:((P=j.user)==null?void 0:P.name)||((F=j.user)==null?void 0:F.email)||"?"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[12.5px] font-medium text-foreground",children:((de=j.user)==null?void 0:de.name)||((le=j.user)==null?void 0:le.email)||"Unknown"}),((ue=j.user)==null?void 0:ue.email)&&j.user.name&&e.jsx("div",{className:"truncate text-[10.5px] text-muted-foreground",children:j.user.email})]}),!a&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.06em] text-muted-foreground",children:j.userType}),e.jsx("button",{type:"button",onClick:()=>Q(j.userId),disabled:!o||k.isPending,"aria-label":`Remove ${((L=j.user)==null?void 0:L.name)||"member"}`,className:"flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-foreground group-hover:opacity-100 disabled:opacity-30",children:e.jsx(i.X,{className:"h-3 w-3"})})]},j.id)})}),n&&e.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1.5 border-t border-border bg-muted/30 px-5 py-2.5",children:e.jsxs("button",{type:"button",onClick:b,className:"inline-flex h-7 items-center gap-1.5 rounded-[5px] border border-rose-200 bg-background px-2.5 text-[12px] font-medium text-rose-600 hover:bg-rose-50 dark:border-rose-900/60 dark:text-rose-400 dark:hover:bg-rose-950/30",children:[e.jsx(s.Trash2,{className:"h-3 w-3"}),"Delete group"]})})]})}function Ks({isTenantUser:t,tenantId:a,onCancel:r,onCreated:n}){const[o,m]=v.useState(""),[f,u]=v.useState(""),[b,y]=v.useState(null),h=_s(),l=o.trim().length>=3&&o.trim().length<=50,x=async()=>{if(!l)return;y(null);const p={name:o.trim(),description:f.trim()||void 0,type:t?"TENANT_GROUP":"ORG_GROUP",...t&&a?{tenantId:a}:{}};try{const g=await h.mutateAsync(p),c=g==null?void 0:g.id;c?n(c):r()}catch(g){y(g instanceof Error?g.message:"Failed to create group")}};return e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:[e.jsx(mt,{children:"Name"}),e.jsx("input",{autoFocus:!0,value:o,onChange:p=>m(p.target.value),placeholder:"Marketing leads, North America sales, …",maxLength:50,className:"mt-1 block h-7 w-full rounded-[5px] border border-border bg-background px-2 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"}),e.jsx("div",{className:"mt-1 text-[10.5px] text-muted-foreground",children:"3–50 characters."}),e.jsxs("div",{className:"mt-4",children:[e.jsx(mt,{children:"Description (optional)"}),e.jsx("textarea",{rows:2,value:f,onChange:p=>u(p.target.value),maxLength:200,placeholder:"What is this group for?",className:"mt-1 block w-full resize-none rounded-[5px] border border-border bg-background px-2 py-1.5 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"}),e.jsxs("div",{className:"mt-1 flex justify-end text-[10.5px] text-muted-foreground",children:[f.length,"/200"]})]}),b&&e.jsx("div",{className:"mt-3 rounded-[5px] border border-rose-200 bg-rose-50 px-2 py-1.5 text-[11.5px] text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/30 dark:text-rose-300",children:b})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-1.5 border-t border-border bg-muted/30 px-5 py-2.5",children:[e.jsx("button",{type:"button",onClick:r,disabled:h.isPending,className:"h-7 rounded-[5px] px-2.5 text-[12px] font-medium text-foreground/80 hover:bg-accent",children:"Cancel"}),e.jsx("button",{type:"button",onClick:x,disabled:!l||h.isPending,className:"inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60",children:h.isPending?e.jsxs(e.Fragment,{children:[e.jsx(i.LoaderCircle,{className:"h-3 w-3 animate-spin"}),"Creating…"]}):e.jsxs(e.Fragment,{children:[e.jsx(s.Plus,{className:"h-3 w-3"}),"Create group"]})})]})]})}function Qs({query:t,setQuery:a,open:r,setOpen:n,candidates:o,showKindChip:m,onAdd:f,busy:u}){const b=v.useRef(null),y=v.useRef(null),[h,l]=v.useState(null);v.useLayoutEffect(()=>{if(!r){l(null);return}const p=()=>{const g=b.current;if(!g)return;const c=g.getBoundingClientRect(),S=240,N=window.innerHeight-c.bottom<S+16&&c.top>S;l({left:c.left,top:N?c.top-6:c.bottom+6,width:c.width,above:N})};return p(),window.addEventListener("resize",p),window.addEventListener("scroll",p,!0),()=>{window.removeEventListener("resize",p),window.removeEventListener("scroll",p,!0)}},[r,o.length]),v.useEffect(()=>{if(!r)return;const p=g=>{var S,w;const c=g.target;(S=b.current)!=null&&S.contains(c)||(w=y.current)!=null&&w.contains(c)||n(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[r,n]);const x=r&&o.length>0&&h;return e.jsxs("div",{className:"shrink-0 border-b border-border px-5 py-2.5",children:[e.jsxs("div",{ref:b,className:"flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40",children:[e.jsx(us,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("input",{value:t,onChange:p=>{a(p.target.value),n(!0)},onFocus:()=>n(!0),placeholder:"Add a member by name or email…",disabled:u,className:"h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none disabled:cursor-not-allowed"})]}),x&&typeof document<"u"&&Zt.createPortal(e.jsx("div",{ref:y,style:{position:"fixed",left:h.left,top:h.top,width:h.width,transform:h.above?"translateY(-100%)":void 0},className:"z-[60] max-h-[240px] overflow-y-auto rounded-[5px] border border-border bg-background shadow-[0_8px_24px_-12px_rgba(0,0,0,0.18)]",children:o.map(p=>e.jsxs("button",{type:"button",onClick:()=>f(p),className:"flex w-full items-center gap-2 border-b border-border/60 px-2.5 py-2 text-left last:border-b-0 hover:bg-accent",children:[e.jsx(Lt,{name:p.name||p.email||"?"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[12px] font-medium text-foreground",children:p.name||p.email||"Unknown"}),p.email&&p.name&&e.jsx("div",{className:"truncate text-[10.5px] text-muted-foreground",children:p.email})]}),m&&p.type&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.06em] text-muted-foreground",children:p.type==="tenant"?"tenant":"org"})]},p.id))}),document.body)]})}function kt(t,a){if(!t)return a;if(t instanceof Error){const r=t.message||"",n=r.match(/\{[\s\S]*"error"\s*:\s*"([^"]+)"[\s\S]*\}/);return n?n[1]:r||a}return typeof t=="string"?t:a}function Et({title:t,message:a,onRetry:r}){return e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 px-6 py-10 text-center",children:[e.jsx("div",{className:"text-[12.5px] font-medium text-foreground",children:t}),e.jsx("div",{className:"max-w-[360px] text-[11.5px] leading-[1.55] text-muted-foreground",children:a}),r&&e.jsx("button",{type:"button",onClick:r,className:"mt-1 inline-flex h-7 items-center rounded-[5px] border border-border bg-background px-2.5 text-[11.5px] font-medium text-foreground hover:bg-accent",children:"Try again"})]})}function mt({children:t}){return e.jsx("label",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:t})}function Lt({name:t}){const a=t.split(" ").map(r=>r[0]).filter(Boolean).slice(0,2).join("").toUpperCase();return e.jsx(Nt,{className:"h-6 w-6 shrink-0",children:e.jsx(Ct,{className:"text-[9px] font-semibold",children:a||"?"})})}function te(t,a,r){var m,f;const n=(t.controls||[]).find(u=>u.id===r);if(n)return n.label;const o=(f=(m=i.findCardById(t,a))==null?void 0:m.controls)==null?void 0:f.find(u=>u.id===r);return(o==null?void 0:o.label)||r}function se(t,a){var r;return((r=i.findCardById(t,a))==null?void 0:r.title)||a}function Ws(t){const{errors:a,dashboard:r}=t;if(!r)return a;const n=new Map;for(const o of a){const m=o.match(/^Card '(.+)' binding for control '(.+)' maps to missing metric '(.+)'\.$/);if(m){const[,h,l]=m,x=`${h}:${l}:missing-metric`;n.has(x)||n.set(x,`"${se(r,h)}" has an outdated "${te(r,h,l)}" mapping. Some choices still point to metrics that are no longer available on this card. Open the card controls and choose replacements.`);continue}const f=o.match(/^Card '(.+)' binding for control '(.+)' maps to missing group-by field '(.+)'\.$/);if(f){const[,h,l]=f,x=`${h}:${l}:missing-group-by`;n.has(x)||n.set(x,`"${se(r,h)}" has an outdated "${te(r,h,l)}" mapping. Some choices still point to fields that are no longer available on this card. Open the card controls and choose replacements.`);continue}const u=o.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid metric target\.$/);if(u){const[,h,l]=u,x=`${h}:${l}:invalid-metric`;n.has(x)||n.set(x,`"${se(r,h)}" has an invalid "${te(r,h,l)}" metric mapping. Open the card controls and choose a valid metric for each option.`);continue}const b=o.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid group-by target\.$/);if(b){const[,h,l]=b,x=`${h}:${l}:invalid-group-by`;n.has(x)||n.set(x,`"${se(r,h)}" has an invalid "${te(r,h,l)}" field mapping. Open the card controls and choose a valid field for each option.`);continue}const y=o.match(/^Card '(.+)' binding for control '(.+)' requires at least one temporal group-by field\.$/);if(y){const[,h,l]=y,x=`${h}:${l}:missing-temporal-group-by`;n.has(x)||n.set(x,`"${se(r,h)}" can no longer use "${te(r,h,l)}" for time grain because the card does not currently group by a date field.`);continue}n.set(o,o)}return Array.from(n.values())}function Js(t,a){return typeof t=="boolean"?t:typeof a=="boolean"?a:!0}function pt(t,a){return{dashboard:s.cloneDeep(t),semanticExecutionPayload:s.cloneDeep(a)}}function Xs(){var tt,st,rt,nt,at,ot,it;O.useExportRecovery(),O.useExportPolling();const{authToken:t,tokenProps:a,id:r,showBriefings:n}=s.useSemaphorContext(),{isLocalDev:o}=s.useDashboardPreferences(),{openBrandStudioPreview:m}=s.useBrandStudioPreview(),{permissions:f}=js(),u=s.useHasDashboardId(),{isLoading:b}=s.useDashboardQuery(),y=i.useDashboardStore(d=>d.theme),h=i.useDashboardStore(d=>d.isDownloadingPdf),l=i.useDashboardStore(d=>d.dashboardAssistantDraftScopeKey),x=i.useDashboardStore(d=>d.lenses),p=i.useDashboardStore(d=>d.selectedLensId),g=x==null?void 0:x.find(d=>d.id===p),c=i.useDashboardStore(d=>d.dashboard),S=i.useDashboardStore(d=>d.selectedSheetId),w=(tt=c==null?void 0:c.sheets)==null?void 0:tt.find(d=>d.id===S),N=i.isDocumentSheet(w),k=N?(st=w==null?void 0:w.document)==null?void 0:st.page:void 0,C=i.useDashboardStore(d=>d.isDashboardEditing),{setDashboardTitle:D}=i.useDashboardStore(d=>d.actions),[W,B]=v.useState(!1),[J,re]=v.useState(!1),[G,z]=v.useState(!1),[H,V]=v.useState(!1),[ne,ae]=v.useState(!1),[oe,ie]=v.useState(!1),[ce,U]=v.useState(!1),[K,Q]=v.useState(null),[T,j]=v.useState([]),[P,F]=v.useState(!1),de=i.useDashboardStore(d=>d.isDashboardPanelOpen),le=i.useDashboardStore(d=>d.actions.setIsDashboardPanelOpen),ue=i.useDashboardStore(d=>d.filterValues),L=i.useDashboardStore(d=>d.isVisualEditing);i.useEditorStore(d=>d.card);const X=s.useManagementStore(d=>d.selectedDashboard),me=s.useManagementStore(d=>d.initialDashboard);s.useManagementStore(d=>d.selectedVisual),i.useDashboardStore(d=>d.selectedFrameId),i.useEditorStore(d=>d.frame);const pe=X?(nt=X==null?void 0:X.permissions)==null?void 0:nt.canEdit:(rt=me==null?void 0:me.permissions)==null?void 0:rt.canEdit,Be=i.useDashboardStore(d=>d.showDashboardJSON),Ne=i.useDashboardStore(d=>d.onSaveFunction),{setIsDashboardEditing:Ge,setShowDashboardJSON:ze}=i.useDashboardStore(d=>d.actions),{setInitialDashboard:He,clearSelectedDashboard:Ce}=s.useManagementStore(d=>d.actions),{resources:he}=s.useResourceManagement(s.ResourceType.DASHBOARD),{data:ke}=s.useUserPreferences(),Mt=((at=ke==null?void 0:ke.preference)==null?void 0:at.defaultDashboardId)||null,{mutate:It,isPending:At}=s.useDefaultDashboardMutation(),{currentUser:Pt}=s.useCurrentUserInfo(),Ot=s.canUserManageGroups(Pt),R=X||me,Ve=R?{id:R.id,title:(c==null?void 0:c.title)||R.title||"Dashboard"}:null,{handleAddNewFrame:Rt}=s.useAddNewFrame(),[Ee,Le]=v.useState(!1),[_t,Y]=v.useState(!1),[Me,xe]=v.useState("close"),Z=s.useUpdateResource(s.ResourceType.DASHBOARD),[A,fe]=v.useState(null),Ut=async(d,M)=>{if(!(c!=null&&c.id)){console.log("No dashboard ID found");return}console.log("Updating dashboard title:",{dashboardId:c.id,newTitle:d,previousTitle:M}),Z.mutate({resourceId:c.id,data:{title:d}},{onSuccess:()=>{console.log("Dashboard title updated successfully"),s.ue.success("Dashboard title updated")},onError:_=>{console.error("Failed to update dashboard title:",_),s.ue.error("Failed to update dashboard title"),D(M)}})};v.useEffect(()=>{if(he&&he.length>0){const d=c==null?void 0:c.id;if(d){const M=he.find(_=>_.id===d);M&&He(M)}}},[he,c==null?void 0:c.id,He]);const ee=a.orgUserId||a.tenantId,Ie=v.useMemo(()=>Ys({accessToken:t==null?void 0:t.accessToken,dashboardId:(c==null?void 0:c.id)||r||a.dashboard_id,selectedSheetId:N?S:void 0,pageSize:k==null?void 0:k.size,orientation:k==null?void 0:k.orientation,theme:y}),[t==null?void 0:t.accessToken,r,c==null?void 0:c.id,N,k==null?void 0:k.orientation,k==null?void 0:k.size,S,y,a.dashboard_id]),Ke=C&&!L&&ee&&pe,{setDashboard:Qe}=i.useDashboardStore(d=>d.actions),We=i.useDashboardStore(d=>d.semanticExecutionPayload),Tt=()=>{Ge(!0)},Ae=()=>{Ge(!1),ze(!1),fe(null)};v.useEffect(()=>{if(!C){A&&fe(null);return}A||!c||b||fe(pt(c,We))},[c,A,C,b,We]);const ge=(A==null?void 0:A.dashboard)??null,{isDirty:Je,isDirtyPending:Ft,resetDirty:be}=ts.useDebouncedDirtyCheck(c,ge,300,1e3,Re.serializeDashboardForDirtyCheck),Xe=v.useCallback(()=>ge?Re.serializeDashboardForDirtyCheck(c)!==Re.serializeDashboardForDirtyCheck(ge):!1,[c,ge]),Ye=Je||Ft,ve=Ee||Z.isPending,qt=()=>{Xe()?(xe("close"),Y(!0)):(Ae(),be())},$t=async()=>{await Pe({closeAfterSave:!0,navigateHomeAfterSave:Me==="home"})},Bt=()=>{A&&Qe(A.dashboard,{semanticExecutionPayload:A.semanticExecutionPayload}),Ae(),Me==="home"&&Ce(),xe("close"),Y(!1),be()},Gt=()=>{A&&(Qe(A.dashboard,{semanticExecutionPayload:A.semanticExecutionPayload}),be())},zt=()=>{if(C&&Xe()){xe("home"),Y(!0);return}Ce()};async function Pe(d){const M=i.useDashboardStore.getState().dashboard;if(!M)return;const _=(d==null?void 0:d.closeAfterSave)??P,Jt=(d==null?void 0:d.navigateHomeAfterSave)??!1;F(_),_&&Y(!1);const Xt=s.cloneDeep(M);U(!0),Q(null),j([]),Le(!0);const Yt={template:M};Z.mutate({resourceId:M.id,data:Yt},{onSuccess:I=>{var je,Se,ct;const $=(I==null?void 0:I.id)||((je=I==null?void 0:I.dashboard)==null?void 0:je.id)||((Se=I==null?void 0:I.resource)==null?void 0:Se.id)||((ct=I==null?void 0:I.template)==null?void 0:ct.id)||null;if(!M.id&&$){const Oe=i.useAIInteractionStore.getState(),we=Oe.pendingDashboardDraftMigration;(we==null?void 0:we.scopeKey)===l?Oe.actions.setPendingDashboardDraftMigrationExpectedDashboardId($):we&&Oe.actions.clearPendingDashboardDraftMigration()}Le(!1),s.ue.success("Dashboard saved!"),fe(pt(Xt,i.useDashboardStore.getState().semanticExecutionPayload)),U(!1),F(!1),_&&(Ae(),be(),Jt&&Ce()),xe("close")},onError:I=>{Le(!1),Q("Failed to save dashboard. Please try again.");const $=I.details,je=Array.isArray($==null?void 0:$.errors)?($.errors||[]).filter(Se=>typeof Se=="string"):[];j(Ws({errors:je,dashboard:M||void 0})),s.ue.error("Failed to save dashboard")}})}async function Ht(){if(B(!0),!p||!g)return;const d=i.useDashboardStore.getState().dashboard;if(!d){B(!1);return}const M=JSON.stringify(d),_={...g,template:M,filterValues:ue};await Fe(a.apiServiceUrl,_,t==null?void 0:t.accessToken),s.ue.success("Lens saved"),Ne==null||Ne(d),B(!1)}const Ze=(g==null?void 0:g.name)||c.title;Z.isPending&&console.log("Title during update:",{title:Ze,dashboardStateTitle:c.title,dashboardId:c==null?void 0:c.id,currentLensName:g==null?void 0:g.name});const et=a.orgUserId||a.tenantId&&a.endUserId&&a.endUserEmail,Vt=!!et&&!!(t!=null&&t.accessToken)&&!!(a!=null&&a.apiServiceUrl),Kt=u,q=(c==null?void 0:c.id)||null,Qt=Js((ot=a.config)==null?void 0:ot.showBriefings,n),ye=!!q&&Mt===q,Wt=()=>{q&&It({dashboardId:ye?null:q})};return e.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between gap-2 overflow-x-auto border-b px-4 py-2",role:"dashboard-controls",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[et&&e.jsxs(e.Fragment,{children:[e.jsx(s.IconButton,{"aria-label":"Manage Dashboards",tooltip:"Manage Dashboards",onClick:()=>{le(!de)},className:"h-7 w-7 px-0",buttonProps:{size:"xs"},children:e.jsx(os,{className:"h-3.5 w-3.5"})}),Kt&&!L&&e.jsx(s.IconButton,{"aria-label":"Dashboard Hub",tooltip:"Dashboard Hub",onClick:zt,className:"h-7 w-7 px-0",buttonProps:{size:"xs"},children:e.jsx(s.House,{className:"h-3.5 w-3.5"})})]}),!L&&u&&(b?e.jsx("div",{className:"h-4 w-28 animate-pulse rounded-md bg-muted/70","aria-label":"Loading dashboard title",role:"status",children:e.jsx("span",{className:"sr-only",children:"Loading dashboard title"})}):e.jsxs(e.Fragment,{children:[e.jsx(s.EditableText,{value:Ze||"Untitled Dashboard",onSave:d=>{console.log("EditableText onSave called:",{newTitle:d,canEditDashboard:pe,dashboardId:c==null?void 0:c.id});const M=(c==null?void 0:c.title)||"";D(d),Ut(d,M)},isEditable:pe&&!g,displayClassName:"text-[13px] font-medium",inputClassName:"text-[13px] font-medium",placeholder:"Dashboard Title",isPending:Z.isPending}),Vt&&q&&e.jsx(i.TooltipProvider,{children:e.jsxs(i.Tooltip,{children:[e.jsx(i.TooltipTrigger,{asChild:!0,children:e.jsx(i.Button,{variant:"ghost",size:"xs",onClick:Wt,disabled:At||!(t!=null&&t.accessToken)||!(a!=null&&a.apiServiceUrl),className:"w-7 px-0","aria-label":ye?"Remove as default dashboard":"Make this a default dashboard",children:e.jsx(s.Star,{className:i.cn("h-3.5 w-3.5 transition-colors",ye?"fill-foreground text-foreground":"text-muted-foreground hover:text-foreground")})})}),e.jsx(i.TooltipContent,{children:e.jsx("p",{children:ye?"Remove as default dashboard":"Make this a default dashboard"})})]})})]}))]}),e.jsxs("div",{className:"flex items-center gap-2",children:[L&&e.jsxs(e.Fragment,{children:[e.jsx(O.AdvancedModeToggle,{}),e.jsx(O.VisualEditingControls,{})]}),!L&&u&&((it=R==null?void 0:R.permissions)==null?void 0:it.canShare)&&e.jsxs(i.Button,{variant:"outline",size:"xs",onClick:()=>re(!0),children:[e.jsx(s.Share2,{className:"h-3.5 w-3.5"}),"Share"]}),!L&&!C&&u&&q&&Qt&&e.jsx(O.DashboardBriefingLauncher,{dashboardId:q,dashboardTitle:(c==null?void 0:c.title)||(R==null?void 0:R.title)}),!L&&C&&f.canUseFilters&&u&&e.jsx(O.DashboardFilterControlsLauncher,{}),C&&!L&&ee&&g&&o&&u&&e.jsxs(i.Button,{variant:"secondary",size:"xs",disabled:W,onClick:Ht,children:[e.jsx(i.Save,{className:"h-3.5 w-3.5"}),"Save Lens"]}),C&&!L&&u&&!N&&e.jsxs(i.Button,{variant:"outline",size:"xs",disabled:!C,onClick:()=>Rt(),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Visual"]}),!L&&!C&&pe&&u&&e.jsxs(i.Button,{size:"xs",onClick:Tt,children:[e.jsx(s.Pencil,{className:"h-3.5 w-3.5"}),"Edit"]}),Ke&&u&&Je&&e.jsxs(i.Button,{variant:"outline",size:"xs",onClick:Gt,disabled:ve,children:[e.jsx(O.Undo2,{className:"h-3.5 w-3.5"}),"Undo"]}),Ke&&u&&e.jsxs(i.Button,{size:"xs",className:i.cn(!Ye&&"opacity-60"),disabled:ve||!Ye,onClick:()=>Pe(),children:[ve?e.jsx(i.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(i.Save,{className:"h-3.5 w-3.5"}),ve?"Saving...":"Save"]}),C&&!L&&u&&e.jsxs(i.Button,{variant:"outline",size:"xs",onClick:qt,children:[e.jsx(s.Cross2Icon,{className:"h-3.5 w-3.5"}),"Close"]}),!L&&u&&e.jsx("div",{className:"ml-2",children:e.jsx(O.NotificationBell,{})}),!L&&o&&e.jsx(xs,{}),!L&&u&&e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.IconButton,{tooltip:"More Options",className:"w-7 px-0 text-muted-foreground hover:text-foreground",buttonProps:{size:"xs",variant:"ghost","aria-label":"More dashboard options"},children:e.jsx(s.EllipsisVertical,{className:"h-3.5 w-3.5"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"w-56 rounded-control border border-border/60 p-1 shadow-sm",children:[e.jsx(s.DropdownMenuLabel,{children:"Reports"}),e.jsxs(s.DropdownMenuItem,{disabled:h,onSelect:()=>ie(!0),children:[e.jsx(s.Download,{className:"h-3.5 w-3.5"}),"Export"]}),e.jsx(s.DropdownMenuSeparator,{}),Ot&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuLabel,{children:"Access"}),e.jsxs(s.DropdownMenuItem,{onClick:()=>z(!0),children:[e.jsx(s.Users,{className:"h-3.5 w-3.5"}),"Manage Groups"]}),e.jsx(s.DropdownMenuSeparator,{})]}),e.jsx(s.DropdownMenuLabel,{children:"Preferences"}),e.jsxs(s.DropdownMenuItem,{onClick:()=>V(!0),children:[e.jsx(s.Calendar,{className:"h-3.5 w-3.5"}),"Calendar Preferences"]}),o&&u&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuSeparator,{}),e.jsx(s.DropdownMenuLabel,{children:"Developer"}),e.jsxs(s.DropdownMenuItem,{onSelect:()=>{var d;t!=null&&t.accessToken&&((d=navigator==null?void 0:navigator.clipboard)!=null&&d.writeText?navigator.clipboard.writeText(t.accessToken).then(()=>s.ue.success("Token copied to clipboard")).catch(()=>s.ue.error("Unable to copy token")):s.ue.error("Clipboard not available"))},children:[e.jsx(s.Copy,{className:"h-3.5 w-3.5"}),"Copy token"]}),N&&e.jsxs(s.DropdownMenuItem,{disabled:!Ie,onSelect:()=>{var d;if(!Ie){s.ue.error("Open a document sheet with a token to copy the local PDF URL");return}(d=navigator==null?void 0:navigator.clipboard)!=null&&d.writeText?navigator.clipboard.writeText(Ie).then(()=>s.ue.success("Local document PDF URL copied to clipboard")).catch(()=>s.ue.error("Unable to copy local document PDF URL")):s.ue.error("Clipboard not available")},children:[e.jsx(s.Copy,{className:"h-3.5 w-3.5"}),"Copy local document PDF URL"]}),e.jsxs(s.DropdownMenuItem,{onSelect:()=>i.invalidateToken(a.apiServiceUrl),children:[e.jsx(ds,{className:"h-3.5 w-3.5"}),"Invalidate token"]}),e.jsxs(s.DropdownMenuItem,{onSelect:m,children:[e.jsx(ss.Palette,{className:"h-3.5 w-3.5"}),"Brand Studio"]}),C&&e.jsxs(s.DropdownMenuItem,{onSelect:()=>ze(!Be),children:[e.jsx(rs.Braces,{className:"h-3.5 w-3.5"}),Be?"Hide dashboard JSON":"Show dashboard JSON"]}),ee&&C&&e.jsxs(s.DropdownMenuItem,{onSelect:()=>ae(!0),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Add lens"]}),ee&&e.jsxs(s.DropdownMenuSub,{children:[e.jsxs(s.DropdownMenuSubTrigger,{children:[e.jsx(as,{className:"h-3.5 w-3.5"}),"Lenses"]}),e.jsx(s.DropdownMenuSubContent,{className:"w-60",children:e.jsx(ys,{})})]})]})]})]}),J&&Ve&&e.jsx(s.ShareDialog,{resource:Ve,resourceType:s.ResourceType.DASHBOARD,onClose:()=>re(!1)}),e.jsx(Bs,{open:G,onOpenChange:z}),e.jsx(es.CalendarPreferencesDialog,{open:H,onOpenChange:V}),o&&ee&&u&&e.jsx(vs,{open:ne,onOpenChange:ae}),u&&e.jsx(s.DownloadPdf,{open:oe,onOpenChange:ie}),e.jsx(s.AlertDialog,{open:ce,onOpenChange:d=>{!d&&Ee&&!K||(U(d),d||(Q(null),j([]),F(!1)))},children:e.jsxs(s.AlertDialogContent,{className:"max-w-sm",children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:K?"Save failed":"Saving dashboard"}),e.jsx(s.AlertDialogDescription,{className:"pt-2",children:K?"We could not save the dashboard. Please try again.":"Please wait while we save your changes."}),T.length>0&&e.jsxs("div",{className:"space-y-1 rounded-md border border-destructive/20 bg-destructive/5 p-3 text-left",children:[e.jsx("div",{className:"text-sm font-medium text-destructive",children:"What needs attention"}),e.jsx("ul",{className:"list-disc space-y-1 pl-4 text-xs text-muted-foreground",children:T.slice(0,5).map(d=>e.jsx("li",{children:d},d))})]})]}),e.jsx(s.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:justify-end",children:K?e.jsxs(e.Fragment,{children:[e.jsx(s.AlertDialogCancel,{onClick:()=>{U(!1),Q(null),j([]),F(!1)},className:"m-0",children:"Close"}),e.jsx(s.AlertDialogAction,{onClick:()=>Pe({closeAfterSave:P,navigateHomeAfterSave:Me==="home"}),className:"m-0",children:"Retry"})]}):e.jsxs(s.AlertDialogAction,{disabled:!0,className:"m-0 cursor-default",children:[e.jsx(i.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]})})]})}),e.jsx(O.UnsavedChangesAlert,{open:_t,onOpenChange:d=>{Y(d)},onSave:$t,onDiscard:Bt,isSaving:Ee,saveLabel:"Save",discardLabel:"Discard"})]})]})}function Ys({accessToken:t,dashboardId:a,selectedSheetId:r,pageSize:n,orientation:o,theme:m}){if(!t||!r)return null;const f=new URL("http://localhost:5173/print-document");f.searchParams.set("token",t),a&&f.searchParams.set("dashboardId",a),f.searchParams.set("selectedSheetId",r),m&&f.searchParams.set("theme",m);const u=new URL("http://127.0.0.1:3002/");return u.searchParams.set("pdfMode","document"),u.searchParams.set("pageSize",n||"letter"),u.searchParams.set("orientation",o||"portrait"),u.searchParams.set("url",f.toString()),u.toString()}exports.default=Xs;