"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[704],{500704:(e,t,r)=>{r.r(t),r.d(t,{default:()=>d});var l=r(667294),a=r(616355),n=r(5364),s=r(751115),u=r(767190),i=r(310581),o=r(263475),c=r(806915),h=r(135944);function d({height:e,width:t,echartOptions:r,setDataMask:d,labelMap:p,labelMapB:f,groupby:g,groupbyB:m,selectedValues:N,formData:b,emitCrossFilters:v,seriesBreakdown:y,onContextMenu:w,onFocusedSeries:k,xValueFormatter:F,xAxis:x,refs:C,coltypeMapping:E}){const V=(0,l.useCallback)((e=>e<y),[y]),I=(0,l.useCallback)(((e,t)=>{const r=Object.values(N||{});let l;l=r.includes(e)?r.filter((t=>t!==e)):[e];const a=V(t)?g:m,n=V(t)?p:f,s=l.map((e=>null==n?void 0:n[e])).filter((e=>!!e));return{dataMask:{extraFormData:{filters:0===l.length?[]:[...a.map(((e,t)=>{const r=s.map((e=>e[t]));return null==r?{col:e,op:"IS NULL"}:{col:e,op:"IN",val:r}}))]},filterState:{value:s.length?s:null,selectedValues:l.length?l:null}},isCurrentValueSelected:r.includes(e)}}),[g,m,V,p,f,N]),M=(0,l.useCallback)(((e,t)=>{const r=V(t);!v||r&&0===g.length||!r&&0===m.length||d(I(e,t).dataMask)}),[V,v,g.length,m.length,d,I]),O={click:e=>{const{seriesName:t,seriesIndex:r}=e;M(t,r)},mouseout:()=>{k(null)},mouseover:e=>{k(e.seriesName)},contextmenu:async e=>{if(w){e.event.stop();const{data:t,seriesName:r,seriesIndex:l}=e,o=e.event.event,h=[],d=[],N=V(l),v=[...e.name?[e.name]:[],...(N?p:f)[e.seriesName]||[]];t&&x.type===a.we.Time&&h.push({col:x.label===n.W3?b.granularitySqla:x.label,grain:b.timeGrainSqla,op:"==",val:t[0],formattedVal:F(t[0])}),[...t&&x.type===a.we.Category?[x.label]:[],...N?b.groupby:b.groupbyB].forEach(((e,t)=>h.push({col:e,op:"==",val:v[t],formattedVal:String(v[t])}))),[...N?b.groupby:b.groupbyB].forEach(((e,t)=>d.push({col:e,op:"==",val:v[t],formattedVal:(0,c.mj)(v[t],{timeFormatter:(0,s.bt)(b.dateFormat),numberFormatter:(0,u.JB)(b.numberFormat),coltype:null==E?void 0:E[(0,i.Z)(e)]})})));const y=N&&g.length>0||!N&&m.length>0;w(o.clientX,o.clientY,{drillToDetail:h,crossFilter:y?I(r,l):void 0,drillBy:{filters:d,groupbyFieldName:N?"groupby":"groupby_b",adhocFilterFieldName:N?"adhoc_filters":"adhoc_filters_b"}})}}};return(0,h.tZ)(o.Z,{refs:C,height:e,width:t,echartOptions:r,eventHandlers:O,selectedValues:N})}},263475:(e,t,r)=>{r.d(t,{Z:()=>R});var l=r(667294),a=r(751995),n=r(768023),s=r(281615),u=r(967021),i=r(358062),o=r(781836),c=r(873463),h=r(216026),d=r(259048),p=r(15746),f=r(126947),g=r(302907),m=r(516049),N=r(541969),b=r(938198),v=r(548785),y=r(557494),w=r(570012),k=r(730322),F=r(655958),x=r(603174),C=r(731281),E=r(210680),V=r(347106),I=r(693450),M=r(499326),O=r(617813),S=r(129167),B=r(787164),Z=r(135944);const j=a.iK.div`
  height: ${({height:e})=>e};
  width: ${({width:e})=>e};
`;function D({width:e,height:t,echartOptions:r,eventHandlers:a,zrEventHandlers:n,selectedValues:u={},refs:i},o){const c=(0,l.useRef)(null);i&&(i.divRef=c);const h=(0,l.useRef)(),d=(0,l.useMemo)((()=>Object.keys(u)||[]),[u]),p=(0,l.useRef)([]);(0,l.useImperativeHandle)(o,(()=>({getEchartInstance:()=>h.current}))),(0,l.useEffect)((()=>{c.current&&(h.current||(h.current=(0,s.S1)(c.current)),Object.entries(a||{}).forEach((([e,t])=>{var r,l;null==(r=h.current)||r.off(e),null==(l=h.current)||l.on(e,t)})),Object.entries(n||{}).forEach((([e,t])=>{var r,l;null==(r=h.current)||r.getZr().off(e),null==(l=h.current)||l.getZr().on(e,t)})),h.current.setOption(r,!0))}),[r,a,n]),(0,l.useEffect)((()=>{h.current&&(h.current.dispatchAction({type:"downplay",dataIndex:p.current.filter((e=>!d.includes(e)))}),d.length&&h.current.dispatchAction({type:"highlight",dataIndex:d}),p.current=d)}),[d]);const f=(0,l.useCallback)((({width:e,height:t})=>{h.current&&h.current.resize({width:e,height:t})}),[]);return(0,l.useEffect)((()=>(f({width:e,height:t}),()=>{var e;return null==(e=h.current)?void 0:e.dispose()})),[]),(0,l.useLayoutEffect)((()=>{f({width:e,height:t})}),[e,t,f]),(0,Z.tZ)(j,{ref:c,height:t,width:e})}(0,n.D)([w.N,u.N,i.N,o.N,c.N,h.N,d.N,p.N,f.N,g.N,m.N,N.N,b.N,v.N,y.N,k.N,F.N,x.N,C.N,E.N,V.N,I.N,M.N,O.N,S.N,B.T]);const R=(0,l.forwardRef)(D)}}]);
//# sourceMappingURL=4a0d1ba168919516a59f.chunk.js.map