yamchart 0.9.1 → 0.9.3

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 (94) hide show
  1. package/dist/{advisor-HVD4FJ56.js → advisor-SC64RTZO.js} +11 -11
  2. package/dist/agent-TZZHNDPK.js +8 -0
  3. package/dist/{chunk-4P5UHWYK.js → chunk-7CD6UQAV.js} +102 -2
  4. package/dist/chunk-7CD6UQAV.js.map +1 -0
  5. package/dist/chunk-7D4SUZUM.js +38 -0
  6. package/dist/{chunk-EHM6AMMA.js → chunk-EAQXUGP6.js} +65 -2
  7. package/dist/chunk-EAQXUGP6.js.map +1 -0
  8. package/dist/{chunk-LQANFANB.js → chunk-H4L3FNLS.js} +16 -6
  9. package/dist/chunk-H4L3FNLS.js.map +1 -0
  10. package/dist/{chunk-R22XWFKX.js → chunk-NXQ6ZO3V.js} +19 -4
  11. package/dist/chunk-NXQ6ZO3V.js.map +1 -0
  12. package/dist/{chunk-LQN2HNQZ.js → chunk-RM6MNDVF.js} +36 -5
  13. package/dist/chunk-RM6MNDVF.js.map +1 -0
  14. package/dist/{chunk-XDDBDJQL.js → chunk-RMIDEBHD.js} +4 -4
  15. package/dist/{chunk-CWAWATL4.js → chunk-S7YQXEKM.js} +159 -2
  16. package/dist/chunk-S7YQXEKM.js.map +1 -0
  17. package/dist/{chunk-ZA6AOQVZ.js → chunk-ZMJPRNOA.js} +2 -2
  18. package/dist/{compare-ZN6RUOOQ.js → compare-RQFCEZIK.js} +2 -2
  19. package/dist/{connection-utils-WVQGWJ7H.js → connection-utils-C4FQGBW6.js} +5 -5
  20. package/dist/{describe-UETE5XYO.js → describe-X75C2VDU.js} +7 -7
  21. package/dist/{dev-2WLFE37D.js → dev-KDNXUNME.js} +27978 -13314
  22. package/dist/dev-KDNXUNME.js.map +1 -0
  23. package/dist/{dist-VNX77VV5.js → dist-JMLAZUL7.js} +9 -3
  24. package/dist/{dist-7CRX2GIR.js → dist-MNXSMGV6.js} +3 -3
  25. package/dist/{dist-OAKQOG6H.js → dist-MX5K2ABB.js} +3 -3
  26. package/dist/{dist-JH7OL7U4.js → dist-NGQG7Z4G.js} +7 -3
  27. package/dist/{generate-KNER36CB.js → generate-B7FAWVIQ.js} +2 -2
  28. package/dist/index.js +33 -33
  29. package/dist/{init-GVBYCLJT.js → init-SECXKD5G.js} +2 -2
  30. package/dist/{lineage-T5NRHHZN.js → lineage-HYO4RKZT.js} +2 -2
  31. package/dist/public/assets/{EventManagement-CWrv68To.js → EventManagement-B7leMxfo.js} +1 -1
  32. package/dist/public/assets/{ExplorePage-2wblm-7t.js → ExplorePage-zI1OiYlH.js} +1 -1
  33. package/dist/public/assets/{LoginPage-J48L4t6I.js → LoginPage-Dyk2ILmo.js} +1 -1
  34. package/dist/public/assets/{PublicViewer-BrjKKW5m.js → PublicViewer-C2tNYBR2.js} +1 -1
  35. package/dist/public/assets/{SetupWizard-fRVi5bF4.js → SetupWizard-BzZSJlbt.js} +1 -1
  36. package/dist/public/assets/{ShareManagement-DUdL-Diq.js → ShareManagement-C7RIZRWe.js} +1 -1
  37. package/dist/public/assets/{UserManagement-BlwTHdH4.js → UserManagement-BD-lLbVH.js} +1 -1
  38. package/dist/public/assets/index-lklRbe2I.js +195 -0
  39. package/dist/public/assets/{index.es-BtmplkrJ.js → index.es-CLyC5-GY.js} +1 -1
  40. package/dist/public/assets/{jspdf.es.min-D0I_3frr.js → jspdf.es.min-CTZVk96E.js} +3 -3
  41. package/dist/public/index.html +1 -1
  42. package/dist/{query-E6NFXKV6.js → query-QNRDS74I.js} +5 -5
  43. package/dist/{reset-password-IZQTDTU7.js → reset-password-HDCLH7PZ.js} +3 -3
  44. package/dist/{rewrite-database-FDJIXKZ2.js → rewrite-database-BOA4QPUR.js} +2 -2
  45. package/dist/{sample-YLJC5H5X.js → sample-SKLHBZBU.js} +5 -5
  46. package/dist/{search-QDOSNM2R.js → search-4KMETZVX.js} +7 -7
  47. package/dist/{semantic-RAP3S5PQ.js → semantic-6WKELH5V.js} +2 -2
  48. package/dist/source-resolver-R7WBIL7M.js +18 -0
  49. package/dist/{sync-dbt-22QQKT3A.js → sync-dbt-72GVO75P.js} +2 -2
  50. package/dist/{sync-warehouse-5HEGZJHG.js → sync-warehouse-UWRNUXE7.js} +41 -15
  51. package/dist/sync-warehouse-UWRNUXE7.js.map +1 -0
  52. package/dist/{tables-6TODJHM5.js → tables-V65QUGHK.js} +7 -7
  53. package/dist/templates/default/docs/yamchart-reference.md +74 -9
  54. package/dist/{test-MXNBCQ3G.js → test-UE5OWG3E.js} +5 -5
  55. package/dist/{update-WMATDZTO.js → update-HWCJNQRP.js} +2 -2
  56. package/package.json +11 -5
  57. package/dist/agent-KWKPAYT2.js +0 -8
  58. package/dist/chunk-4P5UHWYK.js.map +0 -1
  59. package/dist/chunk-CWAWATL4.js.map +0 -1
  60. package/dist/chunk-DGUM43GV.js +0 -11
  61. package/dist/chunk-EHM6AMMA.js.map +0 -1
  62. package/dist/chunk-LQANFANB.js.map +0 -1
  63. package/dist/chunk-LQN2HNQZ.js.map +0 -1
  64. package/dist/chunk-R22XWFKX.js.map +0 -1
  65. package/dist/dev-2WLFE37D.js.map +0 -1
  66. package/dist/public/assets/index-CJ01RqZ2.js +0 -195
  67. package/dist/source-resolver-VAXDVSDF.js +0 -18
  68. package/dist/sync-warehouse-5HEGZJHG.js.map +0 -1
  69. /package/dist/{advisor-HVD4FJ56.js.map → advisor-SC64RTZO.js.map} +0 -0
  70. /package/dist/{agent-KWKPAYT2.js.map → agent-TZZHNDPK.js.map} +0 -0
  71. /package/dist/{chunk-DGUM43GV.js.map → chunk-7D4SUZUM.js.map} +0 -0
  72. /package/dist/{chunk-XDDBDJQL.js.map → chunk-RMIDEBHD.js.map} +0 -0
  73. /package/dist/{chunk-ZA6AOQVZ.js.map → chunk-ZMJPRNOA.js.map} +0 -0
  74. /package/dist/{compare-ZN6RUOOQ.js.map → compare-RQFCEZIK.js.map} +0 -0
  75. /package/dist/{connection-utils-WVQGWJ7H.js.map → connection-utils-C4FQGBW6.js.map} +0 -0
  76. /package/dist/{describe-UETE5XYO.js.map → describe-X75C2VDU.js.map} +0 -0
  77. /package/dist/{dist-JH7OL7U4.js.map → dist-JMLAZUL7.js.map} +0 -0
  78. /package/dist/{dist-7CRX2GIR.js.map → dist-MNXSMGV6.js.map} +0 -0
  79. /package/dist/{dist-OAKQOG6H.js.map → dist-MX5K2ABB.js.map} +0 -0
  80. /package/dist/{dist-VNX77VV5.js.map → dist-NGQG7Z4G.js.map} +0 -0
  81. /package/dist/{generate-KNER36CB.js.map → generate-B7FAWVIQ.js.map} +0 -0
  82. /package/dist/{init-GVBYCLJT.js.map → init-SECXKD5G.js.map} +0 -0
  83. /package/dist/{lineage-T5NRHHZN.js.map → lineage-HYO4RKZT.js.map} +0 -0
  84. /package/dist/{query-E6NFXKV6.js.map → query-QNRDS74I.js.map} +0 -0
  85. /package/dist/{reset-password-IZQTDTU7.js.map → reset-password-HDCLH7PZ.js.map} +0 -0
  86. /package/dist/{rewrite-database-FDJIXKZ2.js.map → rewrite-database-BOA4QPUR.js.map} +0 -0
  87. /package/dist/{sample-YLJC5H5X.js.map → sample-SKLHBZBU.js.map} +0 -0
  88. /package/dist/{search-QDOSNM2R.js.map → search-4KMETZVX.js.map} +0 -0
  89. /package/dist/{semantic-RAP3S5PQ.js.map → semantic-6WKELH5V.js.map} +0 -0
  90. /package/dist/{source-resolver-VAXDVSDF.js.map → source-resolver-R7WBIL7M.js.map} +0 -0
  91. /package/dist/{sync-dbt-22QQKT3A.js.map → sync-dbt-72GVO75P.js.map} +0 -0
  92. /package/dist/{tables-6TODJHM5.js.map → tables-V65QUGHK.js.map} +0 -0
  93. /package/dist/{test-MXNBCQ3G.js.map → test-UE5OWG3E.js.map} +0 -0
  94. /package/dist/{update-WMATDZTO.js.map → update-HWCJNQRP.js.map} +0 -0
@@ -1,4 +1,5 @@
1
1
  import {
2
+ BigQueryConnector,
2
3
  DATE_PRESETS,
3
4
  DuckDBConnector,
4
5
  MySQLConnector,
@@ -9,6 +10,7 @@ import {
9
10
  SnowflakeConnector,
10
11
  SqlList,
11
12
  VERSION,
13
+ bigQueryTypeToString,
12
14
  checkSchema,
13
15
  computePreviousPeriod,
14
16
  createTemplateContext,
@@ -23,6 +25,7 @@ import {
23
25
  isRelativeDateRange,
24
26
  parseModelMetadata,
25
27
  renderTemplate,
28
+ resolveBigQueryAuth,
26
29
  resolveDynamicDefault,
27
30
  resolveMySQLAuth,
28
31
  resolvePostgresAuth,
@@ -32,7 +35,7 @@ import {
32
35
  runModel,
33
36
  serializeDateValue,
34
37
  templateHasVariable
35
- } from "./chunk-CWAWATL4.js";
38
+ } from "./chunk-S7YQXEKM.js";
36
39
  import {
37
40
  SemanticModelBuilder,
38
41
  SemanticQueryCompiler,
@@ -42,8 +45,9 @@ import {
42
45
  inferAggregationType,
43
46
  validateSemanticQuery
44
47
  } from "./chunk-UND73EOB.js";
45
- import "./chunk-DGUM43GV.js";
48
+ import "./chunk-7D4SUZUM.js";
46
49
  export {
50
+ BigQueryConnector,
47
51
  DATE_PRESETS,
48
52
  DuckDBConnector,
49
53
  MySQLConnector,
@@ -57,6 +61,7 @@ export {
57
61
  SnowflakeConnector,
58
62
  SqlList,
59
63
  VERSION,
64
+ bigQueryTypeToString,
60
65
  checkSchema,
61
66
  classifyCatalogColumns,
62
67
  classifyField,
@@ -74,6 +79,7 @@ export {
74
79
  isRelativeDateRange,
75
80
  parseModelMetadata,
76
81
  renderTemplate,
82
+ resolveBigQueryAuth,
77
83
  resolveDynamicDefault,
78
84
  resolveMySQLAuth,
79
85
  resolvePostgresAuth,
@@ -85,4 +91,4 @@ export {
85
91
  templateHasVariable,
86
92
  validateSemanticQuery
87
93
  };
88
- //# sourceMappingURL=dist-VNX77VV5.js.map
94
+ //# sourceMappingURL=dist-JMLAZUL7.js.map
@@ -1,9 +1,9 @@
1
- import "./chunk-CWAWATL4.js";
1
+ import "./chunk-S7YQXEKM.js";
2
2
  import {
3
3
  SemanticModelBuilder,
4
4
  SemanticQueryCompiler
5
5
  } from "./chunk-UND73EOB.js";
6
- import "./chunk-DGUM43GV.js";
6
+ import "./chunk-7D4SUZUM.js";
7
7
 
8
8
  // ../../packages/advisor/dist/dbt/knowledge.js
9
9
  import { readFile } from "fs/promises";
@@ -787,4 +787,4 @@ export {
787
787
  updateSchemaYml,
788
788
  writeDbtModel
789
789
  };
790
- //# sourceMappingURL=dist-7CRX2GIR.js.map
790
+ //# sourceMappingURL=dist-MNXSMGV6.js.map
@@ -24,8 +24,8 @@ import {
24
24
  VERSION,
25
25
  deepMerge,
26
26
  resolveProjectConfig
27
- } from "./chunk-LQN2HNQZ.js";
28
- import "./chunk-DGUM43GV.js";
27
+ } from "./chunk-RM6MNDVF.js";
28
+ import "./chunk-7D4SUZUM.js";
29
29
  export {
30
30
  AgentDefinitionSchema,
31
31
  ChartSchema,
@@ -53,4 +53,4 @@ export {
53
53
  deepMerge,
54
54
  resolveProjectConfig
55
55
  };
56
- //# sourceMappingURL=dist-OAKQOG6H.js.map
56
+ //# sourceMappingURL=dist-MX5K2ABB.js.map
@@ -1,16 +1,20 @@
1
1
  import {
2
2
  AuthDatabase,
3
+ generateOpaqueToken,
3
4
  generateSessionToken,
4
5
  hashPassword,
6
+ hashToken,
5
7
  parseTtl,
6
8
  verifyPassword
7
- } from "./chunk-4P5UHWYK.js";
8
- import "./chunk-DGUM43GV.js";
9
+ } from "./chunk-7CD6UQAV.js";
10
+ import "./chunk-7D4SUZUM.js";
9
11
  export {
10
12
  AuthDatabase,
13
+ generateOpaqueToken,
11
14
  generateSessionToken,
12
15
  hashPassword,
16
+ hashToken,
13
17
  parseTtl,
14
18
  verifyPassword
15
19
  };
16
- //# sourceMappingURL=dist-JH7OL7U4.js.map
20
+ //# sourceMappingURL=dist-NGQG7Z4G.js.map
@@ -1,4 +1,4 @@
1
- import "./chunk-DGUM43GV.js";
1
+ import "./chunk-7D4SUZUM.js";
2
2
 
3
3
  // src/commands/generate.ts
4
4
  import { readFile } from "fs/promises";
@@ -314,4 +314,4 @@ async function generate(projectDir, options) {
314
314
  export {
315
315
  generate
316
316
  };
317
- //# sourceMappingURL=generate-KNER36CB.js.map
317
+ //# sourceMappingURL=generate-B7FAWVIQ.js.map
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  findProjectRoot,
7
7
  loadEnvFile,
8
8
  validateProject
9
- } from "./chunk-XDDBDJQL.js";
9
+ } from "./chunk-RMIDEBHD.js";
10
10
  import {
11
11
  detail,
12
12
  error,
@@ -17,10 +17,10 @@ import {
17
17
  success,
18
18
  warning
19
19
  } from "./chunk-HJVVHYVN.js";
20
- import "./chunk-LQN2HNQZ.js";
21
- import "./chunk-CWAWATL4.js";
20
+ import "./chunk-RM6MNDVF.js";
21
+ import "./chunk-S7YQXEKM.js";
22
22
  import "./chunk-UND73EOB.js";
23
- import "./chunk-DGUM43GV.js";
23
+ import "./chunk-7D4SUZUM.js";
24
24
 
25
25
  // src/index.ts
26
26
  import { Command } from "commander";
@@ -105,7 +105,7 @@ program.command("dev").description("Start development server with hot reload").a
105
105
  process.exit(2);
106
106
  }
107
107
  const globalOpts = program.opts();
108
- const { runDevServer } = await import("./dev-2WLFE37D.js");
108
+ const { runDevServer } = await import("./dev-KDNXUNME.js");
109
109
  await runDevServer(projectDir, {
110
110
  port: parseInt(options.port, 10),
111
111
  apiOnly: options.apiOnly ?? false,
@@ -115,7 +115,7 @@ program.command("dev").description("Start development server with hot reload").a
115
115
  });
116
116
  });
117
117
  program.command("init").description("Create a new yamchart project").argument("[directory]", "Target directory", ".").option("--example", "Create full example project with sample database").option("--empty", "Create only yamchart.yaml (no connections, models, or charts)").option("--force", "Overwrite existing files").action(async (directory, options) => {
118
- const { initProject } = await import("./init-GVBYCLJT.js");
118
+ const { initProject } = await import("./init-SECXKD5G.js");
119
119
  const targetDir = resolve(directory);
120
120
  const result = await initProject(targetDir, options);
121
121
  if (!result.success) {
@@ -134,7 +134,7 @@ program.command("init").description("Create a new yamchart project").argument("[
134
134
  info(`Run \`cd ${directory === "." ? basename(targetDir) : directory} && yamchart dev\` to start.`);
135
135
  });
136
136
  program.command("sync-dbt").description("Sync dbt project metadata into AI-readable catalog").option("-s, --source <type>", "Source type: local, github, dbt-cloud", "local").option("-p, --path <dir>", "Path to dbt project (for local source)").option("--repo <repo>", "GitHub repository (for github source)").option("--branch <branch>", "Git branch (for github source)", "main").option("-i, --include <patterns...>", "Include glob patterns").option("-e, --exclude <patterns...>", "Exclude glob patterns").option("-t, --tag <tags...>", "Filter by dbt tags").option("--refresh", "Re-sync using saved configuration").option("--target-database <database>", "Override database in ref() paths (e.g. switch from dev to prod)").action(async (options) => {
137
- const { syncDbt, loadSyncConfig } = await import("./sync-dbt-22QQKT3A.js");
137
+ const { syncDbt, loadSyncConfig } = await import("./sync-dbt-72GVO75P.js");
138
138
  const projectDir = await findProjectRoot(process.cwd());
139
139
  if (!projectDir) {
140
140
  error("yamchart.yaml not found");
@@ -179,8 +179,8 @@ program.command("sync-dbt").description("Sync dbt project metadata into AI-reada
179
179
  if (!options.targetDatabase) {
180
180
  try {
181
181
  const { readFile } = await import("fs/promises");
182
- const { resolveConnection } = await import("./connection-utils-WVQGWJ7H.js");
183
- const { detectDatabaseMismatch } = await import("./rewrite-database-FDJIXKZ2.js");
182
+ const { resolveConnection } = await import("./connection-utils-C4FQGBW6.js");
183
+ const { detectDatabaseMismatch } = await import("./rewrite-database-BOA4QPUR.js");
184
184
  const catalogJsonStr = await readFile(join(projectDir, ".yamchart", "catalog.json"), "utf-8");
185
185
  const catalogData = JSON.parse(catalogJsonStr);
186
186
  const connection = await resolveConnection(projectDir, void 0, program.opts().env);
@@ -199,7 +199,7 @@ program.command("sync-dbt").description("Sync dbt project metadata into AI-reada
199
199
  }
200
200
  });
201
201
  program.command("generate").description("Generate SQL model stubs from dbt catalog").argument("[model]", "Specific model to generate (optional)").option("--yolo", "Skip all prompts, use defaults for everything").action(async (model, options) => {
202
- const { generate } = await import("./generate-KNER36CB.js");
202
+ const { generate } = await import("./generate-B7FAWVIQ.js");
203
203
  const projectDir = await findProjectRoot(process.cwd());
204
204
  if (!projectDir) {
205
205
  error("yamchart.yaml not found");
@@ -233,7 +233,7 @@ program.command("test").description("Run model tests (@returns schema checks and
233
233
  }
234
234
  loadEnvFile(projectDir);
235
235
  try {
236
- const { testProject, formatTestOutput } = await import("./test-MXNBCQ3G.js");
236
+ const { testProject, formatTestOutput } = await import("./test-UE5OWG3E.js");
237
237
  const result = await testProject(projectDir, model, {
238
238
  connection: options.connection,
239
239
  json: options.json
@@ -256,7 +256,7 @@ program.command("test").description("Run model tests (@returns schema checks and
256
256
  }
257
257
  });
258
258
  program.command("update").description("Check for yamchart updates").action(async () => {
259
- const { runUpdate } = await import("./update-WMATDZTO.js");
259
+ const { runUpdate } = await import("./update-HWCJNQRP.js");
260
260
  await runUpdate(pkg.version);
261
261
  });
262
262
  program.command("reset-password").description("Reset a user password (requires auth to be enabled)").requiredOption("-e, --email <email>", "Email address of the user").action(async (options) => {
@@ -268,7 +268,7 @@ program.command("reset-password").description("Reset a user password (requires a
268
268
  process.exit(2);
269
269
  }
270
270
  loadEnvFile(projectDir);
271
- const { resetPassword } = await import("./reset-password-IZQTDTU7.js");
271
+ const { resetPassword } = await import("./reset-password-HDCLH7PZ.js");
272
272
  await resetPassword(projectDir, options.email);
273
273
  });
274
274
  program.command("tables").description("List tables and views in the connected database").option("-c, --connection <name>", "Connection to use (overrides default)").option("-s, --schema <name>", "Filter to schema").option("-d, --database <name>", "Filter to database (Snowflake/Databricks)").option("--json", "Output as JSON").option("--source <type>", "Data source: auto, catalog, model, or db (default: auto)").option("--compare", "Compare local metadata against live database").action(async (options) => {
@@ -282,8 +282,8 @@ program.command("tables").description("List tables and views in the connected da
282
282
  loadEnvFile(projectDir);
283
283
  try {
284
284
  if (options.compare) {
285
- const { resolveTablesSource } = await import("./source-resolver-VAXDVSDF.js");
286
- const { compareTables, formatCompareTables } = await import("./compare-ZN6RUOOQ.js");
285
+ const { resolveTablesSource } = await import("./source-resolver-R7WBIL7M.js");
286
+ const { compareTables, formatCompareTables } = await import("./compare-RQFCEZIK.js");
287
287
  let localResult;
288
288
  try {
289
289
  localResult = await resolveTablesSource(projectDir, "catalog", options.connection, {
@@ -313,7 +313,7 @@ program.command("tables").description("List tables and views in the connected da
313
313
  }
314
314
  return;
315
315
  }
316
- const { listTables } = await import("./tables-6TODJHM5.js");
316
+ const { listTables } = await import("./tables-V65QUGHK.js");
317
317
  const result = await listTables(projectDir, {
318
318
  ...options,
319
319
  source: options.source || "auto"
@@ -351,8 +351,8 @@ program.command("describe").description("Show columns and types for a table").ar
351
351
  loadEnvFile(projectDir);
352
352
  try {
353
353
  if (options.compare) {
354
- const { resolveDescribeSource } = await import("./source-resolver-VAXDVSDF.js");
355
- const { compareColumns, formatCompareColumns } = await import("./compare-ZN6RUOOQ.js");
354
+ const { resolveDescribeSource } = await import("./source-resolver-R7WBIL7M.js");
355
+ const { compareColumns, formatCompareColumns } = await import("./compare-RQFCEZIK.js");
356
356
  let localResult;
357
357
  try {
358
358
  localResult = await resolveDescribeSource(projectDir, table, "catalog", options.connection);
@@ -373,7 +373,7 @@ program.command("describe").description("Show columns and types for a table").ar
373
373
  }
374
374
  return;
375
375
  }
376
- const { describeTable } = await import("./describe-UETE5XYO.js");
376
+ const { describeTable } = await import("./describe-X75C2VDU.js");
377
377
  const result = await describeTable(projectDir, table, {
378
378
  ...options,
379
379
  source: options.source || "auto"
@@ -412,8 +412,8 @@ program.command("query").description("Execute SQL against a connection").argumen
412
412
  }
413
413
  loadEnvFile(projectDir);
414
414
  try {
415
- const { executeQuery } = await import("./query-E6NFXKV6.js");
416
- const { formatTable, formatJSON } = await import("./connection-utils-WVQGWJ7H.js");
415
+ const { executeQuery } = await import("./query-QNRDS74I.js");
416
+ const { formatTable, formatJSON } = await import("./connection-utils-C4FQGBW6.js");
417
417
  const limit = options.limit ? parseInt(options.limit, 10) : void 0;
418
418
  const result = await executeQuery(projectDir, sql, {
419
419
  connection: options.connection,
@@ -440,8 +440,8 @@ program.command("sample").description("Show sample rows from a table or dbt mode
440
440
  }
441
441
  loadEnvFile(projectDir);
442
442
  try {
443
- const { sampleTable } = await import("./sample-YLJC5H5X.js");
444
- const { formatTable, formatJSON } = await import("./connection-utils-WVQGWJ7H.js");
443
+ const { sampleTable } = await import("./sample-SKLHBZBU.js");
444
+ const { formatTable, formatJSON } = await import("./connection-utils-C4FQGBW6.js");
445
445
  const limit = options.limit ? parseInt(options.limit, 10) : void 0;
446
446
  const result = await sampleTable(projectDir, table, {
447
447
  connection: options.connection,
@@ -471,7 +471,7 @@ program.command("search").description("Search for tables and columns by keyword"
471
471
  }
472
472
  loadEnvFile(projectDir);
473
473
  try {
474
- const { searchDatabase } = await import("./search-QDOSNM2R.js");
474
+ const { searchDatabase } = await import("./search-4KMETZVX.js");
475
475
  const result = await searchDatabase(projectDir, keyword, {
476
476
  ...options,
477
477
  source: options.source || "auto"
@@ -525,7 +525,7 @@ catalogCmd.command("tables").description("List tables from cached catalog").opti
525
525
  process.exit(2);
526
526
  }
527
527
  try {
528
- const { listTables } = await import("./tables-6TODJHM5.js");
528
+ const { listTables } = await import("./tables-V65QUGHK.js");
529
529
  const result = await listTables(projectDir, {
530
530
  source: "catalog",
531
531
  schema: options.schema
@@ -567,7 +567,7 @@ catalogCmd.command("describe").description("Show cached columns and types for a
567
567
  process.exit(2);
568
568
  }
569
569
  try {
570
- const { describeTable } = await import("./describe-UETE5XYO.js");
570
+ const { describeTable } = await import("./describe-X75C2VDU.js");
571
571
  const result = await describeTable(projectDir, table, { source: "catalog" });
572
572
  if (options.json) {
573
573
  console.log(JSON.stringify(result.columns, null, 2));
@@ -609,7 +609,7 @@ catalogCmd.command("search").description("Search cached metadata for tables and
609
609
  process.exit(2);
610
610
  }
611
611
  try {
612
- const { searchDatabase } = await import("./search-QDOSNM2R.js");
612
+ const { searchDatabase } = await import("./search-4KMETZVX.js");
613
613
  const result = await searchDatabase(projectDir, keyword, { source: "catalog" });
614
614
  if (options.json) {
615
615
  console.log(JSON.stringify(result.results, null, 2));
@@ -734,7 +734,7 @@ program.command("sync-warehouse").description("Sync warehouse table metadata int
734
734
  }
735
735
  loadEnvFile(projectDir);
736
736
  try {
737
- const { runSyncWarehouse } = await import("./sync-warehouse-5HEGZJHG.js");
737
+ const { runSyncWarehouse } = await import("./sync-warehouse-UWRNUXE7.js");
738
738
  await runSyncWarehouse(projectDir, options);
739
739
  } catch (err) {
740
740
  error(err instanceof Error ? err.message : String(err));
@@ -751,7 +751,7 @@ program.command("lineage").description("Show upstream dependencies for a model")
751
751
  }
752
752
  loadEnvFile(projectDir);
753
753
  try {
754
- const { getLineage } = await import("./lineage-T5NRHHZN.js");
754
+ const { getLineage } = await import("./lineage-HYO4RKZT.js");
755
755
  const depth = options.depth ? parseInt(options.depth, 10) : void 0;
756
756
  const result = await getLineage(projectDir, model, {
757
757
  depth,
@@ -785,7 +785,7 @@ program.command("advisor").description("AI-powered dbt model advisor \u2014 sugg
785
785
  process.exit(2);
786
786
  }
787
787
  loadEnvFile(projectDir);
788
- const { runAdvisor } = await import("./advisor-HVD4FJ56.js");
788
+ const { runAdvisor } = await import("./advisor-SC64RTZO.js");
789
789
  await runAdvisor(projectDir, question, {
790
790
  top: options.top ? parseInt(options.top, 10) : 5,
791
791
  json: options.json,
@@ -806,7 +806,7 @@ var semanticCmd = program.command("semantic").description("Explore the semantic
806
806
  const { readFile } = await import("fs/promises");
807
807
  const catalogPath = join(projectDir, ".yamchart", "catalog.json");
808
808
  const catalogJson = JSON.parse(await readFile(catalogPath, "utf-8"));
809
- const { listSemanticEntities } = await import("./semantic-RAP3S5PQ.js");
809
+ const { listSemanticEntities } = await import("./semantic-6WKELH5V.js");
810
810
  const result = listSemanticEntities(catalogJson);
811
811
  if (options.json) {
812
812
  console.log(JSON.stringify(result.entities, null, 2));
@@ -853,7 +853,7 @@ semanticCmd.command("query").description("Run a structured query against the sem
853
853
  const { readFile } = await import("fs/promises");
854
854
  const catalogPath = join(projectDir, ".yamchart", "catalog.json");
855
855
  const catalogJson = JSON.parse(await readFile(catalogPath, "utf-8"));
856
- const { querySemanticEntity } = await import("./semantic-RAP3S5PQ.js");
856
+ const { querySemanticEntity } = await import("./semantic-6WKELH5V.js");
857
857
  const filters = (options.filter || []).map((f) => {
858
858
  const eqIdx = f.indexOf("=");
859
859
  if (eqIdx === -1) throw new Error(`Invalid filter format: "${f}". Use dimension=value`);
@@ -875,7 +875,7 @@ semanticCmd.command("query").description("Run a structured query against the sem
875
875
  console.log(result.sql);
876
876
  return;
877
877
  }
878
- const { resolveConnection, createConnector, formatTable, formatJSON } = await import("./connection-utils-WVQGWJ7H.js");
878
+ const { resolveConnection, createConnector, formatTable, formatJSON } = await import("./connection-utils-C4FQGBW6.js");
879
879
  const connection = await resolveConnection(projectDir, options.connection, program.opts().env);
880
880
  const connector = createConnector(connection, projectDir);
881
881
  const start = performance.now();
@@ -1,4 +1,4 @@
1
- import "./chunk-DGUM43GV.js";
1
+ import "./chunk-7D4SUZUM.js";
2
2
 
3
3
  // src/commands/init.ts
4
4
  import { mkdir, readFile, writeFile, access, readdir, copyFile } from "fs/promises";
@@ -131,4 +131,4 @@ async function copyDirectory(srcDir, destDir, files, projectName, basePath = "")
131
131
  export {
132
132
  initProject
133
133
  };
134
- //# sourceMappingURL=init-GVBYCLJT.js.map
134
+ //# sourceMappingURL=init-SECXKD5G.js.map
@@ -1,4 +1,4 @@
1
- import "./chunk-DGUM43GV.js";
1
+ import "./chunk-7D4SUZUM.js";
2
2
 
3
3
  // src/commands/lineage.ts
4
4
  import { readFile, readdir, access } from "fs/promises";
@@ -208,4 +208,4 @@ export {
208
208
  renderLineageTree,
209
209
  resolveDependencies
210
210
  };
211
- //# sourceMappingURL=lineage-T5NRHHZN.js.map
211
+ //# sourceMappingURL=lineage-HYO4RKZT.js.map
@@ -1,4 +1,4 @@
1
- import{t as xe,u as he,v as me,e as be,w as $,j as t,x as E,E as ce,M as fe,y as ve,z as je,I as Ce,a as S}from"./index-CJ01RqZ2.js";import{a as s}from"./echarts-DtOYsfLX.js";const ge=`
1
+ import{t as xe,u as he,v as me,e as be,w as $,j as t,x as E,E as ce,M as fe,y as ve,z as je,I as Ce,a as S}from"./index-lklRbe2I.js";import{a as s}from"./echarts-DtOYsfLX.js";const ge=`
2
2
  .rdp-root {
3
3
  --rdp-accent-color: var(--yc-color-primary, #2563eb);
4
4
  --rdp-accent-background-color: color-mix(in srgb, var(--yc-color-primary, #2563eb) 15%, transparent);
@@ -1 +1 @@
1
- import{j as e,i as k,J as E,K as B,v as M,N as W,O as $,a as D}from"./index-CJ01RqZ2.js";import{a}from"./echarts-DtOYsfLX.js";const T=["What data do I have?","Show me recent trends","What are the top items by revenue?","Compare this month to last month"];function P({summary:t,onPromptClick:i}){return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full px-6 py-12 gap-8",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",style:{color:"var(--yc-color-text)"},children:"Data Explorer"}),e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"Ask questions about your data in plain English"})]}),t&&(t.tableCount>0||t.modelCount>0)&&e.jsxs("div",{className:"rounded-xl px-5 py-4 w-full max-w-md flex flex-col gap-3",style:{background:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)"},children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide",style:{color:"var(--yc-color-text-secondary)"},children:"Connected data"}),e.jsxs("div",{className:"flex gap-6",children:[t.tableCount>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xl font-bold",style:{color:"var(--yc-color-text)"},children:t.tableCount}),e.jsx("span",{className:"text-xs ml-1",style:{color:"var(--yc-color-text-secondary)"},children:t.tableCount===1?"table":"tables"})]}),t.modelCount>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xl font-bold",style:{color:"var(--yc-color-text)"},children:t.modelCount}),e.jsx("span",{className:"text-xs ml-1",style:{color:"var(--yc-color-text-secondary)"},children:t.modelCount===1?"model":"models"})]})]}),t.connections.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.connections.map(l=>e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full",style:{background:"var(--yc-color-bg)",color:"var(--yc-color-text-secondary)",border:"1px solid var(--yc-color-border)"},children:l.name},l.name))})]}),e.jsx("div",{className:"flex flex-wrap gap-2 justify-center max-w-lg",children:T.map(l=>e.jsx("button",{onClick:()=>i(l),className:"text-sm px-3 py-1.5 rounded-full transition-opacity hover:opacity-80",style:{background:"var(--yc-color-surface)",color:"var(--yc-color-text)",border:"1px solid var(--yc-color-border)"},children:l},l))})]})}function R({summary:t,onTableClick:i}){const[l,x]=a.useState(new Set),[n,h]=a.useState(new Set),v=s=>{x(o=>{const c=new Set(o);return c.has(s)?c.delete(s):c.add(s),c})},f=s=>{h(o=>{const c=new Set(o);return c.has(s)?c.delete(s):c.add(s),c})},y=((t==null?void 0:t.connections)??[]).map(s=>({connection:s.name,tables:((t==null?void 0:t.tables)??[]).filter(o=>o.connection===s.name)})),u=(t==null?void 0:t.models)??[];return e.jsxs("div",{className:"w-64 flex-shrink-0 flex flex-col h-full overflow-y-auto",style:{borderRight:"1px solid var(--yc-color-border)",background:"var(--yc-color-surface)"},children:[e.jsx("div",{className:"px-3 py-2 flex items-center",style:{borderBottom:"1px solid var(--yc-color-border)"},children:e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",style:{color:"var(--yc-color-text-secondary)"},children:"Catalog"})}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-2",children:[y.map(s=>e.jsxs("div",{children:[e.jsxs("button",{className:"w-full flex items-center gap-1.5 px-3 py-1.5 hover:opacity-80 text-left",onClick:()=>v(s.connection),children:[e.jsx(g,{expanded:l.has(s.connection)}),e.jsx(I,{}),e.jsx("span",{className:"text-xs font-medium truncate",style:{color:"var(--yc-color-text)"},children:s.connection}),e.jsx("span",{className:"ml-auto text-xs",style:{color:"var(--yc-color-text-secondary)"},children:s.tables.length})]}),l.has(s.connection)&&e.jsx("div",{children:s.tables.map(o=>{const c=`${s.connection}:${o.name}`,m=n.has(c);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1 pl-6 pr-2 py-1 group",children:[e.jsxs("button",{className:"flex items-center gap-1 flex-1 min-w-0 hover:opacity-80 text-left",onClick:()=>f(c),children:[e.jsx(g,{expanded:m}),e.jsx(A,{}),e.jsx("span",{className:"text-xs truncate",style:{color:"var(--yc-color-text)"},children:o.schema?`${o.schema}.${o.name}`:o.name})]}),e.jsx("button",{className:"opacity-0 group-hover:opacity-100 text-xs px-1.5 py-0.5 rounded transition-opacity flex-shrink-0",style:{background:"var(--yc-color-primary)",color:"#fff"},onClick:()=>i(o.schema?`${o.schema}.${o.name}`:o.name),title:`Ask about ${o.name}`,children:"Ask"})]}),m&&o.columns.length>0&&e.jsx("div",{className:"pl-12 pb-1",children:o.columns.map(d=>e.jsxs("div",{className:"flex items-center gap-1.5 py-0.5 pr-2",children:[e.jsx("span",{className:"text-xs truncate",style:{color:"var(--yc-color-text)"},children:d.name}),d.type&&e.jsx("span",{className:"text-xs ml-auto flex-shrink-0",style:{color:"var(--yc-color-text-secondary)"},children:d.type})]},d.name))})]},c)})})]},s.connection)),u.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"px-3 py-1.5",style:{borderTop:"1px solid var(--yc-color-border)"},children:e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",style:{color:"var(--yc-color-text-secondary)"},children:"Models"})}),u.map(s=>e.jsxs("div",{className:"flex items-center gap-1.5 pl-3 pr-2 py-1.5 group",children:[e.jsx(O,{}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs truncate",style:{color:"var(--yc-color-text)"},children:s.name}),s.description&&e.jsx("p",{className:"text-xs truncate",style:{color:"var(--yc-color-text-secondary)"},children:s.description})]}),e.jsx("button",{className:"opacity-0 group-hover:opacity-100 text-xs px-1.5 py-0.5 rounded transition-opacity flex-shrink-0",style:{background:"var(--yc-color-primary)",color:"#fff"},onClick:()=>i(s.name),title:`Ask about ${s.name}`,children:"Ask"})]},s.name))]}),!t||y.length===0&&u.length===0?e.jsx("div",{className:"px-3 py-4 text-center",children:e.jsxs("p",{className:"text-xs",style:{color:"var(--yc-color-text-secondary)"},children:["No catalog data available. Run ",e.jsx("code",{className:"font-mono",children:"yamchart sync-warehouse"})," to populate."]})}):null]})]})}function g({expanded:t}){return e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--yc-color-text-secondary)",transform:t?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s",flexShrink:0},children:e.jsx("polyline",{points:"9 18 15 12 9 6"})})}function I(){return e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--yc-color-text-secondary)",flexShrink:0},children:[e.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),e.jsx("path",{d:"M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"}),e.jsx("path",{d:"M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"})]})}function A(){return e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--yc-color-text-secondary)",flexShrink:0},children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M3 9h18M3 15h18M9 3v18"})]})}function O(){return e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--yc-color-text-secondary)",flexShrink:0},children:[e.jsx("polyline",{points:"16 18 22 12 16 6"}),e.jsx("polyline",{points:"8 6 2 12 8 18"})]})}function q(){const t=k(n=>n.savedCharts),[i,l]=a.useState(!1),x=a.useRef(null);return a.useEffect(()=>{if(!i)return;function n(h){x.current&&!x.current.contains(h.target)&&l(!1)}return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[i]),t.length===0?null:e.jsxs("div",{className:"relative",ref:x,children:[e.jsxs("button",{onClick:()=>l(n=>!n),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-opacity hover:opacity-80",style:{background:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)",color:"var(--yc-color-text)"},children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"7"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"7"}),e.jsx("rect",{x:"14",y:"14",width:"7",height:"7"}),e.jsx("rect",{x:"3",y:"14",width:"7",height:"7"})]}),e.jsxs("span",{children:[t.length," saved ",t.length===1?"chart":"charts"]}),e.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 rounded-full text-xs font-bold text-white",style:{background:"var(--yc-color-primary)"},children:t.length})]}),i&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 w-56 rounded-lg shadow-lg z-50 py-1",style:{background:"var(--yc-color-bg)",border:"1px solid var(--yc-color-border)"},children:[e.jsx("p",{className:"px-3 py-1.5 text-xs font-semibold uppercase tracking-wide",style:{color:"var(--yc-color-text-secondary)"},children:"Saved charts"}),t.map(n=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--yc-color-primary)",flexShrink:0},children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}),e.jsx("span",{className:"text-sm truncate",style:{color:"var(--yc-color-text)"},children:n})]},n))]})]})}function V(){const t=E(),{messages:i,isStreaming:l,savedCharts:x,openPanel:n,setPanelMode:h,snapshotExploreHistory:v,clearConversation:f}=k(),[y,u]=a.useState(!0),[s,o]=a.useState(void 0),c=a.useRef(null);a.useEffect(()=>(h("explore"),n({type:"explore"}),()=>{h("panel")}),[h,n]),a.useEffect(()=>{var r;(r=c.current)==null||r.scrollIntoView({behavior:"smooth"})},[i]);const m=a.useCallback((r,p,S)=>{v(p),h("panel");const L=r==="chart"?"charts":"dashboards";window.location.hash=`/${L}/${encodeURIComponent(p)}${S?"?edit=true":""}`,n({type:r==="chart"?"chart":"dashboard",name:p})},[v,h,n]),{sendMessage:d}=B(m),{data:j}=M({queryKey:["catalog-summary"],queryFn:()=>D.getCatalogSummary(),staleTime:6e4,retry:!1}),b=a.useCallback(r=>{o(`Tell me about the ${r} table`)},[]),w=a.useCallback(r=>{d(r)},[d]),N=a.useCallback(r=>{d(r),o(void 0)},[d]),C=a.useCallback(()=>{const r=x.join(", ");d(`Build a dashboard using these charts: ${r}. Arrange them in a logical layout.`)},[x,d]);return t==="sm"?e.jsx("div",{className:"flex items-center justify-center h-screen px-6",style:{background:"var(--yc-color-bg)"},children:e.jsxs("div",{className:"text-center max-w-xs",children:[e.jsx("p",{className:"text-lg font-semibold mb-2",style:{color:"var(--yc-color-text)"},children:"Desktop required"}),e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"Data Explorer is designed for larger screens. Please open it on a desktop or laptop."})]})}):e.jsxs("div",{className:"flex h-screen overflow-hidden",style:{background:"var(--yc-color-bg)"},children:[y&&e.jsx(R,{summary:j??null,onTableClick:b}),e.jsxs("div",{className:"flex-1 flex flex-col h-full min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 flex-shrink-0",style:{borderBottom:"1px solid var(--yc-color-border)"},children:[e.jsxs("a",{href:"#/",className:"flex items-center gap-1.5 text-sm hover:opacity-80",style:{color:"var(--yc-color-text-secondary)"},onClick:r=>{r.preventDefault(),window.location.hash="/"},children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"15 18 9 12 15 6"})}),"Dashboards"]}),e.jsx("div",{className:"w-px h-4 mx-1",style:{background:"var(--yc-color-border)"}}),e.jsx("button",{className:"p-1.5 rounded hover:opacity-80",style:{color:"var(--yc-color-text-secondary)"},onClick:()=>u(r=>!r),title:y?"Hide catalog":"Show catalog",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M9 3v18"})]})}),e.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--yc-color-text)"},children:"Data Explorer"}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsx(q,{}),e.jsxs("button",{disabled:x.length===0||l,onClick:C,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-opacity disabled:opacity-40",style:{background:"var(--yc-color-primary)",color:"#fff"},children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"7"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"7"}),e.jsx("rect",{x:"14",y:"14",width:"7",height:"7"}),e.jsx("rect",{x:"3",y:"14",width:"7",height:"7"})]}),"Build Dashboard"]}),i.length>0&&e.jsx("button",{className:"p-1.5 rounded hover:opacity-80",style:{color:"var(--yc-color-text-secondary)"},onClick:f,title:"New conversation",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 20h9"}),e.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"})]})})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4 flex flex-col gap-3 min-h-0",children:i.length===0?e.jsx(P,{summary:j??null,onPromptClick:w}):e.jsxs(e.Fragment,{children:[i.map((r,p)=>e.jsx(W,{message:r,isStreaming:l&&p===i.length-1&&r.role==="assistant",onSendMessage:d},p)),e.jsx("div",{ref:c})]})}),e.jsx("div",{className:"px-6 py-3 flex-shrink-0",style:{borderTop:"1px solid var(--yc-color-border)"},children:e.jsx($,{onSend:N,placeholder:"Ask about your data...",disabled:l,initialValue:s})})]})]})}export{V as default};
1
+ import{j as e,i as k,J as E,K as B,v as M,N as W,O as $,a as D}from"./index-lklRbe2I.js";import{a}from"./echarts-DtOYsfLX.js";const T=["What data do I have?","Show me recent trends","What are the top items by revenue?","Compare this month to last month"];function P({summary:t,onPromptClick:i}){return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full px-6 py-12 gap-8",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",style:{color:"var(--yc-color-text)"},children:"Data Explorer"}),e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"Ask questions about your data in plain English"})]}),t&&(t.tableCount>0||t.modelCount>0)&&e.jsxs("div",{className:"rounded-xl px-5 py-4 w-full max-w-md flex flex-col gap-3",style:{background:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)"},children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide",style:{color:"var(--yc-color-text-secondary)"},children:"Connected data"}),e.jsxs("div",{className:"flex gap-6",children:[t.tableCount>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xl font-bold",style:{color:"var(--yc-color-text)"},children:t.tableCount}),e.jsx("span",{className:"text-xs ml-1",style:{color:"var(--yc-color-text-secondary)"},children:t.tableCount===1?"table":"tables"})]}),t.modelCount>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xl font-bold",style:{color:"var(--yc-color-text)"},children:t.modelCount}),e.jsx("span",{className:"text-xs ml-1",style:{color:"var(--yc-color-text-secondary)"},children:t.modelCount===1?"model":"models"})]})]}),t.connections.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.connections.map(l=>e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full",style:{background:"var(--yc-color-bg)",color:"var(--yc-color-text-secondary)",border:"1px solid var(--yc-color-border)"},children:l.name},l.name))})]}),e.jsx("div",{className:"flex flex-wrap gap-2 justify-center max-w-lg",children:T.map(l=>e.jsx("button",{onClick:()=>i(l),className:"text-sm px-3 py-1.5 rounded-full transition-opacity hover:opacity-80",style:{background:"var(--yc-color-surface)",color:"var(--yc-color-text)",border:"1px solid var(--yc-color-border)"},children:l},l))})]})}function R({summary:t,onTableClick:i}){const[l,x]=a.useState(new Set),[n,h]=a.useState(new Set),v=s=>{x(o=>{const c=new Set(o);return c.has(s)?c.delete(s):c.add(s),c})},f=s=>{h(o=>{const c=new Set(o);return c.has(s)?c.delete(s):c.add(s),c})},y=((t==null?void 0:t.connections)??[]).map(s=>({connection:s.name,tables:((t==null?void 0:t.tables)??[]).filter(o=>o.connection===s.name)})),u=(t==null?void 0:t.models)??[];return e.jsxs("div",{className:"w-64 flex-shrink-0 flex flex-col h-full overflow-y-auto",style:{borderRight:"1px solid var(--yc-color-border)",background:"var(--yc-color-surface)"},children:[e.jsx("div",{className:"px-3 py-2 flex items-center",style:{borderBottom:"1px solid var(--yc-color-border)"},children:e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",style:{color:"var(--yc-color-text-secondary)"},children:"Catalog"})}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-2",children:[y.map(s=>e.jsxs("div",{children:[e.jsxs("button",{className:"w-full flex items-center gap-1.5 px-3 py-1.5 hover:opacity-80 text-left",onClick:()=>v(s.connection),children:[e.jsx(g,{expanded:l.has(s.connection)}),e.jsx(I,{}),e.jsx("span",{className:"text-xs font-medium truncate",style:{color:"var(--yc-color-text)"},children:s.connection}),e.jsx("span",{className:"ml-auto text-xs",style:{color:"var(--yc-color-text-secondary)"},children:s.tables.length})]}),l.has(s.connection)&&e.jsx("div",{children:s.tables.map(o=>{const c=`${s.connection}:${o.name}`,m=n.has(c);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1 pl-6 pr-2 py-1 group",children:[e.jsxs("button",{className:"flex items-center gap-1 flex-1 min-w-0 hover:opacity-80 text-left",onClick:()=>f(c),children:[e.jsx(g,{expanded:m}),e.jsx(A,{}),e.jsx("span",{className:"text-xs truncate",style:{color:"var(--yc-color-text)"},children:o.schema?`${o.schema}.${o.name}`:o.name})]}),e.jsx("button",{className:"opacity-0 group-hover:opacity-100 text-xs px-1.5 py-0.5 rounded transition-opacity flex-shrink-0",style:{background:"var(--yc-color-primary)",color:"#fff"},onClick:()=>i(o.schema?`${o.schema}.${o.name}`:o.name),title:`Ask about ${o.name}`,children:"Ask"})]}),m&&o.columns.length>0&&e.jsx("div",{className:"pl-12 pb-1",children:o.columns.map(d=>e.jsxs("div",{className:"flex items-center gap-1.5 py-0.5 pr-2",children:[e.jsx("span",{className:"text-xs truncate",style:{color:"var(--yc-color-text)"},children:d.name}),d.type&&e.jsx("span",{className:"text-xs ml-auto flex-shrink-0",style:{color:"var(--yc-color-text-secondary)"},children:d.type})]},d.name))})]},c)})})]},s.connection)),u.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"px-3 py-1.5",style:{borderTop:"1px solid var(--yc-color-border)"},children:e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",style:{color:"var(--yc-color-text-secondary)"},children:"Models"})}),u.map(s=>e.jsxs("div",{className:"flex items-center gap-1.5 pl-3 pr-2 py-1.5 group",children:[e.jsx(O,{}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs truncate",style:{color:"var(--yc-color-text)"},children:s.name}),s.description&&e.jsx("p",{className:"text-xs truncate",style:{color:"var(--yc-color-text-secondary)"},children:s.description})]}),e.jsx("button",{className:"opacity-0 group-hover:opacity-100 text-xs px-1.5 py-0.5 rounded transition-opacity flex-shrink-0",style:{background:"var(--yc-color-primary)",color:"#fff"},onClick:()=>i(s.name),title:`Ask about ${s.name}`,children:"Ask"})]},s.name))]}),!t||y.length===0&&u.length===0?e.jsx("div",{className:"px-3 py-4 text-center",children:e.jsxs("p",{className:"text-xs",style:{color:"var(--yc-color-text-secondary)"},children:["No catalog data available. Run ",e.jsx("code",{className:"font-mono",children:"yamchart sync-warehouse"})," to populate."]})}):null]})]})}function g({expanded:t}){return e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--yc-color-text-secondary)",transform:t?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s",flexShrink:0},children:e.jsx("polyline",{points:"9 18 15 12 9 6"})})}function I(){return e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--yc-color-text-secondary)",flexShrink:0},children:[e.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),e.jsx("path",{d:"M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"}),e.jsx("path",{d:"M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"})]})}function A(){return e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--yc-color-text-secondary)",flexShrink:0},children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M3 9h18M3 15h18M9 3v18"})]})}function O(){return e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--yc-color-text-secondary)",flexShrink:0},children:[e.jsx("polyline",{points:"16 18 22 12 16 6"}),e.jsx("polyline",{points:"8 6 2 12 8 18"})]})}function q(){const t=k(n=>n.savedCharts),[i,l]=a.useState(!1),x=a.useRef(null);return a.useEffect(()=>{if(!i)return;function n(h){x.current&&!x.current.contains(h.target)&&l(!1)}return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[i]),t.length===0?null:e.jsxs("div",{className:"relative",ref:x,children:[e.jsxs("button",{onClick:()=>l(n=>!n),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-opacity hover:opacity-80",style:{background:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)",color:"var(--yc-color-text)"},children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"7"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"7"}),e.jsx("rect",{x:"14",y:"14",width:"7",height:"7"}),e.jsx("rect",{x:"3",y:"14",width:"7",height:"7"})]}),e.jsxs("span",{children:[t.length," saved ",t.length===1?"chart":"charts"]}),e.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 rounded-full text-xs font-bold text-white",style:{background:"var(--yc-color-primary)"},children:t.length})]}),i&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 w-56 rounded-lg shadow-lg z-50 py-1",style:{background:"var(--yc-color-bg)",border:"1px solid var(--yc-color-border)"},children:[e.jsx("p",{className:"px-3 py-1.5 text-xs font-semibold uppercase tracking-wide",style:{color:"var(--yc-color-text-secondary)"},children:"Saved charts"}),t.map(n=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--yc-color-primary)",flexShrink:0},children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}),e.jsx("span",{className:"text-sm truncate",style:{color:"var(--yc-color-text)"},children:n})]},n))]})]})}function V(){const t=E(),{messages:i,isStreaming:l,savedCharts:x,openPanel:n,setPanelMode:h,snapshotExploreHistory:v,clearConversation:f}=k(),[y,u]=a.useState(!0),[s,o]=a.useState(void 0),c=a.useRef(null);a.useEffect(()=>(h("explore"),n({type:"explore"}),()=>{h("panel")}),[h,n]),a.useEffect(()=>{var r;(r=c.current)==null||r.scrollIntoView({behavior:"smooth"})},[i]);const m=a.useCallback((r,p,S)=>{v(p),h("panel");const L=r==="chart"?"charts":"dashboards";window.location.hash=`/${L}/${encodeURIComponent(p)}${S?"?edit=true":""}`,n({type:r==="chart"?"chart":"dashboard",name:p})},[v,h,n]),{sendMessage:d}=B(m),{data:j}=M({queryKey:["catalog-summary"],queryFn:()=>D.getCatalogSummary(),staleTime:6e4,retry:!1}),b=a.useCallback(r=>{o(`Tell me about the ${r} table`)},[]),w=a.useCallback(r=>{d(r)},[d]),N=a.useCallback(r=>{d(r),o(void 0)},[d]),C=a.useCallback(()=>{const r=x.join(", ");d(`Build a dashboard using these charts: ${r}. Arrange them in a logical layout.`)},[x,d]);return t==="sm"?e.jsx("div",{className:"flex items-center justify-center h-screen px-6",style:{background:"var(--yc-color-bg)"},children:e.jsxs("div",{className:"text-center max-w-xs",children:[e.jsx("p",{className:"text-lg font-semibold mb-2",style:{color:"var(--yc-color-text)"},children:"Desktop required"}),e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"Data Explorer is designed for larger screens. Please open it on a desktop or laptop."})]})}):e.jsxs("div",{className:"flex h-screen overflow-hidden",style:{background:"var(--yc-color-bg)"},children:[y&&e.jsx(R,{summary:j??null,onTableClick:b}),e.jsxs("div",{className:"flex-1 flex flex-col h-full min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 flex-shrink-0",style:{borderBottom:"1px solid var(--yc-color-border)"},children:[e.jsxs("a",{href:"#/",className:"flex items-center gap-1.5 text-sm hover:opacity-80",style:{color:"var(--yc-color-text-secondary)"},onClick:r=>{r.preventDefault(),window.location.hash="/"},children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"15 18 9 12 15 6"})}),"Dashboards"]}),e.jsx("div",{className:"w-px h-4 mx-1",style:{background:"var(--yc-color-border)"}}),e.jsx("button",{className:"p-1.5 rounded hover:opacity-80",style:{color:"var(--yc-color-text-secondary)"},onClick:()=>u(r=>!r),title:y?"Hide catalog":"Show catalog",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M9 3v18"})]})}),e.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--yc-color-text)"},children:"Data Explorer"}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsx(q,{}),e.jsxs("button",{disabled:x.length===0||l,onClick:C,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-opacity disabled:opacity-40",style:{background:"var(--yc-color-primary)",color:"#fff"},children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"7"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"7"}),e.jsx("rect",{x:"14",y:"14",width:"7",height:"7"}),e.jsx("rect",{x:"3",y:"14",width:"7",height:"7"})]}),"Build Dashboard"]}),i.length>0&&e.jsx("button",{className:"p-1.5 rounded hover:opacity-80",style:{color:"var(--yc-color-text-secondary)"},onClick:f,title:"New conversation",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 20h9"}),e.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"})]})})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4 flex flex-col gap-3 min-h-0",children:i.length===0?e.jsx(P,{summary:j??null,onPromptClick:w}):e.jsxs(e.Fragment,{children:[i.map((r,p)=>e.jsx(W,{message:r,isStreaming:l&&p===i.length-1&&r.role==="assistant",onSendMessage:d},p)),e.jsx("div",{ref:c})]})}),e.jsx("div",{className:"px-6 py-3 flex-shrink-0",style:{borderTop:"1px solid var(--yc-color-border)"},children:e.jsx($,{onSend:N,placeholder:"Ask about your data...",disabled:l,initialValue:s})})]})]})}export{V as default};
@@ -1 +1 @@
1
- import{u,j as e,A as p}from"./index-CJ01RqZ2.js";import{a as r}from"./echarts-DtOYsfLX.js";const f="",g={google:"Google",microsoft:"Microsoft",oidc:"SSO"};function j(){const m=u(o=>o.login),l=u(o=>o.providers),[a,x]=r.useState(""),[t,b]=r.useState(""),[c,s]=r.useState(""),[n,d]=r.useState(!1);r.useEffect(()=>{window.location.hash.includes("error=account_conflict")&&(s("An account with this email already exists. Please sign in with your password."),window.location.hash="#/")},[]);const y=async o=>{o.preventDefault(),s(""),d(!0);try{await m(a,t)}catch(i){i instanceof p?s(i.message):s("An unexpected error occurred")}finally{d(!1)}},h=o=>{window.location.href=`${f}/api/auth/sso/${o}`};return e.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{backgroundColor:"var(--yc-color-background)"},children:e.jsxs("div",{className:"rounded-lg shadow-sm p-8 w-full max-w-md",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)"},children:[e.jsx("h1",{className:"text-2xl font-semibold mb-2",style:{color:"var(--yc-color-text)"},children:"Sign in to Yamchart"}),e.jsx("p",{className:"text-sm mb-6",style:{color:"var(--yc-color-text-secondary)"},children:"Enter your credentials to access dashboards."}),c&&e.jsx("div",{className:"text-sm rounded-md px-4 py-3 mb-4",style:{backgroundColor:"color-mix(in srgb, var(--yc-color-danger) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--yc-color-danger) 30%, transparent)",color:"var(--yc-color-danger)"},children:c}),l.length>0&&e.jsxs("div",{className:"space-y-2 mb-6",children:[l.map(o=>e.jsxs("button",{onClick:()=>h(o),className:"w-full py-2 px-4 text-sm font-medium rounded-md hover:bg-black/5",style:{border:"1px solid var(--yc-color-border)",color:"var(--yc-color-text-secondary)"},children:["Sign in with ",g[o]??o]},o)),e.jsxs("div",{className:"relative my-4",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("div",{className:"w-full border-t",style:{borderColor:"var(--yc-color-border)"}})}),e.jsx("div",{className:"relative flex justify-center text-xs",style:{color:"var(--yc-color-text-muted)"},children:e.jsx("span",{className:"px-2",style:{backgroundColor:"var(--yc-color-surface)"},children:"or"})})]})]}),e.jsxs("form",{onSubmit:y,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Email"}),e.jsx("input",{id:"email",type:"email",value:a,onChange:o=>x(o.target.value),required:!0,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},placeholder:"you@example.com"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"password",className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Password"}),e.jsx("input",{id:"password",type:"password",value:t,onChange:o=>b(o.target.value),required:!0,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},placeholder:"Password"})]}),e.jsx("button",{type:"submit",disabled:n,className:"w-full py-2 px-4 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",children:n?"Signing in...":"Sign in"})]})]})})}export{j as LoginPage};
1
+ import{u,j as e,A as p}from"./index-lklRbe2I.js";import{a as r}from"./echarts-DtOYsfLX.js";const f="",g={google:"Google",microsoft:"Microsoft",oidc:"SSO"};function j(){const m=u(o=>o.login),l=u(o=>o.providers),[a,x]=r.useState(""),[t,b]=r.useState(""),[c,s]=r.useState(""),[n,d]=r.useState(!1);r.useEffect(()=>{window.location.hash.includes("error=account_conflict")&&(s("An account with this email already exists. Please sign in with your password."),window.location.hash="#/")},[]);const y=async o=>{o.preventDefault(),s(""),d(!0);try{await m(a,t)}catch(i){i instanceof p?s(i.message):s("An unexpected error occurred")}finally{d(!1)}},h=o=>{window.location.href=`${f}/api/auth/sso/${o}`};return e.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{backgroundColor:"var(--yc-color-background)"},children:e.jsxs("div",{className:"rounded-lg shadow-sm p-8 w-full max-w-md",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)"},children:[e.jsx("h1",{className:"text-2xl font-semibold mb-2",style:{color:"var(--yc-color-text)"},children:"Sign in to Yamchart"}),e.jsx("p",{className:"text-sm mb-6",style:{color:"var(--yc-color-text-secondary)"},children:"Enter your credentials to access dashboards."}),c&&e.jsx("div",{className:"text-sm rounded-md px-4 py-3 mb-4",style:{backgroundColor:"color-mix(in srgb, var(--yc-color-danger) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--yc-color-danger) 30%, transparent)",color:"var(--yc-color-danger)"},children:c}),l.length>0&&e.jsxs("div",{className:"space-y-2 mb-6",children:[l.map(o=>e.jsxs("button",{onClick:()=>h(o),className:"w-full py-2 px-4 text-sm font-medium rounded-md hover:bg-black/5",style:{border:"1px solid var(--yc-color-border)",color:"var(--yc-color-text-secondary)"},children:["Sign in with ",g[o]??o]},o)),e.jsxs("div",{className:"relative my-4",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("div",{className:"w-full border-t",style:{borderColor:"var(--yc-color-border)"}})}),e.jsx("div",{className:"relative flex justify-center text-xs",style:{color:"var(--yc-color-text-muted)"},children:e.jsx("span",{className:"px-2",style:{backgroundColor:"var(--yc-color-surface)"},children:"or"})})]})]}),e.jsxs("form",{onSubmit:y,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Email"}),e.jsx("input",{id:"email",type:"email",value:a,onChange:o=>x(o.target.value),required:!0,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},placeholder:"you@example.com"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"password",className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Password"}),e.jsx("input",{id:"password",type:"password",value:t,onChange:o=>b(o.target.value),required:!0,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},placeholder:"Password"})]}),e.jsx("button",{type:"submit",disabled:n,className:"w-full py-2 px-4 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",children:n?"Signing in...":"Sign in"})]})]})})}export{j as LoginPage};
@@ -1 +1 @@
1
- import{j as e,c as ee,b as re,d as te,e as se,f as ae,g as K,h as le,a as R,F as oe,S as ce,i as ne,C as ie,D as de,k as he,T as xe,G as ue,W as me,l as ye,m as fe,H as ve,n as ge,o as je,p as pe,P as be,q as Ce,B as we,L as ke,r as Ne,s as De}from"./index-CJ01RqZ2.js";import{a as m}from"./echarts-DtOYsfLX.js";function Fe({title:s,description:l,loading:r=!1,error:i=null,cached:t,durationMs:c,hasDrillDown:N,onRefresh:a,children:v}){return e.jsxs("div",{className:"chart-container",children:[e.jsxs("div",{className:"flex items-start justify-between p-4 border-b",style:{borderColor:"var(--yc-color-border)"},children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",style:{color:"var(--yc-color-text)"},children:s}),N&&e.jsxs("svg",{className:"w-4 h-4 flex-shrink-0",style:{color:"var(--yc-color-text-muted)"},viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:[e.jsx("title",{children:"Right-click to drill down"}),e.jsx("path",{fillRule:"evenodd",d:"M5.22 14.78a.75.75 0 001.06 0l7.22-7.22v5.69a.75.75 0 001.5 0v-7.5a.75.75 0 00-.75-.75h-7.5a.75.75 0 000 1.5h5.69l-7.22 7.22a.75.75 0 000 1.06z",clipRule:"evenodd"})]})]}),l&&e.jsx("p",{className:"text-sm mt-1",style:{color:"var(--yc-color-text-secondary)"},children:l})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[t!==void 0&&e.jsx("span",{className:"text-xs px-2 py-1 rounded",style:t?{backgroundColor:"color-mix(in srgb, var(--yc-color-success) 15%, transparent)",color:"var(--yc-color-success)"}:{backgroundColor:"color-mix(in srgb, var(--yc-color-primary) 15%, transparent)",color:"var(--yc-color-primary)"},children:t?"Cached":"Fresh"}),c!==void 0&&e.jsxs("span",{className:"text-xs",style:{color:"var(--yc-color-text-muted)"},children:[c,"ms"]}),a&&e.jsx("button",{onClick:a,disabled:r,className:"p-1.5 hover:bg-black/5 rounded transition-colors disabled:opacity-50",style:{color:"var(--yc-color-text-muted)"},title:"Refresh",children:e.jsx("svg",{className:ee("w-4 h-4",r&&"animate-spin"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})]})]}),e.jsx("div",{className:"p-4",children:i?e.jsx("div",{className:"flex items-center justify-center h-64",style:{color:"var(--yc-color-danger)"},children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:"Failed to load chart"}),e.jsx("p",{className:"text-sm mt-1",children:i.message})]})}):v})]})}const Le={day:{label:"Date",format:"%b %d, %Y"},week:{label:"Week Starting",format:"%b %d"},month:{label:"Month",format:"%b '%y"},quarter:{label:"Quarter",format:"quarter"},year:{label:"Year",format:"%Y"}};function Se({chartName:s}){const[l,r]=m.useState(!1),i=async()=>{const t=`{{${s}}}`;try{await navigator.clipboard.writeText(t),r(!0),setTimeout(()=>r(!1),2e3)}catch(c){console.error("Failed to copy:",c)}};return e.jsx("button",{onClick:i,className:"text-sm flex items-center gap-1.5 px-2 py-1 rounded hover:bg-black/5 transition-colors",style:{color:"var(--yc-color-text-secondary)"},title:`Copy {{${s}}} for use in markdown widgets`,children:l?e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",style:{color:"var(--yc-color-success)"},children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsx("span",{style:{color:"var(--yc-color-success)"},children:"Copied!"})]}):e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})}),e.jsx("span",{children:"Copy Reference"})]})})}function S(s,l){if(!l)return s.toLocaleString();const r=l.decimals??0;switch(l.type){case"currency":return new Intl.NumberFormat("en-US",{style:"currency",currency:l.currency||"USD",minimumFractionDigits:r,maximumFractionDigits:r}).format(s);case"percent":return new Intl.NumberFormat("en-US",{style:"percent",minimumFractionDigits:r,maximumFractionDigits:r}).format(s/100);default:return s.toLocaleString(void 0,{minimumFractionDigits:r,maximumFractionDigits:r})}}function Ae(s,l){const r=s>=0?"+":"";return l==="percent_change"?`${r}${s.toFixed(1)}%`:`${r}${s.toLocaleString()}`}function Me({data:s,config:l,title:r,comparison:i}){var w,k,L;if(!(s!=null&&s[0])||!((w=l.value)!=null&&w.field))return e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-muted)"},children:"No data available"});const t=s[0],c=t[l.value.field],N=S(c,l.format);let a=null,v="percent_change",g,D,p;if(i)a=i.change,v=i.changeType,g=i.currentPeriodLabel,D=i.previousPeriodLabel,p=S(i.previousValue,l.format);else if((k=l.comparison)!=null&&k.enabled&&l.comparison.field){const h=t[l.comparison.field];v=l.comparison.type,h&&h!==0&&(v==="percent_change"?a=(c-h)/h*100:a=c-h,p=S(h,l.format))}const y=l.goal,b=y&&y.value!==0?Math.max(0,Math.min(c/y.value*100,100)):null,F=y?c>=y.value?"var(--yc-color-success)":"var(--yc-color-danger)":void 0;return e.jsxs("div",{className:"h-80 flex flex-col items-center justify-center p-8",children:[e.jsxs("div",{className:"text-6xl font-bold tabular-nums",style:{color:"var(--yc-color-text)"},children:[N,l.unit&&e.jsx("span",{className:"text-3xl font-normal ml-2",style:{color:"var(--yc-color-text-muted)"},children:l.unit})]}),g&&e.jsx("div",{className:"text-sm mt-2",style:{color:"var(--yc-color-text-muted)"},children:g}),r&&e.jsx("div",{className:"text-lg mt-3",style:{color:"var(--yc-color-text-secondary)"},children:r}),a!==null&&e.jsxs("div",{className:"mt-4 flex flex-col items-center gap-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-lg font-medium px-3 py-1 rounded",style:a>=0?{backgroundColor:"color-mix(in srgb, var(--yc-color-success) 15%, transparent)",color:"var(--yc-color-success)"}:{backgroundColor:"color-mix(in srgb, var(--yc-color-danger) 15%, transparent)",color:"var(--yc-color-danger)"},children:Ae(a,v)}),p&&e.jsxs("span",{className:"text-sm",style:{color:"var(--yc-color-text-muted)"},children:["vs ",p]}),!p&&((L=l.comparison)==null?void 0:L.label)&&e.jsx("span",{className:"text-sm",style:{color:"var(--yc-color-text-muted)"},children:l.comparison.label})]}),D&&e.jsx("div",{className:"text-xs",style:{color:"var(--yc-color-text-muted)"},children:D})]}),y&&b!==null&&e.jsxs("div",{className:"mt-4 w-full max-w-[280px]",children:[y.show_progress&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",style:{color:"var(--yc-color-text-muted)"},children:[e.jsxs("span",{children:[S(c,l.format)," / ",S(y.value,l.format)]}),e.jsxs("span",{children:[b.toFixed(0),"%"]})]}),e.jsx("div",{className:"w-full h-2 rounded-full",style:{backgroundColor:"var(--yc-color-surface-hover)"},children:e.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${b}%`,backgroundColor:F}})})]}),y.label&&e.jsx("div",{className:"text-sm mt-1 text-center",style:{color:"var(--yc-color-text-muted)"},children:y.label})]})]})}function _e({chartName:s,drillParams:l}){var O,P,W,U,H,I,q,z;const{data:r,isLoading:i}=re(s),{data:t,isLoading:c,error:N}=te(s),{data:a}=se(),v=ae(),g=K(o=>o.getEffectiveFilters),D=K(o=>o.setChartFilter),p=le(),y=i||c,b=l==null?void 0:l._from,F=l?Object.fromEntries(Object.entries(l).filter(([o])=>!o.startsWith("_"))):{},w=Object.keys(F).length>0,k=Object.entries(F).map(([o,u])=>`${o}: ${u}`).join(", ");m.useEffect(()=>{if(w)for(const[o,u]of Object.entries(F))D(s,o,u)},[s,w]);const L=((O=t==null?void 0:t.meta)==null?void 0:O.serverPaginated)===!0,[h,A]=m.useState(null),M=m.useRef(!0);m.useEffect(()=>{A(null),M.current=!0},[(P=t==null?void 0:t.meta)==null?void 0:P.cacheKey]);const Y=m.useCallback(async(o,u,n,j)=>{if(M.current&&o===0&&!n){M.current=!1;return}M.current=!1,A(d=>({rows:(d==null?void 0:d.rows)??[],page:o,loading:!0}));try{const d=g(s),$={...Object.fromEntries(Object.entries(d).filter(([Ee,G])=>G!=null&&G!=="")),_server_paginated:!0,_page:o,_page_size:u,...n?{_sort_field:n,_sort_dir:j??"asc"}:{}},T=await R.queryChart(s,$);A({rows:T.rows,summaryValues:T.summaryValues,page:o,loading:!1})}catch{A(d=>d?{...d,loading:!1}:null)}},[s,g]),X=m.useMemo(()=>{var n;if(!t||((n=r==null?void 0:r.chart)==null?void 0:n.type)!=="table")return;const o=g(s),u=Object.fromEntries(Object.entries(o).filter(([j,d])=>d!=null&&d!==""));return R.getExportUrl(s,u)},[t,r,s,g]),[x,_]=m.useState(null),C=m.useCallback((o,u,n)=>{_({x:n.x,y:n.y,field:o,value:u})},[]),Q=m.useCallback(()=>{var j,d;if(!x||!((j=r==null?void 0:r.drillDown)!=null&&j.model))return;const o=r.drillDown,u=o.fields?typeof o.fields=="string"?o.fields:o.fields[0]:o.field??((d=r.chart.x)==null?void 0:d.field)??x.field,n=new URLSearchParams;if(x.allFields)for(const[$,T]of Object.entries(x.allFields))n.set($,T);else n.set(u,x.value);n.set("_from",s),window.location.hash=`/charts/${s}/detail?${n.toString()}`,_(null)},[x,r,s]),J=m.useCallback(()=>{var j,d;if(!x||!((j=r==null?void 0:r.drillDown)!=null&&j.chart))return;const o=r.drillDown,u=o.fields?typeof o.fields=="string"?o.fields:o.fields[0]:o.field??((d=r.chart.x)==null?void 0:d.field)??x.field,n=new URLSearchParams({[u]:x.value,_from:s});window.location.hash=`/charts/${r.drillDown.chart}?${n.toString()}`,_(null)},[x,r,s]),B=g(s).granularity,f=B?Le[B]:void 0,V=f==null?void 0:f.label,E=f==null?void 0:f.format;if(i)return e.jsxs("div",{className:"chart-container animate-pulse",children:[e.jsx("div",{className:"p-4 border-b",style:{borderColor:"var(--yc-color-border)"},children:e.jsx("div",{className:"h-6 rounded w-48",style:{backgroundColor:"var(--yc-color-surface-hover)"}})}),e.jsx("div",{className:"p-4",children:e.jsx("div",{className:"h-80 rounded",style:{backgroundColor:"var(--yc-color-surface-hover)"}})})]});if(!r)return e.jsxs("div",{className:"chart-container p-8 text-center",style:{color:"var(--yc-color-text-secondary)"},children:["Chart not found: ",s]});const Z=()=>{var u;if(!t)return e.jsx("div",{className:"h-80 rounded animate-pulse",style:{backgroundColor:"var(--yc-color-surface-hover)"}});const o=r.chart.type;switch(o){case"line":if(!r.chart.x||!r.chart.y&&!r.chart.series)return e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing axis configuration"});{const n=f?{...r.chart.x,label:V,format:E}:r.chart.x;return e.jsx(ke,{data:t.rows,columns:t.columns,xAxis:n,yAxis:r.chart.y,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c,onChartClick:C,goalData:t.goalData,compareData:t.compareData})}case"bar":if(!r.chart.x||!r.chart.y&&!r.chart.series)return e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing axis configuration"});{const n=f?{...r.chart.x,label:V,format:E}:r.chart.x;return e.jsx(we,{data:t.rows,xAxis:n,yAxis:r.chart.y,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c,onChartClick:C,goalData:t.goalData,compareData:t.compareData})}case"area":if(!r.chart.x||!r.chart.y&&!r.chart.series)return e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing axis configuration"});{const n=f?{...r.chart.x,label:V,format:E}:r.chart.x;return e.jsx(Ce,{data:t.rows,xAxis:n,yAxis:r.chart.y,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c,onChartClick:C,goalData:t.goalData,compareData:t.compareData})}case"pie":return!r.chart.x||!r.chart.y?e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing pie chart configuration"}):e.jsx(be,{data:t.rows,xAxis:r.chart.x,yAxis:r.chart.y,theme:a==null?void 0:a.theme,loading:c,onChartClick:C});case"donut":return!r.chart.x||!r.chart.y?e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing donut chart configuration"}):e.jsx(pe,{data:t.rows,xAxis:r.chart.x,yAxis:r.chart.y,centerValue:r.chart.centerValue,theme:a==null?void 0:a.theme,loading:c,onChartClick:C});case"scatter":return!r.chart.x||!r.chart.y?e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing axis configuration"}):e.jsx(je,{data:t.rows,xAxis:r.chart.x,yAxis:r.chart.y,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c});case"combo":if(!r.chart.x)return e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing axis configuration"});{const n=f?{...r.chart.x,label:V,format:E}:r.chart.x;return e.jsx(ge,{data:t.rows,xAxis:n,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c,onChartClick:C,goalData:t.goalData,compareData:t.compareData})}case"kpi":return e.jsx(Me,{data:t.rows,config:r.chart,title:r.title,comparison:t.comparison});case"heatmap":return!r.chart.x||!r.chart.y?e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing axis configuration"}):e.jsx(ve,{data:t.rows,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c});case"funnel":return e.jsx(fe,{data:t.rows,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c});case"sankey":return e.jsx(ye,{data:t.rows,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c,onChartClick:C});case"waterfall":return e.jsx(me,{data:t.rows,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c});case"gauge":return e.jsx(ue,{data:t.rows,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c});case"table":return e.jsx(xe,{data:(h==null?void 0:h.rows)??t.rows,columns:t.columns,chartConfig:r.chart,height:"100%",loading:c||((h==null?void 0:h.loading)??!1),serverPaginated:L,totalCount:(u=t.meta)==null?void 0:u.totalCount,serverSummaryValues:(h==null?void 0:h.summaryValues)??t.summaryValues,onServerPageChange:L?Y:void 0,exportUrl:X});default:return e.jsxs("div",{className:"h-80 flex items-center justify-center text-gray-500",children:['Chart type "',o,'" not yet implemented']})}};return e.jsxs("div",{className:"space-y-4",children:[b&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",style:{color:"var(--yc-color-text-secondary)"},children:[e.jsx("button",{onClick:()=>{window.location.hash=`/charts/${b}`},className:"transition-colors hover:opacity-80",style:{color:"var(--yc-color-primary)"},children:b}),e.jsx("span",{children:"/"}),e.jsx("span",{className:"font-medium",style:{color:"var(--yc-color-text)"},children:r.title}),k&&e.jsxs("span",{style:{color:"var(--yc-color-text-muted)"},children:["(",k,")"]})]}),e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-4",children:[r.parameters.length>0?e.jsx(oe,{parameters:r.parameters,chartName:s}):e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Se,{chartName:s}),e.jsx(ce,{resourceType:"chart",resourceName:s}),p&&e.jsxs("button",{onClick:()=>ne.getState().openPanel({type:"chart",name:s}),className:"text-sm flex items-center gap-1 px-2 py-1 rounded hover:bg-black/5 transition-colors",style:{color:"var(--yc-color-text-secondary)"},title:"Ask AI about this chart",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),"Ask AI"]})]})]}),e.jsx(Fe,{title:r.title,description:r.description,loading:y,cached:t==null?void 0:t.meta.cached,durationMs:t==null?void 0:t.meta.durationMs,hasDrillDown:!!((W=r.drillDown)!=null&&W.chart),onRefresh:()=>v(s),children:e.jsx(ie,{isLoading:c,error:N,data:t==null?void 0:t.rows,onRetry:()=>v(s),children:Z()})}),w&&t&&e.jsx(de,{data:t.rows,columns:t.columns,drillDownColumns:(U=r.drillDown)==null?void 0:U.columns,filterDisplay:k,chartName:s}),x&&e.jsx(he,{x:x.x,y:x.y,field:x.field,value:x.value,allFields:x.allFields,onViewDetails:(H=r.drillDown)!=null&&H.model?Q:void 0,onGoToChart:(I=r.drillDown)!=null&&I.chart?J:void 0,detailModel:(q=r.drillDown)==null?void 0:q.model,targetChart:(z=r.drillDown)==null?void 0:z.chart,onClose:()=>_(null)})]})}function Re({parsed:s}){const l=s.params.token,[r,i]=m.useState(null),[t,c]=m.useState(!1);return m.useEffect(()=>{if(!l){i("No share token provided");return}R.getPublicConfig(l).then(()=>c(!0)).catch(()=>i("This link has expired or been revoked"))},[l]),r?e.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:e.jsx("div",{className:"text-center",children:e.jsx("div",{className:"text-gray-400 text-lg",children:r})})}):t?e.jsx(Ne,{value:l??null,children:e.jsxs("div",{className:"min-h-screen",style:{backgroundColor:"var(--yc-color-bg, #f9fafb)"},children:[s.type==="public_chart"?e.jsx("div",{className:"max-w-7xl mx-auto py-6 px-4",children:e.jsx(_e,{chartName:s.name})}):e.jsx(De,{dashboardId:s.name,initialTab:s.params.tab}),e.jsx("div",{className:"text-center py-4 text-xs",style:{color:"var(--yc-color-text-muted, #9ca3af)"},children:"Shared via yamchart"})]})}):e.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:e.jsx("div",{className:"text-gray-500",children:"Loading..."})})}export{Re as PublicViewer};
1
+ import{j as e,c as ee,b as re,d as te,e as se,f as ae,g as K,h as le,a as R,F as oe,S as ce,i as ne,C as ie,D as de,k as he,T as xe,G as ue,W as me,l as ye,m as fe,H as ve,n as ge,o as je,p as pe,P as be,q as Ce,B as we,L as ke,r as Ne,s as De}from"./index-lklRbe2I.js";import{a as m}from"./echarts-DtOYsfLX.js";function Fe({title:s,description:l,loading:r=!1,error:i=null,cached:t,durationMs:c,hasDrillDown:N,onRefresh:a,children:v}){return e.jsxs("div",{className:"chart-container",children:[e.jsxs("div",{className:"flex items-start justify-between p-4 border-b",style:{borderColor:"var(--yc-color-border)"},children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",style:{color:"var(--yc-color-text)"},children:s}),N&&e.jsxs("svg",{className:"w-4 h-4 flex-shrink-0",style:{color:"var(--yc-color-text-muted)"},viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:[e.jsx("title",{children:"Right-click to drill down"}),e.jsx("path",{fillRule:"evenodd",d:"M5.22 14.78a.75.75 0 001.06 0l7.22-7.22v5.69a.75.75 0 001.5 0v-7.5a.75.75 0 00-.75-.75h-7.5a.75.75 0 000 1.5h5.69l-7.22 7.22a.75.75 0 000 1.06z",clipRule:"evenodd"})]})]}),l&&e.jsx("p",{className:"text-sm mt-1",style:{color:"var(--yc-color-text-secondary)"},children:l})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[t!==void 0&&e.jsx("span",{className:"text-xs px-2 py-1 rounded",style:t?{backgroundColor:"color-mix(in srgb, var(--yc-color-success) 15%, transparent)",color:"var(--yc-color-success)"}:{backgroundColor:"color-mix(in srgb, var(--yc-color-primary) 15%, transparent)",color:"var(--yc-color-primary)"},children:t?"Cached":"Fresh"}),c!==void 0&&e.jsxs("span",{className:"text-xs",style:{color:"var(--yc-color-text-muted)"},children:[c,"ms"]}),a&&e.jsx("button",{onClick:a,disabled:r,className:"p-1.5 hover:bg-black/5 rounded transition-colors disabled:opacity-50",style:{color:"var(--yc-color-text-muted)"},title:"Refresh",children:e.jsx("svg",{className:ee("w-4 h-4",r&&"animate-spin"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})]})]}),e.jsx("div",{className:"p-4",children:i?e.jsx("div",{className:"flex items-center justify-center h-64",style:{color:"var(--yc-color-danger)"},children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:"Failed to load chart"}),e.jsx("p",{className:"text-sm mt-1",children:i.message})]})}):v})]})}const Le={day:{label:"Date",format:"%b %d, %Y"},week:{label:"Week Starting",format:"%b %d"},month:{label:"Month",format:"%b '%y"},quarter:{label:"Quarter",format:"quarter"},year:{label:"Year",format:"%Y"}};function Se({chartName:s}){const[l,r]=m.useState(!1),i=async()=>{const t=`{{${s}}}`;try{await navigator.clipboard.writeText(t),r(!0),setTimeout(()=>r(!1),2e3)}catch(c){console.error("Failed to copy:",c)}};return e.jsx("button",{onClick:i,className:"text-sm flex items-center gap-1.5 px-2 py-1 rounded hover:bg-black/5 transition-colors",style:{color:"var(--yc-color-text-secondary)"},title:`Copy {{${s}}} for use in markdown widgets`,children:l?e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",style:{color:"var(--yc-color-success)"},children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsx("span",{style:{color:"var(--yc-color-success)"},children:"Copied!"})]}):e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})}),e.jsx("span",{children:"Copy Reference"})]})})}function S(s,l){if(!l)return s.toLocaleString();const r=l.decimals??0;switch(l.type){case"currency":return new Intl.NumberFormat("en-US",{style:"currency",currency:l.currency||"USD",minimumFractionDigits:r,maximumFractionDigits:r}).format(s);case"percent":return new Intl.NumberFormat("en-US",{style:"percent",minimumFractionDigits:r,maximumFractionDigits:r}).format(s/100);default:return s.toLocaleString(void 0,{minimumFractionDigits:r,maximumFractionDigits:r})}}function Ae(s,l){const r=s>=0?"+":"";return l==="percent_change"?`${r}${s.toFixed(1)}%`:`${r}${s.toLocaleString()}`}function Me({data:s,config:l,title:r,comparison:i}){var w,k,L;if(!(s!=null&&s[0])||!((w=l.value)!=null&&w.field))return e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-muted)"},children:"No data available"});const t=s[0],c=t[l.value.field],N=S(c,l.format);let a=null,v="percent_change",g,D,p;if(i)a=i.change,v=i.changeType,g=i.currentPeriodLabel,D=i.previousPeriodLabel,p=S(i.previousValue,l.format);else if((k=l.comparison)!=null&&k.enabled&&l.comparison.field){const h=t[l.comparison.field];v=l.comparison.type,h&&h!==0&&(v==="percent_change"?a=(c-h)/h*100:a=c-h,p=S(h,l.format))}const y=l.goal,b=y&&y.value!==0?Math.max(0,Math.min(c/y.value*100,100)):null,F=y?c>=y.value?"var(--yc-color-success)":"var(--yc-color-danger)":void 0;return e.jsxs("div",{className:"h-80 flex flex-col items-center justify-center p-8",children:[e.jsxs("div",{className:"text-6xl font-bold tabular-nums",style:{color:"var(--yc-color-text)"},children:[N,l.unit&&e.jsx("span",{className:"text-3xl font-normal ml-2",style:{color:"var(--yc-color-text-muted)"},children:l.unit})]}),g&&e.jsx("div",{className:"text-sm mt-2",style:{color:"var(--yc-color-text-muted)"},children:g}),r&&e.jsx("div",{className:"text-lg mt-3",style:{color:"var(--yc-color-text-secondary)"},children:r}),a!==null&&e.jsxs("div",{className:"mt-4 flex flex-col items-center gap-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-lg font-medium px-3 py-1 rounded",style:a>=0?{backgroundColor:"color-mix(in srgb, var(--yc-color-success) 15%, transparent)",color:"var(--yc-color-success)"}:{backgroundColor:"color-mix(in srgb, var(--yc-color-danger) 15%, transparent)",color:"var(--yc-color-danger)"},children:Ae(a,v)}),p&&e.jsxs("span",{className:"text-sm",style:{color:"var(--yc-color-text-muted)"},children:["vs ",p]}),!p&&((L=l.comparison)==null?void 0:L.label)&&e.jsx("span",{className:"text-sm",style:{color:"var(--yc-color-text-muted)"},children:l.comparison.label})]}),D&&e.jsx("div",{className:"text-xs",style:{color:"var(--yc-color-text-muted)"},children:D})]}),y&&b!==null&&e.jsxs("div",{className:"mt-4 w-full max-w-[280px]",children:[y.show_progress&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",style:{color:"var(--yc-color-text-muted)"},children:[e.jsxs("span",{children:[S(c,l.format)," / ",S(y.value,l.format)]}),e.jsxs("span",{children:[b.toFixed(0),"%"]})]}),e.jsx("div",{className:"w-full h-2 rounded-full",style:{backgroundColor:"var(--yc-color-surface-hover)"},children:e.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${b}%`,backgroundColor:F}})})]}),y.label&&e.jsx("div",{className:"text-sm mt-1 text-center",style:{color:"var(--yc-color-text-muted)"},children:y.label})]})]})}function _e({chartName:s,drillParams:l}){var O,P,W,U,H,I,q,z;const{data:r,isLoading:i}=re(s),{data:t,isLoading:c,error:N}=te(s),{data:a}=se(),v=ae(),g=K(o=>o.getEffectiveFilters),D=K(o=>o.setChartFilter),p=le(),y=i||c,b=l==null?void 0:l._from,F=l?Object.fromEntries(Object.entries(l).filter(([o])=>!o.startsWith("_"))):{},w=Object.keys(F).length>0,k=Object.entries(F).map(([o,u])=>`${o}: ${u}`).join(", ");m.useEffect(()=>{if(w)for(const[o,u]of Object.entries(F))D(s,o,u)},[s,w]);const L=((O=t==null?void 0:t.meta)==null?void 0:O.serverPaginated)===!0,[h,A]=m.useState(null),M=m.useRef(!0);m.useEffect(()=>{A(null),M.current=!0},[(P=t==null?void 0:t.meta)==null?void 0:P.cacheKey]);const Y=m.useCallback(async(o,u,n,j)=>{if(M.current&&o===0&&!n){M.current=!1;return}M.current=!1,A(d=>({rows:(d==null?void 0:d.rows)??[],page:o,loading:!0}));try{const d=g(s),$={...Object.fromEntries(Object.entries(d).filter(([Ee,G])=>G!=null&&G!=="")),_server_paginated:!0,_page:o,_page_size:u,...n?{_sort_field:n,_sort_dir:j??"asc"}:{}},T=await R.queryChart(s,$);A({rows:T.rows,summaryValues:T.summaryValues,page:o,loading:!1})}catch{A(d=>d?{...d,loading:!1}:null)}},[s,g]),X=m.useMemo(()=>{var n;if(!t||((n=r==null?void 0:r.chart)==null?void 0:n.type)!=="table")return;const o=g(s),u=Object.fromEntries(Object.entries(o).filter(([j,d])=>d!=null&&d!==""));return R.getExportUrl(s,u)},[t,r,s,g]),[x,_]=m.useState(null),C=m.useCallback((o,u,n)=>{_({x:n.x,y:n.y,field:o,value:u})},[]),Q=m.useCallback(()=>{var j,d;if(!x||!((j=r==null?void 0:r.drillDown)!=null&&j.model))return;const o=r.drillDown,u=o.fields?typeof o.fields=="string"?o.fields:o.fields[0]:o.field??((d=r.chart.x)==null?void 0:d.field)??x.field,n=new URLSearchParams;if(x.allFields)for(const[$,T]of Object.entries(x.allFields))n.set($,T);else n.set(u,x.value);n.set("_from",s),window.location.hash=`/charts/${s}/detail?${n.toString()}`,_(null)},[x,r,s]),J=m.useCallback(()=>{var j,d;if(!x||!((j=r==null?void 0:r.drillDown)!=null&&j.chart))return;const o=r.drillDown,u=o.fields?typeof o.fields=="string"?o.fields:o.fields[0]:o.field??((d=r.chart.x)==null?void 0:d.field)??x.field,n=new URLSearchParams({[u]:x.value,_from:s});window.location.hash=`/charts/${r.drillDown.chart}?${n.toString()}`,_(null)},[x,r,s]),B=g(s).granularity,f=B?Le[B]:void 0,V=f==null?void 0:f.label,E=f==null?void 0:f.format;if(i)return e.jsxs("div",{className:"chart-container animate-pulse",children:[e.jsx("div",{className:"p-4 border-b",style:{borderColor:"var(--yc-color-border)"},children:e.jsx("div",{className:"h-6 rounded w-48",style:{backgroundColor:"var(--yc-color-surface-hover)"}})}),e.jsx("div",{className:"p-4",children:e.jsx("div",{className:"h-80 rounded",style:{backgroundColor:"var(--yc-color-surface-hover)"}})})]});if(!r)return e.jsxs("div",{className:"chart-container p-8 text-center",style:{color:"var(--yc-color-text-secondary)"},children:["Chart not found: ",s]});const Z=()=>{var u;if(!t)return e.jsx("div",{className:"h-80 rounded animate-pulse",style:{backgroundColor:"var(--yc-color-surface-hover)"}});const o=r.chart.type;switch(o){case"line":if(!r.chart.x||!r.chart.y&&!r.chart.series)return e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing axis configuration"});{const n=f?{...r.chart.x,label:V,format:E}:r.chart.x;return e.jsx(ke,{data:t.rows,columns:t.columns,xAxis:n,yAxis:r.chart.y,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c,onChartClick:C,goalData:t.goalData,compareData:t.compareData})}case"bar":if(!r.chart.x||!r.chart.y&&!r.chart.series)return e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing axis configuration"});{const n=f?{...r.chart.x,label:V,format:E}:r.chart.x;return e.jsx(we,{data:t.rows,xAxis:n,yAxis:r.chart.y,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c,onChartClick:C,goalData:t.goalData,compareData:t.compareData})}case"area":if(!r.chart.x||!r.chart.y&&!r.chart.series)return e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing axis configuration"});{const n=f?{...r.chart.x,label:V,format:E}:r.chart.x;return e.jsx(Ce,{data:t.rows,xAxis:n,yAxis:r.chart.y,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c,onChartClick:C,goalData:t.goalData,compareData:t.compareData})}case"pie":return!r.chart.x||!r.chart.y?e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing pie chart configuration"}):e.jsx(be,{data:t.rows,xAxis:r.chart.x,yAxis:r.chart.y,theme:a==null?void 0:a.theme,loading:c,onChartClick:C});case"donut":return!r.chart.x||!r.chart.y?e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing donut chart configuration"}):e.jsx(pe,{data:t.rows,xAxis:r.chart.x,yAxis:r.chart.y,centerValue:r.chart.centerValue,theme:a==null?void 0:a.theme,loading:c,onChartClick:C});case"scatter":return!r.chart.x||!r.chart.y?e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing axis configuration"}):e.jsx(je,{data:t.rows,xAxis:r.chart.x,yAxis:r.chart.y,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c});case"combo":if(!r.chart.x)return e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing axis configuration"});{const n=f?{...r.chart.x,label:V,format:E}:r.chart.x;return e.jsx(ge,{data:t.rows,xAxis:n,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c,onChartClick:C,goalData:t.goalData,compareData:t.compareData})}case"kpi":return e.jsx(Me,{data:t.rows,config:r.chart,title:r.title,comparison:t.comparison});case"heatmap":return!r.chart.x||!r.chart.y?e.jsx("div",{className:"h-80 flex items-center justify-center",style:{color:"var(--yc-color-text-secondary)"},children:"Missing axis configuration"}):e.jsx(ve,{data:t.rows,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c});case"funnel":return e.jsx(fe,{data:t.rows,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c});case"sankey":return e.jsx(ye,{data:t.rows,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c,onChartClick:C});case"waterfall":return e.jsx(me,{data:t.rows,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c});case"gauge":return e.jsx(ue,{data:t.rows,chartConfig:r.chart,theme:a==null?void 0:a.theme,loading:c});case"table":return e.jsx(xe,{data:(h==null?void 0:h.rows)??t.rows,columns:t.columns,chartConfig:r.chart,height:"100%",loading:c||((h==null?void 0:h.loading)??!1),serverPaginated:L,totalCount:(u=t.meta)==null?void 0:u.totalCount,serverSummaryValues:(h==null?void 0:h.summaryValues)??t.summaryValues,onServerPageChange:L?Y:void 0,exportUrl:X});default:return e.jsxs("div",{className:"h-80 flex items-center justify-center text-gray-500",children:['Chart type "',o,'" not yet implemented']})}};return e.jsxs("div",{className:"space-y-4",children:[b&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",style:{color:"var(--yc-color-text-secondary)"},children:[e.jsx("button",{onClick:()=>{window.location.hash=`/charts/${b}`},className:"transition-colors hover:opacity-80",style:{color:"var(--yc-color-primary)"},children:b}),e.jsx("span",{children:"/"}),e.jsx("span",{className:"font-medium",style:{color:"var(--yc-color-text)"},children:r.title}),k&&e.jsxs("span",{style:{color:"var(--yc-color-text-muted)"},children:["(",k,")"]})]}),e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-4",children:[r.parameters.length>0?e.jsx(oe,{parameters:r.parameters,chartName:s}):e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Se,{chartName:s}),e.jsx(ce,{resourceType:"chart",resourceName:s}),p&&e.jsxs("button",{onClick:()=>ne.getState().openPanel({type:"chart",name:s}),className:"text-sm flex items-center gap-1 px-2 py-1 rounded hover:bg-black/5 transition-colors",style:{color:"var(--yc-color-text-secondary)"},title:"Ask AI about this chart",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),"Ask AI"]})]})]}),e.jsx(Fe,{title:r.title,description:r.description,loading:y,cached:t==null?void 0:t.meta.cached,durationMs:t==null?void 0:t.meta.durationMs,hasDrillDown:!!((W=r.drillDown)!=null&&W.chart),onRefresh:()=>v(s),children:e.jsx(ie,{isLoading:c,error:N,data:t==null?void 0:t.rows,onRetry:()=>v(s),children:Z()})}),w&&t&&e.jsx(de,{data:t.rows,columns:t.columns,drillDownColumns:(U=r.drillDown)==null?void 0:U.columns,filterDisplay:k,chartName:s}),x&&e.jsx(he,{x:x.x,y:x.y,field:x.field,value:x.value,allFields:x.allFields,onViewDetails:(H=r.drillDown)!=null&&H.model?Q:void 0,onGoToChart:(I=r.drillDown)!=null&&I.chart?J:void 0,detailModel:(q=r.drillDown)==null?void 0:q.model,targetChart:(z=r.drillDown)==null?void 0:z.chart,onClose:()=>_(null)})]})}function Re({parsed:s}){const l=s.params.token,[r,i]=m.useState(null),[t,c]=m.useState(!1);return m.useEffect(()=>{if(!l){i("No share token provided");return}R.getPublicConfig(l).then(()=>c(!0)).catch(()=>i("This link has expired or been revoked"))},[l]),r?e.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:e.jsx("div",{className:"text-center",children:e.jsx("div",{className:"text-gray-400 text-lg",children:r})})}):t?e.jsx(Ne,{value:l??null,children:e.jsxs("div",{className:"min-h-screen",style:{backgroundColor:"var(--yc-color-bg, #f9fafb)"},children:[s.type==="public_chart"?e.jsx("div",{className:"max-w-7xl mx-auto py-6 px-4",children:e.jsx(_e,{chartName:s.name})}):e.jsx(De,{dashboardId:s.name,initialTab:s.params.tab}),e.jsx("div",{className:"text-center py-4 text-xs",style:{color:"var(--yc-color-text-muted, #9ca3af)"},children:"Shared via yamchart"})]})}):e.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:e.jsx("div",{className:"text-gray-500",children:"Loading..."})})}export{Re as PublicViewer};