"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[707],{54391:(H,V,t)=>{t.d(V,{R:()=>d});var a=t(32196),e=t(96540),U=t(40845),T=t(14578),c=t(10354),u=t(72093);const d=({name:s,onChange:W,verifyLayerNameUniqueness:r,overrideStyles:z})=>{const l=(0,U.of)(S),[O,E]=(0,e.useState)(!1),[I,p]=(0,e.useState)(null),L=i=>{E(!0)},D=i=>{if(E(!1),I){p(null);return}s!==i&&W(i)},F=i=>{const A=i.currentTarget.value.trim();if(A.length===0){p("An empty layer name is not allowed");return}if(r&&!r(A)&&A!==s){p("Layer name already exists");return}I&&p(null)},x=i=>{D(i.currentTarget.value.trim())},M=i=>{i.key==="Enter"&&D(i.currentTarget.value)},Q=i=>{i.target.select()};return e.createElement(e.Fragment,null,e.createElement("div",{className:l.wrapper},!O&&e.createElement("button",{className:l.layerNameWrapper,title:"Edit layer name",onClick:L,"data-testid":"layer-name-div"},e.createElement("span",{className:z?"":l.layerName},s),e.createElement(T.I,{name:"pen",className:l.layerEditIcon,size:"sm"})),O&&e.createElement(e.Fragment,null,e.createElement(c.p,{type:"text",defaultValue:s,onBlur:x,autoFocus:!0,onKeyDown:M,onFocus:Q,invalid:I!==null,onChange:F,className:l.layerNameInput,"data-testid":"layer-name-input"}),I&&e.createElement(u.P,{horizontal:!0},I))))},S=s=>({wrapper:(0,a.css)({label:"Wrapper",display:"flex",alignItems:"center",marginLeft:s.spacing(.5)}),layerNameWrapper:(0,a.css)({display:"flex",cursor:"pointer",border:"1px solid transparent",borderRadius:s.shape.radius.default,alignItems:"center",padding:`0 0 0 ${s.spacing(.5)}`,margin:0,background:"transparent","&:hover":{background:s.colors.action.hover,border:`1px dashed ${s.colors.border.strong}`},"&:focus":{border:`2px solid ${s.colors.primary.border}`},"&:hover, &:focus":{".query-name-edit-icon":{visibility:"visible"}}}),layerName:(0,a.css)({fontWeight:s.typography.fontWeightMedium,color:s.colors.primary.text,cursor:"pointer",overflow:"hidden",marginLeft:s.spacing(.5)}),layerEditIcon:(0,a.cx)((0,a.css)({marginLeft:s.spacing(2),visibility:"hidden"}),"query-name-edit-icon"),layerNameInput:(0,a.css)({maxWidth:"300px",margin:"-4px 0"})})},21934:(H,V,t)=>{t.d(V,{N:()=>S});var a=t(32196),e=t(96540),U=t(40845),T=t(88323),c=t(83598),u=t(64278);const d={label:"Fixed color",value:"_____fixed_____"},S=W=>{const{value:r,context:z,onChange:l,item:O}=W,E="dark-green",I=(0,U.of)(s),p=r?.field,L=r&&!p&&r?.fixed,D=(0,u.sE)(z.data),F=(0,u.m3)(D,p,d,void 0,O.settings?.baseNameMode),x=(0,e.useCallback)(i=>{if(!i){l(void 0);return}const A=i.value;if(A&&A!==d.value)l({...r,field:A});else{const J=r?.fixed??E;l({...r,field:void 0,fixed:J})}},[l,r]),M=(0,e.useCallback)(i=>{l({field:void 0,fixed:i??E})},[l]),Q=L?d:F.find(i=>i.value===p);return e.createElement(e.Fragment,null,e.createElement("div",{className:I.container},e.createElement(T.l6,{value:Q,options:F,onChange:x,noOptionsMessage:"No fields found",isClearable:O.settings?.isClearable,placeholder:O.settings?.placeholder}),L&&e.createElement("div",{className:I.picker},e.createElement(c.sk,{color:r?.fixed,onChange:M,enableNamedColors:!0}))))},s=W=>({container:(0,a.css)`
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-end;
    align-items: center;
  `,picker:(0,a.css)`
    padding-left: 8px;
  `})},86640:(H,V,t)=>{t.d(V,{h:()=>z});var a=t(96540),e=t(52622),U=t(39268),T=t(14186),c=t(94354),u=t(55852),d=t(76218),S=t(29286);const s=[{label:"Fixed",value:e.RU.Fixed,description:"Fixed value"},{label:"Field",value:e.RU.Field,description:"Display field value"}],W={settings:{}},r={settings:{}},z=({value:l,context:O,onChange:E})=>{const p=(0,a.useCallback)(M=>{E({...l,mode:M})},[E,l]),L=(0,a.useCallback)(M=>{E({...l,field:M})},[E,l]),D=(0,a.useCallback)((M="")=>{E({...l,fixed:M})},[E,l]),F=()=>{D("")},x=l?.mode??e.RU.Fixed;return a.createElement(a.Fragment,null,a.createElement(U.C,null,a.createElement(T.I,{label:"Source",labelWidth:9,grow:!0},a.createElement(c.z,{value:x,options:s,onChange:p,fullWidth:!0}))),x!==e.RU.Fixed&&a.createElement(U.C,null,a.createElement(T.I,{label:"Field",labelWidth:9,grow:!0},a.createElement(d.O,{context:O,value:l.field??"",onChange:L,item:W}))),x===e.RU.Fixed&&a.createElement(U.C,{key:l?.fixed},a.createElement(T.I,{label:"Value",labelWidth:9,grow:!0},a.createElement(S.g,{context:O,value:l?.fixed,onChange:D,item:r,suffix:l?.fixed&&a.createElement(u.$n,{icon:"times",variant:"secondary",fill:"text",size:"sm",onClick:F})}))),x===e.RU.Template&&a.createElement(U.C,null,a.createElement(T.I,{label:"Template",labelWidth:9,grow:!0},a.createElement(S.g,{context:O,value:l?.fixed,onChange:D,item:r}))))}},78437:(H,V,t)=>{t.d(V,{NO:()=>a.N,mj:()=>E,AW:()=>w,gm:()=>i,hj:()=>ee.h});var a=t(21934),e=t(96540);const U=({value:o,onChange:n})=>{const[h,g]=useState(o?[{value:o,label:o}]:[]),[f,_]=useState(),b=window.__grafana_public_path__+"img/icons/unicons/",R=v=>{n(v),_(v)};return useEffect(()=>{getBackendSrv().get(`${b}/index.json`).then(v=>{g(v.files.map(B=>({value:B,label:B})))})},[b]),React.createElement(Select,{options:h,value:f,onChange:v=>{R(v.value)}})},T=null;var c=t(52622),u=t(39268),d=t(14186),S=t(94354),s=t(76218),W=t(63577),r=t(80744),z=t(25148);const l=[{label:"Fixed",value:c.q_.Fixed,description:"Fixed value"},{label:"Field",value:c.q_.Field,description:"Use a string field result"}],O={settings:{}},E=o=>{const{value:n,context:h,onChange:g,item:f}=o,_=9,b=(0,e.useCallback)(y=>{g({...n,mode:y})},[g,n]),R=(0,e.useCallback)((y="")=>{g({...n,field:y})},[g,n]),v=(0,e.useCallback)(y=>{g({...n,fixed:y??""})},[g,n]),B=y=>{y.stopPropagation(),g({mode:c.q_.Fixed,fixed:"",field:""})},K=n?.mode??c.q_.Fixed,N=f.settings?.showSourceRadio??!0,C=f.settings?.resourceType??r.zu.Icon,j=f.settings?.folderName??W.ResourceFolderName.Icon,G=f.settings?.maxFiles;let $="";return C===r.zu.Icon&&(n?.fixed?$=(0,W.getPublicOrAbsoluteUrl)(n.fixed):f.settings?.placeholderValue&&($=(0,W.getPublicOrAbsoluteUrl)(f.settings.placeholderValue))),e.createElement(e.Fragment,null,N&&e.createElement(u.C,null,e.createElement(d.I,{label:"Source",labelWidth:_,grow:!0},e.createElement(S.z,{value:K,options:l,onChange:b,fullWidth:!0}))),K!==c.q_.Fixed&&e.createElement(u.C,null,e.createElement(d.I,{label:"Field",labelWidth:_,grow:!0},e.createElement(s.O,{context:h,value:n.field??"",onChange:R,item:O}))),K===c.q_.Fixed&&e.createElement(z.n,{onChange:v,onClear:B,value:n?.fixed,src:$,placeholder:f.settings?.placeholderText??"Select a value",name:I(n?.fixed)??"",mediaType:C,folderName:j,size:r.Iy.NORMAL,maxFiles:G}),K===c.q_.Mapping&&e.createElement(u.C,null,e.createElement(d.I,{label:"Mappings",labelWidth:_,grow:!0},e.createElement("div",null,"TODO mappings editor!"))))};function I(o){if(!o)return;const n=o.lastIndexOf("/");return n>0?o.substring(n+1):o}var p=t(32196),L=t(40845),D=t(88323),F=t(64278),x=t(60188),M=t(18379);const Q={label:"Fixed value",value:"_____fixed_____"},i=o=>{const{value:n,context:h,onChange:g,item:f}=o,{settings:_}=f,b=(0,L.of)(A),R=n?.field,v=!R,B=(0,F.sE)(h.data),K=(0,F.m3)(B,R,Q),N=(0,e.useMemo)(()=>(0,M.Nn)(_),[_]),C=(0,e.useCallback)(m=>{g((0,M.Ru)(m,N))},[g,N]),j=(0,e.useCallback)(m=>{const Y=m.value;Y&&Y!==Q.value?C({...n,field:Y}):C({...n,field:void 0})},[C,n]),G=(0,e.useCallback)(m=>{m!==void 0&&C({...n,min:m})},[C,n]),$=(0,e.useCallback)(m=>{m!==void 0&&C({...n,max:m})},[C,n]),y=(0,e.useCallback)(m=>{m!==void 0&&C({...n,fixed:m})},[C,n]),P=n??{},k=v?Q:K.find(m=>m.value===R);return e.createElement(e.Fragment,null,e.createElement("div",null,e.createElement(D.l6,{value:k,options:K,onChange:j,noOptionsMessage:"No fields found"})),e.createElement("div",{className:b.range},v&&e.createElement(u.C,null,e.createElement(d.I,{label:"Value",labelWidth:8,grow:!0},e.createElement(x.Q,{value:P.fixed,...N,onChange:y}))),!v&&!N.hideRange&&e.createElement(e.Fragment,null,e.createElement(u.C,null,e.createElement(d.I,{label:"Min",labelWidth:8,grow:!0},e.createElement(x.Q,{value:P.min,...N,onChange:G}))),e.createElement(u.C,null,e.createElement(d.I,{label:"Max",labelWidth:8,grow:!0},e.createElement(x.Q,{value:P.max,...N,onChange:$}))))))},A=o=>({range:(0,p.css)`
    padding-top: 8px;
  `});var J=t(11261);const X={label:"Fixed value",value:"_____fixed_____"},Z=[{label:"Mod",value:c.WQ.Mod,description:"Use field values, mod from max"},{label:"Clamped",value:c.WQ.Clamped,description:"Use field values, clamped to max and min"}],w=({value:o,context:n,onChange:h,item:g})=>{const{settings:f}=g,_=0,b=o?.field,R=!b,v=(0,F.sE)(n.data),B=(0,F.m3)(v,b,X,J.PU.number),K=(0,L.of)(q),N=(0,e.useCallback)(P=>{const k=P.value;if(k&&k!==X.value)h({...o,field:k});else{const m=o.fixed??_;h({...o,field:void 0,fixed:m})}},[h,o]),C=(0,e.useCallback)(P=>{h({...o,mode:P})},[h,o]),j=(0,e.useCallback)(P=>{h({...o,field:void 0,fixed:P??_})},[h,o]),G=o??{},$=o?.mode??c.WQ.Mod,y=R?X:B.find(P=>P.value===b);return e.createElement(e.Fragment,null,e.createElement("div",null,e.createElement(u.C,null,e.createElement(d.I,{label:"Limit",labelWidth:8,grow:!0},e.createElement(S.z,{value:$,options:Z,onChange:C,fullWidth:!0}))),e.createElement(D.l6,{value:y,options:B,onChange:N,noOptionsMessage:"No fields found"})),e.createElement("div",{className:K.range},R&&e.createElement(u.C,null,e.createElement(d.I,{label:"Value",labelWidth:8,grow:!0},e.createElement(x.Q,{value:G?.fixed??_,onChange:j,max:f?.max,min:f?.min})))))},q=o=>({range:(0,p.css)`
    padding-top: 8px;
  `});var ee=t(86640)}}]);

//# sourceMappingURL=707.1b63de88accc28f81763.js.map