"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[14885],{471567(e,a,l){l.d(a,{A:()=>n});var i=l(602086),t=l(141992);const n=(0,l(272338).w)(e=>(0,i.createElement)("svg",(0,t.d)({viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em"},e),(0,i.createElement)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 3a1 1 0 0 1 1-1h7a1 1 0 0 1 .707.293l3 3A1 1 0 0 1 16 6v11a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V3Z",fill:"currentColor",className:e.twotonedclassname}),(0,i.createElement)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5 2a1 1 0 0 0-1 1v14a1 1 0 0 0 1 1h10a1 1 0 0 0 1-1V6a1 1 0 0 0-.293-.707l-3-3A1 1 0 0 0 12 2H5Zm0 15V3h6.999v2a1 1 0 0 0 1 1h2L15 17H5Z",fill:"currentColor",className:e.baseclassname}),(0,i.createElement)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.999 2a1 1 0 0 0-1 1v14a1 1 0 0 0 1 1h10a1 1 0 0 0 1-1V6a1 1 0 0 0-.293-.707l-3-3A1 1 0 0 0 12 2H5Zm10 4.5h-2.5a1 1 0 0 1-1-1V3L15 6.5Z",fill:"currentColor",className:e.fillclassname})))},135640(e,a,l){l.d(a,{A:()=>n});var i=l(602086),t=l(141992);const n=(0,l(272338).w)(e=>(0,i.createElement)("svg",(0,t.d)({viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em"},e),(0,i.createElement)("path",{d:"M16 3H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1Z",fill:"currentColor",className:e.twotonedclassname}),(0,i.createElement)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m9.633 6.113-2.12 2.121a.5.5 0 1 0 .706.708l1.267-1.268V16.5a.5.5 0 0 0 1 0V7.673l1.268 1.269a.5.5 0 0 0 .707-.708l-2.12-2.121a.502.502 0 0 0-.708 0ZM3 14a1 1 0 0 0 1 1h3v-1H4V4h12v10h-3v1h3a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10Z",fill:"currentColor",className:e.baseclassname}),(0,i.createElement)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.962 17.004a.75.75 0 0 1-.75-.75V8.57l-.479.479a.747.747 0 0 1-1.06 0 .75.75 0 0 1 0-1.061L9.44 6.22A.737.737 0 0 1 9.97 6l.072.003a.737.737 0 0 1 .47.217l1.768 1.768a.752.752 0 0 1 .001 1.06.751.751 0 0 1-1.062 0l-.507-.506v7.71a.75.75 0 0 1-.75.75ZM3 14a1 1 0 0 0 1 1h3v-1.5H4.5v-9h11v9H13V15h3a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10Z",fill:"currentColor",className:e.fillclassname})))},794827(e,a,l){l.d(a,{R:()=>r});var i=l(782988),t=l(29472),n=l(774366),s=l(695881),o=l(839163);const r=({searchText:e,sortByField:a,sortDirection:l,pageSize:r=o.md,pageNumber:d},c={},u={})=>(0,t.sU)(o.A2,o.gI,{data:{searchText:e,sortByField:a,sortDirection:l,pageSize:r,pageNumber:d},...c},{method:n.A.POST,idField:o.RR,fetchConfig:{getAllPostResponse:!0},additionalPayloadSelectors:{[i.bI.PAGE_NUMBER]:{},[i.bI.TOTAL_PAGE_COUNT]:{},[i.bI.TOTAL_ELEMENT_COUNT]:{}},compareFunction:s.G,...u})},839163(e,a,l){l.d(a,{A2:()=>i,RR:()=>n,UE:()=>o,gI:()=>t,iP:()=>r,md:()=>s});const i="sites",t="/v2/api/sites/overview",n="id",s=20;var o;!function(e){e.ASCENDING="ASCENDING",e.DESCENDING="DESCENDING"}(o||(o={}));const r={searchText:"",sortByField:void 0,sortDirection:void 0,pageSize:1e4,pageNumber:0}},695881(e,a,l){l.d(a,{G:()=>i});const i=({data:e},{data:a})=>e.searchText===a.searchText&&e.sortByField===a.sortByField&&e.sortDirection===a.sortDirection},589014(e,a,l){l.d(a,{A:()=>r});var i=l(274934),t=l(602086),n=l(765414),s=l(471567),o=l(648576);const r=({name:e,className:a,children:l=null,id:r,iconWidth:d,iconHeight:c,size:u="small",variant:h="link",iconSize:m="medium",Icon:C=s.A,omitIconSvgMargin:v=!1,disabled:_=!1,...A})=>{const E=(0,t.useCallback)(e=>e.currentTarget.parentNode.parentNode.childNodes[0].click(),[]);return(0,i.jsx)(n.A,{id:r||e,...A,children:(0,i.jsx)(o.Ay,{name:e,size:u,type:"button",variant:h,wrapClassName:a,onClick:E,Icon:C,iconProps:{omitSvgMargin:v,isActive:!0,...d&&{width:d},...c&&{height:c},disabled:_},iconSize:m,disabled:_,children:l})})}},814885(e,a,l){l.r(a),l.d(a,{default:()=>R});var i=l(274934),t=l(602086),n=l(425040),s=l(977872),o=l(843615),r=l(135640),d=l(409844),c=l(669439),u=l(159469),h=l(53049),m=l(309130),C=l(100978),v=l(700444),_=l(869332),A=l(470070),E=l(839163),N=l(794827),p=l(561500),I=l(412927),T=l(777731),O=l(759997),g=l(589014),S=l(384783);const M="upload-site-file",f=(0,l(247816).A)("div")`
  max-width: ${336}px;
  overflow: hidden;
  text-overflow: ellipsis;
`,R=({onClose:e})=>{const{formatMessage:a}=(0,A.tz)(),l=(0,s.wA)(),R=(0,t.useRef)(null),{updateNotification:w}=(0,s.d4)(h.o),[x,b]=(0,t.useState)(""),[D,k]=(0,t.useState)(""),[P,L]=(0,t.useState)(null),[H,y]=(0,t.useState)(!1),[U,j]=(0,t.useState)(!1),V=(0,t.useCallback)(()=>{P&&(l((0,O.ho)(P.backup_id)),L(null)),l((0,_.AS)()),e()},[e,l,P]),z=(0,t.useCallback)(()=>{R.current&&(R.current.value="")},[]),F=(0,t.useCallback)(({target:{value:e}})=>{b(e)},[b]),G=(0,t.useCallback)((e,i)=>{i&&"current"in i&&(R.current=i.current);const t=R.current?.files?.[0];if(!t)return;j(!0);const s=t.name||"network_site_file",o=(0,n.A)();l((0,v.ox)({id:o,renderTitle:()=>a({id:"COMMON_UPLOADING_FILES"}),downloads:[{id:M,filename:s,progress:0,status:a({id:"COMMON_FILE_UPLOADING"}),onCancel:()=>{l((0,v.uU)(o)),j(!1),z()}}],duration:0,notificationType:"DownloadsToast"})),l((0,O.kI)(t)).then(e=>{w({id:o,title:a({id:"COMMON_UPLOADED_FILES"}),downloads:[{id:M,files:[{filename:s,progress:100,status:a({id:"COMMON_FILE_UPLOADED"})}],onCancel:()=>{}}],duration:2e3,notificationType:"DownloadsToast"});const i=e?.data?.[0]||{};i.purpose===T.L.APPLICATION_BACKUP?(l((0,v.ox)({icon:u.C.warning,message:"COMMON_SITE_SWITCHER_IMPORT_SITE_BACKUP_UPLOADED"})),P&&l((0,O.ho)(i.backup_id))):(L(i),k(t?.name))}).catch(e=>{l((0,v.uU)(o)),z(),l((0,v.ox)({errorMessage:e.msg,errorValues:{...e,fileName:D},icon:u.C.danger,message:"COMMON_SITE_SWITCHED_IMPORT_SITE_ERROR"}))}).finally(()=>{j(!1)})},[l,D,a,z,w,P]),B=(0,t.useCallback)(()=>{y(!0),l(P?(0,p.rA)({newSiteName:x,importedSiteId:P?.backup_id}):(0,p.TG)(x)).then(()=>{l((0,N.R)(E.iP)),l((0,I.N)())}).catch(()=>{l((0,v.ox)({type:u.C.danger,message:"COMMON_SITE_SWITCHER_ADD_SITE_ERROR",values:{name:x}}))}).finally(()=>{V(),y(!1)})},[l,V,P,x]),Z=(0,t.useCallback)(()=>{H||V()},[H,V]);return(0,i.jsxs)(S.A,{title:(0,i.jsx)(A.sA,{id:"COMMON_SITE_SWITCHER_ADD_NEW_SITE"}),onRequestClose:Z,size:"small",actions:[{type:"button",text:(0,i.jsx)(A.sA,{id:"COMMON_ACTION_CANCEL"}),onClick:V,disabled:H},{type:"button",text:(0,i.jsx)(A.sA,{id:"COMMON_ACTION_ADD"}),onClick:B,variant:"primary",disabled:!x||H,loader:H?"loading":void 0}],headerClassName:d.AH`
        svg {
          pointer-events: ${H?"none":"cursor"};
        }
      `,children:[(0,i.jsx)(o.A,{full:!0,variant:"secondary",label:a({id:"COMMON_SITE_SWITCHER_SITE_NAME"}),onChange:F,value:x,disabled:H,maxLength:64}),(0,i.jsx)(C.A,{marginTop:m.xO,children:(0,i.jsx)(c.A,{description:(0,i.jsx)(A.sA,{id:"COMMON_SITE_SWITCHER_IMPORT_SITE_TOOLTIP"}),children:(0,i.jsx)("span",{children:(0,i.jsx)(g.A,{name:"import-site",size:"large",variant:"inline",iconSize:"original",Icon:r.A,onChange:G,disabled:U||H,children:(0,i.jsx)(f,{children:D.length>0?D:(0,i.jsx)(A.sA,{id:"COMMON_SITE_SWITCHER_IMPORT_SITE"})})})})})})]})}}}]);