@lamalibre/create-lamaste 4.6.0 → 4.7.0

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 (149) hide show
  1. package/package.json +2 -2
  2. package/scripts/bundle-vendor.js +20 -3
  3. package/scripts/lamaste-priv +22 -3
  4. package/scripts/pin-release.js +98 -0
  5. package/src/index.js +8 -1
  6. package/src/lib/env.js +19 -0
  7. package/src/lib/service-config.js +7 -0
  8. package/src/tasks/redeploy.js +8 -0
  9. package/vendor/docs/00-introduction/how-it-works.md +2 -2
  10. package/vendor/docs/00-introduction/quickstart.md +5 -5
  11. package/vendor/docs/00-introduction/what-is-lamaste.md +5 -5
  12. package/vendor/docs/01-concepts/authentication.md +6 -2
  13. package/vendor/docs/01-concepts/authorization.md +4 -0
  14. package/vendor/docs/01-concepts/certificates.md +3 -3
  15. package/vendor/docs/01-concepts/dns-and-domains.md +9 -0
  16. package/vendor/docs/01-concepts/mtls.md +2 -2
  17. package/vendor/docs/01-concepts/security-model.md +28 -3
  18. package/vendor/docs/01-concepts/tickets.md +2 -2
  19. package/vendor/docs/01-concepts/tunneling.md +4 -4
  20. package/vendor/docs/02-guides/agent-setup.md +5 -5
  21. package/vendor/docs/02-guides/certificate-management.md +2 -2
  22. package/vendor/docs/02-guides/cloud-provisioning.md +3 -3
  23. package/vendor/docs/02-guides/desktop-app-setup.md +10 -10
  24. package/vendor/docs/02-guides/installation.md +3 -3
  25. package/vendor/docs/02-guides/managing-users.md +5 -11
  26. package/vendor/docs/02-guides/onboarding.md +2 -2
  27. package/vendor/docs/02-guides/second-domain.md +82 -0
  28. package/vendor/docs/02-guides/standalone-plugin-with-tickets.md +2 -2
  29. package/vendor/docs/03-architecture/installer-flow.md +2 -2
  30. package/vendor/docs/03-architecture/installer.md +4 -4
  31. package/vendor/docs/03-architecture/management-flow.md +1 -1
  32. package/vendor/docs/03-architecture/nginx-configuration.md +15 -5
  33. package/vendor/docs/03-architecture/overview.md +5 -5
  34. package/vendor/docs/03-architecture/panel-client.md +6 -6
  35. package/vendor/docs/03-architecture/panel-server.md +2 -2
  36. package/vendor/docs/03-architecture/state-management.md +3 -3
  37. package/vendor/docs/03-architecture/system-overview.md +1 -1
  38. package/vendor/docs/04-api-reference/agent-hosted-plugins.md +17 -13
  39. package/vendor/docs/04-api-reference/app-host.md +3 -3
  40. package/vendor/docs/04-api-reference/domains.md +192 -0
  41. package/vendor/docs/04-api-reference/gatekeeper.md +35 -7
  42. package/vendor/docs/04-api-reference/lifecycle-hooks.md +4 -4
  43. package/vendor/docs/04-api-reference/onboarding.md +1 -1
  44. package/vendor/docs/04-api-reference/overview.md +9 -0
  45. package/vendor/docs/04-api-reference/registry-and-oidc.md +26 -13
  46. package/vendor/docs/04-api-reference/sites.md +5 -0
  47. package/vendor/docs/04-api-reference/tunnels.md +15 -10
  48. package/vendor/docs/04-api-reference/users.md +41 -29
  49. package/vendor/docs/05-operations/backup-and-restore.md +1 -1
  50. package/vendor/docs/05-operations/uninstalling.md +1 -1
  51. package/vendor/docs/05-operations/upgrades.md +6 -6
  52. package/vendor/docs/06-reference/config-files.md +1 -1
  53. package/vendor/docs/06-reference/glossary.md +3 -3
  54. package/vendor/docs/06-reference/installer-flags.md +13 -13
  55. package/vendor/docs/06-reference/ports-and-services.md +1 -1
  56. package/vendor/docs/06-reference/troubleshooting.md +8 -8
  57. package/vendor/docs/_index.json +105 -19
  58. package/vendor/docs/external-members-design.md +816 -0
  59. package/vendor/docs/gatekeeper-design.md +8 -8
  60. package/vendor/docs/identity-directory-design.md +3 -3
  61. package/vendor/docs/multi-domain-relay-design.md +836 -0
  62. package/vendor/docs/package.json +1 -1
  63. package/vendor/docs/todo/lib-cli-desktop-refactor.md +27 -27
  64. package/vendor/gatekeeper/dist/cli/index.js +0 -0
  65. package/vendor/gatekeeper/dist/lib/grants.d.ts.map +1 -1
  66. package/vendor/gatekeeper/dist/lib/grants.js +20 -13
  67. package/vendor/gatekeeper/dist/lib/grants.js.map +1 -1
  68. package/vendor/gatekeeper/dist/lib/migrations/gatekeeper/0004_unconsume_access_grants.sql +8 -0
  69. package/vendor/gatekeeper/dist/lib/secret.d.ts +6 -0
  70. package/vendor/gatekeeper/dist/lib/secret.d.ts.map +1 -0
  71. package/vendor/gatekeeper/dist/lib/secret.js +12 -0
  72. package/vendor/gatekeeper/dist/lib/secret.js.map +1 -0
  73. package/vendor/gatekeeper/dist/lib/templates.d.ts +20 -0
  74. package/vendor/gatekeeper/dist/lib/templates.d.ts.map +1 -1
  75. package/vendor/gatekeeper/dist/lib/templates.js +80 -14
  76. package/vendor/gatekeeper/dist/lib/templates.js.map +1 -1
  77. package/vendor/gatekeeper/dist/server/index.d.ts +5 -1
  78. package/vendor/gatekeeper/dist/server/index.d.ts.map +1 -1
  79. package/vendor/gatekeeper/dist/server/index.js +28 -2
  80. package/vendor/gatekeeper/dist/server/index.js.map +1 -1
  81. package/vendor/gatekeeper/dist/server/routes/authz.d.ts.map +1 -1
  82. package/vendor/gatekeeper/dist/server/routes/authz.js +225 -36
  83. package/vendor/gatekeeper/dist/server/routes/authz.js.map +1 -1
  84. package/vendor/gatekeeper/dist/server/routes/diagnostic.d.ts.map +1 -1
  85. package/vendor/gatekeeper/dist/server/routes/diagnostic.js +5 -2
  86. package/vendor/gatekeeper/dist/server/routes/diagnostic.js.map +1 -1
  87. package/vendor/gatekeeper/package.json +2 -2
  88. package/vendor/server/bin/lamaste-server.js +7 -0
  89. package/vendor/server/package.json +2 -2
  90. package/vendor/server/src/commands/domains.js +214 -0
  91. package/vendor/server/src/commands/plugin-identity.js +2 -16
  92. package/vendor/server/src/commands/plugins.js +112 -8
  93. package/vendor/server/src/commands/registry-credential.js +10 -3
  94. package/vendor/server/src/commands/sites.js +3 -0
  95. package/vendor/server/src/commands/status.js +19 -0
  96. package/vendor/server/src/commands/tunnels.js +4 -1
  97. package/vendor/server/src/commands/users.js +8 -19
  98. package/vendor/server/src/domains.js +92 -0
  99. package/vendor/server/src/fail.js +21 -0
  100. package/vendor/server/src/oidc-client-grants.js +63 -0
  101. package/vendor/server/src/panel-api.js +15 -0
  102. package/vendor/server-ui/dist/assets/index-B8Tv_ocF.js +84 -0
  103. package/vendor/server-ui/dist/assets/{index-BZwQ_aQc.css → index-Cb-ADsbB.css} +1 -1
  104. package/vendor/server-ui/dist/index.html +2 -2
  105. package/vendor/serverd/package.json +2 -2
  106. package/vendor/serverd/src/index.js +42 -16
  107. package/vendor/serverd/src/lib/app-error.js +24 -0
  108. package/vendor/serverd/src/lib/audience.js +12 -3
  109. package/vendor/serverd/src/lib/authelia.js +341 -35
  110. package/vendor/serverd/src/lib/directory.js +67 -52
  111. package/vendor/serverd/src/lib/domains.js +1792 -0
  112. package/vendor/serverd/src/lib/gatekeeper-client.js +20 -4
  113. package/vendor/serverd/src/lib/identity-sync.js +35 -0
  114. package/vendor/serverd/src/lib/migrations/state/0016_domains.sql +53 -0
  115. package/vendor/serverd/src/lib/migrations/state/0017_membership_kind.sql +15 -0
  116. package/vendor/serverd/src/lib/migrations/state/0018_domain_group_keys.sql +23 -0
  117. package/vendor/serverd/src/lib/nginx.js +318 -140
  118. package/vendor/serverd/src/lib/owned-groups.js +326 -0
  119. package/vendor/serverd/src/lib/plugin-domain.js +86 -0
  120. package/vendor/serverd/src/lib/plugin-lifecycle.js +1 -0
  121. package/vendor/serverd/src/lib/plugin-oidc.js +144 -42
  122. package/vendor/serverd/src/lib/plugins.js +45 -5
  123. package/vendor/serverd/src/lib/registry-credential.js +39 -6
  124. package/vendor/serverd/src/lib/services.js +9 -1
  125. package/vendor/serverd/src/lib/state.js +11 -0
  126. package/vendor/serverd/src/lib/tunnel-deps.js +2 -4
  127. package/vendor/serverd/src/lib/user-surface.js +29 -4
  128. package/vendor/serverd/src/lib/users-lock.js +23 -0
  129. package/vendor/serverd/src/lib/vhost-reconcile.js +149 -41
  130. package/vendor/serverd/src/lib/web-surface.js +49 -32
  131. package/vendor/serverd/src/middleware/user-access-session.js +11 -4
  132. package/vendor/serverd/src/routes/invite.js +15 -5
  133. package/vendor/serverd/src/routes/management/domains.js +154 -0
  134. package/vendor/serverd/src/routes/management/gatekeeper-proxy.js +44 -8
  135. package/vendor/serverd/src/routes/management/identity.js +21 -7
  136. package/vendor/serverd/src/routes/management/invitations.js +33 -4
  137. package/vendor/serverd/src/routes/management/plugins.js +4 -2
  138. package/vendor/serverd/src/routes/management/registry-credential.js +86 -57
  139. package/vendor/serverd/src/routes/management/sites.js +50 -11
  140. package/vendor/serverd/src/routes/management/tunnels.js +29 -5
  141. package/vendor/serverd/src/routes/management/users.js +184 -64
  142. package/vendor/serverd/src/routes/management.js +2 -0
  143. package/vendor/serverd/src/routes/onboarding/dns.js +3 -17
  144. package/vendor/serverd/src/routes/onboarding/provision.js +22 -13
  145. package/vendor/serverd/src/routes/user-access.js +13 -1
  146. package/vendor/gatekeeper/dist/lib/migrations/migrations/gatekeeper/0001_groups.sql +0 -7
  147. package/vendor/gatekeeper/dist/lib/migrations/migrations/gatekeeper/0002_access_grants.sql +0 -14
  148. package/vendor/gatekeeper/dist/lib/migrations/migrations/gatekeeper/0003_access_request_log.sql +0 -9
  149. package/vendor/server-ui/dist/assets/index-BvEfCZYS.js +0 -84
@@ -0,0 +1,84 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var l=o((e=>{var t=Symbol.for(`react.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.provider`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.iterator;function p(e){return typeof e!=`object`||!e?null:(e=f&&e[f]||e[`@@iterator`],typeof e==`function`?e:null)}var m={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},h=Object.assign,g={};function _(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||m}_.prototype.isReactComponent={},_.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`setState(...): takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},_.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function v(){}v.prototype=_.prototype;function y(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||m}var b=y.prototype=new v;b.constructor=y,h(b,_.prototype),b.isPureReactComponent=!0;var x=Array.isArray,S=Object.prototype.hasOwnProperty,C={current:null},w={key:!0,ref:!0,__self:!0,__source:!0};function T(e,n,r){var i,a={},o=null,s=null;if(n!=null)for(i in n.ref!==void 0&&(s=n.ref),n.key!==void 0&&(o=``+n.key),n)S.call(n,i)&&!w.hasOwnProperty(i)&&(a[i]=n[i]);var c=arguments.length-2;if(c===1)a.children=r;else if(1<c){for(var l=Array(c),u=0;u<c;u++)l[u]=arguments[u+2];a.children=l}if(e&&e.defaultProps)for(i in c=e.defaultProps,c)a[i]===void 0&&(a[i]=c[i]);return{$$typeof:t,type:e,key:o,ref:s,props:a,_owner:C.current}}function E(e,n){return{$$typeof:t,type:e.type,key:n,ref:e.ref,props:e.props,_owner:e._owner}}function D(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function ee(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var te=/\/+/g;function ne(e,t){return typeof e==`object`&&e&&e.key!=null?ee(``+e.key):t.toString(36)}function re(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0}}if(c)return c=e,o=o(c),e=a===``?`.`+ne(c,0):a,x(o)?(i=``,e!=null&&(i=e.replace(te,`$&/`)+`/`),re(o,r,i,``,function(e){return e})):o!=null&&(D(o)&&(o=E(o,i+(!o.key||c&&c.key===o.key?``:(``+o.key).replace(te,`$&/`)+`/`)+e)),r.push(o)),1;if(c=0,a=a===``?`.`:a+`:`,x(e))for(var l=0;l<e.length;l++){s=e[l];var u=a+ne(s,l);c+=re(s,r,i,u,o)}else if(u=p(e),typeof u==`function`)for(e=u.call(e),l=0;!(s=e.next()).done;)s=s.value,u=a+ne(s,l++),c+=re(s,r,i,u,o);else if(s===`object`)throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`);return c}function ie(e,t,n){if(e==null)return e;var r=[],i=0;return re(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ae(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var oe={current:null},se={transition:null},ce={ReactCurrentDispatcher:oe,ReactCurrentBatchConfig:se,ReactCurrentOwner:C};function le(){throw Error(`act(...) is not supported in production builds of React.`)}e.Children={map:ie,forEach:function(e,t,n){ie(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return ie(e,function(){t++}),t},toArray:function(e){return ie(e,function(e){return e})||[]},only:function(e){if(!D(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}},e.Component=_,e.Fragment=r,e.Profiler=a,e.PureComponent=y,e.StrictMode=i,e.Suspense=l,e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ce,e.act=le,e.cloneElement=function(e,n,r){if(e==null)throw Error(`React.cloneElement(...): The argument must be a React element, but you passed `+e+`.`);var i=h({},e.props),a=e.key,o=e.ref,s=e._owner;if(n!=null){if(n.ref!==void 0&&(o=n.ref,s=C.current),n.key!==void 0&&(a=``+n.key),e.type&&e.type.defaultProps)var c=e.type.defaultProps;for(l in n)S.call(n,l)&&!w.hasOwnProperty(l)&&(i[l]=n[l]===void 0&&c!==void 0?c[l]:n[l])}var l=arguments.length-2;if(l===1)i.children=r;else if(1<l){c=Array(l);for(var u=0;u<l;u++)c[u]=arguments[u+2];i.children=c}return{$$typeof:t,type:e.type,key:a,ref:o,props:i,_owner:s}},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:o,_context:e},e.Consumer=e},e.createElement=T,e.createFactory=function(e){var t=T.bind(null,e);return t.type=e,t},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=D,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:ae}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=se.transition;se.transition={};try{e()}finally{se.transition=t}},e.unstable_act=le,e.useCallback=function(e,t){return oe.current.useCallback(e,t)},e.useContext=function(e){return oe.current.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e){return oe.current.useDeferredValue(e)},e.useEffect=function(e,t){return oe.current.useEffect(e,t)},e.useId=function(){return oe.current.useId()},e.useImperativeHandle=function(e,t,n){return oe.current.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return oe.current.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return oe.current.useLayoutEffect(e,t)},e.useMemo=function(e,t){return oe.current.useMemo(e,t)},e.useReducer=function(e,t,n){return oe.current.useReducer(e,t,n)},e.useRef=function(e){return oe.current.useRef(e)},e.useState=function(e){return oe.current.useState(e)},e.useSyncExternalStore=function(e,t,n){return oe.current.useSyncExternalStore(e,t,n)},e.useTransition=function(){return oe.current.useTransition()},e.version=`18.3.1`})),u=o(((e,t)=>{t.exports=l()})),d=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=typeof setTimeout==`function`?setTimeout:null,_=typeof clearTimeout==`function`?clearTimeout:null,v=typeof setImmediate<`u`?setImmediate:null;typeof navigator<`u`&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function b(e){if(h=!1,y(e),!m)if(n(c)!==null)m=!0,ie(x);else{var t=n(l);t!==null&&ae(b,t.startTime-e)}}function x(t,i){m=!1,h&&(h=!1,_(w),w=-1),p=!0;var a=f;try{for(y(i),d=n(c);d!==null&&(!(d.expirationTime>i)||t&&!D());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=i);i=e.unstable_now(),typeof s==`function`?d.callback=s:d===n(c)&&r(c),y(i)}else r(c);d=n(c)}if(d!==null)var u=!0;else{var g=n(l);g!==null&&ae(b,g.startTime-i),u=!1}return u}finally{d=null,f=a,p=!1}}var S=!1,C=null,w=-1,T=5,E=-1;function D(){return!(e.unstable_now()-E<T)}function ee(){if(C!==null){var t=e.unstable_now();E=t;var n=!0;try{n=C(!0,t)}finally{n?te():(S=!1,C=null)}}else S=!1}var te;if(typeof v==`function`)te=function(){v(ee)};else if(typeof MessageChannel<`u`){var ne=new MessageChannel,re=ne.port2;ne.port1.onmessage=ee,te=function(){re.postMessage(null)}}else te=function(){g(ee,0)};function ie(e){C=e,S||(S=!0,te())}function ae(t,n){w=g(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_continueExecution=function(){m||p||(m=!0,ie(x))},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):T=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(_(w),w=-1):h=!0,ae(b,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,ie(x))),r},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),f=o(((e,t)=>{t.exports=d()})),p=o((e=>{var t=u(),n=f();function r(e){for(var t=`https://reactjs.org/docs/error-decoder.html?invariant=`+e,n=1;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n]);return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}var i=new Set,a={};function o(e,t){s(e,t),s(e+`Capture`,t)}function s(e,t){for(a[e]=t,e=0;e<t.length;e++)i.add(t[e])}var c=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),l=Object.prototype.hasOwnProperty,d=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},m={};function h(e){return l.call(m,e)?!0:l.call(p,e)?!1:d.test(e)?m[e]=!0:(p[e]=!0,!1)}function g(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case`function`:case`symbol`:return!0;case`boolean`:return r?!1:n===null?(e=e.toLowerCase().slice(0,5),e!==`data-`&&e!==`aria-`):!n.acceptsBooleans;default:return!1}}function _(e,t,n,r){if(t==null||g(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return!1===t;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function v(e,t,n,r,i,a,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=o}var y={};`children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style`.split(` `).forEach(function(e){y[e]=new v(e,0,!1,e,null,!1,!1)}),[[`acceptCharset`,`accept-charset`],[`className`,`class`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`]].forEach(function(e){var t=e[0];y[t]=new v(t,1,!1,e[1],null,!1,!1)}),[`contentEditable`,`draggable`,`spellCheck`,`value`].forEach(function(e){y[e]=new v(e,2,!1,e.toLowerCase(),null,!1,!1)}),[`autoReverse`,`externalResourcesRequired`,`focusable`,`preserveAlpha`].forEach(function(e){y[e]=new v(e,2,!1,e,null,!1,!1)}),`allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope`.split(` `).forEach(function(e){y[e]=new v(e,3,!1,e.toLowerCase(),null,!1,!1)}),[`checked`,`multiple`,`muted`,`selected`].forEach(function(e){y[e]=new v(e,3,!0,e,null,!1,!1)}),[`capture`,`download`].forEach(function(e){y[e]=new v(e,4,!1,e,null,!1,!1)}),[`cols`,`rows`,`size`,`span`].forEach(function(e){y[e]=new v(e,6,!1,e,null,!1,!1)}),[`rowSpan`,`start`].forEach(function(e){y[e]=new v(e,5,!1,e.toLowerCase(),null,!1,!1)});var b=/[\-:]([a-z])/g;function x(e){return e[1].toUpperCase()}`accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height`.split(` `).forEach(function(e){var t=e.replace(b,x);y[t]=new v(t,1,!1,e,null,!1,!1)}),`xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type`.split(` `).forEach(function(e){var t=e.replace(b,x);y[t]=new v(t,1,!1,e,`http://www.w3.org/1999/xlink`,!1,!1)}),[`xml:base`,`xml:lang`,`xml:space`].forEach(function(e){var t=e.replace(b,x);y[t]=new v(t,1,!1,e,`http://www.w3.org/XML/1998/namespace`,!1,!1)}),[`tabIndex`,`crossOrigin`].forEach(function(e){y[e]=new v(e,1,!1,e.toLowerCase(),null,!1,!1)}),y.xlinkHref=new v(`xlinkHref`,1,!1,`xlink:href`,`http://www.w3.org/1999/xlink`,!0,!1),[`src`,`href`,`action`,`formAction`].forEach(function(e){y[e]=new v(e,1,!1,e.toLowerCase(),null,!0,!0)});function S(e,t,n,r){var i=y.hasOwnProperty(t)?y[t]:null;(i===null?r||!(2<t.length)||t[0]!==`o`&&t[0]!==`O`||t[1]!==`n`&&t[1]!==`N`:i.type!==0)&&(_(t,n,i,r)&&(n=null),r||i===null?h(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,``+n)):i.mustUseProperty?e[i.propertyName]=n===null?i.type===3?!1:``:n:(t=i.attributeName,r=i.attributeNamespace,n===null?e.removeAttribute(t):(i=i.type,n=i===3||i===4&&!0===n?``:``+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var C=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,w=Symbol.for(`react.element`),T=Symbol.for(`react.portal`),E=Symbol.for(`react.fragment`),D=Symbol.for(`react.strict_mode`),ee=Symbol.for(`react.profiler`),te=Symbol.for(`react.provider`),ne=Symbol.for(`react.context`),re=Symbol.for(`react.forward_ref`),ie=Symbol.for(`react.suspense`),ae=Symbol.for(`react.suspense_list`),oe=Symbol.for(`react.memo`),se=Symbol.for(`react.lazy`),ce=Symbol.for(`react.offscreen`),le=Symbol.iterator;function ue(e){return typeof e!=`object`||!e?null:(e=le&&e[le]||e[`@@iterator`],typeof e==`function`?e:null)}var O=Object.assign,de;function fe(e){if(de===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);de=t&&t[1]||``}return`
2
+ `+de+e}var pe=!1;function me(e,t){if(!e||pe)return``;pe=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,`props`,{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(t,[])}catch(e){var r=e}Reflect.construct(e,[],t)}else{try{t.call()}catch(e){r=e}e.call(t.prototype)}else{try{throw Error()}catch(e){r=e}e()}}catch(t){if(t&&r&&typeof t.stack==`string`){for(var i=t.stack.split(`
3
+ `),a=r.stack.split(`
4
+ `),o=i.length-1,s=a.length-1;1<=o&&0<=s&&i[o]!==a[s];)s--;for(;1<=o&&0<=s;o--,s--)if(i[o]!==a[s]){if(o!==1||s!==1)do if(o--,s--,0>s||i[o]!==a[s]){var c=`
5
+ `+i[o].replace(` at new `,` at `);return e.displayName&&c.includes(`<anonymous>`)&&(c=c.replace(`<anonymous>`,e.displayName)),c}while(1<=o&&0<=s);break}}}finally{pe=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:``)?fe(e):``}function he(e){switch(e.tag){case 5:return fe(e.type);case 16:return fe(`Lazy`);case 13:return fe(`Suspense`);case 19:return fe(`SuspenseList`);case 0:case 2:case 15:return e=me(e.type,!1),e;case 11:return e=me(e.type.render,!1),e;case 1:return e=me(e.type,!0),e;default:return``}}function ge(e){if(e==null)return null;if(typeof e==`function`)return e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case E:return`Fragment`;case T:return`Portal`;case ee:return`Profiler`;case D:return`StrictMode`;case ie:return`Suspense`;case ae:return`SuspenseList`}if(typeof e==`object`)switch(e.$$typeof){case ne:return(e.displayName||`Context`)+`.Consumer`;case te:return(e._context.displayName||`Context`)+`.Provider`;case re:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case oe:return t=e.displayName||null,t===null?ge(e.type)||`Memo`:t;case se:t=e._payload,e=e._init;try{return ge(e(t))}catch{}}return null}function _e(e){var t=e.type;switch(e.tag){case 24:return`Cache`;case 9:return(t.displayName||`Context`)+`.Consumer`;case 10:return(t._context.displayName||`Context`)+`.Provider`;case 18:return`DehydratedFragment`;case 11:return e=t.render,e=e.displayName||e.name||``,t.displayName||(e===``?`ForwardRef`:`ForwardRef(`+e+`)`);case 7:return`Fragment`;case 5:return t;case 4:return`Portal`;case 3:return`Root`;case 6:return`Text`;case 16:return ge(t);case 8:return t===D?`StrictMode`:`Mode`;case 22:return`Offscreen`;case 12:return`Profiler`;case 21:return`Scope`;case 13:return`Suspense`;case 19:return`SuspenseList`;case 25:return`TracingMarker`;case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t==`function`)return t.displayName||t.name||null;if(typeof t==`string`)return t}return null}function ve(e){switch(typeof e){case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function ye(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function be(e){var t=ye(e)?`checked`:`value`,n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=``+e[t];if(!e.hasOwnProperty(t)&&n!==void 0&&typeof n.get==`function`&&typeof n.set==`function`){var i=n.get,a=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){r=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function xe(e){e._valueTracker||=be(e)}function Se(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=ye(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function Ce(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function we(e,t){var n=t.checked;return O({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Te(e,t){var n=t.defaultValue==null?``:t.defaultValue,r=t.checked==null?t.defaultChecked:t.checked;n=ve(t.value==null?n:t.value),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type===`checkbox`||t.type===`radio`?t.checked!=null:t.value!=null}}function Ee(e,t){t=t.checked,t!=null&&S(e,`checked`,t,!1)}function De(e,t){Ee(e,t);var n=ve(t.value),r=t.type;if(n!=null)r===`number`?(n===0&&e.value===``||e.value!=n)&&(e.value=``+n):e.value!==``+n&&(e.value=``+n);else if(r===`submit`||r===`reset`){e.removeAttribute(`value`);return}t.hasOwnProperty(`value`)?ke(e,t.type,n):t.hasOwnProperty(`defaultValue`)&&ke(e,t.type,ve(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Oe(e,t,n){if(t.hasOwnProperty(`value`)||t.hasOwnProperty(`defaultValue`)){var r=t.type;if(!(r!==`submit`&&r!==`reset`||t.value!==void 0&&t.value!==null))return;t=``+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==``&&(e.name=``),e.defaultChecked=!!e._wrapperState.initialChecked,n!==``&&(e.name=n)}function ke(e,t,n){(t!==`number`||Ce(e.ownerDocument)!==e)&&(n==null?e.defaultValue=``+e._wrapperState.initialValue:e.defaultValue!==``+n&&(e.defaultValue=``+n))}var Ae=Array.isArray;function je(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+ve(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Me(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(r(91));return O({},t,{value:void 0,defaultValue:void 0,children:``+e._wrapperState.initialValue})}function Ne(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(r(92));if(Ae(n)){if(1<n.length)throw Error(r(93));n=n[0]}t=n}t??=``,n=t}e._wrapperState={initialValue:ve(n)}}function Pe(e,t){var n=ve(t.value),r=ve(t.defaultValue);n!=null&&(n=``+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=``+r)}function Fe(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==``&&t!==null&&(e.value=t)}function Ie(e){switch(e){case`svg`:return`http://www.w3.org/2000/svg`;case`math`:return`http://www.w3.org/1998/Math/MathML`;default:return`http://www.w3.org/1999/xhtml`}}function Le(e,t){return e==null||e===`http://www.w3.org/1999/xhtml`?Ie(t):e===`http://www.w3.org/2000/svg`&&t===`foreignObject`?`http://www.w3.org/1999/xhtml`:e}var Re,ze=function(e){return typeof MSApp<`u`&&MSApp.execUnsafeLocalFunction?function(t,n,r,i){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,i)})}:e}(function(e,t){if(e.namespaceURI!==`http://www.w3.org/2000/svg`||`innerHTML`in e)e.innerHTML=t;else{for(Re||=document.createElement(`div`),Re.innerHTML=`<svg>`+t.valueOf().toString()+`</svg>`,t=Re.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Be(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Ve={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},He=[`Webkit`,`ms`,`Moz`,`O`];Object.keys(Ve).forEach(function(e){He.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Ve[t]=Ve[e]})});function Ue(e,t,n){return t==null||typeof t==`boolean`||t===``?``:n||typeof t!=`number`||t===0||Ve.hasOwnProperty(e)&&Ve[e]?(``+t).trim():t+`px`}function We(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var r=n.indexOf(`--`)===0,i=Ue(n,t[n],r);n===`float`&&(n=`cssFloat`),r?e.setProperty(n,i):e[n]=i}}var Ge=O({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ke(e,t){if(t){if(Ge[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(r(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(r(60));if(typeof t.dangerouslySetInnerHTML!=`object`||!(`__html`in t.dangerouslySetInnerHTML))throw Error(r(61))}if(t.style!=null&&typeof t.style!=`object`)throw Error(r(62))}}function qe(e,t){if(e.indexOf(`-`)===-1)return typeof t.is==`string`;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var Je=null;function Ye(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Xe=null,Ze=null,Qe=null;function $e(e){if(e=Ki(e)){if(typeof Xe!=`function`)throw Error(r(280));var t=e.stateNode;t&&(t=Ji(t),Xe(e.stateNode,e.type,t))}}function et(e){Ze?Qe?Qe.push(e):Qe=[e]:Ze=e}function tt(){if(Ze){var e=Ze,t=Qe;if(Qe=Ze=null,$e(e),t)for(e=0;e<t.length;e++)$e(t[e])}}function nt(e,t){return e(t)}function rt(){}var it=!1;function at(e,t,n){if(it)return e(t,n);it=!0;try{return nt(e,t,n)}finally{it=!1,(Ze!==null||Qe!==null)&&(rt(),tt())}}function ot(e,t){var n=e.stateNode;if(n===null)return null;var i=Ji(n);if(i===null)return null;n=i[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(i=!i.disabled)||(e=e.type,i=!(e===`button`||e===`input`||e===`select`||e===`textarea`)),e=!i;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(r(231,t,typeof n));return n}var st=!1;if(c)try{var ct={};Object.defineProperty(ct,`passive`,{get:function(){st=!0}}),window.addEventListener(`test`,ct,ct),window.removeEventListener(`test`,ct,ct)}catch{st=!1}function lt(e,t,n,r,i,a,o,s,c){var l=Array.prototype.slice.call(arguments,3);try{t.apply(n,l)}catch(e){this.onError(e)}}var ut=!1,dt=null,ft=!1,pt=null,mt={onError:function(e){ut=!0,dt=e}};function ht(e,t,n,r,i,a,o,s,c){ut=!1,dt=null,lt.apply(mt,arguments)}function gt(e,t,n,i,a,o,s,c,l){if(ht.apply(this,arguments),ut){if(ut){var u=dt;ut=!1,dt=null}else throw Error(r(198));ft||(ft=!0,pt=u)}}function _t(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function vt(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function yt(e){if(_t(e)!==e)throw Error(r(188))}function bt(e){var t=e.alternate;if(!t){if(t=_t(e),t===null)throw Error(r(188));return t===e?e:null}for(var n=e,i=t;;){var a=n.return;if(a===null)break;var o=a.alternate;if(o===null){if(i=a.return,i!==null){n=i;continue}break}if(a.child===o.child){for(o=a.child;o;){if(o===n)return yt(a),e;if(o===i)return yt(a),t;o=o.sibling}throw Error(r(188))}if(n.return!==i.return)n=a,i=o;else{for(var s=!1,c=a.child;c;){if(c===n){s=!0,n=a,i=o;break}if(c===i){s=!0,i=a,n=o;break}c=c.sibling}if(!s){for(c=o.child;c;){if(c===n){s=!0,n=o,i=a;break}if(c===i){s=!0,i=o,n=a;break}c=c.sibling}if(!s)throw Error(r(189))}}if(n.alternate!==i)throw Error(r(190))}if(n.tag!==3)throw Error(r(188));return n.stateNode.current===n?e:t}function xt(e){return e=bt(e),e===null?null:St(e)}function St(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=St(e);if(t!==null)return t;e=e.sibling}return null}var Ct=n.unstable_scheduleCallback,wt=n.unstable_cancelCallback,Tt=n.unstable_shouldYield,Et=n.unstable_requestPaint,Dt=n.unstable_now,Ot=n.unstable_getCurrentPriorityLevel,kt=n.unstable_ImmediatePriority,At=n.unstable_UserBlockingPriority,jt=n.unstable_NormalPriority,Mt=n.unstable_LowPriority,Nt=n.unstable_IdlePriority,Pt=null,Ft=null;function It(e){if(Ft&&typeof Ft.onCommitFiberRoot==`function`)try{Ft.onCommitFiberRoot(Pt,e,void 0,(e.current.flags&128)==128)}catch{}}var Lt=Math.clz32?Math.clz32:Bt,Rt=Math.log,zt=Math.LN2;function Bt(e){return e>>>=0,e===0?32:31-(Rt(e)/zt|0)|0}var Vt=64,Ht=4194304;function Ut(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Wt(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,a=e.pingedLanes,o=n&268435455;if(o!==0){var s=o&~i;s===0?(a&=o,a!==0&&(r=Ut(a))):r=Ut(s)}else o=n&~i,o===0?a!==0&&(r=Ut(a)):r=Ut(o);if(r===0)return 0;if(t!==0&&t!==r&&(t&i)===0&&(i=r&-r,a=t&-t,i>=a||i===16&&a&4194240))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-Lt(t),i=1<<n,r|=e[n],t&=~i;return r}function Gt(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Kt(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes;0<a;){var o=31-Lt(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=Gt(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}}function qt(e){return e=e.pendingLanes&-1073741825,e===0?e&1073741824?1073741824:0:e}function Jt(){var e=Vt;return Vt<<=1,!(Vt&4194240)&&(Vt=64),e}function Yt(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Xt(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Lt(t),e[t]=n}function Zt(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var i=31-Lt(n),a=1<<i;t[i]=0,r[i]=-1,e[i]=-1,n&=~a}}function Qt(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Lt(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}var k=0;function $t(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var en,tn,nn,rn,an,on=!1,sn=[],cn=null,ln=null,un=null,dn=new Map,fn=new Map,pn=[],mn=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit`.split(` `);function hn(e,t){switch(e){case`focusin`:case`focusout`:cn=null;break;case`dragenter`:case`dragleave`:ln=null;break;case`mouseover`:case`mouseout`:un=null;break;case`pointerover`:case`pointerout`:dn.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:fn.delete(t.pointerId)}}function gn(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=Ki(t),t!==null&&tn(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function _n(e,t,n,r,i){switch(t){case`focusin`:return cn=gn(cn,e,t,n,r,i),!0;case`dragenter`:return ln=gn(ln,e,t,n,r,i),!0;case`mouseover`:return un=gn(un,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return dn.set(a,gn(dn.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,fn.set(a,gn(fn.get(a)||null,e,t,n,r,i)),!0}return!1}function vn(e){var t=Gi(e.target);if(t!==null){var n=_t(t);if(n!==null){if(t=n.tag,t===13){if(t=vt(n),t!==null){e.blockedOn=t,an(e.priority,function(){nn(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function yn(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=An(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Je=r,n.target.dispatchEvent(r),Je=null}else return t=Ki(n),t!==null&&tn(t),e.blockedOn=n,!1;t.shift()}return!0}function bn(e,t,n){yn(e)&&n.delete(t)}function xn(){on=!1,cn!==null&&yn(cn)&&(cn=null),ln!==null&&yn(ln)&&(ln=null),un!==null&&yn(un)&&(un=null),dn.forEach(bn),fn.forEach(bn)}function Sn(e,t){e.blockedOn===t&&(e.blockedOn=null,on||(on=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,xn)))}function Cn(e){function t(t){return Sn(t,e)}if(0<sn.length){Sn(sn[0],e);for(var n=1;n<sn.length;n++){var r=sn[n];r.blockedOn===e&&(r.blockedOn=null)}}for(cn!==null&&Sn(cn,e),ln!==null&&Sn(ln,e),un!==null&&Sn(un,e),dn.forEach(t),fn.forEach(t),n=0;n<pn.length;n++)r=pn[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<pn.length&&(n=pn[0],n.blockedOn===null);)vn(n),n.blockedOn===null&&pn.shift()}var wn=C.ReactCurrentBatchConfig,Tn=!0;function En(e,t,n,r){var i=k,a=wn.transition;wn.transition=null;try{k=1,On(e,t,n,r)}finally{k=i,wn.transition=a}}function Dn(e,t,n,r){var i=k,a=wn.transition;wn.transition=null;try{k=4,On(e,t,n,r)}finally{k=i,wn.transition=a}}function On(e,t,n,r){if(Tn){var i=An(e,t,n,r);if(i===null)_i(e,t,r,kn,n),hn(e,r);else if(_n(i,e,t,n,r))r.stopPropagation();else if(hn(e,r),t&4&&-1<mn.indexOf(e)){for(;i!==null;){var a=Ki(i);if(a!==null&&en(a),a=An(e,t,n,r),a===null&&_i(e,t,r,kn,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else _i(e,t,r,null,n)}}var kn=null;function An(e,t,n,r){if(kn=null,e=Ye(r),e=Gi(e),e!==null)if(t=_t(e),t===null)e=null;else if(n=t.tag,n===13){if(e=vt(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return kn=e,null}function jn(e){switch(e){case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 1;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`toggle`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 4;case`message`:switch(Ot()){case kt:return 1;case At:return 4;case jt:case Mt:return 16;case Nt:return 536870912;default:return 16}default:return 16}}var Mn=null,Nn=null,Pn=null;function Fn(){if(Pn)return Pn;var e,t=Nn,n=t.length,r,i=`value`in Mn?Mn.value:Mn.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return Pn=i.slice(e,1<r?1-r:void 0)}function In(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Ln(){return!0}function Rn(){return!1}function zn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?Ln:Rn,this.isPropagationStopped=Rn,this}return O(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=Ln)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=Ln)},persist:function(){},isPersistent:Ln}),t}var Bn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Vn=zn(Bn),Hn=O({},Bn,{view:0,detail:0}),Un=zn(Hn),Wn,Gn,Kn,qn=O({},Hn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:j,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==Kn&&(Kn&&e.type===`mousemove`?(Wn=e.screenX-Kn.screenX,Gn=e.screenY-Kn.screenY):Gn=Wn=0,Kn=e),Wn)},movementY:function(e){return`movementY`in e?e.movementY:Gn}}),Jn=zn(qn),Yn=zn(O({},qn,{dataTransfer:0})),Xn=zn(O({},Hn,{relatedTarget:0})),Zn=zn(O({},Bn,{animationName:0,elapsedTime:0,pseudoElement:0})),Qn=zn(O({},Bn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),$n=zn(O({},Bn,{data:0})),er={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},tr={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},A={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function nr(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=A[e])?!!t[e]:!1}function j(){return nr}var rr=zn(O({},Hn,{key:function(e){if(e.key){var t=er[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=In(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?tr[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:j,charCode:function(e){return e.type===`keypress`?In(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?In(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),ir=zn(O({},qn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),ar=zn(O({},Hn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:j})),or=zn(O({},Bn,{propertyName:0,elapsedTime:0,pseudoElement:0})),sr=zn(O({},qn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),cr=[9,13,27,32],lr=c&&`CompositionEvent`in window,ur=null;c&&`documentMode`in document&&(ur=document.documentMode);var dr=c&&`TextEvent`in window&&!ur,fr=c&&(!lr||ur&&8<ur&&11>=ur),pr=` `,mr=!1;function hr(e,t){switch(e){case`keyup`:return cr.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function gr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var M=!1;function N(e,t){switch(e){case`compositionend`:return gr(t);case`keypress`:return t.which===32?(mr=!0,pr):null;case`textInput`:return e=t.data,e===pr&&mr?null:e;default:return null}}function _r(e,t){if(M)return e===`compositionend`||!lr&&hr(e,t)?(e=Fn(),Pn=Nn=Mn=null,M=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return fr&&t.locale!==`ko`?null:t.data;default:return null}}var vr={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function yr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!vr[e.type]:t===`textarea`}function br(e,t,n,r){et(r),t=yi(t,`onChange`),0<t.length&&(n=new Vn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var xr=null,Sr=null;function Cr(e){di(e,0)}function wr(e){if(Se(qi(e)))return e}function Tr(e,t){if(e===`change`)return t}var Er=!1;if(c){var Dr;if(c){var Or=`oninput`in document;if(!Or){var kr=document.createElement(`div`);kr.setAttribute(`oninput`,`return;`),Or=typeof kr.oninput==`function`}Dr=Or}else Dr=!1;Er=Dr&&(!document.documentMode||9<document.documentMode)}function Ar(){xr&&(xr.detachEvent(`onpropertychange`,jr),Sr=xr=null)}function jr(e){if(e.propertyName===`value`&&wr(Sr)){var t=[];br(t,Sr,e,Ye(e)),at(Cr,t)}}function Mr(e,t,n){e===`focusin`?(Ar(),xr=t,Sr=n,xr.attachEvent(`onpropertychange`,jr)):e===`focusout`&&Ar()}function Nr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return wr(Sr)}function Pr(e,t){if(e===`click`)return wr(t)}function Fr(e,t){if(e===`input`||e===`change`)return wr(t)}function Ir(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var Lr=typeof Object.is==`function`?Object.is:Ir;function Rr(e,t){if(Lr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!l.call(t,i)||!Lr(e[i],t[i]))return!1}return!0}function zr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Br(e,t){var n=zr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=zr(n)}}function Vr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Vr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Hr(){for(var e=window,t=Ce();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ce(e.document)}return t}function Ur(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}function Wr(e){var t=Hr(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Vr(n.ownerDocument.documentElement,n)){if(r!==null&&Ur(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),`selectionStart`in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=n.textContent.length,a=Math.min(r.start,i);r=r.end===void 0?a:Math.min(r.end,i),!e.extend&&a>r&&(i=r,r=a,a=i),i=Br(n,a);var o=Br(n,r);i&&o&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),a>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus==`function`&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var Gr=c&&`documentMode`in document&&11>=document.documentMode,Kr=null,qr=null,Jr=null,Yr=!1;function Xr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Yr||Kr==null||Kr!==Ce(r)||(r=Kr,`selectionStart`in r&&Ur(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Jr&&Rr(Jr,r)||(Jr=r,r=yi(qr,`onSelect`),0<r.length&&(t=new Vn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Kr)))}function Zr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var P={animationend:Zr(`Animation`,`AnimationEnd`),animationiteration:Zr(`Animation`,`AnimationIteration`),animationstart:Zr(`Animation`,`AnimationStart`),transitionend:Zr(`Transition`,`TransitionEnd`)},Qr={},$r={};c&&($r=document.createElement(`div`).style,`AnimationEvent`in window||(delete P.animationend.animation,delete P.animationiteration.animation,delete P.animationstart.animation),`TransitionEvent`in window||delete P.transitionend.transition);function ei(e){if(Qr[e])return Qr[e];if(!P[e])return e;var t=P[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in $r)return Qr[e]=t[n];return e}var F=ei(`animationend`),ti=ei(`animationiteration`),ni=ei(`animationstart`),ri=ei(`transitionend`),ii=new Map,ai=`abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);function I(e,t){ii.set(e,t),o(t,[e])}for(var oi=0;oi<ai.length;oi++){var si=ai[oi];I(si.toLowerCase(),`on`+(si[0].toUpperCase()+si.slice(1)))}I(F,`onAnimationEnd`),I(ti,`onAnimationIteration`),I(ni,`onAnimationStart`),I(`dblclick`,`onDoubleClick`),I(`focusin`,`onFocus`),I(`focusout`,`onBlur`),I(ri,`onTransitionEnd`),s(`onMouseEnter`,[`mouseout`,`mouseover`]),s(`onMouseLeave`,[`mouseout`,`mouseover`]),s(`onPointerEnter`,[`pointerout`,`pointerover`]),s(`onPointerLeave`,[`pointerout`,`pointerover`]),o(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),o(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),o(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),o(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),o(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),o(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var ci=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),li=new Set(`cancel close invalid load scroll toggle`.split(` `).concat(ci));function ui(e,t,n){var r=e.type||`unknown-event`;e.currentTarget=n,gt(r,t,void 0,e),e.currentTarget=null}function di(e,t){t=(t&4)!=0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;ui(i,s,l),a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;ui(i,s,l),a=c}}}if(ft)throw e=pt,ft=!1,pt=null,e}function fi(e,t){var n=t[Hi];n===void 0&&(n=t[Hi]=new Set);var r=e+`__bubble`;n.has(r)||(gi(t,e,2,!1),n.add(r))}function pi(e,t,n){var r=0;t&&(r|=4),gi(n,e,r,t)}var mi=`_reactListening`+Math.random().toString(36).slice(2);function hi(e){if(!e[mi]){e[mi]=!0,i.forEach(function(t){t!==`selectionchange`&&(li.has(t)||pi(t,!1,e),pi(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[mi]||(t[mi]=!0,pi(`selectionchange`,!1,t))}}function gi(e,t,n,r){switch(jn(t)){case 1:var i=En;break;case 4:i=Dn;break;default:i=On}n=i.bind(null,t,n,e),i=void 0,!st||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function _i(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var s=r.stateNode.containerInfo;if(s===i||s.nodeType===8&&s.parentNode===i)break;if(o===4)for(o=r.return;o!==null;){var c=o.tag;if((c===3||c===4)&&(c=o.stateNode.containerInfo,c===i||c.nodeType===8&&c.parentNode===i))return;o=o.return}for(;s!==null;){if(o=Gi(s),o===null)return;if(c=o.tag,c===5||c===6){r=a=o;continue a}s=s.parentNode}}r=r.return}at(function(){var r=a,i=Ye(n),o=[];a:{var s=ii.get(e);if(s!==void 0){var c=Vn,l=e;switch(e){case`keypress`:if(In(n)===0)break a;case`keydown`:case`keyup`:c=rr;break;case`focusin`:l=`focus`,c=Xn;break;case`focusout`:l=`blur`,c=Xn;break;case`beforeblur`:case`afterblur`:c=Xn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:c=Jn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:c=Yn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:c=ar;break;case F:case ti:case ni:c=Zn;break;case ri:c=or;break;case`scroll`:c=Un;break;case`wheel`:c=sr;break;case`copy`:case`cut`:case`paste`:c=Qn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:c=ir}var u=(t&4)!=0,d=!u&&e===`scroll`,f=u?s===null?null:s+`Capture`:s;u=[];for(var p=r,m;p!==null;){m=p;var h=m.stateNode;if(m.tag===5&&h!==null&&(m=h,f!==null&&(h=ot(p,f),h!=null&&u.push(vi(p,h,m)))),d)break;p=p.return}0<u.length&&(s=new c(s,l,null,n,i),o.push({event:s,listeners:u}))}}if(!(t&7)){a:{if(s=e===`mouseover`||e===`pointerover`,c=e===`mouseout`||e===`pointerout`,s&&n!==Je&&(l=n.relatedTarget||n.fromElement)&&(Gi(l)||l[Vi]))break a;if((c||s)&&(s=i.window===i?i:(s=i.ownerDocument)?s.defaultView||s.parentWindow:window,c?(l=n.relatedTarget||n.toElement,c=r,l=l?Gi(l):null,l!==null&&(d=_t(l),l!==d||l.tag!==5&&l.tag!==6)&&(l=null)):(c=null,l=r),c!==l)){if(u=Jn,h=`onMouseLeave`,f=`onMouseEnter`,p=`mouse`,(e===`pointerout`||e===`pointerover`)&&(u=ir,h=`onPointerLeave`,f=`onPointerEnter`,p=`pointer`),d=c==null?s:qi(c),m=l==null?s:qi(l),s=new u(h,p+`leave`,c,n,i),s.target=d,s.relatedTarget=m,h=null,Gi(i)===r&&(u=new u(f,p+`enter`,l,n,i),u.target=m,u.relatedTarget=d,h=u),d=h,c&&l)b:{for(u=c,f=l,p=0,m=u;m;m=bi(m))p++;for(m=0,h=f;h;h=bi(h))m++;for(;0<p-m;)u=bi(u),p--;for(;0<m-p;)f=bi(f),m--;for(;p--;){if(u===f||f!==null&&u===f.alternate)break b;u=bi(u),f=bi(f)}u=null}else u=null;c!==null&&xi(o,s,c,u,!1),l!==null&&d!==null&&xi(o,d,l,u,!0)}}a:{if(s=r?qi(r):window,c=s.nodeName&&s.nodeName.toLowerCase(),c===`select`||c===`input`&&s.type===`file`)var g=Tr;else if(yr(s))if(Er)g=Fr;else{g=Nr;var _=Mr}else (c=s.nodeName)&&c.toLowerCase()===`input`&&(s.type===`checkbox`||s.type===`radio`)&&(g=Pr);if(g&&=g(e,r)){br(o,g,n,i);break a}_&&_(e,s,r),e===`focusout`&&(_=s._wrapperState)&&_.controlled&&s.type===`number`&&ke(s,`number`,s.value)}switch(_=r?qi(r):window,e){case`focusin`:(yr(_)||_.contentEditable===`true`)&&(Kr=_,qr=r,Jr=null);break;case`focusout`:Jr=qr=Kr=null;break;case`mousedown`:Yr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Yr=!1,Xr(o,n,i);break;case`selectionchange`:if(Gr)break;case`keydown`:case`keyup`:Xr(o,n,i)}var v;if(lr)b:{switch(e){case`compositionstart`:var y=`onCompositionStart`;break b;case`compositionend`:y=`onCompositionEnd`;break b;case`compositionupdate`:y=`onCompositionUpdate`;break b}y=void 0}else M?hr(e,n)&&(y=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(y=`onCompositionStart`);y&&(fr&&n.locale!==`ko`&&(M||y!==`onCompositionStart`?y===`onCompositionEnd`&&M&&(v=Fn()):(Mn=i,Nn=`value`in Mn?Mn.value:Mn.textContent,M=!0)),_=yi(r,y),0<_.length&&(y=new $n(y,e,null,n,i),o.push({event:y,listeners:_}),v?y.data=v:(v=gr(n),v!==null&&(y.data=v)))),(v=dr?N(e,n):_r(e,n))&&(r=yi(r,`onBeforeInput`),0<r.length&&(i=new $n(`onBeforeInput`,`beforeinput`,null,n,i),o.push({event:i,listeners:r}),i.data=v))}di(o,t)})}function vi(e,t,n){return{instance:e,listener:t,currentTarget:n}}function yi(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;i.tag===5&&a!==null&&(i=a,a=ot(e,n),a!=null&&r.unshift(vi(e,a,i)),a=ot(e,t),a!=null&&r.push(vi(e,a,i))),e=e.return}return r}function bi(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function xi(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(c!==null&&c===r)break;s.tag===5&&l!==null&&(s=l,i?(c=ot(n,a),c!=null&&o.unshift(vi(n,c,s))):i||(c=ot(n,a),c!=null&&o.push(vi(n,c,s)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Si=/\r\n?/g,Ci=/\u0000|\uFFFD/g;function wi(e){return(typeof e==`string`?e:``+e).replace(Si,`
6
+ `).replace(Ci,``)}function Ti(e,t,n){if(t=wi(t),wi(e)!==t&&n)throw Error(r(425))}function Ei(){}var Di=null,Oi=null;function ki(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Ai=typeof setTimeout==`function`?setTimeout:void 0,ji=typeof clearTimeout==`function`?clearTimeout:void 0,Mi=typeof Promise==`function`?Promise:void 0,Ni=typeof queueMicrotask==`function`?queueMicrotask:Mi===void 0?Ai:function(e){return Mi.resolve(null).then(e).catch(Pi)};function Pi(e){setTimeout(function(){throw e})}function Fi(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`){if(r===0){e.removeChild(i),Cn(t);return}r--}else n!==`$`&&n!==`$?`&&n!==`$!`||r++;n=i}while(n);Cn(t)}function Ii(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`)break;if(t===`/$`)return null}}return e}function Li(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`){if(t===0)return e;t--}else n===`/$`&&t++}e=e.previousSibling}return null}var Ri=Math.random().toString(36).slice(2),zi=`__reactFiber$`+Ri,Bi=`__reactProps$`+Ri,Vi=`__reactContainer$`+Ri,Hi=`__reactEvents$`+Ri,Ui=`__reactListeners$`+Ri,Wi=`__reactHandles$`+Ri;function Gi(e){var t=e[zi];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Vi]||n[zi]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Li(e);e!==null;){if(n=e[zi])return n;e=Li(e)}return t}e=n,n=e.parentNode}return null}function Ki(e){return e=e[zi]||e[Vi],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function qi(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(r(33))}function Ji(e){return e[Bi]||null}var Yi=[],Xi=-1;function Zi(e){return{current:e}}function Qi(e){0>Xi||(e.current=Yi[Xi],Yi[Xi]=null,Xi--)}function $i(e,t){Xi++,Yi[Xi]=e.current,e.current=t}var L={},ea=Zi(L),ta=Zi(!1),na=L;function ra(e,t){var n=e.type.contextTypes;if(!n)return L;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},a;for(a in n)i[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function ia(e){return e=e.childContextTypes,e!=null}function aa(){Qi(ta),Qi(ea)}function oa(e,t,n){if(ea.current!==L)throw Error(r(168));$i(ea,t),$i(ta,n)}function sa(e,t,n){var i=e.stateNode;if(t=t.childContextTypes,typeof i.getChildContext!=`function`)return n;for(var a in i=i.getChildContext(),i)if(!(a in t))throw Error(r(108,_e(e)||`Unknown`,a));return O({},n,i)}function ca(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||L,na=ea.current,$i(ea,e),$i(ta,ta.current),!0}function la(e,t,n){var i=e.stateNode;if(!i)throw Error(r(169));n?(e=sa(e,t,na),i.__reactInternalMemoizedMergedChildContext=e,Qi(ta),Qi(ea),$i(ea,e)):Qi(ta),$i(ta,n)}var ua=null,da=!1,fa=!1;function pa(e){ua===null?ua=[e]:ua.push(e)}function ma(e){da=!0,pa(e)}function ha(){if(!fa&&ua!==null){fa=!0;var e=0,t=k;try{var n=ua;for(k=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}ua=null,da=!1}catch(t){throw ua!==null&&(ua=ua.slice(e+1)),Ct(kt,ha),t}finally{k=t,fa=!1}}return null}var ga=[],_a=0,va=null,ya=0,ba=[],xa=0,Sa=null,Ca=1,wa=``;function Ta(e,t){ga[_a++]=ya,ga[_a++]=va,va=e,ya=t}function Ea(e,t,n){ba[xa++]=Ca,ba[xa++]=wa,ba[xa++]=Sa,Sa=e;var r=Ca;e=wa;var i=32-Lt(r)-1;r&=~(1<<i),n+=1;var a=32-Lt(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,Ca=1<<32-Lt(t)+i|n<<i|r,wa=a+e}else Ca=1<<a|n<<i|r,wa=e}function Da(e){e.return!==null&&(Ta(e,1),Ea(e,1,0))}function Oa(e){for(;e===va;)va=ga[--_a],ga[_a]=null,ya=ga[--_a],ga[_a]=null;for(;e===Sa;)Sa=ba[--xa],ba[xa]=null,wa=ba[--xa],ba[xa]=null,Ca=ba[--xa],ba[xa]=null}var ka=null,Aa=null,R=!1,ja=null;function Ma(e,t){var n=Jl(5,null,null,0);n.elementType=`DELETED`,n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function Na(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t===null?!1:(e.stateNode=t,ka=e,Aa=Ii(t.firstChild),!0);case 6:return t=e.pendingProps===``||t.nodeType!==3?null:t,t===null?!1:(e.stateNode=t,ka=e,Aa=null,!0);case 13:return t=t.nodeType===8?t:null,t===null?!1:(n=Sa===null?null:{id:Ca,overflow:wa},e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Jl(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,ka=e,Aa=null,!0);default:return!1}}function Pa(e){return(e.mode&1)!=0&&(e.flags&128)==0}function Fa(e){if(R){var t=Aa;if(t){var n=t;if(!Na(e,t)){if(Pa(e))throw Error(r(418));t=Ii(n.nextSibling);var i=ka;t&&Na(e,t)?Ma(i,n):(e.flags=e.flags&-4097|2,R=!1,ka=e)}}else{if(Pa(e))throw Error(r(418));e.flags=e.flags&-4097|2,R=!1,ka=e}}}function Ia(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;ka=e}function La(e){if(e!==ka)return!1;if(!R)return Ia(e),R=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!==`head`&&t!==`body`&&!ki(e.type,e.memoizedProps)),t&&=Aa){if(Pa(e))throw Ra(),Error(r(418));for(;t;)Ma(e,t),t=Ii(t.nextSibling)}if(Ia(e),e.tag===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(r(317));a:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`){if(t===0){Aa=Ii(e.nextSibling);break a}t--}else n!==`$`&&n!==`$!`&&n!==`$?`||t++}e=e.nextSibling}Aa=null}}else Aa=ka?Ii(e.stateNode.nextSibling):null;return!0}function Ra(){for(var e=Aa;e;)e=Ii(e.nextSibling)}function za(){Aa=ka=null,R=!1}function Ba(e){ja===null?ja=[e]:ja.push(e)}var Va=C.ReactCurrentBatchConfig;function Ha(e,t,n){if(e=n.ref,e!==null&&typeof e!=`function`&&typeof e!=`object`){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(r(309));var i=n.stateNode}if(!i)throw Error(r(147,e));var a=i,o=``+e;return t!==null&&t.ref!==null&&typeof t.ref==`function`&&t.ref._stringRef===o?t.ref:(t=function(e){var t=a.refs;e===null?delete t[o]:t[o]=e},t._stringRef=o,t)}if(typeof e!=`string`)throw Error(r(284));if(!n._owner)throw Error(r(290,e))}return e}function Ua(e,t){throw e=Object.prototype.toString.call(t),Error(r(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e))}function Wa(e){var t=e._init;return t(e._payload)}function Ga(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function i(e,t){for(e=new Map;t!==null;)t.key===null?e.set(t.index,t):e.set(t.key,t),t=t.sibling;return e}function a(e,t){return e=Zl(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=2,n):(r=r.index,r<n?(t.flags|=2,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=2),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=tu(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===E?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===se&&Wa(i)===t.type)?(r=a(t,n.props),r.ref=Ha(e,t,n),r.return=e,r):(r=Ql(n.type,n.key,n.props,null,e.mode,r),r.ref=Ha(e,t,n),r.return=e,r)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=nu(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=$l(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`)return t=tu(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case w:return n=Ql(t.type,t.key,t.props,null,e.mode,n),n.ref=Ha(e,null,t),n.return=e,n;case T:return t=nu(t,e.mode,n),t.return=e,t;case se:var r=t._init;return f(e,r(t._payload),n)}if(Ae(t)||ue(t))return t=$l(t,e.mode,n,null),t.return=e,t;Ua(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case w:return n.key===i?l(e,t,n,r):null;case T:return n.key===i?u(e,t,n,r):null;case se:return i=n._init,p(e,t,i(n._payload),r)}if(Ae(n)||ue(n))return i===null?d(e,t,n,r,null):null;Ua(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case w:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case T:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case se:var a=r._init;return m(e,t,n,a(r._payload),i)}if(Ae(r)||ue(r))return e=e.get(n)||null,d(t,e,r,i,null);Ua(t,r)}return null}function h(r,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(r,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(r,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(r,d),R&&Ta(r,h),l;if(d===null){for(;h<s.length;h++)d=f(r,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return R&&Ta(r,h),l}for(d=i(r,d);h<s.length;h++)g=m(d,r,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(r,e)}),R&&Ta(r,h),l}function g(a,s,c,l){var u=ue(c);if(typeof u!=`function`)throw Error(r(150));if(c=u.call(c),c==null)throw Error(r(151));for(var d=u=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),R&&Ta(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return R&&Ta(a,g),u}for(h=i(a,h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),R&&Ta(a,g),u}function _(e,r,i,o){if(typeof i==`object`&&i&&i.type===E&&i.key===null&&(i=i.props.children),typeof i==`object`&&i){switch(i.$$typeof){case w:a:{for(var c=i.key,l=r;l!==null;){if(l.key===c){if(c=i.type,c===E){if(l.tag===7){n(e,l.sibling),r=a(l,i.props.children),r.return=e,e=r;break a}}else if(l.elementType===c||typeof c==`object`&&c&&c.$$typeof===se&&Wa(c)===l.type){n(e,l.sibling),r=a(l,i.props),r.ref=Ha(e,l,i),r.return=e,e=r;break a}n(e,l);break}else t(e,l);l=l.sibling}i.type===E?(r=$l(i.props.children,e.mode,o,i.key),r.return=e,e=r):(o=Ql(i.type,i.key,i.props,null,e.mode,o),o.ref=Ha(e,r,i),o.return=e,e=o)}return s(e);case T:a:{for(l=i.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===i.containerInfo&&r.stateNode.implementation===i.implementation){n(e,r.sibling),r=a(r,i.children||[]),r.return=e,e=r;break a}else{n(e,r);break}else t(e,r);r=r.sibling}r=nu(i,e.mode,o),r.return=e,e=r}return s(e);case se:return l=i._init,_(e,r,l(i._payload),o)}if(Ae(i))return h(e,r,i,o);if(ue(i))return g(e,r,i,o);Ua(e,i)}return typeof i==`string`&&i!==``||typeof i==`number`?(i=``+i,r!==null&&r.tag===6?(n(e,r.sibling),r=a(r,i),r.return=e,e=r):(n(e,r),r=tu(i,e.mode,o),r.return=e,e=r),s(e)):n(e,r)}return _}var Ka=Ga(!0),qa=Ga(!1),Ja=Zi(null),Ya=null,Xa=null,Za=null;function z(){Za=Xa=Ya=null}function Qa(e){var t=Ja.current;Qi(Ja),e._currentValue=t}function $a(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function eo(e,t){Ya=e,Za=Xa=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(Fs=!0),e.firstContext=null)}function to(e){var t=e._currentValue;if(Za!==e)if(e={context:e,memoizedValue:t,next:null},Xa===null){if(Ya===null)throw Error(r(308));Xa=e,Ya.dependencies={lanes:0,firstContext:e}}else Xa=Xa.next=e;return t}var no=null;function ro(e){no===null?no=[e]:no.push(e)}function io(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,ro(t)):(n.next=i.next,i.next=n),t.interleaved=n,ao(e,r)}function ao(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var oo=!1;function so(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function co(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function lo(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function uo(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Z&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,ao(e,n)}return i=r.interleaved,i===null?(t.next=t,ro(r)):(t.next=i.next,i.next=t),r.interleaved=t,ao(e,n)}function fo(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194240)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Qt(e,n)}}function po(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function mo(e,t,n,r){var i=e.updateQueue;oo=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane,p=s.eventTime;if((r&f)===f){u!==null&&(u=u.next={eventTime:p,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});a:{var m=e,h=s;switch(f=t,p=n,h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(p,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(p,d,f):m,f==null)break a;d=O({},d,f);break a;case 2:oo=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,f=i.effects,f===null?i.effects=[s]:f.push(s))}else p={eventTime:p,lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;f=s,s=f.next,f.next=null,i.lastBaseUpdate=f,i.shared.pending=null}}while(1);if(u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,t=i.shared.interleaved,t!==null){i=t;do o|=i.lane,i=i.next;while(i!==t)}else a===null&&(i.shared.lanes=0);Xc|=o,e.lanes=o,e.memoizedState=d}}function ho(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var i=e[t],a=i.callback;if(a!==null){if(i.callback=null,i=n,typeof a!=`function`)throw Error(r(191,a));a.call(i)}}}var go={},_o=Zi(go),vo=Zi(go),yo=Zi(go);function bo(e){if(e===go)throw Error(r(174));return e}function xo(e,t){switch($i(yo,t),$i(vo,e),$i(_o,go),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Le(null,``);break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Le(t,e)}Qi(_o),$i(_o,t)}function So(){Qi(_o),Qi(vo),Qi(yo)}function Co(e){bo(yo.current);var t=bo(_o.current),n=Le(t,e.type);t!==n&&($i(vo,e),$i(_o,n))}function wo(e){vo.current===e&&(Qi(_o),Qi(vo))}var To=Zi(0);function Eo(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data===`$?`||n.data===`$!`))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Do=[];function Oo(){for(var e=0;e<Do.length;e++)Do[e]._workInProgressVersionPrimary=null;Do.length=0}var ko=C.ReactCurrentDispatcher,B=C.ReactCurrentBatchConfig,Ao=0,jo=null,Mo=null,No=null,Po=!1,Fo=!1,V=0,Io=0;function H(){throw Error(r(321))}function Lo(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Lr(e[n],t[n]))return!1;return!0}function U(e,t,n,i,a,o){if(Ao=o,jo=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,ko.current=e===null||e.memoizedState===null?hs:gs,e=n(i,a),Fo){o=0;do{if(Fo=!1,V=0,25<=o)throw Error(r(301));o+=1,No=Mo=null,t.updateQueue=null,ko.current=_s,e=n(i,a)}while(Fo)}if(ko.current=ms,t=Mo!==null&&Mo.next!==null,Ao=0,No=Mo=jo=null,Po=!1,t)throw Error(r(300));return e}function Ro(){var e=V!==0;return V=0,e}function zo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return No===null?jo.memoizedState=No=e:No=No.next=e,No}function Bo(){if(Mo===null){var e=jo.alternate;e=e===null?null:e.memoizedState}else e=Mo.next;var t=No===null?jo.memoizedState:No.next;if(t!==null)No=t,Mo=e;else{if(e===null)throw Error(r(310));Mo=e,e={memoizedState:Mo.memoizedState,baseState:Mo.baseState,baseQueue:Mo.baseQueue,queue:Mo.queue,next:null},No===null?jo.memoizedState=No=e:No=No.next=e}return No}function Vo(e,t){return typeof t==`function`?t(e):t}function Ho(e){var t=Bo(),n=t.queue;if(n===null)throw Error(r(311));n.lastRenderedReducer=e;var i=Mo,a=i.baseQueue,o=n.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}i.baseQueue=a=o,n.pending=null}if(a!==null){o=a.next,i=i.baseState;var c=s=null,l=null,u=o;do{var d=u.lane;if((Ao&d)===d)l!==null&&(l=l.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),i=u.hasEagerState?u.eagerState:e(i,u.action);else{var f={lane:d,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};l===null?(c=l=f,s=i):l=l.next=f,jo.lanes|=d,Xc|=d}u=u.next}while(u!==null&&u!==o);l===null?s=i:l.next=c,Lr(i,t.memoizedState)||(Fs=!0),t.memoizedState=i,t.baseState=s,t.baseQueue=l,n.lastRenderedState=i}if(e=n.interleaved,e!==null){a=e;do o=a.lane,jo.lanes|=o,Xc|=o,a=a.next;while(a!==e)}else a===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function W(e){var t=Bo(),n=t.queue;if(n===null)throw Error(r(311));n.lastRenderedReducer=e;var i=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);Lr(o,t.memoizedState)||(Fs=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,i]}function Uo(){}function G(e,t){var n=jo,i=Bo(),a=t(),o=!Lr(i.memoizedState,a);if(o&&(i.memoizedState=a,Fs=!0),i=i.queue,Qo(Ko.bind(null,n,i,e),[e]),i.getSnapshot!==t||o||No!==null&&No.memoizedState.tag&1){if(n.flags|=2048,K(9,Go.bind(null,n,i,a,t),void 0,null),Uc===null)throw Error(r(349));Ao&30||Wo(n,t,a)}return a}function Wo(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=jo.updateQueue,t===null?(t={lastEffect:null,stores:null},jo.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Go(e,t,n,r){t.value=n,t.getSnapshot=r,qo(t)&&Jo(e)}function Ko(e,t,n){return n(function(){qo(t)&&Jo(e)})}function qo(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Lr(e,n)}catch{return!0}}function Jo(e){var t=ao(e,1);t!==null&&gl(t,e,1,-1)}function Yo(e){var t=zo();return typeof e==`function`&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Vo,lastRenderedState:e},t.queue=e,e=e.dispatch=us.bind(null,jo,e),[t.memoizedState,e]}function K(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=jo.updateQueue,t===null?(t={lastEffect:null,stores:null},jo.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function Xo(){return Bo().memoizedState}function Zo(e,t,n,r){var i=zo();jo.flags|=e,i.memoizedState=K(1|t,n,void 0,r===void 0?null:r)}function q(e,t,n,r){var i=Bo();r=r===void 0?null:r;var a=void 0;if(Mo!==null){var o=Mo.memoizedState;if(a=o.destroy,r!==null&&Lo(r,o.deps)){i.memoizedState=K(t,n,a,r);return}}jo.flags|=e,i.memoizedState=K(1|t,n,a,r)}function J(e,t){return Zo(8390656,8,e,t)}function Qo(e,t){return q(2048,8,e,t)}function $o(e,t){return q(4,2,e,t)}function es(e,t){return q(4,4,e,t)}function ts(e,t){if(typeof t==`function`)return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function ns(e,t,n){return n=n==null?null:n.concat([e]),q(4,4,ts.bind(null,t,e),n)}function rs(){}function is(e,t){var n=Bo();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Lo(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function as(e,t){var n=Bo();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Lo(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function os(e,t,n){return Ao&21?(Lr(n,t)||(n=Jt(),jo.lanes|=n,Xc|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Fs=!0),e.memoizedState=n)}function ss(e,t){var n=k;k=n!==0&&4>n?n:4,e(!0);var r=B.transition;B.transition={};try{e(!1),t()}finally{k=n,B.transition=r}}function cs(){return Bo().memoizedState}function ls(e,t,n){var r=hl(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},ds(e))fs(t,n);else if(n=io(e,t,n,r),n!==null){var i=ml();gl(n,e,r,i),ps(n,t,r)}}function us(e,t,n){var r=hl(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(ds(e))fs(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Lr(s,o)){var c=t.interleaved;c===null?(i.next=i,ro(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}n=io(e,t,i,r),n!==null&&(i=ml(),gl(n,e,r,i),ps(n,t,r))}}function ds(e){var t=e.alternate;return e===jo||t!==null&&t===jo}function fs(e,t){Fo=Po=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function ps(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Qt(e,n)}}var ms={readContext:to,useCallback:H,useContext:H,useEffect:H,useImperativeHandle:H,useInsertionEffect:H,useLayoutEffect:H,useMemo:H,useReducer:H,useRef:H,useState:H,useDebugValue:H,useDeferredValue:H,useTransition:H,useMutableSource:H,useSyncExternalStore:H,useId:H,unstable_isNewReconciler:!1},hs={readContext:to,useCallback:function(e,t){return zo().memoizedState=[e,t===void 0?null:t],e},useContext:to,useEffect:J,useImperativeHandle:function(e,t,n){return n=n==null?null:n.concat([e]),Zo(4194308,4,ts.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Zo(4194308,4,e,t)},useInsertionEffect:function(e,t){return Zo(4,2,e,t)},useMemo:function(e,t){var n=zo();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=zo();return t=n===void 0?t:n(t),r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=ls.bind(null,jo,e),[r.memoizedState,e]},useRef:function(e){var t=zo();return e={current:e},t.memoizedState=e},useState:Yo,useDebugValue:rs,useDeferredValue:function(e){return zo().memoizedState=e},useTransition:function(){var e=Yo(!1),t=e[0];return e=ss.bind(null,e[1]),zo().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var i=jo,a=zo();if(R){if(n===void 0)throw Error(r(407));n=n()}else{if(n=t(),Uc===null)throw Error(r(349));Ao&30||Wo(i,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,J(Ko.bind(null,i,o,e),[e]),i.flags|=2048,K(9,Go.bind(null,i,o,n,t),void 0,null),n},useId:function(){var e=zo(),t=Uc.identifierPrefix;if(R){var n=wa,r=Ca;n=(r&~(1<<32-Lt(r)-1)).toString(32)+n,t=`:`+t+`R`+n,n=V++,0<n&&(t+=`H`+n.toString(32)),t+=`:`}else n=Io++,t=`:`+t+`r`+n.toString(32)+`:`;return e.memoizedState=t},unstable_isNewReconciler:!1},gs={readContext:to,useCallback:is,useContext:to,useEffect:Qo,useImperativeHandle:ns,useInsertionEffect:$o,useLayoutEffect:es,useMemo:as,useReducer:Ho,useRef:Xo,useState:function(){return Ho(Vo)},useDebugValue:rs,useDeferredValue:function(e){return os(Bo(),Mo.memoizedState,e)},useTransition:function(){return[Ho(Vo)[0],Bo().memoizedState]},useMutableSource:Uo,useSyncExternalStore:G,useId:cs,unstable_isNewReconciler:!1},_s={readContext:to,useCallback:is,useContext:to,useEffect:Qo,useImperativeHandle:ns,useInsertionEffect:$o,useLayoutEffect:es,useMemo:as,useReducer:W,useRef:Xo,useState:function(){return W(Vo)},useDebugValue:rs,useDeferredValue:function(e){var t=Bo();return Mo===null?t.memoizedState=e:os(t,Mo.memoizedState,e)},useTransition:function(){return[W(Vo)[0],Bo().memoizedState]},useMutableSource:Uo,useSyncExternalStore:G,useId:cs,unstable_isNewReconciler:!1};function vs(e,t){if(e&&e.defaultProps){for(var n in t=O({},t),e=e.defaultProps,e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function ys(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:O({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var bs={isMounted:function(e){return(e=e._reactInternals)?_t(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=ml(),i=hl(e),a=lo(r,i);a.payload=t,n!=null&&(a.callback=n),t=uo(e,a,i),t!==null&&(gl(t,e,i,r),fo(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=ml(),i=hl(e),a=lo(r,i);a.tag=1,a.payload=t,n!=null&&(a.callback=n),t=uo(e,a,i),t!==null&&(gl(t,e,i,r),fo(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=ml(),r=hl(e),i=lo(n,r);i.tag=2,t!=null&&(i.callback=t),t=uo(e,i,r),t!==null&&(gl(t,e,r,n),fo(t,e,r))}};function xs(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!Rr(n,r)||!Rr(i,a):!0}function Ss(e,t,n){var r=!1,i=L,a=t.contextType;return typeof a==`object`&&a?a=to(a):(i=ia(t)?na:ea.current,r=t.contextTypes,a=(r=r!=null)?ra(e,i):L),t=new t(n,a),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=bs,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=a),t}function Cs(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&bs.enqueueReplaceState(t,t.state,null)}function ws(e,t,n,r){var i=e.stateNode;i.props=n,i.state=e.memoizedState,i.refs={},so(e);var a=t.contextType;typeof a==`object`&&a?i.context=to(a):(a=ia(t)?na:ea.current,i.context=ra(e,a)),i.state=e.memoizedState,a=t.getDerivedStateFromProps,typeof a==`function`&&(ys(e,t,a,n),i.state=e.memoizedState),typeof t.getDerivedStateFromProps==`function`||typeof i.getSnapshotBeforeUpdate==`function`||typeof i.UNSAFE_componentWillMount!=`function`&&typeof i.componentWillMount!=`function`||(t=i.state,typeof i.componentWillMount==`function`&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount==`function`&&i.UNSAFE_componentWillMount(),t!==i.state&&bs.enqueueReplaceState(i,i.state,null),mo(e,n,i,r),i.state=e.memoizedState),typeof i.componentDidMount==`function`&&(e.flags|=4194308)}function Ts(e,t){try{var n=``,r=t;do n+=he(r),r=r.return;while(r);var i=n}catch(e){i=`
7
+ Error generating stack: `+e.message+`
8
+ `+e.stack}return{value:e,source:t,stack:i,digest:null}}function Es(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Ds(e,t){try{console.error(t.value)}catch(e){setTimeout(function(){throw e})}}var Os=typeof WeakMap==`function`?WeakMap:Map;function ks(e,t,n){n=lo(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){il||(il=!0,al=r),Ds(e,t)},n}function As(e,t,n){n=lo(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r==`function`){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){Ds(e,t)}}var a=e.stateNode;return a!==null&&typeof a.componentDidCatch==`function`&&(n.callback=function(){Ds(e,t),typeof r!=`function`&&(ol===null?ol=new Set([this]):ol.add(this));var n=t.stack;this.componentDidCatch(t.value,{componentStack:n===null?``:n})}),n}function js(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Os;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(i.add(n),e=Vl.bind(null,e,t,n),t.then(e,e))}function Ms(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t===null?!0:t.dehydrated!==null),t)return e;e=e.return}while(e!==null);return null}function Ns(e,t,n,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=lo(-1,1),t.tag=2,uo(n,t,1))),n.lanes|=1),e)}var Ps=C.ReactCurrentOwner,Fs=!1;function Is(e,t,n,r){t.child=e===null?qa(t,null,n,r):Ka(t,e.child,n,r)}function Ls(e,t,n,r,i){n=n.render;var a=t.ref;return eo(t,i),r=U(e,t,n,r,a,i),n=Ro(),e!==null&&!Fs?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,rc(e,t,i)):(R&&n&&Da(t),t.flags|=1,Is(e,t,r,i),t.child)}function Rs(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Yl(a)&&a.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=a,zs(e,t,a,r,i)):(e=Ql(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,(e.lanes&i)===0){var o=a.memoizedProps;if(n=n.compare,n=n===null?Rr:n,n(o,r)&&e.ref===t.ref)return rc(e,t,i)}return t.flags|=1,e=Zl(a,r),e.ref=t.ref,e.return=t,t.child=e}function zs(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Rr(a,r)&&e.ref===t.ref)if(Fs=!1,t.pendingProps=r=a,(e.lanes&i)!==0)e.flags&131072&&(Fs=!0);else return t.lanes=e.lanes,rc(e,t,i)}return Hs(e,t,n,r,i)}function Bs(e,t,n){var r=t.pendingProps,i=r.children,a=e===null?null:e.memoizedState;if(r.mode===`hidden`)if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},$i(qc,Kc),Kc|=n;else{if(!(n&1073741824))return e=a===null?n:a.baseLanes|n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,$i(qc,Kc),Kc|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=a===null?n:a.baseLanes,$i(qc,Kc),Kc|=r}else a===null?r=n:(r=a.baseLanes|n,t.memoizedState=null),$i(qc,Kc),Kc|=r;return Is(e,t,i,n),t.child}function Vs(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Hs(e,t,n,r,i){var a=ia(n)?na:ea.current;return a=ra(t,a),eo(t,i),n=U(e,t,n,r,a,i),r=Ro(),e!==null&&!Fs?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,rc(e,t,i)):(R&&r&&Da(t),t.flags|=1,Is(e,t,n,i),t.child)}function Us(e,t,n,r,i){if(ia(n)){var a=!0;ca(t)}else a=!1;if(eo(t,i),t.stateNode===null)nc(e,t),Ss(t,n,r),ws(t,n,r,i),r=!0;else if(e===null){var o=t.stateNode,s=t.memoizedProps;o.props=s;var c=o.context,l=n.contextType;typeof l==`object`&&l?l=to(l):(l=ia(n)?na:ea.current,l=ra(t,l));var u=n.getDerivedStateFromProps,d=typeof u==`function`||typeof o.getSnapshotBeforeUpdate==`function`;d||typeof o.UNSAFE_componentWillReceiveProps!=`function`&&typeof o.componentWillReceiveProps!=`function`||(s!==r||c!==l)&&Cs(t,o,r,l),oo=!1;var f=t.memoizedState;o.state=f,mo(t,r,o,i),c=t.memoizedState,s!==r||f!==c||ta.current||oo?(typeof u==`function`&&(ys(t,n,u,r),c=t.memoizedState),(s=oo||xs(t,n,s,r,f,c,l))?(d||typeof o.UNSAFE_componentWillMount!=`function`&&typeof o.componentWillMount!=`function`||(typeof o.componentWillMount==`function`&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount==`function`&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount==`function`&&(t.flags|=4194308)):(typeof o.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),o.props=r,o.state=c,o.context=l,r=s):(typeof o.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,co(e,t),s=t.memoizedProps,l=t.type===t.elementType?s:vs(t.type,s),o.props=l,d=t.pendingProps,f=o.context,c=n.contextType,typeof c==`object`&&c?c=to(c):(c=ia(n)?na:ea.current,c=ra(t,c));var p=n.getDerivedStateFromProps;(u=typeof p==`function`||typeof o.getSnapshotBeforeUpdate==`function`)||typeof o.UNSAFE_componentWillReceiveProps!=`function`&&typeof o.componentWillReceiveProps!=`function`||(s!==d||f!==c)&&Cs(t,o,r,c),oo=!1,f=t.memoizedState,o.state=f,mo(t,r,o,i);var m=t.memoizedState;s!==d||f!==m||ta.current||oo?(typeof p==`function`&&(ys(t,n,p,r),m=t.memoizedState),(l=oo||xs(t,n,l,r,f,m,c)||!1)?(u||typeof o.UNSAFE_componentWillUpdate!=`function`&&typeof o.componentWillUpdate!=`function`||(typeof o.componentWillUpdate==`function`&&o.componentWillUpdate(r,m,c),typeof o.UNSAFE_componentWillUpdate==`function`&&o.UNSAFE_componentWillUpdate(r,m,c)),typeof o.componentDidUpdate==`function`&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof o.componentDidUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=m),o.props=r,o.state=m,o.context=c,r=l):(typeof o.componentDidUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return Ws(e,t,n,r,a,i)}function Ws(e,t,n,r,i,a){Vs(e,t);var o=(t.flags&128)!=0;if(!r&&!o)return i&&la(t,n,!1),rc(e,t,a);r=t.stateNode,Ps.current=t;var s=o&&typeof n.getDerivedStateFromError!=`function`?null:r.render();return t.flags|=1,e!==null&&o?(t.child=Ka(t,e.child,null,a),t.child=Ka(t,null,s,a)):Is(e,t,s,a),t.memoizedState=r.state,i&&la(t,n,!0),t.child}function Gs(e){var t=e.stateNode;t.pendingContext?oa(e,t.pendingContext,t.pendingContext!==t.context):t.context&&oa(e,t.context,!1),xo(e,t.containerInfo)}function Ks(e,t,n,r,i){return za(),Ba(i),t.flags|=256,Is(e,t,n,r),t.child}var qs={dehydrated:null,treeContext:null,retryLane:0};function Js(e){return{baseLanes:e,cachePool:null,transitions:null}}function Ys(e,t,n){var r=t.pendingProps,i=To.current,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(i&2)!=0),s?(a=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),$i(To,i&1),e===null)return Fa(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data===`$!`?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(o=r.children,e=r.fallback,a?(r=t.mode,a=t.child,o={mode:`hidden`,children:o},!(r&1)&&a!==null?(a.childLanes=0,a.pendingProps=o):a=eu(o,r,0,null),e=$l(e,r,n,null),a.return=t,e.return=t,a.sibling=e,t.child=a,t.child.memoizedState=Js(n),t.memoizedState=qs,e):Xs(t,o));if(i=e.memoizedState,i!==null&&(s=i.dehydrated,s!==null))return Qs(e,t,o,r,s,i,n);if(a){a=r.fallback,o=t.mode,i=e.child,s=i.sibling;var c={mode:`hidden`,children:r.children};return!(o&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=Zl(i,c),r.subtreeFlags=i.subtreeFlags&14680064),s===null?(a=$l(a,o,n,null),a.flags|=2):a=Zl(s,a),a.return=t,r.return=t,r.sibling=a,t.child=r,r=a,a=t.child,o=e.child.memoizedState,o=o===null?Js(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},a.memoizedState=o,a.childLanes=e.childLanes&~n,t.memoizedState=qs,r}return a=e.child,e=a.sibling,r=Zl(a,{mode:`visible`,children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function Xs(e,t){return t=eu({mode:`visible`,children:t},e.mode,0,null),t.return=e,e.child=t}function Zs(e,t,n,r){return r!==null&&Ba(r),Ka(t,e.child,null,n),e=Xs(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Qs(e,t,n,i,a,o,s){if(n)return t.flags&256?(t.flags&=-257,i=Es(Error(r(422))),Zs(e,t,s,i)):t.memoizedState===null?(o=i.fallback,a=t.mode,i=eu({mode:`visible`,children:i.children},a,0,null),o=$l(o,a,s,null),o.flags|=2,i.return=t,o.return=t,i.sibling=o,t.child=i,t.mode&1&&Ka(t,e.child,null,s),t.child.memoizedState=Js(s),t.memoizedState=qs,o):(t.child=e.child,t.flags|=128,null);if(!(t.mode&1))return Zs(e,t,s,null);if(a.data===`$!`){if(i=a.nextSibling&&a.nextSibling.dataset,i)var c=i.dgst;return i=c,o=Error(r(419)),i=Es(o,i,void 0),Zs(e,t,s,i)}if(c=(s&e.childLanes)!==0,Fs||c){if(i=Uc,i!==null){switch(s&-s){case 4:a=2;break;case 16:a=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:a=32;break;case 536870912:a=268435456;break;default:a=0}a=(a&(i.suspendedLanes|s))===0?a:0,a!==0&&a!==o.retryLane&&(o.retryLane=a,ao(e,a),gl(i,e,a,-1))}return Al(),i=Es(Error(r(421))),Zs(e,t,s,i)}return a.data===`$?`?(t.flags|=128,t.child=e.child,t=Ul.bind(null,e),a._reactRetry=t,null):(e=o.treeContext,Aa=Ii(a.nextSibling),ka=t,R=!0,ja=null,e!==null&&(ba[xa++]=Ca,ba[xa++]=wa,ba[xa++]=Sa,Ca=e.id,wa=e.overflow,Sa=t),t=Xs(t,i.children),t.flags|=4096,t)}function $s(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),$a(e.return,t,n)}function ec(e,t,n,r,i){var a=e.memoizedState;a===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(a.isBackwards=t,a.rendering=null,a.renderingStartTime=0,a.last=r,a.tail=n,a.tailMode=i)}function tc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;if(Is(e,t,r.children,n),r=To.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&$s(e,n,t);else if(e.tag===19)$s(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if($i(To,r),!(t.mode&1))t.memoizedState=null;else switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&Eo(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),ec(t,!1,i,n,a);break;case`backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&Eo(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}ec(t,!0,n,null,a);break;case`together`:ec(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function nc(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function rc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Xc|=t.lanes,(n&t.childLanes)===0)return null;if(e!==null&&t.child!==e.child)throw Error(r(153));if(t.child!==null){for(e=t.child,n=Zl(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Zl(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function ic(e,t,n){switch(t.tag){case 3:Gs(t),za();break;case 5:Co(t);break;case 1:ia(t.type)&&ca(t);break;case 4:xo(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;$i(Ja,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?($i(To,To.current&1),e=rc(e,t,n),e===null?null:e.sibling):Ys(e,t,n):($i(To,To.current&1),t.flags|=128,null);$i(To,To.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return tc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),$i(To,To.current),r)break;return null;case 22:case 23:return t.lanes=0,Bs(e,t,n)}return rc(e,t,n)}var ac=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}},oc=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,bo(_o.current);var o=null;switch(n){case`input`:i=we(e,i),r=we(e,r),o=[];break;case`select`:i=O({},i,{value:void 0}),r=O({},r,{value:void 0}),o=[];break;case`textarea`:i=Me(e,i),r=Me(e,r),o=[];break;default:typeof i.onClick!=`function`&&typeof r.onClick==`function`&&(e.onclick=Ei)}Ke(n,r);var s;for(u in n=null,i)if(!r.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null)if(u===`style`){var c=i[u];for(s in c)c.hasOwnProperty(s)&&(n||={},n[s]=``)}else u!==`dangerouslySetInnerHTML`&&u!==`children`&&u!==`suppressContentEditableWarning`&&u!==`suppressHydrationWarning`&&u!==`autoFocus`&&(a.hasOwnProperty(u)?o||=[]:(o||=[]).push(u,null));for(u in r){var l=r[u];if(c=i?.[u],r.hasOwnProperty(u)&&l!==c&&(l!=null||c!=null))if(u===`style`)if(c){for(s in c)!c.hasOwnProperty(s)||l&&l.hasOwnProperty(s)||(n||={},n[s]=``);for(s in l)l.hasOwnProperty(s)&&c[s]!==l[s]&&(n||={},n[s]=l[s])}else n||(o||=[],o.push(u,n)),n=l;else u===`dangerouslySetInnerHTML`?(l=l?l.__html:void 0,c=c?c.__html:void 0,l!=null&&c!==l&&(o||=[]).push(u,l)):u===`children`?typeof l!=`string`&&typeof l!=`number`||(o||=[]).push(u,``+l):u!==`suppressContentEditableWarning`&&u!==`suppressHydrationWarning`&&(a.hasOwnProperty(u)?(l!=null&&u===`onScroll`&&fi(`scroll`,e),o||c===l||(o=[])):(o||=[]).push(u,l))}n&&(o||=[]).push(`style`,n);var u=o;(t.updateQueue=u)&&(t.flags|=4)}},sc=function(e,t,n,r){n!==r&&(t.flags|=4)};function cc(e,t){if(!R)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Y(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function lc(e,t,n){var i=t.pendingProps;switch(Oa(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Y(t),null;case 1:return ia(t.type)&&aa(),Y(t),null;case 3:return i=t.stateNode,So(),Qi(ta),Qi(ea),Oo(),i.pendingContext&&(i.context=i.pendingContext,i.pendingContext=null),(e===null||e.child===null)&&(La(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ja!==null&&(bl(ja),ja=null))),Y(t),null;case 5:wo(t);var o=bo(yo.current);if(n=t.type,e!==null&&t.stateNode!=null)oc(e,t,n,i,o),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!i){if(t.stateNode===null)throw Error(r(166));return Y(t),null}if(e=bo(_o.current),La(t)){i=t.stateNode,n=t.type;var s=t.memoizedProps;switch(i[zi]=t,i[Bi]=s,e=(t.mode&1)!=0,n){case`dialog`:fi(`cancel`,i),fi(`close`,i);break;case`iframe`:case`object`:case`embed`:fi(`load`,i);break;case`video`:case`audio`:for(o=0;o<ci.length;o++)fi(ci[o],i);break;case`source`:fi(`error`,i);break;case`img`:case`image`:case`link`:fi(`error`,i),fi(`load`,i);break;case`details`:fi(`toggle`,i);break;case`input`:Te(i,s),fi(`invalid`,i);break;case`select`:i._wrapperState={wasMultiple:!!s.multiple},fi(`invalid`,i);break;case`textarea`:Ne(i,s),fi(`invalid`,i)}for(var c in Ke(n,s),o=null,s)if(s.hasOwnProperty(c)){var l=s[c];c===`children`?typeof l==`string`?i.textContent!==l&&(!0!==s.suppressHydrationWarning&&Ti(i.textContent,l,e),o=[`children`,l]):typeof l==`number`&&i.textContent!==``+l&&(!0!==s.suppressHydrationWarning&&Ti(i.textContent,l,e),o=[`children`,``+l]):a.hasOwnProperty(c)&&l!=null&&c===`onScroll`&&fi(`scroll`,i)}switch(n){case`input`:xe(i),Oe(i,s,!0);break;case`textarea`:xe(i),Fe(i);break;case`select`:case`option`:break;default:typeof s.onClick==`function`&&(i.onclick=Ei)}i=o,t.updateQueue=i,i!==null&&(t.flags|=4)}else{c=o.nodeType===9?o:o.ownerDocument,e===`http://www.w3.org/1999/xhtml`&&(e=Ie(n)),e===`http://www.w3.org/1999/xhtml`?n===`script`?(e=c.createElement(`div`),e.innerHTML=`<script><\/script>`,e=e.removeChild(e.firstChild)):typeof i.is==`string`?e=c.createElement(n,{is:i.is}):(e=c.createElement(n),n===`select`&&(c=e,i.multiple?c.multiple=!0:i.size&&(c.size=i.size))):e=c.createElementNS(e,n),e[zi]=t,e[Bi]=i,ac(e,t,!1,!1),t.stateNode=e;a:{switch(c=qe(n,i),n){case`dialog`:fi(`cancel`,e),fi(`close`,e),o=i;break;case`iframe`:case`object`:case`embed`:fi(`load`,e),o=i;break;case`video`:case`audio`:for(o=0;o<ci.length;o++)fi(ci[o],e);o=i;break;case`source`:fi(`error`,e),o=i;break;case`img`:case`image`:case`link`:fi(`error`,e),fi(`load`,e),o=i;break;case`details`:fi(`toggle`,e),o=i;break;case`input`:Te(e,i),o=we(e,i),fi(`invalid`,e);break;case`option`:o=i;break;case`select`:e._wrapperState={wasMultiple:!!i.multiple},o=O({},i,{value:void 0}),fi(`invalid`,e);break;case`textarea`:Ne(e,i),o=Me(e,i),fi(`invalid`,e);break;default:o=i}for(s in Ke(n,o),l=o,l)if(l.hasOwnProperty(s)){var u=l[s];s===`style`?We(e,u):s===`dangerouslySetInnerHTML`?(u=u?u.__html:void 0,u!=null&&ze(e,u)):s===`children`?typeof u==`string`?(n!==`textarea`||u!==``)&&Be(e,u):typeof u==`number`&&Be(e,``+u):s!==`suppressContentEditableWarning`&&s!==`suppressHydrationWarning`&&s!==`autoFocus`&&(a.hasOwnProperty(s)?u!=null&&s===`onScroll`&&fi(`scroll`,e):u!=null&&S(e,s,u,c))}switch(n){case`input`:xe(e),Oe(e,i,!1);break;case`textarea`:xe(e),Fe(e);break;case`option`:i.value!=null&&e.setAttribute(`value`,``+ve(i.value));break;case`select`:e.multiple=!!i.multiple,s=i.value,s==null?i.defaultValue!=null&&je(e,!!i.multiple,i.defaultValue,!0):je(e,!!i.multiple,s,!1);break;default:typeof o.onClick==`function`&&(e.onclick=Ei)}switch(n){case`button`:case`input`:case`select`:case`textarea`:i=!!i.autoFocus;break a;case`img`:i=!0;break a;default:i=!1}}i&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return Y(t),null;case 6:if(e&&t.stateNode!=null)sc(e,t,e.memoizedProps,i);else{if(typeof i!=`string`&&t.stateNode===null)throw Error(r(166));if(n=bo(yo.current),bo(_o.current),La(t)){if(i=t.stateNode,n=t.memoizedProps,i[zi]=t,(s=i.nodeValue!==n)&&(e=ka,e!==null))switch(e.tag){case 3:Ti(i.nodeValue,n,(e.mode&1)!=0);break;case 5:!0!==e.memoizedProps.suppressHydrationWarning&&Ti(i.nodeValue,n,(e.mode&1)!=0)}s&&(t.flags|=4)}else i=(n.nodeType===9?n:n.ownerDocument).createTextNode(i),i[zi]=t,t.stateNode=i}return Y(t),null;case 13:if(Qi(To),i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(R&&Aa!==null&&t.mode&1&&!(t.flags&128))Ra(),za(),t.flags|=98560,s=!1;else if(s=La(t),i!==null&&i.dehydrated!==null){if(e===null){if(!s)throw Error(r(318));if(s=t.memoizedState,s=s===null?null:s.dehydrated,!s)throw Error(r(317));s[zi]=t}else za(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Y(t),s=!1}else ja!==null&&(bl(ja),ja=null),s=!0;if(!s)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(i=i!==null,i!==(e!==null&&e.memoizedState!==null)&&i&&(t.child.flags|=8192,t.mode&1&&(e===null||To.current&1?Jc===0&&(Jc=3):Al())),t.updateQueue!==null&&(t.flags|=4),Y(t),null);case 4:return So(),e===null&&hi(t.stateNode.containerInfo),Y(t),null;case 10:return Qa(t.type._context),Y(t),null;case 17:return ia(t.type)&&aa(),Y(t),null;case 19:if(Qi(To),s=t.memoizedState,s===null)return Y(t),null;if(i=(t.flags&128)!=0,c=s.rendering,c===null)if(i)cc(s,!1);else{if(Jc!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(c=Eo(e),c!==null){for(t.flags|=128,cc(s,!1),i=c.updateQueue,i!==null&&(t.updateQueue=i,t.flags|=4),t.subtreeFlags=0,i=n,n=t.child;n!==null;)s=n,e=i,s.flags&=14680066,c=s.alternate,c===null?(s.childLanes=0,s.lanes=e,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=c.childLanes,s.lanes=c.lanes,s.child=c.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=c.memoizedProps,s.memoizedState=c.memoizedState,s.updateQueue=c.updateQueue,s.type=c.type,e=c.dependencies,s.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return $i(To,To.current&1|2),t.child}e=e.sibling}s.tail!==null&&Dt()>nl&&(t.flags|=128,i=!0,cc(s,!1),t.lanes=4194304)}else{if(!i)if(e=Eo(c),e!==null){if(t.flags|=128,i=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),cc(s,!0),s.tail===null&&s.tailMode===`hidden`&&!c.alternate&&!R)return Y(t),null}else 2*Dt()-s.renderingStartTime>nl&&n!==1073741824&&(t.flags|=128,i=!0,cc(s,!1),t.lanes=4194304);s.isBackwards?(c.sibling=t.child,t.child=c):(n=s.last,n===null?t.child=c:n.sibling=c,s.last=c)}return s.tail===null?(Y(t),null):(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=Dt(),t.sibling=null,n=To.current,$i(To,i?n&1|2:n&1),t);case 22:case 23:return El(),i=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==i&&(t.flags|=8192),i&&t.mode&1?Kc&1073741824&&(Y(t),t.subtreeFlags&6&&(t.flags|=8192)):Y(t),null;case 24:return null;case 25:return null}throw Error(r(156,t.tag))}function uc(e,t){switch(Oa(t),t.tag){case 1:return ia(t.type)&&aa(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return So(),Qi(ta),Qi(ea),Oo(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return wo(t),null;case 13:if(Qi(To),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));za()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Qi(To),null;case 4:return So(),null;case 10:return Qa(t.type._context),null;case 22:case 23:return El(),null;case 24:return null;default:return null}}var dc=!1,fc=!1,pc=typeof WeakSet==`function`?WeakSet:Set,X=null;function mc(e,t){var n=e.ref;if(n!==null)if(typeof n==`function`)try{n(null)}catch(n){Bl(e,t,n)}else n.current=null}function hc(e,t,n){try{n()}catch(n){Bl(e,t,n)}}var gc=!1;function _c(e,t){if(Di=Tn,e=Hr(),Ur(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var i=n.getSelection&&n.getSelection();if(i&&i.rangeCount!==0){n=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Oi={focusedElem:e,selectionRange:n},Tn=!1,X=t;X!==null;)if(t=X,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,X=e;else for(;X!==null;){t=X;try{var h=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var g=h.memoizedProps,_=h.memoizedState,v=t.stateNode;v.__reactInternalSnapshotBeforeUpdate=v.getSnapshotBeforeUpdate(t.elementType===t.type?g:vs(t.type,g),_)}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent=``:y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(e){Bl(t,t.return,e)}if(e=t.sibling,e!==null){e.return=t.return,X=e;break}X=t.return}return h=gc,gc=!1,h}function vc(e,t,n){var r=t.updateQueue;if(r=r===null?null:r.lastEffect,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var a=i.destroy;i.destroy=void 0,a!==void 0&&hc(t,n,a)}i=i.next}while(i!==r)}}function yc(e,t){if(t=t.updateQueue,t=t===null?null:t.lastEffect,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function bc(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t==`function`?t(e):t.current=e}}function xc(e){var t=e.alternate;t!==null&&(e.alternate=null,xc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[zi],delete t[Bi],delete t[Hi],delete t[Ui],delete t[Wi])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Sc(e){return e.tag===5||e.tag===3||e.tag===4}function Cc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Sc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function wc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Ei));else if(r!==4&&(e=e.child,e!==null))for(wc(e,t,n),e=e.sibling;e!==null;)wc(e,t,n),e=e.sibling}function Tc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Tc(e,t,n),e=e.sibling;e!==null;)Tc(e,t,n),e=e.sibling}var Ec=null,Dc=!1;function Oc(e,t,n){for(n=n.child;n!==null;)kc(e,t,n),n=n.sibling}function kc(e,t,n){if(Ft&&typeof Ft.onCommitFiberUnmount==`function`)try{Ft.onCommitFiberUnmount(Pt,n)}catch{}switch(n.tag){case 5:fc||mc(n,t);case 6:var r=Ec,i=Dc;Ec=null,Oc(e,t,n),Ec=r,Dc=i,Ec!==null&&(Dc?(e=Ec,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ec.removeChild(n.stateNode));break;case 18:Ec!==null&&(Dc?(e=Ec,n=n.stateNode,e.nodeType===8?Fi(e.parentNode,n):e.nodeType===1&&Fi(e,n),Cn(e)):Fi(Ec,n.stateNode));break;case 4:r=Ec,i=Dc,Ec=n.stateNode.containerInfo,Dc=!0,Oc(e,t,n),Ec=r,Dc=i;break;case 0:case 11:case 14:case 15:if(!fc&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var a=i,o=a.destroy;a=a.tag,o!==void 0&&(a&2||a&4)&&hc(n,t,o),i=i.next}while(i!==r)}Oc(e,t,n);break;case 1:if(!fc&&(mc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(e){Bl(n,t,e)}Oc(e,t,n);break;case 21:Oc(e,t,n);break;case 22:n.mode&1?(fc=(r=fc)||n.memoizedState!==null,Oc(e,t,n),fc=r):Oc(e,t,n);break;default:Oc(e,t,n)}}function Ac(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new pc),t.forEach(function(t){var r=Wl.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}function jc(e,t){var n=t.deletions;if(n!==null)for(var i=0;i<n.length;i++){var a=n[i];try{var o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 5:Ec=c.stateNode,Dc=!1;break a;case 3:Ec=c.stateNode.containerInfo,Dc=!0;break a;case 4:Ec=c.stateNode.containerInfo,Dc=!0;break a}c=c.return}if(Ec===null)throw Error(r(160));kc(o,s,a),Ec=null,Dc=!1;var l=a.alternate;l!==null&&(l.return=null),a.return=null}catch(e){Bl(a,t,e)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Mc(t,e),t=t.sibling}function Mc(e,t){var n=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(jc(t,e),Nc(e),i&4){try{vc(3,e,e.return),yc(3,e)}catch(t){Bl(e,e.return,t)}try{vc(5,e,e.return)}catch(t){Bl(e,e.return,t)}}break;case 1:jc(t,e),Nc(e),i&512&&n!==null&&mc(n,n.return);break;case 5:if(jc(t,e),Nc(e),i&512&&n!==null&&mc(n,n.return),e.flags&32){var a=e.stateNode;try{Be(a,``)}catch(t){Bl(e,e.return,t)}}if(i&4&&(a=e.stateNode,a!=null)){var o=e.memoizedProps,s=n===null?o:n.memoizedProps,c=e.type,l=e.updateQueue;if(e.updateQueue=null,l!==null)try{c===`input`&&o.type===`radio`&&o.name!=null&&Ee(a,o),qe(c,s);var u=qe(c,o);for(s=0;s<l.length;s+=2){var d=l[s],f=l[s+1];d===`style`?We(a,f):d===`dangerouslySetInnerHTML`?ze(a,f):d===`children`?Be(a,f):S(a,d,f,u)}switch(c){case`input`:De(a,o);break;case`textarea`:Pe(a,o);break;case`select`:var p=a._wrapperState.wasMultiple;a._wrapperState.wasMultiple=!!o.multiple;var m=o.value;m==null?p!==!!o.multiple&&(o.defaultValue==null?je(a,!!o.multiple,o.multiple?[]:``,!1):je(a,!!o.multiple,o.defaultValue,!0)):je(a,!!o.multiple,m,!1)}a[Bi]=o}catch(t){Bl(e,e.return,t)}}break;case 6:if(jc(t,e),Nc(e),i&4){if(e.stateNode===null)throw Error(r(162));a=e.stateNode,o=e.memoizedProps;try{a.nodeValue=o}catch(t){Bl(e,e.return,t)}}break;case 3:if(jc(t,e),Nc(e),i&4&&n!==null&&n.memoizedState.isDehydrated)try{Cn(t.containerInfo)}catch(t){Bl(e,e.return,t)}break;case 4:jc(t,e),Nc(e);break;case 13:jc(t,e),Nc(e),a=e.child,a.flags&8192&&(o=a.memoizedState!==null,a.stateNode.isHidden=o,!o||a.alternate!==null&&a.alternate.memoizedState!==null||(tl=Dt())),i&4&&Ac(e);break;case 22:if(d=n!==null&&n.memoizedState!==null,e.mode&1?(fc=(u=fc)||d,jc(t,e),fc=u):jc(t,e),Nc(e),i&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!d&&e.mode&1)for(X=e,d=e.child;d!==null;){for(f=X=d;X!==null;){switch(p=X,m=p.child,p.tag){case 0:case 11:case 14:case 15:vc(4,p,p.return);break;case 1:mc(p,p.return);var h=p.stateNode;if(typeof h.componentWillUnmount==`function`){i=p,n=p.return;try{t=i,h.props=t.memoizedProps,h.state=t.memoizedState,h.componentWillUnmount()}catch(e){Bl(i,n,e)}}break;case 5:mc(p,p.return);break;case 22:if(p.memoizedState!==null){Lc(f);continue}}m===null?Lc(f):(m.return=p,X=m)}d=d.sibling}a:for(d=null,f=e;;){if(f.tag===5){if(d===null){d=f;try{a=f.stateNode,u?(o=a.style,typeof o.setProperty==`function`?o.setProperty(`display`,`none`,`important`):o.display=`none`):(c=f.stateNode,l=f.memoizedProps.style,s=l!=null&&l.hasOwnProperty(`display`)?l.display:null,c.style.display=Ue(`display`,s))}catch(t){Bl(e,e.return,t)}}}else if(f.tag===6){if(d===null)try{f.stateNode.nodeValue=u?``:f.memoizedProps}catch(t){Bl(e,e.return,t)}}else if((f.tag!==22&&f.tag!==23||f.memoizedState===null||f===e)&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===e)break a;for(;f.sibling===null;){if(f.return===null||f.return===e)break a;d===f&&(d=null),f=f.return}d===f&&(d=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:jc(t,e),Nc(e),i&4&&Ac(e);break;case 21:break;default:jc(t,e),Nc(e)}}function Nc(e){var t=e.flags;if(t&2){try{a:{for(var n=e.return;n!==null;){if(Sc(n)){var i=n;break a}n=n.return}throw Error(r(160))}switch(i.tag){case 5:var a=i.stateNode;i.flags&32&&(Be(a,``),i.flags&=-33),Tc(e,Cc(e),a);break;case 3:case 4:var o=i.stateNode.containerInfo;wc(e,Cc(e),o);break;default:throw Error(r(161))}}catch(t){Bl(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Pc(e,t,n){X=e,Fc(e,t,n)}function Fc(e,t,n){for(var r=(e.mode&1)!=0;X!==null;){var i=X,a=i.child;if(i.tag===22&&r){var o=i.memoizedState!==null||dc;if(!o){var s=i.alternate,c=s!==null&&s.memoizedState!==null||fc;s=dc;var l=fc;if(dc=o,(fc=c)&&!l)for(X=i;X!==null;)o=X,c=o.child,o.tag===22&&o.memoizedState!==null||c===null?Rc(i):(c.return=o,X=c);for(;a!==null;)X=a,Fc(a,t,n),a=a.sibling;X=i,dc=s,fc=l}Ic(e,t,n)}else i.subtreeFlags&8772&&a!==null?(a.return=i,X=a):Ic(e,t,n)}}function Ic(e){for(;X!==null;){var t=X;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:fc||yc(5,t);break;case 1:var i=t.stateNode;if(t.flags&4&&!fc)if(n===null)i.componentDidMount();else{var a=t.elementType===t.type?n.memoizedProps:vs(t.type,n.memoizedProps);i.componentDidUpdate(a,n.memoizedState,i.__reactInternalSnapshotBeforeUpdate)}var o=t.updateQueue;o!==null&&ho(t,o,i);break;case 3:var s=t.updateQueue;if(s!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}ho(t,s,n)}break;case 5:var c=t.stateNode;if(n===null&&t.flags&4){n=c;var l=t.memoizedProps;switch(t.type){case`button`:case`input`:case`select`:case`textarea`:l.autoFocus&&n.focus();break;case`img`:l.src&&(n.src=l.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var d=u.memoizedState;if(d!==null){var f=d.dehydrated;f!==null&&Cn(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}fc||t.flags&512&&bc(t)}catch(e){Bl(t,t.return,e)}}if(t===e){X=null;break}if(n=t.sibling,n!==null){n.return=t.return,X=n;break}X=t.return}}function Lc(e){for(;X!==null;){var t=X;if(t===e){X=null;break}var n=t.sibling;if(n!==null){n.return=t.return,X=n;break}X=t.return}}function Rc(e){for(;X!==null;){var t=X;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{yc(4,t)}catch(e){Bl(t,n,e)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount==`function`){var i=t.return;try{r.componentDidMount()}catch(e){Bl(t,i,e)}}var a=t.return;try{bc(t)}catch(e){Bl(t,a,e)}break;case 5:var o=t.return;try{bc(t)}catch(e){Bl(t,o,e)}}}catch(e){Bl(t,t.return,e)}if(t===e){X=null;break}var s=t.sibling;if(s!==null){s.return=t.return,X=s;break}X=t.return}}var zc=Math.ceil,Bc=C.ReactCurrentDispatcher,Vc=C.ReactCurrentOwner,Hc=C.ReactCurrentBatchConfig,Z=0,Uc=null,Wc=null,Gc=0,Kc=0,qc=Zi(0),Jc=0,Yc=null,Xc=0,Zc=0,Qc=0,$c=null,el=null,tl=0,nl=1/0,rl=null,il=!1,al=null,ol=null,sl=!1,cl=null,ll=0,ul=0,dl=null,fl=-1,pl=0;function ml(){return Z&6?Dt():fl===-1?fl=Dt():fl}function hl(e){return e.mode&1?Z&2&&Gc!==0?Gc&-Gc:Va.transition===null?(e=k,e===0?(e=window.event,e=e===void 0?16:jn(e.type),e):e):(pl===0&&(pl=Jt()),pl):1}function gl(e,t,n,i){if(50<ul)throw ul=0,dl=null,Error(r(185));Xt(e,n,i),(!(Z&2)||e!==Uc)&&(e===Uc&&(!(Z&2)&&(Zc|=n),Jc===4&&Sl(e,Gc)),_l(e,i),n===1&&Z===0&&!(t.mode&1)&&(nl=Dt()+500,da&&ha()))}function _l(e,t){var n=e.callbackNode;Kt(e,t);var r=Wt(e,e===Uc?Gc:0);if(r===0)n!==null&&wt(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&wt(n),t===1)e.tag===0?ma(Cl.bind(null,e)):pa(Cl.bind(null,e)),Ni(function(){!(Z&6)&&ha()}),n=null;else{switch($t(r)){case 1:n=kt;break;case 4:n=At;break;case 16:n=jt;break;case 536870912:n=Nt;break;default:n=jt}n=Kl(n,vl.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function vl(e,t){if(fl=-1,pl=0,Z&6)throw Error(r(327));var n=e.callbackNode;if(Rl()&&e.callbackNode!==n)return null;var i=Wt(e,e===Uc?Gc:0);if(i===0)return null;if(i&30||(i&e.expiredLanes)!==0||t)t=jl(e,i);else{t=i;var a=Z;Z|=2;var o=kl();(Uc!==e||Gc!==t)&&(rl=null,nl=Dt()+500,Dl(e,t));do try{Nl();break}catch(t){Ol(e,t)}while(1);z(),Bc.current=o,Z=a,Wc===null?(Uc=null,Gc=0,t=Jc):t=0}if(t!==0){if(t===2&&(a=qt(e),a!==0&&(i=a,t=yl(e,a))),t===1)throw n=Yc,Dl(e,0),Sl(e,i),_l(e,Dt()),n;if(t===6)Sl(e,i);else{if(a=e.current.alternate,!(i&30)&&!xl(a)&&(t=jl(e,i),t===2&&(o=qt(e),o!==0&&(i=o,t=yl(e,o))),t===1))throw n=Yc,Dl(e,0),Sl(e,i),_l(e,Dt()),n;switch(e.finishedWork=a,e.finishedLanes=i,t){case 0:case 1:throw Error(r(345));case 2:Il(e,el,rl);break;case 3:if(Sl(e,i),(i&130023424)===i&&(t=tl+500-Dt(),10<t)){if(Wt(e,0)!==0)break;if(a=e.suspendedLanes,(a&i)!==i){ml(),e.pingedLanes|=e.suspendedLanes&a;break}e.timeoutHandle=Ai(Il.bind(null,e,el,rl),t);break}Il(e,el,rl);break;case 4:if(Sl(e,i),(i&4194240)===i)break;for(t=e.eventTimes,a=-1;0<i;){var s=31-Lt(i);o=1<<s,s=t[s],s>a&&(a=s),i&=~o}if(i=a,i=Dt()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*zc(i/1960))-i,10<i){e.timeoutHandle=Ai(Il.bind(null,e,el,rl),i);break}Il(e,el,rl);break;case 5:Il(e,el,rl);break;default:throw Error(r(329))}}}return _l(e,Dt()),e.callbackNode===n?vl.bind(null,e):null}function yl(e,t){var n=$c;return e.current.memoizedState.isDehydrated&&(Dl(e,t).flags|=256),e=jl(e,t),e!==2&&(t=el,el=n,t!==null&&bl(t)),e}function bl(e){el===null?el=e:el.push.apply(el,e)}function xl(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!Lr(a(),i))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Sl(e,t){for(t&=~Qc,t&=~Zc,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Lt(t),r=1<<n;e[n]=-1,t&=~r}}function Cl(e){if(Z&6)throw Error(r(327));Rl();var t=Wt(e,0);if(!(t&1))return _l(e,Dt()),null;var n=jl(e,t);if(e.tag!==0&&n===2){var i=qt(e);i!==0&&(t=i,n=yl(e,i))}if(n===1)throw n=Yc,Dl(e,0),Sl(e,t),_l(e,Dt()),n;if(n===6)throw Error(r(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Il(e,el,rl),_l(e,Dt()),null}function wl(e,t){var n=Z;Z|=1;try{return e(t)}finally{Z=n,Z===0&&(nl=Dt()+500,da&&ha())}}function Tl(e){cl!==null&&cl.tag===0&&!(Z&6)&&Rl();var t=Z;Z|=1;var n=Hc.transition,r=k;try{if(Hc.transition=null,k=1,e)return e()}finally{k=r,Hc.transition=n,Z=t,!(Z&6)&&ha()}}function El(){Kc=qc.current,Qi(qc)}function Dl(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,ji(n)),Wc!==null)for(n=Wc.return;n!==null;){var r=n;switch(Oa(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&aa();break;case 3:So(),Qi(ta),Qi(ea),Oo();break;case 5:wo(r);break;case 4:So();break;case 13:Qi(To);break;case 19:Qi(To);break;case 10:Qa(r.type._context);break;case 22:case 23:El()}n=n.return}if(Uc=e,Wc=e=Zl(e.current,null),Gc=Kc=t,Jc=0,Yc=null,Qc=Zc=Xc=0,el=$c=null,no!==null){for(t=0;t<no.length;t++)if(n=no[t],r=n.interleaved,r!==null){n.interleaved=null;var i=r.next,a=n.pending;if(a!==null){var o=a.next;a.next=i,r.next=o}n.pending=r}no=null}return e}function Ol(e,t){do{var n=Wc;try{if(z(),ko.current=ms,Po){for(var i=jo.memoizedState;i!==null;){var a=i.queue;a!==null&&(a.pending=null),i=i.next}Po=!1}if(Ao=0,No=Mo=jo=null,Fo=!1,V=0,Vc.current=null,n===null||n.return===null){Jc=1,Yc=t,Wc=null;break}a:{var o=e,s=n.return,c=n,l=t;if(t=Gc,c.flags|=32768,typeof l==`object`&&l&&typeof l.then==`function`){var u=l,d=c,f=d.tag;if(!(d.mode&1)&&(f===0||f===11||f===15)){var p=d.alternate;p?(d.updateQueue=p.updateQueue,d.memoizedState=p.memoizedState,d.lanes=p.lanes):(d.updateQueue=null,d.memoizedState=null)}var m=Ms(s);if(m!==null){m.flags&=-257,Ns(m,s,c,o,t),m.mode&1&&js(o,u,t),t=m,l=u;var h=t.updateQueue;if(h===null){var g=new Set;g.add(l),t.updateQueue=g}else h.add(l);break a}else{if(!(t&1)){js(o,u,t),Al();break a}l=Error(r(426))}}else if(R&&c.mode&1){var _=Ms(s);if(_!==null){!(_.flags&65536)&&(_.flags|=256),Ns(_,s,c,o,t),Ba(Ts(l,c));break a}}o=l=Ts(l,c),Jc!==4&&(Jc=2),$c===null?$c=[o]:$c.push(o),o=s;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var v=ks(o,l,t);po(o,v);break a;case 1:c=l;var y=o.type,b=o.stateNode;if(!(o.flags&128)&&(typeof y.getDerivedStateFromError==`function`||b!==null&&typeof b.componentDidCatch==`function`&&(ol===null||!ol.has(b)))){o.flags|=65536,t&=-t,o.lanes|=t;var x=As(o,c,t);po(o,x);break a}}o=o.return}while(o!==null)}Fl(n)}catch(e){t=e,Wc===n&&n!==null&&(Wc=n=n.return);continue}break}while(1)}function kl(){var e=Bc.current;return Bc.current=ms,e===null?ms:e}function Al(){(Jc===0||Jc===3||Jc===2)&&(Jc=4),Uc===null||!(Xc&268435455)&&!(Zc&268435455)||Sl(Uc,Gc)}function jl(e,t){var n=Z;Z|=2;var i=kl();(Uc!==e||Gc!==t)&&(rl=null,Dl(e,t));do try{Ml();break}catch(t){Ol(e,t)}while(1);if(z(),Z=n,Bc.current=i,Wc!==null)throw Error(r(261));return Uc=null,Gc=0,Jc}function Ml(){for(;Wc!==null;)Pl(Wc)}function Nl(){for(;Wc!==null&&!Tt();)Pl(Wc)}function Pl(e){var t=Gl(e.alternate,e,Kc);e.memoizedProps=e.pendingProps,t===null?Fl(e):Wc=t,Vc.current=null}function Fl(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=uc(n,t),n!==null){n.flags&=32767,Wc=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Jc=6,Wc=null;return}}else if(n=lc(n,t,Kc),n!==null){Wc=n;return}if(t=t.sibling,t!==null){Wc=t;return}Wc=t=e}while(t!==null);Jc===0&&(Jc=5)}function Il(e,t,n){var r=k,i=Hc.transition;try{Hc.transition=null,k=1,Ll(e,t,n,r)}finally{Hc.transition=i,k=r}return null}function Ll(e,t,n,i){do Rl();while(cl!==null);if(Z&6)throw Error(r(327));n=e.finishedWork;var a=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(r(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(Zt(e,o),e===Uc&&(Wc=Uc=null,Gc=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||sl||(sl=!0,Kl(jt,function(){return Rl(),null})),o=(n.flags&15990)!=0,n.subtreeFlags&15990||o){o=Hc.transition,Hc.transition=null;var s=k;k=1;var c=Z;Z|=4,Vc.current=null,_c(e,n),Mc(n,e),Wr(Oi),Tn=!!Di,Oi=Di=null,e.current=n,Pc(n,e,a),Et(),Z=c,k=s,Hc.transition=o}else e.current=n;if(sl&&(sl=!1,cl=e,ll=a),o=e.pendingLanes,o===0&&(ol=null),It(n.stateNode,i),_l(e,Dt()),t!==null)for(i=e.onRecoverableError,n=0;n<t.length;n++)a=t[n],i(a.value,{componentStack:a.stack,digest:a.digest});if(il)throw il=!1,e=al,al=null,e;return ll&1&&e.tag!==0&&Rl(),o=e.pendingLanes,o&1?e===dl?ul++:(ul=0,dl=e):ul=0,ha(),null}function Rl(){if(cl!==null){var e=$t(ll),t=Hc.transition,n=k;try{if(Hc.transition=null,k=16>e?16:e,cl===null)var i=!1;else{if(e=cl,cl=null,ll=0,Z&6)throw Error(r(331));var a=Z;for(Z|=4,X=e.current;X!==null;){var o=X,s=o.child;if(X.flags&16){var c=o.deletions;if(c!==null){for(var l=0;l<c.length;l++){var u=c[l];for(X=u;X!==null;){var d=X;switch(d.tag){case 0:case 11:case 15:vc(8,d,o)}var f=d.child;if(f!==null)f.return=d,X=f;else for(;X!==null;){d=X;var p=d.sibling,m=d.return;if(xc(d),d===u){X=null;break}if(p!==null){p.return=m,X=p;break}X=m}}}var h=o.alternate;if(h!==null){var g=h.child;if(g!==null){h.child=null;do{var _=g.sibling;g.sibling=null,g=_}while(g!==null)}}X=o}}if(o.subtreeFlags&2064&&s!==null)s.return=o,X=s;else b:for(;X!==null;){if(o=X,o.flags&2048)switch(o.tag){case 0:case 11:case 15:vc(9,o,o.return)}var v=o.sibling;if(v!==null){v.return=o.return,X=v;break b}X=o.return}}var y=e.current;for(X=y;X!==null;){s=X;var b=s.child;if(s.subtreeFlags&2064&&b!==null)b.return=s,X=b;else b:for(s=y;X!==null;){if(c=X,c.flags&2048)try{switch(c.tag){case 0:case 11:case 15:yc(9,c)}}catch(e){Bl(c,c.return,e)}if(c===s){X=null;break b}var x=c.sibling;if(x!==null){x.return=c.return,X=x;break b}X=c.return}}if(Z=a,ha(),Ft&&typeof Ft.onPostCommitFiberRoot==`function`)try{Ft.onPostCommitFiberRoot(Pt,e)}catch{}i=!0}return i}finally{k=n,Hc.transition=t}}return!1}function zl(e,t,n){t=Ts(n,t),t=ks(e,t,1),e=uo(e,t,1),t=ml(),e!==null&&(Xt(e,1,t),_l(e,t))}function Bl(e,t,n){if(e.tag===3)zl(e,e,n);else for(;t!==null;){if(t.tag===3){zl(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(ol===null||!ol.has(r))){e=Ts(n,e),e=As(t,e,1),t=uo(t,e,1),e=ml(),t!==null&&(Xt(t,1,e),_l(t,e));break}}t=t.return}}function Vl(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=ml(),e.pingedLanes|=e.suspendedLanes&n,Uc===e&&(Gc&n)===n&&(Jc===4||Jc===3&&(Gc&130023424)===Gc&&500>Dt()-tl?Dl(e,0):Qc|=n),_l(e,t)}function Hl(e,t){t===0&&(e.mode&1?(t=Ht,Ht<<=1,!(Ht&130023424)&&(Ht=4194304)):t=1);var n=ml();e=ao(e,t),e!==null&&(Xt(e,t,n),_l(e,n))}function Ul(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Hl(e,n)}function Wl(e,t){var n=0;switch(e.tag){case 13:var i=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:i=e.stateNode;break;default:throw Error(r(314))}i!==null&&i.delete(t),Hl(e,n)}var Gl=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||ta.current)Fs=!0;else{if((e.lanes&n)===0&&!(t.flags&128))return Fs=!1,ic(e,t,n);Fs=!!(e.flags&131072)}else Fs=!1,R&&t.flags&1048576&&Ea(t,ya,t.index);switch(t.lanes=0,t.tag){case 2:var i=t.type;nc(e,t),e=t.pendingProps;var a=ra(t,ea.current);eo(t,n),a=U(null,t,i,e,a,n);var o=Ro();return t.flags|=1,typeof a==`object`&&a&&typeof a.render==`function`&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,ia(i)?(o=!0,ca(t)):o=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,so(t),a.updater=bs,t.stateNode=a,a._reactInternals=t,ws(t,i,e,n),t=Ws(null,t,i,!0,o,n)):(t.tag=0,R&&o&&Da(t),Is(null,t,a,n),t=t.child),t;case 16:i=t.elementType;a:{switch(nc(e,t),e=t.pendingProps,a=i._init,i=a(i._payload),t.type=i,a=t.tag=Xl(i),e=vs(i,e),a){case 0:t=Hs(null,t,i,e,n);break a;case 1:t=Us(null,t,i,e,n);break a;case 11:t=Ls(null,t,i,e,n);break a;case 14:t=Rs(null,t,i,vs(i.type,e),n);break a}throw Error(r(306,i,``))}return t;case 0:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:vs(i,a),Hs(e,t,i,a,n);case 1:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:vs(i,a),Us(e,t,i,a,n);case 3:a:{if(Gs(t),e===null)throw Error(r(387));i=t.pendingProps,o=t.memoizedState,a=o.element,co(e,t),mo(t,i,null,n);var s=t.memoizedState;if(i=s.element,o.isDehydrated)if(o={element:i,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){a=Ts(Error(r(423)),t),t=Ks(e,t,i,n,a);break a}else if(i!==a){a=Ts(Error(r(424)),t),t=Ks(e,t,i,n,a);break a}else for(Aa=Ii(t.stateNode.containerInfo.firstChild),ka=t,R=!0,ja=null,n=qa(t,null,i,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(za(),i===a){t=rc(e,t,n);break a}Is(e,t,i,n)}t=t.child}return t;case 5:return Co(t),e===null&&Fa(t),i=t.type,a=t.pendingProps,o=e===null?null:e.memoizedProps,s=a.children,ki(i,a)?s=null:o!==null&&ki(i,o)&&(t.flags|=32),Vs(e,t),Is(e,t,s,n),t.child;case 6:return e===null&&Fa(t),null;case 13:return Ys(e,t,n);case 4:return xo(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=Ka(t,null,i,n):Is(e,t,i,n),t.child;case 11:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:vs(i,a),Ls(e,t,i,a,n);case 7:return Is(e,t,t.pendingProps,n),t.child;case 8:return Is(e,t,t.pendingProps.children,n),t.child;case 12:return Is(e,t,t.pendingProps.children,n),t.child;case 10:a:{if(i=t.type._context,a=t.pendingProps,o=t.memoizedProps,s=a.value,$i(Ja,i._currentValue),i._currentValue=s,o!==null)if(Lr(o.value,s)){if(o.children===a.children&&!ta.current){t=rc(e,t,n);break a}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var c=o.dependencies;if(c!==null){s=o.child;for(var l=c.firstContext;l!==null;){if(l.context===i){if(o.tag===1){l=lo(-1,n&-n),l.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?l.next=l:(l.next=d.next,d.next=l),u.pending=l}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),$a(o.return,n,t),c.lanes|=n;break}l=l.next}}else if(o.tag===10)s=o.type===t.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(r(341));s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),$a(s,n,t),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===t){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}Is(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,i=t.pendingProps.children,eo(t,n),a=to(a),i=i(a),t.flags|=1,Is(e,t,i,n),t.child;case 14:return i=t.type,a=vs(i,t.pendingProps),a=vs(i.type,a),Rs(e,t,i,a,n);case 15:return zs(e,t,t.type,t.pendingProps,n);case 17:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:vs(i,a),nc(e,t),t.tag=1,ia(i)?(e=!0,ca(t)):e=!1,eo(t,n),Ss(t,i,a),ws(t,i,a,n),Ws(null,t,i,!0,e,n);case 19:return tc(e,t,n);case 22:return Bs(e,t,n)}throw Error(r(156,t.tag))};function Kl(e,t){return Ct(e,t)}function ql(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Jl(e,t,n,r){return new ql(e,t,n,r)}function Yl(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Xl(e){if(typeof e==`function`)return+!!Yl(e);if(e!=null){if(e=e.$$typeof,e===re)return 11;if(e===oe)return 14}return 2}function Zl(e,t){var n=e.alternate;return n===null?(n=Jl(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Ql(e,t,n,i,a,o){var s=2;if(i=e,typeof e==`function`)Yl(e)&&(s=1);else if(typeof e==`string`)s=5;else a:switch(e){case E:return $l(n.children,a,o,t);case D:s=8,a|=8;break;case ee:return e=Jl(12,n,t,a|2),e.elementType=ee,e.lanes=o,e;case ie:return e=Jl(13,n,t,a),e.elementType=ie,e.lanes=o,e;case ae:return e=Jl(19,n,t,a),e.elementType=ae,e.lanes=o,e;case ce:return eu(n,a,o,t);default:if(typeof e==`object`&&e)switch(e.$$typeof){case te:s=10;break a;case ne:s=9;break a;case re:s=11;break a;case oe:s=14;break a;case se:s=16,i=null;break a}throw Error(r(130,e==null?e:typeof e,``))}return t=Jl(s,n,t,a),t.elementType=e,t.type=i,t.lanes=o,t}function $l(e,t,n,r){return e=Jl(7,e,r,t),e.lanes=n,e}function eu(e,t,n,r){return e=Jl(22,e,r,t),e.elementType=ce,e.lanes=n,e.stateNode={isHidden:!1},e}function tu(e,t,n){return e=Jl(6,e,null,t),e.lanes=n,e}function nu(e,t,n){return t=Jl(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function ru(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Yt(0),this.expirationTimes=Yt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Yt(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function iu(e,t,n,r,i,a,o,s,c){return e=new ru(e,t,n,s,c),t===1?(t=1,!0===a&&(t|=8)):t=0,a=Jl(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},so(a),e}function au(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:T,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}function ou(e){if(!e)return L;e=e._reactInternals;a:{if(_t(e)!==e||e.tag!==1)throw Error(r(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break a;case 1:if(ia(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break a}}t=t.return}while(t!==null);throw Error(r(171))}if(e.tag===1){var n=e.type;if(ia(n))return sa(e,n,t)}return t}function su(e,t,n,r,i,a,o,s,c){return e=iu(n,r,!0,e,i,a,o,s,c),e.context=ou(null),n=e.current,r=ml(),i=hl(n),a=lo(r,i),a.callback=t??null,uo(n,a,i),e.current.lanes=i,Xt(e,i,r),_l(e,r),e}function cu(e,t,n,r){var i=t.current,a=ml(),o=hl(i);return n=ou(n),t.context===null?t.context=n:t.pendingContext=n,t=lo(a,o),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=uo(i,t,o),e!==null&&(gl(e,i,o,a),fo(e,i,o)),o}function lu(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function uu(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function du(e,t){uu(e,t),(e=e.alternate)&&uu(e,t)}function fu(){return null}var pu=typeof reportError==`function`?reportError:function(e){console.error(e)};function mu(e){this._internalRoot=e}hu.prototype.render=mu.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(r(409));cu(e,t,null,null)},hu.prototype.unmount=mu.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Tl(function(){cu(null,e,null,null)}),t[Vi]=null}};function hu(e){this._internalRoot=e}hu.prototype.unstable_scheduleHydration=function(e){if(e){var t=rn();e={blockedOn:null,target:e,priority:t};for(var n=0;n<pn.length&&t!==0&&t<pn[n].priority;n++);pn.splice(n,0,e),n===0&&vn(e)}};function gu(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function _u(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==` react-mount-point-unstable `))}function vu(){}function yu(e,t,n,r,i){if(i){if(typeof r==`function`){var a=r;r=function(){var e=lu(o);a.call(e)}}var o=su(t,r,e,0,null,!1,!1,``,vu);return e._reactRootContainer=o,e[Vi]=o.current,hi(e.nodeType===8?e.parentNode:e),Tl(),o}for(;i=e.lastChild;)e.removeChild(i);if(typeof r==`function`){var s=r;r=function(){var e=lu(c);s.call(e)}}var c=iu(e,0,!1,null,null,!1,!1,``,vu);return e._reactRootContainer=c,e[Vi]=c.current,hi(e.nodeType===8?e.parentNode:e),Tl(function(){cu(t,c,n,r)}),c}function bu(e,t,n,r,i){var a=n._reactRootContainer;if(a){var o=a;if(typeof i==`function`){var s=i;i=function(){var e=lu(o);s.call(e)}}cu(t,o,e,i)}else o=yu(n,t,e,i,r);return lu(o)}en=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Ut(t.pendingLanes);n!==0&&(Qt(t,n|1),_l(t,Dt()),!(Z&6)&&(nl=Dt()+500,ha()))}break;case 13:Tl(function(){var t=ao(e,1);t!==null&&gl(t,e,1,ml())}),du(e,1)}},tn=function(e){if(e.tag===13){var t=ao(e,134217728);t!==null&&gl(t,e,134217728,ml()),du(e,134217728)}},nn=function(e){if(e.tag===13){var t=hl(e),n=ao(e,t);n!==null&&gl(n,e,t,ml()),du(e,t)}},rn=function(){return k},an=function(e,t){var n=k;try{return k=e,t()}finally{k=n}},Xe=function(e,t,n){switch(t){case`input`:if(De(e,n),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name=`+JSON.stringify(``+t)+`][type="radio"]`),t=0;t<n.length;t++){var i=n[t];if(i!==e&&i.form===e.form){var a=Ji(i);if(!a)throw Error(r(90));Se(i),De(i,a)}}}break;case`textarea`:Pe(e,n);break;case`select`:t=n.value,t!=null&&je(e,!!n.multiple,t,!1)}},nt=wl,rt=Tl;var xu={usingClientEntryPoint:!1,Events:[Ki,qi,Ji,et,tt,wl]},Su={findFiberByHostInstance:Gi,bundleType:0,version:`18.3.1`,rendererPackageName:`react-dom`},Cu={bundleType:Su.bundleType,version:Su.version,rendererPackageName:Su.rendererPackageName,rendererConfig:Su.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:C.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=xt(e),e===null?null:e.stateNode},findFiberByHostInstance:Su.findFiberByHostInstance||fu,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:`18.3.1-next-f1338f8080-20240426`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var wu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!wu.isDisabled&&wu.supportsFiber)try{Pt=wu.inject(Cu),Ft=wu}catch{}}e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=xu,e.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!gu(t))throw Error(r(200));return au(e,t,null,n)},e.createRoot=function(e,t){if(!gu(e))throw Error(r(299));var n=!1,i=``,a=pu;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(i=t.identifierPrefix),t.onRecoverableError!==void 0&&(a=t.onRecoverableError)),t=iu(e,1,!1,null,null,n,!1,i,a),e[Vi]=t.current,hi(e.nodeType===8?e.parentNode:e),new mu(t)},e.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(r(188)):(e=Object.keys(e).join(`,`),Error(r(268,e)));return e=xt(t),e=e===null?null:e.stateNode,e},e.flushSync=function(e){return Tl(e)},e.hydrate=function(e,t,n){if(!_u(t))throw Error(r(200));return bu(null,e,t,!0,n)},e.hydrateRoot=function(e,t,n){if(!gu(e))throw Error(r(405));var i=n!=null&&n.hydratedSources||null,a=!1,o=``,s=pu;if(n!=null&&(!0===n.unstable_strictMode&&(a=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(s=n.onRecoverableError)),t=su(t,null,e,1,n??null,a,!1,o,s),e[Vi]=t.current,hi(e),i)for(e=0;e<i.length;e++)n=i[e],a=n._getVersion,a=a(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,a]:t.mutableSourceEagerHydrationData.push(n,a);return new hu(t)},e.render=function(e,t,n){if(!_u(t))throw Error(r(200));return bu(null,e,t,!1,n)},e.unmountComponentAtNode=function(e){if(!_u(e))throw Error(r(40));return e._reactRootContainer?(Tl(function(){bu(null,null,e,!1,function(){e._reactRootContainer=null,e[Vi]=null})}),!0):!1},e.unstable_batchedUpdates=wl,e.unstable_renderSubtreeIntoContainer=function(e,t,n,i){if(!_u(n))throw Error(r(200));if(e==null||e._reactInternals===void 0)throw Error(r(38));return bu(e,t,n,!1,i)},e.version=`18.3.1-next-f1338f8080-20240426`})),m=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=p()})),h=o((e=>{var t=m();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),g=c(u()),_=c(h(),1);m();function v(){return v=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},v.apply(this,arguments)}var y;(function(e){e.Pop=`POP`,e.Push=`PUSH`,e.Replace=`REPLACE`})(y||={});var b=`popstate`;function x(e){e===void 0&&(e={});function t(e,t){let{pathname:n,search:r,hash:i}=e.location;return E(``,{pathname:n,search:r,hash:i},t.state&&t.state.usr||null,t.state&&t.state.key||`default`)}function n(e,t){return typeof t==`string`?t:D(t)}return te(t,n,null,e)}function S(e,t){if(e===!1||e==null)throw Error(t)}function C(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function w(){return Math.random().toString(36).substr(2,8)}function T(e,t){return{usr:e.state,key:e.key,idx:t}}function E(e,t,n,r){return n===void 0&&(n=null),v({pathname:typeof e==`string`?e:e.pathname,search:``,hash:``},typeof t==`string`?ee(t):t,{state:n,key:t&&t.key||r||w()})}function D(e){let{pathname:t=`/`,search:n=``,hash:r=``}=e;return n&&n!==`?`&&(t+=n.charAt(0)===`?`?n:`?`+n),r&&r!==`#`&&(t+=r.charAt(0)===`#`?r:`#`+r),t}function ee(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function te(e,t,n,r){r===void 0&&(r={});let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=y.Pop,c=null,l=u();l??(l=0,o.replaceState(v({},o.state,{idx:l}),``));function u(){return(o.state||{idx:null}).idx}function d(){s=y.Pop;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=y.Push;let r=E(h.location,e,t);n&&n(r,e),l=u()+1;let d=T(r,l),f=h.createHref(r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=y.Replace;let r=E(h.location,e,t);n&&n(r,e),l=u();let i=T(r,l),d=h.createHref(r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){let t=i.location.origin===`null`?i.location.href:i.location.origin,n=typeof e==`string`?e:D(e);return n=n.replace(/ $/,`%20`),S(t,`No window.location.(origin|href) available to create URL for href: `+n),new URL(n,t)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(b,d),c=e,()=>{i.removeEventListener(b,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}var ne;(function(e){e.data=`data`,e.deferred=`deferred`,e.redirect=`redirect`,e.error=`error`})(ne||={});function re(e,t,n){return n===void 0&&(n=`/`),ie(e,t,n,!1)}function ie(e,t,n,r){let i=be((typeof t==`string`?ee(t):t).pathname||`/`,n);if(i==null)return null;let a=ae(e);se(a);let o=null;for(let e=0;o==null&&e<a.length;++e){let t=ye(i);o=ge(a[e],t,r)}return o}function ae(e,t,n,r){t===void 0&&(t=[]),n===void 0&&(n=[]),r===void 0&&(r=``);let i=(e,i,a)=>{let o={relativePath:a===void 0?e.path||``:a,caseSensitive:e.caseSensitive===!0,childrenIndex:i,route:e};o.relativePath.startsWith(`/`)&&(S(o.relativePath.startsWith(r),`Absolute route path "`+o.relativePath+`" nested under path `+(`"`+r+`" is not valid. An absolute child route path `)+`must start with the combined path of all its parent routes.`),o.relativePath=o.relativePath.slice(r.length));let s=ke([r,o.relativePath]),c=n.concat(o);e.children&&e.children.length>0&&(S(e.index!==!0,`Index routes must not have child routes. Please remove `+(`all child routes from route path "`+s+`".`)),ae(e.children,t,c,s)),!(e.path==null&&!e.index)&&t.push({path:s,score:me(s,e.index),routesMeta:c})};return e.forEach((e,t)=>{var n;if(e.path===``||!((n=e.path)!=null&&n.includes(`?`)))i(e,t);else for(let n of oe(e.path))i(e,t,n)}),t}function oe(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=oe(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function se(e){e.sort((e,t)=>e.score===t.score?he(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var ce=/^:[\w-]+$/,le=3,ue=2,O=1,de=10,fe=-2,pe=e=>e===`*`;function me(e,t){let n=e.split(`/`),r=n.length;return n.some(pe)&&(r+=fe),t&&(r+=ue),n.filter(e=>!pe(e)).reduce((e,t)=>e+(ce.test(t)?le:t===``?O:de),r)}function he(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function ge(e,t,n){n===void 0&&(n=!1);let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=_e({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=_e({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:ke([a,u.pathname]),pathnameBase:Ae(ke([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=ke([a,u.pathnameBase]))}return o}function _e(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=ve(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,t,n)=>{let{paramName:r,isOptional:i}=t;if(r===`*`){let e=s[n]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let c=s[n];return i&&!c?e[r]=void 0:e[r]=(c||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function ve(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),C(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "`+e+`" will be treated as if it were `+(`"`+e.replace(/\*$/,`/*`)+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+(`please change the route path to "`+e.replace(/\*$/,`/*`)+`".`));let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n)=>(r.push({paramName:t,isOptional:n!=null}),n?`/?([^\\/]+)?`:`/([^\\/]+)`));return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function ye(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return C(!1,`The URL path "`+e+`" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent `+(`encoding (`+t+`).`)),e}}function be(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}var xe=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Se=e=>xe.test(e);function Ce(e,t){t===void 0&&(t=`/`);let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?ee(e):e,a;if(n)if(Se(n))a=n;else{if(n.includes(`//`)){let e=n;n=n.replace(/\/\/+/g,`/`),C(!1,`Pathnames cannot have embedded double slashes - normalizing `+(e+` -> `+n))}a=n.startsWith(`/`)?we(n.substring(1),`/`):we(n,t)}else a=t;return{pathname:a,search:je(r),hash:Me(i)}}function we(e,t){let n=t.replace(/\/+$/,``).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function Te(e,t,n,r){return`Cannot include a '`+e+`' character in a manually specified `+("`to."+t+"` field ["+JSON.stringify(r)+`]. Please separate it out to the `)+("`to."+n+"` field. Alternatively you may provide the full path as ")+`a string in <Link to="..."> and the router will parse it for you.`}function Ee(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function De(e,t){let n=Ee(e);return t?n.map((e,t)=>t===n.length-1?e.pathname:e.pathnameBase):n.map(e=>e.pathnameBase)}function Oe(e,t,n,r){r===void 0&&(r=!1);let i;typeof e==`string`?i=ee(e):(i=v({},e),S(!i.pathname||!i.pathname.includes(`?`),Te(`?`,`pathname`,`search`,i)),S(!i.pathname||!i.pathname.includes(`#`),Te(`#`,`pathname`,`hash`,i)),S(!i.search||!i.search.includes(`#`),Te(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=Ce(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var ke=e=>e.join(`/`).replace(/\/\/+/g,`/`),Ae=e=>e.replace(/\/+$/,``).replace(/^\/*/,`/`),je=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,Me=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e;function Ne(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}var Pe=[`post`,`put`,`patch`,`delete`];new Set(Pe);var Fe=[`get`,...Pe];new Set(Fe);function Ie(){return Ie=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ie.apply(this,arguments)}var Le=g.createContext(null),Re=g.createContext(null),ze=g.createContext(null),Be=g.createContext(null),Ve=g.createContext({outlet:null,matches:[],isDataRoute:!1}),He=g.createContext(null);function Ue(e,t){let{relative:n}=t===void 0?{}:t;!We()&&S(!1);let{basename:r,navigator:i}=g.useContext(ze),{hash:a,pathname:o,search:s}=Qe(e,{relative:n}),c=o;return r!==`/`&&(c=o===`/`?r:ke([r,o])),i.createHref({pathname:c,search:s,hash:a})}function We(){return g.useContext(Be)!=null}function Ge(){return!We()&&S(!1),g.useContext(Be).location}function Ke(e){g.useContext(ze).static||g.useLayoutEffect(e)}function qe(){let{isDataRoute:e}=g.useContext(Ve);return e?pt():Je()}function Je(){!We()&&S(!1);let e=g.useContext(Le),{basename:t,future:n,navigator:r}=g.useContext(ze),{matches:i}=g.useContext(Ve),{pathname:a}=Ge(),o=JSON.stringify(De(i,n.v7_relativeSplatPath)),s=g.useRef(!1);return Ke(()=>{s.current=!0}),g.useCallback(function(n,i){if(i===void 0&&(i={}),!s.current)return;if(typeof n==`number`){r.go(n);return}let c=Oe(n,JSON.parse(o),a,i.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:ke([t,c.pathname])),(i.replace?r.replace:r.push)(c,i.state,i)},[t,r,o,a,e])}var Ye=g.createContext(null);function Xe(e){let t=g.useContext(Ve).outlet;return t&&g.createElement(Ye.Provider,{value:e},t)}function Ze(){let{matches:e}=g.useContext(Ve),t=e[e.length-1];return t?t.params:{}}function Qe(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=g.useContext(ze),{matches:i}=g.useContext(Ve),{pathname:a}=Ge(),o=JSON.stringify(De(i,r.v7_relativeSplatPath));return g.useMemo(()=>Oe(e,JSON.parse(o),a,n===`path`),[e,o,a,n])}function $e(e,t){return et(e,t)}function et(e,t,n,r){!We()&&S(!1);let{navigator:i}=g.useContext(ze),{matches:a}=g.useContext(Ve),o=a[a.length-1],s=o?o.params:{};o&&o.pathname;let c=o?o.pathnameBase:`/`;o&&o.route;let l=Ge(),u;if(t){let e=typeof t==`string`?ee(t):t;!(c===`/`||e.pathname?.startsWith(c))&&S(!1),u=e}else u=l;let d=u.pathname||`/`,f=d;if(c!==`/`){let e=c.replace(/^\//,``).split(`/`);f=`/`+d.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let p=re(e,{pathname:f}),m=at(p&&p.map(e=>Object.assign({},e,{params:Object.assign({},s,e.params),pathname:ke([c,i.encodeLocation?i.encodeLocation(e.pathname).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?c:ke([c,i.encodeLocation?i.encodeLocation(e.pathnameBase).pathname:e.pathnameBase])})),a,n,r);return t&&m?g.createElement(Be.Provider,{value:{location:Ie({pathname:`/`,search:``,hash:``,state:null,key:`default`},u),navigationType:y.Pop}},m):m}function tt(){let e=ft(),t=Ne(e)?e.status+` `+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null;return g.createElement(g.Fragment,null,g.createElement(`h2`,null,`Unexpected Application Error!`),g.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?g.createElement(`pre`,{style:{padding:`0.5rem`,backgroundColor:`rgba(200,200,200, 0.5)`}},n):null,null)}var nt=g.createElement(tt,null),rt=class extends g.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){console.error(`React Router caught the following error during render`,e,t)}render(){return this.state.error===void 0?this.props.children:g.createElement(Ve.Provider,{value:this.props.routeContext},g.createElement(He.Provider,{value:this.state.error,children:this.props.component}))}};function it(e){let{routeContext:t,match:n,children:r}=e,i=g.useContext(Le);return i&&i.static&&i.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=n.route.id),g.createElement(Ve.Provider,{value:t},r)}function at(e,t,n,r){if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var i;if(!n)return null;if(n.errors)e=n.matches;else if((i=r)!=null&&i.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let a=e,o=n?.errors;if(o!=null){let e=a.findIndex(e=>e.route.id&&o?.[e.route.id]!==void 0);!(e>=0)&&S(!1),a=a.slice(0,Math.min(a.length,e+1))}let s=!1,c=-1;if(n&&r&&r.v7_partialHydration)for(let e=0;e<a.length;e++){let t=a[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(c=e),t.route.id){let{loaderData:e,errors:r}=n,i=t.route.loader&&e[t.route.id]===void 0&&(!r||r[t.route.id]===void 0);if(t.route.lazy||i){s=!0,a=c>=0?a.slice(0,c+1):[a[0]];break}}}return a.reduceRight((e,r,i)=>{let l,u=!1,d=null,f=null;n&&(l=o&&r.route.id?o[r.route.id]:void 0,d=r.route.errorElement||nt,s&&(c<0&&i===0?(ht(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),u=!0,f=null):c===i&&(u=!0,f=r.route.hydrateFallbackElement||null)));let p=t.concat(a.slice(0,i+1)),m=()=>{let t;return t=l?d:u?f:r.route.Component?g.createElement(r.route.Component,null):r.route.element?r.route.element:e,g.createElement(it,{match:r,routeContext:{outlet:e,matches:p,isDataRoute:n!=null},children:t})};return n&&(r.route.ErrorBoundary||r.route.errorElement||i===0)?g.createElement(rt,{location:n.location,revalidation:n.revalidation,component:d,error:l,children:m(),routeContext:{outlet:null,matches:p,isDataRoute:!0}}):m()},null)}var ot=function(e){return e.UseBlocker=`useBlocker`,e.UseRevalidator=`useRevalidator`,e.UseNavigateStable=`useNavigate`,e}(ot||{}),st=function(e){return e.UseBlocker=`useBlocker`,e.UseLoaderData=`useLoaderData`,e.UseActionData=`useActionData`,e.UseRouteError=`useRouteError`,e.UseNavigation=`useNavigation`,e.UseRouteLoaderData=`useRouteLoaderData`,e.UseMatches=`useMatches`,e.UseRevalidator=`useRevalidator`,e.UseNavigateStable=`useNavigate`,e.UseRouteId=`useRouteId`,e}(st||{});function ct(e){let t=g.useContext(Le);return!t&&S(!1),t}function lt(e){let t=g.useContext(Re);return!t&&S(!1),t}function ut(e){let t=g.useContext(Ve);return!t&&S(!1),t}function dt(e){let t=ut(e),n=t.matches[t.matches.length-1];return!n.route.id&&S(!1),n.route.id}function ft(){let e=g.useContext(He),t=lt(st.UseRouteError),n=dt(st.UseRouteError);return e===void 0?t.errors?.[n]:e}function pt(){let{router:e}=ct(ot.UseNavigateStable),t=dt(st.UseNavigateStable),n=g.useRef(!1);return Ke(()=>{n.current=!0}),g.useCallback(function(r,i){i===void 0&&(i={}),n.current&&(typeof r==`number`?e.navigate(r):e.navigate(r,Ie({fromRouteId:t},i)))},[e,t])}var mt={};function ht(e,t,n){!t&&!mt[e]&&(mt[e]=!0)}var gt=(e,t,n)=>(``+t+("You can use the `"+e+"` future flag to opt-in early. ")+(`For more information, see `+n+`.`),void 0);function _t(e,t){e?.v7_startTransition===void 0&&gt(`v7_startTransition`,"React Router will begin wrapping state updates in `React.startTransition` in v7",`https://reactrouter.com/v6/upgrading/future#v7_starttransition`),e?.v7_relativeSplatPath===void 0&&(!t||t.v7_relativeSplatPath===void 0)&&gt(`v7_relativeSplatPath`,`Relative route resolution within Splat routes is changing in v7`,`https://reactrouter.com/v6/upgrading/future#v7_relativesplatpath`),t&&(t.v7_fetcherPersist===void 0&&gt(`v7_fetcherPersist`,`The persistence behavior of fetchers is changing in v7`,`https://reactrouter.com/v6/upgrading/future#v7_fetcherpersist`),t.v7_normalizeFormMethod===void 0&&gt(`v7_normalizeFormMethod`,"Casing of `formMethod` fields is being normalized to uppercase in v7",`https://reactrouter.com/v6/upgrading/future#v7_normalizeformmethod`),t.v7_partialHydration===void 0&&gt(`v7_partialHydration`,"`RouterProvider` hydration behavior is changing in v7",`https://reactrouter.com/v6/upgrading/future#v7_partialhydration`),t.v7_skipActionErrorRevalidation===void 0&&gt(`v7_skipActionErrorRevalidation`,"The revalidation behavior after 4xx/5xx `action` responses is changing in v7",`https://reactrouter.com/v6/upgrading/future#v7_skipactionerrorrevalidation`))}function vt(e){return Xe(e.context)}function yt(e){S(!1)}function bt(e){let{basename:t=`/`,children:n=null,location:r,navigationType:i=y.Pop,navigator:a,static:o=!1,future:s}=e;We()&&S(!1);let c=t.replace(/^\/*/,`/`),l=g.useMemo(()=>({basename:c,navigator:a,static:o,future:Ie({v7_relativeSplatPath:!1},s)}),[c,s,a,o]);typeof r==`string`&&(r=ee(r));let{pathname:u=`/`,search:d=``,hash:f=``,state:p=null,key:m=`default`}=r,h=g.useMemo(()=>{let e=be(u,c);return e==null?null:{location:{pathname:e,search:d,hash:f,state:p,key:m},navigationType:i}},[c,u,d,f,p,m,i]);return h==null?null:g.createElement(ze.Provider,{value:l},g.createElement(Be.Provider,{children:n,value:h}))}function xt(e){let{children:t,location:n}=e;return $e(Ct(t),n)}var St=function(e){return e[e.pending=0]=`pending`,e[e.success=1]=`success`,e[e.error=2]=`error`,e}(St||{});new Promise(()=>{}),g.Component;function Ct(e,t){t===void 0&&(t=[]);let n=[];return g.Children.forEach(e,(e,r)=>{if(!g.isValidElement(e))return;let i=[...t,r];if(e.type===g.Fragment){n.push.apply(n,Ct(e.props.children,i));return}e.type!==yt&&S(!1),!(!e.props.index||!e.props.children)&&S(!1);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,loader:e.props.loader,action:e.props.action,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=Ct(e.props.children,i)),n.push(a)}),n}function wt(){return wt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},wt.apply(this,arguments)}function Tt(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function Et(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Dt(e,t){return e.button===0&&(!t||t===`_self`)&&!Et(e)}var Ot=[`onClick`,`relative`,`reloadDocument`,`replace`,`state`,`target`,`to`,`preventScrollReset`,`viewTransition`],kt=[`aria-current`,`caseSensitive`,`className`,`end`,`style`,`to`,`viewTransition`,`children`],At=`6`;try{window.__reactRouterVersion=At}catch{}var jt=g.createContext({isTransitioning:!1}),Mt=g.startTransition;function Nt(e){let{basename:t,children:n,future:r,window:i}=e,a=g.useRef();a.current??=x({window:i,v5Compat:!0});let o=a.current,[s,c]=g.useState({action:o.action,location:o.location}),{v7_startTransition:l}=r||{},u=g.useCallback(e=>{l&&Mt?Mt(()=>c(e)):c(e)},[c,l]);return g.useLayoutEffect(()=>o.listen(u),[o,u]),g.useEffect(()=>_t(r),[r]),g.createElement(bt,{basename:t,children:n,location:s.location,navigationType:s.action,navigator:o,future:r})}var Pt=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,Ft=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,It=g.forwardRef(function(e,t){let{onClick:n,relative:r,reloadDocument:i,replace:a,state:o,target:s,to:c,preventScrollReset:l,viewTransition:u}=e,d=Tt(e,Ot),{basename:f}=g.useContext(ze),p,m=!1;if(typeof c==`string`&&Ft.test(c)&&(p=c,Pt))try{let e=new URL(window.location.href),t=c.startsWith(`//`)?new URL(e.protocol+c):new URL(c),n=be(t.pathname,f);t.origin===e.origin&&n!=null?c=n+t.search+t.hash:m=!0}catch{}let h=Ue(c,{relative:r}),_=Vt(c,{replace:a,state:o,target:s,preventScrollReset:l,relative:r,viewTransition:u});function v(e){n&&n(e),e.defaultPrevented||_(e)}return g.createElement(`a`,wt({},d,{href:p||h,onClick:m||i?n:v,ref:t,target:s}))}),Lt=g.forwardRef(function(e,t){let{"aria-current":n=`page`,caseSensitive:r=!1,className:i=``,end:a=!1,style:o,to:s,viewTransition:c,children:l}=e,u=Tt(e,kt),d=Qe(s,{relative:u.relative}),f=Ge(),p=g.useContext(Re),{navigator:m,basename:h}=g.useContext(ze),_=p!=null&&Ht(d)&&c===!0,v=m.encodeLocation?m.encodeLocation(d).pathname:d.pathname,y=f.pathname,b=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;r||(y=y.toLowerCase(),b=b?b.toLowerCase():null,v=v.toLowerCase()),b&&h&&(b=be(b,h)||b);let x=v!==`/`&&v.endsWith(`/`)?v.length-1:v.length,S=y===v||!a&&y.startsWith(v)&&y.charAt(x)===`/`,C=b!=null&&(b===v||!a&&b.startsWith(v)&&b.charAt(v.length)===`/`),w={isActive:S,isPending:C,isTransitioning:_},T=S?n:void 0,E;E=typeof i==`function`?i(w):[i,S?`active`:null,C?`pending`:null,_?`transitioning`:null].filter(Boolean).join(` `);let D=typeof o==`function`?o(w):o;return g.createElement(It,wt({},u,{"aria-current":T,className:E,ref:t,style:D,to:s,viewTransition:c}),typeof l==`function`?l(w):l)}),Rt;(function(e){e.UseScrollRestoration=`useScrollRestoration`,e.UseSubmit=`useSubmit`,e.UseSubmitFetcher=`useSubmitFetcher`,e.UseFetcher=`useFetcher`,e.useViewTransitionState=`useViewTransitionState`})(Rt||={});var zt;(function(e){e.UseFetcher=`useFetcher`,e.UseFetchers=`useFetchers`,e.UseScrollRestoration=`useScrollRestoration`})(zt||={});function Bt(e){let t=g.useContext(Le);return!t&&S(!1),t}function Vt(e,t){let{target:n,replace:r,state:i,preventScrollReset:a,relative:o,viewTransition:s}=t===void 0?{}:t,c=qe(),l=Ge(),u=Qe(e,{relative:o});return g.useCallback(t=>{Dt(t,n)&&(t.preventDefault(),c(e,{replace:r===void 0?D(l)===D(u):r,state:i,preventScrollReset:a,relative:o,viewTransition:s}))},[l,c,u,r,i,n,e,a,o,s])}function Ht(e,t){t===void 0&&(t={});let n=g.useContext(jt);n??S(!1);let{basename:r}=Bt(Rt.useViewTransitionState),i=Qe(e,{relative:t.relative});if(!n.isTransitioning)return!1;let a=be(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=be(n.nextLocation.pathname,r)||n.nextLocation.pathname;return _e(i.pathname,o)!=null||_e(i.pathname,a)!=null}var Ut=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Wt=new class extends Ut{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},Gt={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Kt=new class{#e=Gt;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function qt(e){setTimeout(e,0)}var Jt=typeof window>`u`||`Deno`in globalThis;function Yt(){}function Xt(e,t){return typeof e==`function`?e(t):e}function Zt(e){return typeof e==`number`&&e>=0&&e!==1/0}function Qt(e,t){return Math.max(e+(t||0)-Date.now(),0)}function k(e,t){return typeof e==`function`?e(t):e}function $t(e,t){return typeof e==`function`?e(t):e}function en(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==nn(o,t.options))return!1}else if(!an(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function tn(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(rn(t.options.mutationKey)!==rn(a))return!1}else if(!an(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function nn(e,t){return(t?.queryKeyHashFn||rn)(e)}function rn(e){return JSON.stringify(e,(e,t)=>un(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function an(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>an(e[n],t[n])):!1}var on=Object.prototype.hasOwnProperty;function sn(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=ln(e)&&ln(t);if(!r&&!(un(e)&&un(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:on.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=sn(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function cn(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function ln(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function un(e){if(!dn(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!dn(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function dn(e){return Object.prototype.toString.call(e)===`[object Object]`}function fn(e){return new Promise(t=>{Kt.setTimeout(t,e)})}function pn(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:sn(e,t)}function mn(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function hn(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var gn=Symbol();function _n(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===gn?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function vn(e,t){return typeof e==`function`?e(...t):!!e}function yn(e,t,n){let r=!1,i;return Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var bn=(()=>{let e=()=>Jt;return{isServer(){return e()},setIsServer(t){e=t}}})();function xn(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var Sn=qt;function Cn(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=Sn,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var wn=Cn(),Tn=new class extends Ut{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function En(e){return Math.min(1e3*2**e,3e4)}function Dn(e){return(e??`online`)===`online`?Tn.isOnline():!0}var On=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function kn(e){let t=!1,n=0,r,i=xn(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new On(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>Wt.isFocused()&&(e.networkMode===`always`||Tn.isOnline())&&e.canRun(),u=()=>Dn(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(bn.isServer()?0:3),o=e.retryDelay??En,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),fn(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var An=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Zt(this.gcTime)&&(this.#e=Kt.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(bn.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(Kt.clearTimeout(this.#e),this.#e=void 0)}};function jn(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{yn(e,()=>t.signal,()=>n=!0)},u=_n(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?hn:mn;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?Nn:Mn,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:Mn(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function Mn(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Nn(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function Pn(e,t){return t?Mn(e,t)!=null:!1}function Fn(e,t){return!t||!e.getPreviousPageParam?!1:Nn(e,t)!=null}var In=class extends An{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=zn(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=zn(this.options);e.data!==void 0&&(this.setState(Rn(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=pn(this.state.data,e,this.options);return this.#l({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#l({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(Yt).catch(Yt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>$t(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===gn||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>k(e.options.staleTime,this)===`static`):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!Qt(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#a&&(this.#s||this.#c()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#l({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=_n(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?jn(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:`fetch`,meta:a.fetchOptions?.meta}),this.#a=kn({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof On&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#l({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#l({type:`pause`})},onContinue:()=>{this.#l({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#a.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof On){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#l({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#l(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...Ln(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...Rn(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),wn.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function Ln(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Dn(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function Rn(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function zn(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var Bn=class extends Ut{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=xn(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Hn(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Un(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Un(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof $t(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!cn(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Wn(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||$t(this.options.enabled,this.#t)!==$t(t.enabled,this.#t)||k(this.options.staleTime,this.#t)!==k(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||$t(this.options.enabled,this.#t)!==$t(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return Kn(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Yt)),t}#g(){this.#b();let e=k(this.options.staleTime,this.#t);if(bn.isServer()||this.#r.isStale||!Zt(e))return;let t=Qt(this.#r.dataUpdatedAt,e)+1;this.#d=Kt.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(bn.isServer()||$t(this.options.enabled,this.#t)===!1||!Zt(this.#p)||this.#p===0)&&(this.#f=Kt.setInterval(()=>{(this.options.refetchIntervalInBackground||Wt.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(Kt.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(Kt.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&Hn(e,t),o=i&&Wn(e,n,t,r);(a||o)&&(l={...l,...Ln(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=pn(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=pn(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:Gn(e,t),refetch:this.refetch,promise:this.#o,isEnabled:$t(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{i(this.#o=x.promise=xn())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a();break}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!cn(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){wn.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function Vn(e,t){return $t(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&$t(t.retryOnMount,e)===!1)}function Hn(e,t){return Vn(e,t)||e.state.data!==void 0&&Un(e,t,t.refetchOnMount)}function Un(e,t,n){if($t(t.enabled,e)!==!1&&k(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Gn(e,t)}return!1}function Wn(e,t,n,r){return(e!==t||$t(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Gn(e,n)}function Gn(e,t){return $t(t.enabled,e)!==!1&&e.isStaleByTime(k(t.staleTime,e))}function Kn(e,t){return!cn(e.getCurrentResult(),t)}var qn=class extends Bn{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Pn(t,n.data),hasPreviousPage:Fn(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},Jn=class extends An{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Yn(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=kn({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),wn.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Yn(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Xn=class extends Ut{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new Jn({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Zn(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Zn(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Zn(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=Zn(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){wn.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>tn(t,e))}findAll(e={}){return this.getAll().filter(t=>tn(e,t))}notify(e){wn.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return wn.batch(()=>Promise.all(e.map(e=>e.continue().catch(Yt))))}};function Zn(e){return e.options.scope?.id}var Qn=class extends Ut{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),cn(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&rn(t.mutationKey)!==rn(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Yn();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){wn.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},$n=class extends Ut{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??nn(r,t),a=this.get(i);return a||(a=new In({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){wn.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>en(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>en(e,t)):t}notify(e){wn.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){wn.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){wn.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},er=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new $n,this.#t=e.mutationCache||new Xn,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=Wt.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=Tn.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(k(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=Xt(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return wn.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;wn.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return wn.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=wn.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(Yt).catch(Yt)}invalidateQueries(e,t={}){return wn.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=wn.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(Yt)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(Yt)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(k(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Yt).catch(Yt)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Yt).catch(Yt)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return Tn.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(rn(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{an(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(rn(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{an(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=nn(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===gn&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},tr=o((e=>{var t=u(),n=Symbol.for(`react.element`),r=Symbol.for(`react.fragment`),i=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var s,c={},l=null,u=null;for(s in r!==void 0&&(l=``+r),t.key!==void 0&&(l=``+t.key),t.ref!==void 0&&(u=t.ref),t)i.call(t,s)&&!o.hasOwnProperty(s)&&(c[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps,t)c[s]===void 0&&(c[s]=t[s]);return{$$typeof:n,type:e,key:l,ref:u,props:c,_owner:a.current}}e.Fragment=r,e.jsx=s,e.jsxs=s})),A=o(((e,t)=>{t.exports=tr()}))(),nr=g.createContext(void 0),j=e=>{let t=g.useContext(nr);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},rr=({client:e,children:t})=>(g.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,A.jsx)(nr.Provider,{value:e,children:t})),ir=g.createContext(!1),ar=()=>g.useContext(ir);ir.Provider;function or(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var sr=g.createContext(or()),cr=()=>g.useContext(sr),lr=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?vn(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},ur=e=>{g.useEffect(()=>{e.clearReset()},[e])},dr=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||vn(n,[e.error,r])),fr=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},pr=(e,t)=>e.isLoading&&e.isFetching&&!t,mr=(e,t)=>e?.suspense&&t.isPending,hr=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function gr(e,t,n){let r=ar(),i=cr(),a=j(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?`isRestoring`:`optimistic`,fr(o),lr(o,i,s),ur(i);let c=!a.getQueryCache().get(o.queryHash),[l]=g.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&e.subscribed!==!1;if(g.useSyncExternalStore(g.useCallback(e=>{let t=d?l.subscribe(wn.batchCalls(e)):Yt;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),g.useEffect(()=>{l.setOptions(o)},[o,l]),mr(o,u))throw hr(o,l,i);if(dr({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!bn.isServer()&&pr(u,r)&&(c?hr(o,l,i):s?.promise)?.catch(Yt).finally(()=>{l.updateResult()}),o.notifyOnChangeProps?u:l.trackResult(u)}function M(e,t){return gr(e,Bn,t)}function N(e,t){let n=j(t),[r]=g.useState(()=>new Qn(n,e));g.useEffect(()=>{r.setOptions(e)},[r,e]);let i=g.useSyncExternalStore(g.useCallback(e=>r.subscribe(wn.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=g.useCallback((e,t)=>{r.mutate(e,t).catch(Yt)},[r]);if(i.error&&vn(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function _r(e,t){return gr(e,qn,t)}function vr(e,t=1){if(e===0)return`0 B`;let n=1024,r=[`B`,`KB`,`MB`,`GB`,`TB`],i=Math.floor(Math.log(e)/Math.log(n));return`${(e/n**+i).toFixed(t)} ${r[i]}`}function yr(e){if(!e||e<=0)return`0s`;let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60),i=Math.floor(e%60),a=[];return t>0&&a.push(`${t}d`),n>0&&a.push(`${n}h`),r>0&&a.push(`${r}m`),a.length===0&&a.push(`${i}s`),a.join(` `)}function br(e,t=Date.now()){if(!e)return``;let n=t-new Date(e).getTime();if(n<0)return`just now`;let r=Math.floor(n/1e3);if(r<60)return`${r}s ago`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function xr(e,t){let n=Date.parse(e);if(!Number.isFinite(n))return`an unknown time`;let r=new Date(n);return`${new Date(t).toDateString()===r.toDateString()?r.toLocaleTimeString():r.toLocaleString()} (${br(e,t)})`}function Sr(e){return!e||e.health?.state!==`down`?null:{agentLabel:e.agentLabel,reason:e.health.reason??null,since:e.health.since??null,agentLastSeenAt:e.agentLastSeenAt??null}}function Cr(e){return!e||e.state!==`down`?null:{agentLabel:e.agentLabel,reason:e.reason??null,since:e.since??null,agentLastSeenAt:e.agentLastSeenAt??null}}function wr(e,t){let n=e.since?xr(e.since,t):`an unknown time`;if(e.reason===`app`)return`The agent half is not responding since ${n}`;if(e.reason===`tunnel`){let r=e.agentLastSeenAt?`last sync ${xr(e.agentLastSeenAt,t)}`:`no sync recorded`;return`Hosting agent ${e.agentLabel} is offline since ${n} — ${r}`}return`The hosting on ${e.agentLabel} is down since ${n}`}function Tr(e,t){if(!e||e.hosting!==`agent`||e.agent==null)return{state:`mount`};let n=e.agentHosting,r=e.displayName||e.name;if(!n)return{state:`waiting`,message:`${r} is not hosted on an agent — host it on the Plugins page`};if(n.phase&&n.phase!==`active`)return{state:`waiting`,message:n.phase===`installing`?`The hosting of ${r} on ${n.agentLabel} is being set up`:`The hosting of ${r} on ${n.agentLabel} is being removed`};let i=Sr(n);return i?{state:`offline`,message:wr(i,t)}:{state:`mount`}}function Er(e,t){let n=e.hosting;if(!n)return`Not hosted on an agent yet`;if(n.phase&&n.phase!==`active`)return n.phase===`installing`?`The hosting on ${n.agentLabel} is being set up`:`The hosting on ${n.agentLabel} is being removed`;let r=Cr(n);return r?wr(r,t):typeof e.revision==`number`?null:`The settings could not be read from the agent half yet`}function Dr(e){return e.required===!0&&e.default===void 0}function Or(e){return e.type===`secret`?e.required!==!0:!Dr(e)}function kr(e,t){switch(e.type){case`boolean`:return typeof t==`boolean`?t:null;case`integer`:case`number`:return typeof t==`number`&&Number.isFinite(t)?String(t):``;case`string`:case`enum`:return typeof t==`string`?t:``;default:return``}}function Ar(e){let t={};for(let n of e.fields)n.type!==`secret`&&(t[n.key]=kr(n,e.values?.[n.key]));return t}function jr(e,t){let n=e.values?.[t];return typeof n==`object`&&n&&n.set===!0?{set:!0,setAt:typeof n.setAt==`string`?n.setAt:null}:{set:!1,setAt:null}}function Mr(e){let t={};for(let n of e.fields)n.type===`secret`&&(t[n.key]=jr(e,n.key).set?`keep`:`replace`);return t}function Nr(e){if(!e.set)return`Not set`;if(!e.setAt)return`Set`;let t=new Date(e.setAt);return Number.isNaN(t.getTime())?`Set`:`Set on ${t.toLocaleString()}`}function Pr(e){return e.type===`integer`?`Must be an integer`:`Must be a number`}function Fr(e,t){return e.min!==void 0&&t<e.min?`Must be at least ${e.min}`:e.max!==void 0&&t>e.max?`Must be at most ${e.max}`:null}function Ir(e,t){if(e.pattern===void 0)return!0;let n;try{n=new RegExp(e.pattern,`u`)}catch{return!0}return n.test(t)}function Lr(e,t,{badInput:n=!1}={}){switch(e.type){case`string`:{let n=typeof t==`string`?t:``;if(n===``)return{ok:!0,value:null};let r=e.maxLength??1024;return n.length>r?{ok:!1,message:`Must be at most ${r} characters`}:Ir(e,n)?{ok:!0,value:n}:{ok:!1,message:`Does not match the required format`}}case`integer`:case`number`:{if(n)return{ok:!1,message:Pr(e)};let r=typeof t==`string`?t.trim():``;if(r===``)return{ok:!0,value:null};let i=Number(r);if(!(e.type===`integer`?Number.isSafeInteger(i):Number.isFinite(i)))return{ok:!1,message:Pr(e)};let a=Fr(e,i);return a?{ok:!1,message:a}:{ok:!0,value:i}}case`boolean`:return{ok:!0,value:typeof t==`boolean`?t:null};case`enum`:{let n=typeof t==`string`?t:``;return n===``?{ok:!0,value:null}:(e.options??[]).some(e=>e.value===n)?{ok:!0,value:n}:{ok:!1,message:`Must be one of the options`}}default:return{ok:!1,message:`Cannot be set in this form`}}}function Rr(e,t,n,{badInput:r=!1}={}){if(n===void 0)return!1;if(e.type===`integer`||e.type===`number`){if(r)return!0;let e=typeof t==`string`?t.trim():``,i=typeof n==`string`?n.trim():``;if(e===``||i===``)return e!==i;let a=Number(e),o=Number(i);return Number.isNaN(a)||Number.isNaN(o)?e!==i:a!==o}return t!==n}function zr(e){return JSON.stringify(e??[])}function Br(e,t){let n=Ar(e),r=[];for(let i of e.fields){let e=i.key;if(i.type===`secret`){let n=t.secretActions[e];(n===`clear`||n===`replace`&&t.secretFilled?.[e]===!0)&&r.push(e)}else Rr(i,n[e],t.inputs[e],{badInput:t.badInput?.[e]})&&r.push(e)}return r}function Vr(e,t){let n=Ar(e),r=[],i=[],a=[];for(let o of e.fields){let e=o.key;if(o.type===`secret`){let{action:n,value:r=``}=t.secrets[e]??{action:`keep`};if(n===`clear`)Or(o)?i.push([e,null]):a.push([e,`Is required`]);else if(n===`replace`&&r!==``){let t=o.maxLength??1024;r.length>t?a.push([e,`Must be at most ${t} characters`]):i.push([e,r])}continue}let s=t.badInput?.[e]===!0;if(!Rr(o,n[e],t.inputs[e],{badInput:s}))continue;let c=Lr(o,t.inputs[e],{badInput:s});c.ok?c.value===null&&!Or(o)?a.push([e,`Is required`]):r.push([e,c.value]):a.push([e,c.message])}return a.length>0?{ok:!1,errors:Object.fromEntries(a)}:{ok:!0,body:{revision:e.revision,...r.length>0?{values:Object.fromEntries(r)}:{},...i.length>0?{secrets:Object.fromEntries(i)}:{}},changed:[...r,...i].map(([e])=>e)}}function Hr(e){if(typeof e!=`object`||!e)return null;let t=e.errors;if(typeof t!=`object`||!t||Array.isArray(t))return null;let n=Object.entries(t).filter(([,e])=>typeof e==`string`);return n.length>0?Object.fromEntries(n):null}function Ur(e,t){return e.source===`live`?`Read from the agent half`:e.source===`cache`?e.syncedAt?`From the relay's copy, synced from the agent half ${xr(e.syncedAt,t)}`:`From the relay's copy`:`Never synced from the agent half — showing the defaults`}var Wr=/key|token|secret|password|passwd|credential/i;function Gr(e){return e.type===`string`?Wr.test(e.key)||Wr.test(e.label??``):!1}function Kr(e){try{return typeof e?.supports==`function`&&e.supports(`-webkit-text-security`,`disc`)}catch{return!1}}function qr(e){let t=e.type;if((e.type===`integer`||e.type===`number`)&&(e.min!==void 0&&e.max!==void 0?t+=` ${e.min}–${e.max}`:e.min===void 0?e.max!==void 0&&(t+=` ≤ ${e.max}`):t+=` ≥ ${e.min}`),e.type===`enum`){let n=(e.options??[]).map(e=>e.value);t+=`: ${n.length>5?`${n.slice(0,5).join(` | `)} | …`:n.join(` | `)}`}return e.required?`${t}, required`:t}function Jr(e){if(!e||typeof e!=`object`)return null;let t=e=>Array.isArray(e)?e:[],n=e=>e&&typeof e==`object`?`${e.key} (${e.type})`:String(e),r=[{label:`added`,entries:t(e.added).map(n),note:null},{label:`removed`,entries:t(e.removed).map(n),note:`their values are dropped`},{label:`type changed`,entries:t(e.retyped).map(e=>e&&typeof e==`object`?`${e.key} (${e.from} → ${e.to})`:String(e)),note:`their values are dropped, not converted`},{label:`newly required`,entries:t(e.newRequired).map(String),note:`to be set after the update`}].filter(e=>e.entries.length>0),i=t(e.secretToPlain).map(String);return r.length===0&&i.length===0?null:{rows:r,secretToPlain:i}}var Yr=`lamaste:2fa-required`;function Xr(e,t){let n=e.error||`Request failed with status ${t}`,r=(Array.isArray(e.details?.issues)?e.details.issues:[]).filter(e=>typeof e?.message==`string`).map(e=>Array.isArray(e.path)&&e.path.length>0?`${e.path.join(`.`)}: ${e.message}`:e.message);return r.length>0?`${n}: ${[...new Set(r)].join(`; `)}`:n}function Zr(e){if(String(e).split(/[?#]/,1)[0].split(`/`).some(e=>e===`.`||e===`..`))throw Error(`A panel request path may not have a "." or ".." segment`)}async function P(e,t){Zr(e);let n=await fetch(e,t);if(n.status===401)try{if((await n.clone().json()).error===`2fa_required`)throw window.dispatchEvent(new CustomEvent(Yr)),Error(`2fa_required`)}catch(e){if(e.message===`2fa_required`)throw e}if(!n.ok){let e=await n.json().catch(()=>null),t=typeof e==`object`&&e?e:{},r=Hr(t);throw Object.assign(Error(Xr(t,n.status)),{status:n.status,...typeof t.code==`string`?{code:t.code}:{},...Array.isArray(t.reasons)?{reasons:t.reasons}:{},...t.usedBy&&typeof t.usedBy==`object`?{usedBy:t.usedBy}:{},...typeof t.operationId==`string`?{operationId:t.operationId}:{},...r?{errors:r}:{}})}return n.json()}async function Qr(){return P(`/api/onboarding/status`)}function $r(){let{data:e,isLoading:t,isError:n,error:r,refetch:i}=M({queryKey:[`onboarding`,`status`],queryFn:Qr,staleTime:3e4,retry:2,refetchOnWindowFocus:!0});return{status:e?.status,domain:e?.domain??null,ip:e?.ip??null,isLoading:t,isError:n,error:r,refetch:i}}var ei=(0,g.createContext)(null);function F(){let e=(0,g.useContext)(ei);if(!e)throw Error(`useAdminClient must be used within an AdminClientProvider`);return e}function ti({client:e,children:t}){return(0,A.jsx)(ei.Provider,{value:e,children:t})}var ni=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),ri=(...e)=>e.filter((e,t,n)=>!!e&&n.indexOf(e)===t).join(` `),ii={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},ai=(0,g.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>(0,g.createElement)(`svg`,{ref:c,...ii,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:ri(`lucide`,i),...s},[...o.map(([e,t])=>(0,g.createElement)(e,t)),...Array.isArray(a)?a:[a]])),I=(e,t)=>{let n=(0,g.forwardRef)(({className:n,...r},i)=>(0,g.createElement)(ai,{ref:i,iconNode:t,className:ri(`lucide-${ni(e)}`,n),...r}));return n.displayName=`${e}`,n},oi=I(`Activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),si=I(`Archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),ci=I(`ArrowDown`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),li=I(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),ui=I(`ArrowRightLeft`,[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]),di=I(`BarChart3`,[[`path`,{d:`M3 3v18h18`,key:`1s2lah`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),fi=I(`Bell`,[[`path`,{d:`M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9`,key:`1qo2s2`}],[`path`,{d:`M10.3 21a1.94 1.94 0 0 0 3.4 0`,key:`qgo35s`}]]),pi=I(`BookOpen`,[[`path`,{d:`M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z`,key:`vv98re`}],[`path`,{d:`M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z`,key:`1cyq3y`}]]),mi=I(`Box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),hi=I(`CheckCheck`,[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]),gi=I(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),_i=I(`ChevronDown`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),vi=I(`ChevronLeft`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),yi=I(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),bi=I(`ChevronUp`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),xi=I(`CircleAlert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),Si=I(`CircleCheckBig`,[[`path`,{d:`M22 11.08V12a10 10 0 1 1-5.93-9.14`,key:`g774vq`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),Ci=I(`CircleCheck`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),wi=I(`CircleX`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),Ti=I(`Circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Ei=I(`Clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]]),Di=I(`Copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Oi=I(`Cpu`,[[`rect`,{width:`16`,height:`16`,x:`4`,y:`4`,rx:`2`,key:`14l7u7`}],[`rect`,{width:`6`,height:`6`,x:`9`,y:`9`,rx:`1`,key:`5aljv4`}],[`path`,{d:`M15 2v2`,key:`13l42r`}],[`path`,{d:`M15 20v2`,key:`15mkzm`}],[`path`,{d:`M2 15h2`,key:`1gxd5l`}],[`path`,{d:`M2 9h2`,key:`1bbxkp`}],[`path`,{d:`M20 15h2`,key:`19e6y8`}],[`path`,{d:`M20 9h2`,key:`19tzq7`}],[`path`,{d:`M9 2v2`,key:`165o2o`}],[`path`,{d:`M9 20v2`,key:`i2bqo8`}]]),ki=I(`Database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),Ai=I(`Download`,[[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`polyline`,{points:`7 10 12 15 17 10`,key:`2ggqvy`}],[`line`,{x1:`12`,x2:`12`,y1:`15`,y2:`3`,key:`1vk2je`}]]),ji=I(`Earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3v0a2 2 0 0 1 2 2v0c0 1.1.9 2 2 2v0a2 2 0 0 0 2-2v0c0-1.1.9-2 2-2h3.17`,key:`1fi5u6`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2v0a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`xsiumc`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Mi=I(`Eraser`,[[`path`,{d:`m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21`,key:`182aya`}],[`path`,{d:`M22 21H7`,key:`t4ddhn`}],[`path`,{d:`m5 11 9 9`,key:`1mo9qw`}]]),Ni=I(`ExternalLink`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),Pi=I(`EyeOff`,[[`path`,{d:`M9.88 9.88a3 3 0 1 0 4.24 4.24`,key:`1jxqfv`}],[`path`,{d:`M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68`,key:`9wicm4`}],[`path`,{d:`M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61`,key:`1jreej`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}]]),Fi=I(`Eye`,[[`path`,{d:`M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z`,key:`rwhkz3`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Ii=I(`FileText`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Li=I(`File`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}]]),Ri=I(`Fingerprint`,[[`path`,{d:`M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4`,key:`1nerag`}],[`path`,{d:`M14 13.12c0 2.38 0 6.38-1 8.88`,key:`o46ks0`}],[`path`,{d:`M17.29 21.02c.12-.6.43-2.3.5-3.02`,key:`ptglia`}],[`path`,{d:`M2 12a10 10 0 0 1 18-6`,key:`ydlgp0`}],[`path`,{d:`M2 16h.01`,key:`1gqxmh`}],[`path`,{d:`M21.8 16c.2-2 .131-5.354 0-6`,key:`drycrb`}],[`path`,{d:`M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2`,key:`1tidbn`}],[`path`,{d:`M8.65 22c.21-.66.45-1.32.57-2`,key:`13wd9y`}],[`path`,{d:`M9 6.8a6 6 0 0 1 9 5.2v2`,key:`1fr1j5`}]]),zi=I(`FolderOpen`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),Bi=I(`Folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),Vi=I(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),Hi=I(`Globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),Ui=I(`HardDrive`,[[`line`,{x1:`22`,x2:`2`,y1:`12`,y2:`12`,key:`1y58io`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}],[`line`,{x1:`6`,x2:`6.01`,y1:`16`,y2:`16`,key:`sgf278`}],[`line`,{x1:`10`,x2:`10.01`,y1:`16`,y2:`16`,key:`1l4acy`}]]),Wi=I(`Heart`,[[`path`,{d:`M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z`,key:`c3ymky`}]]),Gi=I(`Home`,[[`path`,{d:`m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`y5dka4`}],[`polyline`,{points:`9 22 9 12 15 12 15 22`,key:`e2us08`}]]),Ki=I(`Info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),qi=I(`KeyRound`,[[`path`,{d:`M2 18v3c0 .6.4 1 1 1h4v-3h3v-3h2l1.4-1.4a6.5 6.5 0 1 0-4-4Z`,key:`167ctg`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),Ji=I(`Key`,[[`path`,{d:`m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4`,key:`g0fldk`}],[`path`,{d:`m21 2-9.6 9.6`,key:`1j0ho8`}],[`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`,key:`yqb3hr`}]]),Yi=I(`Layers`,[[`path`,{d:`m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z`,key:`8b97xw`}],[`path`,{d:`m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65`,key:`dd6zsq`}],[`path`,{d:`m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65`,key:`ep9fru`}]]),Xi=I(`LayoutDashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]),Zi=I(`Link2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),Qi=I(`Link`,[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]),$i=I(`List`,[[`line`,{x1:`8`,x2:`21`,y1:`6`,y2:`6`,key:`7ey8pc`}],[`line`,{x1:`8`,x2:`21`,y1:`12`,y2:`12`,key:`rjfblc`}],[`line`,{x1:`8`,x2:`21`,y1:`18`,y2:`18`,key:`c3b1m8`}],[`line`,{x1:`3`,x2:`3.01`,y1:`6`,y2:`6`,key:`1g7gq3`}],[`line`,{x1:`3`,x2:`3.01`,y1:`12`,y2:`12`,key:`1pjlvk`}],[`line`,{x1:`3`,x2:`3.01`,y1:`18`,y2:`18`,key:`28t2mc`}]]),L=I(`LoaderCircle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),ea=I(`LockOpen`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 9.9-1`,key:`1mm8w8`}]]),ta=I(`Lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),na=I(`Mail`,[[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}],[`path`,{d:`m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7`,key:`1ocrg3`}]]),ra=I(`Map`,[[`path`,{d:`M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z`,key:`169xi5`}],[`path`,{d:`M15 5.764v15`,key:`1pn4in`}],[`path`,{d:`M9 3.236v15`,key:`1uimfh`}]]),ia=I(`Menu`,[[`line`,{x1:`4`,x2:`20`,y1:`12`,y2:`12`,key:`1e0a9i`}],[`line`,{x1:`4`,x2:`20`,y1:`6`,y2:`6`,key:`1owob3`}],[`line`,{x1:`4`,x2:`20`,y1:`18`,y2:`18`,key:`yk5zj1`}]]),aa=I(`Minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),oa=I(`Network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),sa=I(`Package`,[[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}],[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),ca=I(`Pencil`,[[`path`,{d:`M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z`,key:`5qss01`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),la=I(`Play`,[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]]),ua=I(`Plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),da=I(`PowerOff`,[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),fa=I(`Power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),pa=I(`RefreshCw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),ma=I(`Repeat`,[[`path`,{d:`m17 2 4 4-4 4`,key:`nntrym`}],[`path`,{d:`M3 11v-1a4 4 0 0 1 4-4h14`,key:`84bu3i`}],[`path`,{d:`m7 22-4-4 4-4`,key:`1wqhfi`}],[`path`,{d:`M21 13v1a4 4 0 0 1-4 4H3`,key:`1rx37r`}]]),ha=I(`RotateCcw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),ga=I(`RotateCw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),_a=I(`Save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),va=I(`ScrollText`,[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]),ya=I(`Search`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),ba=I(`ServerOff`,[[`path`,{d:`M7 2h13a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-5`,key:`bt2siv`}],[`path`,{d:`M10 10 2.5 2.5C2 2 2 2.5 2 5v3a2 2 0 0 0 2 2h6z`,key:`1hjrv1`}],[`path`,{d:`M22 17v-1a2 2 0 0 0-2-2h-1`,key:`1iynyr`}],[`path`,{d:`M4 14a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16.5l1-.5.5.5-8-8H4z`,key:`161ggg`}],[`path`,{d:`M6 18h.01`,key:`uhywen`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),xa=I(`Server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),Sa=I(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),Ca=I(`Settings`,[[`path`,{d:`M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z`,key:`1qme2f`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),wa=I(`ShieldAlert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),Ta=I(`ShieldCheck`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Ea=I(`Shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),Da=I(`SlidersHorizontal`,[[`line`,{x1:`21`,x2:`14`,y1:`4`,y2:`4`,key:`obuewd`}],[`line`,{x1:`10`,x2:`3`,y1:`4`,y2:`4`,key:`1q6298`}],[`line`,{x1:`21`,x2:`12`,y1:`12`,y2:`12`,key:`1iu8h1`}],[`line`,{x1:`8`,x2:`3`,y1:`12`,y2:`12`,key:`ntss68`}],[`line`,{x1:`21`,x2:`16`,y1:`20`,y2:`20`,key:`14d8ph`}],[`line`,{x1:`12`,x2:`3`,y1:`20`,y2:`20`,key:`m0wm8r`}],[`line`,{x1:`14`,x2:`14`,y1:`2`,y2:`6`,key:`14e1ph`}],[`line`,{x1:`8`,x2:`8`,y1:`10`,y2:`14`,key:`1i6ji0`}],[`line`,{x1:`16`,x2:`16`,y1:`18`,y2:`22`,key:`1lctlv`}]]),Oa=I(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),ka=I(`Terminal`,[[`polyline`,{points:`4 17 10 11 4 5`,key:`akl6gq`}],[`line`,{x1:`12`,x2:`20`,y1:`19`,y2:`19`,key:`q2wloq`}]]),Aa=I(`Ticket`,[[`path`,{d:`M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z`,key:`qn84l0`}],[`path`,{d:`M13 5v2`,key:`dyzc3o`}],[`path`,{d:`M13 17v2`,key:`1ont0d`}],[`path`,{d:`M13 11v2`,key:`1wjjxi`}]]),R=I(`Trash2`,[[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6`,key:`4alrt4`}],[`path`,{d:`M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2`,key:`v07s0e`}],[`line`,{x1:`10`,x2:`10`,y1:`11`,y2:`17`,key:`1uufr5`}],[`line`,{x1:`14`,x2:`14`,y1:`11`,y2:`17`,key:`xtxkd`}]]),ja=I(`TriangleAlert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Ma=I(`Truck`,[[`path`,{d:`M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2`,key:`wrbu53`}],[`path`,{d:`M15 18H9`,key:`1lyqi6`}],[`path`,{d:`M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14`,key:`lysw3i`}],[`circle`,{cx:`17`,cy:`18`,r:`2`,key:`332jqn`}],[`circle`,{cx:`7`,cy:`18`,r:`2`,key:`19iecd`}]]),Na=I(`Undo2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5v0a5.5 5.5 0 0 1-5.5 5.5H11`,key:`llx8ln`}]]),Pa=I(`Unlink`,[[`path`,{d:`m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71`,key:`yqzxt4`}],[`path`,{d:`m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71`,key:`4qinb0`}],[`line`,{x1:`8`,x2:`8`,y1:`2`,y2:`5`,key:`1041cp`}],[`line`,{x1:`2`,x2:`5`,y1:`8`,y2:`8`,key:`14m1p5`}],[`line`,{x1:`16`,x2:`16`,y1:`19`,y2:`22`,key:`rzdirn`}],[`line`,{x1:`19`,x2:`22`,y1:`16`,y2:`16`,key:`ox905f`}]]),Fa=I(`Upload`,[[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`polyline`,{points:`17 8 12 3 7 8`,key:`t8dd8p`}],[`line`,{x1:`12`,x2:`12`,y1:`3`,y2:`15`,key:`widbto`}]]),Ia=I(`UserCheck`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`polyline`,{points:`16 11 18 13 22 9`,key:`1pwet4`}]]),La=I(`UserMinus`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]),Ra=I(`UserPlus`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`19`,x2:`19`,y1:`8`,y2:`14`,key:`1bvyxn`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]),za=I(`UserX`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`17`,x2:`22`,y1:`8`,y2:`13`,key:`3nzzx3`}],[`line`,{x1:`22`,x2:`17`,y1:`8`,y2:`13`,key:`1swrse`}]]),Ba=I(`User`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),Va=I(`UsersRound`,[[`path`,{d:`M18 21a8 8 0 0 0-16 0`,key:`3ypg7q`}],[`circle`,{cx:`10`,cy:`8`,r:`5`,key:`o932ke`}],[`path`,{d:`M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3`,key:`10s06x`}]]),Ha=I(`Users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`path`,{d:`M16 3.13a4 4 0 0 1 0 7.75`,key:`1da9ce`}]]),Ua=I(`WifiOff`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Wa=I(`Wifi`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M2 8.82a15 15 0 0 1 20 0`,key:`dnpr2z`}],[`path`,{d:`M5 12.859a10 10 0 0 1 14 0`,key:`1x1e6c`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}]]),Ga=I(`X`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),Ka=I(`Zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]);function qa({onVerified:e}){let t=F(),[n,r]=(0,g.useState)(``),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(!1),c=(0,g.useRef)(null);(0,g.useEffect)(()=>{c.current?.focus()},[]);function l(e){r(e.target.value.replace(/\D/g,``).slice(0,6)),a(``)}async function u(i){if(i.preventDefault(),n.length!==6){a(`Enter a 6-digit code`);return}s(!0),a(``);try{(await t.verify2fa(n)).verified?e():a(`Verification failed. Please try again.`)}catch(e){let t=e?.message||String(e);a(t===`2fa_required`?`Session expired`:t||`Verification failed`)}finally{s(!1),r(``)}}return(0,A.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,A.jsxs)(`div`,{className:`w-full max-w-sm rounded-lg bg-zinc-800 p-6 shadow-xl`,children:[(0,A.jsxs)(`div`,{className:`mb-4 flex items-center gap-3`,children:[(0,A.jsx)(Ta,{className:`h-6 w-6 text-cyan-400`}),(0,A.jsx)(`h2`,{className:`text-lg font-bold text-white`,children:`Two-Factor Authentication`})]}),(0,A.jsx)(`p`,{className:`mb-4 text-sm text-zinc-400`,children:`Enter the 6-digit code from your authenticator app to continue.`}),(0,A.jsxs)(`form`,{onSubmit:u,className:`space-y-4`,children:[(0,A.jsx)(`input`,{ref:c,type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,value:n,onChange:l,placeholder:`000000`,maxLength:6,className:`w-full rounded-lg border border-zinc-700 bg-zinc-900 px-4 py-3 text-center font-mono text-2xl tracking-[0.3em] text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`}),i&&(0,A.jsx)(`p`,{className:`text-sm text-red-400`,children:i}),(0,A.jsx)(`button`,{type:`submit`,disabled:o||n.length!==6,className:`w-full rounded-lg bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:o?`Verifying...`:`Verify`})]}),(0,A.jsxs)(`p`,{className:`mt-4 text-xs text-zinc-600`,children:[`Lost your authenticator? Run`,` `,(0,A.jsx)(`code`,{className:`text-zinc-500`,children:`sudo lamaste-reset-admin`}),` on the server.`]})]})})}var Ja=(0,g.createContext)(null),Ya=`lamaste:2fa-required`;function Xa({children:e}){let t=F(),n=j(),[r,i]=(0,g.useState)(!1),{data:a}=M({queryKey:[`settings-2fa`],queryFn:()=>t.get2faStatus(),staleTime:6e4,retry:!1}),o=a?.enabled??!1,s=(0,g.useCallback)(()=>{i(!0)},[]),c=(0,g.useCallback)(()=>{i(!1),n.invalidateQueries()},[n]);return(0,g.useEffect)(()=>{function e(){i(!0)}if(typeof window<`u`)return window.addEventListener(Ya,e),()=>window.removeEventListener(Ya,e)},[]),(0,A.jsxs)(Ja.Provider,{value:{is2faEnabled:o,is2faRequired:r,require2fa:s,clearRequirement:c},children:[e,r&&(0,A.jsx)(qa,{onVerified:c})]})}var Za=(0,g.createContext)(null);function z(){let e=(0,g.useContext)(Za);if(!e)throw Error(`useToast must be used within a ToastProvider`);return e}var Qa=0;function $a({children:e}){let[t,n]=(0,g.useState)([]),r=(0,g.useCallback)((e,t=`success`)=>{let r=++Qa;n(n=>[...n,{id:r,message:e,variant:t}]),setTimeout(()=>{n(e=>e.filter(e=>e.id!==r))},3e3)},[]),i=(0,g.useCallback)(e=>{n(t=>t.filter(t=>t.id!==e))},[]);return(0,A.jsxs)(Za.Provider,{value:r,children:[e,(0,A.jsx)(`div`,{className:`fixed bottom-4 right-4 z-50 flex flex-col gap-2`,children:t.map(e=>(0,A.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border px-4 py-3 text-sm font-mono shadow-lg ${e.variant===`error`?`bg-red-500/10 border-red-500/20 text-red-400`:`bg-green-500/10 border-green-500/20 text-green-400`}`,children:[(0,A.jsx)(`span`,{className:`flex-1`,children:e.message}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>i(e.id),className:`text-zinc-500 hover:text-zinc-300`,children:(0,A.jsx)(Ga,{size:14})})]},e.id))})]})}function eo(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`&&e.id!==``&&typeof e.secret==`string`&&e.secret!==``).map(({id:e,secret:t})=>({id:e,secret:t})):[]}function to(e){if(typeof e!=`object`||!e)return{result:e,secrets:[]};let{oidcClients:t,...n}=e;return{result:n,secrets:eo(t)}}function no(e,t){return e.status===`running`?null:t===`reading`?`reading`:e.revealPending===!0?t===`followed`?`read`:`offer`:t===`followed`?`forget`:null}function ro(e,t){return e?.operations?{...e,operations:e.operations.map(e=>e.id===t?{...e,revealPending:!1}:e)}:e}var io={next:1,queue:[]};function ao(e,t){switch(t.type){case`reveal`:{let n=eo(t.secrets);if(n.length===0)return e;let r={key:e.next,plugin:t.plugin,cause:t.cause,secrets:n};return{next:e.next+1,queue:[...e.queue,r]}}case`acknowledge`:return e.queue[0]?.key===t.key?{...e,queue:e.queue.slice(1)}:e;default:return e}}var oo={install:`Installing`,enable:`Enabling`,update:`Updating`};function so({plugin:e,cause:t,secrets:n}){let r=n.length===1?`a confidential OIDC client`:`${n.length} confidential OIDC clients`,i=oo[t];return i?`${i} ${e} created ${r}`:`An operation on ${e} created ${r}`}var co=(0,g.createContext)(null);function lo(){let e=(0,g.useContext)(co);if(!e)throw Error(`useOidcSecretReveal must be used within an OidcSecretRevealProvider`);return e}function uo({children:e}){let[t,n]=(0,g.useReducer)(ao,io),[r,i]=(0,g.useState)(()=>new Map),a=(0,g.useRef)(new Set),o=(0,g.useCallback)(({plugin:e,cause:t,secrets:r})=>n({type:`reveal`,plugin:e,cause:t,secrets:r}),[]),s=(0,g.useCallback)(e=>i(t=>new Map(t).set(e,`followed`)),[]),c=(0,g.useCallback)(e=>a.current.has(e)?!1:(a.current.add(e),i(t=>new Map(t).set(e,`reading`)),!0),[]),l=(0,g.useCallback)(e=>{a.current.delete(e),i(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),u=(0,g.useCallback)(e=>r.get(e),[r]),d=(0,g.useMemo)(()=>({reveal:o,followOperation:s,followState:u,claimOperation:c,releaseOperation:l}),[o,s,u,c,l]),f=t.queue[0]??null;return(0,g.useEffect)(()=>{if(!f)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[f]),(0,A.jsxs)(co.Provider,{value:d,children:[e,f&&(0,A.jsx)(po,{reveal:f,waiting:t.queue.length-1,onAcknowledge:()=>n({type:`acknowledge`,key:f.key})},f.key)]})}var fo=`button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])`;function po({reveal:e,waiting:t,onAcknowledge:n}){let[r,i]=(0,g.useState)(!1),a=(0,g.useRef)(null),o=(0,g.useId)(),s=(0,g.useId)(),c=e.secrets.length===1;return(0,g.useEffect)(()=>{a.current?.focus()},[]),(0,A.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4`,children:(0,A.jsxs)(`div`,{ref:a,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":o,"aria-describedby":s,tabIndex:-1,onKeyDown:e=>{if(e.key!==`Tab`||!a.current)return;let t=[...a.current.querySelectorAll(fo)];if(t.length===0)return;let n=t[0],r=t[t.length-1],i=document.activeElement;e.shiftKey&&(i===n||i===a.current)?(e.preventDefault(),r.focus()):!e.shiftKey&&i===r&&(e.preventDefault(),n.focus())},className:`flex max-h-full w-full max-w-lg flex-col rounded-lg border border-zinc-800 bg-zinc-900 shadow-xl focus:outline-none`,children:[(0,A.jsxs)(`div`,{className:`border-b border-zinc-800 px-6 py-4`,children:[(0,A.jsxs)(`h3`,{id:o,className:`flex items-center gap-2 text-lg font-semibold text-white`,children:[(0,A.jsx)(qi,{size:20,className:`text-cyan-400`}),c?`Client secret`:`Client secrets`,` — shown once`]}),(0,A.jsxs)(`p`,{className:`mt-1 text-sm text-zinc-400`,children:[so(e),`.`]})]}),(0,A.jsxs)(`div`,{className:`space-y-5 overflow-y-auto px-6 py-5`,children:[(0,A.jsxs)(`div`,{id:s,className:`space-y-1 rounded-lg border border-amber-500/20 bg-amber-500/10 p-4 text-sm text-amber-400`,children:[(0,A.jsxs)(`p`,{className:`font-semibold`,children:[`Store `,c?`this secret`:`these secrets`,` now — Lamaste never shows`,` `,c?`it`:`them`,` again.`]}),(0,A.jsxs)(`p`,{children:[`Copy `,c?`it`:`each one`,` into the application that authenticates with`,` `,c?`it`:`them`,`, or into your password manager. A secret that was not stored can only be replaced:`,` `,(0,A.jsx)(`code`,{className:`font-mono text-xs text-amber-300`,children:`lamaste-server plugins rotate-secret <plugin> <client id>`})]})]}),e.secrets.map(({id:e,secret:t})=>(0,A.jsx)(mo,{clientId:e,secret:t},e)),(0,A.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-zinc-300`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>i(e.target.checked),className:`accent-cyan-500`}),`I have stored `,c?`this secret`:`these secrets`]}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,A.jsx)(`span`,{className:`text-xs text-zinc-500`,children:t>0&&`${t} more to show after this`}),(0,A.jsx)(`button`,{type:`button`,disabled:!r,onClick:n,className:`rounded 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:`Done`})]})]})]})})}function mo({clientId:e,secret:t}){let[n,r]=(0,g.useState)(`idle`),i=(0,g.useRef)(null),a=(0,g.useRef)(null);return(0,g.useEffect)(()=>()=>clearTimeout(a.current),[]),(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`div`,{className:`mb-1 flex items-baseline gap-2 text-sm`,children:[(0,A.jsx)(`span`,{className:`shrink-0 text-zinc-500`,children:`Client ID`}),(0,A.jsx)(`span`,{className:`select-all break-all font-mono text-zinc-200`,children:e})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`div`,{ref:i,className:`flex-1 select-all break-all rounded border border-zinc-700 bg-zinc-950 p-3 font-mono text-sm text-yellow-400`,children:t}),(0,A.jsx)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(t),r(`copied`),clearTimeout(a.current),a.current=setTimeout(()=>r(`idle`),2e3)}catch{let e=document.createRange();e.selectNodeContents(i.current);let t=window.getSelection();t.removeAllRanges(),t.addRange(e),r(`failed`)}},title:`Copy the secret`,"aria-label":`Copy the secret of ${e}`,className:`shrink-0 rounded bg-zinc-700 p-2 text-zinc-300 hover:bg-zinc-600`,children:n===`copied`?(0,A.jsx)(gi,{size:16,className:`text-green-400`}):(0,A.jsx)(Di,{size:16})})]}),n===`failed`&&(0,A.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:`Copying is not available here — the secret is selected; copy it with ⌘C or Ctrl+C.`})]})}function ho(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function go(e){return new Date(e).toLocaleString()}function _o({currentPath:e,onNavigate:t}){let n=e===`.`?[]:e.split(`/`);return(0,A.jsxs)(`div`,{className:`flex items-center gap-1 text-sm text-zinc-400 overflow-x-auto`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>t(`.`),className:`flex items-center gap-1 hover:text-cyan-400 shrink-0`,children:(0,A.jsx)(Gi,{size:14})}),n.map((e,r)=>{let i=n.slice(0,r+1).join(`/`),a=r===n.length-1;return(0,A.jsxs)(`span`,{className:`flex items-center gap-1 shrink-0`,children:[(0,A.jsx)(yi,{size:12,className:`text-zinc-600`}),a?(0,A.jsx)(`span`,{className:`text-zinc-200`,children:e}):(0,A.jsx)(`button`,{type:`button`,onClick:()=>t(i),className:`hover:text-cyan-400`,children:e})]},i)})]})}function vo({fileName:e,onConfirm:t,onCancel:n,isPending:r}){return(0,A.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:(0,A.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,A.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:`Delete File`}),(0,A.jsxs)(`p`,{className:`text-zinc-400 text-sm mb-6`,children:[`Are you sure you want to delete`,` `,(0,A.jsx)(`span`,{className:`text-cyan-400 font-mono`,children:e}),`?`]}),(0,A.jsxs)(`div`,{className:`flex items-center justify-end gap-3`,children:[(0,A.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,A.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,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{size:14,className:`animate-spin`}),`Deleting...`]}):`Delete`})]})]})})}function yo({site:e,onBack:t}){let n=F(),r=j(),i=z(),a=(0,g.useRef)(null),[o,s]=(0,g.useState)(`.`),[c,l]=(0,g.useState)(null),u=M({queryKey:[`site-files`,e.id,o],queryFn:()=>n.getSiteFiles(e.id,o),refetchInterval:5e3}),d=N({mutationFn:({files:t})=>n.uploadSiteFiles(e.id,o,t),onSuccess:t=>{r.invalidateQueries({queryKey:[`site-files`,e.id]}),r.invalidateQueries({queryKey:[`sites`]});let n=t?.files?.length??0;i(t?.warning?`${n} file(s) uploaded. ${t.warning}`:`${n} file(s) uploaded`)},onError:e=>{i(e?.message||String(e),`error`)}}),f=N({mutationFn:t=>n.deleteSiteFile(e.id,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`site-files`,e.id]}),r.invalidateQueries({queryKey:[`sites`]}),i(`File deleted`),l(null)},onError:e=>{i(e?.message||String(e),`error`),l(null)}}),p=(0,g.useCallback)(e=>{s(e)},[]),m=(0,g.useCallback)(e=>{e.type===`directory`&&s(e.relativePath)},[]),h=(0,g.useCallback)(()=>{a.current?.click()},[]),_=(0,g.useCallback)(e=>{let t=Array.from(e.target.files||[]);t.length>0&&d.mutate({files:t}),e.target.value=``},[d]),v=u.data?.files||[];return(0,A.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,A.jsxs)(`div`,{className:`mb-6`,children:[(0,A.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-2 text-sm text-zinc-400 hover:text-zinc-200 mb-3`,children:[(0,A.jsx)(li,{size:14}),`Back to Sites`]}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`h1`,{className:`text-xl font-bold text-white`,children:[e.name,(0,A.jsx)(`span`,{className:`text-zinc-500 font-normal ml-2 text-base`,children:`Files`})]}),(0,A.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1 font-mono`,children:e.fqdn})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`input`,{ref:a,type:`file`,multiple:!0,onChange:_,className:`hidden`}),(0,A.jsx)(`button`,{type:`button`,onClick:h,disabled:d.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`,children:d.isPending?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{size:14,className:`animate-spin`}),`Uploading...`]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(Fa,{size:14}),`Upload`]})})]})]})]}),(0,A.jsx)(`div`,{className:`bg-zinc-900 border border-zinc-800 rounded-t-lg px-4 py-3`,children:(0,A.jsx)(_o,{currentPath:o,onNavigate:p})}),u.isLoading?(0,A.jsx)(`div`,{className:`bg-zinc-900 border border-t-0 border-zinc-800 rounded-b-lg p-8 text-center`,children:(0,A.jsx)(L,{size:24,className:`mx-auto text-zinc-500 animate-spin`})}):u.isError?(0,A.jsx)(`div`,{className:`bg-zinc-900 border border-t-0 border-zinc-800 rounded-b-lg p-6`,children:(0,A.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Failed to load files`})}):v.length===0?(0,A.jsx)(`div`,{className:`bg-zinc-900 border border-t-0 border-zinc-800 rounded-b-lg p-8 text-center`,children:(0,A.jsx)(`p`,{className:`text-zinc-500 text-sm`,children:`This directory is empty.`})}):(0,A.jsx)(`div`,{className:`bg-zinc-900 border border-t-0 border-zinc-800 rounded-b-lg overflow-x-auto`,children:(0,A.jsxs)(`table`,{className:`w-full`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`border-b border-zinc-800`,children:[(0,A.jsx)(`th`,{className:`text-left text-zinc-500 text-xs uppercase font-semibold py-2 px-4`,children:`Name`}),(0,A.jsx)(`th`,{className:`text-left text-zinc-500 text-xs uppercase font-semibold py-2 px-4 hidden sm:table-cell`,children:`Size`}),(0,A.jsx)(`th`,{className:`text-left text-zinc-500 text-xs uppercase font-semibold py-2 px-4 hidden md:table-cell`,children:`Modified`}),(0,A.jsx)(`th`,{className:`text-right text-zinc-500 text-xs uppercase font-semibold py-2 px-4 w-16`})]})}),(0,A.jsx)(`tbody`,{children:v.map(e=>(0,A.jsxs)(`tr`,{className:`border-b border-zinc-800/50 ${e.type===`directory`?`cursor-pointer hover:bg-zinc-800/50`:``}`,onClick:()=>m(e),children:[(0,A.jsx)(`td`,{className:`py-2.5 px-4 text-sm`,children:(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[e.type===`directory`?(0,A.jsx)(Bi,{size:14,className:`text-cyan-400 shrink-0`}):(0,A.jsx)(Li,{size:14,className:`text-zinc-500 shrink-0`}),(0,A.jsx)(`span`,{className:`font-mono ${e.type===`directory`?`text-cyan-400`:`text-zinc-200`}`,children:e.name})]})}),(0,A.jsx)(`td`,{className:`py-2.5 px-4 text-sm text-zinc-500 font-mono hidden sm:table-cell`,children:e.type===`file`?ho(e.size):`—`}),(0,A.jsx)(`td`,{className:`py-2.5 px-4 text-sm text-zinc-600 hidden md:table-cell`,children:go(e.modifiedAt)}),(0,A.jsx)(`td`,{className:`py-2.5 px-4 text-right`,children:(0,A.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),l(e)},className:`inline-flex items-center p-1 text-zinc-600 hover:text-red-400`,title:`Delete`,children:(0,A.jsx)(R,{size:14})})})]},e.relativePath))})]})}),c&&(0,A.jsx)(vo,{fileName:c.name,onConfirm:()=>f.mutate(c.relativePath),onCancel:()=>l(null),isPending:f.isPending})]})}var bo={bg:`zinc-950`,card:`zinc-900`,accent:`cyan-400`,border:`zinc-800`},xo=1e4,So=3e4;function Co(e,t){e.textContent=``;let n=document.createElement(`div`);n.className=`flex items-center justify-center h-64`;let r=document.createElement(`p`);r.className=`text-zinc-500 text-sm`,r.textContent=t,n.appendChild(r),e.appendChild(n)}function wo(e,t){return e?.plugins?.find(e=>e.name===t)}function To({availability:e}){return(0,A.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,A.jsxs)(`div`,{className:`flex items-start gap-3`,children:[e.state===`offline`?(0,A.jsx)(Ua,{size:18,className:`mt-0.5 shrink-0 text-red-400`}):(0,A.jsx)(ba,{size:18,className:`mt-0.5 shrink-0 text-zinc-500`}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`text-sm text-zinc-200`,children:e.message}),(0,A.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:`Its pages come from its agent half. This page checks every 10 seconds and opens them once the hosting is up.`})]})]})})}function Eo({pluginName:e,subPath:t=``,basePath:n,panelUrl:r}){let i=F(),a=(0,g.useRef)(null),o=M({queryKey:[`plugins`],queryFn:()=>i.getPlugins(),refetchInterval:t=>Tr(wo(t.state.data,e),Date.now()).state===`mount`?So:xo}),s=o.data?Tr(wo(o.data,e),o.dataUpdatedAt):o.isError?{state:`mount`}:{state:`checking`},[c,l]=(0,g.useState)(null);s.state===`mount`&&c!==e&&l(e);let u=s.state===`mount`||c===e;return(0,g.useEffect)(()=>{let o=a.current;if(!e||!u||!o)return;let s=!1,c=null,l=()=>{let i=window.__lamalibrePlugins?.[e];if(!i||typeof i.mount!=`function`)throw Error(`The plugin bundle registered no panel`);o.textContent=``;let a=i.mount({mountPoint:o,panelUrl:r||window.location.origin,basePath:n||`/plugins/${e}`,subPath:t||``,theme:bo});a&&typeof a.unmount==`function`?c=a.unmount:typeof a==`function`&&(c=a)},d=()=>{s||Co(o,`Failed to load plugin panel for "${e}"`)};if(window.__lamalibrePlugins?.[e])try{l()}catch{d()}else Co(o,`Loading plugin...`),i.fetchPluginBundle(e).then(e=>{if(!s)try{window.__lamalibrePlugins||(window.__lamalibrePlugins={}),Function(e)(),l()}catch{d()}},d);return()=>{s=!0,c&&c()}},[e,t,n,r,i,u]),(0,A.jsxs)(`div`,{className:`p-6 max-w-6xl mx-auto`,children:[!u&&s.state===`checking`&&(0,A.jsx)(`div`,{className:`flex items-center justify-center h-64`,children:(0,A.jsx)(`p`,{className:`text-zinc-500 text-sm`,children:`Loading plugin...`})}),!u&&(s.state===`offline`||s.state===`waiting`)&&(0,A.jsx)(To,{availability:s}),u&&(s.state===`offline`||s.state===`waiting`)&&(0,A.jsxs)(`div`,{className:`mb-4 flex items-start gap-2 rounded border px-3 py-2 text-xs ${s.state===`offline`?`border-red-500/30 text-red-400`:`border-zinc-700 text-zinc-400`}`,children:[(0,A.jsx)(Ua,{size:12,className:`mt-0.5 shrink-0`}),(0,A.jsxs)(`span`,{children:[s.message,` — this page cannot reach its agent half until the hosting is up again.`]})]}),u&&(0,A.jsx)(`div`,{ref:a,className:`min-h-64`,"data-plugin":e})]})}function Do({icon:e,label:t,value:n,isLoading:r,isError:i}){return(0,A.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:[(0,A.jsx)(e,{size:20,className:`text-cyan-400 mb-2`}),(0,A.jsx)(`p`,{className:`text-zinc-400 text-sm mb-1`,children:t}),r?(0,A.jsx)(`div`,{className:`h-7 w-24 animate-pulse rounded bg-zinc-700`}):i?(0,A.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Error`}):(0,A.jsx)(`p`,{className:`text-xl font-semibold text-white`,children:n})]})}function Oo({status:e}){return(0,A.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full ${e===`active`?`bg-green-500`:e===`failed`?`bg-red-500`:`bg-zinc-500`}`})}function ko(){let e=F(),t=M({queryKey:[`system-stats`],queryFn:()=>e.getSystemStats(),refetchInterval:5e3}),n=M({queryKey:[`services`],queryFn:()=>e.getServices(),refetchInterval:5e3}),r=t.data,i=n.data?.services;return(0,A.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,A.jsxs)(`div`,{className:`mb-6`,children:[(0,A.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Dashboard`}),(0,A.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`System overview and service health`})]}),(0,A.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4 mb-8`,children:[(0,A.jsx)(Do,{icon:Oi,label:`CPU Usage`,value:r?`${r.cpu.usage}%`:`—`,isLoading:t.isLoading,isError:t.isError}),(0,A.jsx)(Do,{icon:ki,label:`Memory Usage`,value:r?`${vr(r.memory.used)} / ${vr(r.memory.total)}`:`—`,isLoading:t.isLoading,isError:t.isError}),(0,A.jsx)(Do,{icon:Ui,label:`Disk Usage`,value:r?`${vr(r.disk.used)} / ${vr(r.disk.total)}`:`—`,isLoading:t.isLoading,isError:t.isError}),(0,A.jsx)(Do,{icon:Ei,label:`Uptime`,value:r?yr(r.uptime):`—`,isLoading:t.isLoading,isError:t.isError})]}),(0,A.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6 mb-8`,children:[(0,A.jsxs)(`h2`,{className:`text-sm font-semibold text-zinc-300 mb-4 flex items-center gap-2`,children:[(0,A.jsx)(oi,{size:14,className:`text-cyan-400`}),`Service Health`]}),n.isLoading?(0,A.jsx)(`div`,{className:`flex gap-6 flex-wrap`,children:Array.from({length:4}).map((e,t)=>(0,A.jsx)(`div`,{className:`h-5 w-28 animate-pulse rounded bg-zinc-700`},t))}):n.isError?(0,A.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Failed to load service status`}):(0,A.jsx)(`div`,{className:`flex gap-6 flex-wrap`,children:i?.map(e=>(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(Oo,{status:e.status}),(0,A.jsx)(`span`,{className:`text-zinc-300 text-sm`,children:e.name})]},e.name))})]}),(0,A.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:[(0,A.jsxs)(`h2`,{className:`text-sm font-semibold text-zinc-300 mb-4 flex items-center gap-2`,children:[(0,A.jsx)(oi,{size:14,className:`text-cyan-400`}),`Quick Overview`]}),(0,A.jsxs)(`div`,{className:`flex gap-8 flex-wrap text-sm`,children:[(0,A.jsxs)(`div`,{className:`text-zinc-400`,children:[`Active Services:`,` `,(0,A.jsx)(`span`,{className:`text-white`,children:i?i.filter(e=>e.status===`active`).length:`—`})]}),(0,A.jsxs)(`div`,{className:`text-zinc-400`,children:[`Total Services: `,(0,A.jsx)(`span`,{className:`text-white`,children:i?i.length:`—`})]})]})]})]})}function B(e){return typeof e==`string`?e||`An unknown error occurred`:e instanceof Error?e.message||`An unknown error occurred`:String(e??`An unknown error occurred`)||`An unknown error occurred`}function Ao(e){return typeof e!=`object`||!e?{code:null,reasons:[]}:{code:typeof e.code==`string`?e.code:null,reasons:Array.isArray(e.reasons)?e.reasons.filter(e=>typeof e==`string`):[]}}function jo({status:e}){let t=e===`active`?`bg-green-500/20 text-green-400`:e===`failed`?`bg-red-500/20 text-red-400`:`bg-zinc-500/20 text-zinc-400`,n=e===`active`?`Active`:e===`failed`?`Failed`:e===`inactive`?`Inactive`:`Unknown`;return(0,A.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full ${t}`,children:n})}function Mo({service:e,onAction:t,isActing:n}){let[r,i]=(0,g.useState)(!1),a=e.name===`lamalibre-lamaste-serverd`,o=()=>{if(!a){if(!r){i(!0);return}i(!1),t(e.name,`stop`)}};return(0,A.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-5`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(xa,{size:16,className:`text-cyan-400`}),(0,A.jsx)(`span`,{className:`text-white font-semibold`,children:e.name})]}),(0,A.jsx)(jo,{status:e.status})]}),(0,A.jsx)(`p`,{className:`text-zinc-400 text-sm mb-4`,children:e.status===`active`&&e.uptime?`Uptime: ${e.uptime}`:`—`}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>t(e.name,`start`),className:`flex items-center gap-1.5 rounded bg-zinc-700 px-3 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,A.jsx)(la,{size:12}),`Start`]}),r?(0,A.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,A.jsx)(`span`,{className:`text-zinc-400`,children:`Stop?`}),(0,A.jsx)(`button`,{type:`button`,onClick:o,className:`rounded bg-red-600 px-2 py-1 text-white hover:bg-red-500`,children:`Yes`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>i(!1),className:`rounded bg-zinc-700 px-2 py-1 text-zinc-300 hover:bg-zinc-600`,children:`No`})]}):(0,A.jsxs)(`button`,{type:`button`,disabled:n||a,onClick:o,title:a?`Cannot stop panel service`:`Stop service`,className:`flex items-center gap-1.5 rounded bg-zinc-700 px-3 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,A.jsx)(Oa,{size:12}),`Stop`]}),(0,A.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>t(e.name,`restart`),className:`flex items-center gap-1.5 rounded bg-zinc-700 px-3 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,A.jsx)(ga,{size:12}),`Restart`]})]})]})}var No=1e3;function Po({services:e}){let t=F(),[n,r]=(0,g.useState)(``),[i,a]=(0,g.useState)([]),[o,s]=(0,g.useState)(null),c=(0,g.useRef)(null),l=(0,g.useRef)(null),u=(0,g.useCallback)(e=>{r(e.target.value),a([]),s(null)},[]);(0,g.useEffect)(()=>{let e=c.current;e&&(e.scrollTop=e.scrollHeight)},[i]),(0,g.useEffect)(()=>{if(l.current&&=(l.current(),null),n)return l.current=t.startLogStream(n,e=>{a(t=>{let n=[...t,e];return n.length>No?n.slice(-No):n})}),()=>{l.current&&=(l.current(),null)}},[n,t]);let d=e?.map(e=>e.name)||[];return(0,A.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-5`,children:[(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-300 mb-4`,children:`Service Logs`}),(0,A.jsxs)(`select`,{value:n,onChange:u,className:`mb-4 rounded bg-zinc-800 border border-zinc-700 px-3 py-1.5 text-sm text-zinc-300 focus:outline-none focus:border-cyan-400`,children:[(0,A.jsx)(`option`,{value:``,children:`Select a service...`}),d.map(e=>(0,A.jsx)(`option`,{value:e,children:e},e))]}),(0,A.jsx)(`div`,{ref:c,className:`h-96 overflow-y-auto rounded-lg border border-zinc-800 bg-zinc-950 p-4 font-mono text-sm`,children:n?o?(0,A.jsx)(`p`,{className:`text-red-400`,children:o}):i.length===0?(0,A.jsx)(`p`,{className:`text-zinc-500 text-center mt-36`,children:`Waiting for log data...`}):i.map((e,t)=>(0,A.jsxs)(`div`,{className:`leading-relaxed`,children:[e.timestamp&&(0,A.jsxs)(`span`,{className:`text-zinc-500`,children:[e.timestamp,` `]}),(0,A.jsx)(`span`,{className:`text-zinc-300`,children:e.message})]},t)):(0,A.jsx)(`p`,{className:`text-zinc-500 text-center mt-36`,children:`Select a service to view its logs`})})]})}function Fo(){let e=F(),t=j(),n=z(),r=M({queryKey:[`services`],queryFn:()=>e.getServices(),refetchInterval:5e3}),i=N({mutationFn:({name:t,action:n})=>e.serviceAction(t,n),onSuccess:e=>{t.invalidateQueries({queryKey:[`services`]}),n(`${e.name} ${e.action}ed successfully`)},onError:e=>{n(B(e),`error`)}}),a=(0,g.useCallback)((e,t)=>{i.mutate({name:e,action:t})},[i]),o=r.data?.services;return(0,A.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,A.jsxs)(`div`,{className:`mb-6`,children:[(0,A.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Services`}),(0,A.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`Manage system services and view live logs`})]}),r.isLoading?(0,A.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4 mb-8`,children:Array.from({length:4}).map((e,t)=>(0,A.jsx)(`div`,{className:`h-40 animate-pulse rounded-lg bg-zinc-900 border border-zinc-800`},t))}):r.isError?(0,A.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6 mb-8`,children:(0,A.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Failed to load services`})}):(0,A.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4 mb-8`,children:o?.map(e=>(0,A.jsx)(Mo,{service:e,onAction:a,isActing:i.isPending},e.name))}),(0,A.jsx)(Po,{services:o})]})}var V;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(V||={});var Io;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(Io||={});var H=V.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),Lo=e=>{switch(typeof e){case`undefined`:return H.undefined;case`string`:return H.string;case`number`:return Number.isNaN(e)?H.nan:H.number;case`boolean`:return H.boolean;case`function`:return H.function;case`bigint`:return H.bigint;case`symbol`:return H.symbol;case`object`:return Array.isArray(e)?H.array:e===null?H.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?H.promise:typeof Map<`u`&&e instanceof Map?H.map:typeof Set<`u`&&e instanceof Set?H.set:typeof Date<`u`&&e instanceof Date?H.date:H.object;default:return H.unknown}},U=V.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),Ro=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,V.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};Ro.create=e=>new Ro(e);var zo=(e,t)=>{let n;switch(e.code){case U.invalid_type:n=e.received===H.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case U.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,V.jsonStringifyReplacer)}`;break;case U.unrecognized_keys:n=`Unrecognized key(s) in object: ${V.joinValues(e.keys,`, `)}`;break;case U.invalid_union:n=`Invalid input`;break;case U.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${V.joinValues(e.options)}`;break;case U.invalid_enum_value:n=`Invalid enum value. Expected ${V.joinValues(e.options)}, received '${e.received}'`;break;case U.invalid_arguments:n=`Invalid function arguments`;break;case U.invalid_return_type:n=`Invalid function return type`;break;case U.invalid_date:n=`Invalid date`;break;case U.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:V.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case U.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case U.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case U.custom:n=`Invalid input`;break;case U.invalid_intersection_types:n=`Intersection results could not be merged`;break;case U.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case U.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,V.assertNever(e)}return{message:n}},Bo=zo;function Vo(){return Bo}var Ho=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function W(e,t){let n=Vo(),r=Ho({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===zo?void 0:zo].filter(e=>!!e)});e.common.issues.push(r)}var Uo=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return G;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return G;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},G=Object.freeze({status:`aborted`}),Wo=e=>({status:`dirty`,value:e}),Go=e=>({status:`valid`,value:e}),Ko=e=>e.status===`aborted`,qo=e=>e.status===`dirty`,Jo=e=>e.status===`valid`,Yo=e=>typeof Promise<`u`&&e instanceof Promise,K;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(K||={});var Xo=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Zo=(e,t)=>{if(Jo(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new Ro(e.common.issues);return this._error=t,this._error}}};function q(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var J=class{get description(){return this._def.description}_getType(e){return Lo(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Lo(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Uo,ctx:{common:e.parent.common,data:e.data,parsedType:Lo(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(Yo(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Lo(e)};return Zo(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Lo(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return Jo(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>Jo(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Lo(e)},r=this._parse({data:e,path:n.path,parent:n});return Zo(n,await(Yo(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:U.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new ec({schema:this,typeName:Y.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return tc.create(this,this._def)}nullable(){return nc.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Fs.create(this)}promise(){return $s.create(this,this._def)}or(e){return Rs.create([this,e],this._def)}and(e){return Hs.create(this,e,this._def)}transform(e){return new ec({...q(this._def),schema:this,typeName:Y.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new rc({...q(this._def),innerType:this,defaultValue:t,typeName:Y.ZodDefault})}brand(){return new oc({typeName:Y.ZodBranded,type:this,...q(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new ic({...q(this._def),innerType:this,catchValue:t,typeName:Y.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return sc.create(this,e)}readonly(){return cc.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Qo=/^c[^\s-]{8,}$/i,$o=/^[0-9a-z]+$/,es=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ts=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,ns=/^[a-z0-9_-]{21}$/i,rs=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,is=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,as=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,os=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,ss,cs=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ls=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,us=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,ds=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,fs=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ps=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ms=`((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`,hs=RegExp(`^${ms}$`);function gs(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function _s(e){return RegExp(`^${gs(e)}$`)}function vs(e){let t=`${ms}T${gs(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function ys(e,t){return!!((t===`v4`||!t)&&cs.test(e)||(t===`v6`||!t)&&us.test(e))}function bs(e,t){if(!rs.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function xs(e,t){return!!((t===`v4`||!t)&&ls.test(e)||(t===`v6`||!t)&&ds.test(e))}var Ss=class e extends J{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==H.string){let t=this._getOrReturnCtx(e);return W(t,{code:U.invalid_type,expected:H.string,received:t.parsedType}),G}let t=new Uo,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),W(n,{code:U.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),W(n,{code:U.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?W(n,{code:U.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&W(n,{code:U.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)as.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`email`,code:U.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)ss||=new RegExp(os,`u`),ss.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`emoji`,code:U.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)ts.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`uuid`,code:U.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)ns.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`nanoid`,code:U.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)Qo.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`cuid`,code:U.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)$o.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`cuid2`,code:U.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)es.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`ulid`,code:U.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),W(n,{validation:`url`,code:U.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`regex`,code:U.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),W(n,{code:U.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),W(n,{code:U.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),W(n,{code:U.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?vs(r).test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:U.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?hs.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:U.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?_s(r).test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:U.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?is.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`duration`,code:U.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?ys(e.data,r.version)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`ip`,code:U.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?bs(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`jwt`,code:U.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?xs(e.data,r.version)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`cidr`,code:U.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?fs.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`base64`,code:U.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?ps.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`base64url`,code:U.invalid_string,message:r.message}),t.dirty()):V.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:U.invalid_string,...K.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...K.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...K.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...K.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...K.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...K.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...K.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...K.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...K.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...K.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...K.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...K.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...K.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...K.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...K.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...K.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...K.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...K.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...K.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...K.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...K.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...K.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...K.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...K.errToObj(t)})}nonempty(e){return this.min(1,K.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Ss.create=e=>new Ss({checks:[],typeName:Y.ZodString,coerce:e?.coerce??!1,...q(e)});function Cs(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var ws=class e extends J{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==H.number){let t=this._getOrReturnCtx(e);return W(t,{code:U.invalid_type,expected:H.number,received:t.parsedType}),G}let t,n=new Uo;for(let r of this._def.checks)r.kind===`int`?V.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),W(t,{code:U.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),W(t,{code:U.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),W(t,{code:U.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?Cs(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),W(t,{code:U.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),W(t,{code:U.not_finite,message:r.message}),n.dirty()):V.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,K.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,K.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,K.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,K.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:K.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:K.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:K.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:K.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:K.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:K.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:K.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:K.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:K.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:K.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&V.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};ws.create=e=>new ws({checks:[],typeName:Y.ZodNumber,coerce:e?.coerce||!1,...q(e)});var Ts=class e extends J{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==H.bigint)return this._getInvalidInput(e);let t,n=new Uo;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),W(t,{code:U.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),W(t,{code:U.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),W(t,{code:U.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):V.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return W(t,{code:U.invalid_type,expected:H.bigint,received:t.parsedType}),G}gte(e,t){return this.setLimit(`min`,e,!0,K.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,K.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,K.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,K.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:K.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:K.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:K.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:K.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:K.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:K.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Ts.create=e=>new Ts({checks:[],typeName:Y.ZodBigInt,coerce:e?.coerce??!1,...q(e)});var Es=class extends J{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==H.boolean){let t=this._getOrReturnCtx(e);return W(t,{code:U.invalid_type,expected:H.boolean,received:t.parsedType}),G}return Go(e.data)}};Es.create=e=>new Es({typeName:Y.ZodBoolean,coerce:e?.coerce||!1,...q(e)});var Ds=class e extends J{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==H.date){let t=this._getOrReturnCtx(e);return W(t,{code:U.invalid_type,expected:H.date,received:t.parsedType}),G}if(Number.isNaN(e.data.getTime()))return W(this._getOrReturnCtx(e),{code:U.invalid_date}),G;let t=new Uo,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),W(n,{code:U.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),W(n,{code:U.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):V.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:K.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:K.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};Ds.create=e=>new Ds({checks:[],coerce:e?.coerce||!1,typeName:Y.ZodDate,...q(e)});var Os=class extends J{_parse(e){if(this._getType(e)!==H.symbol){let t=this._getOrReturnCtx(e);return W(t,{code:U.invalid_type,expected:H.symbol,received:t.parsedType}),G}return Go(e.data)}};Os.create=e=>new Os({typeName:Y.ZodSymbol,...q(e)});var ks=class extends J{_parse(e){if(this._getType(e)!==H.undefined){let t=this._getOrReturnCtx(e);return W(t,{code:U.invalid_type,expected:H.undefined,received:t.parsedType}),G}return Go(e.data)}};ks.create=e=>new ks({typeName:Y.ZodUndefined,...q(e)});var As=class extends J{_parse(e){if(this._getType(e)!==H.null){let t=this._getOrReturnCtx(e);return W(t,{code:U.invalid_type,expected:H.null,received:t.parsedType}),G}return Go(e.data)}};As.create=e=>new As({typeName:Y.ZodNull,...q(e)});var js=class extends J{constructor(){super(...arguments),this._any=!0}_parse(e){return Go(e.data)}};js.create=e=>new js({typeName:Y.ZodAny,...q(e)});var Ms=class extends J{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Go(e.data)}};Ms.create=e=>new Ms({typeName:Y.ZodUnknown,...q(e)});var Ns=class extends J{_parse(e){let t=this._getOrReturnCtx(e);return W(t,{code:U.invalid_type,expected:H.never,received:t.parsedType}),G}};Ns.create=e=>new Ns({typeName:Y.ZodNever,...q(e)});var Ps=class extends J{_parse(e){if(this._getType(e)!==H.undefined){let t=this._getOrReturnCtx(e);return W(t,{code:U.invalid_type,expected:H.void,received:t.parsedType}),G}return Go(e.data)}};Ps.create=e=>new Ps({typeName:Y.ZodVoid,...q(e)});var Fs=class e extends J{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==H.array)return W(t,{code:U.invalid_type,expected:H.array,received:t.parsedType}),G;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(W(t,{code:e?U.too_big:U.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(W(t,{code:U.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(W(t,{code:U.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new Xo(t,e,t.path,n)))).then(e=>Uo.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new Xo(t,e,t.path,n)));return Uo.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:K.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:K.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:K.toString(n)}})}nonempty(e){return this.min(1,e)}};Fs.create=(e,t)=>new Fs({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Y.ZodArray,...q(t)});function Is(e){if(e instanceof Ls){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=tc.create(Is(r))}return new Ls({...e._def,shape:()=>t})}else if(e instanceof Fs)return new Fs({...e._def,type:Is(e.element)});else if(e instanceof tc)return tc.create(Is(e.unwrap()));else if(e instanceof nc)return nc.create(Is(e.unwrap()));else if(e instanceof Us)return Us.create(e.items.map(e=>Is(e)));else return e}var Ls=class e extends J{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=V.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==H.object){let t=this._getOrReturnCtx(e);return W(t,{code:U.invalid_type,expected:H.object,received:t.parsedType}),G}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Ns&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new Xo(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof Ns){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(W(n,{code:U.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new Xo(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>Uo.mergeObjectSync(t,e)):Uo.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return K.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:K.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Y.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of V.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of V.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return Is(this)}partial(t){let n={};for(let e of V.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of V.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof tc;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return Xs(V.objectKeys(this.shape))}};Ls.create=(e,t)=>new Ls({shape:()=>e,unknownKeys:`strip`,catchall:Ns.create(),typeName:Y.ZodObject,...q(t)}),Ls.strictCreate=(e,t)=>new Ls({shape:()=>e,unknownKeys:`strict`,catchall:Ns.create(),typeName:Y.ZodObject,...q(t)}),Ls.lazycreate=(e,t)=>new Ls({shape:e,unknownKeys:`strip`,catchall:Ns.create(),typeName:Y.ZodObject,...q(t)});var Rs=class extends J{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new Ro(e.ctx.common.issues));return W(t,{code:U.invalid_union,unionErrors:n}),G}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new Ro(e));return W(t,{code:U.invalid_union,unionErrors:i}),G}}get options(){return this._def.options}};Rs.create=(e,t)=>new Rs({options:e,typeName:Y.ZodUnion,...q(t)});var zs=e=>e instanceof Js?zs(e.schema):e instanceof ec?zs(e.innerType()):e instanceof Ys?[e.value]:e instanceof Zs?e.options:e instanceof Qs?V.objectValues(e.enum):e instanceof rc?zs(e._def.innerType):e instanceof ks?[void 0]:e instanceof As?[null]:e instanceof tc?[void 0,...zs(e.unwrap())]:e instanceof nc?[null,...zs(e.unwrap())]:e instanceof oc||e instanceof cc?zs(e.unwrap()):e instanceof ic?zs(e._def.innerType):[],Bs=class e extends J{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==H.object)return W(t,{code:U.invalid_type,expected:H.object,received:t.parsedType}),G;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(W(t,{code:U.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),G)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=zs(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:Y.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...q(r)})}};function Vs(e,t){let n=Lo(e),r=Lo(t);if(e===t)return{valid:!0,data:e};if(n===H.object&&r===H.object){let n=V.objectKeys(t),r=V.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Vs(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===H.array&&r===H.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Vs(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===H.date&&r===H.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var Hs=class extends J{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(Ko(e)||Ko(r))return G;let i=Vs(e.value,r.value);return i.valid?((qo(e)||qo(r))&&t.dirty(),{status:t.value,value:i.data}):(W(n,{code:U.invalid_intersection_types}),G)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Hs.create=(e,t,n)=>new Hs({left:e,right:t,typeName:Y.ZodIntersection,...q(n)});var Us=class e extends J{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==H.array)return W(n,{code:U.invalid_type,expected:H.array,received:n.parsedType}),G;if(n.data.length<this._def.items.length)return W(n,{code:U.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),G;!this._def.rest&&n.data.length>this._def.items.length&&(W(n,{code:U.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new Xo(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>Uo.mergeArray(t,e)):Uo.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Us.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new Us({items:e,typeName:Y.ZodTuple,rest:null,...q(t)})};var Ws=class e extends J{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==H.object)return W(n,{code:U.invalid_type,expected:H.object,received:n.parsedType}),G;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new Xo(n,e,n.path,e)),value:a._parse(new Xo(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?Uo.mergeObjectAsync(t,r):Uo.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof J?new e({keyType:t,valueType:n,typeName:Y.ZodRecord,...q(r)}):new e({keyType:Ss.create(),valueType:t,typeName:Y.ZodRecord,...q(n)})}},Gs=class extends J{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==H.map)return W(n,{code:U.invalid_type,expected:H.map,received:n.parsedType}),G;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new Xo(n,e,n.path,[a,`key`])),value:i._parse(new Xo(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return G;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return G;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Gs.create=(e,t,n)=>new Gs({valueType:t,keyType:e,typeName:Y.ZodMap,...q(n)});var Ks=class e extends J{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==H.set)return W(n,{code:U.invalid_type,expected:H.set,received:n.parsedType}),G;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(W(n,{code:U.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(W(n,{code:U.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return G;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new Xo(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:K.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:K.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Ks.create=(e,t)=>new Ks({valueType:e,minSize:null,maxSize:null,typeName:Y.ZodSet,...q(t)});var qs=class e extends J{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==H.function)return W(t,{code:U.invalid_type,expected:H.function,received:t.parsedType}),G;function n(e,n){return Ho({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Vo(),zo].filter(e=>!!e),issueData:{code:U.invalid_arguments,argumentsError:n}})}function r(e,n){return Ho({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Vo(),zo].filter(e=>!!e),issueData:{code:U.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof $s){let e=this;return Go(async function(...t){let o=new Ro([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return Go(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new Ro([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new Ro([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Us.create(t).rest(Ms.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||Us.create([]).rest(Ms.create()),returns:n||Ms.create(),typeName:Y.ZodFunction,...q(r)})}},Js=class extends J{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Js.create=(e,t)=>new Js({getter:e,typeName:Y.ZodLazy,...q(t)});var Ys=class extends J{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return W(t,{received:t.data,code:U.invalid_literal,expected:this._def.value}),G}return{status:`valid`,value:e.data}}get value(){return this._def.value}};Ys.create=(e,t)=>new Ys({value:e,typeName:Y.ZodLiteral,...q(t)});function Xs(e,t){return new Zs({values:e,typeName:Y.ZodEnum,...q(t)})}var Zs=class e extends J{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return W(t,{expected:V.joinValues(n),received:t.parsedType,code:U.invalid_type}),G}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return W(t,{received:t.data,code:U.invalid_enum_value,options:n}),G}return Go(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};Zs.create=Xs;var Qs=class extends J{_parse(e){let t=V.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==H.string&&n.parsedType!==H.number){let e=V.objectValues(t);return W(n,{expected:V.joinValues(e),received:n.parsedType,code:U.invalid_type}),G}if(this._cache||=new Set(V.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=V.objectValues(t);return W(n,{received:n.data,code:U.invalid_enum_value,options:e}),G}return Go(e.data)}get enum(){return this._def.values}};Qs.create=(e,t)=>new Qs({values:e,typeName:Y.ZodNativeEnum,...q(t)});var $s=class extends J{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==H.promise&&t.common.async===!1?(W(t,{code:U.invalid_type,expected:H.promise,received:t.parsedType}),G):Go((t.parsedType===H.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};$s.create=(e,t)=>new $s({type:e,typeName:Y.ZodPromise,...q(t)});var ec=class extends J{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{W(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return G;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?G:r.status===`dirty`||t.value===`dirty`?Wo(r.value):r});{if(t.value===`aborted`)return G;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?G:r.status===`dirty`||t.value===`dirty`?Wo(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?G:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?G:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Jo(e))return G;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>Jo(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):G);V.assertNever(r)}};ec.create=(e,t,n)=>new ec({schema:e,typeName:Y.ZodEffects,effect:t,...q(n)}),ec.createWithPreprocess=(e,t,n)=>new ec({schema:t,effect:{type:`preprocess`,transform:e},typeName:Y.ZodEffects,...q(n)});var tc=class extends J{_parse(e){return this._getType(e)===H.undefined?Go(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};tc.create=(e,t)=>new tc({innerType:e,typeName:Y.ZodOptional,...q(t)});var nc=class extends J{_parse(e){return this._getType(e)===H.null?Go(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};nc.create=(e,t)=>new nc({innerType:e,typeName:Y.ZodNullable,...q(t)});var rc=class extends J{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===H.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};rc.create=(e,t)=>new rc({innerType:e,typeName:Y.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...q(t)});var ic=class extends J{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Yo(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new Ro(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new Ro(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ic.create=(e,t)=>new ic({innerType:e,typeName:Y.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...q(t)});var ac=class extends J{_parse(e){if(this._getType(e)!==H.nan){let t=this._getOrReturnCtx(e);return W(t,{code:U.invalid_type,expected:H.nan,received:t.parsedType}),G}return{status:`valid`,value:e.data}}};ac.create=e=>new ac({typeName:Y.ZodNaN,...q(e)});var oc=class extends J{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},sc=class e extends J{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?G:e.status===`dirty`?(t.dirty(),Wo(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?G:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:Y.ZodPipeline})}},cc=class extends J{_parse(e){let t=this._def.innerType._parse(e),n=e=>(Jo(e)&&(e.value=Object.freeze(e.value)),e);return Yo(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};cc.create=(e,t)=>new cc({innerType:e,typeName:Y.ZodReadonly,...q(t)}),Ls.lazycreate;var Y;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(Y||={});var lc=Ss.create;ws.create,ac.create,Ts.create,Es.create,Ds.create,Os.create,ks.create,As.create,js.create,Ms.create,Ns.create,Ps.create,Fs.create,Ls.create,Ls.strictCreate,Rs.create,Bs.create,Hs.create,Us.create,Ws.create,Gs.create,Ks.create,qs.create,Js.create,Ys.create,Zs.create,Qs.create,$s.create,ec.create,tc.create,nc.create,ec.createWithPreprocess,sc.create;var uc=/^(?=.{1,253}$)[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?(\.[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)+$/,dc=Object.freeze([3100,9090,9091,9292,9294]);Object.freeze({min:21e3,max:21999});var fc=[`panel`,`auth`,`tunnel`,`www`,`mail`,`ftp`,`api`],pc=`agent-`;Object.freeze({version:`1.12.0`,sha256:Object.freeze({linux_amd64:`f3f180f1d93aa72cce4e6386f98cc06569a0146fbd65eb4423cf83e6434bcfe6`,linux_arm64:`2ec6152cd2c74fe0146d4d79e4e7aa174521368c56e433d55e023a92ea404ec3`,darwin_amd64:`4aeae36c867f11c8e8c3f2b913a0e063ea3c6d29e1c14a52ed2e6eef8cfc4395`,darwin_arm64:`707a4b932eea214765146504a0df246cefc415b4297af65a80dd67cf69ba85a9`})}),Object.freeze({version:`4.39.28`,sha256:Object.freeze({"linux-amd64":`e8ad9ff965cbf3b93138945e13cb4b7874c999c254772b2bb77952863177699c`,"linux-arm64":`089f3f8bdcba962024e15283811256cea28032d1cdccc56cf4e4c1b284022faa`})}),lc().max(253).transform(e=>e.toLowerCase()).pipe(lc().regex(uc,`Not a domain name`));function X(e){let t=e.toLowerCase();return fc.includes(t)||t.startsWith(`agent-`)}var mc=Object.freeze([`authenticated`,`restricted`]),hc=/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/;function gc(e){switch(e){case`authenticated`:return`authenticated — any signed-in member of its audience`;case`restricted`:return`restricted — members of its audience granted the site`;default:return e?String(e):`unknown`}}function _c(e){return typeof e!=`string`||e.length===0?`Enter a subdomain`:hc.test(e)?e.startsWith(`agent-`)?`'${pc}*' is kept for agent panels`:X(e)?`'${e}' is reserved for the relay`:null:`A subdomain is a DNS label: lowercase letters, digits and hyphens, not starting or ending with a hyphen, at most 63 characters`}function vc(e){return typeof e==`string`&&e.length>16?`${e.slice(0,8)}…${e.slice(-6)}`:e??``}function yc(e){if(!Number.isFinite(e)||e<0)return`unknown size`;if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`],n=e/1024,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n.toFixed(1)} ${t[r]}`}function bc({files:e,totalBytes:t}){return[typeof e==`number`?`${e} file${e===1?``:`s`}`:null,yc(t)].filter(Boolean).join(`, `)}function xc(e){return e?e.served?{served:!0,text:e.site?`Served — its site serves the approved shell and its user-surface API`:`Ready to be served — give it a site`}:{served:!1,text:`${e.site?`Its site answers 503: `:`Not served: `}${Sc(e.reason)}`}:{served:!1,text:`Unknown`}}function Sc(e){switch(e){case`not_installed`:return`no installed plugin holds its route`;case`no_identity`:return`the installed version declares no identity — a web surface serves its users, so it needs one`;case`no_web_surface`:return`the installed version declares no web surface (userSurface.web)`;case`not_owner`:return`its site was created for another package under the same route — delete the site, then create one for this plugin`;case`not_approved`:return`the installed version waits for approval — approve it under Lifecycle hooks`;case`not_hosted`:return`the plugin is not hosted on an agent, or its hosting is not active yet`;case`tree_not_current`:return`the approved web tree is not the one served yet — it is switched to when the approved version is installed`;default:return e?String(e):`not served`}}var Cc={no_web_surface:`The installed version declares no web surface — update to a version that declares userSurface.web.`,no_identity:`A web surface serves the plugin’s users: its installed version must declare identity.`,exists:`The plugin owns a site already — delete it first to start over.`,bound_to_tunnel:`A tunnel is bound as its user surface — move that tunnel’s hostname to the web surface instead.`,hostname_taken:`Pick another subdomain: a tunnel or a site holds this one.`,not_bound:`That tunnel is not bound as this plugin’s user surface any more — refresh the page.`,shared_tunnel:`The tunnel serves other plugins’ user surfaces too — unbind them on the Tunnels page first.`,tunnel_disabled:`Enable the tunnel first: only a live hostname can be handed over.`,not_hosted:`The plugin must be hosted by the agent carrying the tunnel, with its hosting active.`,not_approved:`Approve what the installed version brings under Lifecycle hooks first.`,web_tree:`The installed package’s web tree cannot be served — reinstall or update the plugin, then try again.`,gatekeeper:`Gatekeeper could not be reached to copy the tunnel’s grants — nothing was moved; try again.`,not_found:`It is gone already — refresh the page.`,domain_not_configured:`Configure the relay’s domain and email under Settings first.`};function wc(e){let{code:t}=Ao(e),n=typeof t==`string`&&Object.hasOwn(Cc,t)?Cc[t]:null;return{message:B(e),code:t,hint:n}}function Tc(e,{edited:t=!1}={}){if(!e)return`Loading`;if(e.site)return`The plugin owns a site already`;if(!e.declared)return`The installed version declares no web surface`;if(e.boundTunnel){let t=e.boundTunnel.fqdn??e.boundTunnel.id;return e.boundTunnel.enabled===!1?`Tunnel ${t} is bound as its user surface but disabled — unbind it, or enable it and move it`:`Tunnel ${t} is bound as its user surface — move it instead`}return e.offer&&!e.offer.available&&!t?`'${e.offer.subdomain}' is held by a tunnel or a site — pick another subdomain`:null}function Ec(e,t){if(!e?.boundTunnel)return`No tunnel is bound as its user surface`;if(e.site)return`The plugin owns a site already`;if(!e.declared)return`The installed version declares no web surface`;if(e.boundTunnel.enabled===!1)return`The bound tunnel is disabled — enable it to move it, or unbind it`;let n=(e.boundTunnel.routes??[]).filter(e=>e!==t);return n.length>0?`The tunnel serves other user surfaces too (${n.join(`, `)}) — unbind them first`:null}function Dc(e){let t=e?.owner;return t&&typeof t==`object`&&typeof t.plugin==`string`?t.plugin:null}function Oc(e){let t=new Set;for(let n of Array.isArray(e)?e:[]){let e=Dc(n);e&&t.add(e)}return t}function kc(e,t){return e?.hosting===`agent`?e.userSurface?.web?!0:typeof e.route==`string`&&t.has(e.route):!1}function Ac(e){if(!e||typeof e!=`object`)return null;let t=typeof e.before==`string`?e.before:null,n=e.after&&typeof e.after==`object`&&typeof e.after.sha256==`string`?e.after:null;return t===null&&n===null?null:{kind:t===null?`added`:n===null?`removed`:t===n.sha256?`unchanged`:`changed`,before:t,after:n,changes:e.changes&&typeof e.changes==`object`?e.changes:null}}function jc(e){return`plugin-${e}`}function Mc(e,t){let n=Dc(e);if(n===null)return null;let r=(Array.isArray(t)?t:[]).find(e=>e.route===n)??null;return{route:n,name:r?.name??null,label:r?.displayName||r?.name||n}}function Nc(e){return(e??[]).filter(e=>e.status===`active`).sort((e,t)=>e.primary===t.primary?e.name.localeCompare(t.name):e.primary?-1:1).map(e=>e.name)}function Pc(e){return Nc(e).length>1}function Fc(e){return e.status===`active`?e.primary?`active — primary`:`active`:`pending — sign-in not served yet`}function Ic(e){if(!e)return[];let t=[],n=(e,n)=>{n?.length>0&&t.push(`${e}: ${n.join(`, `)}`)};return n(`Tunnels`,e.tunnels),n(`Sites`,e.sites),n(`Plugins`,e.plugins),e.registry&&t.push(`The registry credential trusts its issuer`),t}function Lc(e){let{code:t}=Ao(e),n=B(e);if(t===`domain_in_use`){let t=Ic(e?.usedBy);return t.length>0?`${n} — ${t.join(`; `)}`:n}return n}function Rc(e,t){let n=new Set((t??[]).map(e=>e.userId));return(e??[]).filter(e=>e.userId&&!n.has(e.userId)).sort((e,t)=>e.username.localeCompare(t.username))}var zc=`An external member reaches only what names them: restricted tunnels and surfaces that grant them, sites that list them, OIDC clients granted to them. They hold no Authelia groups.`;function Bc(e){let t=new Map;for(let n of e??[]){let e=typeof n==`string`?n:n?.name;typeof e==`string`&&t.set(e,n?.kind===`external`?`external`:`member`)}return[...t].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({name:e,kind:t}))}function Vc(e){return Bc(e).some(e=>e.kind===`external`)}function Hc(e,t){return Bc(e).find(e=>e.name===t)?.kind??null}function Z(e,t,n){let r=Bc(e).filter(e=>e.name!==t);return Bc(n===null?r:[...r,{name:t,kind:n}])}function Uc(e,t){let n=e=>Bc(e).map(e=>`${e.name}:${e.kind}`).join(`,`);return n(e)===n(t)}function Wc(e,t){let n=new Set;if(!t)return n;for(let r of e??[])r.userId&&Hc(r.domains,t)===`external`&&n.add(r.userId);return n}function Gc(){let e=F(),t=M({queryKey:[`domains`],queryFn:()=>e.getDomains(),staleTime:3e4});return{...t,domains:t.data?.domains??[],newUsersNeedDomains:t.data?.newUsersNeedDomains===!0}}var Kc=`w-full rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-2 text-sm text-white focus:border-cyan-500 focus:outline-none`;function qc({value:e,onChange:t,label:n=`Domain`}){let{domains:r}=Gc();if(!Pc(r))return null;let[i,...a]=Nc(r);return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`mb-1 block text-sm text-zinc-400`,children:n}),(0,A.jsxs)(`select`,{value:e||i,onChange:e=>t(e.target.value===i?``:e.target.value),className:Kc,children:[(0,A.jsxs)(`option`,{value:i,children:[i,` (primary)`]}),a.map(e=>(0,A.jsx)(`option`,{value:e,children:e},e))]})]})}function Jc(e){let{domains:t,newUsersNeedDomains:n}=Gc(),[r,i]=(0,g.useState)(null),a=Bc(e?.domains),o=!n&&t.length===1?t[0].name:null,s=r??(e||!o?a:[{name:o,kind:`member`}]),c=(n||o!==null)&&(!e||!!e.userId),l=Vc(s);return{domains:t,asks:c,only:o,value:s,external:l,setValue:i,createFields:c&&(n||l)?{domains:s}:{},editFields:c&&r!==null&&!Uc(r,a)?{domains:r}:{}}}function Yc({title:e=zc}){return(0,A.jsx)(`span`,{title:e,className:`rounded-full border border-amber-500/30 bg-amber-500/10 px-2 py-0.5 font-sans text-xs text-amber-300`,children:`external`})}function Xc({choice:e}){if(!e.asks)return null;if(e.only){let t=Hc(e.value,e.only)===`external`;return(0,A.jsxs)(`label`,{className:`flex items-start gap-2 text-sm text-zinc-300`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:t,onChange:()=>e.setValue(Z(e.value,e.only,t?`member`:`external`)),className:`mt-1 accent-cyan-500`}),(0,A.jsxs)(`span`,{children:[`External member of `,(0,A.jsx)(`span`,{className:`font-mono`,children:e.only}),(0,A.jsx)(`span`,{className:`block text-xs text-zinc-500`,children:zc})]})]})}return(0,A.jsxs)(`fieldset`,{children:[(0,A.jsx)(`legend`,{className:`mb-1 block text-sm text-zinc-400`,children:`Domains`}),(0,A.jsx)(`div`,{className:`space-y-2`,children:e.domains.map(t=>{let n=Hc(e.value,t.name);return(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm text-zinc-300`,children:[(0,A.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:n!==null,onChange:()=>e.setValue(Z(e.value,t.name,n?null:`member`)),className:`accent-cyan-500`}),(0,A.jsx)(`span`,{className:`font-mono`,children:t.name}),t.status!==`active`&&(0,A.jsx)(`span`,{className:`text-xs text-zinc-500`,children:`(pending)`})]}),n!==null&&(0,A.jsxs)(`select`,{value:n,onChange:n=>e.setValue(Z(e.value,t.name,n.target.value)),"aria-label":`Kind of membership of ${t.name}`,className:`rounded border border-zinc-700 bg-zinc-900 px-2 py-0.5 text-xs text-white focus:border-cyan-500 focus:outline-none`,children:[(0,A.jsx)(`option`,{value:`member`,children:`member`}),(0,A.jsx)(`option`,{value:`external`,children:`external`})]})]},t.name)})}),e.external&&(0,A.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:`An external member reaches only what names them: restricted tunnels and surfaces that grant them, sites that list them, OIDC clients granted to them. They hold no Authelia groups.`})]})}function Zc({domains:e}){let t=Bc(e);return t.length===0?(0,A.jsx)(`span`,{className:`text-xs text-zinc-500`,children:`none`}):(0,A.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.map(e=>(0,A.jsxs)(`span`,{title:e.kind===`external`?zc:void 0,className:`rounded border px-2 py-0.5 font-mono text-xs ${e.kind===`external`?`border-amber-900 bg-amber-950/40 text-amber-300`:`border-cyan-900 bg-cyan-950/40 text-cyan-300`}`,children:[e.name,e.kind===`external`?` · external`:``]},e.name))})}function Qc(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`}function $c(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function el({site:e}){return e.webSurface&&!e.webSurface.served?(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full border text-yellow-400 bg-yellow-500/10 border-yellow-500/20`,title:`Answers 503: ${Sc(e.webSurface.reason)}`,children:[(0,A.jsx)(Ei,{size:10}),`Not served`]}):e.certIssued&&e.dnsVerified?(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full border text-green-400 bg-green-500/10 border-green-500/20`,children:[(0,A.jsx)(Si,{size:10}),`Live`]}):e.type===`custom`&&!e.dnsVerified?(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full border text-yellow-400 bg-yellow-500/10 border-yellow-500/20`,children:[(0,A.jsx)(Ei,{size:10}),`DNS Pending`]}):(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full border text-zinc-500 bg-zinc-800 border-zinc-700`,children:[(0,A.jsx)(ja,{size:10}),`Setup Required`]})}function tl({type:e}){return(0,A.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full border ${e===`managed`?`text-cyan-400 bg-cyan-500/10 border-cyan-500/20`:`text-purple-400 bg-purple-500/10 border-purple-500/20`}`,children:e})}function nl({owner:e}){return(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full border text-amber-400 bg-amber-500/10 border-amber-500/20`,title:`The web surface of an agent-hosted plugin — managed through the plugin`,children:[(0,A.jsx)(sa,{size:10}),`owned by plugin `,(0,A.jsx)(`span`,{className:`font-mono`,children:e.route})]})}function rl({owner:e,site:t,onOpenPlugin:n,onDelete:r,compact:i=!1}){return e.name?n?(0,A.jsxs)(`button`,{type:`button`,onClick:()=>n(e.name),title:`Manage it on the page of plugin ${e.label} (Web surface)`,className:i?`inline-flex items-center gap-1 text-xs text-cyan-400 hover:text-cyan-300`:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-cyan-400 hover:bg-cyan-600/20 hover:text-cyan-300`,children:[(0,A.jsx)(sa,{size:12}),`Open plugin `,e.label]}):(0,A.jsxs)(`span`,{className:`text-xs text-zinc-500`,children:[`manage under Plugins → `,e.label,` → Web surface`]}):(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,A.jsx)(`span`,{className:`text-xs text-zinc-500`,title:`No installed plugin holds this route`,children:`plugin not installed`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>r(t),className:`p-1.5 text-zinc-400 hover:text-red-400 hover:bg-zinc-700 rounded transition-colors`,title:`Delete the site of the uninstalled plugin`,"aria-label":`Delete ${t.fqdn}`,children:(0,A.jsx)(R,{size:i?14:16})})]})}var il=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;function al(e){return[...new Set(e.split(/[\s,]+/).map(e=>e.trim().toLowerCase()).filter(Boolean))]}function ol({domain:e,onClose:t}){let n=j(),r=z(),i=F(),[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(`managed`),[l,u]=(0,g.useState)(``),[d,f]=(0,g.useState)(``),[p,m]=(0,g.useState)(!1),[h,_]=(0,g.useState)(!1),[v,y]=(0,g.useState)(``),[b,x]=(0,g.useState)({}),[S,C]=(0,g.useState)(null),w=N({mutationFn:e=>i.createSite(e),onSuccess:e=>{n.invalidateQueries({queryKey:[`sites`]}),r(`Site ${e.site.fqdn} created`),t()},onError:e=>{C(B(e))}}),T=(0,g.useCallback)(e=>{e.preventDefault(),C(null);let t={};if(a?il.test(a)||(t.name=`Lowercase letters, numbers, and hyphens only`):t.name=`Name is required`,s===`custom`&&!l&&(t.customDomain=`Domain is required for custom sites`),Object.keys(t).length>0){x(t);return}x({});let n={name:a,type:s,spaMode:p,autheliaProtected:h};if(s===`managed`&&v&&(n.domain=v),s===`custom`){n.customDomain=l.toLowerCase();let e=al(d);e.length>0&&(n.aliases=e)}w.mutate(n)},[a,s,l,d,p,h,v,w]);return(0,A.jsxs)(`div`,{className:`bg-zinc-900 border border-zinc-800 rounded-lg p-5 mb-6`,children:[(0,A.jsxs)(`h2`,{className:`text-sm font-semibold text-zinc-300 mb-4 flex items-center gap-2`,children:[(0,A.jsx)(ua,{size:14,className:`text-cyan-400`}),`Add Static Site`]}),(0,A.jsxs)(`form`,{onSubmit:T,className:`space-y-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-2`,children:`Domain Type`}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>c(`managed`),className:`px-3 py-1.5 text-sm rounded border ${s===`managed`?`border-cyan-400 text-cyan-400 bg-cyan-500/10`:`border-zinc-700 text-zinc-400 bg-zinc-800 hover:border-zinc-600`}`,children:`Managed Subdomain`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>c(`custom`),className:`px-3 py-1.5 text-sm rounded border ${s===`custom`?`border-cyan-400 text-cyan-400 bg-cyan-500/10`:`border-zinc-700 text-zinc-400 bg-zinc-800 hover:border-zinc-600`}`,children:`Custom Domain`})]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Name`}),(0,A.jsxs)(`div`,{className:`flex items-center gap-0`,children:[(0,A.jsx)(`input`,{type:`text`,value:a,onChange:e=>{o(e.target.value.toLowerCase()),x(e=>({...e,name:void 0}))},disabled:w.isPending,placeholder:`blog`,className:`flex-1 ${s===`managed`?`rounded-l`:`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`}),s===`managed`&&(0,A.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:[`.`,v||e]})]}),b.name&&(0,A.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:b.name})]}),s===`managed`&&(0,A.jsx)(qc,{value:v,onChange:y}),s===`custom`&&(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Custom Domain`}),(0,A.jsx)(`input`,{type:`text`,value:l,onChange:e=>{u(e.target.value.toLowerCase()),x(e=>({...e,customDomain:void 0}))},disabled:w.isPending,placeholder:`example.com`,className:`w-full 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.customDomain&&(0,A.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:b.customDomain}),(0,A.jsxs)(`label`,{className:`block text-xs text-zinc-400 mt-3 mb-1`,children:[`Redirect aliases `,(0,A.jsx)(`span`,{className:`text-zinc-600`,children:`(optional)`})]}),(0,A.jsx)(`input`,{type:`text`,value:d,onChange:e=>f(e.target.value),disabled:w.isPending,placeholder:l?`www.${l}`:`www.example.com`,className:`w-full 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`}),(0,A.jsx)(`p`,{className:`text-xs text-zinc-500 mt-1`,children:`These hostnames redirect to the site and share its certificate. Each needs its own A record.`})]}),(0,A.jsxs)(`div`,{className:`flex flex-wrap gap-4`,children:[(0,A.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-zinc-400 cursor-pointer`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked),disabled:w.isPending,className:`rounded border-zinc-700 bg-zinc-800 text-cyan-400 focus:ring-cyan-400`}),`SPA Mode`,(0,A.jsx)(`span`,{className:`text-zinc-600 text-xs`,children:`(fallback to index.html)`})]}),(0,A.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-zinc-400 cursor-pointer`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>_(e.target.checked),disabled:w.isPending,className:`rounded border-zinc-700 bg-zinc-800 text-cyan-400 focus:ring-cyan-400`}),`Authelia Protected`,(0,A.jsx)(`span`,{className:`text-zinc-600 text-xs`,children:`(require login)`})]})]}),S&&(0,A.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,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.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,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{size:14,className:`animate-spin`}),`Creating site...`]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(ua,{size:14}),`Create Site`]})}),(0,A.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 sl({site:e,onClose:t}){let n=j(),r=z(),i=F(),[a,o]=(0,g.useState)(null),s=N({mutationFn:()=>i.verifySiteDns(e.id),onSuccess:e=>{o(e),e.ok&&(n.invalidateQueries({queryKey:[`sites`]}),r(`DNS verified and site is now live!`))},onError:e=>{o({ok:!1,message:B(e)})}});return(0,A.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:(0,A.jsxs)(`div`,{className:`bg-zinc-900 border border-zinc-800 rounded-lg p-6 max-w-lg w-full mx-4 shadow-xl`,children:[(0,A.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:`DNS Verification`}),(0,A.jsxs)(`p`,{className:`text-zinc-400 text-sm mb-4`,children:[`Add an A record pointing`,` `,[e.fqdn,...e.aliases||[]].map((e,t,n)=>(0,A.jsxs)(`span`,{children:[(0,A.jsx)(`span`,{className:`text-cyan-400 font-mono`,children:e}),t<n.length-1?`, `:``]},e)),` `,`to your server IP.`]}),(0,A.jsx)(`div`,{className:`bg-zinc-800 rounded-lg p-4 mb-4`,children:(0,A.jsx)(`table`,{className:`w-full text-sm`,children:(0,A.jsxs)(`tbody`,{children:[(0,A.jsxs)(`tr`,{children:[(0,A.jsx)(`td`,{className:`text-zinc-500 py-1 pr-4`,children:`Type`}),(0,A.jsx)(`td`,{className:`text-zinc-200 font-mono`,children:`A`})]}),(0,A.jsxs)(`tr`,{children:[(0,A.jsx)(`td`,{className:`text-zinc-500 py-1 pr-4`,children:`Name`}),(0,A.jsx)(`td`,{className:`text-zinc-200 font-mono`,children:[e.fqdn,...e.aliases||[]].join(`, `)})]}),(0,A.jsxs)(`tr`,{children:[(0,A.jsx)(`td`,{className:`text-zinc-500 py-1 pr-4`,children:`Value`}),(0,A.jsx)(`td`,{className:`text-zinc-200 font-mono`,children:`(your server IP)`})]})]})})}),a&&(0,A.jsx)(`div`,{className:`rounded px-3 py-2 text-sm mb-4 ${a.ok?`bg-green-500/10 border border-green-500/20 text-green-400`:`bg-yellow-500/10 border border-yellow-500/20 text-yellow-400`}`,children:a.message}),(0,A.jsxs)(`div`,{className:`flex items-center justify-end gap-3`,children:[(0,A.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:a?.ok?`Done`:`Cancel`}),!a?.ok&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>s.mutate(),disabled:s.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`,children:s.isPending?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{size:14,className:`animate-spin`}),`Verifying...`]}):`Verify DNS`})]})]})})}function cl({site:e,onConfirm:t,onCancel:n,isPending:r}){return(0,A.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:(0,A.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,A.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:`Delete Site`}),(0,A.jsxs)(`p`,{className:`text-zinc-400 text-sm mb-6`,children:[`Are you sure you want to delete`,` `,(0,A.jsx)(`span`,{className:`text-cyan-400 font-mono`,children:e.fqdn}),`? This will remove all files, the nginx configuration, and certificate mapping.`]}),(0,A.jsxs)(`div`,{className:`flex items-center justify-end gap-3`,children:[(0,A.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,A.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,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{size:14,className:`animate-spin`}),`Deleting...`]}):`Delete`})]})]})})}function ll({site:e,onClose:t}){let n=j(),r=z(),i=F(),[a,o]=(0,g.useState)(e.spaMode),[s,c]=(0,g.useState)(e.autheliaProtected),[l,u]=(0,g.useState)(e.allowedUsers||[]),[d,f]=(0,g.useState)((e.aliases||[]).join(`, `)),p=al(d),m=JSON.stringify(p.slice().sort())!==JSON.stringify((e.aliases||[]).slice().sort()),h=M({queryKey:[`users`],queryFn:()=>i.getUsers()}),_=N({mutationFn:t=>i.updateSite(e.id,t),onSuccess:i=>{n.invalidateQueries({queryKey:[`sites`]}),r(`Site ${e.fqdn} settings updated`),i?.warning&&r(i.warning,`error`),t()},onError:e=>{r(B(e),`error`)}}),v=e.allowedUsers||[],y=a!==e.spaMode||s!==e.autheliaProtected||m||JSON.stringify(l.slice().sort())!==JSON.stringify(v.slice().sort()),b=(h.data?.users||[]).filter(e=>!l.includes(e.username)),x=e=>{u(t=>[...t,e])},S=e=>{u(t=>t.filter(t=>t!==e))};return(0,A.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:(0,A.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,A.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-1`,children:`Site Settings`}),(0,A.jsx)(`p`,{className:`text-zinc-500 text-sm mb-5 font-mono`,children:e.fqdn}),(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsxs)(`label`,{className:`flex items-center justify-between gap-3 cursor-pointer`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{className:`text-sm text-zinc-200`,children:`SPA Mode`}),(0,A.jsx)(`p`,{className:`text-xs text-zinc-500 mt-0.5`,children:`Fallback to index.html for client-side routing`})]}),(0,A.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),disabled:_.isPending,className:`rounded border-zinc-700 bg-zinc-800 text-cyan-400 focus:ring-cyan-400 h-5 w-5`})]}),(0,A.jsxs)(`label`,{className:`flex items-center justify-between gap-3 cursor-pointer`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{className:`text-sm text-zinc-200`,children:`Authelia Protected`}),(0,A.jsx)(`p`,{className:`text-xs text-zinc-500 mt-0.5`,children:`Require login to access this site`})]}),(0,A.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked),disabled:_.isPending,className:`rounded border-zinc-700 bg-zinc-800 text-cyan-400 focus:ring-cyan-400 h-5 w-5`})]}),e.type===`custom`&&(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{className:`text-sm text-zinc-200`,children:`Redirect aliases`}),(0,A.jsxs)(`p`,{className:`text-xs text-zinc-500 mt-0.5 mb-2`,children:[`Hostnames that redirect to `,e.fqdn,`. On a live site each new alias must already resolve to this server; the certificate is re-issued to cover it.`]}),(0,A.jsx)(`input`,{type:`text`,value:d,onChange:e=>f(e.target.value),disabled:_.isPending,placeholder:`www.${e.fqdn}`,className:`w-full 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`})]}),s&&(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,A.jsx)(Ea,{size:14,className:`text-cyan-400`}),(0,A.jsx)(`span`,{className:`text-sm text-zinc-200`,children:`Allowed Users`})]}),(0,A.jsx)(`p`,{className:`text-xs text-zinc-500 mb-3`,children:l.length===0?`All authenticated users can access this site.`:`Only the selected users can access this site.`}),l.length>0&&(0,A.jsx)(`div`,{className:`flex flex-wrap gap-2 mb-3`,children:l.map(e=>(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-1 rounded-full border border-cyan-500/20 bg-cyan-500/10 text-cyan-400`,children:[e,(0,A.jsx)(`button`,{type:`button`,onClick:()=>S(e),disabled:_.isPending,className:`hover:text-red-400`,children:(0,A.jsx)(Ga,{size:12})})]},e))}),b.length>0&&(0,A.jsxs)(`select`,{onChange:e=>{e.target.value&&(x(e.target.value),e.target.value=``)},disabled:_.isPending,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 focus:outline-none focus:border-cyan-400 disabled:opacity-50`,children:[(0,A.jsx)(`option`,{value:``,children:`Add user...`}),b.map(e=>(0,A.jsxs)(`option`,{value:e.username,children:[e.username,` (`,e.displayname,`)`]},e.username))]}),h.isLoading&&(0,A.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Loading users...`})]})]}),(0,A.jsxs)(`div`,{className:`flex items-center justify-end gap-3 mt-6`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:t,disabled:_.isPending,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Cancel`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>_.mutate({spaMode:a,autheliaProtected:s,allowedUsers:l,...m?{aliases:p}:{}}),disabled:_.isPending||!y,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:_.isPending?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{size:14,className:`animate-spin`}),`Saving...`]}):`Save Changes`})]})]})})}function ul({sites:e,ownerOf:t,onOpenPlugin:n,onDelete:r,onFiles:i,onVerifyDns:a,onSettings:o}){return(0,A.jsx)(`div`,{className:`hidden md:block overflow-x-auto`,children:(0,A.jsxs)(`table`,{className:`w-full`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`border-b border-zinc-700`,children:[(0,A.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Name`}),(0,A.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Domain`}),(0,A.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Type`}),(0,A.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Status`}),(0,A.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Size`}),(0,A.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Created`}),(0,A.jsx)(`th`,{className:`text-right text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Actions`})]})}),(0,A.jsx)(`tbody`,{children:e.map(e=>{let s=t(e);return(0,A.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-800/50`,children:[(0,A.jsx)(`td`,{className:`py-3 px-4 text-sm text-zinc-200 font-mono`,children:e.name}),(0,A.jsxs)(`td`,{className:`py-3 px-4 text-sm`,children:[e.certIssued?(0,A.jsxs)(`a`,{href:`https://${e.fqdn}`,target:`_blank`,rel:`noopener noreferrer`,className:`text-cyan-400 hover:text-cyan-300 inline-flex items-center gap-1`,children:[e.fqdn,(0,A.jsx)(Ni,{size:12})]}):(0,A.jsx)(`span`,{className:`text-zinc-400 font-mono`,children:e.fqdn}),(e.aliases||[]).length>0&&(0,A.jsxs)(`p`,{className:`text-xs text-zinc-500 font-mono mt-0.5`,children:[`also `,e.aliases.join(`, `)]})]}),(0,A.jsx)(`td`,{className:`py-3 px-4`,children:(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,A.jsx)(tl,{type:e.type}),s&&(0,A.jsx)(nl,{owner:s})]})}),(0,A.jsx)(`td`,{className:`py-3 px-4`,children:(0,A.jsx)(el,{site:e})}),(0,A.jsx)(`td`,{className:`py-3 px-4 text-sm text-zinc-400 font-mono`,children:s?(0,A.jsx)(`span`,{className:`text-zinc-600`,title:`Its web tree — see the plugin`,children:`—`}):$c(e.totalSize||0)}),(0,A.jsx)(`td`,{className:`py-3 px-4 text-sm text-zinc-500`,children:Qc(e.createdAt)}),(0,A.jsx)(`td`,{className:`py-3 px-4 text-right`,children:(0,A.jsx)(`div`,{className:`flex items-center justify-end gap-2`,children:s?(0,A.jsx)(rl,{owner:s,site:e,onOpenPlugin:n,onDelete:r}):(0,A.jsxs)(A.Fragment,{children:[e.type===`custom`&&!e.dnsVerified&&(0,A.jsxs)(`button`,{type:`button`,onClick:()=>a(e),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-yellow-400 hover:bg-yellow-600/20 hover:text-yellow-300`,children:[(0,A.jsx)(Hi,{size:12}),`Verify DNS`]}),(0,A.jsxs)(`button`,{type:`button`,onClick:()=>o(e),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-zinc-400 hover:bg-zinc-600 hover:text-zinc-300`,children:[(0,A.jsx)(Ca,{size:12}),`Settings`]}),(0,A.jsxs)(`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-cyan-400 hover:bg-cyan-600/20 hover:text-cyan-300`,children:[(0,A.jsx)(zi,{size:12}),`Files`]}),(0,A.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-red-400 hover:bg-red-600/20 hover:text-red-300`,children:[(0,A.jsx)(R,{size:12}),`Delete`]})]})})})]},e.id)})})]})})}function dl({sites:e,ownerOf:t,onOpenPlugin:n,onDelete:r,onFiles:i,onVerifyDns:a,onSettings:o}){return(0,A.jsx)(`div`,{className:`md:hidden space-y-3`,children:e.map(e=>{let s=t(e);return(0,A.jsxs)(`div`,{className:`bg-zinc-800/50 border border-zinc-700 rounded-lg p-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,A.jsx)(`span`,{className:`text-sm font-semibold text-zinc-200 font-mono`,children:e.name}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(tl,{type:e.type}),(0,A.jsx)(el,{site:e})]})]}),e.certIssued?(0,A.jsxs)(`a`,{href:`https://${e.fqdn}`,target:`_blank`,rel:`noopener noreferrer`,className:`text-cyan-400 hover:text-cyan-300 text-sm inline-flex items-center gap-1 mb-1`,children:[e.fqdn,(0,A.jsx)(Ni,{size:12})]}):(0,A.jsx)(`span`,{className:`text-zinc-400 text-sm font-mono`,children:e.fqdn}),(e.aliases||[]).length>0&&(0,A.jsxs)(`p`,{className:`text-xs text-zinc-500 font-mono mb-1`,children:[`also `,e.aliases.join(`, `)]}),s&&(0,A.jsx)(`div`,{className:`mt-1`,children:(0,A.jsx)(nl,{owner:s})}),(0,A.jsxs)(`div`,{className:`flex items-center gap-4 text-xs text-zinc-500 mt-2`,children:[!s&&(0,A.jsx)(`span`,{children:$c(e.totalSize||0)}),(0,A.jsx)(`span`,{children:Qc(e.createdAt)})]}),(0,A.jsx)(`div`,{className:`flex items-center gap-2 mt-3`,children:s?(0,A.jsx)(rl,{owner:s,site:e,onOpenPlugin:n,onDelete:r,compact:!0}):(0,A.jsxs)(A.Fragment,{children:[e.type===`custom`&&!e.dnsVerified&&(0,A.jsxs)(`button`,{type:`button`,onClick:()=>a(e),className:`inline-flex items-center gap-1 text-xs text-yellow-400 hover:text-yellow-300`,children:[(0,A.jsx)(Hi,{size:12}),`Verify DNS`]}),(0,A.jsxs)(`button`,{type:`button`,onClick:()=>o(e),className:`inline-flex items-center gap-1 text-xs text-zinc-400 hover:text-zinc-300`,children:[(0,A.jsx)(Ca,{size:12}),`Settings`]}),(0,A.jsxs)(`button`,{type:`button`,onClick:()=>i(e),className:`inline-flex items-center gap-1 text-xs text-cyan-400 hover:text-cyan-300`,children:[(0,A.jsx)(zi,{size:12}),`Files`]}),(0,A.jsxs)(`button`,{type:`button`,onClick:()=>r(e),className:`inline-flex items-center gap-1 text-xs text-red-400 hover:text-red-300`,children:[(0,A.jsx)(R,{size:12}),`Delete`]})]})})]},e.id)})})}function fl({domain:e,onOpenPlugin:t}){let n=j(),r=z(),i=F(),[a,o]=(0,g.useState)(!1),[s,c]=(0,g.useState)(null),[l,u]=(0,g.useState)(null),[d,f]=(0,g.useState)(null),[p,m]=(0,g.useState)(null),h=M({queryKey:[`sites`],queryFn:()=>i.getSites(),refetchInterval:1e4}),_=M({queryKey:[`plugins`],queryFn:()=>i.getPlugins()}).data?.plugins,v=(0,g.useCallback)(e=>Mc(e,_),[_]),y=N({mutationFn:e=>{let t=Dc(e);return t?i.deletePluginWebSurface(t):i.deleteSite(e.id)},onSuccess:()=>{n.invalidateQueries({queryKey:[`sites`]}),r(`Site ${s.fqdn} deleted`),c(null)},onError:e=>{r(B(e),`error`),c(null)}}),b=(0,g.useCallback)(e=>c(e),[]),x=(0,g.useCallback)(e=>u(e),[]),S=(0,g.useCallback)(e=>f(e),[]),C=(0,g.useCallback)(e=>m(e),[]),w=(0,g.useCallback)(()=>{s&&y.mutate(s)},[s,y]),T=h.data?.sites||[];return l?(0,A.jsx)(yo,{site:l,onBack:()=>u(null)}):(0,A.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,A.jsxs)(`div`,{className:`mb-6 flex items-center justify-between`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Static Sites`}),(0,A.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`Host static websites, landing pages, and SPAs`})]}),!a&&(0,A.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,A.jsx)(ua,{size:14}),`Add Site`]})]}),a&&e&&(0,A.jsx)(ol,{domain:e,onClose:()=>o(!1)}),h.isLoading?(0,A.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:3}).map((e,t)=>(0,A.jsx)(`div`,{className:`h-16 animate-pulse rounded-lg bg-zinc-900 border border-zinc-800`},t))}):h.isError?(0,A.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,A.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Failed to load sites`})}):T.length===0?(0,A.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-12 text-center`,children:[(0,A.jsx)(Ii,{size:32,className:`mx-auto text-zinc-600 mb-3`}),(0,A.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:`No static sites yet. Create your first site to get started.`})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(ul,{sites:T,ownerOf:v,onOpenPlugin:t,onDelete:b,onFiles:x,onVerifyDns:S,onSettings:C}),(0,A.jsx)(dl,{sites:T,ownerOf:v,onOpenPlugin:t,onDelete:b,onFiles:x,onVerifyDns:S,onSettings:C})]}),d&&(0,A.jsx)(sl,{site:d,onClose:()=>f(null)}),p&&(0,A.jsx)(ll,{site:p,onClose:()=>m(null)}),s&&(0,A.jsx)(cl,{site:s,onConfirm:w,onCancel:()=>c(null),isPending:y.isPending})]})}var pl=Object.defineProperty,ml=Object.getOwnPropertySymbols,hl=Object.prototype.hasOwnProperty,gl=Object.prototype.propertyIsEnumerable,_l=(e,t,n)=>t in e?pl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,vl=(e,t)=>{for(var n in t||={})hl.call(t,n)&&_l(e,n,t[n]);if(ml)for(var n of ml(t))gl.call(t,n)&&_l(e,n,t[n]);return e},yl=(e,t)=>{var n={};for(var r in e)hl.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&ml)for(var r of ml(e))t.indexOf(r)<0&&gl.call(e,r)&&(n[r]=e[r]);return n},bl;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(bl||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(bl||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(bl||={});var xl=bl,Sl={L:xl.QrCode.Ecc.LOW,M:xl.QrCode.Ecc.MEDIUM,Q:xl.QrCode.Ecc.QUARTILE,H:xl.QrCode.Ecc.HIGH},Cl=128,wl=`L`,Tl=`#FFFFFF`,El=`#000000`,Dl=!1,Ol=1,kl=4,Al=0,jl=.1;function Ml(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function Nl(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function Pl(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*jl),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function Fl(e,t){return t==null?e?kl:Al:Math.max(Math.floor(t),0)}function Il({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=g.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...xl.QrSegment.makeSegments(t)),e),[]);return xl.QrCode.encodeSegments(r,Sl[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=g.useMemo(()=>{let e=c.getModules(),t=Fl(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:Pl(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var Ll=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),Rl=g.forwardRef(function(e,t){let n=e,{value:r,size:i=Cl,level:a=wl,bgColor:o=Tl,fgColor:s=El,includeMargin:c=Dl,minVersion:l=Ol,boostLevel:u,marginSize:d,imageSettings:f}=n,p=yl(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=yl(p,[`style`]),_=f?.src,v=g.useRef(null),y=g.useRef(null),b=g.useCallback(e=>{v.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[x,S]=g.useState(!1),{margin:C,cells:w,numCells:T,calculatedImageSettings:E}=Il({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});g.useEffect(()=>{if(v.current!=null){let e=v.current,t=e.getContext(`2d`);if(!t)return;let n=w,r=y.current,a=E!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&E.excavation!=null&&(n=Nl(w,E.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/T*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,T,T),t.fillStyle=s,Ll?t.fill(new Path2D(Ml(n,C))):w.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+C,n+C,1,1)})}),E&&(t.globalAlpha=E.opacity),a&&t.drawImage(r,E.x+C,E.y+C,E.w,E.h)}}),g.useEffect(()=>{S(!1)},[_]);let D=vl({height:i,width:i},m),ee=null;return _!=null&&(ee=g.createElement(`img`,{src:_,key:_,style:{display:`none`},onLoad:()=>{S(!0)},ref:y,crossOrigin:E?.crossOrigin})),g.createElement(g.Fragment,null,g.createElement(`canvas`,vl({style:D,height:i,width:i,ref:b,role:`img`},h)),ee)});Rl.displayName=`QRCodeCanvas`;var zl=g.forwardRef(function(e,t){let n=e,{value:r,size:i=Cl,level:a=wl,bgColor:o=Tl,fgColor:s=El,includeMargin:c=Dl,minVersion:l=Ol,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=yl(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:_,numCells:v,calculatedImageSettings:y}=Il({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:f,imageSettings:p,size:i}),b=_,x=null;p!=null&&y!=null&&(y.excavation!=null&&(b=Nl(_,y.excavation)),x=g.createElement(`image`,{href:p.src,height:y.h,width:y.w,x:y.x+h,y:y.y+h,preserveAspectRatio:`none`,opacity:y.opacity,crossOrigin:y.crossOrigin}));let S=Ml(b,h);return g.createElement(`svg`,vl({height:i,width:i,viewBox:`0 0 ${v} ${v}`,ref:t,role:`img`},m),!!d&&g.createElement(`title`,null,d),g.createElement(`path`,{fill:o,d:`M0,0 h${v}v${v}H0z`,shapeRendering:`crispEdges`}),g.createElement(`path`,{fill:s,d:S,shapeRendering:`crispEdges`}),x)});zl.displayName=`QRCodeSVG`;var Bl=`admins`,Vl={displayName:`display name`,email:`email address`};function Hl(e){return Vl[e]??String(e)}function Ul(e){return typeof e==`string`&&e.length>8?`${e.slice(0,8)}…`:e??``}function Wl(e){return typeof e==`string`?e:e&&typeof e==`object`&&typeof e.message==`string`?e.step?`${e.step}: ${e.message}`:e.message:String(e)}function Gl(e,t){let n=e=>Array.isArray(e?.groups)&&e.groups.includes(Bl)&&e.disabled!==!0;return n(e)?t.filter(n).length<=1:!1}function Kl(e){if(!e)return{ready:!1,text:`Unknown`};if(e.ready)return{ready:!0,text:`Users reach its application`};let t=e.version?`version ${e.version}`:`the installed version`;switch(e.reason){case`not_installed`:return{ready:!1,text:`The plugin is not installed`};case`no_identity`:return{ready:!1,text:`${ql(t)} declares no identity`};case`not_approved`:return{ready:!1,text:`${ql(t)} waits for approval — approve it under Lifecycle hooks`};case`not_hosted`:return{ready:!1,text:`The plugin is not hosted on an agent, or its hosting is not active yet`};case`not_answered`:return{ready:!1,text:`Its agent half has not answered the identity feed for ${t} yet — it is sent its users first`};default:return{ready:!1,text:e.reason?String(e.reason):`Not ready`}}}function ql(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Jl(e){switch(e){case null:case void 0:return`served — users reach its application here`;case`not_installed`:return`no installed plugin holds this route`;case`no_identity`:return`its installed version declares no identity — requests go down the tunnel until one does`;case`not_approved`:return`its installed version waits for approval — requests go down the tunnel until then`;case`not_hosting_agent`:return`the agent carrying this tunnel does not host the plugin (moved, revoked, or hosted elsewhere) — nothing of it is served here; requests go down the tunnel`;default:return String(e)}}function Yl(e){return e.exposure===`internal`||!e.subdomain||(e.type??`app`)!==`app`?{eligible:!1,reason:`Only an app tunnel's host serves a plugin's user surface`}:e.enabled===!1?{eligible:!1,reason:`Enable the tunnel first`}:e.agentLabel?(e.accessMode??`restricted`)===`public`?{eligible:!1,reason:`A public tunnel has no signed-in user to vouch for — make it authenticated or restricted first`}:{eligible:!0,reason:null}:{eligible:!1,reason:`Assign the tunnel to an agent first`}}function Xl(e,t,n){if(n.has(e.route))return`served on ${n.get(e.route)}`;let r=e.agentHosting?.agentLabel??null;return r===null?`not hosted on an agent`:r===t.agentLabel?null:`hosted on ${r}, not on ${t.agentLabel}`}function Zl(e){return Array.isArray(e?.userSurface?.routes)?e.userSurface.routes:[]}function Ql(e,t){return(e?.userSurfaceStatus??[]).find(e=>e.route===t)??null}function $l(e){let t=e.change,n=e=>({username:e?.username??null,displayName:e?.displayName??null,email:e?.email??null}),r={userId:e.userId,seq:e.seq,version:e.version,updatedAt:e.updatedAt,member:!1,...n(null),roles:[],status:`unknown`,reason:null};if(t?.kind===`upsert`&&t.member){let e=t.member;return{...r,member:!0,...n(e),roles:Array.isArray(e.roles)?e.roles:[],status:e.status===`disabled`?`disabled`:`active`}}return t?.kind===`remove`?{...r,...n(t.last),status:t.reason===`erased`?`erased`:`removed`,reason:t.reason??null}:r}function eu(e){switch(e){case`deleted`:return`deleted`;case`unentitled`:return`no longer entitled`;case`erased`:return`erased`;default:return e?String(e):`removed`}}function tu(e,t,n){let r=new Set(e);return n?r.add(t):r.delete(t),[...r].sort()}function nu(e){if(!(`grantsAffected`in e)||!Array.isArray(e.rolesRemoved)||e.rolesRemoved.length===0)return[];let t=e.grantsAffected;if(t===null)return[`not known — Gatekeeper could not be read`];let n=[];return t.revoked>0&&n.push(`${t.revoked} revoked`),t.rewritten>0&&n.push(`${t.rewritten} narrowed to the roles that stay`),n.length>0?n:[`none`]}function ru(e){if(!e||typeof e!=`object`)return null;let t=e=>Array.isArray(e)?e.map(String):[],n=(e,t)=>e?.roles?.find(e=>e.id===t)?.label??null,r=e=>t=>{let r=n(e,t);return r?`${t} (${r})`:t},i=[{label:`roles added`,entries:t(e.rolesAdded).map(r(e.after)),approval:!0},{label:`roles removed`,entries:t(e.rolesRemoved).map(r(e.before)),approval:!0},{label:`receives more about its users`,entries:t(e.attributesAdded).map(Hl),approval:!0},{label:`receives less about its users`,entries:t(e.attributesRemoved).map(Hl),approval:!1},{label:`role labels changed`,entries:t(e.labelsChanged).map(r(e.after)),approval:!1}].filter(e=>e.entries.length>0),a=nu(e);a.length>0&&i.push({label:`role grants affected`,entries:a,approval:!0});let o=e.before!=null,s=e.after!=null;return i.length===0&&o===s?null:{rows:i,declaredBefore:o,declaredAfter:s}}function iu({id:e,missing:t=`not in the directory yet`,full:n=!1}){let[r,i]=(0,g.useState)(!1);return e?(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,A.jsx)(`span`,{className:`font-mono text-xs text-zinc-400`,title:e,children:n?e:Ul(e)}),(0,A.jsx)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)}catch{}},title:`Copy the full id`,"aria-label":`Copy the full id`,className:`text-zinc-500 hover:text-zinc-300`,children:r?(0,A.jsx)(gi,{size:11,className:`text-green-400`}):(0,A.jsx)(Di,{size:11})})]}):(0,A.jsx)(`span`,{className:`text-zinc-600`,title:t,children:`—`})}function au({children:e,onClose:t}){return(0,A.jsx)(`div`,{className:`fixed inset-0 z-40 flex items-center justify-center bg-black/50`,children:(0,A.jsxs)(`div`,{className:`relative max-h-[90vh] w-full max-w-lg overflow-y-auto rounded-lg bg-zinc-800 p-6 shadow-xl`,onClick:e=>e.stopPropagation(),children:[(0,A.jsx)(`button`,{type:`button`,onClick:t,className:`absolute right-4 top-4 text-zinc-500 hover:text-zinc-300`,children:(0,A.jsx)(Ga,{size:18})}),e]})})}function ou({confirmLabel:e,destructive:t,disabled:n=!1,isPending:r,onConfirm:i,onCancel:a}){return(0,A.jsxs)(`div`,{className:`flex gap-3`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:a,className:`flex-1 rounded-lg border border-zinc-700 px-4 py-2 text-sm text-zinc-400 hover:text-white`,children:`Cancel`}),(0,A.jsx)(`button`,{type:`button`,onClick:i,disabled:r||n,className:`flex-1 rounded-lg px-4 py-2 text-sm font-semibold text-white disabled:opacity-50 ${t?`bg-red-600 hover:bg-red-500`:`bg-cyan-600 hover:bg-cyan-500`}`,children:r?`Please wait...`:e})]})}function su({title:e,message:t,confirmLabel:n,destructive:r,onConfirm:i,onCancel:a,isPending:o}){return(0,A.jsxs)(au,{onClose:a,children:[(0,A.jsx)(`h2`,{className:`mb-2 text-lg font-bold text-white`,children:e}),(0,A.jsx)(`p`,{className:`mb-6 text-sm text-zinc-400`,children:t}),(0,A.jsx)(ou,{confirmLabel:n,destructive:r,isPending:o,onConfirm:i,onCancel:a})]})}function cu(e){e.invalidateQueries({queryKey:[`users`]}),e.invalidateQueries({queryKey:[`user-directory`]}),e.invalidateQueries({queryKey:[`plugin-identity`]}),e.invalidateQueries({queryKey:[`plugin-audience`]}),e.invalidateQueries({queryKey:[`domains`]}),e.invalidateQueries({queryKey:[`domain-members`]})}function lu(e,t){for(let n of t?.warnings??[])e(Wl(n),`error`)}function uu({totpUri:e,onClose:t}){let[n,r]=(0,g.useState)(!1),i=e.match(/secret=([A-Z2-7]+)/),a=i?i[1]:``,o=a.replace(/(.{4})/g,`$1 `).trim();function s(){navigator.clipboard.writeText(a).then(()=>{r(!0),setTimeout(()=>r(!1),2e3)}).catch(()=>{})}return(0,A.jsxs)(au,{onClose:t,children:[(0,A.jsx)(`h2`,{className:`mb-4 text-lg font-bold text-white`,children:`Two-Factor Authentication Setup`}),(0,A.jsx)(`p`,{className:`mb-4 text-sm text-zinc-400`,children:`Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)`}),(0,A.jsx)(`div`,{className:`mb-4 flex justify-center`,children:(0,A.jsx)(`div`,{className:`rounded-lg bg-zinc-900 p-4`,children:(0,A.jsx)(zl,{value:e,size:200,bgColor:`transparent`,fgColor:`#ffffff`})})}),(0,A.jsx)(`p`,{className:`mb-2 text-sm text-zinc-400`,children:`Or enter this code manually:`}),(0,A.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 rounded-lg bg-zinc-900 px-4 py-3`,children:[(0,A.jsx)(`code`,{className:`flex-1 font-mono text-sm text-cyan-400 tracking-wider`,children:o}),(0,A.jsx)(`button`,{type:`button`,onClick:s,className:`text-zinc-500 hover:text-zinc-300`,title:`Copy secret`,children:n?(0,A.jsx)(gi,{size:16,className:`text-green-400`}):(0,A.jsx)(Di,{size:16})})]}),(0,A.jsx)(`p`,{className:`mb-6 text-xs text-yellow-400`,children:`This code will only be shown once. Make sure the user scans it before closing.`}),(0,A.jsx)(`button`,{type:`button`,onClick:t,className:`w-full rounded-lg bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500`,children:`Done`})]})}function du(e){return e.split(`,`).map(e=>e.trim()).filter(Boolean)}function fu({label:e,value:t,onChange:n,placeholder:r,external:i}){let a=i&&du(t).length>0;return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`mb-1 block text-sm text-zinc-400`,children:e}),(0,A.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),disabled:i&&!a,placeholder:i?`External members hold no groups`:r,className:`w-full rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-2 text-sm text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none disabled:text-zinc-500`}),a&&(0,A.jsx)(`p`,{className:`mt-1 text-xs text-amber-300`,children:`An external member holds no Authelia groups — remove them to make the user external.`})]})}var pu=`An external member holds no Authelia groups — remove the groups first`;function mu({user:e,onClose:t,onSuccess:n}){let r=!!e,i=z(),a=j(),o=F(),[s,c]=(0,g.useState)({username:e?.username||``,displayname:e?.displayname||``,email:e?.email||``,password:``,groups:e?.groups?.join(`, `)||``}),l=Jc(e),[u,d]=(0,g.useState)(!1),[f,p]=(0,g.useState)(``),m=N({mutationFn:e=>o.createUser(e),onSuccess:e=>{cu(a),lu(i,e)}}),h=N({mutationFn:({username:e,...t})=>o.updateUser(e,t),onSuccess:e=>{cu(a),lu(i,e)}}),_=r?h:m;function v(e,t){c(n=>({...n,[e]:t})),p(``)}async function y(a){if(a.preventDefault(),p(``),!r){if(!s.username||!s.displayname||!s.email||!s.password){p(`All required fields must be filled`);return}if(!/^[a-z0-9_-]+$/.test(s.username)){p(`Username must contain only lowercase alphanumeric characters, underscores, and hyphens`);return}if(s.username.length<2){p(`Username must be at least 2 characters`);return}if(s.password.length<8){p(`Password must be at least 8 characters`);return}}if(r&&s.password&&s.password.length<8){p(`Password must be at least 8 characters`);return}let o=du(s.groups);if(l.external&&o.length>0){p(pu);return}try{if(r){let n={username:e.username};s.displayname!==e.displayname&&(n.displayname=s.displayname),s.email!==e.email&&(n.email=s.email),s.password&&(n.password=s.password);let r=(e.groups||[]).join(`, `);if(s.groups!==r&&(n.groups=o),Object.assign(n,l.editFields),Object.keys(n).length<=1){p(`No changes detected`);return}await _.mutateAsync(n),i(`User updated successfully`),t()}else{let e=await _.mutateAsync({username:s.username,displayname:s.displayname,email:s.email,password:s.password,groups:o,...l.createFields});i(`User created successfully`),n(e.user.username)}}catch(e){p(B(e))}}let b=_.isPending;return(0,A.jsxs)(au,{onClose:t,children:[(0,A.jsx)(`h2`,{className:`mb-4 text-lg font-bold text-white`,children:r?`Edit User`:`Add User`}),(0,A.jsxs)(`form`,{onSubmit:y,className:`space-y-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`mb-1 block text-sm text-zinc-400`,children:`Username`}),(0,A.jsx)(`input`,{type:`text`,value:s.username,onChange:e=>v(`username`,e.target.value),disabled:r,placeholder:`johndoe`,className:`w-full rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-2 text-sm text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none disabled:text-zinc-500`})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`mb-1 block text-sm text-zinc-400`,children:`Display Name`}),(0,A.jsx)(`input`,{type:`text`,value:s.displayname,onChange:e=>v(`displayname`,e.target.value),placeholder:`John Doe`,className:`w-full rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-2 text-sm text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`mb-1 block text-sm text-zinc-400`,children:`Email`}),(0,A.jsx)(`input`,{type:`email`,value:s.email,onChange:e=>v(`email`,e.target.value),placeholder:`john@example.com`,className:`w-full rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-2 text-sm text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`label`,{className:`mb-1 block text-sm text-zinc-400`,children:[`Password`,r?` (leave blank to keep current)`:``]}),(0,A.jsxs)(`div`,{className:`relative`,children:[(0,A.jsx)(`input`,{type:u?`text`:`password`,value:s.password,onChange:e=>v(`password`,e.target.value),placeholder:r?`Leave blank to keep current password`:`Minimum 8 characters`,className:`w-full rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-2 pr-10 text-sm text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>d(!u),className:`absolute right-3 top-1/2 -translate-y-1/2 text-zinc-500 hover:text-zinc-300`,children:u?(0,A.jsx)(Pi,{size:16}):(0,A.jsx)(Fi,{size:16})})]})]}),(0,A.jsx)(fu,{label:`Groups (comma-separated)`,value:s.groups,onChange:e=>v(`groups`,e),placeholder:`admins, users`,external:l.external}),(0,A.jsx)(Xc,{choice:l}),f&&(0,A.jsx)(`p`,{className:`text-sm text-red-400`,children:f}),(0,A.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:t,className:`flex-1 rounded-lg border border-zinc-700 px-4 py-2 text-sm text-zinc-400 hover:text-white`,children:`Cancel`}),(0,A.jsx)(`button`,{type:`submit`,disabled:b,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?`Saving...`:r?`Save Changes`:`Create User`})]})]})]})}function hu({onClose:e,onSuccess:t}){let n=z(),r=j(),i=F(),[a,o]=(0,g.useState)({username:``,email:``,groups:``}),s=Jc(null),[c,l]=(0,g.useState)(``),u=N({mutationFn:e=>i.createInvitation(e),onSuccess:()=>r.invalidateQueries({queryKey:[`invitations`]})});function d(e,t){o(n=>({...n,[e]:t})),l(``)}async function f(e){if(e.preventDefault(),l(``),!a.username||!a.email){l(`Username and email are required`);return}if(!/^[a-z0-9_-]+$/.test(a.username)){l(`Username must contain only lowercase alphanumeric characters, underscores, and hyphens`);return}if(a.username.length<2){l(`Username must be at least 2 characters`);return}let r=du(a.groups);if(s.external&&r.length>0){l(pu);return}try{let e=await u.mutateAsync({username:a.username,email:a.email,groups:r,...s.createFields});n(`Invitation created`),t(e)}catch(e){l(B(e))}}return(0,A.jsxs)(au,{onClose:e,children:[(0,A.jsx)(`h2`,{className:`mb-4 text-lg font-bold text-white`,children:`Invite User`}),(0,A.jsx)(`p`,{className:`mb-4 text-sm text-zinc-400`,children:`Generate an invitation link. The invited user will set their own password and TOTP.`}),(0,A.jsxs)(`form`,{onSubmit:f,className:`space-y-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`mb-1 block text-sm text-zinc-400`,children:`Username`}),(0,A.jsx)(`input`,{type:`text`,value:a.username,onChange:e=>d(`username`,e.target.value),placeholder:`johndoe`,className:`w-full rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-2 text-sm text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`mb-1 block text-sm text-zinc-400`,children:`Email`}),(0,A.jsx)(`input`,{type:`email`,value:a.email,onChange:e=>d(`email`,e.target.value),placeholder:`john@example.com`,className:`w-full rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-2 text-sm text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),(0,A.jsx)(fu,{label:`Groups (comma-separated, optional)`,value:a.groups,onChange:e=>d(`groups`,e),placeholder:`users`,external:s.external}),(0,A.jsx)(Xc,{choice:s}),c&&(0,A.jsx)(`p`,{className:`text-sm text-red-400`,children:c}),(0,A.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:e,className:`flex-1 rounded-lg border border-zinc-700 px-4 py-2 text-sm text-zinc-400 hover:text-white`,children:`Cancel`}),(0,A.jsx)(`button`,{type:`submit`,disabled:u.isPending,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:u.isPending?`Creating...`:`Create Invitation`})]})]})]})}function gu({inviteUrl:e,token:t,onClose:n}){let[r,i]=(0,g.useState)(!1),a=e||`(Domain not configured — token: ${t})`;function o(){let n=e||t;navigator.clipboard.writeText(n).then(()=>{i(!0),setTimeout(()=>i(!1),2e3)}).catch(()=>{})}return(0,A.jsxs)(au,{onClose:n,children:[(0,A.jsx)(`h2`,{className:`mb-4 text-lg font-bold text-white`,children:`Invitation Created`}),(0,A.jsx)(`p`,{className:`mb-4 text-sm text-zinc-400`,children:`Share this link with the invited user. It expires in 7 days.`}),(0,A.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 rounded-lg bg-zinc-900 px-4 py-3`,children:[(0,A.jsx)(`code`,{className:`flex-1 text-sm text-cyan-400 break-all`,children:a}),(0,A.jsx)(`button`,{type:`button`,onClick:o,className:`flex-shrink-0 text-zinc-500 hover:text-zinc-300`,title:`Copy link`,children:r?(0,A.jsx)(gi,{size:16,className:`text-green-400`}):(0,A.jsx)(Di,{size:16})})]}),!e&&(0,A.jsx)(`p`,{className:`mb-4 text-xs text-yellow-400`,children:`Domain is not configured. The invitation token has been created but cannot generate a full URL.`}),(0,A.jsx)(`button`,{type:`button`,onClick:n,className:`w-full rounded-lg bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500`,children:`Done`})]})}function _u({username:e,typed:t,onType:n}){return(0,A.jsxs)(`div`,{className:`mb-4 space-y-3 rounded-lg border border-red-500/30 bg-red-500/5 p-3`,children:[(0,A.jsxs)(`ul`,{className:`list-disc space-y-1 pl-5 text-xs text-zinc-400`,children:[(0,A.jsx)(`li`,{children:`The directory keeps the bare user id; the username, name and address it last had are scrubbed.`}),(0,A.jsx)(`li`,{children:`Their invitations and Gatekeeper's access-request log entries are deleted.`}),(0,A.jsx)(`li`,{children:`Every plugin that had them is sent the erasure: its agent half scrubs its record to the id and runs the plugin's anonymiser. The panel shows it pending until each acknowledges.`}),(0,A.jsx)(`li`,{children:`Authelia's own authentication log is outside Lamaste's reach and is not erased.`}),(0,A.jsx)(`li`,{className:`text-red-400`,children:`This cannot be undone.`})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`label`,{className:`mb-1 block text-xs text-zinc-400`,children:[`Type `,(0,A.jsx)(`span`,{className:`font-mono text-zinc-200`,children:e}),` to confirm`]}),(0,A.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),autoComplete:`off`,spellCheck:!1,className:`w-full rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-2 font-mono text-sm text-white focus:border-red-500 focus:outline-none`})]})]})}function vu({user:e,onConfirm:t,onCancel:n,isPending:r}){let[i,a]=(0,g.useState)(!1),[o,s]=(0,g.useState)(``),c=!i||o===e.username;return(0,A.jsxs)(au,{onClose:n,children:[(0,A.jsx)(`h2`,{className:`mb-2 text-lg font-bold text-white`,children:`Delete User`}),(0,A.jsxs)(`p`,{className:`mb-3 text-sm text-zinc-400`,children:[`Delete `,(0,A.jsx)(`span`,{className:`font-mono text-cyan-400`,children:e.username}),`? They can no longer sign in, their grants and group memberships are removed, and every plugin they used is told they were deleted.`]}),(0,A.jsx)(`p`,{className:`mb-4 text-xs text-zinc-500`,children:`The user directory keeps a tombstone — their user id with the name and address they last had — so what plugins recorded about them stays readable. A user created later under the same username is a new user with a new id.`}),(0,A.jsxs)(`label`,{className:`mb-3 flex items-start gap-2 text-sm text-zinc-300`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>{a(e.target.checked),s(``)},className:`mt-1`}),(0,A.jsx)(`span`,{children:`Also erase their personal data`})]}),i&&(0,A.jsx)(_u,{username:e.username,typed:o,onType:s}),(0,A.jsx)(ou,{confirmLabel:i?`Delete and erase`:`Delete`,destructive:!0,disabled:!c,isPending:r,onConfirm:()=>t(i),onCancel:n})]})}function yu({user:e,onConfirm:t,onCancel:n,isPending:r}){let[i,a]=(0,g.useState)(``);return(0,A.jsxs)(au,{onClose:n,children:[(0,A.jsx)(`h2`,{className:`mb-2 text-lg font-bold text-white`,children:`Erase Deleted User`}),(0,A.jsxs)(`p`,{className:`mb-3 text-sm text-zinc-400`,children:[`Erase what Lamaste keeps of `,(0,A.jsx)(`span`,{className:`font-mono text-cyan-400`,children:e.username}),` `,`(`,(0,A.jsx)(`span`,{className:`font-mono text-xs`,children:e.userId}),`)?`]}),(0,A.jsx)(_u,{username:e.username,typed:i,onType:a}),(0,A.jsx)(ou,{confirmLabel:`Erase`,destructive:!0,disabled:i!==e.username,isPending:r,onConfirm:t,onCancel:n})]})}function bu({status:e}){let t=e===`disabled`;return(0,A.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full border ${t?`text-yellow-400 bg-yellow-500/10 border-yellow-500/20`:`text-green-400 bg-green-500/10 border-green-500/20`}`,title:t?`Cannot sign in; every plugin audience shows them disabled; plugins’ user surfaces refuse them`:void 0,children:t?`disabled`:`active`})}function xu(e){return e.removedReason===`deleted-outside`?`gone from Authelia’s users file (not deleted through Lamaste)`:`deleted`}function Su(){let e=F(),t=j(),n=z(),[r,i]=(0,g.useState)(null),a=M({queryKey:[`user-directory`],queryFn:()=>e.getUserDirectory(),refetchInterval:3e4}),o=N({mutationFn:t=>e.eraseDirectoryUser(t),onSuccess:e=>{cu(t),t.invalidateQueries({queryKey:[`invitations`]}),n(`Erased — ${e.invitationsPurged} invitation(s) and ${e.accessLogPurged} access-log entr${e.accessLogPurged===1?`y`:`ies`} deleted; plugins are being told`),i(null)},onError:e=>{n(B(e),`error`),i(null)}}),s=a.dataUpdatedAt,c=(a.data?.users??[]).filter(e=>e.status===`removed`);return(0,A.jsxs)(`div`,{className:`mt-8`,children:[(0,A.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-end justify-between gap-2`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`h2`,{className:`flex items-center gap-2 text-lg font-bold text-white`,children:[(0,A.jsx)(si,{size:16,className:`text-zinc-400`}),`Deleted Users`]}),(0,A.jsx)(`p`,{className:`text-zinc-500 text-sm`,children:`Tombstones the directory keeps until they are erased, so plugins' history stays readable.`})]}),a.data?.directoryId&&(0,A.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-zinc-500`,children:[`directory `,(0,A.jsx)(iu,{id:a.data.directoryId})]})]}),(0,A.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-zinc-800 bg-zinc-900`,children:a.isLoading?(0,A.jsx)(`div`,{className:`p-6 text-center`,children:(0,A.jsx)(`div`,{className:`mx-auto h-6 w-6 animate-spin rounded-full border-2 border-zinc-600 border-t-cyan-400`})}):a.isError?(0,A.jsxs)(`div`,{className:`p-6 text-center text-red-400 text-sm`,children:[`Failed to load the user directory: `,B(a.error)]}):c.length===0?(0,A.jsx)(`div`,{className:`p-6 text-center text-zinc-500 text-sm`,children:`No deleted users.`}):(0,A.jsxs)(`table`,{className:`w-full text-left`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`border-b border-zinc-700`,children:[(0,A.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400`,children:`User`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400`,children:`User ID`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400 hidden sm:table-cell`,children:`Removed`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400`,children:`State`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400 text-right`,children:`Actions`})]})}),(0,A.jsx)(`tbody`,{children:c.map(e=>{let t=e.erasedAt!==null,n=e.principalClearedAt===null&&!t;return(0,A.jsxs)(`tr`,{className:`border-b border-zinc-700 last:border-b-0 align-top`,children:[(0,A.jsx)(`td`,{className:`px-4 py-3 text-sm`,children:t?(0,A.jsx)(`span`,{className:`text-zinc-600`,children:`erased`}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{className:`font-mono text-zinc-300`,children:e.username}),e.displayName&&(0,A.jsx)(`span`,{className:`block text-xs text-zinc-500`,children:e.displayName})]})}),(0,A.jsx)(`td`,{className:`px-4 py-3`,children:(0,A.jsx)(iu,{id:e.userId})}),(0,A.jsxs)(`td`,{className:`px-4 py-3 text-xs text-zinc-500 hidden sm:table-cell`,children:[xu(e),e.removedAt&&(0,A.jsx)(`span`,{className:`block`,title:new Date(e.removedAt).toLocaleString(),children:br(e.removedAt,s)})]}),(0,A.jsx)(`td`,{className:`px-4 py-3 text-xs`,children:t?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`span`,{className:`text-zinc-400`,children:[`erased `,br(e.erasedAt,s),e.erasure?.requestedBy?` by ${e.erasure.requestedBy}`:``]}),e.pendingErasures.length>0?(0,A.jsxs)(`span`,{className:`mt-0.5 flex items-start gap-1 text-amber-400`,children:[(0,A.jsx)(Mi,{size:11,className:`mt-0.5 shrink-0`}),(0,A.jsxs)(`span`,{children:[`waiting for`,` `,e.pendingErasures.map(t=>(e.pendingErasuresInactive??[]).includes(t)?`${t} (not taking the feed — an agent keeps its data)`:t).join(`, `),` `,`to acknowledge it`]})]}):(0,A.jsx)(`span`,{className:`block text-zinc-600`,children:`acknowledged by every plugin`})]}):n?(0,A.jsxs)(`span`,{className:`flex items-start gap-1 text-yellow-400`,title:`Until it is done, nothing — no user, grant or group membership — is given to this username again`,children:[(0,A.jsx)(ja,{size:11,className:`mt-0.5 shrink-0`}),(0,A.jsx)(`span`,{children:`Gatekeeper cleanup pending — retried every minute; the username cannot be reused until it is done`})]}):(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`tombstone`})}),(0,A.jsx)(`td`,{className:`px-4 py-3 text-right`,children:!t&&(0,A.jsxs)(`button`,{type:`button`,onClick:()=>i(e),className:`inline-flex items-center gap-1 rounded p-1.5 text-xs text-zinc-500 hover:bg-zinc-700 hover:text-red-400`,title:`Erase what Lamaste keeps of this user`,children:[(0,A.jsx)(Mi,{size:14}),`Erase`]})})]},e.userId)})})]})}),r&&(0,A.jsx)(yu,{user:r,onConfirm:()=>o.mutate(r.userId),onCancel:()=>i(null),isPending:o.isPending})]})}function Cu(){let e=z(),t=j(),n=F(),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(null),[l,u]=(0,g.useState)(null),[d,f]=(0,g.useState)(null),[p,m]=(0,g.useState)(null),[h,_]=(0,g.useState)(!1),[v,y]=(0,g.useState)(null),[b,x]=(0,g.useState)(null),{newUsersNeedDomains:S}=Gc(),C=M({queryKey:[`users`],queryFn:()=>n.getUsers(),refetchInterval:3e4}),w=N({mutationFn:({username:e,erase:t})=>n.deleteUser(e,{erase:t}),onSuccess:(n,{username:r,erase:i})=>{cu(t),i&&t.invalidateQueries({queryKey:[`invitations`]}),e(i&&n.erased?`User '${r}' deleted and erased`:`User '${r}' deleted — the directory keeps a tombstone`),n.principalCleared||e(`Gatekeeper has not dropped the grants and groups of '${r}' yet — retried every minute; the username cannot be reused until then`,`error`),lu(e,n),c(null)},onError:t=>{e(B(t),`error`),c(null)}}),T=N({mutationFn:({username:e,disabled:t})=>t?n.disableUser(e):n.enableUser(e),onSuccess:(n,{username:r,disabled:i})=>{cu(t),e(i?`User '${r}' disabled — signed out of the desktop, refused by every plugin`:`User '${r}' enabled`),lu(e,n),u(null)},onError:t=>{e(B(t),`error`),u(null)}}),E=N({mutationFn:e=>n.resetTotp(e),onSuccess:e=>{m(null),f(e.totpUri)},onError:t=>{e(B(t),`error`),m(null)}}),D=M({queryKey:[`invitations`],queryFn:()=>n.getInvitations()}),ee=N({mutationFn:e=>n.revokeInvitation(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`invitations`]}),e(`Invitation revoked`),x(null)},onError:t=>{e(B(t),`error`),x(null)}}),te=C.data?.users||[],ne=D.data?.invitations||[],re=te.length<=1;async function ie(e){i(!1);try{f((await E.mutateAsync(e)).totpUri)}catch{}}function ae(e){m(e)}function oe(){p&&E.mutate(p)}function se(){f(null)}return(0,A.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,A.jsxs)(`div`,{className:`mb-6 flex items-center justify-between`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Users`}),(0,A.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`Manage Authelia users, two-factor authentication, and what the user directory keeps of them.`})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsxs)(`button`,{type:`button`,onClick:()=>_(!0),className:`flex items-center gap-2 rounded-lg border border-zinc-700 px-4 py-2 text-sm font-semibold text-zinc-300 hover:border-cyan-500 hover:text-white`,children:[(0,A.jsx)(na,{size:16}),`Invite User`]}),(0,A.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`flex items-center gap-2 rounded-lg bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500`,children:[(0,A.jsx)(Ra,{size:16}),`Add User`]})]})]}),(0,A.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-zinc-800 bg-zinc-900`,children:C.isLoading?(0,A.jsx)(`div`,{className:`p-8 text-center`,children:(0,A.jsx)(`div`,{className:`mx-auto h-6 w-6 animate-spin rounded-full border-2 border-zinc-600 border-t-cyan-400`})}):C.isError?(0,A.jsx)(`div`,{className:`p-8 text-center text-red-400 text-sm`,children:`Failed to load users`}):te.length===0?(0,A.jsx)(`div`,{className:`p-8 text-center text-zinc-500 text-sm`,children:`No users configured. Add your first user to get started.`}):(0,A.jsxs)(`table`,{className:`w-full text-left`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`border-b border-zinc-700`,children:[(0,A.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400`,children:`Username`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400`,children:`Display Name`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400 hidden sm:table-cell`,children:`Email`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400 hidden md:table-cell`,children:`Groups`}),S&&(0,A.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400 hidden md:table-cell`,children:`Domains`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400`,children:`Status`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400 hidden lg:table-cell`,children:`User ID`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400 text-right`,children:`Actions`})]})}),(0,A.jsx)(`tbody`,{children:te.map(e=>{let t=e.status===`disabled`,n=Gl(e,te);return(0,A.jsxs)(`tr`,{className:`border-b border-zinc-700 last:border-b-0`,children:[(0,A.jsxs)(`td`,{className:`px-4 py-3 font-mono text-sm ${t?`text-zinc-500`:`text-cyan-400`}`,children:[e.username,Vc(e.domains)&&(0,A.jsx)(`span`,{className:`ml-2`,children:(0,A.jsx)(Yc,{})})]}),(0,A.jsx)(`td`,{className:`px-4 py-3 text-sm text-zinc-300`,children:e.displayname}),(0,A.jsx)(`td`,{className:`px-4 py-3 text-sm text-zinc-400 hidden sm:table-cell`,children:e.email}),(0,A.jsx)(`td`,{className:`px-4 py-3 hidden md:table-cell`,children:(0,A.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:(e.groups||[]).map(e=>(0,A.jsx)(`span`,{className:`rounded bg-zinc-700 px-2 py-0.5 text-xs text-zinc-300`,children:e},e))})}),S&&(0,A.jsx)(`td`,{className:`px-4 py-3 hidden md:table-cell`,children:(0,A.jsx)(Zc,{domains:e.domains})}),(0,A.jsx)(`td`,{className:`px-4 py-3`,children:(0,A.jsx)(bu,{status:e.status})}),(0,A.jsx)(`td`,{className:`px-4 py-3 hidden lg:table-cell`,children:(0,A.jsx)(iu,{id:e.userId,missing:`Not in the user directory yet — it adopts new users within a minute`})}),(0,A.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,A.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>o(e),className:`rounded p-1.5 text-zinc-500 hover:bg-zinc-700 hover:text-zinc-300`,title:`Edit user`,children:(0,A.jsx)(ca,{size:14})}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>ae(e.username),className:`rounded p-1.5 text-zinc-500 hover:bg-zinc-700 hover:text-zinc-300`,title:`Reset TOTP`,children:(0,A.jsx)(qi,{size:14})}),t?(0,A.jsx)(`button`,{type:`button`,onClick:()=>T.mutate({username:e.username,disabled:!1}),disabled:T.isPending,className:`rounded p-1.5 text-zinc-500 hover:bg-zinc-700 hover:text-green-400 disabled:opacity-30`,title:`Enable user`,children:(0,A.jsx)(Ia,{size:14})}):(0,A.jsx)(`button`,{type:`button`,onClick:()=>!n&&u(e.username),disabled:n,className:`rounded p-1.5 text-zinc-500 hover:bg-zinc-700 hover:text-yellow-400 disabled:cursor-not-allowed disabled:opacity-30`,title:n?`Cannot disable the last enabled administrator`:`Disable user`,children:(0,A.jsx)(za,{size:14})}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>!re&&c(e),disabled:re,className:`rounded p-1.5 text-zinc-500 hover:bg-zinc-700 hover:text-red-400 disabled:cursor-not-allowed disabled:opacity-30`,title:re?`Cannot delete the last user`:`Delete user`,children:(0,A.jsx)(R,{size:14})})]})})]},e.username)})})]})}),(0,A.jsxs)(`div`,{className:`mt-8 mb-6`,children:[(0,A.jsx)(`h2`,{className:`text-lg font-bold text-white mb-1`,children:`Invitations`}),(0,A.jsx)(`p`,{className:`text-zinc-500 text-sm`,children:`Pending and past invitation links.`})]}),(0,A.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-zinc-800 bg-zinc-900`,children:D.isLoading?(0,A.jsx)(`div`,{className:`p-8 text-center`,children:(0,A.jsx)(`div`,{className:`mx-auto h-6 w-6 animate-spin rounded-full border-2 border-zinc-600 border-t-cyan-400`})}):D.isError?(0,A.jsx)(`div`,{className:`p-8 text-center text-red-400 text-sm`,children:`Failed to load invitations`}):ne.length===0?(0,A.jsx)(`div`,{className:`p-8 text-center text-zinc-500 text-sm`,children:`No invitations yet. Click "Invite User" to generate a link.`}):(0,A.jsxs)(`table`,{className:`w-full text-left`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`border-b border-zinc-700`,children:[(0,A.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400`,children:`Username`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400 hidden sm:table-cell`,children:`Email`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400`,children:`Status`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400 hidden md:table-cell`,children:`Expires`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400 text-right`,children:`Actions`})]})}),(0,A.jsx)(`tbody`,{children:ne.map(e=>(0,A.jsxs)(`tr`,{className:`border-b border-zinc-700 last:border-b-0`,children:[(0,A.jsxs)(`td`,{className:`px-4 py-3 font-mono text-sm text-cyan-400`,children:[e.username,Vc(e.domains)&&(0,A.jsx)(`span`,{className:`ml-2`,children:(0,A.jsx)(Yc,{})})]}),(0,A.jsx)(`td`,{className:`px-4 py-3 text-sm text-zinc-400 hidden sm:table-cell`,children:e.email}),(0,A.jsx)(`td`,{className:`px-4 py-3`,children:(0,A.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full border ${e.status===`accepted`?`text-green-400 bg-green-500/10 border-green-500/20`:e.status===`expired`?`text-zinc-500 bg-zinc-800 border-zinc-700`:`text-yellow-400 bg-yellow-500/10 border-yellow-500/20`}`,children:e.status})}),(0,A.jsx)(`td`,{className:`px-4 py-3 text-sm text-zinc-500 hidden md:table-cell`,children:new Date(e.expiresAt).toLocaleDateString()}),(0,A.jsx)(`td`,{className:`px-4 py-3 text-right`,children:e.status===`pending`&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>x(e.id),className:`rounded p-1.5 text-zinc-500 hover:bg-zinc-700 hover:text-red-400`,title:`Revoke invitation`,children:(0,A.jsx)(wi,{size:14})})})]},e.id))})]})}),h&&(0,A.jsx)(hu,{onClose:()=>_(!1),onSuccess:e=>{_(!1),y(e)}}),v&&(0,A.jsx)(gu,{inviteUrl:v.inviteUrl,token:v.token,onClose:()=>y(null)}),b&&(0,A.jsx)(su,{title:`Revoke Invitation`,message:`Are you sure you want to revoke this invitation? The link will no longer work.`,confirmLabel:`Revoke`,destructive:!0,onConfirm:()=>ee.mutate(b),onCancel:()=>x(null),isPending:ee.isPending}),r&&(0,A.jsx)(mu,{onClose:()=>i(!1),onSuccess:ie}),a&&(0,A.jsx)(mu,{user:a,onClose:()=>o(null)}),s&&(0,A.jsx)(vu,{user:s,onConfirm:e=>w.mutate({username:s.username,erase:e}),onCancel:()=>c(null),isPending:w.isPending}),l&&(0,A.jsx)(su,{title:`Disable User`,message:`Disable '${l}'? They can no longer sign in; their desktop sessions and registry tokens end; every plugin's audience shows them disabled and plugins' user surfaces refuse them at once. Nothing is deleted — enable them again at any time.`,confirmLabel:`Disable`,destructive:!0,onConfirm:()=>T.mutate({username:l,disabled:!0}),onCancel:()=>u(null),isPending:T.isPending}),p&&!d&&(0,A.jsx)(su,{title:`Reset TOTP`,message:`This will invalidate the current TOTP secret for '${p}'. They will need to re-enroll their authenticator app.`,confirmLabel:`Reset TOTP`,onConfirm:oe,onCancel:()=>m(null),isPending:E.isPending}),d&&(0,A.jsx)(uu,{totpUri:d,onClose:se}),(0,A.jsx)(Su,{}),(0,A.jsx)(wu,{})]})}function wu(){let e=F(),[t,n]=(0,g.useState)(!1),r=M({queryKey:[`identity-groups`],queryFn:()=>e.getIdentityGroups(),retry:!1,staleTime:6e4}),i=M({queryKey:[`identity-self`],queryFn:()=>e.getIdentitySelf(),retry:!1,staleTime:6e4,enabled:t}),a=r.data?.groups||[];return(0,A.jsxs)(`div`,{className:`mt-8 border-t border-zinc-700 pt-6`,children:[(0,A.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:`flex items-center gap-2 text-lg font-semibold text-white hover:text-zinc-300 w-full text-left`,children:[(0,A.jsx)(Ri,{size:18,className:`text-cyan-400`}),`Identity & Groups`,t?(0,A.jsx)(bi,{size:16,className:`text-zinc-500 ml-auto`}):(0,A.jsx)(_i,{size:16,className:`text-zinc-500 ml-auto`})]}),t&&(0,A.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[i.data&&(0,A.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-4`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-medium text-zinc-400 mb-2`,children:`Your Identity (via Authelia)`}),(0,A.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-sm`,children:[(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`Username:`}),(0,A.jsx)(`span`,{className:`text-zinc-200`,children:i.data.username||`—`}),(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`Display Name:`}),(0,A.jsx)(`span`,{className:`text-zinc-200`,children:i.data.displayName||`—`}),(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`Email:`}),(0,A.jsx)(`span`,{className:`text-zinc-200`,children:i.data.email||`—`}),(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`Groups:`}),(0,A.jsx)(`span`,{className:`text-zinc-200`,children:i.data.groups?.length>0?i.data.groups.join(`, `):`—`})]})]}),i.isError&&(0,A.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-4`,children:(0,A.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Identity information is only available when accessing the panel through an Authelia-protected domain.`})}),r.isLoading?(0,A.jsx)(`div`,{className:`h-10 animate-pulse rounded-lg bg-zinc-900 border border-zinc-800`}):a.length>0?(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h3`,{className:`text-sm font-medium text-zinc-400 mb-2`,children:`All Groups`}),(0,A.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:a.map(e=>(0,A.jsx)(`span`,{className:`text-xs px-2.5 py-1 rounded-full bg-cyan-500/10 text-cyan-400 border border-cyan-500/20`,children:e},e))})]}):(0,A.jsx)(`p`,{className:`text-sm text-zinc-500`,children:`No groups defined in Authelia.`})]})]})}function Tu(e){return e.os===`darwin`?`macOS`:e.distro?[e.distro.id,e.distro.versionId].filter(Boolean).join(` `):`Linux`}function Eu({facts:e,at:t}){if(!e)return(0,A.jsx)(`span`,{className:`text-xs text-zinc-600`,title:`The agent reports its host on its sync — it has not yet (sync not running, or lamaste-agent too old)`,children:`host not reported`});let n=e.os===`linux`,r=[Tu(e),e.arch,`Node ${e.node}`];return n&&r.push(e.systemd?`systemd`:`no systemd`),(0,A.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-1.5 text-xs text-zinc-500`,children:[(0,A.jsx)(Oi,{size:11,className:`shrink-0 text-zinc-600`}),r.map((e,t)=>(0,A.jsxs)(`span`,{className:`whitespace-nowrap`,children:[t>0&&`· `,e]},`${t}-${e}`)),n&&(e.apphost?(0,A.jsxs)(`span`,{className:`whitespace-nowrap text-cyan-400`,title:`The app host helper is enabled: Lamaste can install agent halves here`,children:[`· app host v`,e.apphost.version,e.apphost.relayKid?(0,A.jsxs)(`span`,{className:`text-zinc-500`,title:`The helper runs app jobs signed with relay key ${e.apphost.relayKid}`,children:[` `,`(relay key `,e.apphost.relayKid.slice(0,12),`)`]}):(0,A.jsxs)(`span`,{className:`text-yellow-400`,title:`The helper has no key of this relay pinned and runs none of its app jobs: sudo lamaste-agent apphost pin`,children:[` `,`(no relay key pinned)`]})]}):(0,A.jsx)(`span`,{className:`whitespace-nowrap text-zinc-600`,title:`Enable it on the agent with: sudo lamaste-agent apphost enable`,children:`· app host off`})),t&&(0,A.jsxs)(`span`,{className:`whitespace-nowrap text-zinc-600`,children:[`· reported `,new Date(t).toLocaleString()]})]})}function Du({type:e}){return(0,A.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full ${{letsencrypt:`bg-blue-500/20 text-blue-400`,"mtls-ca":`bg-purple-500/20 text-purple-400`,"mtls-client":`bg-purple-500/20 text-purple-400`}[e]||`bg-zinc-500/20 text-zinc-400`}`,children:{letsencrypt:`Let's Encrypt`,"mtls-ca":`mTLS CA`,"mtls-client":`mTLS Client`}[e]||e})}function Ou({days:e}){let t=`text-green-400`,n=`bg-green-400`;return e<=7?(t=`text-red-400`,n=`bg-red-400`):e<=30&&(t=`text-amber-400`,n=`bg-amber-400`),(0,A.jsxs)(`span`,{className:`flex items-center gap-1.5 ${t}`,children:[(0,A.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full ${n}`}),e,`d`]})}function ku(e){if(!e)return`N/A`;try{return new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})}catch{return e}}function Au({data:e,isLoading:t}){return t?(0,A.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm text-zinc-500`,children:[(0,A.jsx)(L,{size:14,className:`animate-spin`}),`Checking auto-renewal status...`]}):e?e.active?(0,A.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-x-4 gap-y-1 text-sm text-zinc-400`,children:[(0,A.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,A.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-green-400`}),`Auto-renewal active`]}),e.nextRun&&(0,A.jsxs)(`span`,{children:[`Next run: `,ku(e.nextRun)]}),e.lastRun&&(0,A.jsxs)(`span`,{children:[`Last renewed: `,ku(e.lastRun)]})]}):(0,A.jsxs)(`div`,{className:`mb-4 flex items-center gap-1.5 text-sm text-amber-400`,children:[(0,A.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-red-400`}),`Auto-renewal is not active. Certificates may expire.`]}):null}function ju({certs:e,onRenew:t,renewingDomain:n}){let r=e.filter(e=>e.type===`letsencrypt`);return r.length===0?(0,A.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,A.jsx)(`p`,{className:`text-zinc-500 text-sm text-center`,children:`No Let's Encrypt certificates found.`})}):(0,A.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-zinc-800`,children:(0,A.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-900`,children:[(0,A.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Type`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Domain`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Expiry Date`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Days Remaining`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Actions`})]})}),(0,A.jsx)(`tbody`,{children:r.map(e=>(0,A.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-800`,children:[(0,A.jsx)(`td`,{className:`px-4 py-3`,children:(0,A.jsx)(Du,{type:e.type})}),(0,A.jsx)(`td`,{className:`px-4 py-3 text-zinc-300 font-mono text-xs`,children:e.domain||`N/A`}),(0,A.jsx)(`td`,{className:`px-4 py-3 text-zinc-400`,children:ku(e.expiresAt)}),(0,A.jsx)(`td`,{className:`px-4 py-3`,children:(0,A.jsx)(Ou,{days:e.daysUntilExpiry})}),(0,A.jsx)(`td`,{className:`px-4 py-3`,children:(0,A.jsx)(`button`,{type:`button`,disabled:!!n,onClick:()=>t(e.domain),className:`flex items-center gap-1.5 rounded bg-zinc-700 px-3 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600 disabled:opacity-50 disabled:cursor-not-allowed`,children:n===e.domain?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{size:12,className:`animate-spin`}),`Renewing...`]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(pa,{size:12}),`Renew`]})})})]},e.domain||e.path))})]})})}function Mu({certs:e,onRotate:t,adminAuthMode:n}){let r=e.find(e=>e.type===`mtls-ca`),i=e.find(e=>e.type===`mtls-client`),a=n===`hardware-bound`;return!r&&!i?null:(0,A.jsx)(`div`,{className:`mt-8`,children:(0,A.jsxs)(`div`,{className:`border-t border-zinc-700 pt-6`,children:[(0,A.jsxs)(`h2`,{className:`text-lg font-semibold text-white mb-4 flex items-center gap-2`,children:[(0,A.jsx)(Ta,{size:18,className:`text-purple-400`}),`mTLS Certificates`,a&&(0,A.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full border text-emerald-400 bg-emerald-500/10 border-emerald-500/20`,children:`hardware-bound`})]}),(0,A.jsxs)(`div`,{className:`space-y-4`,children:[r&&(0,A.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-5`,children:[(0,A.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,A.jsx)(Du,{type:`mtls-ca`}),(0,A.jsx)(`span`,{className:`text-white font-semibold text-sm`,children:`Certificate Authority`})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-4 text-sm text-zinc-400 mt-2`,children:[(0,A.jsxs)(`span`,{children:[`Expires: `,ku(r.expiresAt)]}),(0,A.jsx)(Ou,{days:r.daysUntilExpiry})]})]})}),(0,A.jsx)(`p`,{className:`text-xs text-zinc-500 mt-3`,children:`The CA certificate cannot be rotated. It was created during initial setup.`})]}),i&&(0,A.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-5`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,A.jsx)(Du,{type:`mtls-client`}),(0,A.jsx)(`span`,{className:`text-white font-semibold text-sm`,children:`Client Certificate`})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-4 text-sm text-zinc-400 mt-2`,children:[(0,A.jsxs)(`span`,{children:[`Expires: `,ku(i.expiresAt)]}),(0,A.jsx)(Ou,{days:i.daysUntilExpiry})]})]}),!a&&(0,A.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-1.5 rounded bg-amber-600 px-3 py-1.5 text-xs text-white hover:bg-amber-500`,children:[(0,A.jsx)(pa,{size:12}),`Rotate`]})]}),a&&(0,A.jsxs)(`p`,{className:`text-xs text-emerald-400/70 mt-3`,children:[`Admin uses a hardware-bound certificate. P12 download and rotation are disabled. To revert, run`,` `,(0,A.jsx)(`code`,{className:`bg-zinc-800 px-1 py-0.5 rounded`,children:`sudo lamaste-reset-admin`}),` `,`on the server.`]})]})]})]})})}function Nu({status:e}){return(0,A.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full border ${{active:`text-green-400 bg-green-500/10 border-green-500/20`,"expiring-soon":`text-yellow-400 bg-yellow-500/10 border-yellow-500/20`,expired:`text-red-400 bg-red-500/10 border-red-500/20`,revoked:`text-red-400 bg-red-500/10 border-red-500/20`}[e]||`text-zinc-500 bg-zinc-800 border-zinc-700`}`,children:{active:`active`,"expiring-soon":`expiring soon`,expired:`expired`,revoked:`revoked`}[e]||e})}function Pu({method:e}){return e===`hardware-bound`?(0,A.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full border text-emerald-400 bg-emerald-500/10 border-emerald-500/20`,children:`hardware-bound`}):e===`delegated`?(0,A.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full border text-violet-400 bg-violet-500/10 border-violet-500/20`,children:`delegated`}):(0,A.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full border text-zinc-500 bg-zinc-800 border-zinc-700`,children:`p12`})}function Fu(e){if(!e.startsWith(`plugin-agent:`))return null;let t=e.split(`:`);return t.length>=3?{displayName:t.slice(2).join(`:`),viaAgent:t[1]}:null}function Iu({label:e}){let t=Fu(e);return t?(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{className:`text-zinc-200 font-semibold`,children:t.displayName}),(0,A.jsxs)(`span`,{className:`block text-xs text-zinc-500 mt-0.5`,title:e,children:[`via `,t.viaAgent]})]}):(0,A.jsx)(`span`,{className:`text-zinc-200 font-semibold`,children:e})}var Lu=[{value:`tunnels:read`,label:`tunnels:read`,description:`List tunnels and download plist`,mandatory:!0},{value:`tunnels:write`,label:`tunnels:write`,description:`Create and delete tunnels`},{value:`services:read`,label:`services:read`,description:`View service status`},{value:`services:write`,label:`services:write`,description:`Start/stop/restart services`},{value:`system:read`,label:`system:read`,description:`View system stats (CPU, RAM, disk)`},{value:`sites:read`,label:`sites:read`,description:`List sites and browse files`},{value:`sites:write`,label:`sites:write`,description:`Create, delete, and deploy to sites`},{value:`panel:expose`,label:`panel:expose`,description:`Expose agent management panel at agent-<label>.<domain>`},{value:`identity:read`,label:`identity:read`,description:`Parse Authelia identity headers on plugin routes`},{value:`identity:query`,label:`identity:query`,description:`Query panel for Authelia user metadata`}];function Ru({capabilities:e,onChange:t,disabled:n}){let r=n=>{n!==`tunnels:read`&&(e.includes(n)?t(e.filter(e=>e!==n)):t([...e,n]))};return(0,A.jsx)(`div`,{className:`space-y-2`,children:Lu.map(t=>(0,A.jsxs)(`label`,{className:`flex items-start gap-3 rounded border px-3 py-2 cursor-pointer ${e.includes(t.value)?`border-cyan-500/30 bg-cyan-500/5`:`border-zinc-700 bg-zinc-800/50`} ${t.mandatory||n?`opacity-80`:``}`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:e.includes(t.value),onChange:()=>r(t.value),disabled:t.mandatory||n,className:`mt-0.5 accent-cyan-500`}),(0,A.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,A.jsx)(`span`,{className:`text-sm font-mono text-zinc-200`,children:t.label}),(0,A.jsx)(`p`,{className:`text-xs text-zinc-500`,children:t.description})]})]},t.value))})}function zu({onClose:e}){let t=F(),n=j(),r=z(),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)([`tunnels:read`]),[c,l]=(0,g.useState)([]),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)(!1),[m,h]=(0,g.useState)(null),{data:_}=M({queryKey:[`sites`],queryFn:()=>t.getSites()}),v=N({mutationFn:e=>t.generateAgentCert(e),onSuccess:e=>{d(e),n.invalidateQueries({queryKey:[`agent-certs`]})},onError:e=>{h(B(e))}}),y=(0,g.useCallback)(e=>{if(e.preventDefault(),h(null),!i.trim()){h(`Label is required`);return}if(!/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/.test(i)){h(`Lowercase letters, numbers, and hyphens only. Cannot start or end with a hyphen.`);return}v.mutate({label:i,capabilities:o,allowedSites:c})},[i,o,c,v]),b=(0,g.useCallback)(async()=>{if(u?.p12Password)try{await navigator.clipboard.writeText(u.p12Password),p(!0),setTimeout(()=>p(!1),2e3)}catch{r(`Failed to copy — please select and copy manually`,`error`)}},[u,r]),x=(0,g.useCallback)(()=>{u?.label&&t.downloadAgentCert(u.label)},[u,t]),S=(0,g.useCallback)(()=>{e()},[e]);return(0,A.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4`,children:(0,A.jsxs)(`div`,{className:`w-full max-w-lg rounded-lg bg-zinc-900 border border-zinc-800 shadow-xl`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between border-b border-zinc-800 px-6 py-4`,children:[(0,A.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold text-white`,children:[(0,A.jsx)(Ji,{size:20,className:`text-cyan-400`}),u?`Certificate Generated`:`Generate Agent Certificate`]}),!v.isPending&&(0,A.jsx)(`button`,{type:`button`,onClick:S,className:`text-zinc-500 hover:text-zinc-300`,children:(0,A.jsx)(Ga,{size:18})})]}),(0,A.jsx)(`div`,{className:`px-6 py-5`,children:u?(0,A.jsxs)(`div`,{className:`space-y-5`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`text-sm font-medium text-zinc-300 block mb-2`,children:`Certificate Password:`}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`div`,{className:`flex-1 rounded border border-zinc-700 bg-zinc-950 p-3 font-mono text-yellow-400 text-sm break-all select-all`,children:u.p12Password}),(0,A.jsx)(`button`,{type:`button`,onClick:b,className:`rounded bg-zinc-700 p-2 text-zinc-300 hover:bg-zinc-600 shrink-0`,title:`Copy password`,children:f?(0,A.jsx)(gi,{size:16,className:`text-green-400`}):(0,A.jsx)(Di,{size:16})})]})]}),(0,A.jsxs)(`div`,{className:`rounded-lg bg-amber-500/10 border border-amber-500/20 p-4 text-sm text-amber-400 space-y-1`,children:[(0,A.jsx)(`p`,{className:`font-semibold`,children:`Save this password — it cannot be retrieved later.`}),(0,A.jsx)(`p`,{children:`Share the .p12 file and password securely with the Mac user.`})]}),(0,A.jsxs)(`button`,{type:`button`,onClick:x,className:`flex w-full items-center justify-center gap-2 rounded bg-cyan-600 py-3 px-6 text-sm font-semibold text-white hover:bg-cyan-500`,children:[(0,A.jsx)(Ai,{size:16}),`Download `,u.label,`.p12`]}),(0,A.jsx)(`div`,{className:`flex justify-end`,children:(0,A.jsx)(`button`,{type:`button`,onClick:S,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:`Done`})})]}):(0,A.jsxs)(`form`,{onSubmit:y,className:`space-y-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Label`}),(0,A.jsx)(`input`,{type:`text`,value:i,onChange:e=>{a(e.target.value.toLowerCase()),h(null)},disabled:v.isPending,placeholder:`e.g. macbook-pro`,className:`w-full 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`}),(0,A.jsx)(`p`,{className:`text-xs text-zinc-500 mt-1`,children:`Lowercase letters, numbers, and hyphens only.`})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-2`,children:`Capabilities`}),(0,A.jsx)(Ru,{capabilities:o,onChange:s,disabled:v.isPending})]}),(o.includes(`sites:read`)||o.includes(`sites:write`))&&(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-2`,children:`Site Access`}),(0,A.jsx)(`p`,{className:`text-xs text-zinc-500 mb-2`,children:`Select which static sites this agent can manage files for.`}),_?.sites?.length>0?(0,A.jsx)(`div`,{className:`space-y-1`,children:_.sites.map(e=>(0,A.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-zinc-300 cursor-pointer`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:c.includes(e.name),onChange:()=>{l(t=>t.includes(e.name)?t.filter(t=>t!==e.name):[...t,e.name])},disabled:v.isPending,className:`rounded border-zinc-600 bg-zinc-800 text-cyan-400 focus:ring-cyan-400`}),(0,A.jsx)(`span`,{className:`font-mono`,children:e.name}),(0,A.jsxs)(`span`,{className:`text-zinc-500 text-xs`,children:[`(`,e.fqdn,`)`]})]},e.id))}):(0,A.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`No sites created yet.`})]}),m&&(0,A.jsx)(`div`,{className:`rounded bg-red-500/10 border border-red-500/20 px-3 py-2 text-sm text-red-400`,children:m}),(0,A.jsxs)(`div`,{className:`flex items-center gap-3 justify-end`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:S,disabled:v.isPending,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Cancel`}),(0,A.jsx)(`button`,{type:`submit`,disabled:v.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:v.isPending?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{size:14,className:`animate-spin`}),`Generating...`]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(Ji,{size:14}),`Generate`]})})]})]})})]})})}function Bu({label:e,onConfirm:t,onCancel:n,isPending:r}){return(0,A.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:(0,A.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,A.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:`Revoke Certificate`}),(0,A.jsxs)(`p`,{className:`text-zinc-400 text-sm mb-6`,children:[`Revoke certificate for ‘`,(0,A.jsx)(`span`,{className:`text-cyan-400 font-mono`,children:e}),`’? The Mac agent using this certificate will immediately lose access.`]}),(0,A.jsxs)(`div`,{className:`flex items-center justify-end gap-3`,children:[(0,A.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,A.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,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{size:14,className:`animate-spin`}),`Revoking...`]}):`Revoke`})]})]})})}function Vu({agent:e,onClose:t}){let n=F(),r=j(),i=z(),[a,o]=(0,g.useState)(e.capabilities||[`tunnels:read`]),s=N({mutationFn:t=>n.updateAgentCapabilities(e.label,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`agent-certs`]}),i(`Capabilities updated for ${e.label}`),t()},onError:e=>{i(B(e),`error`)}});return(0,A.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4`,children:(0,A.jsxs)(`div`,{className:`w-full max-w-lg rounded-lg bg-zinc-900 border border-zinc-800 shadow-xl`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between border-b border-zinc-800 px-6 py-4`,children:[(0,A.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold text-white`,children:[(0,A.jsx)(Ca,{size:20,className:`text-cyan-400`}),`Capabilities — `,e.label]}),(0,A.jsx)(`button`,{type:`button`,onClick:t,className:`text-zinc-500 hover:text-zinc-300`,children:(0,A.jsx)(Ga,{size:18})})]}),(0,A.jsxs)(`div`,{className:`px-6 py-5 space-y-4`,children:[(0,A.jsx)(Ru,{capabilities:a,onChange:o,disabled:s.isPending}),(0,A.jsxs)(`div`,{className:`flex items-center gap-3 justify-end`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:t,disabled:s.isPending,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Cancel`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>s.mutate(a),disabled:s.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`,children:s.isPending?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{size:14,className:`animate-spin`}),`Saving...`]}):`Save`})]})]})]})})}function Hu({agent:e,onClose:t}){let n=F(),r=j(),i=z(),[a,o]=(0,g.useState)(e.allowedSites||[]),{data:s}=M({queryKey:[`sites`],queryFn:()=>n.getSites()}),c=N({mutationFn:t=>n.updateAgentAllowedSites(e.label,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`agent-certs`]}),i(`Allowed sites updated for ${e.label}`),t()},onError:e=>{i(B(e),`error`)}});return(0,A.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4`,children:(0,A.jsxs)(`div`,{className:`w-full max-w-lg rounded-lg bg-zinc-900 border border-zinc-800 shadow-xl`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between border-b border-zinc-800 px-6 py-4`,children:[(0,A.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold text-white`,children:[(0,A.jsx)(Hi,{size:20,className:`text-cyan-400`}),`Site Access — `,e.label]}),(0,A.jsx)(`button`,{type:`button`,onClick:t,className:`text-zinc-500 hover:text-zinc-300`,children:(0,A.jsx)(Ga,{size:18})})]}),(0,A.jsxs)(`div`,{className:`px-6 py-5 space-y-4`,children:[(0,A.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Select which static sites this agent can manage files for.`}),s?.sites?.length>0?(0,A.jsx)(`div`,{className:`space-y-1`,children:s.sites.map(e=>(0,A.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-zinc-300 cursor-pointer`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:a.includes(e.name),onChange:()=>{o(t=>t.includes(e.name)?t.filter(t=>t!==e.name):[...t,e.name])},disabled:c.isPending,className:`rounded border-zinc-600 bg-zinc-800 text-cyan-400 focus:ring-cyan-400`}),(0,A.jsx)(`span`,{className:`font-mono`,children:e.name}),(0,A.jsxs)(`span`,{className:`text-zinc-500 text-xs`,children:[`(`,e.fqdn,`)`]})]},e.id))}):(0,A.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`No sites created yet.`}),(0,A.jsxs)(`div`,{className:`flex items-center gap-3 justify-end`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:t,disabled:c.isPending,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Cancel`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>c.mutate(a),disabled:c.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`,children:c.isPending?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{size:14,className:`animate-spin`}),`Saving...`]}):`Save`})]})]})]})})}function Uu({onClose:e}){let t=F(),n=j(),[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)([`tunnels:read`]),[s,c]=(0,g.useState)([]),[l,u]=(0,g.useState)(null),[d,f]=(0,g.useState)(null),[p,m]=(0,g.useState)(!1),[h,_]=(0,g.useState)(!1),[v,y]=(0,g.useState)(!1),{data:b}=M({queryKey:[`sites`],queryFn:()=>t.getSites()}),x=N({mutationFn:e=>t.createEnrollmentToken(e),onSuccess:e=>{u(e),n.invalidateQueries({queryKey:[`agent-certs`]})},onError:e=>{f(B(e))}}),S=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(r),C=()=>{f(null),x.mutate({label:r,capabilities:a,allowedSites:s})},w=async()=>{if(l?.token)try{await navigator.clipboard.writeText(l.token),m(!0),setTimeout(()=>m(!1),2e3)}catch{}},T=l?`npx @lamalibre/lamaste-agent setup --token ${l.token} --panel-url <PANEL_URL>`:``;return(0,A.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,A.jsxs)(`div`,{className:`w-full max-w-lg rounded-xl bg-zinc-900 border border-zinc-700 p-6 shadow-xl`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,A.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:l?`Enrollment Token`:`Generate Enrollment Token`}),(0,A.jsx)(`button`,{type:`button`,onClick:e,className:`text-zinc-400 hover:text-white`,children:(0,A.jsx)(Ga,{size:20})})]}),l?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Agent Label`}),(0,A.jsx)(`p`,{className:`text-sm text-cyan-400 font-mono`,children:l.label})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Enrollment Token`}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`code`,{className:`flex-1 block rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-xs text-yellow-300 font-mono break-all`,children:l.token}),(0,A.jsx)(`button`,{type:`button`,onClick:w,className:`rounded bg-zinc-700 p-2 text-zinc-300 hover:bg-zinc-600`,title:`Copy token`,children:p?(0,A.jsx)(gi,{size:14,className:`text-green-400`}):(0,A.jsx)(Di,{size:14})})]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Expires`}),(0,A.jsxs)(`p`,{className:`text-sm text-zinc-400`,children:[new Date(l.expiresAt).toLocaleString(),` (10 minutes)`]})]}),(0,A.jsx)(`div`,{className:`rounded bg-amber-500/10 border border-amber-500/20 px-3 py-2`,children:(0,A.jsx)(`p`,{className:`text-sm text-amber-300`,children:`This token is single-use and expires in 10 minutes. Copy and send it to the agent machine now.`})}),d&&(0,A.jsx)(`div`,{className:`rounded bg-red-500/10 border border-red-500/20 px-3 py-2 text-sm text-red-400`,children:d}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Setup Command`}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`code`,{className:`flex-1 block rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-xs text-zinc-300 font-mono break-all`,children:T}),(0,A.jsx)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(T),_(!0),setTimeout(()=>_(!1),2e3)}catch{}},className:`rounded bg-zinc-700 p-2 text-zinc-300 hover:bg-zinc-600`,title:`Copy command`,children:h?(0,A.jsx)(gi,{size:14,className:`text-green-400`}):(0,A.jsx)(Di,{size:14})})]}),(0,A.jsx)(`p`,{className:`text-xs text-zinc-500 mt-1`,children:`Replace <PANEL_URL> with your panel address (e.g. https://1.2.3.4:9292)`})]})]}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-3 mt-6`,children:[(0,A.jsxs)(`button`,{type:`button`,disabled:v,onClick:async()=>{y(!0);try{await t.revokeEnrollmentToken(l.label),n.invalidateQueries({queryKey:[`agent-certs`]}),e()}catch(e){f(B(e)),y(!1)}},className:`rounded bg-red-600/20 px-4 py-2 text-sm text-red-400 hover:bg-red-600/30 disabled:opacity-50`,children:[v?(0,A.jsx)(L,{size:14,className:`animate-spin inline mr-1`}):(0,A.jsx)(R,{size:14,className:`inline mr-1`}),`Revoke Token`]}),(0,A.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:`Done`})]})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`p`,{className:`text-sm text-zinc-400 mb-4`,children:`Generate a one-time token for hardware-bound agent enrollment. The agent will generate a non-exportable keypair in macOS Keychain.`}),(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Agent Label`}),(0,A.jsx)(`input`,{type:`text`,value:r,onChange:e=>i(e.target.value.toLowerCase()),placeholder:`e.g. macbook-pro`,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:border-cyan-500 focus:outline-none`})]}),(0,A.jsx)(Ru,{capabilities:a,onChange:o}),(a.includes(`sites:read`)||a.includes(`sites:write`))&&b?.sites?.length>0&&(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-2`,children:`Allowed Sites`}),(0,A.jsx)(`div`,{className:`space-y-2 max-h-40 overflow-y-auto`,children:b.sites.map(e=>(0,A.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:s.includes(e.name),onChange:()=>c(t=>t.includes(e.name)?t.filter(t=>t!==e.name):[...t,e.name]),className:`accent-cyan-500`}),(0,A.jsx)(`span`,{className:`text-zinc-300`,children:e.name}),e.fqdn&&(0,A.jsx)(`span`,{className:`text-zinc-500 text-xs`,children:e.fqdn})]},e.id))})]}),d&&(0,A.jsx)(`div`,{className:`rounded bg-red-500/10 border border-red-500/20 px-3 py-2 text-sm text-red-400`,children:d})]}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-3 mt-6`,children:[(0,A.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,A.jsxs)(`button`,{type:`button`,onClick:C,disabled:!S||x.isPending,className:`rounded bg-emerald-600 px-4 py-2 text-sm font-semibold text-white hover:bg-emerald-500 disabled:opacity-50`,children:[x.isPending?(0,A.jsx)(L,{size:14,className:`animate-spin inline mr-1`}):null,`Generate Token`]})]})]})]})})}function Wu(){let e=F(),t=j(),n=z(),[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]=(0,g.useState)(null),[p,m]=(0,g.useState)(`all`),h=M({queryKey:[`agent-certs`],queryFn:()=>e.getAgentCerts(),refetchInterval:3e4}),_=N({mutationFn:t=>e.revokeAgentCert(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`agent-certs`]}),n(`Certificate for ${s} revoked`),c(null)},onError:e=>{n(B(e),`error`),c(null)}}),v=(0,g.useCallback)(e=>{c(e)},[]),y=(0,g.useCallback)(()=>{s&&_.mutate(s)},[s,_]),b=h.data?.agents||[],x=b.some(e=>e.enrollmentMethod===`delegated`),S=b.filter(e=>p===`regular`?e.enrollmentMethod!==`delegated`:p===`delegated`?e.enrollmentMethod===`delegated`:!0);return(0,A.jsxs)(`div`,{className:`mt-8`,children:[(0,A.jsxs)(`div`,{className:`border-t border-zinc-700 pt-6`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,A.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,A.jsx)(Ji,{size:18,className:`text-cyan-400`}),`Agent Certificates`]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsxs)(`button`,{type:`button`,onClick:()=>o(!0),className:`flex items-center gap-2 rounded bg-emerald-600 px-4 py-2 text-sm font-semibold text-white hover:bg-emerald-500`,title:`Generate a one-time token for hardware-bound enrollment`,children:[(0,A.jsx)(Ji,{size:14}),`Enrollment Token`]}),(0,A.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`,title:`Generate a P12 certificate file`,children:[(0,A.jsx)(ua,{size:14}),`Generate P12`]})]})]}),x&&(0,A.jsx)(`div`,{className:`flex items-center gap-1 mb-4`,children:[`all`,`regular`,`delegated`].map(e=>(0,A.jsx)(`button`,{type:`button`,onClick:()=>m(e),className:`rounded px-3 py-1 text-xs font-medium transition-colors ${p===e?`bg-zinc-700 text-zinc-200`:`text-zinc-500 hover:text-zinc-300 hover:bg-zinc-800`}`,children:e===`all`?`All`:e===`regular`?`Regular`:`Delegated`},e))}),h.isLoading?(0,A.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:2}).map((e,t)=>(0,A.jsx)(`div`,{className:`h-14 animate-pulse rounded-lg bg-zinc-900 border border-zinc-800`},t))}):h.isError?(0,A.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,A.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Failed to load agent certificates`})}):S.length===0?(0,A.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-8 text-center`,children:[(0,A.jsx)(Ji,{size:32,className:`mx-auto text-zinc-600 mb-3`}),(0,A.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:`No agent certificates. Generate one to connect a Mac tunnel agent.`})]}):(0,A.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-zinc-800`,children:(0,A.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-900`,children:[(0,A.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Label`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Serial`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Created`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Expires`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Capabilities`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Delegated By`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Type`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Status`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-right text-xs font-medium uppercase text-zinc-400`,children:`Actions`})]})}),(0,A.jsx)(`tbody`,{children:S.map(t=>(0,A.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-800`,children:[(0,A.jsxs)(`td`,{className:`px-4 py-3`,children:[(0,A.jsx)(Iu,{label:t.label}),!t.revoked&&!Fu(t.label)&&(0,A.jsx)(`div`,{className:`mt-0.5 min-w-[16rem]`,children:(0,A.jsx)(Eu,{facts:t.hostFacts,at:t.hostFactsAt})})]}),(0,A.jsx)(`td`,{className:`px-4 py-3 font-mono text-xs text-zinc-600`,children:t.serial?t.serial.slice(0,16):`N/A`}),(0,A.jsx)(`td`,{className:`px-4 py-3 text-zinc-400`,children:ku(t.createdAt)}),(0,A.jsx)(`td`,{className:`px-4 py-3 text-zinc-400`,children:ku(t.expiresAt)}),(0,A.jsxs)(`td`,{className:`px-4 py-3`,children:[(0,A.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:(t.capabilities||[`tunnels:read`]).map(e=>(0,A.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-zinc-700 text-zinc-300 font-mono`,children:e},e))}),t.allowedSites?.length>0&&(0,A.jsxs)(`span`,{className:`text-xs text-zinc-500 mt-1 block`,children:[`Sites: `,t.allowedSites.join(`, `)]})]}),(0,A.jsx)(`td`,{className:`px-4 py-3`,children:t.delegatedBy?(0,A.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-violet-400 font-mono`,children:[(0,A.jsx)(Zi,{size:12,className:`text-violet-400/70`}),t.delegatedBy]}):(0,A.jsx)(`span`,{className:`text-xs text-zinc-600`,children:`—`})}),(0,A.jsx)(`td`,{className:`px-4 py-3`,children:(0,A.jsx)(Pu,{method:t.enrollmentMethod})}),(0,A.jsx)(`td`,{className:`px-4 py-3`,children:(0,A.jsx)(Nu,{status:t.status})}),(0,A.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,A.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[t.status!==`revoked`&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>u(t),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 capabilities`,children:(0,A.jsx)(Ca,{size:12})}),t.status!==`revoked`&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>f(t),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 site access`,children:(0,A.jsx)(Hi,{size:12})}),t.status!==`revoked`&&t.status!==`expired`&&t.enrollmentMethod!==`hardware-bound`&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>e.downloadAgentCert(t.label),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:`Download .p12`,children:(0,A.jsx)(Ai,{size:12})}),t.status!==`revoked`&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>v(t.label),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:`Revoke certificate`,children:(0,A.jsx)(R,{size:12})})]})})]},t.label))})]})})]}),r&&(0,A.jsx)(zu,{onClose:()=>i(!1)}),a&&(0,A.jsx)(Uu,{onClose:()=>o(!1)}),s&&(0,A.jsx)(Bu,{label:s,onConfirm:y,onCancel:()=>c(null),isPending:_.isPending}),l&&(0,A.jsx)(Vu,{agent:l,onClose:()=>u(null)}),d&&(0,A.jsx)(Hu,{agent:d,onClose:()=>f(null)})]})}function Gu({onClose:e}){let t=F(),n=j(),r=z(),[i,a]=(0,g.useState)(`warning`),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(null),[u,d]=(0,g.useState)(!1),[f,p]=(0,g.useState)(!1),[m,h]=(0,g.useState)(!1),_=N({mutationFn:()=>t.rotateMtls(),onSuccess:e=>{s(e),a(`success`),n.invalidateQueries({queryKey:[`certs`]})},onError:e=>{l(B(e)),a(`error`)}}),v=(0,g.useCallback)(()=>{a(`rotating`),_.mutate()},[_]),y=(0,g.useCallback)(async()=>{if(o?.p12Password)try{await navigator.clipboard.writeText(o.p12Password),d(!0),setTimeout(()=>d(!1),2e3)}catch{r(`Failed to copy — please select and copy manually`,`error`)}},[o,r]),b=(0,g.useCallback)(async()=>{try{await t.downloadMtls()}catch(e){r(B(e)||`Download failed`,`error`)}},[t,r]),x=(0,g.useCallback)(()=>{if(!m){h(!0);return}e()},[m,e]);return(0,A.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4`,children:(0,A.jsxs)(`div`,{className:`w-full max-w-lg rounded-lg bg-zinc-900 border border-zinc-800 shadow-xl`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between border-b border-zinc-800 px-6 py-4`,children:[(0,A.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold text-white`,children:[i===`warning`&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(ja,{size:20,className:`text-amber-400`}),`Rotate Client Certificate`]}),i===`rotating`&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{size:20,className:`animate-spin text-cyan-400`}),`Generating New Certificate...`]}),i===`success`&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(Ta,{size:20,className:`text-green-400`}),`New Certificate Ready`]}),i===`error`&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(ja,{size:20,className:`text-red-400`}),`Rotation Failed`]})]}),(i===`warning`||i===`error`)&&(0,A.jsx)(`button`,{type:`button`,onClick:e,className:`text-zinc-500 hover:text-zinc-300`,children:(0,A.jsx)(Ga,{size:18})})]}),(0,A.jsxs)(`div`,{className:`px-6 py-5`,children:[i===`warning`&&(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{className:`rounded-lg bg-amber-500/10 border border-amber-500/20 p-4 text-sm text-amber-400 space-y-2`,children:[(0,A.jsx)(`p`,{className:`font-semibold`,children:`This will immediately invalidate your current browser certificate.`}),(0,A.jsxs)(`p`,{children:[`You `,(0,A.jsx)(`strong`,{children:`MUST`}),` download and import the new certificate before closing this page or your browser.`]}),(0,A.jsx)(`p`,{children:`If you fail to do this, you will be locked out of the panel and will need SSH access to recover.`})]}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:e,autoFocus:!0,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:`Cancel`}),(0,A.jsx)(`button`,{type:`button`,onClick:v,className:`rounded bg-red-600 px-4 py-2 text-sm text-white hover:bg-red-500`,children:`I Understand, Rotate`})]})]}),i===`rotating`&&(0,A.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,A.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:`Generating new certificate...`})}),i===`success`&&o&&(0,A.jsxs)(`div`,{className:`space-y-5`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`text-sm font-medium text-zinc-300 block mb-2`,children:`Certificate Password (copy this first):`}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`div`,{className:`flex-1 rounded border border-zinc-700 bg-zinc-950 p-3 font-mono text-cyan-400 text-sm break-all select-all`,children:o.p12Password}),(0,A.jsx)(`button`,{type:`button`,onClick:y,className:`rounded bg-zinc-700 p-2 text-zinc-300 hover:bg-zinc-600 shrink-0`,title:`Copy password`,children:u?(0,A.jsx)(gi,{size:16,className:`text-green-400`}):(0,A.jsx)(Di,{size:16})})]})]}),(0,A.jsxs)(`button`,{type:`button`,onClick:b,className:`flex w-full items-center justify-center gap-2 rounded bg-cyan-600 py-3 px-6 text-sm font-semibold text-white hover:bg-cyan-500`,children:[(0,A.jsx)(Ai,{size:16}),`Download Certificate`]}),(0,A.jsxs)(`ol`,{className:`list-decimal list-inside text-sm text-zinc-400 space-y-1.5 pl-1`,children:[(0,A.jsx)(`li`,{children:`Copy the password above`}),(0,A.jsx)(`li`,{children:`Click Download Certificate`}),(0,A.jsx)(`li`,{children:`Double-click the downloaded file to import it into your browser's keychain`}),(0,A.jsx)(`li`,{children:`Enter the password when prompted`}),(0,A.jsx)(`li`,{children:`Restart your browser to use the new certificate`})]}),(0,A.jsxs)(`div`,{className:`border-t border-zinc-700 pt-4`,children:[(0,A.jsxs)(`button`,{type:`button`,onClick:()=>p(e=>!e),className:`flex items-center gap-1.5 text-xs text-zinc-500 hover:text-zinc-400`,children:[f?(0,A.jsx)(bi,{size:14}):(0,A.jsx)(_i,{size:14}),`Recovery instructions (if locked out)`]}),f&&(0,A.jsxs)(`div`,{className:`mt-3 rounded border border-zinc-700 bg-zinc-950 p-3`,children:[(0,A.jsx)(`p`,{className:`text-xs text-zinc-400 mb-2`,children:`If you get locked out, connect via SSH and run these commands to restore the backup:`}),(0,A.jsx)(`pre`,{className:`text-xs text-zinc-300 font-mono whitespace-pre-wrap`,children:`sudo cp /etc/lamalibre/lamaste/pki/client.crt.bak /etc/lamalibre/lamaste/pki/client.crt
9
+ sudo cp /etc/lamalibre/lamaste/pki/client.key.bak /etc/lamalibre/lamaste/pki/client.key
10
+ sudo cp /etc/lamalibre/lamaste/pki/client.p12.bak /etc/lamalibre/lamaste/pki/client.p12
11
+ sudo systemctl reload nginx`})]})]}),(0,A.jsx)(`div`,{className:`flex justify-end`,children:m?(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(`span`,{className:`text-sm text-zinc-400`,children:`Have you downloaded and imported the new certificate?`}),(0,A.jsx)(`button`,{type:`button`,onClick:x,className:`rounded bg-green-600 px-4 py-2 text-sm text-white hover:bg-green-500`,children:`Yes, Done`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>h(!1),className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:`Not yet`})]}):(0,A.jsx)(`button`,{type:`button`,onClick:x,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:`Done`})})]}),i===`error`&&(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{className:`rounded-lg bg-red-500/10 border border-red-500/20 p-4 text-sm text-red-400`,children:[(0,A.jsx)(`p`,{className:`font-semibold mb-1`,children:`Rotation failed`}),(0,A.jsx)(`p`,{children:c}),(0,A.jsx)(`p`,{className:`mt-2 text-zinc-400`,children:`Your existing certificate is still valid.`})]}),(0,A.jsx)(`div`,{className:`flex justify-end`,children:(0,A.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:`Close`})})]})]})]})})}function Ku(){let e=F(),t=j(),n=z(),[r,i]=(0,g.useState)(null),[a,o]=(0,g.useState)(!1),s=M({queryKey:[`certs`],queryFn:()=>e.getCerts(),refetchInterval:3e4}),c=M({queryKey:[`auto-renew-status`],queryFn:()=>e.getAutoRenewStatus()}),l=M({queryKey:[`admin-auth-mode`],queryFn:()=>e.getAuthMode()}).data?.adminAuthMode||`p12`,u=N({mutationFn:t=>e.renewCert(t),onSuccess:e=>{t.invalidateQueries({queryKey:[`certs`]});let r=e.newExpiry?` New expiry: ${ku(e.newExpiry)}`:``;n(`Certificate for ${e.domain} renewed.${r}`),e.warning&&n(e.warning,`error`),i(null)},onError:e=>{n(B(e),`error`),i(null)}}),d=(0,g.useCallback)(e=>{i(e),u.mutate(e)},[u]),f=s.data?.certs||[];return(0,A.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,A.jsxs)(`div`,{className:`mb-6`,children:[(0,A.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Certificates`}),(0,A.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`View and manage TLS and mTLS certificates`})]}),(0,A.jsx)(Au,{data:c.data,isLoading:c.isLoading}),s.isLoading?(0,A.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:3}).map((e,t)=>(0,A.jsx)(`div`,{className:`h-14 animate-pulse rounded-lg bg-zinc-900 border border-zinc-800`},t))}):s.isError?(0,A.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,A.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Failed to load certificates`})}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(ju,{certs:f,onRenew:d,renewingDomain:r}),(0,A.jsx)(Mu,{certs:f,onRotate:()=>o(!0),adminAuthMode:l}),(0,A.jsx)(Wu,{})]}),a&&(0,A.jsx)(Gu,{onClose:()=>o(!1)})]})}function qu({status:e}){return(0,A.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full ${e===`active`?`bg-green-500/20 text-green-400`:e===`stale`?`bg-yellow-500/20 text-yellow-400`:e===`dead`?`bg-red-500/20 text-red-400`:e===`grace`?`bg-orange-500/20 text-orange-400`:`bg-zinc-500/20 text-zinc-400`}`,children:e})}function Ju({ticket:e}){return e.used?(0,A.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-zinc-500/20 text-zinc-400`,children:`used`}):new Date(e.expiresAt)<new Date?(0,A.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-red-500/20 text-red-400`,children:`expired`}):(0,A.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-green-500/20 text-green-400`,children:`pending`})}function Yu(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:new Date(e).toLocaleDateString()}var Xu=[{id:`scopes`,label:`Scopes`},{id:`instances`,label:`Instances`},{id:`assignments`,label:`Assignments`},{id:`tickets`,label:`Tickets`},{id:`sessions`,label:`Sessions`}];function Zu(){let e=F(),t=j(),n=z(),{data:r,isLoading:i,isError:a}=M({queryKey:[`ticket-scopes`],queryFn:()=>e.getTicketScopes(),refetchInterval:1e4}),o=N({mutationFn:t=>e.deleteTicketScope(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`ticket-scopes`]}),n(`Scope unregistered`)},onError:e=>n(B(e),`error`)}),[s,c]=(0,g.useState)(null);if(i)return(0,A.jsx)(`div`,{className:`animate-pulse h-32 rounded-lg bg-zinc-900 border border-zinc-800`});if(a)return(0,A.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,A.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Failed to load scopes`})});let l=r?.scopes||[];return l.length===0?(0,A.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-8 text-center`,children:[(0,A.jsx)(Aa,{className:`mx-auto h-8 w-8 text-zinc-600 mb-3`}),(0,A.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:`No ticket scopes registered`}),(0,A.jsx)(`p`,{className:`text-zinc-600 text-xs mt-1`,children:`Install a ticket scope package to get started`})]}):(0,A.jsx)(`div`,{className:`space-y-3`,children:l.map(e=>(0,A.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-5`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(Aa,{size:16,className:`text-cyan-400`}),(0,A.jsx)(`span`,{className:`text-white font-semibold`,children:e.name}),(0,A.jsxs)(`span`,{className:`text-zinc-500 text-xs`,children:[`v`,e.version]})]}),s===e.name?(0,A.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,A.jsx)(`span`,{className:`text-zinc-400`,children:`Remove?`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>{o.mutate(e.name),c(null)},className:`rounded bg-red-600 px-2 py-1 text-white hover:bg-red-500`,children:`Yes`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>c(null),className:`rounded bg-zinc-700 px-2 py-1 text-zinc-300 hover:bg-zinc-600`,children:`No`})]}):(0,A.jsx)(`button`,{type:`button`,onClick:()=>c(e.name),className:`text-zinc-500 hover:text-red-400`,title:`Unregister scope`,children:(0,A.jsx)(R,{size:14})})]}),(0,A.jsx)(`p`,{className:`text-zinc-400 text-sm mb-2`,children:e.description}),(0,A.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.scopes?.map(e=>(0,A.jsxs)(`span`,{className:`text-xs bg-zinc-800 text-cyan-400 px-2 py-0.5 rounded font-mono`,children:[e.name,e.instanceScoped&&(0,A.jsx)(`span`,{className:`text-zinc-500 ml-1`,children:`(instance-scoped)`})]},e.name))}),(0,A.jsxs)(`div`,{className:`mt-2 flex gap-3 text-xs text-zinc-500`,children:[(0,A.jsxs)(`span`,{children:[`Transport: `,e.transport?.strategies?.join(`, `)]}),(0,A.jsxs)(`span`,{children:[`Protocol: `,e.transport?.protocol]}),(0,A.jsxs)(`span`,{children:[`Installed: `,Yu(e.installedAt)]})]})]},e.name))})}function Qu(){let e=F(),t=j(),n=z(),[r,i]=(0,g.useState)(null),{data:a,isLoading:o,isError:s}=M({queryKey:[`ticket-instances`],queryFn:()=>e.getTicketInstances(),refetchInterval:1e4}),c=N({mutationFn:t=>e.deleteTicketInstance(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`ticket-instances`]}),n(`Instance deregistered`),i(null)},onError:e=>n(B(e),`error`)});if(o)return(0,A.jsx)(`div`,{className:`animate-pulse h-32 rounded-lg bg-zinc-900 border border-zinc-800`});if(s)return(0,A.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,A.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Failed to load instances`})});let l=a?.instances||[];return l.length===0?(0,A.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-8 text-center`,children:[(0,A.jsx)(xa,{className:`mx-auto h-8 w-8 text-zinc-600 mb-3`}),(0,A.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:`No instances registered`})]}):(0,A.jsx)(`div`,{className:`overflow-x-auto`,children:(0,A.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`border-b border-zinc-800 text-left text-zinc-500`,children:[(0,A.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Instance ID`}),(0,A.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Scope`}),(0,A.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Agent`}),(0,A.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Status`}),(0,A.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Last Heartbeat`}),(0,A.jsx)(`th`,{className:`pb-2 font-medium`,children:`Actions`})]})}),(0,A.jsx)(`tbody`,{children:l.map(e=>(0,A.jsxs)(`tr`,{className:`border-b border-zinc-800/50`,children:[(0,A.jsxs)(`td`,{className:`py-3 pr-4 font-mono text-cyan-400 text-xs`,children:[e.instanceId.slice(0,12),`...`]}),(0,A.jsx)(`td`,{className:`py-3 pr-4 font-mono text-zinc-300 text-xs`,children:e.scope}),(0,A.jsx)(`td`,{className:`py-3 pr-4 text-zinc-300`,children:e.agentLabel}),(0,A.jsx)(`td`,{className:`py-3 pr-4`,children:(0,A.jsx)(qu,{status:e.status})}),(0,A.jsx)(`td`,{className:`py-3 pr-4 text-zinc-500 text-xs`,children:Yu(e.lastHeartbeat)}),(0,A.jsx)(`td`,{className:`py-3`,children:r===e.instanceId?(0,A.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,A.jsx)(`span`,{className:`text-zinc-400`,children:`Remove?`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>c.mutate(e.instanceId),className:`rounded bg-red-600 px-2 py-1 text-white hover:bg-red-500`,children:`Yes`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>i(null),className:`rounded bg-zinc-700 px-2 py-1 text-zinc-300 hover:bg-zinc-600`,children:`No`})]}):(0,A.jsx)(`button`,{type:`button`,onClick:()=>i(e.instanceId),className:`text-zinc-500 hover:text-red-400`,title:`Deregister instance`,children:(0,A.jsx)(R,{size:14})})})]},e.instanceId))})]})})}function $u(){let e=F(),t=j(),n=z(),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)(null),{data:d,isLoading:f,isError:p}=M({queryKey:[`ticket-assignments`],queryFn:()=>e.getTicketAssignments(),refetchInterval:1e4}),{data:m}=M({queryKey:[`ticket-scopes`],queryFn:()=>e.getTicketScopes(),refetchInterval:1e4}),{data:h}=M({queryKey:[`agents-list`],queryFn:()=>e.getAgentCerts(),staleTime:3e4}),_=N({mutationFn:t=>e.createTicketAssignment(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`ticket-assignments`]}),n(`Assignment created`),i(!1),o(``),c(``)},onError:e=>n(B(e),`error`)}),v=N({mutationFn:({agentLabel:t,instanceScope:n})=>e.deleteTicketAssignment(t,n),onSuccess:()=>{t.invalidateQueries({queryKey:[`ticket-assignments`]}),n(`Assignment removed`),u(null)},onError:e=>n(B(e),`error`)});if(f)return(0,A.jsx)(`div`,{className:`animate-pulse h-32 rounded-lg bg-zinc-900 border border-zinc-800`});if(p)return(0,A.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,A.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Failed to load assignments`})});let y=d?.assignments||[],b=m?.instances||[],x=(h?.agents||[]).filter(e=>!e.revoked),S=b.filter(e=>e.status!==`dead`).map(e=>`${e.scope}:${e.instanceId}`);return(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,A.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:`Assign agents to ticket scope instances`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>i(!r),className:`rounded bg-cyan-600 px-3 py-1.5 text-xs text-white hover:bg-cyan-500`,children:r?`Cancel`:`Add Assignment`})]}),r&&(0,A.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-4 mb-4`,children:[(0,A.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3 mb-3`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Agent`}),(0,A.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value),className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-1.5 text-sm text-zinc-300 focus:outline-none focus:border-cyan-400`,children:[(0,A.jsx)(`option`,{value:``,children:`Select agent...`}),x.map(e=>(0,A.jsx)(`option`,{value:e.label,children:e.label},e.label))]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Instance Scope`}),(0,A.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-1.5 text-sm text-zinc-300 focus:outline-none focus:border-cyan-400`,children:[(0,A.jsx)(`option`,{value:``,children:`Select instance...`}),S.map(e=>(0,A.jsx)(`option`,{value:e,children:e},e))]})]})]}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>_.mutate({agentLabel:a,instanceScope:s}),disabled:!a||!s||_.isPending,className:`rounded bg-cyan-600 px-4 py-1.5 text-xs text-white hover:bg-cyan-500 disabled:opacity-50`,children:`Assign`})]}),y.length===0?(0,A.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-8 text-center`,children:[(0,A.jsx)(Qi,{className:`mx-auto h-8 w-8 text-zinc-600 mb-3`}),(0,A.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:`No assignments`})]}):(0,A.jsx)(`div`,{className:`overflow-x-auto`,children:(0,A.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`border-b border-zinc-800 text-left text-zinc-500`,children:[(0,A.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Agent`}),(0,A.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Instance Scope`}),(0,A.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Assigned`}),(0,A.jsx)(`th`,{className:`pb-2 font-medium`,children:`Actions`})]})}),(0,A.jsx)(`tbody`,{children:y.map(e=>(0,A.jsxs)(`tr`,{className:`border-b border-zinc-800/50`,children:[(0,A.jsx)(`td`,{className:`py-3 pr-4 text-zinc-300`,children:e.agentLabel}),(0,A.jsx)(`td`,{className:`py-3 pr-4 font-mono text-cyan-400 text-xs`,children:e.instanceScope}),(0,A.jsx)(`td`,{className:`py-3 pr-4 text-zinc-500 text-xs`,children:Yu(e.assignedAt)}),(0,A.jsx)(`td`,{className:`py-3`,children:l===`${e.agentLabel}:${e.instanceScope}`?(0,A.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,A.jsx)(`span`,{className:`text-zinc-400`,children:`Remove?`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>v.mutate({agentLabel:e.agentLabel,instanceScope:e.instanceScope}),className:`rounded bg-red-600 px-2 py-1 text-white hover:bg-red-500`,children:`Yes`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>u(null),className:`rounded bg-zinc-700 px-2 py-1 text-zinc-300 hover:bg-zinc-600`,children:`No`})]}):(0,A.jsx)(`button`,{type:`button`,onClick:()=>u(`${e.agentLabel}:${e.instanceScope}`),className:`text-zinc-500 hover:text-red-400`,title:`Remove assignment`,children:(0,A.jsx)(R,{size:14})})})]},`${e.agentLabel}-${e.instanceScope}`))})]})})]})}function ed(){let e=F(),t=j(),n=z(),[r,i]=(0,g.useState)(null),{data:a,isLoading:o,isError:s}=M({queryKey:[`tickets`],queryFn:()=>e.getTickets(),refetchInterval:5e3}),c=N({mutationFn:t=>e.revokeTicket(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`tickets`]}),n(`Ticket revoked`),i(null)},onError:e=>n(B(e),`error`)});if(o)return(0,A.jsx)(`div`,{className:`animate-pulse h-32 rounded-lg bg-zinc-900 border border-zinc-800`});if(s)return(0,A.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,A.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Failed to load tickets`})});let l=a?.tickets||[];return l.length===0?(0,A.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-8 text-center`,children:[(0,A.jsx)(Ei,{className:`mx-auto h-8 w-8 text-zinc-600 mb-3`}),(0,A.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:`No recent tickets`})]}):(0,A.jsx)(`div`,{className:`overflow-x-auto`,children:(0,A.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`border-b border-zinc-800 text-left text-zinc-500`,children:[(0,A.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Ticket ID`}),(0,A.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Scope`}),(0,A.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Source`}),(0,A.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Target`}),(0,A.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Status`}),(0,A.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Created`}),(0,A.jsx)(`th`,{className:`pb-2 font-medium`,children:`Actions`})]})}),(0,A.jsx)(`tbody`,{children:l.map(e=>(0,A.jsxs)(`tr`,{className:`border-b border-zinc-800/50`,children:[(0,A.jsxs)(`td`,{className:`py-3 pr-4 font-mono text-cyan-400 text-xs`,children:[e.id.slice(0,12),`...`]}),(0,A.jsx)(`td`,{className:`py-3 pr-4 font-mono text-zinc-300 text-xs`,children:e.scope}),(0,A.jsx)(`td`,{className:`py-3 pr-4 text-zinc-300`,children:e.source}),(0,A.jsx)(`td`,{className:`py-3 pr-4 text-zinc-300`,children:e.target}),(0,A.jsx)(`td`,{className:`py-3 pr-4`,children:(0,A.jsx)(Ju,{ticket:e})}),(0,A.jsx)(`td`,{className:`py-3 pr-4 text-zinc-500 text-xs`,children:Yu(e.createdAt)}),(0,A.jsx)(`td`,{className:`py-3`,children:!e.used&&new Date(e.expiresAt)>new Date&&(r===e.id?(0,A.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,A.jsx)(`span`,{className:`text-zinc-400`,children:`Revoke?`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>c.mutate(e.id),className:`rounded bg-red-600 px-2 py-1 text-white hover:bg-red-500`,children:`Yes`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>i(null),className:`rounded bg-zinc-700 px-2 py-1 text-zinc-300 hover:bg-zinc-600`,children:`No`})]}):(0,A.jsx)(`button`,{type:`button`,onClick:()=>i(e.id),className:`text-zinc-500 hover:text-red-400`,title:`Revoke ticket`,children:(0,A.jsx)(wi,{size:14})}))})]},e.id))})]})})}function td(){let e=F(),t=j(),n=z(),[r,i]=(0,g.useState)(null),{data:a,isLoading:o,isError:s}=M({queryKey:[`ticket-sessions`],queryFn:()=>e.getTicketSessions(),refetchInterval:5e3}),c=N({mutationFn:t=>e.killTicketSession(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`ticket-sessions`]}),n(`Session terminated`),i(null)},onError:e=>n(B(e),`error`)});if(o)return(0,A.jsx)(`div`,{className:`animate-pulse h-32 rounded-lg bg-zinc-900 border border-zinc-800`});if(s)return(0,A.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,A.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Failed to load sessions`})});let l=a?.sessions||[];return l.length===0?(0,A.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-8 text-center`,children:[(0,A.jsx)(xa,{className:`mx-auto h-8 w-8 text-zinc-600 mb-3`}),(0,A.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:`No active sessions`})]}):(0,A.jsx)(`div`,{className:`overflow-x-auto`,children:(0,A.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`border-b border-zinc-800 text-left text-zinc-500`,children:[(0,A.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Session ID`}),(0,A.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Scope`}),(0,A.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Source`}),(0,A.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Target`}),(0,A.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Status`}),(0,A.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Last Activity`}),(0,A.jsx)(`th`,{className:`pb-2 font-medium`,children:`Actions`})]})}),(0,A.jsx)(`tbody`,{children:l.map(e=>(0,A.jsxs)(`tr`,{className:`border-b border-zinc-800/50`,children:[(0,A.jsxs)(`td`,{className:`py-3 pr-4 font-mono text-cyan-400 text-xs`,children:[e.sessionId.slice(0,12),`...`]}),(0,A.jsx)(`td`,{className:`py-3 pr-4 font-mono text-zinc-300 text-xs`,children:e.scope}),(0,A.jsx)(`td`,{className:`py-3 pr-4 text-zinc-300`,children:e.source}),(0,A.jsx)(`td`,{className:`py-3 pr-4 text-zinc-300`,children:e.target}),(0,A.jsx)(`td`,{className:`py-3 pr-4`,children:(0,A.jsx)(qu,{status:e.status})}),(0,A.jsx)(`td`,{className:`py-3 pr-4 text-zinc-500 text-xs`,children:Yu(e.lastActivityAt)}),(0,A.jsx)(`td`,{className:`py-3`,children:e.status!==`dead`&&(r===e.sessionId?(0,A.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,A.jsx)(`span`,{className:`text-zinc-400`,children:`Kill?`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>c.mutate(e.sessionId),className:`rounded bg-red-600 px-2 py-1 text-white hover:bg-red-500`,children:`Yes`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>i(null),className:`rounded bg-zinc-700 px-2 py-1 text-zinc-300 hover:bg-zinc-600`,children:`No`})]}):(0,A.jsx)(`button`,{type:`button`,onClick:()=>i(e.sessionId),className:`text-zinc-500 hover:text-red-400`,title:`Kill session`,children:(0,A.jsx)(wi,{size:14})}))})]},e.sessionId))})]})})}function nd(){let[e,t]=(0,g.useState)(`scopes`);return(0,A.jsxs)(`div`,{className:`p-6 max-w-5xl mx-auto`,children:[(0,A.jsxs)(`div`,{className:`mb-6`,children:[(0,A.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Tickets & Sessions`}),(0,A.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`Manage agent-to-agent authorization scopes, instances, and active sessions`})]}),(0,A.jsx)(`div`,{className:`flex gap-1 mb-6 border-b border-zinc-800`,children:Xu.map(n=>(0,A.jsx)(`button`,{type:`button`,onClick:()=>t(n.id),className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${e===n.id?`border-cyan-400 text-cyan-400`:`border-transparent text-zinc-500 hover:text-zinc-300`}`,children:n.label},n.id))}),e===`scopes`&&(0,A.jsx)(Zu,{}),e===`instances`&&(0,A.jsx)(Qu,{}),e===`assignments`&&(0,A.jsx)($u,{}),e===`tickets`&&(0,A.jsx)(ed,{}),e===`sessions`&&(0,A.jsx)(td,{})]})}var rd={install:`installs`,update:`updates`,uninstall:`removes`};function id(e,{agentLabel:t=null,action:n=`install`}={}){let{code:r,reasons:i}=Ao(e),a=t?`agent "${t}"`:`the hosting agent`,o=null;return r===`push_install_refused`?o=`Lamaste ${rd[n]??`changes`} the agent half by push install: push install must be on for this relay and enabled for ${a} with its window open, and the agent's policy must allow "${n}" of the agent package from your address.`:r===`agent_not_eligible`?o=`Each agent reports its host on its sync (about every 30 seconds) — once what the reasons name is fixed on the agent, it becomes eligible.`:r===`hooks_not_approved`&&(o=`Review and approve what the plugin brings under Lifecycle hooks on its card first.`),{message:B(e),code:r,reasons:i,hint:o}}function ad(e,t){let{message:n,hint:r}=id(e,t);return r?`${n} — ${r}`:n}function od(e){return e.length>32?`${e.slice(0,17)}…${e.slice(-8)}`:e}var sd={done:(0,A.jsx)(Ci,{size:12,className:`text-green-400`}),failed:(0,A.jsx)(wi,{size:12,className:`text-red-400`}),skipped:(0,A.jsx)(aa,{size:12,className:`text-zinc-600`}),running:(0,A.jsx)(L,{size:12,className:`text-cyan-400 animate-spin`})},cd={running:`text-cyan-400`,succeeded:`text-green-400`,"rolled-back":`text-yellow-400`,failed:`text-red-400`,interrupted:`text-red-400`},ld={host:`Hosting`,unhost:`Removing the hosting`,update:`Update`,uninstall:`Uninstall`,"purge-data":`Purging retained data`};function ud({plugin:e}){let t=F(),n=j(),r=M({queryKey:[`plugin-operations`,e],queryFn:()=>t.getPluginOperations(e),refetchInterval:e=>e.state.data?.operations?.[0]?.status===`running`?2e3:15e3}),i=r.data?.operations,a=i?.[0],o=a?.status,s=(0,g.useRef)(o);(0,g.useEffect)(()=>{s.current===`running`&&o!==`running`&&(n.invalidateQueries({queryKey:[`plugins`]}),n.invalidateQueries({queryKey:[`tunnels`]}),n.invalidateQueries({queryKey:[`plugin-hooks`,e]})),s.current=o},[o,e,n]);let c=a?.finishedAt?Date.parse(a.finishedAt):null;return(0,A.jsxs)(A.Fragment,{children:[a!=null&&!(c&&r.dataUpdatedAt-c>10*6e4)&&(0,A.jsx)(dd,{op:a}),(0,A.jsx)(fd,{plugin:e,operations:i})]})}function dd({op:e}){return(0,A.jsxs)(`div`,{className:`rounded border border-zinc-800 bg-zinc-950/60 p-3 mb-4 text-xs`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,A.jsx)(`span`,{className:`text-zinc-300 font-medium`,children:ld[e.kind]??e.kind}),(0,A.jsx)(`span`,{className:cd[e.status]??`text-zinc-400`,children:e.status===`rolled-back`?`rolled back`:e.status}),(0,A.jsxs)(`span`,{className:`text-zinc-600`,children:[`by `,e.actor]})]}),(0,A.jsxs)(`ul`,{className:`space-y-1`,children:[e.steps.map((e,t)=>(0,A.jsxs)(`li`,{className:`flex items-start gap-1.5`,children:[(0,A.jsx)(`span`,{className:`mt-0.5`,children:sd[e.status]??(0,A.jsx)(Ti,{size:12})}),(0,A.jsxs)(`span`,{className:e.status===`skipped`?`text-zinc-600`:`text-zinc-300`,children:[e.name,(e.error||e.detail)&&(0,A.jsxs)(`span`,{className:`text-zinc-500`,children:[` — `,e.error??e.detail]})]})]},t)),e.status===`running`&&e.steps.every(e=>e.status!==`running`)&&(0,A.jsxs)(`li`,{className:`flex items-center gap-1.5 text-zinc-500`,children:[(0,A.jsx)(L,{size:12,className:`animate-spin`}),` waiting…`]})]}),e.warnings?.length>0&&(0,A.jsx)(`ul`,{className:`mt-2 space-y-1`,children:e.warnings.map((e,t)=>(0,A.jsxs)(`li`,{className:`flex items-start gap-1.5 text-yellow-400`,children:[(0,A.jsx)(ja,{size:12,className:`mt-0.5 shrink-0`}),` `,e]},t))}),e.error&&e.status!==`running`&&(0,A.jsx)(`p`,{className:`mt-2 text-red-400`,children:e.error})]})}function fd({plugin:e,operations:t}){let n=F(),r=j(),i=z(),{reveal:a,followState:o,claimOperation:s,releaseOperation:c}=lo(),l=(0,g.useMemo)(()=>(t??[]).map(e=>({op:e,action:no(e,o(e.id))})).filter(({action:e})=>e!==null),[t,o]),u=(0,g.useCallback)(async(t,{asked:o})=>{if(s(t.id))try{let{operation:s}=await n.getPluginOperation(e,t.id),{secrets:c}=to(s);r.setQueryData([`plugin-operations`,e],e=>ro(e,t.id)),c.length>0?a({plugin:e,cause:t.kind,secrets:c}):o&&i(`Nothing to show — the secrets were shown elsewhere, or waited more than an hour`,`error`)}catch(e){i(`Could not read the client secrets: ${B(e)}`,`error`)}finally{c(t.id),r.invalidateQueries({queryKey:[`plugin-operations`,e]})}},[e,n,r,i,a,s,c]);(0,g.useEffect)(()=>{for(let{op:e,action:t}of l)t===`read`?u(e,{asked:!1}):t===`forget`&&c(e.id)},[l,u,c]);let d=l.filter(({action:e})=>e!==`forget`);return d.length===0?null:d.map(({op:e,action:t})=>(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded border border-amber-500/30 bg-amber-500/5 p-3 mb-4 text-xs`,children:[(0,A.jsx)(qi,{size:12,className:`shrink-0 text-amber-400`}),t===`offer`?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`span`,{className:`flex-1 text-amber-400`,children:[ld[e.kind]??e.kind,e.finishedAt?` (${new Date(e.finishedAt).toLocaleString()})`:``,` created confidential OIDC client secrets that were not shown yet. They are shown once.`]}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>u(e,{asked:!0}),className:`rounded bg-amber-600 px-2.5 py-1 text-white hover:bg-amber-500`,children:`Show the secrets`})]}):(0,A.jsxs)(`span`,{className:`flex items-center gap-1.5 text-zinc-400`,children:[(0,A.jsx)(L,{size:12,className:`animate-spin`}),`Reading the new client secrets…`]})]},e.id))}function pd({relay:e}){return(0,A.jsxs)(`div`,{className:`space-y-1.5 text-zinc-400`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`module `}),e.entry?(0,A.jsxs)(`span`,{className:`font-mono text-zinc-300`,title:e.entrySha256,children:[e.entry,` `,(0,A.jsxs)(`span`,{className:`text-zinc-600`,children:[`sha256 `,vc(e.entrySha256)]})]}):(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`none — shared hooks only`})]}),e.stages.length>0&&(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`stages `}),e.stages.map(e=>(0,A.jsxs)(`span`,{className:`mr-2 font-mono text-zinc-300`,children:[e.stage,(0,A.jsxs)(`span`,{className:`text-zinc-600`,children:[` `,e.timeoutMs,` ms`]})]},e.stage))]}),e.request.map(e=>(0,A.jsxs)(`div`,{className:`rounded bg-zinc-900 px-2 py-1.5`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,A.jsx)(`span`,{className:`font-mono text-zinc-300`,children:e.stage}),(0,A.jsx)(`span`,{className:`text-zinc-500`,children:e.use??`plugin module`}),e.failOpen.length>0&&(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-yellow-500/15 px-1.5 text-yellow-400`,title:`Traffic passes when this hook fails, times out, or cannot see the body`,children:[(0,A.jsx)(wa,{size:11}),` fail-open: `,e.failOpen.join(`, `)]})]}),(0,A.jsx)(`div`,{className:`font-mono text-zinc-400`,children:e.routes.join(`, `)}),(0,A.jsxs)(`div`,{className:`text-zinc-600`,children:[`body `,e.bodyMaxBytes===null?`not seen`:`${e.bodyMaxBytes} B`,` · `,e.timeoutMs,` ms · on error `,e.onError,e.settings&&` · ${e.settings.action}, packs ${e.settings.packs.join(`, `)}, unscannable ${e.settings.onUnscannable}`]}),e.userSurfaceRoutes.length>0&&(0,A.jsxs)(`div`,{className:`text-zinc-600`,children:[`runs on user-surface requests (plugins that declare identity):`,` `,e.userSurfaceRoutes.join(`, `)]})]},e.index)),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`effects `}),(0,A.jsx)(`span`,{className:`text-zinc-300`,children:e.effects.length>0?e.effects.join(`, `):`none`}),e.packs.length>0&&(0,A.jsxs)(`span`,{className:`text-zinc-500`,children:[` · rule packs `,e.packs.join(`, `)]})]})]})}function md({integrity:e}){let[t,n]=(0,g.useState)(!1);return(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,A.jsx)(`span`,{className:`font-mono text-zinc-300`,title:e,children:od(e)}),(0,A.jsx)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{}},title:`Copy the full integrity`,"aria-label":`Copy the full integrity`,className:`text-zinc-500 hover:text-zinc-300`,children:t?(0,A.jsx)(gi,{size:11,className:`text-green-400`}):(0,A.jsx)(Di,{size:11})})]})}function hd({agentHalf:e}){return(0,A.jsxs)(`div`,{className:`space-y-1 text-zinc-400`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`package `}),(0,A.jsxs)(`span`,{className:`font-mono text-zinc-300`,children:[e.package,`@`,e.version]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`integrity `}),(0,A.jsx)(md,{integrity:e.integrity})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`entry `}),(0,A.jsx)(`span`,{className:`font-mono text-zinc-300`,children:e.entry}),(0,A.jsx)(`span`,{className:`text-zinc-500`,children:` · memory `}),(0,A.jsx)(`span`,{className:`font-mono text-zinc-300`,children:e.memoryMax??`not limited`})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`runs as `}),(0,A.jsx)(`span`,{className:`font-mono text-zinc-300`,children:e.serviceUser}),(0,A.jsx)(`span`,{className:`text-zinc-500`,children:` · unit `}),(0,A.jsx)(`span`,{className:`font-mono text-zinc-300`,children:e.unitName})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`data `}),(0,A.jsx)(`span`,{className:`font-mono text-zinc-300`,children:e.dataDir}),(0,A.jsx)(`span`,{className:`text-zinc-600`,children:` — kept when it is removed, unless purged`})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`system packages `}),e.systemPackages.length>0?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{className:`font-mono text-zinc-300`,children:e.systemPackages.join(`, `)}),(0,A.jsx)(`span`,{className:`text-zinc-600`,children:` — installed with apt-get once approved`})]}):(0,A.jsx)(`span`,{className:`text-zinc-300`,children:`none`})]})]})}function gd(e,t){e.invalidateQueries({queryKey:[`plugin-hooks`,t]}),e.invalidateQueries({queryKey:[`plugins`]}),e.invalidateQueries({queryKey:[`plugin-operations`,t]}),e.invalidateQueries({queryKey:[`plugin-web-surface`,t]})}function _d(e,t){return ad(e,{agentLabel:t.agentHosting?.agentLabel,action:`update`})}function vd(e){return{relay:e.relay??null,agentHalf:e.agentHalf??null,identity:e.identity?.declared?e.identity.block:null,web:e.web?.declared?{treeSha256:e.web.treeSha256,surface:e.web.surface??null}:null}}function yd(e){return{relay:e.relay??null,agentHalf:e.agentHalf??null,identity:e.identity?.after??null,web:e.web?.after??null}}function bd(e){return e.length<=1?e[0]??``:`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`}function xd({relay:e,agentHalf:t,identity:n,web:r}){let i=[e&&`relay hooks`,t&&`agent half`,n&&`identity`,r&&`web surface`].filter(Boolean);return i.length===0?{subject:`relay hooks`,plural:!0}:{subject:bd(i),plural:i.length>1||i[0]===`relay hooks`}}function Sd({relay:e,agentHalf:t,identity:n,web:r}){let i=[e&&`run this code on the relay`,t&&(e||n||r?`install this agent half`:`install this agent half on the hosting agent`),n&&`send it its users with these roles and attributes`,r&&`serve this web tree to its users`].filter(Boolean),a=bd(i.length>0?i:[`run this code on the relay`]);return`${a.charAt(0).toUpperCase()}${a.slice(1)}?`}function Cd({relay:e,agentHalf:t,identity:n,web:r}){let i=[e&&`runs its relay hooks`,t&&`installs its agent half`,n&&`sends it its users (and lets them reach it)`,r&&`serves its web tree`,`hosts the plugin`].filter(Boolean),a=e&&!t&&!n&&!r?`they are`:`this is`;return`Lamaste ${bd(i)} only once ${a} approved.`}var wd=`settings.secret-to-plain`,Td=`digest.unapproved`;function Ed(e){let t=new Set((e.approvalRequired??[]).map(e=>e.code)),n=e.settings?.secretToPlain??[],r=`${n.join(`, `)} into ${n.length===1?`a plain setting`:`plain settings`}`,i=yd(e);return t.has(Td)&&t.has(wd)?`${Sd(i).replace(/\?$/,``)}, and turn ${r}?`:t.has(wd)?`Turn ${r} and update?`:Sd(i)}function Dd({digest:e,approved:t=!1}){return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`approval digest `}),(0,A.jsx)(`span`,{className:`font-mono text-zinc-300`,title:e,children:vc(e)}),t&&(0,A.jsx)(`span`,{className:`text-zinc-500`,children:` — unchanged, already approved`})]})}function Od({reasons:e}){return e.length===0?null:(0,A.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-5`,children:e.map(e=>(0,A.jsxs)(`li`,{className:e.code===wd?`text-red-400`:`text-yellow-400/90`,children:[e.reason,e.code===`identity.changed`&&(0,A.jsxs)(`span`,{className:`text-zinc-500`,children:[` `,`— who its users are and what it learns about them; auto-approve never covers it`]})]},e.code))})}function kd({block:e}){return(0,A.jsxs)(`div`,{className:`space-y-1 text-zinc-400`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`roles `}),e.roles.map((e,t)=>(0,A.jsxs)(`span`,{children:[t>0&&(0,A.jsx)(`span`,{className:`text-zinc-600`,children:`, `}),(0,A.jsx)(`span`,{className:`font-mono text-zinc-300`,title:e.description,children:e.id}),(0,A.jsxs)(`span`,{className:`text-zinc-500`,children:[` (`,e.label,`)`]})]},e.id))]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`receives `}),(0,A.jsx)(`span`,{className:`text-zinc-300`,children:[`user id`,`username`,`roles`,`status`,...e.attributes.map(Hl)].join(`, `)}),(0,A.jsx)(`span`,{className:`text-zinc-600`,children:` — of the users entitled to it`})]})]})}function Ad({web:e}){return(0,A.jsxs)(`div`,{className:`space-y-0.5 text-zinc-400`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`tree `}),(0,A.jsx)(`span`,{className:`font-mono text-zinc-300`,title:e.treeSha256,children:vc(e.treeSha256)})]}),e.surface&&(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`offers `}),(0,A.jsx)(`span`,{className:`font-mono text-zinc-300`,children:e.surface.defaultSubdomain}),(0,A.jsxs)(`span`,{className:`text-zinc-500`,children:[` · `,gc(e.surface.accessMode)]})]})]})}function jd({relay:e,agentHalf:t,identity:n,web:r}){return(0,A.jsxs)(A.Fragment,{children:[e&&(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`mb-1 text-zinc-500`,children:`Relay hooks — run in a sandbox on the relay (no network, no files of Lamaste's):`}),(0,A.jsx)(pd,{relay:e})]}),t&&(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`mb-1 text-zinc-500`,children:`Agent half — Lamaste installs it on the hosting agent as a hardened service of its own:`}),(0,A.jsx)(hd,{agentHalf:t})]}),n&&(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`mb-1 text-zinc-500`,children:`Identity — Lamaste sends its agent half the users entitled to these roles, and lets them reach its application:`}),(0,A.jsx)(kd,{block:n})]}),r&&(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`mb-1 text-zinc-500`,children:`Web surface — the relay serves this tree, from its server package, to its users on the site it owns:`}),(0,A.jsx)(Ad,{web:r})]})]})}function Md({web:e}){let t=Ac(e);if(!t)return null;let n={added:`Web surface — this version declares one for the first time:`,removed:`Web surface — this version no longer declares one: its site answers 503 until a version that does is approved:`,changed:`Web surface — this version ships another web tree:`,unchanged:`Web surface — the web tree is unchanged:`}[t.kind];return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`mb-1 text-zinc-500`,children:n}),(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-1.5 text-zinc-400`,children:[(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`tree `}),t.before&&(0,A.jsx)(`span`,{className:`font-mono text-zinc-300`,title:t.before,children:vc(t.before)}),t.kind===`changed`&&(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`→`}),(t.kind===`added`||t.kind===`changed`)&&(0,A.jsx)(`span`,{className:`font-mono text-zinc-300`,title:t.after.sha256,children:vc(t.after.sha256)}),t.after&&(0,A.jsxs)(`span`,{className:`text-zinc-500`,children:[`(`,bc(t.after),`)`]}),t.kind===`removed`&&(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`→ none`})]}),t.changes&&(0,A.jsx)(Nd,{changes:t.changes})]})}function Nd({changes:e}){let t=[[`added`,e.added],[`removed`,e.removed],[`changed`,e.changed]].filter(([,e])=>e?.count>0);return t.length===0&&!(e.review?.length>0)?null:(0,A.jsxs)(`div`,{className:`mt-1 space-y-0.5 text-zinc-400`,children:[e.review?.length>0&&(0,A.jsxs)(`div`,{className:`text-yellow-400`,children:[`Look at these before approving — pages, SVGs or manifests served on the relay’s domain:`,` `,(0,A.jsx)(`span`,{className:`font-mono`,children:e.review.join(`, `)})]}),t.map(([e,t])=>(0,A.jsxs)(`details`,{children:[(0,A.jsxs)(`summary`,{className:`cursor-pointer text-zinc-500`,children:[e,` `,t.count,` `,t.count===1?`file`:`files`]}),(0,A.jsxs)(`div`,{className:`font-mono text-zinc-300`,children:[t.paths.join(`, `),t.count>t.paths.length&&(0,A.jsxs)(`span`,{className:`text-zinc-500`,children:[` … and `,t.count-t.paths.length,` more`]})]})]},e))]})}function Pd({diff:e}){let t=ru(e);return t?(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`mb-1 text-zinc-500`,children:t.declaredBefore?t.declaredAfter?`Identity — what this version changes in it:`:`Identity — this version no longer declares it: its audience is dropped and its user surface is no longer served:`:`Identity — this version declares it for the first time:`}),(0,A.jsx)(`div`,{className:`space-y-0.5 text-zinc-400`,children:t.rows.map(e=>(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`span`,{className:`text-zinc-500`,children:[e.label,` `]}),(0,A.jsx)(`span`,{className:`font-mono text-zinc-300`,children:e.entries.join(`, `)}),e.approval&&(0,A.jsx)(`span`,{className:`text-yellow-400`,children:` — waits for approval`})]},e.label))}),t.declaredAfter&&e.after&&(0,A.jsx)(`div`,{className:`mt-1.5`,children:(0,A.jsx)(kd,{block:e.after})})]}):e?.after?(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`mb-1 text-zinc-500`,children:`Identity — unchanged:`}),(0,A.jsx)(kd,{block:e.after})]}):null}function Fd({diff:e}){let t=Jr(e);return t?(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`mb-1 text-zinc-500`,children:`Settings — what this version changes in them:`}),(0,A.jsx)(`div`,{className:`space-y-0.5 text-zinc-400`,children:t.rows.map(e=>(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`span`,{className:`text-zinc-500`,children:[e.label,` `]}),(0,A.jsx)(`span`,{className:`font-mono text-zinc-300`,children:e.entries.join(`, `)}),e.note&&(0,A.jsxs)(`span`,{className:`text-yellow-400`,children:[` — `,e.note]})]},e.label))}),t.secretToPlain.length>0&&(0,A.jsxs)(`p`,{className:`mt-1.5 flex items-start gap-1.5 text-red-400`,children:[(0,A.jsx)(ja,{size:12,className:`mt-0.5 shrink-0`}),(0,A.jsxs)(`span`,{children:[`Secrets become plain values:`,` `,(0,A.jsx)(`span`,{className:`font-mono`,children:t.secretToPlain.join(`, `)}),`. Their secrets are dropped, but what is typed into them after the update is stored on the relay and shown in clear — never put a credential there.`]})]})]}):null}function Id({reasons:e}){return!Array.isArray(e)||e.length===0?null:(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`mb-1 text-zinc-500`,children:`Auto-approve does not cover it:`}),(0,A.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-5 text-yellow-400/90`,children:e.map(e=>(0,A.jsx)(`li`,{children:e},e))})]})}function Ld({plugin:e,isActing:t}){let n=F(),r=j(),i=z(),{followOperation:a}=lo(),[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)(null),u=M({queryKey:[`plugin-hooks`,e.name],queryFn:()=>n.getPluginHooks(e.name),refetchInterval:3e4}).data?.hooks,d=()=>gd(r,e.name),f=N({mutationFn:({digest:t,version:r})=>n.approvePluginHooks(e.name,t,r),onSuccess:t=>{t.operation&&a(t.operation.id),d(),i(t.operation?`Approved — updating ${e.name}`:`${e.name}: approved`)},onError:t=>{d(),i(_d(t,e),`error`)}}),p=N({mutationFn:t=>n.setPluginHooksAutoApprove(e.name,t),onSuccess:d,onError:e=>i(B(e),`error`)}),m=N({mutationFn:()=>n.discardPluginUpdate(e.name),onSuccess:()=>{d(),i(`Pending update discarded`)},onError:e=>i(B(e),`error`)});if(!u||!u.relay&&!u.agent&&!u.agentHalf&&!u.identity?.declared&&!u.web?.declared&&!u.pendingUpdate)return null;let h=t||f.isPending||p.isPending||m.isPending,{approval:_,pendingUpdate:v}=u,y=_.state===`pending`,b=vd(u),{subject:x,plural:S}=xd(b),C=Array.isArray(v?.approvalRequired)?v.approvalRequired:[],w=(v?.autoApproveWithheld??[]).filter(e=>!C.some(t=>t.reason===e)),T=(e,t,n,r)=>c===e?(0,A.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,A.jsx)(`span`,{className:`text-zinc-400`,children:n}),(0,A.jsx)(`button`,{type:`button`,disabled:h,onClick:()=>{l(null),f.mutate(r)},className:`rounded bg-cyan-600 px-2 py-1 text-white hover:bg-cyan-500 disabled:opacity-50`,children:`Approve`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>l(null),className:`rounded bg-zinc-700 px-2 py-1 text-zinc-300 hover:bg-zinc-600`,children:`Cancel`})]}):(0,A.jsxs)(`button`,{type:`button`,disabled:h,onClick:()=>{s(!0),l(e)},className:`flex items-center gap-1.5 rounded bg-cyan-600 px-2.5 py-1 text-white hover:bg-cyan-500 disabled:opacity-50`,children:[(0,A.jsx)(Ta,{size:11}),` `,t]});return(0,A.jsxs)(`div`,{className:`rounded border border-zinc-800 bg-zinc-950/60 p-3 mb-4 text-xs`,children:[(0,A.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`flex w-full flex-wrap items-center gap-2 text-left`,children:[o?(0,A.jsx)(_i,{size:12}):(0,A.jsx)(yi,{size:12}),(0,A.jsx)(`span`,{className:`text-zinc-300 font-medium`,children:`Lifecycle hooks`}),_.required&&(y?(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-yellow-500/15 px-2 py-0.5 text-yellow-400`,children:[(0,A.jsx)(wa,{size:11}),` `,x,` `,S?`wait`:`waits`,` for approval`]}):(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-green-500/15 px-2 py-0.5 text-green-400`,children:[(0,A.jsx)(gi,{size:11}),` `,x,` approved`]})),u.relay?.failOpenCount>0&&(0,A.jsxs)(`span`,{className:`text-yellow-400`,children:[u.relay.failOpenCount,` fail-open`]}),v&&(0,A.jsxs)(`span`,{className:`text-yellow-400`,children:[`update `,v.version,` waiting`]})]}),o&&(0,A.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[_.required&&(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(`p`,{className:`text-zinc-500`,children:y?Cd(b):`Approved by ${_.approvedBy} ${_.approvedAt?new Date(_.approvedAt).toLocaleString():``} (version ${_.approvedVersion}).`}),(0,A.jsx)(Dd,{digest:_.digest}),(0,A.jsx)(jd,{...b}),(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[y&&T(`installed`,`Approve`,Sd(b),{digest:_.digest}),(0,A.jsxs)(`label`,{className:`flex items-center gap-1.5 text-zinc-400`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:u.autoApprove,disabled:h,onChange:e=>p.mutate(e.target.checked)}),`Approve what later versions of this plugin bring automatically`]})]})]}),u.agent&&(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`text-zinc-500 mb-1`,children:`Agent hooks — run by the agent half on its agent; no approval needed:`}),(0,A.jsx)(`div`,{className:`font-mono text-zinc-300`,children:u.agent.stages.map(e=>e.stage).join(`, `)})]}),v&&(0,A.jsxs)(`div`,{className:`space-y-2 rounded border border-yellow-500/30 p-2`,children:[(0,A.jsxs)(`p`,{className:`text-yellow-400`,children:[`Version `,v.version,` waits for your approval — the installed version stays live until then:`]}),(0,A.jsx)(Od,{reasons:C}),v.digest&&(0,A.jsx)(Dd,{digest:v.digest,approved:v.digest===_.approvedDigest}),(0,A.jsx)(jd,{relay:v.relay,agentHalf:v.agentHalf}),(0,A.jsx)(Pd,{diff:v.identity}),(0,A.jsx)(Md,{web:v.web}),(0,A.jsx)(Fd,{diff:v.settings}),(0,A.jsx)(Id,{reasons:w}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[T(`update`,`Approve and update`,Ed(v),{digest:v.digest,version:v.version}),(0,A.jsxs)(`button`,{type:`button`,disabled:h,onClick:()=>m.mutate(),className:`flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1 text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:[(0,A.jsx)(Ga,{size:11}),` Discard`]})]})]})]})]})}function Rd({plugin:e,isActing:t}){let n=F(),r=j(),i=z(),{followOperation:a}=lo(),[o,s]=(0,g.useState)(``),c=N({mutationFn:()=>n.updatePlugin(e.name,o.trim()||void 0),onSuccess:t=>{t.operation&&a(t.operation.id),gd(r,e.name),t.upToDate?i(`${e.name} is already at ${t.version}`):t.pendingUpdate?i(`${e.name} ${t.pendingUpdate.version} waits for your approval — see why under Lifecycle hooks`):i(`Updating ${e.name}`),s(``)},onError:t=>i(_d(t,e),`error`)});return(0,A.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,A.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:`latest`,className:`w-20 rounded bg-zinc-800 border border-zinc-700 px-2 py-1 text-xs text-zinc-300 focus:outline-none focus:border-cyan-400`,"aria-label":`Version to update to`}),(0,A.jsxs)(`button`,{type:`button`,disabled:t||c.isPending,onClick:()=>c.mutate(),className:`flex items-center gap-1.5 rounded bg-zinc-700 px-3 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,title:`Fetch the version and read it before installing it; relay hooks that changed, a new agent half, a changed web tree, secret settings turned plain and roles added or removed or attributes widened wait for approval`,children:[c.isPending?(0,A.jsx)(L,{size:12,className:`animate-spin`}):(0,A.jsx)(Ai,{size:12}),`Update`]})]})}var zd=`push-install`;function Bd(){requestAnimationFrame(()=>{document.getElementById(zd)?.scrollIntoView({behavior:`smooth`,block:`start`})})}function Vd(e,t){return e!=null&&Date.parse(e)>t}var Hd=30;function Ud(e,t){let n=Number(e);return!/^\d+$/.test(e.trim())||n<t.min||n>t.max?`${t.min} to ${t.max} whole minutes`:null}function Wd({agent:e,config:t,onDone:n}){let r=F(),i=j(),a=z(),o=t.windowMinutes,[s,c]=(0,g.useState)(String(Math.min(Math.max(Hd,o.min),o.max))),[l,u]=(0,g.useState)(t.policies.some(t=>t.id===e.pushInstallPolicy)?e.pushInstallPolicy:t.defaultPolicy),d=Ud(s,o),f=N({mutationFn:()=>r.enablePushInstall(e.label,{durationMinutes:Number(s),policyId:l}),onSuccess:t=>{i.invalidateQueries({queryKey:[`agent-certs`]}),a(`Push install open for ${e.label} until ${new Date(t.pushInstallEnabledUntil).toLocaleTimeString()}`),n()},onError:e=>a(B(e),`error`)});return(0,A.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),d||f.mutate()},className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,A.jsxs)(`label`,{className:`flex items-center gap-1.5 text-zinc-400`,children:[`for`,(0,A.jsx)(`input`,{type:`number`,inputMode:`numeric`,min:o.min,max:o.max,step:1,value:s,onChange:e=>c(e.target.value),"aria-invalid":d!==null,className:`w-20 rounded border bg-zinc-800 px-2 py-1 text-zinc-200 focus:outline-none ${d?`border-red-500/70`:`border-zinc-700 focus:border-cyan-400`}`}),`minutes`]}),(0,A.jsxs)(`label`,{className:`flex items-center gap-1.5 text-zinc-400`,children:[`policy`,(0,A.jsx)(`select`,{value:l,onChange:e=>u(e.target.value),className:`rounded border border-zinc-700 bg-zinc-800 px-2 py-1 text-zinc-200 focus:border-cyan-400 focus:outline-none`,children:t.policies.map(e=>(0,A.jsxs)(`option`,{value:e.id,children:[e.name,e.id===t.defaultPolicy?` (default)`:``]},e.id))})]}),(0,A.jsxs)(`button`,{type:`submit`,disabled:d!==null||f.isPending,className:`flex items-center gap-1.5 rounded bg-cyan-600 px-2.5 py-1 text-white hover:bg-cyan-500 disabled:opacity-50`,children:[f.isPending?(0,A.jsx)(L,{size:11,className:`animate-spin`}):(0,A.jsx)(ea,{size:11}),`Open`]}),(0,A.jsx)(`button`,{type:`button`,onClick:n,className:`rounded bg-zinc-700 px-2.5 py-1 text-zinc-300 hover:bg-zinc-600`,children:`Cancel`}),d&&(0,A.jsxs)(`span`,{className:`basis-full text-red-400`,children:[`A window is open `,d,`.`]})]})}function Gd({children:e}){let t=F(),n=j(),r=z(),[i,a]=(0,g.useState)(null),o=M({queryKey:[`push-install-config`],queryFn:()=>t.getPushInstallConfig(),refetchInterval:3e4}),s=M({queryKey:[`agent-certs`],queryFn:()=>t.getAgentCerts(),refetchInterval:3e4}),c=N({mutationFn:e=>t.updatePushInstallConfig(e),onSuccess:(e,t)=>{n.invalidateQueries({queryKey:[`push-install-config`]}),n.invalidateQueries({queryKey:[`push-install-policies`]}),t.enabled===void 0?r(`Default policy: ${e.defaultPolicy}`):r(e.enabled?`Push install is on — open the window of the agent to push to`:`Push install is off — every push is refused`)},onError:e=>r(B(e),`error`)}),l=N({mutationFn:e=>t.disablePushInstall(e),onSuccess:(e,t)=>{n.invalidateQueries({queryKey:[`agent-certs`]}),r(`Push install closed for ${t}`)},onError:e=>r(B(e),`error`)}),u=o.data,d=(s.data?.agents??[]).filter(e=>!e.revoked&&!e.label.startsWith(`plugin-agent:`)).sort((e,t)=>e.label.localeCompare(t.label)),f=s.dataUpdatedAt,p=e=>Vd(e.pushInstallEnabledUntil,f),m=e=>u?.policies.find(t=>t.id===e)?.name??e;return(0,A.jsx)(`section`,{id:zd,className:`mt-8 scroll-mt-6`,children:(0,A.jsxs)(`div`,{className:`border-t border-zinc-700 pt-6`,children:[(0,A.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center justify-between gap-3`,children:[(0,A.jsxs)(`h2`,{className:`flex items-center gap-2 text-lg font-semibold text-white`,children:[(0,A.jsx)(Ea,{size:18,className:`text-cyan-400`}),`Push Install`,u&&(0,A.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-xs font-normal ${u.enabled?`bg-green-500/20 text-green-400`:`bg-zinc-500/20 text-zinc-400`}`,children:u.enabled?`on`:`off`})]}),u&&(0,A.jsxs)(`button`,{type:`button`,disabled:c.isPending,onClick:()=>c.mutate({enabled:!u.enabled}),className:`flex items-center gap-1.5 rounded px-3 py-1.5 text-xs disabled:opacity-50 ${u.enabled?`bg-zinc-700 text-zinc-300 hover:bg-zinc-600`:`bg-cyan-600 text-white hover:bg-cyan-500`}`,children:[u.enabled?(0,A.jsx)(da,{size:12}):(0,A.jsx)(fa,{size:12}),u.enabled?`Turn off`:`Turn on`]})]}),(0,A.jsx)(`p`,{className:`mb-4 text-sm text-zinc-500`,children:`Lets the panel install, update and remove what Lamaste installs on an agent — the agent half of an app plugin — while that agent's window is open, within its policy. Off: every push is refused, open windows included.`}),o.isError?(0,A.jsx)(`p`,{className:`mb-4 text-sm text-red-400`,children:B(o.error)}):u?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`label`,{className:`mb-4 flex flex-wrap items-center gap-2 text-sm text-zinc-400`,children:[`Default policy for a window`,(0,A.jsx)(`select`,{value:u.defaultPolicy,disabled:c.isPending,onChange:e=>c.mutate({defaultPolicy:e.target.value}),className:`rounded border border-zinc-700 bg-zinc-800 px-2 py-1 text-sm text-zinc-200 focus:border-cyan-400 focus:outline-none`,children:u.policies.map(e=>(0,A.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,A.jsx)(`div`,{className:`mb-6 overflow-x-auto rounded-lg border border-zinc-800`,children:(0,A.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-900`,children:[(0,A.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Agent`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Window`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-right text-xs font-medium uppercase text-zinc-400`,children:`Manage`})]})}),(0,A.jsxs)(`tbody`,{children:[s.isError&&(0,A.jsx)(`tr`,{className:`bg-zinc-800`,children:(0,A.jsx)(`td`,{colSpan:3,className:`px-4 py-3 text-red-400`,children:B(s.error)})}),s.isSuccess&&d.length===0&&(0,A.jsx)(`tr`,{className:`bg-zinc-800`,children:(0,A.jsx)(`td`,{colSpan:3,className:`px-4 py-3 text-zinc-500`,children:`No enrolled machine agent.`})}),d.map(e=>{let t=p(e);return(0,A.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-800`,children:[(0,A.jsx)(`td`,{className:`whitespace-nowrap px-4 py-3 align-top font-mono text-zinc-200`,children:e.label}),(0,A.jsxs)(`td`,{className:`px-4 py-3 align-top`,children:[t?(0,A.jsxs)(`span`,{className:`flex items-center gap-1.5 text-green-400`,children:[(0,A.jsx)(Ei,{size:12}),`open until `,new Date(e.pushInstallEnabledUntil).toLocaleString(),(0,A.jsxs)(`span`,{className:`text-zinc-500`,children:[`· policy `,m(e.pushInstallPolicy)]})]}):(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`closed`}),i===e.label&&(0,A.jsx)(`div`,{className:`mt-2`,children:(0,A.jsx)(Wd,{agent:e,config:u,onDone:()=>a(null)})})]}),(0,A.jsx)(`td`,{className:`px-4 py-3 text-right align-top`,children:(0,A.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[i!==e.label&&(0,A.jsxs)(`button`,{type:`button`,disabled:!u.enabled,onClick:()=>a(e.label),title:u.enabled?`Open the window for a number of minutes, under a policy`:`Turn push install on first`,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 disabled:opacity-50`,children:[(0,A.jsx)(ea,{size:12}),t?`Reopen…`:`Open…`]}),t&&(0,A.jsxs)(`button`,{type:`button`,disabled:l.isPending,onClick:()=>l.mutate(e.label),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 disabled:opacity-50`,children:[(0,A.jsx)(ta,{size:12}),`Close`]})]})})]},e.label)})]})]})})]}):(0,A.jsx)(`div`,{className:`mb-4 h-24 animate-pulse rounded-lg border border-zinc-800 bg-zinc-900`}),e]})})}function Kd({onClose:e}){return(0,A.jsxs)(`button`,{type:`button`,onClick:()=>{e(),Bd()},className:`inline-flex items-center gap-1 text-cyan-400 hover:text-cyan-300 hover:underline`,children:[(0,A.jsx)(ci,{size:11}),`Push install`]})}function qd({until:e,now:t}){return Vd(e,t)?(0,A.jsxs)(`span`,{className:`text-green-400`,children:[`push install open until `,new Date(e).toLocaleTimeString()]}):(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`push install closed`})}var Jd=(0,g.forwardRef)(function({refusal:e,pluginName:t,onClose:n},r){return(0,A.jsxs)(`div`,{ref:r,className:`rounded border border-red-500/30 bg-red-500/5 p-3 text-xs`,children:[(0,A.jsxs)(`p`,{className:`flex items-start gap-1.5 text-red-400`,children:[(0,A.jsx)(ja,{size:12,className:`mt-0.5 shrink-0`}),e.code===`agent_not_eligible`?`Agent "${e.agentLabel}" cannot host ${t}:`:e.message]}),e.code===`agent_not_eligible`&&(0,A.jsx)(`ul`,{className:`mt-1 list-disc space-y-0.5 pl-6 text-zinc-300`,children:e.reasons.map(e=>(0,A.jsx)(`li`,{children:e},e))}),e.hint&&(0,A.jsx)(`p`,{className:`mt-1.5 text-zinc-400`,children:e.hint}),e.code===`push_install_refused`&&(0,A.jsx)(`p`,{className:`mt-1.5`,children:(0,A.jsx)(Kd,{onClose:n})})]})});function Yd({query:e}){let t=e.data?.fields;return(0,A.jsxs)(`div`,{className:`rounded border border-zinc-800 bg-zinc-950/60 p-3`,children:[(0,A.jsxs)(`p`,{className:`mb-1 flex items-center gap-1.5 font-medium text-zinc-300`,children:[(0,A.jsx)(Da,{size:12,className:`text-cyan-400`}),`Settings it asks for`]}),(0,A.jsx)(`p`,{className:`mb-2 text-zinc-500`,children:`Hosting takes no settings: the agent half starts without them, and you fill them in under Settings on the plugin's card once it is hosted. Secrets are kept by the agent half alone; every other value is also kept on the relay and shown in clear.`}),Array.isArray(t)?(0,A.jsx)(`ul`,{className:`space-y-1`,children:t.map(e=>(0,A.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[e.type===`secret`&&(0,A.jsx)(qi,{size:11,className:`shrink-0 self-center text-cyan-400`}),(0,A.jsx)(`span`,{className:`text-zinc-300`,children:e.label}),(0,A.jsx)(`span`,{className:`font-mono text-zinc-600`,children:e.key}),(0,A.jsx)(`span`,{className:e.type===`secret`?`text-cyan-400`:`text-zinc-500`,children:qr(e)}),Gr(e)&&(0,A.jsx)(`span`,{className:`w-full text-yellow-400/90`,children:`Stored on the relay and shown in clear — use a secret field for credentials.`})]},e.key))}):e.isError?(0,A.jsx)(`p`,{className:`text-red-400`,children:B(e.error)}):(0,A.jsx)(L,{size:12,className:`animate-spin text-zinc-500`})]})}function Xd({plugin:e,onHost:t,onClose:n,isActing:r}){let i=F(),[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(null),[l,u]=(0,g.useState)(!1),d=(0,g.useRef)(null);(0,g.useEffect)(()=>{s&&d.current?.scrollIntoView({block:`nearest`,behavior:`smooth`})},[s]);let f=e.hooks?.agentHalf===!0,p=e.hooks?.approval===`pending`,m=M({queryKey:[`plugin-hosting-eligibility`,e.name],queryFn:()=>i.getPluginHostingEligibility(e.name),refetchInterval:3e4}),h=M({queryKey:[`agent-certs`],queryFn:()=>i.getAgentCerts(),refetchInterval:3e4}),_=M({queryKey:[`push-install-config`],queryFn:()=>i.getPushInstallConfig(),enabled:f}),v=M({queryKey:[`plugin-hooks`,e.name],queryFn:()=>i.getPluginHooks(e.name),enabled:f}),y=e.settings!=null,b=M({queryKey:[`plugin-settings`,e.name],queryFn:()=>i.getPluginSettings(e.name),enabled:y,refetchOnWindowFocus:!1}),x=m.data?.agents??[],S=new Map((h.data?.agents??[]).map(e=>[e.label,e])),C=x.some(e=>e.label===a&&e.eligible)?a:``,w=v.data?.hooks?.agentHalf??null,T=f&&_.data?.enabled===!1,E=h.dataUpdatedAt,D=C?S.get(C):void 0,ee=f&&!T&&D!==void 0&&!Vd(D.pushInstallEnabledUntil,E);return(0,A.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4`,children:(0,A.jsxs)(`div`,{className:`flex max-h-full w-full max-w-2xl flex-col rounded-xl border border-zinc-700 bg-zinc-900 shadow-xl`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between border-b border-zinc-800 px-6 py-4`,children:[(0,A.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold text-white`,children:[(0,A.jsx)(xa,{size:18,className:`text-cyan-400`}),`Host `,e.displayName||e.name]}),(0,A.jsx)(`button`,{type:`button`,onClick:n,disabled:l,"aria-label":`Close`,className:`text-zinc-400 hover:text-white disabled:opacity-50`,children:(0,A.jsx)(Ga,{size:20})})]}),(0,A.jsxs)(`div`,{className:`space-y-4 overflow-y-auto px-6 py-4 text-xs`,children:[(0,A.jsx)(`p`,{className:`text-zinc-400`,children:f?`Lamaste installs the agent half on the agent you pick, as a service of its own, and runs the install hooks around creating the internal tunnel, assigning the port and issuing the installation secret.`:`Pick the agent that runs its agent half (installed there by hand): Lamaste runs the install hooks around creating the internal tunnel, assigning the port and issuing the installation secret.`}),f&&(0,A.jsxs)(`div`,{className:`rounded border border-zinc-800 bg-zinc-950/60 p-3`,children:[(0,A.jsx)(`p`,{className:`mb-2 font-medium text-zinc-300`,children:`What Lamaste installs on the agent`}),w?(0,A.jsx)(hd,{agentHalf:w}):v.isError?(0,A.jsx)(`p`,{className:`text-red-400`,children:B(v.error)}):(0,A.jsx)(L,{size:12,className:`animate-spin text-zinc-500`})]}),y&&(0,A.jsx)(Yd,{query:b}),p&&(0,A.jsxs)(`p`,{className:`flex items-start gap-1.5 text-yellow-400`,children:[(0,A.jsx)(wa,{size:12,className:`mt-0.5 shrink-0`}),f?`Not approved yet — approve what it brings under Lifecycle hooks on the plugin’s card, then host it.`:`Its relay hooks are not approved yet — approve them under Lifecycle hooks on the plugin’s card, then host it.`]}),T&&(0,A.jsxs)(`p`,{className:`flex flex-wrap items-start gap-1.5 text-yellow-400`,children:[(0,A.jsx)(ja,{size:12,className:`mt-0.5 shrink-0`}),(0,A.jsxs)(`span`,{children:[`Push install is off on this relay: Lamaste cannot install the agent half until it is on and the agent's window is open — under `,(0,A.jsx)(Kd,{onClose:n}),`.`]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`mb-2 font-medium text-zinc-300`,children:`Agent`}),m.isLoading?(0,A.jsx)(`div`,{className:`space-y-2`,children:Array.from({length:2}).map((e,t)=>(0,A.jsx)(`div`,{className:`h-12 animate-pulse rounded bg-zinc-800`},t))}):m.isError?(0,A.jsx)(`p`,{className:`text-red-400`,children:B(m.error)}):x.length===0?(0,A.jsx)(`p`,{className:`text-zinc-500`,children:`No enrolled machine agent — enroll one under Certificates first.`}):(0,A.jsx)(`ul`,{className:`space-y-1.5`,role:`radiogroup`,"aria-label":`Hosting agent`,children:x.map(t=>{let n=S.get(t.label);return(0,A.jsx)(`li`,{children:(0,A.jsxs)(`label`,{className:`flex items-start gap-2 rounded border px-3 py-2 ${t.eligible?C===t.label?`cursor-pointer border-cyan-500/60 bg-cyan-500/5`:`cursor-pointer border-zinc-800 bg-zinc-950/60 hover:border-zinc-700`:`cursor-not-allowed border-zinc-800 bg-zinc-950/40`}`,children:[(0,A.jsx)(`input`,{type:`radio`,name:`host-${e.name}`,value:t.label,checked:C===t.label,disabled:!t.eligible,onChange:()=>o(t.label),className:`mt-0.5 accent-cyan-500`}),(0,A.jsxs)(`span`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,A.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,A.jsx)(`span`,{className:`font-mono ${t.eligible?`text-zinc-200`:`text-zinc-500`}`,children:t.label}),f&&t.eligible&&n&&(0,A.jsx)(qd,{until:n.pushInstallEnabledUntil,now:E})]}),(0,A.jsx)(`span`,{className:`block`,children:(0,A.jsx)(Eu,{facts:n?.hostFacts??null,at:n?.hostFactsAt??null})}),!t.eligible&&(0,A.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-4 text-yellow-400/90`,children:t.reasons.map(e=>(0,A.jsx)(`li`,{children:e},e))})]})]})},t.label)})})]}),ee&&(0,A.jsxs)(`p`,{className:`flex items-start gap-1.5 text-yellow-400`,children:[(0,A.jsx)(ja,{size:12,className:`mt-0.5 shrink-0`}),(0,A.jsxs)(`span`,{children:[`The push-install window of `,(0,A.jsx)(`span`,{className:`font-mono`,children:C}),` is closed: Lamaste installs the agent half by push install, so open it first — under`,` `,(0,A.jsx)(Kd,{onClose:n}),`.`]})]}),s&&(0,A.jsx)(Jd,{ref:d,refusal:s,pluginName:e.displayName||e.name,onClose:n})]}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-3 border-t border-zinc-800 px-6 py-4`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:n,disabled:l,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Cancel`}),(0,A.jsxs)(`button`,{type:`button`,disabled:l||r||!C||p,onClick:()=>{c(null),u(!0),t(e.name,C,{onSuccess:n,onError:e=>{u(!1);let t=id(e,{agentLabel:C,action:`install`});c({...t,agentLabel:C}),t.code===`agent_not_eligible`&&m.refetch()}})},title:p?`Approve what it brings first (Lifecycle hooks)`:void 0,className:`flex items-center gap-1.5 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:[l?(0,A.jsx)(L,{size:14,className:`animate-spin`}):(0,A.jsx)(xa,{size:14}),C?`Host on ${C}`:`Host on agent`]})]})]})})}function Zd(e,t){e.invalidateQueries({queryKey:[`plugin-identity`,t]}),e.invalidateQueries({queryKey:[`plugin-audience`,t]}),e.invalidateQueries({queryKey:[`plugin-entitlements`,t]}),e.invalidateQueries({queryKey:[`gatekeeper-grants`]})}function Qd(e,t){return e?`${new Date(e).toLocaleString()} (${br(e,t)})`:`—`}function $d({children:e}){return(0,A.jsx)(`p`,{className:`mb-1.5 text-zinc-500`,children:e})}function ef({view:e}){let{declared:t,readiness:n,approval:r}=e,i=Kl(n);return(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)($d,{children:`Roles the installed version declares:`}),(0,A.jsx)(`ul`,{className:`space-y-0.5`,children:t.roles.map(e=>(0,A.jsxs)(`li`,{children:[(0,A.jsx)(`span`,{className:`font-mono text-zinc-200`,children:e.id}),(0,A.jsxs)(`span`,{className:`text-zinc-400`,children:[` — `,e.label]}),e.description&&(0,A.jsxs)(`span`,{className:`text-zinc-600`,children:[` · `,e.description]})]},e.id))})]}),(0,A.jsxs)(`p`,{className:`text-zinc-400`,children:[`Each member reaches it with their user id, username, roles and status`,t.attributes.length>0?`, and their ${t.attributes.map(Hl).join(` and `)}`:` — nothing else about them`,`.`]}),(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r.approved?(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-green-500/15 px-2 py-0.5 text-green-400`,children:[(0,A.jsx)(gi,{size:11}),` identity approved`]}):(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-yellow-500/15 px-2 py-0.5 text-yellow-400`,title:`Its users are sent to it, and reach it, only once it is approved`,children:[(0,A.jsx)(wa,{size:11}),` identity waits for approval (Lifecycle hooks)`]}),(0,A.jsx)(`span`,{className:i.ready?`text-green-400`:`text-yellow-400`,children:i.text})]})]})}function tf({entitlement:e,roles:t,onSet:n,onRemove:r,busy:i}){let[a,o]=(0,g.useState)(!1),s=e.roles.filter(e=>t.some(t=>t.id===e));return(0,A.jsx)(`li`,{className:`rounded bg-zinc-900 px-2 py-1.5`,children:(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,A.jsx)(e.principalType===`user`?Ba:Ha,{size:11,className:e.principalType===`user`?`text-blue-400`:`text-purple-400`}),(0,A.jsx)(`span`,{className:`font-mono text-zinc-200`,children:e.principalId}),e.principalType===`group`&&(0,A.jsx)(`span`,{className:`text-zinc-600`,children:`group`})]}),e.principalType===`user`&&(0,A.jsx)(iu,{id:e.userId,missing:`not in the user directory`}),(0,A.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[t.map(t=>{let r=s.includes(t.id),a=r&&s.length===1;return(0,A.jsxs)(`label`,{className:`flex items-center gap-1 text-zinc-300`,title:a?`The last role — remove the entitlement instead`:t.label,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:r,disabled:i||a,onChange:r=>n(e,tu(s,t.id,r.target.checked))}),(0,A.jsx)(`span`,{className:`font-mono`,children:t.id})]},t.id)}),e.unknownRoles.map(e=>(0,A.jsx)(`span`,{className:`font-mono text-zinc-600 line-through`,title:`The installed version no longer declares this role: it counts for nothing`,children:e},e))]}),(0,A.jsx)(`span`,{className:`ml-auto`,children:a?(0,A.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,A.jsx)(`span`,{className:`text-zinc-400`,children:`Remove every role?`}),(0,A.jsx)(`button`,{type:`button`,disabled:i,onClick:()=>{o(!1),r(e)},className:`rounded bg-red-600 px-2 py-0.5 text-white hover:bg-red-500 disabled:opacity-50`,children:`Remove`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`rounded bg-zinc-700 px-2 py-0.5 text-zinc-300 hover:bg-zinc-600`,children:`Cancel`})]}):(0,A.jsx)(`button`,{type:`button`,disabled:i,onClick:()=>o(!0),title:`Revoke every role this principal holds on the plugin`,className:`text-zinc-500 hover:text-red-400 disabled:opacity-50`,children:(0,A.jsx)(R,{size:12})})})]})})}function nf({roles:e,taken:t,onSet:n,busy:r}){let i=F(),[a,o]=(0,g.useState)(`user`),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)([]),d=M({queryKey:[`users`],queryFn:()=>i.getUsers()}),f=M({queryKey:[`gatekeeper-groups`],queryFn:()=>i.getGatekeeperGroups(),retry:!1}),p=e=>!t.has(`${a}:${e}`),m=a===`user`?(d.data?.users??[]).filter(e=>p(e.username)).map(e=>({id:e.username,label:`${e.username}${e.status===`disabled`?` (disabled)`:``}`})):(f.data?.groups??[]).filter(e=>p(e.name)).map(e=>({id:e.name,label:e.name})),h=a===`user`?d.isError&&`Users could not be listed`:f.isError&&`Lamaste groups could not be listed: ${B(f.error)}`;return(0,A.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),!(!s||l.length===0)&&n({principalType:a,principalId:s,roles:[...l].sort()},()=>{c(``),u([])})},className:`space-y-2 rounded border border-zinc-800 p-2`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[[`user`,`group`].map(e=>(0,A.jsx)(`button`,{type:`button`,onClick:()=>{o(e),c(``)},className:`rounded px-2 py-0.5 ${a===e?`bg-cyan-600 text-white`:`bg-zinc-800 text-zinc-400 hover:text-zinc-200`}`,children:e===`user`?`User`:`Group`},e)),(0,A.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),"aria-label":a===`user`?`User`:`Lamaste group`,className:`min-w-40 rounded border border-zinc-700 bg-zinc-800 px-2 py-1 text-zinc-200 focus:border-cyan-400 focus:outline-none`,children:[(0,A.jsx)(`option`,{value:``,children:a===`user`?`Select a user…`:`Select a Lamaste group…`}),m.map(e=>(0,A.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}),(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`Roles:`}),e.map(e=>(0,A.jsxs)(`label`,{className:`flex items-center gap-1 text-zinc-300`,title:e.label,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:l.includes(e.id),onChange:t=>u(n=>tu(n,e.id,t.target.checked))}),(0,A.jsx)(`span`,{className:`font-mono`,children:e.id})]},e.id)),(0,A.jsxs)(`button`,{type:`submit`,disabled:r||!s||l.length===0,className:`ml-auto flex items-center gap-1 rounded bg-cyan-600 px-2.5 py-1 text-white hover:bg-cyan-500 disabled:opacity-50`,children:[(0,A.jsx)(ua,{size:11}),` Give roles`]})]}),h&&(0,A.jsx)(`p`,{className:`text-red-400`,children:h}),a===`group`&&(0,A.jsx)(`p`,{className:`text-zinc-600`,children:`A Lamaste group's members hold its roles while they are in it.`})]})}function rf({plugin:e,roles:t}){let n=F(),r=j(),i=z(),a=M({queryKey:[`plugin-entitlements`,e.name],queryFn:()=>n.getPluginEntitlements(e.name)}),o=e=>{for(let t of e??[])i(Wl(t),`error`)},s=N({mutationFn:t=>n.setPluginEntitlement(e.name,t),onSuccess:(t,n)=>{Zd(r,e.name),i(t.changed?`${n.principalId}: ${n.roles.join(`, `)}`:`${n.principalId} already holds exactly these roles`),o(t.warnings)},onError:e=>i(B(e),`error`)}),c=N({mutationFn:t=>n.removePluginEntitlement(e.name,t),onSuccess:(t,n)=>{Zd(r,e.name),i(`${n.principalId} holds no role on ${e.name} any more`),o(t.warnings)},onError:e=>i(B(e),`error`)}),l=s.isPending||c.isPending,u=a.data?.entitlements??[],d=new Set(u.map(e=>`${e.principalType}:${e.principalId}`));return(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)($d,{children:`Entitlements — who may use it, with which roles:`}),a.isLoading?(0,A.jsx)(L,{size:12,className:`animate-spin text-zinc-500`}):a.isError?(0,A.jsx)(`p`,{className:`text-red-400`,children:B(a.error)}):u.length===0?(0,A.jsx)(`p`,{className:`text-zinc-600`,children:`Nobody yet — give a user or a Lamaste group a role below.`}):(0,A.jsx)(`ul`,{className:`space-y-1`,children:u.map(e=>(0,A.jsx)(tf,{entitlement:e,roles:t,busy:l,onSet:(e,t)=>s.mutate({principalType:e.principalType,principalId:e.principalId,roles:t}),onRemove:e=>c.mutate({principalType:e.principalType,principalId:e.principalId})},`${e.principalType}:${e.principalId}`))}),a.data?.roleless>0&&(0,A.jsxs)(`p`,{className:`text-zinc-600`,children:[a.data.roleless,` grant`,a.data.roleless===1?``:`s`,` on this plugin carr`,a.data.roleless===1?`ies`:`y`,` no roles (desktop installs, migrated grants) — they never make anyone a member.`]}),(0,A.jsx)(nf,{roles:t,taken:d,busy:l,onSet:(e,t)=>s.mutate(e,{onSuccess:t})})]})}var af={active:`bg-green-500/15 text-green-400`,disabled:`bg-yellow-500/15 text-yellow-400`,removed:`bg-zinc-700/60 text-zinc-400`,erased:`bg-red-500/10 text-red-400`,unknown:`bg-zinc-700/60 text-zinc-500`};function of({view:e,now:t,external:n}){let r=e.status===`erased`?`erased`:e.displayName&&e.username?`${e.displayName} (${e.username})`:e.username??`—`;return(0,A.jsxs)(`tr`,{className:`border-t border-zinc-800`,children:[(0,A.jsxs)(`td`,{className:`py-1 pr-2 ${e.status===`erased`?`text-zinc-600`:`text-zinc-200`}`,children:[r,n&&(0,A.jsx)(`span`,{className:`ml-2`,children:(0,A.jsx)(Yc,{})})]}),(0,A.jsx)(`td`,{className:`py-1 pr-2`,children:(0,A.jsx)(iu,{id:e.userId})}),(0,A.jsx)(`td`,{className:`py-1 pr-2 font-mono text-zinc-300`,children:e.roles.join(`, `)||`—`}),(0,A.jsx)(`td`,{className:`py-1 pr-2`,children:(0,A.jsx)(`span`,{className:`rounded-full px-1.5 py-0.5 ${af[e.status]}`,children:e.status===`removed`?eu(e.reason):e.status})}),(0,A.jsx)(`td`,{className:`py-1 text-zinc-600`,title:`seq ${e.seq} · version ${e.version}`,children:br(e.updatedAt,t)})]})}function sf({plugin:e}){let t=F(),[n,r]=(0,g.useState)(!1),i=M({queryKey:[`plugin-audience`,e.name],queryFn:()=>t.getPluginAudience(e.name),refetchInterval:15e3}),a=Wc(M({queryKey:[`users`],queryFn:()=>t.getUsers()}).data?.users,e.domain),o=i.dataUpdatedAt,s=(i.data?.audience??[]).map($l),c=s.filter(e=>e.member),l=s.filter(e=>!e.member),u=n?[...c,...l]:c;return(0,A.jsxs)(`div`,{children:[(0,A.jsxs)($d,{children:[`Audience — what its agent half is told`,i.data?` (head seq ${i.data.head})`:``,`:`]}),i.isLoading?(0,A.jsx)(L,{size:12,className:`animate-spin text-zinc-500`}):i.isError?(0,A.jsx)(`p`,{className:`text-red-400`,children:B(i.error)}):s.length===0?(0,A.jsx)(`p`,{className:`text-zinc-600`,children:`No members yet.`}):(0,A.jsxs)(A.Fragment,{children:[u.length>0&&(0,A.jsx)(`div`,{className:`overflow-x-auto`,children:(0,A.jsxs)(`table`,{className:`w-full text-left`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`text-zinc-500`,children:[(0,A.jsx)(`th`,{className:`pb-1 pr-2 font-normal`,children:`User`}),(0,A.jsx)(`th`,{className:`pb-1 pr-2 font-normal`,children:`User id`}),(0,A.jsx)(`th`,{className:`pb-1 pr-2 font-normal`,children:`Roles`}),(0,A.jsx)(`th`,{className:`pb-1 pr-2 font-normal`,children:`Status`}),(0,A.jsx)(`th`,{className:`pb-1 font-normal`,children:`Changed`})]})}),(0,A.jsx)(`tbody`,{children:u.map(e=>(0,A.jsx)(of,{view:e,now:o,external:e.member&&a.has(e.userId)},e.userId))})]})}),c.length===0&&(0,A.jsx)(`p`,{className:`text-zinc-600`,children:`No members.`}),l.length>0&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`mt-1 text-zinc-500 hover:text-zinc-300`,children:n?`Hide the users who left`:`Show the ${l.length} user${l.length===1?``:`s`} who left (kept as tombstones)`})]})]})}function cf({plugin:e,sync:t,now:n}){let r=F(),i=j(),a=z(),o=N({mutationFn:t=>r.syncPluginIdentity(e.name,{reconcile:t}),onSuccess:({result:t},n)=>{Zd(i,e.name),t.status===`synced`?a(`${e.name}: ${t.replay?`replayed`:`synced`} up to seq ${t.cursor}`+(n?` — ${t.mismatches??0} out of step`:``)):t.status===`up-to-date`?a(`${e.name}: its agent half is up to date (seq ${t.cursor})`):a(`${e.name}: ${t.error??t.reason??t.status}`,`error`)},onError:e=>a(B(e),`error`)}),s=t.halfDirectoryId!==null&&t.halfDirectoryId!==t.directoryId,c=[[`directory`,(0,A.jsx)(iu,{id:t.directoryId,full:!0},`d`)],[`agent half follows`,t.halfDirectoryId===null?(0,A.jsx)(`span`,{className:`text-zinc-600`,children:`nothing yet`}):s?(0,A.jsxs)(`span`,{className:`text-yellow-400`,children:[`another directory (`,(0,A.jsx)(iu,{id:t.halfDirectoryId}),`) — the next sync replays`]}):`this directory`],[`position`,(0,A.jsxs)(`span`,{children:[`cursor `,(0,A.jsx)(`span`,{className:`font-mono text-zinc-300`,children:t.cursor??`—`}),` of head`,` `,(0,A.jsx)(`span`,{className:`font-mono text-zinc-300`,children:t.head}),t.behind>0?(0,A.jsxs)(`span`,{className:`text-yellow-400`,children:[` — `,t.behind,` change(s) behind`]}):(0,A.jsx)(`span`,{className:`text-green-400`,children:` — up to date`})]},`p`)],[`answered for version`,t.readyVersion??`—`],[`last sync`,Qd(t.lastSyncAt,n)],[`last reconcile`,(0,A.jsxs)(`span`,{children:[Qd(t.lastReconcileAt,n),t.lastMismatches!=null&&(0,A.jsxs)(`span`,{className:t.lastMismatches>0?`text-red-400`:`text-zinc-500`,children:[` `,`— `,t.lastMismatches,` out of step`]})]},`r`)]];return(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)($d,{children:`Feed to the agent half:`}),(0,A.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5`,children:c.map(([e,t])=>(0,A.jsxs)(`div`,{className:`contents`,children:[(0,A.jsx)(`dt`,{className:`text-zinc-500`,children:e}),(0,A.jsx)(`dd`,{className:`text-zinc-300`,children:t})]},e))}),t.lastError&&(0,A.jsxs)(`p`,{className:`flex items-start gap-1.5 text-red-400`,children:[(0,A.jsx)(ja,{size:12,className:`mt-0.5 shrink-0`}),` `,t.lastError]}),(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,A.jsxs)(`button`,{type:`button`,disabled:o.isPending,onClick:()=>o.mutate(!1),className:`flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1 text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,title:`Send the agent half what it has not applied`,children:[o.isPending?(0,A.jsx)(L,{size:11,className:`animate-spin`}):(0,A.jsx)(pa,{size:11}),`Sync now`]}),(0,A.jsxs)(`button`,{type:`button`,disabled:o.isPending,onClick:()=>o.mutate(!0),className:`flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1 text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,title:`Replay the whole audience and count what the agent half held out of step (also runs daily)`,children:[(0,A.jsx)(pa,{size:11}),`Reconcile`]})]})]})}function lf({ids:e}){return e.length===0?null:(0,A.jsxs)(`div`,{children:[(0,A.jsx)($d,{children:(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-amber-400`,children:[(0,A.jsx)(Mi,{size:11}),` Erasures its agent half has not acknowledged yet:`]})}),(0,A.jsx)(`ul`,{className:`flex flex-wrap gap-2`,children:e.map(e=>(0,A.jsx)(`li`,{children:(0,A.jsx)(iu,{id:e})},e))}),(0,A.jsx)(`p`,{className:`mt-1 text-zinc-600`,children:`Delivered within seconds while its hosting agent is online, on reconnect otherwise.`})]})}function uf({plugin:e}){let t=F(),[n,r]=(0,g.useState)(!1),i=M({queryKey:[`plugin-identity`,e.name],queryFn:()=>t.getPluginIdentity(e.name),refetchInterval:n?1e4:6e4}),a=i.data?.identity;if(i.isError)return(0,A.jsxs)(`div`,{className:`rounded border border-zinc-800 bg-zinc-950/60 p-3 mb-4 text-xs text-red-400`,children:[`People: `,B(i.error)]});if(!a?.declared)return null;let o=Kl(a.readiness),s=a.audience??{active:0,disabled:0},c=s.active+s.disabled,l=i.dataUpdatedAt;return(0,A.jsxs)(`div`,{className:`rounded border border-zinc-800 bg-zinc-950/60 p-3 mb-4 text-xs`,children:[(0,A.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),"aria-expanded":n,className:`flex w-full flex-wrap items-center gap-2 text-left`,children:[n?(0,A.jsx)(_i,{size:12}):(0,A.jsx)(yi,{size:12}),(0,A.jsx)(`span`,{className:`text-zinc-300 font-medium`,children:`People`}),o.ready?(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-green-400`,children:[(0,A.jsx)(gi,{size:11}),` ready`]}):(0,A.jsx)(`span`,{className:`text-yellow-400`,title:o.text,children:a.readiness.reason?.replace(/_/g,` `)??`not ready`}),(0,A.jsxs)(`span`,{className:`text-zinc-500`,children:[c,` member`,c===1?``:`s`,s.disabled>0?` (${s.disabled} disabled)`:``]}),a.sync?.behind>0&&(0,A.jsxs)(`span`,{className:`text-yellow-400`,children:[a.sync.behind,` to send`]}),a.sync?.lastError&&(0,A.jsx)(`span`,{className:`text-red-400`,title:a.sync.lastError,children:`sync held up`}),a.pendingErasures.length>0&&(0,A.jsxs)(`span`,{className:`text-amber-400`,children:[a.pendingErasures.length,` erasure`,a.pendingErasures.length===1?``:`s`,` `,`pending`]})]}),n&&(0,A.jsxs)(`div`,{className:`mt-3 space-y-4`,children:[(0,A.jsx)(ef,{view:a}),(0,A.jsx)(rf,{plugin:e,roles:a.declared.roles}),(0,A.jsx)(sf,{plugin:e}),a.sync&&(0,A.jsx)(cf,{plugin:e,sync:a.sync,now:l}),(0,A.jsx)(lf,{ids:a.pendingErasures})]})]})}var df=`w-full rounded bg-zinc-800 border px-2 py-1 text-xs text-zinc-300 placeholder-zinc-600 focus:outline-none focus:border-cyan-400 disabled:opacity-60`,ff=1e4,pf=Kr(typeof CSS>`u`?void 0:CSS);function mf(e){e.preventDefault()}var hf=`flex items-center gap-1.5 rounded bg-zinc-700 px-2 py-0.5 text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`;function gf(e){return`${df} ${e?`border-red-500/70`:`border-zinc-700`}`}function _f(e){let t=e.missing?.length??0;return t===0?`needs configuration`:`${t} required setting${t>1?`s`:``} not set`}function vf({summary:e}){if(!e||e.configured!==!1)return null;let t=e.missing??[];return(0,A.jsxs)(`span`,{className:`flex items-center gap-1 text-xs px-2 py-0.5 rounded-full bg-yellow-500/15 text-yellow-400`,title:t.length>0?`Required settings not set: ${t.join(`, `)}`:`Required settings are not set`,children:[(0,A.jsx)(Da,{size:11}),`Needs configuration`]})}function yf(e){if(e.default!==void 0){let t=(e.options??[]).find(t=>t.value===e.default);return`Default (${t?t.label:e.default})`}return Dr(e)?`Choose…`:`Not set`}function bf({id:e,field:t,missing:n,error:r,children:i}){return(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`div`,{className:`mb-1 flex flex-wrap items-baseline gap-x-2`,children:[(0,A.jsx)(`label`,{htmlFor:e,className:`text-zinc-300`,children:t.label}),(0,A.jsx)(`span`,{className:`font-mono text-zinc-600`,children:t.key}),t.required&&(0,A.jsx)(`span`,{className:n?`text-yellow-400`:`text-zinc-500`,children:n?`required — not set`:`required`})]}),t.description&&(0,A.jsx)(`p`,{className:`mb-1 text-zinc-500`,children:t.description}),i,r&&(0,A.jsx)(`p`,{className:`mt-1 text-red-400`,children:r})]})}function xf({pluginName:e,view:t,readOnly:n,saving:r,errors:i,onEdit:a,onInvalid:o,onSubmit:s,onDiscard:c}){let[l,u]=(0,g.useState)(()=>Ar(t)),[d,f]=(0,g.useState)({}),[p,m]=(0,g.useState)(()=>Mr(t)),[h,_]=(0,g.useState)({}),v=(0,g.useRef)(new Map),y=Ar(t),b=Br(t,{inputs:l,badInput:d,secretActions:p,secretFilled:h}),x=new Set(t.missing??[]),S=(e,t,n=!1)=>{u(n=>({...n,[e]:t})),f(t=>({...t,[e]:n})),a(e)},C=(e,t)=>{let n=v.current.get(e);n&&(n.value=``),_(t=>({...t,[e]:!1})),m(n=>({...n,[e]:t})),a(e)},w=e=>t=>{t?v.current.set(e,t):v.current.delete(e)},T=e=>{if(e.preventDefault(),n||r)return;let i={};for(let e of t.fields)e.type===`secret`&&(i[e.key]={action:p[e.key],value:v.current.get(e.key)?.value??``});let a=Vr(t,{inputs:l,badInput:d,secrets:i});if(!a.ok){o(a.errors);return}if(a.changed.length!==0){for(let e of v.current.values())e.value=``;_({}),s(a.body)}},E=(e,r)=>{let o=r.key,s=i[o]??null;switch(r.type){case`string`:return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`input`,{id:e,type:`text`,value:l[o],onChange:e=>S(o,e.target.value),placeholder:r.default===void 0?void 0:`Default: ${r.default}`,spellCheck:!1,"aria-invalid":s?!0:void 0,"aria-describedby":Gr(r)?`${e}-hint`:void 0,className:gf(s)}),Gr(r)&&(0,A.jsxs)(`p`,{id:`${e}-hint`,className:`mt-1 flex items-start gap-1 text-yellow-400/90`,children:[(0,A.jsx)(Ki,{size:11,className:`mt-0.5 shrink-0`}),`Stored on the relay and shown in clear — use a secret field for credentials.`]})]});case`integer`:case`number`:return(0,A.jsx)(`input`,{id:e,type:`number`,inputMode:r.type===`integer`?`numeric`:`decimal`,step:r.type===`integer`?1:`any`,min:r.min,max:r.max,value:l[o],onChange:e=>S(o,e.target.value,e.target.validity.badInput),placeholder:r.default===void 0?void 0:`Default: ${r.default}`,"aria-invalid":s?!0:void 0,className:`${gf(s)} sm:w-48`});case`boolean`:return(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-zinc-400`,children:[(0,A.jsx)(`input`,{id:e,type:`checkbox`,checked:l[o]===!0,onChange:e=>S(o,e.target.checked),className:`accent-cyan-500`}),l[o]===null?`not set`:l[o]?`on`:`off`]});case`enum`:return(0,A.jsxs)(`select`,{id:e,value:l[o],onChange:e=>S(o,e.target.value),"aria-invalid":s?!0:void 0,className:`${gf(s)} sm:w-auto`,children:[(Or(r)||y[o]===``||l[o]===``)&&(0,A.jsx)(`option`,{value:``,children:yf(r)}),(r.options??[]).map(e=>(0,A.jsx)(`option`,{value:e.value,children:e.label},e.value))]});case`secret`:{let i=jr(t,o),c=p[o];return(0,A.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1 ${i.set?`text-zinc-300`:`text-zinc-500`}`,children:[(0,A.jsx)(qi,{size:11}),Nr(i)]}),c===`clear`&&(0,A.jsx)(`span`,{className:`text-yellow-400`,children:`cleared when you save`}),!n&&i.set&&c===`keep`&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`button`,{type:`button`,onClick:()=>C(o,`replace`),className:hf,children:[(0,A.jsx)(pa,{size:11}),`Replace`]}),Or(r)&&(0,A.jsxs)(`button`,{type:`button`,onClick:()=>C(o,`clear`),className:hf,children:[(0,A.jsx)(Mi,{size:11}),`Clear`]})]}),!n&&i.set&&c!==`keep`&&(0,A.jsxs)(`button`,{type:`button`,onClick:()=>C(o,`keep`),className:hf,children:[(0,A.jsx)(Na,{size:11}),`Keep the current one`]})]}),!n&&c===`replace`&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`input`,{id:e,ref:w(o),type:`text`,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,spellCheck:!1,placeholder:i.set?`New value`:`Value`,onChange:e=>{let t=e.target.value!==``;_(e=>e[o]===t?e:{...e,[o]:t}),a(o)},onCopy:mf,onCut:mf,"aria-invalid":s?!0:void 0,"data-1p-ignore":!0,"data-lpignore":`true`,"data-bwignore":`true`,"data-form-type":`other`,className:`${gf(s)} [-webkit-text-security:disc]`}),!pf&&(0,A.jsx)(`p`,{className:`text-yellow-400/90`,children:`This browser cannot mask the value: it shows as you type it. Use a current browser to keep it out of sight.`})]})]})}default:return(0,A.jsxs)(`span`,{className:`text-zinc-500`,children:[`Cannot be set here (`,r.type,`)`]})}};return(0,A.jsx)(`form`,{onSubmit:T,autoComplete:`off`,noValidate:!0,children:(0,A.jsxs)(`fieldset`,{disabled:n||r,className:`space-y-3`,children:[t.fields.map(t=>{let n=`plugin-settings-${e}-${t.key}`;return(0,A.jsx)(bf,{id:n,field:t,missing:x.has(t.key),error:i[t.key]??null,children:E(n,t)},t.key)}),!n&&(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,A.jsxs)(`button`,{type:`submit`,disabled:b.length===0||r,className:`flex items-center gap-1.5 rounded bg-cyan-600 px-2.5 py-1 text-white hover:bg-cyan-500 disabled:opacity-50`,children:[r?(0,A.jsx)(L,{size:11,className:`animate-spin`}):(0,A.jsx)(_a,{size:11}),`Save`]}),b.length>0&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`button`,{type:`button`,onClick:c,className:hf,children:[(0,A.jsx)(Na,{size:11}),`Discard changes`]}),(0,A.jsxs)(`span`,{className:`text-zinc-500`,children:[b.length,` change`,b.length>1?`s`:``]})]})]})]})})}function Sf({pluginName:e}){let t=F(),n=j(),r=z(),i=[`plugin-settings`,e],a=M({queryKey:i,queryFn:()=>t.getPluginSettings(e),refetchOnWindowFocus:!1,refetchInterval:e=>e.state.data&&Er(e.state.data,e.state.dataUpdatedAt)!==null?ff:!1}),[o,s]=(0,g.useState)({}),[c,l]=(0,g.useState)(null),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)(0),m=(0,g.useRef)(null);(0,g.useEffect)(()=>()=>{m.current=null},[]);let h=()=>n.invalidateQueries({queryKey:i}),_=()=>p(e=>e+1),v=N({mutationFn:()=>{let n=m.current;return m.current=null,n===null?Promise.reject(Error(`Nothing to save`)):t.updatePluginSettings(e,n)},onSuccess:e=>{e&&Array.isArray(e.fields)?n.setQueryData(i,e):h(),_(),n.invalidateQueries({queryKey:[`plugins`]}),r(`Settings saved`)},onError:e=>{let{code:t}=Ao(e);if(t===`revision_mismatch`||t===`schema_mismatch`){d(t===`revision_mismatch`?`The settings were changed elsewhere since this form was loaded. It now shows the current values — make your changes again.`:`The agent half runs another version of these settings (an update may be under way). The form was reloaded — try again once the update has finished.`),_(),h();return}if(t===`hosting_offline`||t===`timeout`||t===`unauthenticated`){l(B(e)),h();return}let n=Hr(e);if(n){let e=new Set((a.data?.fields??[]).map(e=>e.key)),t=Object.fromEntries(Object.entries(n).filter(([t])=>e.has(t))),r=Object.entries(n).filter(([t])=>!e.has(t));s(t),l(r.length>0?r.map(([e,t])=>e===`_`?t:`${e}: ${t}`).join(`; `):`Not saved — see the fields above.`);return}l(B(e))}}),y=e=>{s(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n})};if(a.isPending)return(0,A.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5 text-zinc-500`,children:[(0,A.jsx)(L,{size:12,className:`animate-spin`}),` Loading settings…`]});if(a.isError)return(0,A.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2 text-red-400`,children:[(0,A.jsx)(xi,{size:12}),B(a.error),(0,A.jsxs)(`button`,{type:`button`,onClick:()=>a.refetch(),className:hf,children:[(0,A.jsx)(pa,{size:11}),`Retry`]})]});let b=a.data,x=a.dataUpdatedAt,S=Er(b,x),C=Cr(b.hosting)!==null;return(0,A.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,A.jsx)(`p`,{className:`text-zinc-600`,children:Ur(b,x)}),S&&(0,A.jsxs)(`div`,{className:`flex items-start gap-1.5 rounded border p-2 ${C?`border-red-500/30 text-red-400`:`border-zinc-700 text-zinc-400`}`,children:[C?(0,A.jsx)(Ua,{size:12,className:`mt-0.5 shrink-0`}):(0,A.jsx)(Ki,{size:12,className:`mt-0.5 shrink-0`}),(0,A.jsxs)(`span`,{children:[S,`.`,` `,(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`Read-only for now: changes go to its agent half, which has to be reachable.`})]})]}),u&&(0,A.jsxs)(`p`,{className:`flex items-start gap-1.5 text-yellow-400`,children:[(0,A.jsx)(ha,{size:12,className:`mt-0.5 shrink-0`}),u]}),(0,A.jsx)(xf,{pluginName:e,view:b,readOnly:S!==null,saving:v.isPending,errors:o,onEdit:y,onInvalid:e=>{s(e),l(`Not saved — see the fields above.`)},onSubmit:e=>{s({}),l(null),d(null),m.current=e,v.mutate()},onDiscard:()=>{s({}),l(null),_()}},`${b.revision}:${zr(b.fields)}:${f}`),c&&(0,A.jsxs)(`p`,{className:`flex items-start gap-1.5 text-red-400`,children:[(0,A.jsx)(xi,{size:12,className:`mt-0.5 shrink-0`}),c]})]})}function Cf({plugin:e}){let[t,n]=(0,g.useState)(!1),r=e.settings;return(0,A.jsxs)(`div`,{className:`rounded border border-zinc-800 bg-zinc-950/60 p-3 mb-4 text-xs`,children:[(0,A.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),"aria-expanded":t,className:`flex w-full flex-wrap items-center gap-2 text-left`,children:[t?(0,A.jsx)(_i,{size:12}):(0,A.jsx)(yi,{size:12}),(0,A.jsx)(`span`,{className:`text-zinc-300 font-medium`,children:`Settings`}),r.configured?(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-green-400`,children:[(0,A.jsx)(gi,{size:11}),` configured`]}):(0,A.jsx)(`span`,{className:`text-yellow-400`,children:_f(r)})]}),t&&(0,A.jsx)(Sf,{pluginName:e.name})]})}function wf(e,t){e.invalidateQueries({queryKey:[`plugin-web-surface`,t]}),e.invalidateQueries({queryKey:[`sites`]}),e.invalidateQueries({queryKey:[`tunnels`]}),e.invalidateQueries({queryKey:[`plugin-hooks`,t]}),e.invalidateQueries({queryKey:[`plugins`]}),e.invalidateQueries({queryKey:[`gatekeeper-grants`]})}function Tf({children:e}){return(0,A.jsx)(`p`,{className:`mb-1.5 text-zinc-500`,children:e})}function Ef({error:e}){if(!e)return null;let{message:t,hint:n}=wc(e);return(0,A.jsxs)(`div`,{className:`mt-2 flex items-start gap-1.5 text-red-400`,children:[(0,A.jsx)(ja,{size:12,className:`mt-0.5 shrink-0`}),(0,A.jsxs)(`span`,{children:[t,n&&(0,A.jsx)(`span`,{className:`block text-zinc-400`,children:n})]})]})}function Df({view:e}){let t=xc(e);return(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1`,children:[(0,A.jsx)(`dt`,{className:`text-zinc-500`,children:`declared`}),(0,A.jsx)(`dd`,{className:`text-zinc-300`,children:e.declared?(0,A.jsxs)(A.Fragment,{children:[`subdomain `,(0,A.jsx)(`span`,{className:`font-mono`,children:e.declared.defaultSubdomain}),`,`,` `,e.declared.accessMode,`, shell from`,` `,(0,A.jsx)(`span`,{className:`font-mono`,children:e.declared.root})]}):(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`nothing — the installed version declares no web surface`})}),(0,A.jsx)(`dt`,{className:`text-zinc-500`,children:`site`}),(0,A.jsx)(`dd`,{className:`text-zinc-300`,children:e.site?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`a`,{href:`https://${e.site.fqdn}`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-cyan-400 hover:text-cyan-300`,children:[e.site.fqdn,(0,A.jsx)(Ni,{size:11})]}),(0,A.jsxs)(`span`,{className:`text-zinc-500`,children:[` `,`· `,gc(e.site.accessMode??`authenticated`)]})]}):(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`none`})}),e.boundTunnel&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`dt`,{className:`text-zinc-500`,children:`bound tunnel`}),(0,A.jsxs)(`dd`,{className:`text-zinc-300`,children:[(0,A.jsx)(`span`,{className:`font-mono`,children:e.boundTunnel.fqdn??e.boundTunnel.id}),(0,A.jsx)(`span`,{className:`text-zinc-500`,children:` — serves its user surface today`})]})]})]}),(0,A.jsxs)(`p`,{className:`flex items-start gap-1.5 ${t.served?`text-green-400`:`text-yellow-400`}`,children:[t.served?(0,A.jsx)(gi,{size:12,className:`mt-0.5 shrink-0`}):(0,A.jsx)(ja,{size:12,className:`mt-0.5 shrink-0`}),t.text]})]})}function Of({tree:e}){let t=e.approved!==null&&e.current===e.approved;return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(Tf,{children:`Web trees on the relay:`}),(0,A.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1`,children:[(0,A.jsx)(`dt`,{className:`text-zinc-500`,children:`approved`}),(0,A.jsx)(`dd`,{children:(0,A.jsx)(iu,{id:e.approved,missing:`The installed version declares no web tree`})}),(0,A.jsx)(`dt`,{className:`text-zinc-500`,children:`served`}),(0,A.jsxs)(`dd`,{className:`flex flex-wrap items-center gap-2`,children:[(0,A.jsx)(iu,{id:e.current,missing:`No tree is served yet`}),e.current&&!t&&e.approved&&(0,A.jsx)(`span`,{className:`text-yellow-400`,children:`not the approved one yet`})]}),(0,A.jsx)(`dt`,{className:`text-zinc-500`,children:`previous`}),(0,A.jsx)(`dd`,{children:(0,A.jsx)(iu,{id:e.previous,missing:`None — kept as the fallback once a second tree is served`})})]})]})}function kf({plugin:e,view:t}){let n=F(),r=j(),i=z(),a=t.offer,[o,s]=(0,g.useState)(a?.subdomain??``),[c,l]=(0,g.useState)(a?.accessMode??`authenticated`),u=Tc(t,{edited:a?o!==a.subdomain:!0}),d=_c(o),f=N({mutationFn:()=>n.createPluginWebSurface(e.name,{...a&&o===a.subdomain?{}:{subdomain:o},...a&&c===a.accessMode?{}:{accessMode:c}}),onSuccess:t=>{wf(r,e.name),i(`${e.name}: web surface created on ${t.webSurface?.site?.fqdn??o}`)},onError:()=>wf(r,e.name)});return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(Tf,{children:`Create its web surface:`}),(0,A.jsx)(`p`,{className:`mb-2 text-zinc-400`,children:`Lamaste issues a certificate for the hostname and creates a site the plugin owns: it serves the approved shell from the plugin’s server package and its user-surface API on one host, behind one sign-in. The site answers 503 until the surface is served.`}),(0,A.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,A.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`subdomain`}),(0,A.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value.trim().toLowerCase()),disabled:f.isPending,spellCheck:!1,className:`w-48 rounded border border-zinc-700 bg-zinc-900 px-2 py-1 font-mono text-zinc-200 focus:border-cyan-400 focus:outline-none`})]}),(0,A.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`access`}),(0,A.jsx)(`select`,{value:c,onChange:e=>l(e.target.value),disabled:f.isPending,className:`rounded border border-zinc-700 bg-zinc-900 px-2 py-1 text-zinc-200 focus:border-cyan-400 focus:outline-none`,children:mc.map(e=>(0,A.jsx)(`option`,{value:e,children:e},e))})]}),(0,A.jsxs)(`button`,{type:`button`,disabled:f.isPending||u!==null||d!==null,onClick:()=>f.mutate(),title:u??d??void 0,className:`flex items-center gap-1.5 rounded bg-cyan-600 px-2.5 py-1 text-white hover:bg-cyan-500 disabled:opacity-50`,children:[f.isPending?(0,A.jsx)(L,{size:11,className:`animate-spin`}):(0,A.jsx)(ua,{size:11}),`Create web surface`]})]}),(0,A.jsx)(`p`,{className:`mt-1 text-zinc-500`,children:gc(c)}),(u||d&&o!==``)&&(0,A.jsx)(`p`,{className:`mt-1 text-yellow-400`,children:u??d}),(0,A.jsx)(Ef,{error:f.error})]})}function Af({plugin:e,view:t}){let n=F(),r=j(),i=z(),[a,o]=(0,g.useState)(!1),s=t.boundTunnel,c=Ec(t,e.route),l=s.fqdn??s.id,u=N({mutationFn:()=>n.movePluginWebSurface(e.name,s.id),onSuccess:()=>{o(!1),wf(r,e.name),i(`${e.name}: ${l} now serves its web surface`)},onError:()=>{o(!1),wf(r,e.name)}});return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(Tf,{children:`Move from its tunnel:`}),(0,A.jsxs)(`p`,{className:`mb-2 text-zinc-400`,children:[`Tunnel `,(0,A.jsx)(`span`,{className:`font-mono text-zinc-300`,children:l}),` serves its user surface today. Moving hands that hostname to a site the plugin owns in one nginx reload: the shell is then served from the approved tree on the relay, the API as before. The tunnel stays, disabled and unbound, for a rollback by hand; a restricted tunnel’s grants are copied to the site.`]}),a?(0,A.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,A.jsxs)(`span`,{className:`text-zinc-300`,children:[`Move `,l,` to the web surface?`]}),(0,A.jsxs)(`button`,{type:`button`,disabled:u.isPending,onClick:()=>u.mutate(),className:`flex items-center gap-1.5 rounded bg-cyan-600 px-2.5 py-1 text-white hover:bg-cyan-500 disabled:opacity-50`,children:[u.isPending&&(0,A.jsx)(L,{size:11,className:`animate-spin`}),`Move`]}),(0,A.jsx)(`button`,{type:`button`,disabled:u.isPending,onClick:()=>o(!1),className:`rounded bg-zinc-700 px-2.5 py-1 text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Cancel`})]}):(0,A.jsxs)(`button`,{type:`button`,disabled:c!==null,onClick:()=>o(!0),title:c??void 0,className:`flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1 text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:[(0,A.jsx)(ui,{size:11}),` Move from tunnel `,l]}),c&&(0,A.jsx)(`p`,{className:`mt-1 text-yellow-400`,children:c}),(0,A.jsx)(Ef,{error:u.error})]})}function jf({plugin:e,view:t}){let n=F(),r=j(),i=z(),[a,o]=(0,g.useState)(!1),[s,c]=(0,g.useState)(``),l=t.site.fqdn,u=()=>{o(!1),c(``)},d=N({mutationFn:()=>n.deletePluginWebSurface(e.name),onSuccess:()=>{u(),wf(r,e.name),i(`${e.name}: web surface on ${l} deleted`)},onError:()=>wf(r,e.name)});return(0,A.jsx)(`div`,{children:a?(0,A.jsxs)(`div`,{className:`space-y-2 rounded border border-red-500/30 p-2`,children:[(0,A.jsxs)(`p`,{className:`text-zinc-300`,children:[`Deleting removes the site `,(0,A.jsx)(`span`,{className:`font-mono`,children:l}),`, the web trees the relay keeps for it and every grant on the site. The plugin stays installed and hosted; its users reach it again only once it is given a site or a tunnel.`]}),(0,A.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,A.jsxs)(`span`,{className:`text-zinc-500`,children:[`Type `,(0,A.jsx)(`span`,{className:`font-mono text-zinc-300`,children:l}),` to confirm`]}),(0,A.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),disabled:d.isPending,spellCheck:!1,autoComplete:`off`,className:`w-72 max-w-full rounded border border-zinc-700 bg-zinc-900 px-2 py-1 font-mono text-zinc-200 focus:border-red-400 focus:outline-none`})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,A.jsxs)(`button`,{type:`button`,disabled:d.isPending||s!==l,onClick:()=>d.mutate(),className:`flex items-center gap-1.5 rounded bg-red-600 px-2.5 py-1 text-white hover:bg-red-500 disabled:opacity-50`,children:[d.isPending?(0,A.jsx)(L,{size:11,className:`animate-spin`}):(0,A.jsx)(R,{size:11}),`Delete web surface`]}),(0,A.jsx)(`button`,{type:`button`,disabled:d.isPending,onClick:u,className:`rounded bg-zinc-700 px-2.5 py-1 text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Cancel`})]}),(0,A.jsx)(Ef,{error:d.error})]}):(0,A.jsxs)(`button`,{type:`button`,onClick:()=>o(!0),className:`flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1 text-red-400 hover:bg-red-600/20 hover:text-red-300`,children:[(0,A.jsx)(R,{size:11}),` Delete web surface`]})})}function Mf({plugin:e}){let t=F(),[n,r]=(0,g.useState)(!1),i=typeof t.getPluginWebSurface==`function`,a=M({queryKey:[`plugin-web-surface`,e.name],queryFn:()=>t.getPluginWebSurface(e.name),enabled:i,refetchInterval:n?1e4:6e4});if(!i)return null;if(a.isError)return(0,A.jsxs)(`div`,{className:`rounded border border-zinc-800 bg-zinc-950/60 p-3 mb-4 text-xs text-red-400`,children:[`Web surface: `,B(a.error)]});let o=a.data?.webSurface;if(!o||!o.declared&&!o.site)return null;let s=xc(o);return(0,A.jsxs)(`div`,{className:`rounded border border-zinc-800 bg-zinc-950/60 p-3 mb-4 text-xs`,children:[(0,A.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),"aria-expanded":n,className:`flex w-full flex-wrap items-center gap-2 text-left`,children:[n?(0,A.jsx)(_i,{size:12}):(0,A.jsx)(yi,{size:12}),(0,A.jsx)(Hi,{size:12,className:`text-cyan-400`}),(0,A.jsx)(`span`,{className:`text-zinc-300 font-medium`,children:`Web surface`}),o.site?(0,A.jsx)(`span`,{className:`font-mono text-zinc-400`,children:o.site.fqdn}):(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`no site`}),o.site&&(s.served?(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-green-400`,children:[(0,A.jsx)(gi,{size:11}),` served`]}):(0,A.jsx)(`span`,{className:`text-yellow-400`,title:s.text,children:o.reason?.replace(/_/g,` `)??`not served`})),!o.site&&o.boundTunnel&&(0,A.jsxs)(`span`,{className:`text-zinc-500`,children:[`served by tunnel `,o.boundTunnel.fqdn]})]}),n&&(0,A.jsxs)(`div`,{className:`mt-3 space-y-4`,children:[(0,A.jsx)(Df,{view:o}),(0,A.jsx)(Of,{tree:o.tree}),!o.site&&o.boundTunnel&&(0,A.jsx)(Af,{plugin:e,view:o}),!o.site&&o.declared&&(0,A.jsx)(kf,{plugin:e,view:o},`${o.offer?.subdomain??``}:${o.offer?.accessMode??``}`),o.site&&(0,A.jsx)(jf,{plugin:e,view:o})]})]})}function Nf({plugin:e}){let t=F(),n=j(),r=z(),{domains:i}=Gc(),a=e.domain,[o,s]=(0,g.useState)(``),c=N({mutationFn:n=>t.setPluginDomain(e.name,n),onSuccess:t=>{s(``),r(`${e.name} now belongs to ${t.domain}`),n.invalidateQueries({queryKey:[`plugins`]}),n.invalidateQueries({queryKey:[`domains`]})},onError:e=>r(Lc(e),`error`)});return Pc(i)?(0,A.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2 text-xs text-zinc-400`,children:[(0,A.jsx)(ji,{size:14,className:`text-cyan-400`}),(0,A.jsxs)(`span`,{children:[`Domain `,(0,A.jsx)(`span`,{className:`font-mono text-zinc-200`,children:a})]}),(0,A.jsxs)(`select`,{value:o,onChange:e=>s(e.target.value),disabled:c.isPending,className:`rounded border border-zinc-700 bg-zinc-900 px-2 py-1 text-xs text-white focus:border-cyan-500 focus:outline-none`,children:[(0,A.jsx)(`option`,{value:``,children:`Move to…`}),Nc(i).filter(e=>e!==a).map(e=>(0,A.jsx)(`option`,{value:e,children:e},e))]}),(0,A.jsx)(`button`,{type:`button`,disabled:!o||c.isPending,onClick:()=>c.mutate(o),className:`rounded border border-zinc-700 px-2 py-1 text-zinc-300 hover:border-cyan-600 hover:text-white disabled:opacity-50`,children:`Move`})]}):null}var Pf=`oidc-client`,Ff=`rounded border border-zinc-700 bg-zinc-900 px-2 py-1 text-xs text-white focus:border-cyan-500 focus:outline-none`;function If({clientId:e,candidates:t,groups:n,onGrant:r,busy:i}){let[a,o]=(0,g.useState)(``),[s,c]=a.split(`:`,2);return(0,A.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2`,children:[(0,A.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value),disabled:i,"aria-label":`Grant ${e} to`,className:Ff,children:[(0,A.jsx)(`option`,{value:``,children:`Grant to…`}),t.length>0&&(0,A.jsx)(`optgroup`,{label:`External members`,children:t.map(e=>(0,A.jsx)(`option`,{value:`user:${e.username}`,children:e.username},e.username))}),n.length>0&&(0,A.jsx)(`optgroup`,{label:`Lamaste groups`,children:n.map(e=>(0,A.jsx)(`option`,{value:`group:${e.name}`,children:e.name},e.name))})]}),(0,A.jsxs)(`button`,{type:`button`,disabled:!a||i,onClick:()=>{r({principalType:s,principalId:c}),o(``)},className:`inline-flex items-center gap-1 rounded border border-zinc-700 px-2 py-1 text-zinc-300 hover:border-cyan-600 hover:text-white disabled:opacity-50`,children:[(0,A.jsx)(ua,{size:12}),` Grant`]})]})}function Lf({plugin:e}){let t=F(),n=j(),r=z(),i=M({queryKey:[`plugin-oidc-clients`,e.name],queryFn:()=>t.getPluginOidcClients(e.name),staleTime:3e4}),a=(i.data?.clients??[]).filter(e=>e.userFacing),o=M({queryKey:[`users`],queryFn:()=>t.getUsers(),enabled:a.length>0}),s=M({queryKey:[`gatekeeper-groups`],queryFn:()=>t.getGatekeeperGroups(),enabled:a.length>0}),c=()=>n.invalidateQueries({queryKey:[`plugin-oidc-clients`,e.name]}),l=e=>r(B(e),`error`),u=N({mutationFn:({clientId:e,principalType:n,principalId:r})=>t.createGatekeeperGrant({principalType:n,principalId:r,resourceType:Pf,resourceId:e}),onSuccess:c,onError:l}),d=N({mutationFn:e=>t.revokeGatekeeperGrant(e),onSuccess:c,onError:l});if(a.length===0)return null;let f=Wc(o.data?.users,e.domain),p=(o.data?.users??[]).filter(e=>f.has(e.userId)).sort((e,t)=>e.username.localeCompare(t.username)),m=s.data?.groups??[],h=u.isPending||d.isPending;return(0,A.jsxs)(`div`,{className:`mt-3 rounded-lg border border-zinc-800 p-3 text-xs text-zinc-400`,children:[(0,A.jsxs)(`p`,{className:`mb-2 flex items-center gap-2 text-zinc-300`,children:[(0,A.jsx)(qi,{size:14,className:`text-cyan-400`}),` OIDC sign-in — members of`,` `,(0,A.jsx)(`span`,{className:`font-mono`,children:e.domain}),` sign in; external members only when granted`]}),(0,A.jsx)(`div`,{className:`space-y-3`,children:a.map(e=>(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`p`,{className:`font-mono text-zinc-200`,children:[e.id,e.name?(0,A.jsx)(`span`,{className:`ml-2 font-sans text-zinc-500`,children:e.name}):null]}),e.grants===null?(0,A.jsx)(`p`,{className:`text-amber-300`,children:`Gatekeeper could not be read: grants unknown.`}):(e.grants??[]).length===0?(0,A.jsx)(`p`,{className:`text-zinc-600`,children:`No grants: no external member signs in.`}):(0,A.jsx)(`ul`,{className:`mt-1 flex flex-wrap gap-1`,children:e.grants.map(e=>(0,A.jsxs)(`li`,{className:`inline-flex items-center gap-1 rounded border border-zinc-700 px-2 py-0.5 font-mono text-zinc-300`,children:[e.principalType===`group`?`group:${e.principalId}`:e.principalId,(0,A.jsx)(`button`,{type:`button`,disabled:h,onClick:()=>d.mutate(e.grantId),title:`Revoke`,"aria-label":`Revoke ${e.principalId}`,className:`text-zinc-500 hover:text-red-400 disabled:opacity-50`,children:(0,A.jsx)(Ga,{size:12})})]},e.grantId))}),(0,A.jsx)(If,{clientId:e.id,candidates:p,groups:m,busy:h,onGrant:t=>u.mutate({clientId:e.id,...t})})]},e.id))}),i.isFetching&&(0,A.jsx)(L,{size:12,className:`mt-2 animate-spin`})]})}function Rf({record:e,isActing:t}){let n=F(),r=j(),i=z(),[a,o]=(0,g.useState)(null),s=()=>{r.invalidateQueries({queryKey:[`plugins`]}),r.invalidateQueries({queryKey:[`plugin-operations`,e.plugin]})},c=N({mutationFn:()=>n.purgePluginRetainedData(e.plugin,e.agentLabel),onSuccess:()=>{s(),i(`Purging what ${e.agentLabel} keeps of "${e.plugin}" — follow the steps under its name`)},onError:t=>i(ad(t,{agentLabel:e.agentLabel,action:`uninstall`}),`error`)}),l=N({mutationFn:()=>n.forgetPluginRetainedData(e.plugin,e.agentLabel),onSuccess:()=>{s(),i(`Forgot the record — ${e.dataDir} stays on ${e.agentLabel} until it is removed there`)},onError:e=>i(B(e),`error`)}),u=t||c.isPending||l.isPending,d=(e,t,n)=>(0,A.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,A.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>{o(null),t()},className:`rounded px-2 py-1 text-white disabled:opacity-50 ${n?`bg-red-600 hover:bg-red-500`:`bg-zinc-600 hover:bg-zinc-500`}`,children:e}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>o(null),className:`rounded bg-zinc-700 px-2 py-1 text-zinc-300 hover:bg-zinc-600`,children:`Cancel`})]});return(0,A.jsxs)(`li`,{className:`rounded bg-zinc-900 px-2 py-1.5`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,A.jsx)(`span`,{className:`font-mono text-zinc-200`,children:e.agentLabel}),(0,A.jsxs)(`span`,{className:`text-zinc-500`,children:[`route `,(0,A.jsx)(`span`,{className:`font-mono text-zinc-300`,children:e.route})]}),(0,A.jsx)(`span`,{className:`font-mono text-zinc-400`,children:e.package}),(0,A.jsxs)(`span`,{className:`text-zinc-600`,children:[`since `,new Date(e.since).toLocaleString()]})]}),(0,A.jsxs)(`div`,{className:`font-mono text-zinc-500`,children:[e.dataDir,` `,(0,A.jsx)(`span`,{className:`text-zinc-600`,children:`· account`}),` `,e.serviceUser]}),a===`purge`&&(0,A.jsxs)(`div`,{className:`mt-1.5 space-y-1.5`,children:[(0,A.jsxs)(`p`,{className:`flex items-start gap-1 text-red-400`,children:[(0,A.jsx)(ja,{size:11,className:`mt-0.5 shrink-0`}),(0,A.jsxs)(`span`,{children:[`Delete `,(0,A.jsx)(`span`,{className:`font-mono`,children:e.dataDir}),` and the account`,` `,(0,A.jsx)(`span`,{className:`font-mono`,children:e.serviceUser}),` on agent`,` `,(0,A.jsx)(`span`,{className:`font-mono`,children:e.agentLabel}),` (route`,` `,(0,A.jsx)(`span`,{className:`font-mono`,children:e.route}),`)? The agent's app host helper deletes them once push install lets Lamaste remove`,` `,(0,A.jsx)(`span`,{className:`font-mono`,children:e.package}),` there — this cannot be undone.`]})]}),d(`Purge`,()=>c.mutate(),!0)]}),a===`forget`&&(0,A.jsxs)(`div`,{className:`mt-1.5 space-y-1.5`,children:[(0,A.jsxs)(`p`,{className:`text-zinc-400`,children:[`Drop only the relay's record? Nothing on`,` `,(0,A.jsx)(`span`,{className:`font-mono`,children:e.agentLabel}),` changes:`,` `,(0,A.jsx)(`span`,{className:`font-mono`,children:e.dataDir}),` and the account`,` `,(0,A.jsx)(`span`,{className:`font-mono`,children:e.serviceUser}),` stay on the machine — remove them there with`,` `,(0,A.jsxs)(`span`,{className:`font-mono`,children:[`sudo lamaste-agent apphost remove `,e.route,` --purge`]}),`. For an agent that is gone, or data already removed by hand.`]}),d(`Forget`,()=>l.mutate(),!1)]}),a===null&&(0,A.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-2`,children:[(0,A.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>o(`purge`),title:`Delete the data directory and the account on the agent (a push: uninstall)`,className:`flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1 text-zinc-300 hover:bg-red-600/20 hover:text-red-400 disabled:opacity-50`,children:[(0,A.jsx)(R,{size:11}),`Purge…`]}),(0,A.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>o(`forget`),title:`Drop the relay's record only; the data stays on the agent`,className:`flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1 text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:[(0,A.jsx)(Mi,{size:11}),`Forget…`]})]})]})}function zf({records:e,isActing:t}){return(0,A.jsx)(`ul`,{className:`space-y-1.5`,children:e.map(e=>(0,A.jsx)(Rf,{record:e,isActing:t},`${e.agentLabel}/${e.route}`))})}function Bf({plugin:e,isActing:t}){let n=e.retainedData??[];return n.length===0?null:(0,A.jsxs)(`div`,{className:`rounded border border-zinc-800 bg-zinc-950/60 p-3 mb-4 text-xs`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,A.jsx)(si,{size:12,className:`text-cyan-400`}),(0,A.jsx)(`span`,{className:`text-zinc-300 font-medium`,children:`Retained data`})]}),(0,A.jsx)(`p`,{className:`mb-2 text-zinc-500`,children:`Its agent half was removed without purge: these agents keep its data and account. Hosting the same agent package there again takes the data back; another package is refused until it is purged.`}),(0,A.jsx)(zf,{records:n,isActing:t})]})}function Vf({records:e,installedNames:t,isActing:n}){let r=new Map;for(let n of e)t.has(n.plugin)||r.set(n.plugin,[...r.get(n.plugin)??[],n]);return r.size===0?null:(0,A.jsxs)(`section`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-5 mt-8 text-xs`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,A.jsx)(si,{size:14,className:`text-cyan-400`}),(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-300`,children:`Retained data of uninstalled plugins`})]}),(0,A.jsx)(`p`,{className:`mb-4 text-zinc-500`,children:`These plugins are uninstalled, but agents keep the data and account of their agent halves. Purge it, or forget the record once it is gone from the agent.`}),(0,A.jsx)(`div`,{className:`space-y-4`,children:[...r.entries()].map(([e,t])=>(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`mb-2 font-mono text-sm text-zinc-200`,children:e}),(0,A.jsx)(ud,{plugin:e}),(0,A.jsx)(zf,{records:t,isActing:n})]},e))})]})}function Hf({status:e}){return(0,A.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full ${e===`enabled`?`bg-green-500/20 text-green-400`:`bg-zinc-500/20 text-zinc-400`}`,children:e===`enabled`?`Enabled`:`Disabled`})}function Uf(){return(0,A.jsxs)(`span`,{className:`flex items-center gap-1 text-xs px-2 py-0.5 rounded-full bg-cyan-500/10 text-cyan-400`,title:`The application runs on its own agent. Lamaste never loads its code.`,children:[(0,A.jsx)(oa,{size:11}),`Agent-hosted`]})}function Wf({health:e}){let t=e?.state??`unknown`,n=t===`up`?`bg-green-500/20 text-green-400`:t===`down`?`bg-red-500/20 text-red-400`:`bg-zinc-500/20 text-zinc-400`,r=t===`up`?`reachable`:t===`down`?`down (${e.reason??`?`})`:`unknown`,i=[e?.since?`since ${new Date(e.since).toLocaleString()}`:null,e?.checkedAt?`checked ${new Date(e.checkedAt).toLocaleTimeString()}`:null,t!==`up`&&e?.lastError?e.lastError:null].filter(Boolean).join(` · `);return(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full ${n}`,title:i,children:[(0,A.jsx)(oi,{size:11}),r]})}function Gf({hosting:e,dataDir:t,checked:n,onChange:r}){return(0,A.jsxs)(`span`,{className:`flex basis-full flex-col gap-1`,children:[(0,A.jsxs)(`label`,{className:`flex items-center gap-1 text-zinc-500`,title:`Kept by default: hosting the plugin on this agent again finds its data`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>r(e.target.checked)}),`also delete the agent half's data (purge)`]}),n&&(0,A.jsxs)(`span`,{className:`flex items-start gap-1 text-red-400`,children:[(0,A.jsx)(ja,{size:11,className:`mt-0.5 shrink-0`}),(0,A.jsxs)(`span`,{children:[`Deletes `,t?(0,A.jsx)(`span`,{className:`font-mono`,children:t}):`its data directory`,` `,`and the agent half's service account on`,` `,(0,A.jsx)(`span`,{className:`font-mono`,children:e.agentLabel}),` — this cannot be undone.`]})]})]})}function Kf({plugin:e,dataDir:t,now:n,onHost:r,onUnhost:i,onRotate:a,isActing:o}){let[s,c]=(0,g.useState)(!1),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(!1),[p,m]=(0,g.useState)(!1),h=e.agentHosting,_=e.hooks?.agentHalf===!0,v=e.hooks?.approval===`pending`,y=h&&(!h.phase||h.phase===`active`)?Sr(h):null;return h?(0,A.jsxs)(`div`,{className:`rounded border border-zinc-800 bg-zinc-950/60 p-3 mb-4 text-xs`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 mb-2`,children:[(0,A.jsx)(xa,{size:12,className:`text-cyan-400`}),(0,A.jsxs)(`span`,{className:`text-zinc-300`,children:[`Hosted on `,(0,A.jsx)(`span`,{className:`font-mono text-zinc-200`,children:h.agentLabel})]}),(0,A.jsxs)(`span`,{className:`text-zinc-500`,children:[`port `,(0,A.jsx)(`span`,{className:`font-mono`,children:h.port})]}),h.phase&&h.phase!==`active`?(0,A.jsxs)(`span`,{className:`text-cyan-400`,children:[h.phase,`…`]}):(0,A.jsx)(Wf,{health:h.health}),!h.secretAcknowledged&&(0,A.jsx)(`span`,{className:`text-zinc-500`,title:`The agent fetches it on its next sync`,children:`secret not yet fetched`}),h.rotationPending&&(0,A.jsx)(`span`,{className:`text-yellow-400`,children:`rotation pending`})]}),y&&(0,A.jsx)(`p`,{className:`mb-2 text-red-400`,children:wr(y,n)}),h.agentHalf&&(0,A.jsxs)(`p`,{className:`mb-2 text-zinc-500`,children:[`Agent half `,(0,A.jsx)(`span`,{className:`font-mono text-zinc-300`,children:h.agentHalf.version}),` `,`installed by Lamaste `,new Date(h.agentHalf.installedAt).toLocaleString()]}),(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,A.jsxs)(`button`,{type:`button`,disabled:o,onClick:()=>a(e.name),className:`flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1 text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,title:`Issue a new installation secret; the previous one stays accepted until the agent acknowledges the new one`,children:[(0,A.jsx)(pa,{size:11}),`Rotate secret`]}),l?(0,A.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,A.jsx)(`span`,{className:`text-zinc-400`,children:_?`Run its uninstall hooks, then remove the agent half, tunnel, secret and capability?`:`Run its uninstall hooks, then remove tunnel, secret and capability?`}),(0,A.jsxs)(`label`,{className:`flex items-center gap-1 text-zinc-500`,title:`Go on when a pre-teardown hook fails or the agent does not answer (reported, audited)`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked)}),`force`]}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>{u(!1),i(e.name,{force:d,purge:_&&p},h),f(!1),m(!1)},className:`rounded bg-red-600 px-2 py-1 text-white hover:bg-red-500`,children:`Yes`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>{u(!1),f(!1),m(!1)},className:`rounded bg-zinc-700 px-2 py-1 text-zinc-300 hover:bg-zinc-600`,children:`No`}),_&&(0,A.jsx)(Gf,{hosting:h,dataDir:t,checked:p,onChange:m})]}):(0,A.jsxs)(`button`,{type:`button`,disabled:o,onClick:()=>u(!0),className:`flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1 text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:[(0,A.jsx)(Ga,{size:11}),`Clear hosting`]})]})]}):(0,A.jsxs)(`div`,{className:`rounded border border-zinc-800 bg-zinc-950/60 p-3 mb-4 text-xs`,children:[(0,A.jsx)(`p`,{className:`text-zinc-400 mb-2`,children:_?`Not hosted yet. Pick the agent it runs on: Lamaste installs the agent half there and runs the install hooks around creating the internal tunnel, assigning the port and issuing the installation secret.`:`Not hosted yet. Pick the agent that runs its agent half: Lamaste runs the plugin’s install hooks around creating the internal tunnel, assigning the port and issuing the installation secret.`}),(0,A.jsxs)(`button`,{type:`button`,disabled:o,onClick:()=>c(!0),title:v?`What it brings waits for approval (Lifecycle hooks)`:void 0,className:`flex items-center gap-1.5 rounded bg-cyan-600 px-3 py-1 text-white hover:bg-cyan-500 disabled:opacity-50`,children:[(0,A.jsx)(xa,{size:11}),`Host on an agent…`]}),s&&(0,A.jsx)(Xd,{plugin:e,onHost:r,onClose:()=>c(!1),isActing:o})]})}function qf({plugin:e,now:t,ownedRoutes:n,onEnable:r,onDisable:i,onUninstall:a,onHost:o,onUnhost:s,onRotate:c,isActing:l}){let u=F(),d=e.hosting===`agent`,f=d&&e.agent!=null,p=e.agentHosting!=null&&e.hooks?.agentHalf===!0,m=M({queryKey:[`plugin-hooks`,e.name],queryFn:()=>u.getPluginHooks(e.name),enabled:e.hooks?.agentHalf===!0}).data?.hooks?.agentHalf?.dataDir??null,[h,_]=(0,g.useState)(!1),[v,y]=(0,g.useState)(!1),b=()=>{if(!h){_(!0);return}_(!1),a(e.name,{purge:p&&v},e.agentHosting),y(!1)};return(0,A.jsxs)(`div`,{id:jc(e.name),className:`rounded-lg bg-zinc-900 border border-zinc-800 p-5 scroll-mt-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(sa,{size:16,className:`text-cyan-400`}),(0,A.jsx)(`span`,{className:`text-white font-semibold`,children:e.displayName||e.name}),(0,A.jsxs)(`span`,{className:`text-zinc-500 text-xs`,children:[`v`,e.version]})]}),(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,A.jsx)(vf,{summary:e.settings}),d&&(0,A.jsx)(Uf,{}),(0,A.jsx)(Hf,{status:e.status})]})]}),e.displayName&&(0,A.jsx)(`p`,{className:`text-zinc-500 text-xs font-mono mb-1`,children:e.name}),e.description&&(0,A.jsx)(`p`,{className:`text-zinc-400 text-sm mb-2`,children:e.description}),d&&!f&&(0,A.jsx)(`p`,{className:`text-zinc-500 text-xs mb-2`,children:`Runs on its own agent. Lamaste registers its OIDC clients and capabilities; it mounts no routes and serves no pages for it.`}),f&&(0,A.jsx)(`p`,{className:`text-zinc-500 text-xs mb-2`,children:`Runs on an agent; the panel forwards its admin API and pages to the agent half over an internal tunnel.`}),(0,A.jsxs)(`p`,{className:`text-zinc-500 text-xs mb-4`,children:[e.packageName,e.installedAt&&(0,A.jsxs)(`span`,{children:[` · Installed `,new Date(e.installedAt).toLocaleDateString()]}),e.panel?.pages?.length>0&&(0,A.jsxs)(`span`,{children:[` `,`· `,e.panel.pages.length,` page`,e.panel.pages.length>1?`s`:``]})]}),e.capabilities&&e.capabilities.length>0&&(0,A.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-4`,children:e.capabilities.map(e=>(0,A.jsx)(`span`,{className:`text-xs bg-zinc-800 text-zinc-400 px-2 py-0.5 rounded`,children:e},e))}),d&&(0,A.jsx)(ud,{plugin:e.name}),(e.hooks?.relay||e.hooks?.agent||e.hooks?.agentHalf||e.identity||e.userSurface?.web||e.hooks?.pendingUpdate)&&(0,A.jsx)(Ld,{plugin:e,isActing:l}),f&&(0,A.jsx)(Kf,{plugin:e,dataDir:m,now:t,onHost:o,onUnhost:s,onRotate:c,isActing:l}),e.settings&&(0,A.jsx)(Cf,{plugin:e}),(0,A.jsx)(Nf,{plugin:e}),(0,A.jsx)(Lf,{plugin:e}),e.identity&&(0,A.jsx)(uf,{plugin:e}),kc(e,n)&&(0,A.jsx)(Mf,{plugin:e}),d&&(0,A.jsx)(Bf,{plugin:e,isActing:l}),(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.status===`disabled`?(0,A.jsxs)(`button`,{type:`button`,disabled:l,onClick:()=>r(e.name),className:`flex items-center gap-1.5 rounded bg-zinc-700 px-3 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,A.jsx)(fa,{size:12}),`Enable`]}):(0,A.jsxs)(`button`,{type:`button`,disabled:l,onClick:()=>i(e.name),className:`flex items-center gap-1.5 rounded bg-zinc-700 px-3 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,A.jsx)(da,{size:12}),`Disable`]}),d&&(0,A.jsx)(Rd,{plugin:e,isActing:l}),h?(0,A.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5 text-xs`,children:[(0,A.jsx)(`span`,{className:`text-zinc-400`,children:p?`Remove its hosting and agent half, then uninstall?`:`Uninstall?`}),(0,A.jsx)(`button`,{type:`button`,onClick:b,disabled:e.status===`enabled`,className:`rounded bg-red-600 px-2 py-1 text-white hover:bg-red-500 disabled:opacity-50 disabled:cursor-not-allowed`,children:`Yes`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>{_(!1),y(!1)},className:`rounded bg-zinc-700 px-2 py-1 text-zinc-300 hover:bg-zinc-600`,children:`No`}),p&&(0,A.jsx)(Gf,{hosting:e.agentHosting,dataDir:m,checked:v,onChange:y})]}):(0,A.jsxs)(`button`,{type:`button`,disabled:l||e.status===`enabled`,onClick:b,title:e.status===`enabled`?`Disable before uninstalling`:`Uninstall plugin`,className:`flex items-center gap-1.5 rounded bg-zinc-700 px-3 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,A.jsx)(R,{size:12}),`Uninstall`]})]})]})}function Jf({onInstall:e,isInstalling:t}){let[n,r]=(0,g.useState)(``);return(0,A.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),n.trim()&&(e(n.trim()),r(``))},className:`flex items-end gap-3`,children:[(0,A.jsxs)(`div`,{className:`flex-1`,children:[(0,A.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,htmlFor:`package-name`,children:`Package name`}),(0,A.jsx)(`input`,{id:`package-name`,type:`text`,value:n,onChange:e=>r(e.target.value),placeholder:`@lamalibre/...`,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-1.5 text-sm text-zinc-300 placeholder-zinc-600 focus:outline-none focus:border-cyan-400`})]}),(0,A.jsxs)(`button`,{type:`submit`,disabled:t||!n.trim(),className:`flex items-center gap-1.5 rounded bg-cyan-600 px-4 py-1.5 text-sm text-white hover:bg-cyan-500 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,A.jsx)(Ai,{size:14}),`Install`]})]})}var Yf=[`install`,`update`,`uninstall`,`check-prerequisites`];function Xf({policy:e,onClose:t}){let n=F(),r=j(),i=z(),[a,o]=(0,g.useState)(e.name||``),[s,c]=(0,g.useState)(e.description||``),[l,u]=(0,g.useState)((e.allowedIps||[]).join(`
12
+ `)),[d,f]=(0,g.useState)((e.deniedIps||[]).join(`
13
+ `)),[p,m]=(0,g.useState)((e.allowedPlugins||[]).join(`
14
+ `)),[h,_]=(0,g.useState)(e.allowedActions||Yf.slice(0,3)),v=N({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(B(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,A.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,A.jsxs)(`div`,{className:`w-full max-w-lg rounded-xl bg-zinc-900 border border-zinc-700 p-6 shadow-xl`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,A.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:`Edit Policy`}),(0,A.jsx)(`button`,{type:`button`,onClick:t,className:`text-zinc-400 hover:text-white`,children:(0,A.jsx)(Ga,{size:20})})]}),(0,A.jsxs)(`form`,{onSubmit:y,className:`space-y-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Name`}),(0,A.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,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Description`}),(0,A.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,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Allowed IPs (one per line)`}),(0,A.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,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Denied IPs (one per line)`}),(0,A.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,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Allowed Plugins (one per line)`}),(0,A.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,A.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,A.jsx)(`span`,{className:`font-mono`,children:`agent.package`}),`). Empty allows every package.`]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-2`,children:`Allowed Actions`}),(0,A.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:Yf.map(e=>(0,A.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:h.includes(e),onChange:()=>b(e),className:`accent-cyan-500`}),(0,A.jsx)(`span`,{className:`text-zinc-300`,children:e})]},e))})]}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-3 pt-2`,children:[(0,A.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,A.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,A.jsx)(L,{size:14,className:`animate-spin inline mr-1`}):null,`Save Changes`]})]})]})]})})}function Zf(){let e=F(),t=j(),n=z(),[r,i]=(0,g.useState)(null),a=M({queryKey:[`push-install-policies`],queryFn:()=>e.getPushInstallPolicies(),refetchInterval:3e4}),o=N({mutationFn:t=>e.deletePushInstallPolicy(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`push-install-policies`]}),t.invalidateQueries({queryKey:[`push-install-config`]}),n(`Policy deleted`)},onError:e=>n(B(e),`error`)}),s=a.data?.policies||[];return a.isLoading||s.length===0?null:(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,A.jsx)(Ea,{size:14,className:`text-cyan-400`}),(0,A.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300`,children:`Policies`})]}),(0,A.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-zinc-800`,children:(0,A.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-900`,children:[(0,A.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Name`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400 hidden md:table-cell`,children:`Description`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400 hidden lg:table-cell`,children:`Actions`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-right text-xs font-medium uppercase text-zinc-400`,children:`Manage`})]})}),(0,A.jsx)(`tbody`,{children:s.map(e=>(0,A.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-800`,children:[(0,A.jsx)(`td`,{className:`px-4 py-3 text-zinc-200 font-semibold`,children:e.name}),(0,A.jsx)(`td`,{className:`px-4 py-3 text-zinc-400 hidden md:table-cell`,children:e.description||`—`}),(0,A.jsx)(`td`,{className:`px-4 py-3 hidden lg:table-cell`,children:(0,A.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:(e.allowedActions||[]).map(e=>(0,A.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-zinc-700 text-zinc-300`,children:e},e))})}),(0,A.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,A.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,A.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,A.jsx)(ca,{size:12})}),(0,A.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,A.jsx)(R,{size:12})})]})})]},e.id))})]})}),r&&(0,A.jsx)(Xf,{policy:r,onClose:()=>i(null)})]})}function Qf(){let e=F(),t=j(),n=z(),{reveal:r}=lo(),i=M({queryKey:[`plugins`],queryFn:()=>e.getPlugins(),refetchInterval:1e4}),a=Oc(M({queryKey:[`sites`],queryFn:()=>e.getSites(),refetchInterval:3e4}).data?.sites),o=i.isSuccess;(0,g.useEffect)(()=>{if(!o||typeof window>`u`)return;let e=decodeURIComponent(window.location.hash.slice(1));e&&document.getElementById(e)?.scrollIntoView({block:`start`})},[o]);let s=N({mutationFn:async t=>{let{result:n,secrets:i}=to(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(B(e),`error`)}),c=N({mutationFn:async t=>{let{result:n,secrets:i}=to(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(B(e),`error`)}),l=N({mutationFn:t=>e.disablePlugin(t),onSuccess:e=>{t.invalidateQueries({queryKey:[`plugins`]}),n(`Plugin "${e.name}" disabled`)},onError:e=>n(B(e),`error`)}),u=(e,{hosting:t})=>n(ad(e,{agentLabel:t?.agentLabel,action:`uninstall`}),`error`),d=N({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:u}),f=N({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`)}}),p=N({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:u}),m=N({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(B(e),`error`)}),h=s.isPending||c.isPending||l.isPending||d.isPending||f.isPending||p.isPending||m.isPending,_=(0,g.useCallback)(e=>s.mutate(e),[s]),v=(0,g.useCallback)(e=>c.mutate(e),[c]),y=(0,g.useCallback)(e=>l.mutate(e),[l]),b=(0,g.useCallback)((e,t={},n=null)=>d.mutate({name:e,purge:t.purge===!0,hosting:n}),[d]),x=(0,g.useCallback)((e,t,n)=>f.mutate({name:e,agentLabel:t},n),[f]),S=(0,g.useCallback)((e,t={},n=null)=>p.mutate({name:e,force:t.force===!0,purge:t.purge===!0,hosting:n}),[p]),C=(0,g.useCallback)(e=>m.mutate(e),[m]),w=i.data?.plugins,T=i.data?.retainedData??[],E=new Set((w??[]).map(e=>e.name));return(0,A.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,A.jsxs)(`div`,{className:`mb-6`,children:[(0,A.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Plugins`}),(0,A.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`Install, enable, and manage plugins`})]}),(0,A.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-5 mb-8`,children:[(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-300 mb-4`,children:`Install Plugin`}),(0,A.jsx)(Jf,{onInstall:_,isInstalling:s.isPending}),s.isPending&&(0,A.jsx)(`p`,{className:`text-xs text-zinc-500 mt-2`,children:`Installing...`})]}),i.isLoading?(0,A.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:Array.from({length:2}).map((e,t)=>(0,A.jsx)(`div`,{className:`h-40 animate-pulse rounded-lg bg-zinc-900 border border-zinc-800`},t))}):i.isError?(0,A.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-red-400 text-sm`,children:[(0,A.jsx)(xi,{size:16}),`Failed to load plugins`]})}):w?.length===0?(0,A.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,A.jsx)(`p`,{className:`text-zinc-500 text-sm text-center`,children:`No plugins installed. Use the form above to install one.`})}):(0,A.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:w?.map(e=>(0,A.jsx)(qf,{plugin:e,now:i.dataUpdatedAt,ownedRoutes:a,onEnable:v,onDisable:y,onUninstall:b,onHost:x,onUnhost:S,onRotate:C,isActing:h},e.name))}),(0,A.jsx)(Vf,{records:T,installedNames:E,isActing:h}),(0,A.jsx)(Gd,{children:(0,A.jsx)(Zf,{})})]})}function $f(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 ep=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;function tp(e){return e?e.length>63?`Max 63 characters`:ep.test(e)?null:`Lowercase letters, numbers, and hyphens only. Cannot start or end with a hyphen.`:`Subdomain is required`}var np={default:10,min:1,max:10240};function rp(e){let t=Number(e);return e===``||!Number.isInteger(t)?`Must be a whole number of MiB`:t<np.min?`Minimum ${np.min}`:t>np.max?`Maximum ${np.max}`:null}function ip(e){return e.maxBodySizeMb??1}var ap=[{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`}];function op(e){let t=Number(e);return!e&&e!==0?`Port is required`:Number.isInteger(t)?t<1024?`Minimum 1024`:t>65535?`Maximum 65535`:dc.includes(t)?`Reserved for a Lamaste service on the relay`:null:`Must be an integer`}function sp(){let e=F(),t=M({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 cp({domain:e,onClose:t}){let n=F(),r=j(),i=z(),[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(np.default)),[v,y]=(0,g.useState)(``),{agents:b,isLoading:x}=sp(),[S,C]=(0,g.useState)({}),[w,T]=(0,g.useState)(null),E=N({mutationFn:e=>n.createTunnel(e),onSuccess:e=>{r.invalidateQueries({queryKey:[`tunnels`]}),i(`Tunnel ${e.tunnel.fqdn} created`),t()},onError:e=>{T(B(e))}}),D=(0,g.useCallback)(e=>{e.preventDefault(),T(null);let t=tp(a),n=op(s),r={};t&&(r.subdomain=t),n&&(r.port=n),p||(r.agentLabel=`Choose the agent that carries this tunnel`);let i=rp(h);if(i&&(r.maxBody=i),Object.keys(r).length>0){C(r);return}C({}),E.mutate({subdomain:a,port:Number(s),description:l||void 0,accessMode:d,agentLabel:p,maxBodySizeMb:Number(h),...v?{domain:v}:{}})},[a,s,l,d,p,h,v,E]);return(0,A.jsxs)(`div`,{className:`bg-zinc-900 border border-zinc-800 rounded-lg p-5 mb-6`,children:[(0,A.jsxs)(`h2`,{className:`text-sm font-semibold text-zinc-300 mb-4 flex items-center gap-2`,children:[(0,A.jsx)(ua,{size:14,className:`text-cyan-400`}),`Add Tunnel`]}),(0,A.jsxs)(`form`,{onSubmit:D,className:`space-y-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Subdomain`}),(0,A.jsxs)(`div`,{className:`flex items-center gap-0`,children:[(0,A.jsx)(`input`,{type:`text`,value:a,onChange:e=>{o(e.target.value.toLowerCase()),C(e=>({...e,subdomain:void 0}))},disabled:E.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,A.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:[`.`,v||e]})]}),S.subdomain&&(0,A.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:S.subdomain})]}),(0,A.jsx)(qc,{value:v,onChange:y}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Port`}),(0,A.jsx)(`input`,{type:`number`,value:s,onChange:e=>{c(e.target.value),C(e=>({...e,port:void 0}))},disabled:E.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`}),S.port&&(0,A.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:S.port})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Agent`}),(0,A.jsxs)(`select`,{value:p,onChange:e=>{m(e.target.value),C(e=>({...e,agentLabel:void 0}))},disabled:E.isPending||x,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,A.jsx)(`option`,{value:``,children:x?`Loading agents…`:`Select an agent`}),b.map(e=>(0,A.jsx)(`option`,{value:e,children:e},e))]}),(0,A.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.`}),!x&&b.length===0&&(0,A.jsx)(`p`,{className:`text-yellow-400 text-xs mt-1`,children:`No agents enrolled yet — enroll one under Certificates first.`}),S.agentLabel&&(0,A.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:S.agentLabel})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Largest request body (MiB)`}),(0,A.jsx)(`input`,{type:`number`,value:h,onChange:e=>{_(e.target.value),C(e=>({...e,maxBody:void 0}))},disabled:E.isPending,min:np.min,max:np.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,A.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.`}),S.maxBody&&(0,A.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:S.maxBody})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:[`Description `,(0,A.jsx)(`span`,{className:`text-zinc-600`,children:`(optional)`})]}),(0,A.jsx)(`input`,{type:`text`,value:l,onChange:e=>u(e.target.value),disabled:E.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,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-2`,children:`Access`}),(0,A.jsx)(`div`,{className:`space-y-2`,children:ap.map(e=>(0,A.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,A.jsx)(`input`,{type:`radio`,name:`accessMode`,value:e.value,checked:d===e.value,onChange:e=>f(e.target.value),disabled:E.isPending,className:`mt-1 text-cyan-500 focus:ring-cyan-500 bg-zinc-800 border-zinc-700`}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{className:`text-sm text-zinc-200`,children:e.label}),(0,A.jsx)(`p`,{className:`text-xs text-zinc-500`,children:e.desc})]})]},e.value))})]}),w&&(0,A.jsx)(`div`,{className:`rounded bg-red-500/10 border border-red-500/20 px-3 py-2 text-sm text-red-400`,children:w}),(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(`button`,{type:`submit`,disabled:E.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:E.isPending?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{size:14,className:`animate-spin`}),`Setting up tunnel...`]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(ua,{size:14}),`Add Tunnel`]})}),(0,A.jsx)(`button`,{type:`button`,onClick:t,disabled:E.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 lp({tunnel:e,onConfirm:t,onCancel:n,isPending:r}){return(0,A.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:(0,A.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,A.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:`Delete Tunnel`}),(0,A.jsxs)(`p`,{className:`text-zinc-400 text-sm mb-6`,children:[`Are you sure you want to delete`,` `,(0,A.jsx)(`span`,{className:`text-cyan-400 font-mono`,children:e.fqdn}),`? This will remove the nginx configuration and TLS certificate mapping.`]}),(0,A.jsxs)(`div`,{className:`flex items-center justify-end gap-3`,children:[(0,A.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,A.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,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{size:14,className:`animate-spin`}),`Deleting...`]}):`Delete`})]})]})})}function up({tunnel:e,onConfirm:t,onCancel:n,isPending:r}){let{agents:i,isLoading:a}=sp(),[o,s]=(0,g.useState)(e.agentLabel||``),[c,l]=(0,g.useState)(e.accessMode||`restricted`),u=ip(e),[d,f]=(0,g.useState)(String(u)),p=rp(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,_=Zl(e);return(0,A.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:(0,A.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,A.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-1`,children:`Edit Tunnel`}),(0,A.jsx)(`p`,{className:`text-cyan-400 font-mono text-sm mb-5`,children:e.fqdn}),(0,A.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Agent`}),(0,A.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,A.jsx)(`option`,{value:``,children:`Unassigned — select an agent`}),i.map(e=>(0,A.jsx)(`option`,{value:e,children:e},e))]}),m.agentLabel&&(0,A.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,A.jsx)(`label`,{className:`block text-xs text-zinc-400 mt-4 mb-2`,children:`Access`}),(0,A.jsx)(`div`,{className:`space-y-2`,children:ap.map(e=>{let t=e.value===`public`&&_.length>0;return(0,A.jsxs)(`label`,{className:`flex items-start gap-2 ${t?`cursor-not-allowed opacity-50`:`cursor-pointer`}`,children:[(0,A.jsx)(`input`,{type:`radio`,name:`editAccessMode`,value:e.value,checked:c===e.value,onChange:e=>l(e.target.value),disabled:r||t,className:`mt-1 text-cyan-500 focus:ring-cyan-500 bg-zinc-800 border-zinc-700`}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{className:`text-sm text-zinc-200`,children:e.label}),(0,A.jsx)(`p`,{className:`text-xs text-zinc-500`,children:t?`Not while it serves the user surface of ${_.join(`, `)} — unbind it first`:e.desc})]})]},e.value)})}),(0,A.jsx)(`label`,{className:`block text-xs text-zinc-400 mt-4 mb-1`,children:`Largest request body (MiB)`}),(0,A.jsx)(`input`,{type:`number`,value:d,onChange:e=>f(e.target.value),disabled:r,min:np.min,max:np.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,A.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:p}),(0,A.jsxs)(`div`,{className:`flex items-center justify-end gap-3 mt-6`,children:[(0,A.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,A.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,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{size:14,className:`animate-spin`}),`Saving...`]}):`Save`})]})]})})}function dp({tunnel:e}){let t=Zl(e);return t.length===0?null:(0,A.jsx)(`span`,{className:`mt-1 flex flex-wrap items-center gap-1`,children:t.map(t=>{let n=Ql(e,t),r=n?.served===!0;return(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs ${r?`bg-cyan-500/10 text-cyan-400`:`bg-yellow-500/10 text-yellow-400`}`,title:`User surface of ${t}: ${n?Jl(n.reason):`status unknown`}`,children:[(0,A.jsx)(Va,{size:11}),t,!r&&n?.reason&&(0,A.jsxs)(`span`,{className:`text-yellow-400/70`,children:[`(`,n.reason.replace(/_/g,` `),`)`]})]},t)})})}function fp({tunnelId:e,tunnels:t,onClose:n}){let r=F(),i=j(),a=z(),[o,s]=(0,g.useState)(``),c=t.find(t=>t.id===e),l=M({queryKey:[`plugins`],queryFn:()=>r.getPlugins()}),u=M({queryKey:[`sites`],queryFn:()=>r.getSites()}),d=()=>{i.invalidateQueries({queryKey:[`tunnels`]}),i.invalidateQueries({queryKey:[`plugin-identity`]})},f=N({mutationFn:t=>r.bindTunnelUserSurface(e,t),onSuccess:(e,t)=>{d(),s(``);let n=Ql(e.tunnel,t);a(n?.served?`Users reach ${t} at https://${e.tunnel.fqdn}/api/${t}/app/`:`Bound ${t} — ${Jl(n?.reason??null)}`)},onError:e=>a(B(e),`error`)}),p=N({mutationFn:t=>r.unbindTunnelUserSurface(e,t),onSuccess:(e,t)=>{d(),a(`${t}: its requests go down the tunnel again`)},onError:e=>a(B(e),`error`)});if(!c)return null;let m=f.isPending||p.isPending,h=Zl(c),_=Yl(c),v=new Map;for(let e of t)if(e.id!==c.id)for(let t of Zl(e))v.set(t,e.fqdn??e.subdomain);for(let e of u.data?.sites??[]){let t=Dc(e);t&&v.set(t,`its own site ${e.fqdn}`)}let y=(l.data?.plugins??[]).filter(e=>e.hosting===`agent`&&e.route&&!h.includes(e.route)).sort((e,t)=>e.route.localeCompare(t.route));return(0,A.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:(0,A.jsxs)(`div`,{className:`bg-zinc-900 border border-zinc-800 rounded-lg p-6 max-w-lg w-full mx-4 shadow-xl`,children:[(0,A.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,A.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:`User Surface`}),(0,A.jsx)(`button`,{type:`button`,onClick:n,className:`text-zinc-500 hover:text-zinc-300`,children:(0,A.jsx)(Ga,{size:18})})]}),(0,A.jsx)(`p`,{className:`text-cyan-400 font-mono text-sm mb-3`,children:c.fqdn}),(0,A.jsxs)(`p`,{className:`text-xs text-zinc-500 mb-4`,children:[`Agent-hosted plugins bound here are reached at`,` `,(0,A.jsx)(`span`,{className:`font-mono text-zinc-400`,children:`/api/<route>/app/`}),` on this host by signed-in users: Gatekeeper vouches for the session, the panel passes the user's id and roles to the plugin's agent half. Only a plugin hosted on this tunnel's agent (`,c.agentLabel??`none`,`) is served here. Until a plugin's installed, approved version declares identity, those requests still go down the tunnel.`]}),(0,A.jsx)(`p`,{className:`text-xs text-zinc-400 mb-1`,children:`Bound here`}),h.length===0?(0,A.jsx)(`p`,{className:`text-xs text-zinc-600 mb-4`,children:`No plugin yet.`}):(0,A.jsx)(`ul`,{className:`mb-4 space-y-1`,children:h.map(e=>{let t=Ql(c,e);return(0,A.jsxs)(`li`,{className:`flex items-start justify-between gap-2 rounded bg-zinc-800/60 px-2 py-1.5 text-xs`,children:[(0,A.jsxs)(`span`,{children:[(0,A.jsx)(`span`,{className:`font-mono text-zinc-200`,children:e}),` `,(0,A.jsxs)(`span`,{className:t?.served?`text-green-400`:`text-yellow-400`,children:[`— `,Jl(t?.reason??null)]})]}),(0,A.jsx)(`button`,{type:`button`,disabled:m,onClick:()=>p.mutate(e),className:`shrink-0 rounded bg-zinc-700 px-2 py-0.5 text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Unbind`})]},e)})}),_.eligible?(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,A.jsxs)(`select`,{value:o,onChange:e=>s(e.target.value),disabled:m||l.isLoading,"aria-label":`Agent-hosted plugin`,className:`flex-1 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,A.jsx)(`option`,{value:``,children:l.isLoading?`Loading plugins…`:`Select an agent-hosted plugin`}),y.map(e=>{let t=Xl(e,c,v);return(0,A.jsxs)(`option`,{value:e.route,disabled:t!==null,children:[e.route,t===null?e.identity?``:` — declares no identity yet`:` — ${t}`]},e.route)})]}),(0,A.jsxs)(`button`,{type:`button`,disabled:m||!o,onClick:()=>f.mutate(o),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:[f.isPending?(0,A.jsx)(L,{size:14,className:`animate-spin`}):(0,A.jsx)(ua,{size:14}),`Bind`]}),!l.isLoading&&y.length===0&&(0,A.jsx)(`p`,{className:`basis-full text-xs text-zinc-500`,children:`No other agent-hosted plugin is installed.`})]}):(0,A.jsxs)(`p`,{className:`text-xs text-yellow-400`,children:[`This tunnel cannot serve a user surface: `,_.reason,`.`]})]})})}function pp({tunnel:e}){return(0,A.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 mp({tunnel:e}){return e.agentLabel?(0,A.jsx)(`span`,{className:`text-sm text-zinc-300 font-mono`,children:e.agentLabel}):(0,A.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 hp({tunnels:e,onDelete:t,onToggle:n,onEdit:r,onUserSurface:i}){return(0,A.jsx)(`div`,{className:`hidden md:block overflow-x-auto`,children:(0,A.jsxs)(`table`,{className:`w-full`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`border-b border-zinc-700`,children:[(0,A.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Status`}),(0,A.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Subdomain`}),(0,A.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`FQDN`}),(0,A.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Port`}),(0,A.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Agent`}),(0,A.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Access`}),(0,A.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Body limit`}),(0,A.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Description`}),(0,A.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Created`}),(0,A.jsx)(`th`,{className:`text-right text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Actions`})]})}),(0,A.jsx)(`tbody`,{children:e.map(e=>{let a=e.enabled!==!1,o=e.exposure===`internal`;return(0,A.jsxs)(`tr`,{className:`border-b border-zinc-700 ${a?`bg-zinc-800/50`:`bg-zinc-800/20 opacity-60`}`,children:[(0,A.jsx)(`td`,{className:`py-3 px-4`,children:(0,A.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full border ${a?`text-green-400 bg-green-500/10 border-green-500/20`:`text-zinc-500 bg-zinc-800 border-zinc-700`}`,children:a?`active`:`disabled`})}),(0,A.jsx)(`td`,{className:`py-3 px-4 text-sm text-zinc-200 font-mono`,children:o?(0,A.jsx)(pp,{tunnel:e}):e.fqdn??e.subdomain}),(0,A.jsx)(`td`,{className:`py-3 px-4 text-sm`,children:o?(0,A.jsx)(`span`,{className:`text-zinc-500`,children:`relay loopback only`}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`a`,{href:`https://${e.fqdn}`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 ${a?`text-cyan-400 hover:text-cyan-300`:`text-zinc-500`}`,children:[e.fqdn,(0,A.jsx)(Ni,{size:12})]}),(0,A.jsx)(dp,{tunnel:e})]})}),(0,A.jsx)(`td`,{className:`py-3 px-4 text-sm text-zinc-200 font-mono`,children:e.port}),(0,A.jsx)(`td`,{className:`py-3 px-4`,children:(0,A.jsx)(mp,{tunnel:e})}),(0,A.jsxs)(`td`,{className:`py-3 px-4 text-sm`,children:[o&&(0,A.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`&&!o&&(0,A.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,A.jsx)(`td`,{className:`py-3 px-4 text-sm text-zinc-400 font-mono`,children:e.type===`panel`?`—`:`${ip(e)} MiB`}),(0,A.jsx)(`td`,{className:`py-3 px-4 text-sm text-zinc-400`,children:e.description||`—`}),(0,A.jsx)(`td`,{className:`py-3 px-4 text-sm text-zinc-500`,children:$f(e.createdAt)}),(0,A.jsx)(`td`,{className:`py-3 px-4 text-right`,children:o?(0,A.jsx)(`span`,{className:`text-xs text-zinc-500`,title:`Managed with the plugin's hosting`,children:`managed by plugin hosting`}):(0,A.jsxs)(`div`,{className:`inline-flex items-center gap-2`,children:[e.type!==`panel`&&(0,A.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,A.jsx)(Sa,{size:12}),`Edit`]}),(e.type??`app`)===`app`&&(0,A.jsxs)(`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:`Serve agent-hosted plugins' user surfaces on this host`,children:[(0,A.jsx)(Va,{size:12}),`Users`]}),(0,A.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 ${a?`text-yellow-400`:`text-green-400`}`,title:a?`Disable tunnel`:`Enable tunnel`,children:[(0,A.jsx)(fa,{size:12}),a?`Disable`:`Enable`]}),(0,A.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,A.jsx)(R,{size:12}),`Delete`]})]})})]},e.id)})})]})})}function gp({tunnels:e,onDelete:t,onToggle:n,onEdit:r,onUserSurface:i}){return(0,A.jsx)(`div`,{className:`md:hidden space-y-3`,children:e.map(e=>{let a=e.enabled!==!1,o=e.exposure===`internal`;return(0,A.jsxs)(`div`,{className:`border border-zinc-700 rounded-lg p-4 ${a?`bg-zinc-800/50`:`bg-zinc-800/20 opacity-60`}`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full border ${a?`text-green-400 bg-green-500/10 border-green-500/20`:`text-zinc-500 bg-zinc-800 border-zinc-700`}`,children:a?`active`:`disabled`}),(0,A.jsx)(`span`,{className:`text-sm font-semibold text-zinc-200 font-mono`,children:o?(0,A.jsx)(pp,{tunnel:e}):e.fqdn??e.subdomain})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.type!==`panel`&&!o&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:`text-xs text-zinc-300`,title:`Agent, access mode, body limit`,children:(0,A.jsx)(Sa,{size:14})}),(e.type??`app`)===`app`&&!o&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`text-xs text-zinc-300`,title:`Serve agent-hosted plugins' user surfaces on this host`,children:(0,A.jsx)(Va,{size:14})}),!o&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:`text-xs ${a?`text-yellow-400`:`text-green-400`}`,children:(0,A.jsx)(fa,{size:14})}),!o&&(0,A.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,A.jsx)(R,{size:12})})]})]}),o?(0,A.jsx)(`p`,{className:`text-sm text-zinc-500 mb-1`,children:`Relay loopback only — managed by plugin hosting`}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`a`,{href:`https://${e.fqdn}`,target:`_blank`,rel:`noopener noreferrer`,className:`text-sm inline-flex items-center gap-1 mb-1 ${a?`text-cyan-400 hover:text-cyan-300`:`text-zinc-500`}`,children:[e.fqdn,(0,A.jsx)(Ni,{size:12})]}),(0,A.jsx)(dp,{tunnel:e})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-4 text-xs text-zinc-500 mt-2`,children:[(0,A.jsxs)(`span`,{children:[`Port: `,(0,A.jsx)(`span`,{className:`text-zinc-300 font-mono`,children:e.port})]}),(0,A.jsxs)(`span`,{children:[`Agent: `,(0,A.jsx)(mp,{tunnel:e})]}),(0,A.jsx)(`span`,{children:$f(e.createdAt)})]}),e.description&&(0,A.jsx)(`p`,{className:`text-xs text-zinc-400 mt-2`,children:e.description})]},e.id)})})}function _p(){let e=F(),t=j(),n=z(),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(null),[l,u]=(0,g.useState)(null),d=M({queryKey:[`tunnels`],queryFn:()=>e.getTunnels(),refetchInterval:1e4}),f=M({queryKey:[`tunnel-agent-config`],queryFn:()=>e.getTunnelAgentConfig()}).data?.domain,p=N({mutationFn:t=>e.deleteTunnel(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`tunnels`]}),n(`Tunnel ${a.fqdn} deleted`),o(null)},onError:e=>{n(B(e),`error`),o(null)}}),m=N({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(B(e),`error`)}}),h=N({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(B(e),`error`),c(null)}}),_=(0,g.useCallback)(e=>{c(e)},[]),v=(0,g.useCallback)(e=>{u(e.id)},[]),y=(0,g.useCallback)(e=>{o(e)},[]),b=(0,g.useCallback)(e=>{let t=e.enabled!==!1;m.mutate({id:e.id,enabled:!t})},[m]),x=(0,g.useCallback)(()=>{a&&p.mutate(a.id)},[a,p]),S=d.data?.tunnels||[];return(0,A.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,A.jsxs)(`div`,{className:`mb-6 flex items-center justify-between`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Tunnels`}),(0,A.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`Manage reverse tunnel configurations`})]}),!r&&(0,A.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,A.jsx)(ua,{size:14}),`Add Tunnel`]})]}),r&&f&&(0,A.jsx)(cp,{domain:f,onClose:()=>i(!1)}),d.isLoading?(0,A.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:3}).map((e,t)=>(0,A.jsx)(`div`,{className:`h-16 animate-pulse rounded-lg bg-zinc-900 border border-zinc-800`},t))}):d.isError?(0,A.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,A.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Failed to load tunnels`})}):S.length===0?(0,A.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-12 text-center`,children:[(0,A.jsx)(oa,{size:32,className:`mx-auto text-zinc-600 mb-3`}),(0,A.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:`No tunnels yet. Add your first tunnel to get started.`})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(hp,{tunnels:S,onDelete:y,onToggle:b,onEdit:_,onUserSurface:v}),(0,A.jsx)(gp,{tunnels:S,onDelete:y,onToggle:b,onEdit:_,onUserSurface:v})]}),l&&(0,A.jsx)(fp,{tunnelId:l,tunnels:S,onClose:()=>u(null)}),s&&(0,A.jsx)(up,{tunnel:s,onConfirm:e=>h.mutate({id:s.id,changes:e}),onCancel:()=>c(null),isPending:h.isPending}),a&&(0,A.jsx)(lp,{tunnel:a,onConfirm:x,onCancel:()=>o(null),isPending:p.isPending})]})}function vp({hasDomain:e}){let t=F(),n=z(),r=j(),i=M({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=N({mutationFn:()=>t.setup2fa(),onSuccess:e=>o(e)}),b=N({mutationFn:e=>t.confirm2fa(e),onSuccess:()=>{r.invalidateQueries(),o(null),c(``),n(`Two-factor authentication enabled`)}}),x=N({mutationFn:e=>t.disable2fa(e),onSuccess:()=>{r.invalidateQueries(),u(``),n(`Two-factor authentication disabled`)}}),S=N({mutationFn:e=>t.triggerPanelUpdate(e),onSuccess:()=>{n(`Update initiated. The panel will restart shortly.`),m(``),_(!1)},onError:e=>n(B(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,A.jsx)(`div`,{className:`p-6`,children:(0,A.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,A.jsxs)(`div`,{className:`mx-auto max-w-2xl p-6`,children:[(0,A.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Settings`}),(0,A.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,A.jsxs)(`div`,{className:`mx-auto max-w-2xl p-6`,children:[(0,A.jsxs)(`div`,{className:`mb-6`,children:[(0,A.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Settings`}),(0,A.jsx)(`p`,{className:`mt-1 text-sm text-zinc-500`,children:`Configure panel security settings.`})]}),(0,A.jsxs)(`div`,{className:`rounded-lg border border-zinc-800 bg-zinc-900 p-6`,children:[(0,A.jsxs)(`div`,{className:`mb-4 flex items-center gap-3`,children:[(0,A.jsx)(Ta,{className:`h-5 w-5 text-cyan-400`}),(0,A.jsx)(`h2`,{className:`text-lg font-bold text-white`,children:`Two-Factor Authentication`}),v.enabled&&(0,A.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,A.jsxs)(`div`,{children:[(0,A.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,A.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,A.jsx)(ja,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-yellow-400`}),(0,A.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,A.jsx)(`p`,{className:`mb-3 text-sm text-red-400`,children:te}),(0,A.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,A.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,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`mb-4 text-sm text-zinc-400`,children:`Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)`}),(0,A.jsx)(`div`,{className:`mb-4 flex justify-center`,children:(0,A.jsx)(`div`,{className:`rounded-lg bg-zinc-950 p-4`,children:(0,A.jsx)(zl,{value:a.uri,size:200,bgColor:`transparent`,fgColor:`#ffffff`})})}),(0,A.jsx)(`p`,{className:`mb-2 text-sm text-zinc-400`,children:`Or enter this code manually:`}),(0,A.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 rounded-lg bg-zinc-950 px-4 py-3`,children:[(0,A.jsx)(`code`,{className:`flex-1 font-mono text-sm tracking-wider text-cyan-400`,children:a.manualKey?.replace(/(.{4})/g,`$1 `).trim()}),(0,A.jsx)(`button`,{type:`button`,onClick:w,className:`text-zinc-500 hover:text-zinc-300`,title:`Copy secret`,children:d?(0,A.jsx)(gi,{size:16,className:`text-green-400`}):(0,A.jsx)(Di,{size:16})})]}),(0,A.jsxs)(`form`,{onSubmit:T,className:`space-y-3`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`mb-1 block text-sm text-zinc-400`,children:`Enter the code from your authenticator to confirm`}),(0,A.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,A.jsx)(`p`,{className:`text-sm text-red-400`,children:D}),(0,A.jsxs)(`div`,{className:`flex gap-3`,children:[(0,A.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,A.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,A.jsxs)(`div`,{children:[(0,A.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,A.jsx)(`div`,{className:`mb-4 rounded-lg border border-zinc-700 bg-zinc-950 p-3`,children:(0,A.jsxs)(`p`,{className:`text-xs text-zinc-500`,children:[`Recovery: if you lose access to your authenticator, run`,` `,(0,A.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,A.jsxs)(`form`,{onSubmit:E,className:`space-y-3`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`mb-1 block text-sm text-zinc-400`,children:`Enter a TOTP code to disable 2FA`}),(0,A.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,A.jsx)(`p`,{className:`text-sm text-red-400`,children:ee}),(0,A.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,A.jsxs)(`div`,{className:`mt-6 rounded-lg border border-zinc-800 bg-zinc-900 p-6`,children:[(0,A.jsxs)(`div`,{className:`mb-4 flex items-center gap-3`,children:[(0,A.jsx)(pa,{className:`h-5 w-5 text-cyan-400`}),(0,A.jsx)(`h2`,{className:`text-lg font-bold text-white`,children:`Panel Update`})]}),(0,A.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,A.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,A.jsxs)(`div`,{className:`flex-1`,children:[(0,A.jsx)(`label`,{className:`mb-1 block text-sm text-zinc-400`,htmlFor:`update-version`,children:`Version`}),(0,A.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,A.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,A.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,A.jsx)(`p`,{className:`mt-2 text-sm text-red-400`,children:S.error.message}),h&&(0,A.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,A.jsxs)(`div`,{className:`w-full max-w-sm rounded-xl border border-zinc-700 bg-zinc-900 p-6 shadow-xl`,children:[(0,A.jsxs)(`div`,{className:`mb-4 flex items-center gap-2`,children:[(0,A.jsx)(ja,{className:`h-5 w-5 text-amber-400`}),(0,A.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:`Confirm Update`})]}),(0,A.jsxs)(`p`,{className:`mb-4 text-sm text-zinc-400`,children:[`This will update the panel server to version`,` `,(0,A.jsx)(`strong`,{className:`text-white`,children:p}),` and restart the service. The panel will be unavailable for 1-2 minutes.`]}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,A.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,A.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 yp({onClose:e}){let t=F(),n=j(),r=z(),[i,a]=(0,g.useState)({id:crypto.randomUUID(),label:``,provider:`digitalocean-spaces`,region:``,bucket:``,endpoint:``,accessKey:``,secretKey:``}),o=N({mutationFn:e=>t.registerStorageServer(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`storage-servers`]}),r(`Storage server registered`),e()},onError:e=>r(B(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,A.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,A.jsxs)(`div`,{className:`w-full max-w-lg rounded-xl bg-zinc-900 border border-zinc-700 p-6 shadow-xl`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,A.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:`Register Storage Server`}),(0,A.jsx)(`button`,{type:`button`,onClick:e,className:`text-zinc-400 hover:text-white`,children:(0,A.jsx)(Ga,{size:20})})]}),(0,A.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),o.mutate(i)},className:`space-y-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Label`}),(0,A.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,A.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Provider`}),(0,A.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,A.jsx)(`option`,{value:`digitalocean-spaces`,children:`DigitalOcean Spaces`}),(0,A.jsx)(`option`,{value:`s3`,children:`Amazon S3`})]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Region`}),(0,A.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,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Bucket`}),(0,A.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,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Endpoint URL`}),(0,A.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,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Access Key`}),(0,A.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,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Secret Key`}),(0,A.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,A.jsx)(`div`,{className:`rounded bg-amber-500/10 border border-amber-500/20 px-3 py-2`,children:(0,A.jsx)(`p`,{className:`text-xs text-amber-300`,children:`Credentials are encrypted at rest using AES-256-GCM. They never leave the server.`})}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-3 pt-2`,children:[(0,A.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,A.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,A.jsx)(L,{size:14,className:`animate-spin inline mr-1`}):null,`Register`]})]})]})]})})}function bp({servers:e,onClose:t}){let n=F(),r=j(),i=z(),[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(e[0]?.id||``),l=M({queryKey:[`plugins`],queryFn:()=>n.getPlugins()}),u=N({mutationFn:e=>n.createStorageBinding(e),onSuccess:()=>{r.invalidateQueries({queryKey:[`storage-bindings`]}),i(`Plugin bound to storage`),t()},onError:e=>i(B(e),`error`)}),d=l.data?.plugins||[];return(0,A.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,A.jsxs)(`div`,{className:`w-full max-w-md rounded-xl bg-zinc-900 border border-zinc-700 p-6 shadow-xl`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,A.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:`Bind Plugin to Storage`}),(0,A.jsx)(`button`,{type:`button`,onClick:t,className:`text-zinc-400 hover:text-white`,children:(0,A.jsx)(Ga,{size:20})})]}),(0,A.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),u.mutate({pluginName:a,storageServerId:s})},className:`space-y-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Plugin`}),(0,A.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,A.jsx)(`option`,{value:``,children:`Select a plugin...`}),d.map(e=>(0,A.jsx)(`option`,{value:e.name,children:e.displayName||e.name},e.name))]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Storage Server`}),(0,A.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,A.jsxs)(`option`,{value:e.id,children:[e.label,` (`,e.provider,` / `,e.region,`)`]},e.id))})]}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-3 pt-2`,children:[(0,A.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,A.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,A.jsx)(L,{size:14,className:`animate-spin inline mr-1`}):null,`Bind`]})]})]})]})})}function xp(){let e=F(),t=j(),n=z(),[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=M({queryKey:[`storage-servers`],queryFn:()=>e.getStorageServers(),refetchInterval:1e4}),f=M({queryKey:[`storage-bindings`],queryFn:()=>e.getStorageBindings(),refetchInterval:1e4}),p=N({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(B(e),`error`),c(null)}}),m=N({mutationFn:t=>e.deleteStorageBinding(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`storage-bindings`]}),n(`Plugin unbound from storage`),u(null)},onError:e=>{n(B(e),`error`),u(null)}}),h=d.data?.servers||[],_=f.data?.bindings||[];return(0,A.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,A.jsxs)(`div`,{className:`mb-6`,children:[(0,A.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Storage`}),(0,A.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`Manage S3-compatible storage servers and bind them to plugins.`})]}),(0,A.jsxs)(`div`,{className:`mb-8`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,A.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,A.jsx)(Ui,{size:18,className:`text-cyan-400`}),`Storage Servers`]}),(0,A.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,A.jsx)(ua,{size:14}),`Register Server`]})]}),d.isLoading?(0,A.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:2}).map((e,t)=>(0,A.jsx)(`div`,{className:`h-14 animate-pulse rounded-lg bg-zinc-900 border border-zinc-800`},t))}):d.isError?(0,A.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-red-400 text-sm`,children:[(0,A.jsx)(xi,{size:16}),`Failed to load storage servers`]})}):h.length===0?(0,A.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-8 text-center`,children:[(0,A.jsx)(Ui,{size:32,className:`mx-auto text-zinc-600 mb-3`}),(0,A.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:`No storage servers registered. Register one to enable plugin storage.`})]}):(0,A.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-zinc-800`,children:(0,A.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-900`,children:[(0,A.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Label`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Provider`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400 hidden md:table-cell`,children:`Region`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400 hidden lg:table-cell`,children:`Bucket`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400 hidden lg:table-cell`,children:`Registered`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-right text-xs font-medium uppercase text-zinc-400`,children:`Actions`})]})}),(0,A.jsx)(`tbody`,{children:h.map(e=>(0,A.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-800`,children:[(0,A.jsx)(`td`,{className:`px-4 py-3 text-zinc-200 font-semibold`,children:e.label}),(0,A.jsx)(`td`,{className:`px-4 py-3 text-zinc-400`,children:e.provider}),(0,A.jsx)(`td`,{className:`px-4 py-3 text-zinc-400 hidden md:table-cell`,children:e.region}),(0,A.jsx)(`td`,{className:`px-4 py-3 text-zinc-400 font-mono text-xs hidden lg:table-cell`,children:e.bucket}),(0,A.jsx)(`td`,{className:`px-4 py-3 text-zinc-500 hidden lg:table-cell`,children:e.registeredAt?br(e.registeredAt):`—`}),(0,A.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,A.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,A.jsx)(R,{size:12})})})]},e.id))})]})})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,A.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,A.jsx)(Zi,{size:18,className:`text-cyan-400`}),`Plugin Bindings`]}),h.length>0&&(0,A.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,A.jsx)(ua,{size:14}),`Bind Plugin`]})]}),f.isLoading?(0,A.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:2}).map((e,t)=>(0,A.jsx)(`div`,{className:`h-14 animate-pulse rounded-lg bg-zinc-900 border border-zinc-800`},t))}):f.isError?(0,A.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-red-400 text-sm`,children:[(0,A.jsx)(xi,{size:16}),`Failed to load bindings`]})}):_.length===0?(0,A.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-8 text-center`,children:[(0,A.jsx)(Zi,{size:32,className:`mx-auto text-zinc-600 mb-3`}),(0,A.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,A.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-zinc-800`,children:(0,A.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-900`,children:[(0,A.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Plugin`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Storage Server`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400 hidden md:table-cell`,children:`Bound`}),(0,A.jsx)(`th`,{className:`px-4 py-3 text-right text-xs font-medium uppercase text-zinc-400`,children:`Actions`})]})}),(0,A.jsx)(`tbody`,{children:_.map(e=>{let t=h.find(t=>t.id===e.storageServerId);return(0,A.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-800`,children:[(0,A.jsx)(`td`,{className:`px-4 py-3 text-zinc-200 font-semibold`,children:e.pluginName}),(0,A.jsx)(`td`,{className:`px-4 py-3 text-zinc-400`,children:t?.label||e.storageServerId.slice(0,8)}),(0,A.jsx)(`td`,{className:`px-4 py-3 text-zinc-500 hidden md:table-cell`,children:e.boundAt?br(e.boundAt):`—`}),(0,A.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,A.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,A.jsx)(Pa,{size:12})})})]},e.pluginName)})})]})})]}),r&&(0,A.jsx)(yp,{onClose:()=>i(!1)}),a&&(0,A.jsx)(bp,{servers:h,onClose:()=>o(!1)}),s&&(0,A.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,A.jsxs)(`div`,{className:`w-full max-w-sm rounded-xl border border-zinc-700 bg-zinc-900 p-6 shadow-xl`,children:[(0,A.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-3`,children:`Remove Storage Server`}),(0,A.jsxs)(`p`,{className:`text-sm text-zinc-400 mb-2`,children:[`Are you sure you want to remove`,` `,(0,A.jsx)(`strong`,{className:`text-white`,children:s.label}),`?`]}),(0,A.jsx)(`p`,{className:`text-xs text-amber-400 mb-4`,children:`All plugin bindings to this server will also be removed.`}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,A.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,A.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,A.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,A.jsxs)(`div`,{className:`w-full max-w-sm rounded-xl border border-zinc-700 bg-zinc-900 p-6 shadow-xl`,children:[(0,A.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-3`,children:`Unbind Plugin`}),(0,A.jsxs)(`p`,{className:`text-sm text-zinc-400 mb-4`,children:[`Remove storage binding for `,(0,A.jsx)(`strong`,{className:`text-white`,children:l}),`?`]}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,A.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,A.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 Sp=50,Cp={info:`text-cyan-400`,warning:`text-yellow-400`,critical:`text-red-400`};function wp(){let e=F(),t=j(),n=z(),r=M({queryKey:[`notifications`],queryFn:()=>e.getNotifications({limit:50}),refetchInterval:3e4}),i=N({mutationFn:()=>e.markNotificationsRead({all:!0}),onSuccess:()=>t.invalidateQueries({queryKey:[`notifications`]}),onError:e=>n(B(e),`error`)}),a=r.data?.notifications??[],o=r.data?.unread??0;return(0,A.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-5 mb-6`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,A.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-zinc-300`,children:[(0,A.jsx)(fi,{size:14,className:`text-cyan-400`}),` Notifications`,o>0&&(0,A.jsx)(`span`,{className:`rounded-full bg-cyan-500/20 px-2 text-xs text-cyan-400`,children:o})]}),o>0&&(0,A.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,A.jsx)(hi,{size:12}),` Mark all read`]})]}),a.length===0?(0,A.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Nothing to report.`}):(0,A.jsx)(`ul`,{className:`space-y-1.5 text-xs`,children:a.map(e=>(0,A.jsxs)(`li`,{className:`flex gap-3 ${e.read?`opacity-60`:``}`,children:[(0,A.jsx)(`span`,{className:`shrink-0 text-zinc-500`,children:new Date(e.at).toLocaleString()}),(0,A.jsx)(`span`,{className:`shrink-0 ${Cp[e.level]??`text-zinc-400`}`,children:e.level}),(0,A.jsx)(`span`,{className:`shrink-0 font-mono text-zinc-500`,children:e.source}),(0,A.jsx)(`span`,{className:`text-zinc-300 break-words`,children:e.message})]},e.id))})]})}function Tp(e){return Object.entries(e??{}).map(([e,t])=>`${e}=${typeof t==`object`&&t?JSON.stringify(t):t}`).join(` `)}function Ep(){let e=F(),[t,n]=(0,g.useState)(``),[r,i]=(0,g.useState)(``),a={plugin:t.trim()||void 0,action:r.trim()||void 0},o=_r({queryKey:[`audit`,a],queryFn:({pageParam:t})=>e.getAuditLog({...a,limit:Sp,...t?{before:t}:{}}),initialPageParam:void 0,getNextPageParam:e=>e.entries.length===Sp?e.entries[e.entries.length-1].id:void 0,refetchInterval:3e4}),s=o.data?.pages.flatMap(e=>e.entries)??[];return(0,A.jsxs)(`div`,{className:`p-6 max-w-5xl mx-auto`,children:[(0,A.jsxs)(`div`,{className:`mb-6`,children:[(0,A.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Audit`}),(0,A.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,A.jsx)(wp,{}),(0,A.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-5`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 mb-4`,children:[(0,A.jsx)(va,{size:14,className:`text-cyan-400`}),(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-300 mr-4`,children:`Audit log`}),(0,A.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,A.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,A.jsxs)(`div`,{className:`flex items-center gap-2 text-red-400 text-sm`,children:[(0,A.jsx)(xi,{size:16}),` Failed to load the audit log`]}):s.length===0?(0,A.jsx)(`p`,{className:`text-xs text-zinc-500`,children:o.isLoading?`Loading…`:`No entries.`}):(0,A.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`text-left text-zinc-500`,children:[(0,A.jsx)(`th`,{className:`pb-2 pr-3 font-normal`,children:`When`}),(0,A.jsx)(`th`,{className:`pb-2 pr-3 font-normal`,children:`Action`}),(0,A.jsx)(`th`,{className:`pb-2 pr-3 font-normal`,children:`Actor`}),(0,A.jsx)(`th`,{className:`pb-2 pr-3 font-normal`,children:`Plugin`}),(0,A.jsx)(`th`,{className:`pb-2 font-normal`,children:`Details`})]})}),(0,A.jsx)(`tbody`,{children:s.map(e=>(0,A.jsxs)(`tr`,{className:`border-t border-zinc-800 align-top`,children:[(0,A.jsx)(`td`,{className:`py-1.5 pr-3 whitespace-nowrap text-zinc-500`,children:new Date(e.at).toLocaleString()}),(0,A.jsx)(`td`,{className:`py-1.5 pr-3 font-mono text-cyan-400`,children:e.action}),(0,A.jsx)(`td`,{className:`py-1.5 pr-3 font-mono text-zinc-300`,children:e.actor}),(0,A.jsx)(`td`,{className:`py-1.5 pr-3 font-mono text-zinc-300`,children:e.plugin??``}),(0,A.jsx)(`td`,{className:`py-1.5 font-mono text-zinc-500 break-all`,children:Tp(e.details)})]},e.id))})]}),o.hasNextPage&&(0,A.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`})]})]})}var Dp=`inline-flex items-center gap-1.5 rounded-lg border border-zinc-700 px-3 py-1.5 text-xs text-zinc-300 hover:border-cyan-600 hover:text-white disabled:opacity-50`;function Op(e){for(let t of[[`domains`],[`users`],[`plugins`],[`domain-members`]])e.invalidateQueries({queryKey:t})}function kp(e,t){for(let n of[[`domains`],[`users`],[`domain-members`,t]])e.invalidateQueries({queryKey:n})}function Ap({domain:e}){let t=F(),n=N({mutationFn:()=>t.verifyDomainDns(e.name)}),r=n.data;return(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsxs)(`button`,{type:`button`,className:Dp,onClick:()=>n.mutate(),disabled:n.isPending,children:[(0,A.jsx)(ya,{size:14}),` `,n.isPending?`Checking…`:`Check DNS`]}),n.isError&&(0,A.jsx)(`p`,{className:`text-xs text-red-400`,children:B(n.error)}),r&&(0,A.jsxs)(`div`,{className:`rounded-lg border border-zinc-800 bg-zinc-950 p-3 text-xs`,children:[(0,A.jsx)(`p`,{className:r.ok?`text-green-400`:`text-yellow-400`,children:r.ok?`auth.${e.name} points at this relay (${r.expectedIp}) — it can be activated`:`Create these records at the domain’s DNS host, pointing at ${r.expectedIp}:`}),(0,A.jsx)(`table`,{className:`mt-2 w-full text-left`,children:(0,A.jsx)(`tbody`,{children:r.records.map(e=>(0,A.jsxs)(`tr`,{className:`align-top`,children:[(0,A.jsx)(`td`,{className:`pr-3 font-mono text-zinc-500`,children:e.type}),(0,A.jsx)(`td`,{className:`pr-3 font-mono text-cyan-300`,children:e.name}),(0,A.jsx)(`td`,{className:`pr-3 font-mono text-zinc-300`,children:e.value}),(0,A.jsxs)(`td`,{className:`pr-3 text-zinc-500`,children:[e.purpose,e.required?``:` (optional)`]}),(0,A.jsx)(`td`,{className:e.ok?`text-green-400`:`text-zinc-500`,children:e.ok?`in place`:e.resolvedIps.length>0?e.resolvedIps.join(`, `):`missing`})]},e.name))})})]})]})}function jp({domain:e}){let t=F(),n=j(),r=z(),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(`member`),c=M({queryKey:[`domain-members`,e.name],queryFn:()=>t.getDomainMembers(e.name)}),l=M({queryKey:[`users`],queryFn:()=>t.getUsers()}),u=N({mutationFn:({userId:n,kind:r})=>r?t.addDomainMember(e.name,n,{kind:r}):t.removeDomainMember(e.name,n),onSuccess:()=>{a(``),kp(n,e.name)},onError:e=>r(Lc(e),`error`)}),d=c.data?.members??[],f=Rc(l.data?.users??[],d);return(0,A.jsxs)(`div`,{className:`space-y-3`,children:[c.isLoading?(0,A.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Loading members…`}):d.length===0?(0,A.jsxs)(`p`,{className:`text-xs text-zinc-500`,children:[`No members — nobody can reach `,e.name,`’s protected hosts.`]}):(0,A.jsx)(`ul`,{className:`divide-y divide-zinc-800 rounded-lg border border-zinc-800`,children:d.map(e=>(0,A.jsxs)(`li`,{className:`flex items-center justify-between px-3 py-2 text-sm`,children:[(0,A.jsxs)(`span`,{className:`font-mono text-cyan-400`,children:[e.username??e.userId,e.kind===`external`&&(0,A.jsx)(`span`,{className:`ml-2`,children:(0,A.jsx)(Yc,{})}),e.status!==`active`&&(0,A.jsxs)(`span`,{className:`ml-2 font-sans text-xs text-zinc-500`,children:[`(`,e.status,`)`]})]}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsxs)(`button`,{type:`button`,className:Dp,disabled:u.isPending,title:e.kind===`external`?void 0:zc,onClick:()=>u.mutate({userId:e.userId,kind:e.kind===`external`?`member`:`external`}),children:[(0,A.jsx)(ma,{size:14}),` `,e.kind===`external`?`Make member`:`Make external`]}),(0,A.jsxs)(`button`,{type:`button`,className:Dp,disabled:u.isPending,onClick:()=>u.mutate({userId:e.userId,kind:null}),children:[(0,A.jsx)(La,{size:14}),` Remove`]})]})]},e.userId))}),f.length>0&&(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsxs)(`select`,{value:i,onChange:e=>a(e.target.value),className:`flex-1 rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-1.5 text-sm text-white focus:border-cyan-500 focus:outline-none`,children:[(0,A.jsx)(`option`,{value:``,children:`Add a member…`}),f.map(e=>(0,A.jsx)(`option`,{value:e.userId,children:e.username},e.userId))]}),(0,A.jsxs)(`select`,{value:o,onChange:e=>s(e.target.value),"aria-label":`Kind of membership`,title:`An external member reaches only what names them: restricted tunnels and surfaces that grant them, sites that list them, OIDC clients granted to them. They hold no Authelia groups.`,className:`rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-1.5 text-sm text-white focus:border-cyan-500 focus:outline-none`,children:[(0,A.jsx)(`option`,{value:`member`,children:`member`}),(0,A.jsx)(`option`,{value:`external`,children:`external`})]}),(0,A.jsxs)(`button`,{type:`button`,className:Dp,disabled:!i||u.isPending,onClick:()=>u.mutate({userId:i,kind:o}),children:[(0,A.jsx)(Ra,{size:14}),` Add`]})]})]})}function Mp({domain:e}){let t=F(),n=j(),r=z(),[i,a]=(0,g.useState)(!1),[o,s]=(0,g.useState)(!1),c=e=>r(Lc(e),`error`),l=N({mutationFn:()=>t.activateDomain(e.name),onSuccess:()=>{r(`${e.name} is active: its sign-in is auth.${e.name}`),Op(n)},onError:c}),u=N({mutationFn:()=>t.removeDomain(e.name),onSuccess:()=>{r(`${e.name} removed`),Op(n)},onError:c,onSettled:()=>s(!1)}),d=Ic(e.usedBy),f=e.status===`active`;return(0,A.jsxs)(`div`,{className:`rounded-xl border border-zinc-800 bg-zinc-900 p-4`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`font-mono text-base text-white`,children:e.name}),(0,A.jsxs)(`p`,{className:`text-xs ${f?`text-green-400`:`text-yellow-400`}`,children:[Fc(e),` · `,e.members,` member`,e.members===1?``:`s`,e.externalMembers>0&&` · ${e.externalMembers} external`]})]}),(0,A.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!f&&(0,A.jsxs)(`button`,{type:`button`,className:Dp,disabled:l.isPending,onClick:()=>l.mutate(),children:[(0,A.jsx)(fa,{size:14}),` `,l.isPending?`Activating…`:`Activate`]}),!e.primary&&(0,A.jsxs)(`button`,{type:`button`,className:Dp,disabled:u.isPending||d.length>0,title:d.length>0?`Still in use`:void 0,onClick:()=>s(!0),children:[(0,A.jsx)(R,{size:14}),` Remove`]}),(0,A.jsxs)(`button`,{type:`button`,className:Dp,onClick:()=>a(!i),children:[i?(0,A.jsx)(bi,{size:14}):(0,A.jsx)(_i,{size:14}),` Members`]})]})]}),d.length>0&&(0,A.jsx)(`ul`,{className:`mt-2 space-y-0.5 text-xs text-zinc-400`,children:d.map(e=>(0,A.jsx)(`li`,{children:e},e))}),!f&&(0,A.jsx)(`div`,{className:`mt-3`,children:(0,A.jsx)(Ap,{domain:e})}),i&&(0,A.jsx)(`div`,{className:`mt-3`,children:(0,A.jsx)(jp,{domain:e})}),o&&(0,A.jsx)(su,{title:`Remove ${e.name}?`,message:`Its sign-in stops and its ${e.members+(e.externalMembers??0)} membership(s) end. The users stay.`,confirmLabel:`Remove domain`,destructive:!0,isPending:u.isPending,onConfirm:()=>u.mutate(),onCancel:()=>s(!1)})]})}function Np(){let e=F(),t=j(),n=z(),[r,i]=(0,g.useState)(``),a=N({mutationFn:()=>e.addDomain(r.trim().toLowerCase()),onSuccess:({domain:e})=>{n(`${e.name} added — point auth.${e.name} here, then activate it`),i(``),Op(t)},onError:e=>n(Lc(e),`error`)});return(0,A.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),r.trim()&&a.mutate()},children:[(0,A.jsx)(`input`,{type:`text`,value:r,onChange:e=>i(e.target.value),placeholder:`example.com`,className:`flex-1 rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-2 font-mono text-sm text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`}),(0,A.jsxs)(`button`,{type:`submit`,disabled:!r.trim()||a.isPending,className:`inline-flex items-center gap-1.5 rounded-lg bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:[(0,A.jsx)(ua,{size:16}),` Add domain`]})]})}function Pp(){let{domains:e,isLoading:t,isError:n,error:r}=Gc();return(0,A.jsxs)(`div`,{className:`space-y-6`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(ji,{className:`text-cyan-400`,size:24}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h1`,{className:`text-2xl font-bold text-white`,children:`Domains`}),(0,A.jsx)(`p`,{className:`text-sm text-zinc-400`,children:`Every domain has its own sign-in and member list. The panel and the tunnel endpoint stay on the primary.`})]})]}),(0,A.jsx)(Np,{}),t&&(0,A.jsx)(`p`,{className:`text-sm text-zinc-500`,children:`Loading domains…`}),n&&(0,A.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-red-400`,children:[(0,A.jsx)(xi,{size:16}),` `,B(r)]}),(0,A.jsx)(`div`,{className:`space-y-4`,children:e.map(e=>(0,A.jsx)(Mp,{domain:e},e.name))}),e.length===1&&(0,A.jsxs)(`p`,{className:`flex items-center gap-2 text-xs text-zinc-500`,children:[(0,A.jsx)(Ci,{size:14}),` One domain: every new user is its member, as before, unless made external.`]})]})}function Q(e,t){return t===void 0?P(e,{method:`POST`}):P(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}function Fp(e,t){return P(e,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}function Ip(e,t){return P(e,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}function Lp(e,t){let n={method:`DELETE`};return t&&(n.headers={"Content-Type":`application/json`},n.body=JSON.stringify(t)),P(e,n)}function Rp(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 zp({force:e=!1,purge:t=!1}={}){return Rp({force:e?`true`:void 0,purge:t?`true`:void 0})}function Bp(e,t=``){return`/api/domains/${encodeURIComponent(e)}${t}`}function Vp(e,t){return`/api/plugins/${encodeURIComponent(e)}/${t}`}var Hp={getUsers:()=>P(`/api/users`),createUser:e=>Q(`/api/users`,e),updateUser:(e,t)=>Fp(`/api/users/${encodeURIComponent(e)}`,t),disableUser:e=>Fp(`/api/users/${encodeURIComponent(e)}`,{disabled:!0}),enableUser:e=>Fp(`/api/users/${encodeURIComponent(e)}`,{disabled:!1}),deleteUser:(e,{erase:t=!1}={})=>Lp(`/api/users/${encodeURIComponent(e)}${Rp({erase:t?`true`:void 0})}`),resetTotp:e=>Q(`/api/users/${encodeURIComponent(e)}/reset-totp`),getUserDirectory:()=>P(`/api/identity/directory`),eraseDirectoryUser:e=>Q(`/api/identity/directory/${encodeURIComponent(e)}/erase`),getDomains:()=>P(`/api/domains`),addDomain:e=>Q(`/api/domains`,{name:e}),verifyDomainDns:e=>Q(Bp(e,`/verify-dns`)),activateDomain:e=>Q(Bp(e,`/activate`)),removeDomain:e=>Lp(Bp(e)),getDomainMembers:e=>P(Bp(e,`/members`)),addDomainMember:(e,t,n)=>Fp(Bp(e,`/members/${encodeURIComponent(t)}`),n?.kind?{kind:n.kind}:{}),removeDomainMember:(e,t)=>Lp(Bp(e,`/members/${encodeURIComponent(t)}`)),setPluginDomain:(e,t)=>Fp(Vp(e,`domain`),{domain:t}),getInvitations:()=>P(`/api/invitations`),createInvitation:e=>Q(`/api/invitations`,e),revokeInvitation:e=>Lp(`/api/invitations/${encodeURIComponent(e)}`),getSites:()=>P(`/api/sites`),createSite:e=>Q(`/api/sites`,e),deleteSite:e=>Lp(`/api/sites/${encodeURIComponent(e)}`),updateSite:(e,t)=>Ip(`/api/sites/${encodeURIComponent(e)}`,t),getSiteFiles:(e,t)=>{let n=t&&t!==`.`?`?path=${encodeURIComponent(t)}`:``;return P(`/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 P(`/api/sites/${encodeURIComponent(e)}/files${i}`,{method:`POST`,body:r})},deleteSiteFile:(e,t)=>Lp(`/api/sites/${encodeURIComponent(e)}/files`,{path:t}),verifySiteDns:e=>Q(`/api/sites/${encodeURIComponent(e)}/verify-dns`),getCerts:()=>P(`/api/certs`),renewCert:e=>Q(`/api/certs/${encodeURIComponent(e)}/renew`),rotateMtls:()=>Q(`/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:()=>P(`/api/certs/admin/auth-mode`),getAutoRenewStatus:()=>P(`/api/certs/auto-renew-status`),getAgentCerts:()=>P(`/api/certs/agent`),generateAgentCert:e=>Q(`/api/certs/agent`,e),revokeAgentCert:e=>Lp(`/api/certs/agent/${encodeURIComponent(e)}`),createEnrollmentToken:e=>Q(`/api/certs/agent/enroll`,e),revokeEnrollmentToken:e=>Lp(`/api/certs/agent/enroll/${encodeURIComponent(e)}`),updateAgentCapabilities:(e,t)=>Ip(`/api/certs/agent/${encodeURIComponent(e)}/capabilities`,{capabilities:t}),updateAgentAllowedSites:(e,t)=>Ip(`/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:()=>P(`/api/services`),serviceAction:(e,t)=>Q(`/api/services/${encodeURIComponent(e)}/${encodeURIComponent(t)}`),getSystemStats:()=>P(`/api/system/stats`),triggerPanelUpdate:e=>Q(`/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:()=>P(`/api/tickets/scopes`),createTicketScope:e=>Q(`/api/tickets/scopes`,e),deleteTicketScope:e=>Lp(`/api/tickets/scopes/${encodeURIComponent(e)}`),getTicketInstances:()=>P(`/api/tickets/instances`),deleteTicketInstance:e=>Lp(`/api/tickets/instances/${encodeURIComponent(e)}`),getTicketAssignments:()=>P(`/api/tickets/assignments`),createTicketAssignment:e=>Q(`/api/tickets/assignments`,e),deleteTicketAssignment:(e,t)=>Lp(`/api/tickets/assignments/${encodeURIComponent(e)}/${encodeURIComponent(t)}`),getTickets:()=>P(`/api/tickets`),revokeTicket:e=>Lp(`/api/tickets/${encodeURIComponent(e)}`),getTicketSessions:()=>P(`/api/tickets/sessions`),killTicketSession:e=>Lp(`/api/tickets/sessions/${encodeURIComponent(e)}`),getPlugins:()=>P(`/api/plugins`),installPlugin:e=>Q(`/api/plugins/install`,{packageName:e}),enablePlugin:e=>Q(`/api/plugins/${encodeURIComponent(e)}/enable`),disablePlugin:e=>Q(`/api/plugins/${encodeURIComponent(e)}/disable`),uninstallPlugin:(e,t={})=>Lp(`/api/plugins/${encodeURIComponent(e)}${zp(t)}`),getPluginHosting:e=>P(`/api/plugins/${encodeURIComponent(e)}/hosting`),getPluginHostingEligibility:e=>P(`/api/plugins/${encodeURIComponent(e)}/hosting/eligibility`),setPluginHosting:(e,t)=>Q(`/api/plugins/${encodeURIComponent(e)}/hosting`,{agentLabel:t}),clearPluginHosting:(e,t={})=>Lp(`/api/plugins/${encodeURIComponent(e)}/hosting${zp(t)}`),rotatePluginHostingSecret:e=>Q(`/api/plugins/${encodeURIComponent(e)}/hosting/rotate-secret`),getPluginRetainedData:e=>P(`/api/plugins/${encodeURIComponent(e)}/retained-data`),purgePluginRetainedData:(e,t)=>Lp(`/api/plugins/${encodeURIComponent(e)}/retained-data${Rp({agentLabel:t})}`),forgetPluginRetainedData:(e,t)=>Lp(`/api/plugins/${encodeURIComponent(e)}/retained-data${Rp({agentLabel:t,forget:`true`})}`),getPluginSettings:e=>P(`/api/plugins/${encodeURIComponent(e)}/settings`),updatePluginSettings:(e,t)=>Fp(`/api/plugins/${encodeURIComponent(e)}/settings`,t),getPluginOperations:e=>P(`/api/plugins/${encodeURIComponent(e)}/operations`),getPluginOperation:(e,t)=>P(`/api/plugins/${encodeURIComponent(e)}/operations/${encodeURIComponent(t)}`),getPluginHooks:e=>P(`/api/plugins/${encodeURIComponent(e)}/hooks`),approvePluginHooks:(e,t,n)=>Q(`/api/plugins/${encodeURIComponent(e)}/hooks/approve`,{digest:t,...n?{version:n}:{}}),setPluginHooksAutoApprove:(e,t)=>Fp(`/api/plugins/${encodeURIComponent(e)}/hooks/auto-approve`,{enabled:t}),updatePlugin:(e,t)=>Q(`/api/plugins/${encodeURIComponent(e)}/update`,t?{version:t}:{}),discardPluginUpdate:e=>Lp(`/api/plugins/${encodeURIComponent(e)}/update`),getPluginOidcClients:e=>P(Vp(e,`oidc-clients`)),getPluginIdentity:e=>P(Vp(e,`identity`)),getPluginAudience:e=>P(Vp(e,`audience`)),getPluginEntitlements:e=>P(Vp(e,`entitlements`)),setPluginEntitlement:(e,{principalType:t,principalId:n,roles:r})=>Fp(Vp(e,`entitlements`),{principalType:t,principalId:n,roles:r}),removePluginEntitlement:(e,{principalType:t,principalId:n})=>Lp(`${Vp(e,`entitlements`)}${Rp({principalType:t,principalId:n})}`),syncPluginIdentity:(e,{reconcile:t=!1}={})=>Q(Vp(e,`identity/sync`),{reconcile:t}),getPluginWebSurface:e=>P(Vp(e,`web-surface`)),createPluginWebSurface:(e,{subdomain:t,accessMode:n}={})=>Q(Vp(e,`web-surface`),{...t?{subdomain:t}:{},...n?{accessMode:n}:{}}),movePluginWebSurface:(e,t)=>Q(Vp(e,`web-surface/move`),{tunnelId:t}),deletePluginWebSurface:e=>Lp(Vp(e,`web-surface`)),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:()=>P(`/api/plugins/push-install/config`),updatePushInstallConfig:e=>Ip(`/api/plugins/push-install/config`,e),getPushInstallPolicies:()=>P(`/api/plugins/push-install/policies`),createPushInstallPolicy:e=>Q(`/api/plugins/push-install/policies`,e),deletePushInstallPolicy:e=>Lp(`/api/plugins/push-install/policies/${encodeURIComponent(e)}`),updatePushInstallPolicy:(e,t)=>Ip(`/api/plugins/push-install/policies/${encodeURIComponent(e)}`,t),enablePushInstall:(e,t)=>Q(`/api/plugins/push-install/enable/${encodeURIComponent(e)}`,t),disablePushInstall:e=>Lp(`/api/plugins/push-install/enable/${encodeURIComponent(e)}`),pushInstallCommand:(e,t)=>Q(`/api/plugins/push-install/${encodeURIComponent(e)}`,t),getPushInstallSessions:()=>P(`/api/plugins/push-install/sessions`),getAuditLog:(e={})=>P(`/api/audit${Rp(e)}`),getNotifications:(e={})=>P(`/api/notifications${Rp(e)}`),markNotificationsRead:e=>Q(`/api/notifications/read`,e),registerStorageServer:e=>Q(`/api/storage/servers`,e),getStorageServers:()=>P(`/api/storage/servers`),deleteStorageServer:e=>Lp(`/api/storage/servers/${encodeURIComponent(e)}`),createStorageBinding:e=>Q(`/api/storage/bindings`,e),getStorageBindings:()=>P(`/api/storage/bindings`),getStorageBinding:e=>P(`/api/storage/bindings/${encodeURIComponent(e)}`),deleteStorageBinding:e=>Lp(`/api/storage/bindings/${encodeURIComponent(e)}`),getIdentitySelf:()=>P(`/api/identity/self`),getIdentityUsers:()=>P(`/api/identity/users`),getIdentityUser:e=>P(`/api/identity/users/${encodeURIComponent(e)}`),getIdentityGroups:()=>P(`/api/identity/groups`),get2faStatus:()=>P(`/api/settings/2fa`),setup2fa:()=>Q(`/api/settings/2fa/setup`),confirm2fa:e=>Q(`/api/settings/2fa/confirm`,{code:e}),verify2fa:e=>Q(`/api/settings/2fa/verify`,{code:e}),disable2fa:e=>Q(`/api/settings/2fa/disable`,{code:e}),getAgents:()=>P(`/api/certs/agent`),getUserAccessGrants:()=>P(`/api/user-access/grants`),createUserAccessGrant:e=>Q(`/api/user-access/grants`,e),revokeUserAccessGrant:e=>Lp(`/api/user-access/grants/${encodeURIComponent(e)}`),getTunnels:()=>P(`/api/tunnels`),createTunnel:e=>Q(`/api/tunnels`,e),updateTunnel:(e,t)=>Ip(`/api/tunnels/${encodeURIComponent(e)}`,t),deleteTunnel:e=>Lp(`/api/tunnels/${encodeURIComponent(e)}`),getTunnelAgentConfig:()=>P(`/api/tunnels/agent-config`),bindTunnelUserSurface:(e,t)=>Fp(`/api/tunnels/${encodeURIComponent(e)}/user-surface`,{route:t}),unbindTunnelUserSurface:(e,t)=>Lp(`/api/tunnels/${encodeURIComponent(e)}/user-surface/${encodeURIComponent(t)}`),getGatekeeperGroups:()=>P(`/api/gatekeeper/groups`),createGatekeeperGroup:e=>Q(`/api/gatekeeper/groups`,e),updateGatekeeperGroup:(e,t)=>Ip(`/api/gatekeeper/groups/${encodeURIComponent(e)}`,t),deleteGatekeeperGroup:e=>Lp(`/api/gatekeeper/groups/${encodeURIComponent(e)}`),addGatekeeperGroupMembers:(e,t)=>Q(`/api/gatekeeper/groups/${encodeURIComponent(e)}/members`,t),removeGatekeeperGroupMember:(e,t)=>Lp(`/api/gatekeeper/groups/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`),getGatekeeperGrants:e=>P(`/api/gatekeeper/grants${Rp(e??{})}`),createGatekeeperGrant:e=>Q(`/api/gatekeeper/grants`,e),revokeGatekeeperGrant:e=>Lp(`/api/gatekeeper/grants/${encodeURIComponent(e)}`),checkGatekeeperAccess:(e,t,n)=>P(`/api/gatekeeper/access/check${Rp({username:e,resourceType:t,resourceId:n})}`),bustGatekeeperCache:()=>Q(`/api/gatekeeper/cache/bust`),getGatekeeperSettings:()=>P(`/api/gatekeeper/settings`),updateGatekeeperSettings:e=>Ip(`/api/gatekeeper/settings`,e),getAccessRequestLog:(e=100,t=0)=>P(`/api/gatekeeper/access-log${Rp({limit:e,offset:t})}`),clearAccessRequestLog:()=>Lp(`/api/gatekeeper/access-log`)};function Up({to:e,icon:t,label:n,offline:r=null,onClick:i}){return(0,A.jsxs)(Lt,{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,A.jsx)(t,{className:`h-5 w-5`}),n,r&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{className:`ml-auto h-1.5 w-1.5 shrink-0 rounded-full bg-red-500`,"aria-hidden":`true`}),(0,A.jsxs)(`span`,{className:`sr-only`,children:[`(offline: `,r,`)`]})]})]})}var Wp=`4.7.0`,Gp={activity:oi,"bar-chart-3":di,"book-open":pi,box:mi,cpu:Oi,database:ki,"file-text":Ii,folder:Bi,"git-branch":Vi,globe:Hi,"hard-drive":Ui,heart:Wi,layers:Yi,"layout-dashboard":Xi,list:$i,map:ra,package:sa,server:xa,settings:Ca,shield:Ea,"shield-check":Ta,terminal:ka,ticket:Aa,truck:Ma,users:Ha,wifi:Wa,zap:Ka};function Kp(e){return e&&Object.hasOwn(Gp,e)&&Gp[e]||sa}var qp=[{type:`link`,to:`/`,icon:Xi,label:`Dashboard`},{type:`link`,to:`/tunnels`,icon:Hi,label:`Tunnels`},{type:`link`,to:`/sites`,icon:Ii,label:`Static Sites`},{type:`link`,to:`/users`,icon:Ha,label:`Users`},{type:`link`,to:`/domains`,icon:ji,label:`Domains`},{type:`link`,to:`/certificates`,icon:Ta,label:`Certificates`},{type:`link`,to:`/services`,icon:xa,label:`Services`},{type:`link`,to:`/tickets`,icon:Aa,label:`Tickets`},{type:`link`,to:`/plugins`,icon:sa,label:`Plugins`},{type:`link`,to:`/storage`,icon:Ui,label:`Storage`},{type:`link`,to:`/audit`,icon:va,label:`Audit`},{type:`link`,to:`/settings`,icon:Ca,label:`Settings`},{type:`link`,to:`/docs`,icon:pi,label:`Documentation`}];function Jp({onLinkClick:e}){let t=F(),n=M({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`?Sr(e.agentHosting):null;return t?wr(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:Kp(n.icon),label:n.title,offline:t}))]:e.panel?.label?[{type:`link`,to:`/plugins/${e.name}`,icon:Kp(e.panel?.icon),label:e.panel.label,offline:t}]:[]}),o=[...qp,...a];return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`border-b border-zinc-800 px-4 py-5`,children:(0,A.jsx)(`span`,{className:`font-mono text-lg font-bold text-cyan-400`,children:`Lamaste`})}),(0,A.jsx)(`nav`,{className:`flex-1 space-y-1 px-2 py-4`,children:o.map(t=>t.type===`section-header`?(0,A.jsx)(`div`,{className:`px-3 pt-4 pb-1`,children:(0,A.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-zinc-600`,children:t.label})},t.key):(0,A.jsx)(Up,{to:t.to,icon:t.icon,label:t.label,offline:t.offline??null,onClick:e},t.to))}),(0,A.jsx)(`div`,{className:`border-t border-zinc-800 px-4 py-3`,children:(0,A.jsxs)(`span`,{className:`font-mono text-xs text-zinc-600`,children:[`v`,Wp]})})]})}function Yp(){let[e,t]=(0,g.useState)(!1),n=()=>t(!1);return(0,A.jsxs)(A.Fragment,{children:[(0,A.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,A.jsx)(ia,{className:`h-5 w-5`})}),e&&(0,A.jsxs)(`div`,{className:`fixed inset-0 z-50 lg:hidden`,children:[(0,A.jsx)(`div`,{className:`fixed inset-0 bg-black/50`,onClick:n}),(0,A.jsxs)(`div`,{className:`relative flex h-screen w-64 flex-col bg-zinc-900`,children:[(0,A.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,A.jsx)(Ga,{className:`h-5 w-5`})}),(0,A.jsx)(Jp,{onLinkClick:n})]})]}),(0,A.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,A.jsx)(Jp,{})})]})}function Xp(){return(0,A.jsxs)(`div`,{className:`flex min-h-screen`,children:[(0,A.jsx)(Yp,{}),(0,A.jsx)(`main`,{className:`flex-1 overflow-y-auto bg-zinc-950 p-6 lg:p-8`,children:(0,A.jsx)(vt,{})})]})}function Zp(){return(0,A.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-zinc-950`,children:(0,A.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,A.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-2 border-zinc-700 border-t-cyan-400`}),(0,A.jsx)(`p`,{className:`mt-4 text-sm text-zinc-500`,children:`Connecting to panel server...`})]})})}function Qp({onRetry:e}){return(0,A.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-zinc-950`,children:(0,A.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,A.jsx)(xi,{className:`mb-4 h-12 w-12 text-red-400`}),(0,A.jsx)(`h1`,{className:`mb-2 font-mono text-xl font-bold text-zinc-100`,children:`Unable to connect`}),(0,A.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,A.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 $p=/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,em=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function tm({domain:e,onComplete:t}){let[n,r]=(0,g.useState)(e??``),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)({}),c=j(),l=N({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 $p.test(n)||(e.domain=`Enter a valid domain name (e.g. example.com)`),em.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,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{className:`mb-2 text-xl font-semibold text-white`,children:`Configure your domain`}),(0,A.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,A.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,A.jsxs)(`form`,{onSubmit:d,className:`space-y-5`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:`domain`,className:`mb-1.5 block text-sm font-medium text-zinc-300`,children:`Domain`}),(0,A.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,A.jsx)(`p`,{className:`mt-1 text-xs text-red-400`,children:o.domain})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:`email`,className:`mb-1.5 block text-sm font-medium text-zinc-300`,children:`Email`}),(0,A.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,A.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:`Used for Let's Encrypt certificate registration`}),o.email&&(0,A.jsx)(`p`,{className:`mt-1 text-xs text-red-400`,children:o.email})]}),(0,A.jsx)(`div`,{className:`flex justify-end pt-2`,children:(0,A.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,A.jsx)(L,{size:16,className:`animate-spin`}),l.isPending?`Saving...`:`Save & Continue`]})})]})]})}function nm({text:e}){let[t,n]=(0,g.useState)(!1);function r(){navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})}return(0,A.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,A.jsx)(Di,{size:14}),t&&(0,A.jsx)(`span`,{className:`ml-1 text-xs text-green-400`,children:`Copied`})]})}function rm({type:e,name:t,value:n}){return(0,A.jsxs)(`tr`,{className:`border-b border-zinc-700 last:border-b-0`,children:[(0,A.jsx)(`td`,{className:`px-3 py-2.5 font-mono text-sm text-cyan-400`,children:e}),(0,A.jsx)(`td`,{className:`px-3 py-2.5 font-mono text-sm text-zinc-300`,children:t}),(0,A.jsx)(`td`,{className:`px-3 py-2.5 font-mono text-sm text-zinc-300`,children:(0,A.jsxs)(`span`,{className:`inline-flex items-center`,children:[n,(0,A.jsx)(nm,{text:n})]})})]})}function im({name:e,ok:t,resolvedIps:n,expectedIp:r}){return(0,A.jsxs)(`div`,{className:`flex items-start gap-2`,children:[t?(0,A.jsx)(Ci,{size:18,className:`mt-0.5 shrink-0 text-green-400`}):(0,A.jsx)(wi,{size:18,className:`mt-0.5 shrink-0 text-red-400`}),(0,A.jsxs)(`div`,{className:`text-sm`,children:[(0,A.jsx)(`span`,{className:t?`text-green-400`:`text-red-400`,children:e}),t?(0,A.jsxs)(`span`,{className:`text-zinc-400`,children:[` resolves to `,r]}):n.length>0?(0,A.jsxs)(`span`,{className:`text-zinc-400`,children:[` `,`resolves to `,n.join(`, `),` (expected `,r,`)`]}):(0,A.jsx)(`span`,{className:`text-zinc-400`,children:` does not resolve`})]})]})}function am({name:e,ok:t,expectedIp:n,missingText:r}){return(0,A.jsxs)(`div`,{className:`flex items-start gap-2`,children:[t?(0,A.jsx)(Ci,{size:18,className:`mt-0.5 shrink-0 text-green-400`}):(0,A.jsx)(ja,{size:18,className:`mt-0.5 shrink-0 text-yellow-400`}),(0,A.jsxs)(`div`,{className:`text-sm`,children:[(0,A.jsx)(`span`,{className:t?`text-green-400`:`text-yellow-400`,children:e}),t?(0,A.jsxs)(`span`,{className:`text-zinc-400`,children:[` resolves to `,n]}):(0,A.jsxs)(`span`,{className:`text-zinc-400`,children:[` `,r]})]})]})}function om({result:e}){return e?(0,A.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,A.jsx)(im,{name:t.name,ok:t.ok,resolvedIps:t.resolvedIps,expectedIp:e.expectedIp},t.name)),(0,A.jsx)(am,{name:`*.${e.domain}`,ok:e.wildcardOk,expectedIp:e.expectedIp,missingText:`not configured — you can add individual subdomain records later`}),(0,A.jsx)(am,{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,A.jsx)(`p`,{className:`text-sm text-zinc-400`,children:e.message})]}):null}function sm({domain:e,ip:t,onComplete:n,onBack:r}){let[i,a]=(0,g.useState)(null),o=j(),s=N({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,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{className:`mb-2 text-xl font-semibold text-white`,children:`Configure DNS records`}),(0,A.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,A.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,A.jsx)(`div`,{className:`overflow-hidden rounded-md border border-zinc-700`,children:(0,A.jsxs)(`table`,{className:`w-full text-left`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-800/50`,children:[(0,A.jsx)(`th`,{className:`px-3 py-2 text-xs font-medium uppercase tracking-wider text-zinc-500`,children:`Type`}),(0,A.jsx)(`th`,{className:`px-3 py-2 text-xs font-medium uppercase tracking-wider text-zinc-500`,children:`Name`}),(0,A.jsx)(`th`,{className:`px-3 py-2 text-xs font-medium uppercase tracking-wider text-zinc-500`,children:`Value`})]})}),(0,A.jsxs)(`tbody`,{className:`bg-zinc-900`,children:[(0,A.jsx)(rm,{type:`A`,name:`*.${e}`,value:t}),(0,A.jsx)(rm,{type:`A`,name:e,value:t})]})]})}),(0,A.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,A.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,A.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,A.jsx)(om,{result:i}),(0,A.jsxs)(`div`,{className:`mt-6 flex items-center justify-between`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:r,className:`text-sm text-zinc-400 transition-colors hover:text-zinc-200`,children:`Back`}),(0,A.jsxs)(`div`,{className:`flex gap-3`,children:[(0,A.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,A.jsx)(L,{size:16,className:`animate-spin`}),s.isPending?`Verifying...`:`Verify DNS`]}),i?.ok&&(0,A.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 cm=1e4;function lm(){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,cm);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 um({status:e}){switch(e){case`done`:return(0,A.jsx)(Ci,{size:18,className:`shrink-0 text-green-400`});case`error`:return(0,A.jsx)(wi,{size:18,className:`shrink-0 text-red-400`});case`running`:return(0,A.jsx)(L,{size:18,className:`shrink-0 animate-spin text-cyan-400`});default:return(0,A.jsx)(Ti,{size:18,className:`shrink-0 text-zinc-600`})}}function dm({task:e,isLast:t}){let n=e.status===`pending`?`text-zinc-500`:`text-white`;return(0,A.jsxs)(`div`,{className:`flex gap-3`,children:[(0,A.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,A.jsx)(um,{status:e.status}),!t&&(0,A.jsx)(`div`,{className:`mt-1 w-px flex-1 bg-zinc-700`})]}),(0,A.jsxs)(`div`,{className:`pb-4`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium ${n}`,children:e.title}),e.message&&e.status!==`pending`&&(0,A.jsx)(`p`,{className:`mt-0.5 text-xs text-zinc-400`,children:e.message})]})]})}function fm({onComplete:e}){let{tasks:t,isComplete:n,isError:r,error:i,result:a,progress:o,logs:s,retry:c}=lm(),[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,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{className:`mb-2 text-xl font-semibold text-white`,children:`Setting up your Lamaste`}),(0,A.jsx)(`div`,{className:`mb-5 rounded-md border border-amber-700 bg-amber-900/30 px-4 py-3`,children:(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(ja,{size:16,className:`shrink-0 text-amber-300`}),(0,A.jsx)(`p`,{className:`text-sm text-amber-300`,children:`Do not close this page while provisioning is in progress`})]})}),(0,A.jsx)(`div`,{className:`mb-4`,children:t.map((e,n)=>(0,A.jsx)(dm,{task:e,isLast:n===t.length-1},e.id))}),(0,A.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,A.jsx)(`p`,{className:`italic text-zinc-600`,children:`Waiting for provisioning to start...`}):s.map((e,t)=>(0,A.jsx)(`p`,{className:`leading-relaxed`,children:e},t))}),o.total>0&&(0,A.jsxs)(`p`,{className:`mb-4 text-sm text-zinc-500`,children:[`Step `,o.current,` of `,o.total]}),r&&i&&(0,A.jsxs)(`div`,{className:`mb-4 rounded-md border border-red-700 bg-red-900/30 px-4 py-3`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium text-red-300`,children:`Provisioning failed`}),(0,A.jsx)(`p`,{className:`mt-1 text-xs text-red-400`,children:i.message}),(0,A.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,A.jsx)(L,{size:16,className:`animate-spin`}),d?`Retrying...`:`Retry`]})]}),n&&(0,A.jsx)(`div`,{className:`text-center`,children:(0,A.jsx)(`p`,{className:`text-sm text-green-400`,children:`Provisioning complete. Continuing...`})})]})}function pm({text:e}){let[t,n]=(0,g.useState)(!1);function r(){navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})}return(0,A.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,A.jsx)(Di,{size:14}),t&&(0,A.jsx)(`span`,{className:`ml-1 text-xs text-green-400`,children:`Copied`})]})}function mm(e){try{let t=new URL(e);if(t.protocol===`https:`)return t.href}catch{}return``}function hm({result:e,ip:t}){let[n,r]=(0,g.useState)(!1),i=e?.adminUsername||`admin`,a=e?.adminPassword||``,o=mm(e?.panelUrl||``),s=mm(e?.authUrl||``),c=`https://${t}:9292`;return(0,A.jsxs)(`div`,{className:`animate-fade-in`,children:[(0,A.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,A.jsx)(Ta,{size:48,className:`mx-auto mb-3 text-green-400`}),(0,A.jsx)(`h2`,{className:`text-2xl font-bold text-white`,children:`Lamaste is ready!`}),(0,A.jsx)(`p`,{className:`mt-1 text-sm text-zinc-400`,children:`Your stack is fully configured and operational.`})]}),(0,A.jsxs)(`div`,{className:`mb-5 rounded-lg border border-zinc-700 bg-zinc-800 p-6`,children:[(0,A.jsx)(`h3`,{className:`mb-1 font-semibold text-white`,children:`Admin Credentials`}),(0,A.jsx)(`p`,{className:`mb-4 text-sm text-amber-400`,children:`Save these credentials — they won't be shown again.`}),(0,A.jsxs)(`div`,{className:`space-y-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsx)(`span`,{className:`text-sm text-zinc-400`,children:`Username`}),(0,A.jsxs)(`span`,{className:`inline-flex items-center font-mono text-sm text-white`,children:[i,(0,A.jsx)(pm,{text:i})]})]}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsx)(`span`,{className:`text-sm text-zinc-400`,children:`Password`}),(0,A.jsxs)(`span`,{className:`inline-flex items-center font-mono text-sm text-white`,children:[n?a:`•`.repeat(16),(0,A.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,A.jsx)(Pi,{size:14}):(0,A.jsx)(Fi,{size:14})}),(0,A.jsx)(pm,{text:a})]})]})]})]}),(0,A.jsxs)(`div`,{className:`mb-5 space-y-2`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300`,children:`Access URLs`}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between rounded border border-zinc-700 bg-zinc-900 px-3 py-2`,children:[(0,A.jsx)(`span`,{className:`text-sm text-zinc-400`,children:`Panel`}),(0,A.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,A.jsx)(Ni,{size:12})]})]}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between rounded border border-zinc-700 bg-zinc-900 px-3 py-2`,children:[(0,A.jsx)(`span`,{className:`text-sm text-zinc-400`,children:`Auth Portal`}),(0,A.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,A.jsx)(Ni,{size:12})]})]}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between rounded border border-zinc-700 bg-zinc-900 px-3 py-2`,children:[(0,A.jsx)(`span`,{className:`text-sm text-zinc-400`,children:`IP Access`}),(0,A.jsxs)(`span`,{className:`text-sm text-zinc-400`,children:[c,` `,(0,A.jsx)(`span`,{className:`text-xs text-zinc-500`,children:`(requires client certificate)`})]})]})]}),(0,A.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,A.jsx)(`div`,{className:`flex justify-center`,children:(0,A.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 gm=4;function _m(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 vm({current:e}){return(0,A.jsxs)(`div`,{className:`mb-6 flex items-center gap-3`,children:[(0,A.jsxs)(`span`,{className:`text-sm text-zinc-400`,children:[`Step `,e,` of `,gm]}),(0,A.jsx)(`div`,{className:`flex gap-1.5`,children:Array.from({length:gm},(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,A.jsx)(`div`,{className:i},r)})})]})}function ym(){let{status:e,domain:t,ip:n,isLoading:r,isError:i,refetch:a}=$r(),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(null),u=_m(e),d=o!==null&&o<u?o:u;if(r)return(0,A.jsx)(Zp,{});if(i)return(0,A.jsx)(Qp,{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,A.jsx)(tm,{domain:t,onComplete:f}):d===2?_=(0,A.jsx)(sm,{domain:t,ip:n,onComplete:p,onBack:m}):d===3?_=(0,A.jsx)(fm,{onComplete:h}):d===4&&(_=(0,A.jsx)(hm,{result:c,ip:n})),(0,A.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-zinc-950`,children:(0,A.jsxs)(`div`,{className:`mx-4 w-full max-w-xl rounded-lg border border-zinc-800 bg-zinc-900 p-8`,children:[(0,A.jsx)(`h1`,{className:`mb-2 font-mono text-2xl font-bold text-cyan-400`,children:`Lamaste`}),(0,A.jsx)(vm,{current:d}),_]})})}function bm(){let{pluginName:e,"*":t}=Ze();return(0,A.jsx)(Eo,{pluginName:e,subPath:t||``,basePath:`/plugins/${e}`,panelUrl:window.location.origin})}function xm(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Sm=xm();function Cm(e){Sm=e}var wm={exec:()=>null};function Tm(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(Dm.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Em=(()=>{try{return!0}catch{return!1}})(),Dm={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)}}>`)},Om=/^(?:[ \t]*(?:\n|$))+/,km=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Am=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,jm=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Mm=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Nm=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Pm=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Fm=Tm(Pm).replace(/bull/g,Nm).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(),Im=Tm(Pm).replace(/bull/g,Nm).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(),Lm=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Rm=/^[^\n]+/,zm=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Bm=Tm(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,zm).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Vm=Tm(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Nm).getRegex(),Hm=`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`,Um=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Wm=Tm(`^ {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`,Um).replace(`tag`,Hm).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Gm=Tm(Lm).replace(`hr`,jm).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`,Hm).getRegex(),Km={blockquote:Tm(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Gm).getRegex(),code:km,def:Bm,fences:Am,heading:Mm,hr:jm,html:Wm,lheading:Fm,list:Vm,newline:Om,paragraph:Gm,table:wm,text:Rm},qm=Tm(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,jm).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`,Hm).getRegex(),Jm={...Km,lheading:Im,table:qm,paragraph:Tm(Lm).replace(`hr`,jm).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,qm).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`,Hm).getRegex()},Ym={...Km,html:Tm(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Um).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:wm,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Tm(Lm).replace(`hr`,jm).replace(`heading`,` *#{1,6} *[^
16
+ ]`).replace(`lheading`,Fm).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Xm=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Zm=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Qm=/^( {2,}|\\)\n(?!\s*$)/,$m=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,eh=/[\p{P}\p{S}]/u,th=/[\s\p{P}\p{S}]/u,nh=/[^\s\p{P}\p{S}]/u,rh=Tm(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,th).getRegex(),ih=/(?!~)[\p{P}\p{S}]/u,ah=/(?!~)[\s\p{P}\p{S}]/u,oh=/(?:[^\s\p{P}\p{S}]|~)/u,sh=Tm(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Em?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),ch=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,lh=Tm(ch,`u`).replace(/punct/g,eh).getRegex(),uh=Tm(ch,`u`).replace(/punct/g,ih).getRegex(),dh=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,fh=Tm(dh,`gu`).replace(/notPunctSpace/g,nh).replace(/punctSpace/g,th).replace(/punct/g,eh).getRegex(),ph=Tm(dh,`gu`).replace(/notPunctSpace/g,oh).replace(/punctSpace/g,ah).replace(/punct/g,ih).getRegex(),mh=Tm(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,nh).replace(/punctSpace/g,th).replace(/punct/g,eh).getRegex(),hh=Tm(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,eh).getRegex(),gh=Tm(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,nh).replace(/punctSpace/g,th).replace(/punct/g,eh).getRegex(),_h=Tm(/\\(punct)/,`gu`).replace(/punct/g,eh).getRegex(),vh=Tm(/^<(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(),yh=Tm(Um).replace(`(?:-->|$)`,`-->`).getRegex(),bh=Tm(`^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`,yh).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),xh=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Sh=Tm(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,xh).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ch=Tm(/^!?\[(label)\]\[(ref)\]/).replace(`label`,xh).replace(`ref`,zm).getRegex(),wh=Tm(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,zm).getRegex(),Th=Tm(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,Ch).replace(`nolink`,wh).getRegex(),Eh=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Dh={_backpedal:wm,anyPunctuation:_h,autolink:vh,blockSkip:sh,br:Qm,code:Zm,del:wm,delLDelim:wm,delRDelim:wm,emStrongLDelim:lh,emStrongRDelimAst:fh,emStrongRDelimUnd:mh,escape:Xm,link:Sh,nolink:wh,punctuation:rh,reflink:Ch,reflinkSearch:Th,tag:bh,text:$m,url:wm},Oh={...Dh,link:Tm(/^!?\[(label)\]\((.*?)\)/).replace(`label`,xh).getRegex(),reflink:Tm(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,xh).getRegex()},kh={...Dh,emStrongRDelimAst:ph,emStrongLDelim:uh,delLDelim:hh,delRDelim:gh,url:Tm(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,Eh).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:Tm(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,Eh).getRegex()},Ah={...kh,br:Tm(Qm).replace(`{2,}`,`*`).getRegex(),text:Tm(kh.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},jh={normal:Km,gfm:Jm,pedantic:Ym},Mh={normal:Dh,gfm:kh,breaks:Ah,pedantic:Oh},Nh={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},Ph=e=>Nh[e];function Fh(e,t){if(t){if(Dm.escapeTest.test(e))return e.replace(Dm.escapeReplace,Ph)}else if(Dm.escapeTestNoEncode.test(e))return e.replace(Dm.escapeReplaceNoEncode,Ph);return e}function Ih(e){try{e=encodeURI(e).replace(Dm.percentDecode,`%`)}catch{return null}return e}function Lh(e,t){let n=e.replace(Dm.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(Dm.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(Dm.slashPipe,`|`);return n}function Rh(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 zh(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 Bh(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 Vh(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 Hh(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
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
+ `)}var Uh=class{options;rules;lexer;constructor(e){this.options=e||Sm}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:Rh(e,`
19
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=Hh(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=Rh(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:Rh(t[0],`
20
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=Rh(t[0],`
21
+ `).split(`
22
+ `),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o;for(o=0;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
23
+ `),c=s.replace(this.rules.other.blockquoteSetextReplace,`
24
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
25
+ ${s}`:s,r=r?`${r}
26
+ ${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=l,e.length===0)break;let u=i.at(-1);if(u?.type===`code`)break;if(u?.type===`blockquote`){let t=u,a=t.raw+`
27
+ `+e.join(`
28
+ `),o=this.blockquote(a);i[i.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,r=r.substring(0,r.length-t.text.length)+o.text;break}else if(u?.type===`list`){let t=u,a=t.raw+`
29
+ `+e.join(`
30
+ `),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
31
+ `);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=Bh(t[2].split(`
32
+ `,1)[0],t[1].length),l=e.split(`
33
+ `,1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,s=c.trimStart()):u?d=t[1].length+1:(d=c.search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+`
34
+ `,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d),f=this.rules.other.blockquoteBeginRegex(d);for(;e;){let p=e.split(`
35
+ `,1)[0],m;if(l=p,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),m=l):m=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||f.test(l)||t.test(l)||n.test(l))break;if(m.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
36
+ `+m.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
37
+ `+l}u=!l.trim(),r+=p+`
38
+ `,e=e.substring(p.length+1),c=m.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,``),e.tokens[0]?.type===`text`||e.tokens[0]?.type===`paragraph`){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,``),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}}let t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let n={type:`checkbox`,raw:t[0]+` `,checked:t[0]!==`[ ]`};e.checked=n.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=n.raw+e.tokens[0].raw,e.tokens[0].text=n.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(n)):e.tokens.unshift({type:`paragraph`,raw:n.raw,text:n.raw,tokens:[n]}):e.tokens.unshift(n)}}if(!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:`html`,block:!0,raw:t[0],pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Lh(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
39
+ `):[],a={type:`table`,raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(Lh(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:t[0],depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
40
+ `?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=Rh(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=zh(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),Vh(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return Vh(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}else if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},Wh=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Sm,this.options.tokenizer=this.options.tokenizer||new Uh,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:Dm,block:jh.normal,inline:Mh.normal};this.options.pedantic?(t.block=jh.pedantic,t.inline=Mh.pedantic):this.options.gfm&&(t.block=jh.gfm,this.options.breaks?t.inline=Mh.breaks:t.inline=Mh.gfm),this.tokenizer.rules=t}static get rules(){return{block:jh,inline:Mh}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(Dm.carriageReturn,`
41
+ `),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(Dm.tabCharGlobal,` `).replace(Dm.spaceLine,``));e;){let r;if(this.options.extensions?.block?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);r.raw.length===1&&n!==void 0?n.raw+=`
42
+ `:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
43
+ `)?``:`
44
+ `)+r.raw,n.text+=`
45
+ `+r.text,this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
46
+ `)?``:`
47
+ `)+r.raw,n.text+=`
48
+ `+r.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},t.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let a=t.at(-1);n&&a?.type===`paragraph`?(a.raw+=(a.raw.endsWith(`
49
+ `)?``:`
50
+ `)+r.raw,a.text+=`
51
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
52
+ `)?``:`
53
+ `)+r.raw,n.text+=`
54
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!==null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!==null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!==null;)i=r[2]?r[2].length:0,n=n.slice(0,r.index+i)+`[`+`a`.repeat(r[0].length-i-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let a=!1,o=``;for(;e;){a||(o=``),a=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(i)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(o=r.raw.slice(-1)),a=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return t}},Gh=class{options;parser;constructor(e){this.options=e||Sm}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(Dm.notSpaceStart)?.[0],i=e.replace(Dm.endingNewline,``)+`
55
+ `;return r?`<pre><code class="language-`+Fh(r)+`">`+(n?i:Fh(i,!0))+`</code></pre>
56
+ `:`<pre><code>`+(n?i:Fh(i,!0))+`</code></pre>
57
+ `}blockquote({tokens:e}){return`<blockquote>
58
+ ${this.parser.parse(e)}</blockquote>
59
+ `}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
60
+ `}hr(e){return`<hr>
61
+ `}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?`ol`:`ul`,a=t&&n!==1?` start="`+n+`"`:``;return`<`+i+a+`>
62
+ `+r+`</`+i+`>
63
+ `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
64
+ `}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox"> `}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
65
+ `}table(e){let t=``,n=``;for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r=``;for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n=``;for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&=`<tbody>${r}</tbody>`,`<table>
66
+ <thead>
67
+ `+t+`</thead>
68
+ `+r+`</table>
69
+ `}tablerow({text:e}){return`<tr>
70
+ ${e}</tr>
71
+ `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
72
+ `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Fh(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=Ih(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+Fh(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Ih(e);if(i===null)return Fh(n);e=i;let a=`<img src="${e}" alt="${Fh(n)}"`;return t&&(a+=` title="${Fh(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:Fh(e.text)}},Kh=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},qh=class e{options;renderer;textRenderer;constructor(e){this.options=e||Sm,this.options.renderer=this.options.renderer||new Gh,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Kh}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},Jh=class{options;block;constructor(e){this.options=e||Sm}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Wh.lex:Wh.lexInline}provideParser(e=this.block){return e?qh.parse:qh.parseInline}},Yh=new class{defaults=xm();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=qh;Renderer=Gh;TextRenderer=Kh;Lexer=Wh;Tokenizer=Uh;Hooks=Jh;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new Gh(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Uh(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Jh;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];Jh.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&Jh.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Wh.lex(e,t??this.defaults)}parser(e,t){return qh.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?Wh.lex:Wh.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?qh.parse:qh.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?Wh.lex:Wh.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?qh.parse:qh.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
73
+ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+Fh(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Xh(e,t){return Yh.parse(e,t)}Xh.options=Xh.setOptions=function(e){return Yh.setOptions(e),Xh.defaults=Yh.defaults,Cm(Xh.defaults),Xh},Xh.getDefaults=xm,Xh.defaults=Sm,Xh.use=function(...e){return Yh.use(...e),Xh.defaults=Yh.defaults,Cm(Xh.defaults),Xh},Xh.walkTokens=function(e,t){return Yh.walkTokens(e,t)},Xh.parseInline=Yh.parseInline,Xh.Parser=qh,Xh.parser=qh.parse,Xh.Renderer=Gh,Xh.TextRenderer=Kh,Xh.Lexer=Wh,Xh.lexer=Wh.lex,Xh.Tokenizer=Uh,Xh.Hooks=Jh,Xh.parse=Xh,Xh.options,Xh.setOptions,Xh.use,Xh.walkTokens,Xh.parseInline,qh.parse,Wh.lex;var{entries:Zh,setPrototypeOf:Qh,isFrozen:$h,getPrototypeOf:eg,getOwnPropertyDescriptor:tg}=Object,{freeze:ng,seal:rg,create:ig}=Object,{apply:ag,construct:og}=typeof Reflect<`u`&&Reflect;ng||=function(e){return e},rg||=function(e){return e},ag||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},og||=function(e){return new e(...[...arguments].slice(1))};var sg=Dg(Array.prototype.forEach),cg=Dg(Array.prototype.lastIndexOf),lg=Dg(Array.prototype.pop),ug=Dg(Array.prototype.push),dg=Dg(Array.prototype.splice),fg=Array.isArray,pg=Dg(String.prototype.toLowerCase),mg=Dg(String.prototype.toString),hg=Dg(String.prototype.match),gg=Dg(String.prototype.replace),_g=Dg(String.prototype.indexOf),vg=Dg(String.prototype.trim),yg=Dg(Number.prototype.toString),bg=Dg(Boolean.prototype.toString),xg=typeof BigInt>`u`?null:Dg(BigInt.prototype.toString),Sg=typeof Symbol>`u`?null:Dg(Symbol.prototype.toString),Cg=Dg(Object.prototype.hasOwnProperty),wg=Dg(Object.prototype.toString),Tg=Dg(RegExp.prototype.test),Eg=Og(TypeError);function Dg(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return ag(e,t,n)}}function Og(e){return function(){return og(e,[...arguments])}}function $(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:pg;if(Qh&&Qh(e,null),!fg(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&($h(t)||(t[r]=e),i=e)}e[i]=!0}return e}function kg(e){for(let t=0;t<e.length;t++)Cg(e,t)||(e[t]=null);return e}function Ag(e){let t=ig(null);for(let[n,r]of Zh(e))Cg(e,n)&&(fg(r)?t[n]=kg(r):r&&typeof r==`object`&&r.constructor===Object?t[n]=Ag(r):t[n]=r);return t}function jg(e){switch(typeof e){case`string`:return e;case`number`:return yg(e);case`boolean`:return bg(e);case`bigint`:return xg?xg(e):`0`;case`symbol`:return Sg?Sg(e):`Symbol()`;case`undefined`:return wg(e);case`function`:case`object`:{if(e===null)return wg(e);let t=e,n=Mg(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:wg(e)}return wg(e)}default:return wg(e)}}function Mg(e,t){for(;e!==null;){let n=tg(e,t);if(n){if(n.get)return Dg(n.get);if(typeof n.value==`function`)return Dg(n.value)}e=eg(e)}function n(){return null}return n}function Ng(e){try{return Tg(e,``),!0}catch{return!1}}var Pg=ng(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),Fg=ng(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),Ig=ng([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),Lg=ng([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),Rg=ng(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),zg=ng([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Bg=ng([`#text`]),Vg=ng(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),Hg=ng(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-rendering.textlength.type.u1.u2.unicode.values.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),Ug=ng(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),Wg=ng([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Gg=rg(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Kg=rg(/<%[\w\W]*|[\w\W]*%>/gm),qg=rg(/\$\{[\w\W]*/gm),Jg=rg(/^data-[\-\w.\u00B7-\uFFFF]+$/),Yg=rg(/^aria-[\-\w]+$/),Xg=rg(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Zg=rg(/^(?:\w+script|data):/i),Qg=rg(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),$g=rg(/^html$/i),e_=rg(/^[a-z][.\w]*(-[.\w]+)+$/i),t_=Object.freeze({__proto__:null,ARIA_ATTR:Yg,ATTR_WHITESPACE:Qg,CUSTOM_ELEMENT:e_,DATA_ATTR:Jg,DOCTYPE_NAME:$g,ERB_EXPR:Kg,IS_ALLOWED_URI:Xg,IS_SCRIPT_OR_DATA:Zg,MUSTACHE_EXPR:Gg,TMPLIT_EXPR:qg}),n_={element:1,text:3,progressingInstruction:7,comment:8,document:9},r_=function(){return typeof window>`u`?null:window},i_=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},a_=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function o_(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:r_(),t=e=>o_(e);if(t.version=`3.4.2`,t.removed=[],!e||!e.document||e.document.nodeType!==n_.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e,r=n,i=r.currentScript,{DocumentFragment:a,HTMLTemplateElement:o,Node:s,Element:c,NodeFilter:l,NamedNodeMap:u=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:d,DOMParser:f,trustedTypes:p}=e,m=c.prototype,h=Mg(m,`cloneNode`),g=Mg(m,`remove`),_=Mg(m,`nextSibling`),v=Mg(m,`childNodes`),y=Mg(m,`parentNode`);if(typeof o==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let b,x=``,{implementation:S,createNodeIterator:C,createDocumentFragment:w,getElementsByTagName:T}=n,{importNode:E}=r,D=a_();t.isSupported=typeof Zh==`function`&&typeof y==`function`&&S&&S.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:ee,ERB_EXPR:te,TMPLIT_EXPR:ne,DATA_ATTR:re,ARIA_ATTR:ie,IS_SCRIPT_OR_DATA:ae,ATTR_WHITESPACE:oe,CUSTOM_ELEMENT:se}=t_,{IS_ALLOWED_URI:ce}=t_,le=null,ue=$({},[...Pg,...Fg,...Ig,...Rg,...Bg]),O=null,de=$({},[...Vg,...Hg,...Ug,...Wg]),fe=Object.seal(ig(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),pe=null,me=null,he=Object.seal(ig(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),ge=!0,_e=!0,ve=!1,ye=!0,be=!1,xe=!0,Se=!1,Ce=!1,we=!1,Te=!1,Ee=!1,De=!1,Oe=!0,ke=!1,Ae=`user-content-`,je=!0,Me=!1,Ne={},Pe=null,Fe=$({},[`annotation-xml`,`audio`,`colgroup`,`desc`,`foreignobject`,`head`,`iframe`,`math`,`mi`,`mn`,`mo`,`ms`,`mtext`,`noembed`,`noframes`,`noscript`,`plaintext`,`script`,`style`,`svg`,`template`,`thead`,`title`,`video`,`xmp`]),Ie=null,Le=$({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Re=null,ze=$({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Be=`http://www.w3.org/1998/Math/MathML`,Ve=`http://www.w3.org/2000/svg`,He=`http://www.w3.org/1999/xhtml`,Ue=He,We=!1,Ge=null,Ke=$({},[Be,Ve,He],mg),qe=$({},[`mi`,`mo`,`mn`,`ms`,`mtext`]),Je=$({},[`annotation-xml`]),Ye=$({},[`title`,`style`,`font`,`a`,`script`]),Xe=null,Ze=[`application/xhtml+xml`,`text/html`],Qe=null,$e=null,et=n.createElement(`form`),tt=function(e){return e instanceof RegExp||e instanceof Function},nt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if($e&&$e===e)return;(!e||typeof e!=`object`)&&(e={}),e=Ag(e),Xe=Ze.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,Qe=Xe===`application/xhtml+xml`?mg:pg,le=Cg(e,`ALLOWED_TAGS`)&&fg(e.ALLOWED_TAGS)?$({},e.ALLOWED_TAGS,Qe):ue,O=Cg(e,`ALLOWED_ATTR`)&&fg(e.ALLOWED_ATTR)?$({},e.ALLOWED_ATTR,Qe):de,Ge=Cg(e,`ALLOWED_NAMESPACES`)&&fg(e.ALLOWED_NAMESPACES)?$({},e.ALLOWED_NAMESPACES,mg):Ke,Re=Cg(e,`ADD_URI_SAFE_ATTR`)&&fg(e.ADD_URI_SAFE_ATTR)?$(Ag(ze),e.ADD_URI_SAFE_ATTR,Qe):ze,Ie=Cg(e,`ADD_DATA_URI_TAGS`)&&fg(e.ADD_DATA_URI_TAGS)?$(Ag(Le),e.ADD_DATA_URI_TAGS,Qe):Le,Pe=Cg(e,`FORBID_CONTENTS`)&&fg(e.FORBID_CONTENTS)?$({},e.FORBID_CONTENTS,Qe):Fe,pe=Cg(e,`FORBID_TAGS`)&&fg(e.FORBID_TAGS)?$({},e.FORBID_TAGS,Qe):Ag({}),me=Cg(e,`FORBID_ATTR`)&&fg(e.FORBID_ATTR)?$({},e.FORBID_ATTR,Qe):Ag({}),Ne=Cg(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?Ag(e.USE_PROFILES):e.USE_PROFILES:!1,ge=e.ALLOW_ARIA_ATTR!==!1,_e=e.ALLOW_DATA_ATTR!==!1,ve=e.ALLOW_UNKNOWN_PROTOCOLS||!1,ye=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,be=e.SAFE_FOR_TEMPLATES||!1,xe=e.SAFE_FOR_XML!==!1,Se=e.WHOLE_DOCUMENT||!1,Te=e.RETURN_DOM||!1,Ee=e.RETURN_DOM_FRAGMENT||!1,De=e.RETURN_TRUSTED_TYPE||!1,we=e.FORCE_BODY||!1,Oe=e.SANITIZE_DOM!==!1,ke=e.SANITIZE_NAMED_PROPS||!1,je=e.KEEP_CONTENT!==!1,Me=e.IN_PLACE||!1,ce=Ng(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Xg,Ue=typeof e.NAMESPACE==`string`?e.NAMESPACE:He,qe=Cg(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?Ag(e.MATHML_TEXT_INTEGRATION_POINTS):$({},[`mi`,`mo`,`mn`,`ms`,`mtext`]),Je=Cg(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?Ag(e.HTML_INTEGRATION_POINTS):$({},[`annotation-xml`]);let t=Cg(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?Ag(e.CUSTOM_ELEMENT_HANDLING):ig(null);if(fe=ig(null),Cg(t,`tagNameCheck`)&&tt(t.tagNameCheck)&&(fe.tagNameCheck=t.tagNameCheck),Cg(t,`attributeNameCheck`)&&tt(t.attributeNameCheck)&&(fe.attributeNameCheck=t.attributeNameCheck),Cg(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(fe.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),be&&(_e=!1),Ee&&(Te=!0),Ne&&(le=$({},Bg),O=ig(null),Ne.html===!0&&($(le,Pg),$(O,Vg)),Ne.svg===!0&&($(le,Fg),$(O,Hg),$(O,Wg)),Ne.svgFilters===!0&&($(le,Ig),$(O,Hg),$(O,Wg)),Ne.mathMl===!0&&($(le,Rg),$(O,Ug),$(O,Wg))),he.tagCheck=null,he.attributeCheck=null,Cg(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?he.tagCheck=e.ADD_TAGS:fg(e.ADD_TAGS)&&(le===ue&&(le=Ag(le)),$(le,e.ADD_TAGS,Qe))),Cg(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?he.attributeCheck=e.ADD_ATTR:fg(e.ADD_ATTR)&&(O===de&&(O=Ag(O)),$(O,e.ADD_ATTR,Qe))),Cg(e,`ADD_URI_SAFE_ATTR`)&&fg(e.ADD_URI_SAFE_ATTR)&&$(Re,e.ADD_URI_SAFE_ATTR,Qe),Cg(e,`FORBID_CONTENTS`)&&fg(e.FORBID_CONTENTS)&&(Pe===Fe&&(Pe=Ag(Pe)),$(Pe,e.FORBID_CONTENTS,Qe)),Cg(e,`ADD_FORBID_CONTENTS`)&&fg(e.ADD_FORBID_CONTENTS)&&(Pe===Fe&&(Pe=Ag(Pe)),$(Pe,e.ADD_FORBID_CONTENTS,Qe)),je&&(le[`#text`]=!0),Se&&$(le,[`html`,`head`,`body`]),le.table&&($(le,[`tbody`]),delete pe.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw Eg(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw Eg(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);b=e.TRUSTED_TYPES_POLICY,x=b.createHTML(``)}else b===void 0&&(b=i_(p,i)),b!==null&&typeof x==`string`&&(x=b.createHTML(``));ng&&ng(e),$e=e},rt=$({},[...Fg,...Ig,...Lg]),it=$({},[...Rg,...zg]),at=function(e){let t=y(e);(!t||!t.tagName)&&(t={namespaceURI:Ue,tagName:`template`});let n=pg(e.tagName),r=pg(t.tagName);return Ge[e.namespaceURI]?e.namespaceURI===Ve?t.namespaceURI===He?n===`svg`:t.namespaceURI===Be?n===`svg`&&(r===`annotation-xml`||qe[r]):!!rt[n]:e.namespaceURI===Be?t.namespaceURI===He?n===`math`:t.namespaceURI===Ve?n===`math`&&Je[r]:!!it[n]:e.namespaceURI===He?t.namespaceURI===Ve&&!Je[r]||t.namespaceURI===Be&&!qe[r]?!1:!it[n]&&(Ye[n]||!rt[n]):!!(Xe===`application/xhtml+xml`&&Ge[e.namespaceURI]):!1},ot=function(e){ug(t.removed,{element:e});try{y(e).removeChild(e)}catch{g(e)}},st=function(e,n){try{ug(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{ug(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(Te||Ee)try{ot(n)}catch{}else try{n.setAttribute(e,``)}catch{}},ct=function(e){let t=null,r=null;if(we)e=`<remove></remove>`+e;else{let t=hg(e,/^[\r\n\t ]+/);r=t&&t[0]}Xe===`application/xhtml+xml`&&Ue===He&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=b?b.createHTML(e):e;if(Ue===He)try{t=new f().parseFromString(i,Xe)}catch{}if(!t||!t.documentElement){t=S.createDocument(Ue,`template`,null);try{t.documentElement.innerHTML=We?x:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Ue===He?T.call(t,Se?`html`:`body`)[0]:Se?t.documentElement:a},lt=function(e){return C.call(e.ownerDocument||e,e,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},ut=function(e){return e instanceof d&&(typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||!(e.attributes instanceof u)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`)},dt=function(e){return typeof s==`function`&&e instanceof s};function ft(e,n,r){sg(e,e=>{e.call(t,n,r,$e)})}let pt=function(e){let n=null;if(ft(D.beforeSanitizeElements,e,null),ut(e))return ot(e),!0;let r=Qe(e.nodeName);if(ft(D.uponSanitizeElement,e,{tagName:r,allowedTags:le}),xe&&e.hasChildNodes()&&!dt(e.firstElementChild)&&Tg(/<[/\w!]/g,e.innerHTML)&&Tg(/<[/\w!]/g,e.textContent)||xe&&e.namespaceURI===He&&r===`style`&&dt(e.firstElementChild)||e.nodeType===n_.progressingInstruction||xe&&e.nodeType===n_.comment&&Tg(/<[/\w]/g,e.data))return ot(e),!0;if(pe[r]||!(he.tagCheck instanceof Function&&he.tagCheck(r))&&!le[r]){if(!pe[r]&&gt(r)&&(fe.tagNameCheck instanceof RegExp&&Tg(fe.tagNameCheck,r)||fe.tagNameCheck instanceof Function&&fe.tagNameCheck(r)))return!1;if(je&&!Pe[r]){let t=y(e)||e.parentNode,n=v(e)||e.childNodes;if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=h(n[i],!0);t.insertBefore(r,_(e))}}}return ot(e),!0}return e instanceof c&&!at(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&Tg(/<\/no(script|embed|frames)/i,e.innerHTML)?(ot(e),!0):(be&&e.nodeType===n_.text&&(n=e.textContent,sg([ee,te,ne],e=>{n=gg(n,e,` `)}),e.textContent!==n&&(ug(t.removed,{element:e.cloneNode()}),e.textContent=n)),ft(D.afterSanitizeElements,e,null),!1)},mt=function(e,t,r){if(me[t]||Oe&&(t===`id`||t===`name`)&&(r in n||r in et))return!1;let i=O[t]||he.attributeCheck instanceof Function&&he.attributeCheck(t,e);if(!(_e&&!me[t]&&Tg(re,t))&&!(ge&&Tg(ie,t))){if(!i||me[t]){if(!(gt(e)&&(fe.tagNameCheck instanceof RegExp&&Tg(fe.tagNameCheck,e)||fe.tagNameCheck instanceof Function&&fe.tagNameCheck(e))&&(fe.attributeNameCheck instanceof RegExp&&Tg(fe.attributeNameCheck,t)||fe.attributeNameCheck instanceof Function&&fe.attributeNameCheck(t,e))||t===`is`&&fe.allowCustomizedBuiltInElements&&(fe.tagNameCheck instanceof RegExp&&Tg(fe.tagNameCheck,r)||fe.tagNameCheck instanceof Function&&fe.tagNameCheck(r))))return!1}else if(!Re[t]&&!Tg(ce,gg(r,oe,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&_g(r,`data:`)===0&&Ie[e])&&!(ve&&!Tg(ae,gg(r,oe,``)))&&r)return!1}return!0},ht=$({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),gt=function(e){return!ht[pg(e)]&&Tg(se,e)},_t=function(e){ft(D.beforeSanitizeAttributes,e,null);let{attributes:n}=e;if(!n||ut(e))return;let r={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:O,forceKeepAttr:void 0},i=n.length;for(;i--;){let{name:a,namespaceURI:o,value:s}=n[i],c=Qe(a),l=s,u=a===`value`?l:vg(l);if(r.attrName=c,r.attrValue=u,r.keepAttr=!0,r.forceKeepAttr=void 0,ft(D.uponSanitizeAttribute,e,r),u=r.attrValue,ke&&(c===`id`||c===`name`)&&_g(u,Ae)!==0&&(st(a,e),u=Ae+u),xe&&Tg(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,u)){st(a,e);continue}if(c===`attributename`&&hg(u,`href`)){st(a,e);continue}if(r.forceKeepAttr)continue;if(!r.keepAttr){st(a,e);continue}if(!ye&&Tg(/\/>/i,u)){st(a,e);continue}be&&sg([ee,te,ne],e=>{u=gg(u,e,` `)});let d=Qe(e.nodeName);if(!mt(d,c,u)){st(a,e);continue}if(b&&typeof p==`object`&&typeof p.getAttributeType==`function`&&!o)switch(p.getAttributeType(d,c)){case`TrustedHTML`:u=b.createHTML(u);break;case`TrustedScriptURL`:u=b.createScriptURL(u);break}if(u!==l)try{o?e.setAttributeNS(o,a,u):e.setAttribute(a,u),ut(e)?ot(e):lg(t.removed)}catch{st(a,e)}}ft(D.afterSanitizeAttributes,e,null)},vt=function(e){let t=null,n=lt(e);for(ft(D.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)ft(D.uponSanitizeShadowNode,t,null),pt(t),_t(t),t.content instanceof a&&vt(t.content);ft(D.afterSanitizeShadowDOM,e,null)};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,o=null,c=null,l=null;if(We=!e,We&&(e=`<!-->`),typeof e!=`string`&&!dt(e)&&(e=jg(e),typeof e!=`string`))throw Eg(`dirty is not a string, aborting`);if(!t.isSupported)return e;if(Ce||nt(n),t.removed=[],typeof e==`string`&&(Me=!1),Me){let t=e.nodeName;if(typeof t==`string`){let e=Qe(t);if(!le[e]||pe[e])throw Eg(`root node is forbidden and cannot be sanitized in-place`)}}else if(e instanceof s)i=ct(`<!---->`),o=i.ownerDocument.importNode(e,!0),o.nodeType===n_.element&&o.nodeName===`BODY`||o.nodeName===`HTML`?i=o:i.appendChild(o);else{if(!Te&&!be&&!Se&&e.indexOf(`<`)===-1)return b&&De?b.createHTML(e):e;if(i=ct(e),!i)return Te?null:De?x:``}i&&we&&ot(i.firstChild);let u=lt(Me?e:i);for(;c=u.nextNode();)pt(c),_t(c),c.content instanceof a&&vt(c.content);if(Me)return e;if(Te){if(be){i.normalize();let e=i.innerHTML;sg([ee,te,ne],t=>{e=gg(e,t,` `)}),i.innerHTML=e}if(Ee)for(l=w.call(i.ownerDocument);i.firstChild;)l.appendChild(i.firstChild);else l=i;return(O.shadowroot||O.shadowrootmode)&&(l=E.call(r,l,!0)),l}let d=Se?i.outerHTML:i.innerHTML;return Se&&le[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&Tg($g,i.ownerDocument.doctype.name)&&(d=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
74
+ `+d),be&&sg([ee,te,ne],e=>{d=gg(d,e,` `)}),b&&De?b.createHTML(d):d},t.setConfig=function(){nt(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),Ce=!0},t.clearConfig=function(){$e=null,Ce=!1},t.isValidAttribute=function(e,t,n){return $e||nt({}),mt(Qe(e),Qe(t),n)},t.addHook=function(e,t){typeof t==`function`&&ug(D[e],t)},t.removeHook=function(e,t){if(t!==void 0){let n=cg(D[e],t);return n===-1?void 0:dg(D[e],n,1)[0]}return lg(D[e])},t.removeHooks=function(e){D[e]=[]},t.removeAllHooks=function(){D=a_()},t}var s_=o_(),c_=new Xh.Renderer;function l_(e){let t=e,n;do n=t,t=t.replace(/<[^>]*>/g,``);while(t!==n);return t}c_.heading=({text:e,depth:t})=>`<h${t} id="${l_(e).toLowerCase().replace(/[^\w\s-]/g,``).replace(/\s+/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``)}">${e}</h${t}>`,Xh.setOptions({renderer:c_});function u_(e){let t=[],n=/^(#{2,3})\s+(.+)$/gm,r;for(;(r=n.exec(e))!==null;){let e=r[1].length,n=r[2].replace(/`([^`]+)`/g,`$1`),i=l_(n).toLowerCase().replace(/[^\w\s-]/g,``).replace(/\s+/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``);t.push({depth:e,text:n,id:i})}return t}function d_({index:e,currentSlug:t,sidebarOpen:n,onClose:r}){return(0,A.jsxs)(A.Fragment,{children:[n&&(0,A.jsxs)(`div`,{className:`fixed inset-0 z-50 lg:hidden`,children:[(0,A.jsx)(`div`,{className:`fixed inset-0 bg-black/50`,onClick:r}),(0,A.jsxs)(`div`,{className:`relative flex h-screen w-72 flex-col overflow-y-auto bg-zinc-900 border-r border-zinc-800`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between border-b border-zinc-800 px-4 py-4`,children:[(0,A.jsx)(`span`,{className:`text-sm font-semibold text-zinc-300`,children:`Documentation`}),(0,A.jsx)(`button`,{type:`button`,onClick:r,className:`text-zinc-400 hover:text-zinc-100`,children:(0,A.jsx)(Ga,{className:`h-4 w-4`})})]}),(0,A.jsx)(f_,{index:e,currentSlug:t,onLinkClick:r})]})]}),(0,A.jsxs)(`div`,{className:`sticky top-0 hidden h-screen w-72 flex-shrink-0 flex-col overflow-y-auto border-r border-zinc-800 bg-zinc-900/50 lg:flex`,children:[(0,A.jsx)(`div`,{className:`border-b border-zinc-800 px-4 py-4`,children:(0,A.jsxs)(It,{to:`/docs`,className:`text-sm font-semibold text-zinc-300 hover:text-cyan-400 flex items-center gap-2`,children:[(0,A.jsx)(pi,{size:14,className:`text-cyan-400`}),`Documentation`]})}),(0,A.jsx)(f_,{index:e,currentSlug:t})]})]})}function f_({index:e,currentSlug:t,onLinkClick:n}){return(0,A.jsx)(`nav`,{className:`flex-1 px-3 py-4 space-y-5`,children:e.sections.map(e=>(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h3`,{className:`px-2 mb-1 text-xs font-semibold uppercase tracking-wider text-zinc-500`,children:e.title}),(0,A.jsx)(`ul`,{className:`space-y-0.5`,children:e.pages.map(e=>(0,A.jsx)(`li`,{children:(0,A.jsx)(It,{to:`/docs/${e.slug}`,onClick:n,className:[`block rounded-md px-2 py-1.5 text-sm transition-colors`,t===e.slug?`text-cyan-400 bg-zinc-800/50 font-medium`:`text-zinc-400 hover:text-zinc-100 hover:bg-zinc-800/30`].join(` `),children:e.title})},e.slug))})]},e.title))})}function p_({toc:e,activeId:t}){return e.length===0?null:(0,A.jsxs)(`div`,{className:`sticky top-6 hidden xl:block w-56 flex-shrink-0`,children:[(0,A.jsxs)(`h4`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-zinc-500 flex items-center gap-1.5`,children:[(0,A.jsx)($i,{size:12}),`On this page`]}),(0,A.jsx)(`ul`,{className:`space-y-1 border-l border-zinc-800`,children:e.map(e=>(0,A.jsx)(`li`,{children:(0,A.jsx)(`a`,{href:`#${e.id}`,className:[`block border-l-2 -ml-px text-xs transition-colors py-1`,e.depth===3?`pl-5`:`pl-3`,t===e.id?`border-cyan-400 text-cyan-400`:`border-transparent text-zinc-500 hover:text-zinc-300 hover:border-zinc-600`].join(` `),children:e.text})},e.id))})]})}function m_({prevPage:e,nextPage:t}){return!e&&!t?null:(0,A.jsxs)(`div`,{className:`mt-12 flex items-stretch gap-4 border-t border-zinc-800 pt-6`,children:[e?(0,A.jsxs)(It,{to:`/docs/${e.slug}`,className:`flex-1 group rounded-lg border border-zinc-800 p-4 hover:border-zinc-700 transition-colors`,children:[(0,A.jsxs)(`span`,{className:`text-xs text-zinc-500 flex items-center gap-1`,children:[(0,A.jsx)(vi,{size:12}),`Previous`]}),(0,A.jsx)(`span`,{className:`mt-1 block text-sm text-zinc-300 group-hover:text-cyan-400 transition-colors`,children:e.title})]}):(0,A.jsx)(`div`,{className:`flex-1`}),t?(0,A.jsxs)(It,{to:`/docs/${t.slug}`,className:`flex-1 group rounded-lg border border-zinc-800 p-4 hover:border-zinc-700 transition-colors text-right`,children:[(0,A.jsxs)(`span`,{className:`text-xs text-zinc-500 flex items-center justify-end gap-1`,children:[`Next`,(0,A.jsx)(yi,{size:12})]}),(0,A.jsx)(`span`,{className:`mt-1 block text-sm text-zinc-300 group-hover:text-cyan-400 transition-colors`,children:t.title})]}):(0,A.jsx)(`div`,{className:`flex-1`})]})}function h_(){let{"*":e}=Ze(),t=qe(),n=(0,g.useRef)(null),[r,i]=(0,g.useState)(null),[a,o]=(0,g.useState)(!1),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useReducer)((e,t)=>{switch(t.type){case`fetch`:return{content:``,loading:!0,error:null};case`success`:return{content:t.content,loading:!1,error:null};case`error`:return{content:``,loading:!1,error:t.error};default:return e}},{content:``,loading:!0,error:null}),{content:d,loading:f,error:p}=l;(0,g.useEffect)(()=>{fetch(`/docs/_index.json`).then(e=>e.json()).then(i).catch(e=>u({type:`error`,error:`Failed to load docs index: ${e.message}`}))},[]);let m=(0,g.useMemo)(()=>r?r.sections.flatMap(e=>e.pages):[],[r]),h=e||m[0]?.slug;(0,g.useEffect)(()=>{!e&&m.length>0&&t(`/docs/${m[0].slug}`,{replace:!0})},[e,m,t]);let _=(0,g.useMemo)(()=>m.find(e=>e.slug===h),[m,h]),v=m.indexOf(_),y=v>0?m[v-1]:null,b=v<m.length-1?m[v+1]:null,x=(0,g.useMemo)(()=>!r||!_?null:r.sections.find(e=>e.pages.some(e=>e.slug===h)),[r,_,h]);(0,g.useEffect)(()=>{if(!_)return;let e=!1;return u({type:`fetch`}),fetch(`/docs/${_.file}`).then(e=>{if(!e.ok)throw Error(`Document not found (${e.status})`);return e.text()}).then(t=>{e||u({type:`success`,content:t})}).catch(t=>{e||u({type:`error`,error:t.message})}),()=>{e=!0}},[_]),(0,g.useEffect)(()=>{n.current?.scrollTo(0,0)},[h]);let S=(0,g.useMemo)(()=>u_(d),[d]),C=(0,g.useMemo)(()=>d?Xh.parse(d):``,[d]),w=(0,g.useCallback)(()=>{if(!n.current)return;let e=n.current.querySelectorAll(`h2[id], h3[id]`),t=``;for(let n of e)n.getBoundingClientRect().top<=100&&(t=n.id);c(t)},[]);return(0,g.useEffect)(()=>{let e=n.current;if(e)return e.addEventListener(`scroll`,w),()=>e.removeEventListener(`scroll`,w)},[w]),r?(0,A.jsxs)(`div`,{className:`flex h-screen bg-zinc-950`,children:[(0,A.jsx)(d_,{index:r,currentSlug:h,sidebarOpen:a,onClose:()=>o(!1)}),(0,A.jsxs)(`div`,{ref:n,className:`flex-1 overflow-y-auto`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`sticky top-4 left-4 z-40 rounded-md bg-zinc-900 border border-zinc-800 p-2 text-zinc-400 hover:text-zinc-100 lg:hidden m-4`,"aria-label":`Open docs navigation`,children:(0,A.jsx)(ia,{className:`h-4 w-4`})}),(0,A.jsxs)(`div`,{className:`flex gap-8 max-w-5xl mx-auto px-6 py-8 lg:px-8`,children:[(0,A.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[x&&_&&(0,A.jsxs)(`div`,{className:`mb-6 flex items-center gap-2 text-xs text-zinc-500`,children:[(0,A.jsx)(It,{to:`/docs`,className:`hover:text-zinc-300`,children:`Docs`}),(0,A.jsx)(yi,{size:10}),(0,A.jsx)(`span`,{children:x.title}),(0,A.jsx)(yi,{size:10}),(0,A.jsx)(`span`,{className:`text-zinc-400`,children:_.title})]}),f&&(0,A.jsx)(`div`,{className:`text-zinc-500 text-sm py-12`,children:`Loading...`}),p&&(0,A.jsxs)(`div`,{className:`rounded-lg border border-yellow-500/20 bg-yellow-500/5 p-6 text-sm text-yellow-400`,children:[(0,A.jsx)(`p`,{className:`font-semibold mb-2`,children:`Page Not Available`}),(0,A.jsx)(`p`,{className:`text-yellow-500/80`,children:p}),(0,A.jsx)(It,{to:`/docs/what-is-lamaste`,className:`mt-4 inline-block text-cyan-400 hover:underline`,children:`Go to Introduction`})]}),!f&&!p&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`article`,{className:`prose prose-invert prose-zinc max-w-none
75
+ prose-headings:font-mono prose-headings:scroll-mt-20
76
+ prose-a:text-cyan-400 prose-a:no-underline hover:prose-a:underline
77
+ prose-code:text-cyan-300 prose-code:before:content-none prose-code:after:content-none
78
+ prose-code:rounded prose-code:bg-zinc-800 prose-code:px-1.5 prose-code:py-0.5
79
+ prose-pre:bg-zinc-900 prose-pre:border prose-pre:border-zinc-800
80
+ prose-blockquote:border-cyan-400/30 prose-blockquote:text-zinc-400
81
+ prose-strong:text-zinc-200
82
+ prose-th:text-zinc-300 prose-td:text-zinc-400
83
+ prose-hr:border-zinc-800
84
+ prose-img:rounded-lg`,dangerouslySetInnerHTML:{__html:s_.sanitize(C)}}),(0,A.jsx)(m_,{prevPage:y,nextPage:b})]})]}),(0,A.jsx)(p_,{toc:S,activeId:s})]})]})]}):(0,A.jsx)(`div`,{className:`flex h-screen items-center justify-center bg-zinc-950`,children:(0,A.jsx)(`div`,{className:`text-zinc-500 text-sm`,children:`Loading documentation...`})})}var g_=new er({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}});function __(){let{status:e,domain:t,isLoading:n,isError:r,refetch:i}=$r(),a=qe();return n?(0,A.jsx)(Zp,{}):r?(0,A.jsx)(Qp,{onRetry:i}):e===`COMPLETED`?(0,A.jsx)(xt,{children:(0,A.jsxs)(yt,{element:(0,A.jsx)(Xp,{}),children:[(0,A.jsx)(yt,{path:`/`,element:(0,A.jsx)(ko,{})}),(0,A.jsx)(yt,{path:`/tunnels`,element:(0,A.jsx)(_p,{})}),(0,A.jsx)(yt,{path:`/sites`,element:(0,A.jsx)(fl,{domain:t,onOpenPlugin:e=>a(`/plugins#${encodeURIComponent(jc(e))}`)})}),(0,A.jsx)(yt,{path:`/users`,element:(0,A.jsx)(Cu,{})}),(0,A.jsx)(yt,{path:`/domains`,element:(0,A.jsx)(Pp,{})}),(0,A.jsx)(yt,{path:`/certificates`,element:(0,A.jsx)(Ku,{})}),(0,A.jsx)(yt,{path:`/services`,element:(0,A.jsx)(Fo,{})}),(0,A.jsx)(yt,{path:`/tickets`,element:(0,A.jsx)(nd,{})}),(0,A.jsx)(yt,{path:`/plugins`,element:(0,A.jsx)(Qf,{})}),(0,A.jsx)(yt,{path:`/storage`,element:(0,A.jsx)(xp,{})}),(0,A.jsx)(yt,{path:`/audit`,element:(0,A.jsx)(Ep,{})}),(0,A.jsx)(yt,{path:`/plugins/:pluginName/*`,element:(0,A.jsx)(bm,{})}),(0,A.jsx)(yt,{path:`/settings`,element:(0,A.jsx)(vp,{hasDomain:!!t})}),(0,A.jsx)(yt,{path:`/docs/*`,element:(0,A.jsx)(h_,{})})]})}):(0,A.jsx)(ym,{})}function v_(){return(0,A.jsx)(rr,{client:g_,children:(0,A.jsx)(ti,{client:Hp,children:(0,A.jsx)($a,{children:(0,A.jsx)(uo,{children:(0,A.jsx)(Xa,{children:(0,A.jsx)(Nt,{children:(0,A.jsx)(__,{})})})})})})})}_.createRoot(document.getElementById(`root`)).render((0,A.jsx)(g.StrictMode,{children:(0,A.jsx)(v_,{})}));