"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[90769],{998386(e,t,n){n.d(t,{H:()=>c,v:()=>i});var l=n(765562);const i=e=>`${l.A.fabricsOrchestration}?orchestrationId=${e?.template_id||""}&orgId=${e?.organization_id||""}`,c=e=>`${l.A.fabricsDeviceTemplates}/${e?.template_id||""}?orgId=${e?.organization_id||""}`},152e3(e,t,n){n.d(t,{A:()=>I});var l=n(296540),i=n(436017),c=n(217439),a=n(314714),s=n(592563),r=n(71479),o=n(469733),d=n(180524),m=n(566723),E=n(349107),u=n(294303),h=n(916537),A=n(302167),b=n(457311),S=n(446367),g=n(998386);const C=(0,r.A)("div")`
  width: 100%;
  margin-bottom: ${m.Ln};
`,_=()=>{const e=(0,o.useSelector)(A.zu);return{isOrchestrated:(0,l.useMemo)(()=>(0,S.A)(e),[e]),globalSwitchSettings:e}},O=({globalSwitchSettings:e,children:t})=>{const n=(0,o.useDispatch)(),i=(0,l.useCallback)(()=>{n((0,b.Np)("global_network")).then(e=>{(e?.data?.setting_keys||[]).length>0&&n((0,b.Uc)(void 0,{resolveWithExisting:!1}))})},[n]);return l.createElement(d.A,{placement:"top start",description:l.createElement(u.A,{flexDirection:"column",width:"100%"},l.createElement(h.sA,{id:"COMMON_GLOBAL_SWITCH_SETTINGS_MANAGED_BY_FABRIC"}),l.createElement(u.A,{gap:m.YC,alignItems:"baseline"},l.createElement(E.A,{id:"COMMON_VIEW_IN_SITE_MANAGER",href:(0,g.v)(e.cloud_template)}),l.createElement(c.A,{style:{textTransform:"lowercase"},size:"small"},l.createElement(h.sA,{id:"COMMON_OR"})),l.createElement(s.A,{variant:"destructive",fontSize:"inherit",onClick:i},l.createElement(h.sA,{id:"COMMON_DETACH"}))))},l.createElement("div",null,t))},I={Toggle:({isGlobalSwitchSettingsEnabled:e,setGlobalSwitchSettingsEnabled:t,noStyledRow:n})=>{const{isOrchestrated:a,globalSwitchSettings:s}=_(),r=(0,l.useCallback)(({target:{checked:e}})=>{t(e)},[t]),o=l.createElement(i.A,{full:!0,checked:e,onChange:r,disabled:a},l.createElement(u.A,{width:"100%",alignItems:"center"},l.createElement(c.A,{size:"medium",color:a?"disabled":void 0},l.createElement(h.sA,{id:"COMMON_GLOBAL_SWITCH_SETTINGS"})))),d=n?o:l.createElement(C,null,o);return a?l.createElement(O,{globalSwitchSettings:s},d):d},Checkbox:({isGlobalSwitchSettingsEnabled:e,setGlobalSwitchSettingsEnabled:t,onChange:n,noStyledRow:i})=>{const{isOrchestrated:s,globalSwitchSettings:r}=_(),o=(0,l.useCallback)(({target:{checked:e}})=>{t(e),n?.(e)},[n,t]),d=l.createElement(a.A,{id:"global-switch-settings-checkbox",checked:e,onChange:o,disabled:s},l.createElement(c.A,{size:"medium",color:s?"disabled":void 0},l.createElement(h.sA,{id:"COMMON_GLOBAL_SWITCH_SETTINGS"}))),m=i?d:l.createElement(C,null,d);return s?l.createElement(O,{globalSwitchSettings:r},m):m}}},790769(e,t,n){n.r(t),n.d(t,{default:()=>w});var l=n(82960),i=n(469733),c=n(296540),a=n(449688),s=n(96512),r=n(86571),o=n(689965),d=n(675359),m=n(889764),E=n(171073),u=n(302167),h=n(742920),A=n(457311),b=n(792072),S=n(329109),g=n(410876),C=n(956619),_=n(403116),O=n(89124),I=n(152e3);const w=(0,l.Zz)((0,a.A)([O.UH,_.h,g.q]))(({activeItem:e,setFormDirty:t,setFormInvalid:n,isDirty:l,isInvalid:a})=>{const w=(0,i.useSelector)(m.n0),f=(0,i.useSelector)(m.Lq),v=(0,i.useSelector)(m.H5),N=(0,i.useDispatch)(),p=(0,s.I)(),D=(0,i.useSelector)(u.zu),[y,M]=(0,c.useState)(!D.switch_exclusions?.includes(e.mac)),k=(0,i.useSelector)(b.pB),T=y!==!D.switch_exclusions?.includes(e.mac),G=l||T;return c.createElement(c.Fragment,null,c.createElement(O.Ay,{activeItem:e,label:"COMMON_DEVICE_NAME",setFormDirty:t,setFormInvalid:n}),c.createElement(o.A,{type:o.I.ACCORDION,items:[{id:g.q,openByDefault:!0,label:c.createElement(r.A,{id:"COMMON_ADVANCED"}),renderContent:()=>c.createElement(c.Fragment,null,k?c.createElement(I.A.Checkbox,{isGlobalSwitchSettingsEnabled:y,setGlobalSwitchSettingsEnabled:M}):null,c.createElement(g.A,{activeItem:e,setFormDirty:t,setFormInvalid:n,isGlobalSwitchSettingsEnabled:k?y:void 0}))}]}),c.createElement(o.A,{type:o.I.ACCORDION,items:[{id:_.h,openByDefault:!0,label:c.createElement(r.A,{id:"DEVICE_PROPERTY_HEADER_TOUCHSCREEN"}),renderContent:()=>c.createElement(_.A,{activeItem:e,setFormDirty:t,setFormInvalid:n})}]}),c.createElement(o.A,{type:o.I.ACCORDION,items:[{id:C.f,openByDefault:!0,label:c.createElement(r.A,{id:"COMMON_ACTION_MANAGE"}),renderContent:()=>c.createElement(C.A,{activeItem:e,hideRemove:!0})}]}),c.createElement(S.A,{isDirty:G,isInvalid:a,onFormSubmit:async()=>{if(k&&T){const t=D.switch_exclusions.filter(t=>t!==e.mac);y||t.push(e.mac);try{await N((0,A.OD)({...D,switch_exclusions:t}))}catch{return void N((0,d.ox)({icon:h.C.danger,message:"DEVICE_NOTICE_SAVE_ERROR"}))}}const t=Object.entries(w).reduce((e,[t,n])=>{if("function"==typeof n){const t=n();if("object"==typeof t&&t&&Object.keys(t).length)return{...e,...t}}return e},{});k&&y&&delete t.jumboframe_enabled;const{lcm:n,...l}=t;N((0,E.ex)(l,e._id,e.mac,{extend:!0})).then(()=>{Object.values(f).forEach(e=>{"function"==typeof e&&e()})}).catch(p)},onFormCancel:()=>{k&&M(!D.switch_exclusions?.includes(e.mac)),Object.values(v).forEach(e=>{"function"==typeof e&&e()})}}))})}}]);