harperdb 4.5.2 → 4.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +1 -1
  2. package/bin/harperdb.js +74 -74
  3. package/bin/lite.js +72 -72
  4. package/launchServiceScripts/launchNatsIngestService.js +72 -72
  5. package/launchServiceScripts/launchNatsReplyService.js +72 -72
  6. package/launchServiceScripts/launchUpdateNodes4-0-0.js +72 -72
  7. package/npm-shrinkwrap.json +78 -69
  8. package/package.json +2 -1
  9. package/resources/auditStore.d.ts +3 -3
  10. package/resources/blob.d.ts +1 -1
  11. package/server/jobs/jobProcess.js +72 -72
  12. package/server/threads/threadServer.js +72 -72
  13. package/studio/build-local/asset-manifest.json +34 -34
  14. package/studio/build-local/index.html +1 -1
  15. package/studio/build-local/static/js/{164.f552d832.chunk.js → 164.13a1ca36.chunk.js} +1 -1
  16. package/studio/build-local/static/js/{708.1805e937.chunk.js → 656.c59b30a3.chunk.js} +2 -2
  17. package/studio/build-local/static/js/{833.5847bc85.chunk.js → 833.4f9ba8bb.chunk.js} +1 -1
  18. package/studio/build-local/static/js/{browse-csvupload.97e20c4a.chunk.js → browse-csvupload.098dfbf3.chunk.js} +1 -1
  19. package/studio/build-local/static/js/{browse-datatable.339fb83c.chunk.js → browse-datatable.dfc8d899.chunk.js} +1 -1
  20. package/studio/build-local/static/js/{browse-entitymanager.fd37a083.chunk.js → browse-entitymanager.efe8323a.chunk.js} +1 -1
  21. package/studio/build-local/static/js/{browse-jsonviewer.f57cc39c.chunk.js → browse-jsonviewer.02fc2ff0.chunk.js} +1 -1
  22. package/studio/build-local/static/js/{custom-functions.f682aa33.chunk.js → custom-functions.b5bc3a63.chunk.js} +1 -1
  23. package/studio/build-local/static/js/{instance-cluster.e2dba73f.chunk.js → instance-cluster.6b4d5fe7.chunk.js} +1 -1
  24. package/studio/build-local/static/js/{instance-config.4e2c4644.chunk.js → instance-config.d949e132.chunk.js} +1 -1
  25. package/studio/build-local/static/js/{instance-logs.bcec2256.chunk.js → instance-logs.37ca1ae8.chunk.js} +1 -1
  26. package/studio/build-local/static/js/{instance-roles.1ad69c74.chunk.js → instance-roles.2e4a1bd0.chunk.js} +1 -1
  27. package/studio/build-local/static/js/{instance-status.4e190908.chunk.js → instance-status.4c0f4e09.chunk.js} +1 -1
  28. package/studio/build-local/static/js/{instance-users-datatable.4a2c57e4.chunk.js → instance-users-datatable.b15433ca.chunk.js} +1 -1
  29. package/studio/build-local/static/js/{instance-users-edit.ecf717d1.chunk.js → instance-users-edit.8b70ada6.chunk.js} +1 -1
  30. package/studio/build-local/static/js/{instance-users.967796d9.chunk.js → instance-users.a8e27d45.chunk.js} +1 -1
  31. package/studio/build-local/static/js/{instance.809ece1e.chunk.js → instance.23ed04ec.chunk.js} +1 -1
  32. package/studio/build-local/static/js/{instances.2eb16b86.chunk.js → instances.bf9a8758.chunk.js} +1 -1
  33. package/studio/build-local/static/js/{main.2384076c.js → main.bef07e50.js} +2 -2
  34. package/studio/build-local/static/js/{offline-app.86377447.chunk.js → offline-app.49a81d63.chunk.js} +1 -1
  35. package/studio/build-local/static/js/{online-app.e65f9ef3.chunk.js → online-app.0a0cf21a.chunk.js} +1 -1
  36. package/studio/build-local/static/js/{organization-billing.1c318ac1.chunk.js → organization-billing.c4519987.chunk.js} +1 -1
  37. package/studio/build-local/static/js/{organization-users.36a2ed5a.chunk.js → organization-users.1ec6dae2.chunk.js} +1 -1
  38. package/studio/build-local/static/js/{organization.9a81d022.chunk.js → organization.e39f6cd2.chunk.js} +1 -1
  39. package/studio/build-local/static/js/{organizations.af48c8e8.chunk.js → organizations.b4583aa2.chunk.js} +1 -1
  40. package/studio/build-local/static/js/{profile.190afea3.chunk.js → profile.a5f8dae5.chunk.js} +1 -1
  41. package/studio/build-local/static/js/{resetPassword.50fa5b91.chunk.js → resetPassword.2dd720ac.chunk.js} +1 -1
  42. package/studio/build-local/static/js/{roles-jsonviewer.b5d5a908.chunk.js → roles-jsonviewer.55d5c685.chunk.js} +1 -1
  43. package/studio/build-local/static/js/{signIn.8fbf4021.chunk.js → signIn.90642da2.chunk.js} +1 -1
  44. package/studio/build-local/static/js/{signUp.459d42df.chunk.js → signUp.88e90055.chunk.js} +1 -1
  45. package/studio/build-local/static/js/{structure-reloader.ceaf6675.chunk.js → structure-reloader.760c8015.chunk.js} +1 -1
  46. package/studio/build-local/static/js/{topnav.79dbd3ab.chunk.js → topnav.a8ee396a.chunk.js} +1 -1
  47. package/studio/build-local/static/js/{updatePassword.b05821cb.chunk.js → updatePassword.0fd3692f.chunk.js} +1 -1
  48. package/utility/hdbTerms.d.ts +2 -0
  49. package/utility/scripts/restartHdb.js +72 -72
  50. /package/studio/build-local/static/js/{708.1805e937.chunk.js.LICENSE.txt → 656.c59b30a3.chunk.js.LICENSE.txt} +0 -0
  51. /package/studio/build-local/static/js/{main.2384076c.js.LICENSE.txt → main.bef07e50.js.LICENSE.txt} +0 -0
@@ -1 +1 @@
1
- "use strict";(self.webpackChunkharperdb_studio=self.webpackChunkharperdb_studio||[]).push([[302],{4298:(e,t,n)=>{n.r(t),n.d(t,{default:()=>gt});var a=n(9950),s=n(6713),r=n(135),l=n(5269),o=n(7176),i=n(6114),c=n(4084),u=n(8156),d=n(1345),p=n(9435),m=n(5488),h=n(3452),f=n(9163),g=n.n(f);var x=n(127);const j=async e=>{let{auth:t,url:n}=e;return(0,x.A)({operation:{operation:"custom_functions_status"},auth:t,url:n,timeout:5e3})},v=async e=>{let{auth:t,url:n}=e;return(0,x.A)({operation:{operation:"get_custom_functions"},auth:t,url:n})};function b(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(e&&e.entries){var s,r,l;if(t===n)e.path=n,e.key=null!==(s=null===(r=(l=crypto).randomUUID)||void 0===r?void 0:r.call(l))&&void 0!==s?s:Math.random().toString().slice(2);for(const s of e.entries){var o,i,c;const e=`${t}/${s.name}`,[,r]=e.split("/");s.project=r,s.path=e,s.key=null!==(o=null===(i=(c=crypto).randomUUID)||void 0===i?void 0:i.call(c))&&void 0!==o?o:Math.random().toString().slice(2),s.readOnly=a||!!s.package,b(s,e,n,s.readOnly)}}}const y=async e=>{let{auth:t,url:n}=e;const a=await(0,x.A)({operation:{operation:"get_components"},auth:t,url:n});return b(a,a.name,a.name,!1),a},N=async e=>{let{auth:t,url:n}=e;const{is_enabled:a,port:s,directory:r,error:o,message:i}=await j({auth:t,url:n}),c=await y({auth:t,url:n}),u={is_enabled:a,port:s,endpoints:a?await v({auth:t,url:n}):{},directory:r,error:o,message:i,fileTree:c};return l.A.update((e=>{e.custom_functions=u})),{custom_functions:u}};var A=n(4414);const k=function(){const e=(0,s.O$)(l.A,(e=>e.auth)),t=(0,s.O$)(l.A,(e=>e.url)),n=(0,s.O$)(l.A,(e=>e.is_local)),r=(0,s.O$)(l.A,(e=>{var t;return null===(t=e.custom_functions)||void 0===t?void 0:t.port})),[d,p]=(0,a.useState)({}),[f,j]=(0,a.useState)({port:r||9926});return g()((async()=>{const{submitted:n}=d;if(n){const{port:n}=f;if(n)if(a=n,Number.isNaN(parseFloat(a))||!Number.isFinite(parseFloat(a)))p({error:"port must be a valid number"});else{const a=await(async e=>{let{auth:t,url:n,port:a}=e;return(0,x.A)({operation:{operation:"configure_cluster",CUSTOM_FUNCTIONS_PORT:parseInt(a,10)},auth:t,url:n})})({auth:e,url:t,port:n});a.error?p({error:a.message}):N({auth:e,url:t})}else p({error:"All fields are required"})}var a}),[d]),g()((()=>{d.submitted||p({})}),[f]),n&&!r?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("div",{className:"text-nowrap mb-3",children:"Custom Functions Port"}),(0,A.jsx)(m.A,{id:"custom_api_port",onChange:e=>j({...f,port:e.target.value}),className:"mb-3 "+(d.error&&!f.port?"error":""),type:"number",title:"custom api port",placeholder:"9926",value:f.port}),(0,A.jsx)(h.A,{color:"success",block:!0,onClick:()=>p({submitted:!0}),children:"Set Custom API Port"}),!!d.error&&(0,A.jsx)(c.A,{className:"mt-3 error",children:(0,A.jsx)(u.A,{children:d.error})})]}):(0,A.jsxs)(o.A,{children:[(0,A.jsxs)(i.A,{xs:"10",children:["Custom Functions Port ",n?r:"Set"]}),(0,A.jsx)(i.A,{xs:"2",className:"text-end",children:(0,A.jsx)("i",{className:"fa fa-check-circle fa-lg text-success"})})]})};var C=n(4834),w=n(2010),_=n(6177);const S=function(e){let{setConfiguring:t}=e;const{compute_stack_id:n}=(0,d.g)(),r=(0,s.O$)(l.A,(e=>e.auth),[n]),o=(0,s.O$)(l.A,(e=>e.url),[n]),i=(0,s.O$)(l.A,(e=>{var t;return parseFloat(null===(t=e.registration)||void 0===t?void 0:t.version)>=4?"nats":"socketcluster"}),[n]),[c,u]=(0,a.useState)({});return g()((async()=>{if(c.submitted){if("nats"===i)await(0,C.A)({auth:r,url:o,customFunctions_enabled:!0});else{const e=await(0,_.A)({auth:r,url:o});await(0,C.A)({auth:r,url:o,operation:"configure_cluster",CUSTOM_FUNCTIONS:!0,CLUSTERING:Boolean(null===e||void 0===e?void 0:e.config_cluster_user),CLUSTERING_PORT:null===e||void 0===e?void 0:e.config_cluster_port,CLUSTERING_USER:null===e||void 0===e?void 0:e.config_cluster_user,NODE_NAME:null===e||void 0===e?void 0:e.nodeName})}window._kmq&&window._kmq.push(["record","enabled custom functions"]),(0,w.A)({auth:r,url:o}),setTimeout((()=>t(!0)),0)}}),[c.submitted]),(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("hr",{className:"my-3"}),(0,A.jsx)(h.A,{color:"success",disabled:c.submitted,block:!0,onClick:()=>u({submitted:!0}),children:c.submitted?(0,A.jsx)("i",{className:"fa fa-spinner fa-spin text-white"}):"Enable Custom Functions"})]})};var F=n(6165),O=n(3150),P=n(3628);const $=function(e){let{setConfiguring:t}=e;const{compute_stack_id:n}=(0,d.g)(),a=(0,s.O$)(l.A,(e=>{var t;return null===(t=e.custom_functions)||void 0===t?void 0:t.port}),[n]);return(0,A.jsxs)(o.A,{id:"functions",children:[(0,A.jsxs)(i.A,{xl:"3",lg:"4",md:"5",xs:"12",children:[(0,A.jsx)("span",{className:"floating-card-header",children:"enable custom functions"}),(0,A.jsx)(c.A,{className:"my-3",children:(0,A.jsx)(u.A,{children:(0,A.jsxs)(p.tH,{onError:(e,t)=>(0,P.A)({error:{message:e.message,componentStack:t}}),FallbackComponent:O.A,children:[(0,A.jsx)(k,{}),!!a&&(0,A.jsx)(S,{setConfiguring:t})]})})})]}),(0,A.jsx)(i.A,{xl:"9",lg:"8",md:"7",xs:"12",children:a?(0,A.jsx)(F.A,{headline:"Enable Custom Functions",description:"Click the button at left to enable Custom Functions. NOTE: We'll restart the instance when you click this button.",icon:(0,A.jsx)("i",{className:"fa fa-thumbs-up text-success"})}):(0,A.jsx)(F.A,{headline:"Set Your Custom Functions Server Port",description:"If your instance is behind a firewall, you'll need to ensure this port is accessible by other instances if you want to access the API.",icon:(0,A.jsx)("i",{className:"fa fa-thumbs-up text-success"})})})]})};var E=n(7348),D=n(5553);const I=async e=>{let{auth:t,url:n,project:a,file:s}=e;return(0,x.A)({operation:{operation:"get_component_file",project:a,file:s},auth:t,url:n})},T=async e=>{let{auth:t,url:n,project:a,file:s,payload:r}=e;return(0,x.A)({operation:{operation:"set_component_file",project:a,file:s,payload:r},auth:t,url:n})},R=async e=>{let{auth:t,url:n,project:a,file:s}=e;return(0,x.A)({operation:{operation:"drop_component",project:a,file:s},auth:t,url:n})},z=async e=>{let{auth:t,url:n,project:a,packageUrl:s,payload:r}=e;return r?(0,x.A)({auth:t,url:n,operation:{operation:"deploy_component",project:a,payload:r}}):(0,x.A)({auth:t,url:n,operation:{operation:"deploy_component",project:a,package:s}})};var U=n(1534),L=n(4319);const W=(0,n(6997).A)("editorCache");var M=n(8738),q=n.n(M);function H(){return(0,A.jsx)(c.A,{className:"file-browser-scroll-container",children:(0,A.jsx)(u.A,{children:(0,A.jsxs)("div",{className:"p-4",children:["You have no Harper applications yet. ",(0,A.jsx)("br",{}),(0,A.jsx)("br",{}),'Click "',(0,A.jsx)("i",{className:"fas fa-plus"}),' app" above to create one!',(0,A.jsx)("br",{}),(0,A.jsx)("br",{}),"See the"," ",(0,A.jsx)("a",{className:"docs-link",href:"https://docs.harperdb.io",target:"_blank",rel:"noreferrer",children:"documentation"})," ","for more info on Harper Applications."]})})})}function G(e,t){const n=+Boolean(e.entries),a=+Boolean(t.entries);return n===a?e.name.localeCompare(t.name):a-n}function B(){return(0,A.jsx)("i",{className:q()("package-icon fas fa-cube")})}function V(e){let{name:t,url:n,onPackageSelect:s,selectedPackage:r}=e;const[l,o]=(0,a.useState)(Boolean(r)&&t===(null===r||void 0===r?void 0:r.name));return(0,a.useEffect)((()=>{o(r&&r.name===t)}),[r,t]),(0,A.jsxs)("button",{type:"button",onClick:e=>{s(l?null:{name:t,url:n,event:e}),o(!l)},className:q()("package",{"package-selected":l}),onKeyDown:()=>{},children:[(0,A.jsx)(B,{}),(0,A.jsx)("span",{className:"package-text",children:t})]})}function K(e){let{directoryEntry:t,selectedFile:n,selectedFolder:a,onFileSelect:s,onFolderSelect:r,Icon:l}=e;const o=Boolean(t.entries);const i=t.path===n,c=t.path===(null===a||void 0===a?void 0:a.path);return(0,A.jsxs)("button",{type:"button",onClick:function(e){const n=e.target.classList.contains("rename-file")||e.target.classList.contains("deploy-project");o?c&&n||r(c?null:t):s(i?null:t)},className:q()("file",{"file-selected":i,"folder-selected":c}),onKeyDown:function(){},children:[(0,A.jsx)(l,{className:"filename-icon"}),(0,A.jsx)("span",{className:"filename-text",children:t.name})]})}function Z(e){let{directoryEntry:t,userOnSelect:n,onFolderSelect:s,onDeployProject:r,onFileSelect:l,onPackageSelect:o,onFileRename:i,selectedFile:c,selectedFolder:u,selectedPackage:d}=e;const[p,m]=(0,a.useState)(!0),h=[...t.entries||[]].sort(G),f=(g=t.name)&&[...g].includes(".")?g.split(".").slice(-1)[0]:null;var g;let x;return x=2===t.path.split("/").length?()=>function(e){let{toggleClosed:t,isOpen:n}=e;return(0,A.jsx)("i",{onClick:t,onKeyDown:t,className:q()("project-icon fas fa-file-code"),tabIndex:0,"aria-expanded":n,"aria-controls":"folder","aria-label":n?"close project":"open project",role:"button"})}({isOpen:p,toggleClosed:()=>m(!p)}):t.entries?()=>function(e){let{toggleClosed:t,isOpen:n}=e;return(0,A.jsx)("i",{onClick:t,onKeyDown:t,className:q()("folder-icon fas "+(n?"fa-folder-open":"fa-folder")),tabIndex:0,"aria-expanded":n,"aria-controls":"folder","aria-label":n?"close folder":"open folder",role:"button"})}({isOpen:p,toggleClosed:()=>m(!p)}):()=>function(e){let{extension:t}=e;switch(t){case"js":return(0,A.jsx)("i",{className:q()("file-icon filetype-js fab fa-js")});case"yaml":return(0,A.jsx)("i",{className:q()("file-icon filetype-yaml fas fa-cog")});default:return(0,A.jsx)("i",{className:q()("file-icon filetype-unknown far fa-file-alt")})}}({extension:f}),(0,A.jsxs)(A.Fragment,{children:["components"!==t.name?(0,A.jsx)("li",{className:q()(`${t.entries?"folder-container":"file-container"} ${p?"folder-open":"folder-closed"}`),children:t.package?(0,A.jsx)(V,{selectedPackage:d,onPackageSelect:o,name:t.name,url:t.package}):(0,A.jsx)(K,{Icon:x,selectedFile:c,selectedFolder:u,selectedPackage:d,directoryEntry:t,onDeployProject:r,onFileRename:()=>{i(t)},onFileSelect:l,onFolderSelect:s,userOnSelect:n})},t.key):null,h.map((e=>(0,A.jsx)("li",{children:(0,A.jsx)("ul",{className:q()("folder",{"folder-contents-open":!0,"folder-contents-closed":!1}),children:(0,A.jsx)(Z,{selectedFile:c,selectedFolder:u,selectedPackage:d,directoryEntry:e,onFileSelect:l,onDeployProject:r,onFileRename:i,onFolderSelect:s,onPackageSelect:o,userOnSelect:n})})},e.key)))]})}const Y=function(e){var t;let{files:n,userOnSelect:a,onFileSelect:s,onPackageSelect:r,onDeployProject:l,onFileRename:o,onFolderSelect:i,selectedFile:d,selectedFolder:p,selectedPackage:m}=e;return null!==n&&void 0!==n&&null!==(t=n.entries)&&void 0!==t&&t.length?(0,A.jsx)(c.A,{className:"file-browser-scroll-container",children:(0,A.jsx)(u.A,{children:(0,A.jsx)("ul",{className:"file-browser",children:(0,A.jsx)(Z,{selectedFile:d,selectedFolder:p,selectedPackage:m,onFileSelect:s,onFileRename:o,onFolderSelect:i,onDeployProject:l,onPackageSelect:r,userOnSelect:a,directoryEntry:n})})})}):(0,A.jsx)(H,{})};var J=n(5023);J.wG.init().then((e=>{e.editor.defineTheme("hdb",{base:"vs-dark",inherit:!0,rules:[],colors:{"editor.background":"#111111"}})}));const Q={js:"javascript",yaml:"yaml",ts:"typescript",json:"json",md:"markdown",html:"html",css:"css",graphql:"graphql",mjs:"javascript"};const X=function(e){let{active:t,file:n,onFileChange:s}=e;const[r,l]=(0,a.useState)("javascript");return(0,a.useEffect)((()=>{const e=function(e){var t;const n=null===(t=e||"")||void 0===t?void 0:t.split(".");return n.length>1?n.slice(-1)[0]:""}(null===n||void 0===n?void 0:n.name);l(Q[e]||"plaintext")}),[n]),t?(0,A.jsx)(J.Ay,{height:"100%",language:r,value:(null===n||void 0===n?void 0:n.content)||"",theme:"hdb",onChange:s,options:{readOnly:null===n||void 0===n?void 0:n.readOnly,automaticLayout:!0,minimap:{enabled:!1}}}):null};function ee(e){let{onClick:t,disabled:n=!1,text:a="",extraClasses:s=""}=e;return(0,A.jsxs)("button",{type:"button",disabled:n,onClick:t,className:s,title:"Create a new app",children:[(0,A.jsx)("i",{className:"fas fa-plus"}),a&&(0,A.jsxs)("span",{className:"ms-1",children:[" ",a]})]})}function te(e){let{onClick:t,disabled:n=!1,text:a="",extraClasses:s=""}=e;return(0,A.jsxs)("button",{type:"button",disabled:n,onClick:t,className:s,title:"Add a folder",children:[(0,A.jsx)("i",{className:"fas fa-plus"}),a&&(0,A.jsx)("span",{className:"ms-1 d-none d-lg-inline-block",children:a})]})}function ne(e){let{onClick:t,disabled:n=!1,text:a="",extraClasses:s=""}=e;return(0,A.jsxs)("button",{type:"button",onClick:t,disabled:n,className:s,title:"Delete selected app or folder",children:[(0,A.jsx)("i",{className:"fas fa-minus"}),a&&(0,A.jsx)("span",{className:"ms-1 d-none d-lg-inline-block",children:a})]})}function ae(e){let{onClick:t,disabled:n,text:a="",extraClasses:s=""}=e;return(0,A.jsxs)("button",{type:"button",disabled:n,onClick:t,className:s,title:"Add a new file",children:[(0,A.jsx)("i",{className:"fas fa-plus"}),a&&(0,A.jsxs)("span",{className:"ms-1 d-none d-lg-inline-block",children:[" ",a]})]})}function se(e){let{onClick:t,disabled:n,text:a="",extraClasses:s=""}=e;return(0,A.jsxs)("button",{type:"button",onClick:t,disabled:n,className:s,title:"Delete selected file",children:[(0,A.jsx)("i",{className:"fas fa-minus"}),a&&(0,A.jsxs)("span",{className:"ms-1 d-none d-lg-inline-block",children:[" ",a]})]})}const re=function(e){let{children:t}=e;return(0,A.jsx)("ul",{className:"file-menu text-nowrap",children:t.map((e=>{var t,n,a;return e&&(0,A.jsx)("li",{className:"file-menu-item",children:e},null!==(t=null===(n=(a=crypto).randomUUID)||void 0===n?void 0:n.call(a))&&void 0!==t?t:Math.random().toString().slice(2))}))})};function le(e){let{onClick:t,disabled:n=!1,text:a="",extraClasses:s=""}=e;return(0,A.jsxs)("button",{type:"button",disabled:n,onClick:t,className:s,title:"Import external component or application",children:[(0,A.jsx)("i",{className:"fas fa-share-alt"}),a&&(0,A.jsx)("span",{className:"ms-2 d-none d-lg-inline-block",children:a})]})}function oe(e){let{onClick:t,savingFile:n,disabled:a=!1,text:s="",extraClasses:r=""}=e;return(0,A.jsxs)("button",{type:"button",onClick:t,disabled:a,className:r,title:"save file to instance",children:[(0,A.jsx)("i",{className:q()("fas",{"fa-save":!n,"fa-spinner":n,"fa-spin":n})}),s&&(0,A.jsx)("span",{className:"ms-2 d-none d-lg-inline-block",children:s})]})}function ie(e){let{onClick:t,restarting:n,disabled:a=!1,text:s="",extraClasses:r=""}=e;return(0,A.jsxs)("button",{type:"button",onClick:t,disabled:a,className:r,title:"Click to restart your instance",children:[(0,A.jsx)("i",{className:q()("fas",{"fa-sync":!n,"fa-spinner":n,"fa-spin":n})}),s&&(0,A.jsx)("span",{className:"ms-2 d-none d-lg-inline-block",children:s})]})}function ce(e){let{onClick:t,restartAfterSave:n,disabled:a=!1,text:s="",extraClasses:r=""}=e;return(0,A.jsxs)("button",{type:"button",onClick:t,disabled:a,className:r,title:"Toggle whether saving a file restarts the application",children:[(0,A.jsx)("i",{className:q()("fa",{"fa-toggle-on":n,"fa-toggle-off":!n})}),s&&(0,A.jsx)("span",{className:"ms-2 d-none d-lg-inline-block",children:s})]})}function ue(e){let{onClick:t,disabled:n=!1,text:a="",extraClasses:s="",loading:r}=e;return(0,A.jsxs)("button",{type:"button",disabled:n,onClick:t,className:s,title:"revert file",children:[(0,A.jsx)("i",{className:q()("revert-file fas",{disabled:n,"fa-history":!r,"fa-spinner":r,"fa-spin":r})}),a&&(0,A.jsx)("span",{className:"ms-2 d-none d-lg-inline-block",children:a})]})}function de(e){let{children:t}=e;return(0,A.jsx)("ul",{className:"editor-menu",children:t.map((e=>{var t,n,a;return e&&(0,A.jsx)("li",{className:"editor-menu-item",children:e},null!==(t=null===(n=(a=crypto).randomUUID)||void 0===n?void 0:n.call(a))&&void 0!==t?t:Math.random().toString().slice(2))}))})}function pe(e){let{active:t,AddProjectButtonClick:n,InstallPackageButtonClick:a}=e;return t?(0,A.jsxs)("div",{className:"content-window",children:[(0,A.jsx)("h4",{className:"mb-5",children:"Add A New Application"}),(0,A.jsx)(ee,{text:"Create A New Application Using The Default Template",extraClasses:"btn btn-block btn-success",onClick:n}),(0,A.jsx)(le,{text:"Import Or Deploy A Remote Application Package",extraClasses:"btn btn-block btn-outline-success mt-2",onClick:a})]}):null}function me(e){let{active:t,type:n}=e;return t?(0,A.jsxs)("div",{className:"content-window text-nowrap",children:[(0,A.jsx)("i",{className:"fa fa-exclamation-triangle mt-5 pt-5"}),"\xa0",(0,A.jsxs)("span",{children:["You have selected a ",n,". Nothing to see here!"]})]}):null}var he=n(6359);function fe(e){return/^[a-zA-Z0-9-_]+$/.test(e)}function ge(e){if(!e)return null;const t={type:null,user:null,repo:null,url:null,package:null,tag:null};if(e.url.match("://"))t.url=e.url,t.type="url";else if(e.url.match("semver:")){const[n,a,s]=e.url.split(/[/#]/);t.type="github",t.user=n,t.repo=a,t.tag=s.replace("semver:","")}else{t.type="npm";const n=e.url.split("/");if(1===n.length){const[e,a]=n[0].split("@");t.package=e,t.tag=a}else if(2===n.length){const[,e]=n,[a,s]=e.split("@");t.package=a,t.tag=s}}return t}function xe(e,t,n){var s=this,r=(0,a.useRef)(null),l=(0,a.useRef)(0),o=(0,a.useRef)(null),i=(0,a.useRef)([]),c=(0,a.useRef)(),u=(0,a.useRef)(),d=(0,a.useRef)(e),p=(0,a.useRef)(!0);d.current=e;var m="undefined"!=typeof window,h=!t&&0!==t&&m;if("function"!=typeof e)throw new TypeError("Expected a function");t=+t||0;var f=!!(n=n||{}).leading,g=!("trailing"in n)||!!n.trailing,x="maxWait"in n,j="debounceOnServer"in n&&!!n.debounceOnServer,v=x?Math.max(+n.maxWait||0,t):null;(0,a.useEffect)((function(){return p.current=!0,function(){p.current=!1}}),[]);var b=(0,a.useMemo)((function(){var e=function(e){var t=i.current,n=c.current;return i.current=c.current=null,l.current=e,u.current=d.current.apply(n,t)},n=function(e,t){h&&cancelAnimationFrame(o.current),o.current=h?requestAnimationFrame(e):setTimeout(e,t)},a=function(e){if(!p.current)return!1;var n=e-r.current;return!r.current||n>=t||n<0||x&&e-l.current>=v},b=function(t){return o.current=null,g&&i.current?e(t):(i.current=c.current=null,u.current)},y=function e(){var s=Date.now();if(a(s))return b(s);if(p.current){var o=t-(s-r.current),i=x?Math.min(o,v-(s-l.current)):o;n(e,i)}},N=function(){if(m||j){var d=Date.now(),h=a(d);if(i.current=[].slice.call(arguments),c.current=s,r.current=d,h){if(!o.current&&p.current)return l.current=r.current,n(y,t),f?e(r.current):u.current;if(x)return n(y,t),e(r.current)}return o.current||n(y,t),u.current}};return N.cancel=function(){o.current&&(h?cancelAnimationFrame(o.current):clearTimeout(o.current)),l.current=0,i.current=r.current=c.current=o.current=null},N.isPending=function(){return!!o.current},N.flush=function(){return o.current?b(Date.now()):u.current},N}),[f,x,t,v,g,h,m,j]);return b}function je(e,t){return e===t}function ve(e,t,n){var s=n&&n.equalityFn||je,r=(0,a.useRef)(e),l=(0,a.useState)({})[1],o=xe((0,a.useCallback)((function(e){r.current=e,l({})}),[l]),t,n),i=(0,a.useRef)(e);return s(i.current,e)||(o(e),i.current=e),[r.current,o]}function be(e){let{pkg:t,setPackageSpec:n}=e;const[s,r]=(0,a.useState)((null===t||void 0===t?void 0:t.user)||""),[l]=ve(s,300),[o,i]=(0,a.useState)((null===t||void 0===t?void 0:t.repo)||""),[c]=ve(o,300),[u,d]=(0,a.useState)([]),[p,h]=(0,a.useState)(!1),[f,g]=(0,a.useState)((null===t||void 0===t?void 0:t.tag)||""),[x,j]=(0,a.useState)(""),[,v]=(0,a.useState)(!1),[b,y]=(0,a.useState)(!1);return(0,a.useEffect)((()=>{r((null===t||void 0===t?void 0:t.user)||""),i((null===t||void 0===t?void 0:t.repo)||""),d(null!==t&&void 0!==t&&t.tag?[null===t||void 0===t?void 0:t.tag]:[]),g((null===t||void 0===t?void 0:t.tag)||"")}),[t]),(0,a.useEffect)((()=>{l&&c?(v(!0),async function(e,t){try{const n=await fetch(`https://api.github.com/repos/${e}/${t}`),a=await n.json();return n.status<400?a.name:null}catch(n){return null}}(s,c).then((e=>{e?(j(e),y(!0),async function(e,t){const n=await fetch(`https://api.github.com/repos/${e}/${t}/git/refs/tags`);if(n.status<400)return(await n.json()).map((e=>e.ref.split("/").slice(-1)[0]));return[]}(s,c).then((e=>{v(!1),h(!0),d(e)}))):(v(!1),y(!1),j(""),d([]))})).catch((()=>{v(!1)}))):(y(!1),v(!1),d([]),g(""))}),[l,c,s]),(0,a.useEffect)((()=>{if(s&&o&&x){n(f?`${s}/${o}#semver:${f}`:`${s}/${o}`)}else n("")}),[x,f,s,n,o]),(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(m.A,{title:"Github Organization",className:"mt-2 form-control",valid:l.length>0&&c.length>0&&b,placeholder:"Github Organization",onChange:e=>r(e.target.value),value:s}),(0,A.jsx)(m.A,{title:"Github Repo",className:"mt-2",placeholder:"Github Repo",onChange:e=>i(e.target.value),value:o}),(null===u||void 0===u?void 0:u.length)>0&&(0,A.jsx)(he.Ay,{className:"react-select-container github-tag-select mt-2",classNamePrefix:"react-select",isDisabled:!x,isSearchable:!0,placeholder:"Choose a tag",onChange:e=>g(e.value),options:u.map((e=>({label:e,value:e})))})]})}function ye(e){let{pkg:t,setPackageSpec:n}=e;const[s,r]=(0,a.useState)(""),[l]=ve(s,300),[o,i]=(0,a.useState)(""),[c,u]=(0,a.useState)(""),[d,p]=(0,a.useState)(""),[m,h]=(0,a.useState)(!1),[f,g]=(0,a.useState)(!1);return(0,a.useEffect)((()=>{r((null===t||void 0===t?void 0:t.package)||"")}),[t]),(0,a.useEffect)((function(){if(d){n(c?`${d}@${c}`:d)}else n("")}),[d,c,n]),(0,a.useEffect)((function(){l?(h(!0),async function(e){var t;const n=await fetch(`https://registry.npmjs.org/-/v1/search?text=${e}`),a=(await n.json()).objects.find((t=>t.package.name===e));return null===a||void 0===a||null===(t=a.package)||void 0===t?void 0:t.name}(l).then((e=>{h(!1),g(!!e),p(e),e&&async function(e){const t=await fetch(`https://registry.npmjs.org/${e}`);return(await t.json())["dist-tags"]}(e).then((e=>{i(e),u(null)})).catch((e=>{throw e}))})).catch((()=>{h(!1)}))):(p(null),i(null),u(null))}),[l]),(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)("div",{className:"input-group",children:[(0,A.jsx)("input",{className:"mt-2 form-control",title:"enter an npm package specifier",value:s,placeholder:"Enter the [@scope]/package",onChange:function(e){r(e.target.value)}}),(0,A.jsx)("div",{className:"input-group-append",children:(0,A.jsx)("i",{className:q()("input-group-text fa mt-2",{"fa-spinner fa-spin loading":m,"fa-check found":l.length>0&&f,"fa-times not-found":l.length>0&&!(m||f),"fa-check not-searching":0===l.length})})})]}),(0,A.jsx)(he.Ay,{className:"react-select-container mt-2",classNamePrefix:"react-select",isDisabled:!s,placeholder:"Choose a tag",disabled:!o,onChange:function(e){let{value:t}=e;u(t)},options:Object.entries(o||[]).map((e=>{let[t,n]=e;return{label:`${t} (${n})`,value:t}}))})]})}function Ne(e){return function(e){try{return Boolean(new URL(e))}catch(t){return!1}}(e)&&(-1!==e.indexOf(".tar")||-1!==e.indexOf(".tar.gz")||-1!==e.indexOf(".tgz"))}function Ae(e){let{pkg:t,setPackageSpec:n}=e;const[s,r]=(0,a.useState)((null===t||void 0===t?void 0:t.url)||""),[l,o]=(0,a.useState)(Ne(null===t||void 0===t?void 0:t.url));return(0,a.useEffect)((()=>{n(l?s:"")}),[s,l,n]),(0,A.jsx)(m.A,{type:"text",id:"tarball-url",title:"URL to gzipped tarball",className:q()("package-url-input mt-2",{invalid:!l}),value:s,onChange:e=>{o(0===e.target.value.length||Ne(e.target.value)),r(e.target.value)},placeholder:"URL to gzipped tarball"})}var ke=n(5996);function Ce(e){let{selectedPackage:t,onConfirm:n,onCancel:r,deployTargets:o,active:i}=e;const c=!1,[u,d]=(0,a.useState)(Boolean(t)),[p,f]=(0,a.useState)(ge(t)),[g,x]=(0,a.useState)((null===p||void 0===p?void 0:p.type)||c),[j,v]=(0,a.useState)((null===t||void 0===t?void 0:t.name)||""),[b,y]=(0,a.useState)(!0),[N,k]=(0,a.useState)(""),[C,w]=(0,a.useState)(!1),_=(0,s.O$)(l.A,(e=>e.auth)),S=(0,s.O$)(l.A,(e=>e.url)),[F,O]=(0,a.useState)([{isCurrentInstance:!0,auth:_,instance:{url:S,instance_name:"This Instance"}}]);function P(){v(""),y(!1),x(!1),O([]),r()}return(0,a.useEffect)((function(){const e=ge(t);v((null===t||void 0===t?void 0:t.name)||""),f(ge(t)),x((null===e||void 0===e?void 0:e.type)||c),d(Boolean(t))}),[t,c]),(0,a.useEffect)((function(){y(fe(j))}),[j]),i?(0,A.jsxs)("div",{className:"content-window",children:[(0,A.jsx)("h4",{className:"mb-5",children:"Import Remote App Package"}),(0,A.jsx)(m.A,{valid:b&&j.length>0,title:"enter a name for this package",value:j,placeholder:"Application Name",onChange:e=>{v(e.target.value),y(fe(e.target.value))}}),!ke.A.is_local_studio&&(0,A.jsx)(he.Ay,{className:"react-select-container package-install-deploy-targets-dropdown mt-2",classNamePrefix:"react-select",isSearchable:!0,isMulti:!0,placeholder:"Choose your deploy targets",onChange:e=>{const t=e.map((e=>e.value)),n=o.filter((e=>t.includes(e.instance.url)));O(n)},options:o.map((e=>({label:e.instance.instance_name,value:e.instance.url})))}),(0,A.jsx)(he.Ay,{className:"react-select-container mt-2",classNamePrefix:"react-select",placeholder:"How would you like to fetch this package?",onChange:function(e){let{value:t}=e;x(t)},options:[{label:"A Public GitHub Repo",value:"github"},{label:"Install a gzipped .tar file from a URL",value:"url"}]}),!b&&j.length>0&&(0,A.jsxs)("span",{className:"text-danger text-center mt-3",children:[(0,A.jsx)("i",{className:"fa fa-exclamation-triangle"}),(0,A.jsx)("br",{}),(0,A.jsx)("span",{className:"mt-2",children:"Project name limited to alphanumeric, dashes, & underscores."})]}),b&&F.length>0&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("div",{className:"mt-2"}),"npm"===g&&(0,A.jsx)(ye,{projectName:j,installed:u,pkg:p,setPackageSpec:k}),"github"===g&&(0,A.jsx)(be,{projectName:j,installed:u,pkg:p,setPackageSpec:k}),"url"===g&&(0,A.jsx)(Ae,{projectName:j,installed:u,pkg:p,setPackageSpec:k})]}),b&&F.length>0&&g?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(h.A,{onClick:async()=>{w(!0);try{await n(j,N,F)}catch(e){w(!1)}w(!1)},className:q()("btn btn-block btn-success mt-3",{loading:C}),disabled:!fe(j)||!N||!F.length,children:C?(0,A.jsx)("i",{className:"install-package-status-icon fa fa-spinner fa-spin"}):"Install Package"}),(0,A.jsx)(h.A,{onClick:P,className:"btn btn-block btn-outline-success mt-2",children:"Cancel"})]}):(0,A.jsx)(h.A,{onClick:P,className:"btn btn-block btn-outline-success mt-3",children:"Cancel"})]}):null}function we(e){let{className:t,onClick:n,disabled:s,children:r}=e;const[l,o]=(0,a.useState)(!1);return(0,A.jsx)("button",{disabled:s,type:"button",onClick:async()=>{o(!0);try{await n(),o(!1)}catch(e){o(!1)}},className:q()(`${t} button-with-loader`,{loading:l}),children:l?(0,A.jsx)("i",{className:"button-with-loader-icon fas fa-spinner fa-spin"}):r})}function _e(e){let{onCancel:t,onConfirm:n,onEnter:s,value:r,type:l,validate:o=()=>!0}=e;const[i,c]=(0,a.useState)(r||""),[u,d]=(0,a.useState)(!1);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("input",{className:q()("w-100 text-center",{invalid:i.length>0&&!u}),onChange:e=>{c(e.target.value),d(o(e.target.value))},onKeyDown:function(e){"Enter"===e.key?s(e.target.value):"Esc"===e.key&&t()},value:i,placeholder:`name for your new ${l}`,title:`name for your new ${l}`}),(0,A.jsx)("i",{title:"error: name must contain only alphanumeric characters, dashes and underscores.",className:q()("text-danger fa fa-warning",{hidden:u||0===i.length})}),(0,A.jsx)(we,{disabled:!u,className:"btn btn-success btn-block mt-3",onClick:()=>n(i),children:"OK"}),(0,A.jsx)("button",{type:"button",className:"btn btn-outline-success btn-block mt-2",onClick:t,children:"Cancel"}),i.length>0&&!u&&(0,A.jsx)("div",{className:"validation-message mt-5",children:"error: name must contain only alphanumeric characters, dashes and underscores."})]})}function Se(e){let{active:t,onConfirm:n,onCancel:a}=e;return t?(0,A.jsxs)("div",{className:"content-window",children:[(0,A.jsx)("h4",{className:"mb-5",children:"Default Template Application"}),(0,A.jsx)(_e,{type:"project",validate:fe,onEnter:n,onConfirm:n,onCancel:a})]}):null}function Fe(e){let{active:t,onConfirm:n,onCancel:a,selectedFolder:s}=e;return t?(0,A.jsxs)("div",{className:"content-window",children:[(0,A.jsxs)("h4",{className:"mb-5",children:["Add Folder To ",(0,A.jsx)("span",{className:"text-success",children:s.path.replace("components","")})]}),(0,A.jsx)(_e,{type:"folder",selectedFolder:s,onEnter:n,onConfirm:n,onCancel:a})]}):null}function Oe(e){let{active:t,onConfirm:n,onCancel:a}=e;return t?(0,A.jsxs)("div",{className:"content-window",children:[(0,A.jsx)("h4",{className:"mb-5",children:"Add A New File"}),(0,A.jsx)(_e,{type:"file",onEnter:n,onConfirm:n,onCancel:a})]}):null}function Pe(e){let{active:t,selectedFile:n,onConfirm:a,onCancel:s}=e;if(!t)return null;const{path:r}=n,l=r.split("/"),o=l.pop(),i=l.slice(1);return(0,A.jsxs)("div",{className:"content-window",children:[(0,A.jsxs)("h4",{className:"mb-5",children:["Delete ",(0,A.jsx)("span",{className:"text-danger",children:o})," File"]}),(0,A.jsx)(we,{className:"btn btn-danger btn-block delete-button mt-2",onClick:a,children:"Delete"}),(0,A.jsx)("button",{type:"button",className:"btn btn-outline-danger btn-block mt-2",onClick:s,children:"Cancel"}),(0,A.jsxs)("div",{className:"mt-5",children:["Are you sure you want to delete ",(0,A.jsx)("span",{className:"text-danger",children:o})," from"," ",(0,A.jsx)("span",{className:"text-danger",children:i.join("/")}),"?"]})]})}function $e(e){let{active:t,selectedFolder:n,onConfirm:a,onCancel:s}=e;if(!t)return null;if(!n)return null;const r=n.path.split("/"),l=2===r.length,o=l?null:r.slice(-1)[0];return(0,A.jsxs)("div",{className:"content-window",children:[(0,A.jsxs)("h4",{className:"mb-5",children:["Delete ",(0,A.jsx)("span",{className:"text-danger",children:l?null===n||void 0===n?void 0:n.project:o})," ",l?"Project":"Folder"]}),(0,A.jsx)(we,{className:"btn btn-danger btn-block delete-button mt-2",onClick:a,children:"Delete"}),(0,A.jsx)("button",{type:"button",className:"btn btn-outline-danger btn-block mt-2",onClick:s,children:"Cancel"}),(0,A.jsx)("div",{className:"mt-5",children:l?(0,A.jsxs)("div",{children:["Are you sure you want to delete project ",(0,A.jsx)("span",{className:"text-danger",children:null===n||void 0===n?void 0:n.project})," ?"]}):(0,A.jsxs)("div",{children:["Are you sure you want to delete the folder ",(0,A.jsx)("span",{className:"text-danger",children:o})," from"," ",(0,A.jsx)("span",{className:"text-danger",children:null===n||void 0===n?void 0:n.project}),"?"]})})]})}function Ee(e){let{active:t,selectedPackage:n,onConfirm:a,onCancel:s}=e;if(!t)return null;const r=n.name;return(0,A.jsxs)("div",{className:"content-window",children:[(0,A.jsxs)("h4",{className:"mb-5",children:["Delete ",(0,A.jsx)("span",{className:"text-danger",children:r})," Package"]}),(0,A.jsx)(we,{className:"btn btn-danger btn-block delete-button mt-2",onClick:a,children:"Delete"}),(0,A.jsx)("button",{type:"button",className:"btn btn-outline-danger btn-block mt-2",onClick:s,children:"Cancel"}),(0,A.jsxs)("div",{className:"mt-5",children:["Are you sure you want to delete ",(0,A.jsx)("span",{className:"text-danger",children:r}),"?"]})]})}const De="DEFAULT_WINDOW",Ie="DEFAULT_FOLDER_WINDOW",Te="CODE_EDITOR_WINDOW",Re="NAME_FILE_WINDOW",ze="NAME_PROJECT_WINDOW",Ue="NAME_PROJECT_FOLDER_WINDOW",Le="INSTALL_PACKAGE_WINDOW",We="DELETE_FILE_WINDOW",Me="DELETE_FOLDER_WINDOW",qe="DELETE_PACKAGE_WINDOW";function He(e){let{children:t}=e;return(0,A.jsx)(c.A,{className:"editor-window",children:(0,A.jsx)(u.A,{children:t})})}var Ge=n(5502);const Be=function(e){var t,n,s,r;let{deployTargets:l,fileTree:c,onFileSave:u,onAddFile:d,onRevertFile:p,onAddProjectFolder:m,onAddProject:h,onFileChange:f,onDeleteFolder:g,onDeleteFile:x,onDeletePackage:j,onDeployProject:v,onFileSelect:b,onInstallPackage:y,restartInstance:N,restartingInstance:k}=e;const[C,w]=(0,a.useState)(null),[_,S]=(0,a.useState)(null),[F,O]=(0,a.useState)(null),[P,$]=(0,a.useState)(De),[E,D]=(0,a.useState)(null),[I,T]=(0,a.useState)(!0),[R,z]=(0,a.useState)(!1),[U,L]=(0,a.useState)(!1),W=(null===c||void 0===c||null===(t=c.entries)||void 0===t?void 0:t.length)>0,M=Boolean(W&&C),q=Boolean(W&&(C||F)),H=Boolean(C);function G(e,t){$(e),D(t)}function B(){O(null),w(null),S(null)}function V(){G(De,P)}return(0,A.jsxs)(o.A,{id:"webide",children:[(0,A.jsxs)(i.A,{md:"4",xl:"3",className:"file-browser-outer-container mb-3",children:[(0,A.jsx)("div",{className:"floating-card-header-row",children:(0,A.jsxs)(re,{children:[(0,A.jsx)(ee,{onClick:()=>G(De,P),text:"app"}),(H||q)&&(0,A.jsx)("span",{className:"px-1",children:"|"}),H&&(0,A.jsx)(te,{disabled:!H,onClick:()=>G(Ue,P),text:!q&&"folder"}),q&&(0,A.jsx)(ne,{disabled:!q,onClick:()=>{F?G(qe,P):C&&G(Me,P)},text:"folder"}),(M||(null===_||void 0===_?void 0:_.path))&&(0,A.jsx)("span",{className:"px-1",children:"|"}),M&&(0,A.jsx)(ae,{onClick:()=>G(Re,P),disabled:!M,text:!(null!==_&&void 0!==_&&_.path)&&"file"}),(null===_||void 0===_?void 0:_.path)&&(0,A.jsx)(se,{disabled:!(null!==_&&void 0!==_&&_.path),onClick:()=>G(We,P),text:!M&&"file"})]})}),(0,A.jsx)(Y,{files:c,root:c.path,selectedFile:null===_||void 0===_?void 0:_.path,selectedFolder:C,selectedPackage:F,onDeployProject:v,onFolderSelect:e=>{B(),w(e),G(e?Ie:De,P)},onPackageSelect:e=>{B(),O(e),G(e?Ie:De,P)},onFileSelect:async e=>{const t=!e;if(B(),t)S(null),G(De,P);else{const t=await b(e),{content:n,cached:a}=t;S({...e,content:n,cached:a}),G(Te,P)}}})]}),(0,A.jsxs)(i.A,{md:"8",xl:"9",className:"editor-window-container",children:[(0,A.jsxs)(o.A,{className:"floating-card-header-row g-0",children:[(0,A.jsx)(i.A,{className:"text-nowrap",children:_&&(0,A.jsxs)(A.Fragment,{children:[null===_||void 0===_||null===(n=_.path)||void 0===n||null===(s=n.split("/"))||void 0===s||null===(r=s.slice(1))||void 0===r?void 0:r.join(" > ")," ",(0,A.jsxs)("span",{className:"text-grey d-none d-xl-inline-block",children:["| ",(null===_||void 0===_?void 0:_.size)||"..."," bytes |"," ",null!==_&&void 0!==_&&_.mtime?new Date(_.mtime).toLocaleTimeString():"..."]})]})}),(0,A.jsx)(i.A,{className:"text-nowrap",children:(0,A.jsxs)(de,{children:[(0,A.jsx)(oe,{savingFile:U,disabled:!(null!==_&&void 0!==_&&_.cached&&P===Te),onClick:async()=>{L(!0),await u(_,I),L(!1)},text:"save"}),(0,A.jsx)(ue,{loading:R,disabled:!(null!==_&&void 0!==_&&_.cached&&P===Te),onClick:async()=>{z(!0);try{const e=await p(_),t={..._,content:e,cached:!1};S(t)}finally{z(!1)}},text:"revert"}),(0,A.jsx)("span",{className:"px-1",children:"|"}),(0,A.jsx)(ie,{restarting:k,onClick:N,text:"restart"}),(0,A.jsx)(ce,{restartAfterSave:I,onClick:()=>T(!I),text:"auto"})]})})]}),(0,A.jsxs)(He,{children:[(0,A.jsx)(pe,{fileTree:c,active:P===De,AddProjectButtonClick:()=>G(ze,P),InstallPackageButtonClick:()=>{O(null),G(Le,P)}}),(0,A.jsx)(me,{active:P===Ie,type:F?"package":C?"folder":"nothing"}),(0,A.jsx)(Se,{active:P===ze,onConfirm:e=>{!async function(e){await h(e),G(E,P)}(e),(0,Ge.Ak)()},onCancel:V}),(0,A.jsx)(Fe,{projectName:null===C||void 0===C?void 0:C.project,active:P===Ue,selectedFolder:C,onConfirm:async function(e){await m(e,C),G(E,P)},onCancel:V}),(0,A.jsx)(Oe,{active:P===Re,onConfirm:async function(e){const t=await d(e,C);S(t),G(Te,P)},onCancel:V}),(0,A.jsx)(Ce,{active:P===Le,onConfirm:async function(e,t,n){await y(e,t,n),O(null),G(De,P)},onCancel:V,deployTargets:l,selectedPackage:F}),(0,A.jsx)(Ee,{active:P===qe,selectedPackage:F,onConfirm:async()=>{await j(F),G(De,P),B()},onCancel:V}),(0,A.jsx)($e,{active:P===Me,selectedFolder:C,onConfirm:async()=>{await g(C),G(De,P),B()},onCancel:V}),(0,A.jsx)(Pe,{active:P===We,selectedFile:_,onConfirm:async()=>{await x(_),G(De,P),B()},onCancel:V}),(0,A.jsx)(X,{active:P===Te,file:_,onFileChange:async e=>{_&&(!function(e){const t={..._,content:e};S(t)}(e),await f({path:null===_||void 0===_?void 0:_.path,content:e}),S({..._,content:e,cached:!0}))}})]})]})]})},Ve=async e=>{let{auth:t,url:n,function_content:a,project:s,type:r,file:l}=e;return(0,x.A)({operation:{operation:"set_custom_function",function_content:a,project:s,type:r,file:l},auth:t,url:n})},Ke={routes:"'use strict';\n\n/* Dependencies\n- import any packages that are listed in your projects package.json\n- for example:\nimport needle from 'needle'\n*/\n\n/* Helpers\n- import any helper methods from your project's \"helpers\" directory\n- for example:\nimport filter from '../helpers/filter.js';\n*/\n\nmodule.exports = async (server, { hdbCore, logger }) => {\n // POST route\n // with hdbCore.preValidation to process basic auth\n // uses hdbCore.requese to execute the validated request\n server.route({\n url: '/path/to/my/route',\n method: 'POST',\n preValidation: hdbCore.preValidation,\n handler: hdbCore.request,\n })\n\n // GET route\n // with custom validation\n // uses hdbCore.requestWithoutAuthentication\n server.route({\n url: '/path/to/my/route/:id',\n method: 'GET',\n preValidation: async (request, reply) => {\n const token = request.headers.authorization\n const results = hdbCore.requestWithoutAuthentication({\n body: {\n operation: 'search_by_hash',\n schema: 'auth',\n table: 'tokens',\n hash_values: [token],\n get_attributes: ['id']\n }\n })\n if (!results.length) {\n const errorString = result.body.error || 'Sorry, there was an error authenticating your request';\n logger.error(errorString);\n throw new Error(errorString);\n }\n },\n handler: async (request) => {\n const id = parseInt(request.params.id)\n request.body= {\n operation: 'sql',\n sql: `SELECT * FROM dev.dogs WHERE id = ${id}`\n };\n\n /*\n * requestWithoutAuthentication bypasses the standard HarperDB authentication.\n * YOU MUST ADD YOUR OWN preValidation method above, or this method will be available to anyone.\n */\n const result = await hdbCore.requestWithoutAuthentication(request);\n\n return result\n }\n });\n};\n",helpers:"\n/* filters the results, only returning the selected keys */\nexport default (result, keys) => {\n return result.map(r => {\n const f = {}\n keys.forEach(k => f[k] = r[k])\n return f;\n })\n}\n"};var Ze=n(9561);const Ye=function(e){let{items:t,toggleDropItem:n,toggleCreate:r,baseUrl:c,restarting:u,itemType:p,project:f}=e;const g=(0,d.Zp)(),j=(0,E.MW)(),v=(0,s.O$)(l.A,(e=>e.auth)),b=(0,s.O$)(l.A,(e=>e.url)),[y,k]=(0,a.useState)(!1),[C,w]=(0,a.useState)(!1),[_,S]=(0,a.useState)(!1),F=async e=>{e.preventDefault();let n,a=!1;if(y&&!t.includes(y)||(w(!0),a=!0),y&&!(0,Ze.A)(y)&&(w(!0),a=!0,j.error(("projects"===p?"Project":"File")+" names may only contain letters, numbers, hyphens, or underscores.")),a)return!1;if(S(!0),"projects"===p)n=await(async e=>{let{auth:t,url:n,project:a}=e;return(0,x.A)({operation:{operation:"add_custom_function_project",project:a},auth:t,url:n})})({auth:v,url:b,project:y});else{const e=(e=>Ke[e]||null)(p);n=await Ve({auth:v,url:b,project:f,type:p,file:y,function_content:e})}return n.error?(S(!1),r(!1),j.error(n.message)):setTimeout((async()=>(await(0,U.A)({auth:v,url:b,service:"custom_functions"}),await N({auth:v,url:b}),g(`${c}/${y}`))),500)};return(0,a.useEffect)((()=>{n()}),[n]),(0,a.useEffect)((()=>{y&&t.find((e=>e===y))&&g(`${c}/${y}`)}),[t]),(0,A.jsxs)(o.A,{className:"item-row form",children:[(0,A.jsx)(i.A,{className:"input-holder",children:(0,A.jsx)(m.A,{id:"name",invalid:C,onChange:e=>{w(!1),k(e.target.value)},value:y||"",disabled:_,type:"text",name:"name",placeholder:"projects"===p?"ex: api, api-v1, dogs":"routes"===p?"ex: v1, post, public":"ex: filter, auth, queries"})}),(0,A.jsx)(i.A,{className:"item-action",children:_?(0,A.jsx)(h.A,{color:"success",className:"round me-1",children:(0,A.jsx)("i",{className:"fa fa-spinner fa-spin text-white"})}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(h.A,{id:"createItem",color:"success",className:"round me-1",disabled:u,onClick:F,onKeyDown:e=>13!==e.keyCode||F(e),children:(0,A.jsx)("i",{className:"fa fa-check text-white"})}),(0,A.jsx)(h.A,{id:"toggleCreate",color:"black",className:"round",onClick:()=>r(!1),children:(0,A.jsx)("i",{className:"fa fa-times text-white"})})]})})]})},Je=async e=>{let{auth:t,url:n,project:a}=e;return(0,x.A)({operation:{operation:"drop_custom_function_project",project:a},auth:t,url:n})};const Qe=function(e){let{item:t,baseUrl:n,isActive:r,toggleDropItem:c,isDropping:u,itemType:p,restarting:m}=e;const{project:f}=(0,d.g)(),g=(0,d.Zp)(),j=(0,E.MW)(),[v,b]=(0,a.useState)(!1),[y,k]=(0,a.useState)(!1),C=(0,s.O$)(l.A,(e=>e.auth)),w=(0,s.O$)(l.A,(e=>e.url)),_=async()=>{if(!v)return!1;let e;return e="projects"===p?await Je({auth:C,url:w,project:t}):await(async e=>{let{auth:t,url:n,project:a,type:s,file:r}=e;return(0,x.A)({operation:{operation:"drop_custom_function",project:a,type:s,file:r},auth:t,url:n})})({auth:C,url:w,project:f,type:p,file:t}),e.error?(b(!1),k(!1),j.error(e.message)):(j.success(e.message),(0,U.A)({auth:C,url:w,service:"custom_functions"}),await N({auth:C,url:w}),g(n))};return(0,A.jsxs)(o.A,{title:`View${r?"ing":""} ${t}`,className:"item-row "+(r?"active":""),onClick:m?null:()=>!(r||u||v)&&g(`${n}/${t}`),tabIndex:"0",children:[(0,A.jsx)(i.A,{className:"item-label "+(v?"text-danger text-nowrap":""),children:v?`drop ${t}?`:"projects"===p?`/${t}`:t}),(0,A.jsx)(i.A,{className:"item-action",children:y?(0,A.jsx)(h.A,{tabIndex:"-1",disabled:!0,color:"purple",className:"round",children:(0,A.jsx)("i",{className:"fa fa-spinner fa-spin"})}):v?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(h.A,{id:"confirmDropItem",color:"danger",className:"round me-1",title:`confirm drop ${t}`,onClick:()=>{b(!1),k(!0),_()},children:(0,A.jsx)("i",{className:"fa fa-check text-white"})}),(0,A.jsx)(h.A,{id:"cancelDropItem",color:"black",className:"round",title:`Cancel drop ${t}`,onClick:()=>{b(!1)},children:(0,A.jsx)("i",{className:"fa fa-times text-white"})})]}):u?(0,A.jsx)(h.A,{id:"dropItem",color:"danger",className:"round",title:`Drop ${t}`,onClick:()=>{b(t),c(!1)},children:(0,A.jsx)("i",{className:"fa fa-minus text-white"})}):r?(0,A.jsx)(h.A,{tabIndex:"-1",color:"purple",className:"round",children:(0,A.jsx)("i",{className:"fa fa-chevron-right"})}):null})]},t)};const Xe=function(e){let{items:t,toggleDropItem:n,isDropping:a,toggleCreate:s,project:r,isCreating:l,restarting:c,itemType:u,showForm:d}=e;return(0,A.jsxs)(o.A,{className:"floating-card-header",children:[(0,A.jsx)(i.A,{children:"projects"===u?"projects":`/${r}/${u}`}),d&&null!==t&&void 0!==t&&t.length?(0,A.jsxs)(i.A,{className:"text-end",children:[(0,A.jsx)(h.A,{disabled:c,id:"toggleRemove",color:"link",title:"Remove Functions",className:"add-remove me-3",onClick:()=>{n(!a),s(!1)},children:(0,A.jsx)("i",{className:"fa fa-minus"})}),(0,A.jsx)(h.A,{disabled:c,id:"toggleCreate",color:"link",title:"Add Function",className:"add-remove me-1",onClick:()=>{s(!l),n(!1)},children:(0,A.jsx)("i",{className:"fa fa-plus"})})]}):null]})};const et=function(e){let{items:t,activeItem:n,baseUrl:s,restarting:r,itemType:l,project:o,showForm:i}=e;const[d,p]=(0,a.useState)(!1),[m,h]=(0,a.useState)(!1);return(0,a.useEffect)((()=>{h(),p()}),[n,t.length]),(0,A.jsxs)("div",{className:"entity-manager",children:[(0,A.jsx)(Xe,{items:t,itemType:l,isDropping:d,toggleDropItem:p,isCreating:m,toggleCreate:h,restarting:r,project:o,showForm:i}),(0,A.jsxs)(c.A,{className:"my-3",children:[t&&t.length?(0,A.jsx)(u.A,{className:"scrollable "+(m?"creating":""),children:t.map((e=>(0,A.jsx)(Qe,{item:e,baseUrl:s,isActive:n===e,isDropping:d,toggleDropItem:p,itemType:l,restarting:r},e)))}):null,i&&t&&!t.length||m?(0,A.jsx)(u.A,{children:(0,A.jsx)(Ye,{items:t,itemType:l,baseUrl:s,isDropping:d,toggleDropItem:p,isCreating:m,toggleCreate:h,restarting:r,project:o})}):!t||t.length||m?null:(0,A.jsx)(u.A,{children:(0,A.jsx)("div",{className:"py-3 text-center no-content",children:"no functions found"})})]})]})};const tt=function(){const e=(0,d.Zp)(),t=(0,E.MW)(),{customer_id:n,compute_stack_id:r,project:p,type:m,file:f}=(0,d.g)(),g=(0,s.O$)(l.A,(e=>e.auth)),j=(0,s.O$)(l.A,(e=>e.url)),[v,b]=(0,a.useState)(""),[y,N]=(0,a.useState)(""),k=(0,a.useCallback)((async()=>{if(p&&m&&f&&"undefined"!==f){const e=await(async e=>{let{auth:t,url:n,project:a,type:s,file:r}=e;return(0,x.A)({operation:{operation:"get_custom_function",project:a,type:s,file:r},auth:t,url:n})})({auth:g,url:j,project:p,type:m,file:f});b(null===e||void 0===e?void 0:e.message),N(null===e||void 0===e?void 0:e.message)}else b("")}),[g,j,p,m,f,b]);return(0,a.useEffect)((()=>{k()}),[p,f,k,r]),(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(o.A,{className:"floating-card-header",children:[(0,A.jsxs)(i.A,{children:["edit >\xa0",(0,A.jsxs)("i",{children:["/",p,f&&"undefined"!==f&&`/${m}/${f}.js`]})]}),(0,A.jsxs)(i.A,{className:"text-end",children:[(0,A.jsxs)(h.A,{onClick:k,color:"link",className:"me-2",children:[(0,A.jsx)("span",{className:"me-2",children:"reload"}),(0,A.jsx)("i",{title:"Reload File",className:"fa fa-sync-alt"})]}),(0,A.jsx)("span",{className:"mx-3 text",children:"|"}),(0,A.jsxs)(h.A,{onClick:()=>e(`/o/${n}/i/${r}/functions/deploy/${p}`),color:"link",className:"me-2",children:[(0,A.jsx)("span",{className:"me-2",children:"deploy"}),(0,A.jsx)("i",{title:"Deploy Project",className:"fa fa-share"})]})]})]}),(0,A.jsx)(c.A,{className:"my-3",children:v?(0,A.jsxs)(u.A,{children:[(0,A.jsx)("div",{className:"code-editor-holder",children:(0,A.jsx)(J.Ay,{height:"100%",defaultLanguage:"javascript",value:v,theme:"vs-dark",onChange:b})}),(0,A.jsxs)(o.A,{children:[(0,A.jsx)(i.A,{md:"6",className:"mt-2",children:(0,A.jsx)(h.A,{block:!0,color:"grey",title:"Revert Code to Last Saved State",disabled:v===y,onClick:k,id:"reset",children:(0,A.jsx)("i",{className:"fa fa-undo"})})}),(0,A.jsx)(i.A,{md:"6",className:"mt-2",children:(0,A.jsx)(h.A,{block:!0,title:"Save Code to Instance",color:"success",id:"addEditItem",onClick:async()=>{const e=await Ve({auth:g,url:j,function_content:v,project:p,type:m,file:f});e.error?t.error(e.message):(setTimeout((()=>(0,U.A)({auth:g,url:j,service:"custom_functions"})),500),t.success(e.message)),k()},children:(0,A.jsx)("i",{className:"fa fa-save"})})})]})]}):(0,A.jsx)(u.A,{children:(0,A.jsxs)("div",{className:"empty-prompt narrow",children:[(0,A.jsx)("div",{className:"mt-3 text-bold",children:"This project does not yet have any routes or helpers"}),(0,A.jsx)("div",{className:"mt-3",children:"Add some using the form fields at left."})]})})})]})};var nt=n(4343);const at=e=>{let{initializing:t,loading:n,handleClick:a}=e;return[{Header:"instance name",accessor:"instance_name"},{Header:"instance url",accessor:"url"},{Header:"cf capable",id:"hdb-narrow-cfcapable",Cell:e=>{let{row:{original:{custom_functions_status:t}}}=e;return t.error?"no":"yes"}},{Header:"cf enabled",id:"hdb-narrow-cfenabled",Cell:e=>{let{row:{original:{custom_functions_status:t}}}=e;return t.is_enabled?"yes":"no"}},{Header:"has project",id:"hdb-narrow-cfhasproject",Cell:e=>{let{row:{original:{has_current_project:t}}}=e;return t?"yes":"no"}},{Header:"deploy",id:"hdb-narrow-deploy",Cell:e=>{let{row:{original:{compute_stack_id:s,custom_functions_status:r,has_auth:l}}}=e;return r.is_enabled&&l?(0,A.jsx)(h.A,{color:"success",block:!0,size:"sm",disabled:t||n[s],onClick:()=>a(s,"deploy"),children:(0,A.jsx)("i",{className:"fa "+("deploy"===n[s]?"fa-spinner fa-spin":"fa-share")})}):null}},{Header:"remove",id:"hdb-narrow-remove",Cell:e=>{let{row:{original:{compute_stack_id:t,custom_functions_status:s,has_current_project:r,has_auth:l}}}=e;return s.is_enabled&&r&&l?(0,A.jsx)(h.A,{color:"danger",block:!0,size:"sm",disabled:n[t],onClick:()=>a(t,"drop"),children:(0,A.jsx)("i",{className:"fa "+("drop"===n[t]?"fa-spinner fa-spin":"fa-trash")})}):null}}]},st={filtered:[],sorted:[],page:0,totalPages:1,pageSize:20,autoRefresh:!1,showFilter:!1,lastUpdate:!1};const rt=function(){const{customer_id:e,compute_stack_id:t,project:n}=(0,d.g)(),r=(0,d.Zp)(),[p]=(0,L.A)({}),m=(0,s.O$)(l.A,(e=>e.auth)),f=(0,s.O$)(l.A,(e=>e.url)),b=(0,s.O$)(l.A,(e=>{var t;return null===(t=e.registration)||void 0===t?void 0:t.version})),[{payload:y,file:N},k]=(0,a.useState)([]),C=`/o/${e}/i/${t}/functions/edit/${n}`,w=(0,s.O$)(D.A,(e=>e.instances.filter((e=>e.compute_stack_id!==t)))),[_,S]=b.split("."),F=_>=3&&(_>3||S>=3),[O,P]=(0,a.useState)([]),[$,E]=(0,a.useState)(F),[I,T]=(0,a.useReducer)(((e,t)=>({...e,...t})),{}),[R,z]=(0,a.useState)(st),W=(0,a.useCallback)((()=>r(C)),[r,C]),M=(0,a.useCallback)((async(e,t)=>{const a=O.find((t=>t.compute_stack_id===e)),s=p[e];if(a&&s){T({[e]:t});let r=!1;const l=await j({auth:s,url:a.url});if(!l.error){const e=await v({auth:s,url:a.url});r=Object.keys(e).includes(n)}const o=O.map((t=>(t.compute_stack_id===e&&(t.custom_functions_status=l,t.has_current_project=r),t)));P(o),T({[e]:null})}}),[p,n,O]),q=(0,a.useCallback)((async(e,t)=>{const a=O.find((t=>t.compute_stack_id===e)),s=p[e];a&&s&&(T({[e]:t}),"deploy"===t?(await(async e=>{let{auth:t,url:n,project:a,payload:s,file:r}=e;return(0,x.A)({operation:{operation:"deploy_custom_function_project",project:a,payload:s,file:r},auth:t,url:n})})({auth:s,url:a.url,payload:y,project:n,file:N}),$&&await(async e=>{let{auth:t,url:n,projects:a,dry_run:s=!1}=e;return(0,x.A)({operation:{operation:"install_node_modules",projects:a,dry_run:s},auth:t,url:n})})({auth:s,url:a.url,projects:[n]}),await(0,U.A)({auth:s,url:a.url,service:"custom_functions"})):await Je({auth:s,url:a.url,project:n}),setTimeout((()=>{T({[e]:!1}),M(e,t)}),1e3))}),[N,p,y,n,O,M,$]);return g()((async()=>{if(m&&f&&n){k(!1);const e=await(async e=>{let{auth:t,url:n,project:a,skip_node_modules:s}=e;return(0,x.A)({operation:{operation:"package_custom_function_project",project:a,skip_node_modules:s},auth:t,url:n})})({auth:m,url:f,project:n,skip_node_modules:$});k(e)}}),[m,f,n,$]),g()((async()=>{if(w){const e=await Promise.all(w.map((async e=>{const t=p[e.compute_stack_id];let a={};if(t){const s=await j({auth:t,url:e.url});return s.error||(a=await v({auth:t,url:e.url})),{...e,custom_functions_status:s,has_auth:!0,has_current_project:Object.keys(a).includes(n)}}return{...e,custom_functions_status:!1}})));P(e)}}),[w,n]),(0,a.useEffect)((()=>{z({...R,totalPages:Math.ceil((O.length||R.pageSize)/R.pageSize)})}),[z,R.pageSize]),(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(o.A,{className:"floating-card-header",children:[(0,A.jsxs)(i.A,{children:["deploy ",n&&`> ${n}`]}),(0,A.jsxs)(i.A,{className:"text-end",children:[F&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(h.A,{color:"link",title:"Turn on autofresh",onClick:()=>E(!$),children:[(0,A.jsx)("span",{className:"me-2",children:"install dependencies at destination"}),(0,A.jsx)("i",{className:"fa fa-lg fa-toggle-"+($?"on":"off")})]}),(0,A.jsx)("span",{className:"mx-3 text",children:"|"})]}),(0,A.jsxs)(h.A,{onClick:W,color:"link",className:"me-2",children:[(0,A.jsx)("span",{className:"me-2",children:"back to edit"}),(0,A.jsx)("i",{title:"Edit Project",className:"fa fa-edit"})]})]})]}),(0,A.jsx)(c.A,{className:"my-3",children:(0,A.jsx)(u.A,{className:"react-table-holder",children:O.length?(0,A.jsx)(nt.A,{columns:at({initializing:!y,loading:I,handleClick:q}),data:O,page:R.page,pageSize:R.pageSize,totalPages:R.totalPages,showFilter:R.showFilter,sorted:R.sorted,onFilteredChange:e=>z({...R,filtered:e}),onSortedChange:e=>z({...R,sorted:e}),onPageChange:e=>z({...R,pageSize:e}),onPageSizeChange:e=>z({...R,page:0,pageSize:e})}):(0,A.jsx)("div",{className:"empty-prompt",children:"Please register at least one Custom Function-enabled instance to deploy to"})})})]})};const lt=function(e){let{loading:t,refreshCustomFunctions:n,restarting:a}=e;const r=(0,s.O$)(l.A,(e=>e.auth)),o=(0,s.O$)(l.A,(e=>e.url));return(0,A.jsxs)("span",{className:"structure-reloader d-block text-center mb-4",children:[(0,A.jsxs)(h.A,{disabled:t,color:"link",onClick:n,children:[(0,A.jsx)("span",{className:"me-2",children:"refresh projects"}),(0,A.jsx)("i",{title:"Refresh Endpoint Files",className:"fa "+(t?"fa-spinner fa-spin":"fa-sync-alt")})]}),(0,A.jsx)("span",{className:"mx-3 text",children:"|"}),(0,A.jsxs)(h.A,{disabled:a,color:"link",onClick:()=>(0,U.A)({auth:r,url:o,service:"custom_functions"}),className:"me-2",children:[(0,A.jsx)("span",{className:"me-2",children:"restart server"}),(0,A.jsx)("i",{title:"Refresh Endpoint Files",className:"fa "+(a?"fa-spinner fa-spin":"fa-stop-circle")})]}),(0,A.jsx)("hr",{className:"d-block d-md-none mt-4"})]})};const ot=function(e){let{url:t,project:n,fileCount:a}=e;return(0,A.jsxs)("div",{className:"entity-manager",children:[(0,A.jsxs)("div",{className:"floating-card-header",children:["/",n,"/static"]}),(0,A.jsx)(c.A,{className:"my-3",children:(0,A.jsx)(u.A,{children:(0,A.jsxs)(o.A,{className:"item-row",children:[(0,A.jsx)(i.A,{className:"item-label",children:a?"enabled":'"static" subfolder not found'}),(0,A.jsxs)(i.A,{className:"item-action",children:[(0,A.jsx)(h.A,{tabIndex:"-1",color:a?"success":"danger",disabled:!a,className:"round me-1",children:a}),(0,A.jsx)(h.A,{tabIndex:"-1",color:"purple",className:"round",disabled:!a,href:`${t}/${n}/static`,target:"_blank",rel:"noopener noreferrer",children:(0,A.jsx)("i",{title:"View UI",className:"fa fa-share"})})]})]})})})]})};var it=n(7666);const ct=function(e){var t,n,c;let{refreshCustomFunctions:u,loading:m}=e;const{customer_id:h,compute_stack_id:f,action:g="edit",project:x,file:j}=(0,d.g)(),v=(0,d.Zp)(),b=(0,s.O$)(l.A,(e=>e.custom_functions)),y=(0,s.O$)(l.A,(e=>e.registration)),[N,k]=((null===y||void 0===y?void 0:y.version)||"").split("."),C=parseFloat(`${N}.${k}`)<4.1,w=(0,s.O$)(l.A,(e=>"custom_functions"===e.restarting_service)),_=(0,s.O$)(l.A,(e=>{var t;return e.custom_functions_url||`${e.url.split(":").slice(0,-1).join(":")}:${null===(t=e.custom_functions)||void 0===t?void 0:t.port}`})),S=`/o/${h}/i/${f}/functions/${g}`;return(0,a.useEffect)((()=>{const e=(null===b||void 0===b?void 0:b.endpoints)&&Object.keys(null===b||void 0===b?void 0:b.endpoints).length,t=(null===b||void 0===b?void 0:b.endpoints)&&Object.keys(null===b||void 0===b?void 0:b.endpoints).includes(x);if(e&&x&&!t){const e=x&&Object.keys(null===b||void 0===b?void 0:b.endpoints)[0];v(`${S}/${e}`)}else if(e&&x&&!j){var n,a;const e=x&&(null===b||void 0===b||null===(n=b.endpoints[x])||void 0===n?void 0:n.routes[0]),t=x&&(null===b||void 0===b||null===(a=b.endpoints[x])||void 0===a?void 0:a.helpers[0]);v(`${S}/${x}/${e?"routes":"helpers"}/${e||t}`)}else if(e&&!x){const e=Object.keys(null===b||void 0===b?void 0:b.endpoints)[0];v(`${S}/${e}`)}else e||v(S)}),[null===b||void 0===b?void 0:b.endpoints,h,f,v,g,x,j,S]),(0,r.A)((async()=>{if(_&&w)try{await fetch(_),l.A.update((e=>{e.restarting_service=!1}))}catch(e){console.log(e)}}),1e3),(0,A.jsxs)(o.A,{id:"functions",children:[(0,A.jsx)(i.A,{xl:"3",lg:"4",md:"6",xs:"12",children:(0,A.jsxs)(p.tH,{onError:(e,t)=>(0,P.A)({error:{message:e.message,componentStack:t}}),FallbackComponent:O.A,children:[(0,A.jsx)(et,{itemType:"projects",items:Object.keys(null===b||void 0===b?void 0:b.endpoints)||[],activeItem:x,baseUrl:S,restarting:w,showForm:"edit"===g}),x&&"edit"===g&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(et,{itemType:"routes",items:x&&(null===b||void 0===b||null===(t=b.endpoints[x])||void 0===t?void 0:t.routes)||[],project:x,activeItem:j,baseUrl:`${S}/${x}/routes`,restarting:w,showForm:"edit"===g}),(0,A.jsx)(et,{itemType:"helpers",items:x&&(null===b||void 0===b||null===(n=b.endpoints[x])||void 0===n?void 0:n.helpers)||[],project:x,activeItem:j,baseUrl:`${S}/${x}/helpers`,restarting:w,showForm:"edit"===g}),C&&(0,A.jsx)(ot,{url:_,project:x,fileCount:x&&(null===b||void 0===b||null===(c=b.endpoints[x])||void 0===c?void 0:c.static)||0})]}),(0,A.jsx)("hr",{className:"mt-0"}),(0,A.jsxs)("div",{className:"entity-manager-footer",children:[(0,A.jsx)("div",{className:"text-bold mb-1",children:"Root File Directory"}),(0,A.jsx)(it.A,{text:b.directory}),(0,A.jsx)("div",{className:"text-bold mb-1 mt-3",children:"Custom Functions Server URL"}),(0,A.jsx)(it.A,{text:_})]}),(0,A.jsx)("hr",{}),(0,A.jsx)(lt,{refreshCustomFunctions:u,loading:m,restarting:w})]})}),(0,A.jsx)(i.A,{xl:"9",lg:"8",md:"6",xs:"12",children:"deploy"===g?(0,A.jsx)(rt,{}):x?(0,A.jsx)(tt,{}):(0,A.jsx)(F.A,{refreshCustomFunctions:u,headline:`Please ${null!==b&&void 0!==b&&b.endpoints.length?"choose":"create"} a project at left.`})})]})};function ut(e){return e.split("/").slice(2).join("/")}function dt(e,t,n,a){return e.reduce(((e,s)=>{const r=s.compute_stack_id,l=t[r];if(null===l||void 0===l||!l.version)return e;const[o,i]=(null===l||void 0===l?void 0:l.version.split("."))||[];return parseInt(o,10)>=4&&parseInt(i,10)>=2&&e.push({isCurrentInstance:r===n,auth:a,instance:s}),e}),[])}const pt=function(e){let{refreshCustomFunctions:t,loading:n}=e;const{compute_stack_id:r}=(0,d.g)(),o=(0,s.O$)(l.A,(e=>e.registration)),{fileTree:i}=(0,s.O$)(l.A,(e=>e.custom_functions)),c=(0,s.O$)(l.A,(e=>e.auth)),u=(0,s.O$)(l.A,(e=>e.url)),[p,m]=((null===o||void 0===o?void 0:o.version)||"").split(".")||[],h=parseFloat(`${p}.${m}`)>=4.2,f=(0,s.O$)(D.A,(e=>e.instances)),[g]=(0,L.A)({}),[j,v]=W({}),[b,y]=(0,a.useState)(!1),N=(0,E.MW)();function k(e){let{path:t}=e;const n={...j},a=`${r}_${t}`;a in n&&delete n[a],v({...n})}async function C(e){let{auth:t,url:n}=e;y(!0),setTimeout((async()=>{await(0,U.A)({auth:t,url:n,service:"http_workers"}),y(!1)}),100)}return h?(0,A.jsx)(Be,{fileTree:i,deployTargets:dt(f,g,r,c),onRevertFile:async function(e){k({path:e.path});const{error:n,message:a}=await I({auth:c,url:u,project:e.project,file:ut(e.path)});return n?N.error(a):(await t(),a)},onFileChange:async function(e){const{path:t,content:n}=e,a=`${r}_${t}`;v({...j,[a]:n})},onFileSave:async function(e,n){const a=e.path.split("/").slice(2).join("/"),s={auth:c,url:u,project:e.project,file:a,payload:e.content},{error:r,message:l}=await T(s);r&&N.error(l),n&&await C({auth:c,url:u}),k({path:e.path}),e.cached=!1,await t()},onUpdate:t,onAddFile:async function(e,n){const{path:a,project:s}=n,r=ut(a),l=r?`${r}/${e}`:e;return await T({auth:c,url:u,project:s,file:l,payload:""}),await t(),{content:"",path:[n.path,e].join("/"),project:s}},onAddProject:async function(e){const{error:n,message:a}=await(async e=>{let{auth:t,url:n,project:a}=e;return(0,x.A)({operation:{operation:"add_component",project:a},auth:t,url:n})})({auth:c,url:u,project:e});n&&N.error(a),await(0,U.A)({auth:c,url:u,service:"http_workers"}),await t()},onAddProjectFolder:async function(e,n){const{path:a,project:s}=n,r=ut(a),l=r?`${r}/${e}`:e,{error:o,message:i}=await T({auth:c,url:u,project:s,file:l});o&&N.error(i),await t()},onInstallPackage:async function(e,n,a){const s=a.map((async t=>{const{error:a,message:s}=await z({auth:t.auth,url:t.instance.url,project:e,packageUrl:n});a&&N.error(s),await(0,U.A)({auth:t.auth,url:t.instance.url,service:"http_workers"})}));await Promise.all(s),await t()},onDeployProject:async function(e){let{project:n,deployTarget:a}=e;const{auth:s,instance:r}=a,{payload:l}=await(async e=>{let{auth:t,url:n,project:a,skip_node_modules:s=!0}=e;return(0,x.A)({auth:t,url:n,operation:{operation:"package_component",project:a,skip_node_modules:s}})})({auth:c,url:u,project:n.name});await z({auth:s,url:r.url,project:n.name,payload:l}),await(0,U.A)({auth:s,url:r.url,service:"http_workers"}),await(0,U.A)({auth:c,url:u,service:"http_workers"}),await t()},onDeleteFile:async function(e){const{error:n,message:a}=await R({auth:c,url:u,project:e.project,file:ut(e.path)});n&&N.error(a),await t()},onDeleteFolder:async function(e){let{path:n,project:a}=e;const s=ut(n);if(s.length>0){const{error:e,message:t}=await R({auth:c,url:u,project:a,file:s});e&&N.error(t)}else{const{error:e,message:t}=await R({auth:c,url:u,project:a});e&&N.error(t)}await t()},onDeletePackage:async function(e){let{name:n}=e;const{error:a,message:s}=await R({auth:c,url:u,project:n});a?N.error(s):(await(0,U.A)({auth:c,url:u,service:"http_workers"}),await t())},onFileSelect:async function(e){const{path:t,project:n,name:a}=e,s=ut(t),l=`${r}_${t}`,o=j[l],i=l in j;if(i)return{cached:i,content:o,path:t,project:n,name:a};const{error:d,message:p}=await I({auth:c,url:u,project:n,file:s});return d?(N.error(p),{content:"",path:t,project:n,name:a,cached:!1}):{cached:i,content:p,path:t,project:n,name:a}},onFileRename:async function(e,n){const{path:a,content:s,project:r}=n,l=ut(a).split("/").slice(0,-1).join("/"),o=l?`${l}/${e}`:e;await R({auth:c,url:u,project:r,file:ut(a)}),await T({auth:c,url:u,project:r,file:o,payload:s}),t()},refreshingCustomFunctions:n,restartInstance:async()=>C({auth:c,url:u}),restartingInstance:b}):(0,A.jsx)(ct,{refreshCustomFunctions:t,loading:n})};const mt=function(){return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("div",{className:"floating-card-header text-end",children:"\xa0"}),(0,A.jsx)(c.A,{className:"my-3",children:(0,A.jsx)(u.A,{children:(0,A.jsxs)("div",{className:"empty-prompt narrow",children:[(0,A.jsx)("i",{className:"fa fa-bullhorn fa-3x text-success"}),(0,A.jsx)("div",{className:"mt-3 text-bold",children:"Coming Soon: Custom Functions!"}),(0,A.jsx)("div",{className:"mt-3",children:(0,A.jsxs)("ul",{children:[(0,A.jsx)("li",{children:"Add your own API endpoints to a standalone API server inside Harper"}),(0,A.jsx)("li",{children:"Use Harper Core methods to interact with your data at lightning speed"}),(0,A.jsx)("li",{children:"Custom Functions are powered by Fastify, so they're extremely flexible"}),(0,A.jsx)("li",{children:"Manage in Harper Studio, or use your own IDE and Version Management System"}),(0,A.jsx)("li",{children:"Distribute your Custom Functions to all your Harper instances with a single click"})]})})]})})})]})};var ht=n(4979),ft=n(2914);const gt=function(){const e=(0,s.O$)(l.A,(e=>e.auth)),t=(0,s.O$)(l.A,(e=>e.url)),n=(0,s.O$)(l.A,(e=>e.custom_functions)),o=(0,s.O$)(l.A,(e=>e.registration)),i=(0,ft.A)({version:null===o||void 0===o?void 0:o.version}),c=(0,s.O$)(l.A,(e=>e.restarting)),[u,d]=(0,a.useState)(!1),[p,m]=(0,a.useState)(!0),[h,f]=(0,a.useState)(!1),g=(0,a.useCallback)((async()=>{e&&t&&!c&&(m(!0),await N({auth:e,url:t}),m(!1))}),[e,t,c]);return(0,a.useEffect)((()=>{g()}),[g]),(0,a.useEffect)((()=>{const e=(null===n||void 0===n?void 0:n.is_enabled)&&(null===n||void 0===n?void 0:n.port)||i;d(e),e&&f(!1)}),[n,i]),(0,r.A)((()=>{h&&g()}),2e3),n?n.error?(0,A.jsx)(mt,{}):h?(0,A.jsx)(F.A,{description:"Configuring Custom Functions",icon:(0,A.jsx)("i",{className:"fa fa-spinner fa-spin"})}):u?(0,A.jsx)(pt,{refreshCustomFunctions:g,loading:p}):(0,A.jsx)($,{setConfiguring:f}):(0,A.jsx)(ht.A,{header:"loading custom functions",spinner:!0})}},7666:(e,t,n)=>{n.d(t,{A:()=>c});var a=n(9950),s=n(7176),r=n(6114),l=n(3452),o=n(7348),i=n(4414);const c=function(e){let{text:t,beforeText:n,afterText:c,obscure:u=!1}=e;const d=(0,o.MW)(),p=navigator.clipboard,m=(0,a.useCallback)((async e=>{e.stopPropagation(),await navigator.clipboard.writeText(t),d.success("Text copied to clipboard")}),[d,t]);return(0,i.jsxs)(s.A,{className:"copyable-text-holder g-0",children:[p&&t&&(0,i.jsx)(r.A,{className:"copy-icon",children:(0,i.jsx)(l.A,{title:"Copy this value",onClick:m,color:"link",children:(0,i.jsx)("i",{className:"fa fa-copy text-small"})})}),(0,i.jsx)(r.A,{className:"text-container",children:t?(0,i.jsxs)(i.Fragment,{children:[n,u?t.replace(/./g,"*"):t,c]}):(0,i.jsx)("span",{children:"\xa0"})})]})}},4343:(e,t,n)=>{n.d(t,{A:()=>b});var a=n(9950),s=n(2043),r=n(5488),l=n(9435),o=n(7176),i=n(6114),c=n(4414);const u=e=>{let{headerGroups:t,onSortedChange:n,sorted:a,showFilter:s,dynamicAttributesFromDataTable:r,tableDescriptionAttributes:l}=e;const u=e=>{let t=!1;return l.forEach((n=>{n.attribute===e&&(n.is_primary_key||n.indexed)&&(t=!0)})),t};return t.map((e=>{const{key:t,...l}=e.getHeaderGroupProps();return(0,c.jsxs)("div",{...l,children:[(0,c.jsx)(o.A,{className:"header g-0",children:e.headers.map((e=>{var t,s;return(0,c.jsx)(i.A,{onClick:()=>{var t,s;r&&!r.includes(e.id)&&u(e.id)&&n([{id:e.id,desc:(null===(t=a[0])||void 0===t?void 0:t.id)===e.id&&!(null!==(s=a[0])&&void 0!==s&&s.desc)}])},className:`${(null===(t=a[0])||void 0===t?void 0:t.id)===e.id?"sorted":""} ${null!==(s=a[0])&&void 0!==s&&s.desc?"desc":"asc"} ${-1!==e.id.indexOf("hdb-narrow")?"action":""} px-1 ${r&&!r.includes(e.id)&&u(e.id)?"":"disabled-column"}`,children:(0,c.jsx)("div",{className:"text-renderer",children:e.render("Header")})},e.id)}))}),s&&(0,c.jsx)(o.A,{className:"filter g-0",children:e.headers.map((e=>(0,c.jsx)(i.A,{className:-1!==e.id.indexOf("hdb-narrow")?"action":"",children:e.render("Filter")},e.id)))})]},t)}))};var d=n(3452);const p=function(e){let{page:t,pageSize:n,totalPages:a,onPageChange:s,onPageSizeChange:l,loading:u}=e;return(0,c.jsxs)(o.A,{className:"pagination",children:[(0,c.jsx)(i.A,{xs:"12",sm:"2",className:"previous",children:(0,c.jsx)(d.A,{className:"mb-2 btn-pagination",color:"purple",block:!0,onClick:()=>s(t-1),disabled:!a||0===t,children:(0,c.jsx)("i",{className:"fa fa-chevron-left"})})}),(0,c.jsxs)(i.A,{xs:"12",sm:"4",className:"paginator",children:[(0,c.jsx)("i",{className:"fa fa-book me-2"}),(0,c.jsx)(r.A,{className:"mb-2",type:"number",value:t+1,min:1,max:a,onChange:e=>s(e.target.value-1)}),(0,c.jsxs)("div",{className:"page-count",children:["\xa0/\xa0",u?(0,c.jsx)("i",{className:"fa fa-spinner fa-spin"}):a]})]}),(0,c.jsx)(i.A,{xs:"12",sm:"4",className:"page-size",children:(0,c.jsx)(r.A,{className:"mb-2",type:"select",value:n,onChange:e=>l(e.target.value),children:[20,50,100,250].map((e=>(0,c.jsxs)("option",{value:e,children:[e," rows"]},e)))})}),(0,c.jsx)(i.A,{xs:"12",sm:"2",className:"next",children:(0,c.jsx)(d.A,{className:"mb-2 pull-right btn-pagination",block:!0,color:"purple",onClick:()=>s(t+1),disabled:!a||t+1===a,children:(0,c.jsx)("i",{className:"fa fa-chevron-right"})})})]})};const m=function(e){let{previousPage:t,canPreviousPage:n,pageIndex:a,gotoPage:s,setPageSize:l,pageCount:u,nextPage:p,canNextPage:m,loading:h}=e;return(0,c.jsxs)(o.A,{className:"pagination",children:[(0,c.jsx)(i.A,{xs:"12",sm:"2",className:"previous",children:(0,c.jsx)(d.A,{className:"mb-2 btn-pagination",color:"purple",block:!0,onClick:t,disabled:!u||!n,children:(0,c.jsx)("i",{className:"fa fa-chevron-left"})})}),(0,c.jsxs)(i.A,{xs:"12",sm:"4",className:"paginator",children:[(0,c.jsx)("i",{className:"fa fa-book me-2"}),(0,c.jsx)(r.A,{className:"mb-2",type:"number",value:a+1||1,min:1,max:u,onChange:e=>s(e.target.value?Number(e.target.value)-1:0)}),(0,c.jsxs)("div",{className:"page-count",children:["\xa0/\xa0",h?(0,c.jsx)("i",{className:"fa fa-spinner fa-spin"}):u]})]}),(0,c.jsx)(i.A,{xs:"12",sm:"4",className:"page-size",children:(0,c.jsx)(r.A,{className:"mb-2",type:"select",onChange:e=>{s(0),setTimeout((()=>l(e.target.value)),1e3)},children:[20,50,100,250].map((e=>(0,c.jsxs)("option",{value:e,children:[e," rows"]},e)))})}),(0,c.jsx)(i.A,{xs:"12",sm:"2",className:"next",children:(0,c.jsx)(d.A,{className:"mb-2 pull-right btn-pagination",block:!0,color:"purple",onClick:p,disabled:!u||!m,children:(0,c.jsx)("i",{className:"fa fa-chevron-right"})})})]})};const h=function(e){let{prepareRow:t,row:n,onRowClick:a=!1}=e;return t(n),(0,c.jsx)(o.A,{onClick:()=>a&&a(n.original),className:"g-0",children:n.cells.map((e=>(0,c.jsx)(i.A,{className:-1!==e.column.id.indexOf("hdb-narrow")?"action":"",children:e.render("Cell")},`${e.row.id}-${e.column.id}`)))})};var f=n(3628),g=n(3150);function x(e){let{value:t}=e;return(0,c.jsx)("div",{className:"text-renderer",children:t})}function j(e){let{src:t}=e;const[n,s]=(0,a.useState)(!1),[r,l]=(0,a.useState)(!1);return(0,c.jsxs)("div",{className:"image-renderer",onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:[(0,c.jsx)("i",{className:"fa fa-image"}),n&&r?(0,c.jsxs)("div",{className:"preview-image no-image",children:[(0,c.jsx)("i",{className:"fa fa-ban text-danger"}),(0,c.jsx)("div",{className:"mt-2",children:"image failed to load"})]}):n?(0,c.jsx)("img",{onError:l,alt:t,src:t,className:"preview-image"}):null]})}const v={Filter:e=>{let{column:{filterValue:t,setFilter:n}}=e;return(0,c.jsx)(r.A,{type:"text",value:t||"",onChange:e=>n(e.target.value||void 0)})},Cell:e=>{let{value:t}=e;return(e=>{switch(Object.prototype.toString.call(e)){case"[object Array]":case"[object Object]":return(0,c.jsx)(x,{value:JSON.stringify(e)});case"[object Boolean]":return(0,c.jsx)(x,{value:e?"true":"false"});case"[object String]":return(t=e)&&(t.match(/^https?.*\.(jpeg|jpg|gif|png)$/)||-1!==t.indexOf("data:image"))?(0,c.jsx)(j,{src:e}):(0,c.jsx)(x,{value:e});default:return(0,c.jsx)(x,{value:e})}var t})(t)}};const b=function(e){let{columns:t,data:n,error:r,currentPage:o,pageSize:i,totalPages:d,onFilteredChange:x,onSortedChange:j,onPageChange:b,onPageSizeChange:y,showFilter:N,onRowClick:A,sorted:k,loading:C,dynamicAttributesFromDataTable:w,tableDescriptionAttributes:_,manual:S=!1}=e;const{headerGroups:F,page:O,rows:P,prepareRow:$,state:E,setAllFilters:D,canPreviousPage:I,canNextPage:T,pageOptions:R,pageCount:z,gotoPage:U,nextPage:L,previousPage:W,setPageSize:M}=(0,s.useTable)({columns:t,data:n,defaultColumn:v,onFilteredChange:x,onSortedChange:j,onPageChange:b,onPageSizeChange:y,onRowClick:A,manualPagination:S,manualFilters:S,initialState:{pageIndex:o,pageSize:i}},s.useFilters,s.usePagination),[q,H]=(0,a.useState)(!0),G=S||!O.length?P:O;return(0,a.useEffect)((()=>{!N&&E.filters.length?D([]):x(E.filters)}),[E.filters,N]),(0,a.useEffect)((()=>{setTimeout((()=>H(!1)),100)}),[null===G||void 0===G?void 0:G.length]),(0,c.jsxs)(l.tH,{onError:(e,t)=>(0,f.A)({error:{message:e.message,componentStack:t}}),FallbackComponent:g.A,children:[(0,c.jsxs)("div",{className:"react-table-scroller",children:[(0,c.jsx)(u,{headerGroups:F,tableDescriptionAttributes:_,dynamicAttributesFromDataTable:w,onSortedChange:j,sorted:k,showFilter:N}),C||q?(0,c.jsx)("div",{className:"centered text-center",children:(0,c.jsx)("i",{className:"fa fa-spinner fa-spin"})}):G.length?G.map((e=>(0,c.jsx)(h,{row:e,prepareRow:$,onRowClick:A},e.id))):(0,c.jsxs)("div",{className:"centered text-center",children:[(0,c.jsx)("i",{className:"fa fa-exclamation-triangle text-danger"}),(0,c.jsx)("div",{className:"mt-2 text-darkgrey",children:r?`Error loading data: ${r}`:"no records"})]})]}),S?(0,c.jsx)(p,{page:o,pageSize:i,totalPages:d,onPageChange:b,onPageSizeChange:y,loading:C}):(0,c.jsx)(m,{previousPage:W,pageSize:i,canPreviousPage:I,pageIndex:E.pageIndex,pageOptions:R,gotoPage:U,setPageSize:M,pageCount:z,nextPage:L,canNextPage:T,loading:C})]})}},8750:(e,t,n)=>{n.d(t,{A:()=>s});var a=n(127);const s=async e=>{let{auth:t,url:n}=e;return(0,a.A)({operation:{operation:"get_configuration"},auth:t,url:n})}},2415:(e,t,n)=>{n.d(t,{A:()=>r});var a=n(127),s=n(5269);const r=async e=>{let{auth:t,url:n}=e;const r=await(0,a.A)({operation:{operation:"list_roles"},auth:t,url:n}),l=[...Array.isArray(r)?r:[]].sort(((e,t)=>e.role.toLowerCase()>t.role.toLowerCase()?1:-1));return s.A.update((e=>{e.roles=l})),l}},8222:(e,t,n)=>{n.d(t,{A:()=>r});var a=n(127),s=n(5269);const r=async e=>{let{auth:t,url:n,signal:r}=e;const l=await(0,a.A)({operation:{operation:"list_users"},auth:t,url:n,signal:r}),o=Array.isArray(l)?[...l].map((e=>({username:e.username,role:e.role.role}))).sort(((e,t)=>e.username.toLowerCase()>t.username.toLowerCase()?1:-1)):[];return s.A.update((e=>{e.users=o})),o}},2010:(e,t,n)=>{n.d(t,{A:()=>r});var a=n(127),s=n(5269);const r=async e=>{let{auth:t,url:n}=e;return s.A.update((e=>{e.restarting=!0})),(0,a.A)({operation:{operation:"restart"},auth:t,url:n})}},1534:(e,t,n)=>{n.d(t,{A:()=>r});var a=n(127),s=n(5269);const r=async e=>{let{auth:t,url:n,service:r=null}=e;return r?(s.A.update((e=>{e.restarting_service=r})),(0,a.A)({operation:{operation:"restart_service",service:r},auth:t,url:n})):{error:!0,message:"You must specify a service"}}},4834:(e,t,n)=>{n.d(t,{A:()=>s});var a=n(127);const s=async e=>{let{auth:t,url:n,...s}=e;return(0,a.A)({operation:{operation:"set_configuration",...s},auth:t,url:n})}},6177:(e,t,n)=>{n.d(t,{A:()=>i});var a=n(8750),s=n(2415),r=n(8222),l=n(717),o=n(127);const i=async e=>{var t,n,i,c,u,d,p;let{auth:m,url:h}=e;const f=await(0,a.A)({auth:m,url:h}),g=await(0,l.A)({auth:m,url:h}),x=await(async e=>{let{auth:t,url:n}=e;return(0,o.A)({operation:{operation:"cluster_status"},auth:t,url:n})})({auth:m,url:h}),j=parseFloat(null===g||void 0===g?void 0:g.version)>=4?"nats":"socketcluster",v=await(0,s.A)({auth:m,url:h});let b=!1;v.error||(b=v.find((e=>e.permission.cluster_user)));const y=await(0,r.A)({auth:m,url:h});let N=!1;y.error||(N=b&&y.find((e=>e.role===b.role)));const A="nats"===j?null===(t=f.clustering)||void 0===t?void 0:t.enabled:f.CLUSTERING,k="nats"===j?null===(n=f.clustering)||void 0===n?void 0:n.user:f.CLUSTERING_USER,C="nats"===j?null===(i=f.clustering)||void 0===i||null===(c=i.hubServer)||void 0===c||null===(u=c.cluster)||void 0===u||null===(d=u.network)||void 0===d?void 0:d.port:f.CLUSTERING_PORT,w="nats"===j?null===(p=f.clustering)||void 0===p?void 0:p.nodeName:f.NODE_NAME;return{is_ready:!!A&&!!N&&!!k&&!!b&&!!C&&!!w,cluster_role:b,cluster_user:N,is_enabled:A,config_cluster_user:k,config_cluster_port:C,node_name:w,engine:j,status:null===x||void 0===x?void 0:x.status,message:null===x||void 0===x?void 0:x.message,connections:null===x||void 0===x?void 0:x.connections}}},9561:(e,t,n)=>{n.d(t,{A:()=>a});const a=e=>e.match(/^[-a-zA-Z0-9_]+$/)},5488:(e,t,n)=>{n.d(t,{A:()=>b});var a=n(9950),s=n(1942),r=n.n(s),l=n(8738),o=n.n(l),i=n(1497);function c(e){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c(e)}var u=["className","cssModule","type","bsSize","valid","invalid","tag","addon","plaintext","innerRef"];function d(){return d=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},d.apply(this,arguments)}function p(e,t){if(null==e)return{};var n,a,s=function(e,t){if(null==e)return{};var n,a,s={},r=Object.keys(e);for(a=0;a<r.length;a++)n=r[a],t.indexOf(n)>=0||(s[n]=e[n]);return s}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a<r.length;a++)n=r[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function m(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function f(e){var t=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,a=x(e);if(t){var s=x(this).constructor;n=Reflect.construct(a,arguments,s)}else n=a.apply(this,arguments);return function(e,t){if(t&&("object"===c(t)||"function"===typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return g(e)}(this,n)}}function g(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function x(e){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},x(e)}var j={children:r().node,type:r().string,size:r().oneOfType([r().number,r().string]),bsSize:r().string,valid:r().bool,invalid:r().bool,tag:i.Wx,innerRef:r().oneOfType([r().object,r().func,r().string]),plaintext:r().bool,addon:r().bool,className:r().string,cssModule:r().object},v=function(e){!function(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}(l,e);var t,n,s,r=f(l);function l(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),(t=r.call(this,e)).getRef=t.getRef.bind(g(t)),t.focus=t.focus.bind(g(t)),t}return t=l,(n=[{key:"getRef",value:function(e){this.props.innerRef&&this.props.innerRef(e),this.ref=e}},{key:"focus",value:function(){this.ref&&this.ref.focus()}},{key:"render",value:function(){var e=this.props,t=e.className,n=e.cssModule,s=e.type,r=void 0===s?"text":s,l=e.bsSize,c=e.valid,m=e.invalid,h=e.tag,f=e.addon,g=e.plaintext,x=e.innerRef,j=p(e,u),v=["switch","radio","checkbox"].indexOf(r)>-1,b="select"===r,y="range"===r,N=h||(b||"textarea"===r?r:"input"),A="form-control";g?(A="".concat(A,"-plaintext"),N=h||"input"):y?A="form-range":b?A="form-select":v&&(A=f?null:"form-check-input"),j.size&&/\D/g.test(j.size)&&((0,i.mc)('Please use the prop "bsSize" instead of the "size" to bootstrap\'s input sizing.'),l=j.size,delete j.size);var k=(0,i.qO)(o()(t,m&&"is-invalid",c&&"is-valid",!!l&&(b?"form-select-".concat(l):"form-control-".concat(l)),A),n);return("input"===N||h&&"function"===typeof h)&&(j.type="switch"===r?"checkbox":r),j.children&&!g&&"select"!==r&&"string"===typeof N&&"select"!==N&&((0,i.mc)('Input with a type of "'.concat(r,'" cannot have children. Please use "value"/"defaultValue" instead.')),delete j.children),a.createElement(N,d({},j,{ref:x,className:k,"aria-invalid":m}))}}])&&m(t.prototype,n),s&&m(t,s),Object.defineProperty(t,"prototype",{writable:!1}),l}(a.Component);v.propTypes=j;const b=v}}]);
1
+ "use strict";(self.webpackChunkharperdb_studio=self.webpackChunkharperdb_studio||[]).push([[302],{4298:(e,t,n)=>{n.r(t),n.d(t,{default:()=>gt});var a=n(9950),s=n(6713),r=n(135),l=n(5269),o=n(7176),i=n(6114),c=n(4084),u=n(8156),d=n(5201),p=n(9435),m=n(5488),h=n(3452),f=n(9163),g=n.n(f);var x=n(127);const j=async e=>{let{auth:t,url:n}=e;return(0,x.A)({operation:{operation:"custom_functions_status"},auth:t,url:n,timeout:5e3})},v=async e=>{let{auth:t,url:n}=e;return(0,x.A)({operation:{operation:"get_custom_functions"},auth:t,url:n})};function b(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(e&&e.entries){var s,r,l;if(t===n)e.path=n,e.key=null!==(s=null===(r=(l=crypto).randomUUID)||void 0===r?void 0:r.call(l))&&void 0!==s?s:Math.random().toString().slice(2);for(const s of e.entries){var o,i,c;const e=`${t}/${s.name}`,[,r]=e.split("/");s.project=r,s.path=e,s.key=null!==(o=null===(i=(c=crypto).randomUUID)||void 0===i?void 0:i.call(c))&&void 0!==o?o:Math.random().toString().slice(2),s.readOnly=a||!!s.package,b(s,e,n,s.readOnly)}}}const y=async e=>{let{auth:t,url:n}=e;const a=await(0,x.A)({operation:{operation:"get_components"},auth:t,url:n});return b(a,a.name,a.name,!1),a},N=async e=>{let{auth:t,url:n}=e;const{is_enabled:a,port:s,directory:r,error:o,message:i}=await j({auth:t,url:n}),c=await y({auth:t,url:n}),u={is_enabled:a,port:s,endpoints:a?await v({auth:t,url:n}):{},directory:r,error:o,message:i,fileTree:c};return l.A.update((e=>{e.custom_functions=u})),{custom_functions:u}};var A=n(4414);const k=function(){const e=(0,s.O$)(l.A,(e=>e.auth)),t=(0,s.O$)(l.A,(e=>e.url)),n=(0,s.O$)(l.A,(e=>e.is_local)),r=(0,s.O$)(l.A,(e=>{var t;return null===(t=e.custom_functions)||void 0===t?void 0:t.port})),[d,p]=(0,a.useState)({}),[f,j]=(0,a.useState)({port:r||9926});return g()((async()=>{const{submitted:n}=d;if(n){const{port:n}=f;if(n)if(a=n,Number.isNaN(parseFloat(a))||!Number.isFinite(parseFloat(a)))p({error:"port must be a valid number"});else{const a=await(async e=>{let{auth:t,url:n,port:a}=e;return(0,x.A)({operation:{operation:"configure_cluster",CUSTOM_FUNCTIONS_PORT:parseInt(a,10)},auth:t,url:n})})({auth:e,url:t,port:n});a.error?p({error:a.message}):N({auth:e,url:t})}else p({error:"All fields are required"})}var a}),[d]),g()((()=>{d.submitted||p({})}),[f]),n&&!r?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("div",{className:"text-nowrap mb-3",children:"Custom Functions Port"}),(0,A.jsx)(m.A,{id:"custom_api_port",onChange:e=>j({...f,port:e.target.value}),className:"mb-3 "+(d.error&&!f.port?"error":""),type:"number",title:"custom api port",placeholder:"9926",value:f.port}),(0,A.jsx)(h.A,{color:"success",block:!0,onClick:()=>p({submitted:!0}),children:"Set Custom API Port"}),!!d.error&&(0,A.jsx)(c.A,{className:"mt-3 error",children:(0,A.jsx)(u.A,{children:d.error})})]}):(0,A.jsxs)(o.A,{children:[(0,A.jsxs)(i.A,{xs:"10",children:["Custom Functions Port ",n?r:"Set"]}),(0,A.jsx)(i.A,{xs:"2",className:"text-end",children:(0,A.jsx)("i",{className:"fa fa-check-circle fa-lg text-success"})})]})};var C=n(4834),w=n(2010),_=n(6177);const S=function(e){let{setConfiguring:t}=e;const{compute_stack_id:n}=(0,d.g)(),r=(0,s.O$)(l.A,(e=>e.auth),[n]),o=(0,s.O$)(l.A,(e=>e.url),[n]),i=(0,s.O$)(l.A,(e=>{var t;return parseFloat(null===(t=e.registration)||void 0===t?void 0:t.version)>=4?"nats":"socketcluster"}),[n]),[c,u]=(0,a.useState)({});return g()((async()=>{if(c.submitted){if("nats"===i)await(0,C.A)({auth:r,url:o,customFunctions_enabled:!0});else{const e=await(0,_.A)({auth:r,url:o});await(0,C.A)({auth:r,url:o,operation:"configure_cluster",CUSTOM_FUNCTIONS:!0,CLUSTERING:Boolean(null===e||void 0===e?void 0:e.config_cluster_user),CLUSTERING_PORT:null===e||void 0===e?void 0:e.config_cluster_port,CLUSTERING_USER:null===e||void 0===e?void 0:e.config_cluster_user,NODE_NAME:null===e||void 0===e?void 0:e.nodeName})}window._kmq&&window._kmq.push(["record","enabled custom functions"]),(0,w.A)({auth:r,url:o}),setTimeout((()=>t(!0)),0)}}),[c.submitted]),(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("hr",{className:"my-3"}),(0,A.jsx)(h.A,{color:"success",disabled:c.submitted,block:!0,onClick:()=>u({submitted:!0}),children:c.submitted?(0,A.jsx)("i",{className:"fa fa-spinner fa-spin text-white"}):"Enable Custom Functions"})]})};var F=n(6165),O=n(3150),P=n(3628);const $=function(e){let{setConfiguring:t}=e;const{compute_stack_id:n}=(0,d.g)(),a=(0,s.O$)(l.A,(e=>{var t;return null===(t=e.custom_functions)||void 0===t?void 0:t.port}),[n]);return(0,A.jsxs)(o.A,{id:"functions",children:[(0,A.jsxs)(i.A,{xl:"3",lg:"4",md:"5",xs:"12",children:[(0,A.jsx)("span",{className:"floating-card-header",children:"enable custom functions"}),(0,A.jsx)(c.A,{className:"my-3",children:(0,A.jsx)(u.A,{children:(0,A.jsxs)(p.tH,{onError:(e,t)=>(0,P.A)({error:{message:e.message,componentStack:t}}),FallbackComponent:O.A,children:[(0,A.jsx)(k,{}),!!a&&(0,A.jsx)(S,{setConfiguring:t})]})})})]}),(0,A.jsx)(i.A,{xl:"9",lg:"8",md:"7",xs:"12",children:a?(0,A.jsx)(F.A,{headline:"Enable Custom Functions",description:"Click the button at left to enable Custom Functions. NOTE: We'll restart the instance when you click this button.",icon:(0,A.jsx)("i",{className:"fa fa-thumbs-up text-success"})}):(0,A.jsx)(F.A,{headline:"Set Your Custom Functions Server Port",description:"If your instance is behind a firewall, you'll need to ensure this port is accessible by other instances if you want to access the API.",icon:(0,A.jsx)("i",{className:"fa fa-thumbs-up text-success"})})})]})};var E=n(7348),D=n(5553);const I=async e=>{let{auth:t,url:n,project:a,file:s}=e;return(0,x.A)({operation:{operation:"get_component_file",project:a,file:s},auth:t,url:n})},T=async e=>{let{auth:t,url:n,project:a,file:s,payload:r}=e;return(0,x.A)({operation:{operation:"set_component_file",project:a,file:s,payload:r},auth:t,url:n})},R=async e=>{let{auth:t,url:n,project:a,file:s}=e;return(0,x.A)({operation:{operation:"drop_component",project:a,file:s},auth:t,url:n})},z=async e=>{let{auth:t,url:n,project:a,packageUrl:s,payload:r}=e;return r?(0,x.A)({auth:t,url:n,operation:{operation:"deploy_component",project:a,payload:r}}):(0,x.A)({auth:t,url:n,operation:{operation:"deploy_component",project:a,package:s}})};var U=n(1534),L=n(4319);const W=(0,n(6997).A)("editorCache");var M=n(8738),q=n.n(M);function H(){return(0,A.jsx)(c.A,{className:"file-browser-scroll-container",children:(0,A.jsx)(u.A,{children:(0,A.jsxs)("div",{className:"p-4",children:["You have no Harper applications yet. ",(0,A.jsx)("br",{}),(0,A.jsx)("br",{}),'Click "',(0,A.jsx)("i",{className:"fas fa-plus"}),' app" above to create one!',(0,A.jsx)("br",{}),(0,A.jsx)("br",{}),"See the"," ",(0,A.jsx)("a",{className:"docs-link",href:"https://docs.harperdb.io",target:"_blank",rel:"noreferrer",children:"documentation"})," ","for more info on Harper Applications."]})})})}function G(e,t){const n=+Boolean(e.entries),a=+Boolean(t.entries);return n===a?e.name.localeCompare(t.name):a-n}function B(){return(0,A.jsx)("i",{className:q()("package-icon fas fa-cube")})}function V(e){let{name:t,url:n,onPackageSelect:s,selectedPackage:r}=e;const[l,o]=(0,a.useState)(Boolean(r)&&t===(null===r||void 0===r?void 0:r.name));return(0,a.useEffect)((()=>{o(r&&r.name===t)}),[r,t]),(0,A.jsxs)("button",{type:"button",onClick:e=>{s(l?null:{name:t,url:n,event:e}),o(!l)},className:q()("package",{"package-selected":l}),onKeyDown:()=>{},children:[(0,A.jsx)(B,{}),(0,A.jsx)("span",{className:"package-text",children:t})]})}function K(e){let{directoryEntry:t,selectedFile:n,selectedFolder:a,onFileSelect:s,onFolderSelect:r,Icon:l}=e;const o=Boolean(t.entries);const i=t.path===n,c=t.path===(null===a||void 0===a?void 0:a.path);return(0,A.jsxs)("button",{type:"button",onClick:function(e){const n=e.target.classList.contains("rename-file")||e.target.classList.contains("deploy-project");o?c&&n||r(c?null:t):s(i?null:t)},className:q()("file",{"file-selected":i,"folder-selected":c}),onKeyDown:function(){},children:[(0,A.jsx)(l,{className:"filename-icon"}),(0,A.jsx)("span",{className:"filename-text",children:t.name})]})}function Z(e){let{directoryEntry:t,userOnSelect:n,onFolderSelect:s,onDeployProject:r,onFileSelect:l,onPackageSelect:o,onFileRename:i,selectedFile:c,selectedFolder:u,selectedPackage:d}=e;const[p,m]=(0,a.useState)(!0),h=[...t.entries||[]].sort(G),f=(g=t.name)&&[...g].includes(".")?g.split(".").slice(-1)[0]:null;var g;let x;return x=2===t.path.split("/").length?()=>function(e){let{toggleClosed:t,isOpen:n}=e;return(0,A.jsx)("i",{onClick:t,onKeyDown:t,className:q()("project-icon fas fa-file-code"),tabIndex:0,"aria-expanded":n,"aria-controls":"folder","aria-label":n?"close project":"open project",role:"button"})}({isOpen:p,toggleClosed:()=>m(!p)}):t.entries?()=>function(e){let{toggleClosed:t,isOpen:n}=e;return(0,A.jsx)("i",{onClick:t,onKeyDown:t,className:q()("folder-icon fas "+(n?"fa-folder-open":"fa-folder")),tabIndex:0,"aria-expanded":n,"aria-controls":"folder","aria-label":n?"close folder":"open folder",role:"button"})}({isOpen:p,toggleClosed:()=>m(!p)}):()=>function(e){let{extension:t}=e;switch(t){case"js":return(0,A.jsx)("i",{className:q()("file-icon filetype-js fab fa-js")});case"yaml":return(0,A.jsx)("i",{className:q()("file-icon filetype-yaml fas fa-cog")});default:return(0,A.jsx)("i",{className:q()("file-icon filetype-unknown far fa-file-alt")})}}({extension:f}),(0,A.jsxs)(A.Fragment,{children:["components"!==t.name?(0,A.jsx)("li",{className:q()(`${t.entries?"folder-container":"file-container"} ${p?"folder-open":"folder-closed"}`),children:t.package?(0,A.jsx)(V,{selectedPackage:d,onPackageSelect:o,name:t.name,url:t.package}):(0,A.jsx)(K,{Icon:x,selectedFile:c,selectedFolder:u,selectedPackage:d,directoryEntry:t,onDeployProject:r,onFileRename:()=>{i(t)},onFileSelect:l,onFolderSelect:s,userOnSelect:n})},t.key):null,h.map((e=>(0,A.jsx)("li",{children:(0,A.jsx)("ul",{className:q()("folder",{"folder-contents-open":!0,"folder-contents-closed":!1}),children:(0,A.jsx)(Z,{selectedFile:c,selectedFolder:u,selectedPackage:d,directoryEntry:e,onFileSelect:l,onDeployProject:r,onFileRename:i,onFolderSelect:s,onPackageSelect:o,userOnSelect:n})})},e.key)))]})}const Y=function(e){var t;let{files:n,userOnSelect:a,onFileSelect:s,onPackageSelect:r,onDeployProject:l,onFileRename:o,onFolderSelect:i,selectedFile:d,selectedFolder:p,selectedPackage:m}=e;return null!==n&&void 0!==n&&null!==(t=n.entries)&&void 0!==t&&t.length?(0,A.jsx)(c.A,{className:"file-browser-scroll-container",children:(0,A.jsx)(u.A,{children:(0,A.jsx)("ul",{className:"file-browser",children:(0,A.jsx)(Z,{selectedFile:d,selectedFolder:p,selectedPackage:m,onFileSelect:s,onFileRename:o,onFolderSelect:i,onDeployProject:l,onPackageSelect:r,userOnSelect:a,directoryEntry:n})})})}):(0,A.jsx)(H,{})};var J=n(5023);J.wG.init().then((e=>{e.editor.defineTheme("hdb",{base:"vs-dark",inherit:!0,rules:[],colors:{"editor.background":"#111111"}})}));const Q={js:"javascript",yaml:"yaml",ts:"typescript",json:"json",md:"markdown",html:"html",css:"css",graphql:"graphql",mjs:"javascript"};const X=function(e){let{active:t,file:n,onFileChange:s}=e;const[r,l]=(0,a.useState)("javascript");return(0,a.useEffect)((()=>{const e=function(e){var t;const n=null===(t=e||"")||void 0===t?void 0:t.split(".");return n.length>1?n.slice(-1)[0]:""}(null===n||void 0===n?void 0:n.name);l(Q[e]||"plaintext")}),[n]),t?(0,A.jsx)(J.Ay,{height:"100%",language:r,value:(null===n||void 0===n?void 0:n.content)||"",theme:"hdb",onChange:s,options:{readOnly:null===n||void 0===n?void 0:n.readOnly,automaticLayout:!0,minimap:{enabled:!1}}}):null};function ee(e){let{onClick:t,disabled:n=!1,text:a="",extraClasses:s=""}=e;return(0,A.jsxs)("button",{type:"button",disabled:n,onClick:t,className:s,title:"Create a new app",children:[(0,A.jsx)("i",{className:"fas fa-plus"}),a&&(0,A.jsxs)("span",{className:"ms-1",children:[" ",a]})]})}function te(e){let{onClick:t,disabled:n=!1,text:a="",extraClasses:s=""}=e;return(0,A.jsxs)("button",{type:"button",disabled:n,onClick:t,className:s,title:"Add a folder",children:[(0,A.jsx)("i",{className:"fas fa-plus"}),a&&(0,A.jsx)("span",{className:"ms-1 d-none d-lg-inline-block",children:a})]})}function ne(e){let{onClick:t,disabled:n=!1,text:a="",extraClasses:s=""}=e;return(0,A.jsxs)("button",{type:"button",onClick:t,disabled:n,className:s,title:"Delete selected app or folder",children:[(0,A.jsx)("i",{className:"fas fa-minus"}),a&&(0,A.jsx)("span",{className:"ms-1 d-none d-lg-inline-block",children:a})]})}function ae(e){let{onClick:t,disabled:n,text:a="",extraClasses:s=""}=e;return(0,A.jsxs)("button",{type:"button",disabled:n,onClick:t,className:s,title:"Add a new file",children:[(0,A.jsx)("i",{className:"fas fa-plus"}),a&&(0,A.jsxs)("span",{className:"ms-1 d-none d-lg-inline-block",children:[" ",a]})]})}function se(e){let{onClick:t,disabled:n,text:a="",extraClasses:s=""}=e;return(0,A.jsxs)("button",{type:"button",onClick:t,disabled:n,className:s,title:"Delete selected file",children:[(0,A.jsx)("i",{className:"fas fa-minus"}),a&&(0,A.jsxs)("span",{className:"ms-1 d-none d-lg-inline-block",children:[" ",a]})]})}const re=function(e){let{children:t}=e;return(0,A.jsx)("ul",{className:"file-menu text-nowrap",children:t.map((e=>{var t,n,a;return e&&(0,A.jsx)("li",{className:"file-menu-item",children:e},null!==(t=null===(n=(a=crypto).randomUUID)||void 0===n?void 0:n.call(a))&&void 0!==t?t:Math.random().toString().slice(2))}))})};function le(e){let{onClick:t,disabled:n=!1,text:a="",extraClasses:s=""}=e;return(0,A.jsxs)("button",{type:"button",disabled:n,onClick:t,className:s,title:"Import external component or application",children:[(0,A.jsx)("i",{className:"fas fa-share-alt"}),a&&(0,A.jsx)("span",{className:"ms-2 d-none d-lg-inline-block",children:a})]})}function oe(e){let{onClick:t,savingFile:n,disabled:a=!1,text:s="",extraClasses:r=""}=e;return(0,A.jsxs)("button",{type:"button",onClick:t,disabled:a,className:r,title:"save file to instance",children:[(0,A.jsx)("i",{className:q()("fas",{"fa-save":!n,"fa-spinner":n,"fa-spin":n})}),s&&(0,A.jsx)("span",{className:"ms-2 d-none d-lg-inline-block",children:s})]})}function ie(e){let{onClick:t,restarting:n,disabled:a=!1,text:s="",extraClasses:r=""}=e;return(0,A.jsxs)("button",{type:"button",onClick:t,disabled:a,className:r,title:"Click to restart your instance",children:[(0,A.jsx)("i",{className:q()("fas",{"fa-sync":!n,"fa-spinner":n,"fa-spin":n})}),s&&(0,A.jsx)("span",{className:"ms-2 d-none d-lg-inline-block",children:s})]})}function ce(e){let{onClick:t,restartAfterSave:n,disabled:a=!1,text:s="",extraClasses:r=""}=e;return(0,A.jsxs)("button",{type:"button",onClick:t,disabled:a,className:r,title:"Toggle whether saving a file restarts the application",children:[(0,A.jsx)("i",{className:q()("fa",{"fa-toggle-on":n,"fa-toggle-off":!n})}),s&&(0,A.jsx)("span",{className:"ms-2 d-none d-lg-inline-block",children:s})]})}function ue(e){let{onClick:t,disabled:n=!1,text:a="",extraClasses:s="",loading:r}=e;return(0,A.jsxs)("button",{type:"button",disabled:n,onClick:t,className:s,title:"revert file",children:[(0,A.jsx)("i",{className:q()("revert-file fas",{disabled:n,"fa-history":!r,"fa-spinner":r,"fa-spin":r})}),a&&(0,A.jsx)("span",{className:"ms-2 d-none d-lg-inline-block",children:a})]})}function de(e){let{children:t}=e;return(0,A.jsx)("ul",{className:"editor-menu",children:t.map((e=>{var t,n,a;return e&&(0,A.jsx)("li",{className:"editor-menu-item",children:e},null!==(t=null===(n=(a=crypto).randomUUID)||void 0===n?void 0:n.call(a))&&void 0!==t?t:Math.random().toString().slice(2))}))})}function pe(e){let{active:t,AddProjectButtonClick:n,InstallPackageButtonClick:a}=e;return t?(0,A.jsxs)("div",{className:"content-window",children:[(0,A.jsx)("h4",{className:"mb-5",children:"Add A New Application"}),(0,A.jsx)(ee,{text:"Create A New Application Using The Default Template",extraClasses:"btn btn-block btn-success",onClick:n}),(0,A.jsx)(le,{text:"Import Or Deploy A Remote Application Package",extraClasses:"btn btn-block btn-outline-success mt-2",onClick:a})]}):null}function me(e){let{active:t,type:n}=e;return t?(0,A.jsxs)("div",{className:"content-window text-nowrap",children:[(0,A.jsx)("i",{className:"fa fa-exclamation-triangle mt-5 pt-5"}),"\xa0",(0,A.jsxs)("span",{children:["You have selected a ",n,". Nothing to see here!"]})]}):null}var he=n(6359);function fe(e){return/^[a-zA-Z0-9-_]+$/.test(e)}function ge(e){if(!e)return null;const t={type:null,user:null,repo:null,url:null,package:null,tag:null};if(e.url.match("://"))t.url=e.url,t.type="url";else if(e.url.match("semver:")){const[n,a,s]=e.url.split(/[/#]/);t.type="github",t.user=n,t.repo=a,t.tag=s.replace("semver:","")}else{t.type="npm";const n=e.url.split("/");if(1===n.length){const[e,a]=n[0].split("@");t.package=e,t.tag=a}else if(2===n.length){const[,e]=n,[a,s]=e.split("@");t.package=a,t.tag=s}}return t}function xe(e,t,n){var s=this,r=(0,a.useRef)(null),l=(0,a.useRef)(0),o=(0,a.useRef)(null),i=(0,a.useRef)([]),c=(0,a.useRef)(),u=(0,a.useRef)(),d=(0,a.useRef)(e),p=(0,a.useRef)(!0);d.current=e;var m="undefined"!=typeof window,h=!t&&0!==t&&m;if("function"!=typeof e)throw new TypeError("Expected a function");t=+t||0;var f=!!(n=n||{}).leading,g=!("trailing"in n)||!!n.trailing,x="maxWait"in n,j="debounceOnServer"in n&&!!n.debounceOnServer,v=x?Math.max(+n.maxWait||0,t):null;(0,a.useEffect)((function(){return p.current=!0,function(){p.current=!1}}),[]);var b=(0,a.useMemo)((function(){var e=function(e){var t=i.current,n=c.current;return i.current=c.current=null,l.current=e,u.current=d.current.apply(n,t)},n=function(e,t){h&&cancelAnimationFrame(o.current),o.current=h?requestAnimationFrame(e):setTimeout(e,t)},a=function(e){if(!p.current)return!1;var n=e-r.current;return!r.current||n>=t||n<0||x&&e-l.current>=v},b=function(t){return o.current=null,g&&i.current?e(t):(i.current=c.current=null,u.current)},y=function e(){var s=Date.now();if(a(s))return b(s);if(p.current){var o=t-(s-r.current),i=x?Math.min(o,v-(s-l.current)):o;n(e,i)}},N=function(){if(m||j){var d=Date.now(),h=a(d);if(i.current=[].slice.call(arguments),c.current=s,r.current=d,h){if(!o.current&&p.current)return l.current=r.current,n(y,t),f?e(r.current):u.current;if(x)return n(y,t),e(r.current)}return o.current||n(y,t),u.current}};return N.cancel=function(){o.current&&(h?cancelAnimationFrame(o.current):clearTimeout(o.current)),l.current=0,i.current=r.current=c.current=o.current=null},N.isPending=function(){return!!o.current},N.flush=function(){return o.current?b(Date.now()):u.current},N}),[f,x,t,v,g,h,m,j]);return b}function je(e,t){return e===t}function ve(e,t,n){var s=n&&n.equalityFn||je,r=(0,a.useRef)(e),l=(0,a.useState)({})[1],o=xe((0,a.useCallback)((function(e){r.current=e,l({})}),[l]),t,n),i=(0,a.useRef)(e);return s(i.current,e)||(o(e),i.current=e),[r.current,o]}function be(e){let{pkg:t,setPackageSpec:n}=e;const[s,r]=(0,a.useState)((null===t||void 0===t?void 0:t.user)||""),[l]=ve(s,300),[o,i]=(0,a.useState)((null===t||void 0===t?void 0:t.repo)||""),[c]=ve(o,300),[u,d]=(0,a.useState)([]),[p,h]=(0,a.useState)(!1),[f,g]=(0,a.useState)((null===t||void 0===t?void 0:t.tag)||""),[x,j]=(0,a.useState)(""),[,v]=(0,a.useState)(!1),[b,y]=(0,a.useState)(!1);return(0,a.useEffect)((()=>{r((null===t||void 0===t?void 0:t.user)||""),i((null===t||void 0===t?void 0:t.repo)||""),d(null!==t&&void 0!==t&&t.tag?[null===t||void 0===t?void 0:t.tag]:[]),g((null===t||void 0===t?void 0:t.tag)||"")}),[t]),(0,a.useEffect)((()=>{l&&c?(v(!0),async function(e,t){try{const n=await fetch(`https://api.github.com/repos/${e}/${t}`),a=await n.json();return n.status<400?a.name:null}catch(n){return null}}(s,c).then((e=>{e?(j(e),y(!0),async function(e,t){const n=await fetch(`https://api.github.com/repos/${e}/${t}/git/refs/tags`);if(n.status<400)return(await n.json()).map((e=>e.ref.split("/").slice(-1)[0]));return[]}(s,c).then((e=>{v(!1),h(!0),d(e)}))):(v(!1),y(!1),j(""),d([]))})).catch((()=>{v(!1)}))):(y(!1),v(!1),d([]),g(""))}),[l,c,s]),(0,a.useEffect)((()=>{if(s&&o&&x){n(f?`${s}/${o}#semver:${f}`:`${s}/${o}`)}else n("")}),[x,f,s,n,o]),(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(m.A,{title:"Github Organization",className:"mt-2 form-control",valid:l.length>0&&c.length>0&&b,placeholder:"Github Organization",onChange:e=>r(e.target.value),value:s}),(0,A.jsx)(m.A,{title:"Github Repo",className:"mt-2",placeholder:"Github Repo",onChange:e=>i(e.target.value),value:o}),(null===u||void 0===u?void 0:u.length)>0&&(0,A.jsx)(he.Ay,{className:"react-select-container github-tag-select mt-2",classNamePrefix:"react-select",isDisabled:!x,isSearchable:!0,placeholder:"Choose a tag",onChange:e=>g(e.value),options:u.map((e=>({label:e,value:e})))})]})}function ye(e){let{pkg:t,setPackageSpec:n}=e;const[s,r]=(0,a.useState)(""),[l]=ve(s,300),[o,i]=(0,a.useState)(""),[c,u]=(0,a.useState)(""),[d,p]=(0,a.useState)(""),[m,h]=(0,a.useState)(!1),[f,g]=(0,a.useState)(!1);return(0,a.useEffect)((()=>{r((null===t||void 0===t?void 0:t.package)||"")}),[t]),(0,a.useEffect)((function(){if(d){n(c?`${d}@${c}`:d)}else n("")}),[d,c,n]),(0,a.useEffect)((function(){l?(h(!0),async function(e){var t;const n=await fetch(`https://registry.npmjs.org/-/v1/search?text=${e}`),a=(await n.json()).objects.find((t=>t.package.name===e));return null===a||void 0===a||null===(t=a.package)||void 0===t?void 0:t.name}(l).then((e=>{h(!1),g(!!e),p(e),e&&async function(e){const t=await fetch(`https://registry.npmjs.org/${e}`);return(await t.json())["dist-tags"]}(e).then((e=>{i(e),u(null)})).catch((e=>{throw e}))})).catch((()=>{h(!1)}))):(p(null),i(null),u(null))}),[l]),(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)("div",{className:"input-group",children:[(0,A.jsx)("input",{className:"mt-2 form-control",title:"enter an npm package specifier",value:s,placeholder:"Enter the [@scope]/package",onChange:function(e){r(e.target.value)}}),(0,A.jsx)("div",{className:"input-group-append",children:(0,A.jsx)("i",{className:q()("input-group-text fa mt-2",{"fa-spinner fa-spin loading":m,"fa-check found":l.length>0&&f,"fa-times not-found":l.length>0&&!(m||f),"fa-check not-searching":0===l.length})})})]}),(0,A.jsx)(he.Ay,{className:"react-select-container mt-2",classNamePrefix:"react-select",isDisabled:!s,placeholder:"Choose a tag",disabled:!o,onChange:function(e){let{value:t}=e;u(t)},options:Object.entries(o||[]).map((e=>{let[t,n]=e;return{label:`${t} (${n})`,value:t}}))})]})}function Ne(e){return function(e){try{return Boolean(new URL(e))}catch(t){return!1}}(e)&&(-1!==e.indexOf(".tar")||-1!==e.indexOf(".tar.gz")||-1!==e.indexOf(".tgz"))}function Ae(e){let{pkg:t,setPackageSpec:n}=e;const[s,r]=(0,a.useState)((null===t||void 0===t?void 0:t.url)||""),[l,o]=(0,a.useState)(Ne(null===t||void 0===t?void 0:t.url));return(0,a.useEffect)((()=>{n(l?s:"")}),[s,l,n]),(0,A.jsx)(m.A,{type:"text",id:"tarball-url",title:"URL to gzipped tarball",className:q()("package-url-input mt-2",{invalid:!l}),value:s,onChange:e=>{o(0===e.target.value.length||Ne(e.target.value)),r(e.target.value)},placeholder:"URL to gzipped tarball"})}var ke=n(5996);function Ce(e){let{selectedPackage:t,onConfirm:n,onCancel:r,deployTargets:o,active:i}=e;const c=!1,[u,d]=(0,a.useState)(Boolean(t)),[p,f]=(0,a.useState)(ge(t)),[g,x]=(0,a.useState)((null===p||void 0===p?void 0:p.type)||c),[j,v]=(0,a.useState)((null===t||void 0===t?void 0:t.name)||""),[b,y]=(0,a.useState)(!0),[N,k]=(0,a.useState)(""),[C,w]=(0,a.useState)(!1),_=(0,s.O$)(l.A,(e=>e.auth)),S=(0,s.O$)(l.A,(e=>e.url)),[F,O]=(0,a.useState)([{isCurrentInstance:!0,auth:_,instance:{url:S,instance_name:"This Instance"}}]);function P(){v(""),y(!1),x(!1),O([]),r()}return(0,a.useEffect)((function(){const e=ge(t);v((null===t||void 0===t?void 0:t.name)||""),f(ge(t)),x((null===e||void 0===e?void 0:e.type)||c),d(Boolean(t))}),[t,c]),(0,a.useEffect)((function(){y(fe(j))}),[j]),i?(0,A.jsxs)("div",{className:"content-window",children:[(0,A.jsx)("h4",{className:"mb-5",children:"Import Remote App Package"}),(0,A.jsx)(m.A,{valid:b&&j.length>0,title:"enter a name for this package",value:j,placeholder:"Application Name",onChange:e=>{v(e.target.value),y(fe(e.target.value))}}),!ke.A.is_local_studio&&(0,A.jsx)(he.Ay,{className:"react-select-container package-install-deploy-targets-dropdown mt-2",classNamePrefix:"react-select",isSearchable:!0,isMulti:!0,placeholder:"Choose your deploy targets",onChange:e=>{const t=e.map((e=>e.value)),n=o.filter((e=>t.includes(e.instance.url)));O(n)},options:o.map((e=>({label:e.instance.instance_name,value:e.instance.url})))}),(0,A.jsx)(he.Ay,{className:"react-select-container mt-2",classNamePrefix:"react-select",placeholder:"How would you like to fetch this package?",onChange:function(e){let{value:t}=e;x(t)},options:[{label:"A Public GitHub Repo",value:"github"},{label:"Install a gzipped .tar file from a URL",value:"url"}]}),!b&&j.length>0&&(0,A.jsxs)("span",{className:"text-danger text-center mt-3",children:[(0,A.jsx)("i",{className:"fa fa-exclamation-triangle"}),(0,A.jsx)("br",{}),(0,A.jsx)("span",{className:"mt-2",children:"Project name limited to alphanumeric, dashes, & underscores."})]}),b&&F.length>0&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("div",{className:"mt-2"}),"npm"===g&&(0,A.jsx)(ye,{projectName:j,installed:u,pkg:p,setPackageSpec:k}),"github"===g&&(0,A.jsx)(be,{projectName:j,installed:u,pkg:p,setPackageSpec:k}),"url"===g&&(0,A.jsx)(Ae,{projectName:j,installed:u,pkg:p,setPackageSpec:k})]}),b&&F.length>0&&g?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(h.A,{onClick:async()=>{w(!0);try{await n(j,N,F)}catch(e){w(!1)}w(!1)},className:q()("btn btn-block btn-success mt-3",{loading:C}),disabled:!fe(j)||!N||!F.length,children:C?(0,A.jsx)("i",{className:"install-package-status-icon fa fa-spinner fa-spin"}):"Install Package"}),(0,A.jsx)(h.A,{onClick:P,className:"btn btn-block btn-outline-success mt-2",children:"Cancel"})]}):(0,A.jsx)(h.A,{onClick:P,className:"btn btn-block btn-outline-success mt-3",children:"Cancel"})]}):null}function we(e){let{className:t,onClick:n,disabled:s,children:r}=e;const[l,o]=(0,a.useState)(!1);return(0,A.jsx)("button",{disabled:s,type:"button",onClick:async()=>{o(!0);try{await n(),o(!1)}catch(e){o(!1)}},className:q()(`${t} button-with-loader`,{loading:l}),children:l?(0,A.jsx)("i",{className:"button-with-loader-icon fas fa-spinner fa-spin"}):r})}function _e(e){let{onCancel:t,onConfirm:n,onEnter:s,value:r,type:l,validate:o=()=>!0}=e;const[i,c]=(0,a.useState)(r||""),[u,d]=(0,a.useState)(!1);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("input",{className:q()("w-100 text-center",{invalid:i.length>0&&!u}),onChange:e=>{c(e.target.value),d(o(e.target.value))},onKeyDown:function(e){"Enter"===e.key?s(e.target.value):"Esc"===e.key&&t()},value:i,placeholder:`name for your new ${l}`,title:`name for your new ${l}`}),(0,A.jsx)("i",{title:"error: name must contain only alphanumeric characters, dashes and underscores.",className:q()("text-danger fa fa-warning",{hidden:u||0===i.length})}),(0,A.jsx)(we,{disabled:!u,className:"btn btn-success btn-block mt-3",onClick:()=>n(i),children:"OK"}),(0,A.jsx)("button",{type:"button",className:"btn btn-outline-success btn-block mt-2",onClick:t,children:"Cancel"}),i.length>0&&!u&&(0,A.jsx)("div",{className:"validation-message mt-5",children:"error: name must contain only alphanumeric characters, dashes and underscores."})]})}function Se(e){let{active:t,onConfirm:n,onCancel:a}=e;return t?(0,A.jsxs)("div",{className:"content-window",children:[(0,A.jsx)("h4",{className:"mb-5",children:"Default Template Application"}),(0,A.jsx)(_e,{type:"project",validate:fe,onEnter:n,onConfirm:n,onCancel:a})]}):null}function Fe(e){let{active:t,onConfirm:n,onCancel:a,selectedFolder:s}=e;return t?(0,A.jsxs)("div",{className:"content-window",children:[(0,A.jsxs)("h4",{className:"mb-5",children:["Add Folder To ",(0,A.jsx)("span",{className:"text-success",children:s.path.replace("components","")})]}),(0,A.jsx)(_e,{type:"folder",selectedFolder:s,onEnter:n,onConfirm:n,onCancel:a})]}):null}function Oe(e){let{active:t,onConfirm:n,onCancel:a}=e;return t?(0,A.jsxs)("div",{className:"content-window",children:[(0,A.jsx)("h4",{className:"mb-5",children:"Add A New File"}),(0,A.jsx)(_e,{type:"file",onEnter:n,onConfirm:n,onCancel:a})]}):null}function Pe(e){let{active:t,selectedFile:n,onConfirm:a,onCancel:s}=e;if(!t)return null;const{path:r}=n,l=r.split("/"),o=l.pop(),i=l.slice(1);return(0,A.jsxs)("div",{className:"content-window",children:[(0,A.jsxs)("h4",{className:"mb-5",children:["Delete ",(0,A.jsx)("span",{className:"text-danger",children:o})," File"]}),(0,A.jsx)(we,{className:"btn btn-danger btn-block delete-button mt-2",onClick:a,children:"Delete"}),(0,A.jsx)("button",{type:"button",className:"btn btn-outline-danger btn-block mt-2",onClick:s,children:"Cancel"}),(0,A.jsxs)("div",{className:"mt-5",children:["Are you sure you want to delete ",(0,A.jsx)("span",{className:"text-danger",children:o})," from"," ",(0,A.jsx)("span",{className:"text-danger",children:i.join("/")}),"?"]})]})}function $e(e){let{active:t,selectedFolder:n,onConfirm:a,onCancel:s}=e;if(!t)return null;if(!n)return null;const r=n.path.split("/"),l=2===r.length,o=l?null:r.slice(-1)[0];return(0,A.jsxs)("div",{className:"content-window",children:[(0,A.jsxs)("h4",{className:"mb-5",children:["Delete ",(0,A.jsx)("span",{className:"text-danger",children:l?null===n||void 0===n?void 0:n.project:o})," ",l?"Project":"Folder"]}),(0,A.jsx)(we,{className:"btn btn-danger btn-block delete-button mt-2",onClick:a,children:"Delete"}),(0,A.jsx)("button",{type:"button",className:"btn btn-outline-danger btn-block mt-2",onClick:s,children:"Cancel"}),(0,A.jsx)("div",{className:"mt-5",children:l?(0,A.jsxs)("div",{children:["Are you sure you want to delete project ",(0,A.jsx)("span",{className:"text-danger",children:null===n||void 0===n?void 0:n.project})," ?"]}):(0,A.jsxs)("div",{children:["Are you sure you want to delete the folder ",(0,A.jsx)("span",{className:"text-danger",children:o})," from"," ",(0,A.jsx)("span",{className:"text-danger",children:null===n||void 0===n?void 0:n.project}),"?"]})})]})}function Ee(e){let{active:t,selectedPackage:n,onConfirm:a,onCancel:s}=e;if(!t)return null;const r=n.name;return(0,A.jsxs)("div",{className:"content-window",children:[(0,A.jsxs)("h4",{className:"mb-5",children:["Delete ",(0,A.jsx)("span",{className:"text-danger",children:r})," Package"]}),(0,A.jsx)(we,{className:"btn btn-danger btn-block delete-button mt-2",onClick:a,children:"Delete"}),(0,A.jsx)("button",{type:"button",className:"btn btn-outline-danger btn-block mt-2",onClick:s,children:"Cancel"}),(0,A.jsxs)("div",{className:"mt-5",children:["Are you sure you want to delete ",(0,A.jsx)("span",{className:"text-danger",children:r}),"?"]})]})}const De="DEFAULT_WINDOW",Ie="DEFAULT_FOLDER_WINDOW",Te="CODE_EDITOR_WINDOW",Re="NAME_FILE_WINDOW",ze="NAME_PROJECT_WINDOW",Ue="NAME_PROJECT_FOLDER_WINDOW",Le="INSTALL_PACKAGE_WINDOW",We="DELETE_FILE_WINDOW",Me="DELETE_FOLDER_WINDOW",qe="DELETE_PACKAGE_WINDOW";function He(e){let{children:t}=e;return(0,A.jsx)(c.A,{className:"editor-window",children:(0,A.jsx)(u.A,{children:t})})}var Ge=n(5502);const Be=function(e){var t,n,s,r;let{deployTargets:l,fileTree:c,onFileSave:u,onAddFile:d,onRevertFile:p,onAddProjectFolder:m,onAddProject:h,onFileChange:f,onDeleteFolder:g,onDeleteFile:x,onDeletePackage:j,onDeployProject:v,onFileSelect:b,onInstallPackage:y,restartInstance:N,restartingInstance:k}=e;const[C,w]=(0,a.useState)(null),[_,S]=(0,a.useState)(null),[F,O]=(0,a.useState)(null),[P,$]=(0,a.useState)(De),[E,D]=(0,a.useState)(null),[I,T]=(0,a.useState)(!0),[R,z]=(0,a.useState)(!1),[U,L]=(0,a.useState)(!1),W=(null===c||void 0===c||null===(t=c.entries)||void 0===t?void 0:t.length)>0,M=Boolean(W&&C),q=Boolean(W&&(C||F)),H=Boolean(C);function G(e,t){$(e),D(t)}function B(){O(null),w(null),S(null)}function V(){G(De,P)}return(0,A.jsxs)(o.A,{id:"webide",children:[(0,A.jsxs)(i.A,{md:"4",xl:"3",className:"file-browser-outer-container mb-3",children:[(0,A.jsx)("div",{className:"floating-card-header-row",children:(0,A.jsxs)(re,{children:[(0,A.jsx)(ee,{onClick:()=>G(De,P),text:"app"}),(H||q)&&(0,A.jsx)("span",{className:"px-1",children:"|"}),H&&(0,A.jsx)(te,{disabled:!H,onClick:()=>G(Ue,P),text:!q&&"folder"}),q&&(0,A.jsx)(ne,{disabled:!q,onClick:()=>{F?G(qe,P):C&&G(Me,P)},text:"folder"}),(M||(null===_||void 0===_?void 0:_.path))&&(0,A.jsx)("span",{className:"px-1",children:"|"}),M&&(0,A.jsx)(ae,{onClick:()=>G(Re,P),disabled:!M,text:!(null!==_&&void 0!==_&&_.path)&&"file"}),(null===_||void 0===_?void 0:_.path)&&(0,A.jsx)(se,{disabled:!(null!==_&&void 0!==_&&_.path),onClick:()=>G(We,P),text:!M&&"file"})]})}),(0,A.jsx)(Y,{files:c,root:c.path,selectedFile:null===_||void 0===_?void 0:_.path,selectedFolder:C,selectedPackage:F,onDeployProject:v,onFolderSelect:e=>{B(),w(e),G(e?Ie:De,P)},onPackageSelect:e=>{B(),O(e),G(e?Ie:De,P)},onFileSelect:async e=>{const t=!e;if(B(),t)S(null),G(De,P);else{const t=await b(e),{content:n,cached:a}=t;S({...e,content:n,cached:a}),G(Te,P)}}})]}),(0,A.jsxs)(i.A,{md:"8",xl:"9",className:"editor-window-container",children:[(0,A.jsxs)(o.A,{className:"floating-card-header-row g-0",children:[(0,A.jsx)(i.A,{className:"text-nowrap",children:_&&(0,A.jsxs)(A.Fragment,{children:[null===_||void 0===_||null===(n=_.path)||void 0===n||null===(s=n.split("/"))||void 0===s||null===(r=s.slice(1))||void 0===r?void 0:r.join(" > ")," ",(0,A.jsxs)("span",{className:"text-grey d-none d-xl-inline-block",children:["| ",(null===_||void 0===_?void 0:_.size)||"..."," bytes |"," ",null!==_&&void 0!==_&&_.mtime?new Date(_.mtime).toLocaleTimeString():"..."]})]})}),(0,A.jsx)(i.A,{className:"text-nowrap",children:(0,A.jsxs)(de,{children:[(0,A.jsx)(oe,{savingFile:U,disabled:!(null!==_&&void 0!==_&&_.cached&&P===Te),onClick:async()=>{L(!0),await u(_,I),L(!1)},text:"save"}),(0,A.jsx)(ue,{loading:R,disabled:!(null!==_&&void 0!==_&&_.cached&&P===Te),onClick:async()=>{z(!0);try{const e=await p(_),t={..._,content:e,cached:!1};S(t)}finally{z(!1)}},text:"revert"}),(0,A.jsx)("span",{className:"px-1",children:"|"}),(0,A.jsx)(ie,{restarting:k,onClick:N,text:"restart"}),(0,A.jsx)(ce,{restartAfterSave:I,onClick:()=>T(!I),text:"auto"})]})})]}),(0,A.jsxs)(He,{children:[(0,A.jsx)(pe,{fileTree:c,active:P===De,AddProjectButtonClick:()=>G(ze,P),InstallPackageButtonClick:()=>{O(null),G(Le,P)}}),(0,A.jsx)(me,{active:P===Ie,type:F?"package":C?"folder":"nothing"}),(0,A.jsx)(Se,{active:P===ze,onConfirm:e=>{!async function(e){await h(e),G(E,P)}(e),(0,Ge.Ak)()},onCancel:V}),(0,A.jsx)(Fe,{projectName:null===C||void 0===C?void 0:C.project,active:P===Ue,selectedFolder:C,onConfirm:async function(e){await m(e,C),G(E,P)},onCancel:V}),(0,A.jsx)(Oe,{active:P===Re,onConfirm:async function(e){const t=await d(e,C);S(t),G(Te,P)},onCancel:V}),(0,A.jsx)(Ce,{active:P===Le,onConfirm:async function(e,t,n){await y(e,t,n),O(null),G(De,P)},onCancel:V,deployTargets:l,selectedPackage:F}),(0,A.jsx)(Ee,{active:P===qe,selectedPackage:F,onConfirm:async()=>{await j(F),G(De,P),B()},onCancel:V}),(0,A.jsx)($e,{active:P===Me,selectedFolder:C,onConfirm:async()=>{await g(C),G(De,P),B()},onCancel:V}),(0,A.jsx)(Pe,{active:P===We,selectedFile:_,onConfirm:async()=>{await x(_),G(De,P),B()},onCancel:V}),(0,A.jsx)(X,{active:P===Te,file:_,onFileChange:async e=>{_&&(!function(e){const t={..._,content:e};S(t)}(e),await f({path:null===_||void 0===_?void 0:_.path,content:e}),S({..._,content:e,cached:!0}))}})]})]})]})},Ve=async e=>{let{auth:t,url:n,function_content:a,project:s,type:r,file:l}=e;return(0,x.A)({operation:{operation:"set_custom_function",function_content:a,project:s,type:r,file:l},auth:t,url:n})},Ke={routes:"'use strict';\n\n/* Dependencies\n- import any packages that are listed in your projects package.json\n- for example:\nimport needle from 'needle'\n*/\n\n/* Helpers\n- import any helper methods from your project's \"helpers\" directory\n- for example:\nimport filter from '../helpers/filter.js';\n*/\n\nmodule.exports = async (server, { hdbCore, logger }) => {\n // POST route\n // with hdbCore.preValidation to process basic auth\n // uses hdbCore.requese to execute the validated request\n server.route({\n url: '/path/to/my/route',\n method: 'POST',\n preValidation: hdbCore.preValidation,\n handler: hdbCore.request,\n })\n\n // GET route\n // with custom validation\n // uses hdbCore.requestWithoutAuthentication\n server.route({\n url: '/path/to/my/route/:id',\n method: 'GET',\n preValidation: async (request, reply) => {\n const token = request.headers.authorization\n const results = hdbCore.requestWithoutAuthentication({\n body: {\n operation: 'search_by_hash',\n schema: 'auth',\n table: 'tokens',\n hash_values: [token],\n get_attributes: ['id']\n }\n })\n if (!results.length) {\n const errorString = result.body.error || 'Sorry, there was an error authenticating your request';\n logger.error(errorString);\n throw new Error(errorString);\n }\n },\n handler: async (request) => {\n const id = parseInt(request.params.id)\n request.body= {\n operation: 'sql',\n sql: `SELECT * FROM dev.dogs WHERE id = ${id}`\n };\n\n /*\n * requestWithoutAuthentication bypasses the standard HarperDB authentication.\n * YOU MUST ADD YOUR OWN preValidation method above, or this method will be available to anyone.\n */\n const result = await hdbCore.requestWithoutAuthentication(request);\n\n return result\n }\n });\n};\n",helpers:"\n/* filters the results, only returning the selected keys */\nexport default (result, keys) => {\n return result.map(r => {\n const f = {}\n keys.forEach(k => f[k] = r[k])\n return f;\n })\n}\n"};var Ze=n(9561);const Ye=function(e){let{items:t,toggleDropItem:n,toggleCreate:r,baseUrl:c,restarting:u,itemType:p,project:f}=e;const g=(0,d.Zp)(),j=(0,E.MW)(),v=(0,s.O$)(l.A,(e=>e.auth)),b=(0,s.O$)(l.A,(e=>e.url)),[y,k]=(0,a.useState)(!1),[C,w]=(0,a.useState)(!1),[_,S]=(0,a.useState)(!1),F=async e=>{e.preventDefault();let n,a=!1;if(y&&!t.includes(y)||(w(!0),a=!0),y&&!(0,Ze.A)(y)&&(w(!0),a=!0,j.error(("projects"===p?"Project":"File")+" names may only contain letters, numbers, hyphens, or underscores.")),a)return!1;if(S(!0),"projects"===p)n=await(async e=>{let{auth:t,url:n,project:a}=e;return(0,x.A)({operation:{operation:"add_custom_function_project",project:a},auth:t,url:n})})({auth:v,url:b,project:y});else{const e=(e=>Ke[e]||null)(p);n=await Ve({auth:v,url:b,project:f,type:p,file:y,function_content:e})}return n.error?(S(!1),r(!1),j.error(n.message)):setTimeout((async()=>(await(0,U.A)({auth:v,url:b,service:"custom_functions"}),await N({auth:v,url:b}),g(`${c}/${y}`))),500)};return(0,a.useEffect)((()=>{n()}),[n]),(0,a.useEffect)((()=>{y&&t.find((e=>e===y))&&g(`${c}/${y}`)}),[t]),(0,A.jsxs)(o.A,{className:"item-row form",children:[(0,A.jsx)(i.A,{className:"input-holder",children:(0,A.jsx)(m.A,{id:"name",invalid:C,onChange:e=>{w(!1),k(e.target.value)},value:y||"",disabled:_,type:"text",name:"name",placeholder:"projects"===p?"ex: api, api-v1, dogs":"routes"===p?"ex: v1, post, public":"ex: filter, auth, queries"})}),(0,A.jsx)(i.A,{className:"item-action",children:_?(0,A.jsx)(h.A,{color:"success",className:"round me-1",children:(0,A.jsx)("i",{className:"fa fa-spinner fa-spin text-white"})}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(h.A,{id:"createItem",color:"success",className:"round me-1",disabled:u,onClick:F,onKeyDown:e=>13!==e.keyCode||F(e),children:(0,A.jsx)("i",{className:"fa fa-check text-white"})}),(0,A.jsx)(h.A,{id:"toggleCreate",color:"black",className:"round",onClick:()=>r(!1),children:(0,A.jsx)("i",{className:"fa fa-times text-white"})})]})})]})},Je=async e=>{let{auth:t,url:n,project:a}=e;return(0,x.A)({operation:{operation:"drop_custom_function_project",project:a},auth:t,url:n})};const Qe=function(e){let{item:t,baseUrl:n,isActive:r,toggleDropItem:c,isDropping:u,itemType:p,restarting:m}=e;const{project:f}=(0,d.g)(),g=(0,d.Zp)(),j=(0,E.MW)(),[v,b]=(0,a.useState)(!1),[y,k]=(0,a.useState)(!1),C=(0,s.O$)(l.A,(e=>e.auth)),w=(0,s.O$)(l.A,(e=>e.url)),_=async()=>{if(!v)return!1;let e;return e="projects"===p?await Je({auth:C,url:w,project:t}):await(async e=>{let{auth:t,url:n,project:a,type:s,file:r}=e;return(0,x.A)({operation:{operation:"drop_custom_function",project:a,type:s,file:r},auth:t,url:n})})({auth:C,url:w,project:f,type:p,file:t}),e.error?(b(!1),k(!1),j.error(e.message)):(j.success(e.message),(0,U.A)({auth:C,url:w,service:"custom_functions"}),await N({auth:C,url:w}),g(n))};return(0,A.jsxs)(o.A,{title:`View${r?"ing":""} ${t}`,className:"item-row "+(r?"active":""),onClick:m?null:()=>!(r||u||v)&&g(`${n}/${t}`),tabIndex:"0",children:[(0,A.jsx)(i.A,{className:"item-label "+(v?"text-danger text-nowrap":""),children:v?`drop ${t}?`:"projects"===p?`/${t}`:t}),(0,A.jsx)(i.A,{className:"item-action",children:y?(0,A.jsx)(h.A,{tabIndex:"-1",disabled:!0,color:"purple",className:"round",children:(0,A.jsx)("i",{className:"fa fa-spinner fa-spin"})}):v?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(h.A,{id:"confirmDropItem",color:"danger",className:"round me-1",title:`confirm drop ${t}`,onClick:()=>{b(!1),k(!0),_()},children:(0,A.jsx)("i",{className:"fa fa-check text-white"})}),(0,A.jsx)(h.A,{id:"cancelDropItem",color:"black",className:"round",title:`Cancel drop ${t}`,onClick:()=>{b(!1)},children:(0,A.jsx)("i",{className:"fa fa-times text-white"})})]}):u?(0,A.jsx)(h.A,{id:"dropItem",color:"danger",className:"round",title:`Drop ${t}`,onClick:()=>{b(t),c(!1)},children:(0,A.jsx)("i",{className:"fa fa-minus text-white"})}):r?(0,A.jsx)(h.A,{tabIndex:"-1",color:"purple",className:"round",children:(0,A.jsx)("i",{className:"fa fa-chevron-right"})}):null})]},t)};const Xe=function(e){let{items:t,toggleDropItem:n,isDropping:a,toggleCreate:s,project:r,isCreating:l,restarting:c,itemType:u,showForm:d}=e;return(0,A.jsxs)(o.A,{className:"floating-card-header",children:[(0,A.jsx)(i.A,{children:"projects"===u?"projects":`/${r}/${u}`}),d&&null!==t&&void 0!==t&&t.length?(0,A.jsxs)(i.A,{className:"text-end",children:[(0,A.jsx)(h.A,{disabled:c,id:"toggleRemove",color:"link",title:"Remove Functions",className:"add-remove me-3",onClick:()=>{n(!a),s(!1)},children:(0,A.jsx)("i",{className:"fa fa-minus"})}),(0,A.jsx)(h.A,{disabled:c,id:"toggleCreate",color:"link",title:"Add Function",className:"add-remove me-1",onClick:()=>{s(!l),n(!1)},children:(0,A.jsx)("i",{className:"fa fa-plus"})})]}):null]})};const et=function(e){let{items:t,activeItem:n,baseUrl:s,restarting:r,itemType:l,project:o,showForm:i}=e;const[d,p]=(0,a.useState)(!1),[m,h]=(0,a.useState)(!1);return(0,a.useEffect)((()=>{h(),p()}),[n,t.length]),(0,A.jsxs)("div",{className:"entity-manager",children:[(0,A.jsx)(Xe,{items:t,itemType:l,isDropping:d,toggleDropItem:p,isCreating:m,toggleCreate:h,restarting:r,project:o,showForm:i}),(0,A.jsxs)(c.A,{className:"my-3",children:[t&&t.length?(0,A.jsx)(u.A,{className:"scrollable "+(m?"creating":""),children:t.map((e=>(0,A.jsx)(Qe,{item:e,baseUrl:s,isActive:n===e,isDropping:d,toggleDropItem:p,itemType:l,restarting:r},e)))}):null,i&&t&&!t.length||m?(0,A.jsx)(u.A,{children:(0,A.jsx)(Ye,{items:t,itemType:l,baseUrl:s,isDropping:d,toggleDropItem:p,isCreating:m,toggleCreate:h,restarting:r,project:o})}):!t||t.length||m?null:(0,A.jsx)(u.A,{children:(0,A.jsx)("div",{className:"py-3 text-center no-content",children:"no functions found"})})]})]})};const tt=function(){const e=(0,d.Zp)(),t=(0,E.MW)(),{customer_id:n,compute_stack_id:r,project:p,type:m,file:f}=(0,d.g)(),g=(0,s.O$)(l.A,(e=>e.auth)),j=(0,s.O$)(l.A,(e=>e.url)),[v,b]=(0,a.useState)(""),[y,N]=(0,a.useState)(""),k=(0,a.useCallback)((async()=>{if(p&&m&&f&&"undefined"!==f){const e=await(async e=>{let{auth:t,url:n,project:a,type:s,file:r}=e;return(0,x.A)({operation:{operation:"get_custom_function",project:a,type:s,file:r},auth:t,url:n})})({auth:g,url:j,project:p,type:m,file:f});b(null===e||void 0===e?void 0:e.message),N(null===e||void 0===e?void 0:e.message)}else b("")}),[g,j,p,m,f,b]);return(0,a.useEffect)((()=>{k()}),[p,f,k,r]),(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(o.A,{className:"floating-card-header",children:[(0,A.jsxs)(i.A,{children:["edit >\xa0",(0,A.jsxs)("i",{children:["/",p,f&&"undefined"!==f&&`/${m}/${f}.js`]})]}),(0,A.jsxs)(i.A,{className:"text-end",children:[(0,A.jsxs)(h.A,{onClick:k,color:"link",className:"me-2",children:[(0,A.jsx)("span",{className:"me-2",children:"reload"}),(0,A.jsx)("i",{title:"Reload File",className:"fa fa-sync-alt"})]}),(0,A.jsx)("span",{className:"mx-3 text",children:"|"}),(0,A.jsxs)(h.A,{onClick:()=>e(`/o/${n}/i/${r}/functions/deploy/${p}`),color:"link",className:"me-2",children:[(0,A.jsx)("span",{className:"me-2",children:"deploy"}),(0,A.jsx)("i",{title:"Deploy Project",className:"fa fa-share"})]})]})]}),(0,A.jsx)(c.A,{className:"my-3",children:v?(0,A.jsxs)(u.A,{children:[(0,A.jsx)("div",{className:"code-editor-holder",children:(0,A.jsx)(J.Ay,{height:"100%",defaultLanguage:"javascript",value:v,theme:"vs-dark",onChange:b})}),(0,A.jsxs)(o.A,{children:[(0,A.jsx)(i.A,{md:"6",className:"mt-2",children:(0,A.jsx)(h.A,{block:!0,color:"grey",title:"Revert Code to Last Saved State",disabled:v===y,onClick:k,id:"reset",children:(0,A.jsx)("i",{className:"fa fa-undo"})})}),(0,A.jsx)(i.A,{md:"6",className:"mt-2",children:(0,A.jsx)(h.A,{block:!0,title:"Save Code to Instance",color:"success",id:"addEditItem",onClick:async()=>{const e=await Ve({auth:g,url:j,function_content:v,project:p,type:m,file:f});e.error?t.error(e.message):(setTimeout((()=>(0,U.A)({auth:g,url:j,service:"custom_functions"})),500),t.success(e.message)),k()},children:(0,A.jsx)("i",{className:"fa fa-save"})})})]})]}):(0,A.jsx)(u.A,{children:(0,A.jsxs)("div",{className:"empty-prompt narrow",children:[(0,A.jsx)("div",{className:"mt-3 text-bold",children:"This project does not yet have any routes or helpers"}),(0,A.jsx)("div",{className:"mt-3",children:"Add some using the form fields at left."})]})})})]})};var nt=n(4343);const at=e=>{let{initializing:t,loading:n,handleClick:a}=e;return[{Header:"instance name",accessor:"instance_name"},{Header:"instance url",accessor:"url"},{Header:"cf capable",id:"hdb-narrow-cfcapable",Cell:e=>{let{row:{original:{custom_functions_status:t}}}=e;return t.error?"no":"yes"}},{Header:"cf enabled",id:"hdb-narrow-cfenabled",Cell:e=>{let{row:{original:{custom_functions_status:t}}}=e;return t.is_enabled?"yes":"no"}},{Header:"has project",id:"hdb-narrow-cfhasproject",Cell:e=>{let{row:{original:{has_current_project:t}}}=e;return t?"yes":"no"}},{Header:"deploy",id:"hdb-narrow-deploy",Cell:e=>{let{row:{original:{compute_stack_id:s,custom_functions_status:r,has_auth:l}}}=e;return r.is_enabled&&l?(0,A.jsx)(h.A,{color:"success",block:!0,size:"sm",disabled:t||n[s],onClick:()=>a(s,"deploy"),children:(0,A.jsx)("i",{className:"fa "+("deploy"===n[s]?"fa-spinner fa-spin":"fa-share")})}):null}},{Header:"remove",id:"hdb-narrow-remove",Cell:e=>{let{row:{original:{compute_stack_id:t,custom_functions_status:s,has_current_project:r,has_auth:l}}}=e;return s.is_enabled&&r&&l?(0,A.jsx)(h.A,{color:"danger",block:!0,size:"sm",disabled:n[t],onClick:()=>a(t,"drop"),children:(0,A.jsx)("i",{className:"fa "+("drop"===n[t]?"fa-spinner fa-spin":"fa-trash")})}):null}}]},st={filtered:[],sorted:[],page:0,totalPages:1,pageSize:20,autoRefresh:!1,showFilter:!1,lastUpdate:!1};const rt=function(){const{customer_id:e,compute_stack_id:t,project:n}=(0,d.g)(),r=(0,d.Zp)(),[p]=(0,L.A)({}),m=(0,s.O$)(l.A,(e=>e.auth)),f=(0,s.O$)(l.A,(e=>e.url)),b=(0,s.O$)(l.A,(e=>{var t;return null===(t=e.registration)||void 0===t?void 0:t.version})),[{payload:y,file:N},k]=(0,a.useState)([]),C=`/o/${e}/i/${t}/functions/edit/${n}`,w=(0,s.O$)(D.A,(e=>e.instances.filter((e=>e.compute_stack_id!==t)))),[_,S]=b.split("."),F=_>=3&&(_>3||S>=3),[O,P]=(0,a.useState)([]),[$,E]=(0,a.useState)(F),[I,T]=(0,a.useReducer)(((e,t)=>({...e,...t})),{}),[R,z]=(0,a.useState)(st),W=(0,a.useCallback)((()=>r(C)),[r,C]),M=(0,a.useCallback)((async(e,t)=>{const a=O.find((t=>t.compute_stack_id===e)),s=p[e];if(a&&s){T({[e]:t});let r=!1;const l=await j({auth:s,url:a.url});if(!l.error){const e=await v({auth:s,url:a.url});r=Object.keys(e).includes(n)}const o=O.map((t=>(t.compute_stack_id===e&&(t.custom_functions_status=l,t.has_current_project=r),t)));P(o),T({[e]:null})}}),[p,n,O]),q=(0,a.useCallback)((async(e,t)=>{const a=O.find((t=>t.compute_stack_id===e)),s=p[e];a&&s&&(T({[e]:t}),"deploy"===t?(await(async e=>{let{auth:t,url:n,project:a,payload:s,file:r}=e;return(0,x.A)({operation:{operation:"deploy_custom_function_project",project:a,payload:s,file:r},auth:t,url:n})})({auth:s,url:a.url,payload:y,project:n,file:N}),$&&await(async e=>{let{auth:t,url:n,projects:a,dry_run:s=!1}=e;return(0,x.A)({operation:{operation:"install_node_modules",projects:a,dry_run:s},auth:t,url:n})})({auth:s,url:a.url,projects:[n]}),await(0,U.A)({auth:s,url:a.url,service:"custom_functions"})):await Je({auth:s,url:a.url,project:n}),setTimeout((()=>{T({[e]:!1}),M(e,t)}),1e3))}),[N,p,y,n,O,M,$]);return g()((async()=>{if(m&&f&&n){k(!1);const e=await(async e=>{let{auth:t,url:n,project:a,skip_node_modules:s}=e;return(0,x.A)({operation:{operation:"package_custom_function_project",project:a,skip_node_modules:s},auth:t,url:n})})({auth:m,url:f,project:n,skip_node_modules:$});k(e)}}),[m,f,n,$]),g()((async()=>{if(w){const e=await Promise.all(w.map((async e=>{const t=p[e.compute_stack_id];let a={};if(t){const s=await j({auth:t,url:e.url});return s.error||(a=await v({auth:t,url:e.url})),{...e,custom_functions_status:s,has_auth:!0,has_current_project:Object.keys(a).includes(n)}}return{...e,custom_functions_status:!1}})));P(e)}}),[w,n]),(0,a.useEffect)((()=>{z({...R,totalPages:Math.ceil((O.length||R.pageSize)/R.pageSize)})}),[z,R.pageSize]),(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(o.A,{className:"floating-card-header",children:[(0,A.jsxs)(i.A,{children:["deploy ",n&&`> ${n}`]}),(0,A.jsxs)(i.A,{className:"text-end",children:[F&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(h.A,{color:"link",title:"Turn on autofresh",onClick:()=>E(!$),children:[(0,A.jsx)("span",{className:"me-2",children:"install dependencies at destination"}),(0,A.jsx)("i",{className:"fa fa-lg fa-toggle-"+($?"on":"off")})]}),(0,A.jsx)("span",{className:"mx-3 text",children:"|"})]}),(0,A.jsxs)(h.A,{onClick:W,color:"link",className:"me-2",children:[(0,A.jsx)("span",{className:"me-2",children:"back to edit"}),(0,A.jsx)("i",{title:"Edit Project",className:"fa fa-edit"})]})]})]}),(0,A.jsx)(c.A,{className:"my-3",children:(0,A.jsx)(u.A,{className:"react-table-holder",children:O.length?(0,A.jsx)(nt.A,{columns:at({initializing:!y,loading:I,handleClick:q}),data:O,page:R.page,pageSize:R.pageSize,totalPages:R.totalPages,showFilter:R.showFilter,sorted:R.sorted,onFilteredChange:e=>z({...R,filtered:e}),onSortedChange:e=>z({...R,sorted:e}),onPageChange:e=>z({...R,pageSize:e}),onPageSizeChange:e=>z({...R,page:0,pageSize:e})}):(0,A.jsx)("div",{className:"empty-prompt",children:"Please register at least one Custom Function-enabled instance to deploy to"})})})]})};const lt=function(e){let{loading:t,refreshCustomFunctions:n,restarting:a}=e;const r=(0,s.O$)(l.A,(e=>e.auth)),o=(0,s.O$)(l.A,(e=>e.url));return(0,A.jsxs)("span",{className:"structure-reloader d-block text-center mb-4",children:[(0,A.jsxs)(h.A,{disabled:t,color:"link",onClick:n,children:[(0,A.jsx)("span",{className:"me-2",children:"refresh projects"}),(0,A.jsx)("i",{title:"Refresh Endpoint Files",className:"fa "+(t?"fa-spinner fa-spin":"fa-sync-alt")})]}),(0,A.jsx)("span",{className:"mx-3 text",children:"|"}),(0,A.jsxs)(h.A,{disabled:a,color:"link",onClick:()=>(0,U.A)({auth:r,url:o,service:"custom_functions"}),className:"me-2",children:[(0,A.jsx)("span",{className:"me-2",children:"restart server"}),(0,A.jsx)("i",{title:"Refresh Endpoint Files",className:"fa "+(a?"fa-spinner fa-spin":"fa-stop-circle")})]}),(0,A.jsx)("hr",{className:"d-block d-md-none mt-4"})]})};const ot=function(e){let{url:t,project:n,fileCount:a}=e;return(0,A.jsxs)("div",{className:"entity-manager",children:[(0,A.jsxs)("div",{className:"floating-card-header",children:["/",n,"/static"]}),(0,A.jsx)(c.A,{className:"my-3",children:(0,A.jsx)(u.A,{children:(0,A.jsxs)(o.A,{className:"item-row",children:[(0,A.jsx)(i.A,{className:"item-label",children:a?"enabled":'"static" subfolder not found'}),(0,A.jsxs)(i.A,{className:"item-action",children:[(0,A.jsx)(h.A,{tabIndex:"-1",color:a?"success":"danger",disabled:!a,className:"round me-1",children:a}),(0,A.jsx)(h.A,{tabIndex:"-1",color:"purple",className:"round",disabled:!a,href:`${t}/${n}/static`,target:"_blank",rel:"noopener noreferrer",children:(0,A.jsx)("i",{title:"View UI",className:"fa fa-share"})})]})]})})})]})};var it=n(7666);const ct=function(e){var t,n,c;let{refreshCustomFunctions:u,loading:m}=e;const{customer_id:h,compute_stack_id:f,action:g="edit",project:x,file:j}=(0,d.g)(),v=(0,d.Zp)(),b=(0,s.O$)(l.A,(e=>e.custom_functions)),y=(0,s.O$)(l.A,(e=>e.registration)),[N,k]=((null===y||void 0===y?void 0:y.version)||"").split("."),C=parseFloat(`${N}.${k}`)<4.1,w=(0,s.O$)(l.A,(e=>"custom_functions"===e.restarting_service)),_=(0,s.O$)(l.A,(e=>{var t;return e.custom_functions_url||`${e.url.split(":").slice(0,-1).join(":")}:${null===(t=e.custom_functions)||void 0===t?void 0:t.port}`})),S=`/o/${h}/i/${f}/functions/${g}`;return(0,a.useEffect)((()=>{const e=(null===b||void 0===b?void 0:b.endpoints)&&Object.keys(null===b||void 0===b?void 0:b.endpoints).length,t=(null===b||void 0===b?void 0:b.endpoints)&&Object.keys(null===b||void 0===b?void 0:b.endpoints).includes(x);if(e&&x&&!t){const e=x&&Object.keys(null===b||void 0===b?void 0:b.endpoints)[0];v(`${S}/${e}`)}else if(e&&x&&!j){var n,a;const e=x&&(null===b||void 0===b||null===(n=b.endpoints[x])||void 0===n?void 0:n.routes[0]),t=x&&(null===b||void 0===b||null===(a=b.endpoints[x])||void 0===a?void 0:a.helpers[0]);v(`${S}/${x}/${e?"routes":"helpers"}/${e||t}`)}else if(e&&!x){const e=Object.keys(null===b||void 0===b?void 0:b.endpoints)[0];v(`${S}/${e}`)}else e||v(S)}),[null===b||void 0===b?void 0:b.endpoints,h,f,v,g,x,j,S]),(0,r.A)((async()=>{if(_&&w)try{await fetch(_),l.A.update((e=>{e.restarting_service=!1}))}catch(e){console.log(e)}}),1e3),(0,A.jsxs)(o.A,{id:"functions",children:[(0,A.jsx)(i.A,{xl:"3",lg:"4",md:"6",xs:"12",children:(0,A.jsxs)(p.tH,{onError:(e,t)=>(0,P.A)({error:{message:e.message,componentStack:t}}),FallbackComponent:O.A,children:[(0,A.jsx)(et,{itemType:"projects",items:Object.keys(null===b||void 0===b?void 0:b.endpoints)||[],activeItem:x,baseUrl:S,restarting:w,showForm:"edit"===g}),x&&"edit"===g&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(et,{itemType:"routes",items:x&&(null===b||void 0===b||null===(t=b.endpoints[x])||void 0===t?void 0:t.routes)||[],project:x,activeItem:j,baseUrl:`${S}/${x}/routes`,restarting:w,showForm:"edit"===g}),(0,A.jsx)(et,{itemType:"helpers",items:x&&(null===b||void 0===b||null===(n=b.endpoints[x])||void 0===n?void 0:n.helpers)||[],project:x,activeItem:j,baseUrl:`${S}/${x}/helpers`,restarting:w,showForm:"edit"===g}),C&&(0,A.jsx)(ot,{url:_,project:x,fileCount:x&&(null===b||void 0===b||null===(c=b.endpoints[x])||void 0===c?void 0:c.static)||0})]}),(0,A.jsx)("hr",{className:"mt-0"}),(0,A.jsxs)("div",{className:"entity-manager-footer",children:[(0,A.jsx)("div",{className:"text-bold mb-1",children:"Root File Directory"}),(0,A.jsx)(it.A,{text:b.directory}),(0,A.jsx)("div",{className:"text-bold mb-1 mt-3",children:"Custom Functions Server URL"}),(0,A.jsx)(it.A,{text:_})]}),(0,A.jsx)("hr",{}),(0,A.jsx)(lt,{refreshCustomFunctions:u,loading:m,restarting:w})]})}),(0,A.jsx)(i.A,{xl:"9",lg:"8",md:"6",xs:"12",children:"deploy"===g?(0,A.jsx)(rt,{}):x?(0,A.jsx)(tt,{}):(0,A.jsx)(F.A,{refreshCustomFunctions:u,headline:`Please ${null!==b&&void 0!==b&&b.endpoints.length?"choose":"create"} a project at left.`})})]})};function ut(e){return e.split("/").slice(2).join("/")}function dt(e,t,n,a){return e.reduce(((e,s)=>{const r=s.compute_stack_id,l=t[r];if(null===l||void 0===l||!l.version)return e;const[o,i]=(null===l||void 0===l?void 0:l.version.split("."))||[];return parseInt(o,10)>=4&&parseInt(i,10)>=2&&e.push({isCurrentInstance:r===n,auth:a,instance:s}),e}),[])}const pt=function(e){let{refreshCustomFunctions:t,loading:n}=e;const{compute_stack_id:r}=(0,d.g)(),o=(0,s.O$)(l.A,(e=>e.registration)),{fileTree:i}=(0,s.O$)(l.A,(e=>e.custom_functions)),c=(0,s.O$)(l.A,(e=>e.auth)),u=(0,s.O$)(l.A,(e=>e.url)),[p,m]=((null===o||void 0===o?void 0:o.version)||"").split(".")||[],h=parseFloat(`${p}.${m}`)>=4.2,f=(0,s.O$)(D.A,(e=>e.instances)),[g]=(0,L.A)({}),[j,v]=W({}),[b,y]=(0,a.useState)(!1),N=(0,E.MW)();function k(e){let{path:t}=e;const n={...j},a=`${r}_${t}`;a in n&&delete n[a],v({...n})}async function C(e){let{auth:t,url:n}=e;y(!0),setTimeout((async()=>{await(0,U.A)({auth:t,url:n,service:"http_workers"}),y(!1)}),100)}return h?(0,A.jsx)(Be,{fileTree:i,deployTargets:dt(f,g,r,c),onRevertFile:async function(e){k({path:e.path});const{error:n,message:a}=await I({auth:c,url:u,project:e.project,file:ut(e.path)});return n?N.error(a):(await t(),a)},onFileChange:async function(e){const{path:t,content:n}=e,a=`${r}_${t}`;v({...j,[a]:n})},onFileSave:async function(e,n){const a=e.path.split("/").slice(2).join("/"),s={auth:c,url:u,project:e.project,file:a,payload:e.content},{error:r,message:l}=await T(s);r&&N.error(l),n&&await C({auth:c,url:u}),k({path:e.path}),e.cached=!1,await t()},onUpdate:t,onAddFile:async function(e,n){const{path:a,project:s}=n,r=ut(a),l=r?`${r}/${e}`:e;return await T({auth:c,url:u,project:s,file:l,payload:""}),await t(),{content:"",path:[n.path,e].join("/"),project:s}},onAddProject:async function(e){const{error:n,message:a}=await(async e=>{let{auth:t,url:n,project:a}=e;return(0,x.A)({operation:{operation:"add_component",project:a},auth:t,url:n})})({auth:c,url:u,project:e});n&&N.error(a),await(0,U.A)({auth:c,url:u,service:"http_workers"}),await t()},onAddProjectFolder:async function(e,n){const{path:a,project:s}=n,r=ut(a),l=r?`${r}/${e}`:e,{error:o,message:i}=await T({auth:c,url:u,project:s,file:l});o&&N.error(i),await t()},onInstallPackage:async function(e,n,a){const s=a.map((async t=>{const{error:a,message:s}=await z({auth:t.auth,url:t.instance.url,project:e,packageUrl:n});a&&N.error(s),await(0,U.A)({auth:t.auth,url:t.instance.url,service:"http_workers"})}));await Promise.all(s),await t()},onDeployProject:async function(e){let{project:n,deployTarget:a}=e;const{auth:s,instance:r}=a,{payload:l}=await(async e=>{let{auth:t,url:n,project:a,skip_node_modules:s=!0}=e;return(0,x.A)({auth:t,url:n,operation:{operation:"package_component",project:a,skip_node_modules:s}})})({auth:c,url:u,project:n.name});await z({auth:s,url:r.url,project:n.name,payload:l}),await(0,U.A)({auth:s,url:r.url,service:"http_workers"}),await(0,U.A)({auth:c,url:u,service:"http_workers"}),await t()},onDeleteFile:async function(e){const{error:n,message:a}=await R({auth:c,url:u,project:e.project,file:ut(e.path)});n&&N.error(a),await t()},onDeleteFolder:async function(e){let{path:n,project:a}=e;const s=ut(n);if(s.length>0){const{error:e,message:t}=await R({auth:c,url:u,project:a,file:s});e&&N.error(t)}else{const{error:e,message:t}=await R({auth:c,url:u,project:a});e&&N.error(t)}await t()},onDeletePackage:async function(e){let{name:n}=e;const{error:a,message:s}=await R({auth:c,url:u,project:n});a?N.error(s):(await(0,U.A)({auth:c,url:u,service:"http_workers"}),await t())},onFileSelect:async function(e){const{path:t,project:n,name:a}=e,s=ut(t),l=`${r}_${t}`,o=j[l],i=l in j;if(i)return{cached:i,content:o,path:t,project:n,name:a};const{error:d,message:p}=await I({auth:c,url:u,project:n,file:s});return d?(N.error(p),{content:"",path:t,project:n,name:a,cached:!1}):{cached:i,content:p,path:t,project:n,name:a}},onFileRename:async function(e,n){const{path:a,content:s,project:r}=n,l=ut(a).split("/").slice(0,-1).join("/"),o=l?`${l}/${e}`:e;await R({auth:c,url:u,project:r,file:ut(a)}),await T({auth:c,url:u,project:r,file:o,payload:s}),t()},refreshingCustomFunctions:n,restartInstance:async()=>C({auth:c,url:u}),restartingInstance:b}):(0,A.jsx)(ct,{refreshCustomFunctions:t,loading:n})};const mt=function(){return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("div",{className:"floating-card-header text-end",children:"\xa0"}),(0,A.jsx)(c.A,{className:"my-3",children:(0,A.jsx)(u.A,{children:(0,A.jsxs)("div",{className:"empty-prompt narrow",children:[(0,A.jsx)("i",{className:"fa fa-bullhorn fa-3x text-success"}),(0,A.jsx)("div",{className:"mt-3 text-bold",children:"Coming Soon: Custom Functions!"}),(0,A.jsx)("div",{className:"mt-3",children:(0,A.jsxs)("ul",{children:[(0,A.jsx)("li",{children:"Add your own API endpoints to a standalone API server inside Harper"}),(0,A.jsx)("li",{children:"Use Harper Core methods to interact with your data at lightning speed"}),(0,A.jsx)("li",{children:"Custom Functions are powered by Fastify, so they're extremely flexible"}),(0,A.jsx)("li",{children:"Manage in Harper Studio, or use your own IDE and Version Management System"}),(0,A.jsx)("li",{children:"Distribute your Custom Functions to all your Harper instances with a single click"})]})})]})})})]})};var ht=n(4979),ft=n(2914);const gt=function(){const e=(0,s.O$)(l.A,(e=>e.auth)),t=(0,s.O$)(l.A,(e=>e.url)),n=(0,s.O$)(l.A,(e=>e.custom_functions)),o=(0,s.O$)(l.A,(e=>e.registration)),i=(0,ft.A)({version:null===o||void 0===o?void 0:o.version}),c=(0,s.O$)(l.A,(e=>e.restarting)),[u,d]=(0,a.useState)(!1),[p,m]=(0,a.useState)(!0),[h,f]=(0,a.useState)(!1),g=(0,a.useCallback)((async()=>{e&&t&&!c&&(m(!0),await N({auth:e,url:t}),m(!1))}),[e,t,c]);return(0,a.useEffect)((()=>{g()}),[g]),(0,a.useEffect)((()=>{const e=(null===n||void 0===n?void 0:n.is_enabled)&&(null===n||void 0===n?void 0:n.port)||i;d(e),e&&f(!1)}),[n,i]),(0,r.A)((()=>{h&&g()}),2e3),n?n.error?(0,A.jsx)(mt,{}):h?(0,A.jsx)(F.A,{description:"Configuring Custom Functions",icon:(0,A.jsx)("i",{className:"fa fa-spinner fa-spin"})}):u?(0,A.jsx)(pt,{refreshCustomFunctions:g,loading:p}):(0,A.jsx)($,{setConfiguring:f}):(0,A.jsx)(ht.A,{header:"loading custom functions",spinner:!0})}},7666:(e,t,n)=>{n.d(t,{A:()=>c});var a=n(9950),s=n(7176),r=n(6114),l=n(3452),o=n(7348),i=n(4414);const c=function(e){let{text:t,beforeText:n,afterText:c,obscure:u=!1}=e;const d=(0,o.MW)(),p=navigator.clipboard,m=(0,a.useCallback)((async e=>{e.stopPropagation(),await navigator.clipboard.writeText(t),d.success("Text copied to clipboard")}),[d,t]);return(0,i.jsxs)(s.A,{className:"copyable-text-holder g-0",children:[p&&t&&(0,i.jsx)(r.A,{className:"copy-icon",children:(0,i.jsx)(l.A,{title:"Copy this value",onClick:m,color:"link",children:(0,i.jsx)("i",{className:"fa fa-copy text-small"})})}),(0,i.jsx)(r.A,{className:"text-container",children:t?(0,i.jsxs)(i.Fragment,{children:[n,u?t.replace(/./g,"*"):t,c]}):(0,i.jsx)("span",{children:"\xa0"})})]})}},4343:(e,t,n)=>{n.d(t,{A:()=>b});var a=n(9950),s=n(2043),r=n(5488),l=n(9435),o=n(7176),i=n(6114),c=n(4414);const u=e=>{let{headerGroups:t,onSortedChange:n,sorted:a,showFilter:s,dynamicAttributesFromDataTable:r,tableDescriptionAttributes:l}=e;const u=e=>{let t=!1;return l.forEach((n=>{n.attribute===e&&(n.is_primary_key||n.indexed)&&(t=!0)})),t};return t.map((e=>{const{key:t,...l}=e.getHeaderGroupProps();return(0,c.jsxs)("div",{...l,children:[(0,c.jsx)(o.A,{className:"header g-0",children:e.headers.map((e=>{var t,s;return(0,c.jsx)(i.A,{onClick:()=>{var t,s;r&&!r.includes(e.id)&&u(e.id)&&n([{id:e.id,desc:(null===(t=a[0])||void 0===t?void 0:t.id)===e.id&&!(null!==(s=a[0])&&void 0!==s&&s.desc)}])},className:`${(null===(t=a[0])||void 0===t?void 0:t.id)===e.id?"sorted":""} ${null!==(s=a[0])&&void 0!==s&&s.desc?"desc":"asc"} ${-1!==e.id.indexOf("hdb-narrow")?"action":""} px-1 ${r&&!r.includes(e.id)&&u(e.id)?"":"disabled-column"}`,children:(0,c.jsx)("div",{className:"text-renderer",children:e.render("Header")})},e.id)}))}),s&&(0,c.jsx)(o.A,{className:"filter g-0",children:e.headers.map((e=>(0,c.jsx)(i.A,{className:-1!==e.id.indexOf("hdb-narrow")?"action":"",children:e.render("Filter")},e.id)))})]},t)}))};var d=n(3452);const p=function(e){let{page:t,pageSize:n,totalPages:a,onPageChange:s,onPageSizeChange:l,loading:u}=e;return(0,c.jsxs)(o.A,{className:"pagination",children:[(0,c.jsx)(i.A,{xs:"12",sm:"2",className:"previous",children:(0,c.jsx)(d.A,{className:"mb-2 btn-pagination",color:"purple",block:!0,onClick:()=>s(t-1),disabled:!a||0===t,children:(0,c.jsx)("i",{className:"fa fa-chevron-left"})})}),(0,c.jsxs)(i.A,{xs:"12",sm:"4",className:"paginator",children:[(0,c.jsx)("i",{className:"fa fa-book me-2"}),(0,c.jsx)(r.A,{className:"mb-2",type:"number",value:t+1,min:1,max:a,onChange:e=>s(e.target.value-1)}),(0,c.jsxs)("div",{className:"page-count",children:["\xa0/\xa0",u?(0,c.jsx)("i",{className:"fa fa-spinner fa-spin"}):a]})]}),(0,c.jsx)(i.A,{xs:"12",sm:"4",className:"page-size",children:(0,c.jsx)(r.A,{className:"mb-2",type:"select",value:n,onChange:e=>l(e.target.value),children:[20,50,100,250].map((e=>(0,c.jsxs)("option",{value:e,children:[e," rows"]},e)))})}),(0,c.jsx)(i.A,{xs:"12",sm:"2",className:"next",children:(0,c.jsx)(d.A,{className:"mb-2 pull-right btn-pagination",block:!0,color:"purple",onClick:()=>s(t+1),disabled:!a||t+1===a,children:(0,c.jsx)("i",{className:"fa fa-chevron-right"})})})]})};const m=function(e){let{previousPage:t,canPreviousPage:n,pageIndex:a,gotoPage:s,setPageSize:l,pageCount:u,nextPage:p,canNextPage:m,loading:h}=e;return(0,c.jsxs)(o.A,{className:"pagination",children:[(0,c.jsx)(i.A,{xs:"12",sm:"2",className:"previous",children:(0,c.jsx)(d.A,{className:"mb-2 btn-pagination",color:"purple",block:!0,onClick:t,disabled:!u||!n,children:(0,c.jsx)("i",{className:"fa fa-chevron-left"})})}),(0,c.jsxs)(i.A,{xs:"12",sm:"4",className:"paginator",children:[(0,c.jsx)("i",{className:"fa fa-book me-2"}),(0,c.jsx)(r.A,{className:"mb-2",type:"number",value:a+1||1,min:1,max:u,onChange:e=>s(e.target.value?Number(e.target.value)-1:0)}),(0,c.jsxs)("div",{className:"page-count",children:["\xa0/\xa0",h?(0,c.jsx)("i",{className:"fa fa-spinner fa-spin"}):u]})]}),(0,c.jsx)(i.A,{xs:"12",sm:"4",className:"page-size",children:(0,c.jsx)(r.A,{className:"mb-2",type:"select",onChange:e=>{s(0),setTimeout((()=>l(e.target.value)),1e3)},children:[20,50,100,250].map((e=>(0,c.jsxs)("option",{value:e,children:[e," rows"]},e)))})}),(0,c.jsx)(i.A,{xs:"12",sm:"2",className:"next",children:(0,c.jsx)(d.A,{className:"mb-2 pull-right btn-pagination",block:!0,color:"purple",onClick:p,disabled:!u||!m,children:(0,c.jsx)("i",{className:"fa fa-chevron-right"})})})]})};const h=function(e){let{prepareRow:t,row:n,onRowClick:a=!1}=e;return t(n),(0,c.jsx)(o.A,{onClick:()=>a&&a(n.original),className:"g-0",children:n.cells.map((e=>(0,c.jsx)(i.A,{className:-1!==e.column.id.indexOf("hdb-narrow")?"action":"",children:e.render("Cell")},`${e.row.id}-${e.column.id}`)))})};var f=n(3628),g=n(3150);function x(e){let{value:t}=e;return(0,c.jsx)("div",{className:"text-renderer",children:t})}function j(e){let{src:t}=e;const[n,s]=(0,a.useState)(!1),[r,l]=(0,a.useState)(!1);return(0,c.jsxs)("div",{className:"image-renderer",onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:[(0,c.jsx)("i",{className:"fa fa-image"}),n&&r?(0,c.jsxs)("div",{className:"preview-image no-image",children:[(0,c.jsx)("i",{className:"fa fa-ban text-danger"}),(0,c.jsx)("div",{className:"mt-2",children:"image failed to load"})]}):n?(0,c.jsx)("img",{onError:l,alt:t,src:t,className:"preview-image"}):null]})}const v={Filter:e=>{let{column:{filterValue:t,setFilter:n}}=e;return(0,c.jsx)(r.A,{type:"text",value:t||"",onChange:e=>n(e.target.value||void 0)})},Cell:e=>{let{value:t}=e;return(e=>{switch(Object.prototype.toString.call(e)){case"[object Array]":case"[object Object]":return(0,c.jsx)(x,{value:JSON.stringify(e)});case"[object Boolean]":return(0,c.jsx)(x,{value:e?"true":"false"});case"[object String]":return(t=e)&&(t.match(/^https?.*\.(jpeg|jpg|gif|png)$/)||-1!==t.indexOf("data:image"))?(0,c.jsx)(j,{src:e}):(0,c.jsx)(x,{value:e});default:return(0,c.jsx)(x,{value:e})}var t})(t)}};const b=function(e){let{columns:t,data:n,error:r,currentPage:o,pageSize:i,totalPages:d,onFilteredChange:x,onSortedChange:j,onPageChange:b,onPageSizeChange:y,showFilter:N,onRowClick:A,sorted:k,loading:C,dynamicAttributesFromDataTable:w,tableDescriptionAttributes:_,manual:S=!1}=e;const{headerGroups:F,page:O,rows:P,prepareRow:$,state:E,setAllFilters:D,canPreviousPage:I,canNextPage:T,pageOptions:R,pageCount:z,gotoPage:U,nextPage:L,previousPage:W,setPageSize:M}=(0,s.useTable)({columns:t,data:n,defaultColumn:v,onFilteredChange:x,onSortedChange:j,onPageChange:b,onPageSizeChange:y,onRowClick:A,manualPagination:S,manualFilters:S,initialState:{pageIndex:o,pageSize:i}},s.useFilters,s.usePagination),[q,H]=(0,a.useState)(!0),G=S||!O.length?P:O;return(0,a.useEffect)((()=>{!N&&E.filters.length?D([]):x(E.filters)}),[E.filters,N]),(0,a.useEffect)((()=>{setTimeout((()=>H(!1)),100)}),[null===G||void 0===G?void 0:G.length]),(0,c.jsxs)(l.tH,{onError:(e,t)=>(0,f.A)({error:{message:e.message,componentStack:t}}),FallbackComponent:g.A,children:[(0,c.jsxs)("div",{className:"react-table-scroller",children:[(0,c.jsx)(u,{headerGroups:F,tableDescriptionAttributes:_,dynamicAttributesFromDataTable:w,onSortedChange:j,sorted:k,showFilter:N}),C||q?(0,c.jsx)("div",{className:"centered text-center",children:(0,c.jsx)("i",{className:"fa fa-spinner fa-spin"})}):G.length?G.map((e=>(0,c.jsx)(h,{row:e,prepareRow:$,onRowClick:A},e.id))):(0,c.jsxs)("div",{className:"centered text-center",children:[(0,c.jsx)("i",{className:"fa fa-exclamation-triangle text-danger"}),(0,c.jsx)("div",{className:"mt-2 text-darkgrey",children:r?`Error loading data: ${r}`:"no records"})]})]}),S?(0,c.jsx)(p,{page:o,pageSize:i,totalPages:d,onPageChange:b,onPageSizeChange:y,loading:C}):(0,c.jsx)(m,{previousPage:W,pageSize:i,canPreviousPage:I,pageIndex:E.pageIndex,pageOptions:R,gotoPage:U,setPageSize:M,pageCount:z,nextPage:L,canNextPage:T,loading:C})]})}},8750:(e,t,n)=>{n.d(t,{A:()=>s});var a=n(127);const s=async e=>{let{auth:t,url:n}=e;return(0,a.A)({operation:{operation:"get_configuration"},auth:t,url:n})}},2415:(e,t,n)=>{n.d(t,{A:()=>r});var a=n(127),s=n(5269);const r=async e=>{let{auth:t,url:n}=e;const r=await(0,a.A)({operation:{operation:"list_roles"},auth:t,url:n}),l=[...Array.isArray(r)?r:[]].sort(((e,t)=>e.role.toLowerCase()>t.role.toLowerCase()?1:-1));return s.A.update((e=>{e.roles=l})),l}},8222:(e,t,n)=>{n.d(t,{A:()=>r});var a=n(127),s=n(5269);const r=async e=>{let{auth:t,url:n,signal:r}=e;const l=await(0,a.A)({operation:{operation:"list_users"},auth:t,url:n,signal:r}),o=Array.isArray(l)?[...l].map((e=>({username:e.username,role:e.role.role}))).sort(((e,t)=>e.username.toLowerCase()>t.username.toLowerCase()?1:-1)):[];return s.A.update((e=>{e.users=o})),o}},2010:(e,t,n)=>{n.d(t,{A:()=>r});var a=n(127),s=n(5269);const r=async e=>{let{auth:t,url:n}=e;return s.A.update((e=>{e.restarting=!0})),(0,a.A)({operation:{operation:"restart"},auth:t,url:n})}},1534:(e,t,n)=>{n.d(t,{A:()=>r});var a=n(127),s=n(5269);const r=async e=>{let{auth:t,url:n,service:r=null}=e;return r?(s.A.update((e=>{e.restarting_service=r})),(0,a.A)({operation:{operation:"restart_service",service:r},auth:t,url:n})):{error:!0,message:"You must specify a service"}}},4834:(e,t,n)=>{n.d(t,{A:()=>s});var a=n(127);const s=async e=>{let{auth:t,url:n,...s}=e;return(0,a.A)({operation:{operation:"set_configuration",...s},auth:t,url:n})}},6177:(e,t,n)=>{n.d(t,{A:()=>i});var a=n(8750),s=n(2415),r=n(8222),l=n(717),o=n(127);const i=async e=>{var t,n,i,c,u,d,p;let{auth:m,url:h}=e;const f=await(0,a.A)({auth:m,url:h}),g=await(0,l.A)({auth:m,url:h}),x=await(async e=>{let{auth:t,url:n}=e;return(0,o.A)({operation:{operation:"cluster_status"},auth:t,url:n})})({auth:m,url:h}),j=parseFloat(null===g||void 0===g?void 0:g.version)>=4?"nats":"socketcluster",v=await(0,s.A)({auth:m,url:h});let b=!1;v.error||(b=v.find((e=>e.permission.cluster_user)));const y=await(0,r.A)({auth:m,url:h});let N=!1;y.error||(N=b&&y.find((e=>e.role===b.role)));const A="nats"===j?null===(t=f.clustering)||void 0===t?void 0:t.enabled:f.CLUSTERING,k="nats"===j?null===(n=f.clustering)||void 0===n?void 0:n.user:f.CLUSTERING_USER,C="nats"===j?null===(i=f.clustering)||void 0===i||null===(c=i.hubServer)||void 0===c||null===(u=c.cluster)||void 0===u||null===(d=u.network)||void 0===d?void 0:d.port:f.CLUSTERING_PORT,w="nats"===j?null===(p=f.clustering)||void 0===p?void 0:p.nodeName:f.NODE_NAME;return{is_ready:!!A&&!!N&&!!k&&!!b&&!!C&&!!w,cluster_role:b,cluster_user:N,is_enabled:A,config_cluster_user:k,config_cluster_port:C,node_name:w,engine:j,status:null===x||void 0===x?void 0:x.status,message:null===x||void 0===x?void 0:x.message,connections:null===x||void 0===x?void 0:x.connections}}},9561:(e,t,n)=>{n.d(t,{A:()=>a});const a=e=>e.match(/^[-a-zA-Z0-9_]+$/)},5488:(e,t,n)=>{n.d(t,{A:()=>b});var a=n(9950),s=n(1942),r=n.n(s),l=n(8738),o=n.n(l),i=n(1497);function c(e){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c(e)}var u=["className","cssModule","type","bsSize","valid","invalid","tag","addon","plaintext","innerRef"];function d(){return d=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},d.apply(this,arguments)}function p(e,t){if(null==e)return{};var n,a,s=function(e,t){if(null==e)return{};var n,a,s={},r=Object.keys(e);for(a=0;a<r.length;a++)n=r[a],t.indexOf(n)>=0||(s[n]=e[n]);return s}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a<r.length;a++)n=r[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function m(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function f(e){var t=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,a=x(e);if(t){var s=x(this).constructor;n=Reflect.construct(a,arguments,s)}else n=a.apply(this,arguments);return function(e,t){if(t&&("object"===c(t)||"function"===typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return g(e)}(this,n)}}function g(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function x(e){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},x(e)}var j={children:r().node,type:r().string,size:r().oneOfType([r().number,r().string]),bsSize:r().string,valid:r().bool,invalid:r().bool,tag:i.Wx,innerRef:r().oneOfType([r().object,r().func,r().string]),plaintext:r().bool,addon:r().bool,className:r().string,cssModule:r().object},v=function(e){!function(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}(l,e);var t,n,s,r=f(l);function l(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),(t=r.call(this,e)).getRef=t.getRef.bind(g(t)),t.focus=t.focus.bind(g(t)),t}return t=l,(n=[{key:"getRef",value:function(e){this.props.innerRef&&this.props.innerRef(e),this.ref=e}},{key:"focus",value:function(){this.ref&&this.ref.focus()}},{key:"render",value:function(){var e=this.props,t=e.className,n=e.cssModule,s=e.type,r=void 0===s?"text":s,l=e.bsSize,c=e.valid,m=e.invalid,h=e.tag,f=e.addon,g=e.plaintext,x=e.innerRef,j=p(e,u),v=["switch","radio","checkbox"].indexOf(r)>-1,b="select"===r,y="range"===r,N=h||(b||"textarea"===r?r:"input"),A="form-control";g?(A="".concat(A,"-plaintext"),N=h||"input"):y?A="form-range":b?A="form-select":v&&(A=f?null:"form-check-input"),j.size&&/\D/g.test(j.size)&&((0,i.mc)('Please use the prop "bsSize" instead of the "size" to bootstrap\'s input sizing.'),l=j.size,delete j.size);var k=(0,i.qO)(o()(t,m&&"is-invalid",c&&"is-valid",!!l&&(b?"form-select-".concat(l):"form-control-".concat(l)),A),n);return("input"===N||h&&"function"===typeof h)&&(j.type="switch"===r?"checkbox":r),j.children&&!g&&"select"!==r&&"string"===typeof N&&"select"!==N&&((0,i.mc)('Input with a type of "'.concat(r,'" cannot have children. Please use "value"/"defaultValue" instead.')),delete j.children),a.createElement(N,d({},j,{ref:x,className:k,"aria-invalid":m}))}}])&&m(t.prototype,n),s&&m(t,s),Object.defineProperty(t,"prototype",{writable:!1}),l}(a.Component);v.propTypes=j;const b=v}}]);