"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[704],{33738:(e,t,r)=>{r.r(t),r.d(t,{default:()=>d});var a=r(67294),l=r(16355),n=r(5364),s=r(51115),u=r(67190),i=r(10581),o=r(63475),c=r(6915),h=r(11965);function d({height:e,width:t,echartOptions:r,setDataMask:d,labelMap:p,labelMapB:f,groupby:g,groupbyB:m,selectedValues:b,formData:v,emitCrossFilters:y,seriesBreakdown:w,onContextMenu:k,onFocusedSeries:F,xValueFormatter:x,xAxis:C,refs:E,coltypeMapping:V}){const I=(0,a.useCallback)((e=>e<w),[w]),M=(0,a.useCallback)(((e,t)=>{const r=Object.values(b||{});let a;a=r.includes(e)?r.filter((t=>t!==e)):[e];const l=I(t)?g:m,n=I(t)?p:f,s=a.map((e=>null==n?void 0:n[e])).filter((e=>!!e));return{dataMask:{extraFormData:{filters:0===a.length?[]:[...l.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:a.length?a:null}},isCurrentValueSelected:r.includes(e)}}),[g,m,I,p,f,b]),N=(0,a.useCallback)(((e,t)=>{y&&d(M(e,t).dataMask)}),[y,d,M]),O={click:e=>{const{seriesName:t,seriesIndex:r}=e;N(t,r)},mouseout:()=>{F(null)},mouseover:e=>{F(e.seriesName)},contextmenu:async e=>{if(k){e.event.stop();const{data:t,seriesName:r,seriesIndex:a}=e,o=e.event.event,h=[],d=[],g=I(a),m=[...e.name?[e.name]:[],...(g?p:f)[e.seriesName]];t&&C.type===l.we.Time&&h.push({col:C.label===n.W3?v.granularitySqla:C.label,grain:v.timeGrainSqla,op:"==",val:t[0],formattedVal:x(t[0])}),[...t&&C.type===l.we.Category?[C.label]:[],...g?v.groupby:v.groupbyB].forEach(((e,t)=>h.push({col:e,op:"==",val:m[t],formattedVal:String(m[t])}))),[...g?v.groupby:v.groupbyB].forEach(((e,t)=>d.push({col:e,op:"==",val:m[t],formattedVal:(0,c.mj)(m[t],{timeFormatter:(0,s.bt)(v.dateFormat),numberFormatter:(0,u.JB)(v.numberFormat),coltype:null==V?void 0:V[(0,i.Z)(e)]})}))),k(o.clientX,o.clientY,{drillToDetail:h,crossFilter:M(r,a),drillBy:{filters:d,groupbyFieldName:g?"groupby":"groupby_b",adhocFilterFieldName:g?"adhoc_filters":"adhoc_filters_b"}})}}};return(0,h.tZ)(o.Z,{refs:E,height:e,width:t,echartOptions:r,eventHandlers:O,selectedValues:b})}},63475:(e,t,r)=>{r.d(t,{Z:()=>o});var a=r(67294),l=r(51995),n=r(31431),s=r(11965);const u=l.iK.div`
  height: ${({height:e})=>e};
  width: ${({width:e})=>e};
`;function i({width:e,height:t,echartOptions:r,eventHandlers:l,zrEventHandlers:i,selectedValues:o={},refs:c},h){const d=(0,a.useRef)(null);c&&(c.divRef=d);const p=(0,a.useRef)(),f=(0,a.useMemo)((()=>Object.keys(o)||[]),[o]),g=(0,a.useRef)([]);(0,a.useImperativeHandle)(h,(()=>({getEchartInstance:()=>p.current}))),(0,a.useEffect)((()=>{d.current&&(p.current||(p.current=(0,n.S1)(d.current)),Object.entries(l||{}).forEach((([e,t])=>{var r,a;null==(r=p.current)||r.off(e),null==(a=p.current)||a.on(e,t)})),Object.entries(i||{}).forEach((([e,t])=>{var r,a;null==(r=p.current)||r.getZr().off(e),null==(a=p.current)||a.getZr().on(e,t)})),p.current.setOption(r,!0))}),[r,l,i]),(0,a.useEffect)((()=>{p.current&&(p.current.dispatchAction({type:"downplay",dataIndex:g.current.filter((e=>!f.includes(e)))}),f.length&&p.current.dispatchAction({type:"highlight",dataIndex:f}),g.current=f)}),[f]);const m=(0,a.useCallback)((({width:e,height:t})=>{p.current&&p.current.resize({width:e,height:t})}),[]);return(0,a.useEffect)((()=>(m({width:e,height:t}),()=>{var e;return null==(e=p.current)?void 0:e.dispose()})),[]),(0,a.useLayoutEffect)((()=>{m({width:e,height:t})}),[e,t,m]),(0,s.tZ)(u,{ref:d,height:t,width:e})}const o=(0,a.forwardRef)(i)}}]);
//# sourceMappingURL=c12bcba7ebc720b2403e.chunk.js.map