@lamalibre/create-lamaste 4.4.0 → 4.4.1

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 (50) hide show
  1. package/package.json +2 -2
  2. package/vendor/docs/00-introduction/how-it-works.md +2 -2
  3. package/vendor/docs/00-introduction/quickstart.md +5 -5
  4. package/vendor/docs/00-introduction/what-is-lamaste.md +5 -5
  5. package/vendor/docs/01-concepts/certificates.md +3 -3
  6. package/vendor/docs/01-concepts/mtls.md +2 -2
  7. package/vendor/docs/01-concepts/security-model.md +2 -2
  8. package/vendor/docs/01-concepts/tickets.md +2 -2
  9. package/vendor/docs/01-concepts/tunneling.md +4 -4
  10. package/vendor/docs/02-guides/agent-setup.md +5 -5
  11. package/vendor/docs/02-guides/certificate-management.md +2 -2
  12. package/vendor/docs/02-guides/cloud-provisioning.md +3 -3
  13. package/vendor/docs/02-guides/desktop-app-setup.md +10 -10
  14. package/vendor/docs/02-guides/installation.md +3 -3
  15. package/vendor/docs/02-guides/onboarding.md +2 -2
  16. package/vendor/docs/02-guides/standalone-plugin-with-tickets.md +2 -2
  17. package/vendor/docs/03-architecture/installer-flow.md +2 -2
  18. package/vendor/docs/03-architecture/installer.md +4 -4
  19. package/vendor/docs/03-architecture/management-flow.md +1 -1
  20. package/vendor/docs/03-architecture/overview.md +5 -5
  21. package/vendor/docs/03-architecture/panel-client.md +6 -6
  22. package/vendor/docs/03-architecture/panel-server.md +2 -2
  23. package/vendor/docs/03-architecture/state-management.md +2 -2
  24. package/vendor/docs/03-architecture/system-overview.md +1 -1
  25. package/vendor/docs/04-api-reference/agent-hosted-plugins.md +11 -11
  26. package/vendor/docs/04-api-reference/app-host.md +3 -3
  27. package/vendor/docs/04-api-reference/lifecycle-hooks.md +5 -5
  28. package/vendor/docs/04-api-reference/onboarding.md +1 -1
  29. package/vendor/docs/04-api-reference/registry-and-oidc.md +3 -1
  30. package/vendor/docs/04-api-reference/tunnels.md +1 -1
  31. package/vendor/docs/05-operations/backup-and-restore.md +1 -1
  32. package/vendor/docs/05-operations/uninstalling.md +1 -1
  33. package/vendor/docs/05-operations/upgrades.md +5 -5
  34. package/vendor/docs/06-reference/config-files.md +2 -2
  35. package/vendor/docs/06-reference/glossary.md +3 -3
  36. package/vendor/docs/06-reference/installer-flags.md +13 -13
  37. package/vendor/docs/06-reference/ports-and-services.md +1 -1
  38. package/vendor/docs/06-reference/troubleshooting.md +8 -8
  39. package/vendor/docs/gatekeeper-design.md +8 -8
  40. package/vendor/docs/identity-directory-design.md +2 -2
  41. package/vendor/docs/package.json +1 -1
  42. package/vendor/docs/todo/lib-cli-desktop-refactor.md +27 -27
  43. package/vendor/gatekeeper/package.json +2 -2
  44. package/vendor/server/package.json +2 -2
  45. package/vendor/server-ui/dist/assets/{index-CESyyK8V.js → index-roDHz3dM.js} +1 -1
  46. package/vendor/server-ui/dist/index.html +1 -1
  47. package/vendor/serverd/package.json +2 -2
  48. package/vendor/serverd/src/lib/plugin-packages.js +30 -22
  49. package/vendor/serverd/src/lib/plugins.js +35 -11
  50. package/vendor/serverd/src/lib/registry-credential.js +37 -0
@@ -12,7 +12,7 @@ sudo systemctl reload nginx`})]})]}),(0,N.jsx)(`div`,{className:`flex justify-en
12
12
  `)),[d,f]=(0,g.useState)((e.deniedIps||[]).join(`
13
13
  `)),[p,m]=(0,g.useState)((e.allowedPlugins||[]).join(`
14
14
  `)),[h,_]=(0,g.useState)(e.allowedActions||el.slice(0,3)),v=I({mutationFn:t=>n.updatePushInstallPolicy(e.id,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`push-install-policies`]}),r.invalidateQueries({queryKey:[`push-install-config`]}),i(`Policy updated`),t()},onError:e=>i(K(e),`error`)}),y=e=>{e.preventDefault();let t=e=>e.split(`
15
- `).map(e=>e.trim()).filter(Boolean);v.mutate({name:a,description:s,allowedIps:t(l),deniedIps:t(d),allowedPlugins:t(p),allowedActions:h})},b=e=>{_(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,N.jsxs)(`div`,{className:`w-full max-w-lg rounded-xl bg-zinc-900 border border-zinc-700 p-6 shadow-xl`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,N.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:`Edit Policy`}),(0,N.jsx)(`button`,{type:`button`,onClick:t,className:`text-zinc-400 hover:text-white`,children:(0,N.jsx)(ka,{size:20})})]}),(0,N.jsxs)(`form`,{onSubmit:y,className:`space-y-4`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Name`}),(0,N.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 focus:border-cyan-500 focus:outline-none`})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Description`}),(0,N.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 focus:border-cyan-500 focus:outline-none`})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Allowed IPs (one per line)`}),(0,N.jsx)(`textarea`,{value:l,onChange:e=>u(e.target.value),rows:3,placeholder:`192.168.1.0/24`,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Denied IPs (one per line)`}),(0,N.jsx)(`textarea`,{value:d,onChange:e=>f(e.target.value),rows:2,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono focus:border-cyan-500 focus:outline-none`})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Allowed Plugins (one per line)`}),(0,N.jsx)(`textarea`,{value:p,onChange:e=>m(e.target.value),rows:2,placeholder:`@lamalibre/lamaste-herd-plugin`,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`}),(0,N.jsxs)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:[`For an agent half Lamaste installs, name its agent package (the manifest's`,` `,(0,N.jsx)(`span`,{className:`font-mono`,children:`agent.package`}),`). Empty allows every package.`]})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-2`,children:`Allowed Actions`}),(0,N.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:el.map(e=>(0,N.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:h.includes(e),onChange:()=>b(e),className:`accent-cyan-500`}),(0,N.jsx)(`span`,{className:`text-zinc-300`,children:e})]},e))})]}),(0,N.jsxs)(`div`,{className:`flex justify-end gap-3 pt-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:t,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:`Cancel`}),(0,N.jsxs)(`button`,{type:`submit`,disabled:!a.trim()||v.isPending,className:`rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:[v.isPending?(0,N.jsx)(V,{size:14,className:`animate-spin inline mr-1`}):null,`Save Changes`]})]})]})]})})}function nl(){let e=R(),t=P(),n=G(),[r,i]=(0,g.useState)(null),a=F({queryKey:[`push-install-policies`],queryFn:()=>e.getPushInstallPolicies(),refetchInterval:3e4}),o=I({mutationFn:t=>e.deletePushInstallPolicy(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`push-install-policies`]}),t.invalidateQueries({queryKey:[`push-install-config`]}),n(`Policy deleted`)},onError:e=>n(K(e),`error`)}),s=a.data?.policies||[];return a.isLoading||s.length===0?null:(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,N.jsx)(ha,{size:14,className:`text-cyan-400`}),(0,N.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300`,children:`Policies`})]}),(0,N.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-zinc-800`,children:(0,N.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,N.jsx)(`thead`,{children:(0,N.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-900`,children:[(0,N.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Name`}),(0,N.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400 hidden md:table-cell`,children:`Description`}),(0,N.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400 hidden lg:table-cell`,children:`Actions`}),(0,N.jsx)(`th`,{className:`px-4 py-3 text-right text-xs font-medium uppercase text-zinc-400`,children:`Manage`})]})}),(0,N.jsx)(`tbody`,{children:s.map(e=>(0,N.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-800`,children:[(0,N.jsx)(`td`,{className:`px-4 py-3 text-zinc-200 font-semibold`,children:e.name}),(0,N.jsx)(`td`,{className:`px-4 py-3 text-zinc-400 hidden md:table-cell`,children:e.description||`—`}),(0,N.jsx)(`td`,{className:`px-4 py-3 hidden lg:table-cell`,children:(0,N.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:(e.allowedActions||[]).map(e=>(0,N.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-zinc-700 text-zinc-300`,children:e},e))})}),(0,N.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,N.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600`,title:`Edit policy`,children:(0,N.jsx)($i,{size:12})}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>o.mutate(e.id),disabled:o.isPending,className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-zinc-300 hover:bg-red-600/20 hover:text-red-400`,title:`Delete policy`,children:(0,N.jsx)(ba,{size:12})})]})})]},e.id))})]})}),r&&(0,N.jsx)(tl,{policy:r,onClose:()=>i(null)})]})}function rl(){let e=R(),t=P(),n=G(),{reveal:r}=qa(),i=F({queryKey:[`plugins`],queryFn:()=>e.getPlugins(),refetchInterval:1e4}),a=I({mutationFn:async t=>{let{result:n,secrets:i}=za(await e.installPlugin(t));return r({plugin:n.plugin?.name??t,cause:`install`,secrets:i}),n},onSuccess:e=>{t.invalidateQueries({queryKey:[`plugins`]}),n(`Plugin "${e.plugin?.name||`unknown`}" installed`)},onError:e=>n(K(e),`error`)}),o=I({mutationFn:async t=>{let{result:n,secrets:i}=za(await e.enablePlugin(t));return r({plugin:t,cause:`enable`,secrets:i}),n},onSuccess:e=>{let r=i.data?.plugins?.find(t=>t.name===e.name);t.invalidateQueries({queryKey:[`plugins`]}),n(r?.hosting===`agent`?`Plugin "${e.name}" enabled (agent-hosted — nothing to mount)`:`Plugin "${e.name}" enabled (restart panel to mount routes)`)},onError:e=>n(K(e),`error`)}),s=I({mutationFn:t=>e.disablePlugin(t),onSuccess:e=>{t.invalidateQueries({queryKey:[`plugins`]}),n(`Plugin "${e.name}" disabled`)},onError:e=>n(K(e),`error`)}),c=(e,{hosting:t})=>n(qs(e,{agentLabel:t?.agentLabel,action:`uninstall`}),`error`),l=I({mutationFn:({name:t,purge:n})=>e.uninstallPlugin(t,{purge:n}),onSuccess:(e,{name:r,purge:i})=>{t.invalidateQueries({queryKey:[`plugins`]}),e.operation?(t.invalidateQueries({queryKey:[`plugin-operations`,r]}),n(`Uninstalling "${r}": its hosting is removed first${i?`, with its agent half’s data`:``} — follow the steps on its card`)):n(`Plugin "${e.name}" uninstalled`)},onError:c}),u=I({mutationFn:({name:t,agentLabel:n})=>e.setPluginHosting(t,n),onSuccess:(e,{name:r,agentLabel:i})=>{t.invalidateQueries({queryKey:[`plugin-operations`,r]}),n(`Hosting "${r}" on ${i} — follow the steps on its card`)}}),d=I({mutationFn:({name:t,force:n,purge:r})=>e.clearPluginHosting(t,{force:n,purge:r}),onSuccess:(e,{name:r,purge:i})=>{t.invalidateQueries({queryKey:[`plugin-operations`,r]}),n(`Removing the hosting of "${r}"${i?` and its agent half’s data`:``} — follow the steps on its card`)},onError:c}),f=I({mutationFn:t=>e.rotatePluginHostingSecret(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`plugins`]}),n(`New installation secret issued — the agent picks it up on its next sync`)},onError:e=>n(K(e),`error`)}),p=a.isPending||o.isPending||s.isPending||l.isPending||u.isPending||d.isPending||f.isPending,m=(0,g.useCallback)(e=>a.mutate(e),[a]),h=(0,g.useCallback)(e=>o.mutate(e),[o]),_=(0,g.useCallback)(e=>s.mutate(e),[s]),v=(0,g.useCallback)((e,t={},n=null)=>l.mutate({name:e,purge:t.purge===!0,hosting:n}),[l]),y=(0,g.useCallback)((e,t,n)=>u.mutate({name:e,agentLabel:t},n),[u]),b=(0,g.useCallback)((e,t={},n=null)=>d.mutate({name:e,force:t.force===!0,purge:t.purge===!0,hosting:n}),[d]),x=(0,g.useCallback)(e=>f.mutate(e),[f]),S=i.data?.plugins,C=i.data?.retainedData??[],w=new Set((S??[]).map(e=>e.name));return(0,N.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,N.jsxs)(`div`,{className:`mb-6`,children:[(0,N.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Plugins`}),(0,N.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`Install, enable, and manage plugins`})]}),(0,N.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-5 mb-8`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-300 mb-4`,children:`Install Plugin`}),(0,N.jsx)($c,{onInstall:m,isInstalling:a.isPending}),a.isPending&&(0,N.jsx)(`p`,{className:`text-xs text-zinc-500 mt-2`,children:`Installing...`})]}),i.isLoading?(0,N.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:Array.from({length:2}).map((e,t)=>(0,N.jsx)(`div`,{className:`h-40 animate-pulse rounded-lg bg-zinc-900 border border-zinc-800`},t))}):i.isError?(0,N.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-2 text-red-400 text-sm`,children:[(0,N.jsx)(hi,{size:16}),`Failed to load plugins`]})}):S?.length===0?(0,N.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,N.jsx)(`p`,{className:`text-zinc-500 text-sm text-center`,children:`No plugins installed. Use the form above to install one.`})}):(0,N.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:S?.map(e=>(0,N.jsx)(Qc,{plugin:e,now:i.dataUpdatedAt,onEnable:h,onDisable:_,onUninstall:v,onHost:y,onUnhost:b,onRotate:x,isActing:p},e.name))}),(0,N.jsx)(Kc,{records:C,installedNames:w,isActing:p}),(0,N.jsx)(Tc,{children:(0,N.jsx)(nl,{})})]})}function il(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3),r=Math.floor(n/60),i=Math.floor(r/60),a=Math.floor(i/24);return a>30?new Date(e).toLocaleDateString():a>0?`${a}d ago`:i>0?`${i}h ago`:r>0?`${r}m ago`:`just now`}var al=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;function ol(e){return e?e.length>63?`Max 63 characters`:al.test(e)?null:`Lowercase letters, numbers, and hyphens only. Cannot start or end with a hyphen.`:`Subdomain is required`}var sl={default:10,min:1,max:10240};function cl(e){let t=Number(e);return e===``||!Number.isInteger(t)?`Must be a whole number of MiB`:t<sl.min?`Minimum ${sl.min}`:t>sl.max?`Maximum ${sl.max}`:null}function ll(e){return e.maxBodySizeMb??1}var ul=[{value:`restricted`,label:`Restricted`,desc:`Only granted users and groups`},{value:`authenticated`,label:`All Authelia Users`,desc:`Any authenticated user can access`},{value:`public`,label:`Public`,desc:`No authentication required`}],dl=[3100,9090,9091,9292,9294];function fl(e){let t=Number(e);return!e&&e!==0?`Port is required`:Number.isInteger(t)?t<1024?`Minimum 1024`:t>65535?`Maximum 65535`:dl.includes(t)?`Reserved for a Lamaste service on the relay`:null:`Must be an integer`}function pl(){let e=R(),t=F({queryKey:[`admin-agents`],queryFn:()=>e.getAgents()});return{agents:(t.data?.agents||[]).filter(e=>!e.revoked&&e.certType!==`plugin-agent`).map(e=>e.label).sort(),isLoading:t.isLoading}}function ml({domain:e,onClose:t}){let n=R(),r=P(),i=G(),[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)(``),[d,f]=(0,g.useState)(`restricted`),[p,m]=(0,g.useState)(``),[h,_]=(0,g.useState)(String(sl.default)),{agents:v,isLoading:y}=pl(),[b,x]=(0,g.useState)({}),[S,C]=(0,g.useState)(null),w=I({mutationFn:e=>n.createTunnel(e),onSuccess:e=>{r.invalidateQueries({queryKey:[`tunnels`]}),i(`Tunnel ${e.tunnel.fqdn} created`),t()},onError:e=>{C(K(e))}}),T=(0,g.useCallback)(e=>{e.preventDefault(),C(null);let t=ol(a),n=fl(s),r={};t&&(r.subdomain=t),n&&(r.port=n),p||(r.agentLabel=`Choose the agent that carries this tunnel`);let i=cl(h);if(i&&(r.maxBody=i),Object.keys(r).length>0){x(r);return}x({}),w.mutate({subdomain:a,port:Number(s),description:l||void 0,accessMode:d,agentLabel:p,maxBodySizeMb:Number(h)})},[a,s,l,d,p,h,w]);return(0,N.jsxs)(`div`,{className:`bg-zinc-900 border border-zinc-800 rounded-lg p-5 mb-6`,children:[(0,N.jsxs)(`h2`,{className:`text-sm font-semibold text-zinc-300 mb-4 flex items-center gap-2`,children:[(0,N.jsx)(ta,{size:14,className:`text-cyan-400`}),`Add Tunnel`]}),(0,N.jsxs)(`form`,{onSubmit:T,className:`space-y-4`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Subdomain`}),(0,N.jsxs)(`div`,{className:`flex items-center gap-0`,children:[(0,N.jsx)(`input`,{type:`text`,value:a,onChange:e=>{o(e.target.value.toLowerCase()),x(e=>({...e,subdomain:void 0}))},disabled:w.isPending,placeholder:`myapp`,className:`flex-1 rounded-l bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono placeholder:text-zinc-600 focus:outline-none focus:border-cyan-400 disabled:opacity-50`}),(0,N.jsxs)(`span`,{className:`rounded-r bg-zinc-800/60 border border-l-0 border-zinc-700 px-3 py-2 text-sm text-zinc-500 font-mono`,children:[`.`,e]})]}),b.subdomain&&(0,N.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:b.subdomain})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Port`}),(0,N.jsx)(`input`,{type:`number`,value:s,onChange:e=>{c(e.target.value),x(e=>({...e,port:void 0}))},disabled:w.isPending,placeholder:`8080`,min:1024,max:65535,className:`w-40 rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono placeholder:text-zinc-600 focus:outline-none focus:border-cyan-400 disabled:opacity-50`}),b.port&&(0,N.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:b.port})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Agent`}),(0,N.jsxs)(`select`,{value:p,onChange:e=>{m(e.target.value),x(e=>({...e,agentLabel:void 0}))},disabled:w.isPending||y,className:`w-64 rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono focus:outline-none focus:border-cyan-400 disabled:opacity-50`,children:[(0,N.jsx)(`option`,{value:``,children:y?`Loading agents…`:`Select an agent`}),v.map(e=>(0,N.jsx)(`option`,{value:e,children:e},e))]}),(0,N.jsx)(`p`,{className:`text-xs text-zinc-500 mt-1`,children:`Only this agent forwards the port. It starts carrying the tunnel within 30 seconds.`}),!y&&v.length===0&&(0,N.jsx)(`p`,{className:`text-yellow-400 text-xs mt-1`,children:`No agents enrolled yet — enroll one under Certificates first.`}),b.agentLabel&&(0,N.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:b.agentLabel})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Largest request body (MiB)`}),(0,N.jsx)(`input`,{type:`number`,value:h,onChange:e=>{_(e.target.value),x(e=>({...e,maxBody:void 0}))},disabled:w.isPending,min:sl.min,max:sl.max,className:`w-40 rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono focus:outline-none focus:border-cyan-400 disabled:opacity-50`}),(0,N.jsx)(`p`,{className:`text-xs text-zinc-500 mt-1`,children:`Larger uploads are rejected with 413. Raise it for apps that accept big files.`}),b.maxBody&&(0,N.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:b.maxBody})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:[`Description `,(0,N.jsx)(`span`,{className:`text-zinc-600`,children:`(optional)`})]}),(0,N.jsx)(`input`,{type:`text`,value:l,onChange:e=>u(e.target.value),disabled:w.isPending,placeholder:`My web application`,maxLength:200,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 placeholder:text-zinc-600 focus:outline-none focus:border-cyan-400 disabled:opacity-50`})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-2`,children:`Access`}),(0,N.jsx)(`div`,{className:`space-y-2`,children:ul.map(e=>(0,N.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,N.jsx)(`input`,{type:`radio`,name:`accessMode`,value:e.value,checked:d===e.value,onChange:e=>f(e.target.value),disabled:w.isPending,className:`mt-1 text-cyan-500 focus:ring-cyan-500 bg-zinc-800 border-zinc-700`}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`span`,{className:`text-sm text-zinc-200`,children:e.label}),(0,N.jsx)(`p`,{className:`text-xs text-zinc-500`,children:e.desc})]})]},e.value))})]}),S&&(0,N.jsx)(`div`,{className:`rounded bg-red-500/10 border border-red-500/20 px-3 py-2 text-sm text-red-400`,children:S}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(`button`,{type:`submit`,disabled:w.isPending,className:`flex items-center gap-2 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50 disabled:cursor-not-allowed`,children:w.isPending?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(V,{size:14,className:`animate-spin`}),`Setting up tunnel...`]}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(ta,{size:14}),`Add Tunnel`]})}),(0,N.jsx)(`button`,{type:`button`,onClick:t,disabled:w.isPending,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Cancel`})]})]})]})}function hl({tunnel:e,onConfirm:t,onCancel:n,isPending:r}){return(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:(0,N.jsxs)(`div`,{className:`bg-zinc-900 border border-zinc-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl`,children:[(0,N.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:`Delete Tunnel`}),(0,N.jsxs)(`p`,{className:`text-zinc-400 text-sm mb-6`,children:[`Are you sure you want to delete`,` `,(0,N.jsx)(`span`,{className:`text-cyan-400 font-mono`,children:e.fqdn}),`? This will remove the nginx configuration and TLS certificate mapping.`]}),(0,N.jsxs)(`div`,{className:`flex items-center justify-end gap-3`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:n,disabled:r,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,onClick:t,disabled:r,className:`flex items-center gap-2 rounded bg-red-600 px-4 py-2 text-sm font-semibold text-white hover:bg-red-500 disabled:opacity-50`,children:r?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(V,{size:14,className:`animate-spin`}),`Deleting...`]}):`Delete`})]})]})})}function gl({tunnel:e,onConfirm:t,onCancel:n,isPending:r}){let{agents:i,isLoading:a}=pl(),[o,s]=(0,g.useState)(e.agentLabel||``),[c,l]=(0,g.useState)(e.accessMode||`restricted`),u=ll(e),[d,f]=(0,g.useState)(String(u)),p=cl(d),m={};o&&o!==e.agentLabel&&(m.agentLabel=o),c!==(e.accessMode||`restricted`)&&(m.accessMode=c),!p&&Number(d)!==u&&(m.maxBodySizeMb=Number(d));let h=Object.keys(m).length>0;return(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:(0,N.jsxs)(`div`,{className:`bg-zinc-900 border border-zinc-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl`,children:[(0,N.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-1`,children:`Edit Tunnel`}),(0,N.jsx)(`p`,{className:`text-cyan-400 font-mono text-sm mb-5`,children:e.fqdn}),(0,N.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Agent`}),(0,N.jsxs)(`select`,{value:o,onChange:e=>s(e.target.value),disabled:r||a,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono focus:outline-none focus:border-cyan-400 disabled:opacity-50`,children:[!e.agentLabel&&(0,N.jsx)(`option`,{value:``,children:`Unassigned — select an agent`}),i.map(e=>(0,N.jsx)(`option`,{value:e,children:e},e))]}),m.agentLabel&&(0,N.jsxs)(`p`,{className:`text-xs text-zinc-500 mt-1`,children:[e.agentLabel?`Both agents pick`:`${m.agentLabel} picks`,` the change up within 30 seconds.`]}),(0,N.jsx)(`label`,{className:`block text-xs text-zinc-400 mt-4 mb-2`,children:`Access`}),(0,N.jsx)(`div`,{className:`space-y-2`,children:ul.map(e=>(0,N.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,N.jsx)(`input`,{type:`radio`,name:`editAccessMode`,value:e.value,checked:c===e.value,onChange:e=>l(e.target.value),disabled:r,className:`mt-1 text-cyan-500 focus:ring-cyan-500 bg-zinc-800 border-zinc-700`}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`span`,{className:`text-sm text-zinc-200`,children:e.label}),(0,N.jsx)(`p`,{className:`text-xs text-zinc-500`,children:e.desc})]})]},e.value))}),(0,N.jsx)(`label`,{className:`block text-xs text-zinc-400 mt-4 mb-1`,children:`Largest request body (MiB)`}),(0,N.jsx)(`input`,{type:`number`,value:d,onChange:e=>f(e.target.value),disabled:r,min:sl.min,max:sl.max,className:`w-40 rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono focus:outline-none focus:border-cyan-400 disabled:opacity-50`}),p&&(0,N.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:p}),(0,N.jsxs)(`div`,{className:`flex items-center justify-end gap-3 mt-6`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:n,disabled:r,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>t(m),disabled:r||!h||!!p,className:`flex items-center gap-2 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:r?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(V,{size:14,className:`animate-spin`}),`Saving...`]}):`Save`})]})]})})}function _l({tunnel:e}){return(0,N.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full bg-cyan-500/10 text-cyan-400`,title:`Internal tunnel of an agent-hosted plugin: no hostname, no certificate, reachable only by the panel's forwarder`,children:[`plugin:`,e.pluginRoute||`?`]})}function vl({tunnel:e}){return e.agentLabel?(0,N.jsx)(`span`,{className:`text-sm text-zinc-300 font-mono`,children:e.agentLabel}):(0,N.jsx)(`span`,{className:`inline-block px-2 py-0.5 rounded text-xs bg-red-500/10 text-red-400`,title:`No agent carries this tunnel. Move it to an agent to bring it back.`,children:`unassigned`})}function yl({tunnels:e,onDelete:t,onToggle:n,onEdit:r}){return(0,N.jsx)(`div`,{className:`hidden md:block overflow-x-auto`,children:(0,N.jsxs)(`table`,{className:`w-full`,children:[(0,N.jsx)(`thead`,{children:(0,N.jsxs)(`tr`,{className:`border-b border-zinc-700`,children:[(0,N.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Status`}),(0,N.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Subdomain`}),(0,N.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`FQDN`}),(0,N.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Port`}),(0,N.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Agent`}),(0,N.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Access`}),(0,N.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Body limit`}),(0,N.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Description`}),(0,N.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Created`}),(0,N.jsx)(`th`,{className:`text-right text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Actions`})]})}),(0,N.jsx)(`tbody`,{children:e.map(e=>{let i=e.enabled!==!1,a=e.exposure===`internal`;return(0,N.jsxs)(`tr`,{className:`border-b border-zinc-700 ${i?`bg-zinc-800/50`:`bg-zinc-800/20 opacity-60`}`,children:[(0,N.jsx)(`td`,{className:`py-3 px-4`,children:(0,N.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full border ${i?`text-green-400 bg-green-500/10 border-green-500/20`:`text-zinc-500 bg-zinc-800 border-zinc-700`}`,children:i?`active`:`disabled`})}),(0,N.jsx)(`td`,{className:`py-3 px-4 text-sm text-zinc-200 font-mono`,children:a?(0,N.jsx)(_l,{tunnel:e}):e.subdomain}),(0,N.jsx)(`td`,{className:`py-3 px-4 text-sm`,children:a?(0,N.jsx)(`span`,{className:`text-zinc-500`,children:`relay loopback only`}):(0,N.jsxs)(`a`,{href:`https://${e.fqdn}`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 ${i?`text-cyan-400 hover:text-cyan-300`:`text-zinc-500`}`,children:[e.fqdn,(0,N.jsx)(Ei,{size:12})]})}),(0,N.jsx)(`td`,{className:`py-3 px-4 text-sm text-zinc-200 font-mono`,children:e.port}),(0,N.jsx)(`td`,{className:`py-3 px-4`,children:(0,N.jsx)(vl,{tunnel:e})}),(0,N.jsxs)(`td`,{className:`py-3 px-4 text-sm`,children:[a&&(0,N.jsx)(`span`,{className:`inline-block px-2 py-0.5 rounded text-xs bg-zinc-700/60 text-zinc-300`,children:`Internal`}),e.type!==`panel`&&!a&&(0,N.jsx)(`span`,{className:`inline-block px-2 py-0.5 rounded text-xs ${e.accessMode===`public`?`bg-green-500/10 text-green-400`:e.accessMode===`authenticated`?`bg-blue-500/10 text-blue-400`:`bg-orange-500/10 text-orange-400`}`,children:e.accessMode===`public`?`Public`:e.accessMode===`authenticated`?`All Users`:`Restricted`})]}),(0,N.jsx)(`td`,{className:`py-3 px-4 text-sm text-zinc-400 font-mono`,children:e.type===`panel`?`—`:`${ll(e)} MiB`}),(0,N.jsx)(`td`,{className:`py-3 px-4 text-sm text-zinc-400`,children:e.description||`—`}),(0,N.jsx)(`td`,{className:`py-3 px-4 text-sm text-zinc-500`,children:il(e.createdAt)}),(0,N.jsx)(`td`,{className:`py-3 px-4 text-right`,children:a?(0,N.jsx)(`span`,{className:`text-xs text-zinc-500`,title:`Managed with the plugin's hosting`,children:`managed by plugin hosting`}):(0,N.jsxs)(`div`,{className:`inline-flex items-center gap-2`,children:[e.type!==`panel`&&(0,N.jsxs)(`button`,{type:`button`,onClick:()=>r(e),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600`,title:`Agent, access mode, body limit`,children:[(0,N.jsx)(da,{size:12}),`Edit`]}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs hover:bg-zinc-600 ${i?`text-yellow-400`:`text-green-400`}`,title:i?`Disable tunnel`:`Enable tunnel`,children:[(0,N.jsx)(ra,{size:12}),i?`Disable`:`Enable`]}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>t(e),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-red-400 hover:bg-red-600/20 hover:text-red-300`,children:[(0,N.jsx)(ba,{size:12}),`Delete`]})]})})]},e.id)})})]})})}function bl({tunnels:e,onDelete:t,onToggle:n,onEdit:r}){return(0,N.jsx)(`div`,{className:`md:hidden space-y-3`,children:e.map(e=>{let i=e.enabled!==!1,a=e.exposure===`internal`;return(0,N.jsxs)(`div`,{className:`border border-zinc-700 rounded-lg p-4 ${i?`bg-zinc-800/50`:`bg-zinc-800/20 opacity-60`}`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full border ${i?`text-green-400 bg-green-500/10 border-green-500/20`:`text-zinc-500 bg-zinc-800 border-zinc-700`}`,children:i?`active`:`disabled`}),(0,N.jsx)(`span`,{className:`text-sm font-semibold text-zinc-200 font-mono`,children:a?(0,N.jsx)(_l,{tunnel:e}):e.subdomain})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.type!==`panel`&&!a&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:`text-xs text-zinc-300`,title:`Agent, access mode, body limit`,children:(0,N.jsx)(da,{size:14})}),!a&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:`text-xs ${i?`text-yellow-400`:`text-green-400`}`,children:(0,N.jsx)(ra,{size:14})}),!a&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>t(e),className:`inline-flex items-center gap-1 text-xs text-red-400 hover:text-red-300`,children:(0,N.jsx)(ba,{size:12})})]})]}),a?(0,N.jsx)(`p`,{className:`text-sm text-zinc-500 mb-1`,children:`Relay loopback only — managed by plugin hosting`}):(0,N.jsxs)(`a`,{href:`https://${e.fqdn}`,target:`_blank`,rel:`noopener noreferrer`,className:`text-sm inline-flex items-center gap-1 mb-1 ${i?`text-cyan-400 hover:text-cyan-300`:`text-zinc-500`}`,children:[e.fqdn,(0,N.jsx)(Ei,{size:12})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-4 text-xs text-zinc-500 mt-2`,children:[(0,N.jsxs)(`span`,{children:[`Port: `,(0,N.jsx)(`span`,{className:`text-zinc-300 font-mono`,children:e.port})]}),(0,N.jsxs)(`span`,{children:[`Agent: `,(0,N.jsx)(vl,{tunnel:e})]}),(0,N.jsx)(`span`,{children:il(e.createdAt)})]}),e.description&&(0,N.jsx)(`p`,{className:`text-xs text-zinc-400 mt-2`,children:e.description})]},e.id)})})}function xl(){let e=R(),t=P(),n=G(),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(null),l=F({queryKey:[`tunnels`],queryFn:()=>e.getTunnels(),refetchInterval:1e4}),u=F({queryKey:[`tunnel-agent-config`],queryFn:()=>e.getTunnelAgentConfig()}).data?.domain,d=I({mutationFn:t=>e.deleteTunnel(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`tunnels`]}),n(`Tunnel ${a.fqdn} deleted`),o(null)},onError:e=>{n(K(e),`error`),o(null)}}),f=I({mutationFn:({id:t,enabled:n})=>e.updateTunnel(t,{enabled:n}),onSuccess:e=>{t.invalidateQueries({queryKey:[`tunnels`]});let r=e.tunnel;n(`Tunnel ${r.fqdn} ${r.enabled?`enabled`:`disabled`}`)},onError:e=>{n(K(e),`error`)}}),p=I({mutationFn:({id:t,changes:n})=>e.updateTunnel(t,n),onSuccess:e=>{t.invalidateQueries({queryKey:[`tunnels`]}),n(`Tunnel ${e.tunnel.fqdn} updated`),c(null)},onError:e=>{n(K(e),`error`),c(null)}}),m=(0,g.useCallback)(e=>{c(e)},[]),h=(0,g.useCallback)(e=>{o(e)},[]),_=(0,g.useCallback)(e=>{let t=e.enabled!==!1;f.mutate({id:e.id,enabled:!t})},[f]),v=(0,g.useCallback)(()=>{a&&d.mutate(a.id)},[a,d]),y=l.data?.tunnels||[];return(0,N.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,N.jsxs)(`div`,{className:`mb-6 flex items-center justify-between`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Tunnels`}),(0,N.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`Manage reverse tunnel configurations`})]}),!r&&(0,N.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`flex items-center gap-2 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500`,children:[(0,N.jsx)(ta,{size:14}),`Add Tunnel`]})]}),r&&u&&(0,N.jsx)(ml,{domain:u,onClose:()=>i(!1)}),l.isLoading?(0,N.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:3}).map((e,t)=>(0,N.jsx)(`div`,{className:`h-16 animate-pulse rounded-lg bg-zinc-900 border border-zinc-800`},t))}):l.isError?(0,N.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,N.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Failed to load tunnels`})}):y.length===0?(0,N.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-12 text-center`,children:[(0,N.jsx)(Zi,{size:32,className:`mx-auto text-zinc-600 mb-3`}),(0,N.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:`No tunnels yet. Add your first tunnel to get started.`})]}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(yl,{tunnels:y,onDelete:h,onToggle:_,onEdit:m}),(0,N.jsx)(bl,{tunnels:y,onDelete:h,onToggle:_,onEdit:m})]}),s&&(0,N.jsx)(gl,{tunnel:s,onConfirm:e=>p.mutate({id:s.id,changes:e}),onCancel:()=>c(null),isPending:p.isPending}),a&&(0,N.jsx)(hl,{tunnel:a,onConfirm:v,onCancel:()=>o(null),isPending:d.isPending})]})}function Sl({hasDomain:e}){let t=R(),n=G(),r=P(),i=F({queryKey:[`settings-2fa`],queryFn:()=>t.get2faStatus()}),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)(``),[d,f]=(0,g.useState)(!1),[p,m]=(0,g.useState)(``),[h,_]=(0,g.useState)(!1),v=i.data||{enabled:!1,setupComplete:!1},y=I({mutationFn:()=>t.setup2fa(),onSuccess:e=>o(e)}),b=I({mutationFn:e=>t.confirm2fa(e),onSuccess:()=>{r.invalidateQueries(),o(null),c(``),n(`Two-factor authentication enabled`)}}),x=I({mutationFn:e=>t.disable2fa(e),onSuccess:()=>{r.invalidateQueries(),u(``),n(`Two-factor authentication disabled`)}}),S=I({mutationFn:e=>t.triggerPanelUpdate(e),onSuccess:()=>{n(`Update initiated. The panel will restart shortly.`),m(``),_(!1)},onError:e=>n(K(e),`error`)}),C=/^\d+\.\d+\.\d+$/.test(p);function w(){a?.manualKey&&navigator.clipboard.writeText(a.manualKey).then(()=>{f(!0),setTimeout(()=>f(!1),2e3)},()=>{n(`Failed to copy to clipboard`,`error`)})}function T(e){e.preventDefault(),s.length===6&&b.mutate(s)}function E(e){e.preventDefault(),l.length===6&&x.mutate(l)}if(i.isLoading)return(0,N.jsx)(`div`,{className:`p-6`,children:(0,N.jsx)(`div`,{className:`mx-auto h-6 w-6 animate-spin rounded-full border-2 border-zinc-600 border-t-cyan-400`})});if(i.isError)return(0,N.jsxs)(`div`,{className:`mx-auto max-w-2xl p-6`,children:[(0,N.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Settings`}),(0,N.jsx)(`p`,{className:`mt-4 text-sm text-red-400`,children:`Failed to load settings. Please try again.`})]});let D=b.error?.message,ee=x.error?.message,te=y.error?.message;return(0,N.jsxs)(`div`,{className:`mx-auto max-w-2xl p-6`,children:[(0,N.jsxs)(`div`,{className:`mb-6`,children:[(0,N.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Settings`}),(0,N.jsx)(`p`,{className:`mt-1 text-sm text-zinc-500`,children:`Configure panel security settings.`})]}),(0,N.jsxs)(`div`,{className:`rounded-lg border border-zinc-800 bg-zinc-900 p-6`,children:[(0,N.jsxs)(`div`,{className:`mb-4 flex items-center gap-3`,children:[(0,N.jsx)(ma,{className:`h-5 w-5 text-cyan-400`}),(0,N.jsx)(`h2`,{className:`text-lg font-bold text-white`,children:`Two-Factor Authentication`}),v.enabled&&(0,N.jsx)(`span`,{className:`rounded-full border border-green-500/20 bg-green-500/10 px-2 py-0.5 text-xs text-green-400`,children:`Enabled`})]}),!v.enabled&&!a&&(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{className:`mb-4 text-sm text-zinc-400`,children:`Add a second layer of protection to the admin panel. When enabled, you will need both your mTLS certificate and a TOTP code from your authenticator app to access the panel.`}),!e&&(0,N.jsxs)(`div`,{className:`mb-4 flex items-start gap-2 rounded-lg border border-yellow-500/20 bg-yellow-500/5 p-3`,children:[(0,N.jsx)(xa,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-yellow-400`}),(0,N.jsx)(`p`,{className:`text-sm text-yellow-400`,children:`A domain must be configured before enabling 2FA. Enabling 2FA disables IP:9292 access.`})]}),te&&(0,N.jsx)(`p`,{className:`mb-3 text-sm text-red-400`,children:te}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>y.mutate(),disabled:!e||y.isPending,className:`rounded-lg bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:cursor-not-allowed disabled:opacity-50`,children:y.isPending?`Setting up...`:`Enable Two-Factor Authentication`}),e&&(0,N.jsx)(`p`,{className:`mt-3 text-xs text-zinc-600`,children:`This will disable IP:9292 access. The panel will only be accessible via domain.`})]}),!v.enabled&&a&&(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{className:`mb-4 text-sm text-zinc-400`,children:`Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)`}),(0,N.jsx)(`div`,{className:`mb-4 flex justify-center`,children:(0,N.jsx)(`div`,{className:`rounded-lg bg-zinc-950 p-4`,children:(0,N.jsx)(is,{value:a.uri,size:200,bgColor:`transparent`,fgColor:`#ffffff`})})}),(0,N.jsx)(`p`,{className:`mb-2 text-sm text-zinc-400`,children:`Or enter this code manually:`}),(0,N.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 rounded-lg bg-zinc-950 px-4 py-3`,children:[(0,N.jsx)(`code`,{className:`flex-1 font-mono text-sm tracking-wider text-cyan-400`,children:a.manualKey?.replace(/(.{4})/g,`$1 `).trim()}),(0,N.jsx)(`button`,{type:`button`,onClick:w,className:`text-zinc-500 hover:text-zinc-300`,title:`Copy secret`,children:d?(0,N.jsx)(ui,{size:16,className:`text-green-400`}):(0,N.jsx)(xi,{size:16})})]}),(0,N.jsxs)(`form`,{onSubmit:T,className:`space-y-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`mb-1 block text-sm text-zinc-400`,children:`Enter the code from your authenticator to confirm`}),(0,N.jsx)(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,value:s,onChange:e=>c(e.target.value.replace(/\D/g,``).slice(0,6)),placeholder:`000000`,maxLength:6,className:`w-full rounded-lg border border-zinc-700 bg-zinc-950 px-3 py-2 font-mono text-center text-lg tracking-[0.2em] text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),D&&(0,N.jsx)(`p`,{className:`text-sm text-red-400`,children:D}),(0,N.jsxs)(`div`,{className:`flex gap-3`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>{o(null),c(``),b.reset()},className:`flex-1 rounded-lg border border-zinc-700 px-4 py-2 text-sm text-zinc-400 hover:text-white`,children:`Cancel`}),(0,N.jsx)(`button`,{type:`submit`,disabled:b.isPending||s.length!==6,className:`flex-1 rounded-lg bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:b.isPending?`Confirming...`:`Confirm & Enable`})]})]})]}),v.enabled&&(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{className:`mb-4 text-sm text-zinc-400`,children:`Two-factor authentication is active. The panel requires both your mTLS certificate and a TOTP code.`}),(0,N.jsx)(`div`,{className:`mb-4 rounded-lg border border-zinc-700 bg-zinc-950 p-3`,children:(0,N.jsxs)(`p`,{className:`text-xs text-zinc-500`,children:[`Recovery: if you lose access to your authenticator, run`,` `,(0,N.jsx)(`code`,{className:`text-zinc-400`,children:`sudo lamaste-reset-admin`}),` on the server via the DigitalOcean console. This will reset admin auth to P12 and disable 2FA.`]})}),(0,N.jsxs)(`form`,{onSubmit:E,className:`space-y-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`mb-1 block text-sm text-zinc-400`,children:`Enter a TOTP code to disable 2FA`}),(0,N.jsx)(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,value:l,onChange:e=>u(e.target.value.replace(/\D/g,``).slice(0,6)),placeholder:`000000`,maxLength:6,className:`w-full rounded-lg border border-zinc-700 bg-zinc-950 px-3 py-2 font-mono text-center text-lg tracking-[0.2em] text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),ee&&(0,N.jsx)(`p`,{className:`text-sm text-red-400`,children:ee}),(0,N.jsx)(`button`,{type:`submit`,disabled:x.isPending||l.length!==6,className:`rounded-lg border border-red-500/30 bg-red-500/10 px-4 py-2 text-sm font-semibold text-red-400 hover:bg-red-500/20 disabled:opacity-50`,children:x.isPending?`Disabling...`:`Disable Two-Factor Authentication`})]})]})]}),(0,N.jsxs)(`div`,{className:`mt-6 rounded-lg border border-zinc-800 bg-zinc-900 p-6`,children:[(0,N.jsxs)(`div`,{className:`mb-4 flex items-center gap-3`,children:[(0,N.jsx)(ia,{className:`h-5 w-5 text-cyan-400`}),(0,N.jsx)(`h2`,{className:`text-lg font-bold text-white`,children:`Panel Update`})]}),(0,N.jsx)(`p`,{className:`mb-4 text-sm text-zinc-400`,children:`Trigger an update of the panel server to a specific version. The server will restart automatically after the update completes.`}),(0,N.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,N.jsxs)(`div`,{className:`flex-1`,children:[(0,N.jsx)(`label`,{className:`mb-1 block text-sm text-zinc-400`,htmlFor:`update-version`,children:`Version`}),(0,N.jsx)(`input`,{id:`update-version`,type:`text`,value:p,onChange:e=>m(e.target.value.trim()),placeholder:`1.0.43`,className:`w-full rounded-lg border border-zinc-700 bg-zinc-950 px-3 py-2 text-sm text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none font-mono`})]}),(0,N.jsx)(`button`,{type:`button`,disabled:!C||S.isPending,onClick:()=>_(!0),className:`rounded-lg bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:cursor-not-allowed disabled:opacity-50`,children:`Update Panel`})]}),!C&&p.length>0&&(0,N.jsx)(`p`,{className:`mt-2 text-xs text-red-400`,children:`Version must be in semver format (e.g. 1.0.43)`}),S.error&&(0,N.jsx)(`p`,{className:`mt-2 text-sm text-red-400`,children:S.error.message}),h&&(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,N.jsxs)(`div`,{className:`w-full max-w-sm rounded-xl border border-zinc-700 bg-zinc-900 p-6 shadow-xl`,children:[(0,N.jsxs)(`div`,{className:`mb-4 flex items-center gap-2`,children:[(0,N.jsx)(xa,{className:`h-5 w-5 text-amber-400`}),(0,N.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:`Confirm Update`})]}),(0,N.jsxs)(`p`,{className:`mb-4 text-sm text-zinc-400`,children:[`This will update the panel server to version`,` `,(0,N.jsx)(`strong`,{className:`text-white`,children:p}),` and restart the service. The panel will be unavailable for 1-2 minutes.`]}),(0,N.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>_(!1),className:`rounded-lg border border-zinc-700 px-4 py-2 text-sm text-zinc-400 hover:text-white`,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,disabled:S.isPending,onClick:()=>S.mutate({version:p}),className:`rounded-lg bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:S.isPending?`Updating...`:`Update Now`})]})]})})]})]})}function Cl({onClose:e}){let t=R(),n=P(),r=G(),[i,a]=(0,g.useState)({id:crypto.randomUUID(),label:``,provider:`digitalocean-spaces`,region:``,bucket:``,endpoint:``,accessKey:``,secretKey:``}),o=I({mutationFn:e=>t.registerStorageServer(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`storage-servers`]}),r(`Storage server registered`),e()},onError:e=>r(K(e),`error`)}),s=(e,t)=>a(n=>({...n,[e]:t})),c=i.label&&i.region&&i.bucket&&i.endpoint&&i.accessKey&&i.secretKey;return(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,N.jsxs)(`div`,{className:`w-full max-w-lg rounded-xl bg-zinc-900 border border-zinc-700 p-6 shadow-xl`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,N.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:`Register Storage Server`}),(0,N.jsx)(`button`,{type:`button`,onClick:e,className:`text-zinc-400 hover:text-white`,children:(0,N.jsx)(ka,{size:20})})]}),(0,N.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),o.mutate(i)},className:`space-y-4`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Label`}),(0,N.jsx)(`input`,{type:`text`,value:i.label,onChange:e=>s(`label`,e.target.value),placeholder:`my-storage`,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),(0,N.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Provider`}),(0,N.jsxs)(`select`,{value:i.provider,onChange:e=>s(`provider`,e.target.value),className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 focus:border-cyan-500 focus:outline-none`,children:[(0,N.jsx)(`option`,{value:`digitalocean-spaces`,children:`DigitalOcean Spaces`}),(0,N.jsx)(`option`,{value:`s3`,children:`Amazon S3`})]})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Region`}),(0,N.jsx)(`input`,{type:`text`,value:i.region,onChange:e=>s(`region`,e.target.value),placeholder:`nyc3`,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Bucket`}),(0,N.jsx)(`input`,{type:`text`,value:i.bucket,onChange:e=>s(`bucket`,e.target.value),placeholder:`my-bucket`,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Endpoint URL`}),(0,N.jsx)(`input`,{type:`url`,value:i.endpoint,onChange:e=>s(`endpoint`,e.target.value),placeholder:`https://nyc3.digitaloceanspaces.com`,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Access Key`}),(0,N.jsx)(`input`,{type:`password`,value:i.accessKey,onChange:e=>s(`accessKey`,e.target.value),className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono focus:border-cyan-500 focus:outline-none`})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Secret Key`}),(0,N.jsx)(`input`,{type:`password`,value:i.secretKey,onChange:e=>s(`secretKey`,e.target.value),className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono focus:border-cyan-500 focus:outline-none`})]}),(0,N.jsx)(`div`,{className:`rounded bg-amber-500/10 border border-amber-500/20 px-3 py-2`,children:(0,N.jsx)(`p`,{className:`text-xs text-amber-300`,children:`Credentials are encrypted at rest using AES-256-GCM. They never leave the server.`})}),(0,N.jsxs)(`div`,{className:`flex justify-end gap-3 pt-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:e,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:`Cancel`}),(0,N.jsxs)(`button`,{type:`submit`,disabled:!c||o.isPending,className:`rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:[o.isPending?(0,N.jsx)(V,{size:14,className:`animate-spin inline mr-1`}):null,`Register`]})]})]})]})})}function wl({servers:e,onClose:t}){let n=R(),r=P(),i=G(),[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(e[0]?.id||``),l=F({queryKey:[`plugins`],queryFn:()=>n.getPlugins()}),u=I({mutationFn:e=>n.createStorageBinding(e),onSuccess:()=>{r.invalidateQueries({queryKey:[`storage-bindings`]}),i(`Plugin bound to storage`),t()},onError:e=>i(K(e),`error`)}),d=l.data?.plugins||[];return(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,N.jsxs)(`div`,{className:`w-full max-w-md rounded-xl bg-zinc-900 border border-zinc-700 p-6 shadow-xl`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,N.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:`Bind Plugin to Storage`}),(0,N.jsx)(`button`,{type:`button`,onClick:t,className:`text-zinc-400 hover:text-white`,children:(0,N.jsx)(ka,{size:20})})]}),(0,N.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),u.mutate({pluginName:a,storageServerId:s})},className:`space-y-4`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Plugin`}),(0,N.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value),className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 focus:border-cyan-500 focus:outline-none`,children:[(0,N.jsx)(`option`,{value:``,children:`Select a plugin...`}),d.map(e=>(0,N.jsx)(`option`,{value:e.name,children:e.displayName||e.name},e.name))]})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Storage Server`}),(0,N.jsx)(`select`,{value:s,onChange:e=>c(e.target.value),className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 focus:border-cyan-500 focus:outline-none`,children:e.map(e=>(0,N.jsxs)(`option`,{value:e.id,children:[e.label,` (`,e.provider,` / `,e.region,`)`]},e.id))})]}),(0,N.jsxs)(`div`,{className:`flex justify-end gap-3 pt-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:t,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:`Cancel`}),(0,N.jsxs)(`button`,{type:`submit`,disabled:!a||!s||u.isPending,className:`rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:[u.isPending?(0,N.jsx)(V,{size:14,className:`animate-spin inline mr-1`}):null,`Bind`]})]})]})]})})}function Tl(){let e=R(),t=P(),n=G(),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)(!1),[s,c]=(0,g.useState)(null),[l,u]=(0,g.useState)(null),d=F({queryKey:[`storage-servers`],queryFn:()=>e.getStorageServers(),refetchInterval:1e4}),f=F({queryKey:[`storage-bindings`],queryFn:()=>e.getStorageBindings(),refetchInterval:1e4}),p=I({mutationFn:t=>e.deleteStorageServer(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`storage-servers`]}),t.invalidateQueries({queryKey:[`storage-bindings`]}),n(`Storage server removed`),c(null)},onError:e=>{n(K(e),`error`),c(null)}}),m=I({mutationFn:t=>e.deleteStorageBinding(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`storage-bindings`]}),n(`Plugin unbound from storage`),u(null)},onError:e=>{n(K(e),`error`),u(null)}}),h=d.data?.servers||[],_=f.data?.bindings||[];return(0,N.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,N.jsxs)(`div`,{className:`mb-6`,children:[(0,N.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Storage`}),(0,N.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`Manage S3-compatible storage servers and bind them to plugins.`})]}),(0,N.jsxs)(`div`,{className:`mb-8`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,N.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,N.jsx)(Ii,{size:18,className:`text-cyan-400`}),`Storage Servers`]}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`flex items-center gap-2 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500`,children:[(0,N.jsx)(ta,{size:14}),`Register Server`]})]}),d.isLoading?(0,N.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:2}).map((e,t)=>(0,N.jsx)(`div`,{className:`h-14 animate-pulse rounded-lg bg-zinc-900 border border-zinc-800`},t))}):d.isError?(0,N.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-2 text-red-400 text-sm`,children:[(0,N.jsx)(hi,{size:16}),`Failed to load storage servers`]})}):h.length===0?(0,N.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-8 text-center`,children:[(0,N.jsx)(Ii,{size:32,className:`mx-auto text-zinc-600 mb-3`}),(0,N.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:`No storage servers registered. Register one to enable plugin storage.`})]}):(0,N.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-zinc-800`,children:(0,N.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,N.jsx)(`thead`,{children:(0,N.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-900`,children:[(0,N.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Label`}),(0,N.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Provider`}),(0,N.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400 hidden md:table-cell`,children:`Region`}),(0,N.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400 hidden lg:table-cell`,children:`Bucket`}),(0,N.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400 hidden lg:table-cell`,children:`Registered`}),(0,N.jsx)(`th`,{className:`px-4 py-3 text-right text-xs font-medium uppercase text-zinc-400`,children:`Actions`})]})}),(0,N.jsx)(`tbody`,{children:h.map(e=>(0,N.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-800`,children:[(0,N.jsx)(`td`,{className:`px-4 py-3 text-zinc-200 font-semibold`,children:e.label}),(0,N.jsx)(`td`,{className:`px-4 py-3 text-zinc-400`,children:e.provider}),(0,N.jsx)(`td`,{className:`px-4 py-3 text-zinc-400 hidden md:table-cell`,children:e.region}),(0,N.jsx)(`td`,{className:`px-4 py-3 text-zinc-400 font-mono text-xs hidden lg:table-cell`,children:e.bucket}),(0,N.jsx)(`td`,{className:`px-4 py-3 text-zinc-500 hidden lg:table-cell`,children:e.registeredAt?_r(e.registeredAt):`—`}),(0,N.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,N.jsx)(`button`,{type:`button`,onClick:()=>c(e),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-zinc-300 hover:bg-red-600/20 hover:text-red-400`,title:`Remove server`,children:(0,N.jsx)(ba,{size:12})})})]},e.id))})]})})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,N.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,N.jsx)(Wi,{size:18,className:`text-cyan-400`}),`Plugin Bindings`]}),h.length>0&&(0,N.jsxs)(`button`,{type:`button`,onClick:()=>o(!0),className:`flex items-center gap-2 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500`,children:[(0,N.jsx)(ta,{size:14}),`Bind Plugin`]})]}),f.isLoading?(0,N.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:2}).map((e,t)=>(0,N.jsx)(`div`,{className:`h-14 animate-pulse rounded-lg bg-zinc-900 border border-zinc-800`},t))}):f.isError?(0,N.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-2 text-red-400 text-sm`,children:[(0,N.jsx)(hi,{size:16}),`Failed to load bindings`]})}):_.length===0?(0,N.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-8 text-center`,children:[(0,N.jsx)(Wi,{size:32,className:`mx-auto text-zinc-600 mb-3`}),(0,N.jsxs)(`p`,{className:`text-zinc-400 text-sm`,children:[`No plugins bound to storage.`,` `,h.length===0?`Register a storage server first.`:`Use the button above to bind one.`]})]}):(0,N.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-zinc-800`,children:(0,N.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,N.jsx)(`thead`,{children:(0,N.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-900`,children:[(0,N.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Plugin`}),(0,N.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Storage Server`}),(0,N.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400 hidden md:table-cell`,children:`Bound`}),(0,N.jsx)(`th`,{className:`px-4 py-3 text-right text-xs font-medium uppercase text-zinc-400`,children:`Actions`})]})}),(0,N.jsx)(`tbody`,{children:_.map(e=>{let t=h.find(t=>t.id===e.storageServerId);return(0,N.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-800`,children:[(0,N.jsx)(`td`,{className:`px-4 py-3 text-zinc-200 font-semibold`,children:e.pluginName}),(0,N.jsx)(`td`,{className:`px-4 py-3 text-zinc-400`,children:t?.label||e.storageServerId.slice(0,8)}),(0,N.jsx)(`td`,{className:`px-4 py-3 text-zinc-500 hidden md:table-cell`,children:e.boundAt?_r(e.boundAt):`—`}),(0,N.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,N.jsx)(`button`,{type:`button`,onClick:()=>u(e.pluginName),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-zinc-300 hover:bg-red-600/20 hover:text-red-400`,title:`Unbind plugin`,children:(0,N.jsx)(wa,{size:12})})})]},e.pluginName)})})]})})]}),r&&(0,N.jsx)(Cl,{onClose:()=>i(!1)}),a&&(0,N.jsx)(wl,{servers:h,onClose:()=>o(!1)}),s&&(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,N.jsxs)(`div`,{className:`w-full max-w-sm rounded-xl border border-zinc-700 bg-zinc-900 p-6 shadow-xl`,children:[(0,N.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-3`,children:`Remove Storage Server`}),(0,N.jsxs)(`p`,{className:`text-sm text-zinc-400 mb-2`,children:[`Are you sure you want to remove`,` `,(0,N.jsx)(`strong`,{className:`text-white`,children:s.label}),`?`]}),(0,N.jsx)(`p`,{className:`text-xs text-amber-400 mb-4`,children:`All plugin bindings to this server will also be removed.`}),(0,N.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>c(null),className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,disabled:p.isPending,onClick:()=>p.mutate(s.id),className:`rounded bg-red-600 px-4 py-2 text-sm font-semibold text-white hover:bg-red-500 disabled:opacity-50`,children:p.isPending?`Removing...`:`Remove`})]})]})}),l&&(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,N.jsxs)(`div`,{className:`w-full max-w-sm rounded-xl border border-zinc-700 bg-zinc-900 p-6 shadow-xl`,children:[(0,N.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-3`,children:`Unbind Plugin`}),(0,N.jsxs)(`p`,{className:`text-sm text-zinc-400 mb-4`,children:[`Remove storage binding for `,(0,N.jsx)(`strong`,{className:`text-white`,children:l}),`?`]}),(0,N.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>u(null),className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,disabled:m.isPending,onClick:()=>m.mutate(l),className:`rounded bg-red-600 px-4 py-2 text-sm font-semibold text-white hover:bg-red-500 disabled:opacity-50`,children:m.isPending?`Unbinding...`:`Unbind`})]})]})})]})}var El=50,Dl={info:`text-cyan-400`,warning:`text-yellow-400`,critical:`text-red-400`};function Ol(){let e=R(),t=P(),n=G(),r=F({queryKey:[`notifications`],queryFn:()=>e.getNotifications({limit:50}),refetchInterval:3e4}),i=I({mutationFn:()=>e.markNotificationsRead({all:!0}),onSuccess:()=>t.invalidateQueries({queryKey:[`notifications`]}),onError:e=>n(K(e),`error`)}),a=r.data?.notifications??[],o=r.data?.unread??0;return(0,N.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-5 mb-6`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,N.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-zinc-300`,children:[(0,N.jsx)(si,{size:14,className:`text-cyan-400`}),` Notifications`,o>0&&(0,N.jsx)(`span`,{className:`rounded-full bg-cyan-500/20 px-2 text-xs text-cyan-400`,children:o})]}),o>0&&(0,N.jsxs)(`button`,{type:`button`,disabled:i.isPending,onClick:()=>i.mutate(),className:`flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1 text-xs text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:[(0,N.jsx)(li,{size:12}),` Mark all read`]})]}),a.length===0?(0,N.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Nothing to report.`}):(0,N.jsx)(`ul`,{className:`space-y-1.5 text-xs`,children:a.map(e=>(0,N.jsxs)(`li`,{className:`flex gap-3 ${e.read?`opacity-60`:``}`,children:[(0,N.jsx)(`span`,{className:`shrink-0 text-zinc-500`,children:new Date(e.at).toLocaleString()}),(0,N.jsx)(`span`,{className:`shrink-0 ${Dl[e.level]??`text-zinc-400`}`,children:e.level}),(0,N.jsx)(`span`,{className:`shrink-0 font-mono text-zinc-500`,children:e.source}),(0,N.jsx)(`span`,{className:`text-zinc-300 break-words`,children:e.message})]},e.id))})]})}function kl(e){return Object.entries(e??{}).map(([e,t])=>`${e}=${typeof t==`object`&&t?JSON.stringify(t):t}`).join(` `)}function Al(){let e=R(),[t,n]=(0,g.useState)(``),[r,i]=(0,g.useState)(``),a={plugin:t.trim()||void 0,action:r.trim()||void 0},o=mr({queryKey:[`audit`,a],queryFn:({pageParam:t})=>e.getAuditLog({...a,limit:El,...t?{before:t}:{}}),initialPageParam:void 0,getNextPageParam:e=>e.entries.length===El?e.entries[e.entries.length-1].id:void 0,refetchInterval:3e4}),s=o.data?.pages.flatMap(e=>e.entries)??[];return(0,N.jsxs)(`div`,{className:`p-6 max-w-5xl mx-auto`,children:[(0,N.jsxs)(`div`,{className:`mb-6`,children:[(0,N.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Audit`}),(0,N.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`What administrators decided and what plugins' hooks reported — metadata only, never a request or response body.`})]}),(0,N.jsx)(Ol,{}),(0,N.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-5`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 mb-4`,children:[(0,N.jsx)(ca,{size:14,className:`text-cyan-400`}),(0,N.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-300 mr-4`,children:`Audit log`}),(0,N.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),placeholder:`plugin`,className:`w-36 rounded bg-zinc-800 border border-zinc-700 px-2 py-1 text-xs text-zinc-300 focus:outline-none focus:border-cyan-400`}),(0,N.jsx)(`input`,{type:`text`,value:r,onChange:e=>i(e.target.value),placeholder:`action, or prefix ending in .`,className:`w-56 rounded bg-zinc-800 border border-zinc-700 px-2 py-1 text-xs text-zinc-300 focus:outline-none focus:border-cyan-400`})]}),o.isError?(0,N.jsxs)(`div`,{className:`flex items-center gap-2 text-red-400 text-sm`,children:[(0,N.jsx)(hi,{size:16}),` Failed to load the audit log`]}):s.length===0?(0,N.jsx)(`p`,{className:`text-xs text-zinc-500`,children:o.isLoading?`Loading…`:`No entries.`}):(0,N.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,N.jsx)(`thead`,{children:(0,N.jsxs)(`tr`,{className:`text-left text-zinc-500`,children:[(0,N.jsx)(`th`,{className:`pb-2 pr-3 font-normal`,children:`When`}),(0,N.jsx)(`th`,{className:`pb-2 pr-3 font-normal`,children:`Action`}),(0,N.jsx)(`th`,{className:`pb-2 pr-3 font-normal`,children:`Actor`}),(0,N.jsx)(`th`,{className:`pb-2 pr-3 font-normal`,children:`Plugin`}),(0,N.jsx)(`th`,{className:`pb-2 font-normal`,children:`Details`})]})}),(0,N.jsx)(`tbody`,{children:s.map(e=>(0,N.jsxs)(`tr`,{className:`border-t border-zinc-800 align-top`,children:[(0,N.jsx)(`td`,{className:`py-1.5 pr-3 whitespace-nowrap text-zinc-500`,children:new Date(e.at).toLocaleString()}),(0,N.jsx)(`td`,{className:`py-1.5 pr-3 font-mono text-cyan-400`,children:e.action}),(0,N.jsx)(`td`,{className:`py-1.5 pr-3 font-mono text-zinc-300`,children:e.actor}),(0,N.jsx)(`td`,{className:`py-1.5 pr-3 font-mono text-zinc-300`,children:e.plugin??``}),(0,N.jsx)(`td`,{className:`py-1.5 font-mono text-zinc-500 break-all`,children:kl(e.details)})]},e.id))})]}),o.hasNextPage&&(0,N.jsx)(`button`,{type:`button`,disabled:o.isFetchingNextPage,onClick:()=>o.fetchNextPage(),className:`mt-3 rounded bg-zinc-700 px-3 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Load older`})]})]})}function X(e,t){return L(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}function jl(e,t){return L(e,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}function Ml(e,t){return L(e,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}function Nl(e,t){let n={method:`DELETE`};return t&&(n.headers={"Content-Type":`application/json`},n.body=JSON.stringify(t)),L(e,n)}function Pl(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))r!=null&&r!==``&&t.set(n,String(r));let n=t.toString();return n?`?${n}`:``}function Fl({force:e=!1,purge:t=!1}={}){return Pl({force:e?`true`:void 0,purge:t?`true`:void 0})}var Il={getUsers:()=>L(`/api/users`),createUser:e=>X(`/api/users`,e),updateUser:(e,t)=>jl(`/api/users/${encodeURIComponent(e)}`,t),deleteUser:e=>Nl(`/api/users/${encodeURIComponent(e)}`),resetTotp:e=>X(`/api/users/${encodeURIComponent(e)}/reset-totp`),getInvitations:()=>L(`/api/invitations`),createInvitation:e=>X(`/api/invitations`,e),revokeInvitation:e=>Nl(`/api/invitations/${encodeURIComponent(e)}`),getSites:()=>L(`/api/sites`),createSite:e=>X(`/api/sites`,e),deleteSite:e=>Nl(`/api/sites/${encodeURIComponent(e)}`),updateSite:(e,t)=>Ml(`/api/sites/${encodeURIComponent(e)}`,t),getSiteFiles:(e,t)=>{let n=t&&t!==`.`?`?path=${encodeURIComponent(t)}`:``;return L(`/api/sites/${encodeURIComponent(e)}/files${n}`)},uploadSiteFiles:(e,t,n)=>{let r=new FormData;for(let e of n)r.append(`files`,e);let i=t&&t!==`.`?`?path=${encodeURIComponent(t)}`:``;return L(`/api/sites/${encodeURIComponent(e)}/files${i}`,{method:`POST`,body:r})},deleteSiteFile:(e,t)=>Nl(`/api/sites/${encodeURIComponent(e)}/files`,{path:t}),verifySiteDns:e=>X(`/api/sites/${encodeURIComponent(e)}/verify-dns`),getCerts:()=>L(`/api/certs`),renewCert:e=>X(`/api/certs/${encodeURIComponent(e)}/renew`),rotateMtls:()=>X(`/api/certs/mtls/rotate`),downloadMtls:async()=>{let e=await fetch(`/api/certs/mtls/download`,{credentials:`same-origin`});if(!e.ok)throw Error(`Download failed`);let t=await e.blob(),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`client.p12`,r.click(),URL.revokeObjectURL(n)},getAuthMode:()=>L(`/api/certs/admin/auth-mode`),getAutoRenewStatus:()=>L(`/api/certs/auto-renew-status`),getAgentCerts:()=>L(`/api/certs/agent`),generateAgentCert:e=>X(`/api/certs/agent`,e),revokeAgentCert:e=>Nl(`/api/certs/agent/${encodeURIComponent(e)}`),createEnrollmentToken:e=>X(`/api/certs/agent/enroll`,e),revokeEnrollmentToken:e=>Nl(`/api/certs/agent/enroll/${encodeURIComponent(e)}`),updateAgentCapabilities:(e,t)=>Ml(`/api/certs/agent/${encodeURIComponent(e)}/capabilities`,{capabilities:t}),updateAgentAllowedSites:(e,t)=>Ml(`/api/certs/agent/${encodeURIComponent(e)}/allowed-sites`,{allowedSites:t}),downloadAgentCert:async e=>{let t=await fetch(`/api/certs/agent/${encodeURIComponent(e)}/download`,{credentials:`same-origin`});if(!t.ok)throw Error(`Download failed`);let n=await t.blob(),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e}.p12`,i.click(),URL.revokeObjectURL(r)},getServices:()=>L(`/api/services`),serviceAction:(e,t)=>X(`/api/services/${encodeURIComponent(e)}/${encodeURIComponent(t)}`),getSystemStats:()=>L(`/api/system/stats`),triggerPanelUpdate:e=>X(`/api/system/update`,e),startLogStream:(e,t)=>{let n=`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}/api/services/${encodeURIComponent(e)}/logs`,r=new WebSocket(n);return r.onmessage=e=>{try{t(JSON.parse(e.data))}catch{t({message:e.data,timestamp:new Date().toISOString()})}},r.onerror=()=>{},r.onclose=()=>{},()=>r.close()},getTicketScopes:()=>L(`/api/tickets/scopes`),createTicketScope:e=>X(`/api/tickets/scopes`,e),deleteTicketScope:e=>Nl(`/api/tickets/scopes/${encodeURIComponent(e)}`),getTicketInstances:()=>L(`/api/tickets/instances`),deleteTicketInstance:e=>Nl(`/api/tickets/instances/${encodeURIComponent(e)}`),getTicketAssignments:()=>L(`/api/tickets/assignments`),createTicketAssignment:e=>X(`/api/tickets/assignments`,e),deleteTicketAssignment:(e,t)=>Nl(`/api/tickets/assignments/${encodeURIComponent(e)}/${encodeURIComponent(t)}`),getTickets:()=>L(`/api/tickets`),revokeTicket:e=>Nl(`/api/tickets/${encodeURIComponent(e)}`),getTicketSessions:()=>L(`/api/tickets/sessions`),killTicketSession:e=>Nl(`/api/tickets/sessions/${encodeURIComponent(e)}`),getPlugins:()=>L(`/api/plugins`),installPlugin:e=>X(`/api/plugins/install`,{packageName:e}),enablePlugin:e=>X(`/api/plugins/${encodeURIComponent(e)}/enable`),disablePlugin:e=>X(`/api/plugins/${encodeURIComponent(e)}/disable`),uninstallPlugin:(e,t={})=>Nl(`/api/plugins/${encodeURIComponent(e)}${Fl(t)}`),getPluginHosting:e=>L(`/api/plugins/${encodeURIComponent(e)}/hosting`),getPluginHostingEligibility:e=>L(`/api/plugins/${encodeURIComponent(e)}/hosting/eligibility`),setPluginHosting:(e,t)=>X(`/api/plugins/${encodeURIComponent(e)}/hosting`,{agentLabel:t}),clearPluginHosting:(e,t={})=>Nl(`/api/plugins/${encodeURIComponent(e)}/hosting${Fl(t)}`),rotatePluginHostingSecret:e=>X(`/api/plugins/${encodeURIComponent(e)}/hosting/rotate-secret`),getPluginRetainedData:e=>L(`/api/plugins/${encodeURIComponent(e)}/retained-data`),purgePluginRetainedData:(e,t)=>Nl(`/api/plugins/${encodeURIComponent(e)}/retained-data${Pl({agentLabel:t})}`),forgetPluginRetainedData:(e,t)=>Nl(`/api/plugins/${encodeURIComponent(e)}/retained-data${Pl({agentLabel:t,forget:`true`})}`),getPluginSettings:e=>L(`/api/plugins/${encodeURIComponent(e)}/settings`),updatePluginSettings:(e,t)=>jl(`/api/plugins/${encodeURIComponent(e)}/settings`,t),getPluginOperations:e=>L(`/api/plugins/${encodeURIComponent(e)}/operations`),getPluginOperation:(e,t)=>L(`/api/plugins/${encodeURIComponent(e)}/operations/${encodeURIComponent(t)}`),getPluginHooks:e=>L(`/api/plugins/${encodeURIComponent(e)}/hooks`),approvePluginHooks:(e,t,n)=>X(`/api/plugins/${encodeURIComponent(e)}/hooks/approve`,{digest:t,...n?{version:n}:{}}),setPluginHooksAutoApprove:(e,t)=>jl(`/api/plugins/${encodeURIComponent(e)}/hooks/auto-approve`,{enabled:t}),updatePlugin:(e,t)=>X(`/api/plugins/${encodeURIComponent(e)}/update`,t?{version:t}:{}),discardPluginUpdate:e=>Nl(`/api/plugins/${encodeURIComponent(e)}/update`),fetchPluginBundle:async e=>{let t=await fetch(`/api/${encodeURIComponent(e)}/panel.js`);if(!t.ok)throw Error(`Failed to load plugin bundle for "${e}"`);return t.text()},getPushInstallConfig:()=>L(`/api/plugins/push-install/config`),updatePushInstallConfig:e=>Ml(`/api/plugins/push-install/config`,e),getPushInstallPolicies:()=>L(`/api/plugins/push-install/policies`),createPushInstallPolicy:e=>X(`/api/plugins/push-install/policies`,e),deletePushInstallPolicy:e=>Nl(`/api/plugins/push-install/policies/${encodeURIComponent(e)}`),updatePushInstallPolicy:(e,t)=>Ml(`/api/plugins/push-install/policies/${encodeURIComponent(e)}`,t),enablePushInstall:(e,t)=>X(`/api/plugins/push-install/enable/${encodeURIComponent(e)}`,t),disablePushInstall:e=>Nl(`/api/plugins/push-install/enable/${encodeURIComponent(e)}`),pushInstallCommand:(e,t)=>X(`/api/plugins/push-install/${encodeURIComponent(e)}`,t),getPushInstallSessions:()=>L(`/api/plugins/push-install/sessions`),getAuditLog:(e={})=>L(`/api/audit${Pl(e)}`),getNotifications:(e={})=>L(`/api/notifications${Pl(e)}`),markNotificationsRead:e=>X(`/api/notifications/read`,e),registerStorageServer:e=>X(`/api/storage/servers`,e),getStorageServers:()=>L(`/api/storage/servers`),deleteStorageServer:e=>Nl(`/api/storage/servers/${encodeURIComponent(e)}`),createStorageBinding:e=>X(`/api/storage/bindings`,e),getStorageBindings:()=>L(`/api/storage/bindings`),getStorageBinding:e=>L(`/api/storage/bindings/${encodeURIComponent(e)}`),deleteStorageBinding:e=>Nl(`/api/storage/bindings/${encodeURIComponent(e)}`),getIdentitySelf:()=>L(`/api/identity/self`),getIdentityUsers:()=>L(`/api/identity/users`),getIdentityUser:e=>L(`/api/identity/users/${encodeURIComponent(e)}`),getIdentityGroups:()=>L(`/api/identity/groups`),get2faStatus:()=>L(`/api/settings/2fa`),setup2fa:()=>X(`/api/settings/2fa/setup`),confirm2fa:e=>X(`/api/settings/2fa/confirm`,{code:e}),verify2fa:e=>X(`/api/settings/2fa/verify`,{code:e}),disable2fa:e=>X(`/api/settings/2fa/disable`,{code:e}),getAgents:()=>L(`/api/certs/agent`),getUserAccessGrants:()=>L(`/api/user-access/grants`),createUserAccessGrant:e=>X(`/api/user-access/grants`,e),revokeUserAccessGrant:e=>Nl(`/api/user-access/grants/${encodeURIComponent(e)}`),getTunnels:()=>L(`/api/tunnels`),createTunnel:e=>X(`/api/tunnels`,e),updateTunnel:(e,t)=>Ml(`/api/tunnels/${encodeURIComponent(e)}`,t),deleteTunnel:e=>Nl(`/api/tunnels/${encodeURIComponent(e)}`),getTunnelAgentConfig:()=>L(`/api/tunnels/agent-config`)};function Ll({to:e,icon:t,label:n,offline:r=null,onClick:i}){return(0,N.jsxs)(Ft,{to:e,end:e===`/`,onClick:i,title:r??void 0,className:({isActive:e})=>[`flex items-center gap-3 px-3 py-2 rounded-md text-sm font-medium transition-colors`,e?`text-cyan-400 bg-zinc-800/50`:`text-zinc-400 hover:text-zinc-100 hover:bg-zinc-800`].join(` `),children:[(0,N.jsx)(t,{className:`h-5 w-5`}),n,r&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{className:`ml-auto h-1.5 w-1.5 shrink-0 rounded-full bg-red-500`,"aria-hidden":`true`}),(0,N.jsxs)(`span`,{className:`sr-only`,children:[`(offline: `,r,`)`]})]})]})}var Rl=`4.4.0`,zl={activity:ni,"bar-chart-3":oi,"book-open":ci,box:B,cpu:Si,database:Ci,"file-text":ki,folder:Ni,"git-branch":Pi,globe:Fi,"hard-drive":Ii,heart:Li,layers:Hi,"layout-dashboard":Ui,list:Ki,map:Ji,package:Qi,server:ua,settings:fa,shield:ha,"shield-check":ma,terminal:va,ticket:ya,truck:Sa,users:Ea,wifi:Oa,zap:Aa};function Bl(e){return e&&Object.hasOwn(zl,e)&&zl[e]||Qi}var Vl=[{type:`link`,to:`/`,icon:Ui,label:`Dashboard`},{type:`link`,to:`/tunnels`,icon:Fi,label:`Tunnels`},{type:`link`,to:`/sites`,icon:ki,label:`Static Sites`},{type:`link`,to:`/users`,icon:Ea,label:`Users`},{type:`link`,to:`/certificates`,icon:ma,label:`Certificates`},{type:`link`,to:`/services`,icon:ua,label:`Services`},{type:`link`,to:`/tickets`,icon:ya,label:`Tickets`},{type:`link`,to:`/plugins`,icon:Qi,label:`Plugins`},{type:`link`,to:`/storage`,icon:Ii,label:`Storage`},{type:`link`,to:`/audit`,icon:ca,label:`Audit`},{type:`link`,to:`/settings`,icon:fa,label:`Settings`},{type:`link`,to:`/docs`,icon:ci,label:`Documentation`}];function Hl({onLinkClick:e}){let t=R(),n=F({queryKey:[`plugins`],queryFn:()=>t.getPlugins(),select:e=>(e.plugins||[]).filter(e=>e.status===`enabled`&&(e.panel?.label||e.panel?.pages?.length)),refetchInterval:3e4,staleTime:15e3}),r=n.data,i=e=>{let t=e.hosting===`agent`?yr(e.agentHosting):null;return t?xr(t,n.dataUpdatedAt):null},a=(r||[]).flatMap(e=>{let t=i(e);return e.panel?.pages?.length?[{type:`section-header`,label:e.displayName||e.name,key:`section-${e.name}`},...e.panel.pages.map(n=>({type:`link`,to:`/plugins/${e.name}${n.path}`,icon:Bl(n.icon),label:n.title,offline:t}))]:e.panel?.label?[{type:`link`,to:`/plugins/${e.name}`,icon:Bl(e.panel?.icon),label:e.panel.label,offline:t}]:[]}),o=[...Vl,...a];return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`div`,{className:`border-b border-zinc-800 px-4 py-5`,children:(0,N.jsx)(`span`,{className:`font-mono text-lg font-bold text-cyan-400`,children:`Lamaste`})}),(0,N.jsx)(`nav`,{className:`flex-1 space-y-1 px-2 py-4`,children:o.map(t=>t.type===`section-header`?(0,N.jsx)(`div`,{className:`px-3 pt-4 pb-1`,children:(0,N.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-zinc-600`,children:t.label})},t.key):(0,N.jsx)(Ll,{to:t.to,icon:t.icon,label:t.label,offline:t.offline??null,onClick:e},t.to))}),(0,N.jsx)(`div`,{className:`border-t border-zinc-800 px-4 py-3`,children:(0,N.jsxs)(`span`,{className:`font-mono text-xs text-zinc-600`,children:[`v`,Rl]})})]})}function Ul(){let[e,t]=(0,g.useState)(!1),n=()=>t(!1);return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>t(!0),className:`fixed left-4 top-4 z-40 rounded-md bg-zinc-900 p-2 text-zinc-400 hover:text-zinc-100 lg:hidden`,"aria-label":`Open sidebar`,children:(0,N.jsx)(Yi,{className:`h-5 w-5`})}),e&&(0,N.jsxs)(`div`,{className:`fixed inset-0 z-50 lg:hidden`,children:[(0,N.jsx)(`div`,{className:`fixed inset-0 bg-black/50`,onClick:n}),(0,N.jsxs)(`div`,{className:`relative flex h-screen w-64 flex-col bg-zinc-900`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:n,className:`absolute right-3 top-4 rounded-md p-1 text-zinc-400 hover:text-zinc-100`,"aria-label":`Close sidebar`,children:(0,N.jsx)(ka,{className:`h-5 w-5`})}),(0,N.jsx)(Hl,{onLinkClick:n})]})]}),(0,N.jsx)(`div`,{className:`sticky top-0 hidden h-screen w-64 flex-col border-r border-zinc-800 bg-zinc-900 lg:flex`,children:(0,N.jsx)(Hl,{})})]})}function Wl(){return(0,N.jsxs)(`div`,{className:`flex min-h-screen`,children:[(0,N.jsx)(Ul,{}),(0,N.jsx)(`main`,{className:`flex-1 overflow-y-auto bg-zinc-950 p-6 lg:p-8`,children:(0,N.jsx)(gt,{})})]})}function Gl(){return(0,N.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-zinc-950`,children:(0,N.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,N.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-2 border-zinc-700 border-t-cyan-400`}),(0,N.jsx)(`p`,{className:`mt-4 text-sm text-zinc-500`,children:`Connecting to panel server...`})]})})}function Kl({onRetry:e}){return(0,N.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-zinc-950`,children:(0,N.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,N.jsx)(hi,{className:`mb-4 h-12 w-12 text-red-400`}),(0,N.jsx)(`h1`,{className:`mb-2 font-mono text-xl font-bold text-zinc-100`,children:`Unable to connect`}),(0,N.jsx)(`p`,{className:`mb-6 max-w-md text-center text-zinc-400`,children:`Could not reach the Lamaste panel server. Make sure the server is running and try again.`}),(0,N.jsx)(`button`,{type:`button`,onClick:e,className:`rounded-md bg-cyan-400 px-4 py-2 font-medium text-zinc-900 transition-colors hover:bg-cyan-300`,children:`Retry`})]})})}var ql=/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,Jl=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function Yl({domain:e,onComplete:t}){let[n,r]=(0,g.useState)(e??``),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)({}),c=P(),l=I({mutationFn:async e=>{let t=await fetch(`/api/onboarding/domain`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json();throw Error(e.error||`Request failed`)}return t.json()},onSuccess:()=>{c.invalidateQueries({queryKey:[`onboarding`,`status`]}),t()}});function u(){let e={};return ql.test(n)||(e.domain=`Enter a valid domain name (e.g. example.com)`),Jl.test(i)||(e.email=`Enter a valid email address`),s(e),Object.keys(e).length===0}function d(e){e.preventDefault(),u()&&l.mutate({domain:n.trim(),email:i.trim()})}return(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h2`,{className:`mb-2 text-xl font-semibold text-white`,children:`Configure your domain`}),(0,N.jsx)(`p`,{className:`mb-6 text-sm text-zinc-400`,children:`Enter the domain you want to use for Lamaste. You will need to configure DNS records in the next step.`}),l.isError&&(0,N.jsx)(`div`,{className:`mb-4 rounded-md bg-red-500/10 border border-red-500/20 px-4 py-3 text-sm text-red-400`,children:l.error.message}),(0,N.jsxs)(`form`,{onSubmit:d,className:`space-y-5`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`domain`,className:`mb-1.5 block text-sm font-medium text-zinc-300`,children:`Domain`}),(0,N.jsx)(`input`,{id:`domain`,type:`text`,placeholder:`example.com`,value:n,onChange:e=>{r(e.target.value),s(e=>({...e,domain:void 0}))},className:`w-full rounded-md border border-zinc-600 bg-zinc-900 px-3 py-2 font-mono text-sm text-white placeholder-zinc-500 focus:border-cyan-400 focus:outline-none focus:ring-1 focus:ring-cyan-400`}),o.domain&&(0,N.jsx)(`p`,{className:`mt-1 text-xs text-red-400`,children:o.domain})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`email`,className:`mb-1.5 block text-sm font-medium text-zinc-300`,children:`Email`}),(0,N.jsx)(`input`,{id:`email`,type:`email`,placeholder:`you@example.com`,value:i,onChange:e=>{a(e.target.value),s(e=>({...e,email:void 0}))},className:`w-full rounded-md border border-zinc-600 bg-zinc-900 px-3 py-2 font-mono text-sm text-white placeholder-zinc-500 focus:border-cyan-400 focus:outline-none focus:ring-1 focus:ring-cyan-400`}),(0,N.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:`Used for Let's Encrypt certificate registration`}),o.email&&(0,N.jsx)(`p`,{className:`mt-1 text-xs text-red-400`,children:o.email})]}),(0,N.jsx)(`div`,{className:`flex justify-end pt-2`,children:(0,N.jsxs)(`button`,{type:`submit`,disabled:l.isPending,className:`flex items-center gap-2 rounded-md bg-cyan-500 px-6 py-2 font-medium text-white transition-colors hover:bg-cyan-600 disabled:opacity-50`,children:[l.isPending&&(0,N.jsx)(V,{size:16,className:`animate-spin`}),l.isPending?`Saving...`:`Save & Continue`]})})]})]})}function Xl({text:e}){let[t,n]=(0,g.useState)(!1);function r(){navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})}return(0,N.jsxs)(`button`,{type:`button`,onClick:r,className:`ml-2 inline-flex items-center text-zinc-500 transition-colors hover:text-zinc-300`,title:`Copy to clipboard`,children:[(0,N.jsx)(xi,{size:14}),t&&(0,N.jsx)(`span`,{className:`ml-1 text-xs text-green-400`,children:`Copied`})]})}function Zl({type:e,name:t,value:n}){return(0,N.jsxs)(`tr`,{className:`border-b border-zinc-700 last:border-b-0`,children:[(0,N.jsx)(`td`,{className:`px-3 py-2.5 font-mono text-sm text-cyan-400`,children:e}),(0,N.jsx)(`td`,{className:`px-3 py-2.5 font-mono text-sm text-zinc-300`,children:t}),(0,N.jsx)(`td`,{className:`px-3 py-2.5 font-mono text-sm text-zinc-300`,children:(0,N.jsxs)(`span`,{className:`inline-flex items-center`,children:[n,(0,N.jsx)(Xl,{text:n})]})})]})}function Ql({name:e,ok:t,resolvedIps:n,expectedIp:r}){return(0,N.jsxs)(`div`,{className:`flex items-start gap-2`,children:[t?(0,N.jsx)(_i,{size:18,className:`mt-0.5 shrink-0 text-green-400`}):(0,N.jsx)(vi,{size:18,className:`mt-0.5 shrink-0 text-red-400`}),(0,N.jsxs)(`div`,{className:`text-sm`,children:[(0,N.jsx)(`span`,{className:t?`text-green-400`:`text-red-400`,children:e}),t?(0,N.jsxs)(`span`,{className:`text-zinc-400`,children:[` resolves to `,r]}):n.length>0?(0,N.jsxs)(`span`,{className:`text-zinc-400`,children:[` `,`resolves to `,n.join(`, `),` (expected `,r,`)`]}):(0,N.jsx)(`span`,{className:`text-zinc-400`,children:` does not resolve`})]})]})}function $l({name:e,ok:t,expectedIp:n,missingText:r}){return(0,N.jsxs)(`div`,{className:`flex items-start gap-2`,children:[t?(0,N.jsx)(_i,{size:18,className:`mt-0.5 shrink-0 text-green-400`}):(0,N.jsx)(xa,{size:18,className:`mt-0.5 shrink-0 text-yellow-400`}),(0,N.jsxs)(`div`,{className:`text-sm`,children:[(0,N.jsx)(`span`,{className:t?`text-green-400`:`text-yellow-400`,children:e}),t?(0,N.jsxs)(`span`,{className:`text-zinc-400`,children:[` resolves to `,n]}):(0,N.jsxs)(`span`,{className:`text-zinc-400`,children:[` `,r]})]})]})}function eu({result:e}){return e?(0,N.jsxs)(`div`,{className:`mt-5 space-y-3 rounded-md border border-zinc-700 bg-zinc-900 p-4`,children:[e.records.map(t=>(0,N.jsx)(Ql,{name:t.name,ok:t.ok,resolvedIps:t.resolvedIps,expectedIp:e.expectedIp},t.name)),(0,N.jsx)($l,{name:`*.${e.domain}`,ok:e.wildcardOk,expectedIp:e.expectedIp,missingText:`not configured — you can add individual subdomain records later`}),(0,N.jsx)($l,{name:e.domain,ok:e.apexOk,expectedIp:e.expectedIp,missingText:`does not point here — only needed to serve a site on the domain itself`}),(0,N.jsx)(`p`,{className:`text-sm text-zinc-400`,children:e.message})]}):null}function tu({domain:e,ip:t,onComplete:n,onBack:r}){let[i,a]=(0,g.useState)(null),o=P(),s=I({mutationFn:async()=>{let e=await fetch(`/api/onboarding/verify-dns`,{method:`POST`});if(!e.ok){let t=await e.json();throw Error(t.error||`Verification failed`)}return e.json()},onSuccess:e=>{a(e),e.ok&&o.invalidateQueries({queryKey:[`onboarding`,`status`]})}});function c(){s.mutate()}function l(){n()}return(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h2`,{className:`mb-2 text-xl font-semibold text-white`,children:`Configure DNS records`}),(0,N.jsx)(`p`,{className:`mb-5 text-sm text-zinc-400`,children:`Add these DNS records at your domain registrar or DNS provider.`}),s.isError&&(0,N.jsx)(`div`,{className:`mb-4 rounded-md bg-red-500/10 border border-red-500/20 px-4 py-3 text-sm text-red-400`,children:s.error.message}),(0,N.jsx)(`div`,{className:`overflow-hidden rounded-md border border-zinc-700`,children:(0,N.jsxs)(`table`,{className:`w-full text-left`,children:[(0,N.jsx)(`thead`,{children:(0,N.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-800/50`,children:[(0,N.jsx)(`th`,{className:`px-3 py-2 text-xs font-medium uppercase tracking-wider text-zinc-500`,children:`Type`}),(0,N.jsx)(`th`,{className:`px-3 py-2 text-xs font-medium uppercase tracking-wider text-zinc-500`,children:`Name`}),(0,N.jsx)(`th`,{className:`px-3 py-2 text-xs font-medium uppercase tracking-wider text-zinc-500`,children:`Value`})]})}),(0,N.jsxs)(`tbody`,{className:`bg-zinc-900`,children:[(0,N.jsx)(Zl,{type:`A`,name:`*.${e}`,value:t}),(0,N.jsx)(Zl,{type:`A`,name:e,value:t})]})]})}),(0,N.jsx)(`p`,{className:`mt-3 text-xs italic text-zinc-500`,children:`DNS propagation can take up to 48 hours, but usually completes within a few minutes.`}),(0,N.jsxs)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:[`The wildcard record (*.`,e,`) covers the panel, auth and tunnel subdomains Lamaste needs and every tunnel you create later. Without it, add an A record for each of panel.`,e,`, auth.`,e,` and tunnel.`,e,`.`]}),(0,N.jsxs)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:[`The record for `,e,` itself is optional — it is only needed to serve a site on the domain, and can stay with another host until then.`]}),(0,N.jsx)(eu,{result:i}),(0,N.jsxs)(`div`,{className:`mt-6 flex items-center justify-between`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:r,className:`text-sm text-zinc-400 transition-colors hover:text-zinc-200`,children:`Back`}),(0,N.jsxs)(`div`,{className:`flex gap-3`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:c,disabled:s.isPending,className:`flex items-center gap-2 rounded-md bg-cyan-500 px-6 py-2 font-medium text-white transition-colors hover:bg-cyan-600 disabled:opacity-50`,children:[s.isPending&&(0,N.jsx)(V,{size:16,className:`animate-spin`}),s.isPending?`Verifying...`:`Verify DNS`]}),i?.ok&&(0,N.jsx)(`button`,{type:`button`,onClick:l,className:`rounded-md bg-green-600 px-6 py-2 font-medium text-white transition-colors hover:bg-green-700`,children:`Continue`})]})]})]})}var nu=1e4;function ru(){let[e,t]=(0,g.useState)([]),[n,r]=(0,g.useState)(!1),[i,a]=(0,g.useState)(!1),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(null),[u,d]=(0,g.useState)({current:0,total:0}),[f,p]=(0,g.useState)([]),m=(0,g.useRef)(null),h=(0,g.useRef)(0),_=(0,g.useRef)(null),v=(0,g.useRef)(!1),y=(0,g.useRef)(null);return(0,g.useEffect)(()=>{v.current=!1;function e(){if(v.current)return;let n=`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}/api/onboarding/provision/stream`,i=new WebSocket(n);m.current=i,i.onopen=()=>{h.current=0},i.onmessage=e=>{let n;try{n=JSON.parse(e.data)}catch{return}if(n.type===`state`){n.tasks&&t(n.tasks),n.error&&(a(!0),s(n.error)),n.result&&(l(n.result),r(!0));return}if(n.task===`complete`&&n.status===`done`){r(!0),n.result&&l(n.result);return}n.status===`error`&&(a(!0),s({task:n.task,message:n.error||n.message})),n.progress&&d(n.progress),n.log&&p(e=>[...e.slice(-500),n.log]),n.message&&p(e=>[...e.slice(-500),n.message]),t(e=>{let t=e.findIndex(e=>e.id===n.task);if(t!==-1){let r=[...e];return r[t]={...r[t],status:n.status,message:n.message,log:n.log},r}return[...e,{id:n.task,title:n.title||n.task,status:n.status,message:n.message,log:n.log}]})},i.onclose=()=>{if(v.current)return;let t=h.current,n=Math.min(1e3*2**t,nu);h.current=t+1,_.current=setTimeout(()=>{v.current||e()},n)},i.onerror=()=>{}}return y.current=e,e(),()=>{v.current=!0,_.current&&clearTimeout(_.current),m.current&&m.current.close()}},[]),{tasks:e,isComplete:n,isError:i,error:o,result:c,progress:u,logs:f,retry:(0,g.useCallback)(async()=>{a(!1),s(null),r(!1),l(null),t([]),p([]),d({current:0,total:0});let e=await fetch(`/api/onboarding/provision`,{method:`POST`});if(!e.ok){let t=await e.json();throw Error(t.error||`Failed to start provisioning`)}},[])}}function iu({status:e}){switch(e){case`done`:return(0,N.jsx)(_i,{size:18,className:`shrink-0 text-green-400`});case`error`:return(0,N.jsx)(vi,{size:18,className:`shrink-0 text-red-400`});case`running`:return(0,N.jsx)(V,{size:18,className:`shrink-0 animate-spin text-cyan-400`});default:return(0,N.jsx)(yi,{size:18,className:`shrink-0 text-zinc-600`})}}function au({task:e,isLast:t}){let n=e.status===`pending`?`text-zinc-500`:`text-white`;return(0,N.jsxs)(`div`,{className:`flex gap-3`,children:[(0,N.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,N.jsx)(iu,{status:e.status}),!t&&(0,N.jsx)(`div`,{className:`mt-1 w-px flex-1 bg-zinc-700`})]}),(0,N.jsxs)(`div`,{className:`pb-4`,children:[(0,N.jsx)(`p`,{className:`text-sm font-medium ${n}`,children:e.title}),e.message&&e.status!==`pending`&&(0,N.jsx)(`p`,{className:`mt-0.5 text-xs text-zinc-400`,children:e.message})]})]})}function ou({onComplete:e}){let{tasks:t,isComplete:n,isError:r,error:i,result:a,progress:o,logs:s,retry:c}=ru(),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(!1),p=(0,g.useRef)(null);(0,g.useEffect)(()=>{l||(u(!0),fetch(`/api/onboarding/provision`,{method:`POST`}).catch(()=>{}))},[l]),(0,g.useEffect)(()=>{p.current&&(p.current.scrollTop=p.current.scrollHeight)},[s]),(0,g.useEffect)(()=>{if(n&&e){let t=setTimeout(()=>{e(a)},1e3);return()=>clearTimeout(t)}},[n,e,a]);async function m(){f(!0);try{await c()}catch{}finally{f(!1)}}return(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h2`,{className:`mb-2 text-xl font-semibold text-white`,children:`Setting up your Lamaste`}),(0,N.jsx)(`div`,{className:`mb-5 rounded-md border border-amber-700 bg-amber-900/30 px-4 py-3`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(xa,{size:16,className:`shrink-0 text-amber-300`}),(0,N.jsx)(`p`,{className:`text-sm text-amber-300`,children:`Do not close this page while provisioning is in progress`})]})}),(0,N.jsx)(`div`,{className:`mb-4`,children:t.map((e,n)=>(0,N.jsx)(au,{task:e,isLast:n===t.length-1},e.id))}),(0,N.jsx)(`div`,{ref:p,className:`mb-3 max-h-48 overflow-y-auto rounded border border-zinc-800 bg-zinc-950 p-3 font-mono text-sm text-zinc-400`,children:s.length===0?(0,N.jsx)(`p`,{className:`italic text-zinc-600`,children:`Waiting for provisioning to start...`}):s.map((e,t)=>(0,N.jsx)(`p`,{className:`leading-relaxed`,children:e},t))}),o.total>0&&(0,N.jsxs)(`p`,{className:`mb-4 text-sm text-zinc-500`,children:[`Step `,o.current,` of `,o.total]}),r&&i&&(0,N.jsxs)(`div`,{className:`mb-4 rounded-md border border-red-700 bg-red-900/30 px-4 py-3`,children:[(0,N.jsx)(`p`,{className:`text-sm font-medium text-red-300`,children:`Provisioning failed`}),(0,N.jsx)(`p`,{className:`mt-1 text-xs text-red-400`,children:i.message}),(0,N.jsxs)(`button`,{type:`button`,onClick:m,disabled:d,className:`mt-3 flex items-center gap-2 rounded-md bg-cyan-500 px-6 py-2 font-medium text-white transition-colors hover:bg-cyan-600 disabled:opacity-50`,children:[d&&(0,N.jsx)(V,{size:16,className:`animate-spin`}),d?`Retrying...`:`Retry`]})]}),n&&(0,N.jsx)(`div`,{className:`text-center`,children:(0,N.jsx)(`p`,{className:`text-sm text-green-400`,children:`Provisioning complete. Continuing...`})})]})}function su({text:e}){let[t,n]=(0,g.useState)(!1);function r(){navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})}return(0,N.jsxs)(`button`,{type:`button`,onClick:r,className:`ml-2 inline-flex items-center text-zinc-500 transition-colors hover:text-zinc-300`,title:`Copy to clipboard`,children:[(0,N.jsx)(xi,{size:14}),t&&(0,N.jsx)(`span`,{className:`ml-1 text-xs text-green-400`,children:`Copied`})]})}function cu(e){try{let t=new URL(e);if(t.protocol===`https:`)return t.href}catch{}return``}function lu({result:e,ip:t}){let[n,r]=(0,g.useState)(!1),i=e?.adminUsername||`admin`,a=e?.adminPassword||``,o=cu(e?.panelUrl||``),s=cu(e?.authUrl||``),c=`https://${t}:9292`;return(0,N.jsxs)(`div`,{className:`animate-fade-in`,children:[(0,N.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,N.jsx)(ma,{size:48,className:`mx-auto mb-3 text-green-400`}),(0,N.jsx)(`h2`,{className:`text-2xl font-bold text-white`,children:`Lamaste is ready!`}),(0,N.jsx)(`p`,{className:`mt-1 text-sm text-zinc-400`,children:`Your stack is fully configured and operational.`})]}),(0,N.jsxs)(`div`,{className:`mb-5 rounded-lg border border-zinc-700 bg-zinc-800 p-6`,children:[(0,N.jsx)(`h3`,{className:`mb-1 font-semibold text-white`,children:`Admin Credentials`}),(0,N.jsx)(`p`,{className:`mb-4 text-sm text-amber-400`,children:`Save these credentials — they won't be shown again.`}),(0,N.jsxs)(`div`,{className:`space-y-3`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsx)(`span`,{className:`text-sm text-zinc-400`,children:`Username`}),(0,N.jsxs)(`span`,{className:`inline-flex items-center font-mono text-sm text-white`,children:[i,(0,N.jsx)(su,{text:i})]})]}),(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsx)(`span`,{className:`text-sm text-zinc-400`,children:`Password`}),(0,N.jsxs)(`span`,{className:`inline-flex items-center font-mono text-sm text-white`,children:[n?a:`•`.repeat(16),(0,N.jsx)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`ml-2 text-zinc-500 transition-colors hover:text-zinc-300`,title:n?`Hide password`:`Show password`,children:n?(0,N.jsx)(Di,{size:14}):(0,N.jsx)(Oi,{size:14})}),(0,N.jsx)(su,{text:a})]})]})]})]}),(0,N.jsxs)(`div`,{className:`mb-5 space-y-2`,children:[(0,N.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300`,children:`Access URLs`}),(0,N.jsxs)(`div`,{className:`flex items-center justify-between rounded border border-zinc-700 bg-zinc-900 px-3 py-2`,children:[(0,N.jsx)(`span`,{className:`text-sm text-zinc-400`,children:`Panel`}),(0,N.jsxs)(`a`,{href:o,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-sm text-cyan-400 hover:underline`,children:[o,(0,N.jsx)(Ei,{size:12})]})]}),(0,N.jsxs)(`div`,{className:`flex items-center justify-between rounded border border-zinc-700 bg-zinc-900 px-3 py-2`,children:[(0,N.jsx)(`span`,{className:`text-sm text-zinc-400`,children:`Auth Portal`}),(0,N.jsxs)(`a`,{href:s,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-sm text-cyan-400 hover:underline`,children:[s,(0,N.jsx)(Ei,{size:12})]})]}),(0,N.jsxs)(`div`,{className:`flex items-center justify-between rounded border border-zinc-700 bg-zinc-900 px-3 py-2`,children:[(0,N.jsx)(`span`,{className:`text-sm text-zinc-400`,children:`IP Access`}),(0,N.jsxs)(`span`,{className:`text-sm text-zinc-400`,children:[c,` `,(0,N.jsx)(`span`,{className:`text-xs text-zinc-500`,children:`(requires client certificate)`})]})]})]}),(0,N.jsxs)(`p`,{className:`mb-6 text-xs text-zinc-400`,children:[`On your first login to `,s?new URL(s).hostname:`the auth portal`,`, you will be prompted to set up two-factor authentication (TOTP). Use an authenticator app like Google Authenticator or Authy.`]}),(0,N.jsx)(`div`,{className:`flex justify-center`,children:(0,N.jsx)(`a`,{href:`/`,className:`rounded-md bg-cyan-500 px-8 py-2.5 font-medium text-white transition-colors hover:bg-cyan-600`,children:`Go to Dashboard`})})]})}var uu=4;function du(e){switch(e){case`FRESH`:return 1;case`DOMAIN_SET`:return 2;case`DNS_READY`:case`PROVISIONING`:return 3;case`COMPLETED`:return 4;default:return 1}}function fu({current:e}){return(0,N.jsxs)(`div`,{className:`mb-6 flex items-center gap-3`,children:[(0,N.jsxs)(`span`,{className:`text-sm text-zinc-400`,children:[`Step `,e,` of `,uu]}),(0,N.jsx)(`div`,{className:`flex gap-1.5`,children:Array.from({length:uu},(t,n)=>{let r=n+1,i=`h-2 w-2 rounded-full`;return r<e?i+=` bg-cyan-400`:r===e?i+=` border-2 border-cyan-400 bg-transparent`:i+=` bg-zinc-600`,(0,N.jsx)(`div`,{className:i},r)})})]})}function pu(){let{status:e,domain:t,ip:n,isLoading:r,isError:i,refetch:a}=Yr(),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(null),u=du(e),d=o!==null&&o<u?o:u;if(r)return(0,N.jsx)(Gl,{});if(i)return(0,N.jsx)(Kl,{onRetry:a});function f(){a(),s(null)}function p(){a(),s(null)}function m(){s(1)}function h(e){l(e),s(4),a()}let _;return d===1?_=(0,N.jsx)(Yl,{domain:t,onComplete:f}):d===2?_=(0,N.jsx)(tu,{domain:t,ip:n,onComplete:p,onBack:m}):d===3?_=(0,N.jsx)(ou,{onComplete:h}):d===4&&(_=(0,N.jsx)(lu,{result:c,ip:n})),(0,N.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-zinc-950`,children:(0,N.jsxs)(`div`,{className:`mx-4 w-full max-w-xl rounded-lg border border-zinc-800 bg-zinc-900 p-8`,children:[(0,N.jsx)(`h1`,{className:`mb-2 font-mono text-2xl font-bold text-cyan-400`,children:`Lamaste`}),(0,N.jsx)(fu,{current:d}),_]})})}function mu(){let{pluginName:e,"*":t}=Xe();return(0,N.jsx)(lo,{pluginName:e,subPath:t||``,basePath:`/plugins/${e}`,panelUrl:window.location.origin})}function hu(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var gu=hu();function _u(e){gu=e}var vu={exec:()=>null};function Z(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(bu.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var yu=(()=>{try{return!0}catch{return!1}})(),bu={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},xu=/^(?:[ \t]*(?:\n|$))+/,Su=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Cu=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,wu=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Tu=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Eu=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Du=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ou=Z(Du).replace(/bull/g,Eu).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),ku=Z(Du).replace(/bull/g,Eu).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Au=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ju=/^[^\n]+/,Mu=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Nu=Z(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Mu).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Pu=Z(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Eu).getRegex(),Fu=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,Iu=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Lu=Z(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Iu).replace(`tag`,Fu).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ru=Z(Au).replace(`hr`,wu).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Fu).getRegex(),zu={blockquote:Z(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Ru).getRegex(),code:Su,def:Nu,fences:Cu,heading:Tu,hr:wu,html:Lu,lheading:Ou,list:Pu,newline:xu,paragraph:Ru,table:vu,text:ju},Bu=Z(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,wu).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Fu).getRegex(),Vu={...zu,lheading:ku,table:Bu,paragraph:Z(Au).replace(`hr`,wu).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Bu).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Fu).getRegex()},Hu={...zu,html:Z(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Iu).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:vu,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Z(Au).replace(`hr`,wu).replace(`heading`,` *#{1,6} *[^
15
+ `).map(e=>e.trim()).filter(Boolean);v.mutate({name:a,description:s,allowedIps:t(l),deniedIps:t(d),allowedPlugins:t(p),allowedActions:h})},b=e=>{_(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,N.jsxs)(`div`,{className:`w-full max-w-lg rounded-xl bg-zinc-900 border border-zinc-700 p-6 shadow-xl`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,N.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:`Edit Policy`}),(0,N.jsx)(`button`,{type:`button`,onClick:t,className:`text-zinc-400 hover:text-white`,children:(0,N.jsx)(ka,{size:20})})]}),(0,N.jsxs)(`form`,{onSubmit:y,className:`space-y-4`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Name`}),(0,N.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 focus:border-cyan-500 focus:outline-none`})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Description`}),(0,N.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 focus:border-cyan-500 focus:outline-none`})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Allowed IPs (one per line)`}),(0,N.jsx)(`textarea`,{value:l,onChange:e=>u(e.target.value),rows:3,placeholder:`192.168.1.0/24`,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Denied IPs (one per line)`}),(0,N.jsx)(`textarea`,{value:d,onChange:e=>f(e.target.value),rows:2,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono focus:border-cyan-500 focus:outline-none`})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Allowed Plugins (one per line)`}),(0,N.jsx)(`textarea`,{value:p,onChange:e=>m(e.target.value),rows:2,placeholder:`@lamalibre/lamaste-herd-plugin`,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`}),(0,N.jsxs)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:[`For an agent half Lamaste installs, name its agent package (the manifest's`,` `,(0,N.jsx)(`span`,{className:`font-mono`,children:`agent.package`}),`). Empty allows every package.`]})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-2`,children:`Allowed Actions`}),(0,N.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:el.map(e=>(0,N.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:h.includes(e),onChange:()=>b(e),className:`accent-cyan-500`}),(0,N.jsx)(`span`,{className:`text-zinc-300`,children:e})]},e))})]}),(0,N.jsxs)(`div`,{className:`flex justify-end gap-3 pt-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:t,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:`Cancel`}),(0,N.jsxs)(`button`,{type:`submit`,disabled:!a.trim()||v.isPending,className:`rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:[v.isPending?(0,N.jsx)(V,{size:14,className:`animate-spin inline mr-1`}):null,`Save Changes`]})]})]})]})})}function nl(){let e=R(),t=P(),n=G(),[r,i]=(0,g.useState)(null),a=F({queryKey:[`push-install-policies`],queryFn:()=>e.getPushInstallPolicies(),refetchInterval:3e4}),o=I({mutationFn:t=>e.deletePushInstallPolicy(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`push-install-policies`]}),t.invalidateQueries({queryKey:[`push-install-config`]}),n(`Policy deleted`)},onError:e=>n(K(e),`error`)}),s=a.data?.policies||[];return a.isLoading||s.length===0?null:(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,N.jsx)(ha,{size:14,className:`text-cyan-400`}),(0,N.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300`,children:`Policies`})]}),(0,N.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-zinc-800`,children:(0,N.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,N.jsx)(`thead`,{children:(0,N.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-900`,children:[(0,N.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Name`}),(0,N.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400 hidden md:table-cell`,children:`Description`}),(0,N.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400 hidden lg:table-cell`,children:`Actions`}),(0,N.jsx)(`th`,{className:`px-4 py-3 text-right text-xs font-medium uppercase text-zinc-400`,children:`Manage`})]})}),(0,N.jsx)(`tbody`,{children:s.map(e=>(0,N.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-800`,children:[(0,N.jsx)(`td`,{className:`px-4 py-3 text-zinc-200 font-semibold`,children:e.name}),(0,N.jsx)(`td`,{className:`px-4 py-3 text-zinc-400 hidden md:table-cell`,children:e.description||`—`}),(0,N.jsx)(`td`,{className:`px-4 py-3 hidden lg:table-cell`,children:(0,N.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:(e.allowedActions||[]).map(e=>(0,N.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-zinc-700 text-zinc-300`,children:e},e))})}),(0,N.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,N.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600`,title:`Edit policy`,children:(0,N.jsx)($i,{size:12})}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>o.mutate(e.id),disabled:o.isPending,className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-zinc-300 hover:bg-red-600/20 hover:text-red-400`,title:`Delete policy`,children:(0,N.jsx)(ba,{size:12})})]})})]},e.id))})]})}),r&&(0,N.jsx)(tl,{policy:r,onClose:()=>i(null)})]})}function rl(){let e=R(),t=P(),n=G(),{reveal:r}=qa(),i=F({queryKey:[`plugins`],queryFn:()=>e.getPlugins(),refetchInterval:1e4}),a=I({mutationFn:async t=>{let{result:n,secrets:i}=za(await e.installPlugin(t));return r({plugin:n.plugin?.name??t,cause:`install`,secrets:i}),n},onSuccess:e=>{t.invalidateQueries({queryKey:[`plugins`]}),n(`Plugin "${e.plugin?.name||`unknown`}" installed`)},onError:e=>n(K(e),`error`)}),o=I({mutationFn:async t=>{let{result:n,secrets:i}=za(await e.enablePlugin(t));return r({plugin:t,cause:`enable`,secrets:i}),n},onSuccess:e=>{let r=i.data?.plugins?.find(t=>t.name===e.name);t.invalidateQueries({queryKey:[`plugins`]}),n(r?.hosting===`agent`?`Plugin "${e.name}" enabled (agent-hosted — nothing to mount)`:`Plugin "${e.name}" enabled (restart panel to mount routes)`)},onError:e=>n(K(e),`error`)}),s=I({mutationFn:t=>e.disablePlugin(t),onSuccess:e=>{t.invalidateQueries({queryKey:[`plugins`]}),n(`Plugin "${e.name}" disabled`)},onError:e=>n(K(e),`error`)}),c=(e,{hosting:t})=>n(qs(e,{agentLabel:t?.agentLabel,action:`uninstall`}),`error`),l=I({mutationFn:({name:t,purge:n})=>e.uninstallPlugin(t,{purge:n}),onSuccess:(e,{name:r,purge:i})=>{t.invalidateQueries({queryKey:[`plugins`]}),e.operation?(t.invalidateQueries({queryKey:[`plugin-operations`,r]}),n(`Uninstalling "${r}": its hosting is removed first${i?`, with its agent half’s data`:``} — follow the steps on its card`)):n(`Plugin "${e.name}" uninstalled`)},onError:c}),u=I({mutationFn:({name:t,agentLabel:n})=>e.setPluginHosting(t,n),onSuccess:(e,{name:r,agentLabel:i})=>{t.invalidateQueries({queryKey:[`plugin-operations`,r]}),n(`Hosting "${r}" on ${i} — follow the steps on its card`)}}),d=I({mutationFn:({name:t,force:n,purge:r})=>e.clearPluginHosting(t,{force:n,purge:r}),onSuccess:(e,{name:r,purge:i})=>{t.invalidateQueries({queryKey:[`plugin-operations`,r]}),n(`Removing the hosting of "${r}"${i?` and its agent half’s data`:``} — follow the steps on its card`)},onError:c}),f=I({mutationFn:t=>e.rotatePluginHostingSecret(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`plugins`]}),n(`New installation secret issued — the agent picks it up on its next sync`)},onError:e=>n(K(e),`error`)}),p=a.isPending||o.isPending||s.isPending||l.isPending||u.isPending||d.isPending||f.isPending,m=(0,g.useCallback)(e=>a.mutate(e),[a]),h=(0,g.useCallback)(e=>o.mutate(e),[o]),_=(0,g.useCallback)(e=>s.mutate(e),[s]),v=(0,g.useCallback)((e,t={},n=null)=>l.mutate({name:e,purge:t.purge===!0,hosting:n}),[l]),y=(0,g.useCallback)((e,t,n)=>u.mutate({name:e,agentLabel:t},n),[u]),b=(0,g.useCallback)((e,t={},n=null)=>d.mutate({name:e,force:t.force===!0,purge:t.purge===!0,hosting:n}),[d]),x=(0,g.useCallback)(e=>f.mutate(e),[f]),S=i.data?.plugins,C=i.data?.retainedData??[],w=new Set((S??[]).map(e=>e.name));return(0,N.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,N.jsxs)(`div`,{className:`mb-6`,children:[(0,N.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Plugins`}),(0,N.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`Install, enable, and manage plugins`})]}),(0,N.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-5 mb-8`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-300 mb-4`,children:`Install Plugin`}),(0,N.jsx)($c,{onInstall:m,isInstalling:a.isPending}),a.isPending&&(0,N.jsx)(`p`,{className:`text-xs text-zinc-500 mt-2`,children:`Installing...`})]}),i.isLoading?(0,N.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:Array.from({length:2}).map((e,t)=>(0,N.jsx)(`div`,{className:`h-40 animate-pulse rounded-lg bg-zinc-900 border border-zinc-800`},t))}):i.isError?(0,N.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-2 text-red-400 text-sm`,children:[(0,N.jsx)(hi,{size:16}),`Failed to load plugins`]})}):S?.length===0?(0,N.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,N.jsx)(`p`,{className:`text-zinc-500 text-sm text-center`,children:`No plugins installed. Use the form above to install one.`})}):(0,N.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:S?.map(e=>(0,N.jsx)(Qc,{plugin:e,now:i.dataUpdatedAt,onEnable:h,onDisable:_,onUninstall:v,onHost:y,onUnhost:b,onRotate:x,isActing:p},e.name))}),(0,N.jsx)(Kc,{records:C,installedNames:w,isActing:p}),(0,N.jsx)(Tc,{children:(0,N.jsx)(nl,{})})]})}function il(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3),r=Math.floor(n/60),i=Math.floor(r/60),a=Math.floor(i/24);return a>30?new Date(e).toLocaleDateString():a>0?`${a}d ago`:i>0?`${i}h ago`:r>0?`${r}m ago`:`just now`}var al=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;function ol(e){return e?e.length>63?`Max 63 characters`:al.test(e)?null:`Lowercase letters, numbers, and hyphens only. Cannot start or end with a hyphen.`:`Subdomain is required`}var sl={default:10,min:1,max:10240};function cl(e){let t=Number(e);return e===``||!Number.isInteger(t)?`Must be a whole number of MiB`:t<sl.min?`Minimum ${sl.min}`:t>sl.max?`Maximum ${sl.max}`:null}function ll(e){return e.maxBodySizeMb??1}var ul=[{value:`restricted`,label:`Restricted`,desc:`Only granted users and groups`},{value:`authenticated`,label:`All Authelia Users`,desc:`Any authenticated user can access`},{value:`public`,label:`Public`,desc:`No authentication required`}],dl=[3100,9090,9091,9292,9294];function fl(e){let t=Number(e);return!e&&e!==0?`Port is required`:Number.isInteger(t)?t<1024?`Minimum 1024`:t>65535?`Maximum 65535`:dl.includes(t)?`Reserved for a Lamaste service on the relay`:null:`Must be an integer`}function pl(){let e=R(),t=F({queryKey:[`admin-agents`],queryFn:()=>e.getAgents()});return{agents:(t.data?.agents||[]).filter(e=>!e.revoked&&e.certType!==`plugin-agent`).map(e=>e.label).sort(),isLoading:t.isLoading}}function ml({domain:e,onClose:t}){let n=R(),r=P(),i=G(),[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)(``),[d,f]=(0,g.useState)(`restricted`),[p,m]=(0,g.useState)(``),[h,_]=(0,g.useState)(String(sl.default)),{agents:v,isLoading:y}=pl(),[b,x]=(0,g.useState)({}),[S,C]=(0,g.useState)(null),w=I({mutationFn:e=>n.createTunnel(e),onSuccess:e=>{r.invalidateQueries({queryKey:[`tunnels`]}),i(`Tunnel ${e.tunnel.fqdn} created`),t()},onError:e=>{C(K(e))}}),T=(0,g.useCallback)(e=>{e.preventDefault(),C(null);let t=ol(a),n=fl(s),r={};t&&(r.subdomain=t),n&&(r.port=n),p||(r.agentLabel=`Choose the agent that carries this tunnel`);let i=cl(h);if(i&&(r.maxBody=i),Object.keys(r).length>0){x(r);return}x({}),w.mutate({subdomain:a,port:Number(s),description:l||void 0,accessMode:d,agentLabel:p,maxBodySizeMb:Number(h)})},[a,s,l,d,p,h,w]);return(0,N.jsxs)(`div`,{className:`bg-zinc-900 border border-zinc-800 rounded-lg p-5 mb-6`,children:[(0,N.jsxs)(`h2`,{className:`text-sm font-semibold text-zinc-300 mb-4 flex items-center gap-2`,children:[(0,N.jsx)(ta,{size:14,className:`text-cyan-400`}),`Add Tunnel`]}),(0,N.jsxs)(`form`,{onSubmit:T,className:`space-y-4`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Subdomain`}),(0,N.jsxs)(`div`,{className:`flex items-center gap-0`,children:[(0,N.jsx)(`input`,{type:`text`,value:a,onChange:e=>{o(e.target.value.toLowerCase()),x(e=>({...e,subdomain:void 0}))},disabled:w.isPending,placeholder:`myapp`,className:`flex-1 rounded-l bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono placeholder:text-zinc-600 focus:outline-none focus:border-cyan-400 disabled:opacity-50`}),(0,N.jsxs)(`span`,{className:`rounded-r bg-zinc-800/60 border border-l-0 border-zinc-700 px-3 py-2 text-sm text-zinc-500 font-mono`,children:[`.`,e]})]}),b.subdomain&&(0,N.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:b.subdomain})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Port`}),(0,N.jsx)(`input`,{type:`number`,value:s,onChange:e=>{c(e.target.value),x(e=>({...e,port:void 0}))},disabled:w.isPending,placeholder:`8080`,min:1024,max:65535,className:`w-40 rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono placeholder:text-zinc-600 focus:outline-none focus:border-cyan-400 disabled:opacity-50`}),b.port&&(0,N.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:b.port})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Agent`}),(0,N.jsxs)(`select`,{value:p,onChange:e=>{m(e.target.value),x(e=>({...e,agentLabel:void 0}))},disabled:w.isPending||y,className:`w-64 rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono focus:outline-none focus:border-cyan-400 disabled:opacity-50`,children:[(0,N.jsx)(`option`,{value:``,children:y?`Loading agents…`:`Select an agent`}),v.map(e=>(0,N.jsx)(`option`,{value:e,children:e},e))]}),(0,N.jsx)(`p`,{className:`text-xs text-zinc-500 mt-1`,children:`Only this agent forwards the port. It starts carrying the tunnel within 30 seconds.`}),!y&&v.length===0&&(0,N.jsx)(`p`,{className:`text-yellow-400 text-xs mt-1`,children:`No agents enrolled yet — enroll one under Certificates first.`}),b.agentLabel&&(0,N.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:b.agentLabel})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Largest request body (MiB)`}),(0,N.jsx)(`input`,{type:`number`,value:h,onChange:e=>{_(e.target.value),x(e=>({...e,maxBody:void 0}))},disabled:w.isPending,min:sl.min,max:sl.max,className:`w-40 rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono focus:outline-none focus:border-cyan-400 disabled:opacity-50`}),(0,N.jsx)(`p`,{className:`text-xs text-zinc-500 mt-1`,children:`Larger uploads are rejected with 413. Raise it for apps that accept big files.`}),b.maxBody&&(0,N.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:b.maxBody})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:[`Description `,(0,N.jsx)(`span`,{className:`text-zinc-600`,children:`(optional)`})]}),(0,N.jsx)(`input`,{type:`text`,value:l,onChange:e=>u(e.target.value),disabled:w.isPending,placeholder:`My web application`,maxLength:200,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 placeholder:text-zinc-600 focus:outline-none focus:border-cyan-400 disabled:opacity-50`})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-2`,children:`Access`}),(0,N.jsx)(`div`,{className:`space-y-2`,children:ul.map(e=>(0,N.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,N.jsx)(`input`,{type:`radio`,name:`accessMode`,value:e.value,checked:d===e.value,onChange:e=>f(e.target.value),disabled:w.isPending,className:`mt-1 text-cyan-500 focus:ring-cyan-500 bg-zinc-800 border-zinc-700`}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`span`,{className:`text-sm text-zinc-200`,children:e.label}),(0,N.jsx)(`p`,{className:`text-xs text-zinc-500`,children:e.desc})]})]},e.value))})]}),S&&(0,N.jsx)(`div`,{className:`rounded bg-red-500/10 border border-red-500/20 px-3 py-2 text-sm text-red-400`,children:S}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(`button`,{type:`submit`,disabled:w.isPending,className:`flex items-center gap-2 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50 disabled:cursor-not-allowed`,children:w.isPending?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(V,{size:14,className:`animate-spin`}),`Setting up tunnel...`]}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(ta,{size:14}),`Add Tunnel`]})}),(0,N.jsx)(`button`,{type:`button`,onClick:t,disabled:w.isPending,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Cancel`})]})]})]})}function hl({tunnel:e,onConfirm:t,onCancel:n,isPending:r}){return(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:(0,N.jsxs)(`div`,{className:`bg-zinc-900 border border-zinc-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl`,children:[(0,N.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:`Delete Tunnel`}),(0,N.jsxs)(`p`,{className:`text-zinc-400 text-sm mb-6`,children:[`Are you sure you want to delete`,` `,(0,N.jsx)(`span`,{className:`text-cyan-400 font-mono`,children:e.fqdn}),`? This will remove the nginx configuration and TLS certificate mapping.`]}),(0,N.jsxs)(`div`,{className:`flex items-center justify-end gap-3`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:n,disabled:r,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,onClick:t,disabled:r,className:`flex items-center gap-2 rounded bg-red-600 px-4 py-2 text-sm font-semibold text-white hover:bg-red-500 disabled:opacity-50`,children:r?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(V,{size:14,className:`animate-spin`}),`Deleting...`]}):`Delete`})]})]})})}function gl({tunnel:e,onConfirm:t,onCancel:n,isPending:r}){let{agents:i,isLoading:a}=pl(),[o,s]=(0,g.useState)(e.agentLabel||``),[c,l]=(0,g.useState)(e.accessMode||`restricted`),u=ll(e),[d,f]=(0,g.useState)(String(u)),p=cl(d),m={};o&&o!==e.agentLabel&&(m.agentLabel=o),c!==(e.accessMode||`restricted`)&&(m.accessMode=c),!p&&Number(d)!==u&&(m.maxBodySizeMb=Number(d));let h=Object.keys(m).length>0;return(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:(0,N.jsxs)(`div`,{className:`bg-zinc-900 border border-zinc-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl`,children:[(0,N.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-1`,children:`Edit Tunnel`}),(0,N.jsx)(`p`,{className:`text-cyan-400 font-mono text-sm mb-5`,children:e.fqdn}),(0,N.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Agent`}),(0,N.jsxs)(`select`,{value:o,onChange:e=>s(e.target.value),disabled:r||a,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono focus:outline-none focus:border-cyan-400 disabled:opacity-50`,children:[!e.agentLabel&&(0,N.jsx)(`option`,{value:``,children:`Unassigned — select an agent`}),i.map(e=>(0,N.jsx)(`option`,{value:e,children:e},e))]}),m.agentLabel&&(0,N.jsxs)(`p`,{className:`text-xs text-zinc-500 mt-1`,children:[e.agentLabel?`Both agents pick`:`${m.agentLabel} picks`,` the change up within 30 seconds.`]}),(0,N.jsx)(`label`,{className:`block text-xs text-zinc-400 mt-4 mb-2`,children:`Access`}),(0,N.jsx)(`div`,{className:`space-y-2`,children:ul.map(e=>(0,N.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,N.jsx)(`input`,{type:`radio`,name:`editAccessMode`,value:e.value,checked:c===e.value,onChange:e=>l(e.target.value),disabled:r,className:`mt-1 text-cyan-500 focus:ring-cyan-500 bg-zinc-800 border-zinc-700`}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`span`,{className:`text-sm text-zinc-200`,children:e.label}),(0,N.jsx)(`p`,{className:`text-xs text-zinc-500`,children:e.desc})]})]},e.value))}),(0,N.jsx)(`label`,{className:`block text-xs text-zinc-400 mt-4 mb-1`,children:`Largest request body (MiB)`}),(0,N.jsx)(`input`,{type:`number`,value:d,onChange:e=>f(e.target.value),disabled:r,min:sl.min,max:sl.max,className:`w-40 rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono focus:outline-none focus:border-cyan-400 disabled:opacity-50`}),p&&(0,N.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:p}),(0,N.jsxs)(`div`,{className:`flex items-center justify-end gap-3 mt-6`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:n,disabled:r,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>t(m),disabled:r||!h||!!p,className:`flex items-center gap-2 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:r?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(V,{size:14,className:`animate-spin`}),`Saving...`]}):`Save`})]})]})})}function _l({tunnel:e}){return(0,N.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full bg-cyan-500/10 text-cyan-400`,title:`Internal tunnel of an agent-hosted plugin: no hostname, no certificate, reachable only by the panel's forwarder`,children:[`plugin:`,e.pluginRoute||`?`]})}function vl({tunnel:e}){return e.agentLabel?(0,N.jsx)(`span`,{className:`text-sm text-zinc-300 font-mono`,children:e.agentLabel}):(0,N.jsx)(`span`,{className:`inline-block px-2 py-0.5 rounded text-xs bg-red-500/10 text-red-400`,title:`No agent carries this tunnel. Move it to an agent to bring it back.`,children:`unassigned`})}function yl({tunnels:e,onDelete:t,onToggle:n,onEdit:r}){return(0,N.jsx)(`div`,{className:`hidden md:block overflow-x-auto`,children:(0,N.jsxs)(`table`,{className:`w-full`,children:[(0,N.jsx)(`thead`,{children:(0,N.jsxs)(`tr`,{className:`border-b border-zinc-700`,children:[(0,N.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Status`}),(0,N.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Subdomain`}),(0,N.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`FQDN`}),(0,N.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Port`}),(0,N.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Agent`}),(0,N.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Access`}),(0,N.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Body limit`}),(0,N.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Description`}),(0,N.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Created`}),(0,N.jsx)(`th`,{className:`text-right text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Actions`})]})}),(0,N.jsx)(`tbody`,{children:e.map(e=>{let i=e.enabled!==!1,a=e.exposure===`internal`;return(0,N.jsxs)(`tr`,{className:`border-b border-zinc-700 ${i?`bg-zinc-800/50`:`bg-zinc-800/20 opacity-60`}`,children:[(0,N.jsx)(`td`,{className:`py-3 px-4`,children:(0,N.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full border ${i?`text-green-400 bg-green-500/10 border-green-500/20`:`text-zinc-500 bg-zinc-800 border-zinc-700`}`,children:i?`active`:`disabled`})}),(0,N.jsx)(`td`,{className:`py-3 px-4 text-sm text-zinc-200 font-mono`,children:a?(0,N.jsx)(_l,{tunnel:e}):e.subdomain}),(0,N.jsx)(`td`,{className:`py-3 px-4 text-sm`,children:a?(0,N.jsx)(`span`,{className:`text-zinc-500`,children:`relay loopback only`}):(0,N.jsxs)(`a`,{href:`https://${e.fqdn}`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 ${i?`text-cyan-400 hover:text-cyan-300`:`text-zinc-500`}`,children:[e.fqdn,(0,N.jsx)(Ei,{size:12})]})}),(0,N.jsx)(`td`,{className:`py-3 px-4 text-sm text-zinc-200 font-mono`,children:e.port}),(0,N.jsx)(`td`,{className:`py-3 px-4`,children:(0,N.jsx)(vl,{tunnel:e})}),(0,N.jsxs)(`td`,{className:`py-3 px-4 text-sm`,children:[a&&(0,N.jsx)(`span`,{className:`inline-block px-2 py-0.5 rounded text-xs bg-zinc-700/60 text-zinc-300`,children:`Internal`}),e.type!==`panel`&&!a&&(0,N.jsx)(`span`,{className:`inline-block px-2 py-0.5 rounded text-xs ${e.accessMode===`public`?`bg-green-500/10 text-green-400`:e.accessMode===`authenticated`?`bg-blue-500/10 text-blue-400`:`bg-orange-500/10 text-orange-400`}`,children:e.accessMode===`public`?`Public`:e.accessMode===`authenticated`?`All Users`:`Restricted`})]}),(0,N.jsx)(`td`,{className:`py-3 px-4 text-sm text-zinc-400 font-mono`,children:e.type===`panel`?`—`:`${ll(e)} MiB`}),(0,N.jsx)(`td`,{className:`py-3 px-4 text-sm text-zinc-400`,children:e.description||`—`}),(0,N.jsx)(`td`,{className:`py-3 px-4 text-sm text-zinc-500`,children:il(e.createdAt)}),(0,N.jsx)(`td`,{className:`py-3 px-4 text-right`,children:a?(0,N.jsx)(`span`,{className:`text-xs text-zinc-500`,title:`Managed with the plugin's hosting`,children:`managed by plugin hosting`}):(0,N.jsxs)(`div`,{className:`inline-flex items-center gap-2`,children:[e.type!==`panel`&&(0,N.jsxs)(`button`,{type:`button`,onClick:()=>r(e),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600`,title:`Agent, access mode, body limit`,children:[(0,N.jsx)(da,{size:12}),`Edit`]}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs hover:bg-zinc-600 ${i?`text-yellow-400`:`text-green-400`}`,title:i?`Disable tunnel`:`Enable tunnel`,children:[(0,N.jsx)(ra,{size:12}),i?`Disable`:`Enable`]}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>t(e),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-red-400 hover:bg-red-600/20 hover:text-red-300`,children:[(0,N.jsx)(ba,{size:12}),`Delete`]})]})})]},e.id)})})]})})}function bl({tunnels:e,onDelete:t,onToggle:n,onEdit:r}){return(0,N.jsx)(`div`,{className:`md:hidden space-y-3`,children:e.map(e=>{let i=e.enabled!==!1,a=e.exposure===`internal`;return(0,N.jsxs)(`div`,{className:`border border-zinc-700 rounded-lg p-4 ${i?`bg-zinc-800/50`:`bg-zinc-800/20 opacity-60`}`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full border ${i?`text-green-400 bg-green-500/10 border-green-500/20`:`text-zinc-500 bg-zinc-800 border-zinc-700`}`,children:i?`active`:`disabled`}),(0,N.jsx)(`span`,{className:`text-sm font-semibold text-zinc-200 font-mono`,children:a?(0,N.jsx)(_l,{tunnel:e}):e.subdomain})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.type!==`panel`&&!a&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:`text-xs text-zinc-300`,title:`Agent, access mode, body limit`,children:(0,N.jsx)(da,{size:14})}),!a&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:`text-xs ${i?`text-yellow-400`:`text-green-400`}`,children:(0,N.jsx)(ra,{size:14})}),!a&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>t(e),className:`inline-flex items-center gap-1 text-xs text-red-400 hover:text-red-300`,children:(0,N.jsx)(ba,{size:12})})]})]}),a?(0,N.jsx)(`p`,{className:`text-sm text-zinc-500 mb-1`,children:`Relay loopback only — managed by plugin hosting`}):(0,N.jsxs)(`a`,{href:`https://${e.fqdn}`,target:`_blank`,rel:`noopener noreferrer`,className:`text-sm inline-flex items-center gap-1 mb-1 ${i?`text-cyan-400 hover:text-cyan-300`:`text-zinc-500`}`,children:[e.fqdn,(0,N.jsx)(Ei,{size:12})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-4 text-xs text-zinc-500 mt-2`,children:[(0,N.jsxs)(`span`,{children:[`Port: `,(0,N.jsx)(`span`,{className:`text-zinc-300 font-mono`,children:e.port})]}),(0,N.jsxs)(`span`,{children:[`Agent: `,(0,N.jsx)(vl,{tunnel:e})]}),(0,N.jsx)(`span`,{children:il(e.createdAt)})]}),e.description&&(0,N.jsx)(`p`,{className:`text-xs text-zinc-400 mt-2`,children:e.description})]},e.id)})})}function xl(){let e=R(),t=P(),n=G(),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(null),l=F({queryKey:[`tunnels`],queryFn:()=>e.getTunnels(),refetchInterval:1e4}),u=F({queryKey:[`tunnel-agent-config`],queryFn:()=>e.getTunnelAgentConfig()}).data?.domain,d=I({mutationFn:t=>e.deleteTunnel(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`tunnels`]}),n(`Tunnel ${a.fqdn} deleted`),o(null)},onError:e=>{n(K(e),`error`),o(null)}}),f=I({mutationFn:({id:t,enabled:n})=>e.updateTunnel(t,{enabled:n}),onSuccess:e=>{t.invalidateQueries({queryKey:[`tunnels`]});let r=e.tunnel;n(`Tunnel ${r.fqdn} ${r.enabled?`enabled`:`disabled`}`)},onError:e=>{n(K(e),`error`)}}),p=I({mutationFn:({id:t,changes:n})=>e.updateTunnel(t,n),onSuccess:e=>{t.invalidateQueries({queryKey:[`tunnels`]}),n(`Tunnel ${e.tunnel.fqdn} updated`),c(null)},onError:e=>{n(K(e),`error`),c(null)}}),m=(0,g.useCallback)(e=>{c(e)},[]),h=(0,g.useCallback)(e=>{o(e)},[]),_=(0,g.useCallback)(e=>{let t=e.enabled!==!1;f.mutate({id:e.id,enabled:!t})},[f]),v=(0,g.useCallback)(()=>{a&&d.mutate(a.id)},[a,d]),y=l.data?.tunnels||[];return(0,N.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,N.jsxs)(`div`,{className:`mb-6 flex items-center justify-between`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Tunnels`}),(0,N.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`Manage reverse tunnel configurations`})]}),!r&&(0,N.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`flex items-center gap-2 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500`,children:[(0,N.jsx)(ta,{size:14}),`Add Tunnel`]})]}),r&&u&&(0,N.jsx)(ml,{domain:u,onClose:()=>i(!1)}),l.isLoading?(0,N.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:3}).map((e,t)=>(0,N.jsx)(`div`,{className:`h-16 animate-pulse rounded-lg bg-zinc-900 border border-zinc-800`},t))}):l.isError?(0,N.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,N.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Failed to load tunnels`})}):y.length===0?(0,N.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-12 text-center`,children:[(0,N.jsx)(Zi,{size:32,className:`mx-auto text-zinc-600 mb-3`}),(0,N.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:`No tunnels yet. Add your first tunnel to get started.`})]}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(yl,{tunnels:y,onDelete:h,onToggle:_,onEdit:m}),(0,N.jsx)(bl,{tunnels:y,onDelete:h,onToggle:_,onEdit:m})]}),s&&(0,N.jsx)(gl,{tunnel:s,onConfirm:e=>p.mutate({id:s.id,changes:e}),onCancel:()=>c(null),isPending:p.isPending}),a&&(0,N.jsx)(hl,{tunnel:a,onConfirm:v,onCancel:()=>o(null),isPending:d.isPending})]})}function Sl({hasDomain:e}){let t=R(),n=G(),r=P(),i=F({queryKey:[`settings-2fa`],queryFn:()=>t.get2faStatus()}),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)(``),[d,f]=(0,g.useState)(!1),[p,m]=(0,g.useState)(``),[h,_]=(0,g.useState)(!1),v=i.data||{enabled:!1,setupComplete:!1},y=I({mutationFn:()=>t.setup2fa(),onSuccess:e=>o(e)}),b=I({mutationFn:e=>t.confirm2fa(e),onSuccess:()=>{r.invalidateQueries(),o(null),c(``),n(`Two-factor authentication enabled`)}}),x=I({mutationFn:e=>t.disable2fa(e),onSuccess:()=>{r.invalidateQueries(),u(``),n(`Two-factor authentication disabled`)}}),S=I({mutationFn:e=>t.triggerPanelUpdate(e),onSuccess:()=>{n(`Update initiated. The panel will restart shortly.`),m(``),_(!1)},onError:e=>n(K(e),`error`)}),C=/^\d+\.\d+\.\d+$/.test(p);function w(){a?.manualKey&&navigator.clipboard.writeText(a.manualKey).then(()=>{f(!0),setTimeout(()=>f(!1),2e3)},()=>{n(`Failed to copy to clipboard`,`error`)})}function T(e){e.preventDefault(),s.length===6&&b.mutate(s)}function E(e){e.preventDefault(),l.length===6&&x.mutate(l)}if(i.isLoading)return(0,N.jsx)(`div`,{className:`p-6`,children:(0,N.jsx)(`div`,{className:`mx-auto h-6 w-6 animate-spin rounded-full border-2 border-zinc-600 border-t-cyan-400`})});if(i.isError)return(0,N.jsxs)(`div`,{className:`mx-auto max-w-2xl p-6`,children:[(0,N.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Settings`}),(0,N.jsx)(`p`,{className:`mt-4 text-sm text-red-400`,children:`Failed to load settings. Please try again.`})]});let D=b.error?.message,ee=x.error?.message,te=y.error?.message;return(0,N.jsxs)(`div`,{className:`mx-auto max-w-2xl p-6`,children:[(0,N.jsxs)(`div`,{className:`mb-6`,children:[(0,N.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Settings`}),(0,N.jsx)(`p`,{className:`mt-1 text-sm text-zinc-500`,children:`Configure panel security settings.`})]}),(0,N.jsxs)(`div`,{className:`rounded-lg border border-zinc-800 bg-zinc-900 p-6`,children:[(0,N.jsxs)(`div`,{className:`mb-4 flex items-center gap-3`,children:[(0,N.jsx)(ma,{className:`h-5 w-5 text-cyan-400`}),(0,N.jsx)(`h2`,{className:`text-lg font-bold text-white`,children:`Two-Factor Authentication`}),v.enabled&&(0,N.jsx)(`span`,{className:`rounded-full border border-green-500/20 bg-green-500/10 px-2 py-0.5 text-xs text-green-400`,children:`Enabled`})]}),!v.enabled&&!a&&(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{className:`mb-4 text-sm text-zinc-400`,children:`Add a second layer of protection to the admin panel. When enabled, you will need both your mTLS certificate and a TOTP code from your authenticator app to access the panel.`}),!e&&(0,N.jsxs)(`div`,{className:`mb-4 flex items-start gap-2 rounded-lg border border-yellow-500/20 bg-yellow-500/5 p-3`,children:[(0,N.jsx)(xa,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-yellow-400`}),(0,N.jsx)(`p`,{className:`text-sm text-yellow-400`,children:`A domain must be configured before enabling 2FA. Enabling 2FA disables IP:9292 access.`})]}),te&&(0,N.jsx)(`p`,{className:`mb-3 text-sm text-red-400`,children:te}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>y.mutate(),disabled:!e||y.isPending,className:`rounded-lg bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:cursor-not-allowed disabled:opacity-50`,children:y.isPending?`Setting up...`:`Enable Two-Factor Authentication`}),e&&(0,N.jsx)(`p`,{className:`mt-3 text-xs text-zinc-600`,children:`This will disable IP:9292 access. The panel will only be accessible via domain.`})]}),!v.enabled&&a&&(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{className:`mb-4 text-sm text-zinc-400`,children:`Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)`}),(0,N.jsx)(`div`,{className:`mb-4 flex justify-center`,children:(0,N.jsx)(`div`,{className:`rounded-lg bg-zinc-950 p-4`,children:(0,N.jsx)(is,{value:a.uri,size:200,bgColor:`transparent`,fgColor:`#ffffff`})})}),(0,N.jsx)(`p`,{className:`mb-2 text-sm text-zinc-400`,children:`Or enter this code manually:`}),(0,N.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 rounded-lg bg-zinc-950 px-4 py-3`,children:[(0,N.jsx)(`code`,{className:`flex-1 font-mono text-sm tracking-wider text-cyan-400`,children:a.manualKey?.replace(/(.{4})/g,`$1 `).trim()}),(0,N.jsx)(`button`,{type:`button`,onClick:w,className:`text-zinc-500 hover:text-zinc-300`,title:`Copy secret`,children:d?(0,N.jsx)(ui,{size:16,className:`text-green-400`}):(0,N.jsx)(xi,{size:16})})]}),(0,N.jsxs)(`form`,{onSubmit:T,className:`space-y-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`mb-1 block text-sm text-zinc-400`,children:`Enter the code from your authenticator to confirm`}),(0,N.jsx)(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,value:s,onChange:e=>c(e.target.value.replace(/\D/g,``).slice(0,6)),placeholder:`000000`,maxLength:6,className:`w-full rounded-lg border border-zinc-700 bg-zinc-950 px-3 py-2 font-mono text-center text-lg tracking-[0.2em] text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),D&&(0,N.jsx)(`p`,{className:`text-sm text-red-400`,children:D}),(0,N.jsxs)(`div`,{className:`flex gap-3`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>{o(null),c(``),b.reset()},className:`flex-1 rounded-lg border border-zinc-700 px-4 py-2 text-sm text-zinc-400 hover:text-white`,children:`Cancel`}),(0,N.jsx)(`button`,{type:`submit`,disabled:b.isPending||s.length!==6,className:`flex-1 rounded-lg bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:b.isPending?`Confirming...`:`Confirm & Enable`})]})]})]}),v.enabled&&(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{className:`mb-4 text-sm text-zinc-400`,children:`Two-factor authentication is active. The panel requires both your mTLS certificate and a TOTP code.`}),(0,N.jsx)(`div`,{className:`mb-4 rounded-lg border border-zinc-700 bg-zinc-950 p-3`,children:(0,N.jsxs)(`p`,{className:`text-xs text-zinc-500`,children:[`Recovery: if you lose access to your authenticator, run`,` `,(0,N.jsx)(`code`,{className:`text-zinc-400`,children:`sudo lamaste-reset-admin`}),` on the server via the DigitalOcean console. This will reset admin auth to P12 and disable 2FA.`]})}),(0,N.jsxs)(`form`,{onSubmit:E,className:`space-y-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`mb-1 block text-sm text-zinc-400`,children:`Enter a TOTP code to disable 2FA`}),(0,N.jsx)(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,value:l,onChange:e=>u(e.target.value.replace(/\D/g,``).slice(0,6)),placeholder:`000000`,maxLength:6,className:`w-full rounded-lg border border-zinc-700 bg-zinc-950 px-3 py-2 font-mono text-center text-lg tracking-[0.2em] text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),ee&&(0,N.jsx)(`p`,{className:`text-sm text-red-400`,children:ee}),(0,N.jsx)(`button`,{type:`submit`,disabled:x.isPending||l.length!==6,className:`rounded-lg border border-red-500/30 bg-red-500/10 px-4 py-2 text-sm font-semibold text-red-400 hover:bg-red-500/20 disabled:opacity-50`,children:x.isPending?`Disabling...`:`Disable Two-Factor Authentication`})]})]})]}),(0,N.jsxs)(`div`,{className:`mt-6 rounded-lg border border-zinc-800 bg-zinc-900 p-6`,children:[(0,N.jsxs)(`div`,{className:`mb-4 flex items-center gap-3`,children:[(0,N.jsx)(ia,{className:`h-5 w-5 text-cyan-400`}),(0,N.jsx)(`h2`,{className:`text-lg font-bold text-white`,children:`Panel Update`})]}),(0,N.jsx)(`p`,{className:`mb-4 text-sm text-zinc-400`,children:`Trigger an update of the panel server to a specific version. The server will restart automatically after the update completes.`}),(0,N.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,N.jsxs)(`div`,{className:`flex-1`,children:[(0,N.jsx)(`label`,{className:`mb-1 block text-sm text-zinc-400`,htmlFor:`update-version`,children:`Version`}),(0,N.jsx)(`input`,{id:`update-version`,type:`text`,value:p,onChange:e=>m(e.target.value.trim()),placeholder:`1.0.43`,className:`w-full rounded-lg border border-zinc-700 bg-zinc-950 px-3 py-2 text-sm text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none font-mono`})]}),(0,N.jsx)(`button`,{type:`button`,disabled:!C||S.isPending,onClick:()=>_(!0),className:`rounded-lg bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:cursor-not-allowed disabled:opacity-50`,children:`Update Panel`})]}),!C&&p.length>0&&(0,N.jsx)(`p`,{className:`mt-2 text-xs text-red-400`,children:`Version must be in semver format (e.g. 1.0.43)`}),S.error&&(0,N.jsx)(`p`,{className:`mt-2 text-sm text-red-400`,children:S.error.message}),h&&(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,N.jsxs)(`div`,{className:`w-full max-w-sm rounded-xl border border-zinc-700 bg-zinc-900 p-6 shadow-xl`,children:[(0,N.jsxs)(`div`,{className:`mb-4 flex items-center gap-2`,children:[(0,N.jsx)(xa,{className:`h-5 w-5 text-amber-400`}),(0,N.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:`Confirm Update`})]}),(0,N.jsxs)(`p`,{className:`mb-4 text-sm text-zinc-400`,children:[`This will update the panel server to version`,` `,(0,N.jsx)(`strong`,{className:`text-white`,children:p}),` and restart the service. The panel will be unavailable for 1-2 minutes.`]}),(0,N.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>_(!1),className:`rounded-lg border border-zinc-700 px-4 py-2 text-sm text-zinc-400 hover:text-white`,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,disabled:S.isPending,onClick:()=>S.mutate({version:p}),className:`rounded-lg bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:S.isPending?`Updating...`:`Update Now`})]})]})})]})]})}function Cl({onClose:e}){let t=R(),n=P(),r=G(),[i,a]=(0,g.useState)({id:crypto.randomUUID(),label:``,provider:`digitalocean-spaces`,region:``,bucket:``,endpoint:``,accessKey:``,secretKey:``}),o=I({mutationFn:e=>t.registerStorageServer(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`storage-servers`]}),r(`Storage server registered`),e()},onError:e=>r(K(e),`error`)}),s=(e,t)=>a(n=>({...n,[e]:t})),c=i.label&&i.region&&i.bucket&&i.endpoint&&i.accessKey&&i.secretKey;return(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,N.jsxs)(`div`,{className:`w-full max-w-lg rounded-xl bg-zinc-900 border border-zinc-700 p-6 shadow-xl`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,N.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:`Register Storage Server`}),(0,N.jsx)(`button`,{type:`button`,onClick:e,className:`text-zinc-400 hover:text-white`,children:(0,N.jsx)(ka,{size:20})})]}),(0,N.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),o.mutate(i)},className:`space-y-4`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Label`}),(0,N.jsx)(`input`,{type:`text`,value:i.label,onChange:e=>s(`label`,e.target.value),placeholder:`my-storage`,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),(0,N.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Provider`}),(0,N.jsxs)(`select`,{value:i.provider,onChange:e=>s(`provider`,e.target.value),className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 focus:border-cyan-500 focus:outline-none`,children:[(0,N.jsx)(`option`,{value:`digitalocean-spaces`,children:`DigitalOcean Spaces`}),(0,N.jsx)(`option`,{value:`s3`,children:`Amazon S3`})]})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Region`}),(0,N.jsx)(`input`,{type:`text`,value:i.region,onChange:e=>s(`region`,e.target.value),placeholder:`nyc3`,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Bucket`}),(0,N.jsx)(`input`,{type:`text`,value:i.bucket,onChange:e=>s(`bucket`,e.target.value),placeholder:`my-bucket`,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Endpoint URL`}),(0,N.jsx)(`input`,{type:`url`,value:i.endpoint,onChange:e=>s(`endpoint`,e.target.value),placeholder:`https://nyc3.digitaloceanspaces.com`,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Access Key`}),(0,N.jsx)(`input`,{type:`password`,value:i.accessKey,onChange:e=>s(`accessKey`,e.target.value),className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono focus:border-cyan-500 focus:outline-none`})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Secret Key`}),(0,N.jsx)(`input`,{type:`password`,value:i.secretKey,onChange:e=>s(`secretKey`,e.target.value),className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono focus:border-cyan-500 focus:outline-none`})]}),(0,N.jsx)(`div`,{className:`rounded bg-amber-500/10 border border-amber-500/20 px-3 py-2`,children:(0,N.jsx)(`p`,{className:`text-xs text-amber-300`,children:`Credentials are encrypted at rest using AES-256-GCM. They never leave the server.`})}),(0,N.jsxs)(`div`,{className:`flex justify-end gap-3 pt-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:e,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:`Cancel`}),(0,N.jsxs)(`button`,{type:`submit`,disabled:!c||o.isPending,className:`rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:[o.isPending?(0,N.jsx)(V,{size:14,className:`animate-spin inline mr-1`}):null,`Register`]})]})]})]})})}function wl({servers:e,onClose:t}){let n=R(),r=P(),i=G(),[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(e[0]?.id||``),l=F({queryKey:[`plugins`],queryFn:()=>n.getPlugins()}),u=I({mutationFn:e=>n.createStorageBinding(e),onSuccess:()=>{r.invalidateQueries({queryKey:[`storage-bindings`]}),i(`Plugin bound to storage`),t()},onError:e=>i(K(e),`error`)}),d=l.data?.plugins||[];return(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,N.jsxs)(`div`,{className:`w-full max-w-md rounded-xl bg-zinc-900 border border-zinc-700 p-6 shadow-xl`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,N.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:`Bind Plugin to Storage`}),(0,N.jsx)(`button`,{type:`button`,onClick:t,className:`text-zinc-400 hover:text-white`,children:(0,N.jsx)(ka,{size:20})})]}),(0,N.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),u.mutate({pluginName:a,storageServerId:s})},className:`space-y-4`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Plugin`}),(0,N.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value),className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 focus:border-cyan-500 focus:outline-none`,children:[(0,N.jsx)(`option`,{value:``,children:`Select a plugin...`}),d.map(e=>(0,N.jsx)(`option`,{value:e.name,children:e.displayName||e.name},e.name))]})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Storage Server`}),(0,N.jsx)(`select`,{value:s,onChange:e=>c(e.target.value),className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 focus:border-cyan-500 focus:outline-none`,children:e.map(e=>(0,N.jsxs)(`option`,{value:e.id,children:[e.label,` (`,e.provider,` / `,e.region,`)`]},e.id))})]}),(0,N.jsxs)(`div`,{className:`flex justify-end gap-3 pt-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:t,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:`Cancel`}),(0,N.jsxs)(`button`,{type:`submit`,disabled:!a||!s||u.isPending,className:`rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:[u.isPending?(0,N.jsx)(V,{size:14,className:`animate-spin inline mr-1`}):null,`Bind`]})]})]})]})})}function Tl(){let e=R(),t=P(),n=G(),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)(!1),[s,c]=(0,g.useState)(null),[l,u]=(0,g.useState)(null),d=F({queryKey:[`storage-servers`],queryFn:()=>e.getStorageServers(),refetchInterval:1e4}),f=F({queryKey:[`storage-bindings`],queryFn:()=>e.getStorageBindings(),refetchInterval:1e4}),p=I({mutationFn:t=>e.deleteStorageServer(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`storage-servers`]}),t.invalidateQueries({queryKey:[`storage-bindings`]}),n(`Storage server removed`),c(null)},onError:e=>{n(K(e),`error`),c(null)}}),m=I({mutationFn:t=>e.deleteStorageBinding(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`storage-bindings`]}),n(`Plugin unbound from storage`),u(null)},onError:e=>{n(K(e),`error`),u(null)}}),h=d.data?.servers||[],_=f.data?.bindings||[];return(0,N.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,N.jsxs)(`div`,{className:`mb-6`,children:[(0,N.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Storage`}),(0,N.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`Manage S3-compatible storage servers and bind them to plugins.`})]}),(0,N.jsxs)(`div`,{className:`mb-8`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,N.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,N.jsx)(Ii,{size:18,className:`text-cyan-400`}),`Storage Servers`]}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`flex items-center gap-2 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500`,children:[(0,N.jsx)(ta,{size:14}),`Register Server`]})]}),d.isLoading?(0,N.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:2}).map((e,t)=>(0,N.jsx)(`div`,{className:`h-14 animate-pulse rounded-lg bg-zinc-900 border border-zinc-800`},t))}):d.isError?(0,N.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-2 text-red-400 text-sm`,children:[(0,N.jsx)(hi,{size:16}),`Failed to load storage servers`]})}):h.length===0?(0,N.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-8 text-center`,children:[(0,N.jsx)(Ii,{size:32,className:`mx-auto text-zinc-600 mb-3`}),(0,N.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:`No storage servers registered. Register one to enable plugin storage.`})]}):(0,N.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-zinc-800`,children:(0,N.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,N.jsx)(`thead`,{children:(0,N.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-900`,children:[(0,N.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Label`}),(0,N.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Provider`}),(0,N.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400 hidden md:table-cell`,children:`Region`}),(0,N.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400 hidden lg:table-cell`,children:`Bucket`}),(0,N.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400 hidden lg:table-cell`,children:`Registered`}),(0,N.jsx)(`th`,{className:`px-4 py-3 text-right text-xs font-medium uppercase text-zinc-400`,children:`Actions`})]})}),(0,N.jsx)(`tbody`,{children:h.map(e=>(0,N.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-800`,children:[(0,N.jsx)(`td`,{className:`px-4 py-3 text-zinc-200 font-semibold`,children:e.label}),(0,N.jsx)(`td`,{className:`px-4 py-3 text-zinc-400`,children:e.provider}),(0,N.jsx)(`td`,{className:`px-4 py-3 text-zinc-400 hidden md:table-cell`,children:e.region}),(0,N.jsx)(`td`,{className:`px-4 py-3 text-zinc-400 font-mono text-xs hidden lg:table-cell`,children:e.bucket}),(0,N.jsx)(`td`,{className:`px-4 py-3 text-zinc-500 hidden lg:table-cell`,children:e.registeredAt?_r(e.registeredAt):`—`}),(0,N.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,N.jsx)(`button`,{type:`button`,onClick:()=>c(e),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-zinc-300 hover:bg-red-600/20 hover:text-red-400`,title:`Remove server`,children:(0,N.jsx)(ba,{size:12})})})]},e.id))})]})})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,N.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,N.jsx)(Wi,{size:18,className:`text-cyan-400`}),`Plugin Bindings`]}),h.length>0&&(0,N.jsxs)(`button`,{type:`button`,onClick:()=>o(!0),className:`flex items-center gap-2 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500`,children:[(0,N.jsx)(ta,{size:14}),`Bind Plugin`]})]}),f.isLoading?(0,N.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:2}).map((e,t)=>(0,N.jsx)(`div`,{className:`h-14 animate-pulse rounded-lg bg-zinc-900 border border-zinc-800`},t))}):f.isError?(0,N.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-2 text-red-400 text-sm`,children:[(0,N.jsx)(hi,{size:16}),`Failed to load bindings`]})}):_.length===0?(0,N.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-8 text-center`,children:[(0,N.jsx)(Wi,{size:32,className:`mx-auto text-zinc-600 mb-3`}),(0,N.jsxs)(`p`,{className:`text-zinc-400 text-sm`,children:[`No plugins bound to storage.`,` `,h.length===0?`Register a storage server first.`:`Use the button above to bind one.`]})]}):(0,N.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-zinc-800`,children:(0,N.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,N.jsx)(`thead`,{children:(0,N.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-900`,children:[(0,N.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Plugin`}),(0,N.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Storage Server`}),(0,N.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400 hidden md:table-cell`,children:`Bound`}),(0,N.jsx)(`th`,{className:`px-4 py-3 text-right text-xs font-medium uppercase text-zinc-400`,children:`Actions`})]})}),(0,N.jsx)(`tbody`,{children:_.map(e=>{let t=h.find(t=>t.id===e.storageServerId);return(0,N.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-800`,children:[(0,N.jsx)(`td`,{className:`px-4 py-3 text-zinc-200 font-semibold`,children:e.pluginName}),(0,N.jsx)(`td`,{className:`px-4 py-3 text-zinc-400`,children:t?.label||e.storageServerId.slice(0,8)}),(0,N.jsx)(`td`,{className:`px-4 py-3 text-zinc-500 hidden md:table-cell`,children:e.boundAt?_r(e.boundAt):`—`}),(0,N.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,N.jsx)(`button`,{type:`button`,onClick:()=>u(e.pluginName),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-zinc-300 hover:bg-red-600/20 hover:text-red-400`,title:`Unbind plugin`,children:(0,N.jsx)(wa,{size:12})})})]},e.pluginName)})})]})})]}),r&&(0,N.jsx)(Cl,{onClose:()=>i(!1)}),a&&(0,N.jsx)(wl,{servers:h,onClose:()=>o(!1)}),s&&(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,N.jsxs)(`div`,{className:`w-full max-w-sm rounded-xl border border-zinc-700 bg-zinc-900 p-6 shadow-xl`,children:[(0,N.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-3`,children:`Remove Storage Server`}),(0,N.jsxs)(`p`,{className:`text-sm text-zinc-400 mb-2`,children:[`Are you sure you want to remove`,` `,(0,N.jsx)(`strong`,{className:`text-white`,children:s.label}),`?`]}),(0,N.jsx)(`p`,{className:`text-xs text-amber-400 mb-4`,children:`All plugin bindings to this server will also be removed.`}),(0,N.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>c(null),className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,disabled:p.isPending,onClick:()=>p.mutate(s.id),className:`rounded bg-red-600 px-4 py-2 text-sm font-semibold text-white hover:bg-red-500 disabled:opacity-50`,children:p.isPending?`Removing...`:`Remove`})]})]})}),l&&(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,N.jsxs)(`div`,{className:`w-full max-w-sm rounded-xl border border-zinc-700 bg-zinc-900 p-6 shadow-xl`,children:[(0,N.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-3`,children:`Unbind Plugin`}),(0,N.jsxs)(`p`,{className:`text-sm text-zinc-400 mb-4`,children:[`Remove storage binding for `,(0,N.jsx)(`strong`,{className:`text-white`,children:l}),`?`]}),(0,N.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>u(null),className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:`Cancel`}),(0,N.jsx)(`button`,{type:`button`,disabled:m.isPending,onClick:()=>m.mutate(l),className:`rounded bg-red-600 px-4 py-2 text-sm font-semibold text-white hover:bg-red-500 disabled:opacity-50`,children:m.isPending?`Unbinding...`:`Unbind`})]})]})})]})}var El=50,Dl={info:`text-cyan-400`,warning:`text-yellow-400`,critical:`text-red-400`};function Ol(){let e=R(),t=P(),n=G(),r=F({queryKey:[`notifications`],queryFn:()=>e.getNotifications({limit:50}),refetchInterval:3e4}),i=I({mutationFn:()=>e.markNotificationsRead({all:!0}),onSuccess:()=>t.invalidateQueries({queryKey:[`notifications`]}),onError:e=>n(K(e),`error`)}),a=r.data?.notifications??[],o=r.data?.unread??0;return(0,N.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-5 mb-6`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,N.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-zinc-300`,children:[(0,N.jsx)(si,{size:14,className:`text-cyan-400`}),` Notifications`,o>0&&(0,N.jsx)(`span`,{className:`rounded-full bg-cyan-500/20 px-2 text-xs text-cyan-400`,children:o})]}),o>0&&(0,N.jsxs)(`button`,{type:`button`,disabled:i.isPending,onClick:()=>i.mutate(),className:`flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1 text-xs text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:[(0,N.jsx)(li,{size:12}),` Mark all read`]})]}),a.length===0?(0,N.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Nothing to report.`}):(0,N.jsx)(`ul`,{className:`space-y-1.5 text-xs`,children:a.map(e=>(0,N.jsxs)(`li`,{className:`flex gap-3 ${e.read?`opacity-60`:``}`,children:[(0,N.jsx)(`span`,{className:`shrink-0 text-zinc-500`,children:new Date(e.at).toLocaleString()}),(0,N.jsx)(`span`,{className:`shrink-0 ${Dl[e.level]??`text-zinc-400`}`,children:e.level}),(0,N.jsx)(`span`,{className:`shrink-0 font-mono text-zinc-500`,children:e.source}),(0,N.jsx)(`span`,{className:`text-zinc-300 break-words`,children:e.message})]},e.id))})]})}function kl(e){return Object.entries(e??{}).map(([e,t])=>`${e}=${typeof t==`object`&&t?JSON.stringify(t):t}`).join(` `)}function Al(){let e=R(),[t,n]=(0,g.useState)(``),[r,i]=(0,g.useState)(``),a={plugin:t.trim()||void 0,action:r.trim()||void 0},o=mr({queryKey:[`audit`,a],queryFn:({pageParam:t})=>e.getAuditLog({...a,limit:El,...t?{before:t}:{}}),initialPageParam:void 0,getNextPageParam:e=>e.entries.length===El?e.entries[e.entries.length-1].id:void 0,refetchInterval:3e4}),s=o.data?.pages.flatMap(e=>e.entries)??[];return(0,N.jsxs)(`div`,{className:`p-6 max-w-5xl mx-auto`,children:[(0,N.jsxs)(`div`,{className:`mb-6`,children:[(0,N.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Audit`}),(0,N.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`What administrators decided and what plugins' hooks reported — metadata only, never a request or response body.`})]}),(0,N.jsx)(Ol,{}),(0,N.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-5`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 mb-4`,children:[(0,N.jsx)(ca,{size:14,className:`text-cyan-400`}),(0,N.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-300 mr-4`,children:`Audit log`}),(0,N.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),placeholder:`plugin`,className:`w-36 rounded bg-zinc-800 border border-zinc-700 px-2 py-1 text-xs text-zinc-300 focus:outline-none focus:border-cyan-400`}),(0,N.jsx)(`input`,{type:`text`,value:r,onChange:e=>i(e.target.value),placeholder:`action, or prefix ending in .`,className:`w-56 rounded bg-zinc-800 border border-zinc-700 px-2 py-1 text-xs text-zinc-300 focus:outline-none focus:border-cyan-400`})]}),o.isError?(0,N.jsxs)(`div`,{className:`flex items-center gap-2 text-red-400 text-sm`,children:[(0,N.jsx)(hi,{size:16}),` Failed to load the audit log`]}):s.length===0?(0,N.jsx)(`p`,{className:`text-xs text-zinc-500`,children:o.isLoading?`Loading…`:`No entries.`}):(0,N.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,N.jsx)(`thead`,{children:(0,N.jsxs)(`tr`,{className:`text-left text-zinc-500`,children:[(0,N.jsx)(`th`,{className:`pb-2 pr-3 font-normal`,children:`When`}),(0,N.jsx)(`th`,{className:`pb-2 pr-3 font-normal`,children:`Action`}),(0,N.jsx)(`th`,{className:`pb-2 pr-3 font-normal`,children:`Actor`}),(0,N.jsx)(`th`,{className:`pb-2 pr-3 font-normal`,children:`Plugin`}),(0,N.jsx)(`th`,{className:`pb-2 font-normal`,children:`Details`})]})}),(0,N.jsx)(`tbody`,{children:s.map(e=>(0,N.jsxs)(`tr`,{className:`border-t border-zinc-800 align-top`,children:[(0,N.jsx)(`td`,{className:`py-1.5 pr-3 whitespace-nowrap text-zinc-500`,children:new Date(e.at).toLocaleString()}),(0,N.jsx)(`td`,{className:`py-1.5 pr-3 font-mono text-cyan-400`,children:e.action}),(0,N.jsx)(`td`,{className:`py-1.5 pr-3 font-mono text-zinc-300`,children:e.actor}),(0,N.jsx)(`td`,{className:`py-1.5 pr-3 font-mono text-zinc-300`,children:e.plugin??``}),(0,N.jsx)(`td`,{className:`py-1.5 font-mono text-zinc-500 break-all`,children:kl(e.details)})]},e.id))})]}),o.hasNextPage&&(0,N.jsx)(`button`,{type:`button`,disabled:o.isFetchingNextPage,onClick:()=>o.fetchNextPage(),className:`mt-3 rounded bg-zinc-700 px-3 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Load older`})]})]})}function X(e,t){return L(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}function jl(e,t){return L(e,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}function Ml(e,t){return L(e,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}function Nl(e,t){let n={method:`DELETE`};return t&&(n.headers={"Content-Type":`application/json`},n.body=JSON.stringify(t)),L(e,n)}function Pl(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))r!=null&&r!==``&&t.set(n,String(r));let n=t.toString();return n?`?${n}`:``}function Fl({force:e=!1,purge:t=!1}={}){return Pl({force:e?`true`:void 0,purge:t?`true`:void 0})}var Il={getUsers:()=>L(`/api/users`),createUser:e=>X(`/api/users`,e),updateUser:(e,t)=>jl(`/api/users/${encodeURIComponent(e)}`,t),deleteUser:e=>Nl(`/api/users/${encodeURIComponent(e)}`),resetTotp:e=>X(`/api/users/${encodeURIComponent(e)}/reset-totp`),getInvitations:()=>L(`/api/invitations`),createInvitation:e=>X(`/api/invitations`,e),revokeInvitation:e=>Nl(`/api/invitations/${encodeURIComponent(e)}`),getSites:()=>L(`/api/sites`),createSite:e=>X(`/api/sites`,e),deleteSite:e=>Nl(`/api/sites/${encodeURIComponent(e)}`),updateSite:(e,t)=>Ml(`/api/sites/${encodeURIComponent(e)}`,t),getSiteFiles:(e,t)=>{let n=t&&t!==`.`?`?path=${encodeURIComponent(t)}`:``;return L(`/api/sites/${encodeURIComponent(e)}/files${n}`)},uploadSiteFiles:(e,t,n)=>{let r=new FormData;for(let e of n)r.append(`files`,e);let i=t&&t!==`.`?`?path=${encodeURIComponent(t)}`:``;return L(`/api/sites/${encodeURIComponent(e)}/files${i}`,{method:`POST`,body:r})},deleteSiteFile:(e,t)=>Nl(`/api/sites/${encodeURIComponent(e)}/files`,{path:t}),verifySiteDns:e=>X(`/api/sites/${encodeURIComponent(e)}/verify-dns`),getCerts:()=>L(`/api/certs`),renewCert:e=>X(`/api/certs/${encodeURIComponent(e)}/renew`),rotateMtls:()=>X(`/api/certs/mtls/rotate`),downloadMtls:async()=>{let e=await fetch(`/api/certs/mtls/download`,{credentials:`same-origin`});if(!e.ok)throw Error(`Download failed`);let t=await e.blob(),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`client.p12`,r.click(),URL.revokeObjectURL(n)},getAuthMode:()=>L(`/api/certs/admin/auth-mode`),getAutoRenewStatus:()=>L(`/api/certs/auto-renew-status`),getAgentCerts:()=>L(`/api/certs/agent`),generateAgentCert:e=>X(`/api/certs/agent`,e),revokeAgentCert:e=>Nl(`/api/certs/agent/${encodeURIComponent(e)}`),createEnrollmentToken:e=>X(`/api/certs/agent/enroll`,e),revokeEnrollmentToken:e=>Nl(`/api/certs/agent/enroll/${encodeURIComponent(e)}`),updateAgentCapabilities:(e,t)=>Ml(`/api/certs/agent/${encodeURIComponent(e)}/capabilities`,{capabilities:t}),updateAgentAllowedSites:(e,t)=>Ml(`/api/certs/agent/${encodeURIComponent(e)}/allowed-sites`,{allowedSites:t}),downloadAgentCert:async e=>{let t=await fetch(`/api/certs/agent/${encodeURIComponent(e)}/download`,{credentials:`same-origin`});if(!t.ok)throw Error(`Download failed`);let n=await t.blob(),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e}.p12`,i.click(),URL.revokeObjectURL(r)},getServices:()=>L(`/api/services`),serviceAction:(e,t)=>X(`/api/services/${encodeURIComponent(e)}/${encodeURIComponent(t)}`),getSystemStats:()=>L(`/api/system/stats`),triggerPanelUpdate:e=>X(`/api/system/update`,e),startLogStream:(e,t)=>{let n=`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}/api/services/${encodeURIComponent(e)}/logs`,r=new WebSocket(n);return r.onmessage=e=>{try{t(JSON.parse(e.data))}catch{t({message:e.data,timestamp:new Date().toISOString()})}},r.onerror=()=>{},r.onclose=()=>{},()=>r.close()},getTicketScopes:()=>L(`/api/tickets/scopes`),createTicketScope:e=>X(`/api/tickets/scopes`,e),deleteTicketScope:e=>Nl(`/api/tickets/scopes/${encodeURIComponent(e)}`),getTicketInstances:()=>L(`/api/tickets/instances`),deleteTicketInstance:e=>Nl(`/api/tickets/instances/${encodeURIComponent(e)}`),getTicketAssignments:()=>L(`/api/tickets/assignments`),createTicketAssignment:e=>X(`/api/tickets/assignments`,e),deleteTicketAssignment:(e,t)=>Nl(`/api/tickets/assignments/${encodeURIComponent(e)}/${encodeURIComponent(t)}`),getTickets:()=>L(`/api/tickets`),revokeTicket:e=>Nl(`/api/tickets/${encodeURIComponent(e)}`),getTicketSessions:()=>L(`/api/tickets/sessions`),killTicketSession:e=>Nl(`/api/tickets/sessions/${encodeURIComponent(e)}`),getPlugins:()=>L(`/api/plugins`),installPlugin:e=>X(`/api/plugins/install`,{packageName:e}),enablePlugin:e=>X(`/api/plugins/${encodeURIComponent(e)}/enable`),disablePlugin:e=>X(`/api/plugins/${encodeURIComponent(e)}/disable`),uninstallPlugin:(e,t={})=>Nl(`/api/plugins/${encodeURIComponent(e)}${Fl(t)}`),getPluginHosting:e=>L(`/api/plugins/${encodeURIComponent(e)}/hosting`),getPluginHostingEligibility:e=>L(`/api/plugins/${encodeURIComponent(e)}/hosting/eligibility`),setPluginHosting:(e,t)=>X(`/api/plugins/${encodeURIComponent(e)}/hosting`,{agentLabel:t}),clearPluginHosting:(e,t={})=>Nl(`/api/plugins/${encodeURIComponent(e)}/hosting${Fl(t)}`),rotatePluginHostingSecret:e=>X(`/api/plugins/${encodeURIComponent(e)}/hosting/rotate-secret`),getPluginRetainedData:e=>L(`/api/plugins/${encodeURIComponent(e)}/retained-data`),purgePluginRetainedData:(e,t)=>Nl(`/api/plugins/${encodeURIComponent(e)}/retained-data${Pl({agentLabel:t})}`),forgetPluginRetainedData:(e,t)=>Nl(`/api/plugins/${encodeURIComponent(e)}/retained-data${Pl({agentLabel:t,forget:`true`})}`),getPluginSettings:e=>L(`/api/plugins/${encodeURIComponent(e)}/settings`),updatePluginSettings:(e,t)=>jl(`/api/plugins/${encodeURIComponent(e)}/settings`,t),getPluginOperations:e=>L(`/api/plugins/${encodeURIComponent(e)}/operations`),getPluginOperation:(e,t)=>L(`/api/plugins/${encodeURIComponent(e)}/operations/${encodeURIComponent(t)}`),getPluginHooks:e=>L(`/api/plugins/${encodeURIComponent(e)}/hooks`),approvePluginHooks:(e,t,n)=>X(`/api/plugins/${encodeURIComponent(e)}/hooks/approve`,{digest:t,...n?{version:n}:{}}),setPluginHooksAutoApprove:(e,t)=>jl(`/api/plugins/${encodeURIComponent(e)}/hooks/auto-approve`,{enabled:t}),updatePlugin:(e,t)=>X(`/api/plugins/${encodeURIComponent(e)}/update`,t?{version:t}:{}),discardPluginUpdate:e=>Nl(`/api/plugins/${encodeURIComponent(e)}/update`),fetchPluginBundle:async e=>{let t=await fetch(`/api/${encodeURIComponent(e)}/panel.js`);if(!t.ok)throw Error(`Failed to load plugin bundle for "${e}"`);return t.text()},getPushInstallConfig:()=>L(`/api/plugins/push-install/config`),updatePushInstallConfig:e=>Ml(`/api/plugins/push-install/config`,e),getPushInstallPolicies:()=>L(`/api/plugins/push-install/policies`),createPushInstallPolicy:e=>X(`/api/plugins/push-install/policies`,e),deletePushInstallPolicy:e=>Nl(`/api/plugins/push-install/policies/${encodeURIComponent(e)}`),updatePushInstallPolicy:(e,t)=>Ml(`/api/plugins/push-install/policies/${encodeURIComponent(e)}`,t),enablePushInstall:(e,t)=>X(`/api/plugins/push-install/enable/${encodeURIComponent(e)}`,t),disablePushInstall:e=>Nl(`/api/plugins/push-install/enable/${encodeURIComponent(e)}`),pushInstallCommand:(e,t)=>X(`/api/plugins/push-install/${encodeURIComponent(e)}`,t),getPushInstallSessions:()=>L(`/api/plugins/push-install/sessions`),getAuditLog:(e={})=>L(`/api/audit${Pl(e)}`),getNotifications:(e={})=>L(`/api/notifications${Pl(e)}`),markNotificationsRead:e=>X(`/api/notifications/read`,e),registerStorageServer:e=>X(`/api/storage/servers`,e),getStorageServers:()=>L(`/api/storage/servers`),deleteStorageServer:e=>Nl(`/api/storage/servers/${encodeURIComponent(e)}`),createStorageBinding:e=>X(`/api/storage/bindings`,e),getStorageBindings:()=>L(`/api/storage/bindings`),getStorageBinding:e=>L(`/api/storage/bindings/${encodeURIComponent(e)}`),deleteStorageBinding:e=>Nl(`/api/storage/bindings/${encodeURIComponent(e)}`),getIdentitySelf:()=>L(`/api/identity/self`),getIdentityUsers:()=>L(`/api/identity/users`),getIdentityUser:e=>L(`/api/identity/users/${encodeURIComponent(e)}`),getIdentityGroups:()=>L(`/api/identity/groups`),get2faStatus:()=>L(`/api/settings/2fa`),setup2fa:()=>X(`/api/settings/2fa/setup`),confirm2fa:e=>X(`/api/settings/2fa/confirm`,{code:e}),verify2fa:e=>X(`/api/settings/2fa/verify`,{code:e}),disable2fa:e=>X(`/api/settings/2fa/disable`,{code:e}),getAgents:()=>L(`/api/certs/agent`),getUserAccessGrants:()=>L(`/api/user-access/grants`),createUserAccessGrant:e=>X(`/api/user-access/grants`,e),revokeUserAccessGrant:e=>Nl(`/api/user-access/grants/${encodeURIComponent(e)}`),getTunnels:()=>L(`/api/tunnels`),createTunnel:e=>X(`/api/tunnels`,e),updateTunnel:(e,t)=>Ml(`/api/tunnels/${encodeURIComponent(e)}`,t),deleteTunnel:e=>Nl(`/api/tunnels/${encodeURIComponent(e)}`),getTunnelAgentConfig:()=>L(`/api/tunnels/agent-config`)};function Ll({to:e,icon:t,label:n,offline:r=null,onClick:i}){return(0,N.jsxs)(Ft,{to:e,end:e===`/`,onClick:i,title:r??void 0,className:({isActive:e})=>[`flex items-center gap-3 px-3 py-2 rounded-md text-sm font-medium transition-colors`,e?`text-cyan-400 bg-zinc-800/50`:`text-zinc-400 hover:text-zinc-100 hover:bg-zinc-800`].join(` `),children:[(0,N.jsx)(t,{className:`h-5 w-5`}),n,r&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{className:`ml-auto h-1.5 w-1.5 shrink-0 rounded-full bg-red-500`,"aria-hidden":`true`}),(0,N.jsxs)(`span`,{className:`sr-only`,children:[`(offline: `,r,`)`]})]})]})}var Rl=`4.4.1`,zl={activity:ni,"bar-chart-3":oi,"book-open":ci,box:B,cpu:Si,database:Ci,"file-text":ki,folder:Ni,"git-branch":Pi,globe:Fi,"hard-drive":Ii,heart:Li,layers:Hi,"layout-dashboard":Ui,list:Ki,map:Ji,package:Qi,server:ua,settings:fa,shield:ha,"shield-check":ma,terminal:va,ticket:ya,truck:Sa,users:Ea,wifi:Oa,zap:Aa};function Bl(e){return e&&Object.hasOwn(zl,e)&&zl[e]||Qi}var Vl=[{type:`link`,to:`/`,icon:Ui,label:`Dashboard`},{type:`link`,to:`/tunnels`,icon:Fi,label:`Tunnels`},{type:`link`,to:`/sites`,icon:ki,label:`Static Sites`},{type:`link`,to:`/users`,icon:Ea,label:`Users`},{type:`link`,to:`/certificates`,icon:ma,label:`Certificates`},{type:`link`,to:`/services`,icon:ua,label:`Services`},{type:`link`,to:`/tickets`,icon:ya,label:`Tickets`},{type:`link`,to:`/plugins`,icon:Qi,label:`Plugins`},{type:`link`,to:`/storage`,icon:Ii,label:`Storage`},{type:`link`,to:`/audit`,icon:ca,label:`Audit`},{type:`link`,to:`/settings`,icon:fa,label:`Settings`},{type:`link`,to:`/docs`,icon:ci,label:`Documentation`}];function Hl({onLinkClick:e}){let t=R(),n=F({queryKey:[`plugins`],queryFn:()=>t.getPlugins(),select:e=>(e.plugins||[]).filter(e=>e.status===`enabled`&&(e.panel?.label||e.panel?.pages?.length)),refetchInterval:3e4,staleTime:15e3}),r=n.data,i=e=>{let t=e.hosting===`agent`?yr(e.agentHosting):null;return t?xr(t,n.dataUpdatedAt):null},a=(r||[]).flatMap(e=>{let t=i(e);return e.panel?.pages?.length?[{type:`section-header`,label:e.displayName||e.name,key:`section-${e.name}`},...e.panel.pages.map(n=>({type:`link`,to:`/plugins/${e.name}${n.path}`,icon:Bl(n.icon),label:n.title,offline:t}))]:e.panel?.label?[{type:`link`,to:`/plugins/${e.name}`,icon:Bl(e.panel?.icon),label:e.panel.label,offline:t}]:[]}),o=[...Vl,...a];return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`div`,{className:`border-b border-zinc-800 px-4 py-5`,children:(0,N.jsx)(`span`,{className:`font-mono text-lg font-bold text-cyan-400`,children:`Lamaste`})}),(0,N.jsx)(`nav`,{className:`flex-1 space-y-1 px-2 py-4`,children:o.map(t=>t.type===`section-header`?(0,N.jsx)(`div`,{className:`px-3 pt-4 pb-1`,children:(0,N.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-zinc-600`,children:t.label})},t.key):(0,N.jsx)(Ll,{to:t.to,icon:t.icon,label:t.label,offline:t.offline??null,onClick:e},t.to))}),(0,N.jsx)(`div`,{className:`border-t border-zinc-800 px-4 py-3`,children:(0,N.jsxs)(`span`,{className:`font-mono text-xs text-zinc-600`,children:[`v`,Rl]})})]})}function Ul(){let[e,t]=(0,g.useState)(!1),n=()=>t(!1);return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>t(!0),className:`fixed left-4 top-4 z-40 rounded-md bg-zinc-900 p-2 text-zinc-400 hover:text-zinc-100 lg:hidden`,"aria-label":`Open sidebar`,children:(0,N.jsx)(Yi,{className:`h-5 w-5`})}),e&&(0,N.jsxs)(`div`,{className:`fixed inset-0 z-50 lg:hidden`,children:[(0,N.jsx)(`div`,{className:`fixed inset-0 bg-black/50`,onClick:n}),(0,N.jsxs)(`div`,{className:`relative flex h-screen w-64 flex-col bg-zinc-900`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:n,className:`absolute right-3 top-4 rounded-md p-1 text-zinc-400 hover:text-zinc-100`,"aria-label":`Close sidebar`,children:(0,N.jsx)(ka,{className:`h-5 w-5`})}),(0,N.jsx)(Hl,{onLinkClick:n})]})]}),(0,N.jsx)(`div`,{className:`sticky top-0 hidden h-screen w-64 flex-col border-r border-zinc-800 bg-zinc-900 lg:flex`,children:(0,N.jsx)(Hl,{})})]})}function Wl(){return(0,N.jsxs)(`div`,{className:`flex min-h-screen`,children:[(0,N.jsx)(Ul,{}),(0,N.jsx)(`main`,{className:`flex-1 overflow-y-auto bg-zinc-950 p-6 lg:p-8`,children:(0,N.jsx)(gt,{})})]})}function Gl(){return(0,N.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-zinc-950`,children:(0,N.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,N.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-2 border-zinc-700 border-t-cyan-400`}),(0,N.jsx)(`p`,{className:`mt-4 text-sm text-zinc-500`,children:`Connecting to panel server...`})]})})}function Kl({onRetry:e}){return(0,N.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-zinc-950`,children:(0,N.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,N.jsx)(hi,{className:`mb-4 h-12 w-12 text-red-400`}),(0,N.jsx)(`h1`,{className:`mb-2 font-mono text-xl font-bold text-zinc-100`,children:`Unable to connect`}),(0,N.jsx)(`p`,{className:`mb-6 max-w-md text-center text-zinc-400`,children:`Could not reach the Lamaste panel server. Make sure the server is running and try again.`}),(0,N.jsx)(`button`,{type:`button`,onClick:e,className:`rounded-md bg-cyan-400 px-4 py-2 font-medium text-zinc-900 transition-colors hover:bg-cyan-300`,children:`Retry`})]})})}var ql=/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,Jl=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function Yl({domain:e,onComplete:t}){let[n,r]=(0,g.useState)(e??``),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)({}),c=P(),l=I({mutationFn:async e=>{let t=await fetch(`/api/onboarding/domain`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json();throw Error(e.error||`Request failed`)}return t.json()},onSuccess:()=>{c.invalidateQueries({queryKey:[`onboarding`,`status`]}),t()}});function u(){let e={};return ql.test(n)||(e.domain=`Enter a valid domain name (e.g. example.com)`),Jl.test(i)||(e.email=`Enter a valid email address`),s(e),Object.keys(e).length===0}function d(e){e.preventDefault(),u()&&l.mutate({domain:n.trim(),email:i.trim()})}return(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h2`,{className:`mb-2 text-xl font-semibold text-white`,children:`Configure your domain`}),(0,N.jsx)(`p`,{className:`mb-6 text-sm text-zinc-400`,children:`Enter the domain you want to use for Lamaste. You will need to configure DNS records in the next step.`}),l.isError&&(0,N.jsx)(`div`,{className:`mb-4 rounded-md bg-red-500/10 border border-red-500/20 px-4 py-3 text-sm text-red-400`,children:l.error.message}),(0,N.jsxs)(`form`,{onSubmit:d,className:`space-y-5`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`domain`,className:`mb-1.5 block text-sm font-medium text-zinc-300`,children:`Domain`}),(0,N.jsx)(`input`,{id:`domain`,type:`text`,placeholder:`example.com`,value:n,onChange:e=>{r(e.target.value),s(e=>({...e,domain:void 0}))},className:`w-full rounded-md border border-zinc-600 bg-zinc-900 px-3 py-2 font-mono text-sm text-white placeholder-zinc-500 focus:border-cyan-400 focus:outline-none focus:ring-1 focus:ring-cyan-400`}),o.domain&&(0,N.jsx)(`p`,{className:`mt-1 text-xs text-red-400`,children:o.domain})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`email`,className:`mb-1.5 block text-sm font-medium text-zinc-300`,children:`Email`}),(0,N.jsx)(`input`,{id:`email`,type:`email`,placeholder:`you@example.com`,value:i,onChange:e=>{a(e.target.value),s(e=>({...e,email:void 0}))},className:`w-full rounded-md border border-zinc-600 bg-zinc-900 px-3 py-2 font-mono text-sm text-white placeholder-zinc-500 focus:border-cyan-400 focus:outline-none focus:ring-1 focus:ring-cyan-400`}),(0,N.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:`Used for Let's Encrypt certificate registration`}),o.email&&(0,N.jsx)(`p`,{className:`mt-1 text-xs text-red-400`,children:o.email})]}),(0,N.jsx)(`div`,{className:`flex justify-end pt-2`,children:(0,N.jsxs)(`button`,{type:`submit`,disabled:l.isPending,className:`flex items-center gap-2 rounded-md bg-cyan-500 px-6 py-2 font-medium text-white transition-colors hover:bg-cyan-600 disabled:opacity-50`,children:[l.isPending&&(0,N.jsx)(V,{size:16,className:`animate-spin`}),l.isPending?`Saving...`:`Save & Continue`]})})]})]})}function Xl({text:e}){let[t,n]=(0,g.useState)(!1);function r(){navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})}return(0,N.jsxs)(`button`,{type:`button`,onClick:r,className:`ml-2 inline-flex items-center text-zinc-500 transition-colors hover:text-zinc-300`,title:`Copy to clipboard`,children:[(0,N.jsx)(xi,{size:14}),t&&(0,N.jsx)(`span`,{className:`ml-1 text-xs text-green-400`,children:`Copied`})]})}function Zl({type:e,name:t,value:n}){return(0,N.jsxs)(`tr`,{className:`border-b border-zinc-700 last:border-b-0`,children:[(0,N.jsx)(`td`,{className:`px-3 py-2.5 font-mono text-sm text-cyan-400`,children:e}),(0,N.jsx)(`td`,{className:`px-3 py-2.5 font-mono text-sm text-zinc-300`,children:t}),(0,N.jsx)(`td`,{className:`px-3 py-2.5 font-mono text-sm text-zinc-300`,children:(0,N.jsxs)(`span`,{className:`inline-flex items-center`,children:[n,(0,N.jsx)(Xl,{text:n})]})})]})}function Ql({name:e,ok:t,resolvedIps:n,expectedIp:r}){return(0,N.jsxs)(`div`,{className:`flex items-start gap-2`,children:[t?(0,N.jsx)(_i,{size:18,className:`mt-0.5 shrink-0 text-green-400`}):(0,N.jsx)(vi,{size:18,className:`mt-0.5 shrink-0 text-red-400`}),(0,N.jsxs)(`div`,{className:`text-sm`,children:[(0,N.jsx)(`span`,{className:t?`text-green-400`:`text-red-400`,children:e}),t?(0,N.jsxs)(`span`,{className:`text-zinc-400`,children:[` resolves to `,r]}):n.length>0?(0,N.jsxs)(`span`,{className:`text-zinc-400`,children:[` `,`resolves to `,n.join(`, `),` (expected `,r,`)`]}):(0,N.jsx)(`span`,{className:`text-zinc-400`,children:` does not resolve`})]})]})}function $l({name:e,ok:t,expectedIp:n,missingText:r}){return(0,N.jsxs)(`div`,{className:`flex items-start gap-2`,children:[t?(0,N.jsx)(_i,{size:18,className:`mt-0.5 shrink-0 text-green-400`}):(0,N.jsx)(xa,{size:18,className:`mt-0.5 shrink-0 text-yellow-400`}),(0,N.jsxs)(`div`,{className:`text-sm`,children:[(0,N.jsx)(`span`,{className:t?`text-green-400`:`text-yellow-400`,children:e}),t?(0,N.jsxs)(`span`,{className:`text-zinc-400`,children:[` resolves to `,n]}):(0,N.jsxs)(`span`,{className:`text-zinc-400`,children:[` `,r]})]})]})}function eu({result:e}){return e?(0,N.jsxs)(`div`,{className:`mt-5 space-y-3 rounded-md border border-zinc-700 bg-zinc-900 p-4`,children:[e.records.map(t=>(0,N.jsx)(Ql,{name:t.name,ok:t.ok,resolvedIps:t.resolvedIps,expectedIp:e.expectedIp},t.name)),(0,N.jsx)($l,{name:`*.${e.domain}`,ok:e.wildcardOk,expectedIp:e.expectedIp,missingText:`not configured — you can add individual subdomain records later`}),(0,N.jsx)($l,{name:e.domain,ok:e.apexOk,expectedIp:e.expectedIp,missingText:`does not point here — only needed to serve a site on the domain itself`}),(0,N.jsx)(`p`,{className:`text-sm text-zinc-400`,children:e.message})]}):null}function tu({domain:e,ip:t,onComplete:n,onBack:r}){let[i,a]=(0,g.useState)(null),o=P(),s=I({mutationFn:async()=>{let e=await fetch(`/api/onboarding/verify-dns`,{method:`POST`});if(!e.ok){let t=await e.json();throw Error(t.error||`Verification failed`)}return e.json()},onSuccess:e=>{a(e),e.ok&&o.invalidateQueries({queryKey:[`onboarding`,`status`]})}});function c(){s.mutate()}function l(){n()}return(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h2`,{className:`mb-2 text-xl font-semibold text-white`,children:`Configure DNS records`}),(0,N.jsx)(`p`,{className:`mb-5 text-sm text-zinc-400`,children:`Add these DNS records at your domain registrar or DNS provider.`}),s.isError&&(0,N.jsx)(`div`,{className:`mb-4 rounded-md bg-red-500/10 border border-red-500/20 px-4 py-3 text-sm text-red-400`,children:s.error.message}),(0,N.jsx)(`div`,{className:`overflow-hidden rounded-md border border-zinc-700`,children:(0,N.jsxs)(`table`,{className:`w-full text-left`,children:[(0,N.jsx)(`thead`,{children:(0,N.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-800/50`,children:[(0,N.jsx)(`th`,{className:`px-3 py-2 text-xs font-medium uppercase tracking-wider text-zinc-500`,children:`Type`}),(0,N.jsx)(`th`,{className:`px-3 py-2 text-xs font-medium uppercase tracking-wider text-zinc-500`,children:`Name`}),(0,N.jsx)(`th`,{className:`px-3 py-2 text-xs font-medium uppercase tracking-wider text-zinc-500`,children:`Value`})]})}),(0,N.jsxs)(`tbody`,{className:`bg-zinc-900`,children:[(0,N.jsx)(Zl,{type:`A`,name:`*.${e}`,value:t}),(0,N.jsx)(Zl,{type:`A`,name:e,value:t})]})]})}),(0,N.jsx)(`p`,{className:`mt-3 text-xs italic text-zinc-500`,children:`DNS propagation can take up to 48 hours, but usually completes within a few minutes.`}),(0,N.jsxs)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:[`The wildcard record (*.`,e,`) covers the panel, auth and tunnel subdomains Lamaste needs and every tunnel you create later. Without it, add an A record for each of panel.`,e,`, auth.`,e,` and tunnel.`,e,`.`]}),(0,N.jsxs)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:[`The record for `,e,` itself is optional — it is only needed to serve a site on the domain, and can stay with another host until then.`]}),(0,N.jsx)(eu,{result:i}),(0,N.jsxs)(`div`,{className:`mt-6 flex items-center justify-between`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:r,className:`text-sm text-zinc-400 transition-colors hover:text-zinc-200`,children:`Back`}),(0,N.jsxs)(`div`,{className:`flex gap-3`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:c,disabled:s.isPending,className:`flex items-center gap-2 rounded-md bg-cyan-500 px-6 py-2 font-medium text-white transition-colors hover:bg-cyan-600 disabled:opacity-50`,children:[s.isPending&&(0,N.jsx)(V,{size:16,className:`animate-spin`}),s.isPending?`Verifying...`:`Verify DNS`]}),i?.ok&&(0,N.jsx)(`button`,{type:`button`,onClick:l,className:`rounded-md bg-green-600 px-6 py-2 font-medium text-white transition-colors hover:bg-green-700`,children:`Continue`})]})]})]})}var nu=1e4;function ru(){let[e,t]=(0,g.useState)([]),[n,r]=(0,g.useState)(!1),[i,a]=(0,g.useState)(!1),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(null),[u,d]=(0,g.useState)({current:0,total:0}),[f,p]=(0,g.useState)([]),m=(0,g.useRef)(null),h=(0,g.useRef)(0),_=(0,g.useRef)(null),v=(0,g.useRef)(!1),y=(0,g.useRef)(null);return(0,g.useEffect)(()=>{v.current=!1;function e(){if(v.current)return;let n=`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}/api/onboarding/provision/stream`,i=new WebSocket(n);m.current=i,i.onopen=()=>{h.current=0},i.onmessage=e=>{let n;try{n=JSON.parse(e.data)}catch{return}if(n.type===`state`){n.tasks&&t(n.tasks),n.error&&(a(!0),s(n.error)),n.result&&(l(n.result),r(!0));return}if(n.task===`complete`&&n.status===`done`){r(!0),n.result&&l(n.result);return}n.status===`error`&&(a(!0),s({task:n.task,message:n.error||n.message})),n.progress&&d(n.progress),n.log&&p(e=>[...e.slice(-500),n.log]),n.message&&p(e=>[...e.slice(-500),n.message]),t(e=>{let t=e.findIndex(e=>e.id===n.task);if(t!==-1){let r=[...e];return r[t]={...r[t],status:n.status,message:n.message,log:n.log},r}return[...e,{id:n.task,title:n.title||n.task,status:n.status,message:n.message,log:n.log}]})},i.onclose=()=>{if(v.current)return;let t=h.current,n=Math.min(1e3*2**t,nu);h.current=t+1,_.current=setTimeout(()=>{v.current||e()},n)},i.onerror=()=>{}}return y.current=e,e(),()=>{v.current=!0,_.current&&clearTimeout(_.current),m.current&&m.current.close()}},[]),{tasks:e,isComplete:n,isError:i,error:o,result:c,progress:u,logs:f,retry:(0,g.useCallback)(async()=>{a(!1),s(null),r(!1),l(null),t([]),p([]),d({current:0,total:0});let e=await fetch(`/api/onboarding/provision`,{method:`POST`});if(!e.ok){let t=await e.json();throw Error(t.error||`Failed to start provisioning`)}},[])}}function iu({status:e}){switch(e){case`done`:return(0,N.jsx)(_i,{size:18,className:`shrink-0 text-green-400`});case`error`:return(0,N.jsx)(vi,{size:18,className:`shrink-0 text-red-400`});case`running`:return(0,N.jsx)(V,{size:18,className:`shrink-0 animate-spin text-cyan-400`});default:return(0,N.jsx)(yi,{size:18,className:`shrink-0 text-zinc-600`})}}function au({task:e,isLast:t}){let n=e.status===`pending`?`text-zinc-500`:`text-white`;return(0,N.jsxs)(`div`,{className:`flex gap-3`,children:[(0,N.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,N.jsx)(iu,{status:e.status}),!t&&(0,N.jsx)(`div`,{className:`mt-1 w-px flex-1 bg-zinc-700`})]}),(0,N.jsxs)(`div`,{className:`pb-4`,children:[(0,N.jsx)(`p`,{className:`text-sm font-medium ${n}`,children:e.title}),e.message&&e.status!==`pending`&&(0,N.jsx)(`p`,{className:`mt-0.5 text-xs text-zinc-400`,children:e.message})]})]})}function ou({onComplete:e}){let{tasks:t,isComplete:n,isError:r,error:i,result:a,progress:o,logs:s,retry:c}=ru(),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(!1),p=(0,g.useRef)(null);(0,g.useEffect)(()=>{l||(u(!0),fetch(`/api/onboarding/provision`,{method:`POST`}).catch(()=>{}))},[l]),(0,g.useEffect)(()=>{p.current&&(p.current.scrollTop=p.current.scrollHeight)},[s]),(0,g.useEffect)(()=>{if(n&&e){let t=setTimeout(()=>{e(a)},1e3);return()=>clearTimeout(t)}},[n,e,a]);async function m(){f(!0);try{await c()}catch{}finally{f(!1)}}return(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h2`,{className:`mb-2 text-xl font-semibold text-white`,children:`Setting up your Lamaste`}),(0,N.jsx)(`div`,{className:`mb-5 rounded-md border border-amber-700 bg-amber-900/30 px-4 py-3`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(xa,{size:16,className:`shrink-0 text-amber-300`}),(0,N.jsx)(`p`,{className:`text-sm text-amber-300`,children:`Do not close this page while provisioning is in progress`})]})}),(0,N.jsx)(`div`,{className:`mb-4`,children:t.map((e,n)=>(0,N.jsx)(au,{task:e,isLast:n===t.length-1},e.id))}),(0,N.jsx)(`div`,{ref:p,className:`mb-3 max-h-48 overflow-y-auto rounded border border-zinc-800 bg-zinc-950 p-3 font-mono text-sm text-zinc-400`,children:s.length===0?(0,N.jsx)(`p`,{className:`italic text-zinc-600`,children:`Waiting for provisioning to start...`}):s.map((e,t)=>(0,N.jsx)(`p`,{className:`leading-relaxed`,children:e},t))}),o.total>0&&(0,N.jsxs)(`p`,{className:`mb-4 text-sm text-zinc-500`,children:[`Step `,o.current,` of `,o.total]}),r&&i&&(0,N.jsxs)(`div`,{className:`mb-4 rounded-md border border-red-700 bg-red-900/30 px-4 py-3`,children:[(0,N.jsx)(`p`,{className:`text-sm font-medium text-red-300`,children:`Provisioning failed`}),(0,N.jsx)(`p`,{className:`mt-1 text-xs text-red-400`,children:i.message}),(0,N.jsxs)(`button`,{type:`button`,onClick:m,disabled:d,className:`mt-3 flex items-center gap-2 rounded-md bg-cyan-500 px-6 py-2 font-medium text-white transition-colors hover:bg-cyan-600 disabled:opacity-50`,children:[d&&(0,N.jsx)(V,{size:16,className:`animate-spin`}),d?`Retrying...`:`Retry`]})]}),n&&(0,N.jsx)(`div`,{className:`text-center`,children:(0,N.jsx)(`p`,{className:`text-sm text-green-400`,children:`Provisioning complete. Continuing...`})})]})}function su({text:e}){let[t,n]=(0,g.useState)(!1);function r(){navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})}return(0,N.jsxs)(`button`,{type:`button`,onClick:r,className:`ml-2 inline-flex items-center text-zinc-500 transition-colors hover:text-zinc-300`,title:`Copy to clipboard`,children:[(0,N.jsx)(xi,{size:14}),t&&(0,N.jsx)(`span`,{className:`ml-1 text-xs text-green-400`,children:`Copied`})]})}function cu(e){try{let t=new URL(e);if(t.protocol===`https:`)return t.href}catch{}return``}function lu({result:e,ip:t}){let[n,r]=(0,g.useState)(!1),i=e?.adminUsername||`admin`,a=e?.adminPassword||``,o=cu(e?.panelUrl||``),s=cu(e?.authUrl||``),c=`https://${t}:9292`;return(0,N.jsxs)(`div`,{className:`animate-fade-in`,children:[(0,N.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,N.jsx)(ma,{size:48,className:`mx-auto mb-3 text-green-400`}),(0,N.jsx)(`h2`,{className:`text-2xl font-bold text-white`,children:`Lamaste is ready!`}),(0,N.jsx)(`p`,{className:`mt-1 text-sm text-zinc-400`,children:`Your stack is fully configured and operational.`})]}),(0,N.jsxs)(`div`,{className:`mb-5 rounded-lg border border-zinc-700 bg-zinc-800 p-6`,children:[(0,N.jsx)(`h3`,{className:`mb-1 font-semibold text-white`,children:`Admin Credentials`}),(0,N.jsx)(`p`,{className:`mb-4 text-sm text-amber-400`,children:`Save these credentials — they won't be shown again.`}),(0,N.jsxs)(`div`,{className:`space-y-3`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsx)(`span`,{className:`text-sm text-zinc-400`,children:`Username`}),(0,N.jsxs)(`span`,{className:`inline-flex items-center font-mono text-sm text-white`,children:[i,(0,N.jsx)(su,{text:i})]})]}),(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsx)(`span`,{className:`text-sm text-zinc-400`,children:`Password`}),(0,N.jsxs)(`span`,{className:`inline-flex items-center font-mono text-sm text-white`,children:[n?a:`•`.repeat(16),(0,N.jsx)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`ml-2 text-zinc-500 transition-colors hover:text-zinc-300`,title:n?`Hide password`:`Show password`,children:n?(0,N.jsx)(Di,{size:14}):(0,N.jsx)(Oi,{size:14})}),(0,N.jsx)(su,{text:a})]})]})]})]}),(0,N.jsxs)(`div`,{className:`mb-5 space-y-2`,children:[(0,N.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300`,children:`Access URLs`}),(0,N.jsxs)(`div`,{className:`flex items-center justify-between rounded border border-zinc-700 bg-zinc-900 px-3 py-2`,children:[(0,N.jsx)(`span`,{className:`text-sm text-zinc-400`,children:`Panel`}),(0,N.jsxs)(`a`,{href:o,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-sm text-cyan-400 hover:underline`,children:[o,(0,N.jsx)(Ei,{size:12})]})]}),(0,N.jsxs)(`div`,{className:`flex items-center justify-between rounded border border-zinc-700 bg-zinc-900 px-3 py-2`,children:[(0,N.jsx)(`span`,{className:`text-sm text-zinc-400`,children:`Auth Portal`}),(0,N.jsxs)(`a`,{href:s,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-sm text-cyan-400 hover:underline`,children:[s,(0,N.jsx)(Ei,{size:12})]})]}),(0,N.jsxs)(`div`,{className:`flex items-center justify-between rounded border border-zinc-700 bg-zinc-900 px-3 py-2`,children:[(0,N.jsx)(`span`,{className:`text-sm text-zinc-400`,children:`IP Access`}),(0,N.jsxs)(`span`,{className:`text-sm text-zinc-400`,children:[c,` `,(0,N.jsx)(`span`,{className:`text-xs text-zinc-500`,children:`(requires client certificate)`})]})]})]}),(0,N.jsxs)(`p`,{className:`mb-6 text-xs text-zinc-400`,children:[`On your first login to `,s?new URL(s).hostname:`the auth portal`,`, you will be prompted to set up two-factor authentication (TOTP). Use an authenticator app like Google Authenticator or Authy.`]}),(0,N.jsx)(`div`,{className:`flex justify-center`,children:(0,N.jsx)(`a`,{href:`/`,className:`rounded-md bg-cyan-500 px-8 py-2.5 font-medium text-white transition-colors hover:bg-cyan-600`,children:`Go to Dashboard`})})]})}var uu=4;function du(e){switch(e){case`FRESH`:return 1;case`DOMAIN_SET`:return 2;case`DNS_READY`:case`PROVISIONING`:return 3;case`COMPLETED`:return 4;default:return 1}}function fu({current:e}){return(0,N.jsxs)(`div`,{className:`mb-6 flex items-center gap-3`,children:[(0,N.jsxs)(`span`,{className:`text-sm text-zinc-400`,children:[`Step `,e,` of `,uu]}),(0,N.jsx)(`div`,{className:`flex gap-1.5`,children:Array.from({length:uu},(t,n)=>{let r=n+1,i=`h-2 w-2 rounded-full`;return r<e?i+=` bg-cyan-400`:r===e?i+=` border-2 border-cyan-400 bg-transparent`:i+=` bg-zinc-600`,(0,N.jsx)(`div`,{className:i},r)})})]})}function pu(){let{status:e,domain:t,ip:n,isLoading:r,isError:i,refetch:a}=Yr(),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(null),u=du(e),d=o!==null&&o<u?o:u;if(r)return(0,N.jsx)(Gl,{});if(i)return(0,N.jsx)(Kl,{onRetry:a});function f(){a(),s(null)}function p(){a(),s(null)}function m(){s(1)}function h(e){l(e),s(4),a()}let _;return d===1?_=(0,N.jsx)(Yl,{domain:t,onComplete:f}):d===2?_=(0,N.jsx)(tu,{domain:t,ip:n,onComplete:p,onBack:m}):d===3?_=(0,N.jsx)(ou,{onComplete:h}):d===4&&(_=(0,N.jsx)(lu,{result:c,ip:n})),(0,N.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-zinc-950`,children:(0,N.jsxs)(`div`,{className:`mx-4 w-full max-w-xl rounded-lg border border-zinc-800 bg-zinc-900 p-8`,children:[(0,N.jsx)(`h1`,{className:`mb-2 font-mono text-2xl font-bold text-cyan-400`,children:`Lamaste`}),(0,N.jsx)(fu,{current:d}),_]})})}function mu(){let{pluginName:e,"*":t}=Xe();return(0,N.jsx)(lo,{pluginName:e,subPath:t||``,basePath:`/plugins/${e}`,panelUrl:window.location.origin})}function hu(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var gu=hu();function _u(e){gu=e}var vu={exec:()=>null};function Z(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(bu.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var yu=(()=>{try{return!0}catch{return!1}})(),bu={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},xu=/^(?:[ \t]*(?:\n|$))+/,Su=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Cu=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,wu=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Tu=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Eu=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Du=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ou=Z(Du).replace(/bull/g,Eu).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),ku=Z(Du).replace(/bull/g,Eu).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Au=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ju=/^[^\n]+/,Mu=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Nu=Z(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Mu).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Pu=Z(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Eu).getRegex(),Fu=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,Iu=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Lu=Z(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Iu).replace(`tag`,Fu).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ru=Z(Au).replace(`hr`,wu).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Fu).getRegex(),zu={blockquote:Z(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Ru).getRegex(),code:Su,def:Nu,fences:Cu,heading:Tu,hr:wu,html:Lu,lheading:Ou,list:Pu,newline:xu,paragraph:Ru,table:vu,text:ju},Bu=Z(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,wu).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Fu).getRegex(),Vu={...zu,lheading:ku,table:Bu,paragraph:Z(Au).replace(`hr`,wu).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Bu).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Fu).getRegex()},Hu={...zu,html:Z(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Iu).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:vu,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Z(Au).replace(`hr`,wu).replace(`heading`,` *#{1,6} *[^
16
16
  ]`).replace(`lheading`,Ou).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Uu=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Wu=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Gu=/^( {2,}|\\)\n(?!\s*$)/,Ku=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,qu=/[\p{P}\p{S}]/u,Ju=/[\s\p{P}\p{S}]/u,Yu=/[^\s\p{P}\p{S}]/u,Xu=Z(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Ju).getRegex(),Zu=/(?!~)[\p{P}\p{S}]/u,Qu=/(?!~)[\s\p{P}\p{S}]/u,$u=/(?:[^\s\p{P}\p{S}]|~)/u,ed=Z(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,yu?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),td=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,nd=Z(td,`u`).replace(/punct/g,qu).getRegex(),rd=Z(td,`u`).replace(/punct/g,Zu).getRegex(),id=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,ad=Z(id,`gu`).replace(/notPunctSpace/g,Yu).replace(/punctSpace/g,Ju).replace(/punct/g,qu).getRegex(),od=Z(id,`gu`).replace(/notPunctSpace/g,$u).replace(/punctSpace/g,Qu).replace(/punct/g,Zu).getRegex(),sd=Z(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Yu).replace(/punctSpace/g,Ju).replace(/punct/g,qu).getRegex(),cd=Z(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,qu).getRegex(),ld=Z(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Yu).replace(/punctSpace/g,Ju).replace(/punct/g,qu).getRegex(),ud=Z(/\\(punct)/,`gu`).replace(/punct/g,qu).getRegex(),dd=Z(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),fd=Z(Iu).replace(`(?:-->|$)`,`-->`).getRegex(),pd=Z(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,fd).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),md=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,hd=Z(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,md).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),gd=Z(/^!?\[(label)\]\[(ref)\]/).replace(`label`,md).replace(`ref`,Mu).getRegex(),_d=Z(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Mu).getRegex(),vd=Z(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,gd).replace(`nolink`,_d).getRegex(),yd=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,bd={_backpedal:vu,anyPunctuation:ud,autolink:dd,blockSkip:ed,br:Gu,code:Wu,del:vu,delLDelim:vu,delRDelim:vu,emStrongLDelim:nd,emStrongRDelimAst:ad,emStrongRDelimUnd:sd,escape:Uu,link:hd,nolink:_d,punctuation:Xu,reflink:gd,reflinkSearch:vd,tag:pd,text:Ku,url:vu},xd={...bd,link:Z(/^!?\[(label)\]\((.*?)\)/).replace(`label`,md).getRegex(),reflink:Z(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,md).getRegex()},Sd={...bd,emStrongRDelimAst:od,emStrongLDelim:rd,delLDelim:cd,delRDelim:ld,url:Z(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,yd).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:Z(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,yd).getRegex()},Cd={...Sd,br:Z(Gu).replace(`{2,}`,`*`).getRegex(),text:Z(Sd.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},wd={normal:zu,gfm:Vu,pedantic:Hu},Td={normal:bd,gfm:Sd,breaks:Cd,pedantic:xd},Ed={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},Dd=e=>Ed[e];function Od(e,t){if(t){if(bu.escapeTest.test(e))return e.replace(bu.escapeReplace,Dd)}else if(bu.escapeTestNoEncode.test(e))return e.replace(bu.escapeReplaceNoEncode,Dd);return e}function kd(e){try{e=encodeURI(e).replace(bu.percentDecode,`%`)}catch{return null}return e}function Ad(e,t){let n=e.replace(bu.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(bu.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(bu.slashPipe,`|`);return n}function jd(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Md(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function Nd(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function Pd(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function Fd(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
17
17
  `).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
18
18
  `)}var Id=class{options;rules;lexer;constructor(e){this.options=e||gu}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:jd(e,`
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Lamaste</title>
7
- <script type="module" crossorigin src="/assets/index-CESyyK8V.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-roDHz3dM.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/assets/index-25wo_8av.css">
9
9
  </head>
10
10
  <body style="background-color: #09090b">
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lamalibre/lamaste-serverd",
3
- "version": "4.4.0",
3
+ "version": "4.4.1",
4
4
  "description": "Lamaste server daemon — REST API and plugin host",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "publishConfig": {
@@ -29,7 +29,7 @@
29
29
  "@fastify/rate-limit": "^10.3.0",
30
30
  "@fastify/static": "^9.1.1",
31
31
  "@fastify/websocket": "^11.0.0",
32
- "@lamalibre/lamaste": "^4.4.0",
32
+ "@lamalibre/lamaste": "^4.4.1",
33
33
  "bcryptjs": "^3.0.3",
34
34
  "execa": "^9.6.1",
35
35
  "fastify": "^5.8.4",