/* [create-plugin] version: 6.1.2 */
/* [create-plugin] plugin: opennms-opennms-app@12.0.1 */
define(["@grafana/data","@grafana/ui","jquery","module","react"],(e,a,n,t,r)=>(()=>{"use strict";var l={7781(a){a.exports=e},2007(e){e.exports=a},4846(e){e.exports=n},1308(e){e.exports=t},5959(e){e.exports=r}},o={};function i(e){var a=o[e];if(void 0!==a)return a.exports;var n=o[e]={exports:{}};return l[e](n,n.exports,i),n.exports}i.n=e=>{var a=e&&e.__esModule?()=>e.default:()=>e;return i.d(a,{a}),a},i.d=(e,a)=>{for(var n in a)i.o(a,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:a[n]})},i.o=(e,a)=>Object.prototype.hasOwnProperty.call(e,a),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.p="public/plugins/opennms-opennms-app/";var u={};i.r(u),i.d(u,{plugin:()=>B});var d=i(1308),c=i.n(d);i.p=c()&&c().uri?c().uri.slice(0,c().uri.lastIndexOf("/")+1):"public/plugins/opennms-opennms-app/";var s=i(7781),v=i(5959),b=i.n(v),p=i(4846),g=i.n(p),f=i(2007);const m={label:"Vertical",value:1},x={label:"Horizontal",value:2},y={label:"Acknowledged",value:1},O={label:"Severity",value:2},h={Outstanding:{index:0,label:"Outstanding",value:void 0},Acknowledged:{index:1,label:"Acknowledged",value:!0}},E={index:0,label:"Cleared",value:"CLEARED"},w={index:1,label:"Normal",value:"NORMAL"},C={index:2,label:"Indeterm.",value:"INDETERMINATE"},P={index:3,label:"Warning",value:"WARNING"},A={index:4,label:"Minor",value:"MINOR"},j={index:5,label:"Major",value:"MAJOR"},k={index:6,label:"Critical",value:"CRITICAL"},D=()=>{const e=(0,v.useRef)(void 0),a=(e,a,n)=>e===x.value?[a,n]:[n,a],n=(e,a,n,t=!1)=>{const r=((e,a)=>a.series.map(a=>{var n;return null===(n=a.fields.find(a=>a.name===e))||void 0===n?void 0:n.values.toArray()}))(e,n);let l=0;for(let e of r)if(e)for(let n of e)(n===a||t&&n)&&(l+=1);return l},t=e=>e===y.value?[[h.Acknowledged.index,h.Acknowledged.label],[h.Outstanding.index,h.Outstanding.label]]:[[E.index,E.label],[w.index,w.label],[C.index,C.label],[P.index,P.label],[A.index,A.label],[j.index,j.label],[k.index,k.label]];return{getPlotData:(e,t,r)=>e===y.value?((e,t)=>{const r="Acked By",l=[n(r,h.Outstanding.value,t),n(r,h.Acknowledged.value,t,!0)];return[{data:[a(e,l[0],h.Outstanding.index)],color:f.colors[0]},{data:[a(e,l[1],h.Acknowledged.index)],color:f.colors[4]}]})(t,r):((e,t)=>{const r="Severity",l=[n(r,E.value,t),n(r,w.value,t),n(r,C.value,t),n(r,P.value,t),n(r,A.value,t),n(r,j.value,t),n(r,k.value,t)];return[{data:[a(e,l[0],E.index)],color:"#EEE000"},{data:[a(e,l[1],w.index)],color:"#86B15B"},{data:[a(e,l[2],C.index)],color:"#990000"},{data:[a(e,l[3],P.index)],color:"#FCCC3B"},{data:[a(e,l[4],A.index)],color:"#EE901C"},{data:[a(e,l[5],j.index)],color:"#E3692F"},{data:[a(e,l[6],k.index)],color:"#DB4345"}]})(t,r),getPlotConfig:(e,a)=>{const n=x.value===a?"yaxis":"xaxis";return{series:{bars:{show:!0,barWidth:a===x.value?.5:.6,align:"center",fill:.8,lineWidth:1,horizontal:a===x.value}},[n]:{mode:"categories",tickLength:0,autoscaleMargin:.02,ticks:t(e)},grid:{borderWidth:0}}},ref:e}};function S(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function M(e){for(var a=1;a<arguments.length;a++){var n=null!=arguments[a]?arguments[a]:{},t=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),t.forEach(function(a){S(e,a,n[a])})}return e}const I=({value:e,onChange:a})=>b().createElement("div",null,b().createElement(f.Combobox,{options:[M({},y),M({},O)],value:e,onChange:e=>a(e.value)}));function R(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function N(e){for(var a=1;a<arguments.length;a++){var n=null!=arguments[a]?arguments[a]:{},t=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),t.forEach(function(a){R(e,a,n[a])})}return e}const G=({value:e,onChange:a})=>b().createElement("div",null,b().createElement(f.Combobox,{options:[N({},m),N({},x)],value:e,onChange:e=>a(e.value)})),B=new s.PanelPlugin(({options:e,data:a,width:n,height:t})=>{const{getPlotConfig:r,getPlotData:l,ref:o}=D();return(0,v.useEffect)(()=>{const n=l(e.alarmGroup,e.alarmDirection,a),t=r(e.alarmGroup,e.alarmDirection);g().plot(o.current,n,t)},[a,e.alarmGroup,n,t,e.alarmDirection,r,l,o]),b().createElement("div",{ref:o,style:{width:n,height:t}})}).setPanelOptions(e=>{e.addCustomEditor({id:"alarm-group",path:"alarmGroup",name:"Alarm Group",editor:I}),e.addCustomEditor({id:"alarm-direction",path:"alarmDirection",name:"Alarm Direction",editor:G})});return u})());
//# sourceMappingURL=module.js.map