"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[7317],{39053(E,u,t){t.r(u),t.d(u,{plugin:()=>D});var S=t(16207),y=t(83340),e=t(92745),r=t(74848),x=t(41811),U=t(96540),G=t(78529),P=t(29147),j=t(34072);const N=({width:o,height:n,data:s,options:a})=>{const l=(0,G.JQ)(s.timeRange),m=(0,U.useId)();if(!s||!s.series.length)return(0,r.jsx)("div",{className:"panel-empty",children:(0,r.jsx)("p",{children:(0,r.jsx)(e.x6,{i18nKey:"nodeGraph.node-graph-panel.no-data-found-in-response",children:"No data found in response"})})});const c=(0,x.default)(j.BR);return(0,r.jsx)("div",{style:{width:o,height:n},children:(0,r.jsx)(P.F,{dataFrames:c(s.series,a),getLinks:l,panelId:m,zoomMode:a.zoomMode,layoutAlgorithm:a.layoutAlgorithm})})};var C=t(22803),z=t(63142),A=t(35427),f=t(45861),L=t(48457);const O=({value:o,onChange:n,context:s})=>{const a=(0,z.of)(M),l=()=>{const d={field:"",color:""};n(o?[...o,d]:[d])},m=d=>{const i=o?.slice();i.splice(d,1),n(i)},c=(d,i,g)=>{let F=o?.slice()??[];F[d][i]=g,n(F)};return(0,r.jsxs)(r.Fragment,{children:[o?.map((d,i)=>(0,r.jsxs)("div",{className:a.section,children:[(0,r.jsx)(L.O,{context:s,value:d.field??"",onChange:g=>{c(i,"field",g)},item:{settings:{filter:g=>g.name.includes("arc__")},id:`arc-field-${i}`,name:`arc-field-${i}`}}),(0,r.jsx)(A.sk,{color:d.color||"#808080",onChange:g=>{c(i,"color",g)}}),(0,r.jsx)(f.$n,{size:"sm",icon:"minus",variant:"secondary",onClick:()=>m(i),"aria-label":(0,e.t)("nodeGraph.arc-options-editor.title-remove-arc","Remove arc")})]},i)),(0,r.jsx)(f.$n,{size:"sm",icon:"plus",onClick:l,variant:"secondary",children:(0,r.jsx)(e.x6,{i18nKey:"nodeGraph.arc-options-editor.add-arc",children:"Add arc"})})]})},M=o=>({section:(0,C.css)({display:"flex",alignItems:"center",justifyContent:"space-between",gap:`0 ${o.spacing(1)}`,marginBottom:o.spacing(1)})});var h=t(18209),p=t(95004),$=t(38919),v=t(73495);class B{getListWithDefaults(n){return n.getListAppender({name:v.m.NodeGraph,pluginId:"nodeGraph"})}hasCorrectFields(n){let s=!1,a=!1;const l=[["id",p.PU.string],["title",p.PU.string],["mainstat",p.PU.number]],m=[["id",p.PU.string],["source",p.PU.string],["target",p.PU.string]];for(const c of n)this.checkFields(l,c)&&(s=!0),this.checkFields(m,c)&&(a=!0);return s&&a}checkFields(n,s){let a=!0;for(const l of n){const[m,c]=l,d=s.fields.find(i=>i.name===m);if(!d||c!==d.type){a=!1;break}}return a}getSuggestionsForData(n){if(!n.data)return;const s=this.hasCorrectFields(n.data.series),a=n.data.series.filter(l=>l.meta&&l.meta.preferredVisualisationType==="nodeGraph");(s||a.length===2)&&this.getListWithDefaults(n).append({name:v.m.NodeGraph,score:$.nQ.Best})}}const D=new S.m(N).useFieldConfig({disableStandardOptions:Object.values(y.uo).filter(o=>o!==y.uo.Links)}).setPanelOptions((o,n)=>{const s=[(0,e.t)("node-graph.category-node-graph","Node graph")];o.addSelect({name:(0,e.t)("node-graph.name-zoom-mode","Zoom mode"),category:s,path:"zoomMode",defaultValue:"cooperative",settings:{options:[{value:"cooperative",label:(0,e.t)("node-graph.zoom-mode-options.label-cooperative","Cooperative"),description:(0,e.t)("node-graph.zoom-mode-options.description-cooperative","Lets you scroll the page normally")},{value:"greedy",label:(0,e.t)("node-graph.zoom-mode-options.label-greedy","Greedy"),description:(0,e.t)("node-graph.zoom-mode-options.description-greedy","Reacts to all zoom gestures")}]}}),o.addSelect({name:(0,e.t)("node-graph.name-layout-algorithm","Layout algorithm"),category:s,path:"layoutAlgorithm",defaultValue:h.S.Layered,settings:{options:[{label:(0,e.t)("node-graph.layout-algorithm-options.label-layered","Layered"),value:h.S.Layered,description:(0,e.t)("node-graph.layout-algorithm-options.description-layered","Use a layered layout")},{label:(0,e.t)("node-graph.layout-algorithm-options.label-force","Force"),value:h.S.Force,description:(0,e.t)("node-graph.layout-algorithm-options.description-force","Use a force-directed layout")},{label:(0,e.t)("node-graph.layout-algorithm-options.label-grid","Grid"),value:h.S.Grid,description:(0,e.t)("node-graph.layout-algorithm-options.description-grid","Use a grid layout")}]}}),o.addNestedOptions({category:[(0,e.t)("node-graph.category-nodes","Nodes")],path:"nodes",build:a=>{a.addUnitPicker({name:(0,e.t)("node-graph.name-main-stat-unit","Main stat unit"),path:"mainStatUnit"}),a.addUnitPicker({name:(0,e.t)("node-graph.name-secondary-stat-unit","Secondary stat unit"),path:"secondaryStatUnit"}),a.addCustomEditor({name:(0,e.t)("node-graph.name-arc-sections","Arc sections"),path:"arcs",id:"arcs",editor:O})}}),o.addNestedOptions({category:[(0,e.t)("node-graph.category-edges","Edges")],path:"edges",build:a=>{a.addUnitPicker({name:(0,e.t)("node-graph.name-main-stat-unit","Main stat unit"),path:"mainStatUnit"}),a.addUnitPicker({name:(0,e.t)("node-graph.name-secondary-stat-unit","Secondary stat unit"),path:"secondaryStatUnit"})}})}).setSuggestionsSupplier(new B)}}]);

//# sourceMappingURL=nodeGraphPanel.47f89d1a1cc96398b02d.js.map