@waiaas/daemon 2.9.0-rc.8 → 2.9.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 (60) hide show
  1. package/dist/api/routes/admin.d.ts.map +1 -1
  2. package/dist/api/routes/admin.js +14 -6
  3. package/dist/api/routes/admin.js.map +1 -1
  4. package/dist/api/routes/openapi-schemas.d.ts +91 -0
  5. package/dist/api/routes/openapi-schemas.d.ts.map +1 -1
  6. package/dist/api/routes/openapi-schemas.js +20 -2
  7. package/dist/api/routes/openapi-schemas.js.map +1 -1
  8. package/dist/api/routes/wallet-apps.d.ts +2 -0
  9. package/dist/api/routes/wallet-apps.d.ts.map +1 -1
  10. package/dist/api/routes/wallet-apps.js +95 -2
  11. package/dist/api/routes/wallet-apps.js.map +1 -1
  12. package/dist/api/server.d.ts.map +1 -1
  13. package/dist/api/server.js +1 -0
  14. package/dist/api/server.js.map +1 -1
  15. package/dist/infrastructure/database/migrate.d.ts +1 -1
  16. package/dist/infrastructure/database/migrate.d.ts.map +1 -1
  17. package/dist/infrastructure/database/migrate.js +59 -2
  18. package/dist/infrastructure/database/migrate.js.map +1 -1
  19. package/dist/infrastructure/database/schema.d.ts +76 -0
  20. package/dist/infrastructure/database/schema.d.ts.map +1 -1
  21. package/dist/infrastructure/database/schema.js +4 -0
  22. package/dist/infrastructure/database/schema.js.map +1 -1
  23. package/dist/infrastructure/settings/hot-reload.d.ts.map +1 -1
  24. package/dist/infrastructure/settings/hot-reload.js +5 -10
  25. package/dist/infrastructure/settings/hot-reload.js.map +1 -1
  26. package/dist/infrastructure/settings/setting-keys.js +1 -1
  27. package/dist/infrastructure/settings/setting-keys.js.map +1 -1
  28. package/dist/lifecycle/daemon.d.ts.map +1 -1
  29. package/dist/lifecycle/daemon.js +6 -15
  30. package/dist/lifecycle/daemon.js.map +1 -1
  31. package/dist/notifications/notification-service.d.ts.map +1 -1
  32. package/dist/notifications/notification-service.js +18 -1
  33. package/dist/notifications/notification-service.js.map +1 -1
  34. package/dist/pipeline/stages.d.ts.map +1 -1
  35. package/dist/pipeline/stages.js +28 -16
  36. package/dist/pipeline/stages.js.map +1 -1
  37. package/dist/services/signing-sdk/approval-channel-router.d.ts.map +1 -1
  38. package/dist/services/signing-sdk/approval-channel-router.js +8 -4
  39. package/dist/services/signing-sdk/approval-channel-router.js.map +1 -1
  40. package/dist/services/signing-sdk/channels/wallet-notification-channel.d.ts +1 -1
  41. package/dist/services/signing-sdk/channels/wallet-notification-channel.d.ts.map +1 -1
  42. package/dist/services/signing-sdk/channels/wallet-notification-channel.js +27 -19
  43. package/dist/services/signing-sdk/channels/wallet-notification-channel.js.map +1 -1
  44. package/dist/services/signing-sdk/preset-auto-setup.js +1 -1
  45. package/dist/services/signing-sdk/preset-auto-setup.js.map +1 -1
  46. package/dist/services/signing-sdk/sign-request-builder.d.ts +3 -0
  47. package/dist/services/signing-sdk/sign-request-builder.d.ts.map +1 -1
  48. package/dist/services/signing-sdk/sign-request-builder.js +19 -4
  49. package/dist/services/signing-sdk/sign-request-builder.js.map +1 -1
  50. package/dist/services/signing-sdk/wallet-app-service.d.ts +24 -4
  51. package/dist/services/signing-sdk/wallet-app-service.d.ts.map +1 -1
  52. package/dist/services/signing-sdk/wallet-app-service.js +51 -15
  53. package/dist/services/signing-sdk/wallet-app-service.js.map +1 -1
  54. package/dist/services/wc-signing-bridge.d.ts.map +1 -1
  55. package/dist/services/wc-signing-bridge.js +1 -1
  56. package/dist/services/wc-signing-bridge.js.map +1 -1
  57. package/package.json +5 -5
  58. package/public/admin/assets/index-CBU6NfOH.js +3 -0
  59. package/public/admin/index.html +1 -1
  60. package/public/admin/assets/index-EhxXoWGy.js +0 -1
@@ -0,0 +1,3 @@
1
+ var Ua,Q,tn,nn,Ke,Tt,ln,sn,rn,ht,st,rt,ma={},on=[],Qn=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,$a=Array.isArray;function Ae(t,a){for(var n in a)t[n]=a[n];return t}function pt(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function el(t,a,n){var l,i,s,r={};for(s in a)s=="key"?l=a[s]:s=="ref"?i=a[s]:r[s]=a[s];if(arguments.length>2&&(r.children=arguments.length>3?Ua.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(s in t.defaultProps)r[s]===void 0&&(r[s]=t.defaultProps[s]);return xa(t,r,l,i,null)}function xa(t,a,n,l,i){var s={type:t,props:a,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++tn,__i:-1,__u:0};return i==null&&Q.vnode!=null&&Q.vnode(s),s}function J(t){return t.children}function ua(t,a){this.props=t,this.context=a}function Qe(t,a){if(a==null)return t.__?Qe(t.__,t.__i+1):null;for(var n;a<t.__k.length;a++)if((n=t.__k[a])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?Qe(t):null}function cn(t){var a,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,a=0;a<t.__k.length;a++)if((n=t.__k[a])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return cn(t)}}function kt(t){(!t.__d&&(t.__d=!0)&&Ke.push(t)&&!La.__r++||Tt!=Q.debounceRendering)&&((Tt=Q.debounceRendering)||ln)(La)}function La(){for(var t,a,n,l,i,s,r,c=1;Ke.length;)Ke.length>c&&Ke.sort(sn),t=Ke.shift(),c=Ke.length,t.__d&&(n=void 0,l=void 0,i=(l=(a=t).__v).__e,s=[],r=[],a.__P&&((n=Ae({},l)).__v=l.__v+1,Q.vnode&&Q.vnode(n),mt(a.__P,n,l,a.__n,a.__P.namespaceURI,32&l.__u?[i]:null,s,i??Qe(l),!!(32&l.__u),r),n.__v=l.__v,n.__.__k[n.__i]=n,vn(s,n,r),l.__e=l.__=null,n.__e!=i&&cn(n)));La.__r=0}function dn(t,a,n,l,i,s,r,c,h,o,v){var u,f,A,D,x,g,_,U=l&&l.__k||on,F=a.length;for(h=al(n,a,U,h,F),u=0;u<F;u++)(A=n.__k[u])!=null&&(f=A.__i==-1?ma:U[A.__i]||ma,A.__i=u,g=mt(t,A,f,i,s,r,c,h,o,v),D=A.__e,A.ref&&f.ref!=A.ref&&(f.ref&&ft(f.ref,null,A),v.push(A.ref,A.__c||D,A)),x==null&&D!=null&&(x=D),(_=!!(4&A.__u))||f.__k===A.__k?h=un(A,h,t,_):typeof A.type=="function"&&g!==void 0?h=g:D&&(h=D.nextSibling),A.__u&=-7);return n.__e=x,h}function al(t,a,n,l,i){var s,r,c,h,o,v=n.length,u=v,f=0;for(t.__k=new Array(i),s=0;s<i;s++)(r=a[s])!=null&&typeof r!="boolean"&&typeof r!="function"?(typeof r=="string"||typeof r=="number"||typeof r=="bigint"||r.constructor==String?r=t.__k[s]=xa(null,r,null,null,null):$a(r)?r=t.__k[s]=xa(J,{children:r},null,null,null):r.constructor===void 0&&r.__b>0?r=t.__k[s]=xa(r.type,r.props,r.key,r.ref?r.ref:null,r.__v):t.__k[s]=r,h=s+f,r.__=t,r.__b=t.__b+1,c=null,(o=r.__i=tl(r,n,h,u))!=-1&&(u--,(c=n[o])&&(c.__u|=2)),c==null||c.__v==null?(o==-1&&(i>v?f--:i<v&&f++),typeof r.type!="function"&&(r.__u|=4)):o!=h&&(o==h-1?f--:o==h+1?f++:(o>h?f--:f++,r.__u|=4))):t.__k[s]=null;if(u)for(s=0;s<v;s++)(c=n[s])!=null&&(2&c.__u)==0&&(c.__e==l&&(l=Qe(c)),pn(c,c));return l}function un(t,a,n,l){var i,s;if(typeof t.type=="function"){for(i=t.__k,s=0;i&&s<i.length;s++)i[s]&&(i[s].__=t,a=un(i[s],a,n,l));return a}t.__e!=a&&(l&&(a&&t.type&&!a.parentNode&&(a=Qe(t)),n.insertBefore(t.__e,a||null)),a=t.__e);do a=a&&a.nextSibling;while(a!=null&&a.nodeType==8);return a}function tl(t,a,n,l){var i,s,r,c=t.key,h=t.type,o=a[n],v=o!=null&&(2&o.__u)==0;if(o===null&&c==null||v&&c==o.key&&h==o.type)return n;if(l>(v?1:0)){for(i=n-1,s=n+1;i>=0||s<a.length;)if((o=a[r=i>=0?i--:s++])!=null&&(2&o.__u)==0&&c==o.key&&h==o.type)return r}return-1}function Nt(t,a,n){a[0]=="-"?t.setProperty(a,n??""):t[a]=n==null?"":typeof n!="number"||Qn.test(a)?n:n+"px"}function Ta(t,a,n,l,i){var s,r;e:if(a=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof l=="string"&&(t.style.cssText=l=""),l)for(a in l)n&&a in n||Nt(t.style,a,"");if(n)for(a in n)l&&n[a]==l[a]||Nt(t.style,a,n[a])}else if(a[0]=="o"&&a[1]=="n")s=a!=(a=a.replace(rn,"$1")),r=a.toLowerCase(),a=r in t||a=="onFocusOut"||a=="onFocusIn"?r.slice(2):a.slice(2),t.l||(t.l={}),t.l[a+s]=n,n?l?n.u=l.u:(n.u=ht,t.addEventListener(a,s?rt:st,s)):t.removeEventListener(a,s?rt:st,s);else{if(i=="http://www.w3.org/2000/svg")a=a.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(a!="width"&&a!="height"&&a!="href"&&a!="list"&&a!="form"&&a!="tabIndex"&&a!="download"&&a!="rowSpan"&&a!="colSpan"&&a!="role"&&a!="popover"&&a in t)try{t[a]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&a[4]!="-"?t.removeAttribute(a):t.setAttribute(a,a=="popover"&&n==1?"":n))}}function At(t){return function(a){if(this.l){var n=this.l[a.type+t];if(a.t==null)a.t=ht++;else if(a.t<n.u)return;return n(Q.event?Q.event(a):a)}}}function mt(t,a,n,l,i,s,r,c,h,o){var v,u,f,A,D,x,g,_,U,F,E,K,C,T,m,S,P,y=a.type;if(a.constructor!==void 0)return null;128&n.__u&&(h=!!(32&n.__u),s=[c=a.__e=n.__e]),(v=Q.__b)&&v(a);e:if(typeof y=="function")try{if(_=a.props,U="prototype"in y&&y.prototype.render,F=(v=y.contextType)&&l[v.__c],E=v?F?F.props.value:v.__:l,n.__c?g=(u=a.__c=n.__c).__=u.__E:(U?a.__c=u=new y(_,E):(a.__c=u=new ua(_,E),u.constructor=y,u.render=ll),F&&F.sub(u),u.state||(u.state={}),u.__n=l,f=u.__d=!0,u.__h=[],u._sb=[]),U&&u.__s==null&&(u.__s=u.state),U&&y.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=Ae({},u.__s)),Ae(u.__s,y.getDerivedStateFromProps(_,u.__s))),A=u.props,D=u.state,u.__v=a,f)U&&y.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),U&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(U&&y.getDerivedStateFromProps==null&&_!==A&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(_,E),a.__v==n.__v||!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(_,u.__s,E)===!1){for(a.__v!=n.__v&&(u.props=_,u.state=u.__s,u.__d=!1),a.__e=n.__e,a.__k=n.__k,a.__k.some(function(p){p&&(p.__=a)}),K=0;K<u._sb.length;K++)u.__h.push(u._sb[K]);u._sb=[],u.__h.length&&r.push(u);break e}u.componentWillUpdate!=null&&u.componentWillUpdate(_,u.__s,E),U&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(A,D,x)})}if(u.context=E,u.props=_,u.__P=t,u.__e=!1,C=Q.__r,T=0,U){for(u.state=u.__s,u.__d=!1,C&&C(a),v=u.render(u.props,u.state,u.context),m=0;m<u._sb.length;m++)u.__h.push(u._sb[m]);u._sb=[]}else do u.__d=!1,C&&C(a),v=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++T<25);u.state=u.__s,u.getChildContext!=null&&(l=Ae(Ae({},l),u.getChildContext())),U&&!f&&u.getSnapshotBeforeUpdate!=null&&(x=u.getSnapshotBeforeUpdate(A,D)),S=v,v!=null&&v.type===J&&v.key==null&&(S=hn(v.props.children)),c=dn(t,$a(S)?S:[S],a,n,l,i,s,r,c,h,o),u.base=a.__e,a.__u&=-161,u.__h.length&&r.push(u),g&&(u.__E=u.__=null)}catch(p){if(a.__v=null,h||s!=null)if(p.then){for(a.__u|=h?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;s[s.indexOf(c)]=null,a.__e=c}else{for(P=s.length;P--;)pt(s[P]);ot(a)}else a.__e=n.__e,a.__k=n.__k,p.then||ot(a);Q.__e(p,a,n)}else s==null&&a.__v==n.__v?(a.__k=n.__k,a.__e=n.__e):c=a.__e=nl(n.__e,a,n,l,i,s,r,h,o);return(v=Q.diffed)&&v(a),128&a.__u?void 0:c}function ot(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(ot)}function vn(t,a,n){for(var l=0;l<n.length;l++)ft(n[l],n[++l],n[++l]);Q.__c&&Q.__c(a,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(s){s.call(i)})}catch(s){Q.__e(s,i.__v)}})}function hn(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:$a(t)?t.map(hn):Ae({},t)}function nl(t,a,n,l,i,s,r,c,h){var o,v,u,f,A,D,x,g=n.props||ma,_=a.props,U=a.type;if(U=="svg"?i="http://www.w3.org/2000/svg":U=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),s!=null){for(o=0;o<s.length;o++)if((A=s[o])&&"setAttribute"in A==!!U&&(U?A.localName==U:A.nodeType==3)){t=A,s[o]=null;break}}if(t==null){if(U==null)return document.createTextNode(_);t=document.createElementNS(i,U,_.is&&_),c&&(Q.__m&&Q.__m(a,s),c=!1),s=null}if(U==null)g===_||c&&t.data==_||(t.data=_);else{if(s=s&&Ua.call(t.childNodes),!c&&s!=null)for(g={},o=0;o<t.attributes.length;o++)g[(A=t.attributes[o]).name]=A.value;for(o in g)if(A=g[o],o!="children"){if(o=="dangerouslySetInnerHTML")u=A;else if(!(o in _)){if(o=="value"&&"defaultValue"in _||o=="checked"&&"defaultChecked"in _)continue;Ta(t,o,null,A,i)}}for(o in _)A=_[o],o=="children"?f=A:o=="dangerouslySetInnerHTML"?v=A:o=="value"?D=A:o=="checked"?x=A:c&&typeof A!="function"||g[o]===A||Ta(t,o,A,g[o],i);if(v)c||u&&(v.__html==u.__html||v.__html==t.innerHTML)||(t.innerHTML=v.__html),a.__k=[];else if(u&&(t.innerHTML=""),dn(a.type=="template"?t.content:t,$a(f)?f:[f],a,n,l,U=="foreignObject"?"http://www.w3.org/1999/xhtml":i,s,r,s?s[0]:n.__k&&Qe(n,0),c,h),s!=null)for(o=s.length;o--;)pt(s[o]);c||(o="value",U=="progress"&&D==null?t.removeAttribute("value"):D!=null&&(D!==t[o]||U=="progress"&&!D||U=="option"&&D!=g[o])&&Ta(t,o,D,g[o],i),o="checked",x!=null&&x!=t[o]&&Ta(t,o,x,g[o],i))}return t}function ft(t,a,n){try{if(typeof t=="function"){var l=typeof t.__u=="function";l&&t.__u(),l&&a==null||(t.__u=t(a))}else t.current=a}catch(i){Q.__e(i,n)}}function pn(t,a,n){var l,i;if(Q.unmount&&Q.unmount(t),(l=t.ref)&&(l.current&&l.current!=t.__e||ft(l,null,a)),(l=t.__c)!=null){if(l.componentWillUnmount)try{l.componentWillUnmount()}catch(s){Q.__e(s,a)}l.base=l.__P=null}if(l=t.__k)for(i=0;i<l.length;i++)l[i]&&pn(l[i],a,n||typeof t.type!="function");n||pt(t.__e),t.__c=t.__=t.__e=void 0}function ll(t,a,n){return this.constructor(t,n)}function il(t,a,n){var l,i,s,r;a==document&&(a=document.documentElement),Q.__&&Q.__(t,a),i=(l=!1)?null:a.__k,s=[],r=[],mt(a,t=a.__k=el(J,null,[t]),i||ma,ma,a.namespaceURI,i?null:a.firstChild?Ua.call(a.childNodes):null,s,i?i.__e:a.firstChild,l,r),vn(s,t,r)}Ua=on.slice,Q={__e:function(t,a,n,l){for(var i,s,r;a=a.__;)if((i=a.__c)&&!i.__)try{if((s=i.constructor)&&s.getDerivedStateFromError!=null&&(i.setState(s.getDerivedStateFromError(t)),r=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,l||{}),r=i.__d),r)return i.__E=i}catch(c){t=c}throw t}},tn=0,nn=function(t){return t!=null&&t.constructor===void 0},ua.prototype.setState=function(t,a){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Ae({},this.state),typeof t=="function"&&(t=t(Ae({},n),this.props)),t&&Ae(n,t),t!=null&&this.__v&&(a&&this._sb.push(a),kt(this))},ua.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),kt(this))},ua.prototype.render=J,Ke=[],ln=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,sn=function(t,a){return t.__v.__b-a.__v.__b},La.__r=0,rn=/(PointerCapture)$|Capture$/i,ht=0,st=At(!1),rt=At(!0);var sl=0;function e(t,a,n,l,i,s){a||(a={});var r,c,h=a;if("ref"in h)for(c in h={},a)c=="ref"?r=a[c]:h[c]=a[c];var o={type:t,props:h,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--sl,__i:-1,__u:0,__source:i,__self:s};if(typeof t=="function"&&(r=t.defaultProps))for(c in r)h[c]===void 0&&(h[c]=r[c]);return Q.vnode&&Q.vnode(o),o}var Ra,ye,Ya,Et,ct=0,mn=[],de=Q,Ct=de.__b,It=de.__r,Dt=de.diffed,xt=de.__c,Ot=de.unmount,Lt=de.__;function fn(t,a){de.__h&&de.__h(ye,t,ct||a),ct=0;var n=ye.__H||(ye.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function B(t,a){var n=fn(Ra++,3);!de.__s&&gn(n.__H,a)&&(n.__=t,n.u=a,ye.__H.__h.push(n))}function _a(t){return ct=5,Fa(function(){return{current:t}},[])}function Fa(t,a){var n=fn(Ra++,7);return gn(n.__H,a)&&(n.__=t(),n.__H=a,n.__h=t),n.__}function rl(){for(var t;t=mn.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(Oa),t.__H.__h.forEach(dt),t.__H.__h=[]}catch(a){t.__H.__h=[],de.__e(a,t.__v)}}de.__b=function(t){ye=null,Ct&&Ct(t)},de.__=function(t,a){t&&a.__k&&a.__k.__m&&(t.__m=a.__k.__m),Lt&&Lt(t,a)},de.__r=function(t){It&&It(t),Ra=0;var a=(ye=t.__c).__H;a&&(Ya===ye?(a.__h=[],ye.__h=[],a.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(a.__h.forEach(Oa),a.__h.forEach(dt),a.__h=[],Ra=0)),Ya=ye},de.diffed=function(t){Dt&&Dt(t);var a=t.__c;a&&a.__H&&(a.__H.__h.length&&(mn.push(a)!==1&&Et===de.requestAnimationFrame||((Et=de.requestAnimationFrame)||ol)(rl)),a.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Ya=ye=null},de.__c=function(t,a){a.some(function(n){try{n.__h.forEach(Oa),n.__h=n.__h.filter(function(l){return!l.__||dt(l)})}catch(l){a.some(function(i){i.__h&&(i.__h=[])}),a=[],de.__e(l,n.__v)}}),xt&&xt(t,a)},de.unmount=function(t){Ot&&Ot(t);var a,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(l){try{Oa(l)}catch(i){a=i}}),n.__H=void 0,a&&de.__e(a,n.__v))};var Rt=typeof requestAnimationFrame=="function";function ol(t){var a,n=function(){clearTimeout(l),Rt&&cancelAnimationFrame(a),setTimeout(t)},l=setTimeout(n,35);Rt&&(a=requestAnimationFrame(n))}function Oa(t){var a=ye,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),ye=a}function dt(t){var a=ye;t.__c=t.__(),ye=a}function gn(t,a){return!t||t.length!==a.length||a.some(function(n,l){return n!==t[l]})}var cl=Symbol.for("preact-signals");function Ka(){if(Pe>1)Pe--;else{for(var t,a=!1;va!==void 0;){var n=va;for(va=void 0,ut++;n!==void 0;){var l=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&bn(n))try{n.c()}catch(i){a||(t=i,a=!0)}n=l}}if(ut=0,Pe--,a)throw t}}function dl(t){if(Pe>0)return t();Pe++;try{return t()}finally{Ka()}}var Z=void 0;function yn(t){var a=Z;Z=void 0;try{return t()}finally{Z=a}}var va=void 0,Pe=0,ut=0,Pa=0;function _n(t){if(Z!==void 0){var a=t.n;if(a===void 0||a.t!==Z)return a={i:0,S:t,p:Z.s,n:void 0,t:Z,e:void 0,x:void 0,r:a},Z.s!==void 0&&(Z.s.n=a),Z.s=a,t.n=a,32&Z.f&&t.S(a),a;if(a.i===-1)return a.i=0,a.n!==void 0&&(a.n.p=a.p,a.p!==void 0&&(a.p.n=a.n),a.p=Z.s,a.n=void 0,Z.s.n=a,Z.s=a),a}}function he(t,a){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=a?.watched,this.Z=a?.unwatched,this.name=a?.name}he.prototype.brand=cl;he.prototype.h=function(){return!0};he.prototype.S=function(t){var a=this,n=this.t;n!==t&&t.e===void 0&&(t.x=n,this.t=t,n!==void 0?n.e=t:yn(function(){var l;(l=a.W)==null||l.call(a)}))};he.prototype.U=function(t){var a=this;if(this.t!==void 0){var n=t.e,l=t.x;n!==void 0&&(n.x=l,t.e=void 0),l!==void 0&&(l.e=n,t.x=void 0),t===this.t&&(this.t=l,l===void 0&&yn(function(){var i;(i=a.Z)==null||i.call(a)}))}};he.prototype.subscribe=function(t){var a=this;return ba(function(){var n=a.value,l=Z;Z=void 0;try{t(n)}finally{Z=l}},{name:"sub"})};he.prototype.valueOf=function(){return this.value};he.prototype.toString=function(){return this.value+""};he.prototype.toJSON=function(){return this.value};he.prototype.peek=function(){var t=Z;Z=void 0;try{return this.value}finally{Z=t}};Object.defineProperty(he.prototype,"value",{get:function(){var t=_n(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(ut>100)throw new Error("Cycle detected");this.v=t,this.i++,Pa++,Pe++;try{for(var a=this.t;a!==void 0;a=a.x)a.t.N()}finally{Ka()}}}});function pe(t,a){return new he(t,a)}function bn(t){for(var a=t.s;a!==void 0;a=a.n)if(a.S.i!==a.i||!a.S.h()||a.S.i!==a.i)return!0;return!1}function wn(t){for(var a=t.s;a!==void 0;a=a.n){var n=a.S.n;if(n!==void 0&&(a.r=n),a.S.n=a,a.i=-1,a.n===void 0){t.s=a;break}}}function Sn(t){for(var a=t.s,n=void 0;a!==void 0;){var l=a.p;a.i===-1?(a.S.U(a),l!==void 0&&(l.n=a.n),a.n!==void 0&&(a.n.p=l)):n=a,a.S.n=a.r,a.r!==void 0&&(a.r=void 0),a=l}t.s=n}function ze(t,a){he.call(this,void 0),this.x=t,this.s=void 0,this.g=Pa-1,this.f=4,this.W=a?.watched,this.Z=a?.unwatched,this.name=a?.name}ze.prototype=new he;ze.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Pa))return!0;if(this.g=Pa,this.f|=1,this.i>0&&!bn(this))return this.f&=-2,!0;var t=Z;try{wn(this),Z=this;var a=this.x();(16&this.f||this.v!==a||this.i===0)&&(this.v=a,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return Z=t,Sn(this),this.f&=-2,!0};ze.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var a=this.s;a!==void 0;a=a.n)a.S.S(a)}he.prototype.S.call(this,t)};ze.prototype.U=function(t){if(this.t!==void 0&&(he.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var a=this.s;a!==void 0;a=a.n)a.S.U(a)}};ze.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}};Object.defineProperty(ze.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=_n(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function fa(t,a){return new ze(t,a)}function Tn(t){var a=t.u;if(t.u=void 0,typeof a=="function"){Pe++;var n=Z;Z=void 0;try{a()}catch(l){throw t.f&=-2,t.f|=8,gt(t),l}finally{Z=n,Ka()}}}function gt(t){for(var a=t.s;a!==void 0;a=a.n)a.S.U(a);t.x=void 0,t.s=void 0,Tn(t)}function ul(t){if(Z!==this)throw new Error("Out-of-order effect");Sn(this),Z=t,this.f&=-2,8&this.f&&gt(this),Ka()}function aa(t,a){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=a?.name}aa.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var a=this.x();typeof a=="function"&&(this.u=a)}finally{t()}};aa.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Tn(this),wn(this),Pe++;var t=Z;return Z=this,ul.bind(this,t)};aa.prototype.N=function(){2&this.f||(this.f|=2,this.o=va,va=this)};aa.prototype.d=function(){this.f|=8,1&this.f||gt(this)};aa.prototype.dispose=function(){this.d()};function ba(t,a){var n=new aa(t,a);try{n.c()}catch(i){throw n.d(),i}var l=n.d.bind(n);return l[Symbol.dispose]=l,l}var kn,Ha,ka,vl=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__,Nn=[];ba(function(){kn=this.N})();function ta(t,a){Q[t]=a.bind(null,Q[t]||function(){})}function Ma(t){if(ka){var a=ka;ka=void 0,a()}ka=t&&t.S()}function An(t){var a=this,n=t.data,l=d(n);l.value=n;var i=Fa(function(){for(var c=a,h=a.__v;h=h.__;)if(h.__c){h.__c.__$f|=4;break}var o=fa(function(){var A=l.value.value;return A===0?0:A===!0?"":A||""}),v=fa(function(){return!Array.isArray(o.value)&&!nn(o.value)}),u=ba(function(){if(this.N=En,v.value){var A=o.value;c.__v&&c.__v.__e&&c.__v.__e.nodeType===3&&(c.__v.__e.data=A)}}),f=a.__$u.d;return a.__$u.d=function(){u(),f.call(this)},[v,o]},[]),s=i[0],r=i[1];return s.value?r.peek():r.value}An.displayName="ReactiveTextNode";Object.defineProperties(he.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:An},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});ta("__b",function(t,a){if(typeof a.type=="string"){var n,l=a.props;for(var i in l)if(i!=="children"){var s=l[i];s instanceof he&&(n||(a.__np=n={}),n[i]=s,l[i]=s.peek())}}t(a)});ta("__r",function(t,a){if(t(a),a.type!==J){Ma();var n,l=a.__c;l&&(l.__$f&=-2,(n=l.__$u)===void 0&&(l.__$u=n=(function(i,s){var r;return ba(function(){r=this},{name:s}),r.c=i,r})(function(){var i;vl&&((i=n.y)==null||i.call(n)),l.__$f|=1,l.setState({})},typeof a.type=="function"?a.type.displayName||a.type.name:""))),Ha=l,Ma(n)}});ta("__e",function(t,a,n,l){Ma(),Ha=void 0,t(a,n,l)});ta("diffed",function(t,a){Ma(),Ha=void 0;var n;if(typeof a.type=="string"&&(n=a.__e)){var l=a.__np,i=a.props;if(l){var s=n.U;if(s)for(var r in s){var c=s[r];c!==void 0&&!(r in l)&&(c.d(),s[r]=void 0)}else s={},n.U=s;for(var h in l){var o=s[h],v=l[h];o===void 0?(o=hl(n,h,v,i),s[h]=o):o.o(v,i)}}}t(a)});function hl(t,a,n,l){var i=a in t&&t.ownerSVGElement===void 0,s=pe(n);return{o:function(r,c){s.value=r,l=c},d:ba(function(){this.N=En;var r=s.value.value;l[a]!==r&&(l[a]=r,i?t[a]=r:r!=null&&(r!==!1||a[4]==="-")?t.setAttribute(a,r):t.removeAttribute(a))})}}ta("unmount",function(t,a){if(typeof a.type=="string"){var n=a.__e;if(n){var l=n.U;if(l){n.U=void 0;for(var i in l){var s=l[i];s&&s.d()}}}}else{var r=a.__c;if(r){var c=r.__$u;c&&(r.__$u=void 0,c.d())}}t(a)});ta("__h",function(t,a,n,l){(l<3||l===9)&&(a.__$f|=2),t(a,n,l)});ua.prototype.shouldComponentUpdate=function(t,a){if(this.__R)return!0;var n=this.__$u,l=n&&n.s!==void 0;for(var i in a)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){var s=2&this.__$f;if(!(l||s||4&this.__$f)||1&this.__$f)return!0}else if(!(l||4&this.__$f)||3&this.__$f)return!0;for(var r in t)if(r!=="__source"&&t[r]!==this.props[r])return!0;for(var c in this.props)if(!(c in t))return!0;return!1};function d(t,a){return Fa(function(){return pe(t,a)},[])}function Ba(t,a){var n=_a(t);return n.current=t,Ha.__$f|=4,Fa(function(){return fa(function(){return n.current()},a)},[])}var pl=function(t){queueMicrotask(function(){queueMicrotask(t)})};function ml(){dl(function(){for(var t;t=Nn.shift();)kn.call(t)})}function En(){Nn.push(this)===1&&(Q.requestAnimationFrame||pl)(ml)}const ga=pe(null),fl=fa(()=>ga.value!==null),Cn=pe(900),gl=pe(!1);let Je=null;const Ze=()=>{yt()};function yl(){document.addEventListener("mousemove",Ze,{passive:!0}),document.addEventListener("keydown",Ze,{passive:!0}),document.addEventListener("click",Ze,{passive:!0}),yt()}function _l(){document.removeEventListener("mousemove",Ze),document.removeEventListener("keydown",Ze),document.removeEventListener("click",Ze),Je!==null&&(clearTimeout(Je),Je=null)}function yt(){Je!==null&&clearTimeout(Je),Je=setTimeout(()=>{Va()},Cn.value*1e3)}function bl(t,a){ga.value=t,a!==void 0&&(Cn.value=a),yl(),location.hash="#/dashboard"}function Va(){ga.value=null,_l(),location.hash="#/login"}const L={ADMIN_STATUS:"/v1/admin/status",ADMIN_KILL_SWITCH:"/v1/admin/kill-switch",ADMIN_KILL_SWITCH_ESCALATE:"/v1/admin/kill-switch/escalate",ADMIN_RECOVER:"/v1/admin/recover",ADMIN_SHUTDOWN:"/v1/admin/shutdown",ADMIN_ROTATE_SECRET:"/v1/admin/rotate-secret",WALLETS:"/v1/wallets",WALLET:t=>`/v1/wallets/${t}`,SESSIONS:"/v1/sessions",SESSION:t=>`/v1/sessions/${t}`,POLICIES:"/v1/policies",POLICY:t=>`/v1/policies/${t}`,TOKENS:"/v1/tokens",ADMIN_NOTIFICATIONS_STATUS:"/v1/admin/notifications/status",ADMIN_NOTIFICATIONS_TEST:"/v1/admin/notifications/test",ADMIN_NOTIFICATIONS_LOG:"/v1/admin/notifications/log",MCP_TOKENS:"/v1/mcp/tokens",ADMIN_SETTINGS:"/v1/admin/settings",ADMIN_SETTINGS_TEST_RPC:"/v1/admin/settings/test-rpc",ADMIN_RPC_STATUS:"/v1/admin/rpc-status",WALLET_NETWORKS:t=>`/v1/wallets/${t}/networks`,ADMIN_WALLET_BALANCE:t=>`/v1/admin/wallets/${t}/balance`,ADMIN_WALLET_TRANSACTIONS:t=>`/v1/admin/wallets/${t}/transactions`,ADMIN_API_KEYS:"/v1/admin/api-keys",ADMIN_API_KEY:t=>`/v1/admin/api-keys/${t}`,ADMIN_FOREX_RATES:"/v1/admin/forex/rates",ADMIN_TELEGRAM_USERS:"/v1/admin/telegram-users",ADMIN_TELEGRAM_USER:t=>`/v1/admin/telegram-users/${t}`,WALLET_OWNER:t=>`/v1/wallets/${t}/owner`,WALLET_WITHDRAW:t=>`/v1/wallets/${t}/withdraw`,WALLET_WC_PAIR:t=>`/v1/wallets/${t}/wc/pair`,WALLET_WC_SESSION:t=>`/v1/wallets/${t}/wc/session`,WALLET_WC_PAIR_STATUS:t=>`/v1/wallets/${t}/wc/pair/status`,WALLET_OWNER_VERIFY:t=>`/v1/wallets/${t}/owner/verify`,WALLET_SUSPEND:t=>`/v1/wallets/${t}/suspend`,WALLET_RESUME:t=>`/v1/wallets/${t}/resume`,ADMIN_AGENT_PROMPT:"/v1/admin/agent-prompt",ADMIN_SESSION_REISSUE:t=>`/v1/admin/sessions/${t}/reissue`,ADMIN_TRANSACTIONS:"/v1/admin/transactions",ADMIN_TX_CANCEL:t=>`/v1/admin/transactions/${t}/cancel`,ADMIN_TX_REJECT:t=>`/v1/admin/transactions/${t}/reject`,ADMIN_INCOMING:"/v1/admin/incoming",WALLET_PATCH:t=>`/v1/wallets/${t}`,TOKENS_RESOLVE:"/v1/tokens/resolve",ACTIONS_PROVIDERS:"/v1/actions/providers",ADMIN_WALLET_STAKING:t=>`/v1/admin/wallets/${t}/staking`,ADMIN_DEFI_POSITIONS:"/v1/admin/defi/positions",ADMIN_MASTER_PASSWORD:"/v1/admin/master-password",ADMIN_WALLET_APPS:"/v1/admin/wallet-apps",ADMIN_WALLET_APP:t=>`/v1/admin/wallet-apps/${t}`,ADMIN_WALLET_APP_TEST_NOTIFICATION:t=>`/v1/admin/wallet-apps/${t}/test-notification`},ha=pe(""),Xe=pe(null),pa=pe(!1),De={wrapper:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:"100vh",background:"var(--color-bg-secondary)"},card:{background:"var(--color-bg)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-lg)",padding:"var(--space-8)",width:"100%",maxWidth:"360px",boxShadow:"var(--shadow-md)"},title:{fontSize:"var(--font-size-2xl)",fontWeight:"var(--font-weight-bold)",textAlign:"center",marginBottom:"var(--space-1)"},subtitle:{fontSize:"var(--font-size-sm)",color:"var(--color-text-secondary)",textAlign:"center",marginBottom:"var(--space-6)"},input:{width:"100%",padding:"var(--space-2) var(--space-3)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",fontSize:"var(--font-size-base)",outline:"none"},button:{width:"100%",padding:"var(--space-2) var(--space-4)",background:"var(--color-primary)",color:"white",border:"none",borderRadius:"var(--radius-md)",fontSize:"var(--font-size-base)",fontWeight:"var(--font-weight-medium)",marginTop:"var(--space-4)"},buttonDisabled:{opacity:.6,cursor:"not-allowed"},error:{color:"var(--color-danger)",fontSize:"var(--font-size-sm)",textAlign:"center",marginTop:"var(--space-3)"}},wl=async t=>{if(t.preventDefault(),!!ha.value.trim()){pa.value=!0,Xe.value=null;try{const a=await fetch(L.ADMIN_STATUS,{headers:{"X-Master-Password":ha.value},signal:AbortSignal.timeout(1e4)});if(a.status===401){Xe.value="Invalid master password";return}if(!a.ok){Xe.value="Cannot connect to daemon";return}const n=await a.json();bl(ha.value,n.adminTimeout)}catch{Xe.value="Cannot connect to daemon"}finally{pa.value=!1}}};function Sl(){return e("div",{style:De.wrapper,children:e("form",{style:De.card,onSubmit:wl,children:[e("h1",{style:De.title,children:"WAIaaS Admin"}),e("p",{style:De.subtitle,children:"Enter master password to continue"}),e("input",{type:"password",placeholder:"Master password",autoFocus:!0,value:ha.value,onInput:t=>{ha.value=t.target.value},style:De.input}),e("button",{type:"submit",disabled:pa.value,style:{...De.button,...pa.value?De.buttonDisabled:{}},children:pa.value?"Signing in...":"Sign in"}),Xe.value&&e("p",{style:De.error,children:Xe.value})]})})}const Tl=[{id:"wallets.rpc.solana_mainnet",label:"Solana Mainnet",description:"RPC endpoint URL for Solana mainnet",page:"/wallets",tab:"rpc",fieldName:"rpc.solana_mainnet",keywords:["blockchain","rpc","solana","url","endpoint"]},{id:"wallets.rpc.solana_devnet",label:"Solana Devnet",description:"RPC endpoint URL for Solana devnet",page:"/wallets",tab:"rpc",fieldName:"rpc.solana_devnet",keywords:["blockchain","rpc","solana","url","endpoint","test"]},{id:"wallets.rpc.solana_testnet",label:"Solana Testnet",description:"RPC endpoint URL for Solana testnet",page:"/wallets",tab:"rpc",fieldName:"rpc.solana_testnet",keywords:["blockchain","rpc","solana","url","endpoint","test"]},{id:"wallets.rpc.evm_ethereum_mainnet",label:"Ethereum Mainnet",description:"RPC endpoint URL for Ethereum mainnet",page:"/wallets",tab:"rpc",fieldName:"rpc.evm_ethereum_mainnet",keywords:["blockchain","rpc","evm","ethereum","url","endpoint"]},{id:"wallets.rpc.evm_ethereum_sepolia",label:"Ethereum Sepolia",description:"RPC endpoint URL for Ethereum Sepolia testnet",page:"/wallets",tab:"rpc",fieldName:"rpc.evm_ethereum_sepolia",keywords:["blockchain","rpc","evm","ethereum","url","endpoint","test"]},{id:"wallets.rpc.evm_polygon_mainnet",label:"Polygon Mainnet",description:"RPC endpoint URL for Polygon mainnet",page:"/wallets",tab:"rpc",fieldName:"rpc.evm_polygon_mainnet",keywords:["blockchain","rpc","evm","polygon","matic","url","endpoint"]},{id:"wallets.rpc.evm_polygon_amoy",label:"Polygon Amoy",description:"RPC endpoint URL for Polygon Amoy testnet",page:"/wallets",tab:"rpc",fieldName:"rpc.evm_polygon_amoy",keywords:["blockchain","rpc","evm","polygon","url","endpoint","test"]},{id:"wallets.rpc.evm_arbitrum_mainnet",label:"Arbitrum Mainnet",description:"RPC endpoint URL for Arbitrum mainnet",page:"/wallets",tab:"rpc",fieldName:"rpc.evm_arbitrum_mainnet",keywords:["blockchain","rpc","evm","arbitrum","l2","url","endpoint"]},{id:"wallets.rpc.evm_arbitrum_sepolia",label:"Arbitrum Sepolia",description:"RPC endpoint URL for Arbitrum Sepolia testnet",page:"/wallets",tab:"rpc",fieldName:"rpc.evm_arbitrum_sepolia",keywords:["blockchain","rpc","evm","arbitrum","l2","url","endpoint","test"]},{id:"wallets.rpc.evm_optimism_mainnet",label:"Optimism Mainnet",description:"RPC endpoint URL for Optimism mainnet",page:"/wallets",tab:"rpc",fieldName:"rpc.evm_optimism_mainnet",keywords:["blockchain","rpc","evm","optimism","l2","url","endpoint"]},{id:"wallets.rpc.evm_optimism_sepolia",label:"Optimism Sepolia",description:"RPC endpoint URL for Optimism Sepolia testnet",page:"/wallets",tab:"rpc",fieldName:"rpc.evm_optimism_sepolia",keywords:["blockchain","rpc","evm","optimism","l2","url","endpoint","test"]},{id:"wallets.rpc.evm_base_mainnet",label:"Base Mainnet",description:"RPC endpoint URL for Base mainnet",page:"/wallets",tab:"rpc",fieldName:"rpc.evm_base_mainnet",keywords:["blockchain","rpc","evm","base","coinbase","l2","url","endpoint"]},{id:"wallets.rpc.evm_base_sepolia",label:"Base Sepolia",description:"RPC endpoint URL for Base Sepolia testnet",page:"/wallets",tab:"rpc",fieldName:"rpc.evm_base_sepolia",keywords:["blockchain","rpc","evm","base","coinbase","l2","url","endpoint","test"]},{id:"notifications.balance.enabled",label:"Enabled",description:"Enable or disable balance monitoring",page:"/notifications",tab:"balance",fieldName:"monitoring.enabled",keywords:["balance","monitoring","toggle","enable"]},{id:"notifications.balance.check_interval_sec",label:"Check Interval (seconds)",description:"How often to check wallet balances",page:"/notifications",tab:"balance",fieldName:"monitoring.check_interval_sec",keywords:["balance","monitoring","interval","frequency"]},{id:"notifications.balance.low_balance_threshold_sol",label:"Low Balance Threshold (SOL)",description:"Alert when SOL balance drops below this amount",page:"/notifications",tab:"balance",fieldName:"monitoring.low_balance_threshold_sol",keywords:["balance","monitoring","threshold","solana","alert","low"]},{id:"notifications.balance.low_balance_threshold_eth",label:"Low Balance Threshold (ETH)",description:"Alert when ETH balance drops below this amount",page:"/notifications",tab:"balance",fieldName:"monitoring.low_balance_threshold_eth",keywords:["balance","monitoring","threshold","ethereum","alert","low"]},{id:"notifications.balance.cooldown_hours",label:"Alert Cooldown (hours)",description:"Suppress duplicate alerts for this many hours",page:"/notifications",tab:"balance",fieldName:"monitoring.cooldown_hours",keywords:["balance","monitoring","cooldown","alert","suppress"]},{id:"wallets.walletconnect.project_id",label:"Project ID",description:"WalletConnect Cloud project identifier",page:"/wallets",tab:"walletconnect",fieldName:"walletconnect.project_id",keywords:["walletconnect","project","cloud","dapp"]},{id:"wallets.walletconnect.relay_url",label:"Relay URL",description:"WalletConnect relay server URL",page:"/wallets",tab:"walletconnect",fieldName:"walletconnect.relay_url",keywords:["walletconnect","relay","websocket","server"]},{id:"sessions.settings.max_sessions_per_wallet",label:"Max Sessions per Wallet",description:"Maximum concurrent sessions for a single wallet",page:"/sessions",tab:"settings",fieldName:"security.max_sessions_per_wallet",keywords:["session","limit","concurrent","wallet"]},{id:"sessions.settings.max_pending_tx",label:"Max Pending Transactions",description:"Maximum in-flight transactions per session",page:"/sessions",tab:"settings",fieldName:"security.max_pending_tx",keywords:["transaction","pending","limit","queue"]},{id:"sessions.settings.rate_limit_session_rpm",label:"Session Rate Limit (RPM)",description:"Max requests per minute per session",page:"/sessions",tab:"settings",fieldName:"security.rate_limit_session_rpm",keywords:["rate","limit","rpm","session","throttle"]},{id:"sessions.settings.rate_limit_tx_rpm",label:"Transaction Rate Limit (RPM)",description:"Max transaction requests per minute per session",page:"/sessions",tab:"settings",fieldName:"security.rate_limit_tx_rpm",keywords:["rate","limit","rpm","transaction","throttle"]},{id:"policies.defaults.policy_defaults_delay_seconds",label:"Policy Delay (seconds)",description:"Default delay before executing delayed-tier transactions",page:"/policies",tab:"defaults",fieldName:"security.policy_defaults_delay_seconds",keywords:["policy","delay","default","seconds","timer"]},{id:"policies.defaults.policy_defaults_approval_timeout",label:"Approval Timeout (seconds)",description:"How long to wait for owner approval before timeout",page:"/policies",tab:"defaults",fieldName:"security.policy_defaults_approval_timeout",keywords:["policy","approval","timeout","owner","default"]},{id:"policies.defaults.default_deny_tokens",label:"Default Deny: Token Transfers",description:"Deny token transfers unless a matching whitelist policy exists",page:"/policies",tab:"defaults",fieldName:"policy.default_deny_tokens",keywords:["policy","deny","token","transfer","default","security"]},{id:"policies.defaults.default_deny_contracts",label:"Default Deny: Contract Calls",description:"Deny contract calls unless a matching whitelist policy exists",page:"/policies",tab:"defaults",fieldName:"policy.default_deny_contracts",keywords:["policy","deny","contract","call","default","security"]},{id:"policies.defaults.default_deny_spenders",label:"Default Deny: Token Approvals",description:"Deny token approvals unless a matching whitelist policy exists",page:"/policies",tab:"defaults",fieldName:"policy.default_deny_spenders",keywords:["policy","deny","spender","approval","default","security"]},{id:"notifications.settings.enabled",label:"Enabled",description:"Enable or disable notifications globally",page:"/notifications",tab:"settings",fieldName:"notifications.enabled",keywords:["notifications","enable","toggle","global"]},{id:"notifications.settings.telegram_bot_token",label:"Telegram Bot Token",description:"Bot token for Telegram notifications",page:"/notifications",tab:"settings",fieldName:"notifications.telegram_bot_token",keywords:["telegram","bot","token","notification","credential"]},{id:"notifications.settings.telegram_chat_id",label:"Telegram Chat ID",description:"Chat ID for Telegram notification delivery",page:"/notifications",tab:"settings",fieldName:"notifications.telegram_chat_id",keywords:["telegram","chat","notification"]},{id:"notifications.settings.locale",label:"Locale",description:"Language for notification messages",page:"/notifications",tab:"settings",fieldName:"notifications.locale",keywords:["locale","language","notification","i18n"]},{id:"notifications.settings.discord_webhook_url",label:"Discord Webhook URL",description:"Webhook URL for Discord notifications",page:"/notifications",tab:"settings",fieldName:"notifications.discord_webhook_url",keywords:["discord","webhook","notification","credential"]},{id:"notifications.settings.ntfy_server",label:"Ntfy Server",description:"Server URL for ntfy notifications",page:"/notifications",tab:"settings",fieldName:"notifications.ntfy_server",keywords:["ntfy","server","push","notification"]},{id:"notifications.settings.ntfy_topic",label:"Ntfy Topic",description:"Topic name for ntfy notifications",page:"/notifications",tab:"settings",fieldName:"notifications.ntfy_topic",keywords:["ntfy","topic","push","notification"]},{id:"notifications.settings.slack_webhook_url",label:"Slack Webhook URL",description:"Webhook URL for Slack notifications",page:"/notifications",tab:"settings",fieldName:"notifications.slack_webhook_url",keywords:["slack","webhook","notification","credential"]},{id:"notifications.settings.rate_limit_rpm",label:"Rate Limit (RPM)",description:"Max notifications per minute",page:"/notifications",tab:"settings",fieldName:"notifications.rate_limit_rpm",keywords:["rate","limit","rpm","notification","throttle"]},{id:"notifications.settings.notify_events",label:"Event Filter",description:"Per-event notification filter (choose which events are delivered)",page:"/notifications",tab:"settings",fieldName:"notifications.notify_events",keywords:["filter","event","category","notification","subscribe"]},{id:"notifications.settings.telegram_dedicated_bot_token",label:"Bot Token",description:"Dedicated bot token for Telegram bot (optional, uses notification token if empty)",page:"/notifications",tab:"settings",fieldName:"telegram.bot_token",keywords:["telegram","bot","token","credential"]},{id:"security.autostop.enabled",label:"Enabled",description:"Enable or disable AutoStop protection rules",page:"/security",tab:"autostop",fieldName:"autostop.enabled",keywords:["autostop","protection","enable","toggle","security"]},{id:"security.autostop.consecutive_failures_threshold",label:"Consecutive Failures Threshold",description:"Suspend wallet after this many consecutive failed transactions",page:"/security",tab:"autostop",fieldName:"autostop.consecutive_failures_threshold",keywords:["autostop","failure","threshold","suspend","security"]},{id:"security.autostop.unusual_activity_threshold",label:"Unusual Activity Threshold",description:"Max transactions within window before triggering unusual activity alert",page:"/security",tab:"autostop",fieldName:"autostop.unusual_activity_threshold",keywords:["autostop","unusual","activity","threshold","security"]},{id:"security.autostop.unusual_activity_window_sec",label:"Unusual Activity Window (seconds)",description:"Time window for unusual activity detection",page:"/security",tab:"autostop",fieldName:"autostop.unusual_activity_window_sec",keywords:["autostop","unusual","activity","window","time","security"]},{id:"security.autostop.idle_timeout_sec",label:"Idle Timeout (seconds)",description:"Revoke sessions with no activity for this duration",page:"/security",tab:"autostop",fieldName:"autostop.idle_timeout_sec",keywords:["autostop","idle","timeout","session","revoke","security"]},{id:"security.autostop.idle_check_interval_sec",label:"Idle Check Interval (seconds)",description:"How often to check for idle sessions",page:"/security",tab:"autostop",fieldName:"autostop.idle_check_interval_sec",keywords:["autostop","idle","check","interval","security"]},{id:"system..currency",label:"Display Currency",description:"Currency for USD amount conversion in dashboard and notifications",page:"/system",tab:"",fieldName:"display.currency",keywords:["currency","display","usd","conversion","fiat"]},{id:"system..rate_limit_global_ip_rpm",label:"Global IP Rate Limit (RPM)",description:"Maximum API requests per minute from a single IP address",page:"/system",tab:"",fieldName:"security.rate_limit_global_ip_rpm",keywords:["rate","limit","rpm","ip","global","throttle"]},{id:"system..log_level",label:"Log Level",description:"Daemon logging verbosity level",page:"/system",tab:"",fieldName:"daemon.log_level",keywords:["log","level","debug","info","warn","error","daemon"]},{id:"transactions.monitor.enabled",label:"Monitoring Enabled",description:"Enable or disable incoming transaction monitoring",page:"/transactions",tab:"monitor",fieldName:"incoming.enabled",keywords:["incoming","monitoring","enable","toggle"]},{id:"transactions.monitor.poll_interval",label:"Poll Interval (seconds)",description:"How often to poll for incoming transactions",page:"/transactions",tab:"monitor",fieldName:"incoming.poll_interval",keywords:["incoming","poll","interval","frequency"]},{id:"transactions.monitor.retention_days",label:"Retention Days",description:"How many days to retain incoming transaction records",page:"/transactions",tab:"monitor",fieldName:"incoming.retention_days",keywords:["incoming","retention","days","cleanup"]},{id:"transactions.monitor.suspicious_dust_usd",label:"Suspicious Dust USD Threshold",description:"USD threshold below which transactions are flagged as dust",page:"/transactions",tab:"monitor",fieldName:"incoming.suspicious_dust_usd",keywords:["incoming","suspicious","dust","threshold","usd"]},{id:"transactions.monitor.suspicious_amount_multiplier",label:"Suspicious Amount Multiplier",description:"Multiplier for detecting unusually large incoming amounts",page:"/transactions",tab:"monitor",fieldName:"incoming.suspicious_amount_multiplier",keywords:["incoming","suspicious","amount","multiplier","large"]},{id:"transactions.monitor.cooldown_minutes",label:"Notification Cooldown (minutes)",description:"Cooldown period between duplicate incoming TX notifications",page:"/transactions",tab:"monitor",fieldName:"incoming.cooldown_minutes",keywords:["incoming","cooldown","notification","minutes"]},{id:"transactions.monitor.wss_url",label:"WebSocket URL",description:"Custom WebSocket RPC URL for real-time incoming TX detection",page:"/transactions",tab:"monitor",fieldName:"incoming.wss_url",keywords:["incoming","websocket","wss","rpc","url"]},{id:"system..cross_validation_threshold",label:"Cross Validation Threshold (%)",description:"Maximum allowed deviation between price oracle sources",page:"/system",tab:"",fieldName:"oracle.cross_validation_threshold",keywords:["oracle","price","validation","threshold","deviation"]},{id:"system..signing_sdk_enabled",label:"SDK Enabled",description:"Enable Signing SDK for wallet app approval",page:"/system",tab:"",fieldName:"signing_sdk.enabled",keywords:["signing","sdk","wallet","app","enable"]},{id:"system..signing_sdk_request_expiry",label:"Request Expiry (min)",description:"Minutes before a sign request expires",page:"/system",tab:"",fieldName:"signing_sdk.request_expiry_min",keywords:["signing","sdk","expiry","timeout","request"]},{id:"system..signing_sdk_preferred_channel",label:"Preferred Channel",description:"Preferred signing channel for SDK requests",page:"/system",tab:"",fieldName:"signing_sdk.preferred_channel",keywords:["signing","sdk","channel","ntfy","telegram"]},{id:"wallet-apps..signing_sdk_notifications",label:"Notifications Enabled",description:"Push event notifications to wallet apps",page:"/wallet-apps",tab:"",fieldName:"signing_sdk.notifications_enabled",keywords:["signing","sdk","notification","wallet","push"]}],Se=pe(""),ie=pe(null),kl={"/wallets":"Wallets","/sessions":"Sessions","/transactions":"Transactions","/policies":"Policies","/notifications":"Notifications","/security":"Security","/system":"System"};function Nl(t){if(!t.trim())return[];const a=t.toLowerCase();return Tl.filter(n=>[n.label,n.description,n.keywords.join(" ")].join(" ").toLowerCase().includes(a)).slice(0,10)}function Al(t){const a=kl[t.page]??t.page;return t.tab?`${a} > ${t.tab}`:a}function El({open:t}){const a=d(""),n=d(0),l=_a(null),i=t.value?Nl(a.value):[];if(B(()=>{t.value&&(a.value="",n.value=0,requestAnimationFrame(()=>{l.current?.focus()}))},[t.value]),!t.value)return null;const s=()=>{t.value=!1,a.value="",n.value=0},r=o=>{o.target.classList.contains("search-overlay")&&s()},c=o=>{window.location.hash="#"+o.page,o.tab?ie.value={tab:o.tab,fieldName:o.fieldName}:setTimeout(()=>{Se.value=o.fieldName},100),s()};return e("div",{class:"search-overlay",onClick:r,children:e("div",{class:"search-popover",onKeyDown:o=>{if(o.key==="Escape"){s();return}if(o.key==="ArrowDown"){o.preventDefault(),n.value=Math.min(n.value+1,i.length-1);return}if(o.key==="ArrowUp"){o.preventDefault(),n.value=Math.max(n.value-1,0);return}if(o.key==="Enter"&&i.length>0){o.preventDefault(),c(i[n.value]);return}},children:[e("div",{class:"search-input-wrapper",children:e("input",{ref:l,class:"search-input",type:"text",placeholder:"Search settings...",value:a.value,onInput:o=>{a.value=o.target.value,n.value=0}})}),e("div",{class:"search-results",children:[a.value.trim()&&i.length===0&&e("div",{class:"search-empty",children:"No settings found"}),i.map((o,v)=>e("button",{class:`search-result-item${v===n.value?" selected":""}`,onClick:()=>c(o),onMouseEnter:()=>{n.value=v},children:[e("div",{class:"search-result-label",children:o.label}),e("div",{class:"search-result-desc",children:o.description}),e("div",{class:"search-result-path",children:Al(o)})]},o.id))]}),e("div",{class:"search-hint",children:[e("span",{children:[e("kbd",{children:"Esc"})," close"]}),e("span",{children:[e("kbd",{children:"↑"}),e("kbd",{children:"↓"})," navigate"]}),e("span",{children:[e("kbd",{children:"Enter"})," select"]})]})]})})}const Be=pe([]),In=fa(()=>Be.value.some(t=>typeof t.isDirty=="function"&&t.isDirty()));function Ee(t){Be.value=[...Be.value.filter(a=>a.id!==t.id),t]}function ke(t){Be.value=Be.value.filter(a=>a.id!==t)}async function Cl(){const t=Be.value.filter(a=>typeof a.isDirty=="function"&&a.isDirty());try{for(const a of t)await a.save();return!0}catch{return!1}}function Il(){const t=Be.value.filter(a=>typeof a.isDirty=="function"&&a.isDirty());for(const a of t)a.discard()}function I({label:t,name:a,type:n="text",value:l,onChange:i,options:s,error:r,required:c,disabled:h,placeholder:o,min:v,max:u,description:f}){const A=Se.value===a;if(B(()=>{if(A){const x=document.querySelector(`[name="${a}"]`);x&&x.closest(".form-field")?.scrollIntoView({behavior:"smooth",block:"center"});const g=setTimeout(()=>{Se.value=""},2500);return()=>clearTimeout(g)}},[A,a]),n==="checkbox")return e("div",{class:`form-field${A?" form-field--highlight":""}`,children:[e("label",{children:[e("input",{type:"checkbox",name:a,checked:!!l,onChange:x=>i(x.target.checked),disabled:h}),t,c&&e("span",{children:" *"})]}),f&&e("span",{class:"form-description",children:f}),r&&e("span",{class:"form-error",children:r})]});const D=`field-${a}`;return e("div",{class:`form-field${A?" form-field--highlight":""}`,children:[e("label",{for:D,children:[t,c&&e("span",{children:" *"})]}),n==="select"?e("select",{id:D,name:a,value:l,onChange:x=>i(x.target.value),disabled:h,children:s?.map(x=>e("option",{value:x.value,children:x.label},x.value))}):n==="textarea"?e("textarea",{id:D,name:a,value:l,onInput:x=>i(x.target.value),disabled:h,placeholder:o}):e("input",{id:D,type:n,name:a,value:l,onInput:x=>{const g=x.target;i(n==="number"?Number(g.value):g.value)},disabled:h,placeholder:o,min:v,max:u,required:c}),f&&e("span",{class:"form-description",children:f}),r&&e("span",{class:"form-error",children:r})]})}function R({variant:t="primary",size:a="md",loading:n=!1,disabled:l=!1,onClick:i,children:s,type:r="button"}){const c=["btn",`btn-${t}`,a==="sm"?"btn-sm":""].filter(Boolean).join(" ");return e("button",{type:r,class:c,disabled:l||n,onClick:i,children:n?"...":s})}function z({variant:t,children:a}){return e("span",{class:`badge badge-${t}`,children:a})}const ca=pe(null),ia=pe(!1);function Dn(t){ca.value=t}function Dl(){const t=ca.value;if(!t)return null;const a=async()=>{ia.value=!0;const i=await Cl();ia.value=!1,i&&(ca.value=null,t.execute())},n=()=>{Il(),ca.value=null,t.execute()},l=()=>{ca.value=null};return e("div",{class:"modal-overlay",onClick:l,children:e("div",{class:"modal-card",onClick:i=>i.stopPropagation(),children:[e("div",{class:"modal-header",children:"Unsaved Changes"}),e("div",{class:"modal-body",children:e("p",{children:"You have unsaved changes. What would you like to do?"})}),e("div",{class:"modal-footer unsaved-dialog-footer",children:[e(R,{variant:"secondary",onClick:l,disabled:ia.value,children:"Cancel"}),e(R,{variant:"ghost",onClick:n,disabled:ia.value,children:"Discard & Navigate"}),e(R,{variant:"primary",onClick:a,loading:ia.value,children:"Save & Navigate"})]})]})})}class k extends Error{constructor(a,n,l){super(`[${a}] ${n}: ${l}`),this.status=a,this.code=n,this.serverMessage=l,this.name="ApiError"}}async function wa(t,a){const n={"Content-Type":"application/json",...a?.headers};ga.value!==null&&(n["X-Master-Password"]=ga.value);let l;try{l=await fetch(t,{...a,headers:n,signal:AbortSignal.timeout(1e4)})}catch(i){const s=i;throw s.name==="AbortError"||s.name==="TimeoutError"?new k(0,"TIMEOUT","Request timed out"):new k(0,"NETWORK_ERROR","Cannot connect to daemon")}if(l.status===401)throw t.startsWith("/v1/admin/")&&Va(),new k(401,"UNAUTHORIZED","Authentication failed");if(!l.ok){let i={};try{i=await l.json()}catch{}throw new k(l.status,i.code??"UNKNOWN",i.message??"Unknown error")}return yt(),await l.json()}const G=t=>wa(t,{method:"GET"}),ne=(t,a)=>wa(t,{method:"POST",body:a?JSON.stringify(a):void 0}),le=(t,a)=>wa(t,{method:"PUT",body:a?JSON.stringify(a):void 0}),Me=(t,a)=>wa(t,{method:"DELETE",body:a?JSON.stringify(a):void 0}),xl=(t,a)=>wa(t,{method:"PATCH",body:a?JSON.stringify(a):void 0});function Ol(t){const a=Math.floor(t/86400),n=Math.floor(t%86400/3600),l=Math.floor(t%3600/60);return a>0?`${a}d ${n}h ${l}m`:n>0?`${n}h ${l}m`:`${l}m`}function ve(t){const a=new Date(t*1e3),n=l=>l.toString().padStart(2,"0");return`${a.getFullYear()}-${n(a.getMonth()+1)}-${n(a.getDate())} ${n(a.getHours())}:${n(a.getMinutes())}`}function Wa(t){return t.length<=10?t:`${t.slice(0,4)}..${t.slice(-4)}`}const Ll=new Set(["KRW","JPY","VND","CLP","HUF","PKR"]),Rl=new Set(["KWD","BHD"]);function Pl(t){return Ll.has(t)?0:Rl.has(t)?3:2}function Ml(t,a,n){const l=t*n,i=Pl(a),s=new Intl.NumberFormat("en-US",{style:"currency",currency:a,minimumFractionDigits:i,maximumFractionDigits:i}).format(l);return a==="USD"?s:`≈${s}`}let je=null;const Wl=300*1e3;async function _t(){if(je&&Date.now()-je.fetchedAt<Wl)return{currency:je.currency,rate:je.rate};try{const a=(await G(L.ADMIN_SETTINGS)).display?.["display.currency"]??"USD";if(a==="USD")return je={currency:"USD",rate:1,fetchedAt:Date.now()},{currency:"USD",rate:1};const i=(await G(`${L.ADMIN_FOREX_RATES}?currencies=${a}`)).rates[a]?.rate??null;return je={currency:a,rate:i,fetchedAt:Date.now()},{currency:a,rate:i}}catch{return{currency:"USD",rate:1}}}function ea(t,a,n){return t==null?"":n==null?`$${t.toFixed(2)}`:Ml(t,a,n)}function Ve({columns:t,data:a,onRowClick:n,emptyMessage:l="No data",loading:i=!1}){return e("div",{class:"table-container",children:e("table",{children:[e("thead",{children:e("tr",{children:t.map(s=>e("th",{style:s.width?{width:s.width}:void 0,children:s.header},s.key))})}),e("tbody",{children:i?e("tr",{children:e("td",{colSpan:t.length,class:"table-loading",children:"Loading..."})}):!a||a.length===0?e("tr",{children:e("td",{colSpan:t.length,class:"table-empty",children:l})}):a.map((s,r)=>e("tr",{class:n?"clickable":"",onClick:n?()=>n(s):void 0,children:t.map(c=>e("td",{children:c.render?c.render(s):s[c.key]},c.key))},r))})]})})}const Ul={INVALID_TOKEN:"Your authentication token is invalid. Please log in again.",TOKEN_EXPIRED:"Your session token has expired. Please log in again.",SESSION_REVOKED:"Your session has been revoked by an administrator.",INVALID_SIGNATURE:"The cryptographic signature is invalid.",INVALID_NONCE:"The authentication nonce is invalid or has expired.",INVALID_MASTER_PASSWORD:"Invalid master password. Please try again.",MASTER_PASSWORD_LOCKED:"Master password is locked due to too many failed attempts. Please wait.",SYSTEM_LOCKED:"The system is currently locked.",SESSION_NOT_FOUND:"Session not found.",SESSION_EXPIRED:"The session has expired.",SESSION_LIMIT_EXCEEDED:"Maximum number of sessions reached.",CONSTRAINT_VIOLATED:"A session constraint was violated.",RENEWAL_LIMIT_REACHED:"Session renewal limit has been reached. Create a new session.",SESSION_ABSOLUTE_LIFETIME_EXCEEDED:"Session has exceeded its maximum lifetime.",RENEWAL_TOO_EARLY:"Session renewal attempted too early. Please wait.",SESSION_RENEWAL_MISMATCH:"Session renewal count mismatch. The session may have been renewed elsewhere.",PIPELINE_HALTED:"Transaction is queued for delay or approval.",INSUFFICIENT_BALANCE:"Insufficient balance for this transaction.",INVALID_ADDRESS:"The blockchain address is invalid.",TX_NOT_FOUND:"Transaction not found.",TX_EXPIRED:"The transaction has expired.",TX_ALREADY_PROCESSED:"This transaction has already been processed.",CHAIN_ERROR:"A blockchain network error occurred. Please try again.",SIMULATION_FAILED:"Transaction simulation failed. The transaction may revert.",TOKEN_NOT_FOUND:"Token not found.",TOKEN_NOT_ALLOWED:"This token is not in the allowed list.",INSUFFICIENT_TOKEN_BALANCE:"Insufficient token balance.",CONTRACT_CALL_DISABLED:"Contract calls are disabled. Configure a CONTRACT_WHITELIST policy first.",CONTRACT_NOT_WHITELISTED:"This contract address is not whitelisted.",METHOD_NOT_WHITELISTED:"This contract method is not whitelisted.",APPROVE_DISABLED:"Token approvals are disabled. Configure an APPROVED_SPENDERS policy first.",SPENDER_NOT_APPROVED:"This spender address is not in the approved list.",APPROVE_AMOUNT_EXCEEDED:"The approve amount exceeds the configured limit.",UNLIMITED_APPROVE_BLOCKED:"Unlimited token approvals are blocked by policy.",BATCH_NOT_SUPPORTED:"Batch transactions are not supported on this chain.",BATCH_SIZE_EXCEEDED:"Batch contains too many instructions (maximum 20).",BATCH_POLICY_VIOLATION:"A policy violation occurred in the batch transaction.",POLICY_NOT_FOUND:"Policy not found.",POLICY_DENIED:"Transaction denied by policy.",SPENDING_LIMIT_EXCEEDED:"Spending limit has been exceeded.",RATE_LIMIT_EXCEEDED:"Rate limit exceeded. Please wait before retrying.",WHITELIST_DENIED:"The destination address is not in the whitelist.",OWNER_ALREADY_CONNECTED:"An owner wallet is already connected to this wallet.",OWNER_NOT_CONNECTED:"No owner wallet is connected to this wallet.",OWNER_NOT_FOUND:"Owner not found.",APPROVAL_TIMEOUT:"The approval request has timed out.",APPROVAL_NOT_FOUND:"Approval request not found.",OWNER_NOT_SET:"Owner address must be set before connecting WalletConnect.",OWNER_ADDRESS_MISMATCH:"Connected wallet address does not match registered owner.",KILL_SWITCH_ACTIVE:"Kill switch is active. All operations are suspended.",KILL_SWITCH_NOT_ACTIVE:"Kill switch is not currently active.",KEYSTORE_LOCKED:"The keystore is locked. Please try again.",CHAIN_NOT_SUPPORTED:"This blockchain is not supported.",SHUTTING_DOWN:"The daemon is shutting down.",ADAPTER_NOT_AVAILABLE:"Chain adapter is not available. Please try again.",WALLET_NOT_FOUND:"Wallet not found.",WALLET_SUSPENDED:"This wallet is currently suspended.",WALLET_TERMINATED:"This wallet has been terminated.",WC_NOT_CONFIGURED:"WalletConnect is not configured. Set the Project ID in Settings first.",WC_SESSION_NOT_FOUND:"No active WalletConnect session.",WC_SESSION_EXISTS:"A WalletConnect session already exists. Disconnect first.",WC_SIGNING_FAILED:"WalletConnect signing request failed.",NO_OWNER:"No owner connected. Withdrawal requires an owner wallet.",WITHDRAW_LOCKED_ONLY:"Withdrawal is only available when the owner state is LOCKED.",SWEEP_TOTAL_FAILURE:"All sweep operations failed. Please try again.",INSUFFICIENT_FOR_FEE:"Insufficient balance to cover transaction fees.",ACTION_NOT_FOUND:"Action not found.",ACTION_VALIDATION_FAILED:"Action input validation failed.",ACTION_RESOLVE_FAILED:"Action failed due to an external API error. Please try again.",ACTION_RETURN_INVALID:"Action returned an invalid result.",ACTION_PLUGIN_LOAD_FAILED:"Failed to load the action plugin.",ACTION_NAME_CONFLICT:"An action with this name already exists.",ACTION_CHAIN_MISMATCH:"The request chain does not match the action provider.",ROTATION_TOO_RECENT:"Key rotation was attempted too recently. Please wait.",NETWORK_ERROR:"Cannot connect to the daemon. Check if it is running.",TIMEOUT:"Request timed out. The daemon may be busy."},$l=new Set(["ACTION_VALIDATION_FAILED","CONSTRAINT_VIOLATED","INVALID_ADDRESS","INVALID_SIGNATURE"]);function $(t,a){return a&&$l.has(t)?a:Ul[t]??`An error occurred (${t}).`}const Le=pe([]);let Fl=0;function w(t,a){const n=Fl++;Le.value=[...Le.value,{id:n,type:t,message:a}],setTimeout(()=>{Le.value=Le.value.filter(l=>l.id!==n)},5e3)}function Kl(t){Le.value=Le.value.filter(a=>a.id!==t)}function Hl(){return Le.value.length===0?null:e("div",{class:"toast-container",children:Le.value.map(t=>e("div",{class:`toast toast-${t.type}`,onClick:()=>Kl(t.id),children:t.message},t.id))})}const Bl={"solana-mainnet":"https://solscan.io/tx/{txHash}","solana-devnet":"https://solscan.io/tx/{txHash}?cluster=devnet","solana-testnet":"https://solscan.io/tx/{txHash}?cluster=testnet","ethereum-mainnet":"https://etherscan.io/tx/{txHash}","ethereum-sepolia":"https://sepolia.etherscan.io/tx/{txHash}","polygon-mainnet":"https://polygonscan.com/tx/{txHash}","polygon-amoy":"https://amoy.polygonscan.com/tx/{txHash}","arbitrum-mainnet":"https://arbiscan.io/tx/{txHash}","arbitrum-sepolia":"https://sepolia.arbiscan.io/tx/{txHash}","optimism-mainnet":"https://optimistic.etherscan.io/tx/{txHash}","optimism-sepolia":"https://sepolia-optimism.etherscan.io/tx/{txHash}","base-mainnet":"https://basescan.org/tx/{txHash}","base-sepolia":"https://sepolia.basescan.org/tx/{txHash}"};function Vl(t,a){const n=Bl[t];return n?n.replace("{txHash}",a):null}function zl(t){return t.length<=16?t:t.slice(0,8)+"..."+t.slice(-6)}function bt({network:t,txHash:a,label:n}){if(!a)return null;const l=Vl(t,a),i=n??zl(a);return l?e("a",{href:l,target:"_blank",rel:"noopener noreferrer",class:"explorer-link",children:i}):e("span",{class:"explorer-link-text",children:i})}function be({label:t,value:a,loading:n,badge:l,href:i}){const s=e(J,{children:[e("div",{class:"stat-label",children:[t,i&&e("span",{class:"stat-link-arrow",children:" →"})]}),n?e("div",{class:"stat-skeleton"}):l?e(z,{variant:l,children:a}):e("div",{class:"stat-value",children:a})]});return i?e("a",{href:i,class:"stat-card stat-card-link",style:{textDecoration:"none",color:"inherit",cursor:"pointer"},children:s}):e("div",{class:"stat-card",children:s})}function Gl(t,a){return[{key:"createdAt",header:"Time",render:n=>n.createdAt?ve(n.createdAt):"—"},{key:"walletName",header:"Wallet",render:n=>n.walletName??n.walletId.slice(0,8)},{key:"type",header:"Type"},{key:"amount",header:"Amount",render:n=>{if(!n.amount)return"—";const l=ea(n.amountUsd,t,a);return l?`${n.amount} (${l})`:n.amount}},{key:"network",header:"Network",render:n=>n.network??"—"},{key:"status",header:"Status",render:n=>{const l=n.status==="CONFIRMED"?"success":n.status==="FAILED"?"danger":"warning";return e(z,{variant:l,children:n.status})}},{key:"txHash",header:"Tx Hash",render:n=>e(bt,{network:n.network??"",txHash:n.txHash})}]}function ql(t,a){return[{key:"provider",header:"Provider"},{key:"category",header:"Category",render:n=>e(z,{variant:"info",children:n.category})},{key:"chain",header:"Chain",render:n=>e(z,{variant:"info",children:n.chain})},{key:"amount",header:"Amount"},{key:"amountUsd",header:"USD Value",render:n=>n.amountUsd===null?"—":ea(n.amountUsd,t,a)??`$${n.amountUsd.toFixed(2)}`}]}async function jl(t){try{await navigator.clipboard.writeText(t)}catch{const a=document.createElement("textarea");a.value=t,a.style.position="fixed",a.style.left="-9999px",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a)}}function Pt(){const t=d(null),a=d(!0),n=d(null),l=d("USD"),i=d(1),s=d(!1),r=d(null),c=d(null),h=d(null),o=d(!0),v=async()=>{o.value=!0;try{const x=await G(L.ADMIN_DEFI_POSITIONS);h.value=x}catch{}finally{o.value=!1}},u=async()=>{a.value=!0,n.value=null;try{const x=await G(L.ADMIN_STATUS);t.value=x}catch(x){x instanceof k?n.value=$(x.code):n.value="An unexpected error occurred."}finally{a.value=!1}},f=async()=>{s.value=!0;try{const x=await ne(L.ADMIN_AGENT_PROMPT,{});if(x.walletCount===0){w("warning","No active wallets found");return}r.value=x.prompt,w("success",`Prompt generated for ${x.walletCount} wallet(s)`)}catch(x){x instanceof k?w("error",$(x.code)):w("error","Failed to generate agent prompt")}finally{s.value=!1}},A=async()=>{r.value&&(await jl(r.value),w("success","Copied to clipboard!"))};B(()=>{u(),v(),_t().then(({currency:g,rate:_})=>{l.value=g,i.value=_}).catch(()=>{}),G(L.ADMIN_TRANSACTIONS+"?status=APPROVED&limit=1").then(g=>{c.value=g.total}).catch(()=>{});const x=setInterval(()=>{u(),v()},3e4);return()=>clearInterval(x)},[]);const D=a.value&&!t.value;return e("div",{class:"page",children:[n.value&&e("div",{class:"dashboard-error",children:[e("span",{children:n.value}),e(R,{variant:"secondary",size:"sm",onClick:u,children:"Retry"})]}),t.value?.updateAvailable&&e("div",{class:"update-banner",role:"status",children:[e("span",{class:"update-banner-icon",children:"⬆"}),e("span",{children:[e("strong",{children:"Update available:"})," ",t.value.version," ","→"," ",t.value.latestVersion," — ","Run ",e("code",{children:"waiaas update"})," to update."]})]}),t.value?.autoProvisioned&&e("div",{class:"auto-provision-banner",role:"alert",children:[e("span",{class:"auto-provision-banner-icon",children:"⚠"}),e("span",{children:[e("strong",{children:"Auto-provision mode active."})," ","Change the master password for security."," ",e("a",{href:"#/security?tab=password",class:"auto-provision-link",children:"Go to Security"})]})]}),e("div",{class:"stat-grid",children:[e(be,{label:"Version",value:t.value?.version??"—",loading:D,badge:t.value&&t.value.updateAvailable?"warning":void 0}),e(be,{label:"Uptime",value:t.value?Ol(t.value.uptime):"—",loading:D}),e(be,{label:"Wallets",value:t.value?.walletCount?.toString()??"—",loading:D,href:"#/wallets"}),e(be,{label:"Active Sessions",value:t.value?.activeSessionCount?.toString()??"—",loading:D,href:"#/sessions"})]}),e("div",{class:"stat-grid",style:{marginTop:"var(--space-4)"},children:[e(be,{label:"Kill Switch",value:t.value?.killSwitchState==="ACTIVATED"?"ACTIVATED":"NORMAL",loading:D,badge:t.value?t.value.killSwitchState==="ACTIVATED"?"danger":"success":void 0}),e(be,{label:"Status",value:t.value?.status??"—",loading:D})]}),e("div",{class:"stat-grid",style:{marginTop:"var(--space-4)"},children:[e(be,{label:"Policies",value:t.value?.policyCount?.toString()??"—",loading:D,href:"#/policies"}),e(be,{label:"Recent Txns (24h)",value:t.value?.recentTxCount?.toString()??"—",loading:D,href:"#/transactions"}),e(be,{label:"Failed Txns (24h)",value:t.value?.failedTxCount?.toString()??"—",loading:D,badge:t.value?t.value.failedTxCount===0?"success":"danger":void 0,href:"#/transactions?status=FAILED"}),e(be,{label:"Approval Pending",value:c.value?.toString()??"—",loading:D,badge:c.value!=null&&c.value>0?"warning":void 0,href:"#/transactions?status=APPROVED"})]}),e("div",{class:"prompt-card",style:{marginTop:"var(--space-4)"},children:[e("h3",{style:{marginBottom:"var(--space-2)"},children:"Agent Connection Prompt"}),e("p",{class:"prompt-card-desc",children:"Generate a connection prompt for AI agents. Creates sessions for all active wallets."}),r.value?e(J,{children:[e("pre",{class:"prompt-preview",children:r.value}),e("div",{style:{display:"flex",gap:"var(--space-2)",marginTop:"var(--space-3)"},children:[e(R,{variant:"primary",size:"sm",onClick:A,children:"Copy to Clipboard"}),e(R,{variant:"secondary",size:"sm",onClick:f,loading:s.value,children:"Regenerate"})]})]}):e(R,{variant:"primary",size:"sm",onClick:f,loading:s.value,style:{marginTop:"var(--space-2)"},children:"Generate"})]}),h.value&&h.value.activeCount>0&&e("div",{style:{marginTop:"var(--space-4)"},children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"DeFi Positions"}),e("div",{class:"stat-grid",children:[e(be,{label:"Total DeFi Value",value:h.value.totalValueUsd!==null?ea(h.value.totalValueUsd,l.value,i.value)??`$${h.value.totalValueUsd.toFixed(2)}`:"—",loading:o.value}),e(be,{label:"Health Factor",value:h.value.worstHealthFactor!==null?h.value.worstHealthFactor.toFixed(2):"N/A",loading:o.value,badge:h.value.worstHealthFactor!==null?h.value.worstHealthFactor<1.2?"danger":h.value.worstHealthFactor<1.5?"warning":"success":void 0}),e(be,{label:"Active Positions",value:h.value.activeCount.toString(),loading:o.value})]}),e("div",{style:{marginTop:"var(--space-3)"},children:e(Ve,{columns:ql(l.value,i.value),data:h.value.positions,loading:o.value,emptyMessage:"No active DeFi positions"})})]}),e("div",{style:{marginTop:"var(--space-4)"},children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"Recent Activity"}),e(Ve,{columns:Gl(l.value,i.value),data:t.value?.recentTransactions??[],loading:D,emptyMessage:"No recent transactions"})]})]})}function we({open:t,title:a,children:n,onConfirm:l,onCancel:i,confirmText:s="Confirm",cancelText:r="Cancel",confirmVariant:c="primary",confirmDisabled:h=!1,loading:o=!1}){return B(()=>{if(!t)return;const v=u=>{u.key==="Escape"&&i()};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[t,i]),t?e("div",{class:"modal-overlay",onClick:i,children:e("div",{class:"modal-card",onClick:v=>v.stopPropagation(),children:[e("div",{class:"modal-header",children:a}),e("div",{class:"modal-body",children:n}),e("div",{class:"modal-footer",children:[e(R,{variant:"secondary",onClick:i,disabled:o,children:r}),l&&e(R,{variant:c,onClick:l,loading:o,disabled:h,children:s})]})]})}):null}function ya({value:t,label:a}){const n=d(!1);return e("button",{class:"btn btn-ghost btn-sm",onClick:async()=>{try{await navigator.clipboard.writeText(t)}catch{const i=document.createElement("textarea");i.value=t,i.style.position="fixed",i.style.left="-9999px",document.body.appendChild(i),i.select(),document.execCommand("copy"),document.body.removeChild(i)}n.value=!0,setTimeout(()=>{n.value=!1},2e3)},children:n.value?"Copied!":a??"Copy"})}function Mt({title:t,description:a,actionLabel:n,onAction:l}){return e("div",{class:"empty-state",children:[e("h3",{children:t}),a&&e("p",{children:a}),n&&l&&e("button",{class:"btn btn-primary",onClick:l,children:n})]})}function Ge({tabs:t,activeTab:a,onTabChange:n}){return e("div",{class:"tab-nav",children:t.map(l=>e("button",{class:`tab-btn ${a===l.key?"active":""}`,onClick:()=>{l.key!==a&&(In.value?Dn({type:"tab",execute:()=>n(l.key)}):n(l.key))},children:l.label},l.key))})}function na({pageName:t,tabName:a,onPageClick:n}){return a?e("nav",{class:"breadcrumb","aria-label":"Breadcrumb",children:[e("button",{class:"breadcrumb-page",onClick:n,type:"button",children:t}),e("span",{class:"breadcrumb-separator","aria-hidden":"true",children:">"}),e("span",{class:"breadcrumb-current","aria-current":"page",children:a})]}):null}function xn({value:t,onSearch:a,placeholder:n="Search...",debounceMs:l=300}){const i=_a(null);function s(c){const h=c.target.value;i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>{a(h),i.current=null},l)}function r(){i.current!==null&&(clearTimeout(i.current),i.current=null),a("")}return e("div",{class:"search-input",children:[e("input",{type:"text",value:t,placeholder:n,onInput:s}),t&&e("button",{class:"search-clear",type:"button",onClick:r,children:"x"})]})}function Yl(){const t=window.location.hash,a=t.indexOf("?");if(a===-1)return{};const n=new URLSearchParams(t.slice(a+1)),l={};return n.forEach((i,s)=>{l[s]=i}),l}function Wt(t){const a=window.location.hash,n=a.indexOf("?"),l=n===-1?a:a.slice(0,n),i=new URLSearchParams;for(const[c,h]of Object.entries(t))h&&i.set(c,h);const s=i.toString(),r=s?`${l}?${s}`:l;window.history.replaceState(null,"",r)}function za({fields:t,values:a,onChange:n,syncUrl:l=!0}){B(()=>{if(!l)return;const r=Yl(),c={...a};let h=!1;for(const o of t){const v=r[o.key];v!==void 0&&v!==c[o.key]&&(c[o.key]=v,h=!0)}h&&n(c)},[]);function i(r,c){const h={...a,[r]:c};n(h),l&&Wt(h)}function s(){const r={};for(const c of t)r[c.key]="";n(r),l&&Wt(r)}return e("div",{class:"filter-bar",children:[t.map(r=>e("div",{class:"filter-field",children:[e("label",{children:r.label}),r.type==="select"?e("select",{value:a[r.key]??"",onChange:c=>i(r.key,c.target.value),children:[e("option",{value:"",children:"All"}),r.options?.map(c=>e("option",{value:c.value,children:c.label},c.value))]}):e("input",{type:"date",value:a[r.key]??"",placeholder:r.placeholder,onChange:c=>i(r.key,c.target.value)})]},r.key)),e("button",{class:"btn btn-secondary filter-clear",type:"button",onClick:s,children:"Clear"})]})}const Xl=new Set(["notifications.telegram_bot_token","notifications.discord_webhook_url","notifications.slack_webhook_url","telegram.bot_token"]);function Jl(t){return Xl.has(t)}function X(t){return{enabled:"Enabled",telegram_bot_token:"Telegram Bot Token",telegram_chat_id:"Telegram Chat ID",discord_webhook_url:"Discord Webhook URL",ntfy_server:"Ntfy Server",ntfy_topic:"Ntfy Topic",locale:"Locale",rate_limit_rpm:"Rate Limit (RPM)",solana_mainnet:"Solana Mainnet",solana_devnet:"Solana Devnet",solana_testnet:"Solana Testnet",evm_ethereum_mainnet:"Ethereum Mainnet",evm_ethereum_sepolia:"Ethereum Sepolia",evm_polygon_mainnet:"Polygon Mainnet",evm_polygon_amoy:"Polygon Amoy",evm_arbitrum_mainnet:"Arbitrum Mainnet",evm_arbitrum_sepolia:"Arbitrum Sepolia",evm_optimism_mainnet:"Optimism Mainnet",evm_optimism_sepolia:"Optimism Sepolia",evm_base_mainnet:"Base Mainnet",evm_base_sepolia:"Base Sepolia",max_sessions_per_wallet:"Max Sessions per Wallet",max_pending_tx:"Max Pending Transactions",rate_limit_global_ip_rpm:"Global IP Rate Limit (RPM)",rate_limit_session_rpm:"Session Rate Limit (RPM)",rate_limit_tx_rpm:"Transaction Rate Limit (RPM)",policy_defaults_delay_seconds:"Policy Delay (seconds)",policy_defaults_approval_timeout:"Approval Timeout (seconds)",default_deny_tokens:"Default Deny: Token Transfers",default_deny_contracts:"Default Deny: Contract Calls",default_deny_spenders:"Default Deny: Token Approvals",default_deny_x402_domains:"Default Deny: x402 Domains",project_id:"Project ID",log_level:"Log Level",currency:"Display Currency",consecutive_failures_threshold:"Consecutive Failures Threshold",unusual_activity_threshold:"Unusual Activity Threshold",unusual_activity_window_sec:"Unusual Activity Window (seconds)",idle_timeout_sec:"Idle Timeout (seconds)",idle_check_interval_sec:"Idle Check Interval (seconds)",check_interval_sec:"Check Interval (seconds)",low_balance_threshold_sol:"Low Balance Threshold (SOL)",low_balance_threshold_eth:"Low Balance Threshold (ETH)",cooldown_hours:"Alert Cooldown (hours)",relay_url:"Relay URL",bot_token:"Bot Token",request_expiry_min:"Request Expiry (minutes)",preferred_channel:"Preferred Channel",preferred_wallet:"Preferred Wallet",ntfy_request_topic_prefix:"Ntfy Request Topic Prefix",ntfy_response_topic_prefix:"Ntfy Response Topic Prefix",wallets:"Registered Wallets (JSON)",aave_v3_enabled:"Aave V3 Enabled",aave_v3_health_factor_warning_threshold:"HF Warning Threshold",aave_v3_position_sync_interval_sec:"Position Sync Interval (seconds)",aave_v3_max_ltv_pct:"Max LTV Percentage",kamino_enabled:"Kamino Enabled",kamino_market:"Market",kamino_hf_threshold:"HF Warning Threshold",drift_enabled:"Drift Perp Enabled",drift_max_leverage:"Max Leverage",drift_max_position_usd:"Max Position Size (USD)",drift_margin_warning_threshold_pct:"Margin Warning Threshold (%)",drift_position_sync_interval_sec:"Position Sync Interval (seconds)",poll_interval_sec:"Poll Interval (seconds)",default_timeout_sec:"Default Timeout (seconds)",max_timeout_sec:"Max Timeout (seconds)",max_pending_count:"Max Pending Count"}[t]??t.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function te(t,a,n,l){const i=`${n}.${l}`;if(a[i]!==void 0)return a[i];const s=t[n];if(!s)return"";const r=s[l];return typeof r=="boolean"?Jl(i)?"":String(r):r??""}function He(t,a,n,l){const i=`${n}.${l}`;if(a[i]!==void 0)return a[i]==="true";const s=t[n];if(!s)return!1;const r=s[l];return typeof r=="boolean"?r:r==="true"}function da(t,a,n,l){const i=`${n}.${l}`;if(a[i]!==void 0)return!1;const s=t[n];return s?s[l]===!0:!1}const Ne=[{value:"dcent",label:"D'CENT Wallet",description:"D'CENT hardware wallet with push notification signing"}],Na={dcent:"Wallet App (ntfy)"},Zl={dcent:"sdk_ntfy"};function On(t){switch(t){case"NONE":return"neutral";case"GRACE":return"warning";case"LOCKED":return"success";default:return"neutral"}}function ce({label:t,value:a,copy:n,children:l}){return e("div",{class:"detail-row",children:[e("div",{class:"detail-row-label",children:t}),e("div",{class:"detail-row-value",children:[l??a??"—",n&&a&&e(ya,{value:a})]})]})}const Ut=[{value:null,label:"Auto (Global Fallback)",description:"System decides based on configured channels: Wallet App (ntfy) > Wallet App (Telegram) > WalletConnect > Telegram Bot > REST"},{value:"sdk_ntfy",label:"Wallet App (ntfy)",description:"Push sign request to wallet app via ntfy server",warning:"Signing SDK is not enabled. Go to Wallets > Human Wallet Apps settings.",warningCondition:t=>!t?.signingEnabled},{value:"sdk_telegram",label:"Wallet App (Telegram)",description:"Push sign request to wallet app via Telegram with universal link",warning:"Signing SDK or Telegram bot is not configured. Check Wallets > Human Wallet Apps and Notifications > Settings > Telegram.",warningCondition:t=>!t?.signingEnabled||!t?.telegramBotConfigured},{value:"walletconnect",label:"WalletConnect",description:"Approve via connected WalletConnect wallet (D'CENT, MetaMask, etc.)",warning:"WalletConnect project ID is not configured. Go to Wallets > WalletConnect tab.",warningCondition:t=>!t?.wcConfigured},{value:"telegram_bot",label:"Telegram Bot",description:"Approve/reject via Telegram bot /approve and /reject commands",warning:"Telegram bot token is not configured. Go to Notifications > Settings > Telegram.",warningCondition:t=>!t?.telegramBotConfigured},{value:"rest",label:"REST API",description:"Manual approval via REST API endpoints (POST /approve, /reject)"}],Ql=[{key:"overview",label:"Overview"},{key:"transactions",label:"Transactions"},{key:"owner",label:"Owner"},{key:"staking",label:"Staking"},{key:"mcp",label:"MCP"}],sa=20,ei=[{value:"PENDING",label:"PENDING"},{value:"APPROVED",label:"APPROVED"},{value:"SUBMITTED",label:"SUBMITTED"},{value:"CONFIRMED",label:"CONFIRMED"},{value:"FAILED",label:"FAILED"}],ai=[{value:"TRANSFER",label:"TRANSFER"},{value:"TOKEN_TRANSFER",label:"TOKEN_TRANSFER"},{value:"CONTRACT_CALL",label:"CONTRACT_CALL"},{value:"APPROVE",label:"APPROVE"},{value:"BATCH",label:"BATCH"}],ti=[{key:"status",label:"Status",type:"select",options:ei},{key:"type",label:"Type",type:"select",options:ai}],Xa=["Time","Type","To","Amount","Network","Status","Tx Hash"];function ni(t){return t==="CONFIRMED"?"success":t==="FAILED"?"danger":"warning"}function li({id:t}){const a=d(null),n=d(!0),l=d(!1),i=d(""),s=d(!1),r=d(!1),c=d(!1),h=d(!1),o=d(null),v=d([]),u=d(!0),f=d(null),A=d(!0),D=d([]),x=d(!0),g=d(0),_=d(0),U=d({status:"",type:""}),F=d(!1),E=d(null),K=d(!1),C=d(null),T=d(!0),m=d(!1),S=d(null),P=d(!1),y=d(""),p=d(!1),W=d(""),H=d(!1),j=d(null),se=d(!1),me=d(!1),re=d(""),oe=d(!1),fe=d("overview"),Ue=d("USD"),$e=d(1),Ce=d([]),Ie=d(!0),Te=async()=>{try{const b=await G(L.WALLET(t));a.value=b}catch(b){const V=b instanceof k?b:new k(0,"UNKNOWN","Unknown error");w("error",$(V.code))}finally{n.value=!1}},M=async()=>{s.value=!0;try{const b=await le(L.WALLET(t),{name:i.value});a.value=b,l.value=!1,w("success","Wallet name updated")}catch(b){const V=b instanceof k?b:new k(0,"UNKNOWN","Unknown error");w("error",$(V.code))}finally{s.value=!1}},ee=async()=>{c.value=!0;try{await Me(L.WALLET(t)),w("success","Wallet terminated"),window.location.hash="#/wallets"}catch(b){const V=b instanceof k?b:new k(0,"UNKNOWN","Unknown error");w("error",$(V.code))}finally{c.value=!1}},_e=async()=>{me.value=!0;try{await ne(L.WALLET_SUSPEND(t),{reason:re.value.trim()||void 0}),w("success","Wallet suspended"),se.value=!1,re.value="",await Te()}catch(b){const V=b instanceof k?b:new k(0,"UNKNOWN","Unknown error");w("error",$(V.code))}finally{me.value=!1}},Ga=async()=>{oe.value=!0;try{await ne(L.WALLET_RESUME(t)),w("success","Wallet resumed"),await Te()}catch(b){const V=b instanceof k?b:new k(0,"UNKNOWN","Unknown error");w("error",$(V.code))}finally{oe.value=!1}},qa=()=>{i.value=a.value.name,l.value=!0},N=()=>{l.value=!1},O=async()=>{h.value=!0;try{const b=await ne(L.MCP_TOKENS,{walletId:t});o.value=b,w("success","MCP token provisioned successfully")}catch(b){const V=b instanceof k?b:new k(0,"UNKNOWN","Unknown error");w("error",$(V.code))}finally{h.value=!1}},ae=async()=>{u.value=!0;try{const b=await G(L.WALLET_NETWORKS(t));v.value=b.availableNetworks??[]}catch(b){const V=b instanceof k?b:new k(0,"UNKNOWN","Unknown error");w("error",$(V.code)),v.value=[]}finally{u.value=!1}},ue=async()=>{A.value=!0;try{f.value=await G(L.ADMIN_WALLET_BALANCE(t))}catch{f.value=null}finally{A.value=!1}},qe=async b=>{x.value=!0;try{const q=(b??_.value)*sa,ge=await G(`${L.ADMIN_WALLET_TRANSACTIONS(t)}?offset=${q}&limit=${sa}`);D.value=ge.items,g.value=ge.total}catch{D.value=[],g.value=0}finally{x.value=!1}},Fe=Ba(()=>{let b=D.value;const V=U.value;return V.status&&(b=b.filter(q=>q.status===V.status)),V.type&&(b=b.filter(q=>q.type===V.type)),b}),Y=async()=>{Ie.value=!0;try{const b=await G(L.ADMIN_WALLET_STAKING(t));Ce.value=b.positions??[]}catch{Ce.value=[]}finally{Ie.value=!1}},la=async()=>{T.value=!0;try{C.value=await G(L.WALLET_WC_SESSION(t))}catch{C.value=null}finally{T.value=!1}},Sa=()=>{S.value&&clearInterval(S.value),S.value=setInterval(async()=>{try{const b=await G(L.WALLET_WC_PAIR_STATUS(t));b.status==="connected"?(S.value&&clearInterval(S.value),S.value=null,F.value=!1,E.value=null,C.value=b.session??null,w("success","Wallet connected via WalletConnect")):(b.status==="expired"||b.status==="none")&&(S.value&&clearInterval(S.value),S.value=null,F.value=!1,E.value=null,w("error","Pairing expired. Try again."))}catch{}},3e3)},Pn=async()=>{K.value=!0;try{const b=await ne(L.WALLET_WC_PAIR(t));E.value=b,F.value=!0,Sa()}catch(b){const V=b instanceof k?b:new k(0,"UNKNOWN","Unknown error");V.code==="WC_NOT_CONFIGURED"?(w("error","WalletConnect is not configured. Redirecting to settings..."),ie.value={tab:"walletconnect",fieldName:"walletconnect.project_id"},window.location.hash="#/wallets"):w("error",$(V.code))}finally{K.value=!1}},Mn=async()=>{m.value=!0;try{await Me(L.WALLET_WC_SESSION(t)),C.value=null,w("success","WalletConnect session disconnected")}catch(b){const V=b instanceof k?b:new k(0,"UNKNOWN","Unknown error");w("error",$(V.code))}finally{m.value=!1}},wt=()=>{y.value=a.value?.ownerAddress??"",W.value=a.value?.walletType??"",P.value=!0},Wn=()=>{P.value=!1},Un=async()=>{if(!y.value.trim()){w("error","Owner address is required");return}p.value=!0;try{const b={owner_address:y.value.trim()};W.value&&(b.wallet_type=W.value),await le(L.WALLET_OWNER(t),b),await Te(),P.value=!1;const V=Ne.find(q=>q.value===W.value);V?w("success",`Owner set with ${V.label} auto-setup`):w("success","Owner address updated")}catch(b){const V=b instanceof k?b:new k(0,"UNKNOWN","Unknown error");w("error",$(V.code,V.serverMessage))}finally{p.value=!1}},$n=async b=>{if(a.value?.ownerAddress){p.value=!0;try{const V={owner_address:a.value.ownerAddress};b&&(V.wallet_type=b),await le(L.WALLET_OWNER(t),V),await Te(),H.value=!1;const q=Ne.find(ge=>ge.value===b);q?w("success",`Wallet Type changed to ${q.label}`):w("success","Wallet Type cleared")}catch(V){const q=V instanceof k?V:new k(0,"UNKNOWN","Unknown error");w("error",$(q.code,q.serverMessage))}finally{p.value=!1}}},Fn=async()=>{try{const b=await G(L.ADMIN_SETTINGS),V=b.signing_sdk?.enabled==="true",q=b.telegram?.bot_token===!0||b.notifications?.telegram_bot_token===!0,ge=!!b.walletconnect?.project_id&&b.walletconnect.project_id!=="";j.value={signingEnabled:V,telegramBotConfigured:q,wcConfigured:ge}}catch{}},Kn=async b=>{const V=a.value?.walletType;if(V){const q=Ne.find(ja=>ja.value===V),ge=q?Zl[V]:void 0;if(ge&&b!==ge){const ja=q.label,Jn=Ut.find(Zn=>Zn.value===ge)?.label??ge;if(!confirm(`${ja} preset default is "${Jn}". Changing the approval method may prevent sign requests from being delivered correctly.
2
+
3
+ Proceed with change?`))return}}try{await le(L.WALLET_OWNER(t),{owner_address:a.value.ownerAddress,approval_method:b??null}),await Te(),w("success","Approval method updated")}catch(q){const ge=q instanceof k?q:new k(0,"UNKNOWN","Unknown error");w("error",$(ge.code,ge.serverMessage))}};B(()=>{Te(),ae(),ue(),qe(),la(),Y(),Fn(),_t().then(({currency:b,rate:V})=>{Ue.value=b,$e.value=V}).catch(()=>{})},[t]),B(()=>()=>{S.value&&clearInterval(S.value)},[]),B(()=>{qe()},[_.value]);const St=_.value*sa,Hn=g.value>0?St+1:0,Bn=Math.min(St+sa,g.value),Vn=_.value>0,zn=(_.value+1)*sa<g.value;function Gn(){return a.value?e(J,{children:[e("div",{class:"detail-grid",children:[e(ce,{label:"ID",value:a.value.id,copy:!0}),e(ce,{label:"Public Key",value:a.value.publicKey,copy:!0}),e(ce,{label:"Chain",value:a.value.chain}),e(ce,{label:"Environment",children:e(z,{variant:a.value.environment==="mainnet"?"warning":"info",children:a.value.environment})}),e(ce,{label:"Status",children:e(z,{variant:a.value.status==="ACTIVE"?"success":a.value.status==="SUSPENDED"?"warning":"danger",children:a.value.status})}),a.value.status==="SUSPENDED"&&e(J,{children:[e(ce,{label:"Suspended At",value:a.value.suspendedAt?ve(a.value.suspendedAt):"--"}),e(ce,{label:"Suspension Reason",value:a.value.suspensionReason??"--"})]}),e(ce,{label:"Created",value:ve(a.value.createdAt)}),e(ce,{label:"Updated",value:a.value.updatedAt?ve(a.value.updatedAt):"Never"})]}),e("div",{class:"balance-section",style:{marginTop:"var(--space-6)"},children:[e("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-3)",marginBottom:"var(--space-3)"},children:[e("h3",{style:{margin:0},children:"Balances"}),e(R,{variant:"secondary",size:"sm",onClick:ue,loading:A.value,children:"Refresh"})]}),A.value?e("div",{class:"stat-skeleton",style:{height:"60px"}}):f.value?.balances?.length?e("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-3)"},children:f.value.balances.map(b=>e("div",{style:{padding:"var(--space-3)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",background:"transparent"},children:[e("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)",marginBottom:"var(--space-2)"},children:e("strong",{children:b.network})}),b.error?e("p",{style:{color:"var(--color-text-secondary)",fontSize:"0.85rem"},children:b.error}):b.native?e("div",{children:[e(ce,{label:"Native",children:e("span",{children:[b.native.balance," ",b.native.symbol,b.native.usd!=null&&e("span",{style:{color:"var(--color-text-secondary)",marginLeft:"var(--space-2)",fontSize:"0.85rem"},children:["(",ea(b.native.usd,Ue.value,$e.value),")"]})]})}),b.tokens.length>0?b.tokens.map(V=>e(ce,{label:V.symbol,value:V.balance},V.address)):null]}):e("p",{style:{color:"var(--color-text-secondary)",fontSize:"0.85rem"},children:"Balance unavailable"})]},b.network))}):e("p",{style:{color:"var(--color-text-secondary)"},children:"No balance data available"})]}),e("div",{class:"networks-section",style:{marginTop:"var(--space-6)"},children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"Available Networks"}),u.value?e("div",{class:"stat-skeleton",style:{height:"80px"}}):e("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2)"},children:(v.value??[]).map(b=>e("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"var(--space-2) var(--space-3)",background:"var(--color-bg-secondary)",borderRadius:"var(--radius-md)"},children:e("span",{children:b.name??b.network})},b.network))})]})]}):null}function qn(){return e(J,{children:[e(za,{fields:ti,values:U.value,onChange:b=>{U.value=b},syncUrl:!1}),e("div",{class:"table-container",style:{marginTop:"var(--space-3)"},children:e("table",{children:[e("thead",{children:e("tr",{children:Xa.map(b=>e("th",{children:b},b))})}),e("tbody",{children:x.value&&Fe.value.length===0?e("tr",{children:e("td",{colSpan:Xa.length,class:"table-loading",children:"Loading..."})}):Fe.value.length===0?e("tr",{children:e("td",{colSpan:Xa.length,class:"table-empty",children:"No transactions yet"})}):Fe.value.map(b=>e("tr",{children:[e("td",{children:b.createdAt?ve(b.createdAt):"—"}),e("td",{children:e(z,{variant:"info",children:b.type})}),e("td",{children:b.toAddress?Wa(b.toAddress):"—"}),e("td",{children:b.amount?b.formattedAmount??b.amount:"—"}),e("td",{children:b.network??"—"}),e("td",{children:e(z,{variant:ni(b.status),children:b.status})}),e("td",{children:e(bt,{network:b.network??"",txHash:b.txHash})})]},b.id))})]})}),e("div",{class:"pagination",style:{marginTop:"var(--space-3)"},children:[e("span",{class:"pagination-info",children:["Showing ",Hn,"-",Bn," of ",g.value]}),e("div",{class:"pagination-buttons",children:[e(R,{variant:"secondary",size:"sm",disabled:!Vn,onClick:()=>{_.value=_.value-1},children:"Previous"}),e(R,{variant:"secondary",size:"sm",disabled:!zn,onClick:()=>{_.value=_.value+1},children:"Next"})]})]})]})}function jn(){return a.value?e("div",{class:"owner-section",children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"Owner Wallet"}),a.value.ownerState==="NONE"&&a.value.status!=="TERMINATED"&&e("div",{style:{background:"var(--color-bg-secondary)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"var(--space-3) var(--space-4)",marginBottom:"var(--space-4)"},children:[e("p",{style:{marginBottom:"var(--space-2)",fontWeight:500},children:"What is an Owner Wallet?"}),e("p",{style:{color:"var(--color-text-secondary)",fontSize:"0.85rem",marginBottom:"var(--space-3)"},children:"Register an Owner wallet to enable transaction approval (APPROVAL policy) for high-value transfers. Connect D'CENT, MetaMask, or other WalletConnect-compatible wallets to approve transactions directly."}),e(R,{size:"sm",onClick:wt,children:"Set Owner Address"})]}),P.value&&a.value.ownerState==="NONE"&&e("div",{style:{marginBottom:"var(--space-3)"},children:[e("label",{style:{display:"block",marginBottom:"var(--space-1)",fontSize:"0.85rem",fontWeight:500},children:"Wallet Type"}),e("select",{value:W.value,onChange:b=>{W.value=b.target.value},style:{width:"100%",padding:"var(--space-2) var(--space-3)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",background:"var(--color-bg)",color:"var(--color-text)",fontSize:"0.9rem"},children:[e("option",{value:"",children:"Custom (manual setup)"}),Ne.map(b=>e("option",{value:b.value,children:b.label},b.value))]}),W.value&&e("p",{style:{marginTop:"var(--space-1)",fontSize:"0.8rem",color:"var(--color-text-secondary)"},children:Ne.find(b=>b.value===W.value)?.description}),W.value&&Na[W.value]&&e("p",{style:{marginTop:"var(--space-1)",fontSize:"0.8rem",color:"var(--color-primary)"},children:["Approval: ",Na[W.value]]})]}),e(ce,{label:"Address",children:P.value?e("div",{class:"inline-edit",children:[e("input",{value:y.value,onInput:b=>{y.value=b.target.value},class:"inline-edit-input",placeholder:"Enter owner wallet address"}),e(R,{size:"sm",onClick:Un,loading:p.value,children:"Save"}),e(R,{size:"sm",variant:"secondary",onClick:Wn,children:"Cancel"})]}):e("span",{children:[a.value.ownerAddress?e(J,{children:[Wa(a.value.ownerAddress),e(ya,{value:a.value.ownerAddress})]}):"Not set",a.value.ownerState!=="LOCKED"&&a.value.status==="ACTIVE"&&e("button",{class:"btn btn-ghost btn-sm",onClick:wt,title:"Set owner address",children:"✎"})]})}),e(ce,{label:"State",children:[e(z,{variant:On(a.value.ownerState),children:a.value.ownerState}),a.value.walletType&&e(z,{variant:"info",style:{marginLeft:"var(--space-2)"},children:Ne.find(b=>b.value===a.value.walletType)?.label??a.value.walletType})]}),a.value.ownerState==="GRACE"&&e("div",{style:{marginTop:"var(--space-3)"},children:[e(ce,{label:"Wallet Type",children:H.value?e("div",{class:"inline-edit",children:[e("select",{value:W.value,onChange:b=>{W.value=b.target.value},style:{padding:"var(--space-1) var(--space-2)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",background:"var(--color-bg)",color:"var(--color-text)",fontSize:"0.85rem"},children:[e("option",{value:"",children:"Custom (manual setup)"}),Ne.map(b=>e("option",{value:b.value,children:b.label},b.value))]}),e(R,{size:"sm",onClick:()=>$n(W.value),loading:p.value,children:"Save"}),e(R,{size:"sm",variant:"secondary",onClick:()=>{H.value=!1},children:"Cancel"})]}):e("span",{children:[Ne.find(b=>b.value===a.value.walletType)?.label??a.value.walletType??"Custom",e("button",{class:"btn btn-ghost btn-sm",onClick:()=>{W.value=a.value?.walletType??"",H.value=!0},title:"Change wallet type",children:"✎"})]})}),H.value&&W.value&&Na[W.value]&&e("p",{style:{fontSize:"0.8rem",color:"var(--color-primary)",marginTop:"var(--space-1)"},children:["Approval: ",Na[W.value]]})]}),a.value.ownerState==="LOCKED"&&a.value.walletType&&e(ce,{label:"Wallet Type",children:e("span",{children:Ne.find(b=>b.value===a.value.walletType)?.label??a.value.walletType})}),a.value.ownerState==="GRACE"&&e("div",{style:{background:"var(--color-bg-secondary)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"var(--space-3) var(--space-4)",marginTop:"var(--space-3)"},children:[e("p",{style:{marginBottom:"var(--space-2)",fontWeight:500,fontSize:"0.85rem"},children:"Verify Owner"}),e("p",{style:{color:"var(--color-text-secondary)",fontSize:"0.85rem"},children:"Sign a verification message with the Owner wallet to transition from GRACE to LOCKED. Connect via WalletConnect first, then trigger an APPROVAL-tier transaction or use the CLI/SDK to call the verify endpoint."})]}),a.value.ownerState!=="NONE"&&e("div",{style:{marginTop:"var(--space-4)",paddingTop:"var(--space-3)",borderTop:"1px solid var(--color-border)"},children:[e("h4",{style:{marginBottom:"var(--space-2)",fontSize:"0.9rem"},children:"Approval Method"}),e("p",{style:{color:"var(--color-text-secondary)",fontSize:"0.85rem",marginBottom:"var(--space-3)"},children:'Choose how transaction approvals are delivered to the owner. Leave as "Auto (Global Fallback)" to use the system-wide priority.'}),e("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2)"},children:Ut.map(b=>e("label",{style:{display:"flex",alignItems:"flex-start",gap:"var(--space-2)",padding:"var(--space-2) var(--space-3)",background:a.value?.approvalMethod===b.value?"var(--color-bg-secondary)":"transparent",borderRadius:"var(--radius-md)",cursor:"pointer"},children:[e("input",{type:"radio",name:"approval_method",value:b.value??"",checked:a.value?.approvalMethod===b.value,onChange:()=>Kn(b.value),style:{marginTop:"2px"},disabled:a.value?.ownerState==="LOCKED"}),e("div",{children:[e("div",{style:{fontWeight:500,fontSize:"0.9rem"},children:b.label}),e("div",{style:{color:"var(--color-text-secondary)",fontSize:"0.8rem"},children:b.description}),b.warning&&b.warningCondition?.(j.value)&&e("div",{style:{marginTop:"var(--space-1)",padding:"var(--space-1) var(--space-2)",background:"var(--color-warning-bg, #fff3cd)",border:"1px solid var(--color-warning-border, #ffc107)",borderRadius:"var(--radius-sm)",fontSize:"0.75rem",color:"var(--color-warning-text, #856404)"},children:b.warning})]})]},b.value??"auto"))})]}),a.value?.approvalMethod==="walletconnect"&&e("div",{style:{marginTop:"var(--space-4)",paddingTop:"var(--space-3)",borderTop:"1px solid var(--color-border)"},children:[e("h4",{style:{marginBottom:"var(--space-2)",fontSize:"0.9rem"},children:"WalletConnect"}),T.value?e("div",{class:"stat-skeleton",style:{height:"60px"}}):C.value?e("div",{children:[e(ce,{label:"Status",children:e(z,{variant:"success",children:"Connected"})}),e(ce,{label:"Peer",value:C.value.peerName??"Unknown"}),e(ce,{label:"Chain ID",value:C.value.chainId}),e(ce,{label:"Expires",value:ve(C.value.expiry)}),e("div",{style:{marginTop:"var(--space-3)"},children:e(R,{variant:"danger",onClick:Mn,loading:m.value,children:"Disconnect"})})]}):e("div",{children:[e("p",{style:{marginBottom:"var(--space-3)",color:"var(--color-text-secondary)",fontSize:"0.85rem"},children:"Connect an external wallet (D'CENT, MetaMask, Phantom) via WalletConnect for transaction approval."}),a.value?.ownerAddress?e(R,{onClick:Pn,loading:K.value,children:"Connect Wallet"}):e("p",{style:{color:"var(--color-text-secondary)",fontSize:"0.85rem"},children:"Set an Owner address first to enable WalletConnect."})]})]})]}):null}function Yn(){function b(q){return q==="lido"?"info":"neutral"}function V(q){return q==="COMPLETED"?"success":q==="TIMEOUT"?"danger":"warning"}return e("div",{children:[e("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-3)",marginBottom:"var(--space-3)"},children:[e("h3",{style:{margin:0},children:"Staking Positions"}),e(R,{variant:"secondary",size:"sm",onClick:Y,loading:Ie.value,children:"Refresh"})]}),Ie.value?e("div",{class:"stat-skeleton",style:{height:"80px"}}):Ce.value.length===0?e(Mt,{title:"No staking positions",description:"Stake ETH (Lido) or SOL (Jito) to see positions here."}):e("div",{class:"table-container",children:e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"Protocol"}),e("th",{children:"Asset"}),e("th",{children:"Balance"}),e("th",{children:"Balance (USD)"}),e("th",{children:"APY"}),e("th",{children:"Pending Unstake"})]})}),e("tbody",{children:Ce.value.map(q=>e("tr",{children:[e("td",{children:e(z,{variant:b(q.protocol),children:q.protocol==="lido"?"Lido":"Jito"})}),e("td",{children:q.asset}),e("td",{children:q.chain==="ethereum"?`${(Number(q.balance)/1e18).toFixed(6)} stETH`:`${(Number(q.balance)/1e9).toFixed(6)} JitoSOL`}),e("td",{children:q.balanceUsd?ea(Number(q.balanceUsd),Ue.value,$e.value):"—"}),e("td",{children:q.apy??"—"}),e("td",{children:q.pendingUnstake?e("span",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)"},children:[e(z,{variant:V(q.pendingUnstake.status),children:q.pendingUnstake.status}),e("span",{style:{fontSize:"0.85em",color:"var(--color-text-secondary)"},children:q.chain==="ethereum"?`${(Number(q.pendingUnstake.amount)/1e18).toFixed(4)} stETH`:`${(Number(q.pendingUnstake.amount)/1e9).toFixed(4)} JitoSOL`})]}):"—"})]},`${q.protocol}-${q.chain}`))})]})})]})}function Xn(){return e("div",{class:"mcp-setup-section",children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"MCP Setup"}),o.value?e("div",{children:[e("div",{class:"detail-grid",style:{marginBottom:"var(--space-4)"},children:[e(ce,{label:"Token Path",value:o.value.tokenPath}),e(ce,{label:"Expires At",value:ve(o.value.expiresAt)})]}),e("div",{style:{marginBottom:"var(--space-2)"},children:e("strong",{children:"Claude Desktop Config"})}),e("div",{style:{position:"relative"},children:[e("pre",{children:e("code",{style:{display:"block",whiteSpace:"pre-wrap",wordBreak:"break-all",background:"var(--color-bg-secondary)",padding:"var(--space-3)",borderRadius:"var(--radius-md)",fontSize:"0.85rem",maxHeight:"300px",overflow:"auto"},children:JSON.stringify({mcpServers:o.value.claudeDesktopConfig},null,2)})}),e("div",{style:{marginTop:"var(--space-2)"},children:e(ya,{value:JSON.stringify({mcpServers:o.value.claudeDesktopConfig},null,2),label:"Copy Config"})})]}),e("div",{style:{marginTop:"var(--space-3)"},children:e(R,{variant:"secondary",onClick:O,loading:h.value,children:"Re-provision"})})]}):e("div",{children:[e("p",{style:{marginBottom:"var(--space-3)",color:"var(--color-text-secondary)"},children:"Provision an MCP token for Claude Desktop integration."}),e(R,{onClick:O,loading:h.value,children:"Setup MCP"})]})]})}return e("div",{class:"page",children:[e("a",{href:"#/wallets",class:"back-link",children:"← Back to Wallets"}),n.value?e("div",{class:"stat-skeleton",style:{height:"200px",marginTop:"var(--space-4)"}}):a.value?e("div",{class:"wallet-detail",children:[e("div",{class:"detail-header",children:[e("div",{class:"detail-name",children:l.value?e("div",{class:"inline-edit",children:[e("input",{value:i.value,onInput:b=>{i.value=b.target.value},class:"inline-edit-input"}),e(R,{size:"sm",onClick:M,loading:s.value,children:"Save"}),e(R,{size:"sm",variant:"secondary",onClick:N,children:"Cancel"})]}):e("span",{children:[a.value.name,e("button",{class:"btn btn-ghost btn-sm",onClick:qa,title:"Edit name",children:"✎"})]})}),e("div",{style:{display:"flex",gap:"var(--space-2)"},children:[a.value.status==="ACTIVE"&&e(R,{variant:"secondary",onClick:()=>{se.value=!0},children:"Suspend Wallet"}),a.value.status==="SUSPENDED"&&e(R,{variant:"primary",onClick:Ga,loading:oe.value,children:"Resume Wallet"}),a.value.status!=="TERMINATED"&&e(R,{variant:"danger",onClick:()=>{r.value=!0},children:"Terminate Wallet"})]})]}),e(Ge,{tabs:Ql,activeTab:fe.value,onTabChange:b=>{fe.value=b}}),fe.value==="overview"&&e(Gn,{}),fe.value==="transactions"&&e(qn,{}),fe.value==="owner"&&e(jn,{}),fe.value==="staking"&&e(Yn,{}),fe.value==="mcp"&&e(Xn,{}),e(we,{open:r.value,title:"Terminate Wallet",onCancel:()=>{r.value=!1},onConfirm:ee,confirmText:"Terminate",confirmVariant:"danger",loading:c.value,children:e("p",{children:["Are you sure you want to terminate wallet ",e("strong",{children:a.value.name}),"? This action cannot be undone."]})}),e(we,{open:F.value,title:"Scan QR Code",onCancel:()=>{F.value=!1,S.value&&clearInterval(S.value),S.value=null},children:E.value&&e("div",{style:{textAlign:"center"},children:[e("img",{src:E.value.qrCode,alt:"WalletConnect QR Code",style:{width:"280px",height:"280px",margin:"0 auto"}}),e("p",{style:{marginTop:"var(--space-3)",color:"var(--color-text-secondary)",fontSize:"0.85rem"},children:"Scan with D'CENT, MetaMask, Phantom, or any WalletConnect-compatible wallet"}),e("p",{style:{marginTop:"var(--space-2)",color:"var(--color-text-secondary)",fontSize:"0.75rem"},children:"Waiting for connection..."})]})}),e(we,{open:se.value,title:"Suspend Wallet",onCancel:()=>{se.value=!1,re.value=""},onConfirm:_e,confirmText:"Suspend",confirmVariant:"danger",loading:me.value,children:[e("p",{style:{marginBottom:"var(--space-3)"},children:["Are you sure you want to suspend wallet ",e("strong",{children:a.value.name}),"? Suspended wallets cannot process transactions until resumed."]}),e(I,{label:"Reason (optional)",name:"suspend-reason",value:re.value,onChange:b=>{re.value=b},placeholder:"e.g. suspicious activity"})]})]}):e(Mt,{title:"Wallet not found",description:"The wallet may have been deleted."})]})}const ii={"solana-mainnet":"Solana Mainnet","solana-devnet":"Solana Devnet","solana-testnet":"Solana Testnet","ethereum-mainnet":"Ethereum Mainnet","ethereum-sepolia":"Ethereum Sepolia","polygon-mainnet":"Polygon Mainnet","polygon-amoy":"Polygon Amoy","arbitrum-mainnet":"Arbitrum Mainnet","arbitrum-sepolia":"Arbitrum Sepolia","optimism-mainnet":"Optimism Mainnet","optimism-sepolia":"Optimism Sepolia","base-mainnet":"Base Mainnet","base-sepolia":"Base Sepolia"},Ye=["solana-mainnet","solana-devnet","solana-testnet"],ra=["ethereum-mainnet","ethereum-sepolia","polygon-mainnet","polygon-amoy","arbitrum-mainnet","arbitrum-sepolia","optimism-mainnet","optimism-sepolia","base-mainnet","base-sepolia"];function si(t){if(t<=0)return"";const a=Math.ceil(t/1e3);if(a<60)return`${a}s`;const n=Math.floor(a/60),l=a%60;return l>0?`${n}m ${l}s`:`${n}m`}function ri(t){return Ye.includes(t)?"solana":"evm"}function oi(){const t=d({}),a=d({}),n=d({}),l=d(!1),i=d(!0),s=d({}),r=d({}),c=d({}),h=d({}),o=d({}),v=d({}),u=(m,S)=>{const P={},y=[...Ye,...ra];for(const p of y){const W=[],H=m.rpc_pool;if(H){const re=H[p];if(typeof re=="string"&&re!=="[]")try{const oe=JSON.parse(re);Array.isArray(oe)&&W.push(...oe.filter(fe=>typeof fe=="string"&&fe.length>0))}catch{}}const j=S[p]??[],se=new Set(W),me=[];for(const re of W)me.push({url:re,isBuiltin:j.includes(re),enabled:!0});for(const re of j)se.has(re)||me.push({url:re,isBuiltin:!0,enabled:!0});P[p]=me}return P},f=async()=>{try{try{const P=await G(L.ADMIN_RPC_STATUS);P.builtinUrls&&(h.value=P.builtinUrls),c.value=P.networks??{}}catch{}const m=await G(L.ADMIN_SETTINGS);t.value=m;const S=u(m,h.value);n.value=S,a.value=JSON.parse(JSON.stringify(S))}catch(m){const S=m instanceof k?m:new k(0,"UNKNOWN","Unknown error");w("error",$(S.code))}finally{i.value=!1}};B(()=>{f()},[]),B(()=>{const m=async()=>{try{const P=await G(L.ADMIN_RPC_STATUS);c.value=P.networks??{},P.builtinUrls&&(h.value=P.builtinUrls)}catch{}};m();const S=setInterval(m,15e3);return()=>clearInterval(S)},[]);const A=async(m,S)=>{const P=`${m}:${S}`;o.value={...o.value,[P]:!0};try{const y=await ne(L.ADMIN_SETTINGS_TEST_RPC,{url:S,chain:ri(m)});v.value={...v.value,[P]:y}}catch{v.value={...v.value,[P]:{success:!1,latencyMs:0,error:"Request failed"}}}finally{o.value={...o.value,[P]:!1}}},D=()=>{for(const m of[...Ye,...ra]){const S=n.value[m]??[],P=a.value[m]??[];if(S.length!==P.length)return!0;for(let y=0;y<S.length;y++)if(S[y].url!==P[y].url||S[y].enabled!==P[y].enabled)return!0}return!1},x=Ba(()=>{let m=0;for(const S of[...Ye,...ra]){const P=n.value[S]??[],y=a.value[S]??[];if(P.length!==y.length){m++;continue}for(let p=0;p<P.length;p++)if(P[p].url!==y[p].url||P[p].enabled!==y[p].enabled){m++;break}}return m}),g=async()=>{l.value=!0;try{const m=[];for(const y of[...Ye,...ra]){const W=(a.value[y]??[]).filter(H=>!H.isBuiltin&&H.enabled).map(H=>H.url);m.push({key:`rpc_pool.${y}`,value:JSON.stringify(W)})}const S=await le(L.ADMIN_SETTINGS,{settings:m});t.value=S.settings;const P=u(S.settings);n.value=P,a.value=JSON.parse(JSON.stringify(P)),w("success","RPC settings saved and applied")}catch(m){const S=m instanceof k?m:new k(0,"UNKNOWN","Unknown error");w("error",$(S.code))}finally{l.value=!1}},_=()=>{a.value=JSON.parse(JSON.stringify(n.value))};B(()=>(Ee({id:"wallets-rpc",isDirty:D,save:g,discard:_}),()=>ke("wallets-rpc")),[]);const U=m=>{s.value={...s.value,[m]:!s.value[m]}},F=m=>{const S=(r.value[m]??"").trim();if(!S)return;if(!S.startsWith("https://")){w("warning","URL must start with https://");return}const P=a.value[m]??[];if(P.some(W=>W.url===S)){w("warning","URL already exists in this network");return}const y=[...P];y.findIndex(W=>W.isBuiltin&&!P.slice(0,P.indexOf(W)).some(H=>!H.isBuiltin));const p=y.reduce((W,H,j)=>H.isBuiltin?W:j+1,0);y.splice(p,0,{url:S,isBuiltin:!1,enabled:!0}),a.value={...a.value,[m]:y},r.value={...r.value,[m]:""}},E=(m,S)=>{const P=[...a.value[m]??[]];P[S]?.isBuiltin||(P.splice(S,1),a.value={...a.value,[m]:P})},K=(m,S,P)=>{const y=[...a.value[m]??[]],p=P==="up"?S-1:S+1;if(p<0||p>=y.length)return;const W=y[S],H=y[p];!W||!H||([y[S],y[p]]=[y[p],y[S]],a.value={...a.value,[m]:y})},C=(m,S)=>{const P=[...a.value[m]??[]],y=P[S];y?.isBuiltin&&(P[S]={...y,enabled:!y.enabled},a.value={...a.value,[m]:P})};function T({network:m}){const S=a.value[m]??[],P=s.value[m]??!1,y=S.filter(H=>H.enabled).length,p=c.value[m]??[],W=H=>p.find(j=>j.url===H);return e("details",{class:"rpc-pool-network",open:P,"data-testid":`rpc-network-${m}`,children:[e("summary",{class:"rpc-pool-network-header",onClick:H=>{H.preventDefault(),U(m)},children:[e("span",{children:ii[m]??m}),e("span",{class:"rpc-pool-url-count",children:[y," URL",y!==1?"s":""]})]}),P&&e("div",{class:"rpc-url-list",children:[S.map((H,j)=>{const se=W(H.url),me=`${m}:${H.url}`,re=o.value[me]??!1,oe=v.value[me];return e("div",{class:`rpc-url-item${H.isBuiltin?" rpc-url-item--builtin":""}${H.enabled?"":" rpc-url-disabled"}`,"data-testid":`rpc-url-${m}-${j}`,children:[e("span",{class:"rpc-url-priority",children:["#",j+1]}),e("span",{class:"rpc-url-item-url",title:H.url,children:H.url}),H.isBuiltin&&e("span",{class:"badge-builtin",children:"(built-in)"}),e("span",{class:"rpc-url-status","data-testid":`rpc-status-${m}-${j}`,children:se?se.status==="available"?e(J,{children:[e("span",{class:"rpc-url-status-dot rpc-url-status-dot--available"}),e("span",{children:"Available"})]}):e(J,{children:[e("span",{class:"rpc-url-status-dot rpc-url-status-dot--cooldown"}),e("span",{children:"Cooldown"}),e("span",{class:"rpc-url-cooldown-info",children:[si(se.cooldownRemainingMs)," remaining"]}),e(z,{variant:"warning",children:[se.failureCount," fail",se.failureCount!==1?"s":""]})]}):e(J,{children:[e("span",{class:"rpc-url-status-dot rpc-url-status-dot--unknown"}),e("span",{children:"Unknown"})]})}),e("span",{class:"rpc-url-test-inline",children:[e(R,{variant:"ghost",size:"sm",onClick:()=>A(m,H.url),loading:re,children:"Test"}),oe&&e("span",{class:`rpc-test-result ${oe.success?"rpc-test-result--success":"rpc-test-result--failure"}`,children:[e(z,{variant:oe.success?"success":"danger",children:oe.success?"OK":"FAIL"}),oe.success&&e(J,{children:[" ",oe.latencyMs,"ms",oe.blockNumber!==void 0&&` (block #${oe.blockNumber.toLocaleString()})`]}),oe.error&&` - ${oe.error}`]})]}),e("span",{class:"rpc-url-actions",children:[e("button",{class:"btn btn-ghost btn-sm rpc-action-btn",onClick:()=>K(m,j,"up"),disabled:j===0,title:"Move up","aria-label":"Move up",children:"↑"}),e("button",{class:"btn btn-ghost btn-sm rpc-action-btn",onClick:()=>K(m,j,"down"),disabled:j===S.length-1,title:"Move down","aria-label":"Move down",children:"↓"}),H.isBuiltin?e("button",{class:`btn btn-ghost btn-sm rpc-action-btn${H.enabled?"":" rpc-toggle-off"}`,onClick:()=>C(m,j),title:H.enabled?"Disable":"Enable","aria-label":H.enabled?"Disable":"Enable",children:H.enabled?"On":"Off"}):e("button",{class:"btn btn-ghost btn-sm rpc-action-btn rpc-delete-btn",onClick:()=>E(m,j),title:"Remove","aria-label":"Remove",children:"×"})]})]},`${m}-${j}`)}),e("div",{class:"rpc-add-url",children:[e("input",{type:"text",class:"rpc-add-url-input",placeholder:"https://your-rpc-url.com",value:r.value[m]??"",onInput:H=>{r.value={...r.value,[m]:H.target.value}},onKeyDown:H=>{H.key==="Enter"&&F(m)}}),e(R,{variant:"secondary",size:"sm",onClick:()=>F(m),children:"Add"})]})]})]})}return i.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(J,{children:[x.value>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[x.value," unsaved change",x.value>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(R,{variant:"ghost",size:"sm",onClick:_,children:"Discard"}),e(R,{variant:"primary",size:"sm",onClick:g,loading:l.value,children:"Save"})]})]}),e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"RPC Endpoints"}),e("p",{class:"settings-description",children:"Manage prioritized RPC URL lists per network. User URLs have highest priority; built-in defaults are appended automatically."})]}),e("div",{class:"settings-category-body",children:[e("div",{class:"settings-subgroup",children:[e("div",{class:"settings-subgroup-title",children:"Solana"}),Ye.map(m=>e(T,{network:m},m))]}),e("div",{class:"settings-subgroup",children:[e("div",{class:"settings-subgroup-title",children:"EVM"}),ra.map(m=>e(T,{network:m},m))]})]})]})]})}function ci(){const t=d({}),a=d({}),n=d(!1),l=d(!0),i=async()=>{try{const o=await G(L.ADMIN_SETTINGS);t.value=o}catch(o){const v=o instanceof k?o:new k(0,"UNKNOWN","Unknown error");w("error",$(v.code))}finally{l.value=!1}};B(()=>{i()},[]);const s=(o,v)=>{const u=String(v);a.value={...a.value,[o]:u}},r=async()=>{n.value=!0;try{const o=Object.entries(a.value).filter(([u])=>u.startsWith("walletconnect.")).map(([u,f])=>({key:u,value:f})),v=await le(L.ADMIN_SETTINGS,{settings:o});t.value=v.settings,a.value={},w("success","Settings saved and applied")}catch(o){const v=o instanceof k?o:new k(0,"UNKNOWN","Unknown error");w("error",$(v.code))}finally{n.value=!1}},c=()=>{a.value={}};B(()=>(Ee({id:"wallets-walletconnect",isDirty:()=>Object.keys(a.value).filter(o=>o.startsWith("walletconnect.")).length>0,save:r,discard:c}),()=>ke("wallets-walletconnect")),[]);const h=Object.keys(a.value).filter(o=>o.startsWith("walletconnect.")).length;return l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(J,{children:[h>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[h," unsaved change",h>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(R,{variant:"ghost",size:"sm",onClick:c,children:"Discard"}),e(R,{variant:"primary",size:"sm",onClick:r,loading:n.value,children:"Save"})]})]}),e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"WalletConnect"}),e("p",{class:"settings-description",children:"WalletConnect integration for dApp connections"})]}),e("div",{class:"settings-category-body",children:[e("div",{class:"settings-fields-grid",children:[e("div",{class:"settings-field-full",children:e(I,{label:X("project_id"),name:"walletconnect.project_id",type:"text",value:te(t.value,a.value,"walletconnect","project_id"),onChange:o=>s("walletconnect.project_id",o),description:"WalletConnect Cloud project identifier"})}),e("div",{class:"settings-field-full",children:e(I,{label:X("relay_url"),name:"walletconnect.relay_url",type:"text",value:te(t.value,a.value,"walletconnect","relay_url"),onChange:o=>s("walletconnect.relay_url",o),placeholder:"wss://relay.walletconnect.com",description:"WalletConnect relay server URL"})})]}),e("div",{class:"settings-info-box",children:["Get your project ID from"," ",e("a",{href:"https://cloud.walletconnect.com",target:"_blank",rel:"noopener noreferrer",children:"https://cloud.walletconnect.com"})," ","— Create a free account and project to obtain your project ID."]}),e("div",{class:"settings-info-box",children:"Relay URL defaults to wss://relay.walletconnect.com if not set."})]})]})]})}const di=[{key:"chain",label:"Chain",type:"select",options:[{value:"solana",label:"Solana"},{value:"ethereum",label:"Ethereum"}]},{key:"environment",label:"Environment",type:"select",options:[{value:"testnet",label:"Testnet"},{value:"mainnet",label:"Mainnet"}]},{key:"status",label:"Status",type:"select",options:[{value:"ACTIVE",label:"ACTIVE"},{value:"SUSPENDED",label:"SUSPENDED"},{value:"TERMINATED",label:"TERMINATED"}]}];function ui(){const t=d([]),a=d(!0),n=d(!1),l=d(""),i=d("solana"),s=d("testnet"),r=d(null),c=d(!1),h=d(null),o=d(""),v=d({chain:"",environment:"",status:""}),u=async()=>{try{const _=await G(L.WALLETS);t.value=_.items}catch(_){const U=_ instanceof k?_:new k(0,"UNKNOWN","Unknown error");w("error",$(U.code))}finally{a.value=!1}},f=Ba(()=>{let _=t.value;const U=o.value.toLowerCase();U&&(_=_.filter(E=>E.name.toLowerCase().includes(U)||E.publicKey.toLowerCase().includes(U)));const F=v.value;return F.chain&&(_=_.filter(E=>E.chain===F.chain)),F.environment&&(_=_.filter(E=>E.environment===F.environment)),F.status&&(_=_.filter(E=>E.status===F.status)),_}),A=[{key:"name",header:"Name"},{key:"chain",header:"Chain"},{key:"environment",header:"Environment",render:_=>e(z,{variant:_.environment==="mainnet"?"warning":"info",children:_.environment})},{key:"publicKey",header:"Public Key",render:_=>e("span",{style:{display:"flex",alignItems:"center",gap:"0.25rem"},children:[Wa(_.publicKey)," ",e(ya,{value:_.publicKey})]})},{key:"status",header:"Status",render:_=>e(z,{variant:_.status==="ACTIVE"?"success":_.status==="SUSPENDED"?"warning":"danger",children:_.status})},{key:"ownerState",header:"Owner",render:_=>e(z,{variant:On(_.ownerState),children:_.ownerState})},{key:"createdAt",header:"Created",render:_=>ve(_.createdAt)}],D=async()=>{if(!l.value.trim()){r.value="Name is required";return}r.value=null,c.value=!0;try{const _=await ne(L.WALLETS,{name:l.value.trim(),chain:i.value,environment:s.value});_.session?.token?(h.value=_.session.token,w("success","Wallet created with session")):w("success","Wallet created"),l.value="",i.value="solana",s.value="testnet",n.value=!1,a.value=!0,await u()}catch(_){const U=_ instanceof k?_:new k(0,"UNKNOWN","Unknown error");r.value=$(U.code)}finally{c.value=!1}},x=_=>{window.location.hash="#/wallets/"+_.id},g=_=>{i.value=_};return B(()=>{u()},[]),e(J,{children:[e("div",{class:"page-actions",children:!n.value&&e(R,{onClick:()=>{n.value=!0},children:"Create Wallet"})}),n.value&&e("div",{class:"inline-form",children:[e(I,{label:"Name",name:"name",value:l.value,onChange:_=>{l.value=_},required:!0,placeholder:"e.g. trading-bot",error:r.value??void 0}),e(I,{label:"Chain",name:"chain",type:"select",value:i.value,onChange:g,options:[{label:"Solana",value:"solana"},{label:"Ethereum",value:"ethereum"}]}),e(I,{label:"Environment",name:"environment",type:"select",value:s.value,onChange:_=>{s.value=_},options:[{label:"Testnet",value:"testnet"},{label:"Mainnet",value:"mainnet"}]}),e("div",{class:"inline-form-actions",children:[e(R,{onClick:D,loading:c.value,children:"Create"}),e(R,{variant:"secondary",onClick:()=>{n.value=!1,r.value=null},children:"Cancel"})]})]}),h.value&&e("div",{class:"inline-form",style:{marginBottom:"1rem"},children:[e("div",{style:{fontWeight:"bold",marginBottom:"0.5rem"},children:"Session Token (copy now — shown only once)"}),e("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[e("input",{type:"text",readOnly:!0,value:h.value,style:{flex:1,fontFamily:"monospace",fontSize:"0.85rem",padding:"0.5rem"},onClick:_=>_.target.select()}),e(R,{variant:"secondary",onClick:()=>{navigator.clipboard.writeText(h.value),w("success","Token copied")},children:"Copy"}),e(R,{variant:"secondary",onClick:()=>{h.value=null},children:"Dismiss"})]})]}),e(za,{fields:di,values:v.value,onChange:_=>{v.value=_},syncUrl:!1}),e(xn,{value:o.value,onSearch:_=>{o.value=_},placeholder:"Search by name or public key..."}),e(Ve,{columns:A,data:f.value,loading:a.value,onRowClick:x,emptyMessage:"No wallets yet"})]})}const $t=[{key:"wallets",label:"Wallets"},{key:"rpc",label:"RPC Endpoints"},{key:"walletconnect",label:"WalletConnect"}];function vi(){const t=d("wallets");return B(()=>{const a=ie.value;a&&a.tab&&(t.value=a.tab,setTimeout(()=>{Se.value=a.fieldName},100),ie.value=null)},[ie.value]),e("div",{class:"page",children:[e(na,{pageName:"Wallets",tabName:$t.find(a=>a.key===t.value)?.label??"",onPageClick:()=>{t.value="wallets"}}),e(Ge,{tabs:$t,activeTab:t.value,onTabChange:a=>{t.value=a}}),t.value==="wallets"&&e(ui,{}),t.value==="rpc"&&e(oi,{}),t.value==="walletconnect"&&e(ci,{})]})}function Ft(){const t=Oe.value,a=t.startsWith("/wallets/")?t.slice(9):null;return a?e(li,{id:a}):e(vi,{})}const Kt=[{key:"transactions",label:"All Transactions"},{key:"monitor",label:"Monitor Settings"}],xe=20,hi=[{value:"all",label:"All"},{value:"outgoing",label:"Outgoing"},{value:"incoming",label:"Incoming"}],pi=[{value:"TRANSFER",label:"TRANSFER"},{value:"TOKEN_TRANSFER",label:"TOKEN_TRANSFER"},{value:"CONTRACT_CALL",label:"CONTRACT_CALL"},{value:"APPROVE",label:"APPROVE"},{value:"BATCH",label:"BATCH"}],mi=[{value:"PENDING",label:"PENDING"},{value:"QUEUED",label:"QUEUED"},{value:"APPROVED",label:"APPROVED"},{value:"SUBMITTED",label:"SUBMITTED"},{value:"CONFIRMED",label:"CONFIRMED"},{value:"FAILED",label:"FAILED"},{value:"CANCELLED",label:"CANCELLED"}],fi=[{value:"DETECTED",label:"DETECTED"},{value:"CONFIRMED",label:"CONFIRMED"}],gi=[{value:"solana",label:"Solana"},{value:"evm",label:"EVM"}],yi=[{value:"true",label:"Yes"},{value:"false",label:"No"}],_i=[{value:"solana-mainnet",label:"solana-mainnet"},{value:"solana-devnet",label:"solana-devnet"},{value:"solana-testnet",label:"solana-testnet"},{value:"ethereum-mainnet",label:"ethereum-mainnet"},{value:"ethereum-sepolia",label:"ethereum-sepolia"},{value:"polygon-mainnet",label:"polygon-mainnet"},{value:"polygon-amoy",label:"polygon-amoy"},{value:"arbitrum-mainnet",label:"arbitrum-mainnet"},{value:"arbitrum-sepolia",label:"arbitrum-sepolia"},{value:"optimism-mainnet",label:"optimism-mainnet"},{value:"optimism-sepolia",label:"optimism-sepolia"},{value:"base-mainnet",label:"base-mainnet"},{value:"base-sepolia",label:"base-sepolia"}],Aa=["Time","Direction","Wallet","Counterparty","Amount","Network","Status","Tx Hash"];function bi(t){return t==="CONFIRMED"?"success":t==="FAILED"?"danger":"warning"}function Ht(t){return{id:`out-${t.id}`,direction:"outgoing",time:t.createdAt,walletId:t.walletId,walletName:t.walletName,counterparty:t.toAddress,amount:t.amount,formattedAmount:t.formattedAmount,amountUsd:t.amountUsd,network:t.network??t.chain,status:t.status,txHash:t.txHash,chain:t.chain,outgoing:t}}function Bt(t){return{id:`in-${t.id}`,direction:"incoming",time:t.detectedAt,walletId:t.walletId,walletName:t.walletName,counterparty:t.fromAddress,amount:t.amount,formattedAmount:t.formattedAmount,amountUsd:null,network:t.network,status:t.status,txHash:t.txHash,chain:t.chain,incoming:t}}function Vt(){const t=d("transactions"),a=d([]),n=d(0),l=d(0),i=d(!0),s=d(null),r=d("all"),c=d({wallet_id:"",type:"",status:"",network:"",chain:"",suspicious:"",since:"",until:""}),h=d(""),o=d(0),v=d(null),u=d("USD"),f=d(1),A=d([]),D=d({}),x=d({}),g=d(!1),_=d(!0),U=d([]),F=d(!0),E=d({}),K=d(null),C=(N,O)=>{x.value={...x.value,[N]:String(O)}},T=(N,O)=>te(D.value,x.value,N,O),m=async()=>{g.value=!0;try{const N=Object.entries(x.value).filter(([ae])=>ae.startsWith("incoming.")).map(([ae,ue])=>({key:ae,value:ue}));if(N.length===0){w("info","No changes to save"),g.value=!1;return}const O=await le(L.ADMIN_SETTINGS,{settings:N});D.value=O.settings,x.value={},w("success","Settings saved and applied")}catch(N){const O=N instanceof k?N:new k(0,"UNKNOWN","Unknown error");w("error",$(O.code))}finally{g.value=!1}},S=()=>{x.value={}};B(()=>(Object.keys(x.value).filter(O=>O.startsWith("incoming.")).length>0?Ee({id:"transactions-monitor",isDirty:()=>Object.keys(x.value).filter(O=>O.startsWith("incoming.")).length>0,save:m,discard:S}):ke("transactions-monitor"),()=>ke("transactions-monitor")),[x.value]);function P(){const N=r.value,O=[{key:"wallet_id",label:"Wallet",type:"select",options:A.value}];return(N==="outgoing"||N==="all")&&O.push({key:"type",label:"Type",type:"select",options:pi}),N==="outgoing"?O.push({key:"status",label:"Status",type:"select",options:mi}):N==="incoming"&&O.push({key:"status",label:"Status",type:"select",options:fi}),O.push({key:"network",label:"Network",type:"select",options:_i}),(N==="incoming"||N==="all")&&(O.push({key:"chain",label:"Chain",type:"select",options:gi}),O.push({key:"suspicious",label:"Suspicious",type:"select",options:yi})),O.push({key:"since",label:"Since",type:"date"},{key:"until",label:"Until",type:"date"}),O}const y=async()=>{const N=new URLSearchParams,O=c.value;if(O.wallet_id&&N.set("wallet_id",O.wallet_id),O.type&&N.set("type",O.type),O.status&&r.value!=="all"&&N.set("status",O.status),O.network&&N.set("network",O.network),O.since){const ae=new Date(O.since);isNaN(ae.getTime())||N.set("since",String(Math.floor(ae.getTime()/1e3)))}if(O.until){const ae=new Date(O.until);isNaN(ae.getTime())||(ae.setHours(23,59,59,999),N.set("until",String(Math.floor(ae.getTime()/1e3))))}return h.value&&N.set("search",h.value),N.set("offset",String(o.value*xe)),N.set("limit",String(xe)),G(`${L.ADMIN_TRANSACTIONS}?${N.toString()}`)},p=async()=>{const N=new URLSearchParams,O=c.value;return O.wallet_id&&N.set("wallet_id",O.wallet_id),O.chain&&N.set("chain",O.chain),O.status&&r.value!=="all"&&N.set("status",O.status),O.suspicious&&N.set("suspicious",O.suspicious),N.set("offset",String(o.value*xe)),N.set("limit",String(xe)),G(`${L.ADMIN_INCOMING}?${N.toString()}`)},W=async()=>{i.value=!0,s.value=null;try{const N=r.value;if(N==="outgoing"){const O=await y();a.value=O.items.map(Ht),n.value=O.total,l.value=0}else if(N==="incoming"){const O=await p();a.value=O.items.map(Bt),n.value=0,l.value=O.total}else{const[O,ae]=await Promise.all([y(),p()]),ue=[...O.items.map(Ht),...ae.items.map(Bt)];ue.sort((qe,Fe)=>(Fe.time??0)-(qe.time??0)),a.value=ue,n.value=O.total,l.value=ae.total}}catch(N){N instanceof k?s.value=$(N.code):s.value="An unexpected error occurred."}finally{i.value=!1}},H=async()=>{try{const N=await G(L.WALLETS),O=Array.isArray(N)?N:N.items??[];A.value=O.map(ue=>({value:ue.id,label:ue.name||ue.id.slice(0,8)})),U.value=O;const ae={};for(const ue of O)ae[ue.id]=ue.monitorIncoming??!1;E.value=ae}catch{}finally{F.value=!1}},j=async()=>{try{const N=await G(L.ADMIN_SETTINGS);D.value=N}catch(N){const O=N instanceof k?N:new k(0,"UNKNOWN","Unknown error");w("error",$(O.code))}finally{_.value=!1}};B(()=>{W(),H(),_t().then(({currency:N,rate:O})=>{u.value=N,f.value=O}).catch(()=>{}),j()},[]),B(()=>{W()},[c.value,h.value,o.value,r.value]),B(()=>{const N=ie.value;N&&N.tab&&(t.value=N.tab,ie.value=null,setTimeout(()=>{Se.value=N.fieldName},100))},[ie.value]);function se(N){t.value=N}function me(N){c.value=N,o.value=0}function re(N){h.value=N,o.value=0}function oe(N){r.value=N,o.value=0,c.value={...c.value,type:"",status:"",chain:"",suspicious:""}}function fe(N){v.value=v.value===N.id?null:N.id}function Ue(){o.value>0&&(o.value=o.value-1)}function $e(){const N=n.value+l.value;(o.value+1)*xe<N&&(o.value=o.value+1)}async function Ce(N){if(window.confirm("Are you sure you want to cancel this transaction?"))try{await ne(L.ADMIN_TX_CANCEL(N)),w("success","Transaction cancelled"),await W()}catch(O){const ae=O instanceof k?O:new k(0,"UNKNOWN","Unknown error");w("error",$(ae.code))}}async function Ie(N){if(window.confirm("Are you sure you want to reject this transaction?"))try{await ne(L.ADMIN_TX_REJECT(N)),w("success","Transaction rejected"),await W()}catch(O){const ae=O instanceof k?O:new k(0,"UNKNOWN","Unknown error");w("error",$(ae.code))}}async function Te(N){const O=E.value[N]??!1;K.value=N;try{const ae=await xl(L.WALLET_PATCH(N),{monitorIncoming:!O});E.value={...E.value,[N]:ae.monitorIncoming}}catch(ae){const ue=ae instanceof k?ae:new k(0,"UNKNOWN","Unknown error");w("error",$(ue.code))}finally{K.value=null}}function M(){const N=n.value+l.value,O=o.value*xe,ae=N>0?O+1:0,ue=Math.min(O+xe,N),qe=o.value>0,Fe=(o.value+1)*xe<N;return e(J,{children:[s.value&&e("div",{class:"dashboard-error",children:[e("span",{children:s.value}),e(R,{variant:"secondary",size:"sm",onClick:W,children:"Retry"})]}),e("div",{class:"filter-bar",style:{marginBottom:0},children:e("div",{class:"filter-field",children:[e("label",{children:"Direction"}),e("select",{value:r.value,onChange:Y=>oe(Y.target.value),children:hi.map(Y=>e("option",{value:Y.value,children:Y.label},Y.value))})]})}),e(za,{fields:P(),values:c.value,onChange:me}),r.value!=="incoming"&&e(xn,{value:h.value,onSearch:re,placeholder:"Search by txHash or recipient address..."}),e("div",{class:"table-container",children:e("table",{children:[e("thead",{children:e("tr",{children:Aa.map(Y=>e("th",{children:Y},Y))})}),e("tbody",{children:i.value&&a.value.length===0?e("tr",{children:e("td",{colSpan:Aa.length,class:"table-loading",children:"Loading..."})}):a.value.length===0?e("tr",{children:e("td",{colSpan:Aa.length,class:"table-empty",children:"No transactions found"})}):a.value.map(Y=>e(J,{children:[e("tr",{class:`clickable${v.value===Y.id?" row-expanded":""}`,style:{cursor:"pointer"},onClick:()=>fe(Y),children:[e("td",{children:Y.time?ve(Y.time):"—"}),e("td",{children:e(z,{variant:Y.direction==="outgoing"?"info":"success",children:Y.direction==="outgoing"?"Outgoing":"Incoming"})}),e("td",{children:Y.walletName??Y.walletId.slice(0,8)}),e("td",{children:Y.counterparty?Wa(Y.counterparty):"—"}),e("td",{children:Y.amount?(()=>{const la=Y.formattedAmount??Y.amount;if(Y.amountUsd!=null){const Sa=ea(Y.amountUsd,u.value,f.value);return Sa?`${la} (${Sa})`:la}return la})():"—"}),e("td",{children:Y.network}),e("td",{children:e(z,{variant:bi(Y.status),children:Y.status})}),e("td",{children:e(bt,{network:Y.network,txHash:Y.txHash})})]},Y.id),v.value===Y.id&&e("tr",{class:"row-expand",children:e("td",{colSpan:Aa.length,children:[Y.outgoing?ee(Y.outgoing):null,Y.incoming?_e(Y.incoming):null]})},`${Y.id}-expand`)]}))})]})}),e("div",{class:"pagination",children:[e("span",{class:"pagination-info",children:["Showing ",ae,"-",ue," of ",N]}),e("div",{class:"pagination-buttons",children:[e(R,{variant:"secondary",size:"sm",disabled:!qe,onClick:Ue,children:"Previous"}),e(R,{variant:"secondary",size:"sm",disabled:!Fe,onClick:$e,children:"Next"})]})]})]})}function ee(N){return e("div",{class:"detail-grid",children:[e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"ID"}),e("span",{class:"detail-value",children:N.id})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Wallet ID"}),e("span",{class:"detail-value",children:N.walletId})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Wallet Name"}),e("span",{class:"detail-value",children:N.walletName??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Type"}),e("span",{class:"detail-value",children:N.type})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Status"}),e("span",{class:"detail-value",children:N.status})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Tier"}),e("span",{class:"detail-value",children:N.tier??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"To Address"}),e("span",{class:"detail-value",children:N.toAddress??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Amount"}),e("span",{class:"detail-value",children:N.amount??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Amount USD"}),e("span",{class:"detail-value",children:N.amountUsd!=null?`$${N.amountUsd.toFixed(2)}`:"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Network"}),e("span",{class:"detail-value",children:N.network??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Chain"}),e("span",{class:"detail-value",children:N.chain})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Tx Hash"}),e("span",{class:"detail-value",children:N.txHash??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Created At"}),e("span",{class:"detail-value",children:N.createdAt?ve(N.createdAt):"—"})]}),N.status==="QUEUED"&&e("div",{class:"detail-item",style:{gridColumn:"1 / -1",marginTop:"var(--space-2)"},children:e("div",{style:{display:"flex",gap:"var(--space-2)"},children:[e(R,{variant:"danger",size:"sm",onClick:O=>{O.stopPropagation(),Ce(N.id)},children:"Cancel"}),e(R,{variant:"secondary",size:"sm",onClick:O=>{O.stopPropagation(),Ie(N.id)},children:"Reject"})]})})]})}function _e(N){return e("div",{class:"detail-grid",children:[e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"ID"}),e("span",{class:"detail-value",children:N.id})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Tx Hash"}),e("span",{class:"detail-value",children:N.txHash})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Wallet ID"}),e("span",{class:"detail-value",children:N.walletId})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Wallet Name"}),e("span",{class:"detail-value",children:N.walletName??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"From Address"}),e("span",{class:"detail-value",children:N.fromAddress})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Amount"}),e("span",{class:"detail-value",children:N.amount})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Token Address"}),e("span",{class:"detail-value",children:N.tokenAddress??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Chain"}),e("span",{class:"detail-value",children:N.chain})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Network"}),e("span",{class:"detail-value",children:N.network})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Status"}),e("span",{class:"detail-value",children:N.status})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Block Number"}),e("span",{class:"detail-value",children:N.blockNumber??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Detected At"}),e("span",{class:"detail-value",children:N.detectedAt?ve(N.detectedAt):"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Confirmed At"}),e("span",{class:"detail-value",children:N.confirmedAt?ve(N.confirmedAt):"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Suspicious"}),e("span",{class:"detail-value",children:N.suspicious?"Yes":"No"})]})]})}function Ga(){const N=Object.keys(x.value).filter(O=>O.startsWith("incoming.")).length;return e(J,{children:[N>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[N," unsaved change",N>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(R,{variant:"ghost",size:"sm",onClick:S,children:"Discard"}),e(R,{variant:"primary",size:"sm",onClick:m,loading:g.value,children:"Save"})]})]}),e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Incoming TX Monitoring Settings"}),e("p",{class:"settings-description",children:"Monitor incoming transactions to wallets. Detects native and token transfers, flags suspicious activity (dust attacks, large amounts, unknown tokens)."})]}),e("div",{class:"settings-category-body",children:_.value?e("span",{children:"Loading settings..."}):e(J,{children:[e("div",{class:"settings-fields-grid",children:[e(I,{label:"Monitoring Enabled",name:"incoming.enabled",type:"select",value:T("incoming","enabled")||"false",onChange:O=>C("incoming.enabled",O),options:[{label:"Yes",value:"true"},{label:"No",value:"false"}]}),e(I,{label:"Poll Interval (seconds)",name:"incoming.poll_interval",type:"number",value:Number(T("incoming","poll_interval"))||30,onChange:O=>C("incoming.poll_interval",O),min:5,max:3600}),e(I,{label:"Retention Days",name:"incoming.retention_days",type:"number",value:Number(T("incoming","retention_days"))||90,onChange:O=>C("incoming.retention_days",O),min:1,max:365}),e(I,{label:"Suspicious Dust USD Threshold",name:"incoming.suspicious_dust_usd",type:"number",value:Number(T("incoming","suspicious_dust_usd"))||.01,onChange:O=>C("incoming.suspicious_dust_usd",O),min:0,max:1e3}),e(I,{label:"Suspicious Amount Multiplier",name:"incoming.suspicious_amount_multiplier",type:"number",value:Number(T("incoming","suspicious_amount_multiplier"))||10,onChange:O=>C("incoming.suspicious_amount_multiplier",O),min:1,max:1e3}),e(I,{label:"Notification Cooldown (minutes)",name:"incoming.cooldown_minutes",type:"number",value:Number(T("incoming","cooldown_minutes"))||5,onChange:O=>C("incoming.cooldown_minutes",O),min:1,max:1440}),e(I,{label:"WebSocket URL (optional)",name:"incoming.wss_url",type:"text",value:T("incoming","wss_url"),onChange:O=>C("incoming.wss_url",O),placeholder:"wss://custom-rpc.example.com"})]}),e("div",{class:"settings-info-box",children:"Monitors wallets with incoming monitoring enabled for incoming transactions. Uses WebSocket subscription when available, falls back to polling. Suspicious transactions (dust attacks, unusually large amounts, unknown tokens) trigger broadcast alerts to all notification channels. Changes take effect immediately via hot-reload."})]})})]}),e("div",{class:"settings-category",style:{marginTop:"var(--space-4)"},children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Per-Wallet Monitoring"}),e("p",{class:"settings-description",children:"Enable or disable incoming transaction monitoring for individual wallets"})]}),e("div",{class:"settings-category-body",children:F.value?e("span",{children:"Loading wallets..."}):U.value.length===0?e("p",{class:"empty-text",children:"No wallets found"}):e("div",{class:"table-container",children:e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"Wallet Name"}),e("th",{children:"Chain"}),e("th",{children:"Status"}),e("th",{children:"Monitor Incoming"})]})}),e("tbody",{children:U.value.map(O=>e("tr",{children:[e("td",{children:O.name||O.id.slice(0,8)}),e("td",{children:O.chain}),e("td",{children:e(z,{variant:(O.status??"ACTIVE")==="ACTIVE"?"success":"warning",children:O.status??"ACTIVE"})}),e("td",{children:e(R,{variant:E.value[O.id]?"primary":"secondary",size:"sm",onClick:()=>Te(O.id),loading:K.value===O.id,children:E.value[O.id]?"ON":"OFF"})})]},O.id))})]})})})]})]})}const qa=Kt.find(N=>N.key===t.value)?.label;return e("div",{class:"page",children:[e(na,{pageName:"Transactions",tabName:qa,onPageClick:()=>{t.value="transactions"}}),e(Ge,{tabs:Kt,activeTab:t.value,onTabChange:se}),e("div",{style:{marginTop:"var(--space-4)"},children:t.value==="transactions"?M():Ga()})]})}const wi=["ethereum-mainnet","ethereum-sepolia","polygon-mainnet","polygon-amoy","arbitrum-mainnet","arbitrum-sepolia","optimism-mainnet","optimism-sepolia","base-mainnet","base-sepolia"],Ja=["Symbol","Name","Address","Decimals","Source","Actions"];function Si(t){return t.length<=10?t:`${t.slice(0,6)}...${t.slice(-4)}`}function Ti(){const t=d("ethereum-mainnet"),a=d([]),n=d(!0),l=d(null),i=d(!1),s=d(""),r=d(""),c=d(""),h=d("18"),o=d(!1),v=d(!1),u=d(null),f=_a(null),A=async()=>{n.value=!0,l.value=null;try{const E=await G(`${L.TOKENS}?network=${encodeURIComponent(t.value)}`);a.value=E.tokens}catch(E){E instanceof k?l.value=$(E.code):l.value="An unexpected error occurred.",a.value=[]}finally{n.value=!1}};B(()=>{A()},[t.value]);function D(E){t.value=E.target.value}function x(){s.value="",r.value="",c.value="",h.value="18",v.value=!1,i.value=!1,f.current&&clearTimeout(f.current)}async function g(E){v.value=!0;try{const K=await G(`${L.TOKENS_RESOLVE}?network=${encodeURIComponent(t.value)}&address=${encodeURIComponent(E)}`);r.value=K.symbol,c.value=K.name,h.value=String(K.decimals),w("success",`Resolved: ${K.symbol} (${K.name})`)}catch{}finally{v.value=!1}}function _(E){const K=E.target.value;s.value=K,f.current&&clearTimeout(f.current),/^0x[a-fA-F0-9]{40}$/.test(K)&&(f.current=setTimeout(()=>g(K),500))}async function U(){if(!s.value||!r.value||!c.value){w("error","Please fill in all required fields.");return}o.value=!0;try{await ne(L.TOKENS,{network:t.value,address:s.value,symbol:r.value,name:c.value,decimals:Number(h.value)}),w("success",`Token ${r.value} added successfully.`),x(),await A()}catch(E){E instanceof k?w("error",$(E.code)):w("error","Failed to add token.")}finally{o.value=!1}}async function F(E){u.value=E;try{await Me(L.TOKENS,{network:t.value,address:E}),w("success","Token removed successfully."),await A()}catch(K){K instanceof k?w("error",$(K.code)):w("error","Failed to remove token.")}finally{u.value=null}}return e("div",{class:"page",children:[l.value&&e("div",{class:"dashboard-error",children:[e("span",{children:l.value}),e(R,{variant:"secondary",size:"sm",onClick:A,children:"Retry"})]}),e("div",{class:"filter-bar",children:[e("div",{class:"filter-field",children:[e("label",{children:"Network"}),e("select",{value:t.value,onChange:D,children:wi.map(E=>e("option",{value:E,children:E},E))})]}),e("div",{style:{marginLeft:"auto"},children:e(R,{variant:"primary",size:"sm",onClick:()=>{i.value=!i.value},children:i.value?"Cancel":"Add Token"})})]}),i.value&&e("div",{class:"card",style:{marginTop:"var(--space-3)",padding:"var(--space-4)"},children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"Add Custom Token"}),e("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"var(--space-3)"},children:[e("div",{class:"form-field",children:[e("label",{for:"token-address",children:["Contract Address ",v.value&&e("span",{style:{color:"var(--warning)",fontSize:"0.85em"},children:"(resolving...)"})]}),e("input",{id:"token-address",type:"text",value:s.value,onInput:_,placeholder:"0x... (metadata auto-fetched)"})]}),e("div",{class:"form-field",children:[e("label",{for:"token-symbol",children:"Symbol"}),e("input",{id:"token-symbol",type:"text",value:r.value,onInput:E=>{r.value=E.target.value},placeholder:"e.g. USDC"})]}),e("div",{class:"form-field",children:[e("label",{for:"token-name",children:"Name"}),e("input",{id:"token-name",type:"text",value:c.value,onInput:E=>{c.value=E.target.value},placeholder:"e.g. USD Coin"})]}),e("div",{class:"form-field",children:[e("label",{for:"token-decimals",children:"Decimals"}),e("input",{id:"token-decimals",type:"number",value:h.value,onInput:E=>{h.value=E.target.value},placeholder:"18"})]})]}),e("div",{style:{marginTop:"var(--space-3)",display:"flex",gap:"var(--space-2)"},children:[e(R,{variant:"primary",size:"sm",loading:o.value,onClick:U,children:"Submit"}),e(R,{variant:"secondary",size:"sm",onClick:x,children:"Cancel"})]})]}),e("div",{class:"table-container",style:{marginTop:"var(--space-3)"},children:e("table",{children:[e("thead",{children:e("tr",{children:Ja.map(E=>e("th",{children:E},E))})}),e("tbody",{children:n.value&&a.value.length===0?e("tr",{children:e("td",{colSpan:Ja.length,class:"table-loading",children:"Loading..."})}):a.value.length===0?e("tr",{children:e("td",{colSpan:Ja.length,class:"table-empty",children:"No tokens found for this network"})}):a.value.map(E=>e("tr",{children:[e("td",{children:E.symbol}),e("td",{children:E.name}),e("td",{title:E.address,children:Si(E.address)}),e("td",{children:E.decimals}),e("td",{children:e(z,{variant:E.source==="builtin"?"neutral":"info",children:E.source==="builtin"?"Built-in":"Custom"})}),e("td",{children:E.source==="custom"?e(R,{variant:"danger",size:"sm",loading:u.value===E.address,onClick:()=>F(E.address),children:"Delete"}):"—"})]},E.address))})]})})]})}function Re({legend:t,children:a,description:n}){return e("fieldset",{class:"field-group",children:[e("legend",{class:"field-group-legend",children:t}),n&&e("p",{class:"field-group-description",children:n}),e("div",{class:"field-group-body",children:a})]})}function ki(t,a,n){a.value=t,n.value=!0}const zt=[{key:"sessions",label:"Sessions"},{key:"settings",label:"Settings"}],Za=["security.max_sessions_per_wallet","security.max_pending_tx","security.rate_limit_session_rpm","security.rate_limit_tx_rpm"];function Ni(){const t=d({}),a=d({}),n=d(!1),l=d(!0),i=async()=>{try{const o=await G(L.ADMIN_SETTINGS);t.value=o}catch(o){const v=o instanceof k?o:new k(0,"UNKNOWN","Unknown error");w("error",$(v.code))}finally{l.value=!1}};B(()=>{i()},[]);const s=(o,v)=>{const u=String(v);a.value={...a.value,[o]:u}},r=async()=>{n.value=!0;try{const o=Object.entries(a.value).filter(([u])=>Za.includes(u)).map(([u,f])=>({key:u,value:f})),v=await le(L.ADMIN_SETTINGS,{settings:o});t.value=v.settings,a.value={},w("success","Session settings saved and applied")}catch(o){const v=o instanceof k?o:new k(0,"UNKNOWN","Unknown error");w("error",$(v.code))}finally{n.value=!1}},c=()=>{a.value={}};B(()=>(Ee({id:"sessions-settings",isDirty:()=>Object.keys(a.value).filter(o=>Za.includes(o)).length>0,save:r,discard:c}),()=>ke("sessions-settings")),[]);const h=Object.keys(a.value).filter(o=>Za.includes(o)).length;return l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(J,{children:[h>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[h," unsaved change",h>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(R,{variant:"ghost",size:"sm",onClick:c,children:"Discard"}),e(R,{variant:"primary",size:"sm",onClick:r,loading:n.value,children:"Save"})]})]}),e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Session Configuration"}),e("p",{class:"settings-description",children:"Configure session lifetime, renewal limits, and request rate limiting. Changes apply immediately without daemon restart."})]}),e("div",{class:"settings-category-body",children:[e(Re,{legend:"Limits",description:"Session concurrency limits",children:e("div",{class:"settings-fields-grid",children:e(I,{label:X("max_sessions_per_wallet"),name:"security.max_sessions_per_wallet",type:"number",value:Number(te(t.value,a.value,"security","max_sessions_per_wallet"))||0,onChange:o=>s("security.max_sessions_per_wallet",o),min:1,max:100,description:"Maximum concurrent sessions for a single wallet"})})}),e(Re,{legend:"Rate Limits",description:"Request throttling per session and transaction",children:e("div",{class:"settings-fields-grid",children:[e(I,{label:X("max_pending_tx"),name:"security.max_pending_tx",type:"number",value:Number(te(t.value,a.value,"security","max_pending_tx"))||0,onChange:o=>s("security.max_pending_tx",o),min:1,max:100,description:"Maximum in-flight transactions per session"}),e(I,{label:X("rate_limit_session_rpm"),name:"security.rate_limit_session_rpm",type:"number",value:Number(te(t.value,a.value,"security","rate_limit_session_rpm"))||0,onChange:o=>s("security.rate_limit_session_rpm",o),min:10,description:"Max requests per minute per session"}),e(I,{label:X("rate_limit_tx_rpm"),name:"security.rate_limit_tx_rpm",type:"number",value:Number(te(t.value,a.value,"security","rate_limit_tx_rpm"))||0,onChange:o=>s("security.rate_limit_tx_rpm",o),min:1,description:"Max transaction requests per minute per session"})]})})]})]})]})}function Ai(){const t=d("sessions");B(()=>{const y=ie.value;y&&y.tab&&(t.value=y.tab,setTimeout(()=>{Se.value=y.fieldName},100),ie.value=null)},[ie.value]);const a=d([]),n=d(""),l=d(""),i=d([]),s=d(!1),r=d(!0),c=d(!1),h=d(!1),o=d(""),v=d(!1),u=d(""),f=d(!1),A=d(null),D=d(!1),x=d(new Set),g=d(!1),_=d(""),U=d(""),F=d(""),E=async()=>{try{const y=await G(L.WALLETS);a.value=y.items.filter(p=>p.status==="ACTIVE")}catch(y){const p=y instanceof k?y:new k(0,"UNKNOWN","Unknown error");w("error",$(p.code))}finally{r.value=!1}},K=async()=>{s.value=!0;try{const y=n.value?`${L.SESSIONS}?walletId=${n.value}`:L.SESSIONS,p=await G(y);i.value=p}catch(y){const p=y instanceof k?y:new k(0,"UNKNOWN","Unknown error");w("error",$(p.code))}finally{s.value=!1}},C=y=>{const p=new Set(x.value);p.has(y)?p.delete(y):p.add(y),x.value=p},T=async()=>{c.value=!0;try{const y=Array.from(x.value),p=y.length===1?{walletId:y[0]}:{walletIds:y},W=Number(_.value);W>0&&(p.ttl=W*86400);const H=Number(U.value);U.value!==""&&H>=0&&(p.maxRenewals=H);const j=Number(F.value);j>0&&(p.absoluteLifetime=j*86400);const se=await ne(L.SESSIONS,p);o.value=se.token,h.value=!0,D.value=!1,g.value=!1,_.value="",U.value="",F.value="",await K()}catch(y){const p=y instanceof k?y:new k(0,"UNKNOWN","Unknown error");w("error",$(p.code))}finally{c.value=!1}},m=async()=>{f.value=!0;try{await Me(L.SESSION(u.value)),w("success","Session revoked"),v.value=!1,await K()}catch(y){const p=y instanceof k?y:new k(0,"UNKNOWN","Unknown error");w("error",$(p.code))}finally{f.value=!1}},S=async y=>{A.value=y;try{const p=await ne(L.ADMIN_SESSION_REISSUE(y),{});o.value=p.token,h.value=!0,await K()}catch(p){const W=p instanceof k?p:new k(0,"UNKNOWN","Unknown error");w("error",$(W.code))}finally{A.value=null}};B(()=>{E()},[]),B(()=>{i.value=[],K()},[n.value]);const P=[{key:"id",header:"ID",render:y=>y.id.slice(0,8)+"..."},{key:"walletName",header:"Wallet",render:y=>y.wallets&&y.wallets.length>0?e("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:y.wallets.map(p=>e("span",{children:p.name??p.id.slice(0,8)},p.id))}):y.walletName??y.walletId.slice(0,8)+"..."},{key:"source",header:"Source",render:y=>e(z,{variant:y.source==="mcp"?"info":"neutral",children:y.source==="mcp"?"MCP":"API"})},{key:"status",header:"Status",render:y=>e(z,{variant:y.status==="ACTIVE"?"success":y.status==="EXPIRED"?"warning":"danger",children:y.status})},{key:"expiresAt",header:"Expires At",render:y=>y.expiresAt===0?"Never":ve(y.expiresAt)},{key:"renewals",header:"Renewals",render:y=>`${y.renewalCount}/${y.maxRenewals}`},{key:"tokenIssuedCount",header:"Tokens",render:y=>String(y.tokenIssuedCount??1)},{key:"createdAt",header:"Created",render:y=>ve(y.createdAt)},{key:"actions",header:"Actions",render:y=>y.status==="ACTIVE"?e("div",{style:{display:"flex",gap:"var(--space-1)"},children:[e(R,{size:"sm",variant:"secondary",onClick:()=>S(y.id),loading:A.value===y.id,children:"Reissue"}),e(R,{size:"sm",variant:"danger",onClick:()=>ki(y.id,u,v),children:"Revoke"})]}):null}];return e("div",{class:"page",children:[e(na,{pageName:"Sessions",tabName:zt.find(y=>y.key===t.value)?.label??"",onPageClick:()=>{t.value="sessions"}}),e(Ge,{tabs:zt,activeTab:t.value,onTabChange:y=>{t.value=y}}),t.value==="sessions"&&e(J,{children:[e("div",{class:"session-controls",children:[e("div",{class:"session-wallet-select",children:[e("label",{for:"wallet-select",children:"Wallet"}),e("select",{id:"wallet-select",value:n.value,onChange:y=>{n.value=y.target.value},disabled:r.value,children:[e("option",{value:"",children:"All Wallets"}),a.value.map(y=>e("option",{value:y.id,children:[y.name," (",y.chain,"/",y.network,")"]},y.id))]})]}),e("div",{class:"session-wallet-select",children:[e("label",{for:"source-select",children:"Source"}),e("select",{id:"source-select",value:l.value,onChange:y=>{l.value=y.target.value},children:[e("option",{value:"",children:"All"}),e("option",{value:"api",children:"API"}),e("option",{value:"mcp",children:"MCP"})]})]}),e(R,{onClick:()=>{x.value=new Set,D.value=!0},disabled:a.value.length===0,children:"Create Session"})]}),e(Ve,{columns:P,data:l.value?i.value.filter(y=>y.source===l.value):i.value,loading:s.value,emptyMessage:"No sessions"}),e(we,{open:h.value,title:"Session Created",onCancel:()=>{h.value=!1},cancelText:"Close",children:[e("p",{class:"token-warning",children:"Copy this token now. It will not be shown again."}),e("div",{class:"token-display",children:[e("code",{class:"token-value",children:o.value}),e(ya,{value:o.value,label:"Copy Token"})]})]}),e(we,{open:v.value,title:"Revoke Session",onCancel:()=>{v.value=!1},onConfirm:m,confirmText:"Revoke",confirmVariant:"danger",loading:f.value,children:e("p",{children:"Are you sure you want to revoke this session? The associated token will be immediately invalidated."})}),e(we,{open:D.value,title:"Create Session",onCancel:()=>{D.value=!1},onConfirm:T,confirmText:`Create Session (${x.value.size} wallet${x.value.size!==1?"s":""})`,confirmDisabled:x.value.size===0,loading:c.value,children:[e("div",{children:[e("label",{style:{fontWeight:600,display:"block",marginBottom:"var(--space-2)"},children:"Select Wallets"}),e("div",{style:{maxHeight:"250px",overflow:"auto",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"var(--space-2)"},children:a.value.map(y=>e("label",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)",padding:"var(--space-1) 0",cursor:"pointer"},children:[e("input",{type:"checkbox",checked:x.value.has(y.id),onChange:()=>C(y.id)}),e("span",{children:y.name}),e("span",{style:{color:"var(--color-text-secondary)",fontSize:"0.8rem"},children:["(",y.chain,"/",y.network,")"]})]},y.id))})]}),e("div",{style:{marginTop:"var(--space-3)"},children:[e("button",{type:"button",onClick:()=>{g.value=!g.value},style:{background:"none",border:"none",color:"var(--color-primary)",cursor:"pointer",padding:0,fontSize:"0.85rem"},children:[g.value?"Hide":"Show"," Advanced Options"]}),g.value&&e("div",{style:{marginTop:"var(--space-2)",display:"grid",gap:"var(--space-2)"},children:[e(I,{label:"TTL (days)",name:"create-ttl",type:"number",value:_.value,onChange:y=>{_.value=String(y)},min:0,description:"Leave empty for unlimited session",placeholder:"Unlimited"}),e(I,{label:"Max Renewals",name:"create-max-renewals",type:"number",value:U.value,onChange:y=>{U.value=String(y)},min:0,description:"0 = unlimited renewals",placeholder:"Unlimited"}),e(I,{label:"Absolute Lifetime (days)",name:"create-lifetime",type:"number",value:F.value,onChange:y=>{F.value=String(y)},min:0,description:"Leave empty for unlimited lifetime",placeholder:"Unlimited"})]})]})]})]}),t.value==="settings"&&e(Ni,{})]})}const Ei={"solana-mainnet":"SOL","solana-devnet":"SOL","solana-testnet":"SOL","ethereum-mainnet":"ETH","ethereum-sepolia":"ETH","polygon-mainnet":"POL","polygon-amoy":"POL","arbitrum-mainnet":"ETH","arbitrum-sepolia":"ETH","optimism-mainnet":"ETH","optimism-sepolia":"ETH","base-mainnet":"ETH","base-sepolia":"ETH"};function Ci(t){return t&&Ei[t]||"Native"}const Gt=["ethereum-mainnet","ethereum-sepolia","polygon-mainnet","polygon-amoy","arbitrum-mainnet","arbitrum-sepolia","optimism-mainnet","optimism-sepolia","base-mainnet","base-sepolia"];function Ii({rules:t,onChange:a,errors:n,network:l}){const i=d([]),s=d(!1),r=g=>_=>{a({...t,[g]:_})},c=g=>_=>{const U=Number(_),F={...t};_===""||_===0||Number.isNaN(U)?delete F[g]:F[g]=U,a(F)},h=t.token_limits||{},o=g=>_=>{const U=String(_),E={...h.native||{instant_max:"",notify_max:"",delay_max:""},[g]:U};if(!E.instant_max&&!E.notify_max&&!E.delay_max){const K={...h};delete K.native,a({...t,token_limits:Object.keys(K).length>0?K:void 0})}else a({...t,token_limits:{...h,native:E}})},v=(g,_,U)=>{const E={...h[g]||{instant_max:"0",notify_max:"0",delay_max:"0"},[_]:U};a({...t,token_limits:{...h,[g]:E}})},u=g=>{const _={...h};delete _[g],a({...t,token_limits:Object.keys(_).length>0?_:void 0})},f=g=>{if(!g||h[g])return;const _={instant_max:"0",notify_max:"0",delay_max:"0"};a({...t,token_limits:{...h,[g]:_}})},A=()=>{const g=prompt("Enter CAIP-19 asset ID (e.g., eip155:1/erc20:0xa0b8...)");if(!g||h[g])return;const _={instant_max:"0",notify_max:"0",delay_max:"0"};a({...t,token_limits:{...h,[g]:_}})};B(()=>{if(!l){i.value=[];return}if(!Gt.includes(l)){i.value=[];return}s.value=!0,G(`${L.TOKENS}?network=${l}`).then(g=>{i.value=g.tokens}).catch(()=>{i.value=[]}).finally(()=>{s.value=!1})},[l]);const D=Object.entries(h).filter(([g])=>g!=="native").map(([g,_])=>({assetId:g,symbol:i.value.find(U=>U.assetId===g)?.symbol||g.split("/").pop()?.split(":").pop()||g,instant_max:_.instant_max,notify_max:_.notify_max,delay_max:_.delay_max})),x=Ci(l);return e("div",{class:"policy-form-fields",children:[e("h4",{children:"USD Amount Tiers"}),e("div",{class:"policy-form-grid",children:[e(I,{label:"Instant Max USD",name:"instant_max_usd",type:"number",value:t.instant_max_usd??"",onChange:c("instant_max_usd"),placeholder:"Optional"}),e(I,{label:"Notify Max USD",name:"notify_max_usd",type:"number",value:t.notify_max_usd??"",onChange:c("notify_max_usd"),placeholder:"Optional"}),e(I,{label:"Delay Max USD",name:"delay_max_usd",type:"number",value:t.delay_max_usd??"",onChange:c("delay_max_usd"),placeholder:"Optional"})]}),e("h4",{children:"Token-Specific Limits"}),e("h5",{children:["Native Token (",x,")"]}),e("div",{class:"policy-form-grid",children:[e(I,{label:`Instant Max (${x})`,name:"native_instant_max",value:h.native?.instant_max??"",onChange:o("instant_max"),placeholder:"e.g. 0.5",error:n["token_limits.native.instant_max"]}),e(I,{label:`Notify Max (${x})`,name:"native_notify_max",value:h.native?.notify_max??"",onChange:o("notify_max"),placeholder:"e.g. 0.5",error:n["token_limits.native.notify_max"]}),e(I,{label:`Delay Max (${x})`,name:"native_delay_max",value:h.native?.delay_max??"",onChange:o("delay_max"),placeholder:"e.g. 0.5",error:n["token_limits.native.delay_max"]})]}),e("p",{class:"form-description",children:"Human-readable amounts (e.g., 0.5 SOL, not lamports/wei)"}),e("h5",{style:{marginTop:"1rem"},children:"Custom Token Limits"}),D.map((g,_)=>e("div",{class:"token-limit-row",style:{border:"1px solid var(--border)",borderRadius:"0.5rem",padding:"0.75rem",marginBottom:"0.5rem"},children:[e("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"0.5rem"},children:[e("strong",{children:g.symbol}),e("span",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",flex:1,marginLeft:"0.5rem",overflow:"hidden",textOverflow:"ellipsis"},children:g.assetId}),e("button",{class:"btn btn-ghost btn-sm",onClick:()=>u(g.assetId),title:"Remove",children:"x"})]}),e("div",{class:"policy-form-grid",children:[e(I,{label:"Instant Max",name:`token-${_}-instant`,value:g.instant_max,onChange:U=>v(g.assetId,"instant_max",String(U)),placeholder:"e.g. 100",error:n[`token_limits.${g.assetId}.instant_max`]}),e(I,{label:"Notify Max",name:`token-${_}-notify`,value:g.notify_max,onChange:U=>v(g.assetId,"notify_max",String(U)),placeholder:"e.g. 500",error:n[`token_limits.${g.assetId}.notify_max`]}),e(I,{label:"Delay Max",name:`token-${_}-delay`,value:g.delay_max,onChange:U=>v(g.assetId,"delay_max",String(U)),placeholder:"e.g. 1000",error:n[`token_limits.${g.assetId}.delay_max`]})]})]},g.assetId)),l&&Gt.includes(l)&&i.value.length>0&&e("div",{style:{display:"flex",gap:"0.5rem",alignItems:"flex-end",marginTop:"0.5rem"},children:e(I,{label:"Select Token",name:"add-token-select",type:"select",value:"",onChange:g=>f(g),options:[{label:s.value?"Loading...":"-- Select a token --",value:""},...i.value.filter(g=>g.assetId&&!h[g.assetId]).map(g=>({label:`${g.symbol} (${g.name})`,value:g.assetId}))]})}),e("button",{class:"btn btn-secondary btn-sm",style:{marginTop:"0.5rem"},onClick:A,children:"+ Add Token Limit (manual CAIP-19)"}),e("h4",{children:"Cumulative USD Limits (Optional)"}),e("div",{class:"policy-form-grid",children:[e(I,{label:"Daily Limit USD (24h rolling)",name:"daily_limit_usd",type:"number",value:t.daily_limit_usd??"",onChange:c("daily_limit_usd"),placeholder:"e.g. 500",error:n.daily_limit_usd}),e(I,{label:"Monthly Limit USD (30d rolling)",name:"monthly_limit_usd",type:"number",value:t.monthly_limit_usd??"",onChange:c("monthly_limit_usd"),placeholder:"e.g. 5000",error:n.monthly_limit_usd})]}),e("h4",{children:["Legacy Raw Tiers ",e("span",{class:"badge badge-warning",children:"Deprecated"})]}),e("p",{class:"form-description",children:"Raw tiers use lamports/wei units and apply uniformly to all tokens. Use USD Tiers or Token-Specific Limits instead. These fields will be removed in a future version."}),e("div",{class:"policy-form-grid",children:[e(I,{label:"Instant Max (lamports/wei)",name:"instant_max",value:t.instant_max||"",onChange:r("instant_max"),error:n.instant_max}),e(I,{label:"Notify Max (lamports/wei)",name:"notify_max",value:t.notify_max||"",onChange:r("notify_max"),error:n.notify_max}),e(I,{label:"Delay Max (lamports/wei)",name:"delay_max",value:t.delay_max||"",onChange:r("delay_max"),error:n.delay_max})]}),e(I,{label:"Delay Duration (seconds, min 60)",name:"delay_seconds",type:"number",value:t.delay_seconds??900,onChange:r("delay_seconds"),error:n.delay_seconds,required:!0,min:60})]})}function We({items:t,onAdd:a,onRemove:n,renderRow:l,onChange:i,addLabel:s="+ Add",minItems:r=0,error:c}){return e("div",{class:"dynamic-row-list",children:[t.map((h,o)=>e("div",{class:"dynamic-row",children:[e("div",{class:"dynamic-row-fields",children:l(h,o,i)}),e("button",{class:"btn btn-ghost btn-sm dynamic-row-remove",onClick:()=>n(o),disabled:t.length<=r,title:"Remove",children:"x"})]},o)),e("button",{class:"btn btn-secondary btn-sm",onClick:a,children:s}),c&&e("span",{class:"form-error",children:c})]})}function Di({rules:t,onChange:a,errors:n}){const l=t.allowed_addresses||[];return e("div",{class:"policy-form-fields",children:e(We,{items:l,onAdd:()=>a({...t,allowed_addresses:[...l,""]}),onRemove:i=>a({...t,allowed_addresses:l.filter((s,r)=>r!==i)}),onChange:(i,s)=>{const r=[...l];r[i]=s,a({...t,allowed_addresses:r})},renderRow:(i,s,r)=>e(I,{label:`Address ${s+1}`,name:`address-${s}`,value:i,onChange:c=>r(s,c),placeholder:"Wallet address",error:n[`allowed_addresses.${s}`],required:!0}),addLabel:"+ Add Address",error:n.allowed_addresses})})}function xi({rules:t,onChange:a,errors:n}){const l=i=>s=>{a({...t,[i]:s})};return e("div",{class:"policy-form-fields",children:[e(I,{label:"Max Requests",name:"max_requests",type:"number",value:t.max_requests??100,onChange:l("max_requests"),error:n.max_requests,required:!0,min:1}),e(I,{label:"Window (seconds)",name:"window_seconds",type:"number",value:t.window_seconds??3600,onChange:l("window_seconds"),error:n.window_seconds,required:!0,min:1})]})}function Oi({rules:t,onChange:a,errors:n}){const l=i=>{const s={...t};i===""||i===void 0?delete s.maxAmount:s.maxAmount=i,a(s)};return e("div",{class:"policy-form-fields",children:[e(I,{label:"Max Amount (lamports/wei, optional)",name:"maxAmount",value:t.maxAmount??"",onChange:l,error:n.maxAmount,placeholder:"Leave empty for no limit"}),e(I,{label:"Block Unlimited Approvals",name:"blockUnlimited",type:"checkbox",value:t.blockUnlimited??!0,onChange:i=>a({...t,blockUnlimited:i})})]})}const Li=[{label:"Instant",value:"INSTANT"},{label:"Notify",value:"NOTIFY"},{label:"Delay",value:"DELAY"},{label:"Approval",value:"APPROVAL"}];function Ri({rules:t,onChange:a,errors:n}){return e("div",{class:"policy-form-fields",children:e(I,{label:"Override Tier",name:"tier",type:"select",value:t.tier??"DELAY",onChange:l=>a({...t,tier:l}),options:Li,error:n.tier})})}const Pi=[{label:"All Chains",value:""},{label:"Solana",value:"solana"},{label:"Ethereum",value:"ethereum"}];function Mi({rules:t,onChange:a,errors:n}){const l=t.tokens||[];return e("div",{class:"policy-form-fields",children:e(We,{items:l,onAdd:()=>a({...t,tokens:[...l,{address:"",symbol:"",chain:""}]}),onRemove:i=>a({...t,tokens:l.filter((s,r)=>r!==i)}),onChange:(i,s)=>{const r=[...l];r[i]=s,a({...t,tokens:r})},renderRow:(i,s,r)=>e("div",{class:"dynamic-row-fields",style:{display:"flex",gap:"0.5rem",flex:1},children:[e(I,{label:`Address ${s+1}`,name:`token-addr-${s}`,value:i.address,onChange:c=>r(s,{...i,address:c}),placeholder:"Token mint/contract address",error:n[`tokens.${s}.address`],required:!0}),e(I,{label:"Symbol",name:`token-symbol-${s}`,value:i.symbol,onChange:c=>r(s,{...i,symbol:c}),placeholder:"e.g. USDC"}),e(I,{label:"Chain",name:`token-chain-${s}`,type:"select",value:i.chain,onChange:c=>{const h={...i,chain:c};c||delete h.chain,r(s,h)},options:Pi})]}),addLabel:"+ Add Token",error:n.tokens})})}const Wi=[{label:"All Chains",value:""},{label:"Solana",value:"solana"},{label:"Ethereum",value:"ethereum"}];function Ui({rules:t,onChange:a,errors:n}){const l=t.contracts||[];return e("div",{class:"policy-form-fields",children:e(We,{items:l,onAdd:()=>a({...t,contracts:[...l,{address:"",name:"",chain:""}]}),onRemove:i=>a({...t,contracts:l.filter((s,r)=>r!==i)}),onChange:(i,s)=>{const r=[...l];r[i]=s,a({...t,contracts:r})},renderRow:(i,s,r)=>e("div",{class:"dynamic-row-fields",style:{display:"flex",gap:"0.5rem",flex:1},children:[e(I,{label:`Address ${s+1}`,name:`contract-addr-${s}`,value:i.address,onChange:c=>r(s,{...i,address:c}),placeholder:"Contract address",error:n[`contracts.${s}.address`],required:!0}),e(I,{label:"Name",name:`contract-name-${s}`,value:i.name,onChange:c=>r(s,{...i,name:c}),placeholder:"e.g. Uniswap Router"}),e(I,{label:"Chain",name:`contract-chain-${s}`,type:"select",value:i.chain,onChange:c=>{const h={...i,chain:c};c||delete h.chain,r(s,h)},options:Wi})]}),addLabel:"+ Add Contract",error:n.contracts})})}function $i({rules:t,onChange:a,errors:n}){const l=t.methods||[],i=s=>{a({...t,methods:s})};return e("div",{class:"policy-form-fields",children:e(We,{items:l,onAdd:()=>i([...l,{contractAddress:"",selectors:[""]}]),onRemove:s=>i(l.filter((r,c)=>c!==s)),onChange:(s,r)=>{const c=[...l];c[s]=r,i(c)},renderRow:(s,r,c)=>e("div",{style:{flex:1},children:[e(I,{label:`Contract Address ${r+1}`,name:`method-addr-${r}`,value:s.contractAddress,onChange:h=>c(r,{...s,contractAddress:h}),placeholder:"Contract address",error:n[`methods.${r}.contractAddress`],required:!0}),e("div",{style:{marginTop:"0.5rem",marginLeft:"1rem"},children:[e("label",{style:{fontSize:"0.85rem",fontWeight:500},children:"Selectors"}),e(We,{items:s.selectors,onAdd:()=>c(r,{...s,selectors:[...s.selectors,""]}),onRemove:h=>c(r,{...s,selectors:s.selectors.filter((o,v)=>v!==h)}),onChange:(h,o)=>{const v=[...s.selectors];v[h]=o,c(r,{...s,selectors:v})},renderRow:(h,o,v)=>e(I,{label:`Selector ${o+1}`,name:`method-sel-${r}-${o}`,value:h,onChange:u=>v(o,u),placeholder:"e.g. 0xa9059cbb or transfer(address,uint256)",error:n[`methods.${r}.selectors.${o}`],required:!0}),addLabel:"+ Add Selector",error:n[`methods.${r}.selectors`]})]})]}),addLabel:"+ Add Method Entry",error:n.methods})})}function Fi({rules:t,onChange:a,errors:n}){const l=t.spenders||[];return e("div",{class:"policy-form-fields",children:e(We,{items:l,onAdd:()=>a({...t,spenders:[...l,{address:"",name:"",maxAmount:""}]}),onRemove:i=>a({...t,spenders:l.filter((s,r)=>r!==i)}),onChange:(i,s)=>{const r=[...l];r[i]=s,s.maxAmount||delete r[i].maxAmount,a({...t,spenders:r})},renderRow:(i,s,r)=>e("div",{class:"dynamic-row-fields",style:{display:"flex",gap:"0.5rem",flex:1},children:[e(I,{label:`Address ${s+1}`,name:`spender-addr-${s}`,value:i.address,onChange:c=>r(s,{...i,address:c}),placeholder:"Spender address",error:n[`spenders.${s}.address`],required:!0}),e(I,{label:"Name",name:`spender-name-${s}`,value:i.name,onChange:c=>r(s,{...i,name:c}),placeholder:"e.g. Uniswap"}),e(I,{label:"Max Amount",name:`spender-max-${s}`,value:i.maxAmount||"",onChange:c=>r(s,{...i,maxAmount:c}),placeholder:"Leave empty for unlimited",error:n[`spenders.${s}.maxAmount`]})]}),addLabel:"+ Add Spender",error:n.spenders})})}const Ki=Array.from({length:24},(t,a)=>({label:`${String(a).padStart(2,"0")}:00`,value:String(a)})),Hi=Array.from({length:24},(t,a)=>({label:`${String(a+1).padStart(2,"0")}:00`,value:String(a+1)})),Bi=[{label:"Sun",value:0},{label:"Mon",value:1},{label:"Tue",value:2},{label:"Wed",value:3},{label:"Thu",value:4},{label:"Fri",value:5},{label:"Sat",value:6}];function Vi({rules:t,onChange:a,errors:n}){const l=t.allowed_hours||{start:0,end:24},i=t.allowed_days||[],s=c=>h=>{const o={...l,[c]:Number(h)};a({...t,allowed_hours:o})},r=c=>{const h=i.includes(c)?i.filter(o=>o!==c):[...i,c].sort((o,v)=>o-v);a({...t,allowed_days:h})};return e("div",{class:"policy-form-fields",children:[e("h4",{children:"Allowed Hours"}),e("div",{class:"policy-form-grid",children:[e(I,{label:"Start Hour",name:"allowed_hours_start",type:"select",value:String(l.start),onChange:s("start"),options:Ki,error:n.allowed_hours}),e(I,{label:"End Hour",name:"allowed_hours_end",type:"select",value:String(l.end),onChange:s("end"),options:Hi})]}),e("h4",{children:"Allowed Days"}),e("div",{style:{display:"flex",gap:"0.75rem",flexWrap:"wrap"},children:Bi.map(c=>e("label",{style:{display:"flex",alignItems:"center",gap:"0.25rem",cursor:"pointer"},children:[e("input",{type:"checkbox",checked:i.includes(c.value),onChange:()=>r(c.value)}),c.label]},c.value))}),n.allowed_days&&e("span",{class:"form-error",children:n.allowed_days})]})}const zi=[{label:"solana-mainnet",value:"solana-mainnet"},{label:"solana-devnet",value:"solana-devnet"},{label:"solana-testnet",value:"solana-testnet"},{label:"ethereum-mainnet",value:"ethereum-mainnet"},{label:"ethereum-sepolia",value:"ethereum-sepolia"},{label:"polygon-mainnet",value:"polygon-mainnet"},{label:"polygon-amoy",value:"polygon-amoy"},{label:"arbitrum-mainnet",value:"arbitrum-mainnet"},{label:"arbitrum-sepolia",value:"arbitrum-sepolia"},{label:"optimism-mainnet",value:"optimism-mainnet"},{label:"optimism-sepolia",value:"optimism-sepolia"},{label:"base-mainnet",value:"base-mainnet"},{label:"base-sepolia",value:"base-sepolia"}];function Gi({rules:t,onChange:a,errors:n}){const l=t.networks||[];return e("div",{class:"policy-form-fields",children:e(We,{items:l,onAdd:()=>a({...t,networks:[...l,{network:"solana-mainnet",name:""}]}),onRemove:i=>a({...t,networks:l.filter((s,r)=>r!==i)}),onChange:(i,s)=>{const r=[...l];r[i]=s,a({...t,networks:r})},renderRow:(i,s,r)=>e("div",{class:"dynamic-row-fields",style:{display:"flex",gap:"0.5rem",flex:1},children:[e(I,{label:`Network ${s+1}`,name:`network-sel-${s}`,type:"select",value:i.network,onChange:c=>r(s,{...i,network:c}),options:zi,error:n[`networks.${s}.network`],required:!0}),e(I,{label:"Label",name:`network-name-${s}`,value:i.name,onChange:c=>r(s,{...i,name:c}),placeholder:"Optional label"})]}),addLabel:"+ Add Network",error:n.networks})})}function qi({rules:t,onChange:a,errors:n}){const l=t.domains||[];return e("div",{class:"policy-form-fields",children:e(We,{items:l,onAdd:()=>a({...t,domains:[...l,""]}),onRemove:i=>a({...t,domains:l.filter((s,r)=>r!==i)}),onChange:(i,s)=>{const r=[...l];r[i]=s,a({...t,domains:r})},renderRow:(i,s,r)=>e(I,{label:`Domain ${s+1}`,name:`domain-${s}`,value:i,onChange:c=>r(s,c),placeholder:"e.g. api.example.com or *.service.io",error:n[`domains.${s}`],required:!0}),addLabel:"+ Add Domain",error:n.domains})})}function qt({type:t,rules:a,onChange:n,errors:l,network:i}){switch(t){case"SPENDING_LIMIT":return e(Ii,{rules:a,onChange:n,errors:l,network:i});case"WHITELIST":return e(Di,{rules:a,onChange:n,errors:l});case"RATE_LIMIT":return e(xi,{rules:a,onChange:n,errors:l});case"APPROVE_AMOUNT_LIMIT":return e(Oi,{rules:a,onChange:n,errors:l});case"APPROVE_TIER_OVERRIDE":return e(Ri,{rules:a,onChange:n,errors:l});case"ALLOWED_TOKENS":return e(Mi,{rules:a,onChange:n,errors:l});case"CONTRACT_WHITELIST":return e(Ui,{rules:a,onChange:n,errors:l});case"METHOD_WHITELIST":return e($i,{rules:a,onChange:n,errors:l});case"APPROVED_SPENDERS":return e(Fi,{rules:a,onChange:n,errors:l});case"TIME_RESTRICTION":return e(Vi,{rules:a,onChange:n,errors:l});case"ALLOWED_NETWORKS":return e(Gi,{rules:a,onChange:n,errors:l});case"X402_ALLOWED_DOMAINS":return e(qi,{rules:a,onChange:n,errors:l});default:return e("p",{class:"policy-form-placeholder",children:"This policy type uses JSON editor. Toggle to JSON mode."})}}function vt(t){const a=typeof t=="string"?Number(t):t;return Number.isNaN(a)?String(t):a.toLocaleString("en-US")}function ji(t){return t===86400?"1d":t%86400===0?`${t/86400}d`:t===3600?"1h":t%3600===0?`${t/3600}h`:t===60?"1m":t%60===0?`${t/60}m`:`${t}s`}const Qa=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Yi(t){if(!t||t.length===0)return"";const a=[...t].sort((l,i)=>l-i);let n=!0;for(let l=1;l<a.length;l++)if(a[l]!==a[l-1]+1){n=!1;break}return n&&a.length>2?`${Qa[a[0]]}-${Qa[a[a.length-1]]}`:a.map(l=>Qa[l]??String(l)).join(", ")}function jt(t){return String(t).padStart(2,"0")}function Xi({rules:t}){const a=Number(t.instant_max??0),n=Number(t.notify_max??0),l=Number(t.delay_max??0),i=Math.max(a,n,l,1),s=[{label:"Instant",value:t.instant_max,width:a/i*100,cls:"instant"},{label:"Notify",value:t.notify_max,width:n/i*100,cls:"notify"},{label:"Delay",value:t.delay_max,width:l/i*100,cls:"delay"},{label:"Approval",value:"",width:100,cls:"approval"}];return e("div",{class:"tier-bars",children:s.map(r=>e("div",{class:"tier-bar",children:[e("span",{class:"tier-bar-label",children:r.label}),e("div",{class:"tier-bar-track",children:e("div",{class:`tier-bar-fill tier-bar-fill--${r.cls}`,style:{width:`${r.width}%`}})}),e("span",{class:"tier-bar-value",children:r.value?vt(r.value):""})]},r.cls))})}function Yt(t){return t.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:2})}function Ji({rules:t}){const a=t.daily_limit_usd,n=t.monthly_limit_usd;return!a&&!n?null:e("div",{class:"cumulative-limits",children:[e("div",{class:"cumulative-limits-label",children:"Cumulative Limits"}),a&&e("div",{class:"cumulative-limit-row",children:[e("span",{class:"cumulative-limit-type",children:"Daily (24h)"}),e("span",{class:"cumulative-limit-value",children:["$",Yt(a)]})]}),n&&e("div",{class:"cumulative-limit-row",children:[e("span",{class:"cumulative-limit-type",children:"Monthly (30d)"}),e("span",{class:"cumulative-limit-value",children:["$",Yt(n)]})]})]})}const Zi={INSTANT:"success",NOTIFY:"info",DELAY:"warning",APPROVAL:"danger"};function Qi({type:t,rules:a}){switch(t){case"SPENDING_LIMIT":return e("div",{class:"spending-limit-summary",children:[e(Xi,{rules:a}),e(Ji,{rules:a})]});case"ALLOWED_TOKENS":{const n=a.tokens||[];return n.length===0?e("span",{class:"rules-vis-text",children:"No tokens"}):e("div",{class:"rules-vis-badges",children:n.map((l,i)=>e(z,{variant:"info",children:l.symbol||(l.address?l.address.slice(0,8)+"...":"?")},i))})}case"RATE_LIMIT":{const n=a.max_requests,l=a.window_seconds;return e("span",{class:"rules-vis-text",children:[n," req / ",ji(l)]})}case"WHITELIST":{const n=a.allowed_addresses||[];return e(z,{variant:"neutral",children:[n.length," addresses"]})}case"TIME_RESTRICTION":{const n=a.allowed_days||[],l=a.allowed_hours,i=Yi(n),s=l?`${jt(l.start)}:00-${jt(l.end)}:00`:"";return e("span",{class:"rules-vis-text",children:[i," ",s]})}case"CONTRACT_WHITELIST":{const n=a.contracts||[];if(n.length===0)return e("span",{class:"rules-vis-text",children:"No contracts"});const l=n.slice(0,3),i=n.length-3;return e("div",{class:"rules-vis-badges",children:[l.map((s,r)=>e(z,{variant:"neutral",children:s.name||(s.address?s.address.slice(0,8)+"...":"?")},r)),i>0&&e(z,{variant:"neutral",children:["+",i," more"]})]})}case"METHOD_WHITELIST":{const n=a.methods||[],l=n.length,i=n.reduce((s,r)=>s+(r.selectors?.length||0),0);return e(z,{variant:"neutral",children:[l," contracts, ",i," methods"]})}case"APPROVED_SPENDERS":{const n=a.spenders||[];return e(z,{variant:"neutral",children:[n.length," spenders"]})}case"APPROVE_AMOUNT_LIMIT":{const n=a.maxAmount,l=a.blockUnlimited;return n&&l?e("span",{class:"rules-vis-text",children:["Max: ",vt(n)," + Block unlimited"]}):n?e("span",{class:"rules-vis-text",children:["Max: ",vt(n)]}):l?e("span",{class:"rules-vis-text",children:"Block unlimited only"}):e("span",{class:"rules-vis-text",children:"No limits"})}case"APPROVE_TIER_OVERRIDE":{const n=a.tier||"DELAY",l=Zi[n]||"neutral";return e(z,{variant:l,children:n})}case"ALLOWED_NETWORKS":{const n=a.networks||[];if(n.length===0)return e("span",{class:"rules-vis-text",children:"No networks"});const l=n.slice(0,3),i=n.length-3;return e("div",{class:"rules-vis-badges",children:[l.map((s,r)=>e(z,{variant:"info",children:s.network},r)),i>0&&e(z,{variant:"info",children:["+",i," more"]})]})}case"X402_ALLOWED_DOMAINS":{const n=a.domains||[];if(n.length===0)return e("span",{class:"rules-vis-text",children:"No domains"});const l=n.slice(0,3),i=n.length-3;return e("div",{class:"rules-vis-badges",children:[l.map((s,r)=>e(z,{variant:"neutral",children:s},r)),i>0&&e(z,{variant:"neutral",children:["+",i," more"]})]})}default:{const n=JSON.stringify(a);return e("span",{class:"rules-summary",children:n.length>60?n.slice(0,60)+"...":n})}}}const Ln=[{label:"Spending Limit",value:"SPENDING_LIMIT"},{label:"Whitelist",value:"WHITELIST"},{label:"Time Restriction",value:"TIME_RESTRICTION"},{label:"Rate Limit",value:"RATE_LIMIT"},{label:"Allowed Tokens",value:"ALLOWED_TOKENS"},{label:"Contract Whitelist",value:"CONTRACT_WHITELIST"},{label:"Method Whitelist",value:"METHOD_WHITELIST"},{label:"Approved Spenders",value:"APPROVED_SPENDERS"},{label:"Approve Amount Limit",value:"APPROVE_AMOUNT_LIMIT"},{label:"Approve Tier Override",value:"APPROVE_TIER_OVERRIDE"},{label:"Allowed Networks",value:"ALLOWED_NETWORKS"},{label:"x402 Allowed Domains",value:"X402_ALLOWED_DOMAINS"}],et={SPENDING_LIMIT:"Set per-transaction and cumulative spending limits by security tier (instant, notify, delay, approval).",WHITELIST:"Allow transfers only to pre-approved recipient addresses.",TIME_RESTRICTION:"Restrict transactions to specific time windows or days of the week.",RATE_LIMIT:"Limit the maximum number of transactions within a time window.",ALLOWED_TOKENS:"Allow only specified tokens for transfers; all others are denied.",CONTRACT_WHITELIST:"Allow contract calls only to pre-approved contract addresses.",METHOD_WHITELIST:"Allow only specific contract methods (function selectors) to be called.",APPROVED_SPENDERS:"Allow token approvals only for pre-approved spender addresses.",APPROVE_AMOUNT_LIMIT:"Set maximum token approval amounts and optionally block unlimited approvals.",APPROVE_TIER_OVERRIDE:"Force a specific security tier for all token approval transactions.",ALLOWED_NETWORKS:"Restrict transactions to specific blockchain networks only.",X402_ALLOWED_DOMAINS:"Allow x402 payments only to pre-approved domains."},oa={SPENDING_LIMIT:{instant_max_usd:"10",notify_max_usd:"100",delay_max_usd:"1000",delay_seconds:300,approval_timeout:3600},WHITELIST:{allowed_addresses:[]},TIME_RESTRICTION:{allowed_hours:{start:0,end:24},allowed_days:[0,1,2,3,4,5,6]},RATE_LIMIT:{max_requests:100,window_seconds:3600},ALLOWED_TOKENS:{tokens:[]},CONTRACT_WHITELIST:{contracts:[]},METHOD_WHITELIST:{methods:[]},APPROVED_SPENDERS:{spenders:[]},APPROVE_AMOUNT_LIMIT:{maxAmount:"1000000",blockUnlimited:!0},APPROVE_TIER_OVERRIDE:{tier:"DELAY"},ALLOWED_NETWORKS:{networks:[]},X402_ALLOWED_DOMAINS:{domains:[]}};function Ea(t,a){const n={};if(t==="SPENDING_LIMIT"){a.instant_max&&!/^\d+$/.test(a.instant_max)&&(n.instant_max="Positive integer required"),a.notify_max&&!/^\d+$/.test(a.notify_max)&&(n.notify_max="Positive integer required"),a.delay_max&&!/^\d+$/.test(a.delay_max)&&(n.delay_max="Positive integer required");const l=!!(a.instant_max||a.notify_max||a.delay_max),i=!!(a.instant_max_usd||a.notify_max_usd||a.delay_max_usd),s=a.token_limits,r=s&&Object.keys(s).length>0;if(!l&&!i&&!r&&(n.__form="At least one of USD limits, token limits, or raw limits required"),s){const v=/^\d+(\.\d+)?$/;for(const[u,f]of Object.entries(s)){const A=f;if(!A||typeof A!="object")continue;A.instant_max&&!v.test(A.instant_max)&&(n[`token_limits.${u}.instant_max`]="Must be a non-negative decimal"),A.notify_max&&!v.test(A.notify_max)&&(n[`token_limits.${u}.notify_max`]="Must be a non-negative decimal"),A.delay_max&&!v.test(A.delay_max)&&(n[`token_limits.${u}.delay_max`]="Must be a non-negative decimal");const D=parseFloat(A.instant_max||"0"),x=parseFloat(A.notify_max||"0"),g=parseFloat(A.delay_max||"0");D>x&&(n[`token_limits.${u}.instant_max`]="Must be <= Notify Max"),x>g&&(n[`token_limits.${u}.notify_max`]="Must be <= Delay Max")}}const c=Number(a.delay_seconds);(a.delay_seconds===void 0||a.delay_seconds===""||Number.isNaN(c)||c<60)&&(n.delay_seconds="Minimum 60 seconds");const h=a.daily_limit_usd;if(h!==void 0&&h!==""){const v=Number(h);(Number.isNaN(v)||v<=0)&&(n.daily_limit_usd="Must be a positive number")}const o=a.monthly_limit_usd;if(o!==void 0&&o!==""){const v=Number(o);(Number.isNaN(v)||v<=0)&&(n.monthly_limit_usd="Must be a positive number")}}else if(t==="WHITELIST"){const l=a.allowed_addresses||[];l.length===0&&(n.allowed_addresses="At least one address required"),l.forEach((i,s)=>{(!i||i.trim()==="")&&(n[`allowed_addresses.${s}`]="Address required")})}else if(t==="RATE_LIMIT"){const l=Number(a.max_requests);(!a.max_requests||Number.isNaN(l)||l<1||!Number.isInteger(l))&&(n.max_requests="Positive integer required");const i=Number(a.window_seconds);(!a.window_seconds||Number.isNaN(i)||i<1||!Number.isInteger(i))&&(n.window_seconds="Positive integer required")}else if(t==="APPROVE_AMOUNT_LIMIT")a.maxAmount&&!/^\d+$/.test(a.maxAmount)&&(n.maxAmount="Must be a positive integer string");else if(t==="ALLOWED_TOKENS"){const l=a.tokens||[];l.length===0&&(n.tokens="At least one token required"),l.forEach((i,s)=>{(!i.address||i.address.trim()==="")&&(n[`tokens.${s}.address`]="Address required")})}else if(t==="CONTRACT_WHITELIST"){const l=a.contracts||[];l.length===0&&(n.contracts="At least one contract required"),l.forEach((i,s)=>{(!i.address||i.address.trim()==="")&&(n[`contracts.${s}.address`]="Address required")})}else if(t==="METHOD_WHITELIST"){const l=a.methods||[];l.length===0&&(n.methods="At least one method entry required"),l.forEach((i,s)=>{(!i.contractAddress||i.contractAddress.trim()==="")&&(n[`methods.${s}.contractAddress`]="Contract address required"),!i.selectors||i.selectors.length===0?n[`methods.${s}.selectors`]="At least one selector required":i.selectors.forEach((r,c)=>{(!r||r.trim()==="")&&(n[`methods.${s}.selectors.${c}`]="Selector required")})})}else if(t==="APPROVED_SPENDERS"){const l=a.spenders||[];l.length===0&&(n.spenders="At least one spender required"),l.forEach((i,s)=>{(!i.address||i.address.trim()==="")&&(n[`spenders.${s}.address`]="Address required"),i.maxAmount&&!/^\d+$/.test(i.maxAmount)&&(n[`spenders.${s}.maxAmount`]="Must be a positive integer")})}else if(t==="TIME_RESTRICTION"){(a.allowed_days||[]).length===0&&(n.allowed_days="At least one day required");const i=a.allowed_hours;i&&i.start>=i.end&&(n.allowed_hours="Start must be before end")}else if(t==="ALLOWED_NETWORKS"){const l=a.networks||[];l.length===0&&(n.networks="At least one network required"),l.forEach((i,s)=>{(!i.network||i.network.trim()==="")&&(n[`networks.${s}.network`]="Network required")})}else if(t==="X402_ALLOWED_DOMAINS"){const l=a.domains||[];l.length===0&&(n.domains="At least one domain required"),l.forEach((i,s)=>{(!i||i.trim()==="")&&(n[`domains.${s}`]="Domain required")})}return n}function es(t,a){if(!t)return"Global";const n=a.find(l=>l.id===t);return n?n.name:t.slice(0,8)+"..."}function at(t){const a=Ln.find(n=>n.value===t);return a?a.label:t}const Xt=[{key:"policies",label:"Policies"},{key:"defaults",label:"Defaults"}],tt=["security.policy_defaults_delay_seconds","security.policy_defaults_approval_timeout","policy.default_deny_tokens","policy.default_deny_contracts","policy.default_deny_spenders","policy.default_deny_x402_domains"];function as(){const t=d({}),a=d({}),n=d(!1),l=d(!0),i=async()=>{try{const o=await G(L.ADMIN_SETTINGS);t.value=o}catch(o){const v=o instanceof k?o:new k(0,"UNKNOWN","Unknown error");w("error",$(v.code))}finally{l.value=!1}};B(()=>{i()},[]);const s=(o,v)=>{const u=String(v);a.value={...a.value,[o]:u}},r=async()=>{n.value=!0;try{const o=Object.entries(a.value).filter(([u])=>tt.includes(u)).map(([u,f])=>({key:u,value:f})),v=await le(L.ADMIN_SETTINGS,{settings:o});t.value=v.settings,a.value={},w("success","Policy defaults saved and applied")}catch(o){const v=o instanceof k?o:new k(0,"UNKNOWN","Unknown error");w("error",$(v.code))}finally{n.value=!1}},c=()=>{a.value={}};B(()=>(Ee({id:"policies-defaults",isDirty:()=>Object.keys(a.value).filter(o=>tt.includes(o)).length>0,save:r,discard:c}),()=>ke("policies-defaults")),[]);const h=Object.keys(a.value).filter(o=>tt.includes(o)).length;return l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(J,{children:[h>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[h," unsaved change",h>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(R,{variant:"ghost",size:"sm",onClick:c,children:"Discard"}),e(R,{variant:"primary",size:"sm",onClick:r,loading:n.value,children:"Save"})]})]}),e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Policy Defaults"}),e("p",{class:"settings-description",children:"Configure default delay, approval timeout, and default-deny policies. Changes apply immediately without daemon restart."})]}),e("div",{class:"settings-category-body",children:[e("div",{class:"settings-fields-grid",children:[e(I,{label:X("policy_defaults_delay_seconds"),name:"security.policy_defaults_delay_seconds",type:"number",value:Number(te(t.value,a.value,"security","policy_defaults_delay_seconds"))||0,onChange:o=>s("security.policy_defaults_delay_seconds",o),min:0,description:"Default delay before executing delayed-tier transactions"}),e(I,{label:X("policy_defaults_approval_timeout"),name:"security.policy_defaults_approval_timeout",type:"number",value:Number(te(t.value,a.value,"security","policy_defaults_approval_timeout"))||0,onChange:o=>s("security.policy_defaults_approval_timeout",o),min:60,description:"How long to wait for owner approval before timeout"})]}),e("div",{class:"settings-subgroup",style:{marginTop:"1rem",borderTop:"1px solid var(--border)",paddingTop:"1rem"},children:[e("h4",{style:{margin:"0 0 0.5rem 0",fontSize:"0.875rem",fontWeight:600,color:"var(--text-secondary)"},children:"Default Deny Policies"}),e("div",{class:"settings-fields-grid",children:[e(I,{label:X("default_deny_tokens"),name:"policy.default_deny_tokens",type:"checkbox",value:He(t.value,a.value,"policy","default_deny_tokens"),onChange:o=>s("policy.default_deny_tokens",o),description:"Deny token transfers unless a matching whitelist policy exists"}),e(I,{label:X("default_deny_contracts"),name:"policy.default_deny_contracts",type:"checkbox",value:He(t.value,a.value,"policy","default_deny_contracts"),onChange:o=>s("policy.default_deny_contracts",o),description:"Deny contract calls unless a matching whitelist policy exists"}),e(I,{label:X("default_deny_spenders"),name:"policy.default_deny_spenders",type:"checkbox",value:He(t.value,a.value,"policy","default_deny_spenders"),onChange:o=>s("policy.default_deny_spenders",o),description:"Deny token approvals unless a matching whitelist policy exists"}),e(I,{label:X("default_deny_x402_domains"),name:"policy.default_deny_x402_domains",type:"checkbox",value:He(t.value,a.value,"policy","default_deny_x402_domains"),onChange:o=>s("policy.default_deny_x402_domains",o),description:"Deny x402 payments unless a matching domain whitelist policy exists"})]})]}),e("div",{class:"settings-info-box",children:"When enabled, transactions are denied if no matching whitelist policy exists. Disable to allow all transactions of that type when no policy is configured."})]})]})]})}function ts(){const t=d("policies");B(()=>{const M=ie.value;M&&M.tab&&(t.value=M.tab,setTimeout(()=>{Se.value=M.fieldName},100),ie.value=null)},[ie.value]);const a=d([]),n=d([]),l=d("__all__"),i=d(!1),s=d(!0),r=d(!1),c=d("SPENDING_LIMIT"),h=d(""),o=d(JSON.stringify(oa.SPENDING_LIMIT,null,2)),v=d(oa.SPENDING_LIMIT),u=d({}),f=d(!1),A=d(0),D=d(!0),x=d(""),g=d(null),_=d(!1),U=d(!1),F=d(null),E=d(""),K=d({}),C=d(!1),T=d({}),m=d(0),S=d(!0),P=d(null),y=d(!1),p=d(!1),W=d(null),H=d(!1),j=async()=>{try{const M=await G(L.WALLETS);a.value=M.items}catch(M){const ee=M instanceof k?M:new k(0,"UNKNOWN","Unknown error");w("error",$(ee.code))}finally{s.value=!1}},se=async()=>{i.value=!0;try{let M=L.POLICIES;l.value!=="__all__"&&l.value!=="__global__"&&(M=`${L.POLICIES}?walletId=${l.value}`);const ee=await G(M);l.value==="__global__"?n.value=ee.filter(_e=>_e.walletId===null):n.value=ee}catch(M){const ee=M instanceof k?M:new k(0,"UNKNOWN","Unknown error");w("error",$(ee.code))}finally{i.value=!1}},me=async()=>{g.value=null;let M;if(f.value)try{M=JSON.parse(o.value)}catch{g.value="Invalid JSON in rules field";return}else{const ee=Ea(c.value,v.value);if(Object.keys(ee).length>0){u.value=ee;return}u.value={},M=v.value}_.value=!0;try{await ne(L.POLICIES,{walletId:h.value||void 0,type:c.value,rules:M,priority:A.value,enabled:D.value,network:x.value||void 0}),w("success","Policy created"),r.value=!1,c.value="SPENDING_LIMIT",h.value="",x.value="",o.value=JSON.stringify(oa.SPENDING_LIMIT,null,2),v.value=oa.SPENDING_LIMIT,u.value={},f.value=!1,A.value=0,D.value=!0,g.value=null,await se()}catch(ee){const _e=ee instanceof k?ee:new k(0,"UNKNOWN","Unknown error");w("error",$(_e.code))}finally{_.value=!1}},re=M=>{F.value=M,E.value=JSON.stringify(M.rules,null,2),K.value={...M.rules},C.value=!1,T.value={},m.value=M.priority,S.value=M.enabled,P.value=null,U.value=!0},oe=async()=>{P.value=null;let M;if(C.value)try{M=JSON.parse(E.value)}catch{P.value="Invalid JSON in rules field";return}else{const ee=Ea(F.value.type,K.value);if(Object.keys(ee).length>0){T.value=ee;return}T.value={},M=K.value}y.value=!0;try{await le(L.POLICY(F.value.id),{rules:M,priority:m.value,enabled:S.value}),w("success","Policy updated"),U.value=!1,await se()}catch(ee){const _e=ee instanceof k?ee:new k(0,"UNKNOWN","Unknown error");w("error",$(_e.code))}finally{y.value=!1}},fe=()=>{if(!C.value)E.value=JSON.stringify(K.value,null,2);else try{K.value=JSON.parse(E.value),P.value=null}catch{P.value="Invalid JSON — cannot switch to form mode";return}C.value=!C.value},Ue=M=>{W.value=M,p.value=!0},$e=async()=>{H.value=!0;try{await Me(L.POLICY(W.value.id)),w("success","Policy deleted"),p.value=!1,await se()}catch(M){const ee=M instanceof k?M:new k(0,"UNKNOWN","Unknown error");w("error",$(ee.code))}finally{H.value=!1}},Ce=M=>{const ee=M;c.value=ee;const _e=oa[ee];_e&&(o.value=JSON.stringify(_e,null,2),v.value={..._e}),u.value={},f.value=!1},Ie=()=>{if(!f.value)o.value=JSON.stringify(v.value,null,2);else try{v.value=JSON.parse(o.value),g.value=null}catch{g.value="Invalid JSON — cannot switch to form mode";return}f.value=!f.value};B(()=>{j()},[]),B(()=>{se()},[l.value]);const Te=[{key:"type",header:"Type",render:M=>e(z,{variant:M.type==="SPENDING_LIMIT"?"success":"info",children:at(M.type)})},{key:"walletId",header:"Wallet",render:M=>es(M.walletId,a.value)},{key:"network",header:"Network",render:M=>M.network??"All"},{key:"rules",header:"Rules",render:M=>e(Qi,{type:M.type,rules:M.rules})},{key:"priority",header:"Priority"},{key:"enabled",header:"Enabled",render:M=>e(z,{variant:M.enabled?"success":"danger",children:M.enabled?"ON":"OFF"})},{key:"actions",header:"Actions",render:M=>e("span",{style:{display:"flex",gap:"0.25rem"},children:[e("button",{class:"btn btn-ghost btn-sm",onClick:ee=>{ee.stopPropagation(),re(M)},children:"Edit"}),e(R,{size:"sm",variant:"danger",onClick:()=>Ue(M),children:"Delete"})]})}];return e("div",{class:"page",children:[e(na,{pageName:"Policies",tabName:Xt.find(M=>M.key===t.value)?.label??"",onPageClick:()=>{t.value="policies"}}),e(Ge,{tabs:Xt,activeTab:t.value,onTabChange:M=>{t.value=M}}),t.value==="policies"&&e(J,{children:[e("div",{class:"policy-controls",children:[e("div",{class:"policy-filter-select",children:[e("label",{for:"policy-wallet-filter",children:"Filter by Wallet"}),e("select",{id:"policy-wallet-filter",value:l.value,onChange:M=>{l.value=M.target.value},disabled:s.value,children:[e("option",{value:"__all__",children:"All Policies"}),e("option",{value:"__global__",children:"Global Only"}),a.value.map(M=>e("option",{value:M.id,children:[M.name," (",M.chain,"/",M.network,")"]},M.id))]})]}),!r.value&&e(R,{onClick:()=>{r.value=!0},children:"Create Policy"})]}),r.value&&e("div",{class:"inline-form",children:[e(I,{label:"Type",name:"type",type:"select",value:c.value,onChange:Ce,options:Ln,description:et[c.value]??""}),e(I,{label:"Wallet",name:"walletId",type:"select",value:h.value,onChange:M=>{h.value=M},options:[{label:"Global (no wallet)",value:""},...a.value.map(M=>({label:`${M.name} (${M.chain}/${M.network})`,value:M.id}))]}),e(I,{label:"Network Scope",name:"network",value:x.value,onChange:M=>{x.value=M},placeholder:"e.g. polygon-mainnet (leave empty for all networks)"}),e("div",{class:"policy-form-section",children:[e("div",{class:"policy-form-header",children:[e("label",{children:"Rules"}),e("button",{class:"btn btn-ghost btn-sm json-toggle",onClick:Ie,children:f.value?"Switch to Form":"JSON Direct Edit"})]}),f.value?e(I,{label:"",name:"rules",type:"textarea",value:o.value,onChange:M=>{o.value=M},error:g.value??void 0}):e(qt,{type:c.value,rules:v.value,onChange:M=>{v.value=M,Object.keys(u.value).length>0&&(u.value=Ea(c.value,M))},errors:u.value,network:x.value})]}),e(I,{label:"Priority",name:"priority",type:"number",value:A.value,onChange:M=>{A.value=M},min:0,max:999}),e(I,{label:"Enabled",name:"enabled",type:"checkbox",value:D.value,onChange:M=>{D.value=M}}),e("div",{class:"inline-form-actions",children:[e(R,{onClick:me,loading:_.value,children:"Create"}),e(R,{variant:"secondary",onClick:()=>{r.value=!1,g.value=null},children:"Cancel"})]})]}),e(Ve,{columns:Te,data:n.value,loading:i.value,emptyMessage:"No policies found"}),e(we,{open:U.value,title:"Edit Policy",onCancel:()=>{U.value=!1},onConfirm:oe,confirmText:"Save",loading:y.value,children:F.value&&e("div",{children:[e("div",{class:"policy-type-readonly",children:["Type: ",at(F.value.type),et[F.value.type]&&e("span",{class:"form-description",children:et[F.value.type]})]}),e("div",{class:"policy-form-section",children:[e("div",{class:"policy-form-header",children:[e("label",{children:"Rules"}),e("button",{class:"btn btn-ghost btn-sm json-toggle",onClick:fe,children:C.value?"Switch to Form":"JSON Direct Edit"})]}),C.value?e("div",{class:"edit-rules-textarea",children:e(I,{label:"",name:"edit-rules",type:"textarea",value:E.value,onChange:M=>{E.value=M},error:P.value??void 0})}):e(qt,{type:F.value.type,rules:K.value,onChange:M=>{K.value=M,Object.keys(T.value).length>0&&(T.value=Ea(F.value.type,M))},errors:T.value,network:F.value.network??""})]}),e(I,{label:"Priority",name:"edit-priority",type:"number",value:m.value,onChange:M=>{m.value=M},min:0,max:999}),e(I,{label:"Enabled",name:"edit-enabled",type:"checkbox",value:S.value,onChange:M=>{S.value=M}})]})}),e(we,{open:p.value,title:"Delete Policy",onCancel:()=>{p.value=!1},onConfirm:$e,confirmText:"Delete",confirmVariant:"danger",loading:H.value,children:W.value&&e("p",{children:["Are you sure you want to delete this"," ",e("strong",{children:at(W.value.type)})," policy? This action cannot be undone."]})})]}),t.value==="defaults"&&e(as,{})]})}function ns(){return e(ls,{})}function ls(){const t=d([]),a=d(!0),n=d(!1),l=d(null),i=d("ADMIN"),s=d(!1),r=d(!1),c=d(null),h=d(!1),o=async()=>{a.value=!0;try{const g=await G(L.ADMIN_TELEGRAM_USERS);t.value=g.users}catch(g){const _=g instanceof k?g:new k(0,"UNKNOWN","Unknown error");w("error",$(_.code))}finally{a.value=!1}};B(()=>{o()},[]);const v=g=>{l.value=g,i.value="ADMIN",n.value=!0},u=async()=>{if(l.value){s.value=!0;try{await le(L.ADMIN_TELEGRAM_USER(l.value.chat_id),{role:i.value}),w("success",`User approved as ${i.value}`),n.value=!1,l.value=null,await o()}catch(g){const _=g instanceof k?g:new k(0,"UNKNOWN","Unknown error");w("error",$(_.code))}finally{s.value=!1}}},f=g=>{c.value=g,r.value=!0},A=async()=>{if(c.value){h.value=!0;try{await Me(L.ADMIN_TELEGRAM_USER(c.value.chat_id)),w("success","User deleted"),r.value=!1,c.value=null,await o()}catch(g){const _=g instanceof k?g:new k(0,"UNKNOWN","Unknown error");w("error",$(_.code))}finally{h.value=!1}}},D=g=>g==="PENDING"?"warning":g==="ADMIN"?"success":"info";return e("div",{class:"page",children:[e(Ve,{columns:[{key:"chat_id",header:"Chat ID",render:g=>String(g.chat_id)},{key:"username",header:"Username",render:g=>g.username??"-"},{key:"role",header:"Role",render:g=>e(z,{variant:D(g.role),children:g.role})},{key:"registered_at",header:"Registered",render:g=>ve(g.registered_at)},{key:"approved_at",header:"Approved",render:g=>g.approved_at?ve(g.approved_at):"-"},{key:"actions",header:"Actions",render:g=>e("div",{style:{display:"flex",gap:"var(--space-1)"},children:[g.role==="PENDING"&&e(R,{size:"sm",variant:"primary",onClick:()=>v(g),children:"Approve"}),e(R,{size:"sm",variant:"danger",onClick:()=>f(g),children:"Delete"})]})}],data:t.value,loading:a.value,emptyMessage:"No Telegram users registered. Users appear here after sending /start to the bot."}),e(we,{open:n.value,title:"Approve Telegram User",onCancel:()=>{n.value=!1,l.value=null},onConfirm:u,confirmText:"Approve",confirmVariant:"primary",loading:s.value,children:l.value&&e("div",{children:[e("p",{children:[e("strong",{children:"Chat ID:"})," ",l.value.chat_id,l.value.username&&e("span",{children:[" (",e("strong",{children:["@",l.value.username]}),")"]})]}),e("div",{class:"form-field",style:{marginTop:"var(--space-3)"},children:[e("label",{for:"approve-role",children:"Role"}),e("select",{id:"approve-role",value:i.value,onChange:g=>{i.value=g.target.value},children:[e("option",{value:"ADMIN",children:"ADMIN"}),e("option",{value:"READONLY",children:"READONLY"})]})]})]})}),e(we,{open:r.value,title:"Delete Telegram User",onCancel:()=>{r.value=!1,c.value=null},onConfirm:A,confirmText:"Delete",confirmVariant:"danger",loading:h.value,children:e("p",{children:"Are you sure you want to remove this user? They will need to /start again to re-register."})})]})}const nt=20,Jt=[{key:"channels",label:"Channels & Logs"},{key:"telegram",label:"Telegram Users"},{key:"settings",label:"Settings"},{key:"balance",label:"Balance Monitor"}],is=[{key:"eventType",label:"Event Type",type:"select",options:[{value:"tx.submitted",label:"tx.submitted"},{value:"tx.confirmed",label:"tx.confirmed"},{value:"tx.failed",label:"tx.failed"},{value:"policy.violation",label:"policy.violation"},{value:"security.kill_switch",label:"security.kill_switch"},{value:"security.auto_stop",label:"security.auto_stop"},{value:"security.suspicious_tx",label:"security.suspicious_tx"},{value:"session.created",label:"session.created"},{value:"session.expired",label:"session.expired"},{value:"owner.registered",label:"owner.registered"},{value:"owner.verified",label:"owner.verified"},{value:"incoming.detected",label:"incoming.detected"},{value:"incoming.suspicious",label:"incoming.suspicious"}]},{key:"channel",label:"Channel",type:"select",options:[{value:"telegram",label:"Telegram"},{value:"discord",label:"Discord"},{value:"ntfy",label:"ntfy"},{value:"slack",label:"Slack"},{value:"wallet_app",label:"Wallet App"}]},{key:"status",label:"Status",type:"select",options:[{value:"sent",label:"Sent"},{value:"failed",label:"Failed"}]},{key:"since",label:"Since",type:"date"},{key:"until",label:"Until",type:"date"}];function ss(){const t=d({}),a=d({}),n=d(!1),l=d(!0),i=d([]),s=d(!1),r=async()=>{try{const f=await G(L.ADMIN_SETTINGS);t.value=f}catch(f){const A=f instanceof k?f:new k(0,"UNKNOWN","Unknown error");w("error",$(A.code))}finally{l.value=!1}};B(()=>{r()},[]);const c=(f,A)=>{const D=String(A);a.value={...a.value,[f]:D}},h=async()=>{n.value=!0;try{const f=Object.entries(a.value).filter(([D])=>D.startsWith("notifications.")||D.startsWith("telegram.")).map(([D,x])=>({key:D,value:x})),A=await le(L.ADMIN_SETTINGS,{settings:f});t.value=A.settings,a.value={},w("success","Notification settings saved and applied")}catch(f){const A=f instanceof k?f:new k(0,"UNKNOWN","Unknown error");w("error",$(A.code))}finally{n.value=!1}},o=()=>{a.value={}};B(()=>(Ee({id:"notifications-settings",isDirty:()=>Object.keys(a.value).filter(f=>f.startsWith("notifications.")||f.startsWith("telegram.")).length>0,save:h,discard:o}),()=>ke("notifications-settings")),[]);const v=async()=>{s.value=!0,i.value=[];try{const f=await ne(L.ADMIN_NOTIFICATIONS_TEST,{});if(i.value=f.results,f.results.length===0)w("info","No notification channels configured");else{const A=f.results.every(D=>D.success);w(A?"success":"warning",A?"All test notifications sent":"Some channels failed")}}catch(f){const A=f instanceof k?f:new k(0,"UNKNOWN","Unknown error");w("error",$(A.code))}finally{s.value=!1}},u=Object.keys(a.value).filter(f=>f.startsWith("notifications.")||f.startsWith("telegram.")).length;return l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(J,{children:[u>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[u," unsaved change",u>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(R,{variant:"ghost",size:"sm",onClick:o,children:"Discard"}),e(R,{variant:"primary",size:"sm",onClick:h,loading:n.value,children:"Save"})]})]}),e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Notification Configuration"}),e("p",{class:"settings-description",children:"Configure notification channels for transaction alerts. Changes apply immediately via hot-reload."})]}),e("div",{class:"settings-category-body",children:[e("div",{class:"settings-fields-grid",style:{marginBottom:"var(--space-4)"},children:[e("div",{class:"settings-field-full",children:e(I,{label:"Enabled",name:"notifications.enabled",type:"checkbox",value:He(t.value,a.value,"notifications","enabled"),onChange:f=>c("notifications.enabled",f),description:"Enable or disable notifications globally"})}),e(I,{label:X("locale"),name:"notifications.locale",type:"select",value:te(t.value,a.value,"notifications","locale")||"en",onChange:f=>c("notifications.locale",f),options:[{label:"English",value:"en"},{label:"Korean",value:"ko"}],description:"Language for notification messages"})]}),e(Re,{legend:"Telegram",description:"Telegram notification channel and bot configuration",children:[e("div",{class:"settings-info-box",style:{marginBottom:"0.75rem"},children:["Get your bot token from"," ",e("a",{href:"https://t.me/BotFather",target:"_blank",rel:"noopener noreferrer",children:"@BotFather"})," ","— send /newbot and follow the instructions. To get your Chat ID, send a message to your bot then visit"," ",e("a",{href:"https://api.telegram.org",target:"_blank",rel:"noopener noreferrer",children:"Telegram Bot API"}),"."]}),e("div",{class:"settings-fields-grid",children:[e(I,{label:X("telegram_bot_token"),name:"notifications.telegram_bot_token",type:"password",value:te(t.value,a.value,"notifications","telegram_bot_token"),onChange:f=>c("notifications.telegram_bot_token",f),placeholder:da(t.value,a.value,"notifications","telegram_bot_token")?"(configured)":"",description:"Bot token for Telegram notifications"}),e(I,{label:X("telegram_chat_id"),name:"notifications.telegram_chat_id",type:"text",value:te(t.value,a.value,"notifications","telegram_chat_id"),onChange:f=>c("notifications.telegram_chat_id",f),description:"Chat ID for Telegram notification delivery"})]}),e("div",{class:"settings-subgroup",style:{marginTop:"0.75rem",borderTop:"1px solid var(--border)",paddingTop:"0.75rem"},children:[e("div",{class:"settings-subgroup-title",children:"Telegram Bot"}),e("div",{class:"settings-fields-grid",children:[e(I,{label:X("bot_token"),name:"telegram.bot_token",type:"password",value:te(t.value,a.value,"telegram","bot_token"),onChange:f=>c("telegram.bot_token",f),placeholder:da(t.value,a.value,"telegram","bot_token")?"(configured)":"Leave empty to use notification token",description:"Dedicated bot token for Telegram bot (optional, uses notification token if empty)"}),e(I,{label:"Locale",name:"telegram.locale",type:"select",value:te(t.value,a.value,"telegram","locale")||"en",onChange:f=>c("telegram.locale",f),options:[{label:"English",value:"en"},{label:"한국어",value:"ko"}],description:"Language for Telegram bot messages"})]})]})]}),e(Re,{legend:"ntfy",description:"Push notification channel for Human Wallet Apps (signing requests and activity alerts)",children:[e("div",{class:"settings-info-box",style:{marginBottom:"0.75rem"},children:["ntfy is the push notification infrastructure used by Human Wallet Apps for signing requests and activity alerts. Per-wallet ntfy topics (sign topic, notify topic) are managed in"," ",e("a",{href:"#/wallet-apps",children:"Human Wallet Apps"}),". The server URL below is shared across all wallet apps."]}),e("div",{class:"settings-fields-grid",children:e(I,{label:X("ntfy_server"),name:"notifications.ntfy_server",type:"text",value:te(t.value,a.value,"notifications","ntfy_server"),onChange:f=>c("notifications.ntfy_server",f),description:"Server URL for ntfy push notifications"})})]}),e(Re,{legend:"Other Channels",description:"Discord, Slack, and rate limiting",children:[e("div",{class:"settings-info-box",style:{marginBottom:"0.75rem"},children:[e("strong",{children:"Discord:"})," Create a webhook in Server Settings > Integrations >"," ",e("a",{href:"https://support.discord.com/hc/en-us/articles/228383668",target:"_blank",rel:"noopener noreferrer",children:"Webhooks"}),"."," ",e("strong",{children:"Slack:"})," Create an"," ",e("a",{href:"https://api.slack.com/messaging/webhooks",target:"_blank",rel:"noopener noreferrer",children:"Incoming Webhook"})," in your Slack workspace."]}),e("div",{class:"settings-fields-grid",children:[e(I,{label:X("discord_webhook_url"),name:"notifications.discord_webhook_url",type:"password",value:te(t.value,a.value,"notifications","discord_webhook_url"),onChange:f=>c("notifications.discord_webhook_url",f),placeholder:da(t.value,a.value,"notifications","discord_webhook_url")?"(configured)":"",description:"Webhook URL for Discord notifications"}),e(I,{label:"Slack Webhook URL",name:"notifications.slack_webhook_url",type:"password",value:te(t.value,a.value,"notifications","slack_webhook_url"),onChange:f=>c("notifications.slack_webhook_url",f),placeholder:da(t.value,a.value,"notifications","slack_webhook_url")?"(configured)":"",description:"Webhook URL for Slack notifications"}),e(I,{label:X("rate_limit_rpm"),name:"notifications.rate_limit_rpm",type:"number",value:Number(te(t.value,a.value,"notifications","rate_limit_rpm"))||20,onChange:f=>c("notifications.rate_limit_rpm",f),min:1,max:1e3,description:"Max notifications per minute"})]})]}),e(Re,{legend:"Event Filter",description:"Choose which notification events are delivered. All checked = receive all.",children:[(()=>{const f=new Set(["KILL_SWITCH_ACTIVATED","KILL_SWITCH_RECOVERED","AUTO_STOP_TRIGGERED","TX_INCOMING_SUSPICIOUS"]),A=[{category:"transaction",label:"Transaction Events",events:[{event:"TX_REQUESTED",desc:"Transaction request received"},{event:"TX_QUEUED",desc:"Waiting in time-delay queue"},{event:"TX_SUBMITTED",desc:"Submitted to blockchain"},{event:"TX_CONFIRMED",desc:"Confirmed on-chain"},{event:"TX_FAILED",desc:"Transaction failed"},{event:"TX_CANCELLED",desc:"Cancelled by user or policy"},{event:"TX_DOWNGRADED_DELAY",desc:"Auto-approved demoted to time-delay"},{event:"TX_APPROVAL_REQUIRED",desc:"Owner approval required"},{event:"TX_APPROVAL_EXPIRED",desc:"Approval wait timed out"},{event:"TX_INCOMING",desc:"Incoming transaction detected"}]},{category:"policy",label:"Policy",events:[{event:"POLICY_VIOLATION",desc:"Blocked by policy rule"},{event:"CUMULATIVE_LIMIT_WARNING",desc:"Cumulative spend limit warning"}]},{category:"security_alert",label:"Security Alerts",events:[{event:"WALLET_SUSPENDED",desc:"Wallet suspended"},{event:"KILL_SWITCH_ACTIVATED",desc:"Emergency lock activated"},{event:"KILL_SWITCH_RECOVERED",desc:"Emergency lock released"},{event:"KILL_SWITCH_ESCALATED",desc:"Kill switch escalated"},{event:"AUTO_STOP_TRIGGERED",desc:"Auto-stop triggered"},{event:"TX_INCOMING_SUSPICIOUS",desc:"Suspicious incoming transaction"}]},{category:"session",label:"Session Events",events:[{event:"SESSION_EXPIRING_SOON",desc:"Session expiring soon"},{event:"SESSION_EXPIRED",desc:"Session expired"},{event:"SESSION_CREATED",desc:"Session created"},{event:"SESSION_WALLET_ADDED",desc:"Wallet added to session"},{event:"SESSION_WALLET_REMOVED",desc:"Wallet removed from session"}]},{category:"owner",label:"Owner Events",events:[{event:"OWNER_SET",desc:"Owner address registered"},{event:"OWNER_REMOVED",desc:"Owner address removed"},{event:"OWNER_VERIFIED",desc:"Owner address verified"}]},{category:"system",label:"System Notifications",events:[{event:"DAILY_SUMMARY",desc:"Daily summary report"},{event:"LOW_BALANCE",desc:"Low balance warning"},{event:"APPROVAL_CHANNEL_SWITCHED",desc:"Approval channel changed"},{event:"UPDATE_AVAILABLE",desc:"Daemon update available"}]}],D=A.flatMap(E=>E.events.map(K=>K.event)).filter(E=>!f.has(E)),x=te(t.value,a.value,"notifications","notify_events")||"[]";let g=[];try{const E=JSON.parse(x);Array.isArray(E)&&(g=E)}catch{}const _=g.length===0?D:g,U=(E,K)=>{const C=K?[..._,E]:_.filter(m=>m!==E),T=C.length===D.length&&D.every(m=>C.includes(m))?[]:C;c("notifications.notify_events",JSON.stringify(T))},F=(E,K)=>{const C=E.events.filter(S=>!f.has(S.event)).map(S=>S.event);let T;if(K)T=[...new Set([..._,...C])];else{const S=new Set(C);T=_.filter(P=>!S.has(P))}const m=T.length===D.length&&D.every(S=>T.includes(S))?[]:T;c("notifications.notify_events",JSON.stringify(m))};return e("div",{class:"event-filter-groups",children:A.map(E=>{const K=E.events.filter(m=>!f.has(m.event)),C=K.every(m=>_.includes(m.event)),T=K.some(m=>_.includes(m.event));return e("details",{class:"event-filter-group",open:!0,children:[e("summary",{class:"event-filter-group-header",children:[e("span",{class:"event-filter-group-label",children:E.label}),e("label",{class:"event-filter-group-all",onClick:m=>m.stopPropagation(),children:[e("input",{type:"checkbox",checked:C,ref:m=>{m&&(m.indeterminate=T&&!C)},onChange:m=>F(E,m.target.checked)})," All"]})]}),e("div",{class:"event-filter-events",children:E.events.map(m=>{const S=f.has(m.event);return e("label",{class:`event-filter-event ${S?"event-broadcast":""}`,children:[e("input",{type:"checkbox",checked:S||_.includes(m.event),disabled:S,onChange:P=>U(m.event,P.target.checked)}),e("code",{children:m.event}),e("span",{class:"event-desc",children:m.desc}),S&&e("span",{class:"event-broadcast-badge",children:"Always sent"})]},m.event)})})]},E.category)})})})(),e("div",{class:"settings-info-box",style:{marginTop:"0.5rem"},children:"Applies to all notification channels (Telegram, Discord, ntfy, Slack) and wallet app side channel. Broadcast events (Kill Switch, Auto Stop, Suspicious TX) always bypass the filter."})]}),e("div",{class:"notif-test-section",children:[e(R,{variant:"secondary",size:"sm",onClick:v,loading:s.value,children:"Test Notification"}),i.value.length>0&&e("div",{class:"test-results",children:i.value.map(f=>e("div",{class:`test-result-item ${f.success?"test-result-success":"test-result-failure"}`,children:[e(z,{variant:f.success?"success":"danger",children:f.success?"OK":"FAIL"}),e("span",{children:f.channel}),f.error&&e("span",{style:"font-size: var(--font-size-xs); color: var(--color-danger);",children:[" - ",f.error]})]},f.channel))})]})]})]})]})}const Zt={enabled:"Enable or disable balance monitoring",check_interval_sec:"How often to check wallet balances",low_balance_threshold_sol:"Alert when SOL balance drops below this amount",low_balance_threshold_eth:"Alert when ETH balance drops below this amount",cooldown_hours:"Suppress duplicate alerts for this many hours"};function rs(){const t=d({}),a=d({}),n=d(!1),l=d(!0),i=async()=>{try{const v=await G(L.ADMIN_SETTINGS);t.value=v}catch(v){const u=v instanceof k?v:new k(0,"UNKNOWN","Unknown error");w("error",$(u.code))}finally{l.value=!1}};B(()=>{i()},[]);const s=(v,u)=>{const f=String(u);a.value={...a.value,[v]:f}},r=async()=>{n.value=!0;try{const v=Object.entries(a.value).filter(([f])=>f.startsWith("monitoring.")).map(([f,A])=>({key:f,value:A})),u=await le(L.ADMIN_SETTINGS,{settings:v});t.value=u.settings,a.value={},w("success","Settings saved and applied")}catch(v){const u=v instanceof k?v:new k(0,"UNKNOWN","Unknown error");w("error",$(u.code))}finally{n.value=!1}},c=()=>{a.value={}};B(()=>(Ee({id:"notifications-balance",isDirty:()=>Object.keys(a.value).filter(v=>v.startsWith("monitoring.")).length>0,save:r,discard:c}),()=>ke("notifications-balance")),[]);const h=[{key:"enabled",type:"checkbox"},{key:"check_interval_sec",type:"number",min:60,max:86400},{key:"low_balance_threshold_sol",type:"number",min:0},{key:"low_balance_threshold_eth",type:"number",min:0},{key:"cooldown_hours",type:"number",min:1,max:168}],o=Object.keys(a.value).filter(v=>v.startsWith("monitoring.")).length;return l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(J,{children:[o>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[o," unsaved change",o>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(R,{variant:"ghost",size:"sm",onClick:c,children:"Discard"}),e(R,{variant:"primary",size:"sm",onClick:r,loading:n.value,children:"Save"})]})]}),e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Balance Monitoring"}),e("p",{class:"settings-description",children:"Periodic balance checks for all active wallets. Sends LOW_BALANCE alerts when native token balance drops below thresholds. Changes apply immediately."})]}),e("div",{class:"settings-category-body",children:[e("div",{class:"settings-fields-grid",children:h.map(v=>v.type==="checkbox"?e("div",{class:"settings-field-full",children:e(I,{label:X(v.key),name:`monitoring.${v.key}`,type:"checkbox",value:He(t.value,a.value,"monitoring",v.key),onChange:u=>s(`monitoring.${v.key}`,u),description:Zt[v.key]})},v.key):e(I,{label:X(v.key),name:`monitoring.${v.key}`,type:"number",value:Number(te(t.value,a.value,"monitoring",v.key))||0,onChange:u=>s(`monitoring.${v.key}`,u),min:v.min,max:v.max,description:Zt[v.key]},v.key))}),e("div",{class:"settings-info-box",children:"Monitors all active wallet native token balances (SOL, ETH) at the configured interval. When balance drops below threshold, a LOW_BALANCE notification is sent. Duplicate alerts are suppressed for the cooldown period (per wallet)."})]})]})]})}function Qt(){const t=d("channels");B(()=>{const T=ie.value;T&&T.tab&&(t.value=T.tab,setTimeout(()=>{Se.value=T.fieldName},100),ie.value=null)},[ie.value]);const a=d(null),n=d(!0),l=d(!1),i=d(null),s=d(null),r=d(null),c=d(!0),h=d(1),o=d(null),v=d({eventType:"",channel:"",status:"",since:"",until:""}),u=async()=>{try{const T=await G(L.ADMIN_NOTIFICATIONS_STATUS);a.value=T}catch(T){const m=T instanceof k?T:new k(0,"UNKNOWN","Unknown error");w("error",$(m.code))}finally{n.value=!1}},f=async T=>{c.value=!0;try{const m=new URLSearchParams;m.set("page",String(T)),m.set("pageSize",String(nt));const S=v.value;if(S.eventType&&m.set("eventType",S.eventType),S.channel&&m.set("channel",S.channel),S.status&&m.set("status",S.status),S.since){const y=new Date(S.since);isNaN(y.getTime())||m.set("since",String(Math.floor(y.getTime()/1e3)))}if(S.until){const y=new Date(S.until);isNaN(y.getTime())||(y.setHours(23,59,59,999),m.set("until",String(Math.floor(y.getTime()/1e3))))}const P=await G(`${L.ADMIN_NOTIFICATIONS_LOG}?${m.toString()}`);r.value=P}catch(m){const S=m instanceof k?m:new k(0,"UNKNOWN","Unknown error");w("error",$(S.code))}finally{c.value=!1}},A=async()=>{l.value=!0,s.value=null;try{const m=(await ne(L.ADMIN_NOTIFICATIONS_TEST,{})).results;s.value=m,m.every(P=>P.success)?w("success","Test sent successfully"):w("warning","Some channels failed")}catch(T){const m=T instanceof k?T:new k(0,"UNKNOWN","Unknown error");w("error",$(m.code))}finally{l.value=!1}},D=async T=>{i.value=T,s.value=null;try{const S=(await ne(L.ADMIN_NOTIFICATIONS_TEST,{channel:T})).results;s.value=S,S.every(y=>y.success)?w("success",`Test sent to ${T}`):w("warning",`${T} test failed`)}catch(m){const S=m instanceof k?m:new k(0,"UNKNOWN","Unknown error");w("error",$(S.code))}finally{i.value=null}},x=()=>{h.value>1&&(h.value-=1,f(h.value))},g=()=>{const T=r.value?Math.ceil(r.value.total/nt):1;h.value<T&&(h.value+=1,f(h.value))},_=T=>{o.value=o.value?.id===T.id?null:T},U=T=>{v.value=T,h.value=1,f(1)};B(()=>{u(),f(1);const T=setInterval(()=>f(h.value),3e4);return()=>clearInterval(T)},[]);const F=n.value&&!a.value,E=a.value?.channels.some(T=>T.enabled)??!1,K=r.value?Math.max(1,Math.ceil(r.value.total/nt)):1,C=[{key:"eventType",header:"Event Type"},{key:"walletId",header:"Wallet ID",render:T=>T.walletId?e("a",{href:`#/wallets/${T.walletId}`,class:"wallet-link",onClick:m=>m.stopPropagation(),title:T.walletId,children:[T.walletId.slice(0,8),"..."]}):"—"},{key:"channel",header:"Channel",render:T=>e("span",{style:{textTransform:"capitalize"},children:T.channel})},{key:"status",header:"Status",render:T=>e(z,{variant:T.status==="sent"?"success":"danger",children:T.status})},{key:"createdAt",header:"Time",render:T=>ve(T.createdAt)}];return e("div",{class:"page",children:[e(na,{pageName:"Notifications",tabName:Jt.find(T=>T.key===t.value)?.label??"",onPageClick:()=>{t.value="channels"}}),e(Ge,{tabs:Jt,activeTab:t.value,onTabChange:T=>{t.value=T}}),t.value==="telegram"?e(ns,{}):t.value==="settings"?e(ss,{}):t.value==="balance"?e(rs,{}):e(J,{children:[e("h2",{children:"Channel Status"}),a.value&&!a.value.enabled&&e("div",{class:"notif-disabled-banner",children:["Notifications are disabled."," ",e("a",{href:"#",onClick:T=>{T.preventDefault(),t.value="settings"},children:"Enable them in the Settings tab"})]}),F?e("div",{class:"channel-grid",children:[1,2,3].map(T=>e("div",{class:"channel-card",children:e("div",{class:"stat-skeleton"})},T))}):e("div",{class:"channel-grid",children:a.value?.channels.map(T=>e("div",{class:"channel-card",children:e("div",{class:"channel-card-header",children:[e("span",{class:"channel-card-name",children:T.name}),e("div",{class:"channel-card-actions",children:[e(z,{variant:T.enabled?"success":"neutral",children:T.enabled?T.configuredWallets!=null?`${T.configuredWallets} wallet${T.configuredWallets!==1?"s":""} configured`:"Connected":"Not Configured"}),T.enabled&&e(R,{variant:"secondary",size:"sm",onClick:()=>D(T.name),loading:i.value===T.name,children:"Test"})]})]})},T.name))}),e("div",{style:{marginTop:"var(--space-4)",marginBottom:"var(--space-6)"},children:[e(R,{onClick:A,loading:l.value,disabled:!E,children:"Test All Channels"}),s.value&&e("div",{class:"test-results",children:s.value.map(T=>e("div",{class:"test-result-item",children:[e("span",{class:T.success?"test-result-success":"test-result-failure",children:T.success?"✓":"✗"}),e("span",{style:{textTransform:"capitalize"},children:T.channel}),!T.success&&T.error&&e("span",{class:"test-result-failure",children:[" - ",T.error]})]},T.channel))})]}),e("h2",{children:"Delivery Log"}),e(za,{fields:is,values:v.value,onChange:U,syncUrl:!1}),e(Ve,{columns:C,data:r.value?.logs??[],loading:c.value,emptyMessage:"No notification logs",onRowClick:_}),o.value&&e("div",{class:"log-message-detail",children:[e("div",{class:"log-message-detail-header",children:[e("strong",{children:o.value.eventType})," via ",e("span",{style:{textTransform:"capitalize"},children:o.value.channel}),e(R,{variant:"ghost",size:"sm",onClick:()=>{o.value=null},children:"Close"})]}),e("div",{class:"log-message-detail-body",children:o.value.message?e("pre",{style:{whiteSpace:"pre-wrap",margin:0,fontSize:"var(--font-size-sm)"},children:o.value.message}):e("span",{class:"text-muted",children:"(No message recorded)"})})]}),e("div",{class:"pagination",children:[e("span",{class:"pagination-info",children:["Page ",h.value," of ",K,r.value?` (${r.value.total} total)`:""]}),e("div",{class:"pagination-buttons",children:[e(R,{variant:"secondary",size:"sm",onClick:x,disabled:h.value<=1,children:"Previous"}),e(R,{variant:"secondary",size:"sm",onClick:g,disabled:h.value>=K,children:"Next"})]})]}),e("div",{class:"config-guidance",children:e("p",{children:"Configure notification channels in the Settings tab above. Changes are applied immediately via hot-reload."})})]})]})}const lt=[{key:"killswitch",label:"Kill Switch"},{key:"autostop",label:"AutoStop Rules"},{key:"jwt",label:"Invalidate Sessions"},{key:"password",label:"Master Password"}];function os(){const t=d(null),a=d(!0),n=d(!1),l=async()=>{try{const u=await G(L.ADMIN_KILL_SWITCH);t.value=u}catch(u){const f=u instanceof k?u:new k(0,"UNKNOWN","Unknown error");w("error",$(f.code))}finally{a.value=!1}};B(()=>{l()},[]);const i=async()=>{n.value=!0;try{await ne(L.ADMIN_KILL_SWITCH),w("success","Kill switch activated - all operations suspended"),await l()}catch(u){const f=u instanceof k?u:new k(0,"UNKNOWN","Unknown error");w("error",$(f.code))}finally{n.value=!1}},s=async()=>{n.value=!0;try{await ne(L.ADMIN_KILL_SWITCH_ESCALATE),w("success","Kill switch escalated to LOCKED"),await l()}catch(u){const f=u instanceof k?u:new k(0,"UNKNOWN","Unknown error");w("error",$(f.code))}finally{n.value=!1}},r=async()=>{n.value=!0;try{await ne(L.ADMIN_RECOVER),w("success","Kill switch recovered - operations resumed"),await l()}catch(u){const f=u instanceof k?u:new k(0,"UNKNOWN","Unknown error");w("error",$(f.code))}finally{n.value=!1}},c=t.value,h=c?.state==="ACTIVE",o=c?.state==="SUSPENDED",v=c?.state==="LOCKED";return e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Kill Switch"}),e("p",{class:"settings-description",children:"Emergency stop - suspends all wallet operations immediately. 3-state: ACTIVE (normal) → SUSPENDED (paused) → LOCKED (permanent)."})]}),e("div",{class:"settings-category-body",children:a.value?e("span",{children:"Loading..."}):c?e(J,{children:[e("div",{class:"ks-state-card",style:{marginBottom:"var(--space-4)"},children:[e(z,{variant:h?"success":v?"danger":"warning",children:c.state}),!h&&c.activatedAt&&e("span",{class:"ks-state-info",children:["Since ",ve(c.activatedAt),c.activatedBy?` by ${c.activatedBy}`:""]})]}),e("div",{style:{display:"flex",gap:"var(--space-2)",flexWrap:"wrap"},children:[h&&e(R,{variant:"danger",onClick:i,loading:n.value,children:"Activate Kill Switch"}),o&&e(J,{children:[e(R,{variant:"primary",onClick:r,loading:n.value,children:"Recover"}),e(R,{variant:"danger",onClick:s,loading:n.value,children:"Escalate to LOCKED"})]}),v&&e(R,{variant:"primary",onClick:r,loading:n.value,children:"Recover from LOCKED (5s wait)"})]}),o&&e("div",{class:"settings-info-box",style:{marginTop:"var(--space-3)"},children:"All wallet operations are suspended. Sessions revoked, transactions cancelled. You can Recover to resume operations, or Escalate to LOCKED for permanent lockdown."}),v&&e("div",{class:"settings-info-box",style:{marginTop:"var(--space-3)",borderColor:"var(--color-danger)"},children:"System is permanently locked. Recovery requires dual-auth (Owner signature + Master password) and has a mandatory 5-second wait period."})]}):null})]})}function cs(){const t=d({}),a=d({}),n=d(!1),l=d(!0),i=async()=>{try{const o=await G(L.ADMIN_SETTINGS);t.value=o}catch(o){const v=o instanceof k?o:new k(0,"UNKNOWN","Unknown error");w("error",$(v.code))}finally{l.value=!1}};B(()=>{i()},[]);const s=(o,v)=>{const u=String(v);a.value={...a.value,[o]:u}},r=async()=>{n.value=!0;try{const o=Object.entries(a.value).filter(([u])=>u.startsWith("autostop.")).map(([u,f])=>({key:u,value:f})),v=await le(L.ADMIN_SETTINGS,{settings:o});t.value=v.settings,a.value={},w("success","AutoStop settings saved and applied")}catch(o){const v=o instanceof k?o:new k(0,"UNKNOWN","Unknown error");w("error",$(v.code))}finally{n.value=!1}},c=()=>{a.value={}};B(()=>(Ee({id:"security-autostop",isDirty:()=>Object.keys(a.value).filter(o=>o.startsWith("autostop.")).length>0,save:r,discard:c}),()=>ke("security-autostop")),[]);const h=Object.keys(a.value).filter(o=>o.startsWith("autostop.")).length;return l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(J,{children:[h>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[h," unsaved change",h>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(R,{variant:"ghost",size:"sm",onClick:c,children:"Discard"}),e(R,{variant:"primary",size:"sm",onClick:r,loading:n.value,children:"Save"})]})]}),e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"AutoStop Rules"}),e("p",{class:"settings-description",children:"Automatic protection rules that suspend wallets or trigger Kill Switch on anomalies. Changes apply immediately without daemon restart."})]}),e("div",{class:"settings-category-body",children:[e("div",{class:"settings-field-full",style:{marginBottom:"var(--space-4)"},children:e(I,{label:X("enabled"),name:"autostop.enabled",type:"checkbox",value:He(t.value,a.value,"autostop","enabled"),onChange:o=>s("autostop.enabled",o),description:"Enable or disable AutoStop protection rules"})}),e(Re,{legend:"Activity Detection",description:"Detects failures and unusual transaction patterns",children:e("div",{class:"settings-fields-grid",children:[e(I,{label:X("consecutive_failures_threshold"),name:"autostop.consecutive_failures_threshold",type:"number",value:Number(te(t.value,a.value,"autostop","consecutive_failures_threshold"))||0,onChange:o=>s("autostop.consecutive_failures_threshold",o),min:1,max:100,description:"Suspend wallet after this many consecutive failed transactions"}),e(I,{label:X("unusual_activity_threshold"),name:"autostop.unusual_activity_threshold",type:"number",value:Number(te(t.value,a.value,"autostop","unusual_activity_threshold"))||0,onChange:o=>s("autostop.unusual_activity_threshold",o),min:5,max:1e3,description:"Max transactions within window before triggering unusual activity alert"}),e(I,{label:X("unusual_activity_window_sec"),name:"autostop.unusual_activity_window_sec",type:"number",value:Number(te(t.value,a.value,"autostop","unusual_activity_window_sec"))||0,onChange:o=>s("autostop.unusual_activity_window_sec",o),min:60,max:86400,description:"Time window for unusual activity detection"})]})}),e(Re,{legend:"Idle Detection",description:"Monitors inactivity and revokes idle sessions",children:e("div",{class:"settings-fields-grid",children:[e(I,{label:X("idle_timeout_sec"),name:"autostop.idle_timeout_sec",type:"number",value:Number(te(t.value,a.value,"autostop","idle_timeout_sec"))||0,onChange:o=>s("autostop.idle_timeout_sec",o),min:60,max:604800,description:"Revoke sessions with no activity for this duration"}),e(I,{label:X("idle_check_interval_sec"),name:"autostop.idle_check_interval_sec",type:"number",value:Number(te(t.value,a.value,"autostop","idle_check_interval_sec"))||0,onChange:o=>s("autostop.idle_check_interval_sec",o),min:10,max:3600,description:"How often to check for idle sessions"})]})}),e("div",{class:"settings-info-box",children:[e("strong",{children:"Consecutive Failures:"})," Suspends wallet after N consecutive failed transactions.",e("br",{}),e("strong",{children:"Unusual Activity:"})," Suspends wallet if transaction count exceeds threshold within the time window.",e("br",{}),e("strong",{children:"Idle Timeout:"})," Revokes sessions with no activity for the configured duration."]})]})]})]})}function ds(){const t=d(!1),a=d(!1),n=async()=>{a.value=!0;try{await ne(L.ADMIN_ROTATE_SECRET),t.value=!1,w("success","All session tokens invalidated. Old tokens remain valid for 5 minutes.")}catch(l){const i=l instanceof k?l:new k(0,"UNKNOWN","Unknown error");w("error",$(i.code))}finally{a.value=!1}};return e(J,{children:[e("div",{class:"settings-section",children:[e("div",{class:"settings-section-header",children:[e("h3",{children:"Invalidate All Session Tokens"}),e("p",{class:"settings-description",children:"Revoke all active session tokens by rotating the signing key. Existing tokens remain valid for 5 minutes, then all wallets must create new sessions."})]}),e("div",{class:"settings-section-body",children:e(R,{variant:"secondary",onClick:()=>{t.value=!0},children:"Invalidate All Tokens"})})]}),e(we,{open:t.value,title:"Invalidate All Session Tokens",onCancel:()=>{t.value=!1},onConfirm:n,confirmText:"Invalidate",confirmVariant:"primary",loading:a.value,children:e("p",{children:"This will rotate the signing key and invalidate all active session tokens after 5 minutes. Every wallet will need to create a new session to continue API access. Use this when a token may have been compromised."})})]})}function us(){const t=d(""),a=d(""),n=d(""),l=d(!1),i=d(null),s=()=>a.value.length<8?(i.value="New password must be at least 8 characters.",!1):a.value!==n.value?(i.value="New password and confirmation do not match.",!1):(i.value=null,!0),r=async()=>{if(s()){l.value=!0;try{await le(L.ADMIN_MASTER_PASSWORD,{newPassword:a.value}),w("success","Master password changed. Please log in again."),t.value="",a.value="",n.value="",setTimeout(()=>Va(),500)}catch(c){const h=c instanceof k?c:new k(0,"UNKNOWN","Unknown error");w("error",$(h.code))}finally{l.value=!1}}};return e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Change Master Password"}),e("p",{class:"settings-description",children:"Update the master password used to authenticate with the Admin UI. You will be logged out after a successful change."})]}),e("div",{class:"settings-category-body",children:[i.value&&e("div",{class:"settings-info-box",style:{borderColor:"var(--color-danger)",color:"var(--color-danger)",marginBottom:"var(--space-3)"},children:i.value}),e("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-3)",maxWidth:"400px"},children:[e(I,{label:"Current Password",name:"current-password",type:"password",value:t.value,onChange:c=>{t.value=String(c)}}),e(I,{label:"New Password",name:"new-password",type:"password",value:a.value,onChange:c=>{a.value=String(c)},description:"Minimum 8 characters"}),e(I,{label:"Confirm New Password",name:"confirm-password",type:"password",value:n.value,onChange:c=>{n.value=String(c)}}),e("div",{children:e(R,{variant:"primary",onClick:r,loading:l.value,disabled:!t.value||!a.value||!n.value,children:"Change Password"})})]})]})]})}function vs(){const t=(()=>{const l=location.hash,i=l.indexOf("?");if(i>=0){const r=new URLSearchParams(l.slice(i+1)).get("tab");if(r&&lt.some(c=>c.key===r))return r}return"killswitch"})(),a=d(t);B(()=>{const l=ie.value;l&&l.tab&&(a.value=l.tab,setTimeout(()=>{Se.value=l.fieldName},100),ie.value=null)},[ie.value]);const n=lt.find(l=>l.key===a.value)?.label??"";return e("div",{class:"page",children:[e(na,{pageName:"Security",tabName:n,onPageClick:()=>{a.value="killswitch"}}),e(Ge,{tabs:lt,activeTab:a.value,onTabChange:l=>{a.value=l}}),a.value==="killswitch"&&e(os,{}),a.value==="autostop"&&e(cs,{}),a.value==="jwt"&&e(ds,{}),a.value==="password"&&e(us,{})]})}const Ca=[{code:"USD",name:"US Dollar",symbol:"$"},{code:"KRW",name:"Korean Won",symbol:"₩"},{code:"JPY",name:"Japanese Yen",symbol:"¥"},{code:"EUR",name:"Euro",symbol:"€"},{code:"GBP",name:"British Pound",symbol:"£"},{code:"CNY",name:"Chinese Yuan",symbol:"¥"},{code:"CAD",name:"Canadian Dollar",symbol:"CA$"},{code:"AUD",name:"Australian Dollar",symbol:"A$"},{code:"CHF",name:"Swiss Franc",symbol:"CHF"},{code:"SGD",name:"Singapore Dollar",symbol:"S$"},{code:"HKD",name:"Hong Kong Dollar",symbol:"HK$"},{code:"INR",name:"Indian Rupee",symbol:"₹"},{code:"TWD",name:"Taiwan Dollar",symbol:"NT$"},{code:"THB",name:"Thai Baht",symbol:"฿"},{code:"MYR",name:"Malaysian Ringgit",symbol:"RM"},{code:"IDR",name:"Indonesian Rupiah",symbol:"Rp"},{code:"PHP",name:"Philippine Peso",symbol:"₱"},{code:"VND",name:"Vietnamese Dong",symbol:"₫"},{code:"BRL",name:"Brazilian Real",symbol:"R$"},{code:"MXN",name:"Mexican Peso",symbol:"MX$"},{code:"CLP",name:"Chilean Peso",symbol:"CL$"},{code:"TRY",name:"Turkish Lira",symbol:"₺"},{code:"PLN",name:"Polish Zloty",symbol:"zł"},{code:"CZK",name:"Czech Koruna",symbol:"Kč"},{code:"HUF",name:"Hungarian Forint",symbol:"Ft"},{code:"SEK",name:"Swedish Krona",symbol:"kr"},{code:"NOK",name:"Norwegian Krone",symbol:"kr"},{code:"DKK",name:"Danish Krone",symbol:"kr"},{code:"NZD",name:"New Zealand Dollar",symbol:"NZ$"},{code:"ZAR",name:"South African Rand",symbol:"R"},{code:"ILS",name:"Israeli Shekel",symbol:"₪"},{code:"SAR",name:"Saudi Riyal",symbol:"SR"},{code:"AED",name:"UAE Dirham",symbol:"AED"},{code:"KWD",name:"Kuwaiti Dinar",symbol:"KD"},{code:"BHD",name:"Bahraini Dinar",symbol:"BD"},{code:"NGN",name:"Nigerian Naira",symbol:"₦"},{code:"RUB",name:"Russian Ruble",symbol:"₽"},{code:"UAH",name:"Ukrainian Hryvnia",symbol:"₴"},{code:"PKR",name:"Pakistani Rupee",symbol:"Rs"},{code:"BDT",name:"Bangladeshi Taka",symbol:"৳"},{code:"LKR",name:"Sri Lankan Rupee",symbol:"Rs"},{code:"MMK",name:"Myanmar Kyat",symbol:"K"},{code:"GEL",name:"Georgian Lari",symbol:"₾"}];function hs({value:t,onChange:a,name:n}){const l=d(""),i=d(!1),s=d(null),r=d(!1),c=_a(null),h=Ba(()=>{const v=l.value.toLowerCase();return v?Ca.filter(u=>u.code.toLowerCase().includes(v)||u.name.toLowerCase().includes(v)||u.symbol.includes(v)):Ca});B(()=>{if(t==="USD"){s.value="1 USD = $1.00";return}r.value=!0,G(`${L.ADMIN_FOREX_RATES}?currencies=${t}`).then(v=>{const u=v.rates[t];s.value=u?.preview??null}).catch(()=>{s.value=null}).finally(()=>{r.value=!1})},[t]),B(()=>{const v=u=>{c.current&&!c.current.contains(u.target)&&(i.value=!1,l.value="")};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[]);const o=Ca.find(v=>v.code===t)??Ca[0];return e("div",{class:"currency-select",ref:c,children:[n&&e("input",{type:"hidden",name:n,value:t}),e("button",{type:"button",class:"currency-select-trigger",onClick:()=>{i.value=!i.value},children:[e("span",{class:"currency-select-value",children:[o.code," - ",o.name," (",o.symbol,")"]}),e("span",{class:"currency-select-chevron",children:i.value?"▲":"▼"})]}),s.value&&e("div",{class:"currency-rate-preview",children:r.value?"...":s.value}),i.value&&e("div",{class:"currency-select-dropdown",children:[e("input",{type:"text",class:"currency-select-search",placeholder:"Search currency...",value:l.value,onInput:v=>{l.value=v.target.value},autoFocus:!0}),e("div",{class:"currency-select-list",children:[h.value.map(v=>e("button",{type:"button",class:`currency-select-option ${v.code===t?"currency-select-option--active":""}`,onClick:()=>{a(v.code),i.value=!1,l.value=""},children:[e("span",{class:"currency-option-code",children:v.code}),e("span",{class:"currency-option-name",children:v.name}),e("span",{class:"currency-option-symbol",children:v.symbol})]},v.code)),h.value.length===0&&e("div",{class:"currency-select-empty",children:"No currencies found"})]})]})]})}const ps=["display.","daemon.","oracle.","gas_condition."],ms=new Set(["security.rate_limit_global_ip_rpm"]);function it(t){return ps.some(a=>t.startsWith(a))||ms.has(t)}function fs(){const t=d({}),a=d({}),n=d(!1),l=d(!0),i=d([]),s=d(!0);d(null),d(""),d(!1);const r=d(!1),c=d(!1),h=d(""),o=d(!1),v=async()=>{try{const m=await G(L.ADMIN_SETTINGS);t.value=m}catch(m){const S=m instanceof k?m:new k(0,"UNKNOWN","Unknown error");w("error",$(S.code))}finally{l.value=!1}},u=async()=>{try{const m=await G(L.ADMIN_API_KEYS);i.value=m.keys}catch{}finally{s.value=!1}};B(()=>{v(),u()},[]),B(()=>{const m=ie.value;m&&(setTimeout(()=>{Se.value=m.fieldName},100),ie.value=null)},[ie.value]);const f=(m,S)=>te(t.value,a.value,m,S),A=(m,S)=>da(t.value,a.value,m,S),D=(m,S)=>{const P=String(S);a.value={...a.value,[m]:P}},x=async()=>{n.value=!0;try{const m=Object.entries(a.value).filter(([P])=>it(P)).map(([P,y])=>({key:P,value:y})),S=await le(L.ADMIN_SETTINGS,{settings:m});t.value=S.settings,a.value={},w("success","Settings saved and applied")}catch(m){const S=m instanceof k?m:new k(0,"UNKNOWN","Unknown error");w("error",$(S.code))}finally{n.value=!1}},g=()=>{a.value={}};B(()=>(Ee({id:"system-settings",isDirty:()=>Object.keys(a.value).filter(m=>it(m)).length>0,save:x,discard:g}),()=>ke("system-settings")),[]);const _=async()=>{c.value=!0;try{await ne(L.ADMIN_SHUTDOWN),r.value=!1,h.value="",w("info","Shutdown initiated"),o.value=!0}catch(m){const S=m instanceof k?m:new k(0,"UNKNOWN","Unknown error");w("error",$(S.code))}finally{c.value=!1}},U=Object.keys(a.value).filter(m=>it(m)).length;function F(){return e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Oracle"}),e("p",{class:"settings-description",children:"Price oracle configuration for cross-validation"})]}),e("div",{class:"settings-category-body",children:[e("div",{class:"settings-fields-grid",children:e(I,{label:"Cross Validation Threshold (%)",name:"oracle.cross_validation_threshold",type:"number",value:Number(f("oracle","cross_validation_threshold"))||5,onChange:m=>D("oracle.cross_validation_threshold",m),min:0,max:100,description:"Maximum allowed deviation between price oracle sources"})}),e("div",{style:{borderTop:"1px solid var(--border)",paddingTop:"var(--space-3)",marginTop:"var(--space-3)"},children:e(I,{label:"CoinGecko API Key",name:"oracle.coingecko_api_key",type:"password",value:A("oracle","coingecko_api_key")?"••••••••":"",onChange:m=>D("oracle.coingecko_api_key",m),placeholder:"Enter CoinGecko Pro API key (optional)",description:"Pro API key for higher rate limits. Free tier: ~30 req/min."})}),e("div",{class:"settings-info-box",children:["Maximum allowed deviation between price sources before flagging a discrepancy. Default is 5%. CoinGecko Pro API key increases rate limits for reliable price data. Get your API key from"," ",e("a",{href:"https://www.coingecko.com/en/api",target:"_blank",rel:"noopener noreferrer",children:"CoinGecko API Dashboard"}),"."]})]})]})}function E(){const m=Se.value==="display.currency";return B(()=>{if(m){const S=document.querySelector('[name="display.currency"]');S&&S.closest(".form-field")?.scrollIntoView({behavior:"smooth",block:"center"});const P=setTimeout(()=>{Se.value=""},2500);return()=>clearTimeout(P)}},[m]),e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Display Currency"}),e("p",{class:"settings-description",children:"Configure display currency for USD amount conversion"})]}),e("div",{class:"settings-category-body",children:[e("div",{class:"settings-fields-grid",children:e("div",{class:`form-field${m?" form-field--highlight":""}`,children:[e("label",{children:X("currency")}),e(hs,{name:"display.currency",value:f("display","currency")||"USD",onChange:S=>D("display.currency",S)})]})}),e("div",{class:"settings-info-box",children:"All USD amounts in the dashboard, notifications, and API responses will be converted to the selected currency. Policy evaluation always uses USD. The “≈” prefix indicates an approximate conversion."})]})]})}function K(){return e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Global IP Rate Limit"}),e("p",{class:"settings-description",children:"Maximum API requests per minute from a single IP address"})]}),e("div",{class:"settings-category-body",children:e("div",{class:"settings-fields-grid",children:e(I,{label:X("rate_limit_global_ip_rpm"),name:"security.rate_limit_global_ip_rpm",type:"number",value:Number(f("security","rate_limit_global_ip_rpm"))||0,onChange:m=>D("security.rate_limit_global_ip_rpm",m),min:10,description:"Maximum API requests per minute from a single IP address"})})})]})}function C(){return e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Log Level"}),e("p",{class:"settings-description",children:"General daemon configuration"})]}),e("div",{class:"settings-category-body",children:e("div",{class:"settings-fields-grid",children:e(I,{label:X("log_level"),name:"daemon.log_level",type:"select",value:f("daemon","log_level")||"info",onChange:m=>D("daemon.log_level",m),options:[{label:"debug",value:"debug"},{label:"info",value:"info"},{label:"warn",value:"warn"},{label:"error",value:"error"}],description:"Daemon logging verbosity level"})})})]})}function T(){return e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Gas Condition"}),e("p",{class:"settings-description",children:"Configure gas conditional execution for deferred transactions"})]}),e("div",{class:"settings-category-body",children:[e("div",{class:"settings-fields-grid",children:[e(I,{label:"Gas Condition Enabled",name:"gas_condition.enabled",type:"select",value:f("gas_condition","enabled")||"true",onChange:m=>D("gas_condition.enabled",m),options:[{label:"Yes",value:"true"},{label:"No",value:"false"}],description:"Enable gas conditional execution for agents"}),e(I,{label:X("poll_interval_sec"),name:"gas_condition.poll_interval_sec",type:"number",value:Number(f("gas_condition","poll_interval_sec"))||30,onChange:m=>D("gas_condition.poll_interval_sec",m),min:10,max:300,description:"How often to check gas prices (seconds)"}),e(I,{label:X("default_timeout_sec"),name:"gas_condition.default_timeout_sec",type:"number",value:Number(f("gas_condition","default_timeout_sec"))||3600,onChange:m=>D("gas_condition.default_timeout_sec",m),min:60,max:86400,description:"Default wait timeout when not specified in request (seconds)"}),e(I,{label:X("max_timeout_sec"),name:"gas_condition.max_timeout_sec",type:"number",value:Number(f("gas_condition","max_timeout_sec"))||86400,onChange:m=>D("gas_condition.max_timeout_sec",m),min:60,max:86400,description:"Maximum allowed timeout for gas conditions (seconds)"}),e(I,{label:X("max_pending_count"),name:"gas_condition.max_pending_count",type:"number",value:Number(f("gas_condition","max_pending_count"))||100,onChange:m=>D("gas_condition.max_pending_count",m),min:1,max:1e4,description:"Maximum number of concurrent GAS_WAITING transactions"})]}),e("div",{class:"settings-info-box",children:"Gas conditional execution allows agents to specify gas price conditions. Transactions wait until gas prices fall below the specified threshold before executing."})]})]})}return e("div",{class:"page",children:[o.value&&e("div",{class:"shutdown-overlay",children:[e("h2",{children:"Daemon is shutting down..."}),e("p",{children:"You can close this tab."})]}),U>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[U," unsaved change",U>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(R,{variant:"ghost",size:"sm",onClick:g,children:"Discard"}),e(R,{variant:"primary",size:"sm",onClick:x,loading:n.value,children:"Save"})]})]}),l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(J,{children:[e(F,{}),e(E,{}),e(K,{}),e(C,{}),e(T,{})]}),e("div",{class:"settings-section settings-section--danger",children:[e("div",{class:"settings-section-header",children:[e("h3",{children:"Danger Zone"}),e("p",{class:"settings-description",children:"Irreversible actions. Proceed with caution."})]}),e("div",{class:"settings-section-body",children:e(R,{variant:"danger",onClick:()=>{r.value=!0},children:"Shutdown Daemon"})})]}),e(we,{open:r.value,title:"Shutdown Daemon",onCancel:()=>{r.value=!1,h.value=""},onConfirm:_,confirmText:"Shutdown",confirmVariant:"danger",confirmDisabled:h.value!=="SHUTDOWN",loading:c.value,children:[e("p",{children:"This will gracefully stop the daemon process. All active connections will be terminated."}),e("div",{class:"shutdown-confirm-input",children:[e("label",{children:["Type ",e("strong",{children:"SHUTDOWN"})," to confirm"]}),e("input",{type:"text",value:h.value,onInput:m=>{h.value=m.target.value},placeholder:"SHUTDOWN"})]})]})]})}const en=[{key:"jupiter_swap",name:"Jupiter Swap",description:"Solana DEX aggregator",chain:"solana",requiresApiKey:!1,docsUrl:"https://station.jup.ag/docs"},{key:"zerox_swap",name:"0x Swap",description:"EVM DEX aggregator (AllowanceHolder)",chain:"evm",requiresApiKey:!0,docsUrl:"https://dashboard.0x.org"},{key:"lifi",name:"LI.FI",description:"Multi-chain DEX/bridge aggregator",chain:"multi",requiresApiKey:!1,docsUrl:"https://docs.li.fi"},{key:"lido_staking",name:"Lido Staking",description:"ETH liquid staking (stETH/wstETH)",chain:"evm",requiresApiKey:!1,docsUrl:"https://docs.lido.fi"},{key:"jito_staking",name:"Jito Staking",description:"SOL liquid staking (JitoSOL)",chain:"solana",requiresApiKey:!1,docsUrl:"https://www.jito.network/docs"},{key:"aave_v3",name:"Aave V3 Lending",description:"EVM lending protocol (supply, borrow, repay, withdraw)",chain:"evm",requiresApiKey:!1,docsUrl:"https://docs.aave.com/developers"},{key:"kamino",name:"Kamino Lending",description:"Solana lending protocol (supply, borrow, repay, withdraw)",chain:"solana",requiresApiKey:!1,docsUrl:"https://docs.kamino.finance"},{key:"pendle_yield",name:"Pendle Yield",description:"EVM yield trading: buy/sell PT/YT, redeem at maturity, add/remove LP",chain:"evm",requiresApiKey:!1,docsUrl:"https://docs.pendle.finance"},{key:"drift_perp",name:"Drift Perp",description:"Solana perpetual futures trading (open, close, modify positions with leverage)",chain:"solana",requiresApiKey:!1,docsUrl:"https://docs.drift.trade"}];function gs(){const t=d([]),a=d({}),n=d([]),l=d(!0),i=d(null),s=d(""),r=d(!1),c=d(null),h=d({}),o=async()=>{try{const C=await G(L.ADMIN_SETTINGS);a.value=C}catch(C){const T=C instanceof k?C:new k(0,"UNKNOWN","Unknown error");w("error",$(T.code))}},v=async()=>{try{const C=await G(L.ADMIN_API_KEYS);n.value=C.keys}catch{}},u=async()=>{try{const C=await G(L.ACTIONS_PROVIDERS);t.value=C.providers??[]}catch{}},f=async()=>{l.value=!0,await Promise.all([o(),v(),u()]),l.value=!1};B(()=>{f()},[]);const A=async(C,T)=>{const m=`actions.${C}_enabled`;c.value=C;try{const S=await le(L.ADMIN_SETTINGS,{settings:[{key:m,value:String(T)}]});a.value=S.settings,w("success",`${T?"Enabled":"Disabled"} ${C.replace(/_/g," ")}`)}catch(S){const P=S instanceof k?S:new k(0,"UNKNOWN","Unknown error");w("error",$(P.code))}finally{c.value=null}},D=async C=>{r.value=!0;try{await le(L.ADMIN_API_KEY(C),{apiKey:s.value}),w("success",`API key saved for ${C}`),i.value=null,s.value="",await v()}catch(T){const m=T instanceof k?T:new k(0,"UNKNOWN","Unknown error");w("error",$(m.code))}finally{r.value=!1}},x=async C=>{try{await Me(L.ADMIN_API_KEY(C)),w("success",`API key deleted for ${C}`),await v()}catch(T){const m=T instanceof k?T:new k(0,"UNKNOWN","Unknown error");w("error",$(m.code))}},g=async(C,T)=>{const m=`actions.${C}`;try{const S=await le(L.ADMIN_SETTINGS,{settings:[{key:m,value:T}]});a.value=S.settings;const P={...h.value};delete P[C],h.value=P,w("success","Setting updated")}catch(S){const P=S instanceof k?S:new k(0,"UNKNOWN","Unknown error");w("error",$(P.code))}};function _(C){const T=a.value.actions;return T?T[`${C}_enabled`]==="true":!1}function U(C){return t.value.some(T=>T.name.toLowerCase().replace(/[\s-]/g,"_")===C||T.name.toLowerCase().includes(C.replace(/_/g," ")))}function F(C){return n.value.find(T=>T.providerName===C||T.providerName.toLowerCase().replace(/[\s-]/g,"_")===C)}function E(C){return t.value.find(T=>T.name.toLowerCase().replace(/[\s-]/g,"_")===C||T.name.toLowerCase().includes(C.replace(/_/g," ")))}function K(C){const T=_(C.key),m=U(C.key);return T&&C.requiresApiKey&&!F(C.key)?.hasKey?{label:"Requires API Key",variant:"warning"}:T&&m?{label:"Active",variant:"success"}:{label:"Inactive",variant:"neutral"}}return l.value?e("div",{class:"page",children:e("div",{class:"empty-state",children:e("p",{children:"Loading action providers..."})})}):e("div",{class:"page",children:[en.map(C=>{const T=K(C),m=_(C.key),S=E(C.key),P=F(C.key),y=c.value===C.key;return e("div",{class:"settings-category",style:{marginBottom:"var(--space-4)"},children:[e("div",{class:"settings-category-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e("div",{children:[e("h3",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)",margin:0},children:[C.name,S&&e(z,{variant:"info",children:S.version}),e(z,{variant:(C.chain==="solana","info"),children:C.chain})]}),e("p",{class:"settings-description",style:{marginTop:"var(--space-1)"},children:[C.description,C.docsUrl&&e(J,{children:[" ","—"," ",e("a",{href:C.docsUrl,target:"_blank",rel:"noopener noreferrer",children:"Docs"})]})]})]}),e(z,{variant:T.variant,children:T.label})]}),e("div",{class:"settings-category-body",children:[e("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-3)",marginBottom:"var(--space-3)"},children:[e(I,{label:"Enabled",name:`actions.${C.key}_enabled`,type:"checkbox",value:m,onChange:p=>A(C.key,!!p),disabled:y}),y&&e("span",{style:{fontSize:"var(--font-size-sm)",color:"var(--text-secondary)"},children:"Saving..."})]}),C.requiresApiKey&&e("div",{style:{borderTop:"1px solid var(--border)",paddingTop:"var(--space-3)",marginBottom:"var(--space-3)"},children:[e("div",{style:{fontWeight:600,fontSize:"var(--font-size-sm)",marginBottom:"var(--space-2)",color:"var(--text-secondary)"},children:"API Key"}),i.value===C.key?e("div",{style:{display:"flex",alignItems:"flex-end",gap:"var(--space-2)"},children:[e(I,{label:"API Key",type:"password",name:`apikey-${C.key}`,value:s.value,onChange:p=>{s.value=String(p)},placeholder:"Enter API key"}),e(R,{onClick:()=>D(C.key),loading:r.value,size:"sm",children:"Save"}),e(R,{variant:"ghost",onClick:()=>{i.value=null,s.value=""},size:"sm",children:"Cancel"})]}):e("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)"},children:[e("span",{style:{fontFamily:"monospace",fontSize:"var(--font-size-sm)",color:"var(--text-secondary)"},children:P?.hasKey?P.maskedKey:"Not set"}),e(R,{variant:"ghost",onClick:()=>{i.value=C.key,s.value=""},size:"sm",children:P?.hasKey?"Update":"Set"}),P?.hasKey&&e(R,{variant:"danger",onClick:()=>x(C.key),size:"sm",children:"Delete"})]})]}),C.key==="aave_v3"&&m&&e("div",{style:{borderTop:"1px solid var(--border)",paddingTop:"var(--space-3)",marginBottom:"var(--space-3)"},children:[e("div",{style:{fontWeight:600,fontSize:"var(--font-size-sm)",marginBottom:"var(--space-2)",color:"var(--text-secondary)"},children:"Advanced Settings"}),["aave_v3_health_factor_warning_threshold","aave_v3_position_sync_interval_sec","aave_v3_max_ltv_pct"].map(p=>{const W=a.value.actions,H=h.value[p]??W?.[p]??"";return e("div",{style:{marginBottom:"var(--space-2)"},onBlur:()=>{const j=h.value[p];j!==void 0&&g(p,j)},children:e(I,{label:X(p),name:`actions.${p}`,type:"text",value:H,onChange:j=>{h.value={...h.value,[p]:String(j)}}})},p)})]}),C.key==="kamino"&&m&&e("div",{style:{borderTop:"1px solid var(--border)",paddingTop:"var(--space-3)",marginBottom:"var(--space-3)"},children:[e("div",{style:{fontWeight:600,fontSize:"var(--font-size-sm)",marginBottom:"var(--space-2)",color:"var(--text-secondary)"},children:"Advanced Settings"}),["kamino_market","kamino_hf_threshold"].map(p=>{const W=a.value.actions,H=h.value[p]??W?.[p]??"";return e("div",{style:{marginBottom:"var(--space-2)"},onBlur:()=>{const j=h.value[p];j!==void 0&&g(p,j)},children:e(I,{label:X(p),name:`actions.${p}`,type:"text",value:H,onChange:j=>{h.value={...h.value,[p]:String(j)}}})},p)})]}),C.key==="drift_perp"&&m&&e("div",{style:{borderTop:"1px solid var(--border)",paddingTop:"var(--space-3)",marginBottom:"var(--space-3)"},children:[e("div",{style:{fontWeight:600,fontSize:"var(--font-size-sm)",marginBottom:"var(--space-2)",color:"var(--text-secondary)"},children:"Advanced Settings"}),["drift_max_leverage","drift_max_position_usd","drift_margin_warning_threshold_pct","drift_position_sync_interval_sec"].map(p=>{const W=a.value.actions,H=h.value[p]??W?.[p]??"";return e("div",{style:{marginBottom:"var(--space-2)"},onBlur:()=>{const j=h.value[p];j!==void 0&&g(p,j)},children:e(I,{label:X(p),name:`actions.${p}`,type:"text",value:H,onChange:j=>{h.value={...h.value,[p]:String(j)}}})},p)})]}),m&&S&&S.actions.length>0&&e("div",{style:{borderTop:"1px solid var(--border)",paddingTop:"var(--space-3)"},children:[e("div",{style:{fontWeight:600,fontSize:"var(--font-size-sm)",marginBottom:"var(--space-2)",color:"var(--text-secondary)"},children:"Registered Actions"}),e("table",{class:"table",children:[e("thead",{children:e("tr",{children:[e("th",{children:"Name"}),e("th",{children:"Chain"}),e("th",{children:"Risk Level"}),e("th",{children:"Default Tier"})]})}),e("tbody",{children:S.actions.map(p=>e("tr",{children:[e("td",{children:p.name}),e("td",{children:e(z,{variant:"info",children:p.chain})}),e("td",{children:p.riskLevel}),e("td",{children:p.defaultTier})]},p.name))})]})]})]})]},C.key)}),en.length===0&&e("div",{class:"empty-state",children:e("p",{children:"No action providers available."})})]})}function ys(){const t=d([]),a=d(!0),n=d(!1),l=d(!1),i=d(!1),s=d(null),r=d(!1),c=d(""),h=d(""),o=d(""),v=d(!1),u=d({}),f=d(null),A=d(null),D=d({}),x=d(null),g=async()=>{try{const p=await G(L.ADMIN_WALLET_APPS);t.value=p.apps}catch{w("Failed to load wallet apps","error")}},_=async()=>{try{const W=(await G(L.ADMIN_SETTINGS)).signing_sdk;W&&(l.value=String(W.enabled)==="true",n.value=String(W.notifications_enabled)==="true")}catch{}};B(()=>{Promise.all([g(),_()]).finally(()=>{a.value=!1})},[]);const U=async()=>{i.value=!0;const p=!n.value;try{await le(L.ADMIN_SETTINGS,{settings:[{key:"signing_sdk.notifications_enabled",value:String(p)}]}),n.value=p,w(`Wallet app notifications ${p?"enabled":"disabled"}`,"success")}catch{w("Failed to update notification setting","error")}finally{i.value=!1}},F=async(p,W)=>{A.value=`${p.id}-${W}`;try{await le(L.ADMIN_WALLET_APP(p.id),{[W]:!p[W]}),await g(),w(`${W==="signing_enabled"?"Signing":"Alerts"} ${p[W]?"disabled":"enabled"} for ${p.display_name}`,"success")}catch{w("Failed to update toggle","error")}finally{A.value=null}},E=async p=>{s.value=p.id;try{const W=await ne(L.ADMIN_WALLET_APP_TEST_NOTIFICATION(p.id));W.success?w(`Test notification sent to ${W.topic}`,"success"):w(W.error||"Test notification failed","error")}catch{w("Failed to send test notification","error")}finally{s.value=null}},K=async()=>{if(!c.value.trim()||!h.value.trim()){w("Name and display name are required","error");return}v.value=!0;try{const p={name:c.value.trim(),display_name:h.value.trim()};o.value.trim()&&(p.wallet_type=o.value.trim()),await ne(L.ADMIN_WALLET_APPS,p),r.value=!1,c.value="",h.value="",o.value="",await g(),w("Wallet app registered","success")}catch(p){p instanceof k&&p.code==="WALLET_APP_DUPLICATE"?w("App already registered","error"):w("Failed to register app","error")}finally{v.value=!1}},C=async(p,W)=>{f.value=p.id;try{await le(L.ADMIN_WALLET_APP(p.id),{subscription_token:W||""});const H={...u.value};delete H[p.id],u.value=H,await g(),w(W?"Subscription token set":"Subscription token cleared","success")}catch{w("Failed to update subscription token","error")}finally{f.value=null}},T=async p=>{if(confirm(`Remove "${p.display_name}"? Wallets using this app will no longer route signing requests to it.`))try{await Me(L.ADMIN_WALLET_APP(p.id)),await g(),w(`${p.display_name} removed`,"success")}catch{w("Failed to remove app","error")}},m=p=>{D.value={...D.value,[p.id]:{signTopic:p.sign_topic??"",notifyTopic:p.notify_topic??""}}},S=p=>{const W={...D.value};delete W[p],D.value=W},P=async p=>{const W=D.value[p.id];if(W){x.value=p.id;try{await le(L.ADMIN_WALLET_APP(p.id),{sign_topic:W.signTopic||null,notify_topic:W.notifyTopic||null}),S(p.id),await g(),w("Topics updated","success")}catch{w("Failed to update topics","error")}finally{x.value=null}}},y=t.value.some(p=>p.alerts_enabled);return a.value?e("div",{class:"loading-container",children:"Loading..."}):e("div",{class:"human-wallet-apps-page",children:[e("div",{class:"settings-category",style:{marginBottom:"1.5rem"},children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Wallet App Notifications"}),e("p",{class:"settings-description",children:"Push event notifications (transaction alerts, balance changes) to registered wallet apps via ntfy"})]}),e("div",{class:"settings-category-body",children:[e("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[e("input",{type:"checkbox",checked:n.value,onChange:U,disabled:i.value,"data-testid":"notif-toggle"}),e("span",{children:"Notifications"}),e(z,{variant:n.value?"success":"muted",children:n.value?"ON":"OFF"})]}),i.value&&e("span",{style:{fontSize:"0.85rem",color:"var(--text-muted)"},children:"Saving..."})]}),!l.value&&e("div",{class:"settings-warning-box",style:{marginTop:"0.75rem",padding:"0.75rem",background:"var(--warning-bg, #fff3cd)",border:"1px solid var(--warning-border, #ffc107)",borderRadius:"4px",fontSize:"0.85rem"},children:"Signing SDK is disabled. Enable it in System > Signing SDK to use wallet app notifications."}),!n.value&&y&&e("div",{class:"settings-warning-box",style:{marginTop:"0.75rem",padding:"0.75rem",background:"var(--warning-bg, #fff3cd)",border:"1px solid var(--warning-border, #ffc107)",borderRadius:"4px",fontSize:"0.85rem"},children:"Notifications are disabled but some apps have alerts enabled. Enable notifications above for alerts to be delivered."})]})]}),e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e("div",{children:[e("h3",{children:"Registered Apps"}),e("p",{class:"settings-description",children:"Wallet apps registered for signing and notifications"})]}),e(R,{onClick:()=>{r.value=!0},children:"+ Register App"})]}),e("div",{class:"settings-category-body",children:t.value.length===0?e("div",{class:"settings-info-box",children:'No wallet apps registered. Use "+ Register App" to add one, or apply a wallet preset when setting up a wallet owner.'}):e("div",{style:{display:"grid",gap:"1rem"},children:t.value.map(p=>e("div",{class:"settings-category",style:{border:"1px solid var(--border)",padding:"1rem"},children:[e("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e("div",{children:[e("h4",{style:{margin:"0 0 0.25rem 0"},children:[p.display_name,p.wallet_type&&p.wallet_type!==p.name&&e(z,{variant:"info",style:{marginLeft:"0.5rem",fontSize:"0.7rem"},children:p.wallet_type})]}),e("code",{style:{fontSize:"0.8rem",color:"var(--text-muted)"},children:p.name})]}),e(R,{variant:"danger",size:"sm",onClick:()=>T(p),children:"Remove"})]}),e("div",{style:{display:"flex",gap:"2rem",marginTop:"1rem",flexWrap:"wrap",alignItems:"center"},children:[e("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[e("input",{type:"checkbox",checked:p.signing_enabled,onChange:()=>F(p,"signing_enabled"),disabled:A.value===`${p.id}-signing_enabled`}),e("span",{children:"Signing"}),e(z,{variant:p.signing_enabled?"success":"muted",children:p.signing_enabled?"ON":"OFF"})]}),e("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[e("input",{type:"checkbox",checked:p.alerts_enabled,onChange:()=>F(p,"alerts_enabled"),disabled:A.value===`${p.id}-alerts_enabled`}),e("span",{children:"Alerts"}),e(z,{variant:p.alerts_enabled?"success":"muted",children:p.alerts_enabled?"ON":"OFF"})]}),p.alerts_enabled&&e(R,{variant:"secondary",size:"sm",onClick:()=>E(p),disabled:s.value===p.id,children:s.value===p.id?"Sending...":"Test"})]}),e("div",{style:{marginTop:"0.75rem"},children:[e("span",{style:{fontSize:"0.85rem",fontWeight:500},children:"Used by: "}),p.used_by.length===0?e("span",{style:{fontSize:"0.85rem",color:"var(--text-muted)"},children:"No wallets"}):e("span",{style:{fontSize:"0.85rem"},children:p.used_by.map((W,H)=>e("span",{children:[H>0&&", ",e("a",{href:`#/wallets/${W.id}`,style:{color:"var(--primary)"},children:W.label})]},W.id))})]}),e("div",{style:{marginTop:"0.75rem"},children:[e("span",{style:{fontSize:"0.85rem",fontWeight:500},children:"Subscription Token: "}),u.value[p.id]!==void 0?e("span",{style:{display:"inline-flex",gap:"0.5rem",alignItems:"center"},children:[e("input",{type:"text",value:u.value[p.id],onInput:W=>{u.value={...u.value,[p.id]:W.target.value}},placeholder:"e.g., a1b2c3d4",style:{padding:"0.25rem 0.5rem",fontSize:"0.85rem",width:"140px"}}),e(R,{size:"sm",onClick:()=>C(p,u.value[p.id]),disabled:f.value===p.id,children:f.value===p.id?"Saving...":"Set"}),e(R,{variant:"secondary",size:"sm",onClick:()=>{const W={...u.value};delete W[p.id],u.value=W},children:"Cancel"})]}):p.subscription_token?e("span",{style:{fontSize:"0.85rem"},children:[e("code",{children:[p.subscription_token.slice(0,4),"****"]}),e(R,{variant:"secondary",size:"sm",onClick:()=>C(p,""),disabled:f.value===p.id,style:{marginLeft:"0.5rem"},children:"Clear"})]}):e("span",{style:{fontSize:"0.85rem"},children:[e("span",{style:{color:"var(--text-muted)"},children:"Not set"}),e(R,{variant:"secondary",size:"sm",onClick:()=>{u.value={...u.value,[p.id]:""}},style:{marginLeft:"0.5rem"},children:"Set"})]})]}),D.value[p.id]?e("div",{style:{marginTop:"0.75rem",borderTop:"1px solid var(--border)",paddingTop:"0.75rem"},children:[e("span",{style:{fontSize:"0.85rem",fontWeight:500,display:"block",marginBottom:"0.5rem"},children:"ntfy Topics"}),e("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.5rem"},children:[e(I,{label:"Sign Topic",name:`sign-topic-${p.id}`,type:"text",value:D.value[p.id].signTopic,onChange:W=>{D.value={...D.value,[p.id]:{...D.value[p.id],signTopic:String(W)}}},placeholder:`waiaas-sign-${p.name}`,description:"ntfy topic for signing requests"}),e(I,{label:"Notify Topic",name:`notify-topic-${p.id}`,type:"text",value:D.value[p.id].notifyTopic,onChange:W=>{D.value={...D.value,[p.id]:{...D.value[p.id],notifyTopic:String(W)}}},placeholder:`waiaas-notify-${p.name}`,description:"ntfy topic for activity alerts"})]}),e("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end",marginTop:"0.5rem"},children:[e(R,{variant:"secondary",size:"sm",onClick:()=>S(p.id),children:"Cancel"}),e(R,{size:"sm",onClick:()=>P(p),disabled:x.value===p.id,children:x.value===p.id?"Saving...":"Save Topics"})]})]}):e("div",{style:{marginTop:"0.75rem",borderTop:"1px solid var(--border)",paddingTop:"0.75rem"},children:[e("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"0.5rem"},children:[e("span",{style:{fontSize:"0.85rem",fontWeight:500},children:"ntfy Topics"}),e(R,{variant:"secondary",size:"sm",onClick:()=>m(p),children:"Edit"})]}),e("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.5rem",fontSize:"0.85rem"},children:[e("div",{children:[e("span",{style:{color:"var(--text-muted)"},children:"Sign Topic: "}),e("code",{children:p.sign_topic??"(default)"})]}),e("div",{children:[e("span",{style:{color:"var(--text-muted)"},children:"Notify Topic: "}),e("code",{children:p.notify_topic??"(default)"})]})]})]})]},p.id))})})]}),e(we,{open:r.value,title:"Register Wallet App",onCancel:()=>{r.value=!1},children:e("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[e(I,{label:"App Name",name:"register-app-name",type:"text",value:c.value,onChange:p=>{c.value=String(p)},placeholder:"my-custom-wallet",description:"Lowercase alphanumeric with hyphens (e.g., dcent, my-wallet)"}),e(I,{label:"Display Name",name:"register-app-display-name",type:"text",value:h.value,onChange:p=>{h.value=String(p)},placeholder:"My Custom Wallet",description:"Human-readable name shown in the UI"}),e(I,{label:"Wallet Type (optional)",name:"register-app-wallet-type",type:"text",value:o.value,onChange:p=>{o.value=String(p)},placeholder:"dcent, ledger, or custom",description:"Group multiple devices under the same wallet type. Defaults to app name."}),e("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end"},children:[e(R,{variant:"secondary",onClick:()=>{r.value=!1},children:"Cancel"}),e(R,{onClick:K,disabled:v.value||!c.value.trim()||!h.value.trim(),children:v.value?"Registering...":"Register"})]})]})})]})}function Rn(t){const a=t.slice(1)||"/dashboard",n=a.indexOf("?");return n>=0?a.slice(0,n):a}const Oe=pe(Rn(window.location.hash)),Ia=pe(!1);window.addEventListener("hashchange",()=>{Oe.value=Rn(window.location.hash)});const _s={"/dashboard":"Dashboard","/wallets":"Wallets","/transactions":"Transactions","/sessions":"Sessions","/tokens":"Token Registry","/actions":"Actions","/policies":"Policies","/notifications":"Notifications","/security":"Security","/wallet-apps":"Human Wallet Apps","/system":"System"},bs={"/dashboard":"System overview and key metrics","/wallets":"Manage wallets, balances, and connections","/transactions":"View all transactions and configure incoming monitoring","/sessions":"View and manage active sessions","/tokens":"Manage EVM token registry per network","/actions":"Manage DeFi action providers and API keys","/policies":"Configure transaction policies and rules","/notifications":"Channel status, delivery logs, and settings","/security":"Emergency controls and automatic protection rules","/wallet-apps":"Manage wallet apps for signing and notifications","/system":"API keys, display preferences, and daemon configuration"};function ws(t){return t.startsWith("/wallets/")?"Wallet Detail":_s[t]??"Dashboard"}function an(t){return bs[t]}const Ss=[{path:"/dashboard",label:"Dashboard"},{path:"/wallets",label:"Wallets"},{path:"/transactions",label:"Transactions"},{path:"/sessions",label:"Sessions"},{path:"/tokens",label:"Tokens"},{path:"/actions",label:"Actions"},{path:"/policies",label:"Policies"},{path:"/notifications",label:"Notifications"},{path:"/wallet-apps",label:"Human Wallet Apps"},{path:"/security",label:"Security"},{path:"/system",label:"System"}];function Ts(){const t=Oe.value;return t==="/transactions"?e(Vt,{}):t==="/incoming"?(window.location.hash="#/transactions",e(Vt,{})):t==="/tokens"?e(Ti,{}):t==="/actions"?e(gs,{}):t==="/sessions"?e(Ai,{}):t==="/policies"?e(ts,{}):t==="/notifications"?e(Qt,{}):t==="/telegram-users"?(window.location.hash="#/notifications",e(Qt,{})):t==="/settings"?(window.location.hash="#/dashboard",e(Pt,{})):t==="/walletconnect"?(window.location.hash="#/wallets",e(Ft,{})):t==="/security"?e(vs,{}):t==="/wallet-apps"?e(ys,{}):t==="/system"?e(fs,{}):t.startsWith("/wallets")?e(Ft,{}):e(Pt,{})}function ks(){return B(()=>{const t=a=>{(a.metaKey||a.ctrlKey)&&a.key==="k"&&(a.preventDefault(),Ia.value=!Ia.value)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[]),e("div",{class:"layout",children:[e("aside",{class:"sidebar",children:[e("div",{class:"sidebar-brand",children:"WAIaaS"}),e("nav",{class:"sidebar-nav",children:Ss.map(t=>{const a=t.path==="/wallets"?Oe.value.startsWith("/wallets"):Oe.value===t.path;return e("a",{href:`#${t.path}`,class:`sidebar-link ${a?"active":""}`,onClick:n=>{In.value&&(n.preventDefault(),Dn({type:"nav",execute:()=>{window.location.hash=`#${t.path}`}}))},children:t.label})})})]}),e("main",{class:"main",children:[e("header",{class:"header",children:[e("div",{class:"header-left",children:[e("h1",{class:"header-title",children:ws(Oe.value)}),an(Oe.value)&&e("p",{class:"header-subtitle",children:an(Oe.value)})]}),e("div",{class:"header-actions",children:[e("button",{class:"btn-search",onClick:()=>{Ia.value=!0},title:"Search settings (Ctrl+K)",children:"🔍"}),e("button",{class:"btn-logout",onClick:()=>Va(),children:"Logout"})]})]}),e("div",{class:"content",children:e(Ts,{})})]}),e(El,{open:Ia}),e(Dl,{})]})}const Da={overlay:{position:"fixed",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0, 0, 0, 0.7)",color:"white",zIndex:9999},content:{textAlign:"center"},title:{fontSize:"var(--font-size-2xl)",fontWeight:"var(--font-weight-bold)",marginBottom:"var(--space-2)"},message:{fontSize:"var(--font-size-base)",color:"var(--color-text-muted)"}};function Ns(){return e("div",{style:Da.overlay,children:e("div",{style:Da.content,children:[e("h1",{style:Da.title,children:"Daemon Shutting Down"}),e("p",{style:Da.message,children:"The daemon is shutting down. Please wait or restart."})]})})}function As(){return gl.value?e(Ns,{}):fl.value?e(J,{children:[e(ks,{}),e(Hl,{})]}):e(Sl,{})}il(e(As,{}),document.getElementById("app"));