@malloydata/malloy-explorer 0.0.295-dev250710213205 → 0.0.299-dev250808170326

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 (68) hide show
  1. package/@flowtypes/components/MalloyExplorerProvider.flow.js +1 -1
  2. package/dist/cjs/index.cjs +1163 -573
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/esm/index.js +1130 -540
  5. package/dist/esm/index.js.map +1 -1
  6. package/dist/malloy-explorer.css +1 -2
  7. package/dist/types/components/FieldToken.d.ts +5 -1
  8. package/dist/types/components/MalloyExplorerProvider.d.ts +1 -1
  9. package/dist/types/components/QueryPanel/AddMenu/AddAggregate.d.ts +1 -3
  10. package/dist/types/components/QueryPanel/AddMenu/AddEmptyNest.d.ts +1 -3
  11. package/dist/types/components/QueryPanel/AddMenu/AddGroupBy.d.ts +1 -3
  12. package/dist/types/components/QueryPanel/AddMenu/AddLimit.d.ts +1 -3
  13. package/dist/types/components/QueryPanel/AddMenu/AddMenu.d.ts +1 -3
  14. package/dist/types/components/QueryPanel/AddMenu/AddOrderBy.d.ts +1 -3
  15. package/dist/types/components/QueryPanel/AddMenu/AddView.d.ts +1 -3
  16. package/dist/types/components/QueryPanel/AddMenu/AddWhere.d.ts +0 -2
  17. package/dist/types/components/QueryPanel/Operations.d.ts +2 -3
  18. package/dist/types/components/QueryPanel/Parameters.d.ts +3 -3
  19. package/dist/types/components/QueryPanel/Query.d.ts +3 -4
  20. package/dist/types/components/QueryPanel/Source.d.ts +3 -3
  21. package/dist/types/components/QueryPanel/View.d.ts +2 -3
  22. package/dist/types/components/QueryPanel/ViewDefinition.d.ts +2 -3
  23. package/dist/types/components/QueryPanel/Visualization.d.ts +1 -2
  24. package/dist/types/components/QueryPanel/VizEditor/VizEditor.d.ts +1 -2
  25. package/dist/types/components/QueryPanel/VizEditor/VizEditorDialog.d.ts +1 -2
  26. package/dist/types/components/QueryPanel/VizEditor/VizEditorPopover.d.ts +1 -2
  27. package/dist/types/components/QueryPanel/VizEditor/styles.d.ts +3 -0
  28. package/dist/types/components/QueryPanel/VizEditor/utils.d.ts +3 -0
  29. package/dist/types/components/QueryPanel/operations/AggregateOperations.d.ts +3 -4
  30. package/dist/types/components/QueryPanel/operations/DrillOperations.d.ts +1 -2
  31. package/dist/types/components/QueryPanel/operations/FilterOperations.d.ts +2 -3
  32. package/dist/types/components/QueryPanel/operations/GroupByOperations.d.ts +2 -3
  33. package/dist/types/components/QueryPanel/operations/LimitOperation.d.ts +2 -3
  34. package/dist/types/components/QueryPanel/operations/NestOperation.d.ts +3 -5
  35. package/dist/types/components/QueryPanel/operations/OperationActionTitle.d.ts +0 -2
  36. package/dist/types/components/QueryPanel/operations/OrderByOperations.d.ts +2 -3
  37. package/dist/types/components/QueryPanel/operations/RenameDialog.d.ts +3 -4
  38. package/dist/types/components/QueryPanel/operations/SortableOperations.d.ts +3 -4
  39. package/dist/types/components/ResultPanel/DownloadButton.d.ts +6 -0
  40. package/dist/types/components/SourcePanel/FieldGroupList.d.ts +3 -1
  41. package/dist/types/components/SourcePanel/FieldTokenWithActions.d.ts +3 -2
  42. package/dist/types/components/SourcePanel/SearchResultList.d.ts +3 -1
  43. package/dist/types/components/SourcePanel/hooks/useOperations.d.ts +0 -4
  44. package/dist/types/components/primitives/DropdownMenu.d.ts +1 -1
  45. package/dist/types/components/primitives/utils/icon.d.ts +6 -0
  46. package/dist/types/components/utils/axis.d.ts +10 -0
  47. package/dist/types/components/utils/download.d.ts +44 -0
  48. package/dist/types/components/utils/download.spec.d.ts +1 -0
  49. package/dist/types/components/utils/icon.d.ts +3 -3
  50. package/dist/types/components/utils/segment.d.ts +1 -0
  51. package/dist/types/contexts/QueryEditorContext.d.ts +1 -10
  52. package/dist/types/hooks/useQueryBuilder.d.ts +2 -2
  53. package/dist/types/hooks/useQueryUpdate.d.ts +10 -0
  54. package/dist/types/hooks/useTopValues.d.ts +18 -0
  55. package/package.json +8 -8
  56. package/.editorconfig +0 -8
  57. package/.github/workflows/prerelease.yaml +0 -28
  58. package/.github/workflows/test.yaml +0 -26
  59. package/.gitmodules +0 -3
  60. package/.node-version +0 -1
  61. package/.prettierrc.js +0 -8
  62. package/.vscode/extensions.json +0 -6
  63. package/babel.config.cjs +0 -49
  64. package/eslint.config.mjs +0 -150
  65. package/index.html +0 -19
  66. package/jest.config.ts +0 -27
  67. package/postcss.config.mjs +0 -20
  68. package/vite.config.mts +0 -69
@@ -17,7 +17,7 @@ var _a, _b, _captureMap, _compiled, _pattern, _nameMap, _strategy, __EmulatedReg
17
17
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
18
18
  const jsxRuntime = require("react/jsx-runtime");
19
19
  const React = require("react");
20
- const QB = require("@malloydata/malloy-query-builder");
20
+ const malloyQueryBuilder = require("@malloydata/malloy-query-builder");
21
21
  const malloyTag = require("@malloydata/malloy-tag");
22
22
  const render = require("@malloydata/render");
23
23
  const malloyFilter = require("@malloydata/malloy-filter");
@@ -39,7 +39,6 @@ function _interopNamespaceDefault(e) {
39
39
  return Object.freeze(n);
40
40
  }
41
41
  const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
42
- const QB__namespace = /* @__PURE__ */ _interopNamespaceDefault(QB);
43
42
  const ReactDOM__namespace = /* @__PURE__ */ _interopNamespaceDefault(ReactDOM);
44
43
  function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
45
44
  return function handleEvent(event) {
@@ -3329,11 +3328,14 @@ var Root3$1 = Tooltip;
3329
3328
  var Trigger$4 = TooltipTrigger;
3330
3329
  var Portal$4 = TooltipPortal;
3331
3330
  var Content2$4 = TooltipContent;
3332
- const QueryEditorContext = /* @__PURE__ */ React__namespace.createContext({});
3331
+ const QueryEditorContext = /* @__PURE__ */ React__namespace.createContext({
3332
+ setQuery: () => {
3333
+ }
3334
+ });
3333
3335
  function useQueryBuilder(source, query) {
3334
3336
  return React.useMemo(() => {
3335
3337
  if (source) {
3336
- return new QB__namespace.ASTQuery({
3338
+ return new malloyQueryBuilder.ASTQuery({
3337
3339
  query,
3338
3340
  source
3339
3341
  });
@@ -3363,7 +3365,7 @@ function MalloyQueryFocusProvider({
3363
3365
  }
3364
3366
  if (rootQuery) {
3365
3367
  const queryDef = rootQuery.definition;
3366
- if (queryDef instanceof QB.ASTArrowQueryDefinition) {
3368
+ if (queryDef instanceof malloyQueryBuilder.ASTArrowQueryDefinition) {
3367
3369
  return findNestView(queryDef.view, [...focusedNestViewPath].reverse());
3368
3370
  }
3369
3371
  }
@@ -3397,12 +3399,12 @@ const findNestView = (currentView, remainingPath) => {
3397
3399
  if (remainingPath.length === 0) {
3398
3400
  return null;
3399
3401
  }
3400
- if (currentView instanceof QB.ASTArrowViewDefinition) {
3402
+ if (currentView instanceof malloyQueryBuilder.ASTArrowViewDefinition) {
3401
3403
  return findNestView(currentView.view, remainingPath);
3402
3404
  }
3403
- if (currentView instanceof QB.ASTSegmentViewDefinition) {
3405
+ if (currentView instanceof malloyQueryBuilder.ASTSegmentViewDefinition) {
3404
3406
  const currentNestName = remainingPath.pop();
3405
- const currentNestOperation = currentView.operations.items.find((operation) => operation instanceof QB.ASTNestViewOperation && operation.name === currentNestName);
3407
+ const currentNestOperation = currentView.operations.items.find((operation) => operation instanceof malloyQueryBuilder.ASTNestViewOperation && operation.name === currentNestName);
3406
3408
  if (currentNestOperation === void 0) {
3407
3409
  remainingPath.push(currentNestName);
3408
3410
  return null;
@@ -3412,15 +3414,34 @@ const findNestView = (currentView, remainingPath) => {
3412
3414
  return findNestView(currentNestOperation.view.definition, remainingPath);
3413
3415
  }
3414
3416
  }
3415
- if (currentView instanceof QB.ASTRefinementViewDefinition) {
3417
+ if (currentView instanceof malloyQueryBuilder.ASTRefinementViewDefinition) {
3416
3418
  return findNestView(currentView.refinement, remainingPath);
3417
3419
  }
3418
3420
  return null;
3419
3421
  };
3422
+ const UpdateQueryContext = /* @__PURE__ */ React.createContext({
3423
+ updateQuery: () => {
3424
+ console.warn("Missing <MalloyExplorerProvider>");
3425
+ }
3426
+ });
3427
+ function useUpdateQuery() {
3428
+ const {
3429
+ updateQuery
3430
+ } = React.useContext(UpdateQueryContext);
3431
+ return updateQuery;
3432
+ }
3433
+ const TopValuesContext = /* @__PURE__ */ React.createContext({});
3434
+ function useTopValues() {
3435
+ const {
3436
+ topValues
3437
+ } = React.useContext(TopValuesContext);
3438
+ return topValues;
3439
+ }
3420
3440
  function MalloyExplorerProvider({
3421
3441
  source,
3422
3442
  query,
3423
- onQueryChange,
3443
+ onQueryChange = () => {
3444
+ },
3424
3445
  focusedNestViewPath,
3425
3446
  onFocusedNestViewPathChange,
3426
3447
  children,
@@ -3428,20 +3449,32 @@ function MalloyExplorerProvider({
3428
3449
  onDrill
3429
3450
  }) {
3430
3451
  const rootQuery = useQueryBuilder(source, query);
3452
+ const updateQuery = React.useCallback(() => {
3453
+ onQueryChange == null ? void 0 : onQueryChange(rootQuery == null ? void 0 : rootQuery.build());
3454
+ }, [onQueryChange, rootQuery]);
3431
3455
  return /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, {
3432
3456
  children: /* @__PURE__ */ jsxRuntime.jsx(MalloyQueryFocusProvider, {
3433
3457
  rootQuery,
3434
3458
  focusedNestViewPath,
3435
3459
  onFocusedNestViewPathChange,
3436
- children: /* @__PURE__ */ jsxRuntime.jsx(QueryEditorContext.Provider, {
3460
+ children: /* @__PURE__ */ jsxRuntime.jsx(UpdateQueryContext.Provider, {
3437
3461
  value: {
3438
- source,
3439
- rootQuery,
3440
- setQuery: onQueryChange,
3441
- topValues,
3442
- onDrill
3462
+ updateQuery
3443
3463
  },
3444
- children
3464
+ children: /* @__PURE__ */ jsxRuntime.jsx(TopValuesContext.Provider, {
3465
+ value: {
3466
+ topValues
3467
+ },
3468
+ children: /* @__PURE__ */ jsxRuntime.jsx(QueryEditorContext.Provider, {
3469
+ value: {
3470
+ source,
3471
+ rootQuery,
3472
+ setQuery: onQueryChange,
3473
+ onDrill
3474
+ },
3475
+ children
3476
+ })
3477
+ })
3445
3478
  })
3446
3479
  })
3447
3480
  });
@@ -3813,6 +3846,7 @@ const SvgInfo = (props2) => /* @__PURE__ */ React__namespace.createElement("svg"
3813
3846
  const SvgError = (props2) => /* @__PURE__ */ React__namespace.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 -960 960 960", width: "24px", fill: "currentColor", ...props2 }, /* @__PURE__ */ React__namespace.createElement("path", { d: "M480-280q17 0 28.5-11.5T520-320q0-17-11.5-28.5T480-360q-17 0-28.5 11.5T440-320q0 17 11.5 28.5T480-280Zm-40-160h80v-240h-80v240ZM330-120 120-330v-300l210-210h300l210 210v300L630-120H330Zm34-80h232l164-164v-232L596-760H364L200-596v232l164 164Zm116-280Z" }));
3814
3847
  const SvgRefresh = (props2) => /* @__PURE__ */ React__namespace.createElement("svg", { height: 20, viewBox: "0 0 20 20", width: 20, xmlns: "http://www.w3.org/2000/svg", ...props2 }, /* @__PURE__ */ React__namespace.createElement("g", { fill: "none", stroke: "currentColor" }, /* @__PURE__ */ React__namespace.createElement("path", { d: "m17.08 11.15c.01.16.02.32.02.49 0 3.89-3.16 7.05-7.05 7.05-3.89-.01-7.05-3.16-7.05-7.06 0-3.89 3.16-7.05 7.05-7.05.85 0 1.66.15 2.41.42", strokeWidth: 1.1 }), /* @__PURE__ */ React__namespace.createElement("path", { d: "m9.9 2 2.89 2.89-3 3.01" })));
3815
3848
  const SvgSidebarCollapse = (props2) => /* @__PURE__ */ React__namespace.createElement("svg", { height: 24, viewBox: "0 0 24 24", width: 24, xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", stroke: "none", ...props2 }, /* @__PURE__ */ React__namespace.createElement("path", { fill: "currentColor", stroke: "none", d: "m20 24h-16c-2.2 0-4-1.8-4-4v-16c0-2.2 1.8-4 4-4h16c2.2 0 4 1.8 4 4v16c0 2.2-1.8 4-4 4zm-16-22c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2v-16c0-1.1-.9-2-2-2z" }), /* @__PURE__ */ React__namespace.createElement("path", { fill: "currentColor", d: "m8 24c-.6 0-1-.4-1-1v-22c0-.6.4-1 1-1s1 .4 1 1v22c0 .6-.4 1-1 1z" }), /* @__PURE__ */ React__namespace.createElement("path", { fill: "currentColor", d: "m14 13c-.3 0-.5-.1-.7-.3-.4-.4-.4-1 0-1.4l3-3c.4-.4 1-.4 1.4 0s.4 1 0 1.4l-3 3c-.2.2-.4.3-.7.3z" }), /* @__PURE__ */ React__namespace.createElement("path", { fill: "currentColor", d: "m17 16c-.3 0-.5-.1-.7-.3l-3-3c-.4-.4-.4-1 0-1.4s1-.4 1.4 0l3 3c.4.4.4 1 0 1.4-.2.2-.4.3-.7.3z" }));
3849
+ const SvgDownload = (props2) => /* @__PURE__ */ React__namespace.createElement("svg", { width: "24px", height: "24px", viewBox: "0 0 80 80", fill: "currentColor", ...props2 }, /* @__PURE__ */ React__namespace.createElement("g", null, /* @__PURE__ */ React__namespace.createElement("path", { d: "M19.5833333,78.3333333 L74.4166667,78.3333333 L74.4166667,70.5 L19.5833333,70.5 L19.5833333,78.3333333 Z M74.4166667,35.25 L58.75,35.25 L58.75,11.75 L35.25,11.75 L35.25,35.25 L19.5833333,35.25 L47,62.6666667 L74.4166667,35.25 Z", fillRule: "nonzero", fill: "var(--vscode-icon-foreground)" })));
3816
3850
  const SvgFilterSliders = (props2) => /* @__PURE__ */ React__namespace.createElement("svg", { fill: "none", height: 24, viewBox: "0 0 24 24", width: 24, xmlns: "http://www.w3.org/2000/svg", ...props2 }, /* @__PURE__ */ React__namespace.createElement("path", { d: "m11 8h10m-10 0c0 1.65685-1.34315 3-3 3s-3-1.34315-3-3m6 0c0-1.65685-1.34315-3-3-3s-3 1.34315-3 3m0 0h-2m10 8h-10m10 0c0-1.6569 1.3431-3 3-3s3 1.3431 3 3m-6 0c0 1.6569 1.3431 3 3 3s3-1.3431 3-3m0 0h2", stroke: "currentColor", strokeWidth: 1.5 }));
3817
3851
  const SvgVizBarChart = (props2) => /* @__PURE__ */ React__namespace.createElement("svg", { width: "110px", height: "110px", viewBox: "15 15 80 80", xmlns: "http://www.w3.org/2000/svg", xmlnsXlink: "http://www.w3.org/1999/xlink", ...props2 }, /* @__PURE__ */ React__namespace.createElement("g", { id: "viz_bar_chart", stroke: "none", strokeWidth: 1, fill: "none", fillRule: "evenodd" }, /* @__PURE__ */ React__namespace.createElement("g", { id: "Group-3", transform: "translate(20.000000, 24.000000)", fill: "currentColor" }, /* @__PURE__ */ React__namespace.createElement("g", { id: "Group-2", transform: "translate(34.500000, 31.000000) rotate(-270.000000) translate(-34.500000, -31.000000) translate(3.500000, -3.500000)" }, /* @__PURE__ */ React__namespace.createElement("path", { d: "M-26.056314,30.056314 L34.943686,30.056314 C37.152825,30.056314 38.943686,31.847175 38.943686,34.056314 L38.943686,34.943686 C38.943686,37.152825 37.152825,38.943686 34.943686,38.943686 L-26.056314,38.943686 C-28.265453,38.943686 -30.056314,37.152825 -30.056314,34.943686 L-30.056314,34.056314 C-30.056314,31.847175 -28.265453,30.056314 -26.056314,30.056314 Z", id: "Rectangle-Copy-59", transform: "translate(4.443686, 34.500000) rotate(-90.000000) translate(-4.443686, -34.500000) " }), /* @__PURE__ */ React__namespace.createElement("path", { d: "M-0.491247385,37.8466366 L44.9281075,37.8466366 C47.1372465,37.8466366 48.9281075,39.6374976 48.9281075,41.8466366 L48.9281075,42.7340086 C48.9281075,44.9431476 47.1372465,46.7340086 44.9281075,46.7340086 L-0.491247385,46.7340086 C-2.70038638,46.7340086 -4.49124739,44.9431476 -4.49124739,42.7340086 L-4.49124739,41.8466366 C-4.49124739,39.6374976 -2.70038638,37.8466366 -0.491247385,37.8466366 Z", id: "Rectangle-Copy-62", transform: "translate(22.218430, 42.290323) rotate(-90.000000) translate(-22.218430, -42.290323) " }), /* @__PURE__ */ React__namespace.createElement("path", { d: "M23.3837854,43.9469253 L56.6025627,43.9469253 C58.8117017,43.9469253 60.6025627,45.7377863 60.6025627,47.9469253 L60.6025627,48.8342973 C60.6025627,51.0434363 58.8117017,52.8342973 56.6025627,52.8342973 L23.3837854,52.8342973 C21.1746464,52.8342973 19.3837854,51.0434363 19.3837854,48.8342973 L19.3837854,47.9469253 C19.3837854,45.7377863 21.1746464,43.9469253 23.3837854,43.9469253 Z", id: "Rectangle-Copy-66", transform: "translate(39.993174, 48.390611) rotate(-90.000000) translate(-39.993174, -48.390611) " }), /* @__PURE__ */ React__namespace.createElement("path", { d: "M46.7286345,49.7286345 L68.8072017,49.7286345 C71.0163407,49.7286345 72.8072017,51.5194955 72.8072017,53.7286345 L72.8072017,54.1927983 C72.8072017,56.4019373 71.0163407,58.1927983 68.8072017,58.1927983 L46.7286345,58.1927983 C44.5194955,58.1927983 42.7286345,56.4019373 42.7286345,54.1927983 L42.7286345,53.7286345 C42.7286345,51.5194955 44.5194955,49.7286345 46.7286345,49.7286345 Z", id: "Rectangle-Copy-67", transform: "translate(57.767918, 53.960716) rotate(-90.000000) translate(-57.767918, -53.960716) " })))));
3818
3852
  const SvgVizBoolean = (props2) => /* @__PURE__ */ React__namespace.createElement("svg", { width: "110px", height: "110px", viewBox: "15 15 80 80", xmlns: "http://www.w3.org/2000/svg", xmlnsXlink: "http://www.w3.org/1999/xlink", ...props2 }, /* @__PURE__ */ React__namespace.createElement("g", { id: "viz_boolean", stroke: "none", strokeWidth: 1, fill: "none", fillRule: "evenodd" }, /* @__PURE__ */ React__namespace.createElement("g", { id: "noun_switch_3350414-2", transform: "translate(20.000000, 22.000000)", fill: "currentColor", fillRule: "nonzero" }, /* @__PURE__ */ React__namespace.createElement("g", { id: "noun_switch_3350414" }, /* @__PURE__ */ React__namespace.createElement("path", { d: "M15.2972028,30.8 L54.7027972,30.8 C63.151209,30.8 70,23.9051851 70,15.4 C70,6.89481485 63.151209,0 54.7027972,0 L15.2972028,0 C6.84879098,0 0,6.89481485 0,15.4 C0,23.9051851 6.84879098,30.8 15.2972028,30.8 Z M15.2972028,6.16 L54.7027972,6.16 C59.7718443,6.16 63.8811189,10.2968889 63.8811189,15.4 C63.8811189,20.5031111 59.7718443,24.64 54.7027972,24.64 L15.2972028,24.64 C10.2281557,24.64 6.11888112,20.5031111 6.11888112,15.4 C6.11888112,10.2968889 10.2281557,6.16 15.2972028,6.16 Z", id: "Shape" }), /* @__PURE__ */ React__namespace.createElement("path", { d: "M19.6340542,21.9997804 C22.2930484,22.0215224 24.7022661,20.4273668 25.7348338,17.9629544 C26.7674016,15.4985421 26.2191958,12.6510518 24.3466309,10.7523518 C22.474066,8.85365189 19.6473211,8.27908795 17.1885612,9.29740315 C14.7298014,10.3157183 13.125,12.7256064 13.125,15.3998806 C13.125,19.0240523 16.0305897,21.9703156 19.6340542,21.9997804 L19.6340542,21.9997804 Z", id: "Path" }), /* @__PURE__ */ React__namespace.createElement("path", { d: "M54.7027971,35.2 L15.2972025,35.2 C6.84879081,35.2 0,42.094815 0,50.6 C0,59.105185 6.84879081,66 15.2972025,66 L54.7027971,66 C63.151209,66 70,59.1051851 70,50.6 C70,42.0948149 63.151209,35.2 54.7027971,35.2 L54.7027971,35.2 Z M54.7027971,59.84 L15.2972025,59.84 C10.2281554,59.84 6.11888082,55.7031111 6.11888082,50.6 C6.11888082,45.4968889 10.2281554,41.36 15.2972025,41.36 L54.7027971,41.36 C59.7718442,41.36 63.8811189,45.4968889 63.8811189,50.6 C63.8811189,55.7031111 59.7718442,59.84 54.7027971,59.84 L54.7027971,59.84 Z", id: "Shape" }), /* @__PURE__ */ React__namespace.createElement("path", { d: "M50.3659458,44.0002196 C47.7069516,43.9784776 45.2977339,45.5726332 44.2651662,48.0370456 C43.2325984,50.5014579 43.7808042,53.3489482 45.6533691,55.2476482 C47.525934,57.1463481 50.3526789,57.720912 52.8114388,56.7025969 C55.2701986,55.6842817 56.875,53.2743936 56.875,50.6001194 C56.875,46.9759477 53.9694103,44.0296844 50.3659458,44.0002196 Z", id: "Path" })))));
@@ -3855,6 +3889,7 @@ const ICON_MAP = {
3855
3889
  refresh: SvgRefresh,
3856
3890
  sidebarCollapse: SvgSidebarCollapse,
3857
3891
  filterSliders: SvgFilterSliders,
3892
+ download: SvgDownload,
3858
3893
  // Operations
3859
3894
  aggregate: SvgInsertMeasure,
3860
3895
  dimension: SvgTypeIconString,
@@ -3922,11 +3957,11 @@ function Icon({
3922
3957
  return null;
3923
3958
  }
3924
3959
  return /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {
3925
- ..._stylex.props(styles$Q.main, colorVariants$3[color], customStyle),
3960
+ ..._stylex.props(styles$R.main, colorVariants$3[color], customStyle),
3926
3961
  "data-testid": `icon-${color}-${name}`
3927
3962
  });
3928
3963
  }
3929
- const styles$Q = {
3964
+ const styles$R = {
3930
3965
  main: {
3931
3966
  display: "mly1rg5ohu",
3932
3967
  width: "mly1kky2od",
@@ -3995,18 +4030,18 @@ function Badge({
3995
4030
  customStyle
3996
4031
  }) {
3997
4032
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
3998
- ..._stylex.props(styles$P.main, colorVariants$2[color], customStyle),
4033
+ ..._stylex.props(styles$Q.main, colorVariants$2[color], customStyle),
3999
4034
  children: [icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, {
4000
4035
  color,
4001
4036
  name: icon
4002
4037
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
4003
4038
  "data-testid": "badge-label",
4004
- ..._stylex.props(fontStyles.badge, styles$P.label),
4039
+ ..._stylex.props(fontStyles.badge, styles$Q.label),
4005
4040
  children: label
4006
4041
  })]
4007
4042
  });
4008
4043
  }
4009
- const styles$P = {
4044
+ const styles$Q = {
4010
4045
  main: {
4011
4046
  display: "mly3nfvp2",
4012
4047
  height: "mly1qx5ct2",
@@ -4088,10 +4123,10 @@ function Divider({
4088
4123
  customStyle
4089
4124
  }) {
4090
4125
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
4091
- ..._stylex.props(styles$O.main, orientationVariants[orientation], customStyle)
4126
+ ..._stylex.props(styles$P.main, orientationVariants[orientation], customStyle)
4092
4127
  });
4093
4128
  }
4094
- const styles$O = {
4129
+ const styles$P = {
4095
4130
  main: {
4096
4131
  background: "mly1xnbgy5",
4097
4132
  backgroundAttachment: null,
@@ -4897,7 +4932,7 @@ function Button({
4897
4932
  ...props2
4898
4933
  }) {
4899
4934
  const button = /* @__PURE__ */ jsxRuntime.jsxs("button", {
4900
- ..._stylex.props(styles$N.main, colorVariants$1[variant], sizeVariants$1[size2], customStyle),
4935
+ ..._stylex.props(styles$O.main, colorVariants$1[variant], sizeVariants$1[size2], customStyle),
4901
4936
  type: "button",
4902
4937
  disabled: isDisabled,
4903
4938
  ...props2,
@@ -4907,9 +4942,9 @@ function Button({
4907
4942
  },
4908
4943
  children: [icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, {
4909
4944
  name: icon,
4910
- customStyle: styles$N.icon
4945
+ customStyle: styles$O.icon
4911
4946
  }), label && /* @__PURE__ */ jsxRuntime.jsx("div", {
4912
- ..._stylex.props(variant === "primary" ? fontStyles.emphasized : fontStyles.body, styles$N.label),
4947
+ ..._stylex.props(variant === "primary" ? fontStyles.emphasized : fontStyles.body, styles$O.label),
4913
4948
  children: label
4914
4949
  })]
4915
4950
  }), isDisabled && /* @__PURE__ */ jsxRuntime.jsx("div", {
@@ -4936,7 +4971,7 @@ function Button({
4936
4971
  return button;
4937
4972
  }
4938
4973
  }
4939
- const styles$N = {
4974
+ const styles$O = {
4940
4975
  main: {
4941
4976
  display: "mly3nfvp2",
4942
4977
  flexDirection: "mlydt5ytf",
@@ -5187,7 +5222,7 @@ function Token({
5187
5222
  }) {
5188
5223
  const isInteractive = onClick !== void 0 || asButtonTrigger;
5189
5224
  const token2 = /* @__PURE__ */ jsxRuntime.jsxs("div", {
5190
- ..._stylex.props(tokenStyles.main, tokenColorVariants[color], tokenSizeVariants[size2], !isInteractive && styles$M.nonInteractive, customStyle),
5225
+ ..._stylex.props(tokenStyles.main, tokenColorVariants[color], tokenSizeVariants[size2], !isInteractive && styles$N.nonInteractive, customStyle),
5191
5226
  ...dragProps == null ? void 0 : dragProps.attributes,
5192
5227
  ...dragProps == null ? void 0 : dragProps.listeners,
5193
5228
  children: [icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, {
@@ -5224,7 +5259,7 @@ function Token({
5224
5259
  })]
5225
5260
  }) : token2;
5226
5261
  }
5227
- const styles$M = {
5262
+ const styles$N = {
5228
5263
  nonInteractive: {
5229
5264
  cursor: "mlyt0e3qv",
5230
5265
  background: "mly1np9qvj",
@@ -5248,7 +5283,7 @@ function TokenGroup({
5248
5283
  }) {
5249
5284
  const count2 = React__namespace.Children.count(children);
5250
5285
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
5251
- ..._stylex.props(styles$L.main, customStyle),
5286
+ ..._stylex.props(styles$M.main, customStyle),
5252
5287
  children: React__namespace.Children.map(children, (child, index2) => /* @__PURE__ */ React__namespace.cloneElement(child, {
5253
5288
  customStyle: {
5254
5289
  ...child.props.customStyle,
@@ -5259,16 +5294,16 @@ function TokenGroup({
5259
5294
  });
5260
5295
  }
5261
5296
  const getChildStyle = (index2, count2) => {
5262
- if (count2 === 1) return styles$L.onlyChild;
5263
- if (index2 === 0) return styles$L.firstChild;
5264
- if (index2 === count2 - 1) return styles$L.lastChild;
5265
- return styles$L.innerChild;
5297
+ if (count2 === 1) return styles$M.onlyChild;
5298
+ if (index2 === 0) return styles$M.firstChild;
5299
+ if (index2 === count2 - 1) return styles$M.lastChild;
5300
+ return styles$M.innerChild;
5266
5301
  };
5267
5302
  const getTokenColor = (child, groupColor) => {
5268
5303
  const childColor = child.props.color;
5269
5304
  return childColor === void 0 ? groupColor : childColor;
5270
5305
  };
5271
- const styles$L = {
5306
+ const styles$M = {
5272
5307
  main: {
5273
5308
  display: "mlyrvj5dj",
5274
5309
  gridAutoFlow: "mly1mt1orb",
@@ -5340,7 +5375,7 @@ function ErrorIcon({
5340
5375
  },
5341
5376
  children: /* @__PURE__ */ jsxRuntime.jsx(Icon, {
5342
5377
  name: "warning",
5343
- customStyle: styles$K.errorIcon
5378
+ customStyle: styles$L.errorIcon
5344
5379
  })
5345
5380
  })
5346
5381
  }), /* @__PURE__ */ jsxRuntime.jsx(TooltipPortal, {
@@ -5353,7 +5388,7 @@ function ErrorIcon({
5353
5388
  })]
5354
5389
  });
5355
5390
  }
5356
- const styles$K = {
5391
+ const styles$L = {
5357
5392
  errorIcon: {
5358
5393
  color: "mly1e2nbdu",
5359
5394
  $$css: true
@@ -5398,22 +5433,22 @@ function EditableToken({
5398
5433
  className: "mly78zum5 mly6s0dn4"
5399
5434
  },
5400
5435
  children: [/* @__PURE__ */ jsxRuntime.jsxs("div", {
5401
- ..._stylex.props(tokenStyles.main, tokenColorVariants[color], tokenSizeVariants[size2], isFocused && styles$J.focused, !!errorMessage && styles$J.hasError, customStyle),
5436
+ ..._stylex.props(tokenStyles.main, tokenColorVariants[color], tokenSizeVariants[size2], isFocused && styles$K.focused, !!errorMessage && styles$K.hasError, customStyle),
5402
5437
  children: [icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, {
5403
5438
  name: icon,
5404
- customStyle: styles$J.icon
5439
+ customStyle: styles$K.icon
5405
5440
  }), /* @__PURE__ */ jsxRuntime.jsxs("span", {
5406
5441
  ...{
5407
5442
  className: "mlywz0xwf"
5408
5443
  },
5409
5444
  children: [/* @__PURE__ */ jsxRuntime.jsx("span", {
5410
- ..._stylex.props(fontStyles.body, styles$J.placeholder),
5445
+ ..._stylex.props(fontStyles.body, styles$K.placeholder),
5411
5446
  style: {
5412
5447
  whiteSpaceCollapse: "preserve"
5413
5448
  },
5414
5449
  children: value
5415
5450
  }), /* @__PURE__ */ jsxRuntime.jsx("input", {
5416
- ..._stylex.props(styles$J.input, fontStyles.body),
5451
+ ..._stylex.props(styles$K.input, fontStyles.body),
5417
5452
  ref: inputRef,
5418
5453
  pattern: type === "number" ? "^-?[0-9.]*$" : void 0,
5419
5454
  value,
@@ -5438,7 +5473,7 @@ function EditableToken({
5438
5473
  })]
5439
5474
  });
5440
5475
  }
5441
- const styles$J = {
5476
+ const styles$K = {
5442
5477
  focused: {
5443
5478
  background: "mlyotlr4g",
5444
5479
  backgroundAttachment: null,
@@ -7780,12 +7815,12 @@ function TextInput({
7780
7815
  }
7781
7816
  };
7782
7817
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
7783
- ..._stylex.props(styles$I.main, isFocused && styles$I.focused, sizeVariants[size2], customStyle),
7818
+ ..._stylex.props(styles$J.main, isFocused && styles$J.focused, sizeVariants[size2], customStyle),
7784
7819
  children: [icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, {
7785
7820
  name: icon,
7786
7821
  color: "secondary"
7787
7822
  }), /* @__PURE__ */ jsxRuntime.jsx("input", {
7788
- ..._stylex.props(fontStyles.body, styles$I.input),
7823
+ ..._stylex.props(fontStyles.body, styles$J.input),
7789
7824
  value,
7790
7825
  placeholder,
7791
7826
  onChange: handleChange,
@@ -7793,7 +7828,7 @@ function TextInput({
7793
7828
  onBlur: handleBlur,
7794
7829
  onKeyDown
7795
7830
  }), hasClear && /* @__PURE__ */ jsxRuntime.jsx("button", {
7796
- ..._stylex.props(fontStyles.supporting, styles$I.actionButton, value === "" && styles$I.hidden),
7831
+ ..._stylex.props(fontStyles.supporting, styles$J.actionButton, value === "" && styles$J.hidden),
7797
7832
  ref: buttonRef,
7798
7833
  onClick: () => onChange(""),
7799
7834
  tabIndex: 0,
@@ -7801,7 +7836,7 @@ function TextInput({
7801
7836
  })]
7802
7837
  });
7803
7838
  }
7804
- const styles$I = {
7839
+ const styles$J = {
7805
7840
  main: {
7806
7841
  display: "mly78zum5",
7807
7842
  alignItems: "mly6s0dn4",
@@ -8010,7 +8045,7 @@ function SelectorToken({
8010
8045
  onValueChange: handleValueChange,
8011
8046
  required: true,
8012
8047
  children: [/* @__PURE__ */ jsxRuntime.jsxs(Trigger$3, {
8013
- ..._stylex.props(tokenStyles.main, styles$H.selectTrigger, tokenColorVariants[color], tokenSizeVariants[size2], customStyle),
8048
+ ..._stylex.props(tokenStyles.main, styles$I.selectTrigger, tokenColorVariants[color], tokenSizeVariants[size2], customStyle),
8014
8049
  children: [icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, {
8015
8050
  name: icon,
8016
8051
  customStyle: tokenStyles.icon
@@ -8037,7 +8072,7 @@ function SelectorToken({
8037
8072
  size: "compact",
8038
8073
  icon: "search",
8039
8074
  hasClear: true,
8040
- customStyle: styles$H.searchInput,
8075
+ customStyle: styles$I.searchInput,
8041
8076
  onKeyDown: (event) => {
8042
8077
  const excludedKeys = ["ArrowUp", "ArrowDown"];
8043
8078
  if (!excludedKeys.includes(event.key)) {
@@ -8068,21 +8103,21 @@ function SelectItem({
8068
8103
  ...props2
8069
8104
  }) {
8070
8105
  return /* @__PURE__ */ jsxRuntime.jsxs(Item$1, {
8071
- ..._stylex.props(fontStyles.body, styles$H.selectItem),
8106
+ ..._stylex.props(fontStyles.body, styles$I.selectItem),
8072
8107
  value,
8073
8108
  ...props2,
8074
8109
  children: [value === selectedValue ? /* @__PURE__ */ jsxRuntime.jsx(Icon, {
8075
8110
  name: "radioChecked",
8076
- customStyle: styles$H.radioChecked
8111
+ customStyle: styles$I.radioChecked
8077
8112
  }) : /* @__PURE__ */ jsxRuntime.jsx(Icon, {
8078
8113
  name: "radioUnchecked",
8079
- customStyle: styles$H.radioUnchecked
8114
+ customStyle: styles$I.radioUnchecked
8080
8115
  }), /* @__PURE__ */ jsxRuntime.jsx(ItemText, {
8081
8116
  children
8082
8117
  })]
8083
8118
  });
8084
8119
  }
8085
- const styles$H = {
8120
+ const styles$I = {
8086
8121
  selectTrigger: {
8087
8122
  whiteSpace: "mlyuxw1ft",
8088
8123
  overflow: "mlyb3r6kr",
@@ -8172,7 +8207,7 @@ function Card({
8172
8207
  customStyle
8173
8208
  }) {
8174
8209
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
8175
- ..._stylex.props(styles$G.container, customStyle),
8210
+ ..._stylex.props(styles$H.container, customStyle),
8176
8211
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
8177
8212
  ...{
8178
8213
  className: "mly1717udv"
@@ -8186,7 +8221,7 @@ function Card({
8186
8221
  })]
8187
8222
  });
8188
8223
  }
8189
- const styles$G = {
8224
+ const styles$H = {
8190
8225
  container: {
8191
8226
  display: "mly78zum5",
8192
8227
  flexDirection: "mlydt5ytf",
@@ -8279,7 +8314,7 @@ function CollapsiblePanel({
8279
8314
  },
8280
8315
  children: [icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, {
8281
8316
  name: icon,
8282
- customStyle: styles$F.icon
8317
+ customStyle: styles$G.icon
8283
8318
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
8284
8319
  ...{
8285
8320
  className: "mlyuxw1ft mlyb3r6kr mlylyipyv mlyehqz9p mly1ghz6dp mly117nqv4"
@@ -8321,7 +8356,7 @@ function CollapsiblePanel({
8321
8356
  })]
8322
8357
  });
8323
8358
  }
8324
- const styles$F = {
8359
+ const styles$G = {
8325
8360
  icon: {
8326
8361
  $$css: true
8327
8362
  }
@@ -8353,10 +8388,10 @@ function CollapsibleListItem({
8353
8388
  className: "mly78zum5 mlydt5ytf mly1iyjqo2 mlyb3r6kr"
8354
8389
  },
8355
8390
  children: [/* @__PURE__ */ jsxRuntime.jsx("span", {
8356
- ..._stylex.props(fontStyles.body, styles$E.label),
8391
+ ..._stylex.props(fontStyles.body, styles$F.label),
8357
8392
  children: label
8358
8393
  }), sublabel && /* @__PURE__ */ jsxRuntime.jsx("span", {
8359
- ..._stylex.props(fontStyles.supporting, styles$E.sublabel),
8394
+ ..._stylex.props(fontStyles.supporting, styles$F.sublabel),
8360
8395
  children: sublabel
8361
8396
  })]
8362
8397
  })]
@@ -8368,7 +8403,7 @@ function CollapsibleListItem({
8368
8403
  })]
8369
8404
  });
8370
8405
  }
8371
- const styles$E = {
8406
+ const styles$F = {
8372
8407
  label: {
8373
8408
  flexGrow: "mly1iyjqo2",
8374
8409
  fontWeight: "mly1xlr1w8",
@@ -19182,7 +19217,7 @@ function Spinner({
19182
19217
  } = SIZES[size2];
19183
19218
  const frameSize = diameter + border * 2;
19184
19219
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
19185
- ..._stylex.props(styles$D.root, customStyle),
19220
+ ..._stylex.props(styles$E.root, customStyle),
19186
19221
  children: /* @__PURE__ */ jsxRuntime.jsx("span", {
19187
19222
  "aria-valuetext": "Loading",
19188
19223
  ...{
@@ -19202,7 +19237,7 @@ function Spinner({
19202
19237
  })
19203
19238
  });
19204
19239
  }
19205
- const styles$D = {
19240
+ const styles$E = {
19206
19241
  root: {
19207
19242
  alignItems: "mly6s0dn4",
19208
19243
  display: "mly3nfvp2",
@@ -22271,7 +22306,7 @@ function toArray() {
22271
22306
  m.millisecond()
22272
22307
  ];
22273
22308
  }
22274
- function toObject() {
22309
+ function toObject$1() {
22275
22310
  var m = this;
22276
22311
  return {
22277
22312
  years: m.year(),
@@ -22709,7 +22744,7 @@ proto.set = stringSet;
22709
22744
  proto.startOf = startOf;
22710
22745
  proto.subtract = subtract$1;
22711
22746
  proto.toArray = toArray;
22712
- proto.toObject = toObject;
22747
+ proto.toObject = toObject$1;
22713
22748
  proto.toDate = toDate;
22714
22749
  proto.toISOString = toISOString;
22715
22750
  proto.inspect = inspect;
@@ -23600,7 +23635,7 @@ const Popover = ({
23600
23635
  })
23601
23636
  });
23602
23637
  };
23603
- const styles$C = {
23638
+ const styles$D = {
23604
23639
  wrapper: {
23605
23640
  position: "mly1n2onr6",
23606
23641
  $$css: true
@@ -23652,7 +23687,7 @@ const SelectDropdown = ({
23652
23687
  setOpen(false);
23653
23688
  };
23654
23689
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
23655
- ..._stylex.props(styles$C.wrapper, customStyle),
23690
+ ..._stylex.props(styles$D.wrapper, customStyle),
23656
23691
  children: [/* @__PURE__ */ jsxRuntime.jsxs("button", {
23657
23692
  type: "button",
23658
23693
  autoFocus,
@@ -23720,7 +23755,7 @@ function SelectList({
23720
23755
  const [hoveredIndex, setHoveredIndex] = React.useState(null);
23721
23756
  return /* @__PURE__ */ jsxRuntime.jsx(ScrollableArea, {
23722
23757
  children: /* @__PURE__ */ jsxRuntime.jsx("div", {
23723
- ..._stylex.props(styles$C.selectListDiv, customStyle),
23758
+ ..._stylex.props(styles$D.selectListDiv, customStyle),
23724
23759
  children: options.reduce((result, option2, index2) => {
23725
23760
  const isSelected = value !== void 0 && valueEqual(value, option2.value);
23726
23761
  if (option2.divider) {
@@ -23752,8 +23787,8 @@ function SelectList({
23752
23787
  }), /* @__PURE__ */ jsxRuntime.jsx(Icon, {
23753
23788
  name: "checkmark",
23754
23789
  customStyle: {
23755
- ...styles$C.checkIcon,
23756
- ...isSelected ? styles$C.checkIconSelected : void 0
23790
+ ...styles$D.checkIcon,
23791
+ ...isSelected ? styles$D.checkIconSelected : void 0
23757
23792
  }
23758
23793
  }), /* @__PURE__ */ jsxRuntime.jsx("span", {
23759
23794
  ...{
@@ -23805,7 +23840,7 @@ const DateInput = ({
23805
23840
  setTempValue(hooks.utc(value).format(format2));
23806
23841
  }, [value, format2]);
23807
23842
  return /* @__PURE__ */ jsxRuntime.jsx("input", {
23808
- ..._stylex.props(customStyle, isActive ? styles$B.active : null),
23843
+ ..._stylex.props(customStyle, isActive ? styles$C.active : null),
23809
23844
  type: "text",
23810
23845
  placeholder: placeholder || format2,
23811
23846
  value: tempValue,
@@ -23840,7 +23875,7 @@ function guessUnits(moment2, isDateTime) {
23840
23875
  }
23841
23876
  return isDateTime ? "second" : "day";
23842
23877
  }
23843
- const styles$B = {
23878
+ const styles$C = {
23844
23879
  active: {
23845
23880
  backgroundColor: "mly1vzefiq",
23846
23881
  $$css: true
@@ -23952,7 +23987,7 @@ function DatePicker({
23952
23987
  });
23953
23988
  };
23954
23989
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
23955
- ..._stylex.props(styles$A.outer, customStyle),
23990
+ ..._stylex.props(styles$B.outer, customStyle),
23956
23991
  ref: forwardRef,
23957
23992
  children: [/* @__PURE__ */ jsxRuntime.jsxs("div", {
23958
23993
  ...{
@@ -24268,7 +24303,7 @@ function DatePicker({
24268
24303
  })]
24269
24304
  });
24270
24305
  }
24271
- const styles$A = {
24306
+ const styles$B = {
24272
24307
  outer: {
24273
24308
  userSelect: "mly87ps6o",
24274
24309
  fontSize: "mlymhiqyu",
@@ -24354,7 +24389,7 @@ function Banner({
24354
24389
  className: "mly1q4ynmn mlyh8yej3 mly5yr21d mly78zum5 mlydt5ytf mly1kmqopl mly16zck5j"
24355
24390
  },
24356
24391
  children: [/* @__PURE__ */ jsxRuntime.jsxs("div", {
24357
- ..._stylex.props(styles$z.header, variantColors[variant], children ? styles$z.headerWithContent : null),
24392
+ ..._stylex.props(styles$A.header, variantColors[variant], children ? styles$A.headerWithContent : null),
24358
24393
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
24359
24394
  ...{
24360
24395
  className: "mly1qx5ct2 mly78zum5 mlyl56j7k mly6s0dn4"
@@ -24367,22 +24402,22 @@ function Banner({
24367
24402
  className: "mly78zum5 mlydt5ytf mlyb3r6kr"
24368
24403
  },
24369
24404
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
24370
- ..._stylex.props(styles$z.title, fontStyles.emphasized),
24405
+ ..._stylex.props(styles$A.title, fontStyles.emphasized),
24371
24406
  children: title
24372
24407
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
24373
- ..._stylex.props(styles$z.description, fontStyles.supporting),
24408
+ ..._stylex.props(styles$A.description, fontStyles.supporting),
24374
24409
  children: description
24375
24410
  })]
24376
24411
  })]
24377
24412
  }), children && /* @__PURE__ */ jsxRuntime.jsx("div", {
24378
- ..._stylex.props(styles$z.content, fontStyles.body),
24413
+ ..._stylex.props(styles$A.content, fontStyles.body),
24379
24414
  children: /* @__PURE__ */ jsxRuntime.jsx(ScrollableArea, {
24380
24415
  children
24381
24416
  })
24382
24417
  })]
24383
24418
  });
24384
24419
  }
24385
- const styles$z = {
24420
+ const styles$A = {
24386
24421
  header: {
24387
24422
  borderRadius: "mly1q4ynmn",
24388
24423
  borderStartStartRadius: null,
@@ -24524,14 +24559,14 @@ function AccordionList({
24524
24559
  onExpandedItemChange: handleExpandedItemChange
24525
24560
  },
24526
24561
  children: /* @__PURE__ */ jsxRuntime.jsx("div", {
24527
- ..._stylex.props(styles$y.main, customStyle),
24562
+ ..._stylex.props(styles$z.main, customStyle),
24528
24563
  children: React__namespace.Children.map(children, (child) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
24529
24564
  children: [child, /* @__PURE__ */ jsxRuntime.jsx(Divider, {})]
24530
24565
  }))
24531
24566
  })
24532
24567
  });
24533
24568
  }
24534
- const styles$y = {
24569
+ const styles$z = {
24535
24570
  main: {
24536
24571
  display: "mly78zum5",
24537
24572
  flexDirection: "mlydt5ytf",
@@ -24568,10 +24603,10 @@ function AccordionListItem({
24568
24603
  className: "mly78zum5 mlydt5ytf mlyb3r6kr mly1iyjqo2"
24569
24604
  },
24570
24605
  children: [/* @__PURE__ */ jsxRuntime.jsx("span", {
24571
- ..._stylex.props(fontStyles.body, styles$x.label),
24606
+ ..._stylex.props(fontStyles.body, styles$y.label),
24572
24607
  children: label
24573
24608
  }), sublabel && /* @__PURE__ */ jsxRuntime.jsx("span", {
24574
- ..._stylex.props(fontStyles.supporting, styles$x.sublabel),
24609
+ ..._stylex.props(fontStyles.supporting, styles$y.sublabel),
24575
24610
  children: sublabel
24576
24611
  })]
24577
24612
  }), badge && badge, endIcon && endIcon]
@@ -24583,7 +24618,7 @@ function AccordionListItem({
24583
24618
  })]
24584
24619
  });
24585
24620
  }
24586
- const styles$x = {
24621
+ const styles$y = {
24587
24622
  label: {
24588
24623
  flexGrow: "mly1iyjqo2",
24589
24624
  fontWeight: "mly1xlr1w8",
@@ -25868,7 +25903,7 @@ function DropdownMenu({
25868
25903
  children: trigger
25869
25904
  }), /* @__PURE__ */ jsxRuntime.jsx(Portal2, {
25870
25905
  children: /* @__PURE__ */ jsxRuntime.jsx(Content2, {
25871
- ..._stylex.props(fontStyles.body, styles$w.content),
25906
+ ..._stylex.props(fontStyles.body, styles$x.content),
25872
25907
  side: "bottom",
25873
25908
  align: "start",
25874
25909
  sideOffset: 4,
@@ -25895,22 +25930,22 @@ function DropdownMenuItem({
25895
25930
  disabled,
25896
25931
  children: [icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, {
25897
25932
  name: icon,
25898
- customStyle: styles$w.icon
25933
+ customStyle: styles$x.icon
25899
25934
  }), /* @__PURE__ */ jsxRuntime.jsxs("div", {
25900
25935
  ...{
25901
25936
  className: "mly78zum5 mlydt5ytf mly1iyjqo2"
25902
25937
  },
25903
25938
  children: [/* @__PURE__ */ jsxRuntime.jsx("span", {
25904
- ..._stylex.props(fontStyles.body, styles$w.label),
25939
+ ..._stylex.props(fontStyles.body, styles$x.label),
25905
25940
  children: label
25906
25941
  }), sublabel && /* @__PURE__ */ jsxRuntime.jsx("span", {
25907
- ..._stylex.props(fontStyles.supporting, styles$w.sublabel),
25942
+ ..._stylex.props(fontStyles.supporting, styles$x.sublabel),
25908
25943
  children: sublabel
25909
25944
  })]
25910
25945
  })]
25911
25946
  });
25912
25947
  }
25913
- const styles$w = {
25948
+ const styles$x = {
25914
25949
  content: {
25915
25950
  display: "mly78zum5",
25916
25951
  flexDirection: "mlydt5ytf",
@@ -25994,7 +26029,7 @@ function QueryActionBar({
25994
26029
  children: [/* @__PURE__ */ jsxRuntime.jsx(Icon, {
25995
26030
  name: "filterSliders"
25996
26031
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
25997
- ..._stylex.props(fontStyles.largeBody, styles$v.title),
26032
+ ..._stylex.props(fontStyles.largeBody, styles$w.title),
25998
26033
  children: "Query"
25999
26034
  })]
26000
26035
  }), /* @__PURE__ */ jsxRuntime.jsxs("div", {
@@ -26004,9 +26039,9 @@ function QueryActionBar({
26004
26039
  children: [/* @__PURE__ */ jsxRuntime.jsx(Button, {
26005
26040
  onClick: () => {
26006
26041
  focusMainView();
26007
- setQuery == null ? void 0 : setQuery(void 0);
26042
+ setQuery(void 0);
26008
26043
  },
26009
- isDisabled: !rootQuery || (rootQuery == null ? void 0 : rootQuery.isEmpty()),
26044
+ isDisabled: !rootQuery || rootQuery.isEmpty(),
26010
26045
  label: "Clear",
26011
26046
  variant: "flat",
26012
26047
  size: "compact"
@@ -26039,13 +26074,13 @@ function QueryActionBar({
26039
26074
  })]
26040
26075
  });
26041
26076
  }
26042
- const styles$v = {
26077
+ const styles$w = {
26043
26078
  title: {
26044
26079
  fontWeight: "mly1xlr1w8",
26045
26080
  $$css: true
26046
26081
  }
26047
26082
  };
26048
- const styles$u = {
26083
+ const styles$v = {
26049
26084
  labelWithIcon: {
26050
26085
  display: "mly78zum5",
26051
26086
  alignItems: "mly6s0dn4",
@@ -26216,6 +26251,7 @@ function fieldToIcon(field) {
26216
26251
  break;
26217
26252
  case "dimension":
26218
26253
  case "measure":
26254
+ case "calculate":
26219
26255
  icon = atomicTypeToIcon(field.type.kind);
26220
26256
  break;
26221
26257
  case "join":
@@ -26227,8 +26263,7 @@ function fieldToIcon(field) {
26227
26263
  function relationshipToIcon(relationship) {
26228
26264
  return relationshipMap[relationship];
26229
26265
  }
26230
- function viewToVisualizationIcon(view) {
26231
- const currentTag = view.getTag();
26266
+ function tagToVisualization(currentTag) {
26232
26267
  const currentRenderer = tagToRenderer(currentTag) ?? "table";
26233
26268
  return `viz_${currentRenderer}`;
26234
26269
  }
@@ -26248,6 +26283,7 @@ const fieldKindMap = {
26248
26283
  view: "purple",
26249
26284
  dimension: "cyan",
26250
26285
  measure: "green",
26286
+ calculate: "green",
26251
26287
  join: void 0
26252
26288
  };
26253
26289
  const relationshipMap = {
@@ -26257,31 +26293,36 @@ const relationshipMap = {
26257
26293
  };
26258
26294
  function FieldToken({
26259
26295
  field,
26296
+ additionalSiblings,
26260
26297
  hoverActions,
26261
26298
  hoverActionsVisible,
26262
26299
  ...props2
26263
26300
  }) {
26301
+ const [isHovered, setIsHovered] = React__namespace.useState(false);
26264
26302
  let label = field.name;
26265
26303
  if (field.kind === "dimension" && (field.type.kind === "timestamp_type" || field.type.kind === "date_type")) {
26266
26304
  if (field.type.timeframe) {
26267
26305
  label += `.${field.type.timeframe}`;
26268
26306
  }
26269
26307
  }
26308
+ const showHover = (isHovered || hoverActionsVisible) && !!hoverActions;
26270
26309
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
26310
+ onMouseEnter: () => setIsHovered(true),
26311
+ onMouseLeave: () => setIsHovered(false),
26271
26312
  ...{
26272
26313
  0: {
26273
- className: "mly78zum5 mly6s0dn4 mly1nhvcw1 mly1jnr06f mly28fmrt mly1x0xcia"
26314
+ className: "mly78zum5 mly6s0dn4 mly1nhvcw1 mly1jnr06f"
26274
26315
  },
26275
26316
  1: {
26276
26317
  className: "mly78zum5 mly6s0dn4 mly1nhvcw1 mly1jnr06f mlym9y5t7"
26277
26318
  }
26278
- }[!!hoverActionsVisible << 0],
26319
+ }[!!showHover << 0],
26279
26320
  children: [/* @__PURE__ */ jsxRuntime.jsx(Token, {
26280
26321
  label,
26281
26322
  color: fieldKindToColor(field.kind),
26282
26323
  icon: fieldToIcon(field),
26283
26324
  ...props2
26284
- }), hoverActions && /* @__PURE__ */ jsxRuntime.jsx("div", {
26325
+ }), additionalSiblings, showHover && /* @__PURE__ */ jsxRuntime.jsx("div", {
26285
26326
  ...{
26286
26327
  className: "mly1vsucm1 mly2lah0s"
26287
26328
  },
@@ -26297,7 +26338,7 @@ function DrillOperations({
26297
26338
  }
26298
26339
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
26299
26340
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
26300
- ..._stylex.props(styles$u.title),
26341
+ ..._stylex.props(styles$v.title),
26301
26342
  children: "drills"
26302
26343
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
26303
26344
  ...{
@@ -26312,7 +26353,7 @@ function DrillOperations({
26312
26353
  field
26313
26354
  }), /* @__PURE__ */ jsxRuntime.jsx(Token, {
26314
26355
  label: "="
26315
- }), drill.filter instanceof QB.ASTFilterWithLiteralEquality ? /* @__PURE__ */ jsxRuntime.jsx(LiteralValue, {
26356
+ }), drill.filter instanceof malloyQueryBuilder.ASTFilterWithLiteralEquality ? /* @__PURE__ */ jsxRuntime.jsx(LiteralValue, {
26316
26357
  value: drill.filter.value.node
26317
26358
  }) : /* @__PURE__ */ jsxRuntime.jsx(Token, {
26318
26359
  label: drill.filter.filterString
@@ -30230,7 +30271,7 @@ function isIndexView(field) {
30230
30271
  return allFields.size === INDEX_FIELDS.length;
30231
30272
  }
30232
30273
  function getViewDefinition(parent) {
30233
- return parent instanceof QB.ASTArrowQueryDefinition ? parent.view : parent.definition;
30274
+ return parent instanceof malloyQueryBuilder.ASTArrowQueryDefinition ? parent.view : parent.definition;
30234
30275
  }
30235
30276
  function getInputSchemaFromViewParent(parent) {
30236
30277
  if (!parent) {
@@ -30272,32 +30313,32 @@ function BadgeForField({
30272
30313
  label: "view",
30273
30314
  icon: "view_filled",
30274
30315
  color: "purple",
30275
- customStyle: styles$t.noBackground
30316
+ customStyle: styles$u.noBackground
30276
30317
  });
30277
30318
  } else if (field.kind === "dimension") {
30278
30319
  return /* @__PURE__ */ jsxRuntime.jsx(Badge, {
30279
30320
  label: "dimension",
30280
30321
  icon: fieldToIcon(field),
30281
30322
  color: "cyan",
30282
- customStyle: styles$t.noBackground
30323
+ customStyle: styles$u.noBackground
30283
30324
  });
30284
30325
  } else if (field.kind === "measure") {
30285
30326
  return /* @__PURE__ */ jsxRuntime.jsx(Badge, {
30286
30327
  label: "measure",
30287
30328
  icon: fieldToIcon(field),
30288
30329
  color: "green",
30289
- customStyle: styles$t.noBackground
30330
+ customStyle: styles$u.noBackground
30290
30331
  });
30291
30332
  } else if (field.kind === "join") {
30292
30333
  return /* @__PURE__ */ jsxRuntime.jsx(Badge, {
30293
30334
  label: "join",
30294
30335
  icon: fieldToIcon(field),
30295
30336
  color: "gray",
30296
- customStyle: styles$t.noBackground
30337
+ customStyle: styles$u.noBackground
30297
30338
  });
30298
30339
  }
30299
30340
  }
30300
- const styles$t = {
30341
+ const styles$u = {
30301
30342
  noBackground: {
30302
30343
  backgroundColor: "mlyjbqb8w",
30303
30344
  $$css: true
@@ -30606,7 +30647,7 @@ var Content$1 = DialogContent;
30606
30647
  var Title = DialogTitle;
30607
30648
  var Description = DialogDescription;
30608
30649
  var Close = DialogClose;
30609
- const styles$s = {
30650
+ const styles$t = {
30610
30651
  left: {
30611
30652
  display: "mly78zum5",
30612
30653
  justifyContent: "mly1lvf691",
@@ -30617,6 +30658,12 @@ const styles$s = {
30617
30658
  justifyContent: "mly1rfj78v",
30618
30659
  $$css: true
30619
30660
  },
30661
+ nest: {
30662
+ gridColumn: "mly623te4",
30663
+ gridColumnStart: null,
30664
+ gridColumnEnd: null,
30665
+ $$css: true
30666
+ },
30620
30667
  heading: {
30621
30668
  gridColumn: "mly623te4",
30622
30669
  gridColumnStart: null,
@@ -30740,11 +30787,11 @@ function HoverCard({
30740
30787
  customStyle
30741
30788
  }) {
30742
30789
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
30743
- ..._stylex.props(styles$r.container, fontStyles.body, customStyle),
30790
+ ..._stylex.props(styles$s.container, fontStyles.body, customStyle),
30744
30791
  children
30745
30792
  });
30746
30793
  }
30747
- const styles$r = {
30794
+ const styles$s = {
30748
30795
  container: {
30749
30796
  boxShadow: "mly5n1uv4",
30750
30797
  backgroundColor: "mly12peec7",
@@ -30781,7 +30828,7 @@ function InfoHover({
30781
30828
  children: [/* @__PURE__ */ jsxRuntime.jsx(Trigger$4, {
30782
30829
  asChild: true,
30783
30830
  children: /* @__PURE__ */ jsxRuntime.jsx("div", {
30784
- ..._stylex.props(styles$s.infoTrigger, fontStyles.body),
30831
+ ..._stylex.props(styles$t.infoTrigger, fontStyles.body),
30785
30832
  children: /* @__PURE__ */ jsxRuntime.jsx(Icon, {
30786
30833
  name: "info",
30787
30834
  color: "disabled"
@@ -30792,7 +30839,7 @@ function InfoHover({
30792
30839
  side: "right",
30793
30840
  align: "start",
30794
30841
  children: /* @__PURE__ */ jsxRuntime.jsx(HoverCard, {
30795
- customStyle: styles$s.card,
30842
+ customStyle: styles$t.card,
30796
30843
  children: info
30797
30844
  })
30798
30845
  })
@@ -30914,9 +30961,9 @@ const PillInput = ({
30914
30961
  commitValue();
30915
30962
  });
30916
30963
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
30917
- ..._stylex.props(fontStyles.body, styles$q.main),
30964
+ ..._stylex.props(fontStyles.body, styles$r.main),
30918
30965
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", {
30919
- ..._stylex.props(styles$q.content, customStyle),
30966
+ ..._stylex.props(styles$r.content, customStyle),
30920
30967
  onKeyUp,
30921
30968
  onClick: () => {
30922
30969
  var _a2;
@@ -30982,7 +31029,7 @@ const Pill = ({
30982
31029
  onClick,
30983
31030
  tabIndex: 0,
30984
31031
  ref: forwardRef,
30985
- ..._stylex.props(styles$q.pill, colorVariants[color]),
31032
+ ..._stylex.props(styles$r.pill, colorVariants[color]),
30986
31033
  children: [children, /* @__PURE__ */ jsxRuntime.jsx("div", {
30987
31034
  title: "Remove",
30988
31035
  ...{
@@ -30997,7 +31044,7 @@ const Pill = ({
30997
31044
  })]
30998
31045
  });
30999
31046
  };
31000
- const styles$q = {
31047
+ const styles$r = {
31001
31048
  main: {
31002
31049
  borderRadius: "mly12oqio5",
31003
31050
  borderStartStartRadius: null,
@@ -31129,6 +31176,20 @@ const colorVariants = {
31129
31176
  $$css: true
31130
31177
  }
31131
31178
  };
31179
+ function setAtPath(current, path, value) {
31180
+ const newCurrent = {
31181
+ ...current
31182
+ };
31183
+ let target = newCurrent;
31184
+ for (let i2 = 0; i2 < path.length - 1; i2++) {
31185
+ if (typeof target[path[i2]] !== "object") {
31186
+ target[path[i2]] = {};
31187
+ }
31188
+ target = target[path[i2]];
31189
+ }
31190
+ target[path[path.length - 1]] = value;
31191
+ return newCurrent;
31192
+ }
31132
31193
  function OneOfEditor({
31133
31194
  view,
31134
31195
  name,
@@ -31139,7 +31200,7 @@ function OneOfEditor({
31139
31200
  }) {
31140
31201
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
31141
31202
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
31142
- ..._stylex.props(styles$s.label, styles$s.left),
31203
+ ..._stylex.props(styles$t.label, styles$t.left),
31143
31204
  children: /* @__PURE__ */ jsxRuntime.jsxs("label", {
31144
31205
  children: [option2.title ?? name, ":"]
31145
31206
  })
@@ -31174,6 +31235,15 @@ function OneOfEditor({
31174
31235
  current,
31175
31236
  option: subOption
31176
31237
  }, key2);
31238
+ case "object":
31239
+ return /* @__PURE__ */ jsxRuntime.jsx(OneOfObjectEditor, {
31240
+ view,
31241
+ name,
31242
+ path,
31243
+ updateCurrent,
31244
+ current,
31245
+ option: subOption
31246
+ }, key2);
31177
31247
  }
31178
31248
  return null;
31179
31249
  })]
@@ -31190,7 +31260,7 @@ function OneOfStringEditor({
31190
31260
  if (option2.enum) {
31191
31261
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
31192
31262
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
31193
- ..._stylex.props(styles$s.left),
31263
+ ..._stylex.props(styles$t.left),
31194
31264
  children: /* @__PURE__ */ jsxRuntime.jsx("input", {
31195
31265
  type: "radio",
31196
31266
  checked: isString2 && option2.enum.includes(current),
@@ -31221,7 +31291,7 @@ function OneOfStringEditor({
31221
31291
  } else {
31222
31292
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
31223
31293
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
31224
- ..._stylex.props(styles$s.left),
31294
+ ..._stylex.props(styles$t.left),
31225
31295
  children: /* @__PURE__ */ jsxRuntime.jsx("input", {
31226
31296
  type: "radio",
31227
31297
  checked: isString2,
@@ -31259,7 +31329,7 @@ function OneOfNumberEditor({
31259
31329
  const [value, setValue] = React.useState(isNumber2 ? current : option2.minimum ?? 0);
31260
31330
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
31261
31331
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
31262
- ..._stylex.props(styles$s.left),
31332
+ ..._stylex.props(styles$t.left),
31263
31333
  children: /* @__PURE__ */ jsxRuntime.jsx("input", {
31264
31334
  type: "radio",
31265
31335
  checked: isNumber2,
@@ -31283,10 +31353,10 @@ function OneOfNumberEditor({
31283
31353
  valueAsNumber
31284
31354
  }
31285
31355
  }) => {
31286
- setValue(value);
31356
+ setValue(valueAsNumber);
31287
31357
  updateCurrent(path, valueAsNumber);
31288
31358
  },
31289
- ..._stylex.props(styles$s.input)
31359
+ ..._stylex.props(styles$t.input)
31290
31360
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {})]
31291
31361
  });
31292
31362
  }
@@ -31299,7 +31369,7 @@ function OneOfArrayEditor({
31299
31369
  const [value, setValue] = React.useState(isArray2 ? current : []);
31300
31370
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
31301
31371
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
31302
- ..._stylex.props(styles$s.left),
31372
+ ..._stylex.props(styles$t.left),
31303
31373
  children: /* @__PURE__ */ jsxRuntime.jsx("input", {
31304
31374
  type: "radio",
31305
31375
  checked: isArray2,
@@ -31322,6 +31392,48 @@ function OneOfArrayEditor({
31322
31392
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {})]
31323
31393
  });
31324
31394
  }
31395
+ function OneOfObjectEditor({
31396
+ path,
31397
+ current,
31398
+ option: option2,
31399
+ updateCurrent,
31400
+ view
31401
+ }) {
31402
+ const isObject2 = current != null && typeof current === "object" && !Array.isArray(current);
31403
+ const [objectValue, setObjectValue] = React.useState(isObject2 ? current : {});
31404
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
31405
+ children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
31406
+ ..._stylex.props(styles$t.left),
31407
+ children: /* @__PURE__ */ jsxRuntime.jsx("input", {
31408
+ type: "radio",
31409
+ checked: isObject2,
31410
+ onChange: ({
31411
+ target: {
31412
+ checked
31413
+ }
31414
+ }) => {
31415
+ if (checked) {
31416
+ updateCurrent(path, objectValue);
31417
+ }
31418
+ }
31419
+ })
31420
+ }), /* @__PURE__ */ jsxRuntime.jsx("div", {
31421
+ ..._stylex.props(styles$t.nest, styles$t.editorGrid),
31422
+ children: /* @__PURE__ */ jsxRuntime.jsx(ObjectEditor, {
31423
+ current: objectValue,
31424
+ updateCurrent: (path2, value) => {
31425
+ const [_2, ...subPath] = path2;
31426
+ setObjectValue(setAtPath(objectValue, subPath, value));
31427
+ updateCurrent(path2, value);
31428
+ },
31429
+ view,
31430
+ name: "",
31431
+ path,
31432
+ option: option2
31433
+ })
31434
+ })]
31435
+ });
31436
+ }
31325
31437
  function ArrayEditor({
31326
31438
  name,
31327
31439
  path,
@@ -31331,7 +31443,7 @@ function ArrayEditor({
31331
31443
  }) {
31332
31444
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
31333
31445
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
31334
- ..._stylex.props(styles$s.left, styles$s.label),
31446
+ ..._stylex.props(styles$t.left, styles$t.label),
31335
31447
  children: /* @__PURE__ */ jsxRuntime.jsxs("label", {
31336
31448
  children: [option2.title ?? name, ":"]
31337
31449
  })
@@ -31352,14 +31464,15 @@ function NumberEditor$1({
31352
31464
  option: option2,
31353
31465
  updateCurrent
31354
31466
  }) {
31467
+ const [value, setValue] = React__namespace.useState(current ?? option2.minimum);
31355
31468
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
31356
31469
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
31357
- ..._stylex.props(styles$s.left, styles$s.label),
31470
+ ..._stylex.props(styles$t.left, styles$t.label),
31358
31471
  children: /* @__PURE__ */ jsxRuntime.jsxs("label", {
31359
31472
  children: [option2.title ?? name, ":"]
31360
31473
  })
31361
31474
  }), /* @__PURE__ */ jsxRuntime.jsx("input", {
31362
- value: current,
31475
+ value,
31363
31476
  type: "number",
31364
31477
  min: option2.minimum,
31365
31478
  max: option2.maximum,
@@ -31368,9 +31481,10 @@ function NumberEditor$1({
31368
31481
  valueAsNumber
31369
31482
  }
31370
31483
  }) => {
31484
+ setValue(valueAsNumber);
31371
31485
  updateCurrent(path, valueAsNumber);
31372
31486
  },
31373
- ..._stylex.props(styles$s.input)
31487
+ ..._stylex.props(styles$t.input)
31374
31488
  }, name), option2.description ? /* @__PURE__ */ jsxRuntime.jsx(InfoHover, {
31375
31489
  info: option2.description
31376
31490
  }) : /* @__PURE__ */ jsxRuntime.jsx("div", {})]
@@ -31386,7 +31500,7 @@ function StringEditor$1({
31386
31500
  if (option2.enum) {
31387
31501
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
31388
31502
  children: [/* @__PURE__ */ React.createElement("div", {
31389
- ..._stylex.props(styles$s.left, styles$s.label),
31503
+ ..._stylex.props(styles$t.left, styles$t.label),
31390
31504
  key: `${name}-label`
31391
31505
  }, /* @__PURE__ */ jsxRuntime.jsxs("label", {
31392
31506
  children: [option2.title ?? name, ":"]
@@ -31406,7 +31520,7 @@ function StringEditor$1({
31406
31520
  } else {
31407
31521
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
31408
31522
  children: [/* @__PURE__ */ React.createElement("div", {
31409
- ..._stylex.props(styles$s.left, styles$s.label),
31523
+ ..._stylex.props(styles$t.left, styles$t.label),
31410
31524
  key: `${name}-label`
31411
31525
  }, /* @__PURE__ */ jsxRuntime.jsxs("label", {
31412
31526
  children: [option2.title ?? name, ":"]
@@ -31434,14 +31548,14 @@ function BooleanEditor({
31434
31548
  }) {
31435
31549
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
31436
31550
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
31437
- ..._stylex.props(styles$s.left),
31551
+ ..._stylex.props(styles$t.left),
31438
31552
  children: /* @__PURE__ */ jsxRuntime.jsxs("label", {
31439
- ..._stylex.props(styles$s.label),
31553
+ ..._stylex.props(styles$t.label),
31440
31554
  htmlFor: `${name}-checkbox`,
31441
31555
  children: [option2.title ?? name, ":"]
31442
31556
  }, `${name}-label`)
31443
31557
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
31444
- ..._stylex.props(styles$s.right),
31558
+ ..._stylex.props(styles$t.right),
31445
31559
  children: /* @__PURE__ */ jsxRuntime.jsx("input", {
31446
31560
  type: "checkbox",
31447
31561
  checked: current,
@@ -31490,7 +31604,7 @@ function FieldEditor({
31490
31604
  });
31491
31605
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
31492
31606
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
31493
- ..._stylex.props(styles$s.left, styles$s.label),
31607
+ ..._stylex.props(styles$t.left, styles$t.label),
31494
31608
  children: /* @__PURE__ */ jsxRuntime.jsxs("label", {
31495
31609
  children: [option2.title ?? name, ":"]
31496
31610
  })
@@ -31566,11 +31680,12 @@ function ObjectEditor({
31566
31680
  option: option2,
31567
31681
  updateCurrent
31568
31682
  }) {
31569
- const [isExpanded, setIsExpanded] = React.useState(path.length === 0);
31683
+ const [isExpanded, setIsExpanded] = React.useState(path.length === 0 || !name);
31570
31684
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
31571
31685
  children: [name ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
31572
31686
  children: [/* @__PURE__ */ jsxRuntime.jsxs("div", {
31573
- ..._stylex.props(styles$s.label, styles$s.heading),
31687
+ ..._stylex.props(styles$t.label, styles$t.heading),
31688
+ onClick: () => setIsExpanded(!isExpanded),
31574
31689
  children: [/* @__PURE__ */ jsxRuntime.jsx("label", {
31575
31690
  children: option2.title ?? name
31576
31691
  }), option2.description ? /* @__PURE__ */ jsxRuntime.jsx(InfoHover, {
@@ -31657,40 +31772,29 @@ function ObjectEditor({
31657
31772
  }
31658
31773
  return null;
31659
31774
  }) : null, /* @__PURE__ */ jsxRuntime.jsx("div", {
31660
- ..._stylex.props(styles$s.divider)
31775
+ ..._stylex.props(styles$t.divider)
31661
31776
  })]
31662
31777
  });
31663
31778
  }
31664
31779
  function VizEditor({
31665
- rootQuery,
31666
31780
  view,
31667
31781
  plugin,
31668
31782
  setOpen
31669
31783
  }) {
31670
- const {
31671
- setQuery
31672
- } = React.useContext(QueryEditorContext);
31784
+ const updateQuery = useUpdateQuery();
31673
31785
  const [current, setCurrent] = React.useState(plugin.getSettings());
31674
- console.info("RendererEditor current settings:", current);
31675
31786
  const schema = plugin.getSchema();
31676
31787
  const updateCurrent = (path, value) => {
31677
- const newCurrent = {
31678
- ...current
31679
- };
31680
- let target = newCurrent;
31681
- for (let i2 = 0; i2 < path.length - 1; i2++) {
31682
- if (!(path[i2] in target)) {
31683
- target[path[i2]] = {};
31684
- }
31685
- target = target[path[i2]];
31686
- }
31687
- target[path[path.length - 1]] = value;
31788
+ const newCurrent = setAtPath(current, path, value);
31688
31789
  setCurrent(newCurrent);
31689
31790
  };
31791
+ React__namespace.useEffect(() => {
31792
+ console.info("RendererEditor current settings:", current);
31793
+ }, [current]);
31690
31794
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
31691
- ..._stylex.props(styles$s.editor),
31795
+ ..._stylex.props(styles$t.editor),
31692
31796
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
31693
- ..._stylex.props(styles$s.editorGrid),
31797
+ ..._stylex.props(styles$t.editorGrid),
31694
31798
  children: /* @__PURE__ */ jsxRuntime.jsx(ObjectEditor, {
31695
31799
  view,
31696
31800
  name: "",
@@ -31700,13 +31804,13 @@ function VizEditor({
31700
31804
  updateCurrent
31701
31805
  })
31702
31806
  }), /* @__PURE__ */ jsxRuntime.jsxs("div", {
31703
- ..._stylex.props(styles$s.editorRow),
31807
+ ..._stylex.props(styles$t.editorRow),
31704
31808
  children: [/* @__PURE__ */ jsxRuntime.jsx(Button, {
31705
31809
  label: "Cancel",
31706
31810
  onClick: () => {
31707
31811
  setOpen(false);
31708
31812
  },
31709
- customStyle: styles$s.editorCell
31813
+ customStyle: styles$t.editorCell
31710
31814
  }), /* @__PURE__ */ jsxRuntime.jsx(Button, {
31711
31815
  variant: "primary",
31712
31816
  label: "Apply",
@@ -31718,13 +31822,13 @@ function VizEditor({
31718
31822
  if (old) {
31719
31823
  annotations.remove(old);
31720
31824
  }
31721
- view.getOrAddAnnotations().add(new QB.ASTAnnotation({
31825
+ view.getOrAddAnnotations().add(new malloyQueryBuilder.ASTAnnotation({
31722
31826
  value
31723
31827
  }));
31724
- setQuery == null ? void 0 : setQuery(rootQuery.build());
31828
+ updateQuery();
31725
31829
  setOpen(false);
31726
31830
  },
31727
- customStyle: styles$s.editorCell
31831
+ customStyle: styles$t.editorCell
31728
31832
  })]
31729
31833
  })]
31730
31834
  });
@@ -31934,7 +32038,6 @@ const dialogStyles = {
31934
32038
  }
31935
32039
  };
31936
32040
  function VizEditorDialog({
31937
- rootQuery,
31938
32041
  plugin,
31939
32042
  view,
31940
32043
  customStyle,
@@ -31951,7 +32054,7 @@ function VizEditorDialog({
31951
32054
  children: /* @__PURE__ */ jsxRuntime.jsx(Overlay, {
31952
32055
  ..._stylex.props(dialogStyles.overlay),
31953
32056
  children: /* @__PURE__ */ jsxRuntime.jsxs(Content$1, {
31954
- ..._stylex.props(fontStyles.body, dialogStyles.content, styles$p.content, customStyle),
32057
+ ..._stylex.props(fontStyles.body, dialogStyles.content, styles$q.content, customStyle),
31955
32058
  children: [/* @__PURE__ */ jsxRuntime.jsxs(Title, {
31956
32059
  ..._stylex.props(dialogStyles.title),
31957
32060
  children: ["Visualization Settings", /* @__PURE__ */ jsxRuntime.jsx(Close, {
@@ -31964,7 +32067,6 @@ function VizEditorDialog({
31964
32067
  ..._stylex.props(dialogStyles.displayNone),
31965
32068
  children: "Edit visualization parameters"
31966
32069
  }), /* @__PURE__ */ jsxRuntime.jsx(VizEditor, {
31967
- rootQuery,
31968
32070
  view,
31969
32071
  plugin,
31970
32072
  setOpen
@@ -31974,7 +32076,7 @@ function VizEditorDialog({
31974
32076
  })
31975
32077
  });
31976
32078
  }
31977
- const styles$p = {
32079
+ const styles$q = {
31978
32080
  content: {
31979
32081
  maxWidth: "mly14zcgw3",
31980
32082
  width: "mly14rvwrp",
@@ -31983,12 +32085,9 @@ const styles$p = {
31983
32085
  }
31984
32086
  };
31985
32087
  function Visualization$1({
31986
- rootQuery,
31987
32088
  view
31988
32089
  }) {
31989
- const {
31990
- setQuery
31991
- } = React.useContext(QueryEditorContext);
32090
+ const updateQuery = useUpdateQuery();
31992
32091
  const renderer = React.useMemo(() => new render.MalloyRenderer(), []);
31993
32092
  const [currentRenderer, setCurrentRenderer] = React.useState("table");
31994
32093
  const [plugin, setPlugin] = React.useState();
@@ -32033,7 +32132,7 @@ function Visualization$1({
32033
32132
  }, [renderer, view, tag]);
32034
32133
  const updateViz = (renderer2) => {
32035
32134
  view.setTagProperty(["viz"], renderer2, RENDERER_PREFIX);
32036
- setQuery == null ? void 0 : setQuery(rootQuery.build());
32135
+ updateQuery();
32037
32136
  };
32038
32137
  const items = VIZ_RENDERERS.map((viz) => ({
32039
32138
  icon: /* @__PURE__ */ jsxRuntime.jsx(Icon, {
@@ -32044,7 +32143,7 @@ function Visualization$1({
32044
32143
  onClick: () => updateViz(viz)
32045
32144
  }));
32046
32145
  const tokens2 = [/* @__PURE__ */ jsxRuntime.jsx(SelectorToken, {
32047
- customStyle: styles$o.first,
32146
+ customStyle: styles$p.first,
32048
32147
  icon: `viz_${currentRenderer}`,
32049
32148
  value: currentRenderer,
32050
32149
  items,
@@ -32054,7 +32153,7 @@ function Visualization$1({
32054
32153
  tokens2.push(/* @__PURE__ */ jsxRuntime.jsx(Token, {
32055
32154
  icon: "gear",
32056
32155
  onClick: () => setOpen(true),
32057
- customStyle: styles$o.trigger,
32156
+ customStyle: styles$p.trigger,
32058
32157
  tooltip: "Edit Settings..."
32059
32158
  }, "gear"));
32060
32159
  }
@@ -32062,23 +32161,22 @@ function Visualization$1({
32062
32161
  tokens2.push(/* @__PURE__ */ jsxRuntime.jsx(Token, {
32063
32162
  icon: "warning",
32064
32163
  tooltip: error,
32065
- customStyle: styles$o.trigger
32164
+ customStyle: styles$p.trigger
32066
32165
  }));
32067
32166
  }
32068
32167
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
32069
32168
  children: [/* @__PURE__ */ jsxRuntime.jsx(TokenGroup, {
32070
- customStyle: styles$o.group,
32169
+ customStyle: styles$p.group,
32071
32170
  children: tokens2
32072
32171
  }), /* @__PURE__ */ jsxRuntime.jsx(VizEditorDialog, {
32073
32172
  open,
32074
32173
  setOpen,
32075
- rootQuery,
32076
32174
  plugin,
32077
32175
  view
32078
32176
  })]
32079
32177
  });
32080
32178
  }
32081
- const styles$o = {
32179
+ const styles$p = {
32082
32180
  trigger: {
32083
32181
  height: "mly1ktj5wk",
32084
32182
  $$css: true
@@ -32115,7 +32213,7 @@ function ViewAttributeTable({
32115
32213
  }) {
32116
32214
  const dimensions = viewInfo.schema.fields.filter((f2) => f2.kind === "dimension");
32117
32215
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
32118
- ..._stylex.props(styles$n.attributeTableContainer, style),
32216
+ ..._stylex.props(styles$o.attributeTableContainer, style),
32119
32217
  children: /* @__PURE__ */ jsxRuntime.jsx("table", {
32120
32218
  ...{
32121
32219
  className: "mly1mwwwfo mly9f619 mlyh8yej3 mly5yr21d"
@@ -32153,9 +32251,9 @@ function ViewAttributeTableRow({
32153
32251
  className: "mlydpxx8g"
32154
32252
  },
32155
32253
  children: [/* @__PURE__ */ jsxRuntime.jsx("td", {
32156
- ..._stylex.props(styles$n.attributeTableKeyCell, fontStyles.supporting),
32254
+ ..._stylex.props(styles$o.attributeTableKeyCell, fontStyles.supporting),
32157
32255
  children: /* @__PURE__ */ jsxRuntime.jsx("div", {
32158
- ..._stylex.props(styles$n.attributeTableKeyCellContent, fontStyles.supporting),
32256
+ ..._stylex.props(styles$o.attributeTableKeyCellContent, fontStyles.supporting),
32159
32257
  children: attribute
32160
32258
  })
32161
32259
  }), /* @__PURE__ */ jsxRuntime.jsx("td", {
@@ -32166,7 +32264,7 @@ function ViewAttributeTableRow({
32166
32264
  })]
32167
32265
  });
32168
32266
  }
32169
- const styles$n = {
32267
+ const styles$o = {
32170
32268
  attributeTableContainer: {
32171
32269
  padding: "mlye8ttls",
32172
32270
  paddingInline: null,
@@ -32215,9 +32313,7 @@ function TopValuesTable({
32215
32313
  field,
32216
32314
  path
32217
32315
  }) {
32218
- const {
32219
- topValues
32220
- } = React.useContext(QueryEditorContext);
32316
+ const topValues = useTopValues();
32221
32317
  const fieldPath = [...path, field.name].join(".");
32222
32318
  const fieldTopValues = topValues == null ? void 0 : topValues.find((entry) => entry.fieldName === fieldPath);
32223
32319
  if (!fieldTopValues) {
@@ -32298,12 +32394,12 @@ function RichText({
32298
32394
  });
32299
32395
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
32300
32396
  ref,
32301
- ..._stylex.props(multiLine && styles$m.preWrap, multiLine && styles$m.breakWord, customStyle),
32397
+ ..._stylex.props(multiLine && styles$n.preWrap, multiLine && styles$n.breakWord, customStyle),
32302
32398
  ...props2,
32303
32399
  children: formatted
32304
32400
  });
32305
32401
  }
32306
- const styles$m = {
32402
+ const styles$n = {
32307
32403
  preWrap: {
32308
32404
  whiteSpace: "mly126k92a",
32309
32405
  $$css: true
@@ -32332,7 +32428,7 @@ function HoverText({
32332
32428
  onMouseEnter: () => setIsTriggerHovered(true),
32333
32429
  onMouseLeave: () => setIsTriggerHovered(false),
32334
32430
  onPointerMove: (e) => e.preventDefault(),
32335
- customStyle: [fontStyles.supporting, styles$l.text],
32431
+ customStyle: [fontStyles.supporting, styles$m.text],
32336
32432
  children: text2
32337
32433
  })
32338
32434
  }), /* @__PURE__ */ jsxRuntime.jsx(Portal$4, {
@@ -32351,7 +32447,7 @@ function HoverText({
32351
32447
  })]
32352
32448
  });
32353
32449
  }
32354
- const styles$l = {
32450
+ const styles$m = {
32355
32451
  text: {
32356
32452
  overflow: "mlyb3r6kr",
32357
32453
  overflowX: null,
@@ -32378,7 +32474,7 @@ function FieldHoverCard({
32378
32474
  details = /* @__PURE__ */ jsxRuntime.jsx(ViewAttributeTable, {
32379
32475
  viewInfo: field,
32380
32476
  isCompact: true,
32381
- style: styles$k.viewAttributeTable
32477
+ style: styles$l.viewAttributeTable
32382
32478
  });
32383
32479
  } else if (field.kind === "dimension") {
32384
32480
  details = /* @__PURE__ */ jsxRuntime.jsx(TopValuesTable, {
@@ -32387,7 +32483,7 @@ function FieldHoverCard({
32387
32483
  });
32388
32484
  }
32389
32485
  return /* @__PURE__ */ jsxRuntime.jsxs(HoverCard, {
32390
- customStyle: styles$k.container,
32486
+ customStyle: styles$l.container,
32391
32487
  children: [/* @__PURE__ */ jsxRuntime.jsxs("div", {
32392
32488
  ref,
32393
32489
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
@@ -32398,10 +32494,10 @@ function FieldHoverCard({
32398
32494
  field
32399
32495
  })
32400
32496
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
32401
- ..._stylex.props(fontStyles.supporting, styles$k.path),
32497
+ ..._stylex.props(fontStyles.supporting, styles$l.path),
32402
32498
  children: pathString
32403
32499
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
32404
- ..._stylex.props(fontStyles.emphasized, styles$k.title),
32500
+ ..._stylex.props(fontStyles.emphasized, styles$l.title),
32405
32501
  children: field.name
32406
32502
  }), description && /* @__PURE__ */ jsxRuntime.jsx(HoverText, {
32407
32503
  text: description,
@@ -32412,7 +32508,7 @@ function FieldHoverCard({
32412
32508
  })]
32413
32509
  });
32414
32510
  }
32415
- const styles$k = {
32511
+ const styles$l = {
32416
32512
  container: {
32417
32513
  width: "mlybl57os",
32418
32514
  maxHeight: "mlyq3t0pi",
@@ -32590,9 +32686,7 @@ function BooleanFilterCore({
32590
32686
  });
32591
32687
  }
32592
32688
  function useSearch(searchTerm, fieldPath) {
32593
- const {
32594
- topValues
32595
- } = React.useContext(QueryEditorContext);
32689
+ const topValues = useTopValues();
32596
32690
  if (topValues && searchTerm) {
32597
32691
  let searchValues = topValues;
32598
32692
  if (fieldPath) {
@@ -32647,7 +32741,7 @@ function ValueList({
32647
32741
  children: (stringSearchResults == null ? void 0 : stringSearchResults.length) ? stringSearchResults.map((value) => /* @__PURE__ */ jsxRuntime.jsxs("div", {
32648
32742
  role: "menuitem",
32649
32743
  tabIndex: -1,
32650
- ..._stylex.props(addMenuStyles.item, styles$j.valueItem),
32744
+ ..._stylex.props(addMenuStyles.item, styles$k.valueItem),
32651
32745
  onClick: () => onClick(value),
32652
32746
  children: [/* @__PURE__ */ jsxRuntime.jsx(Value, {
32653
32747
  value
@@ -32671,10 +32765,10 @@ function Value({
32671
32765
  label: value.fieldValue ?? "∅",
32672
32766
  icon: "filter",
32673
32767
  color: "purple",
32674
- customStyle: styles$j.token
32768
+ customStyle: styles$k.token
32675
32769
  });
32676
32770
  }
32677
- const styles$j = {
32771
+ const styles$k = {
32678
32772
  valueItem: {
32679
32773
  height: "mly1qx5ct2",
32680
32774
  paddingTop: "mly1y1aw1k",
@@ -32850,7 +32944,7 @@ const StringFilterCore = ({
32850
32944
  setSearchValue("");
32851
32945
  }
32852
32946
  },
32853
- customStyle: styles$i.valueList,
32947
+ customStyle: styles$j.valueList,
32854
32948
  showPath: false,
32855
32949
  filter: (value) => !currentFilter.values.includes(value),
32856
32950
  hideNoMatchMessage: true
@@ -32921,7 +33015,7 @@ function stringFilterChangeType(filter, type) {
32921
33015
  };
32922
33016
  }
32923
33017
  }
32924
- const styles$i = {
33018
+ const styles$j = {
32925
33019
  valueList: {
32926
33020
  maxHeight: "mly3d5gib",
32927
33021
  width: "mly1hfn5x7",
@@ -33873,7 +33967,7 @@ function FieldList({
33873
33967
  ..._stylex.props(customStyle),
33874
33968
  children: groups.length ? groups.map((group) => /* @__PURE__ */ jsxRuntime.jsxs("div", {
33875
33969
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
33876
- ..._stylex.props(addMenuStyles.item, styles$h.fieldItem, styles$h.sticky),
33970
+ ..._stylex.props(addMenuStyles.item, styles$i.fieldItem, styles$i.sticky),
33877
33971
  "data-disabled": "true",
33878
33972
  children: group.name
33879
33973
  }), group.fields.map((field) => isFilterOperation && (field.kind === "dimension" || field.kind === "measure") ? /* @__PURE__ */ jsxRuntime.jsx(FilterPopover, {
@@ -33883,7 +33977,7 @@ function FieldList({
33883
33977
  anchor: /* @__PURE__ */ jsxRuntime.jsx("div", {
33884
33978
  role: "menuitem",
33885
33979
  tabIndex: -1,
33886
- ..._stylex.props(addMenuStyles.item, styles$h.fieldItem),
33980
+ ..._stylex.props(addMenuStyles.item, styles$i.fieldItem),
33887
33981
  children: /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, {
33888
33982
  asChild: true,
33889
33983
  children: /* @__PURE__ */ jsxRuntime.jsx(FieldToken, {
@@ -33910,7 +34004,7 @@ function FieldList({
33910
34004
  }, group.name + ":" + field.name) : /* @__PURE__ */ jsxRuntime.jsx("div", {
33911
34005
  role: "menuitem",
33912
34006
  tabIndex: -1,
33913
- ..._stylex.props(addMenuStyles.item, styles$h.fieldItem),
34007
+ ..._stylex.props(addMenuStyles.item, styles$i.fieldItem),
33914
34008
  children: /* @__PURE__ */ jsxRuntime.jsx(FieldToken, {
33915
34009
  field,
33916
34010
  onClick: () => onAddOperation(field, group.path),
@@ -33933,7 +34027,7 @@ function FieldList({
33933
34027
  })
33934
34028
  });
33935
34029
  }
33936
- const styles$h = {
34030
+ const styles$i = {
33937
34031
  fieldItem: {
33938
34032
  height: "mly1qx5ct2",
33939
34033
  paddingTop: "mly1y1aw1k",
@@ -33962,7 +34056,7 @@ function FieldMenu({
33962
34056
  }) {
33963
34057
  const [search, setSearch] = React.useState("");
33964
34058
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
33965
- ..._stylex.props(addMenuStyles.content, styles$g.content),
34059
+ ..._stylex.props(addMenuStyles.content, styles$h.content),
33966
34060
  role: "menu",
33967
34061
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
33968
34062
  ..._stylex.props(addMenuStyles.item),
@@ -33988,25 +34082,61 @@ function FieldMenu({
33988
34082
  })]
33989
34083
  });
33990
34084
  }
33991
- const styles$g = {
34085
+ const styles$h = {
33992
34086
  content: {
33993
34087
  maxHeight: "mly3d5gib",
33994
34088
  $$css: true
33995
34089
  }
33996
34090
  };
34091
+ const getPrimaryAxis = (view) => {
34092
+ const schema = view.getOutputSchema();
34093
+ return getPrimaryAxisFromSchema(schema);
34094
+ };
34095
+ const getPrimaryAxisFromSchema = (schema) => {
34096
+ let primaryAxisField = void 0;
34097
+ primaryAxisField = findAxisFieldByAnnotation(schema.fields) || findAxisFieldByType(schema.fields) || findDefaultAxisField(schema.fields);
34098
+ return primaryAxisField;
34099
+ };
34100
+ const findAxisFieldByAnnotation = (fields) => {
34101
+ return fields.find((field) => {
34102
+ if (field.kind === "dimension" && field.annotations && field.annotations.find((annotation) => annotation.value === "# x")) {
34103
+ return true;
34104
+ }
34105
+ return false;
34106
+ });
34107
+ };
34108
+ const findAxisFieldByType = (fields) => {
34109
+ return fields.find((field) => {
34110
+ if (field.kind === "dimension") {
34111
+ const dimension = field;
34112
+ if (dimension.type.kind === "date_type" || dimension.type.kind === "timestamp_type") {
34113
+ return true;
34114
+ }
34115
+ }
34116
+ return false;
34117
+ });
34118
+ };
34119
+ const findDefaultAxisField = (fields) => {
34120
+ return fields.find((field) => {
34121
+ if (field.kind === "dimension") {
34122
+ return true;
34123
+ }
34124
+ return false;
34125
+ });
34126
+ };
33997
34127
  function toFullName(path, name) {
33998
34128
  return [...path || [], name].join(".");
33999
34129
  }
34000
34130
  function segmentHasLimit(segment) {
34001
- return segment.operations.items.find((operation) => operation instanceof QB.ASTLimitViewOperation) !== void 0;
34131
+ return segment.operations.items.find((operation) => operation instanceof malloyQueryBuilder.ASTLimitViewOperation) !== void 0;
34002
34132
  }
34003
34133
  function segmentHasOrderBy(segment, name) {
34004
- return segment.operations.items.find((operation) => operation instanceof QB.ASTOrderByViewOperation && operation.name === name) !== void 0;
34134
+ return segment.operations.items.find((operation) => operation instanceof malloyQueryBuilder.ASTOrderByViewOperation && operation.name === name) !== void 0;
34005
34135
  }
34006
34136
  function getOutputNameToInputNameMap(segment) {
34007
34137
  const nameMap = /* @__PURE__ */ new Map();
34008
34138
  for (const operation of segment.operations.items) {
34009
- if (operation instanceof QB.ASTGroupByViewOperation || operation instanceof QB.ASTAggregateViewOperation) {
34139
+ if (operation instanceof malloyQueryBuilder.ASTGroupByViewOperation || operation instanceof malloyQueryBuilder.ASTAggregateViewOperation) {
34010
34140
  const reference = operation.field.getReference();
34011
34141
  if (reference) {
34012
34142
  nameMap.set(operation.name, toFullName(reference.path, reference.name));
@@ -34019,7 +34149,7 @@ function segmentHasOrderBySourceField(segment, path, name) {
34019
34149
  const nameMap = getOutputNameToInputNameMap(segment);
34020
34150
  const fullInputName = toFullName(path, name);
34021
34151
  return !!segment.operations.items.find((operation) => {
34022
- if (operation instanceof QB.ASTOrderByViewOperation && nameMap.has(operation.name)) {
34152
+ if (operation instanceof malloyQueryBuilder.ASTOrderByViewOperation && nameMap.has(operation.name)) {
34023
34153
  return fullInputName === nameMap.get(operation.name);
34024
34154
  }
34025
34155
  return false;
@@ -34030,7 +34160,7 @@ function areReferencesEqual(path1, name1, path2, name2) {
34030
34160
  }
34031
34161
  function segmentHasFieldInOutputSpace(segment, path, name) {
34032
34162
  const match = segment.operations.items.find((operation) => {
34033
- if (operation instanceof QB.ASTGroupByViewOperation || operation instanceof QB.ASTAggregateViewOperation) {
34163
+ if (operation instanceof malloyQueryBuilder.ASTGroupByViewOperation || operation instanceof malloyQueryBuilder.ASTAggregateViewOperation) {
34034
34164
  const reference = operation.field.getReference();
34035
34165
  if (reference) {
34036
34166
  return areReferencesEqual(path, name, reference.path, reference.name);
@@ -34044,7 +34174,7 @@ function segmentHasFieldInOutputSpace(segment, path, name) {
34044
34174
  }
34045
34175
  function segmentNestNo(segment, name) {
34046
34176
  return segment.operations.items.reduce((acc, operation) => {
34047
- if (operation instanceof QB.ASTNestViewOperation) {
34177
+ if (operation instanceof malloyQueryBuilder.ASTNestViewOperation) {
34048
34178
  {
34049
34179
  if (operation.name === name) {
34050
34180
  do {
@@ -34072,6 +34202,34 @@ function addGroupBy(view, field, path) {
34072
34202
  segment.addTimestampGroupBy(field.name, path, "second");
34073
34203
  } else {
34074
34204
  segment.addGroupBy(field.name, path, rename);
34205
+ recomputePartitionByAndPrimaryAxis(segment);
34206
+ }
34207
+ }
34208
+ function recomputePartitionByAndPrimaryAxis(segment) {
34209
+ var _a2;
34210
+ const primaryAxis = getPrimaryAxisFromSchema(segment.getOutputSchema());
34211
+ const groupBys = segment.operations.items.filter((op) => op.kind === "group_by");
34212
+ const movingAverages = segment.operations.items.filter((op) => op.kind === "calculate" && op.expression.kind === "moving_average");
34213
+ const canSmooth = primaryAxis !== null && (primaryAxis == null ? void 0 : primaryAxis.kind) === "dimension" && (primaryAxis.type.kind === "timestamp_type" || primaryAxis.type.kind === "date_type");
34214
+ if (!canSmooth) {
34215
+ movingAverages.forEach((operation) => {
34216
+ operation.delete();
34217
+ segment.addAggregate(operation.getFieldInfo().name);
34218
+ });
34219
+ } else {
34220
+ const nonPrimaryGroupByNames = groupBys.filter((gb) => gb.name !== primaryAxis.name);
34221
+ movingAverages.forEach((operation) => {
34222
+ operation.expression.edit();
34223
+ operation.expression.setPartitionFields(nonPrimaryGroupByNames.map((gb) => gb.field.getReference()).filter((ref) => !!ref));
34224
+ });
34225
+ const primaryTimeAxisOperation = groupBys.find((gb) => gb.name === primaryAxis.name);
34226
+ if (primaryTimeAxisOperation) {
34227
+ const expression = (_a2 = primaryTimeAxisOperation.field) == null ? void 0 : _a2.expression;
34228
+ if (expression && expression.kind === "time_truncation") {
34229
+ const truncationExpression = primaryTimeAxisOperation.field.expression;
34230
+ truncationExpression.truncation = "day";
34231
+ }
34232
+ }
34075
34233
  }
34076
34234
  }
34077
34235
  function addAggregate(view, field, path) {
@@ -34126,10 +34284,10 @@ function getSegmentIfPresent(parent) {
34126
34284
  return void 0;
34127
34285
  }
34128
34286
  const definition = getViewDefinition(parent);
34129
- if (definition instanceof QB.ASTSegmentViewDefinition) {
34287
+ if (definition instanceof malloyQueryBuilder.ASTSegmentViewDefinition) {
34130
34288
  return definition;
34131
- } else if (definition instanceof QB.ASTRefinementViewDefinition) {
34132
- if (definition.refinement instanceof QB.ASTSegmentViewDefinition) {
34289
+ } else if (definition instanceof malloyQueryBuilder.ASTRefinementViewDefinition) {
34290
+ if (definition.refinement instanceof malloyQueryBuilder.ASTSegmentViewDefinition) {
34133
34291
  return definition.refinement;
34134
34292
  }
34135
34293
  }
@@ -34149,7 +34307,7 @@ function OperationActionTitle({
34149
34307
  return !(segment == null ? void 0 : segment.hasField(field.name, path)) && isNotAnnotatedFilteredField(field);
34150
34308
  };
34151
34309
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
34152
- ..._stylex.props(styles$u.title, hoverStyles.main),
34310
+ ..._stylex.props(styles$v.title, hoverStyles.main),
34153
34311
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
34154
34312
  children: title
34155
34313
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
@@ -34183,16 +34341,13 @@ function OperationActionTitle({
34183
34341
  });
34184
34342
  }
34185
34343
  function RenameDialog({
34186
- rootQuery,
34187
34344
  view,
34188
34345
  target,
34189
34346
  open,
34190
34347
  setOpen
34191
34348
  }) {
34192
34349
  const [name, setName] = React.useState("");
34193
- const {
34194
- setQuery
34195
- } = React.useContext(QueryEditorContext);
34350
+ const updateQuery = useUpdateQuery();
34196
34351
  React.useEffect(() => {
34197
34352
  if (target) {
34198
34353
  setName(target.name);
@@ -34202,8 +34357,9 @@ function RenameDialog({
34202
34357
  return null;
34203
34358
  }
34204
34359
  const onRename = () => {
34360
+ target.edit();
34205
34361
  target.name = name;
34206
- setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
34362
+ updateQuery();
34207
34363
  setOpen(false);
34208
34364
  };
34209
34365
  const {
@@ -34266,15 +34422,12 @@ function RenameDialog({
34266
34422
  });
34267
34423
  }
34268
34424
  function SortableOperations({
34269
- rootQuery,
34270
34425
  segment,
34271
34426
  view,
34272
34427
  operations,
34273
34428
  kind
34274
34429
  }) {
34275
- const {
34276
- setQuery
34277
- } = React.useContext(QueryEditorContext);
34430
+ const updateQuery = useUpdateQuery();
34278
34431
  const sensors = useSensors(useSensor(PointerSensor));
34279
34432
  const items = React.useMemo(() => {
34280
34433
  return operations.map((operation) => ({
@@ -34286,7 +34439,7 @@ function SortableOperations({
34286
34439
  return null;
34287
34440
  }
34288
34441
  function handleDragEnd(event) {
34289
- const operations2 = segment.operations.items.filter((operation) => operation instanceof QB.ASTAggregateViewOperation || operation instanceof QB.ASTGroupByViewOperation || operation instanceof QB.ASTNestViewOperation);
34442
+ const operations2 = segment.operations.items.filter((operation) => operation instanceof malloyQueryBuilder.ASTAggregateViewOperation || operation instanceof malloyQueryBuilder.ASTGroupByViewOperation || operation instanceof malloyQueryBuilder.ASTNestViewOperation);
34290
34443
  const names = operations2.map((operation) => operation.name);
34291
34444
  const {
34292
34445
  active,
@@ -34296,7 +34449,7 @@ function SortableOperations({
34296
34449
  const oldIndex = names.indexOf(active.id);
34297
34450
  const newIndex = names.indexOf(over.id);
34298
34451
  segment.reorderFields(arrayMove(names, oldIndex, newIndex));
34299
- setQuery == null ? void 0 : setQuery(rootQuery.build());
34452
+ updateQuery();
34300
34453
  }
34301
34454
  }
34302
34455
  const {
@@ -34308,7 +34461,7 @@ function SortableOperations({
34308
34461
  types: ["dimension"],
34309
34462
  onClick: (field, path) => {
34310
34463
  addGroupBy(view, field, path);
34311
- setQuery == null ? void 0 : setQuery(rootQuery.build());
34464
+ updateQuery();
34312
34465
  }
34313
34466
  } : {
34314
34467
  title: "aggregate",
@@ -34316,17 +34469,16 @@ function SortableOperations({
34316
34469
  types: ["measure"],
34317
34470
  onClick: (field, path) => {
34318
34471
  addAggregate(view, field, path);
34319
- setQuery == null ? void 0 : setQuery(rootQuery.build());
34472
+ updateQuery();
34320
34473
  }
34321
34474
  };
34322
34475
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
34323
34476
  children: [/* @__PURE__ */ jsxRuntime.jsx(OperationActionTitle, {
34324
- rootQuery,
34325
34477
  view,
34326
34478
  fields,
34327
34479
  ...props2
34328
34480
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
34329
- ..._stylex.props(styles$u.tokenContainer),
34481
+ ..._stylex.props(styles$v.tokenContainer),
34330
34482
  children: /* @__PURE__ */ jsxRuntime.jsx(DndContext, {
34331
34483
  sensors,
34332
34484
  collisionDetection: closestCenter,
@@ -34334,7 +34486,6 @@ function SortableOperations({
34334
34486
  children: /* @__PURE__ */ jsxRuntime.jsx(SortableContext, {
34335
34487
  items,
34336
34488
  children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(SortableOperation, {
34337
- rootQuery,
34338
34489
  id: item.id,
34339
34490
  color: kind === "group_by" ? "cyan" : "green",
34340
34491
  view,
@@ -34347,18 +34498,16 @@ function SortableOperations({
34347
34498
  }
34348
34499
  const NULL_PATH = [];
34349
34500
  function SortableOperation({
34350
- rootQuery,
34351
34501
  id,
34352
34502
  view,
34353
34503
  operation,
34354
34504
  color
34355
34505
  }) {
34356
34506
  var _a2;
34357
- const {
34358
- setQuery
34359
- } = React.useContext(QueryEditorContext);
34507
+ const updateQuery = useUpdateQuery();
34360
34508
  const fieldInfo = operation.getFieldInfo();
34361
- const path = ((_a2 = operation.field.getReference()) == null ? void 0 : _a2.path) ?? NULL_PATH;
34509
+ const field = operation instanceof malloyQueryBuilder.ASTCalculateViewOperation ? null : operation.field;
34510
+ const path = operation instanceof malloyQueryBuilder.ASTCalculateViewOperation ? operation.expression.node.field_reference.path ?? NULL_PATH : ((_a2 = operation.field.getReference()) == null ? void 0 : _a2.path) ?? NULL_PATH;
34362
34511
  const {
34363
34512
  attributes,
34364
34513
  listeners,
@@ -34378,6 +34527,18 @@ function SortableOperation({
34378
34527
  transform: CSS$1.Transform.toString(transform2),
34379
34528
  transition
34380
34529
  };
34530
+ const primaryAxis = React.useMemo(() => {
34531
+ return getPrimaryAxis(view);
34532
+ }, [view]);
34533
+ const canSmooth = operation.kind === "aggregate" && primaryAxis !== null && (primaryAxis == null ? void 0 : primaryAxis.kind) === "dimension" && (primaryAxis.type.kind === "timestamp_type" || primaryAxis.type.kind === "date_type");
34534
+ const enableSmoothing = React.useCallback((operation2) => {
34535
+ if (!canSmooth) {
34536
+ return;
34537
+ }
34538
+ operation2.convertToCalculateMovingAverage(operation2.name + "_smoothed", 7);
34539
+ recomputePartitionByAndPrimaryAxis(view.getOrAddDefaultSegment());
34540
+ updateQuery();
34541
+ }, [canSmooth, updateQuery, view]);
34381
34542
  const hoverActions = React.useMemo(() => {
34382
34543
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
34383
34544
  children: [/* @__PURE__ */ jsxRuntime.jsx(DropdownMenu, {
@@ -34388,7 +34549,14 @@ function SortableOperation({
34388
34549
  tooltip: "More Actions"
34389
34550
  }),
34390
34551
  onOpenChange: setHoverActionsVisible,
34391
- children: [/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, {
34552
+ children: [canSmooth ? /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, {
34553
+ label: "Add smoothing",
34554
+ onClick: () => {
34555
+ if (operation instanceof malloyQueryBuilder.ASTAggregateViewOperation) {
34556
+ enableSmoothing(operation);
34557
+ }
34558
+ }
34559
+ }, "smoothing") : null, /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, {
34392
34560
  label: "Rename",
34393
34561
  onClick: () => {
34394
34562
  setRenameTarget(operation);
@@ -34398,12 +34566,21 @@ function SortableOperation({
34398
34566
  }, [...path, fieldInfo.name].join(".")), /* @__PURE__ */ jsxRuntime.jsx(ClearButton, {
34399
34567
  onClick: () => {
34400
34568
  operation.delete();
34401
- setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
34569
+ recomputePartitionByAndPrimaryAxis(view.getOrAddDefaultSegment());
34570
+ updateQuery();
34402
34571
  }
34403
34572
  })]
34404
34573
  });
34405
- }, [fieldInfo, operation, path, rootQuery, setQuery]);
34406
- const granular = granularityMenuItems(fieldInfo, operation.field);
34574
+ }, [canSmooth, enableSmoothing, fieldInfo.name, operation, path, updateQuery, view]);
34575
+ const hasSmoothedField = React.useMemo(() => {
34576
+ return view.getOrAddDefaultSegment().operations.items.some((operation2) => {
34577
+ return operation2.kind === "calculate";
34578
+ });
34579
+ }, [view]);
34580
+ const granular = granularityMenuItems(fieldInfo, field);
34581
+ if (hasSmoothedField && granular && operation.name === (primaryAxis == null ? void 0 : primaryAxis.name)) {
34582
+ granular.options = granular.options.filter((option2) => option2.value === "day");
34583
+ }
34407
34584
  let icon = "orderBy";
34408
34585
  if (fieldInfo.kind === "dimension" || fieldInfo.kind === "measure") {
34409
34586
  icon = atomicTypeToIcon(fieldInfo.type.kind);
@@ -34412,7 +34589,7 @@ function SortableOperation({
34412
34589
  id,
34413
34590
  ref: setNodeRef,
34414
34591
  style,
34415
- children: [granular ? /* @__PURE__ */ jsxRuntime.jsxs("div", {
34592
+ children: [field && granular ? /* @__PURE__ */ jsxRuntime.jsxs("div", {
34416
34593
  ...{
34417
34594
  0: {
34418
34595
  className: "mly78zum5 mly6s0dn4 mly1nhvcw1 mly1jnr06f mly11ogjb6 mly1g9of4s"
@@ -34435,8 +34612,8 @@ function SortableOperation({
34435
34612
  color,
34436
34613
  value: granular.value,
34437
34614
  onChange: (granulation) => {
34438
- if (operation.field.expression instanceof QB.ASTTimeTruncationExpression) operation.field.expression.truncation = granulation;
34439
- setQuery == null ? void 0 : setQuery(rootQuery.build());
34615
+ if (field.expression instanceof malloyQueryBuilder.ASTTimeTruncationExpression) field.expression.truncation = granulation;
34616
+ updateQuery();
34440
34617
  },
34441
34618
  items: granular.options
34442
34619
  })]
@@ -34446,7 +34623,7 @@ function SortableOperation({
34446
34623
  },
34447
34624
  children: hoverActions
34448
34625
  })]
34449
- }) : /* @__PURE__ */ jsxRuntime.jsx(FieldToken, {
34626
+ }) : operation instanceof malloyQueryBuilder.ASTCalculateViewOperation ? /* @__PURE__ */ jsxRuntime.jsx(FieldToken, {
34450
34627
  field: fieldInfo,
34451
34628
  color,
34452
34629
  hoverActionsVisible,
@@ -34463,9 +34640,67 @@ function SortableOperation({
34463
34640
  dragProps: {
34464
34641
  attributes,
34465
34642
  listeners
34466
- }
34643
+ },
34644
+ additionalSiblings: /* @__PURE__ */ jsxRuntime.jsx(SelectorToken, {
34645
+ color,
34646
+ value: "" + (operation.expression.node.rows_preceding ?? 7),
34647
+ onChange: (value) => {
34648
+ if (value === "1") {
34649
+ view.getOrAddDefaultSegment().operations.add(new malloyQueryBuilder.ASTAggregateViewOperation({
34650
+ kind: "aggregate",
34651
+ field: {
34652
+ expression: {
34653
+ kind: "field_reference",
34654
+ name: operation.expression.node.field_reference.name
34655
+ }
34656
+ }
34657
+ }));
34658
+ operation.delete();
34659
+ updateQuery();
34660
+ } else {
34661
+ operation.expression.edit();
34662
+ operation.expression.rowsPreceding = parseInt(value, 10);
34663
+ updateQuery();
34664
+ }
34665
+ },
34666
+ items: [{
34667
+ label: "7d",
34668
+ value: "7"
34669
+ }, {
34670
+ label: "14d",
34671
+ value: "14"
34672
+ }, {
34673
+ label: "28d",
34674
+ value: "28"
34675
+ }, {
34676
+ label: "30d",
34677
+ value: "30"
34678
+ }, {
34679
+ label: "Remove smoothing",
34680
+ value: "1"
34681
+ }]
34682
+ })
34683
+ }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
34684
+ children: /* @__PURE__ */ jsxRuntime.jsx(FieldToken, {
34685
+ field: fieldInfo,
34686
+ color,
34687
+ hoverActionsVisible,
34688
+ hoverActions,
34689
+ tooltip: /* @__PURE__ */ jsxRuntime.jsx(FieldHoverCard, {
34690
+ field: fieldInfo,
34691
+ path
34692
+ }),
34693
+ tooltipProps: {
34694
+ side: "right",
34695
+ align: "start",
34696
+ alignOffset: 28
34697
+ },
34698
+ dragProps: {
34699
+ attributes,
34700
+ listeners
34701
+ }
34702
+ })
34467
34703
  }), /* @__PURE__ */ jsxRuntime.jsx(RenameDialog, {
34468
- rootQuery,
34469
34704
  view,
34470
34705
  target: renameTarget,
34471
34706
  open: renameOpen,
@@ -34476,7 +34711,7 @@ function SortableOperation({
34476
34711
  const DateGranulation = ["day", "week", "month", "quarter", "year"];
34477
34712
  const TimestampGranulation = ["second", "minute", "hour", "day", "week", "month", "quarter", "year"];
34478
34713
  function granularityMenuItems(fieldInfo, field) {
34479
- if (fieldInfo.kind !== "dimension" || !(field.expression instanceof QB.ASTTimeTruncationExpression)) {
34714
+ if (!field || fieldInfo.kind !== "dimension" || !(field.expression instanceof malloyQueryBuilder.ASTTimeTruncationExpression)) {
34480
34715
  return null;
34481
34716
  }
34482
34717
  if (fieldInfo.type.kind === "timestamp_type") {
@@ -34506,13 +34741,11 @@ const customStyles = {
34506
34741
  }
34507
34742
  };
34508
34743
  function GroupByOperations({
34509
- rootQuery,
34510
34744
  segment,
34511
34745
  view,
34512
34746
  groupBys
34513
34747
  }) {
34514
34748
  return /* @__PURE__ */ jsxRuntime.jsx(SortableOperations, {
34515
- rootQuery,
34516
34749
  segment,
34517
34750
  view,
34518
34751
  operations: groupBys,
@@ -34755,34 +34988,30 @@ function displayTimeFromMoment(momentObj) {
34755
34988
  return momentObj.moment;
34756
34989
  }
34757
34990
  function FilterOperations({
34758
- rootQuery,
34759
34991
  filters
34760
34992
  }) {
34761
- const {
34762
- setQuery
34763
- } = React.useContext(QueryEditorContext);
34993
+ const updateQuery = useUpdateQuery();
34764
34994
  if (filters.length === 0) {
34765
34995
  return null;
34766
34996
  }
34767
34997
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
34768
34998
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
34769
- ..._stylex.props(styles$u.title),
34999
+ ..._stylex.props(styles$v.title),
34770
35000
  children: "filter by"
34771
35001
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
34772
- ..._stylex.props(styles$u.tokenContainer),
35002
+ ..._stylex.props(styles$v.tokenContainer),
34773
35003
  children: filters.map((filterOperation, key2) => {
34774
35004
  return /* @__PURE__ */ jsxRuntime.jsx(ErrorElement, {
34775
35005
  fallback: /* @__PURE__ */ jsxRuntime.jsxs("div", {
34776
35006
  children: ["Invalid filter", /* @__PURE__ */ jsxRuntime.jsx(ClearButton, {
34777
35007
  onClick: () => {
34778
35008
  filterOperation.delete();
34779
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35009
+ updateQuery();
34780
35010
  }
34781
35011
  })]
34782
35012
  }),
34783
35013
  children: /* @__PURE__ */ jsxRuntime.jsx(SingleFilterOperation, {
34784
- filterOperation,
34785
- rootQuery
35014
+ filterOperation
34786
35015
  })
34787
35016
  }, key2);
34788
35017
  })
@@ -34790,29 +35019,26 @@ function FilterOperations({
34790
35019
  });
34791
35020
  }
34792
35021
  function SingleFilterOperation({
34793
- rootQuery,
34794
35022
  filterOperation
34795
35023
  }) {
34796
- const {
34797
- setQuery
34798
- } = React.useContext(QueryEditorContext);
35024
+ const updateQuery = useUpdateQuery();
34799
35025
  const setFilter = React.useCallback((filter2) => {
34800
- if (filterOperation.filter instanceof QB.ASTFilterWithFilterString) {
35026
+ if (filterOperation.filter instanceof malloyQueryBuilder.ASTFilterWithFilterString) {
34801
35027
  filterOperation.filter.setFilter(filter2);
34802
35028
  }
34803
- setQuery == null ? void 0 : setQuery(rootQuery.build());
34804
- }, [filterOperation.filter, rootQuery, setQuery]);
35029
+ updateQuery();
35030
+ }, [filterOperation.filter, updateQuery]);
34805
35031
  const {
34806
35032
  filter
34807
35033
  } = filterOperation;
34808
- if (!(filter instanceof QB.ASTFilterWithFilterString)) {
35034
+ if (!(filter instanceof malloyQueryBuilder.ASTFilterWithFilterString)) {
34809
35035
  return null;
34810
35036
  }
34811
35037
  const {
34812
35038
  expression,
34813
35039
  filterString
34814
35040
  } = filter;
34815
- if (!(expression instanceof QB.ASTReferenceExpression)) {
35041
+ if (!(expression instanceof malloyQueryBuilder.ASTReferenceExpression)) {
34816
35042
  return null;
34817
35043
  }
34818
35044
  const fieldInfo = filter.getFieldInfo();
@@ -34845,25 +35071,22 @@ function SingleFilterOperation({
34845
35071
  children: /* @__PURE__ */ jsxRuntime.jsx(ClearButton, {
34846
35072
  onClick: () => {
34847
35073
  filterOperation.delete();
34848
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35074
+ updateQuery();
34849
35075
  }
34850
35076
  })
34851
35077
  })]
34852
35078
  });
34853
35079
  }
34854
35080
  function LimitOperation({
34855
- rootQuery,
34856
35081
  limit
34857
35082
  }) {
34858
- const {
34859
- setQuery
34860
- } = React.useContext(QueryEditorContext);
35083
+ const updateQuery = useUpdateQuery();
34861
35084
  if (!limit) {
34862
35085
  return null;
34863
35086
  }
34864
35087
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
34865
35088
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
34866
- ..._stylex.props(styles$u.title),
35089
+ ..._stylex.props(styles$v.title),
34867
35090
  children: "limit"
34868
35091
  }), /* @__PURE__ */ jsxRuntime.jsxs("div", {
34869
35092
  ..._stylex.props(hoverStyles.main),
@@ -34872,7 +35095,7 @@ function LimitOperation({
34872
35095
  value: limit.limit,
34873
35096
  onChange: (value) => {
34874
35097
  limit.limit = value;
34875
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35098
+ updateQuery();
34876
35099
  },
34877
35100
  errorMessage: limit.limit < 0 ? "Limit must be positive" : void 0
34878
35101
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
@@ -34880,7 +35103,7 @@ function LimitOperation({
34880
35103
  children: /* @__PURE__ */ jsxRuntime.jsx(ClearButton, {
34881
35104
  onClick: () => {
34882
35105
  limit.delete();
34883
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35106
+ updateQuery();
34884
35107
  }
34885
35108
  })
34886
35109
  })]
@@ -34888,13 +35111,11 @@ function LimitOperation({
34888
35111
  });
34889
35112
  }
34890
35113
  function AggregateOperations({
34891
- rootQuery,
34892
35114
  segment,
34893
35115
  view,
34894
35116
  aggregates
34895
35117
  }) {
34896
35118
  return /* @__PURE__ */ jsxRuntime.jsx(SortableOperations, {
34897
- rootQuery,
34898
35119
  segment,
34899
35120
  view,
34900
35121
  operations: aggregates,
@@ -34902,21 +35123,18 @@ function AggregateOperations({
34902
35123
  });
34903
35124
  }
34904
35125
  function OrderByOperations({
34905
- rootQuery,
34906
35126
  orderBys
34907
35127
  }) {
34908
- const {
34909
- setQuery
34910
- } = React.useContext(QueryEditorContext);
35128
+ const updateQuery = useUpdateQuery();
34911
35129
  if (orderBys.length === 0) {
34912
35130
  return null;
34913
35131
  }
34914
35132
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
34915
35133
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
34916
- ..._stylex.props(styles$u.title),
35134
+ ..._stylex.props(styles$v.title),
34917
35135
  children: "order by"
34918
35136
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
34919
- ..._stylex.props(styles$u.tokenContainer),
35137
+ ..._stylex.props(styles$v.tokenContainer),
34920
35138
  children: orderBys.map((orderBy) => {
34921
35139
  const {
34922
35140
  fieldReference
@@ -34947,7 +35165,7 @@ function OrderByOperations({
34947
35165
  value: orderBy.direction ?? "asc",
34948
35166
  onChange: (direction) => {
34949
35167
  orderBy.direction = direction;
34950
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35168
+ updateQuery();
34951
35169
  }
34952
35170
  })]
34953
35171
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
@@ -34955,7 +35173,7 @@ function OrderByOperations({
34955
35173
  children: /* @__PURE__ */ jsxRuntime.jsx(ClearButton, {
34956
35174
  onClick: () => {
34957
35175
  orderBy.delete();
34958
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35176
+ updateQuery();
34959
35177
  }
34960
35178
  })
34961
35179
  })]
@@ -34965,7 +35183,6 @@ function OrderByOperations({
34965
35183
  });
34966
35184
  }
34967
35185
  function View({
34968
- rootQuery,
34969
35186
  view
34970
35187
  }) {
34971
35188
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
@@ -34975,10 +35192,8 @@ function View({
34975
35192
  gap: 8
34976
35193
  },
34977
35194
  children: [/* @__PURE__ */ jsxRuntime.jsx(Visualization$1, {
34978
- rootQuery,
34979
35195
  view
34980
35196
  }), /* @__PURE__ */ jsxRuntime.jsx(ViewDefinition, {
34981
- rootQuery,
34982
35197
  view,
34983
35198
  viewDef: view.definition
34984
35199
  })]
@@ -35002,7 +35217,7 @@ function AddItem({
35002
35217
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", {
35003
35218
  role: "menuitem",
35004
35219
  tabIndex: -1,
35005
- ..._stylex.props(addMenuStyles.item, addMenuStyles.clickable, open ? styles$f.open : null),
35220
+ ..._stylex.props(addMenuStyles.item, addMenuStyles.clickable, open ? styles$g.open : null),
35006
35221
  onClick: doOnClick,
35007
35222
  "data-disabled": disabled ? "true" : void 0,
35008
35223
  children: [/* @__PURE__ */ jsxRuntime.jsxs("div", {
@@ -35026,7 +35241,7 @@ function AddItem({
35026
35241
  }) : null]
35027
35242
  });
35028
35243
  }
35029
- const styles$f = {
35244
+ const styles$g = {
35030
35245
  open: {
35031
35246
  background: "mly16o7sp0",
35032
35247
  backgroundAttachment: null,
@@ -35043,12 +35258,9 @@ const styles$f = {
35043
35258
  }
35044
35259
  };
35045
35260
  function AddLimit({
35046
- rootQuery,
35047
35261
  view
35048
35262
  }) {
35049
- const {
35050
- setQuery
35051
- } = React.useContext(QueryEditorContext);
35263
+ const updateQuery = useUpdateQuery();
35052
35264
  const segment = getSegmentIfPresent(view);
35053
35265
  const hasLimit = segment ? segmentHasLimit(segment) : false;
35054
35266
  return /* @__PURE__ */ jsxRuntime.jsx(AddItem, {
@@ -35060,17 +35272,14 @@ function AddLimit({
35060
35272
  onClick: () => {
35061
35273
  const segment2 = view.getOrAddDefaultSegment();
35062
35274
  segment2.setLimit(10);
35063
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35275
+ updateQuery();
35064
35276
  }
35065
35277
  });
35066
35278
  }
35067
35279
  function AddEmptyNest({
35068
- rootQuery,
35069
35280
  view
35070
35281
  }) {
35071
- const {
35072
- setQuery
35073
- } = React.useContext(QueryEditorContext);
35282
+ const updateQuery = useUpdateQuery();
35074
35283
  return /* @__PURE__ */ jsxRuntime.jsx(AddItem, {
35075
35284
  icon: /* @__PURE__ */ jsxRuntime.jsx(Icon, {
35076
35285
  name: "nest"
@@ -35080,7 +35289,7 @@ function AddEmptyNest({
35080
35289
  const segment = view.getOrAddDefaultSegment();
35081
35290
  const nestNo = segmentNestNo(segment, `Nest`);
35082
35291
  segment.addEmptyNest(nestNo > 1 ? `Nest ${nestNo}` : `Nest`);
35083
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35292
+ updateQuery();
35084
35293
  }
35085
35294
  });
35086
35295
  }
@@ -35101,10 +35310,10 @@ function AddFieldItem({
35101
35310
  onAddOperation,
35102
35311
  isFilterOperation,
35103
35312
  search,
35104
- customStyle: styles$e.list
35313
+ customStyle: styles$f.list
35105
35314
  });
35106
35315
  }
35107
- const styles$e = {
35316
+ const styles$f = {
35108
35317
  list: {
35109
35318
  minWidth: "mly2ixbly",
35110
35319
  maxWidth: "mly1j9u4d2",
@@ -35112,13 +35321,10 @@ const styles$e = {
35112
35321
  }
35113
35322
  };
35114
35323
  function AddOrderBy({
35115
- rootQuery,
35116
35324
  view,
35117
35325
  search
35118
35326
  }) {
35119
- const {
35120
- setQuery
35121
- } = React.useContext(QueryEditorContext);
35327
+ const updateQuery = useUpdateQuery();
35122
35328
  const outputSchemaFields = view.getOutputSchema().fields;
35123
35329
  const segment = getSegmentIfPresent(view);
35124
35330
  const fields = React.useMemo(() => outputSchemaFields.filter((field) => field.kind === "dimension").filter((field) => ORDERABLE_TYPES$1.includes(field.type.kind)).filter((field) => segment ? !segmentHasOrderBy(segment, field.name) : true), [outputSchemaFields, segment]);
@@ -35130,7 +35336,7 @@ function AddOrderBy({
35130
35336
  types: ["dimension"],
35131
35337
  onAddOperation: (field) => {
35132
35338
  addOrderBy(view, field);
35133
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35339
+ updateQuery();
35134
35340
  },
35135
35341
  disabledMessage: "There must be at least one field in the output to order by.",
35136
35342
  search
@@ -35138,13 +35344,10 @@ function AddOrderBy({
35138
35344
  }
35139
35345
  const ORDERABLE_TYPES$1 = ["string_type", "number_type", "boolean_type", "date_type", "timestamp_type"];
35140
35346
  function AddGroupBy({
35141
- rootQuery,
35142
35347
  view,
35143
35348
  search
35144
35349
  }) {
35145
- const {
35146
- setQuery
35147
- } = React.useContext(QueryEditorContext);
35350
+ const updateQuery = useUpdateQuery();
35148
35351
  const {
35149
35352
  fields
35150
35353
  } = getInputSchemaFromViewParent(view);
@@ -35161,19 +35364,16 @@ function AddGroupBy({
35161
35364
  filter,
35162
35365
  onAddOperation: (field, path) => {
35163
35366
  addGroupBy(view, field, path);
35164
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35367
+ updateQuery();
35165
35368
  },
35166
35369
  search
35167
35370
  });
35168
35371
  }
35169
35372
  function AddAggregate({
35170
- rootQuery,
35171
35373
  view,
35172
35374
  search
35173
35375
  }) {
35174
- const {
35175
- setQuery
35176
- } = React.useContext(QueryEditorContext);
35376
+ const updateQuery = useUpdateQuery();
35177
35377
  const {
35178
35378
  fields
35179
35379
  } = getInputSchemaFromViewParent(view);
@@ -35190,7 +35390,7 @@ function AddAggregate({
35190
35390
  filter,
35191
35391
  onAddOperation: (field, path) => {
35192
35392
  addAggregate(view, field, path);
35193
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35393
+ updateQuery();
35194
35394
  },
35195
35395
  search
35196
35396
  });
@@ -35199,10 +35399,7 @@ function AddWhere({
35199
35399
  view,
35200
35400
  search
35201
35401
  }) {
35202
- const {
35203
- rootQuery,
35204
- setQuery
35205
- } = React__namespace.useContext(QueryEditorContext);
35402
+ const updateQuery = useUpdateQuery();
35206
35403
  const {
35207
35404
  fields
35208
35405
  } = getInputSchemaFromViewParent(view);
@@ -35216,7 +35413,7 @@ function AddWhere({
35216
35413
  onAddOperation: (field, path, filter) => {
35217
35414
  if (filter && (field.kind === "dimension" || field.kind === "measure")) {
35218
35415
  addFilter(view, field, path, filter);
35219
- setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
35416
+ updateQuery();
35220
35417
  }
35221
35418
  },
35222
35419
  isFilterOperation: true,
@@ -35225,15 +35422,18 @@ function AddWhere({
35225
35422
  }
35226
35423
  const FILTERABLE_TYPES$1 = /* @__PURE__ */ new Set(["string_type", "boolean_type", "number_type", "date_type", "timestamp_type"]);
35227
35424
  function AddView({
35228
- rootQuery,
35229
35425
  view,
35230
35426
  search
35231
35427
  }) {
35232
35428
  const {
35233
- setQuery
35429
+ rootQuery
35234
35430
  } = React.useContext(QueryEditorContext);
35431
+ const updateQuery = useUpdateQuery();
35235
35432
  const allFields = getInputSchemaFromViewParent(view).fields;
35236
35433
  const fields = React.useMemo(() => allFields.filter((field) => field.kind === "view" && !isIndexView(field)), [allFields]);
35434
+ if (!rootQuery) {
35435
+ return null;
35436
+ }
35237
35437
  return /* @__PURE__ */ jsxRuntime.jsx(AddFieldItem, {
35238
35438
  label: "Add view",
35239
35439
  icon: "view",
@@ -35247,20 +35447,17 @@ function AddView({
35247
35447
  } else {
35248
35448
  addNest(view, field);
35249
35449
  }
35250
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35450
+ updateQuery();
35251
35451
  },
35252
35452
  search
35253
35453
  });
35254
35454
  }
35255
35455
  function AddMenu({
35256
- rootQuery,
35257
35456
  view
35258
35457
  }) {
35259
35458
  const [open, setOpen] = React.useState(false);
35260
35459
  const [active, setActive] = React.useState("");
35261
- const {
35262
- setQuery
35263
- } = React.useContext(QueryEditorContext);
35460
+ const updateQuery = useUpdateQuery();
35264
35461
  const [search, setSearch] = React.useState("");
35265
35462
  const segment = getSegmentIfPresent(view);
35266
35463
  const toggleActive = (toggle) => {
@@ -35301,7 +35498,7 @@ function AddMenu({
35301
35498
  value: search,
35302
35499
  onChange: setSearch,
35303
35500
  placeholder: "Search...",
35304
- customStyle: styles$d.search
35501
+ customStyle: styles$e.search
35305
35502
  })
35306
35503
  }), /* @__PURE__ */ jsxRuntime.jsx(Divider, {}), /* @__PURE__ */ jsxRuntime.jsxs("div", {
35307
35504
  ...{
@@ -35324,7 +35521,7 @@ function AddMenu({
35324
35521
  } else {
35325
35522
  addNest(view, field);
35326
35523
  }
35327
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35524
+ updateQuery();
35328
35525
  },
35329
35526
  search
35330
35527
  }), /* @__PURE__ */ jsxRuntime.jsx(Divider, {}), /* @__PURE__ */ jsxRuntime.jsx(ValueList, {
@@ -35340,7 +35537,7 @@ function AddMenu({
35340
35537
  values: [value.fieldValue ?? "∅"]
35341
35538
  }
35342
35539
  });
35343
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35540
+ updateQuery();
35344
35541
  }
35345
35542
  })]
35346
35543
  }) : /* @__PURE__ */ jsxRuntime.jsxs("div", {
@@ -35377,7 +35574,6 @@ function AddMenu({
35377
35574
  onClick: () => toggleActive("view"),
35378
35575
  open: active === "view"
35379
35576
  }), /* @__PURE__ */ jsxRuntime.jsx(Divider, {}), /* @__PURE__ */ jsxRuntime.jsx(AddLimit, {
35380
- rootQuery,
35381
35577
  view
35382
35578
  }), /* @__PURE__ */ jsxRuntime.jsx(AddItem, {
35383
35579
  icon: /* @__PURE__ */ jsxRuntime.jsx(Icon, {
@@ -35387,7 +35583,6 @@ function AddMenu({
35387
35583
  onClick: () => toggleActive("order_by"),
35388
35584
  open: active === "order_by"
35389
35585
  }), /* @__PURE__ */ jsxRuntime.jsx(AddEmptyNest, {
35390
- rootQuery,
35391
35586
  view
35392
35587
  })]
35393
35588
  }), /* @__PURE__ */ jsxRuntime.jsxs("div", {
@@ -35396,23 +35591,18 @@ function AddMenu({
35396
35591
  overflowY: "auto"
35397
35592
  },
35398
35593
  children: [active === "group_by" && /* @__PURE__ */ jsxRuntime.jsx(AddGroupBy, {
35399
- rootQuery,
35400
35594
  view,
35401
35595
  search
35402
35596
  }), active === "aggregate" && /* @__PURE__ */ jsxRuntime.jsx(AddAggregate, {
35403
- rootQuery,
35404
35597
  view,
35405
35598
  search
35406
35599
  }), active === "where" && /* @__PURE__ */ jsxRuntime.jsx(AddWhere, {
35407
- rootQuery,
35408
35600
  view,
35409
35601
  search
35410
35602
  }), active === "view" && /* @__PURE__ */ jsxRuntime.jsx(AddView, {
35411
- rootQuery,
35412
35603
  view,
35413
35604
  search
35414
35605
  }), active === "order_by" && /* @__PURE__ */ jsxRuntime.jsx(AddOrderBy, {
35415
- rootQuery,
35416
35606
  view,
35417
35607
  search
35418
35608
  })]
@@ -35422,7 +35612,7 @@ function AddMenu({
35422
35612
  })]
35423
35613
  });
35424
35614
  }
35425
- const styles$d = {
35615
+ const styles$e = {
35426
35616
  search: {
35427
35617
  width: "mlyh8yej3",
35428
35618
  $$css: true
@@ -35458,7 +35648,6 @@ function FocusableView({
35458
35648
  });
35459
35649
  }
35460
35650
  function NestOperations({
35461
- rootQuery,
35462
35651
  view,
35463
35652
  nests
35464
35653
  }) {
@@ -35466,22 +35655,18 @@ function NestOperations({
35466
35655
  return null;
35467
35656
  }
35468
35657
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
35469
- ..._stylex.props(styles$u.tokenContainer),
35658
+ ..._stylex.props(styles$v.tokenContainer),
35470
35659
  children: nests.map((nest) => /* @__PURE__ */ jsxRuntime.jsx(NestOperation, {
35471
- rootQuery,
35472
35660
  view,
35473
35661
  nest
35474
35662
  }, nest.name))
35475
35663
  });
35476
35664
  }
35477
35665
  function NestOperation({
35478
- rootQuery,
35479
35666
  view,
35480
35667
  nest
35481
35668
  }) {
35482
- const {
35483
- setQuery
35484
- } = React.useContext(QueryEditorContext);
35669
+ const updateQuery = useUpdateQuery();
35485
35670
  const [renameOpen, setRenameOpen] = React.useState(false);
35486
35671
  const parentNestViewPath = React.useContext(NestViewPathContext);
35487
35672
  const {
@@ -35502,7 +35687,7 @@ function NestOperation({
35502
35687
  onClick: () => {
35503
35688
  focusNestView([...parentNestViewPath]);
35504
35689
  nest2.delete();
35505
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35690
+ updateQuery();
35506
35691
  }
35507
35692
  }), /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, {
35508
35693
  label: "Rename",
@@ -35511,7 +35696,6 @@ function NestOperation({
35511
35696
  }
35512
35697
  })]
35513
35698
  }), /* @__PURE__ */ jsxRuntime.jsx(AddMenu, {
35514
- rootQuery,
35515
35699
  view: nest2.view
35516
35700
  })]
35517
35701
  });
@@ -35523,17 +35707,15 @@ function NestOperation({
35523
35707
  },
35524
35708
  children: [/* @__PURE__ */ jsxRuntime.jsx(CollapsiblePanel, {
35525
35709
  title: nest.name,
35526
- icon: viewToVisualizationIcon(nest.view),
35710
+ icon: tagToVisualization(nest.view.getTag()),
35527
35711
  defaultOpen: true,
35528
35712
  controls: getControls(nest),
35529
35713
  collapsedControls: getControls(nest),
35530
35714
  isFocused: isNestViewFocused([...parentNestViewPath, nest.name]),
35531
35715
  children: /* @__PURE__ */ jsxRuntime.jsx(View, {
35532
- rootQuery,
35533
35716
  view: nest.view
35534
35717
  })
35535
35718
  }), /* @__PURE__ */ jsxRuntime.jsx(RenameDialog, {
35536
- rootQuery,
35537
35719
  view,
35538
35720
  target: nest,
35539
35721
  open: renameOpen,
@@ -35543,7 +35725,6 @@ function NestOperation({
35543
35725
  });
35544
35726
  }
35545
35727
  function Operations({
35546
- rootQuery,
35547
35728
  view,
35548
35729
  viewDef
35549
35730
  }) {
@@ -35554,24 +35735,24 @@ function Operations({
35554
35735
  const orderBys = [];
35555
35736
  const nests = [];
35556
35737
  let limit;
35557
- if (!(viewDef instanceof QB.ASTSegmentViewDefinition)) {
35738
+ if (!(viewDef instanceof malloyQueryBuilder.ASTSegmentViewDefinition)) {
35558
35739
  return null;
35559
35740
  }
35560
35741
  const segment = viewDef;
35561
35742
  segment.operations.items.forEach((operation) => {
35562
- if (operation instanceof QB.ASTGroupByViewOperation) {
35743
+ if (operation instanceof malloyQueryBuilder.ASTGroupByViewOperation) {
35563
35744
  groupBys.push(operation);
35564
- } else if (operation instanceof QB.ASTAggregateViewOperation) {
35745
+ } else if (operation instanceof malloyQueryBuilder.ASTAggregateViewOperation || operation instanceof malloyQueryBuilder.ASTCalculateViewOperation) {
35565
35746
  aggregates.push(operation);
35566
- } else if (operation instanceof QB.ASTWhereViewOperation) {
35747
+ } else if (operation instanceof malloyQueryBuilder.ASTWhereViewOperation) {
35567
35748
  filters.push(operation);
35568
- } else if (operation instanceof QB.ASTHavingViewOperation) {
35749
+ } else if (operation instanceof malloyQueryBuilder.ASTHavingViewOperation) {
35569
35750
  filters.push(operation);
35570
- } else if (operation instanceof QB.ASTOrderByViewOperation) {
35751
+ } else if (operation instanceof malloyQueryBuilder.ASTOrderByViewOperation) {
35571
35752
  orderBys.push(operation);
35572
- } else if (operation instanceof QB.ASTNestViewOperation) {
35753
+ } else if (operation instanceof malloyQueryBuilder.ASTNestViewOperation) {
35573
35754
  nests.push(operation);
35574
- } else if (operation instanceof QB.ASTDrillViewOperation) {
35755
+ } else if (operation instanceof malloyQueryBuilder.ASTDrillViewOperation) {
35575
35756
  drills.push(operation);
35576
35757
  } else {
35577
35758
  limit = operation;
@@ -35582,66 +35763,53 @@ function Operations({
35582
35763
  className: "mly1tpqehw mly10lvyaf"
35583
35764
  },
35584
35765
  children: [/* @__PURE__ */ jsxRuntime.jsx(GroupByOperations, {
35585
- rootQuery,
35586
35766
  segment,
35587
35767
  view,
35588
35768
  groupBys
35589
35769
  }), /* @__PURE__ */ jsxRuntime.jsx(AggregateOperations, {
35590
- rootQuery,
35591
35770
  segment,
35592
35771
  view,
35593
35772
  aggregates
35594
35773
  }), /* @__PURE__ */ jsxRuntime.jsx(DrillOperations, {
35595
- rootQuery,
35596
35774
  drills
35597
35775
  }), /* @__PURE__ */ jsxRuntime.jsx(FilterOperations, {
35598
- rootQuery,
35599
35776
  filters
35600
35777
  }), /* @__PURE__ */ jsxRuntime.jsx(OrderByOperations, {
35601
- rootQuery,
35602
35778
  orderBys
35603
35779
  }), /* @__PURE__ */ jsxRuntime.jsx(NestOperations, {
35604
- rootQuery,
35605
35780
  view,
35606
35781
  nests
35607
35782
  }), /* @__PURE__ */ jsxRuntime.jsx(LimitOperation, {
35608
- rootQuery,
35609
35783
  limit
35610
35784
  })]
35611
35785
  });
35612
35786
  }
35613
35787
  function ViewDefinition({
35614
- rootQuery,
35615
35788
  view,
35616
35789
  viewDef
35617
35790
  }) {
35618
- if (viewDef instanceof QB.ASTArrowViewDefinition) {
35791
+ if (viewDef instanceof malloyQueryBuilder.ASTArrowViewDefinition) {
35619
35792
  return /* @__PURE__ */ jsxRuntime.jsx(ViewDefinition, {
35620
- rootQuery,
35621
35793
  view,
35622
35794
  viewDef: viewDef.view
35623
35795
  });
35624
- } else if (viewDef instanceof QB.ASTRefinementViewDefinition) {
35796
+ } else if (viewDef instanceof malloyQueryBuilder.ASTRefinementViewDefinition) {
35625
35797
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
35626
35798
  children: [/* @__PURE__ */ jsxRuntime.jsx(ViewDefinition, {
35627
- rootQuery,
35628
35799
  view,
35629
35800
  viewDef: viewDef.base
35630
35801
  }), /* @__PURE__ */ jsxRuntime.jsx(ViewDefinition, {
35631
- rootQuery,
35632
35802
  view,
35633
35803
  viewDef: viewDef.refinement
35634
35804
  })]
35635
35805
  });
35636
- } else if (viewDef instanceof QB.ASTSegmentViewDefinition) {
35806
+ } else if (viewDef instanceof malloyQueryBuilder.ASTSegmentViewDefinition) {
35637
35807
  return /* @__PURE__ */ jsxRuntime.jsx(Operations, {
35638
- rootQuery,
35639
35808
  view,
35640
35809
  viewDef
35641
35810
  });
35642
35811
  } else {
35643
35812
  return /* @__PURE__ */ jsxRuntime.jsx(CollapsingView, {
35644
- rootQuery,
35645
35813
  viewDef
35646
35814
  });
35647
35815
  }
@@ -35678,11 +35846,11 @@ function CollapsingView({
35678
35846
  })]
35679
35847
  }), !collapsed && /* @__PURE__ */ jsxRuntime.jsx(ViewAttributeTable, {
35680
35848
  viewInfo: viewDef.getViewInfo(),
35681
- style: styles$c.preview
35849
+ style: styles$d.preview
35682
35850
  })]
35683
35851
  });
35684
35852
  }
35685
- const styles$c = {
35853
+ const styles$d = {
35686
35854
  preview: {
35687
35855
  height: "mlyt7dq6l",
35688
35856
  maxHeight: "mly1hkcv85",
@@ -35710,14 +35878,21 @@ const styles$c = {
35710
35878
  }
35711
35879
  };
35712
35880
  function Query({
35713
- rootQuery,
35714
- query,
35715
- setQuery
35881
+ definition
35716
35882
  }) {
35717
35883
  const {
35718
35884
  focusMainView,
35719
35885
  isMainViewFocused
35720
35886
  } = useQueryFocus();
35887
+ const {
35888
+ rootQuery,
35889
+ setQuery
35890
+ } = React.useContext(QueryEditorContext);
35891
+ const updateQuery = useUpdateQuery();
35892
+ if (!rootQuery) {
35893
+ return null;
35894
+ }
35895
+ const isEmpty = rootQuery.isEmpty();
35721
35896
  return /* @__PURE__ */ jsxRuntime.jsx(FocusableView, {
35722
35897
  children: /* @__PURE__ */ jsxRuntime.jsxs(CollapsiblePanel, {
35723
35898
  title: "Main query",
@@ -35736,44 +35911,41 @@ function Query({
35736
35911
  label: "Clear query",
35737
35912
  onClick: () => {
35738
35913
  focusMainView();
35739
- setQuery == null ? void 0 : setQuery(void 0);
35914
+ setQuery(void 0);
35740
35915
  },
35741
- disabled: rootQuery.isEmpty()
35916
+ disabled: isEmpty
35742
35917
  }), /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, {
35743
35918
  icon: "nest",
35744
35919
  label: "Nest query",
35745
35920
  onClick: () => {
35746
- if (rootQuery.definition instanceof QB.ASTArrowQueryDefinition) {
35747
- rootQuery.definition.view.convertToNest("Nest");
35921
+ if (definition instanceof malloyQueryBuilder.ASTArrowQueryDefinition) {
35922
+ definition.view.convertToNest("Nest");
35748
35923
  }
35749
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35924
+ updateQuery();
35750
35925
  },
35751
- disabled: rootQuery.isEmpty() || !(rootQuery.definition instanceof QB.ASTArrowQueryDefinition)
35926
+ disabled: isEmpty || !(definition instanceof malloyQueryBuilder.ASTArrowQueryDefinition)
35752
35927
  })]
35753
35928
  }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {})
35754
- }), query.definition instanceof QB.ASTArrowQueryDefinition ? /* @__PURE__ */ jsxRuntime.jsx(AddMenu, {
35755
- rootQuery,
35756
- view: query.definition
35929
+ }), definition instanceof malloyQueryBuilder.ASTArrowQueryDefinition ? /* @__PURE__ */ jsxRuntime.jsx(AddMenu, {
35930
+ view: definition
35757
35931
  }) : null]
35758
35932
  }),
35759
35933
  collapsedControls: /* @__PURE__ */ jsxRuntime.jsx(Icon, {
35760
- name: viewToVisualizationIcon(query)
35934
+ name: tagToVisualization(rootQuery.getTag())
35761
35935
  }),
35762
- children: [query.definition instanceof QB.ASTArrowQueryDefinition ? /* @__PURE__ */ jsxRuntime.jsxs("div", {
35936
+ children: [definition instanceof malloyQueryBuilder.ASTArrowQueryDefinition ? /* @__PURE__ */ jsxRuntime.jsxs("div", {
35763
35937
  style: {
35764
35938
  display: "flex",
35765
35939
  flexDirection: "column",
35766
35940
  gap: 8
35767
35941
  },
35768
- children: [!query.isEmpty() && /* @__PURE__ */ jsxRuntime.jsx(Visualization$1, {
35769
- rootQuery,
35770
- view: query
35942
+ children: [!isEmpty && /* @__PURE__ */ jsxRuntime.jsx(Visualization$1, {
35943
+ view: rootQuery
35771
35944
  }), /* @__PURE__ */ jsxRuntime.jsx(ViewDefinition, {
35772
- rootQuery,
35773
- view: query.definition,
35774
- viewDef: query.definition.view
35945
+ view: definition,
35946
+ viewDef: definition.view
35775
35947
  })]
35776
- }) : null, query.isEmpty() ? /* @__PURE__ */ jsxRuntime.jsx("div", {
35948
+ }) : null, isEmpty ? /* @__PURE__ */ jsxRuntime.jsx("div", {
35777
35949
  ...{
35778
35950
  className: "mly78zum5 mlyl56j7k mly6s0dn4 mlyng8ra"
35779
35951
  },
@@ -35795,27 +35967,27 @@ function Query({
35795
35967
  });
35796
35968
  }
35797
35969
  function Source({
35798
- rootQuery
35970
+ definition
35799
35971
  }) {
35800
- if (rootQuery.definition instanceof QB.ASTArrowQueryDefinition) {
35972
+ if (definition instanceof malloyQueryBuilder.ASTArrowQueryDefinition) {
35801
35973
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
35802
- ..._stylex.props(styles$u.queryCard, styles$b.content),
35974
+ ..._stylex.props(styles$v.queryCard, styles$c.content),
35803
35975
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", {
35804
- ..._stylex.props(styles$u.labelWithIcon),
35976
+ ..._stylex.props(styles$v.labelWithIcon),
35805
35977
  children: [/* @__PURE__ */ jsxRuntime.jsx(Icon, {
35806
35978
  name: "database"
35807
35979
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
35808
35980
  ...{
35809
35981
  className: "mlyb3r6kr mlylyipyv mly117nqv4"
35810
35982
  },
35811
- children: rootQuery.definition.as.ArrowQueryDefinition().source.as.ReferenceQueryArrowSource().name
35983
+ children: definition.source.getSourceInfo().name
35812
35984
  })]
35813
35985
  })
35814
35986
  });
35815
35987
  }
35816
35988
  return null;
35817
35989
  }
35818
- const styles$b = {
35990
+ const styles$c = {
35819
35991
  content: {
35820
35992
  display: "mlyrvj5dj",
35821
35993
  gridAutoFlow: "mly1mt1orb",
@@ -35866,15 +36038,15 @@ function DateLiteralEditor({
35866
36038
  children: [/* @__PURE__ */ jsxRuntime.jsx(Trigger$2, {
35867
36039
  asChild: true,
35868
36040
  children: /* @__PURE__ */ jsxRuntime.jsx("div", {
35869
- ..._stylex.props(tokenStyles.main, styles$a.wrapper, customStyle),
36041
+ ..._stylex.props(tokenStyles.main, styles$b.wrapper, customStyle),
35870
36042
  children: /* @__PURE__ */ jsxRuntime.jsx(DateInput, {
35871
36043
  value: hooks.utc(date).toDate(),
35872
36044
  setValue: onSetValue,
35873
36045
  units,
35874
36046
  onFocus: () => setOpen(true),
35875
36047
  customStyle: {
35876
- ...styles$a.input,
35877
- ...isDate2 ? styles$a.dateInput : styles$a.timestampInput
36048
+ ...styles$b.input,
36049
+ ...isDate2 ? styles$b.dateInput : styles$b.timestampInput
35878
36050
  },
35879
36051
  forwardRef: input
35880
36052
  })
@@ -35890,14 +36062,14 @@ function DateLiteralEditor({
35890
36062
  setValue: onSetValue,
35891
36063
  units,
35892
36064
  maxLevel: units,
35893
- customStyle: styles$a.datePicker,
36065
+ customStyle: styles$b.datePicker,
35894
36066
  forwardRef: picker
35895
36067
  })
35896
36068
  })
35897
36069
  })]
35898
36070
  });
35899
36071
  }
35900
- const styles$a = {
36072
+ const styles$b = {
35901
36073
  input: {
35902
36074
  border: "mly1gs6z28",
35903
36075
  borderWidth: null,
@@ -36145,13 +36317,13 @@ function LiteralValueEditor({
36145
36317
  }
36146
36318
  }
36147
36319
  function Parameters({
36148
- rootQuery
36320
+ definition
36149
36321
  }) {
36150
- const {
36151
- setQuery
36152
- } = React.useContext(QueryEditorContext);
36153
- if (rootQuery.definition instanceof QB.ASTArrowQueryDefinition) {
36154
- const source = rootQuery.definition.as.ArrowQueryDefinition().source.as.ReferenceQueryArrowSource();
36322
+ const updateQuery = useUpdateQuery();
36323
+ if (definition instanceof malloyQueryBuilder.ASTArrowQueryDefinition && definition.source instanceof malloyQueryBuilder.ASTReferenceQueryArrowSource) {
36324
+ const {
36325
+ source
36326
+ } = definition;
36155
36327
  const sourceParameters = source.getSourceParameters();
36156
36328
  if (!sourceParameters || sourceParameters.length === 0) {
36157
36329
  return null;
@@ -36165,7 +36337,7 @@ function Parameters({
36165
36337
  children: sourceParameters.map((parameter) => {
36166
36338
  var _a2;
36167
36339
  return /* @__PURE__ */ jsxRuntime.jsxs(TokenGroup, {
36168
- customStyle: styles$9.tokenGroup,
36340
+ customStyle: styles$a.tokenGroup,
36169
36341
  children: [/* @__PURE__ */ jsxRuntime.jsx(Token, {
36170
36342
  icon: atomicTypeToIcon(parameter.type.kind),
36171
36343
  label: parameter.name
@@ -36174,7 +36346,7 @@ function Parameters({
36174
36346
  value: ((_a2 = source.tryGetParameter(parameter.name)) == null ? void 0 : _a2.parameter.value) ?? parameter.default_value,
36175
36347
  setValue: (value) => {
36176
36348
  source.setParameter(parameter.name, value);
36177
- setQuery == null ? void 0 : setQuery(rootQuery.build());
36349
+ updateQuery();
36178
36350
  }
36179
36351
  })]
36180
36352
  }, parameter.name);
@@ -36184,7 +36356,7 @@ function Parameters({
36184
36356
  }
36185
36357
  return null;
36186
36358
  }
36187
- const styles$9 = {
36359
+ const styles$a = {
36188
36360
  tokenGroup: {
36189
36361
  display: "mly78zum5",
36190
36362
  $$css: true
@@ -36192,27 +36364,27 @@ const styles$9 = {
36192
36364
  };
36193
36365
  function QueryEditor() {
36194
36366
  const {
36195
- rootQuery,
36196
- setQuery
36367
+ rootQuery
36197
36368
  } = React.useContext(QueryEditorContext);
36198
36369
  if (!rootQuery) {
36199
36370
  console.error("Missing <MalloyExplorerProvider>");
36200
36371
  return null;
36201
36372
  }
36373
+ const {
36374
+ definition
36375
+ } = rootQuery;
36202
36376
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
36203
- ..._stylex.props(fontStyles.body, styles$8.main),
36377
+ ..._stylex.props(fontStyles.body, styles$9.main),
36204
36378
  children: [/* @__PURE__ */ jsxRuntime.jsx(Source, {
36205
- rootQuery
36379
+ definition
36206
36380
  }), /* @__PURE__ */ jsxRuntime.jsx(Parameters, {
36207
- rootQuery
36381
+ definition
36208
36382
  }), /* @__PURE__ */ jsxRuntime.jsx(Query, {
36209
- rootQuery,
36210
- query: rootQuery,
36211
- setQuery
36383
+ definition
36212
36384
  })]
36213
36385
  });
36214
36386
  }
36215
- const styles$8 = {
36387
+ const styles$9 = {
36216
36388
  main: {
36217
36389
  display: "mly78zum5",
36218
36390
  flexDirection: "mlydt5ytf",
@@ -36262,7 +36434,7 @@ function BookmarkedView({
36262
36434
  label: "view",
36263
36435
  icon: "view_filled",
36264
36436
  color: "purple",
36265
- customStyle: styles$7.viewBadge
36437
+ customStyle: styles$8.viewBadge
36266
36438
  }), /* @__PURE__ */ jsxRuntime.jsx(Button, {
36267
36439
  variant: "default",
36268
36440
  size: "compact",
@@ -36278,14 +36450,14 @@ function BookmarkedView({
36278
36450
  })]
36279
36451
  })]
36280
36452
  }),
36281
- customStyle: styles$7.card,
36453
+ customStyle: styles$8.card,
36282
36454
  children: /* @__PURE__ */ jsxRuntime.jsx(ViewAttributeTable, {
36283
36455
  viewInfo
36284
36456
  })
36285
36457
  })
36286
36458
  });
36287
36459
  }
36288
- const styles$7 = {
36460
+ const styles$8 = {
36289
36461
  viewBadge: {
36290
36462
  backgroundColor: "mlyjbqb8w",
36291
36463
  $$css: true
@@ -36308,7 +36480,7 @@ function EmptyQueryDisplay({
36308
36480
  className: "mly1bpp3o7 mly78zum5 mlydt5ytf mlyl56j7k mly6s0dn4"
36309
36481
  },
36310
36482
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
36311
- ..._stylex.props(styles$6.header, fontStyles.emphasized),
36483
+ ..._stylex.props(styles$7.header, fontStyles.emphasized),
36312
36484
  children: "Start with a Bookmarked View"
36313
36485
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
36314
36486
  ...{
@@ -36324,7 +36496,7 @@ function EmptyQueryDisplay({
36324
36496
  })
36325
36497
  });
36326
36498
  }
36327
- const styles$6 = {
36499
+ const styles$7 = {
36328
36500
  header: {
36329
36501
  paddingBottom: "mly1l90r2v",
36330
36502
  $$css: true
@@ -36518,7 +36690,7 @@ function RunInfoHover({
36518
36690
  children: [/* @__PURE__ */ jsxRuntime.jsx(Trigger$4, {
36519
36691
  asChild: true,
36520
36692
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", {
36521
- ..._stylex.props(styles$5.triggerContentContainer, fontStyles.body),
36693
+ ..._stylex.props(styles$6.triggerContentContainer, fontStyles.body),
36522
36694
  children: [/* @__PURE__ */ jsxRuntime.jsx(Icon, {
36523
36695
  name: "info",
36524
36696
  color: "disabled"
@@ -36529,7 +36701,7 @@ function RunInfoHover({
36529
36701
  side: HOVER_SIDE,
36530
36702
  align: HOVER_ALIGN,
36531
36703
  children: /* @__PURE__ */ jsxRuntime.jsx(HoverCard, {
36532
- customStyle: styles$5.card,
36704
+ customStyle: styles$6.card,
36533
36705
  children: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
36534
36706
  children: [runInfo.customContent, (runInfo == null ? void 0 : runInfo.performanceAspects) && Object.entries(runInfo.performanceAspects).map(([aspect, properties2]) => {
36535
36707
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
@@ -36547,7 +36719,7 @@ function RunInfoHover({
36547
36719
  href: runInfo.queryLink.href,
36548
36720
  target: "_blank",
36549
36721
  rel: "noreferrer",
36550
- ..._stylex.props(styles$5.link, fontStyles.link),
36722
+ ..._stylex.props(styles$6.link, fontStyles.link),
36551
36723
  children: runInfo.queryLink.linkText
36552
36724
  })]
36553
36725
  })
@@ -36556,7 +36728,7 @@ function RunInfoHover({
36556
36728
  })]
36557
36729
  });
36558
36730
  }
36559
- const styles$5 = {
36731
+ const styles$6 = {
36560
36732
  card: {
36561
36733
  maxWidth: "mly1dc814f",
36562
36734
  $$css: true
@@ -36747,11 +36919,11 @@ function RenderedResult({
36747
36919
  const {
36748
36920
  stableQuery
36749
36921
  } = drillData;
36750
- const rootQuery = new QB.ASTQuery({
36922
+ const rootQuery = new malloyQueryBuilder.ASTQuery({
36751
36923
  query: stableQuery,
36752
36924
  source
36753
36925
  });
36754
- setQuery == null ? void 0 : setQuery(rootQuery.build());
36926
+ setQuery(rootQuery.build());
36755
36927
  },
36756
36928
  tableConfig: {
36757
36929
  enableDrill: true
@@ -36807,7 +36979,7 @@ function LoadingDisplay({
36807
36979
  },
36808
36980
  children: [/* @__PURE__ */ jsxRuntime.jsx(Spinner, {
36809
36981
  size: "large",
36810
- customStyle: styles$4.spinner
36982
+ customStyle: styles$5.spinner
36811
36983
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
36812
36984
  ..._stylex.props(fontStyles.emphasized),
36813
36985
  children: `${EXECUTION_STATES[executionState]} query...`
@@ -36831,7 +37003,7 @@ function useTimeElapsedMillis(queryResolutionStartMillis) {
36831
37003
  }, [queryResolutionStartMillis]);
36832
37004
  return time;
36833
37005
  }
36834
- const styles$4 = {
37006
+ const styles$5 = {
36835
37007
  spinner: {
36836
37008
  marginBottom: "mly1e56ztr",
36837
37009
  $$css: true
@@ -36900,6 +37072,383 @@ function CopyToClipboard({
36900
37072
  }
36901
37073
  });
36902
37074
  }
37075
+ class DataWriter {
37076
+ constructor(stream, result) {
37077
+ this.stream = stream;
37078
+ this.result = result;
37079
+ }
37080
+ }
37081
+ class JSONWriter extends DataWriter {
37082
+ async process(data) {
37083
+ this.stream.write("[\n");
37084
+ let first = true;
37085
+ for await (const row of data) {
37086
+ if (first) {
37087
+ first = false;
37088
+ } else {
37089
+ this.stream.write(",\n");
37090
+ }
37091
+ const json2 = JSON.stringify(toObject(this.result.schema.fields.filter((field) => field.kind === "dimension"), row.record_value), null, 2);
37092
+ const jsonLines = json2.split("\n");
37093
+ for (let i2 = 0; i2 < jsonLines.length; i2++) {
37094
+ const line = jsonLines[i2];
37095
+ this.stream.write(` ${line}`);
37096
+ if (i2 < jsonLines.length - 1) {
37097
+ this.stream.write("\n");
37098
+ }
37099
+ }
37100
+ }
37101
+ this.stream.write("\n]\n");
37102
+ this.stream.close();
37103
+ }
37104
+ }
37105
+ class CSVWriter extends DataWriter {
37106
+ constructor() {
37107
+ super(...arguments);
37108
+ this.columnSeparator = ",";
37109
+ this.rowSeparator = "\n";
37110
+ this.quoteCharacter = '"';
37111
+ this.includeHeader = true;
37112
+ this.emptyCell = "";
37113
+ }
37114
+ escape(value) {
37115
+ const hasInnerQuote = value.includes(this.quoteCharacter);
37116
+ const hasInnerCommas = value.includes(this.columnSeparator);
37117
+ const hasNewline = value.includes(this.rowSeparator);
37118
+ const needsQuoting = hasInnerCommas || hasInnerQuote || hasNewline;
37119
+ if (hasInnerQuote) {
37120
+ value = value.replace(new RegExp(this.quoteCharacter, "g"), this.quoteCharacter + this.quoteCharacter);
37121
+ }
37122
+ if (needsQuoting) {
37123
+ value = this.quoteCharacter + value + this.quoteCharacter;
37124
+ }
37125
+ return value;
37126
+ }
37127
+ // Re-using the old stringify method for sanity.
37128
+ stringify(value) {
37129
+ switch (value.kind) {
37130
+ case "string_cell":
37131
+ return this.escape(value.string_value);
37132
+ case "boolean_cell":
37133
+ return JSON.stringify(value.boolean_value);
37134
+ case "number_cell":
37135
+ return JSON.stringify(value.number_value);
37136
+ case "date_cell":
37137
+ return value.date_value;
37138
+ case "timestamp_cell":
37139
+ return value.timestamp_value;
37140
+ case "json_cell":
37141
+ return this.escape(value.json_value);
37142
+ case "null_cell":
37143
+ return this.emptyCell;
37144
+ case "sql_native_cell":
37145
+ return this.escape(value.sql_native_value);
37146
+ }
37147
+ return "";
37148
+ }
37149
+ // Extra weight to be added because of nested tables inside the cells.
37150
+ getColWeight(fields) {
37151
+ let numKeys = 0;
37152
+ for (const field of fields) {
37153
+ numKeys = numKeys + 1;
37154
+ if (field.type.kind === "array_type" && field.type.element_type.kind === "record_type") {
37155
+ const weight = this.getColWeight(field.type.element_type.fields) - 1;
37156
+ numKeys = numKeys + weight;
37157
+ }
37158
+ }
37159
+ return numKeys;
37160
+ }
37161
+ // Get header row along with extra empty spaces for nested children.
37162
+ getHeaderRow(fields) {
37163
+ const csv = [];
37164
+ let width = 0;
37165
+ for (const field of fields) {
37166
+ csv.push(this.escape(field.name));
37167
+ width++;
37168
+ if (field.type.kind === "array_type" && field.type.element_type.kind === "record_type") {
37169
+ const numKeys = this.getColWeight(field.type.element_type.fields) - 1;
37170
+ width = width + numKeys;
37171
+ for (let i2 = 0; i2 < numKeys; i2++) {
37172
+ csv.push(this.emptyCell);
37173
+ }
37174
+ }
37175
+ }
37176
+ return {
37177
+ rows: [csv.join(this.columnSeparator)],
37178
+ length: 1,
37179
+ width
37180
+ };
37181
+ }
37182
+ // Merge the child matrices i.e. merge the columns into one bigger matrix i.e. CSV.
37183
+ mergeMatrices(matrices) {
37184
+ const maxLength = Math.max(...matrices.map((matrix) => matrix.length));
37185
+ const matrixWidth = matrices.reduce((sum, matrix) => sum + matrix.width, 0);
37186
+ const csvMatrix = [];
37187
+ for (let i2 = 0; i2 < maxLength; i2++) {
37188
+ const csvRow = [];
37189
+ for (const matrix of matrices) {
37190
+ if (i2 < matrix.length) {
37191
+ csvRow.push(matrix.rows[i2]);
37192
+ } else {
37193
+ const emptyCells = Array(matrix.width).fill(this.emptyCell);
37194
+ csvRow.push(...emptyCells);
37195
+ }
37196
+ }
37197
+ csvMatrix.push(csvRow.join(this.columnSeparator));
37198
+ }
37199
+ return {
37200
+ rows: csvMatrix,
37201
+ length: maxLength,
37202
+ width: matrixWidth
37203
+ };
37204
+ }
37205
+ // Gets CSV for a data cell that has nested data.
37206
+ getChildMatrix(fields, value) {
37207
+ if (value.kind !== "array_cell") {
37208
+ return {
37209
+ rows: ["Invalid data found, value is not an array"],
37210
+ length: 1,
37211
+ width: 1
37212
+ };
37213
+ } else if (value.array_value.length === 0) {
37214
+ return {
37215
+ rows: [""],
37216
+ length: 1,
37217
+ width: 1
37218
+ };
37219
+ }
37220
+ const csvMatrix = [];
37221
+ const header = this.getHeaderRow(fields);
37222
+ csvMatrix.push(...header.rows);
37223
+ const width = header.width;
37224
+ let rowCount = 1;
37225
+ for (const row of value.array_value) {
37226
+ if (row.kind === "record_cell") {
37227
+ const rowMatrix = this.getRowMatrix(fields, row.record_value);
37228
+ rowCount = rowCount + rowMatrix.length;
37229
+ csvMatrix.push(...rowMatrix.rows);
37230
+ }
37231
+ }
37232
+ return {
37233
+ rows: csvMatrix,
37234
+ length: rowCount,
37235
+ width
37236
+ };
37237
+ }
37238
+ // Creates CSV content for one row of data.
37239
+ getRowMatrix(fields, row) {
37240
+ const matrices = [];
37241
+ for (let idx = 0; idx < fields.length; idx++) {
37242
+ const field = fields[idx];
37243
+ const val = row[idx];
37244
+ if (field.type.kind === "array_type" && field.type.element_type.kind === "record_type") {
37245
+ const cell = this.getChildMatrix(field.type.element_type.fields, val);
37246
+ matrices.push(cell);
37247
+ } else {
37248
+ const cell = {
37249
+ rows: [this.stringify(val)],
37250
+ length: 1,
37251
+ width: 1
37252
+ };
37253
+ matrices.push(cell);
37254
+ }
37255
+ }
37256
+ return this.mergeMatrices(matrices);
37257
+ }
37258
+ async process(data) {
37259
+ let headerDefined = false;
37260
+ for await (const row of data) {
37261
+ const fields = this.result.schema.fields.filter((field) => field.kind === "dimension");
37262
+ if (!headerDefined && this.includeHeader) {
37263
+ const header = this.getHeaderRow(fields);
37264
+ this.stream.write(header.rows[0]);
37265
+ this.stream.write(this.rowSeparator);
37266
+ headerDefined = true;
37267
+ }
37268
+ const rowCsv = this.getRowMatrix(fields, row.record_value);
37269
+ for (const line of rowCsv.rows) {
37270
+ this.stream.write(line);
37271
+ this.stream.write(this.rowSeparator);
37272
+ }
37273
+ }
37274
+ this.stream.close();
37275
+ }
37276
+ }
37277
+ function toObject(fields, data) {
37278
+ const result = {};
37279
+ for (let idx = 0; idx < fields.length; idx++) {
37280
+ const field = fields[idx];
37281
+ const value = data[idx];
37282
+ switch (value.kind) {
37283
+ case "string_cell":
37284
+ result[field.name] = value.string_value;
37285
+ break;
37286
+ case "boolean_cell":
37287
+ result[field.name] = value.boolean_value;
37288
+ break;
37289
+ case "date_cell":
37290
+ result[field.name] = value.date_value;
37291
+ break;
37292
+ case "timestamp_cell":
37293
+ result[field.name] = value.timestamp_value;
37294
+ break;
37295
+ case "number_cell":
37296
+ result[field.name] = value.number_value;
37297
+ break;
37298
+ case "json_cell":
37299
+ result[field.name] = value.json_value;
37300
+ break;
37301
+ case "record_cell":
37302
+ result[field.name] = toObject(fields, value.record_value);
37303
+ break;
37304
+ case "array_cell":
37305
+ if (field.type.kind === "array_type" && field.type.element_type.kind === "record_type") {
37306
+ const ary = [];
37307
+ for (const cell of value.array_value) {
37308
+ if (cell.kind === "record_cell") {
37309
+ ary.push(toObject(field.type.element_type.fields, cell.record_value));
37310
+ }
37311
+ }
37312
+ result[field.name] = ary;
37313
+ }
37314
+ break;
37315
+ case "null_cell":
37316
+ result[field.name] = null;
37317
+ break;
37318
+ case "sql_native_cell":
37319
+ result[field.name] = value.sql_native_value;
37320
+ break;
37321
+ }
37322
+ }
37323
+ return result;
37324
+ }
37325
+ async function* dataIterator(result) {
37326
+ var _a2;
37327
+ if (((_a2 = result.data) == null ? void 0 : _a2.kind) === "array_cell") {
37328
+ for (const row of result.data.array_value) {
37329
+ if (row.kind === "record_cell") {
37330
+ yield row;
37331
+ }
37332
+ }
37333
+ }
37334
+ }
37335
+ function DownloadButton({
37336
+ name = "malloy",
37337
+ result
37338
+ }) {
37339
+ const [href, setHref] = React.useState("");
37340
+ const [fileName, setFileName] = React.useState("");
37341
+ const [format2, _setFormat] = React.useState("csv");
37342
+ React.useEffect(() => {
37343
+ const createBlob = async () => {
37344
+ if (!result) {
37345
+ setHref("");
37346
+ return;
37347
+ }
37348
+ const writeStream = new MemoryWriteStream();
37349
+ let writer;
37350
+ let type;
37351
+ let fileName2;
37352
+ if (format2 === "json") {
37353
+ writer = new JSONWriter(writeStream, result);
37354
+ type = "text/json";
37355
+ fileName2 = `${name}.json`;
37356
+ } else {
37357
+ writer = new CSVWriter(writeStream, result);
37358
+ type = "text/csv";
37359
+ fileName2 = `${name}.csv`;
37360
+ }
37361
+ const rowStream = dataIterator(result);
37362
+ await writer.process(rowStream);
37363
+ writeStream.close();
37364
+ const data = writeStream.data;
37365
+ const blob = new Blob([data], {
37366
+ type
37367
+ });
37368
+ setHref(window.URL.createObjectURL(blob));
37369
+ setFileName(fileName2);
37370
+ };
37371
+ void createBlob();
37372
+ }, [name, format2, result]);
37373
+ React.useEffect(() => {
37374
+ return () => {
37375
+ if (href) {
37376
+ window.URL.revokeObjectURL(href);
37377
+ }
37378
+ };
37379
+ }, [href]);
37380
+ if (href) {
37381
+ return /* @__PURE__ */ jsxRuntime.jsxs("a", {
37382
+ href,
37383
+ download: fileName,
37384
+ ...props(styles$4.link, fontStyles.body),
37385
+ children: [/* @__PURE__ */ jsxRuntime.jsx(Icon, {
37386
+ name: "download"
37387
+ }), /* @__PURE__ */ jsxRuntime.jsx("div", {
37388
+ children: "Download CSV"
37389
+ })]
37390
+ });
37391
+ } else {
37392
+ return null;
37393
+ }
37394
+ }
37395
+ class MemoryWriteStream {
37396
+ constructor() {
37397
+ this._data = [];
37398
+ }
37399
+ write(data) {
37400
+ this._data.push(data);
37401
+ }
37402
+ close() {
37403
+ }
37404
+ get data() {
37405
+ return this._data.join("");
37406
+ }
37407
+ }
37408
+ const styles$4 = {
37409
+ link: {
37410
+ display: "mly78zum5",
37411
+ alignContent: "mlyc26acl",
37412
+ gap: "mly167g77z",
37413
+ rowGap: null,
37414
+ columnGap: null,
37415
+ textDecoration: "mly1hl2dhg",
37416
+ textDecorationColor: null,
37417
+ textDecorationLine: null,
37418
+ textDecorationStyle: null,
37419
+ textDecorationThickness: null,
37420
+ background: "mly1md70p1 mly14hn1a8 mlywghvya",
37421
+ backgroundAttachment: null,
37422
+ backgroundClip: null,
37423
+ backgroundColor: null,
37424
+ backgroundImage: null,
37425
+ backgroundOrigin: null,
37426
+ backgroundPosition: null,
37427
+ backgroundPositionX: null,
37428
+ backgroundPositionY: null,
37429
+ backgroundRepeat: null,
37430
+ backgroundSize: null,
37431
+ borderRadius: "mlyur7f20",
37432
+ borderStartStartRadius: null,
37433
+ borderStartEndRadius: null,
37434
+ borderEndStartRadius: null,
37435
+ borderEndEndRadius: null,
37436
+ borderTopLeftRadius: null,
37437
+ borderTopRightRadius: null,
37438
+ borderBottomLeftRadius: null,
37439
+ borderBottomRightRadius: null,
37440
+ padding: "mlyfawy5m",
37441
+ paddingInline: null,
37442
+ paddingStart: null,
37443
+ paddingLeft: null,
37444
+ paddingEnd: null,
37445
+ paddingRight: null,
37446
+ paddingBlock: null,
37447
+ paddingTop: null,
37448
+ paddingBottom: null,
37449
+ $$css: true
37450
+ }
37451
+ };
36903
37452
  var Tab = /* @__PURE__ */ function(Tab2) {
36904
37453
  Tab2["RESULTS"] = "Results";
36905
37454
  Tab2["MALLOY"] = "Malloy";
@@ -36914,7 +37463,7 @@ function ResultPanel({
36914
37463
  submittedQuery,
36915
37464
  options
36916
37465
  }) {
36917
- var _a2, _b2, _c2;
37466
+ var _a2, _b2, _c2, _d;
36918
37467
  const [tab, setTab] = React.useState(Tab.MALLOY);
36919
37468
  const malloyText = (_a2 = useQueryBuilder(source, draftQuery)) == null ? void 0 : _a2.toMalloy();
36920
37469
  const views = source.schema.fields.filter((f2) => f2.kind === "view");
@@ -36972,6 +37521,8 @@ function ResultPanel({
36972
37521
  }), tab !== Tab.RESULTS && clipboardText && /* @__PURE__ */ jsxRuntime.jsx(CopyToClipboard, {
36973
37522
  text: clipboardText,
36974
37523
  label: "Copy Code"
37524
+ }), tab === Tab.RESULTS && /* @__PURE__ */ jsxRuntime.jsx(DownloadButton, {
37525
+ result: (_b2 = submittedQuery == null ? void 0 : submittedQuery.response) == null ? void 0 : _b2.result
36975
37526
  })]
36976
37527
  }), /* @__PURE__ */ jsxRuntime.jsxs("div", {
36977
37528
  ...{
@@ -37021,7 +37572,7 @@ function ResultPanel({
37021
37572
  ...{
37022
37573
  className: "mlywp4ipm mlyh8yej3 mly5yr21d mly9f619"
37023
37574
  },
37024
- children: ((_c2 = (_b2 = submittedQuery == null ? void 0 : submittedQuery.response) == null ? void 0 : _b2.result) == null ? void 0 : _c2.sql) && /* @__PURE__ */ jsxRuntime.jsx(CodeBlock, {
37575
+ children: ((_d = (_c2 = submittedQuery == null ? void 0 : submittedQuery.response) == null ? void 0 : _c2.result) == null ? void 0 : _d.sql) && /* @__PURE__ */ jsxRuntime.jsx(CodeBlock, {
37025
37576
  code: submittedQuery.response.result.sql,
37026
37577
  language: "sql"
37027
37578
  })
@@ -37277,7 +37828,7 @@ function useOperations(view, field, path) {
37277
37828
  const groupByDisabledReason = React.useMemo(() => {
37278
37829
  const segment = getSegmentIfPresent(view);
37279
37830
  if ((matchingFieldItem == null ? void 0 : matchingFieldItem.field.kind) !== "dimension") {
37280
- return "Grouping is only available on a dimenion.";
37831
+ return "Grouping is only available on a dimension.";
37281
37832
  }
37282
37833
  if (segment == null ? void 0 : segment.hasField(field.name, path)) {
37283
37834
  return "Cannot group by a field already in the view.";
@@ -37332,145 +37883,44 @@ function useOperations(view, field, path) {
37332
37883
  return "";
37333
37884
  }, [matchingFieldItem, view, path, field.name, fullName]);
37334
37885
  return {
37335
- isGroupByAllowed: !groupByDisabledReason,
37336
37886
  groupByDisabledReason,
37337
- isAggregateAllowed: !aggregateDisabledReason,
37338
37887
  aggregateDisabledReason,
37339
- isFilterAllowed: !filterDisabledReason,
37340
37888
  filterDisabledReason,
37341
- isOrderByAllowed: !orderByDisabledReason,
37342
37889
  orderByDisabledReason
37343
37890
  };
37344
37891
  }
37345
37892
  const FILTERABLE_TYPES = ["string_type", "boolean_type", "number_type", "date_type", "timestamp_type"];
37346
37893
  const ORDERABLE_TYPES = ["string_type", "number_type", "boolean_type", "date_type", "timestamp_type"];
37347
37894
  function FieldTokenWithActions({
37895
+ rootQuery,
37348
37896
  field,
37349
37897
  path,
37350
37898
  viewDef
37351
37899
  }) {
37352
- const {
37353
- rootQuery,
37354
- setQuery
37355
- } = React.useContext(QueryEditorContext);
37356
37900
  const {
37357
37901
  focusedNestView
37358
37902
  } = useQueryFocus();
37903
+ const updateQuery = useUpdateQuery();
37359
37904
  const view = focusedNestView ?? viewDef;
37360
- const {
37361
- groupByDisabledReason,
37362
- aggregateDisabledReason,
37363
- filterDisabledReason,
37364
- orderByDisabledReason
37365
- } = useOperations(view, field, path);
37366
- const [isFilterPopoverOpen, setIsFilterPopoverOpen] = React.useState();
37905
+ const [isFilterPopoverOpen, setIsFilterPopoverOpen] = React.useState(false);
37367
37906
  const [isTooltipOpen, setIsTooltipOpen] = React.useState(false);
37368
- const handleAddOperationAction = (operation, filter) => {
37369
- if (field.kind === "dimension" || field.kind === "measure") {
37370
- if (operation === "groupBy" && !groupByDisabledReason) {
37371
- addGroupBy(view, field, path);
37372
- } else if (operation === "aggregate" && !aggregateDisabledReason) {
37373
- addAggregate(view, field, path);
37374
- } else if (operation === "orderBy" && !orderByDisabledReason) {
37375
- addOrderByFromSource(view, path, field.name);
37376
- } else if (operation === "filter" && !filterDisabledReason && filter) {
37377
- addFilter(view, field, path, filter);
37378
- }
37379
- setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
37380
- }
37381
- };
37382
- const handleSetView = () => {
37383
- if (field.kind === "view" && (rootQuery == null ? void 0 : rootQuery.isEmpty())) {
37384
- rootQuery == null ? void 0 : rootQuery.setView(field.name);
37385
- setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
37386
- }
37387
- };
37388
- const handleAddView = () => {
37389
- if (field.kind === "view") {
37390
- addNest(view, field);
37391
- setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
37392
- }
37393
- };
37907
+ const showHover = isFilterPopoverOpen || isTooltipOpen;
37394
37908
  return /* @__PURE__ */ jsxRuntime.jsx(FieldToken, {
37395
37909
  field,
37396
- hoverActions: field.kind === "view" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
37397
- children: [/* @__PURE__ */ jsxRuntime.jsx(ActionButton, {
37398
- icon: "insert",
37399
- disabled: !(rootQuery == null ? void 0 : rootQuery.isEmpty()),
37400
- onClick: handleSetView,
37401
- tooltip: !(rootQuery == null ? void 0 : rootQuery.isEmpty()) ? "Can only add a view to an empty query." : "Add view",
37402
- onTooltipOpenChange: setIsTooltipOpen
37403
- }), /* @__PURE__ */ jsxRuntime.jsx(ActionButton, {
37404
- icon: "nest",
37405
- onClick: handleAddView,
37406
- tooltip: "Add as new nested query",
37407
- onTooltipOpenChange: setIsTooltipOpen
37408
- })]
37409
- }) : field.kind === "measure" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
37410
- children: [/* @__PURE__ */ jsxRuntime.jsx(ActionButton, {
37411
- icon: "aggregate",
37412
- tooltip: aggregateDisabledReason || "Add as aggregate",
37413
- disabled: !!aggregateDisabledReason,
37414
- onClick: () => handleAddOperationAction("aggregate"),
37415
- onTooltipOpenChange: setIsTooltipOpen
37416
- }), /* @__PURE__ */ jsxRuntime.jsx(FilterPopover, {
37417
- fieldInfo: field,
37418
- path,
37419
- setFilter: (filter) => handleAddOperationAction("filter", filter),
37420
- trigger: /* @__PURE__ */ jsxRuntime.jsx(ActionButton, {
37421
- icon: "filter",
37422
- tooltip: filterDisabledReason || "Add as filter",
37423
- disabled: !!filterDisabledReason,
37424
- onTooltipOpenChange: setIsTooltipOpen
37425
- }),
37426
- onOpenChange: setIsFilterPopoverOpen,
37427
- layoutProps: {
37428
- align: "start"
37429
- }
37430
- }), /* @__PURE__ */ jsxRuntime.jsx(ActionButton, {
37431
- icon: "orderBy",
37432
- tooltip: orderByDisabledReason || "Add as order by",
37433
- disabled: !!orderByDisabledReason,
37434
- onClick: () => handleAddOperationAction("orderBy"),
37435
- onTooltipOpenChange: setIsTooltipOpen
37436
- })]
37437
- }) : field.kind === "dimension" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
37438
- children: [/* @__PURE__ */ jsxRuntime.jsx(ActionButton, {
37439
- icon: "groupBy",
37440
- tooltip: groupByDisabledReason || "Add as group by",
37441
- disabled: !!groupByDisabledReason,
37442
- onClick: () => handleAddOperationAction("groupBy"),
37443
- onTooltipOpenChange: setIsTooltipOpen
37444
- }), /* @__PURE__ */ jsxRuntime.jsx(FilterPopover, {
37445
- fieldInfo: field,
37446
- path,
37447
- setFilter: (filter) => handleAddOperationAction("filter", filter),
37448
- trigger: /* @__PURE__ */ jsxRuntime.jsx(ActionButton, {
37449
- icon: "filter",
37450
- tooltip: filterDisabledReason || "Add as filter",
37451
- disabled: !!filterDisabledReason,
37452
- onTooltipOpenChange: setIsTooltipOpen
37453
- }),
37454
- onOpenChange: setIsFilterPopoverOpen,
37455
- layoutProps: {
37456
- align: "start"
37457
- }
37458
- }), /* @__PURE__ */ jsxRuntime.jsx(ActionButton, {
37459
- icon: "orderBy",
37460
- tooltip: orderByDisabledReason || "Add as order by",
37461
- disabled: !!orderByDisabledReason,
37462
- onClick: () => handleAddOperationAction("orderBy"),
37463
- onTooltipOpenChange: setIsTooltipOpen
37464
- })]
37465
- }) : null,
37466
- onClick: field.kind === "dimension" && !groupByDisabledReason ? () => handleAddOperationAction("groupBy") : field.kind === "measure" && !aggregateDisabledReason ? () => handleAddOperationAction("aggregate") : field.kind === "view" ? () => {
37467
- if (rootQuery == null ? void 0 : rootQuery.isEmpty()) {
37468
- handleSetView();
37469
- } else {
37470
- handleAddView();
37910
+ hoverActions: /* @__PURE__ */ jsxRuntime.jsx(QueryEditorActions, {
37911
+ rootQuery,
37912
+ field,
37913
+ view,
37914
+ path,
37915
+ setIsFilterPopoverOpen,
37916
+ setIsTooltipOpen
37917
+ }),
37918
+ onClick: () => {
37919
+ if (queryEditorClick(rootQuery, view, field, path)) {
37920
+ updateQuery();
37471
37921
  }
37472
- } : void 0,
37473
- hoverActionsVisible: isFilterPopoverOpen || isTooltipOpen,
37922
+ },
37923
+ hoverActionsVisible: showHover,
37474
37924
  tooltip: /* @__PURE__ */ jsxRuntime.jsx(FieldHoverCard, {
37475
37925
  field,
37476
37926
  path
@@ -37506,8 +37956,146 @@ function ActionButton({
37506
37956
  })]
37507
37957
  });
37508
37958
  }
37959
+ function QueryEditorActions({
37960
+ rootQuery,
37961
+ view,
37962
+ field,
37963
+ path,
37964
+ setIsTooltipOpen,
37965
+ setIsFilterPopoverOpen
37966
+ }) {
37967
+ const updateQuery = useUpdateQuery();
37968
+ const {
37969
+ groupByDisabledReason,
37970
+ aggregateDisabledReason,
37971
+ filterDisabledReason,
37972
+ orderByDisabledReason
37973
+ } = useOperations(view, field, path);
37974
+ const handleAddOperationAction = (operation, filter) => {
37975
+ if (field.kind === "dimension" || field.kind === "measure") {
37976
+ if (operation === "groupBy" && !groupByDisabledReason) {
37977
+ addGroupBy(view, field, path);
37978
+ } else if (operation === "aggregate" && !aggregateDisabledReason) {
37979
+ addAggregate(view, field, path);
37980
+ } else if (operation === "orderBy" && !orderByDisabledReason) {
37981
+ addOrderByFromSource(view, path, field.name);
37982
+ } else if (operation === "filter" && !filterDisabledReason && filter) {
37983
+ addFilter(view, field, path, filter);
37984
+ }
37985
+ updateQuery();
37986
+ }
37987
+ };
37988
+ const handleSetView = () => {
37989
+ if (field.kind === "view" && rootQuery.isEmpty()) {
37990
+ rootQuery.setView(field.name);
37991
+ updateQuery();
37992
+ }
37993
+ };
37994
+ const handleAddView = () => {
37995
+ if (field.kind === "view") {
37996
+ addNest(view, field);
37997
+ updateQuery();
37998
+ }
37999
+ };
38000
+ return field.kind === "view" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
38001
+ children: [/* @__PURE__ */ jsxRuntime.jsx(ActionButton, {
38002
+ icon: "insert",
38003
+ disabled: !rootQuery.isEmpty(),
38004
+ onClick: handleSetView,
38005
+ tooltip: !rootQuery.isEmpty() ? "Can only add a view to an empty query." : "Add view",
38006
+ onTooltipOpenChange: setIsTooltipOpen
38007
+ }), /* @__PURE__ */ jsxRuntime.jsx(ActionButton, {
38008
+ icon: "nest",
38009
+ onClick: handleAddView,
38010
+ tooltip: "Add as new nested query",
38011
+ onTooltipOpenChange: setIsTooltipOpen
38012
+ })]
38013
+ }) : field.kind === "measure" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
38014
+ children: [/* @__PURE__ */ jsxRuntime.jsx(ActionButton, {
38015
+ icon: "aggregate",
38016
+ tooltip: aggregateDisabledReason || "Add as aggregate",
38017
+ disabled: !!aggregateDisabledReason,
38018
+ onClick: () => handleAddOperationAction("aggregate"),
38019
+ onTooltipOpenChange: setIsTooltipOpen
38020
+ }), /* @__PURE__ */ jsxRuntime.jsx(FilterPopover, {
38021
+ fieldInfo: field,
38022
+ path,
38023
+ setFilter: (filter) => handleAddOperationAction("filter", filter),
38024
+ trigger: /* @__PURE__ */ jsxRuntime.jsx(ActionButton, {
38025
+ icon: "filter",
38026
+ tooltip: filterDisabledReason || "Add as filter",
38027
+ disabled: !!filterDisabledReason,
38028
+ onTooltipOpenChange: setIsTooltipOpen
38029
+ }),
38030
+ onOpenChange: setIsFilterPopoverOpen,
38031
+ layoutProps: {
38032
+ align: "start"
38033
+ }
38034
+ }), /* @__PURE__ */ jsxRuntime.jsx(ActionButton, {
38035
+ icon: "orderBy",
38036
+ tooltip: orderByDisabledReason || "Add as order by",
38037
+ disabled: !!orderByDisabledReason,
38038
+ onClick: () => handleAddOperationAction("orderBy"),
38039
+ onTooltipOpenChange: setIsTooltipOpen
38040
+ })]
38041
+ }) : field.kind === "dimension" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
38042
+ children: [/* @__PURE__ */ jsxRuntime.jsx(ActionButton, {
38043
+ icon: "groupBy",
38044
+ tooltip: groupByDisabledReason || "Add as group by",
38045
+ disabled: !!groupByDisabledReason,
38046
+ onClick: () => handleAddOperationAction("groupBy"),
38047
+ onTooltipOpenChange: setIsTooltipOpen
38048
+ }), /* @__PURE__ */ jsxRuntime.jsx(FilterPopover, {
38049
+ fieldInfo: field,
38050
+ path,
38051
+ setFilter: (filter) => handleAddOperationAction("filter", filter),
38052
+ trigger: /* @__PURE__ */ jsxRuntime.jsx(ActionButton, {
38053
+ icon: "filter",
38054
+ tooltip: filterDisabledReason || "Add as filter",
38055
+ disabled: !!filterDisabledReason,
38056
+ onTooltipOpenChange: setIsTooltipOpen
38057
+ }),
38058
+ onOpenChange: setIsFilterPopoverOpen,
38059
+ layoutProps: {
38060
+ align: "start"
38061
+ }
38062
+ }), /* @__PURE__ */ jsxRuntime.jsx(ActionButton, {
38063
+ icon: "orderBy",
38064
+ tooltip: orderByDisabledReason || "Add as order by",
38065
+ disabled: !!orderByDisabledReason,
38066
+ onClick: () => handleAddOperationAction("orderBy"),
38067
+ onTooltipOpenChange: setIsTooltipOpen
38068
+ })]
38069
+ }) : null;
38070
+ }
38071
+ function queryEditorClick(rootQuery, view, field, path) {
38072
+ const segment = getSegmentIfPresent(view);
38073
+ if (field.kind === "dimension") {
38074
+ if (!(segment == null ? void 0 : segment.hasField(field.name, path))) {
38075
+ addGroupBy(view, field, path);
38076
+ } else {
38077
+ return false;
38078
+ }
38079
+ } else if (field.kind === "measure") {
38080
+ if (!(segment == null ? void 0 : segment.hasField(field.name, path))) {
38081
+ addAggregate(view, field, path);
38082
+ } else {
38083
+ return false;
38084
+ }
38085
+ } else if (field.kind === "view") {
38086
+ if (rootQuery.isEmpty()) {
38087
+ rootQuery.setView(field.name);
38088
+ } else {
38089
+ addNest(view, field);
38090
+ }
38091
+ } else {
38092
+ return false;
38093
+ }
38094
+ return true;
38095
+ }
37509
38096
  const FIELD_KIND_ORDER = ["dimension", "measure", "view"];
37510
38097
  function SearchResultList({
38098
+ rootQuery,
37511
38099
  source,
37512
38100
  items
37513
38101
  }) {
@@ -37517,11 +38105,8 @@ function SearchResultList({
37517
38105
  items: groupFieldItemsByPath(source, group.items)
37518
38106
  }));
37519
38107
  }, [source, items]);
37520
- const {
37521
- rootQuery
37522
- } = React__namespace.useContext(QueryEditorContext);
37523
- const viewDef = rootQuery == null ? void 0 : rootQuery.definition;
37524
- if (!(viewDef instanceof QB.ASTArrowQueryDefinition)) {
38108
+ const viewDef = rootQuery.definition;
38109
+ if (!(viewDef instanceof malloyQueryBuilder.ASTArrowQueryDefinition)) {
37525
38110
  return null;
37526
38111
  }
37527
38112
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
@@ -37557,6 +38142,7 @@ function SearchResultList({
37557
38142
  field,
37558
38143
  path
37559
38144
  }) => /* @__PURE__ */ jsxRuntime.jsx(FieldTokenWithActions, {
38145
+ rootQuery,
37560
38146
  field,
37561
38147
  path,
37562
38148
  viewDef
@@ -37583,6 +38169,7 @@ const getSublabelFromPath = (source, path) => {
37583
38169
  return path.length > 0 ? `joined to ${[...path.slice(0, -1), source.name].join(" > ")}` : void 0;
37584
38170
  };
37585
38171
  function FieldGroupList({
38172
+ rootQuery,
37586
38173
  source,
37587
38174
  fieldItems,
37588
38175
  fieldGroupType
@@ -37602,11 +38189,8 @@ function FieldGroupList({
37602
38189
  group
37603
38190
  }) => group === fieldGroupType)) == null ? void 0 : _a2.items) ?? [];
37604
38191
  }, [fieldGroupsByKindByPath, fieldGroupType]);
37605
- const {
37606
- rootQuery
37607
- } = React__namespace.useContext(QueryEditorContext);
37608
- const viewDef = rootQuery == null ? void 0 : rootQuery.definition;
37609
- if (!(viewDef instanceof QB.ASTArrowQueryDefinition)) {
38192
+ const viewDef = rootQuery.definition;
38193
+ if (!(viewDef instanceof malloyQueryBuilder.ASTArrowQueryDefinition)) {
37610
38194
  return null;
37611
38195
  }
37612
38196
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
@@ -37622,6 +38206,7 @@ function FieldGroupList({
37622
38206
  field,
37623
38207
  path
37624
38208
  }) => /* @__PURE__ */ jsxRuntime.jsx(FieldTokenWithActions, {
38209
+ rootQuery,
37625
38210
  field,
37626
38211
  path,
37627
38212
  viewDef
@@ -37634,7 +38219,8 @@ function SourcePanel({
37634
38219
  onRefresh
37635
38220
  }) {
37636
38221
  const {
37637
- source
38222
+ source,
38223
+ rootQuery
37638
38224
  } = React__namespace.useContext(QueryEditorContext);
37639
38225
  const [searchQuery, setSearchQuery] = React__namespace.useState("");
37640
38226
  const {
@@ -37657,7 +38243,7 @@ function SourcePanel({
37657
38243
  return [];
37658
38244
  }, [fieldItems, searchQuery]);
37659
38245
  const isSearchActive = !!searchQuery;
37660
- if (!source) {
38246
+ if (!source || !rootQuery) {
37661
38247
  return null;
37662
38248
  }
37663
38249
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
@@ -37712,6 +38298,7 @@ function SourcePanel({
37712
38298
  className: "mly78zum5 mlydt5ytf mlyysyzu8 mly1iyjqo2"
37713
38299
  },
37714
38300
  children: isSearchActive ? /* @__PURE__ */ jsxRuntime.jsx(SearchResultList, {
38301
+ rootQuery,
37715
38302
  source,
37716
38303
  items: searchResultItems
37717
38304
  }) : /* @__PURE__ */ jsxRuntime.jsxs(AccordionList, {
@@ -37728,6 +38315,7 @@ function SourcePanel({
37728
38315
  color: "cyan"
37729
38316
  }),
37730
38317
  children: /* @__PURE__ */ jsxRuntime.jsx(FieldGroupList, {
38318
+ rootQuery,
37731
38319
  source,
37732
38320
  fieldItems,
37733
38321
  fieldGroupType: "dimension"
@@ -37744,6 +38332,7 @@ function SourcePanel({
37744
38332
  color: "green"
37745
38333
  }),
37746
38334
  children: /* @__PURE__ */ jsxRuntime.jsx(FieldGroupList, {
38335
+ rootQuery,
37747
38336
  source,
37748
38337
  fieldItems,
37749
38338
  fieldGroupType: "measure"
@@ -37760,6 +38349,7 @@ function SourcePanel({
37760
38349
  color: "purple"
37761
38350
  }),
37762
38351
  children: /* @__PURE__ */ jsxRuntime.jsx(FieldGroupList, {
38352
+ rootQuery,
37763
38353
  source,
37764
38354
  fieldItems,
37765
38355
  fieldGroupType: "view"