"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[8551],{88551:(e,t,r)=>{r.r(t),r.d(t,{default:()=>C});var n=r(67294),l=r(16355),a=r(5364),o=r(51115),s=r(67190),u=r(10581),c=r(63475),i=r(6915),d=r(51995),f=r(93362),h=r(49239),g=r(11965);const{RadioButtonControl:p}=f.default,m=d.iK.div`
  text-align: center;
`;function v(e){let{formData:t,setControlValue:r}=e;const{extraControlsOptions:l,extraControlsHandler:a,extraValue:o}=function(e){let{formData:t,setControlValue:r}=e;const{stack:l,area:a}=t,[o,s]=(0,n.useState)(null!=l?l:void 0);return(0,n.useEffect)((()=>{s(l)}),[l]),{extraControlsOptions:(0,n.useMemo)((()=>a?h.Df:[]),[a]),extraControlsHandler:(0,n.useCallback)((e=>{a&&r&&(r("stack",e),s(e))}),[a,r]),extraValue:o}}({formData:t,setControlValue:r});return t.showExtraControls?(0,g.tZ)(m,null,(0,g.tZ)(p,{options:l,onChange:a,value:o})):null}const b=300;function C(e){let{formData:t,height:r,width:d,echartOptions:f,groupby:h,labelMap:p,selectedValues:m,setDataMask:C,setControlValue:y,legendData:x=[],onContextMenu:k,onLegendStateChanged:w,onFocusedSeries:E,xValueFormatter:V,xAxis:Z,refs:F,emitCrossFilters:S,coltypeMapping:D}=e;const{stack:O}=t,R=(0,n.useRef)(null);F.echartRef=R;const M=(0,n.useRef)(),H=(0,n.useRef)(null),[I,T]=(0,n.useState)(0);(0,n.useEffect)((()=>{var e;const t=(null==(e=H.current)?void 0:e.offsetHeight)||0;T(t)}),[t.showExtraControls]);const N=(0,n.useCallback)((e=>{const t=Object.values(m);let r;r=t.includes(e)?t.filter((t=>t!==e)):[e];const n=r.map((e=>p[e]));return{dataMask:{extraFormData:{filters:0===r.length?[]:h.map(((e,t)=>{const r=n.map((e=>e[t]));return null==r?{col:e,op:"IS NULL"}:{col:e,op:"IN",val:r}}))},filterState:{label:n.length?n:void 0,value:n.length?n:null,selectedValues:r.length?r:null}},isCurrentValueSelected:t.includes(e)}}),[h,p,m]),j=(0,n.useCallback)((e=>{S&&C(N(e).dataMask)}),[S,C,N]),L={click:e=>{M.current&&clearTimeout(M.current),M.current=setTimeout((()=>{const{seriesName:t}=e;j(t)}),b)},mouseout:()=>{E(null)},mouseover:e=>{E(e.seriesName)},legendselectchanged:e=>{null==w||w(e.selected)},legendselectall:e=>{null==w||w(e.selected)},legendinverseselect:e=>{null==w||w(e.selected)},contextmenu:async e=>{if(k){var r;e.event.stop();const{data:n,seriesName:c}=e,d=[],f=[],h=e.event.event,g=[...e.name?[e.name]:[],...null!=(r=p[c])?r:[]];n&&Z.type===l.we.time&&d.push({col:Z.label===a.W3?t.granularitySqla:Z.label,grain:t.timeGrainSqla,op:"==",val:n[0],formattedVal:V(n[0])}),[...Z.type===l.we.category&&n?[Z.label]:[],...t.groupby].forEach(((e,t)=>d.push({col:e,op:"==",val:g[t],formattedVal:String(g[t])}))),t.groupby.forEach(((e,r)=>{const n=p[c][r];f.push({col:e,op:"==",val:n,formattedVal:(0,i.mj)(g[r],{timeFormatter:(0,o.bt)(t.dateFormat),numberFormatter:(0,s.JB)(t.numberFormat),coltype:null==D?void 0:D[(0,u.Z)(e)]})})})),k(h.clientX,h.clientY,{drillToDetail:d,crossFilter:N(c),drillBy:{filters:f,groupbyFieldName:"groupby"}})}}},z={dblclick:e=>{var t;M.current&&clearTimeout(M.current);const r=[e.offsetX,e.offsetY],n=null==(t=R.current)?void 0:t.getEchartInstance();if(null!=n&&n.containPixel("grid",r)){var l;if(!O&&"ec-polygon"===(null==(l=e.target)?void 0:l.type))return;const t=n.getModel(),r=((e,t)=>{let r=e,n=null;for(;r;){const e=r.__ecComponentInfo;if(null!=e){n=t.getComponent(e.mainType,e.index);break}r=r.parent}return n})(e.target,t);if(r){const{name:e}=r,t=x.reduce(((t,r)=>({...t,[r]:r===e})),{});null==w||w(t)}}}};return(0,g.tZ)(n.Fragment,null,(0,g.tZ)("div",{ref:H},(0,g.tZ)(v,{formData:t,setControlValue:y})),(0,g.tZ)(c.Z,{ref:R,refs:F,height:r-I,width:d,echartOptions:f,eventHandlers:L,zrEventHandlers:z,selectedValues:m}))}},63475:(e,t,r)=>{r.d(t,{Z:()=>c});var n=r(67294),l=r(51995),a=r(31431),o=r(11965);const s=l.iK.div`
  height: ${e=>{let{height:t}=e;return t}};
  width: ${e=>{let{width:t}=e;return t}};
`;function u(e,t){let{width:r,height:l,echartOptions:u,eventHandlers:c,zrEventHandlers:i,selectedValues:d={},refs:f}=e;const h=(0,n.useRef)(null);f&&(f.divRef=h);const g=(0,n.useRef)(),p=(0,n.useMemo)((()=>Object.keys(d)||[]),[d]),m=(0,n.useRef)([]);(0,n.useImperativeHandle)(t,(()=>({getEchartInstance:()=>g.current}))),(0,n.useEffect)((()=>{h.current&&(g.current||(g.current=(0,a.S1)(h.current)),Object.entries(c||{}).forEach((e=>{var t,r;let[n,l]=e;null==(t=g.current)||t.off(n),null==(r=g.current)||r.on(n,l)})),Object.entries(i||{}).forEach((e=>{var t,r;let[n,l]=e;null==(t=g.current)||t.getZr().off(n),null==(r=g.current)||r.getZr().on(n,l)})),g.current.setOption(u,!0))}),[u,c,i]),(0,n.useEffect)((()=>{g.current&&(g.current.dispatchAction({type:"downplay",dataIndex:m.current.filter((e=>!p.includes(e)))}),p.length&&g.current.dispatchAction({type:"highlight",dataIndex:p}),m.current=p)}),[p]);const v=(0,n.useCallback)((e=>{let{width:t,height:r}=e;g.current&&g.current.resize({width:t,height:r})}),[]);return(0,n.useEffect)((()=>(v({width:r,height:l}),()=>{var e;return null==(e=g.current)?void 0:e.dispose()})),[]),(0,n.useLayoutEffect)((()=>{v({width:r,height:l})}),[r,l,v]),(0,o.tZ)(s,{ref:h,height:l,width:r})}const c=(0,n.forwardRef)(u)}}]);
//# sourceMappingURL=e2bff7159f05a80701b5.chunk.js.map