"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[1002],{39025(C,D,n){n.d(D,{FM:()=>E,K4:()=>m,nE:()=>s});var O=n(72830),g=n(69192),f=n(35831),p=n(17727),r=n(52358),a=n(28520),l=n(55791),_=n(33143);function h(o){return t=>{for(const e of t.fields)if(o(e,t,[]))return e}}function u(o){return t=>{for(const e of t.fields){if(o.has(e.name.toLowerCase()))return e;const d=(0,O.Ct)(e,t);if(o.has(d))return e}}}const M={mode:a.aG.Auto,geohash:u(new Set(["geohash"])),latitude:u(new Set(["latitude","lat"])),longitude:u(new Set(["longitude","lon","lng"])),h3:u(new Set(["h3"])),wkt:u(new Set(["wkt"])),lookup:u(new Set(["lookup"])),geo:o=>o.fields.find(t=>t.type===p.PU.geo)};function m(){return{...M,mode:a.aG.Auto}}async function s(o){const t={...M,mode:o?.mode??a.aG.Auto};switch(t.gazetteer=await(0,_.q3)(o?.gazetteer),t.mode){case a.aG.Geohash:o?.geohash?t.geohash=h((0,g.NS)({id:f.Ct.byName,options:o.geohash})):t.geohash=()=>{};break;case a.aG.Lookup:const e=o?.lookup?.length?(0,g.NS)({id:f.Ct.byName,options:o.lookup}):(0,g.NS)({id:f.Ct.byType,options:p.PU.string});t.lookup=h(e);break;case a.aG.Coords:o?.latitude?t.latitude=h((0,g.NS)({id:f.Ct.byName,options:o.latitude})):t.latitude=()=>{},o?.longitude?t.longitude=h((0,g.NS)({id:f.Ct.byName,options:o.longitude})):t.longitude=()=>{};break}return t}function i(o,t){const e={mode:t.mode??a.aG.Auto};if(e.mode===a.aG.Auto){if(e.geo=t.geo(o),e.geo)return e;if(e.latitude=t.latitude(o),e.longitude=t.longitude(o),e.latitude&&e.longitude)return e.mode=a.aG.Coords,e;if(e.geohash=t.geohash(o),e.geohash)return e.mode=a.aG.Geohash,e;if(e.lookup=t.lookup(o),e.lookup)return e.mode=a.aG.Lookup,e}switch(e.mode){case a.aG.Coords:e.latitude=t.latitude(o),e.longitude=t.longitude(o);break;case a.aG.Geohash:e.geohash=t.geohash(o);break;case a.aG.Lookup:e.lookup=t.lookup(o);break}return e}function E(o,t){const e=i(o,t);switch(e.mode){case a.aG.Auto:return e.geo?{field:e.geo}:{warning:(0,r.t)("geo.get-geometry-field.warning-unable-to-find","Unable to find location fields")};case a.aG.Coords:return e.latitude&&e.longitude?{field:(0,l.Pz)(e.longitude,e.latitude),derived:!0,description:`${e.mode}: ${e.latitude.name}, ${e.longitude.name}`}:{warning:(0,r.t)("geo.get-geometry-field.warning-select-lat-long","Select latitude/longitude fields")};case a.aG.Geohash:return e.geohash?{field:(0,l.qy)(e.geohash),derived:!0,description:`${e.mode}`}:{warning:(0,r.t)("geo.get-geometry-field.warning-select-geohash","Select geohash field")};case a.aG.Lookup:return e.lookup?t.gazetteer?{field:(0,l.Dc)(t.gazetteer,e.lookup),derived:!0,description:`${e.mode}: ${t.gazetteer.path}`}:{warning:(0,r.t)("geo.get-geometry-field.warning-gazetteer-not-found","Gazetteer not found")}:{warning:(0,r.t)("geo.get-geometry-field.warning-select-lookup","Select lookup field")}}return{warning:(0,r.t)("geo.get-geometry-field.warning-no-geometry","unable to find geometry")}}},91002(C,D,n){n.d(D,{B:()=>M,getSpatialTransformer:()=>u});var O=n(65474),g=n(69862),f=n(19560),p=n(17727),r=n(52358),a=n(55791),l=n(39025),_=n(2823),h=n(97932);const u=()=>({id:f.F.spatial,name:(0,r.t)("transformers.get-spatial-transformer.name.spatial-operations","Spatial operations"),description:(0,r.t)("transformers.get-spatial-transformer.description.apply-spatial-operations-to-query-results","Apply spatial operations to query results."),defaultOptions:{},operator:s=>i=>i.pipe((0,g.Z)(E=>(0,O.H)(m(E,s))))});function M(s){return s.action===_.dy.Modify&&s.modify?.op===_.YD.LineBuilder}async function m(s,i){const E=await(0,l.nE)(i.source);if(M(i)){const o=await(0,l.nE)(i.modify?.target);return s.map(t=>{const e=(0,l.FM)(t,E),d=(0,l.FM)(t,o);if(e.field&&d.field){const c=[...t.fields],y=(0,a.XR)(e.field,d.field),P=c[0];return P.type===p.PU.geo&&P!==e.field&&P!==d.field?c[0]=(0,a.RA)(P,y):c.unshift(y),{...t,fields:c}}return t})}return s.map(o=>{let t=(0,l.FM)(o,E);if(t.field){if(i.action===_.dy.Modify){switch(i.modify?.op){case _.YD.AsLine:let d=t.field.name;return(!d||d==="Point")&&(d="Line"),{...o,length:1,fields:[{...t.field,name:d,type:p.PU.geo,values:[(0,h.tt)(t.field)]}]}}return o}const e=t.derived?[t.field,...o.fields]:o.fields.slice(0);if(i.action===_.dy.Calculate&&(e.push((0,h.pp)(t.field,i.calculate??{})),t.derived=!0),t.derived)return{...o,fields:e}}return o})}}}]);

//# sourceMappingURL=1002.8b047d3d726cb4158026.js.map