"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[3951],{88168:(e,t,n)=>{n.d(t,{A:()=>Xe});var r,o=n(61225),i=n(82960),a=n(2514),s=n(7735),l=n(96540),d=n(95579),c=n(96453),u=n(5362),h=n(69108),p=n(27366),m=n(62952),g=n(73212),v=n(17444),b=n(50455),f=n(49544),y=n(35700),x=n(27023),C=n(32132),S=n(92201);!function(e){e.Explore="explore",e.Dashboard="dashboard"}(r||(r={}));var A,w=n(86274),T=n(88055),D=n.n(T),_=n(2404),Y=n.n(_),F=n(4124),I=n.n(F),$=n(5556),E=n.n($),M=n(58863),R=n(80145),N=n(93641),k=n(28846),O=n(17437),U=n(28290),q=n(6749),L=n(53860),z=n(15595),H=n(95004),P=n(70542),W=n(83537),j=n(67429),V=n(38221),B=n.n(V),G=n(72391),Q=n(87843),K=n(58561),X=n.n(K),J=n(5373),Z=n(12249),ee=n(90868),te=n(5261),ne=n(35233),re=n(13270),oe=n(71519),ie=n(85861),ae=n(46920),se=n(94229),le=n(60237),de=n(59838),ce=n(55976),ue=n(25946),he=n(84666),pe=n(85183);!function(e){e[e.Chart=0]="Chart",e[e.Table=1]="Table"}(A||(A={}));var me=n(2445);function ge({formData:e,result:t,dataset:n,onContextMenu:r,inContextMenu:o}){const i=(0,l.useMemo)((()=>({onContextMenu:r})),[r]);return(0,me.Y)("div",{css:O.AH`
        width: 100%;
        height: 100%;
        min-height: 0;
      `,children:(0,me.Y)(k.A,{disableErrorBoundary:!0,chartType:e.viz_type,enableNoResults:!0,datasource:n,formData:e,queriesData:t,hooks:i,inContextMenu:o,height:"100%",width:"100%"})})}var ve=n(69193),be=n(15151);const fe=(0,c.I4)(z.BD.Item)`
  ${({theme:e,isClickable:t,isHidden:n})=>O.AH`
    cursor: ${t?"pointer":"auto"};
    color: ${e.colors.grayscale.light1};
    transition: color ease-in ${e.transitionTiming}s;
    .ant-breadcrumb > span:last-child > & {
      color: ${e.colors.grayscale.dark1};
    }
    &:hover {
      color: ${t?e.colors.grayscale.dark1:"inherit"};
    }
    visibility: ${n?"hidden":"visible"};
  `}
`;var ye=n(8877),xe=n(48327);const Ce=c.I4.div`
  ${({theme:e})=>O.AH`
    & .pagination-container {
      bottom: ${4*-e.gridUnit}px;
    }
  `}
`,Se="adhoc_filters",Ae=({formData:e,closeModal:t})=>{const n=(0,o.wA)(),{addDangerToast:r}=(0,te.Yf)(),i=(0,c.DP)(),[a,u]=(0,l.useState)(""),h=(0,l.useContext)(se.DashboardPageIdContext),p=(0,l.useCallback)((()=>{n((0,s.logEvent)(y.Ro,{slice_id:e.slice_id}))}),[n,e.slice_id]),m=(0,o.d4)((e=>{var t;return(0,he.L)("can_explore","Superset",null==(t=e.user)?void 0:t.roles)})),[g,v]=e.datasource.split("__");(0,l.useEffect)((()=>{(0,le.T3)(Number(g),v,e,0).then((e=>{u(`/explore/?form_data_key=${e}&dashboard_page_id=${h}`)})).catch((()=>{r((0,d.t)("Failed to generate chart edit URL"))}))}),[r,h,g,v,e]);const b=!a||!m;return(0,me.FD)(me.FK,{children:[(0,me.Y)(ae.A,{buttonStyle:"secondary",buttonSize:"small",onClick:p,disabled:b,tooltip:b?(0,d.t)("You do not have sufficient permissions to edit the chart"):void 0,children:(0,me.Y)(oe.N_,{css:O.AH`
            &:hover {
              text-decoration: none;
            }
          `,to:a,children:(0,d.t)("Edit chart")})}),(0,me.Y)(ae.A,{buttonStyle:"primary",buttonSize:"small",onClick:t,css:O.AH`
          margin-left: ${2*i.gridUnit}px;
        `,children:(0,d.t)("Close")})]})};function we({column:e,dataset:t,drillByConfig:n,formData:r,onHideModal:i,canDownload:u}){const h=(0,o.wA)(),p=(0,c.DP)(),{addDangerToast:g}=(0,te.Yf)(),[b,f]=(0,l.useState)(!0),[x,C]=(0,l.useState)([{...n,column:e}]);(0,l.useEffect)((()=>{h((0,s.logEvent)(y.bD,{slice_id:r.slice_id}))}),[h,r.slice_id]);const{column:S,groupbyFieldName:w=n.groupbyFieldName}=x[x.length-1]||{},T=(0,l.useMemo)((()=>(0,m.A)(r[w]).map((e=>{var n;return null==(n=t.columns)?void 0:n.find((t=>t.column_name===e))})).filter(re.A)),[t.columns,r,w]),{displayModeToggle:D,drillByDisplayMode:_}=(()=>{const[e,t]=(0,l.useState)(A.Chart);return{displayModeToggle:(0,l.useMemo)((()=>(0,me.Y)("div",{css:e=>O.AH`
          margin-bottom: ${6*e.gridUnit}px;
        `,children:(0,me.Y)(ve.s.GroupWrapper,{onChange:({target:{value:e}})=>{t(e)},defaultValue:A.Chart,options:[{label:(0,d.t)("Chart"),value:A.Chart},{label:(0,d.t)("Table"),value:A.Table}],optionType:"button",buttonStyle:"outline"})})),[]),drillByDisplayMode:e}})(),[Y,F]=(0,l.useState)(),I=((e,t,n)=>(0,re.A)(e)?1===e.length?(0,me.Y)(Ce,{children:(0,me.Y)(ye.U,{colnames:e[0].colnames,coltypes:e[0].coltypes,rowcount:e[0].sql_rowcount,data:e[0].data,dataSize:15,datasourceId:t,isVisible:!0,canDownload:n})}):(0,me.Y)(xe.Ay,{fullWidth:!1,children:e.map(((e,r)=>(0,me.Y)(xe.Ay.TabPane,{tab:(0,d.t)("Results %s",r+1),children:(0,me.Y)(Ce,{children:(0,me.Y)(ye.U,{colnames:e.colnames,coltypes:e.coltypes,data:e.data,rowcount:e.sql_rowcount,dataSize:15,datasourceId:t,isVisible:!0,canDownload:n})})},r)))}):(0,me.Y)("div",{}))(Y,r.datasource,u),[$,E]=(0,l.useState)(r),[M,R]=(0,l.useState)([...T,e].filter(re.A)),[N,k]=(0,l.useState)([{groupby:T,filters:n.filters},{groupby:e||[]}]),U=(0,l.useCallback)(((e,t=w)=>Array.isArray(r[t])?[e.column_name]:e.column_name),[r,w]),q=(0,l.useCallback)((e=>e.reduce(((e,t)=>{null!=t&&t.groupbyFieldName&&t.column&&(e.formData[t.groupbyFieldName]=U(t.column,t.groupbyFieldName),e.overriddenGroupbyFields.add(t.groupbyFieldName));const n=(null==t?void 0:t.adhocFilterFieldName)||Se;return e.formData[n]=[...(0,m.A)(e[n]),...(0,m.A)(t.filters).map((e=>(0,de.r)(e)))],e.overriddenAdhocFilterFields.add(n),e}),{formData:{},overriddenGroupbyFields:new Set,overriddenAdhocFilterFields:new Set})),[U]),L=(0,l.useCallback)((()=>x.reduce(((e,t)=>{const n=t.adhocFilterFieldName||Se;return e[n]=[...e[n]||[],...t.filters.map((e=>(0,de.r)(e)))],e}),{})),[x]),H=((e,t=be.fZ)=>(0,l.useMemo)((()=>{const n=t=>t<e.length-1,r=e=>`${(0,m.A)(e.groupby).map((e=>e.verbose_name||e.column_name)).join(", ")} ${e.filters?`(${e.filters.map((e=>e.formattedVal||e.val)).join(", ")})`:""}`;return(0,me.Y)(z.BD,{css:e=>O.AH`
          margin: ${2*e.gridUnit}px 0 ${4*e.gridUnit}px;
        `,children:e.map(((e,o)=>{return(0,me.Y)(fe,{isClickable:n(o),isHidden:(i=e,0===(0,m.A)(i.groupby).length&&0===(0,m.A)(i.filters).length),onClick:n(o)?()=>t(e,o):be.fZ,children:r(e)},o);var i})).filter((e=>!1===e.props.isHidden))})}),[e,t]))(N,(0,l.useCallback)(((e,t)=>{h((0,s.logEvent)(y.g$,{slice_id:r.slice_id})),C((e=>e.slice(0,t))),k((e=>{const n=e.slice(0,t+1);return delete n[n.length-1].filters,n})),R((e=>e.slice(0,t))),E((()=>{if(0===t)return r;const{formData:e,overriddenAdhocFilterFields:n}=q(x.slice(0,t)),o={...r,...e};return n.forEach((t=>({...o,[t]:[...r[t],...e[t]]}))),o}))}),[h,x,r,q])),P=(0,l.useMemo)((()=>{let e={...$};S&&w&&(e[w]=U(S));const t=L();return Object.keys(t).forEach((n=>{e={...e,[n]:[...(0,m.A)(r[n]),...t[n]]}})),e.slice_id=0,delete e.slice_name,delete e.dashboards,e}),[$,S,w,L,U,r]);(0,l.useEffect)((()=>{R((e=>!S||e.some((e=>e.column_name===S.column_name))?e:[...e,S]))}),[S]);const W=(0,l.useCallback)(((e,t)=>{h((0,s.logEvent)(y.gi,{drill_depth:x.length+1,slice_id:r.slice_id})),E(P),C((n=>[...n,{...t,column:e}])),k((n=>{const r=[...n,{groupby:e}];return r[r.length-2].filters=t.filters,r}))}),[h,x.length,P,r.slice_id]),j=(0,l.useMemo)((()=>({drillBy:{excludedColumns:M,openNewModal:!1}})),[M]),{contextMenu:V,inContextMenu:B,onContextMenu:G}=((e,t,n,r,o)=>{const i=(0,l.useRef)(null),[a,s]=(0,l.useState)(!1),d=(0,l.useCallback)(((...e)=>{s(!1),null==n||n(...e)}),[n]),c=(0,l.useCallback)((()=>{s(!1)}),[]);return{contextMenu:(0,l.useMemo)((()=>(0,me.Y)(Ee,{ref:i,id:0,formData:t,onSelection:d,onClose:c,displayedItems:r,additionalConfig:o})),[o,0,r,t,c,d]),inContextMenu:a,onContextMenu:(e,t,n)=>{var r;null==(r=i.current)||r.open(e,t,n),s(!0)}}})(0,$,W,Fe.DrillBy,j),Q=(0,o.d4)((e=>{const t=Object.values(e.dashboardLayout.present).find((e=>{var t;return(null==(t=e.meta)?void 0:t.chartId)===r.slice_id}));return(null==t?void 0:t.meta.sliceNameOverride)||(null==t?void 0:t.meta.sliceName)}));(0,l.useEffect)((()=>{if(P){const[e]=(0,pe.Mp)(P);f(!0),F(void 0),(0,a.getChartDataRequest)({formData:P}).then((({response:t,json:n})=>(0,a.handleChartDataResponse)(t,n,e))).then((e=>{F(e)})).catch((()=>{g((0,d.t)("Failed to load chart data."))})).finally((()=>{f(!1)}))}}),[g,P]);const{metadataBar:K}=(0,ce.M)({dataset:t});return(0,me.Y)(ie.Ay,{css:O.AH`
        .antd5-modal-footer {
          border-top: none;
        }
      `,show:!0,onHide:null!=i?i:()=>null,title:(0,d.t)("Drill by: %s",Q),footer:(0,me.Y)(Ae,{formData:P}),responsive:!0,resizable:!0,resizableConfig:{minHeight:128*p.gridUnit,minWidth:128*p.gridUnit,defaultSize:{width:"auto",height:"80vh"}},draggable:!0,destroyOnClose:!0,maskClosable:!1,children:(0,me.FD)("div",{css:O.AH`
          display: flex;
          flex-direction: column;
          height: 100%;
        `,children:[K,H,D,b&&(0,me.Y)(v.A,{}),!b&&!Y&&(0,me.Y)(ue.A,{type:"error",message:(0,d.t)("There was an error loading the chart data")}),_===A.Chart&&Y&&(0,me.Y)(ge,{dataset:t,formData:P,result:Y,onContextMenu:G,inContextMenu:B}),_===A.Table&&Y&&I,V]})})}var Te=n(28543);const De=(0,G.a)().get("load.drillby.options"),_e=X().encode({columns:["table_name","owners.first_name","owners.last_name","created_by.first_name","created_by.last_name","created_on_humanized","changed_by.first_name","changed_by.last_name","changed_on_humanized","columns.column_name","columns.verbose_name","columns.groupby"]}),Ye=({drillByConfig:e,formData:t,contextMenuY:n=0,submenuIndex:r=0,onSelection:o=()=>{},onClick:i=()=>{},excludedColumns:a,openNewModal:s=!0,canDownload:h,open:p,...g})=>{const b=(0,c.DP)(),{addDangerToast:f}=(0,te.Yf)(),[y,x]=(0,l.useState)(!0),[C,S]=(0,l.useState)(""),[A,w]=(0,l.useState)(""),[T,D]=(0,l.useState)(),[_,Y]=(0,l.useState)([]),[F,I]=(0,l.useState)(!1),[$,E]=(0,l.useState)(),N=(0,l.useRef)(null),k=De||_.length>10,U=(0,l.useCallback)(((t,n)=>{i(t),o(n,e),E(n),s&&I(!0)}),[e,i,o,s]),L=(0,l.useCallback)((()=>{I(!1)}),[]);(0,l.useEffect)((()=>{var e,t;p?null==(e=N.current)||null==(t=e.input)||t.focus({preventScroll:!0}):(S(""),w(""))}),[p]);const z=null==e?void 0:e.groupbyFieldName,H=(0,l.useMemo)((()=>{var e;return null==(e=(0,R.A)().get(t.viz_type))?void 0:e.behaviors.find((e=>e===M.nS.DrillBy))}),[t.viz_type]),P=(e=>{const t={};return(0,m.A)(null==e?void 0:e.columns).forEach((e=>{t[e.column_name]=e.verbose_name||e.column_name})),(0,m.A)(null==e?void 0:e.metrics).forEach((e=>{t[e.metric_name]=e.verbose_name||e.metric_name})),t})(T);(0,l.useEffect)((()=>{H&&z&&async function(){const n=Number(t.datasource.split("__")[0]);try{let r;x(!0),r=De?await De(n,t):await(0,ne.w)({endpoint:`/api/v1/dataset/${n}?q=${_e}`});const{json:o}=r,{result:i}=o;D(i),Y((0,m.A)(i.columns).filter((e=>e.groupby)).filter((n=>{var r,o;return!(0,m.A)(t[null!=(r=null==e?void 0:e.groupbyFieldName)?r:""]).includes(n.column_name)&&n.column_name!==t.x_axis&&(null==(o=(0,m.A)(a))?void 0:o.every((e=>e.column_name!==n.column_name)))})))}catch(e){u.A.error(e),ne.e.delete(`/api/v1/dataset/${n}`),f((0,d.t)("Failed to load dimensions for drill by"))}finally{x(!1)}}()}),[f,null==e?void 0:e.groupbyFieldName,a,t,H,z]);const V=(0,l.useMemo)((()=>B()((e=>{w(e)}),Q.j)),[]),G=(0,l.useMemo)((()=>_.filter((e=>(e.verbose_name||e.column_name).toLowerCase().includes(A.toLowerCase())))),[_,A]),K=(0,l.useMemo)((()=>(0,W.Gs)(n,G.length||1,r,200,k?48:0)),[n,G.length,r,k]);let X;return H?z||(X=(0,d.t)("Drill by is not available for this data point")):X=(0,d.t)("Drill by is not yet supported for this chart type"),H&&z?(0,me.FD)(me.FK,{children:[(0,me.Y)(q.W1.SubMenu,{title:(0,d.t)("Drill by"),popupClassName:"chart-context-submenu",popupOffset:[0,K],...g,children:(0,me.FD)("div",{children:[k&&(0,me.Y)(ee.pd,{ref:N,prefix:(0,me.Y)(Z.A.Search,{iconSize:"l",iconColor:b.colors.grayscale.light1}),onChange:e=>{var t;e.stopPropagation(),t=e.target.value,S(t),V(t)},placeholder:(0,d.t)("Search columns"),onClick:e=>{e.nativeEvent.stopImmediatePropagation()},allowClear:!0,css:O.AH`
                width: auto;
                max-width: 100%;
                margin: ${2*b.gridUnit}px ${3*b.gridUnit}px;
                box-shadow: none;
              `,value:C}),y?(0,me.Y)("div",{css:O.AH`
                padding: ${3*b.gridUnit}px 0;
              `,children:(0,me.Y)(v.A,{position:"inline-centered"})}):G.length?(0,me.Y)(J.Y1,{width:"100%",height:200,itemSize:35,itemCount:G.length,itemData:{columns:G,...g},overscanCount:20,children:({index:e,data:t,style:n})=>{const{columns:r,...o}=t,i=r[e];return(0,me.Y)(Te.o,{tooltipText:i.verbose_name||i.column_name,...o,onClick:e=>U(e,i),style:n,children:i.verbose_name||i.column_name},`drill-by-item-${i.column_name}`)}}):(0,me.Y)(q.W1.Item,{disabled:!0,...g,children:(0,d.t)("No columns found")},"no-drill-by-columns-found")]})}),F&&(0,me.Y)(we,{column:$,drillByConfig:e,formData:t,onHideModal:L,dataset:{...T,verbose_map:P},canDownload:h})]}):(0,me.Y)(q.W1.Item,{disabled:!0,...g,children:(0,me.FD)("div",{children:[(0,d.t)("Drill by"),(0,me.Y)(j.C,{title:X})]})},"drill-by-disabled")};var Fe,Ie=n(29356);!function(e){e[e.CrossFilter=0]="CrossFilter",e[e.DrillToDetail=1]="DrillToDetail",e[e.DrillBy=2]="DrillBy",e[e.All=3]="All"}(Fe||(Fe={}));const $e=({id:e,formData:t,onSelection:n,onClose:r,displayedItems:i=Fe.All,additionalConfig:a},s)=>{var u,h;const g=(0,c.DP)(),v=(0,o.wA)(),{canDrillToDetail:b,canDrillBy:f,canDownload:y}=(0,L.S)(),x=(0,o.d4)((({dashboardInfo:e})=>e.crossFiltersEnabled)),[C,S]=(0,l.useState)([]),[A,w]=(0,l.useState)([]),[T,D]=(0,l.useState)(!1),_=e=>i===Fe.All||(0,m.A)(i).includes(e),[{filters:Y,clientX:F,clientY:I},$]=(0,l.useState)({clientX:0,clientY:0}),[E,N]=(0,l.useState)(!1),k=[],V=(0,p.G7)(p.TO.DrillToDetail)&&b&&_(Fe.DrillToDetail),B=(0,p.G7)(p.TO.DrillBy)&&f&&_(Fe.DrillBy),G=_(Fe.CrossFilter),Q=null==(u=(0,R.A)().get(t.viz_type))||null==(h=u.behaviors)?void 0:h.includes(M.nS.InteractiveChart);let K=0;if(G&&(K+=1),V&&(K+=2),B&&(K+=1),0===K&&(K=1),G){var X;const t=!Q||!x||!(null!=Y&&Y.crossFilter);let n=null;t?x?Q?null!=Y&&Y.crossFilter||(n=(0,me.Y)(me.FK,{children:(0,me.Y)("div",{children:(0,d.t)("You can't apply cross-filter on this data point.")})})):n=(0,me.Y)(me.FK,{children:(0,me.Y)("div",{children:(0,d.t)("This visualization type does not support cross-filtering.")})}):n=(0,me.Y)(me.FK,{children:(0,me.Y)("div",{children:(0,d.t)("Cross-filtering is not enabled for this dashboard.")})}):n=(0,me.FD)(me.FK,{children:[(0,me.Y)("div",{children:(0,d.t)("Cross-filter will be applied to all of the charts that use this dataset.")}),(0,me.Y)("div",{children:(0,d.t)("You can also just click on the chart to apply cross-filter.")})]}),k.push((0,me.FD)(me.FK,{children:[(0,me.Y)(q.W1.Item,{disabled:t,onClick:()=>{null!=Y&&Y.crossFilter&&v((0,H.Mv)(e,Y.crossFilter.dataMask))},children:null!=Y&&null!=(X=Y.crossFilter)&&X.isCurrentValueSelected?(0,d.t)("Remove cross-filter"):(0,me.FD)("div",{children:[(0,d.t)("Add cross-filter"),(0,me.Y)(j.C,{title:n,color:t?void 0:g.colors.grayscale.base})]})},"cross-filtering-menu-item"),K>1&&(0,me.Y)(q.W1.Divider,{})]}))}if(V&&k.push((0,me.Y)(P.k,{formData:t,filters:null==Y?void 0:Y.drillToDetail,setFilters:w,isContextMenu:!0,contextMenuY:I,onSelection:n,submenuIndex:G?2:1,setShowModal:N,...(null==a?void 0:a.drillToDetail)||{}})),B){let e=0;G&&(e+=1),V&&(e+=2),k.push((0,me.Y)(Ye,{drillByConfig:null==Y?void 0:Y.drillBy,onSelection:n,formData:t,contextMenuY:I,submenuIndex:e,canDownload:y,open:C.includes("drill-by-submenu"),...(null==a?void 0:a.drillBy)||{}},"drill-by-submenu"))}const J=(0,l.useCallback)(((t,n,r)=>{var o;const i=(0,W.x4)(n,K);$({clientX:t,clientY:i,filters:r}),null==(o=document.getElementById(`hidden-span-${e}`))||o.click()}),[e,K]);return(0,l.useImperativeHandle)(s,(()=>({open:J})),[J]),U.createPortal((0,me.FD)(me.FK,{children:[(0,me.Y)(z.rM,{overlay:(0,me.Y)(q.W1,{className:"chart-context-menu",onOpenChange:S,onClick:()=>{D(!1),r()},children:k.length?k:(0,me.Y)(q.W1.Item,{disabled:!0,children:(0,d.t)("No actions")})}),trigger:["click"],onVisibleChange:e=>{D(e),e||S([])},visible:T,children:(0,me.Y)("span",{id:`hidden-span-${e}`,css:(0,O.AH)({visibility:"hidden",position:"fixed",top:I,left:F,width:1,height:1},"","")})}),V&&(0,me.Y)(Ie.A,{initialFilters:A,chartId:e,formData:t,showModal:E,onHideModal:()=>{N(!1)}})]}),document.body)},Ee=(0,l.forwardRef)($e),Me={annotationData:E().object,actions:E().object,chartId:E().number.isRequired,datasource:E().object,initialValues:E().object,formData:E().object.isRequired,latestQueryFormData:E().object,labelsColor:E().object,labelsColorMap:E().object,height:E().number,width:E().number,setControlValue:E().func,vizType:E().string.isRequired,triggerRender:E().bool,chartAlert:E().string,chartStatus:E().string,queriesResponse:E().arrayOf(E().object),triggerQuery:E().bool,chartIsStale:E().bool,addFilter:E().func,setDataMask:E().func,onFilterMenuOpen:E().func,onFilterMenuClose:E().func,ownState:E().object,postTransformProps:E().func,source:E().oneOf([r.Dashboard,r.Explore]),emitCrossFilters:E().bool},Re={},Ne=[M.nS.InteractiveChart],ke={addFilter:()=>Re,onFilterMenuOpen:()=>Re,onFilterMenuClose:()=>Re,initialValues:Re,setControlValue(){},triggerRender:!1};class Oe extends l.Component{constructor(e){var t,n;super(e);const o=null==(t=(0,R.A)().get(null!=(n=e.formData.viz_type)?n:e.vizType))?void 0:t.suppressContextMenu;this.state={showContextMenu:e.source===r.Dashboard&&!o&&(0,p.G7)(p.TO.DrillToDetail),inContextMenu:!1,legendState:void 0},this.hasQueryResponseChange=!1,this.contextMenuRef=(0,l.createRef)(),this.handleAddFilter=this.handleAddFilter.bind(this),this.handleRenderSuccess=this.handleRenderSuccess.bind(this),this.handleRenderFailure=this.handleRenderFailure.bind(this),this.handleSetControlValue=this.handleSetControlValue.bind(this),this.handleOnContextMenu=this.handleOnContextMenu.bind(this),this.handleContextMenuSelected=this.handleContextMenuSelected.bind(this),this.handleContextMenuClosed=this.handleContextMenuClosed.bind(this),this.handleLegendStateChanged=this.handleLegendStateChanged.bind(this),this.onContextMenuFallback=this.onContextMenuFallback.bind(this),this.hooks={onAddFilter:this.handleAddFilter,onContextMenu:this.state.showContextMenu?this.handleOnContextMenu:void 0,onError:this.handleRenderFailure,setControlValue:this.handleSetControlValue,onFilterMenuOpen:this.props.onFilterMenuOpen,onFilterMenuClose:this.props.onFilterMenuClose,onLegendStateChanged:this.handleLegendStateChanged,setDataMask:e=>{var t;null==(t=this.props.actions)||t.updateDataMask(this.props.chartId,e)}},this.mutableQueriesResponse=D()(this.props.queriesResponse)}shouldComponentUpdate(e,t){var n,r;return!(!(e.queriesResponse&&["success","rendered"].indexOf(e.chartStatus)>-1)||null!=(n=e.queriesResponse)&&null!=(r=n[0])&&r.error)&&(!Y()(this.state,t)||(this.hasQueryResponseChange=e.queriesResponse!==this.props.queriesResponse,this.hasQueryResponseChange&&(this.mutableQueriesResponse=D()(e.queriesResponse)),this.hasQueryResponseChange||!Y()(e.datasource,this.props.datasource)||e.annotationData!==this.props.annotationData||e.ownState!==this.props.ownState||e.filterState!==this.props.filterState||e.height!==this.props.height||e.width!==this.props.width||e.triggerRender||e.labelsColor!==this.props.labelsColor||e.labelsColorMap!==this.props.labelsColorMap||e.formData.color_scheme!==this.props.formData.color_scheme||e.formData.stack!==this.props.formData.stack||e.cacheBusterProp!==this.props.cacheBusterProp||e.emitCrossFilters!==this.props.emitCrossFilters))}handleAddFilter(e,t,n=!0,r=!0){this.props.addFilter(e,t,n,r)}handleRenderSuccess(){const{actions:e,chartStatus:t,chartId:n,vizType:r}=this.props;["loading","rendered"].indexOf(t)<0&&e.chartRenderingSucceeded(n),this.hasQueryResponseChange&&e.logEvent(y.tE,{slice_id:n,viz_type:r,start_offset:this.renderStartTime,ts:(new Date).getTime(),duration:y.Vy.getTimestamp()-this.renderStartTime})}handleRenderFailure(e,t){const{actions:n,chartId:r}=this.props;u.A.warn(e),n.chartRenderingFailed(e.toString(),r,t?t.componentStack:null),this.hasQueryResponseChange&&n.logEvent(y.tE,{slice_id:r,has_err:!0,error_details:e.toString(),start_offset:this.renderStartTime,ts:(new Date).getTime(),duration:y.Vy.getTimestamp()-this.renderStartTime})}handleSetControlValue(...e){const{setControlValue:t}=this.props;t&&t(...e)}handleOnContextMenu(e,t,n){this.contextMenuRef.current.open(e,t,n),this.setState({inContextMenu:!0})}handleContextMenuSelected(){this.setState({inContextMenu:!1})}handleContextMenuClosed(){this.setState({inContextMenu:!1})}handleLegendStateChanged(e){this.setState({legendState:e})}onContextMenuFallback(e){this.state.inContextMenu||(e.preventDefault(),this.handleOnContextMenu(e.clientX,e.clientY))}render(){var e;const{chartAlert:t,chartStatus:n,chartId:o,emitCrossFilters:i}=this.props;if("loading"===n||t||null===n)return null;this.renderStartTime=y.Vy.getTimestamp();const{width:a,height:s,datasource:l,annotationData:c,initialValues:u,ownState:h,filterState:p,chartIsStale:m,formData:g,latestQueryFormData:v,postTransformProps:f}=this.props,x=m&&v?v:g,C=x.viz_type||this.props.vizType,S=I()(C),A=C===N.Y.Table?`superset-chart-${S}`:S;let w;const T=(0,d.t)("No results were returned for this query"),D=this.props.source===r.Explore?(0,d.t)("Make sure that the controls are configured properly and the datasource contains data for the selected time range"):void 0,_="chart.svg";w=a>300&&s>220?(0,me.Y)(b.p,{size:"large",title:T,description:D,image:_}):(0,me.Y)(b.p,{size:"small",title:T,image:_});const Y=null!=(e=(0,R.A)().get(g.viz_type))&&e.behaviors.find((e=>e===M.nS.DrillToDetail))?{inContextMenu:this.state.inContextMenu}:{};return(0,me.FD)(me.FK,{children:[this.state.showContextMenu&&(0,me.Y)(Ee,{ref:this.contextMenuRef,id:o,formData:x,onSelection:this.handleContextMenuSelected,onClose:this.handleContextMenuClosed}),(0,me.Y)("div",{onContextMenu:this.state.showContextMenu?this.onContextMenuFallback:void 0,children:(0,me.Y)(k.A,{disableErrorBoundary:!0,id:`chart-id-${o}`,className:A,chartType:C,width:a,height:s,annotationData:c,datasource:l,initialValues:u,formData:x,ownState:h,filterState:p,hooks:this.hooks,behaviors:Ne,queriesData:this.mutableQueriesResponse,onRenderSuccess:this.handleRenderSuccess,onRenderFailure:this.handleRenderFailure,noResults:w,postTransformProps:f,emitCrossFilters:i,legendState:this.state.legendState,...Y},`${o}`)})]})}}Oe.propTypes=Me,Oe.defaultProps=ke;const Ue=Oe;var qe=n(71478),Le=n(79427);const ze=({chartId:e,error:t,...n})=>{const{result:r}=(0,qe.RG)(e),o=t&&{...t,extra:{...t.extra,owners:r}};return(0,me.Y)(Le.A,{...n,error:o})};var He=n(21357);const Pe={},We=(0,d.t)("The dataset associated with this chart no longer exists"),je={addFilter:()=>Pe,onFilterMenuOpen:()=>Pe,onFilterMenuClose:()=>Pe,initialValues:Pe,setControlValue:()=>Pe,triggerRender:!1,dashboardId:void 0,chartStackTrace:void 0,force:!1,isInView:!0},Ve=c.I4.div`
  min-height: ${e=>e.height}px;
  position: relative;

  .chart-tooltip {
    opacity: 0.75;
    font-size: ${({theme:e})=>e.typography.sizes.s}px;
  }

  .slice_container {
    display: flex;
    flex-direction: column;
    justify-content: center;

    height: ${e=>e.height}px;

    .pivot_table tbody tr {
      font-feature-settings: 'tnum' 1;
    }

    .alert {
      margin: ${({theme:e})=>2*e.gridUnit}px;
    }
  }
`,Be=c.I4.div`
  position: absolute;
  left: 50%;
  top: 50%;
  width: 80%;
  transform: translate(-50%, -50%);
`,Ge=c.I4.span`
  display: block;
  text-align: center;
  margin: ${({theme:e})=>4*e.gridUnit}px auto;
  width: fit-content;
  color: ${({theme:e})=>e.colors.grayscale.base};
`;class Qe extends l.PureComponent{constructor(e){super(e),this.renderStartTime=void 0,this.handleRenderContainerFailure=this.handleRenderContainerFailure.bind(this)}componentDidMount(){this.props.triggerQuery&&this.runQuery()}componentDidUpdate(){this.props.triggerQuery&&this.runQuery()}runQuery(){this.props.actions.postChartFormData(this.props.formData,Boolean(this.props.force||(0,C.P3)(x.vX.force)),this.props.timeout,this.props.chartId,this.props.dashboardId,this.props.ownState)}handleRenderContainerFailure(e,t){const{actions:n,chartId:r}=this.props;u.A.warn(e),n.chartRenderingFailed(e.toString(),r,t?t.componentStack:null),n.logEvent(y.tE,{slice_id:r,has_err:!0,error_details:e.toString(),start_offset:this.renderStartTime,ts:(new Date).getTime(),duration:y.Vy.getTimestamp()-this.renderStartTime})}renderErrorMessage(e){var t;const{chartId:n,chartAlert:o,chartStackTrace:i,datasource:a,dashboardId:s,height:l,datasetsStatus:c}=this.props;let u=null==e||null==(t=e.errors)?void 0:t[0];void 0===u&&(u={error_type:h.eK.FRONTEND_NETWORK_ERROR,level:"error",message:(0,d.t)("Check your network connection"),extra:null});const p=o||(null==e?void 0:e.message);return void 0!==o&&o!==We&&a===g.As&&c!==w.bk.Error?(0,me.Y)(Ve,{"data-ui-anchor":"chart",className:"chart-container",height:l,children:(0,me.Y)(v.A,{})},n):(0,me.Y)(ze,{chartId:n,error:u,subtitle:p,link:e?e.link:void 0,source:s?r.Dashboard:r.Explore,stackTrace:i},n)}renderSpinner(e){const t=e?(0,d.t)("Waiting on %s",e):(0,d.t)("Waiting on database...");return(0,me.FD)(Be,{children:[(0,me.Y)(v.A,{position:"inline-centered"}),(0,me.Y)(Ge,{children:t})]})}renderChartContainer(){return(0,me.Y)("div",{className:"slice_container",children:this.props.isInView||!(0,p.G7)(p.TO.DashboardVirtualization)||(0,S.a)()?(0,me.Y)(Ue,{...this.props,source:this.props.dashboardId?"dashboard":"explore"}):(0,me.Y)(v.A,{})})}render(){var e;const{height:t,chartAlert:n,chartStatus:r,datasource:o,errorMessage:i,chartIsStale:a,queriesResponse:s=[],width:l}=this.props,c=null==o||null==(e=o.database)?void 0:e.name,u="loading"===r;return"failed"===r?s.map((e=>this.renderErrorMessage(e))):i&&0===(0,m.A)(s).length?(0,me.Y)(b.p,{size:"large",title:(0,d.t)("Add required control values to preview chart"),description:(0,He.w)(!0),image:"chart.svg"}):u||n||i||!a||0!==(0,m.A)(s).length?(0,me.Y)(f.A,{onError:this.handleRenderContainerFailure,showMessage:!1,children:(0,me.Y)(Ve,{"data-ui-anchor":"chart",className:"chart-container",height:t,width:l,children:u?this.renderSpinner(c):this.renderChartContainer()})}):(0,me.Y)(b.p,{size:"large",title:(0,d.t)("Your chart is ready to go!"),description:(0,me.FD)("span",{children:[(0,d.t)('Click on "Create chart" button in the control panel on the left to preview a visualization or')," ",(0,me.Y)("span",{role:"button",tabIndex:0,onClick:this.props.onQuery,children:(0,d.t)("click here")}),"."]}),image:"chart.svg"})}}Qe.defaultProps=je;const Ke=Qe,Xe=(0,o.Ng)(null,(function(e){return{actions:(0,i.zH)({...a,updateDataMask:H.Mv,logEvent:s.logEvent},e)}}))(Ke)},90422:(e,t,n)=>{n.d(t,{A:()=>s});var r=n(95483),o=n(71191),i=n(2511);const a=[...r.Wy].map((e=>r.nS[e].operation));class s{constructor(e){var t;this.expressionType=e.expressionType||i.A.Simple,this.expressionType===i.A.Simple?(this.subject=e.subject,this.operator=null==(t=e.operator)?void 0:t.toUpperCase(),this.operatorId=e.operatorId,this.comparator=e.comparator,[r.ux.IsTrue,r.ux.IsFalse].indexOf(e.operatorId)>=0&&(this.comparator=e.operatorId===r.ux.IsTrue),[r.ux.IsNull,r.ux.IsNotNull].indexOf(e.operatorId)>=0&&(this.comparator=null),this.clause=e.clause||i.v.Where,this.sqlExpression=null):this.expressionType===i.A.Sql&&(this.sqlExpression="string"==typeof e.sqlExpression?e.sqlExpression:(0,o.e)(e,{useSimple:!0}),this.clause=e.clause,e.operator&&a.indexOf(e.operator)>=0?(this.subject=e.subject,this.operator=e.operator,this.operatorId=e.operatorId):(this.subject=null,this.operator=null),this.comparator=null),this.isExtra=!!e.isExtra,this.isNew=!!e.isNew,this.datasourceWarning=!!e.datasourceWarning,this.filterOptionName=e.filterOptionName||`filter_${Math.random().toString(36).substring(2,15)}_${Math.random().toString(36).substring(2,15)}`}duplicateWith(e){return new s({...this,isNew:!1,...e})}equals(e){return e.clause===this.clause&&e.expressionType===this.expressionType&&e.sqlExpression===this.sqlExpression&&e.operator===this.operator&&e.operatorId===this.operatorId&&e.comparator===this.comparator&&e.subject===this.subject}isValid(){const e=[r.ux.IsNotNull,r.ux.IsNull].map((e=>r.nS[e].operation)),t=[r.ux.IsTrue,r.ux.IsFalse].map((e=>r.nS[e].operation));if(this.expressionType===i.A.Simple){if(e.indexOf(this.operator)>=0)return!(!this.operator||!this.subject);if(t.indexOf(this.operator)>=0)return!(!this.subject||null===this.comparator);if(this.operator&&this.subject&&this.clause)if(Array.isArray(this.comparator)){if(this.comparator.length>0)return!0}else if(null!==this.comparator)return!0}else if(this.expressionType===i.A.Sql)return!(!this.sqlExpression||!this.clause);return!1}getDefaultLabel(){const e=this.translateToSql();return e.length<43?e:`${e.substring(0,40)}...`}getTooltipTitle(){return this.translateToSql()}translateToSql(){return(0,o.e)(this)}}},25671:(e,t,n)=>{n.d(t,{A:()=>N});var r=n(96540),o=n(5556),i=n.n(o),a=n(35742),s=n(5362),l=n(95579),d=n(62952),c=n(98837),u=n(50317),h=n(8901),p=n(32291),m=n(17093),g=n(95483),v=n(84064),b=n(72652),f=n(12249),y=n(85861),x=n(8972),C=n(28254),S=n(59638),A=n(2445);function w({adhocFilter:e,options:t,datasource:n,onFilterEdit:r,onRemoveFilter:o,partitionColumn:i,onMoveLabel:a,onDropLabel:s,index:l,sections:d,operators:c}){const{actualTimeRange:u,title:h}=(0,S.K)(e);return(0,A.Y)(x.A,{sections:d,operators:c,adhocFilter:e,options:t,datasource:n,onFilterEdit:r,partitionColumn:i,children:(0,A.Y)(b.Px,{label:null!=u?u:e.getDefaultLabel(),tooltipTitle:null!=h?h:e.getTooltipTitle(),onRemove:o,onMoveLabel:a,onDropLabel:s,index:l,type:C.S.FilterOption,withCaret:!0,isExtra:e.isExtra})})}var T=n(90422),D=n(2511);const _=i().oneOfType([i().shape({expressionType:i().oneOf([D.A.Simple]).isRequired,clause:i().oneOf([D.v.Having,D.v.Where]).isRequired,subject:i().string.isRequired,comparator:i().oneOfType([i().string,i().arrayOf(i().string)]).isRequired}),i().shape({expressionType:i().oneOf([D.A.Sql]).isRequired,clause:i().oneOf([D.v.Where,D.v.Having]).isRequired,sqlExpression:i().string.isRequired})]);var Y=n(21062),F=n(32132);const{warning:I}=y.Ay,$=i().oneOfType([i().string,h.A]),E={label:i().oneOfType([i().object,i().string]),name:i().string,sections:i().arrayOf(i().string),operators:i().arrayOf(i().string),onChange:i().func,value:i().arrayOf(_),datasource:i().object,columns:i().arrayOf(Y.A),savedMetrics:i().arrayOf(p.A),selectedMetrics:i().oneOfType([$,i().arrayOf($)]),isLoading:i().bool,canDelete:i().func};function M(e){return e&&!(e instanceof T.A)&&e.expressionType}class R extends r.Component{constructor(e){super(e),this.optionsForSelect=this.optionsForSelect.bind(this),this.onRemoveFilter=this.onRemoveFilter.bind(this),this.onNewFilter=this.onNewFilter.bind(this),this.onFilterEdit=this.onFilterEdit.bind(this),this.moveLabel=this.moveLabel.bind(this),this.onChange=this.onChange.bind(this),this.mapOption=this.mapOption.bind(this),this.getMetricExpression=this.getMetricExpression.bind(this),this.removeFilter=this.removeFilter.bind(this);const t=(this.props.value||[]).map((e=>M(e)?new T.A(e):e));this.optionRenderer=e=>(0,A.Y)(v.A,{option:e}),this.valueRenderer=(e,t)=>(0,A.Y)(w,{index:t,adhocFilter:e,onFilterEdit:this.onFilterEdit,options:this.state.options,sections:this.props.sections,operators:this.props.operators,datasource:this.props.datasource,onRemoveFilter:e=>{e.stopPropagation(),this.onRemoveFilter(t)},onMoveLabel:this.moveLabel,onDropLabel:()=>this.props.onChange(this.state.values),partitionColumn:this.state.partitionColumn},t),this.state={values:t,options:this.optionsForSelect(this.props),partitionColumn:null}}componentDidMount(){const{datasource:e}=this.props;if(e&&"table"===e.type){var t;const n=null==(t=e.database)?void 0:t.id,{datasource_name:r,catalog:o,schema:i,is_sqllab_view:l}=e;!l&&n&&r&&i&&a.A.get({endpoint:`/api/v1/database/${n}/table_metadata/extra/${(0,F.zJ)({name:r,catalog:o,schema:i})}`}).then((({json:e})=>{if(e&&e.partitions){const{partitions:t}=e;t&&t.cols&&1===Object.keys(t.cols).length&&this.setState({partitionColumn:t.cols[0]})}})).catch((e=>{s.A.error("fetch extra_table_metadata:",e.statusText)}))}}UNSAFE_componentWillReceiveProps(e){this.props.columns!==e.columns&&this.setState({options:this.optionsForSelect(e)}),this.props.value!==e.value&&this.setState({values:(e.value||[]).map((e=>M(e)?new T.A(e):e))})}removeFilter(e){const t=[...this.state.values];t.splice(e,1),this.setState((e=>({...e,values:t}))),this.props.onChange(t)}onRemoveFilter(e){const{canDelete:t}=this.props,{values:n}=this.state,r=null==t?void 0:t(n[e],n);"string"!=typeof r?this.removeFilter(e):I({title:(0,l.t)("Warning"),content:r})}onNewFilter(e){const t=this.mapOption(e);t&&this.setState((e=>({...e,values:[...e.values,t]})),(()=>{this.props.onChange(this.state.values)}))}onFilterEdit(e){this.props.onChange(this.state.values.map((t=>t.filterOptionName===e.filterOptionName?e:t)))}onChange(e){const t=(e||[]).map((e=>this.mapOption(e))).filter((e=>e));this.props.onChange(t)}getMetricExpression(e){return this.props.savedMetrics.find((t=>t.metric_name===e)).expression}moveLabel(e,t){const{values:n}=this.state,r=[...n];[r[t],r[e]]=[r[e],r[t]],this.setState({values:r})}mapOption(e){return e instanceof T.A?e:e.saved_metric_name?new T.A({expressionType:D.A.Sql,subject:this.getMetricExpression(e.saved_metric_name),operator:g.nS[g.ux.GreaterThan].operation,comparator:0,clause:D.v.Having}):e.label?new T.A({expressionType:D.A.Sql,subject:new m.A(e).translateToSql(),operator:g.nS[g.ux.GreaterThan].operation,comparator:0,clause:D.v.Having}):e.column_name?new T.A({expressionType:D.A.Simple,subject:e.column_name,operator:g.nS[g.ux.Equals].operation,comparator:"",clause:D.v.Where,isNew:!0}):null}optionsForSelect(e){return[...e.columns,...(0,d.A)(e.selectedMetrics).map((e=>e&&("string"==typeof e?{saved_metric_name:e}:new m.A(e))))].filter((e=>e)).reduce(((e,t)=>(t.saved_metric_name?e.push({...t,filterOptionName:t.saved_metric_name}):t.column_name?e.push({...t,filterOptionName:`_col_${t.column_name}`}):t instanceof m.A&&e.push({...t,filterOptionName:`_adhocmetric_${t.label}`}),e)),[]).sort(((e,t)=>(e.saved_metric_name||e.column_name||e.label).localeCompare(t.saved_metric_name||t.column_name||t.label)))}addNewFilterPopoverTrigger(e){return(0,A.Y)(x.A,{operators:this.props.operators,sections:this.props.sections,adhocFilter:new T.A({}),datasource:this.props.datasource,options:this.state.options,onFilterEdit:this.onNewFilter,partitionColumn:this.state.partitionColumn,children:e})}render(){const{theme:e}=this.props;return(0,A.FD)("div",{className:"metrics-select",children:[(0,A.FD)(b.B3,{children:[(0,A.Y)(u.A,{...this.props}),this.addNewFilterPopoverTrigger((0,A.Y)(b.XB,{children:(0,A.Y)(f.A.PlusLarge,{iconSize:"s",iconColor:e.colors.grayscale.light5})}))]}),(0,A.Y)(b.p6,{children:this.state.values.length>0?this.state.values.map(((e,t)=>this.valueRenderer(e,t))):this.addNewFilterPopoverTrigger((0,A.FD)(b.JG,{children:[(0,A.Y)(f.A.PlusSmall,{iconColor:e.colors.grayscale.light1}),(0,l.t)("Add filter")]}))})]})}}R.propTypes=E,R.defaultProps={name:"",onChange:()=>{},columns:[],savedMetrics:[],selectedMetrics:[]};const N=(0,c.b)(R)},21062:(e,t,n)=>{n.d(t,{A:()=>i});var r=n(5556),o=n.n(r);const i=o().shape({column_name:o().string.isRequired,type:o().string})},17093:(e,t,n)=>{n.d(t,{A:()=>s,t:()=>o});var r=n(95483);const o={SIMPLE:"SIMPLE",SQL:"SQL"};function i(e){if(e.sqlExpression&&r.Vw.test(e.sqlExpression)){const t=e.sqlExpression.indexOf(")"),n=e.sqlExpression.substring(0,t).lastIndexOf("(");if(t>0&&n>0)return e.sqlExpression.substring(n+1,t)}return null}function a(e){if(e.sqlExpression&&r.Vw.test(e.sqlExpression)){const t=e.sqlExpression.indexOf("(");if(t>0)return e.sqlExpression.substring(0,t)}return null}class s{constructor(e){if(this.expressionType=e.expressionType||o.SIMPLE,this.expressionType===o.SIMPLE){const t=i(e);this.column=e.column||t&&{column_name:t},this.aggregate=e.aggregate||a(e),this.sqlExpression=null}else this.expressionType===o.SQL&&(this.sqlExpression=e.sqlExpression,this.column=null,this.aggregate=null);this.datasourceWarning=!!e.datasourceWarning,this.hasCustomLabel=!(!e.hasCustomLabel||!e.label),this.label=this.hasCustomLabel?e.label:this.getDefaultLabel(),this.optionName=e.optionName||`metric_${Math.random().toString(36).substring(2,15)}_${Math.random().toString(36).substring(2,15)}`}getDefaultLabel(){return this.translateToSql({useVerboseName:!0})}translateToSql(e={useVerboseName:!1,transformCountDistinct:!1}){if(this.expressionType===o.SIMPLE){var t,n;const o=this.aggregate||"",i=e.useVerboseName&&null!=(t=this.column)&&t.verbose_name?`(${this.column.verbose_name})`:null!=(n=this.column)&&n.column_name?`(${this.column.column_name})`:"";return e.transformCountDistinct&&o===r.dq.COUNT_DISTINCT&&/^\(.*\)$/.test(i)?`COUNT(DISTINCT ${i.slice(1,-1)})`:o+i}return this.expressionType===o.SQL?this.sqlExpression:""}duplicateWith(e){return new s({...this,...e})}equals(e){return e.label===this.label&&e.expressionType===this.expressionType&&e.sqlExpression===this.sqlExpression&&e.aggregate===this.aggregate&&(e.column&&e.column.column_name)===(this.column&&this.column.column_name)}isValid(){return this.expressionType===o.SIMPLE?!(!this.column||!this.aggregate):this.expressionType===o.SQL&&!!this.sqlExpression}inferSqlExpressionAggregate(){return a(this)}inferSqlExpressionColumn(){return i(this)}}},84064:(e,t,n)=>{n.d(t,{A:()=>c});var r=n(5556),o=n.n(r),i=n(74792),a=n(8901),s=n(84080),l=n(2445);const d={option:o().oneOfType([i.A,o().shape({saved_metric_name:o().string.isRequired}),a.A]).isRequired};function c({option:e}){return e.saved_metric_name?(0,l.Y)(s.V,{column:{column_name:e.saved_metric_name,type:"expression"},showType:!0}):e.column_name?(0,l.Y)(s.V,{column:e,showType:!0}):e.label?(0,l.Y)(s.V,{column:{column_name:e.label,type:"expression"},showType:!0}):null}c.propTypes=d},8901:(e,t,n)=>{n.d(t,{A:()=>l});var r=n(5556),o=n.n(r),i=n(95483),a=n(74792),s=n(17093);const l=o().oneOfType([o().shape({expressionType:o().oneOf([s.t.SIMPLE]).isRequired,column:a.A.isRequired,aggregate:o().oneOf(Object.keys(i.dq)).isRequired,label:o().string.isRequired}),o().shape({expressionType:o().oneOf([s.t.SQL]).isRequired,sqlExpression:o().string.isRequired,label:o().string.isRequired})])},74792:(e,t,n)=>{n.d(t,{A:()=>i});var r=n(5556),o=n.n(r);const i=o().shape({column_name:o().string.isRequired,type:o().string})},32291:(e,t,n)=>{n.d(t,{A:()=>i});var r=n(5556),o=n.n(r);const i=o().shape({metric_name:o().string,verbose_name:o().string,expression:o().string})},15700:(e,t,n)=>{n.d(t,{t3:()=>W,oU:()=>V});var r=n(96540),o=n(61225),i=n(93641),a=n(96453),s=n(17437),l=n(95579),d=n(27366),c=n(12249),u=n(6749),h=n(18301),p=n(46920),m=n(5261),g=n(85183),v=n(72965),b=n(32132),f=n(73135),y=n(32850),x=n(7735),C=n(35700),S=n(17432),A=n(90868),w=n(19966),T=n(27023),D=n(39091),_=n(2445);const Y=(0,a.I4)(D.i8)`
  && {
    margin: 0 0 ${({theme:e})=>e.gridUnit}px;
  }
`,F=({formData:e,addDangerToast:t})=>{const[n,o]=(0,r.useState)("400"),[i,a]=(0,r.useState)("600"),[d,c]=(0,r.useState)(""),[u,h]=(0,r.useState)(""),p=(0,r.useCallback)((e=>{const{value:t,name:n}=e.currentTarget;"width"===n&&a(t),"height"===n&&o(t)}),[]),m=(0,r.useCallback)((()=>{c(""),(0,b.Kx)(e).then((e=>{c(e),h("")})).catch((()=>{h((0,l.t)("Error")),t((0,l.t)("Sorry, something went wrong. Try again later."))}))}),[t,e]);(0,r.useEffect)((()=>{m()}),[]);const g=(0,r.useMemo)((()=>{if(!d)return"";const e=`${d}?${T.vX.standalone.name}=1&height=${n}`;return`<iframe\n  width="${i}"\n  height="${n}"\n  seamless\n  frameBorder="0"\n  scrolling="no"\n  src="${e}"\n>\n</iframe>`}),[n,d,i]),v=u||g||(0,l.t)("Generating link, please wait..");return(0,_.FD)("div",{id:"embed-code-popover",children:[(0,_.FD)("div",{css:s.AH`
          display: flex;
          flex-direction: column;
        `,children:[(0,_.Y)(w.A,{shouldShowText:!1,text:g,copyNode:(0,_.Y)(Y,{buttonSize:"xsmall",children:(0,_.Y)("i",{className:"fa fa-clipboard"})})}),(0,_.Y)(A.fs,{name:"embedCode",disabled:!g,value:v,rows:"4",readOnly:!0,css:e=>s.AH`
            resize: vertical;
            padding: ${2*e.gridUnit}px;
            font-size: ${e.typography.sizes.s}px;
            border-radius: 4px;
            background-color: ${e.colors.secondary.light5};
          `})]}),(0,_.FD)("div",{css:e=>s.AH`
          display: flex;
          margin-top: ${4*e.gridUnit}px;
          & > div {
            margin-right: ${2*e.gridUnit}px;
          }
          & > div:last-of-type {
            margin-right: 0;
            margin-left: ${2*e.gridUnit}px;
          }
        `,children:[(0,_.FD)("div",{children:[(0,_.Y)("label",{htmlFor:"embed-height",children:(0,l.t)("Chart height")}),(0,_.Y)(A.pd,{type:"text",defaultValue:n,name:"height",onChange:p})]}),(0,_.FD)("div",{children:[(0,_.Y)("label",{htmlFor:"embed-width",children:(0,l.t)("Chart width")}),(0,_.Y)(A.pd,{type:"text",defaultValue:i,name:"width",onChange:p,id:"embed-width"})]})]})]})};var I=n(71519);const $=({chartId:e,dashboards:t=[],...n})=>{const o=(0,a.DP)(),[i,d]=(0,r.useState)(),[h,p]=(0,r.useState)(),m=t.length>10,g=t.filter((e=>!i||e.dashboard_title.toLowerCase().includes(i.toLowerCase()))),v=0===t.length,b=i&&0===g.length,f=e?`?focused_chart=${e}`:"";return(0,_.FD)(_.FK,{children:[m&&(0,_.Y)(A.pd,{allowClear:!0,placeholder:(0,l.t)("Search"),prefix:(0,_.Y)(c.A.Search,{iconSize:"l"}),css:s.AH`
            width: ${220}px;
            margin: ${2*o.gridUnit}px ${3*o.gridUnit}px;
          `,value:i,onChange:e=>d(e.currentTarget.value)}),(0,_.FD)("div",{css:s.AH`
          max-height: ${300}px;
          overflow: auto;
        `,children:[g.map((e=>(0,_.Y)(u.W1.Item,{onMouseEnter:()=>p(e.id),onMouseLeave:()=>{h===e.id&&p(null)},...n,children:(0,_.Y)(I.N_,{target:"_blank",rel:"noreferer noopener",to:`/superset/dashboard/${e.id}${f}`,children:(0,_.FD)("div",{css:s.AH`
                  display: flex;
                  flex-direction: row;
                  align-items: center;
                  max-width: ${220}px;
                `,children:[(0,_.Y)("div",{css:s.AH`
                    white-space: normal;
                  `,children:e.dashboard_title}),(0,_.Y)(c.A.Full,{iconSize:"l",iconColor:o.colors.grayscale.base,css:s.AH`
                    margin-left: ${2*o.gridUnit}px;
                    visibility: ${h===e.id?"visible":"hidden"};
                  `})]})})},String(e.id)))),b&&(0,_.Y)("div",{css:s.AH`
              margin-left: ${3*o.gridUnit}px;
              margin-bottom: ${o.gridUnit}px;
            `,children:(0,l.t)("No results found")}),v&&(0,_.Y)(u.W1.Item,{disabled:!0,css:s.AH`
              min-width: ${220}px;
            `,...n,children:(0,l.t)("None")})]})]})},E="edit_properties",M="export_to_csv",R="export_to_csv_pivoted",N="export_to_json",k="export_to_xlsx",O="download_as_image",U="copy_permalink",q="embed_code",L="share_by_email",z="view_query",H="run_in_sql_lab",P=[i.Y.PivotTable],W=a.I4.div`
  ${({theme:e})=>s.AH`
    display: flex;
    align-items: center;

    & svg {
      width: ${3*e.gridUnit}px;
      height: ${3*e.gridUnit}px;
    }

    & span[role='checkbox'] {
      display: inline-flex;
      margin-right: ${e.gridUnit}px;
    }
  `}
`,j=((0,a.I4)(p.A)`
  ${({theme:e})=>s.AH`
    width: ${8*e.gridUnit}px;
    height: ${8*e.gridUnit}px;
    padding: 0;
    border: 1px solid ${e.colors.primary.dark2};

    &.antd5-btn > span.anticon {
      line-height: 0;
      transition: inherit;
    }

    &:hover:not(:focus) > span.anticon {
      color: ${e.colors.primary.light1};
    }
  `}
`,s.AH`
  .ant-dropdown-menu-item > & > .anticon:first-child {
    margin-right: 0;
    vertical-align: 0;
  }
`),V=(e,t,n,i,s,p,A,...w)=>{const T=(0,a.DP)(),{addDangerToast:D,addSuccessToast:Y}=(0,m.Yf)(),I=(0,o.wA)(),[W,V]=(0,r.useState)(null),[B,G]=(0,r.useState)(!1),Q=(0,o.d4)((e=>{var t;return null==(t=e.charts)?void 0:t[(0,g.kD)(e.explore)]})),{datasource:K}=e,X=(0,r.useCallback)((async()=>{try{const t=(0,l.t)("Superset Chart"),n=await(0,b.Kx)(e),r=encodeURIComponent((0,l.t)("%s%s","Check out this chart: ",n));window.location.href=`mailto:?Subject=${t}%20&Body=${r}`}catch(e){D((0,l.t)("Sorry, something went wrong. Try again later."))}}),[D,e]),J=(0,r.useCallback)((()=>t?(0,g.RY)({formData:e,ownState:p,resultType:"full",resultFormat:"csv"}):null),[t,e]),Z=(0,r.useCallback)((()=>t?(0,g.RY)({formData:e,resultType:"post_processed",resultFormat:"csv"}):null),[t,e]),ee=(0,r.useCallback)((()=>t?(0,g.RY)({formData:e,resultType:"results",resultFormat:"json"}):null),[t,e]),te=(0,r.useCallback)((()=>t?(0,g.RY)({formData:e,resultType:"results",resultFormat:"xlsx"}):null),[t,e]),ne=(0,r.useCallback)((async()=>{try{if(!e)throw new Error;await(0,f.A)((()=>(0,b.Kx)(e))),Y((0,l.t)("Copied to clipboard!"))}catch(e){D((0,l.t)("Sorry, something went wrong. Try again later."))}}),[D,Y,e]),re=(0,r.useCallback)((({key:t,domEvent:r})=>{var o;switch(t){case E:s(),G(!1);break;case M:J(),G(!1),I((0,x.logEvent)(C.xb,{chartId:null==n?void 0:n.slice_id,chartName:null==n?void 0:n.slice_name}));break;case R:Z(),G(!1),I((0,x.logEvent)(C.vp,{chartId:null==n?void 0:n.slice_id,chartName:null==n?void 0:n.slice_name}));break;case N:ee(),G(!1),I((0,x.logEvent)(C.v2,{chartId:null==n?void 0:n.slice_id,chartName:null==n?void 0:n.slice_name}));break;case k:te(),G(!1),I((0,x.logEvent)(C.k8,{chartId:null==n?void 0:n.slice_id,chartName:null==n?void 0:n.slice_name}));break;case O:(0,v.A)(".panel-body .chart-container",null!=(o=null==n?void 0:n.slice_name)?o:(0,l.t)("New chart"),!0)(r),G(!1),I((0,x.logEvent)(C.C7,{chartId:null==n?void 0:n.slice_id,chartName:null==n?void 0:n.slice_name}));break;case U:ne(),G(!1);break;case q:G(!1);break;case L:X(),G(!1);break;case z:G(!1);break;case H:i(e,r.metaKey),G(!1)}}),[ne,J,Z,ee,e,i,s,X,null==n?void 0:n.slice_name]);return[(0,r.useMemo)((()=>(0,_.FD)(u.W1,{onClick:re,selectable:!1,...w,children:[(0,_.FD)(_.FK,{children:[n&&(0,_.Y)(u.W1.Item,{children:(0,l.t)("Edit chart properties")},E),(0,_.Y)(u.W1.SubMenu,{title:(0,l.t)("On dashboards"),children:(0,_.Y)($,{chartId:null==n?void 0:n.slice_id,dashboards:A})},"dashboards_added_to"),(0,_.Y)(u.W1.Divider,{})]}),(0,_.FD)(u.W1.SubMenu,{title:(0,l.t)("Download"),children:[P.includes(e.viz_type)?(0,_.FD)(_.FK,{children:[(0,_.Y)(u.W1.Item,{icon:(0,_.Y)(c.A.FileOutlined,{css:j}),disabled:!t,children:(0,l.t)("Export to original .CSV")},M),(0,_.Y)(u.W1.Item,{icon:(0,_.Y)(c.A.FileOutlined,{css:j}),disabled:!t,children:(0,l.t)("Export to pivoted .CSV")},R)]}):(0,_.Y)(u.W1.Item,{icon:(0,_.Y)(c.A.FileOutlined,{css:j}),disabled:!t,children:(0,l.t)("Export to .CSV")},M),(0,_.Y)(u.W1.Item,{icon:(0,_.Y)(c.A.FileOutlined,{css:j}),disabled:!t,children:(0,l.t)("Export to .JSON")},N),(0,_.Y)(u.W1.Item,{icon:(0,_.Y)(c.A.FileImageOutlined,{css:j}),children:(0,l.t)("Download as image")},O),(0,_.Y)(u.W1.Item,{icon:(0,_.Y)(c.A.FileOutlined,{css:j}),disabled:!t,children:(0,l.t)("Export to Excel")},k)]},"download_submenu"),(0,_.FD)(u.W1.SubMenu,{title:(0,l.t)("Share"),children:[(0,_.Y)(u.W1.Item,{children:(0,l.t)("Copy permalink to clipboard")},U),(0,_.Y)(u.W1.Item,{children:(0,l.t)("Share chart by email")},L),(0,d.G7)(d.TO.EmbeddableCharts)?(0,_.Y)(u.W1.Item,{children:(0,_.Y)(h.A,{triggerNode:(0,_.Y)("div",{children:(0,l.t)("Embed code")}),modalTitle:(0,l.t)("Embed code"),modalBody:(0,_.Y)(F,{formData:e,addDangerToast:D}),maxWidth:100*T.gridUnit+"px",destroyOnClose:!0,responsive:!0})},q):null]},"share_submenu"),(0,_.Y)(u.W1.Divider,{}),W?(0,_.FD)(_.FK,{children:[(0,_.Y)(u.W1.SubMenu,{title:(0,l.t)("Manage email report"),children:(0,_.Y)(y.A,{chart:Q,setShowReportSubMenu:V,showReportSubMenu:W,setIsDropdownVisible:G,isDropdownVisible:B,useTextMenu:!0})}),(0,_.Y)(u.W1.Divider,{})]}):(0,_.Y)(u.W1,{children:(0,_.Y)(y.A,{chart:Q,setShowReportSubMenu:V,setIsDropdownVisible:G,isDropdownVisible:B,useTextMenu:!0})}),(0,_.Y)(u.W1.Item,{children:(0,_.Y)(h.A,{triggerNode:(0,_.Y)("div",{children:(0,l.t)("View query")}),modalTitle:(0,l.t)("View query"),modalBody:(0,_.Y)(S.A,{latestQueryFormData:e}),draggable:!0,resizable:!0,responsive:!0})},z),K&&(0,_.Y)(u.W1.Item,{children:(0,l.t)("Run in SQL Lab")},H)]})),[D,t,Q,A,re,B,e,W,n,T.gridUnit]),B,G]}},28274:(e,t,n)=>{n.d(t,{A:()=>o});var r=n(67553);const o=["AND","AS","ASC","AVG","BY","CASE","COUNT","CREATE","CROSS","DATABASE","DEFAULT","DELETE","DESC","DISTINCT","DROP","ELSE","END","FOREIGN","FROM","GRANT","GROUP","HAVING","IF","INNER","INSERT","JOIN","KEY","LEFT","LIMIT","MAX","MIN","NATURAL","NOT","NULL","OFFSET","ON","OR","ORDER","OUTER","PRIMARY","REFERENCES","RIGHT","SELECT","SUM","TABLE","THEN","TYPE","UNION","UPDATE","WHEN","WHERE"].concat(["BIGINT","BINARY","BIT","CHAR","DATE","DECIMAL","DOUBLE","FLOAT","INT","INTEGER","MONEY","NUMBER","NUMERIC","REAL","SET","TEXT","TIMESTAMP","VARCHAR"]).map((e=>({meta:"sql",name:e,score:r.lI,value:e})))},67429:(e,t,n)=>{n.d(t,{C:()=>s});var r=n(17437),o=n(12249),i=n(19129),a=n(2445);const s=({title:e,color:t})=>(0,a.Y)(i.m,{title:e,placement:"top",children:(0,a.Y)(o.A.InfoCircleOutlined,{css:e=>r.AH`
        color: ${t||e.colors.text.label};
        margin-left: ${2*e.gridUnit}px;
        &.anticon {
          font-size: unset;
          .anticon {
            line-height: unset;
            vertical-align: unset;
          }
        }
      `})})},29356:(e,t,n)=>{n.d(t,{A:()=>B});var r=n(96540),o=n(61574),i=n(96453),a=n(95579),s=n(17437),l=n(85861),d=n(46920),c=n(61225),u=n(94229),h=n(84666),p=n(87903),m=n(62952),g=n(98250),v=n(17444),b=n(27023),f=n(2445);const y=function({value:e}){return(0,f.Y)("span",{children:e?b.bU:b.y2})},x=i.I4.span`
  color: ${({theme:e})=>e.colors.grayscale.light1};
`,C=function(){return(0,f.Y)(x,{children:b.bV})};var S=n(85170),A=n(7349);const w=function({format:e=S.A.DATABASE_DATETIME,value:t}){return t?(0,f.Y)("span",{children:(0,A.mo)(e).format(t)}):(0,f.Y)(C,{})};var T=n(50455),D=n(2514),_=n(51003),Y=n(69193),F=n(12249),I=n(10044);const $=function(e){const{headerTitle:t,groupTitle:n,groupOptions:o,value:a,onChange:l}=e,d=(0,i.DP)(),[c,u]=(0,r.useState)(!1);return(0,f.FD)("div",{css:s.AH`
        display: flex;
        align-items: center;
      `,children:[(0,f.Y)(I.A,{trigger:"click",visible:c,content:(0,f.FD)("div",{children:[(0,f.Y)("div",{css:s.AH`
                font-weight: ${d.typography.weights.bold};
                margin-bottom: ${d.gridUnit}px;
              `,children:n}),(0,f.Y)(Y.s.GroupWrapper,{spaceConfig:{direction:"vertical",size:4,wrap:!1,align:"start"},value:a,onChange:e=>{l(e.target.value),u(!1)},options:o})]}),placement:"bottomLeft",arrowPointAtCenter:!0,children:(0,f.Y)(F.A.SettingOutlined,{iconSize:"m",iconColor:d.colors.grayscale.light1,css:s.AH`
            margin-top: 3px; // we need exactly 3px to align the icon
            margin-right: ${d.gridUnit}px;
          `,onClick:()=>u(!0)})}),t]})};var E=n(86274),M=n(55976),R=n(66270),N=n(70700),k=n(26761);function O({filters:e,setFilters:t,totalCount:n,loading:o,onReload:l}){const d=(0,i.DP)(),c=(0,r.useMemo)((()=>Object.assign({},...e.map((e=>({[(0,N.q0)(e.col)?e.col.label:e.col]:e}))))),[e]),u=(0,r.useCallback)((e=>{const n={...c};delete n[e],t([...Object.values(n)])}),[c,t]),h=(0,r.useMemo)((()=>Object.entries(c).map((([e,{val:t,formattedVal:n}])=>({colName:e,val:null!=n?n:t}))).sort(((e,t)=>e.colName.localeCompare(t.colName)))),[c]);return(0,f.FD)("div",{css:s.AH`
        display: flex;
        justify-content: space-between;
        padding: ${d.gridUnit/2}px 0;
        margin-bottom: ${2*d.gridUnit}px;
      `,children:[(0,f.Y)("div",{css:s.AH`
          display: flex;
          flex-wrap: wrap;
          margin-bottom: -${4*d.gridUnit}px;
        `,children:h.map((({colName:e,val:t})=>(0,f.FD)(R.A,{closable:!0,onClose:u.bind(null,e),css:s.AH`
              height: ${6*d.gridUnit}px;
              display: flex;
              align-items: center;
              padding: ${d.gridUnit/2}px ${2*d.gridUnit}px;
              margin-right: ${4*d.gridUnit}px;
              margin-bottom: ${4*d.gridUnit}px;
              line-height: 1.2;
            `,children:[(0,f.Y)("span",{css:s.AH`
                margin-right: ${d.gridUnit}px;
              `,children:e}),(0,f.Y)("strong",{children:t})]},e)))}),(0,f.FD)("div",{css:s.AH`
          display: flex;
          align-items: center;
          height: min-content;
        `,children:[(0,f.Y)(k.A,{loading:o&&!n,rowcount:n}),(0,f.Y)(F.A.ReloadOutlined,{iconColor:d.colors.grayscale.light1,iconSize:"l","aria-label":(0,a.t)("Reload"),role:"button",onClick:l})]})]})}var U=n(90179),q=n.n(U),L=n(26632);const z=50;var H,P={name:"82a6rk",styles:"flex:1"};function W({children:e}){const{ref:t,height:n}=(0,g.uZ)();return(0,f.Y)("div",{ref:t,css:P,children:(0,r.cloneElement)(e,{height:n})})}function j({formData:e,initialFilters:t}){var n;const o=(0,i.DP)(),[l,d]=(0,r.useState)(0),u=(0,r.useRef)(l),[h,g]=(0,r.useState)(t),[b,x]=(0,r.useState)(!1),[S,A]=(0,r.useState)(""),[Y,F]=(0,r.useState)(new Map),[I,R]=(0,r.useState)({}),N=(0,c.d4)((e=>e.common.conf.SAMPLES_ROW_LIMIT)),[k,U]=(0,r.useMemo)((()=>e.datasource.split("__")),[e.datasource]),{metadataBar:P,status:j}=(0,M.M)({datasetId:k}),V=(0,r.useMemo)((()=>{const e=Y.get(l);return e?(u.current=l,e):Y.get(u.current)}),[l,Y]),B=(0,r.useMemo)((()=>(null==V?void 0:V.colNames.map(((e,t)=>({key:e,dataIndex:e,title:(null==V?void 0:V.colTypes[t])===p.s.Temporal?(0,f.Y)($,{headerTitle:e,groupTitle:(0,a.t)("Formatting"),groupOptions:[{label:(0,a.t)("Original value"),value:H.Original},{label:(0,a.t)("Formatted value"),value:H.Formatted}],value:I[e]===H.Original?H.Original:H.Formatted,onChange:t=>R((n=>({...n,[e]:parseInt(t,10)})))}):e,render:n=>!0===n||!1===n?(0,f.Y)(y,{value:n}):null===n?(0,f.Y)(C,{}):(null==V?void 0:V.colTypes[t])===p.s.Temporal&&I[e]!==H.Original&&("number"==typeof n||n instanceof Date)?(0,f.Y)(w,{value:n}):String(n),width:150}))))||[]),[null==V?void 0:V.colNames,null==V?void 0:V.colTypes,I]),G=(0,r.useMemo)((()=>(null==V?void 0:V.data.map(((e,t)=>null==V?void 0:V.colNames.reduce(((t,n)=>({...t,[n]:e[n]})),{key:t}))))||[]),[null==V?void 0:V.colNames,null==V?void 0:V.data]),Q=(0,r.useCallback)((()=>{A(""),F(new Map),d(0)}),[]);(0,r.useEffect)((()=>{A(""),F(new Map),d(0)}),[h]),(0,r.useEffect)((()=>{if(Y.has(l)&&[...Y.keys()].at(-1)!==l){const e=new Map(Y);e.delete(l),F(e.set(l,Y.get(l)))}}),[l,Y]),(0,r.useEffect)((()=>{if(!S&&!b&&!Y.has(l)){var t;x(!0);const n=null!=(t=function(e,t){if(!e)return;const n=(0,L.A)(e),r=q()(n.extras,"having"),o=[...(0,m.A)(n.filters),...(0,m.A)(t).map((e=>q()(e,"formattedVal")))];return{granularity:n.granularity,time_range:n.time_range,filters:o,extras:r}}(e,h))?t:{},r=Math.ceil(N/z);(0,D.getDatasourceSamples)(U,k,!1,n,z,l+1).then((e=>{F(new Map([...[...Y.entries()].slice(1-r),[l,{total:e.total_count,data:e.data,colNames:(0,m.A)(e.colnames),colTypes:(0,m.A)(e.coltypes)}]])),A("")})).catch((e=>{A(`${e.name}: ${e.message}`)})).finally((()=>{x(!1)}))}}),[N,k,U,h,e,b,l,S,Y]);const K=!S&&!Y.size||j===E.bk.Loading,X=null==(n=e.allow_render_html)||n;let J=null;if(S)J=(0,f.Y)("pre",{css:s.AH`
          margin-top: ${4*o.gridUnit}px;
        `,children:S});else if(K)J=(0,f.Y)(v.A,{});else if(0===(null==V?void 0:V.total)){const e=(0,a.t)("No rows were returned for this dataset");J=(0,f.Y)(T.p,{image:"document.svg",title:e})}else J=(0,f.Y)(W,{children:(0,f.Y)(_.Ay,{data:G,columns:B,size:_.QS.Small,defaultPageSize:z,recordCount:null==V?void 0:V.total,usePagination:!0,loading:b,onChange:e=>d(e.current?e.current-1:0),resizable:!0,virtualize:!0,allowHTML:X})});return(0,f.FD)(f.FK,{children:[!K&&P,!K&&(0,f.Y)(O,{filters:h,setFilters:g,totalCount:null==V?void 0:V.total,loading:b,onReload:Q}),J]})}!function(e){e[e.Original=0]="Original",e[e.Formatted=1]="Formatted"}(H||(H={}));const V=({canExplore:e,closeModal:t,exploreChart:n})=>{const r=(0,i.DP)();return(0,f.FD)(f.FK,{children:[(0,f.Y)(d.A,{buttonStyle:"secondary",buttonSize:"small",onClick:n,disabled:!e,tooltip:e?void 0:(0,a.t)("You do not have sufficient permissions to edit the chart"),children:(0,a.t)("Edit chart")}),(0,f.Y)(d.A,{buttonStyle:"primary",buttonSize:"small",onClick:t,css:s.AH`
          margin-left: ${2*r.gridUnit}px;
        `,children:(0,a.t)("Close")})]})};function B({chartId:e,formData:t,initialFilters:n,showModal:d,onHideModal:p}){const m=(0,i.DP)(),g=(0,o.W6)(),v=(0,r.useContext)(u.DashboardPageIdContext),{slice_name:b}=(0,c.d4)((t=>{var n,r;return(null==(n=t.sliceEntities)||null==(r=n.slices)?void 0:r[e])||{}})),y=(0,c.d4)((e=>{var t;return(0,h.L)("can_explore","Superset",null==(t=e.user)?void 0:t.roles)})),x=(0,r.useMemo)((()=>`/explore/?dashboard_page_id=${v}&slice_id=${e}`),[e,v]),C=(0,r.useCallback)((()=>{g.push(x)}),[x,g]);return(0,f.Y)(l.Ay,{show:d,onHide:null!=p?p:()=>null,css:s.AH`
        .antd5-modal-body {
          display: flex;
          flex-direction: column;
        }
      `,title:(0,a.t)("Drill to detail: %s",b),footer:(0,f.Y)(V,{exploreChart:C,canExplore:y}),responsive:!0,resizable:!0,resizableConfig:{minHeight:128*m.gridUnit,minWidth:128*m.gridUnit,defaultSize:{width:"auto",height:"75vh"}},draggable:!0,destroyOnClose:!0,maskClosable:!1,children:(0,f.Y)(j,{formData:t,initialFilters:n})})}},70542:(e,t,n)=>{n.d(t,{k:()=>w});var r=n(62193),o=n.n(r),i=n(96540),a=n(95579),s=n(17437),l=n(58642),d=n(96453),c=n(80145),u=n(58863),h=n(46302),p=n(61225),m=n(6749),g=n(83537),v=n(67429),b=n(28543),f=n(2445);const y=(0,a.t)("Drill to detail"),x=(0,a.t)("Drill to detail by"),C={DATABASE:(0,a.t)("Drill to detail is disabled for this database. Change the database settings to enable it."),NO_AGGREGATIONS:(0,a.t)("Drill to detail is disabled because this chart does not group data by dimension value."),NO_FILTERS:(0,a.t)("Right-click on a dimension value to drill to detail by that value."),NOT_SUPPORTED:(0,a.t)("Drill to detail by value is not yet supported for this chart type.")},S=({children:e,...t})=>(0,f.Y)(m.W1.Item,{disabled:!0,...t,children:(0,f.Y)("div",{css:s.AH`
        white-space: normal;
        max-width: 160px;
      `,children:e})}),A=(0,d.I4)((({children:e,stripHTML:t=!1})=>{const n=t&&"string"==typeof e?(0,l.zF)(e):e;return(0,f.Y)("span",{children:n})}))`
  ${({theme:e})=>`\n     font-weight: ${e.typography.weights.bold};\n     color: ${e.colors.primary.base};\n   `}
`,w=({formData:e,filters:t=[],isContextMenu:n=!1,contextMenuY:r=0,onSelection:l=()=>null,onClick:d=()=>null,submenuIndex:w=0,setFilters:T,setShowModal:D,key:_,...Y})=>{const F=(0,p.d4)((({datasources:t})=>{var n,r;return null==(n=t[e.datasource])||null==(r=n.database)?void 0:r.disable_drill_to_detail})),I=(0,i.useCallback)(((e,t)=>{d(t),l(),T(e),D(!0)}),[d,l]),$=(0,i.useMemo)((()=>{var t;return null==(t=(0,c.A)().get(e.viz_type))?void 0:t.behaviors.find((e=>e===u.nS.DrillToDetail))}),[e.viz_type]),E=(0,i.useMemo)((()=>{const{metrics:t}=(0,h.A)(e);return o()(t)}),[e]),M=(0,i.useMemo)((()=>(0,g.Gs)(r,t.length>1?t.length+1:t.length,w)),[r,t.length,w]);let R,N;F?(R=C.DATABASE,N=C.DATABASE):$?E?(R=C.NO_AGGREGATIONS,N=C.NO_AGGREGATIONS):null!=t&&t.length||(N=C.NO_FILTERS):N=C.NOT_SUPPORTED;const k=R?(0,s.n)(S,{...Y,key:"drill-to-detail-disabled"},y,(0,f.Y)(v.C,{title:R})):(0,s.n)(m.W1.Item,{...Y,key:"drill-to-detail",onClick:I.bind(null,[])},y),O=N?(0,s.n)(S,{...Y,key:"drill-to-detail-by-disabled"},x,(0,f.Y)(v.C,{title:N})):(0,s.n)(m.W1.SubMenu,{...Y,popupOffset:[0,M],popupClassName:"chart-context-submenu",title:x,key:_},(0,f.FD)("div",{children:[t.map(((e,t)=>(0,s.n)(b.o,{...Y,tooltipText:`${x} ${e.formattedVal}`,key:`drill-detail-filter-${t}`,onClick:I.bind(null,[e])},`${x} `,(0,f.Y)(A,{stripHTML:!0,children:e.formattedVal})))),t.length>1&&(0,s.n)(m.W1.Item,{...Y,key:"drill-detail-filter-all",onClick:I.bind(null,t)},(0,f.FD)("div",{children:[`${x} `,(0,f.Y)(A,{stripHTML:!1,children:(0,a.t)("all")})]}))]}));return(0,f.FD)(f.FK,{children:[k,n&&O]})}},28543:(e,t,n)=>{n.d(t,{o:()=>l});var r=n(37827),o=n(17437),i=n(6749),a=n(19129),s=n(2445);const l=({tooltipText:e,children:t,...n})=>{const[l,d]=(0,r.A)();return(0,s.Y)(i.W1.Item,{css:o.AH`
        display: flex;
        line-height: 1.5em;
      `,...n,children:(0,s.Y)(a.m,{title:d?e:null,children:(0,s.Y)("div",{ref:l,css:o.AH`
            max-width: 100%;
            ${r.P};
          `,children:t})})})}},83537:(e,t,n)=>{n.d(t,{Gs:()=>o,x4:()=>r});const r=(e,t,n=Number.MAX_SAFE_INTEGER,r=0)=>{const o=Math.max(document.documentElement.clientHeight||0,window.innerHeight||0),i=Math.min(32*t,n)+32+r;return o-e<i?o-i:e},o=(e,t,n=0,o=Number.MAX_SAFE_INTEGER,i=0)=>{const a=e+4+32*n+4;return r(a,t,o,i)-a}},50068:(e,t,n)=>{n.d(t,{Dj:()=>s.Dj,cp:()=>s.cp,Ay:()=>a});var r=n(96453),o=n(2445);const i=r.I4.span`
  &,
  & svg {
    vertical-align: top;
  }
`;function a({checked:e,onChange:t,style:n,className:r}){return(0,o.Y)(i,{style:n,onClick:()=>{t(!e)},role:"checkbox",tabIndex:0,"aria-checked":e,"aria-label":"Checkbox",className:r||"",children:e?(0,o.Y)(s.Dj,{}):(0,o.Y)(s.cp,{})})}var s=n(75264)},19966:(e,t,n)=>{n.d(t,{A:()=>h});var r=n(96540),o=n(95579),i=n(19129),a=n(5261),s=n(73135),l=n(2445);const d={copyNode:(0,l.Y)("span",{children:(0,o.t)("Copy")}),onCopyEnd:()=>{},shouldShowText:!0,wrapped:!0,tooltipText:(0,o.t)("Copy to clipboard"),hideTooltip:!1};var c={name:"8irbms",styles:"display:inline-flex;align-items:center"};class u extends r.Component{constructor(e){super(e),this.copyToClipboard=this.copyToClipboard.bind(this),this.onClick=this.onClick.bind(this)}onClick(){this.props.getText?this.props.getText((e=>{this.copyToClipboard(Promise.resolve(e))})):this.copyToClipboard(Promise.resolve(this.props.text||""))}getDecoratedCopyNode(){return(0,r.cloneElement)(this.props.copyNode,{style:{cursor:"pointer"},onClick:this.onClick})}copyToClipboard(e){(0,s.A)((()=>e)).then((()=>{this.props.addSuccessToast((0,o.t)("Copied to clipboard!"))})).catch((()=>{this.props.addDangerToast((0,o.t)("Sorry, your browser does not support copying. Use Ctrl / Cmd + C!"))})).finally((()=>{this.props.onCopyEnd&&this.props.onCopyEnd()}))}renderTooltip(e){return(0,l.Y)(l.FK,{children:this.props.hideTooltip?this.getDecoratedCopyNode():(0,l.Y)(i.m,{id:"copy-to-clipboard-tooltip",placement:"topRight",style:{cursor:e},title:this.props.tooltipText||"",trigger:["hover"],arrow:{pointAtCenter:!0},children:this.getDecoratedCopyNode()})})}renderNotWrapped(){return this.renderTooltip("pointer")}renderLink(){return(0,l.FD)("span",{css:c,children:[this.props.shouldShowText&&this.props.text&&(0,l.Y)("span",{className:"m-r-5",children:this.props.text}),this.renderTooltip("pointer")]})}render(){const{wrapped:e}=this.props;return e?this.renderLink():this.renderNotWrapped()}}u.defaultProps=d;const h=(0,a.Ay)(u)},93103:(e,t,n)=>{n.d(t,{R2:()=>m,ms:()=>p});var r=n(96540),o=n(15595),i=n(45572),a=n(96453),s=n(12249),l=n(2445);const d=a.I4.div`
  width: ${({theme:e})=>.75*e.gridUnit}px;
  height: ${({theme:e})=>.75*e.gridUnit}px;
  border-radius: 50%;
  background-color: ${({theme:e})=>e.colors.grayscale.light1};

  font-weight: ${({theme:e})=>e.typography.weights.normal};
  display: inline-flex;
  position: relative;

  &:hover {
    background-color: ${({theme:e})=>e.colors.primary.base};

    &::before,
    &::after {
      background-color: ${({theme:e})=>e.colors.primary.base};
    }
  }

  &::before,
  &::after {
    position: absolute;
    content: ' ';
    width: ${({theme:e})=>.75*e.gridUnit}px;
    height: ${({theme:e})=>.75*e.gridUnit}px;
    border-radius: 50%;
    background-color: ${({theme:e})=>e.colors.grayscale.light1};
  }

  &::before {
    top: ${({theme:e})=>e.gridUnit}px;
  }

  &::after {
    bottom: ${({theme:e})=>e.gridUnit}px;
  }
`,c=a.I4.div`
  display: flex;
  align-items: center;
  padding: ${({theme:e})=>2*e.gridUnit}px;
  padding-left: ${({theme:e})=>e.gridUnit}px;
`;var u;!function(e){e.Vertical="vertical",e.Horizontal="horizontal"}(u||(u={}));const h=(e=u.Vertical)=>e===u.Horizontal?(0,l.Y)(s.A.MoreHoriz,{iconSize:"xl"}):(0,l.Y)(d,{}),p=({overlay:e,iconOrientation:t=u.Vertical,...n})=>(0,l.Y)(o.rM,{overlay:e,...n,children:(0,l.Y)(c,{children:h(t)})}),m=e=>{const{children:t,onBlur:n,onKeyDown:o,...a}=e,s=(0,r.cloneElement)(t,{onBlur:n,onKeyDown:o});return(0,l.Y)(i.A,{overlayStyle:e.overlayStyle,...a,children:s})}},70175:(e,t,n)=>{var r;n.d(t,{Q:()=>r}),function(e){e.Dashboards="dashboards",e.Description="description",e.LastModified="lastModified",e.Owner="owner",e.Rows="rows",e.Sql="sql",e.Table="table",e.Tags="tags"}(r||(r={}))},14693:(e,t,n)=>{n.d(t,{QD:()=>C.Q,Ay:()=>S});var r=n(9063),o=n.n(r),i=n(96540),a=n(98250),s=n(96453),l=n(19129),d=n(62952),c=n(95579),u=n(12249),h=n(2445);const p=s.I4.div`
  font-weight: ${({theme:e})=>e.typography.weights.bold};
`,m=({text:e,header:t})=>{const n=(0,d.A)(e);return(0,h.FD)(h.FK,{children:[t&&(0,h.Y)(p,{children:t}),n.map((e=>(0,h.Y)("div",{children:e},e)))]})},g=16,v={dashboards:0,table:1,sql:2,rows:3,tags:4,description:5,owner:6,lastModified:7},b=s.I4.div`
  ${({theme:e,count:t})=>`\n    display: flex;\n    align-items: center;\n    padding: 8px 12px;\n    background-color: ${e.colors.grayscale.light4};\n    color: ${e.colors.grayscale.base};\n    font-size: ${e.typography.sizes.s}px;\n    min-width: ${24+32*t-g}px;\n    border-radius: ${e.borderRadius}px;\n    line-height: 1;\n  `}
`,f=s.I4.div`
  ${({theme:e,collapsed:t,last:n,onClick:r})=>`\n    display: flex;\n    align-items: center;\n    max-width: ${174+(n?0:g)}px;\n    min-width: ${t?16+(n?0:g):94+(n?0:g)}px;\n    padding-right: ${n?0:g}px;\n    cursor: ${r?"pointer":"default"};\n    & .metadata-icon {\n      color: ${r&&t?e.colors.primary.base:e.colors.grayscale.base};\n      padding-right: ${t?0:8}px;\n      & .anticon {\n        line-height: 0;\n      }\n    }\n    & .metadata-text {\n      min-width: 70px;\n      overflow: hidden;\n      text-overflow: ${t?"unset":"ellipsis"};\n      white-space: nowrap;\n      text-decoration: ${r?"underline":"none"};\n      line-height: 1.4;\n    }\n  `}
`,y=s.I4.div`
  display: -webkit-box;
  -webkit-line-clamp: 20;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
`,x=({barWidth:e,contentType:t,collapsed:n,last:r=!1,tooltipPlacement:o})=>{const{icon:a,title:s,tooltip:d=s}=(e=>{const{type:t}=e;switch(t){case C.Q.Dashboards:return{icon:u.A.FundProjectionScreenOutlined,title:e.title,tooltip:e.description?(0,h.Y)("div",{children:(0,h.Y)(m,{header:e.title,text:e.description})}):void 0};case C.Q.Description:return{icon:u.A.BookOutlined,title:e.value};case C.Q.LastModified:return{icon:u.A.EditOutlined,title:e.value,tooltip:(0,h.FD)("div",{children:[(0,h.Y)(m,{header:(0,c.t)("Last modified"),text:e.value}),(0,h.Y)(m,{header:(0,c.t)("Modified by"),text:e.modifiedBy})]})};case C.Q.Owner:return{icon:u.A.UserOutlined,title:e.createdBy,tooltip:(0,h.FD)("div",{children:[(0,h.Y)(m,{header:(0,c.t)("Created by"),text:e.createdBy}),!!e.owners&&(0,h.Y)(m,{header:(0,c.t)("Owners"),text:e.owners}),(0,h.Y)(m,{header:(0,c.t)("Created on"),text:e.createdOn})]})};case C.Q.Rows:return{icon:u.A.InsertRowBelowOutlined,title:e.title,tooltip:e.title};case C.Q.Sql:return{icon:u.A.ConsoleSqlOutlined,title:e.title,tooltip:e.title};case C.Q.Table:return{icon:u.A.Table,title:e.title,tooltip:e.title};case C.Q.Tags:return{icon:u.A.TagsOutlined,title:e.values.join(", "),tooltip:(0,h.Y)("div",{children:(0,h.Y)(m,{header:(0,c.t)("Tags"),text:e.values})})};default:throw Error(`Invalid type provided: ${t}`)}})(t),[p,g]=(0,i.useState)(!1),v=(0,i.useRef)(null),b=a,{type:x,onClick:S}=t;(0,i.useEffect)((()=>{g(!!v.current&&v.current.scrollWidth>v.current.clientWidth)}),[e,g,t]);const A=(0,h.FD)(f,{collapsed:n,last:r,onClick:S?()=>S(x):void 0,role:S?"button":void 0,children:[(0,h.Y)(b,{iconSize:"l",className:"metadata-icon"}),!n&&(0,h.Y)("span",{ref:v,className:"metadata-text",children:s})]});return p||n||d&&d!==s?(0,h.Y)(l.m,{placement:o,title:(0,h.Y)(y,{children:d}),children:A}):A};var C=n(70175);const S=({items:e,tooltipPlacement:t="top"})=>{const[n,r]=(0,i.useState)(),[s,l]=(0,i.useState)(!1),d=o()(e,((e,t)=>e.type===t.type)).sort(((e,t)=>v[e.type]-v[t.type])),c=d.length;if(c<2)throw Error("The minimum number of items for the metadata bar is 2.");if(c>6)throw Error("The maximum number of items for the metadata bar is 6.");const u=(0,i.useCallback)((e=>{const t=110*c-g;r(e),l(Boolean(e&&e<t))}),[c]),{ref:p}=(0,a.uZ)({onResize:u});return(0,h.Y)(b,{ref:p,count:c,children:d.map(((e,r)=>(0,h.Y)(x,{barWidth:n,contentType:e,collapsed:s,last:r===c-1,tooltipPlacement:t},r)))})}},40104:(e,t,n)=>{n.d(t,{Kg:()=>g,J8:()=>p,Pz:()=>v,tg:()=>u,pY:()=>h,px:()=>m});var r=n(96627),o=n(58863),i=n(95579),a=n(88488);const s=e=>null!=e&&"function"==typeof e[Symbol.iterator];var l=n(49588),d=n(38708);const c=()=>{var e,t;const n=(0,d.A)();return(null==n||null==(e=n.common)||null==(t=e.conf)?void 0:t.NATIVE_FILTER_DEFAULT_ROW_LIMIT)||1e3},u=({datasetId:e,dependencies:t={},groupby:n,defaultDataMask:r,controlValues:o,filterType:i,sortMetric:s,adhoc_filters:l,time_range:d,granularity_sqla:u,type:h,dashboardId:p,id:m})=>{var g;const v={};return e&&(v.datasource=`${e}__table`),n&&(v.groupby=[n]),s&&(v.sortMetric=s),{...o,...v,adhoc_filters:null!=l?l:[],extra_filters:[],extra_form_data:t,granularity_sqla:u,metrics:["count"],row_limit:c(),showSearch:!0,defaultValue:null==r||null==(g=r.filterState)?void 0:g.value,time_range:d,url_params:(0,a.A)("regular"),inView:!0,viz_type:i,type:h,dashboardId:p,native_filter_id:m}};function h(e={},t={}){const n={};return r.t1.forEach((r=>{const o=e[r],i=t[r],a=[...s(o)?o:[],...s(i)?i:[]];a.length&&(n[r]=a)})),r.zk.forEach((r=>{const o=e[r];void 0!==o&&(n[r]=o);const i=t[r];void 0!==i&&(n[r]=i)})),n}function p(e,t){let n={};return t.forEach((t=>{var r,o;n=h(n,null!=(r=null==(o=e[t])?void 0:o.extraFormData)?r:{})})),n}function m(e){return!e.includes(o.nS.NativeFilter)||e.includes(o.nS.InteractiveChart)}const g=(e,t)=>new Set(t.map((t=>{var n,r;return null==(n=e.find((e=>{var n;return(null==e||null==(n=e.meta)?void 0:n.chartId)===t})))||null==(r=n.parents)?void 0:r.filter((e=>e.startsWith(`${l.B8}-`)))})).filter((e=>void 0!==e)).flat()),v=e=>null==e?"":"string"==typeof e||"number"==typeof e?`${e}`:Array.isArray(e)?e.join(", "):"object"==typeof e?JSON.stringify(e):(0,i.t)("Unknown value")},76295:(e,t,n)=>{n.d(t,{A:()=>u});var r=n(2404),o=n.n(r),i=n(40104),a=n(35839);function s(e){return Object.entries(e).map((([e,t])=>({col:e,op:Array.isArray(t)?"IN":"==",val:t}))).filter((e=>null!==e.val))}var l=n(92008);const d={},c={};function u({chart:e,filters:t,nativeFilters:n,chartConfiguration:r,colorScheme:u,ownColorScheme:h,colorNamespace:p,sliceId:m,dataMask:g,extraControls:v,labelsColor:b,labelsColorMap:f,sharedLabelsColors:y,allSliceIds:x}){const C=c[m];if(d[m]===t&&(0,a.r$)(null==C?void 0:C.own_color_scheme,h)&&(0,a.r$)(null==C?void 0:C.color_scheme,u)&&(0,a.r$)(null==C?void 0:C.color_namespace,p,{ignoreUndefined:!0})&&(0,a.r$)(null==C?void 0:C.label_colors,b,{ignoreUndefined:!0})&&(0,a.r$)(null==C?void 0:C.map_label_colors,f,{ignoreUndefined:!0})&&o()(null==C?void 0:C.shared_label_colors,y)&&C&&(0,a.r$)(null==C?void 0:C.dataMask,g,{ignoreUndefined:!0})&&(0,a.r$)(null==C?void 0:C.extraControls,v,{ignoreUndefined:!0}))return C;let S={};const A=(0,l.R)({chartConfiguration:r,dataMask:g,nativeFilters:n,allSliceIds:x}),w=Object.entries(A).filter((([,{scope:t}])=>t.includes(e.id))).map((([e])=>e));w.length&&(S={extra_form_data:(0,i.J8)(g,w)});const T={...e.form_data,chart_id:e.id,label_colors:b,shared_label_colors:y,map_label_colors:f,...u&&{color_scheme:u},...h&&{own_color_scheme:h},extra_filters:s(t),...S,...v};return d[m]=t,c[m]={...T,dataMask:g,extraControls:v},T}},39091:(e,t,n)=>{n.d(t,{$r:()=>E,TN:()=>T,XS:()=>R,ZY:()=>D,i8:()=>w});var r=n(17437),o=n(38221),i=n.n(o),a=n(96540),s=n(96453),l=n(95579),d=n(7349),c=n(85170),u=n(87903),h=n(58642),p=n(90868),m=n(27023),g=n(69193),v=n(12249),b=n(46920),f=n(10044),y=n(15151),x=n(19966),C=n(86832),S=n(2445);const A=(0,s.I4)("span")`
  color: ${({theme:e})=>e.colors.grayscale.light1};
`,w=(0,s.I4)(b.A)`
  font-size: ${({theme:e})=>e.typography.sizes.s}px;

  // needed to override button's first-of-type margin: 0
  && {
    margin: 0 ${({theme:e})=>2*e.gridUnit}px;
  }

  i {
    padding: 0 ${({theme:e})=>e.gridUnit}px;
  }
`,T=({data:e,columns:t})=>{const n=(0,s.DP)();return(0,S.Y)(x.A,{text:e&&t?(0,y.L)(e,t):"",wrapped:!1,copyNode:(0,S.Y)(v.A.CopyOutlined,{iconColor:n.colors.grayscale.base,iconSize:"l","aria-label":(0,l.t)("Copy"),role:"button",css:r.AH`
            &.anticon > * {
              line-height: 0;
            }
          `})})},D=({onChangeHandler:e,shouldFocus:t=!1})=>{const n=(0,a.useRef)(null);(0,a.useEffect)((()=>{n.current&&t&&n.current.focus()}),[]);const o=(0,s.DP)(),d=i()(e,m.Qs);return(0,S.Y)(p.pd,{prefix:(0,S.Y)(v.A.Search,{iconColor:o.colors.grayscale.base}),placeholder:(0,l.t)("Search"),onChange:e=>{const t=e.target.value;d(t)},css:r.AH`
        width: 200px;
        margin-right: ${2*o.gridUnit}px;
      `,ref:n})};var _;!function(e){e.Formatted="formatted",e.Original="original"}(_||(_={}));const Y=({onChange:e,value:t})=>(0,S.Y)(g.s.GroupWrapper,{spaceConfig:{direction:"vertical",align:"start",size:15,wrap:!1},size:"large",value:t,onChange:e,options:[{label:(0,l.t)("Formatted date"),value:_.Formatted},{label:(0,l.t)("Original value"),value:_.Original}]}),F=s.I4.div`
  display: flex;
  flex-direction: column;

  padding: ${({theme:e})=>4*e.gridUnit+"px"};
`,I=s.I4.span`
  font-size: ${({theme:e})=>e.typography.sizes.s}px;
  color: ${({theme:e})=>e.colors.grayscale.base};
  margin-bottom: ${({theme:e})=>2*e.gridUnit}px;
`,$=({columnName:e,onTimeColumnChange:t,datasourceId:n,isOriginalTimeColumn:o})=>{const i=(0,s.DP)(),d=n=>{t(e,n.target.value)},c=(0,a.useMemo)((()=>n?(0,S.FD)(F,{onClick:e=>e.stopPropagation(),children:[(0,S.Y)(r.mL,{styles:r.AH`
              .column-formatting-popover .ant-popover-inner-content {
                padding: 0;
              }
            `}),(0,S.Y)(I,{children:(0,l.t)("Column Formatting")}),(0,S.Y)(Y,{onChange:d,value:o?_.Original:_.Formatted})]}):null),[n,o]);return n?(0,S.FD)("span",{children:[(0,S.Y)(f.A,{overlayClassName:"column-formatting-popover",trigger:"click",content:c,placement:"bottomLeft",arrowPointAtCenter:!0,children:(0,S.Y)(v.A.SettingOutlined,{iconSize:"m",iconColor:i.colors.grayscale.light1,css:(0,r.AH)({marginRight:`${i.gridUnit}px`},"",""),onClick:e=>e.stopPropagation()})}),e]}):(0,S.Y)("span",{children:e})},E=(e,t)=>{const n=(0,a.useMemo)((()=>{var e;return null!=(e=null==t?void 0:t.map((e=>Object.values(e).map((e=>e?e.toString().toLowerCase():(0,l.t)("N/A"))))))?e:[]}),[t]);return(0,a.useMemo)((()=>null!=t&&t.length?t.filter(((t,r)=>n[r].some((t=>null==t?void 0:t.includes(e.toLowerCase()))))):[]),[t,e,n])},M=(0,d.mo)(c.A.DATABASE_DATETIME),R=(e,t,n,r,o,i,s)=>{const[l,d]=(0,a.useState)((0,C.p)(r)),c=(e,t)=>{if(r)if(t!==_.Original||l.includes(e)){if(t===_.Formatted&&l.includes(e)){const t=(0,C.p)(r);t.splice(t.indexOf(e),1),(0,C.J)(r,t),d(t)}}else{const t=(0,C.p)(r);t.push(e),(0,C.J)(r,t),d(t)}};return(0,a.useEffect)((()=>{o&&d((0,C.p)(r))}),[r,o]),(0,a.useMemo)((()=>e&&null!=n&&n.length?e.filter((e=>Object.keys(n[0]).includes(e))).map(((e,o)=>{const a=null==t?void 0:t[o],d=n[0][e],p=a===u.s.Temporal?l.indexOf(e):-1,g=l.includes(e);return{id:e||o,accessor:t=>t[e],Header:a===u.s.Temporal&&"string"!=typeof d?(0,S.Y)($,{columnName:e,datasourceId:r,onTimeColumnChange:c,isOriginalTimeColumn:g}):e,Cell:({value:e})=>!0===e?m.bU:!1===e?m.y2:null===e?(0,S.Y)(A,{children:m.bV}):a===u.s.Temporal&&-1===p&&"number"==typeof e?M(e):"string"==typeof e&&s?(0,h.nn)(e):String(e),...null==i?void 0:i[e]}})):[]),[e,n,t,r,i,l])}},86832:(e,t,n)=>{n.d(t,{J:()=>a,p:()=>i});var r=n(62952),o=n(62221);const i=e=>{const t=(0,o.Gq)(o.Hh.ExploreDataTableOriginalFormattedTimeColumns,{});return void 0===e?[]:(0,r.A)(t[e])},a=(e,t)=>{const n=(0,o.Gq)(o.Hh.ExploreDataTableOriginalFormattedTimeColumns,{});(0,o.SO)(o.Hh.ExploreDataTableOriginalFormattedTimeColumns,{...n,[e]:t})}},80493:(e,t,n)=>{n.d(t,{x:()=>g,y:()=>m});var r=n(65611),o=n.n(r),i=n(96540),a=n(96453),s=n(87903),l=n(17437),d=n(39091),c=n(15151),u=n(86832),h=n(26761),p=n(2445);const m=a.I4.div`
  ${({theme:e})=>`\n    display: flex;\n    align-items: center;\n    justify-content: space-between;\n    margin-bottom: ${2*e.gridUnit}px;\n\n    span {\n      flex-shrink: 0;\n    }\n  `}
`,g=({data:e,datasourceId:t,onInputChange:n,columnNames:r,columnTypes:a,rowcount:g,isLoading:v,canDownload:b})=>{const f=(0,u.p)(t),y=o()(r,a).filter((([e,t])=>t===s.s.Temporal&&e&&!f.includes(e))).map((([e])=>e)),x=(0,i.useMemo)((()=>(0,c.bE)(e,y)),[e,y]);return(0,p.FD)(m,{children:[(0,p.Y)(d.ZY,{onChangeHandler:n,shouldFocus:!0}),(0,p.FD)("div",{css:l.AH`
          display: flex;
          align-items: center;
        `,children:[(0,p.Y)(h.A,{rowcount:g,loading:v}),b&&(0,p.Y)(d.TN,{data:x,columns:r})]})]})}},8877:(e,t,n)=>{n.d(t,{U:()=>d});var r=n(96540),o=n(95579),i=n(50217),a=n(39091),s=n(80493),l=n(2445);const d=({data:e,colnames:t,coltypes:n,rowcount:d,datasourceId:c,dataSize:u=50,isVisible:h,canDownload:p})=>{const[m,g]=(0,r.useState)(""),v=(0,a.XS)(t,n,e,c,h,{},!0),b=(0,a.$r)(m,e);return(0,l.FD)(l.FK,{children:[(0,l.Y)(s.x,{data:b,columnNames:t,columnTypes:n,rowcount:d,datasourceId:c,onInputChange:e=>g(e),isLoading:!1,canDownload:p}),(0,l.Y)(i.A,{columns:v,data:b,pageSize:u,noDataText:(0,o.t)("No results"),emptyWrapperType:i.V.Small,className:"table-condensed",isPaginationSticky:!0,showRowCount:!1,small:!0})]})}},8786:(e,t,n)=>{n.d(t,{_h:()=>$,ih:()=>w});var r,o=n(96540),i=n(96453),a=n(27366),s=n(95579),l=n(12249),d=n(48327),c=n(62221);!function(e){e.Results="results",e.Samples="samples"}(r||(r={}));var u=n(80145),h=n(62952),p=n(51436),m=n(17444),g=n(50455),v=n(2514),b=n(8877),f=n(80493),y=n(2445);const x=i.I4.pre`
  margin-top: ${({theme:e})=>4*e.gridUnit+"px"};
`,C=new WeakMap,S=({isRequest:e,queryFormData:t,queryForce:n,ownState:r,errorMessage:i,actions:a,isVisible:l,dataSize:d=50,canDownload:c})=>{var S;const A=(0,u.A)().get((null==t?void 0:t.viz_type)||(null==t?void 0:t.vizType)),[w,T]=(0,o.useState)([]),[D,_]=(0,o.useState)(!0),[Y,F]=(0,o.useState)(""),I=null!=(S=null==A?void 0:A.queryObjectCount)?S:1;if((0,o.useEffect)((()=>{i||(e&&C.has(t)&&(T((0,h.A)(C.get(t))),F(""),n&&a&&a.setForceQuery(!1),_(!1)),e&&!C.has(t)&&(_(!0),(0,v.getChartDataRequest)({formData:t,force:n,resultFormat:"json",resultType:"results",ownState:r}).then((({json:e})=>{T((0,h.A)(e.result)),F(""),C.set(t,e.result),n&&a&&a.setForceQuery(!1)})).catch((e=>{(0,p.h4)(e).then((({error:e,message:t})=>{F(e||t||(0,s.t)("Sorry, an error occurred"))}))})).finally((()=>{_(!1)}))))}),[t,e]),(0,o.useEffect)((()=>{i&&_(!1)}),[i]),D)return Array(I).fill((0,y.Y)(m.A,{}));if(i){const e=(0,s.t)("Run a query to display results");return Array(I).fill((0,y.Y)(g.p,{image:"document.svg",title:e}))}if(Y){const e=(0,y.FD)(y.FK,{children:[(0,y.Y)(f.x,{data:[],columnNames:[],columnTypes:[],rowcount:0,datasourceId:t.datasource,onInputChange:()=>{},isLoading:!1,canDownload:c}),(0,y.Y)(x,{children:Y})]});return Array(I).fill(e)}if(0===w.length){const e=(0,s.t)("No results were returned for this query");return Array(I).fill((0,y.Y)(g.p,{image:"document.svg",title:e}))}return w.slice(0,I).map(((e,n)=>(0,y.Y)(b.U,{data:e.data,colnames:e.colnames,coltypes:e.coltypes,rowcount:e.rowcount,dataSize:d,datasourceId:t.datasource,isVisible:l,canDownload:c},n)))},A=i.I4.div`
  display: flex;
  flex-direction: column;
  height: 100%;

  .ant-tabs {
    height: 100%;
  }

  .ant-tabs-content {
    height: 100%;
  }

  .ant-tabs-tabpane {
    display: flex;
    flex-direction: column;
  }

  .table-condensed {
    overflow: auto;
  }
`,w=({isRequest:e,queryFormData:t,queryForce:n,ownState:o,errorMessage:i,actions:a,isVisible:l,dataSize:c=50,canDownload:u})=>{const h=S({errorMessage:i,queryFormData:t,queryForce:n,ownState:o,isRequest:e,actions:a,dataSize:c,isVisible:l,canDownload:u});if(1===h.length)return(0,y.Y)(A,{children:h[0]});const p=h.map(((e,t)=>0===t?(0,y.Y)(d.Ay.TabPane,{tab:(0,s.t)("Results"),children:e},r.Results):(0,y.Y)(d.Ay.TabPane,{tab:(0,s.t)("Results %s",t+1),children:e},`${r.Results} ${t+1}`)));return(0,y.Y)(A,{children:(0,y.Y)(d.Ay,{fullWidth:!1,children:p})})};var T=n(50217),D=n(39091);const _=i.I4.pre`
  margin-top: ${({theme:e})=>4*e.gridUnit+"px"};
`,Y=new WeakSet,F=({isRequest:e,datasource:t,queryForce:n,actions:r,dataSize:i=50,isVisible:a,canDownload:l})=>{const[d,c]=(0,o.useState)(""),[u,p]=(0,o.useState)([]),[b,x]=(0,o.useState)([]),[C,S]=(0,o.useState)([]),[A,w]=(0,o.useState)(!1),[F,I]=(0,o.useState)(0),[$,E]=(0,o.useState)(""),M=(0,o.useMemo)((()=>`${t.id}__${t.type}`),[t]);(0,o.useEffect)((()=>{e&&n&&Y.delete(t),e&&!Y.has(t)&&(w(!0),(0,v.getDatasourceSamples)(t.type,t.id,n,{}).then((e=>{p((0,h.A)(e.data)),x((0,h.A)(e.colnames)),S((0,h.A)(e.coltypes)),I(e.rowcount),E(""),Y.add(t),n&&r&&r.setForceQuery(!1)})).catch((e=>{p([]),x([]),S([]),E(`${e.name}: ${e.message}`)})).finally((()=>{w(!1)})))}),[t,e,n]);const R=(0,D.XS)(b,C,u,M,a,{},!0),N=(0,D.$r)(d,u);if(A)return(0,y.Y)(m.A,{});if($)return(0,y.FD)(y.FK,{children:[(0,y.Y)(f.x,{data:N,columnNames:b,columnTypes:C,rowcount:F,datasourceId:M,onInputChange:e=>c(e),isLoading:A,canDownload:l}),(0,y.Y)(_,{children:$})]});if(0===u.length){const e=(0,s.t)("No samples were returned for this dataset");return(0,y.Y)(g.p,{image:"document.svg",title:e})}return(0,y.FD)(y.FK,{children:[(0,y.Y)(f.x,{data:N,columnNames:b,columnTypes:C,rowcount:F,datasourceId:M,onInputChange:e=>c(e),isLoading:A,canDownload:l}),(0,y.Y)(T.A,{columns:R,data:N,pageSize:i,noDataText:(0,s.t)("No results"),emptyWrapperType:T.V.Small,className:"table-condensed",isPaginationSticky:!0,showRowCount:!1,small:!0})]})},I=i.I4.div`
  ${({theme:e})=>`\n    position: relative;\n    background-color: ${e.colors.grayscale.light5};\n    z-index: 5;\n    overflow: hidden;\n\n    .ant-tabs {\n      height: 100%;\n    }\n\n    .ant-tabs-content-holder {\n      height: 100%;\n    }\n\n    .ant-tabs-content {\n      height: 100%;\n    }\n\n    .ant-tabs-tabpane {\n      display: flex;\n      flex-direction: column;\n      height: 100%;\n\n      .table-condensed {\n        height: 100%;\n        overflow: auto;\n        margin-bottom: ${4*e.gridUnit}px;\n\n        .table {\n          margin-bottom: ${2*e.gridUnit}px;\n        }\n      }\n\n      .pagination-container > ul[role='navigation'] {\n        margin-top: 0;\n      }\n    }\n  `}
`,$=({queryFormData:e,datasource:t,queryForce:n,onCollapseChange:u,chartStatus:h,ownState:p,errorMessage:m,actions:g,canDownload:v})=>{const b=(0,i.DP)(),[x,C]=(0,o.useState)(r.Results),[A,w]=(0,o.useState)({results:!1,samples:!1}),[T,D]=(0,o.useState)(!(0,a.G7)(a.TO.DatapanelClosedByDefault)&&(0,c.Gq)(c.Hh.IsDatapanelOpen,!1));(0,o.useEffect)((()=>{(0,a.G7)(a.TO.DatapanelClosedByDefault)||(0,c.SO)(c.Hh.IsDatapanelOpen,T)}),[T]),(0,o.useEffect)((()=>{T||w({results:!1,samples:!1}),T&&x.startsWith(r.Results)&&h&&"loading"!==h&&w({results:!0,samples:!1}),T&&x===r.Samples&&w({results:!1,samples:!0})}),[T,x,h]);const _=(0,o.useCallback)((e=>{u(e),D(e)}),[u]),Y=(0,o.useCallback)(((e,t)=>{T?e===x&&(t.preventDefault(),_(!1)):_(!0),C(e)}),[x,_,T]),$=(0,o.useMemo)((()=>{const e=T?(0,y.Y)(l.A.CaretUp,{iconColor:b.colors.grayscale.base,"aria-label":(0,s.t)("Collapse data panel")}):(0,y.Y)(l.A.CaretDown,{iconColor:b.colors.grayscale.base,"aria-label":(0,s.t)("Expand data panel")});return(0,y.Y)(f.y,{children:T?(0,y.Y)("span",{role:"button",tabIndex:0,onClick:()=>_(!1),children:e}):(0,y.Y)("span",{role:"button",tabIndex:0,onClick:()=>_(!0),children:e})})}),[_,T,b.colors.grayscale.base]),E=S({errorMessage:m,queryFormData:e,queryForce:n,ownState:p,isRequest:A.results,actions:g,isVisible:r.Results===x,canDownload:v}).map(((e,t)=>0===t?(0,y.Y)(d.Ay.TabPane,{tab:(0,s.t)("Results"),children:e},r.Results):t>0?(0,y.Y)(d.Ay.TabPane,{tab:(0,s.t)("Results %s",t+1),children:e},`${r.Results} ${t+1}`):null));return(0,y.Y)(I,{children:(0,y.FD)(d.Ay,{fullWidth:!1,tabBarExtraContent:$,activeKey:T?x:"",onTabClick:Y,children:[E,(0,y.Y)(d.Ay.TabPane,{tab:(0,s.t)("Samples"),children:(0,y.Y)(F,{datasource:t,queryForce:n,isRequest:A.samples,actions:g,isVisible:r.Samples===x,canDownload:v})},r.Samples)]})})}},28254:(e,t,n)=>{var r;n.d(t,{S:()=>r}),function(e){e.Column="column",e.ColumnOption="columnOption",e.AdhocColumnOption="adhocColumn",e.Metric="metric",e.MetricOption="metricOption",e.AdhocMetricOption="adhocMetric",e.FilterOption="filterOption"}(r||(r={}))},16238:(e,t,n)=>{n.d(t,{y:()=>r});const r=n(96453).I4.div`
  .edit-popover-resize {
    transform: scaleX(-1);
    float: right;
    margin-top: ${({theme:e})=>4*e.gridUnit}px;
    margin-right: ${({theme:e})=>-2*e.gridUnit}px;
    cursor: nwse-resize;
  }
  .filter-sql-editor {
    border: ${({theme:e})=>e.colors.grayscale.light2} solid thin;
  }
`},26761:(e,t,n)=>{n.d(t,{A:()=>d});var r=n(95579),o=n(32142),i=n(35768),a=n(19129),s=n(2445);const l=(0,r.t)("The row limit set for the chart was reached. The chart may show partial data.");function d(e){const{rowcount:t=0,limit:n=null,loading:d}=e,c=n&&t>=n,u=c||0===t&&!d?"danger":"default",h=(0,o.gV)()(t),p=(0,s.Y)(i.Ay,{type:u,children:d?(0,r.t)("Loading..."):(0,s.Y)("span",{children:(0,r.tn)("%s row","%s rows",t,h)})});return c?(0,s.Y)(a.m,{id:"tt-rowcount-tooltip",title:(0,s.Y)("span",{children:l}),children:p}):p}},8972:(e,t,n)=>{n.d(t,{A:()=>J});var r=n(96540),o=n(5556),i=n.n(o),a=n(46920),s=n(96453),l=n(95579),d=n(49544),c=n(48327),u=n(8901),h=n(90422),p=n(86523),m=n(15595),g=n(13270),v=n(35742),b=n(27366),f=n(95483),y=n(84064),x=n(19129),C=n(90868),S=n(15151),A=n(67984),w=n(38221),T=n.n(w),D=n(62952),_=n(58561),Y=n.n(_);const F={parsedAdvancedDataType:"",advancedDataTypeOperatorList:[],errorMessage:""};var I=n(59638),$=n(39942),E=n(2511),M=n(2445);const R=(0,s.I4)(C.pd)`
  margin-bottom: ${({theme:e})=>4*e.gridUnit}px;
`,N=((0,s.I4)(p.A)`
  &.ant-row.ant-form-item {
    margin: 0;
  }
`,(0,s.I4)(m.l6)`
  .ant-select-selector::after {
    content: ${({labelText:e})=>e||"\\A0"};
    display: inline-block;
    white-space: nowrap;
    color: ${({theme:e})=>e.colors.grayscale.light1};
    width: max-content;
  }
`),k=e=>{var t,n;const{onSubjectChange:o,onOperatorChange:i,isOperatorRelevant:a,onComparatorChange:s,onDatePickerChange:d}=(e=>{const t=(0,$.IM)(),n=(t,n)=>{var r;const o=null==(r=e.datasource.columns)?void 0:r.find((e=>e.column_name===n)),i=!!o&&("BOOL"===o.type||"BOOLEAN"===o.type),a=!!o&&("INT"===o.type||"INTEGER"===o.type),s=!!o&&!!o.expression;if(t&&t===f.ux.LatestPartition){const{partitionColumn:t}=e;return t&&n&&n===t}return(!t||t!==f.ux.TemporalRange)&&(t===f.ux.IsTrue||t===f.ux.IsFalse?i||a||s:i?t===f.ux.IsNull||t===f.ux.IsNotNull:e.adhocFilter.clause!==E.v.Having||-1!==f._T.indexOf(t))};return{onSubjectChange:r=>{const o=e.options.find((e=>"column_name"in e&&e.column_name===r||"optionName"in e&&e.optionName===r));let i,a="";o&&"column_name"in o?(a=o.column_name,i=E.v.Where):o&&"saved_metric_name"in o?(a=o.saved_metric_name,i=E.v.Having):null!=o&&o.label&&(a=o.label,i=E.v.Having);let{operator:s,operatorId:l,comparator:d}=e.adhocFilter;s=s&&l&&n(l,a)?f.nS[l].operation:null,(0,g.A)(s)||(s=f.ux.In,l=f.ux.In,d=void 0),(0,A.D)(r,e.datasource)&&(a=r,s=f.ux.TemporalRange,l=f.ux.TemporalRange,d=t),e.onChange(e.adhocFilter.duplicateWith({subject:a,clause:i,operator:s,expressionType:E.A.Simple,operatorId:l,comparator:d}))},onOperatorChange:t=>{const n=e.adhocFilter.comparator;let r;r=f.sJ.has(t)?Array.isArray(n)?n:[n].filter((e=>e)):Array.isArray(n)?n[0]:n,t!==f.ux.IsTrue&&t!==f.ux.IsFalse||(r=f.ux.IsTrue===t),t&&f.Wy.has(t)?e.onChange(e.adhocFilter.duplicateWith({subject:e.adhocFilter.subject,clause:E.v.Where,operatorId:t,operator:f.nS[t].operation,expressionType:E.A.Sql,datasource:e.datasource})):e.onChange(e.adhocFilter.duplicateWith({operatorId:t,operator:f.nS[t].operation,comparator:r,expressionType:E.A.Simple}))},onComparatorChange:t=>{e.onChange(e.adhocFilter.duplicateWith({comparator:t,expressionType:E.A.Simple}))},isOperatorRelevant:n,clearOperator:()=>{e.onChange(e.adhocFilter.duplicateWith({operatorId:void 0,operator:void 0}))},onDatePickerChange:(t,n)=>{e.onChange(e.adhocFilter.duplicateWith({subject:t,operator:f.ux.TemporalRange,comparator:n,expressionType:E.A.Simple}))}}})(e),[c,u]=(0,r.useState)([]),[h,p]=(0,r.useState)(e.adhocFilter.comparator),[C,w]=(0,r.useState)(!1),{advancedDataTypesState:_,subjectAdvancedDataType:k,fetchAdvancedDataTypeValueCallback:O,fetchSubjectAdvancedDataType:U}=(e=>{const[t,n]=(0,r.useState)(F),[o,i]=(0,r.useState)(),a=(0,r.useCallback)(((t,r,o)=>{const i=(0,D.A)(t);o?T()((()=>{const t=`/api/v1/advanced_data_type/convert?q=${Y().encode({type:o,values:i})}`;v.A.get({endpoint:t}).then((({json:t})=>{n({parsedAdvancedDataType:t.result.display_value,advancedDataTypeOperatorList:t.result.valid_filter_operators,errorMessage:t.result.error_message}),e(!t.result.error_message)})).catch((()=>{n({parsedAdvancedDataType:"",advancedDataTypeOperatorList:r.advancedDataTypeOperatorList,errorMessage:(0,l.t)("Failed to retrieve advanced type")}),e(!1)}))}),600)():n(F)}),[e]);return{advancedDataTypesState:t,subjectAdvancedDataType:o,setAdvancedDataTypesState:n,fetchAdvancedDataTypeValueCallback:a,fetchSubjectAdvancedDataType:e=>{const t=e.options.find((t=>"column_name"in t&&t.column_name===e.adhocFilter.subject||"optionName"in t&&t.optionName===e.adhocFilter.subject));t&&"advanced_data_type"in t?i(t.advanced_data_type):e.validHandler(!0)}}})(e.validHandler),q=(e,t)=>k?a(e,t)&&_.advancedDataTypeOperatorList.includes(e):a(e,t),L=()=>{const e=(()=>{const e=Array.isArray(h)?h.filter((e=>c.includes(e))).length:0;return c?c.length-e:0})(),t=(0,l.t)("%s option(s)",e);return e?t:""};let z=e.options;const{subject:H,operator:P,operatorId:W}=e.adhocFilter,j={ariaLabel:(0,l.t)("Select subject"),value:null!=H?H:void 0,onChange:e=>{p(void 0),o(e)},notFoundContent:(0,l.t)("No such column found. To filter on a metric, try the Custom SQL tab."),autoFocus:!H,placeholder:""};j.placeholder=e.adhocFilter.clause===E.v.Where?(0,l.t)("%s column(s)",z.length):(0,l.t)("To filter on a metric, use Custom SQL tab."),z=e.options.filter((e=>"column_name"in e&&e.column_name));const V={placeholder:(0,l.t)("%s operator(s)",(null!=(t=e.operators)?t:f.RX).filter((e=>q(e,H))).length),value:W,onChange:i,autoFocus:!!j.value&&!P,ariaLabel:(0,l.t)("Select operator")},B=!!j.value&&!!V.value,G={allowClear:!0,allowNewOptions:!0,ariaLabel:(0,l.t)("Comparator option"),mode:f.sJ.has(W)?"multiple":"single",loading:C,value:h,onChange:s,notFoundContent:(0,l.t)("Type a value here"),disabled:f.Sd.includes(W),placeholder:L(),autoFocus:B},Q=h&&h.length>0&&L(),K=(0,I.w)({columnName:e.adhocFilter.subject,timeRange:e.adhocFilter.operator===f.ux.TemporalRange?e.adhocFilter.comparator:void 0,datasource:e.datasource,onChange:d});(0,r.useEffect)((()=>{K||(()=>{const{datasource:t}=e,n=e.adhocFilter.subject,r=e.adhocFilter.clause===E.v.Having;if(n&&t&&t.filter_select&&!r){const e=new AbortController,{signal:r}=e;C&&e.abort(),w(!0),v.A.get({signal:r,endpoint:`/api/v1/datasource/${t.type}/${t.id}/column/${n}/values/`}).then((({json:e})=>{u(e.result.map((e=>({value:e,label:(0,S.ed)(e)})))),w(!1)})).catch((()=>{u([]),w(!1)}))}})()}),[e.adhocFilter.subject]),(0,r.useEffect)((()=>{(0,b.G7)(b.TO.EnableAdvancedDataTypes)&&U(e)}),[e.adhocFilter.subject]),(0,r.useEffect)((()=>{(0,b.G7)(b.TO.EnableAdvancedDataTypes)&&O(void 0===h?"":h,_,k)}),[h,k,O]),(0,r.useEffect)((()=>{(0,b.G7)(b.TO.EnableAdvancedDataTypes)&&p(e.adhocFilter.comparator)}),[e.adhocFilter.comparator]);const X=(0,M.Y)(m.l6,{css:e=>({marginTop:4*e.gridUnit,marginBottom:4*e.gridUnit}),options:z.map((e=>{return{value:"column_name"in e&&e.column_name||"optionName"in e&&e.optionName||"",label:"saved_metric_name"in e&&e.saved_metric_name||"column_name"in e&&e.column_name||"label"in e&&e.label,key:"id"in e&&e.id||"optionName"in e&&e.optionName||void 0,customLabel:(t=e,(0,M.Y)(y.A,{option:t}))};var t})),...j}),J=(0,M.FD)(M.FK,{children:[(0,M.Y)(m.l6,{css:e=>({marginBottom:4*e.gridUnit}),options:(null!=(n=e.operators)?n:f.RX).filter((e=>q(e,H))).map(((e,t)=>({value:e,label:f.nS[e].display,key:e,order:t}))),...V}),f.sJ.has(W)||c.length>0?(0,M.Y)(x.m,{title:_.errorMessage||_.parsedAdvancedDataType,children:(0,M.Y)(N,{labelText:Q,options:c,...G})}):(0,M.Y)(x.m,{title:_.errorMessage||_.parsedAdvancedDataType,children:(0,M.Y)(R,{name:"filter-value",ref:e=>{e&&B&&e.focus()},onChange:e=>{const{value:t}=e.target;p(t),s(t)},value:h,placeholder:(0,l.t)("Filter value (case sensitive)"),disabled:f.Sd.includes(W)})})]});return(0,M.FD)(M.FK,{children:[X,null!=K?K:J]})};var O=n(17437),U=n(24976),q=n(28274),L=n(92013);const z=(0,s.I4)(m.l6)`
  ${({theme:e})=>`\n    width: ${30*e.gridUnit}px;\n    marginRight: ${e.gridUnit}px;\n  `}
`;function H({adhocFilter:e,onChange:t,options:n,height:o}){const i=(0,r.useRef)(null),a=(0,s.DP)();(0,r.useEffect)((()=>{var e;null==i||null==(e=i.current)||e.editor.resize()}),[e]);const d=(0,r.useMemo)((()=>q.A.concat((0,L.r)(n.filter((e=>"object"==typeof e&&null!==e&&"column_name"in e&&"string"==typeof e.column_name&&"type"in e))))),[q.A]),c=(0,r.useMemo)((()=>Object.values(E.v).map((e=>({label:e,value:e})))),[E.v]);return(0,M.FD)("span",{children:[(0,M.FD)("div",{className:"filter-edit-clause-section",children:[(0,M.Y)("div",{children:(0,M.Y)(z,{options:c,ariaLabel:(0,l.t)("Select column"),placeholder:(0,l.t)("choose WHERE or HAVING..."),value:e.clause,onChange:n=>{t(e.duplicateWith({clause:n,expressionType:E.A.Sql}))}})}),(0,M.FD)("span",{className:"filter-edit-clause-info",children:[(0,M.Y)("strong",{children:"WHERE"})," ",(0,l.t)("Filters by columns"),(0,M.Y)("br",{}),(0,M.Y)("strong",{children:"HAVING"})," ",(0,l.t)("Filters by metrics")]})]}),(0,M.Y)("div",{css:(0,O.AH)({marginTop:4*a.gridUnit},"",""),children:(0,M.Y)(U.YU,{ref:i,keywords:d,height:o-130+"px",onChange:n=>{t(e.duplicateWith({sqlExpression:n,expressionType:E.A.Sql}))},width:"100%",showGutter:!1,value:e.sqlExpression||e.translateToSql(),editorProps:{$blockScrolling:!0},enableLiveAutocompletion:!0,className:"filter-sql-editor",wrapEnabled:!0})})]})}var P=n(21062);const W={adhocFilter:i().instanceOf(h.A).isRequired,onChange:i().func.isRequired,onClose:i().func.isRequired,onResize:i().func.isRequired,options:i().arrayOf(i().oneOfType([P.A,i().shape({saved_metric_name:i().string.isRequired}),u.A])).isRequired,datasource:i().object,partitionColumn:i().string,theme:i().object,sections:i().arrayOf(i().string),operators:i().arrayOf(i().string),requireSave:i().bool},j=s.I4.i`
  margin-left: ${({theme:e})=>2*e.gridUnit}px;
`,V=s.I4.div`
  .adhoc-filter-edit-tabs > .nav-tabs {
    margin-bottom: ${({theme:e})=>2*e.gridUnit}px;

    & > li > a {
      padding: ${({theme:e})=>e.gridUnit}px;
    }
  }

  #filter-edit-popover {
    max-width: none;
  }

  .filter-edit-clause-info {
    font-size: ${({theme:e})=>e.typography.sizes.xs}px;
  }

  .filter-edit-clause-section {
    display: flex;
    flex-direction: row;
    gap: ${({theme:e})=>5*e.gridUnit}px;
  }

  .adhoc-filter-simple-column-dropdown {
    margin-top: ${({theme:e})=>5*e.gridUnit}px;
  }
`,B=s.I4.div`
  margin-top: ${({theme:e})=>2*e.gridUnit}px;
`;class G extends r.Component{constructor(e){var t,n;super(e),this.onSave=this.onSave.bind(this),this.onDragDown=this.onDragDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onAdhocFilterChange=this.onAdhocFilterChange.bind(this),this.setSimpleTabIsValid=this.setSimpleTabIsValid.bind(this),this.adjustHeight=this.adjustHeight.bind(this),this.onTabChange=this.onTabChange.bind(this),this.state={adhocFilter:this.props.adhocFilter,width:f._R,height:f.Z_,activeKey:(null==(t=this.props)||null==(n=t.adhocFilter)?void 0:n.expressionType)||"SIMPLE",isSimpleTabValid:!0},this.popoverContentRef=(0,r.createRef)()}componentDidMount(){document.addEventListener("mouseup",this.onMouseUp)}componentWillUnmount(){document.removeEventListener("mouseup",this.onMouseUp),document.removeEventListener("mousemove",this.onMouseMove)}onAdhocFilterChange(e){this.setState({adhocFilter:e})}setSimpleTabIsValid(e){this.setState({isSimpleTabValid:e})}onSave(){this.props.onChange(this.state.adhocFilter),this.props.onClose()}onDragDown(e){this.dragStartX=e.clientX,this.dragStartY=e.clientY,this.dragStartWidth=this.state.width,this.dragStartHeight=this.state.height,document.addEventListener("mousemove",this.onMouseMove)}onMouseMove(e){this.props.onResize(),this.setState({width:Math.max(this.dragStartWidth+(e.clientX-this.dragStartX),f._R),height:Math.max(this.dragStartHeight+(e.clientY-this.dragStartY),f.Z_)})}onMouseUp(){document.removeEventListener("mousemove",this.onMouseMove)}onTabChange(e){this.setState({activeKey:e})}adjustHeight(e){this.setState((t=>({height:t.height+e})))}render(){const{adhocFilter:e,options:t,onChange:n,onClose:r,onResize:o,datasource:i,partitionColumn:s,theme:u,operators:h,requireSave:p,...m}=this.props,{adhocFilter:g}=this.state,v=g.isValid(),b=p||!g.equals(e);return(0,M.FD)(V,{id:"filter-edit-popover",...m,ref:this.popoverContentRef,children:[(0,M.FD)(c.Ay,{id:"adhoc-filter-edit-tabs",defaultActiveKey:g.expressionType,className:"adhoc-filter-edit-tabs",style:{minHeight:this.state.height,width:this.state.width},allowOverflow:!0,onChange:this.onTabChange,children:[(0,M.Y)(c.Ay.TabPane,{className:"adhoc-filter-edit-tab",tab:(0,l.t)("Simple"),children:(0,M.Y)(d.A,{children:(0,M.Y)(k,{operators:h,adhocFilter:this.state.adhocFilter,onChange:this.onAdhocFilterChange,options:t,datasource:i,onHeightChange:this.adjustHeight,partitionColumn:s,popoverRef:this.popoverContentRef.current,validHandler:this.setSimpleTabIsValid})})},E.A.Simple),(0,M.Y)(c.Ay.TabPane,{className:"adhoc-filter-edit-tab",tab:(0,l.t)("Custom SQL"),children:(0,M.Y)(d.A,{children:(0,M.Y)(H,{adhocFilter:this.state.adhocFilter,onChange:this.onAdhocFilterChange,options:this.props.options,height:this.state.height,activeKey:this.state.activeKey})})},E.A.Sql)]}),(0,M.FD)(B,{children:[(0,M.Y)(a.A,{buttonSize:"small",onClick:this.props.onClose,cta:!0,children:(0,l.t)("Close")}),(0,M.Y)(a.A,{disabled:!v||!this.state.isSimpleTabValid||!b,buttonStyle:"primary",buttonSize:"small",className:"m-r-5",onClick:this.onSave,cta:!0,children:(0,l.t)("Save")}),(0,M.Y)(j,{role:"button","aria-label":"Resize",tabIndex:0,onMouseDown:this.onDragDown,className:"fa fa-expand edit-popover-resize text-muted"})]})]})}}G.propTypes=W;var Q=n(16238),K=n(22533);class X extends r.PureComponent{constructor(e){super(e),this.onPopoverResize=this.onPopoverResize.bind(this),this.closePopover=this.closePopover.bind(this),this.togglePopover=this.togglePopover.bind(this),this.state={popoverVisible:!1}}onPopoverResize(){this.forceUpdate()}closePopover(){this.togglePopover(!1)}togglePopover(e){this.setState({popoverVisible:e})}render(){const{adhocFilter:e,isControlledComponent:t}=this.props,{visible:n,togglePopover:r,closePopover:o}=t?{visible:this.props.visible,togglePopover:this.props.togglePopover,closePopover:this.props.closePopover}:{visible:this.state.popoverVisible,togglePopover:this.togglePopover,closePopover:this.closePopover},i=(0,M.Y)(Q.y,{children:(0,M.Y)(G,{adhocFilter:e,options:this.props.options,datasource:this.props.datasource,partitionColumn:this.props.partitionColumn,onResize:this.onPopoverResize,onClose:o,sections:this.props.sections,operators:this.props.operators,onChange:this.props.onFilterEdit,requireSave:this.props.requireSave})});return(0,M.Y)(K.A,{trigger:"click",content:i,defaultVisible:n,visible:n,onVisibleChange:r,destroyTooltipOnHide:!0,children:this.props.children})}}const J=X},2511:(e,t,n)=>{var r,o;n.d(t,{A:()=>r,v:()=>o}),function(e){e.Simple="SIMPLE",e.Sql="SQL"}(r||(r={})),function(e){e.Having="HAVING",e.Where="WHERE"}(o||(o={}))},59638:(e,t,n)=>{n.d(t,{w:()=>m,K:()=>l});var r=n(96540),o=n(96627),i=n(77189),a=n(95483),s=n(2511);const l=e=>{const[t,n]=(0,r.useState)({});return(0,r.useEffect)((()=>{e.operator===a.ux.TemporalRange&&e.expressionType===s.A.Simple||n({}),e.operator===a.ux.TemporalRange&&e.comparator===o.WC&&n({actualTimeRange:`${e.subject} (${o.WC})`,title:o.WC}),e.operator===a.ux.TemporalRange&&e.expressionType===s.A.Simple&&e.comparator!==o.WC&&t.title!==e.comparator&&(0,i.x9)(e.comparator,e.subject).then((({value:t,error:r})=>{n(r?{actualTimeRange:`${e.subject} (${e.comparator})`,title:r}:{actualTimeRange:null!=t?t:"",title:e.comparator})}))}),[e]),t};var d=n(95579),c=n(67984),u=n(45267),h=n(50317),p=n(2445);const m=({columnName:e,timeRange:t,datasource:n,onChange:r})=>(0,c.D)(e,n)?(0,p.FD)(p.FK,{children:[(0,p.Y)(h.A,{label:(0,d.t)("Time Range")}),(0,p.Y)(u.A,{value:t,name:"time_range",onChange:t=>r(e,t),overlayStyle:"Modal"})]}):void 0},71191:(e,t,n)=>{n.d(t,{e:()=>s});var r=n(808),o=n(95483),i=n(85183);const a={"==":"=","!=":"<>",">":">","<":"<",">=":">=","<=":"<=",IN:"IN","NOT IN":"NOT IN",LIKE:"LIKE",ILIKE:"ILIKE",REGEX:"REGEX","IS NOT NULL":"IS NOT NULL","IS NULL":"IS NULL","IS TRUE":"IS TRUE","IS FALSE":"IS FALSE","LATEST PARTITION":({datasource:e})=>`= '{{ presto.latest_partition('${e.schema}.${e.datasource_name}') }}'`},s=(e,{useSimple:t}={useSimple:!1})=>{if((0,r.md)(e)||t){const{subject:t,operator:n}=e,r="comparator"in e?e.comparator:void 0,s=n&&n===o.nS[o.ux.LatestPartition].operation?a[n](e):a[n];return(0,i.zJ)(t,s,r)}return(0,r.wF)(e)?e.sqlExpression:""}},72652:(e,t,n)=>{n.d(t,{B3:()=>C,Bt:()=>f,Gh:()=>y,JG:()=>T,JU:()=>v,Px:()=>_,XB:()=>D,a2:()=>g,f$:()=>w,p6:()=>S,yJ:()=>m});var r=n(96540),o=n(26206),i=n(30535),a=n(96453),s=n(17437),l=n(95579),d=n(66537),c=n(19129),u=n(12249),h=n(84080),p=n(2445);const m=a.I4.div`
  margin-bottom: ${({theme:e})=>e.gridUnit}px;
  :last-child {
    margin-bottom: 0;
  }
`,g=a.I4.div`
  display: flex;
  align-items: center;
  width: 100%;
  font-size: ${({theme:e})=>e.typography.sizes.s}px;
  height: ${({theme:e})=>6*e.gridUnit}px;
  background-color: ${({theme:e})=>e.colors.grayscale.light3};
  border-radius: 3px;
  cursor: ${({withCaret:e})=>e?"pointer":"default"};
`,v=a.I4.div`
  ${({theme:e})=>`\n    display: flex;\n    width: 100%;\n    overflow: hidden;\n    text-overflow: ellipsis;\n    align-items: center;\n    white-space: nowrap;\n    padding-left: ${e.gridUnit}px;\n    svg {\n      margin-right: ${e.gridUnit}px;\n    }\n    .type-label {\n      margin-right: ${2*e.gridUnit}px;\n      margin-left: ${e.gridUnit}px;\n      font-weight: ${e.typography.weights.normal};\n      width: auto;\n    }\n    .option-label {\n      display: inline;\n    }\n  `}
`,b=a.I4.span`
  overflow: hidden;
  text-overflow: ellipsis;
`,f=a.I4.div`
  height: 100%;
  border-left: solid 1px ${({theme:e})=>e.colors.grayscale.dark2}0C;
  margin-left: auto;
`,y=a.I4.div`
  height: 100%;
  width: ${({theme:e})=>6*e.gridUnit}px;
  border-right: solid 1px ${({theme:e})=>e.colors.grayscale.dark2}0C;
  cursor: pointer;
`,x=(0,a.I4)(d.W)`
  margin: 0 ${({theme:e})=>e.gridUnit}px;
`,C=a.I4.div`
  display: flex;
  align-items: center;
  justify-content: space-between;
`,S=a.I4.div`
  padding: ${({theme:e})=>e.gridUnit}px;
  border: solid 1px ${({theme:e})=>e.colors.grayscale.light2};
  border-radius: ${({theme:e})=>e.gridUnit}px;
`,A=s.i7`
  0% {
    right: 100%;
  }
  50% {
    left: 4px;
  }
  90% {
    right: 4px;
  }
  100% {
    left: 100%;
  }
`,w=a.I4.div`
  ${({theme:e,isLoading:t,canDrop:n,isDragging:r,isOver:o})=>`\n  position: relative;\n  padding: ${e.gridUnit}px;\n  border: ${!t&&r?`dashed 1px ${n?e.colors.info.dark1:e.colors.error.dark1}`:`solid 1px ${t&&r?e.colors.warning.light1:e.colors.grayscale.light2}`};\n  border-radius: ${e.gridUnit}px;\n  &:before,\n  &:after {\n    content: ' ';\n    position: absolute;\n    border-radius: ${e.gridUnit}px;\n  }\n  &:before {\n    display: ${r||t?"block":"none"};\n    background-color: ${n?e.colors.primary.base:e.colors.error.light1};\n    z-index: ${e.zIndex.aboveDashboardCharts};\n    opacity: ${e.opacity.light};\n    top: 1px;\n    right: 1px;\n    bottom: 1px;\n    left: 1px;\n  }\n  &:after {\n    display: ${t||n&&o?"block":"none"};\n    background-color: ${t?e.colors.grayscale.light3:e.colors.primary.base};\n    z-index: ${e.zIndex.dropdown};\n    opacity: ${e.opacity.mediumLight};\n    top: ${-e.gridUnit}px;\n    right: ${-e.gridUnit}px;\n    bottom: ${-e.gridUnit}px;\n    left: ${-e.gridUnit}px;\n    cursor: ${t?"wait":"auto"};\n  }\n  `}

  &:before {
    ${({theme:e,isLoading:t})=>t&&s.AH`
        animation: ${A} 2s ease-in infinite;
        background: linear-gradient(currentColor 0 0) 0 100%/0% 3px no-repeat;
        background-size: 100% ${e.gridUnit/2}px;
        top: auto;
        right: ${e.gridUnit}px;
        left: ${e.gridUnit}px;
        bottom: -${e.gridUnit/2}px;
        height: ${e.gridUnit/2}px;
      `};
  }
`,T=a.I4.div`
  display: flex;
  align-items: center;
  width: 100%;
  height: ${({theme:e})=>6*e.gridUnit}px;
  padding-left: ${({theme:e})=>e.gridUnit}px;
  font-size: ${({theme:e})=>e.typography.sizes.s}px;
  color: ${({theme:e})=>e.colors.grayscale.light1};
  border: dashed 1px ${({theme:e})=>e.colors.grayscale.light2};
  border-radius: ${({theme:e})=>e.gridUnit}px;
  cursor: ${({cancelHover:e})=>e?"inherit":"pointer"};

  :hover {
    background-color: ${({cancelHover:e,theme:t})=>e?"inherit":t.colors.grayscale.light4};
  }

  :active {
    background-color: ${({cancelHover:e,theme:t})=>e?"inherit":t.colors.grayscale.light3};
  }
`,D=a.I4.button`
  display: flex;
  align-items: center;
  justify-content: center;
  height: ${({theme:e})=>4*e.gridUnit}px;
  width: ${({theme:e})=>4*e.gridUnit}px;
  padding: 0;
  background-color: ${({theme:e})=>e.colors.primary.dark1};
  border: none;
  border-radius: 2px;

  :disabled {
    cursor: not-allowed;
    background-color: ${({theme:e})=>e.colors.grayscale.light1};
  }
`,_=({label:e,savedMetric:t,adhocMetric:n,onRemove:s,onMoveLabel:d,onDropLabel:C,withCaret:S,isFunction:A,type:w,index:T,isExtra:D,datasourceWarningMessage:_,tooltipTitle:Y,multi:F=!0,...I})=>{const $=(0,a.DP)(),E=(0,r.useRef)(null),M=(0,r.useRef)(null),R=null==t?void 0:t.metric_name,[,N]=(0,o.H)({accept:w,drop(){F&&(null==C||C())},hover(e,t){var n;if(!F)return;if(!E.current)return;const{dragIndex:r}=e,o=T;if(r===o)return;const i=null==(n=E.current)?void 0:n.getBoundingClientRect(),a=(i.bottom-i.top)/2,s=t.getClientOffset(),l=null!=s&&s.y?(null==s?void 0:s.y)-i.top:0;r<o&&l<a||r>o&&l>a||(null==d||d(r,o),e.dragIndex=o)}}),[{isDragging:k},O]=(0,i.i)({item:{type:w,dragIndex:T,value:null!=t&&t.metric_name?t:n},collect:e=>({isDragging:e.isDragging()})});return O(N(E)),(0,p.Y)(m,{ref:E,children:(0,p.FD)(g,{withCaret:S,...I,children:[(0,p.Y)(y,{role:"button",onClick:s,children:(0,p.Y)(u.A.XSmall,{iconColor:$.colors.grayscale.light1})}),(0,p.FD)(v,{children:[A&&(0,p.Y)(u.A.FieldDerived,{}),(()=>{const n=!k&&"string"==typeof e&&Y&&e&&Y!==e||!k&&M&&M.current&&M.current.scrollWidth>M.current.clientWidth;return t&&R?(0,p.Y)(h.b,{metric:t,labelRef:M,shouldShowTooltip:!k}):n?(0,p.Y)(c.m,{title:Y||e,children:(0,p.Y)(b,{ref:M,children:e})}):(0,p.Y)(b,{ref:M,children:e})})()]}),(!!_||D)&&(0,p.Y)(x,{icon:"exclamation-triangle",placement:"top",bsStyle:"warning",tooltip:_||(0,l.t)("\n                This filter was inherited from the dashboard's context.\n                It won't be saved when saving the chart.\n              ")}),S&&(0,p.Y)(f,{children:(0,p.Y)(u.A.CaretRight,{iconColor:$.colors.grayscale.light1})})]})})}},91643:(e,t,n)=>{n.d(t,{A:()=>v});var r=n(96453),o=n(45738),i=n(10286),a=n(19966),s=n(39091),l=n(8143),d=n(69633),c=n(78360),u=n(69172),h=n(2445);const p=(0,r.I4)(s.i8)`
  && {
    margin: 0 0 ${({theme:e})=>e.gridUnit}px;
  }
`;o.A.registerLanguage("markdown",l.A),o.A.registerLanguage("html",d.A),o.A.registerLanguage("sql",c.A),o.A.registerLanguage("json",u.A);const m=r.I4.div`
  height: 100%;
  display: flex;
  flex-direction: column;
`,g=(0,r.I4)(o.A)`
  flex: 1;
`,v=e=>{const{sql:t,language:n="sql"}=e;return(0,h.FD)(m,{children:[(0,h.Y)(a.A,{text:t,shouldShowText:!1,copyNode:(0,h.Y)(p,{buttonSize:"xsmall",children:(0,h.Y)("i",{className:"fa fa-clipboard"})})}),(0,h.Y)(g,{language:n,style:i.A,children:t})]},t)}},17432:(e,t,n)=>{n.d(t,{A:()=>p});var r=n(96540),o=n(96453),i=n(62952),a=n(51436),s=n(95579),l=n(17444),d=n(2514),c=n(91643),u=n(2445);const h=o.I4.div`
  height: 100%;
  display: flex;
  flex-direction: column;
`,p=e=>{const[t,n]=(0,r.useState)([]),[o,p]=(0,r.useState)(!1),[m,g]=(0,r.useState)(null);return(0,r.useEffect)((()=>{p(!0),(0,d.getChartDataRequest)({formData:e.latestQueryFormData,resultFormat:"json",resultType:"query"}).then((({json:e})=>{n((0,i.A)(e.result)),p(!1),g(null)})).catch((e=>{(0,a.h4)(e).then((({error:t,message:n})=>{g(t||n||e.statusText||(0,s.t)("Sorry, An error occurred")),p(!1)}))}))}),[JSON.stringify(e.latestQueryFormData)]),o?(0,u.Y)(l.A,{}):m?(0,u.Y)("pre",{children:m}):(0,u.Y)(h,{children:t.map((e=>e.query?(0,u.Y)(c.A,{sql:e.query,language:e.language||void 0}):null))})}},92013:(e,t,n)=>{n.d(t,{r:()=>s});var r=n(95579),o=n(24976),i=n(67553),a=n(2445);function s(e){return e.map((({column_name:e,verbose_name:t,is_certified:n,certified_by:s,description:l,type:d})=>({name:t||e,value:e,docHTML:(0,o.jS)({title:e,meta:d?`column: ${d}`:"column",body:`${null!=l?l:""}`,footer:n?(0,a.Y)(a.FK,{children:(0,r.t)("Certified by %s",s)}):void 0}),score:i.v9,meta:"column"})))}},60237:(e,t,n)=>{n.d(t,{T3:()=>c,cL:()=>u,kV:()=>s});var r=n(90179),o=n.n(r),i=n(35742);const a=["url_params"],s=e=>o()(e,a),l=(e,t)=>{let n="api/v1/explore/form_data";return e&&(n=n.concat(`/${e}`)),t&&(n=n.concat(`?tab_id=${t}`)),n},d=(e,t,n,r)=>{const o={datasource_id:e,datasource_type:t,form_data:JSON.stringify(s(n))};return r&&(o.chart_id=r),o},c=(e,t,n,r,o)=>i.A.post({endpoint:l(void 0,o),jsonPayload:d(e,t,n,r)}).then((e=>e.json.key)),u=(e,t,n,r,o,a)=>i.A.put({endpoint:l(n,a),jsonPayload:d(e,t,r,o)}).then((e=>e.json.message))},55976:(e,t,n)=>{n.d(t,{M:()=>p});var r=n(96540),o=n(96453),i=n(95579),a=n(17437),s=n(25946),l=n(14693),d=n(70175),c=n(86274),u=n(35233),h=n(2445);const p=({dataset:e,datasetId:t})=>{const n=(0,o.DP)(),[p,m]=(0,r.useState)(),[g,v]=(0,r.useState)(e?c.bk.Complete:c.bk.Loading);return(0,r.useEffect)((()=>{!e&&t&&(0,u.w)({endpoint:`/api/v1/dataset/${t}`}).then((({json:{result:e}})=>{m(e),v(c.bk.Complete)})).catch((()=>{v(c.bk.Error)}))}),[t,e]),{metadataBar:(0,r.useMemo)((()=>{const t=[],r=e||p;if(r){var o,u;const{changed_on_humanized:e,created_on_humanized:n,description:a,table_name:s,changed_by:l,created_by:c,owners:h}=r,p=(0,i.t)("Not available"),m=`${null!=(o=null==c?void 0:c.first_name)?o:""} ${null!=(u=null==c?void 0:c.last_name)?u:""}`.trim()||p,g=l?`${l.first_name} ${l.last_name}`:p,v=(null==h?void 0:h.length)>0?h.map((e=>`${e.first_name} ${e.last_name}`)):[p];t.push({type:d.Q.Table,title:s}),t.push({type:d.Q.LastModified,value:e,modifiedBy:g}),t.push({type:d.Q.Owner,createdBy:m,owners:v,createdOn:n}),a&&t.push({type:d.Q.Description,value:a})}return(0,h.FD)("div",{css:a.AH`
          display: flex;
          margin-bottom: ${4*n.gridUnit}px;
        `,children:[g===c.bk.Complete&&(0,h.Y)(l.Ay,{items:t,tooltipPlacement:"bottom"}),g===c.bk.Error&&(0,h.Y)(s.A,{type:"error",message:(0,i.t)("There was an error loading the dataset metadata")})]})}),[e,p,g,n.gridUnit]),status:g}}},32850:(e,t,n)=>{n.d(t,{v:()=>ie,A:()=>de});var r,o,i=n(17437),a=n(62193),s=n.n(a),l=n(96540),d=n(61225),c=n(72391),u=n(96453),h=n(27366),p=n(83505),m=n(95579),g=n(12249),v=n(75488),b=n(6749),f=n(50068),y=n(15151),x=n(93103),C=n(37020),S=n(93641),A=n(51436),w=n(93491),T=n(25946),D=n(17466),_=n(97987),Y=n(69193),F=n(90868),I=n(5261);!function(e){e.Dashboards="dashboards",e.Charts="charts"}(r||(r={})),function(e){e.Text="TEXT",e.PNG="PNG",e.CSV="CSV"}(o||(o={}));var $=n(50500),E=n(19968),M=n(85861),R=n(46920),N=n(51647);const k=(0,u.I4)(M.Ay)`
  .antd5-modal-body {
    padding: 0;
  }
`,O=u.I4.div`
  padding: ${({theme:e})=>`${3*e.gridUnit}px ${4*e.gridUnit}px ${2*e.gridUnit}px`};
  label {
    font-size: ${({theme:e})=>e.typography.sizes.s}px;
    color: ${({theme:e})=>e.colors.grayscale.light1};
  }
`,U=u.I4.div`
  border-top: 1px solid ${({theme:e})=>e.colors.grayscale.light2};
  padding: ${({theme:e})=>`${4*e.gridUnit}px ${4*e.gridUnit}px ${6*e.gridUnit}px`};
  .ant-select {
    width: 100%;
  }
  .control-label {
    font-size: ${({theme:e})=>e.typography.sizes.s}px;
    color: ${({theme:e})=>e.colors.grayscale.light1};
  }
`,q=u.I4.span`
  span {
    margin-right: ${({theme:e})=>2*e.gridUnit}px;
    vertical-align: middle;
  }
  .text {
    vertical-align: middle;
  }
`,L=u.I4.div`
  margin-bottom: ${({theme:e})=>7*e.gridUnit}px;

  h4 {
    margin-bottom: ${({theme:e})=>3*e.gridUnit}px;
  }
`,z=(0,u.I4)(N.l5)`
  margin-bottom: ${({theme:e})=>3*e.gridUnit}px;
  width: ${({theme:e})=>120*e.gridUnit}px;
`,H=u.I4.p`
  color: ${({theme:e})=>e.colors.error.base};
`,P=i.AH`
  margin-bottom: 0;
`,W=(0,u.I4)(R.A)`
  width: ${({theme:e})=>40*e.gridUnit}px;
`,j=e=>i.AH`
  margin: ${3*e.gridUnit}px 0 ${2*e.gridUnit}px;
`,V=u.I4.div`
  margin: ${({theme:e})=>8*e.gridUnit}px 0
    ${({theme:e})=>4*e.gridUnit}px;
`;(0,u.I4)(Y.s)`
  display: block;
  line-height: ${({theme:e})=>8*e.gridUnit}px;
`;var B=n(2445);const G=[S.Y.PivotTable,"table",S.Y.PairedTTest],Q={crontab:"0 12 * * 1"},K={},X=(0,I.Ay)((function({onHide:e,show:t=!1,dashboardId:n,chart:r,userId:a,userEmail:s,ccEmail:c,bccEmail:u,creationMethod:h,dashboardName:p,chartName:v}){var b;const f=null==r||null==(b=r.sliceFormData)?void 0:b.viz_type,y=!!r,x=y&&f&&G.includes(f),C=x?o.Text:o.PNG,S=p||v,I=(0,l.useMemo)((()=>({...Q,name:S?(0,m.t)("Weekly Report for %s",S):(0,m.t)("Weekly Report")})),[S]),M=(0,l.useCallback)(((e,t)=>"reset"===t?I:{...e,...t}),[I]),[R,N]=(0,l.useReducer)(M,I),[X,J]=(0,l.useState)(),Z=(0,d.wA)(),ee=(0,d.d4)((e=>{const t=n?ie.Dashboards:ie.Charts;return(0,$.oi)(e,t,n||(null==r?void 0:r.id))||K})),te=ee&&Object.keys(ee).length;(0,l.useEffect)((()=>{N(te?ee:"reset")}),[te,ee]);const ne=(0,B.FD)(q,{children:[(0,B.Y)(g.A.Calendar,{}),(0,B.Y)("span",{className:"text",children:te?(0,m.t)("Edit email report"):(0,m.t)("Schedule a new email report")})]}),re=(0,B.FD)(B.FK,{children:[(0,B.Y)(W,{onClick:e,children:(0,m.t)("Cancel")},"back"),(0,B.Y)(W,{buttonStyle:"primary",onClick:async()=>{const t={type:"Report",active:!0,force_screenshot:!1,custom_width:R.custom_width,creation_method:h,dashboard:n,chart:null==r?void 0:r.id,owners:[a],recipients:[{recipient_config_json:{target:s,ccTarget:c,bccTarget:u},type:"Email"}],name:R.name,description:R.description,crontab:R.crontab,report_format:R.report_format||C,timezone:R.timezone};N({isSubmitting:!0,error:void 0});try{te?await Z((0,w.Zp)(R.id,t)):await Z((0,w.ef)(t)),e()}catch(e){const{error:t}=await(0,A.h4)(e);N({error:t})}N({isSubmitting:!1})},disabled:!R.name,loading:R.isSubmitting,children:te?(0,m.t)("Save"):(0,m.t)("Add")},"submit")]}),oe=(0,B.FD)(B.FK,{children:[(0,B.Y)(V,{children:(0,B.Y)("h4",{children:(0,m.t)("Message content")})}),(0,B.Y)("div",{className:"inline-container",children:(0,B.Y)(Y.s.GroupWrapper,{spaceConfig:{direction:"vertical",size:"middle",align:"start",wrap:!1},onChange:e=>{N({report_format:e.target.value})},value:R.report_format||C,options:[{label:(0,m.t)("Text embedded in email"),value:o.Text},{label:(0,m.t)("Image (PNG) embedded in email"),value:o.PNG},{label:(0,m.t)("Formatted CSV attached in email"),value:o.CSV}]})})]}),ae=(0,B.FD)(E.tu,{children:[(0,B.Y)("div",{className:"control-label",css:j,children:(0,m.t)("Screenshot width")}),(0,B.Y)("div",{className:"input-container",children:(0,B.Y)(F.pd,{type:"number",name:"custom_width",value:(null==R?void 0:R.custom_width)||"",placeholder:(0,m.t)("Input custom width in pixels"),onChange:e=>{N({custom_width:parseInt(e.target.value,10)||null})}})})]});return(0,B.FD)(k,{show:t,onHide:e,title:ne,footer:re,width:"432",centered:!0,children:[(0,B.FD)(O,{children:[(0,B.Y)(_.A,{id:"name",name:"name",value:R.name||"",placeholder:I.name,required:!0,validationMethods:{onChange:({target:e})=>N({name:e.value})},label:(0,m.t)("Report Name")}),(0,B.Y)(_.A,{id:"description",name:"description",value:(null==R?void 0:R.description)||"",validationMethods:{onChange:({target:e})=>{N({description:e.value})}},label:(0,m.t)("Description"),placeholder:(0,m.t)("Include a description that will be sent with your report"),css:P})]}),(0,B.FD)(U,{children:[(0,B.FD)(L,{children:[(0,B.Y)("h4",{css:e=>(e=>i.AH`
  margin: ${3*e.gridUnit}px 0;
`)(e),children:(0,m.t)("Schedule")}),(0,B.Y)("p",{children:(0,m.t)("The report will be sent to your email at")})]}),(0,B.Y)(z,{clearButton:!1,value:R.crontab||"0 12 * * 1",setValue:e=>{N({crontab:e})},onError:J}),(0,B.Y)(H,{children:X}),(0,B.Y)("div",{className:"control-label",css:e=>(e=>i.AH`
  margin: ${3*e.gridUnit}px 0 ${2*e.gridUnit}px;
`)(e),children:(0,m.t)("Timezone")}),(0,B.Y)(D.A,{timezone:R.timezone,onTimezoneChange:e=>{N({timezone:e})}}),y&&oe,(!y||!x)&&ae]}),R.error&&(0,B.Y)(T.A,{type:"error",css:e=>(e=>i.AH`
  margin: ${4*e.gridUnit}px;
  margin-top: 0;
`)(e),message:te?(0,m.t)("Failed to update report"):(0,m.t)("Failed to create report"),description:R.error})]})}));var J=n(15700);const Z=(0,c.a)(),ee=e=>i.AH`
  color: ${e.colors.error.base};
`,te=e=>i.AH`
  & .antd5-menu-item {
    padding: 5px 12px;
    margin-top: 0px;
    margin-bottom: 4px;
    :hover {
      color: ${e.colors.grayscale.dark1};
    }
  }
  :hover {
    background-color: ${e.colors.secondary.light5};
  }
`,ne=e=>i.AH`
  &:hover {
    color: ${e.colors.grayscale.dark1};
    background-color: ${e.colors.secondary.light5};
  }
`,re=u.I4.div`
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  > *:first-child {
    margin-right: ${({theme:e})=>e.gridUnit}px;
  }
`,oe=Z.get("report-modal.dropdown.item.icon");var ie;!function(e){e.Charts="charts",e.Dashboards="dashboards"}(ie||(ie={}));const ae={};var se={name:"1e1ncky",styles:"border:none"},le={name:"833hqy",styles:"width:200px"};function de({dashboardId:e,chart:t,useTextMenu:n=!1,setShowReportSubMenu:r,setIsDropdownVisible:o,isDropdownVisible:a,...c}){const S=(0,d.wA)(),A=(0,d.d4)((n=>{const r=e?ie.Dashboards:ie.Charts;return(0,$.oi)(n,r,e||(null==t?void 0:t.id))||ae})),T=(null==A?void 0:A.active)||!1,D=(0,d.d4)((e=>e.user)),_=()=>!!(0,h.G7)(h.TO.AlertReports)&&(!(null==D||!D.userId)&&(!!(e||null!=t&&t.id)&&Object.keys(D.roles||[]).map((e=>D.roles[e].filter((e=>"menu_access"===e[0]&&"Manage"===e[1])))).some((e=>e.length>0)))),[Y,F]=(0,l.useState)(null),I=(0,u.DP)(),E=(0,p.Z)(e),[M,R]=(0,l.useState)(!1),N=async(e,t)=>{null!=e&&e.id&&S((0,w.PM)(e,t))},k=_()&&!!(e&&E!==e||null!=t&&t.id);(0,l.useEffect)((()=>{k&&S((0,w.LQ)({userId:D.userId,filterField:e?"dashboard_id":"chart_id",creationMethod:e?"dashboards":"charts",resourceId:e||(null==t?void 0:t.id)}))}),[]);const O=A&&r&&_();(0,l.useEffect)((()=>{O?r(!0):!A&&r&&r(!1)}),[A]);const U=()=>{o&&(o(!1),R(!0))};return(0,B.Y)(B.FK,{children:_()&&(0,B.FD)(B.FK,{children:[(0,B.Y)(X,{userId:D.userId,show:M,onHide:()=>R(!1),userEmail:D.email,dashboardId:e,chart:t,creationMethod:e?ie.Dashboards:ie.Charts}),a?n?s()(A)?(0,B.FD)(b.W1,{selectable:!1,...c,css:te,children:[(0,B.Y)(b.W1.Item,{onClick:U,children:oe?(0,B.FD)(re,{children:[(0,B.Y)("div",{children:(0,m.t)("Set up an email report")}),(0,B.Y)(oe,{})]}):(0,m.t)("Set up an email report")}),(0,B.Y)(b.W1.Divider,{})]}):(0,B.FD)(b.W1,{selectable:!1,css:se,children:[(0,B.Y)(b.W1.Item,{css:ne,onClick:()=>N(A,!T),children:(0,B.FD)(J.t3,{children:[(0,B.Y)(f.Ay,{checked:T,onChange:y.fZ}),(0,m.t)("Email reports active")]})}),(0,B.Y)(b.W1.Item,{css:ne,onClick:U,children:(0,m.t)("Edit email report")}),(0,B.Y)(b.W1.Item,{css:ne,onClick:()=>{o&&(o(!1),F(A))},children:(0,m.t)("Delete email report")})]}):s()(A)?(0,B.Y)("span",{role:"button",title:(0,m.t)("Schedule email report"),tabIndex:0,className:"action-button action-schedule-report",onClick:()=>R(!0),children:(0,B.Y)(g.A.Calendar,{})}):(0,B.Y)(B.FK,{children:(0,B.Y)(x.R2,{overlay:(0,B.FD)(b.W1,{selectable:!1,css:le,children:[(0,B.FD)(b.W1.Item,{children:[(0,m.t)("Email reports active"),(0,B.Y)(v.d,{checked:T,onClick:e=>N(A,e),size:"small",css:(0,i.AH)({marginLeft:2*I.gridUnit},"","")})]}),(0,B.Y)(b.W1.Item,{onClick:()=>R(!0),children:(0,m.t)("Edit email report")}),(0,B.Y)(b.W1.Item,{onClick:()=>F(A),css:ee,children:(0,m.t)("Delete email report")})]}),overlayStyle:{zIndex:99,animationDuration:"0s"},trigger:["click"],getPopupContainer:e=>e.closest(".action-button"),children:(0,B.Y)("span",{role:"button",className:"action-button action-schedule-report",tabIndex:0,children:(0,B.Y)(g.A.Calendar,{})})})}):null,Y&&(0,B.Y)(C.A,{description:(0,m.t)("This action will permanently delete %s.",null==Y?void 0:Y.name),onConfirm:()=>{Y&&(async e=>{await S((0,w.i7)(e)),F(null)})(Y)},onHide:()=>F(null),open:!0,title:(0,m.t)("Delete Report?")})]})})}},53860:(e,t,n)=>{n.d(t,{S:()=>i});var r=n(61225),o=n(84666);const i=()=>{const e=(0,r.d4)((e=>{var t;return(0,o.L)("can_explore","Superset",null==(t=e.user)?void 0:t.roles)})),t=(0,r.d4)((e=>{var t;return(0,o.L)("can_write","ExploreFormDataRestApi",null==(t=e.user)?void 0:t.roles)})),n=(0,r.d4)((e=>{var t;return(0,o.L)("can_samples","Datasource",null==(t=e.user)?void 0:t.roles)})),i=(0,r.d4)((e=>{var t;return(0,o.L)("can_csv","Superset",null==(t=e.user)?void 0:t.roles)})),a=(0,r.d4)((e=>{var t;return(0,o.L)("can_drill","Dashboard",null==(t=e.user)?void 0:t.roles)}));return{canExplore:e,canWriteExploreFormData:t,canDatasourceSamples:n,canDownload:i,canDrill:a,canDrillBy:(e||a)&&t,canDrillToDetail:(e||a)&&n,canViewQuery:(0,r.d4)((e=>{var t;return(0,o.L)("can_view_query","Dashboard",null==(t=e.user)?void 0:t.roles)})),canViewTable:(0,r.d4)((e=>{var t;return(0,o.L)("can_view_chart_as_table","Dashboard",null==(t=e.user)?void 0:t.roles)}))}}},48422:(e,t,n)=>{n.d(t,{w:()=>a});var r=n(96540),o=n(43561);const i=new BroadcastChannel("tab_id_channel");function a(){const[e,t]=(0,r.useState)();return(0,r.useEffect)((()=>{if(!function(){try{return window.localStorage&&window.sessionStorage}catch(e){return!1}}())return void(e||t((0,o.Ak)()));const n=()=>{let e;try{e=window.localStorage.getItem("last_tab_id")}catch(e){}const n=String(e?Number.parseInt(e,10)+1:1);try{window.sessionStorage.setItem("tab_id",n),window.localStorage.setItem("last_tab_id",n)}catch(e){}t(n)};let r;try{r=window.sessionStorage.getItem("tab_id")}catch(e){}r?(i.postMessage({type:"REQUESTING_TAB_ID",tabId:r}),t(r)):n(),i.onmessage=t=>{if(t.data.tabId===e)if("REQUESTING_TAB_ID"===t.data.type){const e={type:"TAB_ID_DENIED",tabId:t.data.tabId};i.postMessage(e)}else"TAB_ID_DENIED"===t.data.type&&n()}}),[e]),e}},35233:(e,t,n)=>{n.d(t,{e:()=>i,w:()=>a});var r=n(35742),o=n(43859);const i=new Map,a=(0,o.K)(r.A.get,i,(({endpoint:e})=>e||""))},72965:(e,t,n)=>{n.d(t,{A:()=>u});var r=n(20249),o=n.n(r),i=n(67390),a=n.n(i),s=n(95579),l=n(96453),d=n(95272);const c=(e,t=new Date)=>`${o()(e)}-${t.toISOString().replace(/[: ]/g,"-")}`;function u(e,t,n=!1){return r=>{const o=n?document.querySelector(e):r.currentTarget.closest(e);return o?a().toJpeg(o,{bgcolor:l.TT.colors.grayscale.light4,filter:e=>"string"!=typeof e.className||"mapboxgl-control-container"!==e.className&&!e.className.includes("header-controls")}).then((e=>{const n=document.createElement("a");n.download=`${c(t)}.jpg`,n.href=e,n.click()})).catch((e=>{console.error("Creating image failed",e)})):(0,d.Zd)((0,s.t)("Image download failed, please refresh and try again."))}}},21357:(e,t,n)=>{n.d(t,{w:()=>a});var r=n(95579);const o=(0,r.t)("Create chart"),i=(0,r.t)("Update chart"),a=e=>(0,r.t)("Select values in highlighted field(s) in the control panel. Then run the query by clicking on the %s button.",`"${e?o:i}"`)},92201:(e,t,n)=>{n.d(t,{a:()=>r});const r=()=>{var e,t;return null==(e=window)||null==(t=e.navigator)?void 0:t.webdriver}},59838:(e,t,n)=>{n.d(t,{r:()=>s});var r=n(70700),o=n(2511),i=n(95483),a=n(71191);const s=(e,t=o.v.Where)=>{let n;var s;return n=(0,r.q0)(e.col)?{expressionType:"SQL",clause:t,sqlExpression:(0,a.e)({expressionType:o.A.Simple,subject:`(${e.col.sqlExpression})`,operator:e.op,comparator:"val"in e?e.val:void 0})}:{expressionType:"SIMPLE",clause:t,operator:e.op,operatorId:null==(s=Object.entries(i.nS).find((t=>t[1].operation===e.op)))?void 0:s[0],subject:e.col,comparator:"val"in e?e.val:void 0},e.isExtra&&Object.assign(n,{isExtra:!0,filterOptionName:`filter_${Math.random().toString(36).substring(2,15)}_${Math.random().toString(36).substring(2,15)}`}),n}}}]);