"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[3293],{73293(T,M,r){r.d(M,{GroupByTransformerEditor:()=>m});var n=r(14553),E=r(22803),d=r(55501),c=r(76529),i=r(13048),o=r(52358),D=r(89702),P=r(33100),O=r(68763),p=r(72480),h=r(78364),B=r(49439),C=r(75251);const v=({options:l,onChange:t,fieldNames:e})=>{const _=(0,d.useCallback)(a=>f=>{t({...l,fields:{...l.fields,[a]:f}})},[t]);let s,g=!1;for(const a of Object.values(l.fields))a.aggregations.length>0&&a.operation!==null&&(g=!0),a.operation===i.R3.groupBy&&(s=!0);const u=g&&!s;return(0,n.jsxs)(O.B,{direction:"column",children:[u&&(0,n.jsx)(P.F,{title:(0,o.t)("transformers.group-by-transformer-editor.title-calc-alert","Calculations will not have an effect if no fields are being grouped on"),severity:"warning"}),e.map(a=>(0,n.jsx)(R,{onConfigChange:_(a),fieldName:a,config:l.fields[a]},a))]})},m=(0,C.fJ)(v,{withBaseFieldNames:!0}),R=({fieldName:l,config:t,onConfigChange:e})=>{const _=(0,B.$j)(),s=y(_),g=(0,d.useCallback)(a=>{e({aggregations:t?.aggregations??[],operation:a?.value??null})},[t,e]),u=[{label:(0,o.t)("transformers.group-by-field-configuration.options.label.group-by","Group by"),value:i.R3.groupBy},{label:(0,o.t)("transformers.group-by-field-configuration.options.label.calculate","Calculate"),value:i.R3.aggregate}];return(0,n.jsx)(p.I,{className:s.label,label:l,grow:!0,shrink:!0,children:(0,n.jsxs)(O.B,{gap:.5,direction:"row",children:[(0,n.jsx)("div",{className:s.operation,children:(0,n.jsx)(h.G,{options:u,value:t?.operation,placeholder:(0,o.t)("transformers.group-by-field-configuration.placeholder-ignored","Ignored"),onChange:g,isClearable:!0})}),t?.operation&&(0,n.jsx)(D.S,{placeholder:(0,o.t)("transformers.group-by-field-configuration.placeholder-select-stats","Select stats"),allowMultiple:!0,stats:t.aggregations,onChange:a=>{e({...t,aggregations:a.filter(f=>f in c.gy)})},filterOptions:a=>t?.operation===i.R3.groupBy?a.id===c.gy.count:!0})]})})},y=l=>({label:(0,E.css)({label:{minWidth:l.spacing(32)}}),operation:(0,E.css)({flexShrink:0,height:"100%",width:l.spacing(24)})})}}]);

//# sourceMappingURL=3293-react19.63ee3fa865d41daa2892.js.map