"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[4781],{54781(L,R,n){n.d(R,{getConfigFromDataTransformer:()=>C});var c=n(81160),F=n(72830),A=n(69192),P=n(19560),D=n(35831),_=n(76529),y=n(52358),O=n(64333);function U(g,d){let i=null;for(const s of d)if(s.refId===g.configRefId){i=s;break}if(!i)return d;const v={fields:[],length:1},m=(0,O.L5)(i,g.mappings??[],!1);for(const s of i.fields){const p={...s},e=(0,F.Ct)(s,i),a=m.index[e],o=(0,_.Nw)({field:s,reducers:[a.reducerId]});p.values=[o[a.reducerId]],v.fields.push(p)}const T=[],M=(0,A.NS)(g.applyTo||{id:D.Ct.numeric});for(const s of d){if(s===i&&d.length>1)continue;const p={...s,fields:[]};for(const e of s.fields)if(M(e,s,d)){const a=(0,O.cZ)(v,0,m);p.fields.push({...e,config:{...e.config,...a}})}else p.fields.push(e);T.push(p)}return T}const C=()=>({id:P.F.configFromData,name:(0,y.t)("transformers.get-config-from-data-transformer.name.config-from-query-results","Config from query results"),description:(0,y.t)("transformers.get-config-from-data-transformer.description.set-unit-min-max-and-more","Set unit, min, max and more."),defaultOptions:{configRefId:"config",mappings:[]},operator:g=>d=>d.pipe((0,c.T)(i=>U(g,i)))})},64333(L,R,n){n.d(R,{L5:()=>p,Mc:()=>i,V1:()=>s,cZ:()=>g,we:()=>d});var c=n(2543),F=n.n(c),A=n(70479),P=n(72830),D=n(18472),_=n(76529),y=n(8175),O=n(83128),U=n(92061),C=n(17727);function g(e,a,o){const r={},u={};for(const I of e.fields){const t=(0,P.Ct)(I,e),E=o.index[t],f=E.handler;if(!f)continue;const h=I.values[a];if(h==null)continue;const l=f.processor(h,r,u,E.handlerArguments);l!=null&&(r[f.targetProperty??f.key]=l)}return u.mappingValues&&(r.mappings=v(u)),r.thresholds&&(r.thresholds.steps=(0,A.RU)(r.thresholds.steps)),r}var d=(e=>(e.Name="field.name",e.Value="field.value",e.Label="field.label",e.Ignore="__ignore",e))(d||{});const i=[{key:"field.name",name:"Field name",processor:()=>{}},{key:"field.value",name:"Field value",processor:()=>{}},{key:"field.label",name:"Field label",processor:()=>{}},{key:"__ignore",name:"Ignore",processor:()=>{}},{key:"max",processor:M},{key:"min",processor:M},{key:"unit",processor:e=>e.toString()},{key:"decimals",processor:M},{key:"displayName",name:"Display name",processor:e=>e.toString()},{key:"color",processor:e=>({fixedColor:e,mode:y.Y.Fixed})},{key:"threshold1",name:"Threshold",targetProperty:"thresholds",processor:(e,a,o,r)=>{const u=(0,D.t)(e);if(!isNaN(u))return a.thresholds||(a.thresholds={mode:O.O.Absolute,steps:[]}),a.thresholds.steps.push({value:u,color:r.threshold?.color??"red"}),a.thresholds}},{key:"mappings.value",name:"Value mappings / Value",targetProperty:"mappings",defaultReducer:_.gy.allValues,processor:(e,a,o)=>{if((0,c.isArray)(e))return o.mappingValues=e,a.mappings}},{key:"mappings.color",name:"Value mappings / Color",targetProperty:"mappings",defaultReducer:_.gy.allValues,processor:(e,a,o)=>{if((0,c.isArray)(e))return o.mappingColors=e,a.mappings}},{key:"mappings.text",name:"Value mappings / Display text",targetProperty:"mappings",defaultReducer:_.gy.allValues,processor:(e,a,o)=>{if((0,c.isArray)(e))return o.mappingTexts=e,a.mappings}}];function v(e){const a={type:U.d.ValueToText,options:{}};if(!e.mappingValues)return[];for(let o=0;o<e.mappingValues.length;o++){const r=e.mappingValues[o];r!=null&&(a.options[r.toString()]={color:e.mappingColors&&e.mappingColors[o],text:e.mappingTexts&&e.mappingTexts[o],index:o})}return[a]}let m=null;function T(){if(m===null){m={};for(const e of i)m[e.key]=e}return m}function M(e){const a=(0,D.t)(e);if(!isNaN(a))return a}function s(e){return e?T()[e]:null}function p(e,a,o){const r={index:{}};let u=a.find(t=>t.handlerKey==="field.name"),I=a.find(t=>t.handlerKey==="field.value");for(const t of e.fields){const E=(0,P.Ct)(t,e),f=a.find(B=>B.fieldName===E),h=f?f.handlerKey:E.toLowerCase();let l=s(h);o&&(l?(l.key==="field.name"&&(r.nameField=t),l.key==="field.value"&&(r.valueField=t)):f||(!r.nameField&&!u&&t.type===C.PU.string&&(r.nameField=t,l=s("field.name")),!r.valueField&&!I&&t.type===C.PU.number&&(r.valueField=t,l=s("field.value")))),!l&&o&&(l=s("field.label")),r.index[E]={automatic:!f,handler:l,handlerArguments:f?.handlerArguments??{},reducerId:f?.reducerId??l?.defaultReducer??_.gy.lastNotNull}}return r}}}]);

//# sourceMappingURL=4781.2c98905d7df5fb0e0e7e.js.map