"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8373],{64333(L,T,l){l.d(T,{L5:()=>R,Mc:()=>d,V1:()=>m,cZ:()=>t,we:()=>i});var M=l(2543),A=l.n(M),v=l(72830),P=l(18472),_=l(76529),C=l(8175),F=l(83128),I=l(92061),u=l(17727);function t(e,n,a){const r={},y={};for(const D of e.fields){const s=(0,v.Ct)(D,e),h=a.index[s],p=h.handler;if(!p)continue;const O=D.values[n];if(O==null)continue;const o=p.processor(O,r,y,h.handlerArguments);o!=null&&(r[p.targetProperty??p.key]=o)}return y.mappingValues&&(r.mappings=c(y)),r}var i=(e=>(e.Name="field.name",e.Value="field.value",e.Label="field.label",e.Ignore="__ignore",e))(i||{});const d=[{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:C.Y.Fixed})},{key:"threshold1",name:"Threshold",targetProperty:"thresholds",processor:(e,n,a,r)=>{const y=(0,P.t)(e);if(!isNaN(y))return n.thresholds||(n.thresholds={mode:F.O.Absolute,steps:[]}),n.thresholds.steps.push({value:y,color:r.threshold?.color??"red"}),n.thresholds}},{key:"mappings.value",name:"Value mappings / Value",targetProperty:"mappings",defaultReducer:_.gy.allValues,processor:(e,n,a)=>{if((0,M.isArray)(e))return a.mappingValues=e,n.mappings}},{key:"mappings.color",name:"Value mappings / Color",targetProperty:"mappings",defaultReducer:_.gy.allValues,processor:(e,n,a)=>{if((0,M.isArray)(e))return a.mappingColors=e,n.mappings}},{key:"mappings.text",name:"Value mappings / Display text",targetProperty:"mappings",defaultReducer:_.gy.allValues,processor:(e,n,a)=>{if((0,M.isArray)(e))return a.mappingTexts=e,n.mappings}}];function c(e){const n={type:I.d.ValueToText,options:{}};if(!e.mappingValues)return[];for(let a=0;a<e.mappingValues.length;a++){const r=e.mappingValues[a];r!=null&&(n.options[r.toString()]={color:e.mappingColors&&e.mappingColors[a],text:e.mappingTexts&&e.mappingTexts[a],index:a})}return[n]}let g=null;function f(){if(g===null){g={};for(const e of d)g[e.key]=e}return g}function E(e){const n=(0,P.t)(e);if(!isNaN(n))return n}function m(e){return e?f()[e]:null}function R(e,n,a){const r={index:{}};let y=n.find(s=>s.handlerKey==="field.name"),D=n.find(s=>s.handlerKey==="field.value");for(const s of e.fields){const h=(0,v.Ct)(s,e),p=n.find(U=>U.fieldName===h),O=p?p.handlerKey:h.toLowerCase();let o=m(O);a&&(o?(o.key==="field.name"&&(r.nameField=s),o.key==="field.value"&&(r.valueField=s)):p||(!r.nameField&&!y&&s.type===u.PU.string&&(r.nameField=s,o=m("field.name")),!r.valueField&&!D&&s.type===u.PU.number&&(r.valueField=s,o=m("field.value")))),!o&&a&&(o=m("field.label")),r.index[h]={automatic:!p,handler:o,handlerArguments:p?.handlerArguments??{},reducerId:p?.reducerId??o?.defaultReducer??_.gy.lastNotNull}}return r}},18373(L,T,l){l.d(T,{getRowsToFieldsTransformer:()=>C});var M=l(81160),A=l(72830),v=l(19560),P=l(52358),_=l(64333);const C=()=>({id:v.F.rowsToFields,name:(0,P.t)("transformers.get-rows-to-fields-transformer.name.rows-to-fields","Rows to fields"),description:(0,P.t)("transformers.get-rows-to-fields-transformer.description.convert-field-dynamic-config","Convert each row into a field with dynamic config."),defaultOptions:{},operator:u=>t=>t.pipe((0,M.T)(i=>i.map(d=>F(u,d))))});function F(u,t){const i=(0,_.L5)(t,u.mappings??[],!0),{nameField:d,valueField:c}=i;if(!d||!c)return t;const g=[];for(let f=0;f<d.values.length;f++){const E=d.values[f],m=c.values[f],R=(0,_.cZ)(t,f,i),e=I(t,f,i),n={name:`${E}`,type:c.type,values:[m],config:R,labels:e};g.push(n)}return{fields:g,length:1,refId:`${v.F.rowsToFields}-${t.refId}`}}function I(u,t,i){const d={...i.nameField.labels};for(let c=0;c<u.fields.length;c++){const g=u.fields[c],f=(0,A.Ct)(g,u),E=i.index[f];if(E.handler&&E.handler.key!==_.we.Label)continue;const m=g.values[t];m!=null&&(d[f]=m)}return d}}}]);

//# sourceMappingURL=8373.2f4d332c61313a04cc7a.js.map