"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[27148],{341699(e,t,i){i.d(t,{HV:()=>n,pm:()=>l,vF:()=>r});var s=i(726831);const r=e=>`${s.A.fabricsOrchestration}?orchestrationId=${e?.template_id||""}&orgId=${e?.organization_id||""}`,n=e=>`${s.A.fabricsDeviceTemplates}/${e?.template_id||""}?orgId=${e?.organization_id||""}`,l=()=>`${s.A.fabricsOrchestration}`},637084(e,t,i){i.d(t,{A:()=>_});var s=i(274934),r=i(602086),n=i(843871),l=i(977872),o=i(418398),c=i(205521),a=i(232410),d=i(1469),h=i(260288),u=i(619619),A=i(876809),m=i(113454),b=i(621309);const O=(0,n.bk)({enableReinitialize:!0,mapPropsToValues:({powerSupervisor:e,device:t})=>({powerSupervisor:(0,u.f)(e,(0,m.lD)(t,e))}),handleSubmit:(e,{resetForm:t})=>t({values:e}),validationSchema:A.A}),_=(0,o.Zz)((0,l.Ng)((e,{device:{mac:t}})=>({powerSupervisor:(0,a.x0)(t)(e)})))(O(({powerSupervisor:e,device:t,setFormDirty:i,setFormInvalid:n,validateForm:o,values:a,resetForm:u,dirty:A,isValid:m,formName:O=h.r8})=>{const _=(0,l.wA)();return(0,r.useEffect)(()=>(_((0,c.uo)({[O]:()=>({})})),_((0,c.Oo)({[O]:()=>{o().then(t=>{Object.keys(t).length||_((0,b.A)(e?.id,a.powerSupervisor))})}})),_((0,c.rW)({[O]:u})),()=>{_((0,c.uo)({[O]:null})),_((0,c.Oo)({[O]:null})),_((0,c.rW)({[O]:null}))}),[_,u,a.powerSupervisor,O,o,e?.id]),(0,r.useEffect)(()=>{i?.(O,A),n?.(O,!m)},[i,A,n,m,O]),(0,s.jsx)(d.A,{device:t})}))},876809(e,t,i){i.d(t,{A:()=>n,q:()=>r});var s=i(950804);const r=s.A.object().shape({power_sources:s.A.array().transform(e=>e.filter(e=>e.power_source_mac)).of(s.A.object().shape({client_psu_index:s.A.number().required(),power_source_mac:s.A.string().label("COMMON_POWER_SOURCE").required(),power_source_index:s.A.string().label("COMMON_OUTLET").required()})).label("COMMON_POWER_SOURCE").min(1)}).optional(),n=s.A.object().shape({powerSupervisor:r})},419685(e,t,i){i.d(t,{A:()=>v});var s=i(274934),r=i(602086),n=i(770698),l=i(938984),o=i(762705),c=i(954702),a=i(247816),d=i(977872),h=i(669439),u=i(309130),A=i(793442),m=i(100978),b=i(470070),O=i(291935),_=i(598990),x=i(6276),S=i(341699);const p=(0,a.A)("div")`
  width: 100%;
  margin-bottom: ${u.Ln};
`,C=()=>{const e=(0,d.d4)(O.zu);return{isOrchestrated:(0,r.useMemo)(()=>(0,x.A)(e),[e]),globalSwitchSettings:e}},g=({globalSwitchSettings:e,children:t})=>{const i=(0,d.wA)(),n=(0,r.useCallback)(()=>{i((0,_.Np)("global_network")).then(e=>{(e?.data?.setting_keys||[]).length>0&&i((0,_.Uc)(void 0,{resolveWithExisting:!1}))})},[i]);return(0,s.jsx)(h.A,{placement:"top start",description:(0,s.jsxs)(m.A,{flexDirection:"column",width:"100%",children:[(0,s.jsx)(b.sA,{id:"COMMON_GLOBAL_SWITCH_SETTINGS_MANAGED_BY_FABRIC"}),(0,s.jsxs)(m.A,{gap:u.YC,alignItems:"baseline",children:[(0,s.jsx)(A.A,{id:"COMMON_VIEW_IN_SITE_MANAGER",href:(0,S.vF)(e.cloud_template)}),(0,s.jsx)(l.A,{style:{textTransform:"lowercase"},size:"small",children:(0,s.jsx)(b.sA,{id:"COMMON_OR"})}),(0,s.jsx)(c.A,{variant:"destructive",fontSize:"inherit",onClick:n,children:(0,s.jsx)(b.sA,{id:"COMMON_DETACH"})})]})]}),children:(0,s.jsx)("div",{children:t})})},v={Toggle:({isGlobalSwitchSettingsEnabled:e,setGlobalSwitchSettingsEnabled:t,noStyledRow:i})=>{const{isOrchestrated:o,globalSwitchSettings:c}=C(),a=(0,r.useCallback)(({target:{checked:e}})=>{t(e)},[t]),d=(0,s.jsx)(n.A,{full:!0,checked:e,onChange:a,disabled:o,children:(0,s.jsx)(m.A,{width:"100%",alignItems:"center",children:(0,s.jsx)(l.A,{size:"medium",color:o?"disabled":void 0,children:(0,s.jsx)(b.sA,{id:"COMMON_GLOBAL_SWITCH_SETTINGS"})})})}),h=i?d:(0,s.jsx)(p,{children:d});return o?(0,s.jsx)(g,{globalSwitchSettings:c,children:h}):h},Checkbox:({isGlobalSwitchSettingsEnabled:e,setGlobalSwitchSettingsEnabled:t,onChange:i,noStyledRow:n})=>{const{isOrchestrated:c,globalSwitchSettings:a}=C(),d=(0,r.useCallback)(({target:{checked:e}})=>{t(e),i?.(e)},[i,t]),h=(0,s.jsx)(o.A,{id:"global-switch-settings-checkbox",checked:e,onChange:d,disabled:c,children:(0,s.jsx)(l.A,{size:"medium",color:c?"disabled":void 0,children:(0,s.jsx)(b.sA,{id:"COMMON_GLOBAL_SWITCH_SETTINGS"})})}),u=n?h:(0,s.jsx)(p,{children:h});return c?(0,s.jsx)(g,{globalSwitchSettings:a,children:u}):u}}},527148(e,t,i){i.r(t),i.d(t,{default:()=>w});var s=i(274934),r=i(418398),n=i(977872),l=i(602086),o=i(478961),c=i(630849),a=i(376892),d=i(535322),h=i(700444),u=i(446863),A=i(795206),m=i(291935),b=i(159469),O=i(598990),_=i(167933),x=i(637084),S=i(115114),p=i(322784),C=i(532635),g=i(269935),v=i(795928),j=i(419685);const w=(0,r.Zz)((0,o.A)([v.UH,p.q,g.h]))(({activeItem:e,setFormDirty:t,setFormInvalid:i,isDirty:r,isInvalid:o})=>{const w=(0,n.d4)(u.n0),E=(0,n.d4)(u.Lq),f=(0,n.d4)(u.H5),I=(0,n.wA)(),N=(0,c.I)(),y=(0,n.d4)(m.zu),[M,D]=(0,l.useState)(!y.switch_exclusions?.includes(e.mac)),k=(0,n.d4)(_.pB),F=M!==!y.switch_exclusions?.includes(e.mac),T=r||F;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(v.Ay,{activeItem:e,label:"COMMON_DEVICE_NAME",setFormDirty:t,setFormInvalid:i}),(0,s.jsx)(d.A,{type:d.I.ACCORDION,items:[{id:p.q,openByDefault:!0,label:(0,s.jsx)(a.A,{id:"COMMON_ADVANCED"}),renderContent:()=>(0,s.jsxs)(s.Fragment,{children:[k?(0,s.jsx)(j.A.Checkbox,{isGlobalSwitchSettingsEnabled:M,setGlobalSwitchSettingsEnabled:D}):null,(0,s.jsx)(p.A,{activeItem:e,setFormDirty:t,setFormInvalid:i,isGlobalSwitchSettingsEnabled:k?M:void 0})]})}]}),(0,s.jsx)(x.A,{device:e,setFormDirty:t,setFormInvalid:i}),(0,s.jsx)(d.A,{type:d.I.ACCORDION,items:[{id:g.h,openByDefault:!0,label:(0,s.jsx)(a.A,{id:"DEVICE_PROPERTY_HEADER_TOUCHSCREEN"}),renderContent:()=>(0,s.jsx)(g.A,{activeItem:e,setFormDirty:t,setFormInvalid:i})}]}),(0,s.jsx)(d.A,{type:d.I.ACCORDION,items:[{id:C.f,openByDefault:!0,label:(0,s.jsx)(a.A,{id:"COMMON_ACTION_MANAGE"}),renderContent:()=>(0,s.jsx)(C.A,{activeItem:e})}]}),(0,s.jsx)(S.A,{isDirty:T,isInvalid:o,onFormSubmit:async()=>{if(k&&F){const t=y.switch_exclusions.filter(t=>t!==e.mac);M||t.push(e.mac);try{await I((0,O.OD)({...y,switch_exclusions:t}))}catch{return void I((0,h.ox)({icon:b.C.danger,message:"DEVICE_NOTICE_SAVE_ERROR"}))}}const t=Object.entries(w).reduce((e,[t,i])=>{if("function"==typeof i){const t=i();if("object"==typeof t&&t&&Object.keys(t).length)return{...e,...t}}return e},{});k&&M&&delete t.jumboframe_enabled;const{lcm:i,...s}=t;I((0,A.ex)(s,e._id,e.mac,{extend:!0})).then(()=>{Object.values(E).forEach(e=>{"function"==typeof e&&e()})}).catch(N)},onFormCancel:()=>{k&&D(!y.switch_exclusions?.includes(e.mac)),Object.values(f).forEach(e=>{"function"==typeof e&&e()})}})]})})}}]);