(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 y(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 x={blue:c.Ej,red:c.hM},g=(0,l.forwardRef)((function(e,n){var t=e.actionCancelText,p=void 0===t?"Cancel":t,m=e.actionProceedText,g=e.contentContainerProps,b=void 0===g?{}:g,j=e.closeOnProceed,w=void 0!==j&&j,Z=e.content,O=e.dialogProps,S=void 0===O?{}:O,C=S.open,P=void 0!==C&&C,A=S.PaperProps,k=void 0===A?{}:A,I=e.disableProceed,D=e.formContent,U=e.loading,E=void 0!==U&&U,F=e.loadingAction,L=void 0!==F&&F,T=e.onActionAppend,N=e.onCancelAppend,M=e.onProceedAppend,B=e.onSubmitAppend,_=e.openInitially,R=void 0!==_&&_,W=e.preActionArea,H=e.proceedButtonProps,V=void 0===H?{}:H,z=e.proceedColour,$=void 0===z?"blue":z,G=e.scrollContent,X=void 0!==G&&G,J=e.scrollBoxProps,Y=(void 0===J?{}:J).sx,q=e.titleText,K=v(e.dialogProps,["open","PaperProps"]),Q=v(e.scrollBoxProps,["sx"]),ee=k.sx,ne=v(k,["sx"]),te=V.disabled,re=void 0===te?I:te,oe=V.sx,ie=v(V,["disabled","sx"]),le=(0,l.useState)(R),ce=le[0],ae=le[1],ue=(0,l.useMemo)((function(){return n?ce:P}),[P,ce,n]),se=(0,l.useMemo)((function(){return x[$]}),[$]),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=P(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=v(e,["onClearIndicatorClick"]),y=t.sx,x=t.value,g=v(t,["sx","value"]),b=(0,d.useMemo)((function(){var e;return h((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),y)}),[y]),j=(0,d.useMemo)((function(){return String(x).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,x]);return(0,r.jsx)(f.Z,h({endAdornment:j,value:x},g,{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),h=t(7169),v=t(8128),y=t(3631),x=t(4390),g=t(157),b=t(4825),j=t(1496),w=t(3457),Z=t(3640),O=t(480),S=t(267),C=t(1925),P=t(5934),A=[["iso",["application/x-cd-image","ISO (optical disc)"]],["other",["text/plain","Other file type"]],["script",["text/plain","Script (program)"]]],k=new Map(A),I=t(4427),D=t(9),U=t(192),E=t(2879);function F(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]:B,n=e.fileName,t=e.fileType,o=e.fileLocations,i=e.isReadonly,l=e.onChange,c=(0,P.Z)(),a="file-name-".concat(c),u="File name",s="file-type-".concat(c),f="File type";return(0,r.jsxs)(w.Z,{sx:{"> :not(:first-child)":{marginTop:"1em"}},children:[(0,r.jsxs)(Z.Z,{children:[(0,r.jsx)(U.Z,{htmlFor:a,children:u}),(0,r.jsx)(D.Z,{defaultValue:n,disabled:i,id:a,label:u,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)(U.Z,{htmlFor:s,children:f}),(0,r.jsx)(E.Z,{defaultValue:t,disabled:i,id:s,input:(0,r.jsx)(D.Z,{label:f}),onChange:function(e){var n=e.target.value;null===l||void 0===l||l.call(null,{fileType:n===t?void 0:n})},children:A.map((function(e){var n=L(e,2),t=n[0],o=L(n[1],2)[1];return(0,r.jsx)(I.Z,{value:t,children:o},t)}))})]}),o.map((function(e,n){var t=e.anvilName,o=e.anvilDescription,c=e.anvilUUID,a=e.isFileLocationActive;return(0,r.jsx)(O.Z,{control:(0,r.jsx)(_,{checkedIcon:(0,r.jsx)(S.Z,{}),defaultChecked:a,disabled:i,icon:(0,r.jsx)(C.Z,{}),onChange:function(e){var t=e.target.checked;null===l||void 0===l||l.call(null,{isFileLocationActive:t===a?void 0:t},{fileLocationIndex:n})}}),label:"".concat(t,": ").concat(o),sx:{color:h.lD},value:"".concat(c,"-sync")},c)}))]})};R.defaultProps=B;var W=R,H=t(2152),V=t(1200);function z(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]:q,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),S=O[0],C=O[1],P=(0,c.useState)(0),A=P[0],k=P[1],I={backgroundColor:h.hM,color:h.lD,"&:hover":{backgroundColor:h.hM}},D=function(e){return function(n){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).fileLocationIndex;void 0!==t?u[e].fileLocations[t]=J({},u[e].fileLocations[t],n):u[e]=J({},u[e],n)}},U=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(x.Z.put("/file/".concat(i),l)),e}),[]);Promise.all(n).then((function(){Z(!1)})).then(t)},E=function(){C(!1),Z(!0);var e=d.filter((function(e){return e.isSelected})).map((function(e){var n=e.fileUUID;return x.Z.delete("/file/".concat(n))}));Promise.all(e).then((function(){Z(!1)})).then(o)},F=function(){C(!1)},L=function(){var e=d.filter((function(e){return e.isSelected})).length;k(e),e>0&&C(!0)};return(0,c.useEffect)((function(){Z(!0),Promise.all(n.map(function(){var e=G(l().mark((function e(n){var t,r;return l().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=J({},n,{fileLocations:[]}),e.prev=1,e.next=4,(0,V.Z)("".concat(m.Z,"/file/").concat(n.fileUUID));case 4:r=e.sent,t.fileLocations=r.map((function(e){var n=Y(e,10),t=n[5],r=n[6],o=n[7],i=n[8];return{anvilDescription:n[9],anvilName:i,anvilUUID:o,fileLocationUUID:t,isFileLocationActive:1===parseInt(r,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)(v.Z,{onChange:function(e){var t=e.target.checked;d[n].isSelected=t},sx:X({color:h.s7},"&.".concat(y.Z.checked),{color:h.lD})})}),(0,r.jsx)(W,{fileName:t,fileType:i,fileLocations:o,onChange:D(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)(g.Z,{actionProceedText:"Purge",content:"".concat(A," files will be removed from the system. You cannot undo this purge."),dialogProps:{open:S},onCancelAppend:F,onProceedAppend:E,proceedButtonProps:{sx:I},titleText:"Are you sure you want to purge ".concat(A," selected files? ")})]})})};K.defaultProps=q;var Q=K,ee=t(8462),ne=t(7212),te=t(7720),re=t(8600),oe=t.n(re),ie=t(7750),le=function(e){var n=e.filesOverview;return(0,r.jsx)(ee.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=oe()(l,{binary:!0});return(0,r.jsx)(ne.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)(ie.Ac,{sx:{fontFamily:"Source Code Pro",fontWeight:400},text:i}),(0,r.jsx)(te.Z,{flexItem:!0,orientation:"vertical",sx:{backgroundColor:h.d,marginLeft:".5em",marginRight:".5em"}}),(0,r.jsx)(ie.Ac,{text:null!==(t=null===(n=k.get(c))||void 0===n?void 0:n[1])&&void 0!==t?t:""})]}),(0,r.jsx)(ie.Ac,{text:s})]}),(0,r.jsx)(a.Z,{sx:{alignItems:"center",display:"flex",flexDirection:"row"},children:(0,r.jsx)(ie.Ac,{sx:{fontFamily:"Source Code Pro",fontWeight:400},text:o})})]})},u)}))})},ce=t(76),ae=t(9332),ue=t(9297),se=t(8187);function fe(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]:ye,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=k.entries();do{var r=t.next();if(r.value){var o=me(r.value,2),i=o[0];e===me(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)}})))},h=function(e){return function(n){l[e]=pe({},l[e],n)}},v=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,pe({},r)));var c={fileName:o,progressValue:0};f.push(c),x.Z.post("/file",i,{headers:{"Content-Type":"multipart/form-data"},onUploadProgress:function(e){var n=e.loaded,t=e.total;c.progressValue=Math.round(n/t*100),d(he(f))}}).then((function(){null===n||void 0===n||n.call(null),f.splice(f.indexOf(c),1),d(he(f))}))}}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:v,children:[(0,r.jsx)(ce.Z,{htmlFor:"select-file",children:(0,r.jsx)(ae.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.map((function(e){var n=e.fileName,t=e.progressValue;return(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)(ie.Ac,{text:n}),(0,r.jsx)(ue.k,{progressPercentage:t})]},"in-upload-".concat(n))}))}),(0,r.jsxs)(a.Z,{sx:{display:"flex",flexDirection:"column","& > :not(:first-child)":{marginTop:"1em"}},children:[l.length>0&&(0,r.jsx)(se.Z,{text:"Uploaded files will be listed automatically, but it may take a while for larger files to appear.",type:"info"}),l.map((function(e,n){var t=e.file.name,r=e.fileName,o=e.fileLocations;return(0,c.createElement)(W,{fileName:r,fileLocations:o,key:"selected-".concat(t),onChange:h(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"})})]})]})};xe.defaultProps=ye;var ge=xe,be=t(1706),je=t(3679),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)(ie.z,{text:"Files"}),!g&&(0,r.jsx)(be.Z,{onClick:function(){j.emit("openFilePicker")},children:(0,r.jsx)(u.Z,{})}),(0,r.jsx)(be.Z,{onClick:function(){j.emit("clearSelectedFiles"),b(!g)},children:g?(0,r.jsx)(s.Z,{sx:{color:h.Ej}}):(0,r.jsx)(f.Z,{})})]}),i&&(0,r.jsx)(se.Z,{text:i,type:"error"}),(0,r.jsx)(ge,{eventEmitter:j,onFileUploadComplete:w}),function(){var e;if(v)e=(0,r.jsx)(H.Z,{});else{var t=n.map((function(e){var n=Se(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=g?(0,r.jsx)(Q,{filesOverview:t,onEditFilesComplete:w,onPurgeFilesComplete:w}):(0,r.jsx)(le,{filesOverview:t})}return e}()]})},Ae=Pe,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,923,894,182,768,746,203,774,888,179],(function(){return n=8283,e(e.s=n);var n}));var n=e.O();_N_E=n}]);