@malloy-publisher/sdk 0.3.0 → 0.3.1

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 (156) hide show
  1. package/README.md +8 -0
  2. package/dist/DocumentStorageProvider-BeBD0uWc.cjs.js +134 -0
  3. package/dist/DocumentStorageProvider-tGvodI8f.es.js +24268 -0
  4. package/dist/RenderedResult-CPi6uQWq.cjs.js +115 -0
  5. package/dist/RenderedResult-mDE-4u8S.es.js +542 -0
  6. package/dist/ServerProvider-CH71GsoL.cjs.js +1 -0
  7. package/dist/{ServerProvider-DSK9rfSY.es.js → ServerProvider-X2Ma0HRs.es.js} +486 -521
  8. package/dist/builder/index.cjs.js +105 -0
  9. package/dist/builder/index.d.ts +2 -0
  10. package/dist/builder/index.es.js +9561 -0
  11. package/dist/builder-entry.d.ts +8 -0
  12. package/dist/client/index.cjs.js +1 -1
  13. package/dist/client/index.es.js +1 -1
  14. package/dist/components/Dashboard/Dashboard.d.ts +19 -14
  15. package/dist/components/Dashboard/DashboardGrid.d.ts +67 -0
  16. package/dist/components/Dashboard/DashboardTile.d.ts +6 -1
  17. package/dist/components/Dashboard/ExploreDialog.d.ts +18 -0
  18. package/dist/components/Dashboard/RowsDialog.d.ts +47 -0
  19. package/dist/components/Dashboard/TileCard.d.ts +44 -0
  20. package/dist/components/Dashboard/index.d.ts +2 -0
  21. package/dist/components/Dashboard/promoteMeasureRow.d.ts +7 -3
  22. package/dist/components/Dashboard/telemetry.d.ts +43 -0
  23. package/dist/components/DashboardBuilder/AddTileDialog.d.ts +35 -0
  24. package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +29 -0
  25. package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +112 -0
  26. package/dist/components/DashboardBuilder/DashboardEditor.d.ts +32 -0
  27. package/dist/components/DashboardBuilder/DiffDialog.d.ts +15 -0
  28. package/dist/components/DashboardBuilder/DrillDialog.d.ts +15 -0
  29. package/dist/components/DashboardBuilder/FilterDialog.d.ts +54 -0
  30. package/dist/components/DashboardBuilder/FilterStrip.d.ts +17 -0
  31. package/dist/components/DashboardBuilder/SettingsPopover.d.ts +20 -0
  32. package/dist/components/DashboardBuilder/TileFrame.d.ts +42 -0
  33. package/dist/components/DashboardBuilder/TileMenu.d.ts +24 -0
  34. package/dist/components/DashboardBuilder/catalog.d.ts +62 -0
  35. package/dist/components/DashboardBuilder/controls.d.ts +157 -0
  36. package/dist/components/DashboardBuilder/diff.d.ts +35 -0
  37. package/dist/components/DashboardBuilder/document.d.ts +218 -0
  38. package/dist/components/DashboardBuilder/layout.d.ts +71 -0
  39. package/dist/components/DashboardBuilder/malloyText.d.ts +45 -0
  40. package/dist/components/DashboardBuilder/preview.d.ts +60 -0
  41. package/dist/components/DashboardBuilder/readDocument.d.ts +106 -0
  42. package/dist/components/DashboardBuilder/sortable.d.ts +51 -0
  43. package/dist/components/DashboardBuilder/spliceDocument.d.ts +44 -0
  44. package/dist/components/DashboardBuilder/testing/fixtures.d.ts +10 -0
  45. package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +22 -0
  46. package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +63 -0
  47. package/dist/components/DashboardBuilder/useDraft.d.ts +13 -0
  48. package/dist/components/DashboardBuilder/useFilterForm.d.ts +65 -0
  49. package/dist/components/DashboardBuilder/useTileReorder.d.ts +22 -0
  50. package/dist/components/DashboardBuilder/useTileResize.d.ts +29 -0
  51. package/dist/components/DocumentStorage/DocumentStorageProvider.d.ts +7 -0
  52. package/dist/components/DocumentStorage/index.d.ts +1 -1
  53. package/dist/components/FloatingIconButton.d.ts +16 -0
  54. package/dist/components/Prose.d.ts +46 -0
  55. package/dist/components/RenderedResult/ResultPanel.d.ts +30 -0
  56. package/dist/components/RenderedResult/index.d.ts +1 -0
  57. package/dist/components/drill/index.d.ts +1 -1
  58. package/dist/components/drill/resolveDrill.d.ts +22 -0
  59. package/dist/components/drill/useDrill.d.ts +11 -2
  60. package/dist/components/index.d.ts +1 -0
  61. package/dist/components/styles.d.ts +0 -4
  62. package/dist/hooks/index.d.ts +2 -0
  63. package/dist/hooks/useDocumentControls.d.ts +70 -0
  64. package/dist/hooks/useQueryResult.d.ts +40 -0
  65. package/dist/index.cjs.js +23 -270
  66. package/dist/index.es.js +16977 -41293
  67. package/dist/utils/malloyLiteral.d.ts +11 -0
  68. package/package.json +24 -9
  69. package/src/builder-entry.ts +55 -0
  70. package/src/components/Dashboard/Dashboard.spec.tsx +7 -10
  71. package/src/components/Dashboard/Dashboard.tsx +165 -175
  72. package/src/components/Dashboard/DashboardGrid.tsx +124 -0
  73. package/src/components/Dashboard/DashboardTile.spec.tsx +30 -6
  74. package/src/components/Dashboard/DashboardTile.tsx +66 -123
  75. package/src/components/Dashboard/ExploreDialog.tsx +84 -0
  76. package/src/components/Dashboard/RowsDialog.spec.ts +42 -0
  77. package/src/components/Dashboard/RowsDialog.tsx +234 -0
  78. package/src/components/Dashboard/TileCard.tsx +120 -0
  79. package/src/components/Dashboard/index.ts +2 -0
  80. package/src/components/Dashboard/promoteMeasureRow.spec.ts +70 -0
  81. package/src/components/Dashboard/promoteMeasureRow.ts +33 -2
  82. package/src/components/Dashboard/telemetry.ts +44 -0
  83. package/src/components/Dashboard/tileGridColumn.spec.ts +1 -1
  84. package/src/components/DashboardBuilder/AddTileDialog.tsx +249 -0
  85. package/src/components/DashboardBuilder/BuilderToolbar.tsx +270 -0
  86. package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +858 -0
  87. package/src/components/DashboardBuilder/DashboardBuilder.tsx +653 -0
  88. package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +211 -0
  89. package/src/components/DashboardBuilder/DashboardEditor.tsx +493 -0
  90. package/src/components/DashboardBuilder/DiffDialog.tsx +129 -0
  91. package/src/components/DashboardBuilder/DrillDialog.tsx +281 -0
  92. package/src/components/DashboardBuilder/FilterDialog.tsx +581 -0
  93. package/src/components/DashboardBuilder/FilterStrip.tsx +125 -0
  94. package/src/components/DashboardBuilder/SettingsPopover.tsx +168 -0
  95. package/src/components/DashboardBuilder/TileFrame.tsx +380 -0
  96. package/src/components/DashboardBuilder/TileMenu.tsx +188 -0
  97. package/src/components/DashboardBuilder/catalog.spec.ts +215 -0
  98. package/src/components/DashboardBuilder/catalog.ts +225 -0
  99. package/src/components/DashboardBuilder/controls.spec.ts +243 -0
  100. package/src/components/DashboardBuilder/controls.ts +398 -0
  101. package/src/components/DashboardBuilder/diff.spec.ts +44 -0
  102. package/src/components/DashboardBuilder/diff.ts +93 -0
  103. package/src/components/DashboardBuilder/document.ts +209 -0
  104. package/src/components/DashboardBuilder/keepRowStructure.spec.ts +84 -0
  105. package/src/components/DashboardBuilder/layout.ts +143 -0
  106. package/src/components/DashboardBuilder/malloyText.spec.ts +84 -0
  107. package/src/components/DashboardBuilder/malloyText.ts +151 -0
  108. package/src/components/DashboardBuilder/moveIntoGap.spec.ts +90 -0
  109. package/src/components/DashboardBuilder/preview.spec.ts +149 -0
  110. package/src/components/DashboardBuilder/preview.ts +172 -0
  111. package/src/components/DashboardBuilder/readDocument.spec.ts +375 -0
  112. package/src/components/DashboardBuilder/readDocument.ts +467 -0
  113. package/src/components/DashboardBuilder/sortable.tsx +151 -0
  114. package/src/components/DashboardBuilder/spliceDocument.spec.ts +1108 -0
  115. package/src/components/DashboardBuilder/spliceDocument.ts +1098 -0
  116. package/src/components/DashboardBuilder/testing/fixtures.ts +48 -0
  117. package/src/components/DashboardBuilder/useBuilderShortcuts.ts +88 -0
  118. package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +255 -0
  119. package/src/components/DashboardBuilder/useDashboardEditor.ts +193 -0
  120. package/src/components/DashboardBuilder/useDraft.ts +43 -0
  121. package/src/components/DashboardBuilder/useFilterForm.spec.tsx +144 -0
  122. package/src/components/DashboardBuilder/useFilterForm.ts +352 -0
  123. package/src/components/DashboardBuilder/useTileReorder.spec.tsx +97 -0
  124. package/src/components/DashboardBuilder/useTileReorder.ts +115 -0
  125. package/src/components/DashboardBuilder/useTileResize.spec.tsx +121 -0
  126. package/src/components/DashboardBuilder/useTileResize.ts +110 -0
  127. package/src/components/DashboardBuilder/withGaps.spec.ts +96 -0
  128. package/src/components/DocumentStorage/DocumentStorageProvider.tsx +12 -0
  129. package/src/components/DocumentStorage/index.ts +1 -0
  130. package/src/components/Environment/About.tsx +4 -36
  131. package/src/components/FloatingIconButton.tsx +41 -0
  132. package/src/components/Model/Model.tsx +6 -23
  133. package/src/components/Model/ModelCell.tsx +33 -72
  134. package/src/components/Notebook/Notebook.tsx +25 -88
  135. package/src/components/Notebook/NotebookCell.tsx +35 -183
  136. package/src/components/Prose.spec.tsx +85 -0
  137. package/src/components/Prose.tsx +179 -0
  138. package/src/components/QueryResult/QueryResult.tsx +15 -43
  139. package/src/components/RenderedResult/ResultContainer.tsx +4 -12
  140. package/src/components/RenderedResult/ResultPanel.spec.tsx +49 -0
  141. package/src/components/RenderedResult/ResultPanel.tsx +73 -0
  142. package/src/components/RenderedResult/index.ts +1 -0
  143. package/src/components/drill/index.ts +1 -0
  144. package/src/components/drill/resolveDrill.ts +22 -1
  145. package/src/components/drill/useDrill.spec.tsx +94 -0
  146. package/src/components/drill/useDrill.tsx +52 -12
  147. package/src/components/given/GivensPanel.tsx +1 -1
  148. package/src/components/index.ts +6 -0
  149. package/src/components/styles.ts +0 -37
  150. package/src/hooks/index.ts +13 -0
  151. package/src/hooks/useDocumentControls.ts +170 -0
  152. package/src/hooks/useQueryResult.ts +82 -0
  153. package/src/utils/malloyLiteral.spec.ts +43 -0
  154. package/src/utils/malloyLiteral.ts +76 -0
  155. package/vite.config.ts +5 -0
  156. package/dist/ServerProvider-CGnLjzag.cjs.js +0 -1
@@ -0,0 +1,115 @@
1
+ "use strict";var ve=Object.create;var le=Object.defineProperty;var ge=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var ke=Object.getPrototypeOf,Re=Object.prototype.hasOwnProperty;var xe=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of we(r))!Re.call(e,o)&&o!==t&&le(e,o,{get:()=>r[o],enumerable:!(n=ge(r,o))||n.enumerable});return e};var G=(e,r,t)=>(t=e!=null?ve(ke(e)):{},xe(r||!e||!e.__esModule?le(t,"default",{value:e,enumerable:!0}):t,e));const B=require("react/jsx-runtime"),U=require("@mui/material"),p=require("react"),v=require("./DocumentStorageProvider-BeBD0uWc.cjs.js"),X=require("./ServerProvider-CH71GsoL.cjs.js"),g="publisher-drill";function de(e,r){const t=new Set;let n;try{n=e.getMetadata()?.getAllFields()??[]}catch{return t}const o=new Set;for(const a of n)!a||r(a)||a.tag?.tag("hidden")===void 0&&o.add(a.tag?.text("label")??a.name);for(const a of n){if(!a||!r(a))continue;const l=a.tag?.text("label")??a.name;o.has(l)||t.add(l)}return t}function M(e){const r=/^\s*(\d+)/.exec(e.style?.gridColumn??"");return r?r[1]:void 0}function ce(e,r){if(r.size!==0)for(const t of e.querySelectorAll(".malloy-table")){const n=l=>l.closest(".malloy-table")===t,o=new Set;for(const l of t.querySelectorAll(".column-cell.th")){if(!n(l))continue;const s=(l.textContent??"").replace(/\u200b/g,"").trim(),f=M(l);f&&r.has(s)&&o.add(f)}if(o.size===0)continue;const a=new Set;for(const l of t.querySelectorAll(`.${g}[tabindex="0"]`)){if(!n(l))continue;const s=M(l);s&&(a.has(s)?l.tabIndex=-1:a.add(s))}for(const l of t.querySelectorAll(".column-cell.td")){if(!n(l))continue;const s=M(l),f=!l.querySelector(".value-null")&&(l.textContent??"").trim()!=="";if(s&&f&&o.has(s)&&!l.querySelector(".malloy-table")){if(l.classList.add(g),l.tabIndex===0)a.add(s);else{const u=a.has(s);u||a.add(s),l.tabIndex=u?-1:0}l.setAttribute("role","button")}}}}function Ce(e){const r=e.closest(".malloy-table"),t=M(e);return!r||!t?[]:Array.from(r.querySelectorAll(`.${g}`)).filter(n=>n.closest(".malloy-table")===r&&M(n)===t)}function ie(e,r){const t=Ce(e),n=t.indexOf(e);if(n===-1)return;const o=r==="first"?t[0]:r==="last"?t[t.length-1]:t[Math.min(Math.max(n+r,0),t.length-1)];if(o){for(const a of t)a.tabIndex=a===o?0:-1;return o}}function ue(e){return{background:e.dashboardRoot,tableBackground:e.tableBackground,tableHeaderColor:e.tableHeader,tableBodyColor:e.tableBody,tableBorder:e.border,tablePinnedBackground:e.tableHeaderBackground,tablePinnedBorder:e.pinnedBorder,tableFontSize:`${e.font.size}px`,fontFamily:e.font.family,mapColor:e.mapColor}}function he(e){const{foreground:r,axisFaint:t,font:n}=e,o={background:e.background,font:n.family,title:{color:r,font:n.family},axis:{labelColor:r,titleColor:r,domainColor:t,tickColor:t,gridColor:t,labelFont:n.family,titleFont:n.family},legend:{labelColor:r,titleColor:r,labelFont:n.family,titleFont:n.family},header:{labelColor:r,titleColor:r},range:{category:e.series}};return a=>o}function me(e){if(!e)return;const r=e.tag("theme");if(!r)return;const t={},n=r.tag("palette");if(n){const a={},l=n.textArray("series");l&&l.length>0&&(a.series=l);for(const s of X.PER_MODE_COLOR_KEYS){const f=n.tag(s);if(!f)continue;const u={},k=f.text("light"),S=f.text("dark");k&&(u.light=k),S&&(u.dark=S),Object.keys(u).length>0&&(a[s]=u)}Object.keys(a).length>0&&(t.palette=a)}const o=r.tag("font");if(o){const a={},l=o.text("family");l&&(a.family=l);const s=o.numeric("size");typeof s=="number"&&Number.isFinite(s)&&(a.size=s),Object.keys(a).length>0&&(t.font=a)}return Object.keys(t).length>0?t:void 0}const Ee=async(e,r)=>{if(typeof window>"u")throw new Error("MalloyRenderer can only be used in browser environment");const{MalloyRenderer:t}=await import("@malloydata/render");return new t({onClick:r,vegaConfigOverride:he(e),theme:ue(e),onError:o=>{console.error("Error rendering visualization:",typeof o,o)}}).createViz()};typeof window<"u"&&import("@malloydata/render");async function Se(e){if(!e||typeof e!="object")return;const r=e,t=[...Array.isArray(r.model_annotations)?r.model_annotations:[],...Array.isArray(r.source_annotations)?r.source_annotations:[],...Array.isArray(r.annotations)?r.annotations:[]].map(o=>typeof o?.value=="string"?o.value:void 0).filter(o=>!!o);if(t.length===0)return;let n;try{({parseAnnotation:n}=await import("@malloydata/malloy-tag"))}catch{return}try{const{tag:o}=n(t);return me(o)}catch(o){console.warn("Failed to parse # theme.* annotations; chart will render with the shell theme.",{error:o,lines:t});return}}function Ae(e,r,t){const n=v.buildTableCssVars(r,t);for(const[o,a]of Object.entries(n))e.style.setProperty(o,a)}const De=`
2
+ /* Card geometry, through the renderer's OWN theme vars rather than over the top
3
+ of them. It declares --malloy-theme--dashboard-* on .malloy-render itself and
4
+ passes each through to the --malloy-render--* the card CSS reads, so a value
5
+ inherited from our wrapper loses to that declaration however early it is set:
6
+ this has to be a rule on the same element, at higher specificity. Doubling the
7
+ class does that, and then no !important is needed — which matters, because
8
+ !important here also lands on .dashboard-item-borderless and repaints a card
9
+ the author asked to have no card. */
10
+ .malloy-render.malloy-render {
11
+ --malloy-theme--dashboard-card-radius: var(--publisher-dashboard-card-radius);
12
+ --malloy-theme--dashboard-card-padding: var(--publisher-dashboard-card-padding);
13
+ }
14
+ /* dashboard.css hardcodes background: #f7f9fc on .malloy-dashboard
15
+ and .dashboard-row-header, which would paint light grey in dark
16
+ mode and also bleed an operator-picked palette.background across
17
+ the panel chrome in light. Both surfaces use
18
+ --malloy-render--background here, which buildMalloyExplicitTheme
19
+ wires to dashboardRoot: a mode-keyed neutral that stays decoupled
20
+ from palette.background (the chart canvas) on purpose. Selectors
21
+ are duplicated at higher specificity to beat the renderer s own
22
+ scoped rules. */
23
+ .malloy-render .malloy-dashboard,
24
+ .malloy-render.malloy-render .malloy-dashboard,
25
+ div.malloy-render .malloy-dashboard {
26
+ /* --publisher-dashboard-root is set on the outer Publisher wrapper
27
+ (see buildTableCssVars) and stays decoupled from
28
+ --malloy-render--background, which gets shadowed inside the
29
+ renderer when a theme.background annotation is present. The
30
+ dedicated var means the panel between tiles always paints the
31
+ operator neutral dashboardRoot regardless of annotations. */
32
+ background: var(--publisher-dashboard-root) !important;
33
+ background-color: var(--publisher-dashboard-root) !important;
34
+ color: var(--malloy-render--table-body-color) !important;
35
+ }
36
+ .malloy-render .malloy-dashboard .dashboard-row,
37
+ .malloy-render .malloy-dashboard .dashboard-row-body,
38
+ .malloy-render .malloy-dashboard .dashboard-row-header,
39
+ .malloy-render.malloy-render .malloy-dashboard .dashboard-row-header,
40
+ div.malloy-render .malloy-dashboard .dashboard-row-header {
41
+ /* Belt + suspenders: dashboard.css hardcodes .dashboard-row-header
42
+ to #f7f9fc, and row / row-body have no explicit background but
43
+ get caught in any annotation-driven inline writes. Force all of
44
+ them to the neutral panel colour. */
45
+ background: var(--publisher-dashboard-root) !important;
46
+ background-color: var(--publisher-dashboard-root) !important;
47
+ }
48
+ .malloy-render .malloy-dashboard .dashboard-item:not(.dashboard-item-borderless) {
49
+ /* Tile padding around each chart / table. Uses our custom
50
+ --malloy-render--tile-background so the operator can theme the
51
+ tile separately from the table header row (which paints from
52
+ --malloy-render--table-pinned-background below).
53
+
54
+ A flat bordered card rather than the renderer's shadow ring, which is what
55
+ makes it match the composite tile's Paper. :not(borderless) because
56
+ # borderless asks for no card at all, and an !important background and
57
+ border drew one anyway. */
58
+ background: var(--malloy-render--tile-background) !important;
59
+ color: var(--malloy-render--table-body-color) !important;
60
+ box-shadow: none !important;
61
+ border: var(--malloy-render--table-border) !important;
62
+ }
63
+ .malloy-render .malloy-dashboard .dashboard-row-header-separator {
64
+ background: var(--malloy-render--table-border) !important;
65
+ }
66
+ .malloy-render .malloy-table .th.column-cell {
67
+ /* Non-pinned tables have no header background in the renderer's
68
+ own CSS (only pinned scrolled tables paint the pinned-header
69
+ with this var). Force the same value here so every table has a
70
+ visible header band reflecting the operator's choice. */
71
+ background: var(--malloy-render--table-pinned-background) !important;
72
+ }
73
+ .malloy-render .dashboard-item-title,
74
+ .malloy-render .dashboard-dimension-name {
75
+ color: var(--malloy-render--label-color) !important;
76
+ }
77
+ .malloy-render .dashboard-item-value,
78
+ .malloy-render .dashboard-item-value-measure,
79
+ .malloy-render .dashboard-dimension-value {
80
+ color: var(--malloy-render--value-color) !important;
81
+ }
82
+ .malloy-render .malloy-table,
83
+ .malloy-render .malloy-list {
84
+ color: var(--malloy-render--table-body-color) !important;
85
+ }
86
+ .malloy-render .column-cell.th,
87
+ .malloy-render .cell-content.header {
88
+ color: var(--malloy-render--table-header-color) !important;
89
+ }
90
+ /* A cell whose column declares a "# drill" this surface can honor, marked
91
+ by markDrillableCells. Ordinary text with a pointer cursor until hovered,
92
+ then it reads as a link: the same affordance Malloyyo gives the same tag,
93
+ and the only thing that tells a reader a cell navigates. Kept off the
94
+ resting state deliberately: a column painted blue competes with the data.
95
+ (No backticks in here: this is inside a template literal.) */
96
+ .malloy-render .${g} {
97
+ cursor: pointer;
98
+ }
99
+ .malloy-render .${g}:hover > .cell-content {
100
+ color: var(--publisher-drill-link) !important;
101
+ text-decoration: underline;
102
+ }
103
+ /* Keyboard focus reads the same as hover, plus a ring: a hover colour is not
104
+ something a keyboard user can produce, and a focus ring is not something a
105
+ mouse user sees. focus-visible rather than focus, so a click does not leave a
106
+ ring behind it. (No backticks in here: this is inside a template literal.) */
107
+ .malloy-render .${g}:focus-visible {
108
+ outline: 2px solid var(--publisher-drill-link);
109
+ outline-offset: -2px;
110
+ }
111
+ .malloy-render .${g}:focus-visible > .cell-content {
112
+ color: var(--publisher-drill-link) !important;
113
+ text-decoration: underline;
114
+ }
115
+ `,se="publisher-malloy-renderer-overrides";function Oe(){if(typeof document>"u"||document.getElementById(se))return;const e=document.createElement("style");e.id=se,e.textContent=De,document.head.appendChild(e)}function Te({result:e,height:r,drill:t,onSizeChange:n,onSizing:o}){const a=p.useRef(null),l=p.useRef(t);l.current=t;const s=p.useCallback(h=>{l.current?.onClick(h)},[]),f=t!==void 0,u=p.useRef(!1),k=p.useRef(null),S=p.useRef(0),{theme:Y,layers:J,mode:W}=X.usePublisherTheme(),Q=U.useTheme().shape.borderRadius,Z=p.useMemo(()=>({radius:`${Q}px`,padding:`${v.DASHBOARD_CARD_PADDING_PX}px`}),[Q]);return p.useEffect(()=>()=>{S.current+=1,k.current?.viz.remove(),k.current=null},[]),p.useLayoutEffect(()=>{if(!a.current||!e)return;Oe();const h=a.current,fe=S.current+=1;let P=!1;const q=()=>!P&&fe===S.current;let d,m,N=null,V=0,I=null,j=null,$=null,L=null,_=null,z=null,ee=null,re=0,A=null;u.current=!1;let w,D;const H=R=>{if(P||!R.firstElementChild||v.resultSizing(w,D)==="container")return;const F=v.remeasuresAfterReady(w,D);if(u.current&&!F)return;const C=v.measureContentHeight(R,v.contentNodeDepth(w));C>0&&(u.current=!0,n&&C!==re&&(re=C,n(C)));const y=v.contentNode(R,v.contentNodeDepth(w));F&&y&&ee!==y&&(ee=y,z?.disconnect(),z=new ResizeObserver(()=>H(R)),z.observe(y))};return(async()=>{let R;try{R=JSON.parse(e)}catch(x){console.error("Error parsing visualization result:",x);return}const F=await Se(R),C=F?X.resolveTheme([...J,F],W):Y;if(!q())return;try{m=await Ee(C,s)}catch(x){console.error("Failed to create renderer:",x);return}if(!q()){m.remove(),m=void 0;return}const y=k.current;d=document.createElement("div"),d.style.width="100%",d.style.height="100%",Ae(d,C,Z),y&&(h.style.position="relative",d.style.position="absolute",d.style.inset="0",d.style.visibility="hidden"),h.appendChild(d);const c=d;L=new MutationObserver(()=>{_&&clearTimeout(_),_=setTimeout(()=>{H(c),u.current&&L?.disconnect()},100)}),L.observe(d,{childList:!0,subtree:!0,attributes:!0});const ye=m;let te=!1;const oe=()=>{te||!q()||(te=!0,A&&(clearTimeout(A),A=null),y&&(y.viz.remove(),y.node.parentNode===h&&h.removeChild(y.node)),c.style.position="",c.style.inset="",c.style.visibility="",h.style.position="",k.current={viz:ye,node:c},H(c))};try{m.setResult(R);try{const E=m.getMetadata(),O=E?.getRootField();w=O?.renderAs(),D=O?E?.getPluginsForField(O.key)?.[0]?.sizingStrategy:void 0}catch{w=void 0,D=void 0}o?.(v.resultSizing(w,D)),d.dataset.malloyRenderAs=w??"unknown",d.dataset.malloySizing=v.resultSizing(w,D),m.render(d);const x=l.current;try{if(x){const E=de(m,x.canDrill),O=()=>{try{ce(c,E)}catch(i){console.warn("Drill affordance skipped:",i)}};O();const ne=i=>{const T=i.querySelector(".cell-content")??i,K=T.getBoundingClientRect();T.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:T.ownerDocument.defaultView,clientX:Math.round(K.left+K.width/2),clientY:Math.round(K.bottom)}))},ae=i=>i.target?.closest?.(`.${g}`)??null,pe=(i,b)=>{ie(i,b)?.focus()};I=i=>{const b=ae(i);if(!b)return;const T=i.key==="ArrowDown"?1:i.key==="ArrowUp"?-1:i.key==="Home"?"first":i.key==="End"?"last":void 0;if(T!==void 0){i.preventDefault(),pe(b,T);return}i.key==="Enter"?(i.preventDefault(),ne(b)):i.key===" "&&i.preventDefault()},j=i=>{if(i.key!==" ")return;const b=ae(i);b&&(i.preventDefault(),ne(b))},$=i=>{const b=i.target?.closest?.(`.${g}`);b&&ie(b,0)},c.addEventListener("keydown",I),c.addEventListener("keyup",j),c.addEventListener("focusin",$),E.size>0&&typeof MutationObserver<"u"&&(N=new MutationObserver(()=>{cancelAnimationFrame(V),V=requestAnimationFrame(O)}),N.observe(c,{childList:!0,subtree:!0}))}}catch(E){console.warn("Drill affordance skipped:",E)}m.onReady(oe),A=setTimeout(oe,1e4)}catch(x){console.error("Error rendering visualization:",x),L?.disconnect(),z?.disconnect(),N?.disconnect(),m.remove(),m=void 0,c.parentNode===h&&h.removeChild(c)}})(),()=>{P=!0,L?.disconnect(),z?.disconnect(),_&&clearTimeout(_),A&&clearTimeout(A),d&&k.current?.node!==d&&(I&&d.removeEventListener("keydown",I),j&&d.removeEventListener("keyup",j),$&&d.removeEventListener("focusin",$),N?.disconnect(),cancelAnimationFrame(V),m?.remove(),d.parentNode===h&&h.removeChild(d),h.style.position="")}},[e,s,f,n,o,Y,J,W,Z]),B.jsx("div",{ref:a,style:{width:"100%",height:r?`${r}px`:"400px"}})}function be(e){return typeof window>"u"?B.jsx(U.Box,{sx:{width:"100%",height:e.height?`${e.height}px`:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:"Loading..."}):B.jsx(p.Suspense,{fallback:B.jsx(U.Box,{sx:{width:"100%",height:e.height?`${e.height}px`:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:"Loading visualization..."}),children:B.jsx(Te,{...e})})}const Le=Object.freeze(Object.defineProperty({__proto__:null,default:be},Symbol.toStringTag,{value:"Module"}));exports.DRILL_CELL_CLASS=g;exports.RenderedResult=be;exports.RenderedResult$1=Le;exports.buildMalloyExplicitTheme=ue;exports.buildVegaThemeOverride=he;exports.drillableFieldNames=de;exports.markDrillableCells=ce;exports.readChartAnnotations=me;
@@ -0,0 +1,542 @@
1
+ import { jsx as L } from "react/jsx-runtime";
2
+ import { Box as oe, useTheme as ce } from "@mui/material";
3
+ import { Suspense as ue, useRef as z, useCallback as he, useMemo as me, useEffect as fe, useLayoutEffect as be } from "react";
4
+ import { D as ye, r as K, b as pe, a as ve, m as ge, c as we, d as ae } from "./DocumentStorageProvider-tGvodI8f.es.js";
5
+ import { aD as ke, aE as Ce, aF as xe } from "./ServerProvider-X2Ma0HRs.es.js";
6
+ const v = "publisher-drill";
7
+ function Re(e, r) {
8
+ const t = /* @__PURE__ */ new Set();
9
+ let a;
10
+ try {
11
+ a = e.getMetadata()?.getAllFields() ?? [];
12
+ } catch {
13
+ return t;
14
+ }
15
+ const n = /* @__PURE__ */ new Set();
16
+ for (const o of a)
17
+ !o || r(o) || o.tag?.tag("hidden") === void 0 && n.add(o.tag?.text("label") ?? o.name);
18
+ for (const o of a) {
19
+ if (!o || !r(o)) continue;
20
+ const l = o.tag?.text("label") ?? o.name;
21
+ n.has(l) || t.add(l);
22
+ }
23
+ return t;
24
+ }
25
+ function B(e) {
26
+ const r = /^\s*(\d+)/.exec(e.style?.gridColumn ?? "");
27
+ return r ? r[1] : void 0;
28
+ }
29
+ function Ee(e, r) {
30
+ if (r.size !== 0)
31
+ for (const t of e.querySelectorAll(
32
+ ".malloy-table"
33
+ )) {
34
+ const a = (l) => l.closest(".malloy-table") === t, n = /* @__PURE__ */ new Set();
35
+ for (const l of t.querySelectorAll(
36
+ ".column-cell.th"
37
+ )) {
38
+ if (!a(l)) continue;
39
+ const s = (l.textContent ?? "").replace(/\u200b/g, "").trim(), b = B(l);
40
+ b && r.has(s) && n.add(b);
41
+ }
42
+ if (n.size === 0) continue;
43
+ const o = /* @__PURE__ */ new Set();
44
+ for (const l of t.querySelectorAll(
45
+ `.${v}[tabindex="0"]`
46
+ )) {
47
+ if (!a(l)) continue;
48
+ const s = B(l);
49
+ s && (o.has(s) ? l.tabIndex = -1 : o.add(s));
50
+ }
51
+ for (const l of t.querySelectorAll(
52
+ ".column-cell.td"
53
+ )) {
54
+ if (!a(l)) continue;
55
+ const s = B(l), b = !l.querySelector(".value-null") && (l.textContent ?? "").trim() !== "";
56
+ if (s && b && n.has(s) && !l.querySelector(".malloy-table")) {
57
+ if (l.classList.add(v), l.tabIndex === 0)
58
+ o.add(s);
59
+ else {
60
+ const u = o.has(s);
61
+ u || o.add(s), l.tabIndex = u ? -1 : 0;
62
+ }
63
+ l.setAttribute("role", "button");
64
+ }
65
+ }
66
+ }
67
+ }
68
+ function Se(e) {
69
+ const r = e.closest(".malloy-table"), t = B(e);
70
+ return !r || !t ? [] : Array.from(
71
+ r.querySelectorAll(`.${v}`)
72
+ ).filter(
73
+ (a) => a.closest(".malloy-table") === r && B(a) === t
74
+ );
75
+ }
76
+ function ne(e, r) {
77
+ const t = Se(e), a = t.indexOf(e);
78
+ if (a === -1) return;
79
+ const n = r === "first" ? t[0] : r === "last" ? t[t.length - 1] : t[Math.min(Math.max(a + r, 0), t.length - 1)];
80
+ if (n) {
81
+ for (const o of t) o.tabIndex = o === n ? 0 : -1;
82
+ return n;
83
+ }
84
+ }
85
+ function Ae(e) {
86
+ return {
87
+ background: e.dashboardRoot,
88
+ tableBackground: e.tableBackground,
89
+ tableHeaderColor: e.tableHeader,
90
+ tableBodyColor: e.tableBody,
91
+ tableBorder: e.border,
92
+ // Header row background (operator-customizable, NEW). The
93
+ // renderer reuses tablePinnedBackground for any pinned header
94
+ // cell; we additionally paint the regular header row from the
95
+ // same var via injectRendererOverrides so non-pinned tables
96
+ // also show the header band.
97
+ tablePinnedBackground: e.tableHeaderBackground,
98
+ tablePinnedBorder: e.pinnedBorder,
99
+ tableFontSize: `${e.font.size}px`,
100
+ fontFamily: e.font.family,
101
+ // Saturated end of the choropleth gradient. The renderer
102
+ // generates a low-to-high ramp from a neutral grey to this
103
+ // colour for shape-map / segment-map plugins via getColorScale.
104
+ mapColor: e.mapColor
105
+ };
106
+ }
107
+ function De(e) {
108
+ const { foreground: r, axisFaint: t, font: a } = e, n = {
109
+ background: e.background,
110
+ font: a.family,
111
+ title: { color: r, font: a.family },
112
+ axis: {
113
+ labelColor: r,
114
+ titleColor: r,
115
+ domainColor: t,
116
+ tickColor: t,
117
+ gridColor: t,
118
+ labelFont: a.family,
119
+ titleFont: a.family
120
+ },
121
+ legend: {
122
+ labelColor: r,
123
+ titleColor: r,
124
+ labelFont: a.family,
125
+ titleFont: a.family
126
+ },
127
+ header: { labelColor: r, titleColor: r },
128
+ range: { category: e.series }
129
+ };
130
+ return (o) => n;
131
+ }
132
+ function Oe(e) {
133
+ if (!e) return;
134
+ const r = e.tag("theme");
135
+ if (!r) return;
136
+ const t = {}, a = r.tag("palette");
137
+ if (a) {
138
+ const o = {}, l = a.textArray("series");
139
+ l && l.length > 0 && (o.series = l);
140
+ for (const s of ke) {
141
+ const b = a.tag(s);
142
+ if (!b) continue;
143
+ const u = {}, g = b.text("light"), R = b.text("dark");
144
+ g && (u.light = g), R && (u.dark = R), Object.keys(u).length > 0 && (o[s] = u);
145
+ }
146
+ Object.keys(o).length > 0 && (t.palette = o);
147
+ }
148
+ const n = r.tag("font");
149
+ if (n) {
150
+ const o = {}, l = n.text("family");
151
+ l && (o.family = l);
152
+ const s = n.numeric("size");
153
+ typeof s == "number" && Number.isFinite(s) && (o.size = s), Object.keys(o).length > 0 && (t.font = o);
154
+ }
155
+ return Object.keys(t).length > 0 ? t : void 0;
156
+ }
157
+ const Fe = async (e, r) => {
158
+ if (typeof window > "u")
159
+ throw new Error("MalloyRenderer can only be used in browser environment");
160
+ const { MalloyRenderer: t } = await import("@malloydata/render");
161
+ return new t({
162
+ onClick: r,
163
+ vegaConfigOverride: De(e),
164
+ // Pass the explicit theme so table chrome and dashboard tiles
165
+ // pick up the operator's colours directly. Without this the
166
+ // renderer's own inline style writes `--malloy-render--*` values
167
+ // sourced from its built-in defaults and shadows whatever we set
168
+ // on the outer wrapper.
169
+ theme: Ae(e),
170
+ onError: (n) => {
171
+ console.error("Error rendering visualization:", typeof n, n);
172
+ }
173
+ }).createViz();
174
+ };
175
+ typeof window < "u" && import("@malloydata/render");
176
+ async function Te(e) {
177
+ if (!e || typeof e != "object") return;
178
+ const r = e, t = [
179
+ ...Array.isArray(r.model_annotations) ? r.model_annotations : [],
180
+ ...Array.isArray(r.source_annotations) ? r.source_annotations : [],
181
+ ...Array.isArray(r.annotations) ? r.annotations : []
182
+ ].map((n) => typeof n?.value == "string" ? n.value : void 0).filter((n) => !!n);
183
+ if (t.length === 0) return;
184
+ let a;
185
+ try {
186
+ ({ parseAnnotation: a } = await import("@malloydata/malloy-tag"));
187
+ } catch {
188
+ return;
189
+ }
190
+ try {
191
+ const { tag: n } = a(t);
192
+ return Oe(n);
193
+ } catch (n) {
194
+ console.warn(
195
+ "Failed to parse # theme.* annotations; chart will render with the shell theme.",
196
+ { error: n, lines: t }
197
+ );
198
+ return;
199
+ }
200
+ }
201
+ function _e(e, r, t) {
202
+ const a = pe(r, t);
203
+ for (const [n, o] of Object.entries(a))
204
+ e.style.setProperty(n, o);
205
+ }
206
+ const ze = `
207
+ /* Card geometry, through the renderer's OWN theme vars rather than over the top
208
+ of them. It declares --malloy-theme--dashboard-* on .malloy-render itself and
209
+ passes each through to the --malloy-render--* the card CSS reads, so a value
210
+ inherited from our wrapper loses to that declaration however early it is set:
211
+ this has to be a rule on the same element, at higher specificity. Doubling the
212
+ class does that, and then no !important is needed — which matters, because
213
+ !important here also lands on .dashboard-item-borderless and repaints a card
214
+ the author asked to have no card. */
215
+ .malloy-render.malloy-render {
216
+ --malloy-theme--dashboard-card-radius: var(--publisher-dashboard-card-radius);
217
+ --malloy-theme--dashboard-card-padding: var(--publisher-dashboard-card-padding);
218
+ }
219
+ /* dashboard.css hardcodes background: #f7f9fc on .malloy-dashboard
220
+ and .dashboard-row-header, which would paint light grey in dark
221
+ mode and also bleed an operator-picked palette.background across
222
+ the panel chrome in light. Both surfaces use
223
+ --malloy-render--background here, which buildMalloyExplicitTheme
224
+ wires to dashboardRoot: a mode-keyed neutral that stays decoupled
225
+ from palette.background (the chart canvas) on purpose. Selectors
226
+ are duplicated at higher specificity to beat the renderer s own
227
+ scoped rules. */
228
+ .malloy-render .malloy-dashboard,
229
+ .malloy-render.malloy-render .malloy-dashboard,
230
+ div.malloy-render .malloy-dashboard {
231
+ /* --publisher-dashboard-root is set on the outer Publisher wrapper
232
+ (see buildTableCssVars) and stays decoupled from
233
+ --malloy-render--background, which gets shadowed inside the
234
+ renderer when a theme.background annotation is present. The
235
+ dedicated var means the panel between tiles always paints the
236
+ operator neutral dashboardRoot regardless of annotations. */
237
+ background: var(--publisher-dashboard-root) !important;
238
+ background-color: var(--publisher-dashboard-root) !important;
239
+ color: var(--malloy-render--table-body-color) !important;
240
+ }
241
+ .malloy-render .malloy-dashboard .dashboard-row,
242
+ .malloy-render .malloy-dashboard .dashboard-row-body,
243
+ .malloy-render .malloy-dashboard .dashboard-row-header,
244
+ .malloy-render.malloy-render .malloy-dashboard .dashboard-row-header,
245
+ div.malloy-render .malloy-dashboard .dashboard-row-header {
246
+ /* Belt + suspenders: dashboard.css hardcodes .dashboard-row-header
247
+ to #f7f9fc, and row / row-body have no explicit background but
248
+ get caught in any annotation-driven inline writes. Force all of
249
+ them to the neutral panel colour. */
250
+ background: var(--publisher-dashboard-root) !important;
251
+ background-color: var(--publisher-dashboard-root) !important;
252
+ }
253
+ .malloy-render .malloy-dashboard .dashboard-item:not(.dashboard-item-borderless) {
254
+ /* Tile padding around each chart / table. Uses our custom
255
+ --malloy-render--tile-background so the operator can theme the
256
+ tile separately from the table header row (which paints from
257
+ --malloy-render--table-pinned-background below).
258
+
259
+ A flat bordered card rather than the renderer's shadow ring, which is what
260
+ makes it match the composite tile's Paper. :not(borderless) because
261
+ # borderless asks for no card at all, and an !important background and
262
+ border drew one anyway. */
263
+ background: var(--malloy-render--tile-background) !important;
264
+ color: var(--malloy-render--table-body-color) !important;
265
+ box-shadow: none !important;
266
+ border: var(--malloy-render--table-border) !important;
267
+ }
268
+ .malloy-render .malloy-dashboard .dashboard-row-header-separator {
269
+ background: var(--malloy-render--table-border) !important;
270
+ }
271
+ .malloy-render .malloy-table .th.column-cell {
272
+ /* Non-pinned tables have no header background in the renderer's
273
+ own CSS (only pinned scrolled tables paint the pinned-header
274
+ with this var). Force the same value here so every table has a
275
+ visible header band reflecting the operator's choice. */
276
+ background: var(--malloy-render--table-pinned-background) !important;
277
+ }
278
+ .malloy-render .dashboard-item-title,
279
+ .malloy-render .dashboard-dimension-name {
280
+ color: var(--malloy-render--label-color) !important;
281
+ }
282
+ .malloy-render .dashboard-item-value,
283
+ .malloy-render .dashboard-item-value-measure,
284
+ .malloy-render .dashboard-dimension-value {
285
+ color: var(--malloy-render--value-color) !important;
286
+ }
287
+ .malloy-render .malloy-table,
288
+ .malloy-render .malloy-list {
289
+ color: var(--malloy-render--table-body-color) !important;
290
+ }
291
+ .malloy-render .column-cell.th,
292
+ .malloy-render .cell-content.header {
293
+ color: var(--malloy-render--table-header-color) !important;
294
+ }
295
+ /* A cell whose column declares a "# drill" this surface can honor, marked
296
+ by markDrillableCells. Ordinary text with a pointer cursor until hovered,
297
+ then it reads as a link: the same affordance Malloyyo gives the same tag,
298
+ and the only thing that tells a reader a cell navigates. Kept off the
299
+ resting state deliberately: a column painted blue competes with the data.
300
+ (No backticks in here: this is inside a template literal.) */
301
+ .malloy-render .${v} {
302
+ cursor: pointer;
303
+ }
304
+ .malloy-render .${v}:hover > .cell-content {
305
+ color: var(--publisher-drill-link) !important;
306
+ text-decoration: underline;
307
+ }
308
+ /* Keyboard focus reads the same as hover, plus a ring: a hover colour is not
309
+ something a keyboard user can produce, and a focus ring is not something a
310
+ mouse user sees. focus-visible rather than focus, so a click does not leave a
311
+ ring behind it. (No backticks in here: this is inside a template literal.) */
312
+ .malloy-render .${v}:focus-visible {
313
+ outline: 2px solid var(--publisher-drill-link);
314
+ outline-offset: -2px;
315
+ }
316
+ .malloy-render .${v}:focus-visible > .cell-content {
317
+ color: var(--publisher-drill-link) !important;
318
+ text-decoration: underline;
319
+ }
320
+ `, le = "publisher-malloy-renderer-overrides";
321
+ function Le() {
322
+ if (typeof document > "u" || document.getElementById(le)) return;
323
+ const e = document.createElement("style");
324
+ e.id = le, e.textContent = ze, document.head.appendChild(e);
325
+ }
326
+ function Be({
327
+ result: e,
328
+ height: r,
329
+ drill: t,
330
+ onSizeChange: a,
331
+ onSizing: n
332
+ }) {
333
+ const o = z(null), l = z(t);
334
+ l.current = t;
335
+ const s = he((h) => {
336
+ l.current?.onClick(h);
337
+ }, []), b = t !== void 0, u = z(!1), g = z(
338
+ null
339
+ ), R = z(0), { theme: G, layers: U, mode: X } = Ce(), Y = ce().shape.borderRadius, J = me(
340
+ () => ({
341
+ radius: `${Y}px`,
342
+ padding: `${ye}px`
343
+ }),
344
+ [Y]
345
+ );
346
+ return fe(() => () => {
347
+ R.current += 1, g.current?.viz.remove(), g.current = null;
348
+ }, []), be(() => {
349
+ if (!o.current || !e) return;
350
+ Le();
351
+ const h = o.current, ie = R.current += 1;
352
+ let P = !1;
353
+ const j = () => !P && ie === R.current;
354
+ let d, m, M = null, V = 0, I = null, N = null, $ = null, O = null, F = null, T = null, W = null, Q = 0, E = null;
355
+ u.current = !1;
356
+ let p, S;
357
+ const q = (w) => {
358
+ if (P || !w.firstElementChild || K(p, S) === "container") return;
359
+ const _ = ve(p, S);
360
+ if (u.current && !_) return;
361
+ const C = ge(
362
+ w,
363
+ ae(p)
364
+ );
365
+ C > 0 && (u.current = !0, a && C !== Q && (Q = C, a(C)));
366
+ const y = we(w, ae(p));
367
+ _ && y && W !== y && (W = y, T?.disconnect(), T = new ResizeObserver(() => q(w)), T.observe(y));
368
+ };
369
+ return (async () => {
370
+ let w;
371
+ try {
372
+ w = JSON.parse(e);
373
+ } catch (k) {
374
+ console.error("Error parsing visualization result:", k);
375
+ return;
376
+ }
377
+ const _ = await Te(w), C = _ ? xe([...U, _], X) : G;
378
+ if (!j()) return;
379
+ try {
380
+ m = await Fe(C, s);
381
+ } catch (k) {
382
+ console.error("Failed to create renderer:", k);
383
+ return;
384
+ }
385
+ if (!j()) {
386
+ m.remove(), m = void 0;
387
+ return;
388
+ }
389
+ const y = g.current;
390
+ d = document.createElement("div"), d.style.width = "100%", d.style.height = "100%", _e(d, C, J), y && (h.style.position = "relative", d.style.position = "absolute", d.style.inset = "0", d.style.visibility = "hidden"), h.appendChild(d);
391
+ const c = d;
392
+ O = new MutationObserver(() => {
393
+ F && clearTimeout(F), F = setTimeout(() => {
394
+ q(c), u.current && O?.disconnect();
395
+ }, 100);
396
+ }), O.observe(d, {
397
+ childList: !0,
398
+ subtree: !0,
399
+ attributes: !0
400
+ });
401
+ const se = m;
402
+ let Z = !1;
403
+ const ee = () => {
404
+ Z || !j() || (Z = !0, E && (clearTimeout(E), E = null), y && (y.viz.remove(), y.node.parentNode === h && h.removeChild(y.node)), c.style.position = "", c.style.inset = "", c.style.visibility = "", h.style.position = "", g.current = { viz: se, node: c }, q(c));
405
+ };
406
+ try {
407
+ m.setResult(w);
408
+ try {
409
+ const x = m.getMetadata(), A = x?.getRootField();
410
+ p = A?.renderAs(), S = A ? x?.getPluginsForField(A.key)?.[0]?.sizingStrategy : void 0;
411
+ } catch {
412
+ p = void 0, S = void 0;
413
+ }
414
+ n?.(K(p, S)), d.dataset.malloyRenderAs = p ?? "unknown", d.dataset.malloySizing = K(p, S), m.render(d);
415
+ const k = l.current;
416
+ try {
417
+ if (k) {
418
+ const x = Re(m, k.canDrill), A = () => {
419
+ try {
420
+ Ee(c, x);
421
+ } catch (i) {
422
+ console.warn("Drill affordance skipped:", i);
423
+ }
424
+ };
425
+ A();
426
+ const re = (i) => {
427
+ const D = i.querySelector(".cell-content") ?? i, H = D.getBoundingClientRect();
428
+ D.dispatchEvent(
429
+ new MouseEvent("click", {
430
+ bubbles: !0,
431
+ cancelable: !0,
432
+ view: D.ownerDocument.defaultView,
433
+ clientX: Math.round(H.left + H.width / 2),
434
+ clientY: Math.round(H.bottom)
435
+ })
436
+ );
437
+ }, te = (i) => i.target?.closest?.(`.${v}`) ?? null, de = (i, f) => {
438
+ ne(i, f)?.focus();
439
+ };
440
+ I = (i) => {
441
+ const f = te(i);
442
+ if (!f) return;
443
+ const D = i.key === "ArrowDown" ? 1 : i.key === "ArrowUp" ? -1 : i.key === "Home" ? "first" : i.key === "End" ? "last" : void 0;
444
+ if (D !== void 0) {
445
+ i.preventDefault(), de(f, D);
446
+ return;
447
+ }
448
+ i.key === "Enter" ? (i.preventDefault(), re(f)) : i.key === " " && i.preventDefault();
449
+ }, N = (i) => {
450
+ if (i.key !== " ") return;
451
+ const f = te(i);
452
+ f && (i.preventDefault(), re(f));
453
+ }, $ = (i) => {
454
+ const f = i.target?.closest?.(`.${v}`);
455
+ f && ne(f, 0);
456
+ }, c.addEventListener("keydown", I), c.addEventListener("keyup", N), c.addEventListener("focusin", $), x.size > 0 && typeof MutationObserver < "u" && (M = new MutationObserver(() => {
457
+ cancelAnimationFrame(V), V = requestAnimationFrame(A);
458
+ }), M.observe(c, {
459
+ childList: !0,
460
+ subtree: !0
461
+ }));
462
+ }
463
+ } catch (x) {
464
+ console.warn("Drill affordance skipped:", x);
465
+ }
466
+ m.onReady(ee), E = setTimeout(ee, 1e4);
467
+ } catch (k) {
468
+ console.error("Error rendering visualization:", k), O?.disconnect(), T?.disconnect(), M?.disconnect(), m.remove(), m = void 0, c.parentNode === h && h.removeChild(c);
469
+ }
470
+ })(), () => {
471
+ P = !0, O?.disconnect(), T?.disconnect(), F && clearTimeout(F), E && clearTimeout(E), d && g.current?.node !== d && (I && d.removeEventListener("keydown", I), N && d.removeEventListener("keyup", N), $ && d.removeEventListener("focusin", $), M?.disconnect(), cancelAnimationFrame(V), m?.remove(), d.parentNode === h && h.removeChild(d), h.style.position = "");
472
+ };
473
+ }, [
474
+ e,
475
+ s,
476
+ b,
477
+ a,
478
+ n,
479
+ G,
480
+ U,
481
+ X,
482
+ J
483
+ ]), /* @__PURE__ */ L(
484
+ "div",
485
+ {
486
+ ref: o,
487
+ style: {
488
+ width: "100%",
489
+ height: r ? `${r}px` : "400px"
490
+ }
491
+ }
492
+ );
493
+ }
494
+ function Me(e) {
495
+ return typeof window > "u" ? /* @__PURE__ */ L(
496
+ oe,
497
+ {
498
+ sx: {
499
+ width: "100%",
500
+ height: e.height ? `${e.height}px` : "100%",
501
+ display: "flex",
502
+ alignItems: "center",
503
+ justifyContent: "center",
504
+ color: "text.secondary"
505
+ },
506
+ children: "Loading..."
507
+ }
508
+ ) : /* @__PURE__ */ L(
509
+ ue,
510
+ {
511
+ fallback: /* @__PURE__ */ L(
512
+ oe,
513
+ {
514
+ sx: {
515
+ width: "100%",
516
+ height: e.height ? `${e.height}px` : "100%",
517
+ display: "flex",
518
+ alignItems: "center",
519
+ justifyContent: "center",
520
+ color: "text.secondary"
521
+ },
522
+ children: "Loading visualization..."
523
+ }
524
+ ),
525
+ children: /* @__PURE__ */ L(Be, { ...e })
526
+ }
527
+ );
528
+ }
529
+ const Ve = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
530
+ __proto__: null,
531
+ default: Me
532
+ }, Symbol.toStringTag, { value: "Module" }));
533
+ export {
534
+ v as D,
535
+ Me as R,
536
+ De as a,
537
+ Ae as b,
538
+ Ve as c,
539
+ Re as d,
540
+ Ee as m,
541
+ Oe as r
542
+ };