(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[941],{8283:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/file-manager",function(){return t(7241)}])},157:function(e,n,t){"use strict";var r=t(5893),o=t(7357),i=t(8262),l=t(7294),c=t(7169),a=t(4825),u=t(4690),s=t(3679),f=t(2152),d=t(7750);function p(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function x(e){return function(e){if(Array.isArray(e))return p(e)}(e)||function(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(!e)return;if("string"===typeof e)return p(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return p(e,n)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var g={blue:c.Ej,red:c.hM},y=(0,l.forwardRef)((function(e,n){var t=e.actionCancelText,p=void 0===t?"Cancel":t,m=e.actionProceedText,y=e.contentContainerProps,b=void 0===y?{}:y,j=e.closeOnProceed,w=void 0!==j&&j,Z=e.content,O=e.dialogProps,P=void 0===O?{}:O,S=P.open,C=void 0!==S&&S,A=P.PaperProps,k=void 0===A?{}:A,I=e.disableProceed,U=e.formContent,D=e.loading,E=void 0!==D&&D,F=e.loadingAction,L=void 0!==F&&F,N=e.onActionAppend,T=e.onCancelAppend,M=e.onProceedAppend,B=e.onSubmitAppend,_=e.openInitially,R=void 0!==_&&_,W=e.preActionArea,V=e.proceedButtonProps,H=void 0===V?{}:V,z=e.proceedColour,G=void 0===z?"blue":z,$=e.scrollContent,X=void 0!==$&&$,J=e.scrollBoxProps,Y=(void 0===J?{}:J).sx,q=e.titleText,K=h(e.dialogProps,["open","PaperProps"]),Q=h(e.scrollBoxProps,["sx"]),ee=k.sx,ne=h(k,["sx"]),te=H.disabled,re=void 0===te?I:te,oe=H.sx,ie=h(H,["disabled","sx"]),le=(0,l.useState)(R),ce=le[0],ae=le[1],ue=(0,l.useMemo)((function(){return n?ce:C}),[C,ce,n]),se=(0,l.useMemo)((function(){return g[G]}),[G]),fe=(0,l.useMemo)((function(){var e,n,t,r=function(){for(var e=arguments.length,n=new Array(e),t=0;t1?n-1:0),r=1;re.length)&&(n=e.length);for(var t=0,r=new Array(n);t1&&void 0!==arguments[1]?arguments[1]:"suiapi.";return t["".concat(n).concat(e)]}),[t]),i=(0,s.useCallback)((function(){return o("user")}),[o]);return(0,s.useEffect)((function(){if(e){var n=document.cookie.split(/\s*;\s*/);r(n.reduce((function(e,n){var t,r=C(n.split("=",2),2),o=r[0],i=r[1],l=decodeURIComponent(i);if(l.startsWith("j:"))try{t=JSON.parse(l.substring(2))}catch(c){t=i}else t=i;return e[o]=t,e}),{}))}}),[e]),{cookieJar:t,getCookie:o,getSessionUser:i}};function k(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function I(e){for(var n=1;n0)},ref:n})]})}},4427:function(e,n,t){"use strict";var r=t(5893),o=t(2429),i=t(9309),l=t(7169);function c(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function a(e){for(var n=1;n=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}n.Z=function(e){var n=e.onClearIndicatorClick,t=h(e,["onClearIndicatorClick"]),x=t.sx,g=t.value,y=h(t,["sx","value"]),b=(0,d.useMemo)((function(){var e;return v((m(e={},"& .".concat(i.Z.icon),{color:p.s7}),m(e,"& .".concat(l.Z.root),{marginRight:".8em"}),m(e,"& .".concat(c.Z.root),{color:p.s7,visibility:"hidden"}),m(e,"&:hover .".concat(l.Z.root," .").concat(c.Z.root,",\n &.").concat(a.Z.focused," .").concat(l.Z.root," .").concat(c.Z.root),{visibility:"visible"}),e),x)}),[x]),j=(0,d.useMemo)((function(){return String(g).length>0&&n&&(0,r.jsx)(u.Z,{position:"end",children:(0,r.jsx)(s.Z,{onClick:n,children:(0,r.jsx)(o.Z,{fontSize:"small"})})})}),[n,g]);return(0,r.jsx)(f.Z,v({endAdornment:j,value:g},y,{sx:b}))}},1081:function(e,n,t){"use strict";var r=t(7294);n.Z=function(){var e=(0,r.useRef)(!0);return e.current?(e.current=!1,!0):e.current}},7241:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return Ie}});var r=t(5893),o=t(9008),i=t(4051),l=t.n(i),c=t(7294),a=t(7357),u=t(2428),s=t(2026),f=t(1797),d=t(5293),p=t.n(d),m=t(2029),v=t(7169),h=t(8128),x=t(3631),g=t(4390),y=t(157),b=t(4825),j=t(1496),w=t(3457),Z=t(3640),O=t(6886),P=t(480),S=t(267),C=t(1925),A=t(5934),k=[["iso",["application/x-cd-image","ISO (optical disc)"]],["other",["text/plain","Other file type"]],["script",["text/plain","Script (program)"]]],I=new Map(k),U=t(6125),D=t(4427),E=t(9),F=t(192),L=t(3679),N=t(2879);function T(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t0&&void 0!==arguments[0]?arguments[0]:W,n=e.fileName,t=e.fileType,o=e.fileLocations,i=e.isReadonly,l=e.onChange,a=(0,A.Z)(),u="file-name-".concat(a),s="File name",f="file-type-".concat(a),d="File type",p=(0,c.useMemo)((function(){return o.reduce((function(e,n){var t=n.anvilDescription,r=n.anvilName,o=n.anvilUUID;return e[o]||(e[o]={anvilDescription:t,anvilName:r,anvilUUID:o,flocs:[]}),e[o].flocs.push(n),e}),{})}),[o]);return(0,r.jsxs)(w.Z,{sx:{"> :not(:first-child)":{marginTop:"1em"}},children:[(0,r.jsxs)(Z.Z,{children:[(0,r.jsx)(F.Z,{htmlFor:u,children:s}),(0,r.jsx)(E.Z,{defaultValue:n,disabled:i,id:u,label:s,onChange:function(e){var t=e.target.value;null===l||void 0===l||l.call(null,{fileName:t===n?void 0:t})}})]}),t&&(0,r.jsxs)(Z.Z,{children:[(0,r.jsx)(F.Z,{htmlFor:f,children:d}),(0,r.jsx)(N.Z,{defaultValue:t,disabled:i,id:f,input:(0,r.jsx)(E.Z,{label:d}),onChange:function(e){var n=e.target.value;null===l||void 0===l||l.call(null,{fileType:n===t?void 0:n})},children:k.map((function(e){var n=M(e,2),t=n[0],o=M(n[1],2)[1];return(0,r.jsx)(D.Z,{value:t,children:o},t)}))})]}),(0,r.jsx)(U.Z,{listItems:p,listProps:{dense:!0,disablePadding:!0},renderListItem:function(e,n){var t=n.anvilDescription,c=n.anvilName,a=n.flocs;return(0,r.jsx)(L.TZ,{header:"".concat(c,": ").concat(t),panelProps:{padding:0,width:"100%"},children:(0,r.jsx)(L.bc,{children:(0,r.jsx)(O.ZP,{columns:{xs:1,sm:2,md:3,lg:4,xl:5},columnSpacing:"1em",container:!0,direction:"row",children:a.map((function(n){var t=n.fileLocationUUID,c=n.hostName,a=n.hostUUID,u=n.isFileLocationActive;return(0,r.jsx)(O.ZP,{item:!0,xs:1,children:(0,r.jsx)(P.Z,{control:(0,r.jsx)(V,{checkedIcon:(0,r.jsx)(S.Z,{}),defaultChecked:u,disabled:i,edge:"start",icon:(0,r.jsx)(C.Z,{}),onChange:function(e){var n=e.target.checked;null===l||void 0===l||l.call(null,{isFileLocationActive:n===u?void 0:n},{fileLocationIndex:o.findIndex((function(e){var n=e.fileLocationUUID;return t===n}))})}}),label:c,sx:{color:v.lD},value:"".concat(a,"-sync")})},"floc-".concat(e,"-").concat(a))}))})})})}})]})};H.defaultProps=W;var z=H,G=t(2152),$=t(1200);function X(e,n,t,r,o,i,l){try{var c=e[i](l),a=c.value}catch(u){return void t(u)}c.done?n(a):Promise.resolve(a).then(r,o)}function J(e){return function(){var n=this,t=arguments;return new Promise((function(r,o){var i=e.apply(n,t);function l(e){X(i,r,o,l,c,"next",e)}function c(e){X(i,r,o,l,c,"throw",e)}l(void 0)}))}}function Y(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function q(e){for(var n=1;n0&&void 0!==arguments[0]?arguments[0]:K,n=e.filesOverview,t=e.onEditFilesComplete,o=e.onPurgeFilesComplete,i=(0,c.useState)([]),u=i[0],s=i[1],f=(0,c.useState)([]),d=f[0],p=f[1],j=(0,c.useState)(!1),w=j[0],Z=j[1],O=(0,c.useState)(!1),P=O[0],S=O[1],C=(0,c.useState)(0),A=C[0],k=C[1],I={backgroundColor:v.hM,color:v.lD,"&:hover":{backgroundColor:v.hM}},U=function(e){return function(n){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).fileLocationIndex;void 0!==t?u[e].fileLocations[t]=q({},u[e].fileLocations[t],n):u[e]=q({},u[e],n)}},D=function(e){e.preventDefault(),Z(!0);var n=u.reduce((function(e,n){var t=n.fileLocations,r=n.fileName,o=n.fileType,i=n.fileUUID,l={};void 0!==r&&(l.fileName=r),void 0!==o&&(l.fileType=o);var c=t.reduce((function(e,n){var t=n.fileLocationUUID,r=n.isFileLocationActive;return void 0!==r&&e.push({fileLocationUUID:t,isFileLocationActive:r}),e}),[]);return c.length>0&&(l.fileLocations=c),Object.keys(l).length>0&&e.push(g.Z.put("/file/".concat(i),l)),e}),[]);Promise.all(n).then((function(){Z(!1)})).then(t)},E=function(){S(!1),Z(!0);var e=d.filter((function(e){return e.isSelected})).map((function(e){var n=e.fileUUID;return g.Z.delete("/file/".concat(n))}));Promise.all(e).then((function(){Z(!1)})).then(o)},F=function(){S(!1)},L=function(){var e=d.filter((function(e){return e.isSelected})).length;k(e),e>0&&S(!0)};return(0,c.useEffect)((function(){Z(!0),Promise.all(n.map(function(){var e=J(l().mark((function e(n){var t,r;return l().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=q({},n,{fileLocations:[]}),e.prev=1,e.next=4,(0,$.Z)("".concat(m.Z,"/file/").concat(n.fileUUID));case 4:r=e.sent,t.fileLocations=r.map((function(e){var n=e[5],t=e[6],r=e[7],o=e[8],i=e[9],l=e[10];return{anvilDescription:i,anvilName:o,anvilUUID:r,fileLocationUUID:n,hostName:e[11],hostUUID:l,isFileLocationActive:1===parseInt(t,10)}})),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),t.dataIncompleteError=e.t0;case 11:return e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(n){return e.apply(this,arguments)}}())).then((function(e){p(e);for(var n=[],t=0;t :not(:first-child)":{marginTop:"1em"}},children:[d.map((function(e,n){var t=e.fileName,o=e.fileLocations,i=e.fileType,l=e.fileUUID;return(0,r.jsxs)(a.Z,{sx:{display:"flex",flexDirection:"row","& > :last-child":{flexGrow:1}},children:[(0,r.jsx)(a.Z,{sx:{marginTop:".4em"},children:(0,r.jsx)(h.Z,{onChange:function(e){var t=e.target.checked;d[n].isSelected=t},sx:Y({color:v.s7},"&.".concat(x.Z.checked),{color:v.lD})})}),(0,r.jsx)(z,{fileName:t,fileType:i,fileLocations:o,onChange:U(n)})]},"file-edit-".concat(l))})),d.length>0&&(0,r.jsxs)(a.Z,{sx:{display:"flex",flexDirection:"row",justifyContent:"flex-end","& > :not(:last-child)":{marginRight:".5em"}},children:[(0,r.jsx)(b.Z,{onClick:L,sx:I,children:"Purge"}),(0,r.jsx)(b.Z,{type:"submit",children:"Update"})]})]}),(0,r.jsx)(y.Z,{actionProceedText:"Purge",content:"".concat(A," files will be removed from the system. You cannot undo this purge."),dialogProps:{open:P},onCancelAppend:F,onProceedAppend:E,proceedButtonProps:{sx:I},titleText:"Are you sure you want to purge ".concat(A," selected files? ")})]})})};Q.defaultProps=K;var ee=Q,ne=t(8462),te=t(7212),re=t(7720),oe=t(8600),ie=t.n(oe),le=t(7750),ce=function(e){var n=e.filesOverview;return(0,r.jsx)(ne.Z,{children:n.map((function(e){var n,t,o=e.fileChecksum,i=e.fileName,l=e.fileSizeInBytes,c=e.fileType,u=e.fileUUID,s=ie()(l,{binary:!0});return(0,r.jsx)(te.ZP,{sx:{padding:".6em 0"},children:(0,r.jsxs)(a.Z,{sx:{display:"flex",flexDirection:{xs:"column",md:"row"},width:"100%"},children:[(0,r.jsxs)(a.Z,{sx:{flexGrow:1},children:[(0,r.jsxs)(a.Z,{sx:{display:"flex",flexDirection:"row"},children:[(0,r.jsx)(le.Ac,{sx:{fontFamily:"Source Code Pro",fontWeight:400},text:i}),(0,r.jsx)(re.Z,{flexItem:!0,orientation:"vertical",sx:{backgroundColor:v.d,marginLeft:".5em",marginRight:".5em"}}),(0,r.jsx)(le.Ac,{text:null!==(t=null===(n=I.get(c))||void 0===n?void 0:n[1])&&void 0!==t?t:""})]}),(0,r.jsx)(le.Ac,{text:s})]}),(0,r.jsx)(a.Z,{sx:{alignItems:"center",display:"flex",flexDirection:"row"},children:(0,r.jsx)(le.Ac,{sx:{fontFamily:"Source Code Pro",fontWeight:400},text:o})})]})},u)}))})},ae=t(76),ue=t(9332),se=t(9297),fe=t(8187);function de(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t0&&void 0!==arguments[0]?arguments[0]:ge,n=e.onFileUploadComplete,t=e.eventEmitter,o=(0,c.useRef)(),i=(0,c.useState)([]),l=i[0],u=i[1],s=(0,c.useState)([]),f=s[0],d=s[1],p=function(e){var n,t=I.entries();do{var r=t.next();if(r.value){var o=ve(r.value,2),i=o[0];e===ve(o[1],1)[0]&&(n=i)}else n="other"}while(!n);return n},m=function(e){var n=e.target.files;n&&u(Array.from(n).map((function(e){return{file:e,fileName:e.name,fileLocations:[],fileType:p(e.type)}})))},v=function(e){return function(n){l[e]=me({},l[e],n)}},h=function(e){for(e.preventDefault();l.length>0;){var t=l.shift();if(t){var r=t.file,o=t.fileName,i=new FormData;i.append("file",new File([r],o,me({},r)));var c={fileName:o,progressValue:0};f.push(c),g.Z.post("/file",i,{headers:{"Content-Type":"multipart/form-data"},onUploadProgress:function(e){return function(n){var t=n.loaded,r=n.total;d((function(n){var o=n.find((function(n){return(null===n||void 0===n?void 0:n.fileName)===e}));return o?(o.progressValue=Math.round(t/r*99),he(n)):n}))}}(o)}).then(function(e){return function(){d((function(n){var t=n.find((function(n){return(null===n||void 0===n?void 0:n.fileName)===e}));return t?(t.progressValue=100,he(n)):n})),setTimeout((function(){d((function(n){var t=n.findIndex((function(n){return(null===n||void 0===n?void 0:n.fileName)===e}));return-1===t?n:(delete n[t],he(n))}))}),5e3),null===n||void 0===n||n.call(null)}}(o))}}u([]),d(he(f))};return(0,c.useEffect)((function(){null===t||void 0===t||t.addListener("openFilePicker",(function(){var e;null===(e=o.current)||void 0===e||e.click()})),null===t||void 0===t||t.addListener("clearSelectedFiles",(function(){u([])}))}),[t]),(0,r.jsxs)("form",{onSubmit:h,children:[(0,r.jsx)(ae.Z,{htmlFor:"select-file",children:(0,r.jsx)(ue.Z,{id:"select-file",inputProps:{multiple:!0},onChange:m,ref:o,sx:{display:"none"},type:"file"})}),(0,r.jsx)(a.Z,{sx:{display:"flex",flexDirection:"column"},children:f.reduce((function(e,n){if(!n)return e;var t=n.fileName,o=n.progressValue;return e.push((0,r.jsxs)(a.Z,{sx:{alignItems:{md:"center"},display:"flex",flexDirection:{xs:"column",md:"row"},"& > :first-child":{minWidth:100,overflow:"hidden",overflowWrap:"normal",textOverflow:"ellipsis",whiteSpace:"nowrap",width:{xs:"100%",md:200},wordBreak:"keep-all"},"& > :last-child":{flexGrow:1}},children:[(0,r.jsx)(le.Ac,{text:t}),(0,r.jsx)(se.k,{progressPercentage:o})]},"in-upload-".concat(t))),e}),[])}),(0,r.jsxs)(a.Z,{sx:{display:"flex",flexDirection:"column","& > :not(:first-child)":{marginTop:"1em"}},children:[l.length>0&&(0,r.jsx)(fe.Z,{type:"info",children:"Uploaded files will be listed automatically, but it may take a while for larger files to finish uploading and appear on the list."}),l.map((function(e,n){var t=e.file.name,r=e.fileName,o=e.fileLocations;return(0,c.createElement)(z,{fileName:r,fileLocations:o,key:"selected-".concat(t),onChange:v(n)})})),l.length>0&&(0,r.jsx)(a.Z,{sx:{display:"flex",flexDirection:"row",justifyContent:"flex-end"},children:(0,r.jsx)(b.Z,{type:"submit",children:"Upload"})})]})]})};ye.defaultProps=ge;var be=ye,je=t(1706),we=t(1905);function Ze(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t :first-child":{flexGrow:1},"& > :not(:first-child, :last-child)":{marginRight:".3em"}},children:[(0,r.jsx)(le.z,{text:"Files"}),!y&&(0,r.jsx)(je.Z,{onClick:function(){j.emit("openFilePicker")},children:(0,r.jsx)(u.Z,{})}),(0,r.jsx)(je.Z,{onClick:function(){j.emit("clearSelectedFiles"),b(!y)},children:y?(0,r.jsx)(s.Z,{sx:{color:v.Ej}}):(0,r.jsx)(f.Z,{})})]}),i&&(0,r.jsx)(fe.Z,{text:i,type:"error"}),(0,r.jsx)(be,{eventEmitter:j,onFileUploadComplete:w}),function(){var e;if(h)e=(0,r.jsx)(G.Z,{});else{var t=n.map((function(e){var n=Pe(e,5),t=n[0],r=n[1],o=n[2],i=n[3];return{fileChecksum:n[4],fileName:r,fileSizeInBytes:parseInt(o,10),fileType:i,fileUUID:t}}));e=y?(0,r.jsx)(ee,{filesOverview:t,onEditFilesComplete:w,onPurgeFilesComplete:w}):(0,r.jsx)(ce,{filesOverview:t})}return e}()]})},Ae=Ce,ke=t(5521),Ie=function(){return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.default,{children:(0,r.jsx)("title",{children:"File Manager"})}),(0,r.jsx)(ke.Z,{}),(0,r.jsx)(Ae,{})]})}}},function(e){e.O(0,[382,483,894,182,768,62,780,774,888,179],(function(){return n=8283,e(e.s=n);var n}));var n=e.O();_N_E=n}]);