import{m as a,u as l,d as s,n as u}from"./index-009d300e.js";const p={props:{value:Boolean,associations:Array,node:Object},watch:{value(){this.$refs.form&&this.$refs.form.resetValidation(),this.resetGroup()}},computed:{...a(l,["controllerNode","nodes"]),filteredNodes(){return this.node.protocol===s.Protocols.ZWaveLongRange?[this.controllerNode]:this.nodes.filter(n=>n.id!==this.node.id&&n.protocol!==s.Protocols.ZWaveLongRange)},endpoints(){return this.getEndpointItems(this.node)},targetEndpoints(){return this.getEndpointItems(this.group.target,!0)},maxNodes(){return this.group.group?this.group.group.maxNodes:-1},nodesInGroup(){return this.group.group?this.associations.filter(n=>n.groupId===this.group.group.value&&n.endpoint===this.group.endpoint).length:0},endpointGroups(){let n=[];try{n=this.node.groups;const t=this.group.endpoint;n=n.filter(e=>e.endpoint===t||t===null&&e.endpoint===0&&!e.multiChannel)}catch{}return n}},data(){return{valid:!0,group:{},defaultGroup:{endpoint:null},required:n=>!!n||"This field is required"}},methods:{resetGroup(){this.group=Object.assign({},this.defaultGroup)},getEndpointLabel(n,t){if(n&&n.endpoints){const e=n.endpoints.find(o=>o.index===t);if(e)return e.label}return"Endpoint "+t},getEndpointItems(n,t=!1){const e=[];if(t&&e.unshift({text:"No Endpoint",value:null}),n&&n.endpoints)for(const o of n.endpoints)e.push({text:o.label,value:o.index});return e}}};var d=function(){var t=this,e=t._self._c;return e("v-dialog",{attrs:{"max-width":"500px",persistent:""},model:{value:t.value,callback:function(o){t.value=o},expression:"value"}},[e("v-card",[e("v-card-title",[e("span",{staticClass:"headline"},[t._v("New Association")])]),e("v-card-text",[e("v-container",{attrs:{"grid-list-md":""}},[e("v-form",{ref:"form",attrs:{"lazy-validation":""},model:{value:t.valid,callback:function(o){t.valid=o},expression:"valid"}},[e("v-row",[e("v-col",{attrs:{cols:"12"}},[e("v-select",{attrs:{label:"Node Endpoint",hint:"Used to filter available groups","persistent-hint":"",items:t.endpoints},model:{value:t.group.endpoint,callback:function(o){t.$set(t.group,"endpoint",o)},expression:"group.endpoint"}})],1),e("v-col",{attrs:{cols:"12"}},[e("v-select",{attrs:{label:"Group",hint:"Node/Endpoint Group association to Add/Remove","persistent-hint":"",items:t.endpointGroups,rules:[t.required],"return-object":""},scopedSlots:t._u([{key:"selection",fn:function({item:o}){return[t._v(" "+t._s(o.text)+" ")]}},{key:"item",fn:function({item:o,attrs:r,on:i}){return[e("v-list-item",t._g(t._b({attrs:{"two-line":""}},"v-list-item",r,!1),i),[e("v-list-item-content",[e("v-list-item-title",[t._v(t._s(`[${o.value}] ${o.text}`))]),e("v-list-item-subtitle",[t._v(t._s(o.endpoint>=0?t.getEndpointLabel(t.node,o.endpoint):"No Endpoint"))])],1)],1)]}}]),model:{value:t.group.group,callback:function(o){t.$set(t.group,"group",o)},expression:"group.group"}})],1),t.group.group?e("v-col",{attrs:{cols:"12"}},[e("p",{staticClass:"text-subtitle-1 pa-0 ma-0"},[t._v(" Max associations: "),e("strong",[t._v(t._s(t.maxNodes))])]),e("p",{staticClass:"text-subtitle-1 pa-0 ma-0"},[t._v(" Actual associations: "),e("strong",[t._v(t._s(t.nodesInGroup))])])]):t._e(),t.nodesInGroup<t.maxNodes?e("v-col",{staticClass:"pa-0"},[e("v-col",{attrs:{cols:"12"}},[e("v-combobox",{attrs:{label:"Target Node",items:t.filteredNodes,"return-object":"",rules:[t.required],hint:"Node to add to the association group","persistent-hint":"","item-text":"_name"},model:{value:t.group.target,callback:function(o){t.$set(t.group,"target",o)},expression:"group.target"}})],1),t.group.group&&t.group.group.multiChannel?e("v-col",{attrs:{cols:"12"}},[e("v-select",{attrs:{"persistent-hint":"",label:"Target Endpoint",hint:"Target node endpoint",items:t.targetEndpoints},model:{value:t.group.targetEndpoint,callback:function(o){t.$set(t.group,"targetEndpoint",t._n(o))},expression:"group.targetEndpoint"}})],1):t._e()],1):t._e()],1)],1)],1)],1),e("v-card-actions",[e("v-spacer"),e("v-btn",{attrs:{color:"blue darken-1",text:""},on:{click:function(o){return t.$emit("close")}}},[t._v("Cancel")]),e("v-btn",{attrs:{color:"blue darken-1",text:"",disabled:t.nodesInGroup>=t.maxNodes},on:{click:function(o){t.$refs.form.validate()&&t.$emit("add",t.group)}}},[t._v("ADD")])],1)],1)],1)},c=[],v=u(p,d,c,!1,null,null,null,null);const f=v.exports;export{f as default};
