(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[941],{8283:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/file-manager",function(){return n(7241)}])},4427:function(e,t,n){"use strict";var r=n(5893),o=n(2429),i=n(9309),l=n(7169);function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e){for(var t=1;t=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var m={onClearIndicatorClick:null},y=function(e){var t,n=e.onClearIndicatorClick,y=void 0===n?m.onClearIndicatorClick:n,x=h(e,["onClearIndicatorClick"]),g=x.children,b=x.sx,j=x.value,w=String(j).length>0&&y?(0,r.jsx)(o.Z,{position:"end",children:(0,r.jsx)(i.Z,{onClick:y,children:(0,r.jsx)(f.Z,{fontSize:"small"})})}):void 0,Z=v((p(t={},"& .".concat(l.Z.icon),{color:d.s7}),p(t,"& .".concat(a.Z.root),{marginRight:".8em"}),p(t,"& .".concat(c.Z.root),{color:d.s7,visibility:"hidden"}),p(t,"&:hover .".concat(a.Z.root," .").concat(c.Z.root,",\n &.").concat(u.Z.focused," .").concat(a.Z.root," .").concat(c.Z.root),{visibility:"visible"}),t),b);return(0,r.jsx)(s.Z,v({endAdornment:w},x,{sx:Z,children:g}))};y.defaultProps=m,t.Z=y},7241:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return Ae}});var r=n(5893),o=n(9008),i=n(4051),l=n.n(i),a=n(7294),c=n(7357),u=n(2428),s=n(2026),f=n(1797),d=n(5293),p=n.n(d),v=n(2029),h=n(7169),m=n(8128),y=n(3631),x=n(4390),g=n(157),b=n(4825),j=n(1496),w=n(3457),Z=n(3640),S=n(480),O=n(267),C=n(1925),P=n(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),A=n(4427),U=n(9),D=n(192),F=n(2879);function L(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&void 0!==arguments[0]?arguments[0]:M,t=e.fileName,n=e.fileType,o=e.fileLocations,i=e.isReadonly,l=e.onChange,a=(0,P.Z)(),c="file-name-".concat(a),u="File name",s="file-type-".concat(a),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)(D.Z,{htmlFor:c,children:u}),(0,r.jsx)(U.Z,{defaultValue:t,disabled:i,id:c,label:u,onChange:function(e){var n=e.target.value;null===l||void 0===l||l.call(null,{fileName:n===t?void 0:n})}})]}),n&&(0,r.jsxs)(Z.Z,{children:[(0,r.jsx)(D.Z,{htmlFor:s,children:f}),(0,r.jsx)(F.Z,{defaultValue:n,disabled:i,id:s,input:(0,r.jsx)(U.Z,{label:f}),onChange:function(e){var t=e.target.value;null===l||void 0===l||l.call(null,{fileType:t===n?void 0:t})},children:k.map((function(e){var t=E(e,2),n=t[0],o=E(t[1],2)[1];return(0,r.jsx)(A.Z,{value:n,children:o},n)}))})]}),o.map((function(e,t){var n=e.anvilName,o=e.anvilDescription,a=e.anvilUUID,c=e.isFileLocationActive;return(0,r.jsx)(S.Z,{control:(0,r.jsx)(R,{checkedIcon:(0,r.jsx)(O.Z,{}),defaultChecked:c,disabled:i,icon:(0,r.jsx)(C.Z,{}),onChange:function(e){var n=e.target.checked;null===l||void 0===l||l.call(null,{isFileLocationActive:n===c?void 0:n},{fileLocationIndex:t})}}),label:"".concat(n,": ").concat(o),sx:{color:h.lD},value:"".concat(a,"-sync")},a)}))]})};V.defaultProps=M;var B=V,W=n(2152),z=n(1200);function G(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&void 0!==arguments[0]?arguments[0]:J,t=e.filesOverview,n=e.onEditFilesComplete,o=e.onPurgeFilesComplete,i=(0,a.useState)([]),u=i[0],s=i[1],f=(0,a.useState)([]),d=f[0],p=f[1],j=(0,a.useState)(!1),w=j[0],Z=j[1],S=(0,a.useState)(!1),O=S[0],C=S[1],P=(0,a.useState)(0),k=P[0],I=P[1],A={backgroundColor:h.hM,color:h.lD,"&:hover":{backgroundColor:h.hM}},U=function(e){return function(t){var n=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).fileLocationIndex;void 0!==n?u[e].fileLocations[n]=q({},u[e].fileLocations[n],t):u[e]=q({},u[e],t)}},D=function(e){e.preventDefault(),Z(!0);var t=u.reduce((function(e,t){var n=t.fileLocations,r=t.fileName,o=t.fileType,i=t.fileUUID,l={};void 0!==r&&(l.fileName=r),void 0!==o&&(l.fileType=o);var a=n.reduce((function(e,t){var n=t.fileLocationUUID,r=t.isFileLocationActive;return void 0!==r&&e.push({fileLocationUUID:n,isFileLocationActive:r}),e}),[]);return a.length>0&&(l.fileLocations=a),Object.keys(l).length>0&&e.push(x.Z.put("/file/".concat(i),l)),e}),[]);Promise.all(t).then((function(){Z(!1)})).then(n)},F=function(){C(!1),Z(!0);var e=d.filter((function(e){return e.isSelected})).map((function(e){var t=e.fileUUID;return x.Z.delete("/file/".concat(t))}));Promise.all(e).then((function(){Z(!1)})).then(o)},L=function(){C(!1)},E=function(){var e=d.filter((function(e){return e.isSelected})).length;I(e),e>0&&C(!0)};return(0,a.useEffect)((function(){Z(!0),Promise.all(t.map(function(){var e=X(l().mark((function e(t){var n,r;return l().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=q({},t,{fileLocations:[]}),e.prev=1,e.next=4,(0,z.Z)("".concat(v.Z,"/file/").concat(t.fileUUID));case 4:r=e.sent,n.fileLocations=r.map((function(e){var t=H(e,10),n=t[5],r=t[6],o=t[7],i=t[8];return{anvilDescription:t[9],anvilName:i,anvilUUID:o,fileLocationUUID:n,isFileLocationActive:1===parseInt(r,10)}})),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),n.dataIncompleteError=e.t0;case 11:return e.abrupt("return",n);case 12:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t){return e.apply(this,arguments)}}())).then((function(e){p(e);for(var t=[],n=0;n :not(:first-child)":{marginTop:"1em"}},children:[d.map((function(e,t){var n=e.fileName,o=e.fileLocations,i=e.fileType,l=e.fileUUID;return(0,r.jsxs)(c.Z,{sx:{display:"flex",flexDirection:"row","& > :last-child":{flexGrow:1}},children:[(0,r.jsx)(c.Z,{sx:{marginTop:".4em"},children:(0,r.jsx)(m.Z,{onChange:function(e){var n=e.target.checked;d[t].isSelected=n},sx:Y({color:h.s7},"&.".concat(y.Z.checked),{color:h.lD})})}),(0,r.jsx)(B,{fileName:n,fileType:i,fileLocations:o,onChange:U(t)})]},"file-edit-".concat(l))})),d.length>0&&(0,r.jsxs)(c.Z,{sx:{display:"flex",flexDirection:"row",justifyContent:"flex-end","& > :not(:last-child)":{marginRight:".5em"}},children:[(0,r.jsx)(b.Z,{onClick:E,sx:A,children:"Purge"}),(0,r.jsx)(b.Z,{type:"submit",children:"Update"})]})]}),(0,r.jsx)(g.Z,{actionProceedText:"Purge",content:"".concat(k," files will be removed from the system. You cannot undo this purge."),dialogProps:{open:O},onCancelAppend:L,onProceedAppend:F,proceedButtonProps:{sx:A},titleText:"Are you sure you want to purge ".concat(k," selected files? ")})]})})};K.defaultProps=J;var Q=K,ee=n(8462),te=n(891),ne=n(7720),re=n(8600),oe=n.n(re),ie=n(2416),le=function(e){var t=e.filesOverview;return(0,r.jsx)(ee.Z,{children:t.map((function(e){var t,n,o=e.fileChecksum,i=e.fileName,l=e.fileSizeInBytes,a=e.fileType,u=e.fileUUID,s=oe()(l,{binary:!0});return(0,r.jsx)(te.ZP,{sx:{padding:".6em 0"},children:(0,r.jsxs)(c.Z,{sx:{display:"flex",flexDirection:{xs:"column",md:"row"},width:"100%"},children:[(0,r.jsxs)(c.Z,{sx:{flexGrow:1},children:[(0,r.jsxs)(c.Z,{sx:{display:"flex",flexDirection:"row"},children:[(0,r.jsx)(ie.Ac,{sx:{fontFamily:"Source Code Pro",fontWeight:400},text:i}),(0,r.jsx)(ne.Z,{flexItem:!0,orientation:"vertical",sx:{backgroundColor:h.d,marginLeft:".5em",marginRight:".5em"}}),(0,r.jsx)(ie.Ac,{text:null!==(n=null===(t=I.get(a))||void 0===t?void 0:t[1])&&void 0!==n?n:""})]}),(0,r.jsx)(ie.Ac,{text:s})]}),(0,r.jsx)(c.Z,{sx:{alignItems:"center",display:"flex",flexDirection:"row"},children:(0,r.jsx)(ie.Ac,{sx:{fontFamily:"Source Code Pro",fontWeight:400},text:o})})]})},u)}))})},ae=n(76),ce=n(9332),ue=n(9297),se=n(8187);function fe(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&void 0!==arguments[0]?arguments[0]:ye,t=e.onFileUploadComplete,n=e.eventEmitter,o=(0,a.useRef)(),i=(0,a.useState)([]),l=i[0],u=i[1],s=(0,a.useState)([]),f=s[0],d=s[1],p=function(e){var t,n=I.entries();do{var r=n.next();if(r.value){var o=ve(r.value,2),i=o[0];e===ve(o[1],1)[0]&&(t=i)}else t="other"}while(!t);return t},v=function(e){var t=e.target.files;t&&u(Array.from(t).map((function(e){return{file:e,fileName:e.name,fileLocations:[],fileType:p(e.type)}})))},h=function(e){return function(t){l[e]=pe({},l[e],t)}},m=function(e){for(e.preventDefault();l.length>0;){var n=l.shift();if(n){var r=n.file,o=n.fileName,i=new FormData;i.append("file",new File([r],o,pe({},r)));var a={fileName:o,progressValue:0};f.push(a),x.Z.post("/file",i,{headers:{"Content-Type":"multipart/form-data"},onUploadProgress:function(e){var t=e.loaded,n=e.total;a.progressValue=Math.round(t/n*100),d(he(f))}}).then((function(){null===t||void 0===t||t.call(null),f.splice(f.indexOf(a),1),d(he(f))}))}}u([]),d(he(f))};return(0,a.useEffect)((function(){null===n||void 0===n||n.addListener("openFilePicker",(function(){var e;null===(e=o.current)||void 0===e||e.click()})),null===n||void 0===n||n.addListener("clearSelectedFiles",(function(){u([])}))}),[n]),(0,r.jsxs)("form",{onSubmit:m,children:[(0,r.jsx)(ae.Z,{htmlFor:"select-file",children:(0,r.jsx)(ce.Z,{id:"select-file",inputProps:{multiple:!0},onChange:v,ref:o,sx:{display:"none"},type:"file"})}),(0,r.jsx)(c.Z,{sx:{display:"flex",flexDirection:"column"},children:f.map((function(e){var t=e.fileName,n=e.progressValue;return(0,r.jsxs)(c.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:t}),(0,r.jsx)(ue.k,{progressPercentage:n})]},"in-upload-".concat(t))}))}),(0,r.jsxs)(c.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,t){var n=e.file.name,r=e.fileName,o=e.fileLocations;return(0,a.createElement)(B,{fileName:r,fileLocations:o,key:"selected-".concat(n),onChange:h(t)})})),l.length>0&&(0,r.jsx)(c.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=n(1706),je=n(3679),we=n(1905);function Ze(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n :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(m)e=(0,r.jsx)(W.Z,{});else{var n=t.map((function(e){var t=Oe(e,5),n=t[0],r=t[1],o=t[2],i=t[3];return{fileChecksum:t[4],fileName:r,fileSizeInBytes:parseInt(o,10),fileType:i,fileUUID:n}}));e=g?(0,r.jsx)(Q,{filesOverview:n,onEditFilesComplete:w,onPurgeFilesComplete:w}):(0,r.jsx)(le,{filesOverview:n})}return e}()]})},ke=Pe,Ie=n(5716),Ae=function(){return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.default,{children:(0,r.jsx)("title",{children:"File Manager"})}),(0,r.jsx)(Ie.Z,{}),(0,r.jsx)(ke,{})]})}}},function(e){e.O(0,[738,688,7,643,716,315,818,141,774,888,179],(function(){return t=8283,e(e.s=t);var t}));var t=e.O();_N_E=t}]);