yamchart 0.8.8 → 0.9.0

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 (65) hide show
  1. package/dist/{advisor-IJBW56F5.js → advisor-Z7TKPPBR.js} +10 -10
  2. package/dist/{agent-2DFNL2UB.js → agent-KWKPAYT2.js} +2 -2
  3. package/dist/{chunk-34ZVFILD.js → chunk-AMHCOB4D.js} +4 -4
  4. package/dist/{chunk-5N3FYFBV.js → chunk-CWAWATL4.js} +34 -7
  5. package/dist/chunk-CWAWATL4.js.map +1 -0
  6. package/dist/{chunk-D3ELUYYE.js → chunk-E2QN2M7S.js} +52 -5
  7. package/dist/chunk-E2QN2M7S.js.map +1 -0
  8. package/dist/{chunk-B5ZLCKNF.js → chunk-FZFBBB7K.js} +2 -2
  9. package/dist/{chunk-232AMQ5T.js → chunk-G57J2WQM.js} +4 -4
  10. package/dist/{chunk-77U26A7F.js → chunk-ZA6AOQVZ.js} +4 -4
  11. package/dist/chunk-ZA6AOQVZ.js.map +1 -0
  12. package/dist/{connection-utils-ZLSV5OLQ.js → connection-utils-CTPN7PV3.js} +4 -4
  13. package/dist/{describe-VO4CEYL2.js → describe-4NME6RCB.js} +5 -5
  14. package/dist/{dev-JUA73B6D.js → dev-6QGAB4ZH.js} +316 -29
  15. package/dist/dev-6QGAB4ZH.js.map +1 -0
  16. package/dist/{dist-PINRLZVT.js → dist-4GUE24QV.js} +2 -2
  17. package/dist/{dist-GVNWQXFR.js → dist-7CRX2GIR.js} +2 -2
  18. package/dist/{dist-E2PVGIPT.js → dist-VNX77VV5.js} +4 -2
  19. package/dist/index.js +21 -21
  20. package/dist/public/assets/{EventManagement-DQY1Sic0.js → EventManagement-MMsAkJKj.js} +2 -2
  21. package/dist/public/assets/{ExplorePage-C9M-fQ3Y.js → ExplorePage-BSkSNgLT.js} +1 -1
  22. package/dist/public/assets/{LoginPage-XYLwfbfw.js → LoginPage-vaI1dnyL.js} +1 -1
  23. package/dist/public/assets/PublicViewer-B-OKj2cg.js +1 -0
  24. package/dist/public/assets/{SetupWizard-fle7FC4b.js → SetupWizard-DvlVX2O6.js} +1 -1
  25. package/dist/public/assets/{ShareManagement-b3j4jzn3.js → ShareManagement-ulvPrOAQ.js} +1 -1
  26. package/dist/public/assets/{UserManagement-DwZ-AaqI.js → UserManagement-CvmpNy3o.js} +1 -1
  27. package/dist/public/assets/{index-CRcgti3B.css → index-CfyF2Wf-.css} +1 -1
  28. package/dist/public/assets/index-DD59fsOk.js +195 -0
  29. package/dist/public/assets/{index.es-Bd2YVqtj.js → index.es-BeTaRWIv.js} +1 -1
  30. package/dist/public/assets/{jspdf.es.min-CpRfbJ_H.js → jspdf.es.min-9haD1GSE.js} +3 -3
  31. package/dist/public/index.html +2 -2
  32. package/dist/{query-PXJMSDKR.js → query-Z75RKTHV.js} +4 -4
  33. package/dist/{sample-M24H3M73.js → sample-OIJNXQNC.js} +4 -4
  34. package/dist/{search-UCJS7X5D.js → search-YDCPIDZX.js} +5 -5
  35. package/dist/{source-resolver-RXNB7A64.js → source-resolver-4SUWXUGW.js} +5 -5
  36. package/dist/{sync-warehouse-S75DWVTG.js → sync-warehouse-NZFDS6WK.js} +4 -4
  37. package/dist/{tables-W3M3JDJO.js → tables-WJS2VI4L.js} +5 -5
  38. package/dist/templates/default/CLAUDE.md +1 -1
  39. package/dist/templates/default/docs/yamchart-reference.md +108 -2
  40. package/dist/{test-67AXD5PI.js → test-I4XOF7TZ.js} +5 -17
  41. package/dist/test-I4XOF7TZ.js.map +1 -0
  42. package/package.json +3 -3
  43. package/dist/chunk-5N3FYFBV.js.map +0 -1
  44. package/dist/chunk-77U26A7F.js.map +0 -1
  45. package/dist/chunk-D3ELUYYE.js.map +0 -1
  46. package/dist/dev-JUA73B6D.js.map +0 -1
  47. package/dist/public/assets/PublicViewer-CZJYS0wF.js +0 -1
  48. package/dist/public/assets/index-m_Jm3sB1.js +0 -188
  49. package/dist/test-67AXD5PI.js.map +0 -1
  50. /package/dist/{advisor-IJBW56F5.js.map → advisor-Z7TKPPBR.js.map} +0 -0
  51. /package/dist/{agent-2DFNL2UB.js.map → agent-KWKPAYT2.js.map} +0 -0
  52. /package/dist/{chunk-34ZVFILD.js.map → chunk-AMHCOB4D.js.map} +0 -0
  53. /package/dist/{chunk-B5ZLCKNF.js.map → chunk-FZFBBB7K.js.map} +0 -0
  54. /package/dist/{chunk-232AMQ5T.js.map → chunk-G57J2WQM.js.map} +0 -0
  55. /package/dist/{connection-utils-ZLSV5OLQ.js.map → connection-utils-CTPN7PV3.js.map} +0 -0
  56. /package/dist/{describe-VO4CEYL2.js.map → describe-4NME6RCB.js.map} +0 -0
  57. /package/dist/{dist-E2PVGIPT.js.map → dist-4GUE24QV.js.map} +0 -0
  58. /package/dist/{dist-GVNWQXFR.js.map → dist-7CRX2GIR.js.map} +0 -0
  59. /package/dist/{dist-PINRLZVT.js.map → dist-VNX77VV5.js.map} +0 -0
  60. /package/dist/{query-PXJMSDKR.js.map → query-Z75RKTHV.js.map} +0 -0
  61. /package/dist/{sample-M24H3M73.js.map → sample-OIJNXQNC.js.map} +0 -0
  62. /package/dist/{search-UCJS7X5D.js.map → search-YDCPIDZX.js.map} +0 -0
  63. /package/dist/{source-resolver-RXNB7A64.js.map → source-resolver-4SUWXUGW.js.map} +0 -0
  64. /package/dist/{sync-warehouse-S75DWVTG.js.map → sync-warehouse-NZFDS6WK.js.map} +0 -0
  65. /package/dist/{tables-W3M3JDJO.js.map → tables-WJS2VI4L.js.map} +0 -0
@@ -24,7 +24,7 @@ import {
24
24
  VERSION,
25
25
  deepMerge,
26
26
  resolveProjectConfig
27
- } from "./chunk-D3ELUYYE.js";
27
+ } from "./chunk-E2QN2M7S.js";
28
28
  import "./chunk-DGUM43GV.js";
29
29
  export {
30
30
  AgentDefinitionSchema,
@@ -53,4 +53,4 @@ export {
53
53
  deepMerge,
54
54
  resolveProjectConfig
55
55
  };
56
- //# sourceMappingURL=dist-PINRLZVT.js.map
56
+ //# sourceMappingURL=dist-4GUE24QV.js.map
@@ -1,4 +1,4 @@
1
- import "./chunk-5N3FYFBV.js";
1
+ import "./chunk-CWAWATL4.js";
2
2
  import {
3
3
  SemanticModelBuilder,
4
4
  SemanticQueryCompiler
@@ -787,4 +787,4 @@ export {
787
787
  updateSchemaYml,
788
788
  writeDbtModel
789
789
  };
790
- //# sourceMappingURL=dist-GVNWQXFR.js.map
790
+ //# sourceMappingURL=dist-7CRX2GIR.js.map
@@ -23,6 +23,7 @@ import {
23
23
  isRelativeDateRange,
24
24
  parseModelMetadata,
25
25
  renderTemplate,
26
+ resolveDynamicDefault,
26
27
  resolveMySQLAuth,
27
28
  resolvePostgresAuth,
28
29
  resolveSnowflakeAuth,
@@ -31,7 +32,7 @@ import {
31
32
  runModel,
32
33
  serializeDateValue,
33
34
  templateHasVariable
34
- } from "./chunk-5N3FYFBV.js";
35
+ } from "./chunk-CWAWATL4.js";
35
36
  import {
36
37
  SemanticModelBuilder,
37
38
  SemanticQueryCompiler,
@@ -73,6 +74,7 @@ export {
73
74
  isRelativeDateRange,
74
75
  parseModelMetadata,
75
76
  renderTemplate,
77
+ resolveDynamicDefault,
76
78
  resolveMySQLAuth,
77
79
  resolvePostgresAuth,
78
80
  resolveSnowflakeAuth,
@@ -83,4 +85,4 @@ export {
83
85
  templateHasVariable,
84
86
  validateSemanticQuery
85
87
  };
86
- //# sourceMappingURL=dist-E2PVGIPT.js.map
88
+ //# sourceMappingURL=dist-VNX77VV5.js.map
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  findProjectRoot,
7
7
  loadEnvFile,
8
8
  validateProject
9
- } from "./chunk-232AMQ5T.js";
9
+ } from "./chunk-G57J2WQM.js";
10
10
  import {
11
11
  detail,
12
12
  error,
@@ -17,8 +17,8 @@ import {
17
17
  success,
18
18
  warning
19
19
  } from "./chunk-HJVVHYVN.js";
20
- import "./chunk-D3ELUYYE.js";
21
- import "./chunk-5N3FYFBV.js";
20
+ import "./chunk-E2QN2M7S.js";
21
+ import "./chunk-CWAWATL4.js";
22
22
  import "./chunk-UND73EOB.js";
23
23
  import "./chunk-DGUM43GV.js";
24
24
 
@@ -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-JUA73B6D.js");
108
+ const { runDevServer } = await import("./dev-6QGAB4ZH.js");
109
109
  await runDevServer(projectDir, {
110
110
  port: parseInt(options.port, 10),
111
111
  apiOnly: options.apiOnly ?? false,
@@ -179,7 +179,7 @@ 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-ZLSV5OLQ.js");
182
+ const { resolveConnection } = await import("./connection-utils-CTPN7PV3.js");
183
183
  const { detectDatabaseMismatch } = await import("./rewrite-database-FDJIXKZ2.js");
184
184
  const catalogJsonStr = await readFile(join(projectDir, ".yamchart", "catalog.json"), "utf-8");
185
185
  const catalogData = JSON.parse(catalogJsonStr);
@@ -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-67AXD5PI.js");
236
+ const { testProject, formatTestOutput } = await import("./test-I4XOF7TZ.js");
237
237
  const result = await testProject(projectDir, model, {
238
238
  connection: options.connection,
239
239
  json: options.json
@@ -282,7 +282,7 @@ 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-RXNB7A64.js");
285
+ const { resolveTablesSource } = await import("./source-resolver-4SUWXUGW.js");
286
286
  const { compareTables, formatCompareTables } = await import("./compare-ZN6RUOOQ.js");
287
287
  let localResult;
288
288
  try {
@@ -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-W3M3JDJO.js");
316
+ const { listTables } = await import("./tables-WJS2VI4L.js");
317
317
  const result = await listTables(projectDir, {
318
318
  ...options,
319
319
  source: options.source || "auto"
@@ -351,7 +351,7 @@ 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-RXNB7A64.js");
354
+ const { resolveDescribeSource } = await import("./source-resolver-4SUWXUGW.js");
355
355
  const { compareColumns, formatCompareColumns } = await import("./compare-ZN6RUOOQ.js");
356
356
  let localResult;
357
357
  try {
@@ -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-VO4CEYL2.js");
376
+ const { describeTable } = await import("./describe-4NME6RCB.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-PXJMSDKR.js");
416
- const { formatTable, formatJSON } = await import("./connection-utils-ZLSV5OLQ.js");
415
+ const { executeQuery } = await import("./query-Z75RKTHV.js");
416
+ const { formatTable, formatJSON } = await import("./connection-utils-CTPN7PV3.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-M24H3M73.js");
444
- const { formatTable, formatJSON } = await import("./connection-utils-ZLSV5OLQ.js");
443
+ const { sampleTable } = await import("./sample-OIJNXQNC.js");
444
+ const { formatTable, formatJSON } = await import("./connection-utils-CTPN7PV3.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-UCJS7X5D.js");
474
+ const { searchDatabase } = await import("./search-YDCPIDZX.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-W3M3JDJO.js");
528
+ const { listTables } = await import("./tables-WJS2VI4L.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-VO4CEYL2.js");
570
+ const { describeTable } = await import("./describe-4NME6RCB.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-UCJS7X5D.js");
612
+ const { searchDatabase } = await import("./search-YDCPIDZX.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-S75DWVTG.js");
737
+ const { runSyncWarehouse } = await import("./sync-warehouse-NZFDS6WK.js");
738
738
  await runSyncWarehouse(projectDir, options);
739
739
  } catch (err) {
740
740
  error(err instanceof Error ? err.message : String(err));
@@ -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-IJBW56F5.js");
788
+ const { runAdvisor } = await import("./advisor-Z7TKPPBR.js");
789
789
  await runAdvisor(projectDir, question, {
790
790
  top: options.top ? parseInt(options.top, 10) : 5,
791
791
  json: options.json,
@@ -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-ZLSV5OLQ.js");
878
+ const { resolveConnection, createConnector, formatTable, formatJSON } = await import("./connection-utils-CTPN7PV3.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{s as xe,u as he,t as me,e as be,v as $,j as t,w as E,E as ce,M as fe,x as ve,y as je,z as Ce,a as S}from"./index-m_Jm3sB1.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-DD59fsOk.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);
@@ -15,4 +15,4 @@ import{s as xe,u as he,t as me,e as be,v as $,j as t,w as E,E as ce,M as fe,x as
15
15
  border: 2px solid var(--yc-color-primary, #2563eb);
16
16
  }
17
17
  .rdp-day_button:hover { background-color: var(--yc-color-surface-hover, #e5e7eb) !important; }
18
- `;function L({selected:h,onSelect:m,onClose:n}){const x=s.useRef(null);return s.useEffect(()=>{function y(b){x.current&&!x.current.contains(b.target)&&n()}return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[n]),t.jsxs("div",{ref:x,className:"absolute z-50 rounded-lg shadow-lg p-2",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)",top:"100%",left:0},onClick:y=>y.stopPropagation(),children:[t.jsx("style",{children:ge}),t.jsx(je,{mode:"single",numberOfMonths:1,selected:h,defaultMonth:h,onSelect:y=>{y&&m(Ce(y,"yyyy-MM-dd"))}})]})}function De(){var oe,le;const h=xe(),m=he(e=>e.auth),n=m.status==="disabled"||m.status==="authenticated"&&(m.user.role==="admin"||m.user.role==="editor"),{data:x,isLoading:y}=me({queryKey:["chartEvents"],queryFn:()=>S.getChartEvents()}),b=(x==null?void 0:x.events)??[],{data:i}=be(),ne=new Set(["line","bar","area","combo"]),w=((i==null?void 0:i.charts)??[]).filter(e=>ne.has(e.type)).map(e=>e.name),f=s.useMemo(()=>Object.fromEntries(((i==null?void 0:i.charts)??[]).map(e=>[e.name,e.title])),[i==null?void 0:i.charts]),[k,G]=s.useState(null),[c,j]=s.useState(null),[C,M]=s.useState(""),[O,D]=s.useState(!1),[o,u]=s.useState({date:"",endDate:"",label:"",description:"",color:"",charts:[]}),[A,K]=s.useState(""),[J,P]=s.useState(!1),[U,I]=s.useState(!1),[X,R]=s.useState(null),[Y,B]=s.useState(null),[N,_]=s.useState(!1),[q,z]=s.useState(""),[g,F]=s.useState(null),Q=s.useRef(null);s.useEffect(()=>{var e;c&&((e=Q.current)==null||e.focus())},[c]);const W=s.useRef(null);s.useEffect(()=>{if(k===null)return;function e(r){W.current&&!W.current.contains(r.target)&&(G(null),K(""))}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[k]);const T=s.useRef(null);s.useEffect(()=>{if(!N)return;function e(r){T.current&&!T.current.contains(r.target)&&(_(!1),z(""))}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[N]);const v=$({mutationFn:({index:e,event:r})=>S.updateChartEvent(e,r),onSuccess:()=>h.invalidateQueries({queryKey:["chartEvents"]})}),de=$({mutationFn:e=>S.deleteChartEvent(e),onSuccess:()=>h.invalidateQueries({queryKey:["chartEvents"]})}),ie=$({mutationFn:e=>S.createChartEvent(e),onSuccess:()=>{h.invalidateQueries({queryKey:["chartEvents"]}),D(!1),u({date:"",endDate:"",label:"",description:"",color:"",charts:[]})}});function Z(e,r,a){n&&(j({index:e,field:r}),M(a))}function V(){var a;if(!c)return;if(c.field==="date"||c.field==="endDate"){j(null);return}const e=b[c.index];if(!e)return;const r={...e,[c.field]:C};if(e[c.field]===C||!e[c.field]&&!C){j(null);return}v.mutate({index:c.index,event:{date:r.date,label:r.label,...r.description?{description:r.description}:{},...r.color?{color:r.color}:{},...r.endDate?{endDate:r.endDate}:{},...(a=r.charts)!=null&&a.length?{charts:r.charts}:{}}}),j(null)}function ee(e){e.key==="Enter"&&V(),e.key==="Escape"&&j(null)}function ue(e){F(e)}function ye(){g!==null&&(de.mutate(g),F(null))}function te(){!o.date.trim()||!o.label.trim()||ie.mutate({date:o.date.trim(),label:o.label.trim(),...o.description.trim()?{description:o.description.trim()}:{},...o.color.trim()?{color:o.color.trim()}:{},...o.endDate.trim()?{endDate:o.endDate.trim()}:{},...o.charts.length>0?{charts:o.charts}:{}})}function re(e){e.key==="Enter"&&te(),e.key==="Escape"&&(D(!1),u({date:"",endDate:"",label:"",description:"",color:"",charts:[]}))}return y?t.jsx("div",{className:"p-6",style:{color:"var(--yc-color-text-secondary)"},children:"Loading..."}):t.jsxs("div",{className:"p-6 max-w-5xl",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h2",{className:"text-lg font-semibold",style:{color:"var(--yc-color-text)"},children:"Events"}),n&&t.jsx("button",{onClick:()=>D(!0),disabled:O,className:"px-3 py-1.5 text-sm rounded text-white disabled:opacity-50",style:{backgroundColor:"var(--yc-color-primary, #3b82f6)"},children:"Add event"})]}),b.length===0&&!O?t.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"No events yet. Add events to annotate your time series charts with milestones, launches, and incidents."}):t.jsx("div",{className:"rounded-lg",style:{border:"1px solid var(--yc-color-border)"},children:t.jsxs("table",{className:"w-full text-sm table-fixed",style:{overflow:"visible"},children:[t.jsxs("colgroup",{children:[t.jsx("col",{style:{width:40}}),t.jsx("col",{style:{width:"12%"}}),t.jsx("col",{style:{width:"12%"}}),t.jsx("col",{style:{width:"16%"}}),t.jsx("col",{style:{width:"20%"}}),t.jsx("col",{style:{width:"12%"}}),t.jsx("col",{style:{width:"18%"}}),n&&t.jsx("col",{style:{width:48}})]}),t.jsx("thead",{className:"border-b",style:{backgroundColor:"var(--yc-color-input-bg)",borderColor:"var(--yc-color-border)"},children:t.jsxs("tr",{children:[t.jsx("th",{className:"text-right px-3 py-2 font-medium",style:{color:"var(--yc-color-text-muted)"},children:"#"}),t.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:"var(--yc-color-text-secondary)"},children:"Date"}),t.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:"var(--yc-color-text-secondary)"},children:"End Date"}),t.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:"var(--yc-color-text-secondary)"},children:"Label"}),t.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:"var(--yc-color-text-secondary)"},children:"Description"}),t.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:"var(--yc-color-text-secondary)"},children:"Color"}),t.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:"var(--yc-color-text-secondary)"},children:"Charts"}),n&&t.jsx("th",{className:"px-4 py-2"})]})}),t.jsxs("tbody",{children:[O&&t.jsxs("tr",{className:"border-b",style:{borderColor:"var(--yc-color-border)",backgroundColor:"color-mix(in srgb, var(--yc-color-primary) 5%, transparent)"},children:[t.jsx("td",{className:"px-3 py-2 text-right",style:{color:"var(--yc-color-text-muted)"},children:"—"}),t.jsxs("td",{className:"px-4 py-2 relative",children:[t.jsx("button",{onClick:()=>P(!J),className:"w-full px-2 py-1 text-sm rounded border box-border -my-1 text-left",style:{backgroundColor:"var(--yc-color-background)",borderColor:"var(--yc-color-border)",color:o.date?"var(--yc-color-text)":"var(--yc-color-text-muted)"},children:o.date||"Select date"}),J&&t.jsx(L,{selected:o.date?E(o.date,"yyyy-MM-dd",new Date):void 0,onSelect:e=>{u({...o,date:e}),P(!1)},onClose:()=>P(!1)})]}),t.jsxs("td",{className:"px-4 py-2 relative",children:[t.jsx("button",{onClick:()=>I(!U),className:"w-full px-2 py-1 text-sm rounded border box-border -my-1 text-left",style:{backgroundColor:"var(--yc-color-background)",borderColor:"var(--yc-color-border)",color:o.endDate?"var(--yc-color-text)":"var(--yc-color-text-muted)"},children:o.endDate||"—"}),U&&t.jsx(L,{selected:o.endDate?E(o.endDate,"yyyy-MM-dd",new Date):void 0,onSelect:e=>{u({...o,endDate:e}),I(!1)},onClose:()=>I(!1)})]}),t.jsx("td",{className:"px-4 py-2",children:t.jsx("input",{type:"text",value:o.label,onChange:e=>u({...o,label:e.target.value}),onKeyDown:re,placeholder:"Event label",className:"w-full px-2 py-1 text-sm rounded border box-border -my-1",style:{backgroundColor:"var(--yc-color-background)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text)"}})}),t.jsx("td",{className:"px-4 py-2",children:t.jsx("input",{type:"text",value:o.description,onChange:e=>u({...o,description:e.target.value}),onKeyDown:re,placeholder:"Optional",className:"w-full px-2 py-1 text-sm rounded border box-border -my-1",style:{backgroundColor:"var(--yc-color-background)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text)"}})}),t.jsx("td",{className:"px-4 py-2",children:t.jsx(ce,{value:o.color,onChange:e=>u({...o,color:e}),themePalette:(oe=i==null?void 0:i.theme)==null?void 0:oe.palette})}),t.jsxs("td",{className:"px-4 py-2 relative",children:[t.jsx("button",{onClick:()=>_(!N),className:"text-sm truncate max-w-full text-left",style:{color:o.charts.length>0?"var(--yc-color-text-secondary)":"var(--yc-color-text-muted)"},children:o.charts.length>0?o.charts.map(e=>f[e]??e).join(", "):"All charts"}),N&&(()=>{const e=q.toLowerCase(),r=e?w.filter(a=>(f[a]??a).toLowerCase().includes(e)||a.toLowerCase().includes(e)):w;return t.jsxs("div",{ref:T,className:"absolute z-50 rounded-lg shadow-lg p-2 text-sm min-w-[220px]",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)",top:"100%",left:16},onClick:a=>a.stopPropagation(),children:[t.jsx("input",{type:"text",value:q,onChange:a=>z(a.target.value),placeholder:"Search charts...",autoFocus:!0,className:"w-full px-2 py-1 text-sm rounded border mb-1",style:{backgroundColor:"var(--yc-color-background)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text)"}}),t.jsxs("div",{className:"max-h-52 overflow-y-auto",children:[!q&&t.jsxs("label",{className:"flex items-center gap-2 px-2 py-1 rounded cursor-pointer hover:opacity-80",style:{color:"var(--yc-color-text)"},children:[t.jsx("input",{type:"checkbox",checked:o.charts.length===0,onChange:()=>u({...o,charts:[]})}),"All charts"]}),r.map(a=>t.jsxs("label",{className:"flex items-center gap-2 px-2 py-1 rounded cursor-pointer hover:opacity-80",style:{color:"var(--yc-color-text)"},children:[t.jsx("input",{type:"checkbox",checked:o.charts.includes(a),onChange:()=>{const l=o.charts.includes(a)?o.charts.filter(p=>p!==a):[...o.charts,a];u({...o,charts:l})}}),f[a]??a]},a)),r.length===0&&t.jsx("div",{className:"px-2 py-2 text-center",style:{color:"var(--yc-color-text-muted)"},children:"No matching charts"})]})]})})()]}),t.jsx("td",{className:"px-4 py-2",children:t.jsxs("div",{className:"flex gap-1",children:[t.jsx("button",{onClick:te,disabled:!o.date.trim()||!o.label.trim(),className:"text-xs px-2 py-1 rounded text-white disabled:opacity-50",style:{backgroundColor:"var(--yc-color-primary, #3b82f6)"},children:"Save"}),t.jsx("button",{onClick:()=>{D(!1),u({date:"",endDate:"",label:"",description:"",color:"",charts:[]}),_(!1),z("")},className:"text-xs px-2 py-1 rounded",style:{color:"var(--yc-color-text-muted)"},children:"Cancel"})]})})]}),b.map((e,r)=>{var a;return t.jsxs("tr",{className:"border-b last:border-0",style:{borderColor:"var(--yc-color-border)"},children:[t.jsx("td",{className:"px-3 py-3 text-right",style:{color:"var(--yc-color-text-muted)"},children:r+1}),t.jsxs("td",{className:"px-4 py-3 relative",style:{color:"var(--yc-color-text)",cursor:n?"pointer":"default"},onClick:()=>{n&&R(X===r?null:r)},children:[e.date,X===r&&t.jsx(L,{selected:(()=>{try{return E(e.date,"yyyy-MM-dd",new Date)}catch{return}})(),onSelect:l=>{R(null),l!==e.date&&v.mutate({index:r,event:{...e,date:l}})},onClose:()=>R(null)})]}),t.jsxs("td",{className:"px-4 py-3 relative",style:{color:e.endDate?"var(--yc-color-text)":"var(--yc-color-text-muted)",cursor:n?"pointer":"default"},onClick:()=>{n&&B(Y===r?null:r)},children:[e.endDate||"—",Y===r&&t.jsx(L,{selected:(()=>{try{return e.endDate?E(e.endDate,"yyyy-MM-dd",new Date):void 0}catch{return}})(),onSelect:l=>{B(null),l!==e.endDate&&v.mutate({index:r,event:{...e,endDate:l}})},onClose:()=>B(null)})]}),t.jsx("td",{className:"px-4 py-3 font-medium",style:{color:"var(--yc-color-text)",cursor:n?"pointer":"default"},onClick:()=>Z(r,"label",e.label),children:(c==null?void 0:c.index)===r&&c.field==="label"?t.jsx("input",{ref:Q,type:"text",value:C,onChange:l=>M(l.target.value),onBlur:V,onKeyDown:ee,className:"w-full py-0 text-sm border-0 border-b outline-none",style:{backgroundColor:"transparent",borderColor:"var(--yc-color-primary, #3b82f6)",color:"var(--yc-color-text)",borderBottomWidth:1,borderBottomStyle:"solid"}}):e.label}),t.jsx("td",{className:"px-4 py-3",style:{color:e.description?"var(--yc-color-text-secondary)":"var(--yc-color-text-muted)",cursor:n?"pointer":"default"},onClick:()=>Z(r,"description",e.description??""),children:(c==null?void 0:c.index)===r&&c.field==="description"?t.jsx("input",{ref:Q,type:"text",value:C,onChange:l=>M(l.target.value),onBlur:V,onKeyDown:ee,placeholder:"Add description",className:"w-full py-0 text-sm border-0 border-b outline-none",style:{backgroundColor:"transparent",borderColor:"var(--yc-color-primary, #3b82f6)",color:"var(--yc-color-text)",borderBottomWidth:1,borderBottomStyle:"solid"}}):e.description?t.jsx(fe,{components:{p:({children:l})=>t.jsx("span",{children:l}),a:({href:l,children:p})=>t.jsx("a",{href:l,onClick:d=>d.stopPropagation(),...l&&!l.startsWith("#")?{target:"_blank",rel:"noopener noreferrer"}:{},style:{color:"var(--yc-color-primary, #3b82f6)",textDecoration:"underline"},children:p})},children:e.description}):"—"}),t.jsx("td",{className:"px-4 py-3",children:n?t.jsx(ce,{value:e.color??"",onChange:l=>{var p;v.mutate({index:r,event:{date:e.date,label:e.label,...e.description?{description:e.description}:{},...l?{color:l}:{},...e.endDate?{endDate:e.endDate}:{},...(p=e.charts)!=null&&p.length?{charts:e.charts}:{}}})},themePalette:(a=i==null?void 0:i.theme)==null?void 0:a.palette}):t.jsxs("span",{className:"flex items-center gap-2",children:[e.color&&t.jsx("span",{className:"w-4 h-4 rounded-full border inline-block flex-shrink-0",style:{backgroundColor:e.color,borderColor:"var(--yc-color-border)"}}),t.jsx("span",{style:{color:e.color?"var(--yc-color-text-secondary)":"var(--yc-color-text-muted)"},children:e.color||"—"})]})}),t.jsxs("td",{className:"px-4 py-3 relative",style:{color:"var(--yc-color-text-secondary)",cursor:n?"pointer":"default"},onClick:()=>{n&&(G(k===r?null:r),K(""))},children:[k===r?(()=>{const l=A.toLowerCase(),p=l?w.filter(d=>(f[d]??d).toLowerCase().includes(l)||d.toLowerCase().includes(l)):w;return t.jsxs("div",{ref:W,className:"absolute z-50 rounded-lg shadow-lg p-2 text-sm min-w-[220px]",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)",top:"100%",left:16},onClick:d=>d.stopPropagation(),children:[t.jsx("input",{type:"text",value:A,onChange:d=>K(d.target.value),placeholder:"Search charts...",autoFocus:!0,className:"w-full px-2 py-1 text-sm rounded border mb-1",style:{backgroundColor:"var(--yc-color-background)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text)"}}),t.jsxs("div",{className:"max-h-52 overflow-y-auto",children:[!A&&t.jsxs("label",{className:"flex items-center gap-2 px-2 py-1 rounded cursor-pointer hover:opacity-80",style:{color:"var(--yc-color-text)"},children:[t.jsx("input",{type:"checkbox",checked:!e.charts||e.charts.length===0,onChange:()=>{v.mutate({index:r,event:{date:e.date,label:e.label,...e.description?{description:e.description}:{},...e.color?{color:e.color}:{},...e.endDate?{endDate:e.endDate}:{}}})}}),"All charts"]}),p.map(d=>{var ae;return t.jsxs("label",{className:"flex items-center gap-2 px-2 py-1 rounded cursor-pointer hover:opacity-80",style:{color:"var(--yc-color-text)"},children:[t.jsx("input",{type:"checkbox",checked:((ae=e.charts)==null?void 0:ae.includes(d))??!1,onChange:()=>{const H=e.charts??[],se=H.includes(d)?H.filter(pe=>pe!==d):[...H,d];v.mutate({index:r,event:{date:e.date,label:e.label,...e.description?{description:e.description}:{},...e.color?{color:e.color}:{},...e.endDate?{endDate:e.endDate}:{},...se.length>0?{charts:se}:{}}})}}),f[d]??d]},d)}),p.length===0&&t.jsx("div",{className:"px-2 py-2 text-center",style:{color:"var(--yc-color-text-muted)"},children:"No matching charts"})]})]})})():null,e.charts&&e.charts.length>0?e.charts.map(l=>f[l]??l).join(", "):t.jsx("span",{style:{color:"var(--yc-color-text-muted)"},children:"All charts"})]}),n&&t.jsx("td",{className:"px-4 py-3 text-right",children:t.jsx("button",{onClick:()=>ue(r),title:"Delete event",className:"hover:opacity-80",style:{color:"var(--yc-color-danger, #ef4444)"},children:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0"})})})})]},r)})]})]})}),t.jsx(ve,{open:g!==null,title:"Delete event",message:`Delete "${g!==null?(le=b[g])==null?void 0:le.label:""}"? This cannot be undone.`,onConfirm:ye,onCancel:()=>F(null)})]})}export{De as EventManagement};
18
+ `;function L({selected:h,onSelect:m,onClose:n}){const x=s.useRef(null);return s.useEffect(()=>{function y(b){x.current&&!x.current.contains(b.target)&&n()}return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[n]),t.jsxs("div",{ref:x,className:"absolute z-50 rounded-lg shadow-lg p-2",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)",top:"100%",left:0},onClick:y=>y.stopPropagation(),children:[t.jsx("style",{children:ge}),t.jsx(je,{mode:"single",numberOfMonths:1,selected:h,defaultMonth:h,onSelect:y=>{y&&m(Ce(y,"yyyy-MM-dd"))}})]})}function De(){var oe,le;const h=xe(),m=he(e=>e.auth),n=m.status==="disabled"||m.status==="authenticated"&&(m.user.role==="admin"||m.user.role==="editor"),{data:x,isLoading:y}=me({queryKey:["chartEvents"],queryFn:()=>S.getChartEvents()}),b=(x==null?void 0:x.events)??[],{data:i}=be(),ne=new Set(["line","bar","area","combo"]),w=((i==null?void 0:i.charts)??[]).filter(e=>ne.has(e.type)).map(e=>e.name),f=s.useMemo(()=>Object.fromEntries(((i==null?void 0:i.charts)??[]).map(e=>[e.name,e.title])),[i==null?void 0:i.charts]),[k,G]=s.useState(null),[c,j]=s.useState(null),[C,M]=s.useState(""),[O,D]=s.useState(!1),[o,u]=s.useState({date:"",endDate:"",label:"",description:"",color:"",charts:[]}),[A,I]=s.useState(""),[J,K]=s.useState(!1),[U,P]=s.useState(!1),[X,R]=s.useState(null),[Y,B]=s.useState(null),[N,_]=s.useState(!1),[q,z]=s.useState(""),[g,F]=s.useState(null),Q=s.useRef(null);s.useEffect(()=>{var e;c&&((e=Q.current)==null||e.focus())},[c]);const W=s.useRef(null);s.useEffect(()=>{if(k===null)return;function e(r){W.current&&!W.current.contains(r.target)&&(G(null),I(""))}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[k]);const T=s.useRef(null);s.useEffect(()=>{if(!N)return;function e(r){T.current&&!T.current.contains(r.target)&&(_(!1),z(""))}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[N]);const v=$({mutationFn:({index:e,event:r})=>S.updateChartEvent(e,r),onSuccess:()=>h.invalidateQueries({queryKey:["chartEvents"]})}),de=$({mutationFn:e=>S.deleteChartEvent(e),onSuccess:()=>h.invalidateQueries({queryKey:["chartEvents"]})}),ie=$({mutationFn:e=>S.createChartEvent(e),onSuccess:()=>{h.invalidateQueries({queryKey:["chartEvents"]}),D(!1),u({date:"",endDate:"",label:"",description:"",color:"",charts:[]})}});function Z(e,r,a){n&&(j({index:e,field:r}),M(a))}function V(){var a;if(!c)return;if(c.field==="date"||c.field==="endDate"){j(null);return}const e=b[c.index];if(!e)return;const r={...e,[c.field]:C};if(e[c.field]===C||!e[c.field]&&!C){j(null);return}v.mutate({index:c.index,event:{date:r.date,label:r.label,...r.description?{description:r.description}:{},...r.color?{color:r.color}:{},...r.endDate?{endDate:r.endDate}:{},...(a=r.charts)!=null&&a.length?{charts:r.charts}:{}}}),j(null)}function ee(e){e.key==="Enter"&&V(),e.key==="Escape"&&j(null)}function ue(e){F(e)}function ye(){g!==null&&(de.mutate(g),F(null))}function te(){!o.date.trim()||!o.label.trim()||ie.mutate({date:o.date.trim(),label:o.label.trim(),...o.description.trim()?{description:o.description.trim()}:{},...o.color.trim()?{color:o.color.trim()}:{},...o.endDate.trim()?{endDate:o.endDate.trim()}:{},...o.charts.length>0?{charts:o.charts}:{}})}function re(e){e.key==="Enter"&&te(),e.key==="Escape"&&(D(!1),u({date:"",endDate:"",label:"",description:"",color:"",charts:[]}))}return y?t.jsx("div",{className:"p-6",style:{color:"var(--yc-color-text-secondary)"},children:"Loading..."}):t.jsxs("div",{className:"p-6 max-w-5xl",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h2",{className:"text-lg font-semibold",style:{color:"var(--yc-color-text)"},children:"Events"}),n&&t.jsx("button",{onClick:()=>D(!0),disabled:O,className:"px-3 py-1.5 text-sm rounded text-white disabled:opacity-50",style:{backgroundColor:"var(--yc-color-primary, #3b82f6)"},children:"Add event"})]}),b.length===0&&!O?t.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"No events yet. Add events to annotate your time series charts with milestones, launches, and incidents."}):t.jsx("div",{className:"rounded-lg",style:{border:"1px solid var(--yc-color-border)"},children:t.jsxs("table",{className:"w-full text-sm table-fixed",style:{overflow:"visible"},children:[t.jsxs("colgroup",{children:[t.jsx("col",{style:{width:40}}),t.jsx("col",{style:{width:"12%"}}),t.jsx("col",{style:{width:"12%"}}),t.jsx("col",{style:{width:"16%"}}),t.jsx("col",{style:{width:"20%"}}),t.jsx("col",{style:{width:"12%"}}),t.jsx("col",{style:{width:"18%"}}),n&&t.jsx("col",{style:{width:48}})]}),t.jsx("thead",{className:"border-b",style:{backgroundColor:"var(--yc-color-input-bg)",borderColor:"var(--yc-color-border)"},children:t.jsxs("tr",{children:[t.jsx("th",{className:"text-right px-3 py-2 font-medium",style:{color:"var(--yc-color-text-muted)"},children:"#"}),t.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:"var(--yc-color-text-secondary)"},children:"Date"}),t.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:"var(--yc-color-text-secondary)"},children:"End Date"}),t.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:"var(--yc-color-text-secondary)"},children:"Label"}),t.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:"var(--yc-color-text-secondary)"},children:"Description"}),t.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:"var(--yc-color-text-secondary)"},children:"Color"}),t.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:"var(--yc-color-text-secondary)"},children:"Charts"}),n&&t.jsx("th",{className:"px-4 py-2"})]})}),t.jsxs("tbody",{children:[O&&t.jsxs("tr",{className:"border-b",style:{borderColor:"var(--yc-color-border)",backgroundColor:"color-mix(in srgb, var(--yc-color-primary) 5%, transparent)"},children:[t.jsx("td",{className:"px-3 py-2 text-right",style:{color:"var(--yc-color-text-muted)"},children:"—"}),t.jsxs("td",{className:"px-4 py-2 relative",children:[t.jsx("button",{onClick:()=>K(!J),className:"w-full px-2 py-1 text-sm rounded border box-border -my-1 text-left",style:{backgroundColor:"var(--yc-color-background)",borderColor:"var(--yc-color-border)",color:o.date?"var(--yc-color-text)":"var(--yc-color-text-muted)"},children:o.date||"Select date"}),J&&t.jsx(L,{selected:o.date?E(o.date,"yyyy-MM-dd",new Date):void 0,onSelect:e=>{u({...o,date:e}),K(!1)},onClose:()=>K(!1)})]}),t.jsxs("td",{className:"px-4 py-2 relative",children:[t.jsx("button",{onClick:()=>P(!U),className:"w-full px-2 py-1 text-sm rounded border box-border -my-1 text-left",style:{backgroundColor:"var(--yc-color-background)",borderColor:"var(--yc-color-border)",color:o.endDate?"var(--yc-color-text)":"var(--yc-color-text-muted)"},children:o.endDate||"—"}),U&&t.jsx(L,{selected:o.endDate?E(o.endDate,"yyyy-MM-dd",new Date):void 0,onSelect:e=>{u({...o,endDate:e}),P(!1)},onClose:()=>P(!1)})]}),t.jsx("td",{className:"px-4 py-2",children:t.jsx("input",{type:"text",value:o.label,onChange:e=>u({...o,label:e.target.value}),onKeyDown:re,placeholder:"Event label",className:"w-full px-2 py-1 text-sm rounded border box-border -my-1",style:{backgroundColor:"var(--yc-color-background)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text)"}})}),t.jsx("td",{className:"px-4 py-2",children:t.jsx("input",{type:"text",value:o.description,onChange:e=>u({...o,description:e.target.value}),onKeyDown:re,placeholder:"Optional",className:"w-full px-2 py-1 text-sm rounded border box-border -my-1",style:{backgroundColor:"var(--yc-color-background)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text)"}})}),t.jsx("td",{className:"px-4 py-2",children:t.jsx(ce,{value:o.color,onChange:e=>u({...o,color:e}),themePalette:(oe=i==null?void 0:i.theme)==null?void 0:oe.palette})}),t.jsxs("td",{className:"px-4 py-2 relative",children:[t.jsx("button",{onClick:()=>_(!N),className:"text-sm truncate max-w-full text-left",style:{color:o.charts.length>0?"var(--yc-color-text-secondary)":"var(--yc-color-text-muted)"},children:o.charts.length>0?o.charts.map(e=>f[e]??e).join(", "):"All charts"}),N&&(()=>{const e=q.toLowerCase(),r=e?w.filter(a=>(f[a]??a).toLowerCase().includes(e)||a.toLowerCase().includes(e)):w;return t.jsxs("div",{ref:T,className:"absolute z-50 rounded-lg shadow-lg p-2 text-sm min-w-[220px]",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)",top:"100%",left:16},onClick:a=>a.stopPropagation(),children:[t.jsx("input",{type:"text",value:q,onChange:a=>z(a.target.value),placeholder:"Search charts...",autoFocus:!0,className:"w-full px-2 py-1 text-sm rounded border mb-1",style:{backgroundColor:"var(--yc-color-background)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text)"}}),t.jsxs("div",{className:"max-h-52 overflow-y-auto",children:[!q&&t.jsxs("label",{className:"flex items-center gap-2 px-2 py-1 rounded cursor-pointer hover:opacity-80",style:{color:"var(--yc-color-text)"},children:[t.jsx("input",{type:"checkbox",checked:o.charts.length===0,onChange:()=>u({...o,charts:[]})}),"All charts"]}),r.map(a=>t.jsxs("label",{className:"flex items-center gap-2 px-2 py-1 rounded cursor-pointer hover:opacity-80",style:{color:"var(--yc-color-text)"},children:[t.jsx("input",{type:"checkbox",checked:o.charts.includes(a),onChange:()=>{const l=o.charts.includes(a)?o.charts.filter(p=>p!==a):[...o.charts,a];u({...o,charts:l})}}),f[a]??a]},a)),r.length===0&&t.jsx("div",{className:"px-2 py-2 text-center",style:{color:"var(--yc-color-text-muted)"},children:"No matching charts"})]})]})})()]}),t.jsx("td",{className:"px-4 py-2",children:t.jsxs("div",{className:"flex gap-1",children:[t.jsx("button",{onClick:te,disabled:!o.date.trim()||!o.label.trim(),className:"text-xs px-2 py-1 rounded text-white disabled:opacity-50",style:{backgroundColor:"var(--yc-color-primary, #3b82f6)"},children:"Save"}),t.jsx("button",{onClick:()=>{D(!1),u({date:"",endDate:"",label:"",description:"",color:"",charts:[]}),_(!1),z("")},className:"text-xs px-2 py-1 rounded",style:{color:"var(--yc-color-text-muted)"},children:"Cancel"})]})})]}),b.map((e,r)=>{var a;return t.jsxs("tr",{className:"border-b last:border-0",style:{borderColor:"var(--yc-color-border)"},children:[t.jsx("td",{className:"px-3 py-3 text-right",style:{color:"var(--yc-color-text-muted)"},children:r+1}),t.jsxs("td",{className:"px-4 py-3 relative",style:{color:"var(--yc-color-text)",cursor:n?"pointer":"default"},onClick:()=>{n&&R(X===r?null:r)},children:[e.date,X===r&&t.jsx(L,{selected:(()=>{try{return E(e.date,"yyyy-MM-dd",new Date)}catch{return}})(),onSelect:l=>{R(null),l!==e.date&&v.mutate({index:r,event:{...e,date:l}})},onClose:()=>R(null)})]}),t.jsxs("td",{className:"px-4 py-3 relative",style:{color:e.endDate?"var(--yc-color-text)":"var(--yc-color-text-muted)",cursor:n?"pointer":"default"},onClick:()=>{n&&B(Y===r?null:r)},children:[e.endDate||"—",Y===r&&t.jsx(L,{selected:(()=>{try{return e.endDate?E(e.endDate,"yyyy-MM-dd",new Date):void 0}catch{return}})(),onSelect:l=>{B(null),l!==e.endDate&&v.mutate({index:r,event:{...e,endDate:l}})},onClose:()=>B(null)})]}),t.jsx("td",{className:"px-4 py-3 font-medium",style:{color:"var(--yc-color-text)",cursor:n?"pointer":"default"},onClick:()=>Z(r,"label",e.label),children:(c==null?void 0:c.index)===r&&c.field==="label"?t.jsx("input",{ref:Q,type:"text",value:C,onChange:l=>M(l.target.value),onBlur:V,onKeyDown:ee,className:"w-full py-0 text-sm border-0 border-b outline-none",style:{backgroundColor:"transparent",borderColor:"var(--yc-color-primary, #3b82f6)",color:"var(--yc-color-text)",borderBottomWidth:1,borderBottomStyle:"solid"}}):e.label}),t.jsx("td",{className:"px-4 py-3",style:{color:e.description?"var(--yc-color-text-secondary)":"var(--yc-color-text-muted)",cursor:n?"pointer":"default"},onClick:()=>Z(r,"description",e.description??""),children:(c==null?void 0:c.index)===r&&c.field==="description"?t.jsx("input",{ref:Q,type:"text",value:C,onChange:l=>M(l.target.value),onBlur:V,onKeyDown:ee,placeholder:"Add description",className:"w-full py-0 text-sm border-0 border-b outline-none",style:{backgroundColor:"transparent",borderColor:"var(--yc-color-primary, #3b82f6)",color:"var(--yc-color-text)",borderBottomWidth:1,borderBottomStyle:"solid"}}):e.description?t.jsx(fe,{components:{p:({children:l})=>t.jsx("span",{children:l}),a:({href:l,children:p})=>t.jsx("a",{href:l,onClick:d=>d.stopPropagation(),...l&&!l.startsWith("#")?{target:"_blank",rel:"noopener noreferrer"}:{},style:{color:"var(--yc-color-primary, #3b82f6)",textDecoration:"underline"},children:p})},children:e.description}):"—"}),t.jsx("td",{className:"px-4 py-3",children:n?t.jsx(ce,{value:e.color??"",onChange:l=>{var p;v.mutate({index:r,event:{date:e.date,label:e.label,...e.description?{description:e.description}:{},...l?{color:l}:{},...e.endDate?{endDate:e.endDate}:{},...(p=e.charts)!=null&&p.length?{charts:e.charts}:{}}})},themePalette:(a=i==null?void 0:i.theme)==null?void 0:a.palette}):t.jsxs("span",{className:"flex items-center gap-2",children:[e.color&&t.jsx("span",{className:"w-4 h-4 rounded-full border inline-block flex-shrink-0",style:{backgroundColor:e.color,borderColor:"var(--yc-color-border)"}}),t.jsx("span",{style:{color:e.color?"var(--yc-color-text-secondary)":"var(--yc-color-text-muted)"},children:e.color||"—"})]})}),t.jsxs("td",{className:"px-4 py-3 relative",style:{color:"var(--yc-color-text-secondary)",cursor:n?"pointer":"default"},onClick:()=>{n&&(G(k===r?null:r),I(""))},children:[k===r?(()=>{const l=A.toLowerCase(),p=l?w.filter(d=>(f[d]??d).toLowerCase().includes(l)||d.toLowerCase().includes(l)):w;return t.jsxs("div",{ref:W,className:"absolute z-50 rounded-lg shadow-lg p-2 text-sm min-w-[220px]",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)",top:"100%",left:16},onClick:d=>d.stopPropagation(),children:[t.jsx("input",{type:"text",value:A,onChange:d=>I(d.target.value),placeholder:"Search charts...",autoFocus:!0,className:"w-full px-2 py-1 text-sm rounded border mb-1",style:{backgroundColor:"var(--yc-color-background)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text)"}}),t.jsxs("div",{className:"max-h-52 overflow-y-auto",children:[!A&&t.jsxs("label",{className:"flex items-center gap-2 px-2 py-1 rounded cursor-pointer hover:opacity-80",style:{color:"var(--yc-color-text)"},children:[t.jsx("input",{type:"checkbox",checked:!e.charts||e.charts.length===0,onChange:()=>{v.mutate({index:r,event:{date:e.date,label:e.label,...e.description?{description:e.description}:{},...e.color?{color:e.color}:{},...e.endDate?{endDate:e.endDate}:{}}})}}),"All charts"]}),p.map(d=>{var ae;return t.jsxs("label",{className:"flex items-center gap-2 px-2 py-1 rounded cursor-pointer hover:opacity-80",style:{color:"var(--yc-color-text)"},children:[t.jsx("input",{type:"checkbox",checked:((ae=e.charts)==null?void 0:ae.includes(d))??!1,onChange:()=>{const H=e.charts??[],se=H.includes(d)?H.filter(pe=>pe!==d):[...H,d];v.mutate({index:r,event:{date:e.date,label:e.label,...e.description?{description:e.description}:{},...e.color?{color:e.color}:{},...e.endDate?{endDate:e.endDate}:{},...se.length>0?{charts:se}:{}}})}}),f[d]??d]},d)}),p.length===0&&t.jsx("div",{className:"px-2 py-2 text-center",style:{color:"var(--yc-color-text-muted)"},children:"No matching charts"})]})]})})():null,e.charts&&e.charts.length>0?e.charts.map(l=>f[l]??l).join(", "):t.jsx("span",{style:{color:"var(--yc-color-text-muted)"},children:"All charts"})]}),n&&t.jsx("td",{className:"px-4 py-3 text-right",children:t.jsx("button",{onClick:()=>ue(r),title:"Delete event",className:"hover:opacity-80",style:{color:"var(--yc-color-danger, #ef4444)"},children:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0"})})})})]},r)})]})]})}),t.jsx(ve,{open:g!==null,title:"Delete event",message:`Delete "${g!==null?(le=b[g])==null?void 0:le.label:""}"? This cannot be undone.`,onConfirm:ye,onCancel:()=>F(null)})]})}export{De as EventManagement};
@@ -1 +1 @@
1
- import{j as e,i as k,I as E,J as B,t as M,K as W,N as $,a as D}from"./index-m_Jm3sB1.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 I({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 P({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(R,{}),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(q,{}),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 R(){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 q(){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 O(){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(P,{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(O,{}),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(I,{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-DD59fsOk.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-m_Jm3sB1.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-DD59fsOk.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};
@@ -0,0 +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-DD59fsOk.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 +1 @@
1
- import{u as g,j as e,A as h}from"./index-m_Jm3sB1.js";import{a as o}from"./echarts-DtOYsfLX.js";function j(){const m=g(r=>r.setup),[a,b]=o.useState(""),[l,x]=o.useState(""),[t,p]=o.useState(""),[c,y]=o.useState(""),[n,s]=o.useState(""),[d,u]=o.useState(!1),f=async r=>{if(r.preventDefault(),s(""),t!==c){s("Passwords do not match");return}if(t.length<8){s("Password must be at least 8 characters");return}u(!0);try{await m(a,l,t)}catch(i){i instanceof h?s(i.message):s("An unexpected error occurred")}finally{u(!1)}};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:"Welcome to Yamchart"}),e.jsx("p",{className:"text-sm mb-6",style:{color:"var(--yc-color-text-secondary)"},children:"Create your admin account to get started."}),n&&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:n}),e.jsxs("form",{onSubmit:f,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"name",className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Name"}),e.jsx("input",{id:"name",type:"text",value:l,onChange:r=>x(r.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:"Your Name"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"setup-email",className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Email"}),e.jsx("input",{id:"setup-email",type:"email",value:a,onChange:r=>b(r.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:"admin@example.com"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"setup-password",className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Password"}),e.jsx("input",{id:"setup-password",type:"password",value:t,onChange:r=>p(r.target.value),required:!0,minLength:8,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:"At least 8 characters"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"confirm-password",className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Confirm Password"}),e.jsx("input",{id:"confirm-password",type:"password",value:c,onChange:r=>y(r.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:"Confirm password"})]}),e.jsx("button",{type:"submit",disabled:d,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:d?"Creating account...":"Create Admin Account"})]})]})})}export{j as SetupWizard};
1
+ import{u as g,j as e,A as h}from"./index-DD59fsOk.js";import{a as o}from"./echarts-DtOYsfLX.js";function j(){const m=g(r=>r.setup),[a,b]=o.useState(""),[l,x]=o.useState(""),[t,p]=o.useState(""),[c,y]=o.useState(""),[n,s]=o.useState(""),[d,u]=o.useState(!1),f=async r=>{if(r.preventDefault(),s(""),t!==c){s("Passwords do not match");return}if(t.length<8){s("Password must be at least 8 characters");return}u(!0);try{await m(a,l,t)}catch(i){i instanceof h?s(i.message):s("An unexpected error occurred")}finally{u(!1)}};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:"Welcome to Yamchart"}),e.jsx("p",{className:"text-sm mb-6",style:{color:"var(--yc-color-text-secondary)"},children:"Create your admin account to get started."}),n&&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:n}),e.jsxs("form",{onSubmit:f,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"name",className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Name"}),e.jsx("input",{id:"name",type:"text",value:l,onChange:r=>x(r.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:"Your Name"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"setup-email",className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Email"}),e.jsx("input",{id:"setup-email",type:"email",value:a,onChange:r=>b(r.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:"admin@example.com"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"setup-password",className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Password"}),e.jsx("input",{id:"setup-password",type:"password",value:t,onChange:r=>p(r.target.value),required:!0,minLength:8,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:"At least 8 characters"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"confirm-password",className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Confirm Password"}),e.jsx("input",{id:"confirm-password",type:"password",value:c,onChange:r=>y(r.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:"Confirm password"})]}),e.jsx("button",{type:"submit",disabled:d,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:d?"Creating account...":"Create Admin Account"})]})]})})}export{j as SetupWizard};
@@ -1 +1 @@
1
- import{j as e,a as c}from"./index-m_Jm3sB1.js";import{a as s}from"./echarts-DtOYsfLX.js";function h(){const[o,a]=s.useState([]),[l,d]=s.useState(!0),n=async()=>{try{const r=await c.listShareLinks();a(r.links)}catch(r){console.error("Failed to load share links:",r)}finally{d(!1)}};s.useEffect(()=>{n()},[]);const i=async r=>{try{await c.revokeShareLink(r),a(t=>t.filter(x=>x.id!==r))}catch(t){console.error("Failed to revoke share link:",t)}};return l?e.jsx("div",{className:"p-6",style:{color:"var(--yc-color-text-secondary)"},children:"Loading..."}):e.jsxs("div",{className:"p-6 max-w-4xl",children:[e.jsx("h2",{className:"text-lg font-semibold mb-4",style:{color:"var(--yc-color-text)"},children:"Shared Links"}),o.length===0?e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"No active share links."}):e.jsx("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--yc-color-border)"},children:e.jsxs("table",{className:"w-full text-sm yc-table",children:[e.jsx("thead",{className:"border-b",style:{backgroundColor:"var(--yc-color-input-bg)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text-secondary)"},children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-right px-3 py-2 font-medium w-10",style:{color:"var(--yc-color-text-muted)"},children:"#"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Resource"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Type"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Created"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Expires"}),e.jsx("th",{className:"px-4 py-2"})]})}),e.jsx("tbody",{children:o.map((r,t)=>e.jsxs("tr",{className:"border-b last:border-0",style:{borderColor:"var(--yc-color-border)"},children:[e.jsx("td",{className:"px-3 py-3 text-right yc-row-num w-10",children:t+1}),e.jsx("td",{className:"px-4 py-3 font-medium",style:{color:"var(--yc-color-text)"},children:r.resource_name}),e.jsx("td",{className:"px-4 py-3 capitalize",style:{color:"var(--yc-color-text-secondary)"},children:r.resource_type}),e.jsx("td",{className:"px-4 py-3",style:{color:"var(--yc-color-text-secondary)"},children:new Date(r.created_at).toLocaleDateString()}),e.jsx("td",{className:"px-4 py-3",style:{color:"var(--yc-color-text-secondary)"},children:r.expires_at?new Date(r.expires_at).toLocaleDateString():"Never"}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsx("button",{onClick:()=>i(r.id),className:"text-sm hover:opacity-80",style:{color:"var(--yc-color-danger)"},children:"Revoke"})})]},r.id))})]})})]})}export{h as ShareManagement};
1
+ import{j as e,a as c}from"./index-DD59fsOk.js";import{a as s}from"./echarts-DtOYsfLX.js";function h(){const[o,a]=s.useState([]),[l,d]=s.useState(!0),n=async()=>{try{const r=await c.listShareLinks();a(r.links)}catch(r){console.error("Failed to load share links:",r)}finally{d(!1)}};s.useEffect(()=>{n()},[]);const i=async r=>{try{await c.revokeShareLink(r),a(t=>t.filter(x=>x.id!==r))}catch(t){console.error("Failed to revoke share link:",t)}};return l?e.jsx("div",{className:"p-6",style:{color:"var(--yc-color-text-secondary)"},children:"Loading..."}):e.jsxs("div",{className:"p-6 max-w-4xl",children:[e.jsx("h2",{className:"text-lg font-semibold mb-4",style:{color:"var(--yc-color-text)"},children:"Shared Links"}),o.length===0?e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"No active share links."}):e.jsx("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--yc-color-border)"},children:e.jsxs("table",{className:"w-full text-sm yc-table",children:[e.jsx("thead",{className:"border-b",style:{backgroundColor:"var(--yc-color-input-bg)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text-secondary)"},children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-right px-3 py-2 font-medium w-10",style:{color:"var(--yc-color-text-muted)"},children:"#"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Resource"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Type"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Created"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Expires"}),e.jsx("th",{className:"px-4 py-2"})]})}),e.jsx("tbody",{children:o.map((r,t)=>e.jsxs("tr",{className:"border-b last:border-0",style:{borderColor:"var(--yc-color-border)"},children:[e.jsx("td",{className:"px-3 py-3 text-right yc-row-num w-10",children:t+1}),e.jsx("td",{className:"px-4 py-3 font-medium",style:{color:"var(--yc-color-text)"},children:r.resource_name}),e.jsx("td",{className:"px-4 py-3 capitalize",style:{color:"var(--yc-color-text-secondary)"},children:r.resource_type}),e.jsx("td",{className:"px-4 py-3",style:{color:"var(--yc-color-text-secondary)"},children:new Date(r.created_at).toLocaleDateString()}),e.jsx("td",{className:"px-4 py-3",style:{color:"var(--yc-color-text-secondary)"},children:r.expires_at?new Date(r.expires_at).toLocaleDateString():"Never"}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsx("button",{onClick:()=>i(r.id),className:"text-sm hover:opacity-80",style:{color:"var(--yc-color-danger)"},children:"Revoke"})})]},r.id))})]})})]})}export{h as ShareManagement};
@@ -1 +1 @@
1
- import{j as e,a as p,A as j}from"./index-m_Jm3sB1.js";import{a as s}from"./echarts-DtOYsfLX.js";function O(){var A;const[i,N]=s.useState([]),[b,C]=s.useState(!0),[h,v]=s.useState(!1),[x,w]=s.useState(""),[l,g]=s.useState(null),[u,c]=s.useState([]),[m,y]=s.useState(!1),d=async()=>{try{const{users:t}=await p.authListUsers();N(t)}catch{w("Failed to load users")}finally{C(!1)}};s.useEffect(()=>{d()},[]);const a=async(t,r)=>{try{await p.authUpdateUser(t,{role:r}),await d()}catch(o){alert(o instanceof j?o.message:"Failed to update role")}},f=async(t,r)=>{if(confirm(`Delete user "${r}"? This cannot be undone.`))try{await p.authDeleteUser(t),await d()}catch(o){alert(o instanceof j?o.message:"Failed to delete user")}},U=t=>{if(l===t.id)g(null),c([]);else{g(t.id);const r=JSON.parse(t.attributes||"{}");c(Object.entries(r).map(([o,n])=>({key:o,value:n})))}},k=(t,r,o)=>{c(n=>n.map((S,M)=>M===t?{...S,[r]:o}:S))},E=()=>{c(t=>[...t,{key:"",value:""}])},L=t=>{c(r=>r.filter((o,n)=>n!==t))},D=async()=>{if(l){y(!0);try{const t={};for(const{key:r,value:o}of u){const n=r.trim();n&&(t[n]=o)}await p.authUpdateUser(l,{attributes:t}),await d(),c(Object.entries(t).map(([r,o])=>({key:r,value:o})))}catch(t){alert(t instanceof j?t.message:"Failed to save attributes")}finally{y(!1)}}};return b?e.jsx("div",{className:"p-6",style:{color:"var(--yc-color-text-secondary)"},children:"Loading users..."}):e.jsxs("div",{className:"p-6 max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h1",{className:"text-xl font-semibold",style:{color:"var(--yc-color-text)"},children:"User Management"}),e.jsx("button",{onClick:()=>v(!0),className:"px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700",children:"Add User"})]}),x&&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:x}),e.jsx("div",{className:"rounded-lg overflow-hidden",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)"},children:e.jsxs("table",{className:"w-full yc-table",children:[e.jsx("thead",{className:"border-b",style:{backgroundColor:"var(--yc-color-input-bg)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text-secondary)"},children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-3 text-right text-xs font-medium w-10",style:{color:"var(--yc-color-text-muted)"},children:"#"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase",children:"Name"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase",children:"Email"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase",children:"Role"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase",children:"Created"}),e.jsx("th",{className:"px-4 py-3 text-right text-xs font-medium uppercase",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y",style:{borderColor:"var(--yc-color-border)"},children:i.map((t,r)=>e.jsxs("tr",{className:"group",children:[e.jsx("td",{className:"px-3 py-3 text-right text-sm yc-row-num w-10",children:r+1}),e.jsx("td",{className:"px-4 py-3 text-sm",style:{color:"var(--yc-color-text)"},children:t.name}),e.jsx("td",{className:"px-4 py-3 text-sm",style:{color:"var(--yc-color-text-secondary)"},children:t.email}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("select",{value:t.role,onChange:o=>a(t.id,o.target.value),className:"text-sm border rounded px-2 py-1",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},children:[e.jsx("option",{value:"admin",children:"Admin"}),e.jsx("option",{value:"editor",children:"Editor"}),e.jsx("option",{value:"viewer",children:"Viewer"})]})}),e.jsx("td",{className:"px-4 py-3 text-sm",style:{color:"var(--yc-color-text-secondary)"},children:new Date(t.created_at).toLocaleDateString()}),e.jsxs("td",{className:"px-4 py-3 text-right space-x-3",children:[e.jsx("button",{onClick:()=>U(t),className:"text-sm hover:opacity-80",style:{color:"var(--yc-color-primary)"},children:l===t.id?"Hide Attrs":"Attrs"}),e.jsx("button",{onClick:()=>f(t.id,t.name),className:"text-sm hover:opacity-80",style:{color:"var(--yc-color-danger)"},children:"Delete"})]})]},t.id))})]})}),l&&e.jsxs("div",{className:"mt-4 rounded-lg p-4",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h3",{className:"text-sm font-medium",style:{color:"var(--yc-color-text-secondary)"},children:["Attributes for ",(A=i.find(t=>t.id===l))==null?void 0:A.name]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:E,className:"px-3 py-1 text-xs font-medium rounded hover:opacity-80",style:{color:"var(--yc-color-primary)",border:"1px solid color-mix(in srgb, var(--yc-color-primary) 50%, transparent)"},children:"Add Attribute"}),e.jsx("button",{onClick:D,disabled:m,className:"px-3 py-1 text-xs font-medium text-white bg-blue-600 rounded hover:bg-blue-700 disabled:opacity-50",children:m?"Saving...":"Save"})]})]}),u.length===0?e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-muted)"},children:'No attributes. Click "Add Attribute" to define key-value pairs for row-level security.'}):e.jsx("div",{className:"space-y-2",children:u.map((t,r)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",placeholder:"Key (e.g. department)",value:t.key,onChange:o=>k(r,"key",o.target.value),className:"flex-1 px-3 py-1.5 text-sm border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"}}),e.jsx("input",{type:"text",placeholder:"Value (e.g. Sales)",value:t.value,onChange:o=>k(r,"value",o.target.value),className:"flex-1 px-3 py-1.5 text-sm border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"}}),e.jsx("button",{onClick:()=>L(r),className:"p-1.5 hover:opacity-80",style:{color:"var(--yc-color-text-muted)"},title:"Remove attribute",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},r))})]}),h&&e.jsx(R,{onClose:()=>v(!1),onCreated:d})]})}function R({onClose:i,onCreated:N}){const[b,C]=s.useState(""),[h,v]=s.useState(""),[x,w]=s.useState(""),[l,g]=s.useState("viewer"),[u,c]=s.useState(""),[m,y]=s.useState(!1),d=async a=>{a.preventDefault(),c(""),y(!0);try{await p.authCreateUser({email:b,name:h,password:x,role:l}),N(),i()}catch(f){c(f instanceof j?f.message:"Failed to create user")}finally{y(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:i,children:e.jsxs("div",{className:"rounded-lg shadow-lg p-6 w-full max-w-md",style:{backgroundColor:"var(--yc-color-surface)"},onClick:a=>a.stopPropagation(),children:[e.jsx("h2",{className:"text-lg font-semibold mb-4",style:{color:"var(--yc-color-text)"},children:"Add User"}),u&&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:u}),e.jsxs("form",{onSubmit:d,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Name"}),e.jsx("input",{type:"text",value:h,onChange:a=>v(a.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",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Email"}),e.jsx("input",{type:"email",value:b,onChange:a=>C(a.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",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Temporary Password"}),e.jsx("input",{type:"password",value:x,onChange:a=>w(a.target.value),required:!0,minLength:8,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Role"}),e.jsxs("select",{value:l,onChange:a=>g(a.target.value),className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},children:[e.jsx("option",{value:"viewer",children:"Viewer"}),e.jsx("option",{value:"editor",children:"Editor"}),e.jsx("option",{value:"admin",children:"Admin"})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:i,className:"px-4 py-2 text-sm hover:bg-black/5 rounded-md",style:{color:"var(--yc-color-text-secondary)"},children:"Cancel"}),e.jsx("button",{type:"submit",disabled:m,className:"px-4 py-2 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700 disabled:opacity-50",children:m?"Creating...":"Create User"})]})]})]})})}export{O as UserManagement};
1
+ import{j as e,a as p,A as j}from"./index-DD59fsOk.js";import{a as s}from"./echarts-DtOYsfLX.js";function O(){var A;const[i,N]=s.useState([]),[b,C]=s.useState(!0),[h,v]=s.useState(!1),[x,w]=s.useState(""),[l,g]=s.useState(null),[u,c]=s.useState([]),[m,y]=s.useState(!1),d=async()=>{try{const{users:t}=await p.authListUsers();N(t)}catch{w("Failed to load users")}finally{C(!1)}};s.useEffect(()=>{d()},[]);const a=async(t,r)=>{try{await p.authUpdateUser(t,{role:r}),await d()}catch(o){alert(o instanceof j?o.message:"Failed to update role")}},f=async(t,r)=>{if(confirm(`Delete user "${r}"? This cannot be undone.`))try{await p.authDeleteUser(t),await d()}catch(o){alert(o instanceof j?o.message:"Failed to delete user")}},U=t=>{if(l===t.id)g(null),c([]);else{g(t.id);const r=JSON.parse(t.attributes||"{}");c(Object.entries(r).map(([o,n])=>({key:o,value:n})))}},k=(t,r,o)=>{c(n=>n.map((S,M)=>M===t?{...S,[r]:o}:S))},E=()=>{c(t=>[...t,{key:"",value:""}])},L=t=>{c(r=>r.filter((o,n)=>n!==t))},D=async()=>{if(l){y(!0);try{const t={};for(const{key:r,value:o}of u){const n=r.trim();n&&(t[n]=o)}await p.authUpdateUser(l,{attributes:t}),await d(),c(Object.entries(t).map(([r,o])=>({key:r,value:o})))}catch(t){alert(t instanceof j?t.message:"Failed to save attributes")}finally{y(!1)}}};return b?e.jsx("div",{className:"p-6",style:{color:"var(--yc-color-text-secondary)"},children:"Loading users..."}):e.jsxs("div",{className:"p-6 max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h1",{className:"text-xl font-semibold",style:{color:"var(--yc-color-text)"},children:"User Management"}),e.jsx("button",{onClick:()=>v(!0),className:"px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700",children:"Add User"})]}),x&&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:x}),e.jsx("div",{className:"rounded-lg overflow-hidden",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)"},children:e.jsxs("table",{className:"w-full yc-table",children:[e.jsx("thead",{className:"border-b",style:{backgroundColor:"var(--yc-color-input-bg)",borderColor:"var(--yc-color-border)",color:"var(--yc-color-text-secondary)"},children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-3 text-right text-xs font-medium w-10",style:{color:"var(--yc-color-text-muted)"},children:"#"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase",children:"Name"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase",children:"Email"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase",children:"Role"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase",children:"Created"}),e.jsx("th",{className:"px-4 py-3 text-right text-xs font-medium uppercase",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y",style:{borderColor:"var(--yc-color-border)"},children:i.map((t,r)=>e.jsxs("tr",{className:"group",children:[e.jsx("td",{className:"px-3 py-3 text-right text-sm yc-row-num w-10",children:r+1}),e.jsx("td",{className:"px-4 py-3 text-sm",style:{color:"var(--yc-color-text)"},children:t.name}),e.jsx("td",{className:"px-4 py-3 text-sm",style:{color:"var(--yc-color-text-secondary)"},children:t.email}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("select",{value:t.role,onChange:o=>a(t.id,o.target.value),className:"text-sm border rounded px-2 py-1",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},children:[e.jsx("option",{value:"admin",children:"Admin"}),e.jsx("option",{value:"editor",children:"Editor"}),e.jsx("option",{value:"viewer",children:"Viewer"})]})}),e.jsx("td",{className:"px-4 py-3 text-sm",style:{color:"var(--yc-color-text-secondary)"},children:new Date(t.created_at).toLocaleDateString()}),e.jsxs("td",{className:"px-4 py-3 text-right space-x-3",children:[e.jsx("button",{onClick:()=>U(t),className:"text-sm hover:opacity-80",style:{color:"var(--yc-color-primary)"},children:l===t.id?"Hide Attrs":"Attrs"}),e.jsx("button",{onClick:()=>f(t.id,t.name),className:"text-sm hover:opacity-80",style:{color:"var(--yc-color-danger)"},children:"Delete"})]})]},t.id))})]})}),l&&e.jsxs("div",{className:"mt-4 rounded-lg p-4",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h3",{className:"text-sm font-medium",style:{color:"var(--yc-color-text-secondary)"},children:["Attributes for ",(A=i.find(t=>t.id===l))==null?void 0:A.name]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:E,className:"px-3 py-1 text-xs font-medium rounded hover:opacity-80",style:{color:"var(--yc-color-primary)",border:"1px solid color-mix(in srgb, var(--yc-color-primary) 50%, transparent)"},children:"Add Attribute"}),e.jsx("button",{onClick:D,disabled:m,className:"px-3 py-1 text-xs font-medium text-white bg-blue-600 rounded hover:bg-blue-700 disabled:opacity-50",children:m?"Saving...":"Save"})]})]}),u.length===0?e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-muted)"},children:'No attributes. Click "Add Attribute" to define key-value pairs for row-level security.'}):e.jsx("div",{className:"space-y-2",children:u.map((t,r)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",placeholder:"Key (e.g. department)",value:t.key,onChange:o=>k(r,"key",o.target.value),className:"flex-1 px-3 py-1.5 text-sm border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"}}),e.jsx("input",{type:"text",placeholder:"Value (e.g. Sales)",value:t.value,onChange:o=>k(r,"value",o.target.value),className:"flex-1 px-3 py-1.5 text-sm border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"}}),e.jsx("button",{onClick:()=>L(r),className:"p-1.5 hover:opacity-80",style:{color:"var(--yc-color-text-muted)"},title:"Remove attribute",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},r))})]}),h&&e.jsx(R,{onClose:()=>v(!1),onCreated:d})]})}function R({onClose:i,onCreated:N}){const[b,C]=s.useState(""),[h,v]=s.useState(""),[x,w]=s.useState(""),[l,g]=s.useState("viewer"),[u,c]=s.useState(""),[m,y]=s.useState(!1),d=async a=>{a.preventDefault(),c(""),y(!0);try{await p.authCreateUser({email:b,name:h,password:x,role:l}),N(),i()}catch(f){c(f instanceof j?f.message:"Failed to create user")}finally{y(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:i,children:e.jsxs("div",{className:"rounded-lg shadow-lg p-6 w-full max-w-md",style:{backgroundColor:"var(--yc-color-surface)"},onClick:a=>a.stopPropagation(),children:[e.jsx("h2",{className:"text-lg font-semibold mb-4",style:{color:"var(--yc-color-text)"},children:"Add User"}),u&&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:u}),e.jsxs("form",{onSubmit:d,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Name"}),e.jsx("input",{type:"text",value:h,onChange:a=>v(a.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",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Email"}),e.jsx("input",{type:"email",value:b,onChange:a=>C(a.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",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Temporary Password"}),e.jsx("input",{type:"password",value:x,onChange:a=>w(a.target.value),required:!0,minLength:8,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Role"}),e.jsxs("select",{value:l,onChange:a=>g(a.target.value),className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},children:[e.jsx("option",{value:"viewer",children:"Viewer"}),e.jsx("option",{value:"editor",children:"Editor"}),e.jsx("option",{value:"admin",children:"Admin"})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:i,className:"px-4 py-2 text-sm hover:bg-black/5 rounded-md",style:{color:"var(--yc-color-text-secondary)"},children:"Cancel"}),e.jsx("button",{type:"submit",disabled:m,className:"px-4 py-2 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700 disabled:opacity-50",children:m?"Creating...":"Create User"})]})]})]})})}export{O as UserManagement};