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

//# sourceMappingURL=4781.68192953d78d11616bbe.js.map