@waiaas/daemon 2.4.0 → 2.5.0-rc
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.
- package/dist/api/routes/admin.d.ts.map +1 -1
- package/dist/api/routes/admin.js +146 -29
- package/dist/api/routes/admin.js.map +1 -1
- package/dist/api/routes/connect-info.d.ts +2 -0
- package/dist/api/routes/connect-info.d.ts.map +1 -1
- package/dist/api/routes/connect-info.js +31 -19
- package/dist/api/routes/connect-info.js.map +1 -1
- package/dist/api/routes/openapi-schemas.d.ts +24 -0
- package/dist/api/routes/openapi-schemas.d.ts.map +1 -1
- package/dist/api/routes/openapi-schemas.js +10 -0
- package/dist/api/routes/openapi-schemas.js.map +1 -1
- package/dist/api/routes/sessions.d.ts.map +1 -1
- package/dist/api/routes/sessions.js +3 -0
- package/dist/api/routes/sessions.js.map +1 -1
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +1 -0
- package/dist/api/server.js.map +1 -1
- package/dist/infrastructure/database/migrate.d.ts +1 -1
- package/dist/infrastructure/database/migrate.d.ts.map +1 -1
- package/dist/infrastructure/database/migrate.js +14 -3
- package/dist/infrastructure/database/migrate.js.map +1 -1
- package/dist/infrastructure/database/schema.d.ts +17 -0
- package/dist/infrastructure/database/schema.d.ts.map +1 -1
- package/dist/infrastructure/database/schema.js +1 -0
- package/dist/infrastructure/database/schema.js.map +1 -1
- package/package.json +4 -4
- package/public/admin/assets/index-Coj1D0TN.js +1 -0
- package/public/admin/index.html +1 -1
- package/public/admin/assets/index-i7xhksGh.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var ut,F,_a,ya,we,Gt,ga,ba,wa,Ut,Dt,Lt,ze={},Sa=[],Xa=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,vt=Array.isArray;function ve(a,t){for(var n in t)a[n]=t[n];return a}function $t(a){a&&a.parentNode&&a.parentNode.removeChild(a)}function Za(a,t,n){var l,i,s,r={};for(s in t)s=="key"?l=t[s]:s=="ref"?i=t[s]:r[s]=t[s];if(arguments.length>2&&(r.children=arguments.length>3?ut.call(arguments,2):n),typeof a=="function"&&a.defaultProps!=null)for(s in a.defaultProps)r[s]===void 0&&(r[s]=a.defaultProps[s]);return it(a,r,l,i,null)}function it(a,t,n,l,i){var s={type:a,props:t,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++_a,__i:-1,__u:0};return i==null&&F.vnode!=null&&F.vnode(s),s}function j(a){return a.children}function Be(a,t){this.props=a,this.context=t}function Oe(a,t){if(t==null)return a.__?Oe(a.__,a.__i+1):null;for(var n;t<a.__k.length;t++)if((n=a.__k[t])!=null&&n.__e!=null)return n.__e;return typeof a.type=="function"?Oe(a):null}function ka(a){var t,n;if((a=a.__)!=null&&a.__c!=null){for(a.__e=a.__c.base=null,t=0;t<a.__k.length;t++)if((n=a.__k[t])!=null&&n.__e!=null){a.__e=a.__c.base=n.__e;break}return ka(a)}}function qt(a){(!a.__d&&(a.__d=!0)&&we.push(a)&&!rt.__r++||Gt!=F.debounceRendering)&&((Gt=F.debounceRendering)||ga)(rt)}function rt(){for(var a,t,n,l,i,s,r,c=1;we.length;)we.length>c&&we.sort(ba),a=we.shift(),c=we.length,a.__d&&(n=void 0,l=void 0,i=(l=(t=a).__v).__e,s=[],r=[],t.__P&&((n=ve({},l)).__v=l.__v+1,F.vnode&&F.vnode(n),Kt(t.__P,n,l,t.__n,t.__P.namespaceURI,32&l.__u?[i]:null,s,i??Oe(l),!!(32&l.__u),r),n.__v=l.__v,n.__.__k[n.__i]=n,Ca(s,n,r),l.__e=l.__=null,n.__e!=i&&ka(n)));rt.__r=0}function Na(a,t,n,l,i,s,r,c,h,o,u){var d,m,p,k,C,w,I,L=l&&l.__k||Sa,H=t.length;for(h=Qa(n,t,L,h,H),d=0;d<H;d++)(p=n.__k[d])!=null&&(m=p.__i==-1?ze:L[p.__i]||ze,p.__i=d,w=Kt(a,p,m,i,s,r,c,h,o,u),k=p.__e,p.ref&&m.ref!=p.ref&&(m.ref&&Bt(m.ref,null,p),u.push(p.ref,p.__c||k,p)),C==null&&k!=null&&(C=k),(I=!!(4&p.__u))||m.__k===p.__k?h=Ta(p,h,a,I):typeof p.type=="function"&&w!==void 0?h=w:k&&(h=k.nextSibling),p.__u&=-7);return n.__e=C,h}function Qa(a,t,n,l,i){var s,r,c,h,o,u=n.length,d=u,m=0;for(a.__k=new Array(i),s=0;s<i;s++)(r=t[s])!=null&&typeof r!="boolean"&&typeof r!="function"?(typeof r=="string"||typeof r=="number"||typeof r=="bigint"||r.constructor==String?r=a.__k[s]=it(null,r,null,null,null):vt(r)?r=a.__k[s]=it(j,{children:r},null,null,null):r.constructor===void 0&&r.__b>0?r=a.__k[s]=it(r.type,r.props,r.key,r.ref?r.ref:null,r.__v):a.__k[s]=r,h=s+m,r.__=a,r.__b=a.__b+1,c=null,(o=r.__i=en(r,n,h,d))!=-1&&(d--,(c=n[o])&&(c.__u|=2)),c==null||c.__v==null?(o==-1&&(i>u?m--:i<u&&m++),typeof r.type!="function"&&(r.__u|=4)):o!=h&&(o==h-1?m--:o==h+1?m++:(o>h?m--:m++,r.__u|=4))):a.__k[s]=null;if(d)for(s=0;s<u;s++)(c=n[s])!=null&&(2&c.__u)==0&&(c.__e==l&&(l=Oe(c)),Aa(c,c));return l}function Ta(a,t,n,l){var i,s;if(typeof a.type=="function"){for(i=a.__k,s=0;i&&s<i.length;s++)i[s]&&(i[s].__=a,t=Ta(i[s],t,n,l));return t}a.__e!=t&&(l&&(t&&a.type&&!t.parentNode&&(t=Oe(a)),n.insertBefore(a.__e,t||null)),t=a.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function en(a,t,n,l){var i,s,r,c=a.key,h=a.type,o=t[n],u=o!=null&&(2&o.__u)==0;if(o===null&&c==null||u&&c==o.key&&h==o.type)return n;if(l>(u?1:0)){for(i=n-1,s=n+1;i>=0||s<t.length;)if((o=t[r=i>=0?i--:s++])!=null&&(2&o.__u)==0&&c==o.key&&h==o.type)return r}return-1}function jt(a,t,n){t[0]=="-"?a.setProperty(t,n??""):a[t]=n==null?"":typeof n!="number"||Xa.test(t)?n:n+"px"}function Ze(a,t,n,l,i){var s,r;e:if(t=="style")if(typeof n=="string")a.style.cssText=n;else{if(typeof l=="string"&&(a.style.cssText=l=""),l)for(t in l)n&&t in n||jt(a.style,t,"");if(n)for(t in n)l&&n[t]==l[t]||jt(a.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")s=t!=(t=t.replace(wa,"$1")),r=t.toLowerCase(),t=r in a||t=="onFocusOut"||t=="onFocusIn"?r.slice(2):t.slice(2),a.l||(a.l={}),a.l[t+s]=n,n?l?n.u=l.u:(n.u=Ut,a.addEventListener(t,s?Lt:Dt,s)):a.removeEventListener(t,s?Lt:Dt,s);else{if(i=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in a)try{a[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!="-"?a.removeAttribute(t):a.setAttribute(t,t=="popover"&&n==1?"":n))}}function Yt(a){return function(t){if(this.l){var n=this.l[t.type+a];if(t.t==null)t.t=Ut++;else if(t.t<n.u)return;return n(F.event?F.event(t):t)}}}function Kt(a,t,n,l,i,s,r,c,h,o){var u,d,m,p,k,C,w,I,L,H,K,S,O,P,q,Y,ee,J=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(h=!!(32&n.__u),s=[c=t.__e=n.__e]),(u=F.__b)&&u(t);e:if(typeof J=="function")try{if(I=t.props,L="prototype"in J&&J.prototype.render,H=(u=J.contextType)&&l[u.__c],K=u?H?H.props.value:u.__:l,n.__c?w=(d=t.__c=n.__c).__=d.__E:(L?t.__c=d=new J(I,K):(t.__c=d=new Be(I,K),d.constructor=J,d.render=an),H&&H.sub(d),d.state||(d.state={}),d.__n=l,m=d.__d=!0,d.__h=[],d._sb=[]),L&&d.__s==null&&(d.__s=d.state),L&&J.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=ve({},d.__s)),ve(d.__s,J.getDerivedStateFromProps(I,d.__s))),p=d.props,k=d.state,d.__v=t,m)L&&J.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),L&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(L&&J.getDerivedStateFromProps==null&&I!==p&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(I,K),t.__v==n.__v||!d.__e&&d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(I,d.__s,K)===!1){for(t.__v!=n.__v&&(d.props=I,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(T){T&&(T.__=t)}),S=0;S<d._sb.length;S++)d.__h.push(d._sb[S]);d._sb=[],d.__h.length&&r.push(d);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(I,d.__s,K),L&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(p,k,C)})}if(d.context=K,d.props=I,d.__P=a,d.__e=!1,O=F.__r,P=0,L){for(d.state=d.__s,d.__d=!1,O&&O(t),u=d.render(d.props,d.state,d.context),q=0;q<d._sb.length;q++)d.__h.push(d._sb[q]);d._sb=[]}else do d.__d=!1,O&&O(t),u=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++P<25);d.state=d.__s,d.getChildContext!=null&&(l=ve(ve({},l),d.getChildContext())),L&&!m&&d.getSnapshotBeforeUpdate!=null&&(C=d.getSnapshotBeforeUpdate(p,k)),Y=u,u!=null&&u.type===j&&u.key==null&&(Y=Ea(u.props.children)),c=Na(a,vt(Y)?Y:[Y],t,n,l,i,s,r,c,h,o),d.base=t.__e,t.__u&=-161,d.__h.length&&r.push(d),w&&(d.__E=d.__=null)}catch(T){if(t.__v=null,h||s!=null)if(T.then){for(t.__u|=h?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;s[s.indexOf(c)]=null,t.__e=c}else{for(ee=s.length;ee--;)$t(s[ee]);Ot(t)}else t.__e=n.__e,t.__k=n.__k,T.then||Ot(t);F.__e(T,t,n)}else s==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):c=t.__e=tn(n.__e,t,n,l,i,s,r,h,o);return(u=F.diffed)&&u(t),128&t.__u?void 0:c}function Ot(a){a&&a.__c&&(a.__c.__e=!0),a&&a.__k&&a.__k.forEach(Ot)}function Ca(a,t,n){for(var l=0;l<n.length;l++)Bt(n[l],n[++l],n[++l]);F.__c&&F.__c(t,a),a.some(function(i){try{a=i.__h,i.__h=[],a.some(function(s){s.call(i)})}catch(s){F.__e(s,i.__v)}})}function Ea(a){return typeof a!="object"||a==null||a.__b&&a.__b>0?a:vt(a)?a.map(Ea):ve({},a)}function tn(a,t,n,l,i,s,r,c,h){var o,u,d,m,p,k,C,w=n.props||ze,I=t.props,L=t.type;if(L=="svg"?i="http://www.w3.org/2000/svg":L=="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((p=s[o])&&"setAttribute"in p==!!L&&(L?p.localName==L:p.nodeType==3)){a=p,s[o]=null;break}}if(a==null){if(L==null)return document.createTextNode(I);a=document.createElementNS(i,L,I.is&&I),c&&(F.__m&&F.__m(t,s),c=!1),s=null}if(L==null)w===I||c&&a.data==I||(a.data=I);else{if(s=s&&ut.call(a.childNodes),!c&&s!=null)for(w={},o=0;o<a.attributes.length;o++)w[(p=a.attributes[o]).name]=p.value;for(o in w)if(p=w[o],o!="children"){if(o=="dangerouslySetInnerHTML")d=p;else if(!(o in I)){if(o=="value"&&"defaultValue"in I||o=="checked"&&"defaultChecked"in I)continue;Ze(a,o,null,p,i)}}for(o in I)p=I[o],o=="children"?m=p:o=="dangerouslySetInnerHTML"?u=p:o=="value"?k=p:o=="checked"?C=p:c&&typeof p!="function"||w[o]===p||Ze(a,o,p,w[o],i);if(u)c||d&&(u.__html==d.__html||u.__html==a.innerHTML)||(a.innerHTML=u.__html),t.__k=[];else if(d&&(a.innerHTML=""),Na(t.type=="template"?a.content:a,vt(m)?m:[m],t,n,l,L=="foreignObject"?"http://www.w3.org/1999/xhtml":i,s,r,s?s[0]:n.__k&&Oe(n,0),c,h),s!=null)for(o=s.length;o--;)$t(s[o]);c||(o="value",L=="progress"&&k==null?a.removeAttribute("value"):k!=null&&(k!==a[o]||L=="progress"&&!k||L=="option"&&k!=w[o])&&Ze(a,o,k,w[o],i),o="checked",C!=null&&C!=a[o]&&Ze(a,o,C,w[o],i))}return a}function Bt(a,t,n){try{if(typeof a=="function"){var l=typeof a.__u=="function";l&&a.__u(),l&&t==null||(a.__u=a(t))}else a.current=t}catch(i){F.__e(i,n)}}function Aa(a,t,n){var l,i;if(F.unmount&&F.unmount(a),(l=a.ref)&&(l.current&&l.current!=a.__e||Bt(l,null,t)),(l=a.__c)!=null){if(l.componentWillUnmount)try{l.componentWillUnmount()}catch(s){F.__e(s,t)}l.base=l.__P=null}if(l=a.__k)for(i=0;i<l.length;i++)l[i]&&Aa(l[i],t,n||typeof a.type!="function");n||$t(a.__e),a.__c=a.__=a.__e=void 0}function an(a,t,n){return this.constructor(a,n)}function nn(a,t,n){var l,i,s,r;t==document&&(t=document.documentElement),F.__&&F.__(a,t),i=(l=!1)?null:t.__k,s=[],r=[],Kt(t,a=t.__k=Za(j,null,[a]),i||ze,ze,t.namespaceURI,i?null:t.firstChild?ut.call(t.childNodes):null,s,i?i.__e:t.firstChild,l,r),Ca(s,a,r)}ut=Sa.slice,F={__e:function(a,t,n,l){for(var i,s,r;t=t.__;)if((i=t.__c)&&!i.__)try{if((s=i.constructor)&&s.getDerivedStateFromError!=null&&(i.setState(s.getDerivedStateFromError(a)),r=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(a,l||{}),r=i.__d),r)return i.__E=i}catch(c){a=c}throw a}},_a=0,ya=function(a){return a!=null&&a.constructor===void 0},Be.prototype.setState=function(a,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=ve({},this.state),typeof a=="function"&&(a=a(ve({},n),this.props)),a&&ve(n,a),a!=null&&this.__v&&(t&&this._sb.push(t),qt(this))},Be.prototype.forceUpdate=function(a){this.__v&&(this.__e=!0,a&&this.__h.push(a),qt(this))},Be.prototype.render=j,we=[],ga=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ba=function(a,t){return a.__v.__b-t.__v.__b},rt.__r=0,wa=/(PointerCapture)$|Capture$/i,Ut=0,Dt=Yt(!1),Lt=Yt(!0);var ln=0;function e(a,t,n,l,i,s){t||(t={});var r,c,h=t;if("ref"in h)for(c in h={},t)c=="ref"?r=t[c]:h[c]=t[c];var o={type:a,props:h,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ln,__i:-1,__u:0,__source:i,__self:s};if(typeof a=="function"&&(r=a.defaultProps))for(c in r)h[c]===void 0&&(h[c]=r[c]);return F.vnode&&F.vnode(o),o}var ot,se,kt,Jt,xt=0,Ia=[],X=F,Xt=X.__b,Zt=X.__r,Qt=X.diffed,ea=X.__c,ta=X.unmount,aa=X.__;function Da(a,t){X.__h&&X.__h(se,a,xt||t),xt=0;var n=se.__H||(se.__H={__:[],__h:[]});return a>=n.__.length&&n.__.push({}),n.__[a]}function R(a,t){var n=Da(ot++,3);!X.__s&&La(n.__H,t)&&(n.__=a,n.u=t,se.__H.__h.push(n))}function Ft(a){return xt=5,ht(function(){return{current:a}},[])}function ht(a,t){var n=Da(ot++,7);return La(n.__H,t)&&(n.__=a(),n.__H=t,n.__h=a),n.__}function sn(){for(var a;a=Ia.shift();)if(a.__P&&a.__H)try{a.__H.__h.forEach(st),a.__H.__h.forEach(Rt),a.__H.__h=[]}catch(t){a.__H.__h=[],X.__e(t,a.__v)}}X.__b=function(a){se=null,Xt&&Xt(a)},X.__=function(a,t){a&&t.__k&&t.__k.__m&&(a.__m=t.__k.__m),aa&&aa(a,t)},X.__r=function(a){Zt&&Zt(a),ot=0;var t=(se=a.__c).__H;t&&(kt===se?(t.__h=[],se.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.forEach(st),t.__h.forEach(Rt),t.__h=[],ot=0)),kt=se},X.diffed=function(a){Qt&&Qt(a);var t=a.__c;t&&t.__H&&(t.__H.__h.length&&(Ia.push(t)!==1&&Jt===X.requestAnimationFrame||((Jt=X.requestAnimationFrame)||rn)(sn)),t.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),kt=se=null},X.__c=function(a,t){t.some(function(n){try{n.__h.forEach(st),n.__h=n.__h.filter(function(l){return!l.__||Rt(l)})}catch(l){t.some(function(i){i.__h&&(i.__h=[])}),t=[],X.__e(l,n.__v)}}),ea&&ea(a,t)},X.unmount=function(a){ta&&ta(a);var t,n=a.__c;n&&n.__H&&(n.__H.__.forEach(function(l){try{st(l)}catch(i){t=i}}),n.__H=void 0,t&&X.__e(t,n.__v))};var na=typeof requestAnimationFrame=="function";function rn(a){var t,n=function(){clearTimeout(l),na&&cancelAnimationFrame(t),setTimeout(a)},l=setTimeout(n,35);na&&(t=requestAnimationFrame(n))}function st(a){var t=se,n=a.__c;typeof n=="function"&&(a.__c=void 0,n()),se=t}function Rt(a){var t=se;a.__c=a.__(),se=t}function La(a,t){return!a||a.length!==t.length||t.some(function(n,l){return n!==a[l]})}var on=Symbol.for("preact-signals");function pt(){if(fe>1)fe--;else{for(var a,t=!1;Fe!==void 0;){var n=Fe;for(Fe=void 0,Pt++;n!==void 0;){var l=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Ra(n))try{n.c()}catch(i){t||(a=i,t=!0)}n=l}}if(Pt=0,fe--,t)throw a}}function cn(a){if(fe>0)return a();fe++;try{return a()}finally{pt()}}var B=void 0;function Oa(a){var t=B;B=void 0;try{return a()}finally{B=t}}var Fe=void 0,fe=0,Pt=0,ct=0;function xa(a){if(B!==void 0){var t=a.n;if(t===void 0||t.t!==B)return t={i:0,S:a,p:B.s,n:void 0,t:B,e:void 0,x:void 0,r:t},B.s!==void 0&&(B.s.n=t),B.s=t,a.n=t,32&B.f&&a.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=B.s,t.n=void 0,B.s.n=t,B.s=t),t}}function ne(a,t){this.v=a,this.i=0,this.n=void 0,this.t=void 0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}ne.prototype.brand=on;ne.prototype.h=function(){return!0};ne.prototype.S=function(a){var t=this,n=this.t;n!==a&&a.e===void 0&&(a.x=n,this.t=a,n!==void 0?n.e=a:Oa(function(){var l;(l=t.W)==null||l.call(t)}))};ne.prototype.U=function(a){var t=this;if(this.t!==void 0){var n=a.e,l=a.x;n!==void 0&&(n.x=l,a.e=void 0),l!==void 0&&(l.e=n,a.x=void 0),a===this.t&&(this.t=l,l===void 0&&Oa(function(){var i;(i=t.Z)==null||i.call(t)}))}};ne.prototype.subscribe=function(a){var t=this;return je(function(){var n=t.value,l=B;B=void 0;try{a(n)}finally{B=l}},{name:"sub"})};ne.prototype.valueOf=function(){return this.value};ne.prototype.toString=function(){return this.value+""};ne.prototype.toJSON=function(){return this.value};ne.prototype.peek=function(){var a=B;B=void 0;try{return this.value}finally{B=a}};Object.defineProperty(ne.prototype,"value",{get:function(){var a=xa(this);return a!==void 0&&(a.i=this.i),this.v},set:function(a){if(a!==this.v){if(Pt>100)throw new Error("Cycle detected");this.v=a,this.i++,ct++,fe++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{pt()}}}});function le(a,t){return new ne(a,t)}function Ra(a){for(var t=a.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Pa(a){for(var t=a.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){a.s=t;break}}}function Wa(a){for(var t=a.s,n=void 0;t!==void 0;){var l=t.p;t.i===-1?(t.S.U(t),l!==void 0&&(l.n=t.n),t.n!==void 0&&(t.n.p=l)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=l}a.s=n}function ke(a,t){ne.call(this,void 0),this.x=a,this.s=void 0,this.g=ct-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}ke.prototype=new ne;ke.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===ct))return!0;if(this.g=ct,this.f|=1,this.i>0&&!Ra(this))return this.f&=-2,!0;var a=B;try{Pa(this),B=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return B=a,Wa(this),this.f&=-2,!0};ke.prototype.S=function(a){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}ne.prototype.S.call(this,a)};ke.prototype.U=function(a){if(this.t!==void 0&&(ne.prototype.U.call(this,a),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};ke.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var a=this.t;a!==void 0;a=a.x)a.t.N()}};Object.defineProperty(ke.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var a=xa(this);if(this.h(),a!==void 0&&(a.i=this.i),16&this.f)throw this.v;return this.v}});function Ge(a,t){return new ke(a,t)}function Ma(a){var t=a.u;if(a.u=void 0,typeof t=="function"){fe++;var n=B;B=void 0;try{t()}catch(l){throw a.f&=-2,a.f|=8,Ht(a),l}finally{B=n,pt()}}}function Ht(a){for(var t=a.s;t!==void 0;t=t.n)t.S.U(t);a.x=void 0,a.s=void 0,Ma(a)}function dn(a){if(B!==this)throw new Error("Out-of-order effect");Wa(this),B=a,this.f&=-2,8&this.f&&Ht(this),pt()}function We(a,t){this.x=a,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=t?.name}We.prototype.c=function(){var a=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.u=t)}finally{a()}};We.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Ma(this),Pa(this),fe++;var a=B;return B=this,dn.bind(this,a)};We.prototype.N=function(){2&this.f||(this.f|=2,this.o=Fe,Fe=this)};We.prototype.d=function(){this.f|=8,1&this.f||Ht(this)};We.prototype.dispose=function(){this.d()};function je(a,t){var n=new We(a,t);try{n.c()}catch(i){throw n.d(),i}var l=n.d.bind(n);return l[Symbol.dispose]=l,l}var Ua,mt,Qe,un=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__,$a=[];je(function(){Ua=this.N})();function Me(a,t){F[a]=t.bind(null,F[a]||function(){})}function dt(a){if(Qe){var t=Qe;Qe=void 0,t()}Qe=a&&a.S()}function Ka(a){var t=this,n=a.data,l=v(n);l.value=n;var i=ht(function(){for(var c=t,h=t.__v;h=h.__;)if(h.__c){h.__c.__$f|=4;break}var o=Ge(function(){var p=l.value.value;return p===0?0:p===!0?"":p||""}),u=Ge(function(){return!Array.isArray(o.value)&&!ya(o.value)}),d=je(function(){if(this.N=Ba,u.value){var p=o.value;c.__v&&c.__v.__e&&c.__v.__e.nodeType===3&&(c.__v.__e.data=p)}}),m=t.__$u.d;return t.__$u.d=function(){d(),m.call(this)},[u,o]},[]),s=i[0],r=i[1];return s.value?r.peek():r.value}Ka.displayName="ReactiveTextNode";Object.defineProperties(ne.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Ka},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});Me("__b",function(a,t){if(typeof t.type=="string"){var n,l=t.props;for(var i in l)if(i!=="children"){var s=l[i];s instanceof ne&&(n||(t.__np=n={}),n[i]=s,l[i]=s.peek())}}a(t)});Me("__r",function(a,t){if(a(t),t.type!==j){dt();var n,l=t.__c;l&&(l.__$f&=-2,(n=l.__$u)===void 0&&(l.__$u=n=(function(i,s){var r;return je(function(){r=this},{name:s}),r.c=i,r})(function(){var i;un&&((i=n.y)==null||i.call(n)),l.__$f|=1,l.setState({})},typeof t.type=="function"?t.type.displayName||t.type.name:""))),mt=l,dt(n)}});Me("__e",function(a,t,n,l){dt(),mt=void 0,a(t,n,l)});Me("diffed",function(a,t){dt(),mt=void 0;var n;if(typeof t.type=="string"&&(n=t.__e)){var l=t.__np,i=t.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],u=l[h];o===void 0?(o=vn(n,h,u,i),s[h]=o):o.o(u,i)}}}a(t)});function vn(a,t,n,l){var i=t in a&&a.ownerSVGElement===void 0,s=le(n);return{o:function(r,c){s.value=r,l=c},d:je(function(){this.N=Ba;var r=s.value.value;l[t]!==r&&(l[t]=r,i?a[t]=r:r!=null&&(r!==!1||t[4]==="-")?a.setAttribute(t,r):a.removeAttribute(t))})}}Me("unmount",function(a,t){if(typeof t.type=="string"){var n=t.__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=t.__c;if(r){var c=r.__$u;c&&(r.__$u=void 0,c.d())}}a(t)});Me("__h",function(a,t,n,l){(l<3||l===9)&&(t.__$f|=2),a(t,n,l)});Be.prototype.shouldComponentUpdate=function(a,t){if(this.__R)return!0;var n=this.__$u,l=n&&n.s!==void 0;for(var i in t)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 a)if(r!=="__source"&&a[r]!==this.props[r])return!0;for(var c in this.props)if(!(c in a))return!0;return!1};function v(a,t){return ht(function(){return le(a,t)},[])}function hn(a,t){var n=Ft(a);return n.current=a,mt.__$f|=4,ht(function(){return Ge(function(){return n.current()},t)},[])}var pn=function(a){queueMicrotask(function(){queueMicrotask(a)})};function mn(){cn(function(){for(var a;a=$a.shift();)Ua.call(a)})}function Ba(){$a.push(this)===1&&(F.requestAnimationFrame||pn)(mn)}const qe=le(null),fn=Ge(()=>qe.value!==null),Fa=le(900),_n=le(!1);let Ie=null;const De=()=>{Vt()};function yn(){document.addEventListener("mousemove",De,{passive:!0}),document.addEventListener("keydown",De,{passive:!0}),document.addEventListener("click",De,{passive:!0}),Vt()}function gn(){document.removeEventListener("mousemove",De),document.removeEventListener("keydown",De),document.removeEventListener("click",De),Ie!==null&&(clearTimeout(Ie),Ie=null)}function Vt(){Ie!==null&&clearTimeout(Ie),Ie=setTimeout(()=>{zt()},Fa.value*1e3)}function bn(a,t){qe.value=a,t!==void 0&&(Fa.value=t),yn(),location.hash="#/dashboard"}function zt(){qe.value=null,gn(),location.hash="#/login"}const E={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:a=>`/v1/wallets/${a}`,SESSIONS:"/v1/sessions",SESSION:a=>`/v1/sessions/${a}`,POLICIES:"/v1/policies",POLICY:a=>`/v1/policies/${a}`,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",WALLET_NETWORKS:a=>`/v1/wallets/${a}/networks`,WALLET_DEFAULT_NETWORK:a=>`/v1/wallets/${a}/default-network`,ADMIN_WALLET_BALANCE:a=>`/v1/admin/wallets/${a}/balance`,ADMIN_WALLET_TRANSACTIONS:a=>`/v1/admin/wallets/${a}/transactions`,ADMIN_API_KEYS:"/v1/admin/api-keys",ADMIN_API_KEY:a=>`/v1/admin/api-keys/${a}`,ADMIN_FOREX_RATES:"/v1/admin/forex/rates",ADMIN_TELEGRAM_USERS:"/v1/admin/telegram-users",ADMIN_TELEGRAM_USER:a=>`/v1/admin/telegram-users/${a}`,WALLET_OWNER:a=>`/v1/wallets/${a}/owner`,WALLET_WITHDRAW:a=>`/v1/wallets/${a}/withdraw`,WALLET_WC_PAIR:a=>`/v1/wallets/${a}/wc/pair`,WALLET_WC_SESSION:a=>`/v1/wallets/${a}/wc/session`,WALLET_WC_PAIR_STATUS:a=>`/v1/wallets/${a}/wc/pair/status`,WALLET_OWNER_VERIFY:a=>`/v1/wallets/${a}/owner/verify`,ADMIN_BULK_SESSIONS:"/v1/admin/sessions/bulk",ADMIN_BULK_MCP_TOKENS:"/v1/admin/mcp/tokens/bulk",ADMIN_AGENT_PROMPT:"/v1/admin/agent-prompt"},He=le(""),Ae=le(null),Ve=le(!1),he={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)"}},wn=async a=>{if(a.preventDefault(),!!He.value.trim()){Ve.value=!0,Ae.value=null;try{const t=await fetch(E.ADMIN_STATUS,{headers:{"X-Master-Password":He.value},signal:AbortSignal.timeout(1e4)});if(t.status===401){Ae.value="Invalid master password";return}if(!t.ok){Ae.value="Cannot connect to daemon";return}const n=await t.json();bn(He.value,n.adminTimeout)}catch{Ae.value="Cannot connect to daemon"}finally{Ve.value=!1}}};function Sn(){return e("div",{style:he.wrapper,children:e("form",{style:he.card,onSubmit:wn,children:[e("h1",{style:he.title,children:"WAIaaS Admin"}),e("p",{style:he.subtitle,children:"Enter master password to continue"}),e("input",{type:"password",placeholder:"Master password",autoFocus:!0,value:He.value,onInput:a=>{He.value=a.target.value},style:he.input}),e("button",{type:"submit",disabled:Ve.value,style:{...he.button,...Ve.value?he.buttonDisabled:{}},children:Ve.value?"Signing in...":"Sign in"}),Ae.value&&e("p",{style:he.error,children:Ae.value})]})})}const kn=[{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:"wallets.rpc.evm_default_network",label:"Default EVM Network",description:"Default EVM network for new wallets",page:"/wallets",tab:"rpc",fieldName:"rpc.evm_default_network",keywords:["blockchain","evm","default","network"]},{id:"wallets.monitoring.enabled",label:"Enabled",description:"Enable or disable balance monitoring",page:"/wallets",tab:"monitoring",fieldName:"monitoring.enabled",keywords:["balance","monitoring","toggle","enable"]},{id:"wallets.monitoring.check_interval_sec",label:"Check Interval (seconds)",description:"How often to check wallet balances",page:"/wallets",tab:"monitoring",fieldName:"monitoring.check_interval_sec",keywords:["balance","monitoring","interval","frequency"]},{id:"wallets.monitoring.low_balance_threshold_sol",label:"Low Balance Threshold (SOL)",description:"Alert when SOL balance drops below this amount",page:"/wallets",tab:"monitoring",fieldName:"monitoring.low_balance_threshold_sol",keywords:["balance","monitoring","threshold","solana","alert","low"]},{id:"wallets.monitoring.low_balance_threshold_eth",label:"Low Balance Threshold (ETH)",description:"Alert when ETH balance drops below this amount",page:"/wallets",tab:"monitoring",fieldName:"monitoring.low_balance_threshold_eth",keywords:["balance","monitoring","threshold","ethereum","alert","low"]},{id:"wallets.monitoring.cooldown_hours",label:"Alert Cooldown (hours)",description:"Suppress duplicate alerts for this many hours",page:"/wallets",tab:"monitoring",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.session_ttl",label:"Session TTL (seconds)",description:"How long a session token is valid before renewal",page:"/sessions",tab:"settings",fieldName:"security.session_ttl",keywords:["session","ttl","lifetime","expiry","timeout"]},{id:"sessions.settings.session_absolute_lifetime",label:"Absolute Lifetime (seconds)",description:"Maximum total session duration regardless of renewals",page:"/sessions",tab:"settings",fieldName:"security.session_absolute_lifetime",keywords:["session","lifetime","absolute","maximum"]},{id:"sessions.settings.session_max_renewals",label:"Max Renewals",description:"Maximum number of times a session can be renewed",page:"/sessions",tab:"settings",fieldName:"security.session_max_renewals",keywords:["session","renewal","limit","maximum"]},{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.telegram_bot_enabled",label:"Bot Enabled",description:"Enable or disable the Telegram bot",page:"/notifications",tab:"settings",fieldName:"telegram.enabled",keywords:["telegram","bot","enable","toggle"]},{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:"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"]}],de=le(""),Z=le(null),Nn={"/wallets":"Wallets","/sessions":"Sessions","/policies":"Policies","/notifications":"Notifications","/security":"Security","/system":"System"};function Tn(a){if(!a.trim())return[];const t=a.toLowerCase();return kn.filter(n=>[n.label,n.description,n.keywords.join(" ")].join(" ").toLowerCase().includes(t)).slice(0,10)}function Cn(a){const t=Nn[a.page]??a.page;return a.tab?`${t} > ${a.tab}`:t}function En({open:a}){const t=v(""),n=v(0),l=Ft(null),i=a.value?Tn(t.value):[];if(R(()=>{a.value&&(t.value="",n.value=0,requestAnimationFrame(()=>{l.current?.focus()}))},[a.value]),!a.value)return null;const s=()=>{a.value=!1,t.value="",n.value=0},r=o=>{o.target.classList.contains("search-overlay")&&s()},c=o=>{window.location.hash="#"+o.page,o.tab?Z.value={tab:o.tab,fieldName:o.fieldName}:setTimeout(()=>{de.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:t.value,onInput:o=>{t.value=o.target.value,n.value=0}})}),e("div",{class:"search-results",children:[t.value.trim()&&i.length===0&&e("div",{class:"search-empty",children:"No settings found"}),i.map((o,u)=>e("button",{class:`search-result-item${u===n.value?" selected":""}`,onClick:()=>c(o),onMouseEnter:()=>{n.value=u},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:Cn(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 Se=le([]),Ha=Ge(()=>Se.value.some(a=>a.isDirty()));function ye(a){Se.value=[...Se.value.filter(t=>t.id!==a.id),a]}function ge(a){Se.value=Se.value.filter(t=>t.id!==a)}async function An(){const a=Se.value.filter(t=>t.isDirty());try{for(const t of a)await t.save();return!0}catch{return!1}}function In(){const a=Se.value.filter(t=>t.isDirty());for(const t of a)t.discard()}function N({label:a,name:t,type:n="text",value:l,onChange:i,options:s,error:r,required:c,disabled:h,placeholder:o,min:u,max:d,description:m}){const p=de.value===t;if(R(()=>{if(p){const C=document.querySelector(`[name="${t}"]`);C&&C.closest(".form-field")?.scrollIntoView({behavior:"smooth",block:"center"});const w=setTimeout(()=>{de.value=""},2500);return()=>clearTimeout(w)}},[p,t]),n==="checkbox")return e("div",{class:`form-field${p?" form-field--highlight":""}`,children:[e("label",{children:[e("input",{type:"checkbox",name:t,checked:!!l,onChange:C=>i(C.target.checked),disabled:h}),a,c&&e("span",{children:" *"})]}),m&&e("span",{class:"form-description",children:m}),r&&e("span",{class:"form-error",children:r})]});const k=`field-${t}`;return e("div",{class:`form-field${p?" form-field--highlight":""}`,children:[e("label",{for:k,children:[a,c&&e("span",{children:" *"})]}),n==="select"?e("select",{id:k,name:t,value:l,onChange:C=>i(C.target.value),disabled:h,children:s?.map(C=>e("option",{value:C.value,children:C.label},C.value))}):n==="textarea"?e("textarea",{id:k,name:t,value:l,onInput:C=>i(C.target.value),disabled:h,placeholder:o}):e("input",{id:k,type:n,name:t,value:l,onInput:C=>{const w=C.target;i(n==="number"?Number(w.value):w.value)},disabled:h,placeholder:o,min:u,max:d,required:c}),m&&e("span",{class:"form-description",children:m}),r&&e("span",{class:"form-error",children:r})]})}function A({variant:a="primary",size:t="md",loading:n=!1,disabled:l=!1,onClick:i,children:s,type:r="button"}){const c=["btn",`btn-${a}`,t==="sm"?"btn-sm":""].filter(Boolean).join(" ");return e("button",{type:r,class:c,disabled:l||n,onClick:i,children:n?"...":s})}function W({variant:a,children:t}){return e("span",{class:`badge badge-${a}`,children:t})}const Ke=le(null),Ue=le(!1);function Va(a){Ke.value=a}function Dn(){const a=Ke.value;if(!a)return null;const t=async()=>{Ue.value=!0;const i=await An();Ue.value=!1,i&&(Ke.value=null,a.execute())},n=()=>{In(),Ke.value=null,a.execute()},l=()=>{Ke.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(A,{variant:"secondary",onClick:l,disabled:Ue.value,children:"Cancel"}),e(A,{variant:"ghost",onClick:n,disabled:Ue.value,children:"Discard & Navigate"}),e(A,{variant:"primary",onClick:t,loading:Ue.value,children:"Save & Navigate"})]})]})})}class _ extends Error{constructor(t,n,l){super(`[${t}] ${n}: ${l}`),this.status=t,this.code=n,this.serverMessage=l,this.name="ApiError"}}async function ft(a,t){const n={"Content-Type":"application/json",...t?.headers};qe.value!==null&&(n["X-Master-Password"]=qe.value);let l;try{l=await fetch(a,{...t,headers:n,signal:AbortSignal.timeout(1e4)})}catch(i){const s=i;throw s.name==="AbortError"||s.name==="TimeoutError"?new _(0,"TIMEOUT","Request timed out"):new _(0,"NETWORK_ERROR","Cannot connect to daemon")}if(l.status===401)throw zt(),new _(401,"INVALID_MASTER_PASSWORD","Authentication failed");if(!l.ok){let i={};try{i=await l.json()}catch{}throw new _(l.status,i.code??"UNKNOWN",i.message??"Unknown error")}return Vt(),await l.json()}const z=a=>ft(a,{method:"GET"}),ae=(a,t)=>ft(a,{method:"POST",body:t?JSON.stringify(t):void 0}),ie=(a,t)=>ft(a,{method:"PUT",body:t?JSON.stringify(t):void 0}),xe=a=>ft(a,{method:"DELETE"});function Ln(a){const t=Math.floor(a/86400),n=Math.floor(a%86400/3600),l=Math.floor(a%3600/60);return t>0?`${t}d ${n}h ${l}m`:n>0?`${n}h ${l}m`:`${l}m`}function re(a){const t=new Date(a*1e3),n=l=>l.toString().padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function Wt(a){return a.length<=10?a:`${a.slice(0,4)}..${a.slice(-4)}`}const On=new Set(["KRW","JPY","VND","CLP","HUF","PKR"]),xn=new Set(["KWD","BHD"]);function Rn(a){return On.has(a)?0:xn.has(a)?3:2}function Pn(a,t,n){const l=a*n,i=Rn(t),s=new Intl.NumberFormat("en-US",{style:"currency",currency:t,minimumFractionDigits:i,maximumFractionDigits:i}).format(l);return t==="USD"?s:`≈${s}`}let Ee=null;const Wn=300*1e3;async function Mn(){if(Ee&&Date.now()-Ee.fetchedAt<Wn)return{currency:Ee.currency,rate:Ee.rate};try{const t=(await z(E.ADMIN_SETTINGS)).display?.["display.currency"]??"USD";if(t==="USD")return Ee={currency:"USD",rate:1,fetchedAt:Date.now()},{currency:"USD",rate:1};const i=(await z(`${E.ADMIN_FOREX_RATES}?currencies=${t}`)).rates[t]?.rate??null;return Ee={currency:t,rate:i,fetchedAt:Date.now()},{currency:t,rate:i}}catch{return{currency:"USD",rate:1}}}function Un(a,t,n){return a==null?"":n==null?`$${a.toFixed(2)}`:Pn(a,t,n)}function Ne({columns:a,data:t,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:a.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:a.length,class:"table-loading",children:"Loading..."})}):!t||t.length===0?e("tr",{children:e("td",{colSpan:a.length,class:"table-empty",children:l})}):t.map((s,r)=>e("tr",{class:n?"clickable":"",onClick:n?()=>n(s):void 0,children:a.map(c=>e("td",{children:c.render?c.render(s):s[c.key]},c.key))},r))})]})})}const $n={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."},Kn=new Set(["ACTION_VALIDATION_FAILED","CONSTRAINT_VIOLATED","INVALID_ADDRESS","INVALID_SIGNATURE"]);function D(a,t){return t&&Kn.has(a)?t:$n[a]??`An error occurred (${a}).`}const me=le([]);let Bn=0;function g(a,t){const n=Bn++;me.value=[...me.value,{id:n,type:a,message:t}],setTimeout(()=>{me.value=me.value.filter(l=>l.id!==n)},5e3)}function Fn(a){me.value=me.value.filter(t=>t.id!==a)}function Hn(){return me.value.length===0?null:e("div",{class:"toast-container",children:me.value.map(a=>e("div",{class:`toast toast-${a.type}`,onClick:()=>Fn(a.id),children:a.message},a.id))})}function ue({label:a,value:t,loading:n,badge:l,href:i}){const s=e(j,{children:[e("div",{class:"stat-label",children:[a,i&&e("span",{class:"stat-link-arrow",children:" →"})]}),n?e("div",{class:"stat-skeleton"}):l?e(W,{variant:l,children:t}):e("div",{class:"stat-value",children:t})]});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 Vn(a,t){return[{key:"createdAt",header:"Time",render:n=>n.createdAt?re(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=Un(n.amountUsd,a,t);return l?`${n.amount} (${l})`:n.amount}},{key:"status",header:"Status",render:n=>{const l=n.status==="CONFIRMED"?"success":n.status==="FAILED"?"danger":"warning";return e(W,{variant:l,children:n.status})}}]}async function zn(a){try{await navigator.clipboard.writeText(a)}catch{const t=document.createElement("textarea");t.value=a,t.style.position="fixed",t.style.left="-9999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}}function la(){const a=v(null),t=v(!0),n=v(null),l=v("USD"),i=v(1),s=v(!1),r=v(null),c=async()=>{t.value=!0,n.value=null;try{const d=await z(E.ADMIN_STATUS);a.value=d}catch(d){d instanceof _?n.value=D(d.code):n.value="An unexpected error occurred."}finally{t.value=!1}},h=async()=>{s.value=!0;try{const d=await ae(E.ADMIN_AGENT_PROMPT,{});if(d.walletCount===0){g("warning","No active wallets found");return}r.value=d.prompt,g("success",`Prompt generated for ${d.walletCount} wallet(s)`)}catch(d){d instanceof _?g("error",D(d.code)):g("error","Failed to generate agent prompt")}finally{s.value=!1}},o=async()=>{r.value&&(await zn(r.value),g("success","Copied to clipboard!"))};R(()=>{c(),Mn().then(({currency:m,rate:p})=>{l.value=m,i.value=p}).catch(()=>{});const d=setInterval(c,3e4);return()=>clearInterval(d)},[]);const u=t.value&&!a.value;return e("div",{class:"page",children:[n.value&&e("div",{class:"dashboard-error",children:[e("span",{children:n.value}),e(A,{variant:"secondary",size:"sm",onClick:c,children:"Retry"})]}),a.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:"})," ",a.value.version," ","→"," ",a.value.latestVersion," — ","Run ",e("code",{children:"waiaas update"})," to update."]})]}),e("div",{class:"stat-grid",children:[e(ue,{label:"Version",value:a.value?.version??"—",loading:u,badge:a.value&&a.value.updateAvailable?"warning":void 0}),e(ue,{label:"Uptime",value:a.value?Ln(a.value.uptime):"—",loading:u}),e(ue,{label:"Wallets",value:a.value?.walletCount?.toString()??"—",loading:u,href:"#/wallets"}),e(ue,{label:"Active Sessions",value:a.value?.activeSessionCount?.toString()??"—",loading:u,href:"#/sessions"})]}),e("div",{class:"stat-grid",style:{marginTop:"var(--space-4)"},children:[e(ue,{label:"Kill Switch",value:a.value?.killSwitchState==="ACTIVATED"?"ACTIVATED":"NORMAL",loading:u,badge:a.value?a.value.killSwitchState==="ACTIVATED"?"danger":"success":void 0}),e(ue,{label:"Status",value:a.value?.status??"—",loading:u})]}),e("div",{class:"stat-grid",style:{marginTop:"var(--space-4)"},children:[e(ue,{label:"Policies",value:a.value?.policyCount?.toString()??"—",loading:u,href:"#/policies"}),e(ue,{label:"Recent Txns (24h)",value:a.value?.recentTxCount?.toString()??"—",loading:u}),e(ue,{label:"Failed Txns (24h)",value:a.value?.failedTxCount?.toString()??"—",loading:u,badge:a.value?a.value.failedTxCount===0?"success":"danger":void 0})]}),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(A,{variant:"primary",size:"sm",onClick:o,children:"Copy to Clipboard"}),e(A,{variant:"secondary",size:"sm",onClick:h,loading:s.value,children:"Regenerate"})]})]}):e(A,{variant:"primary",size:"sm",onClick:h,loading:s.value,style:{marginTop:"var(--space-2)"},children:"Generate"})]}),e("div",{style:{marginTop:"var(--space-4)"},children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"Recent Activity"}),e(Ne,{columns:Vn(l.value,i.value),data:a.value?.recentTransactions??[],loading:u,emptyMessage:"No recent transactions"})]})]})}function oe({open:a,title:t,children:n,onConfirm:l,onCancel:i,confirmText:s="Confirm",cancelText:r="Cancel",confirmVariant:c="primary",confirmDisabled:h=!1,loading:o=!1}){return R(()=>{if(!a)return;const u=d=>{d.key==="Escape"&&i()};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[a,i]),a?e("div",{class:"modal-overlay",onClick:i,children:e("div",{class:"modal-card",onClick:u=>u.stopPropagation(),children:[e("div",{class:"modal-header",children:t}),e("div",{class:"modal-body",children:n}),e("div",{class:"modal-footer",children:[e(A,{variant:"secondary",onClick:i,disabled:o,children:r}),l&&e(A,{variant:c,onClick:l,loading:o,disabled:h,children:s})]})]})}):null}function Re({value:a,label:t}){const n=v(!1);return e("button",{class:"btn btn-ghost btn-sm",onClick:async()=>{try{await navigator.clipboard.writeText(a)}catch{const i=document.createElement("textarea");i.value=a,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!":t??"Copy"})}function Gn({title:a,description:t,actionLabel:n,onAction:l}){return e("div",{class:"empty-state",children:[e("h3",{children:a}),t&&e("p",{children:t}),n&&l&&e("button",{class:"btn btn-primary",onClick:l,children:n})]})}function Ye({tabs:a,activeTab:t,onTabChange:n}){return e("div",{class:"tab-nav",children:a.map(l=>e("button",{class:`tab-btn ${t===l.key?"active":""}`,onClick:()=>{l.key!==t&&(Ha.value?Va({type:"tab",execute:()=>n(l.key)}):n(l.key))},children:l.label},l.key))})}function Je({pageName:a,tabName:t,onPageClick:n}){return t?e("nav",{class:"breadcrumb","aria-label":"Breadcrumb",children:[e("button",{class:"breadcrumb-page",onClick:n,type:"button",children:a}),e("span",{class:"breadcrumb-separator","aria-hidden":"true",children:">"}),e("span",{class:"breadcrumb-current","aria-current":"page",children:t})]}):null}const qn=new Set(["notifications.telegram_bot_token","notifications.discord_webhook_url","notifications.slack_webhook_url","telegram.bot_token"]);function jn(a){return qn.has(a)}function U(a){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",evm_default_network:"Default EVM Network",session_ttl:"Session TTL (seconds)",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",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",session_absolute_lifetime:"Absolute Lifetime (seconds)",session_max_renewals:"Max Renewals",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)"}[a]??a.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function $(a,t,n,l){const i=`${n}.${l}`;if(t[i]!==void 0)return t[i];const s=a[n];if(!s)return"";const r=s[l];return typeof r=="boolean"?jn(i)?"":String(r):r??""}function Le(a,t,n,l){const i=`${n}.${l}`;if(t[i]!==void 0)return t[i]==="true";const s=a[n];if(!s)return!1;const r=s[l];return typeof r=="boolean"?r:r==="true"}function et(a,t,n,l){const i=`${n}.${l}`;if(t[i]!==void 0)return!1;const s=a[n];return s?s[l]===!0:!1}const Yn=[{key:"name",header:"Name"},{key:"chain",header:"Chain"},{key:"environment",header:"Environment",render:a=>e(W,{variant:a.environment==="mainnet"?"warning":"info",children:a.environment})},{key:"publicKey",header:"Public Key",render:a=>e("span",{style:{display:"flex",alignItems:"center",gap:"0.25rem"},children:[Wt(a.publicKey)," ",e(Re,{value:a.publicKey})]})},{key:"status",header:"Status",render:a=>e(W,{variant:a.status==="ACTIVE"?"success":"danger",children:a.status})},{key:"ownerState",header:"Owner",render:a=>e(W,{variant:za(a.ownerState),children:a.ownerState})},{key:"createdAt",header:"Created",render:a=>re(a.createdAt)}];function za(a){switch(a){case"NONE":return"neutral";case"GRACE":return"warning";case"LOCKED":return"success";default:return"neutral"}}function te({label:a,value:t,copy:n,children:l}){return e("div",{class:"detail-row",children:[e("div",{class:"detail-row-label",children:a}),e("div",{class:"detail-row-value",children:[l??t??"—",n&&t&&e(Re,{value:t})]})]})}const Jn=[{value:null,label:"Auto (Global Fallback)",description:"System decides based on configured channels: SDK ntfy > SDK Telegram > WalletConnect > Telegram Bot > REST"},{value:"sdk_ntfy",label:"SDK via ntfy",description:"Push notifications via ntfy server to wallet app",warning:"Signing SDK is not enabled. Go to System > Signing SDK settings.",warningCondition:a=>!a?.signingEnabled},{value:"sdk_telegram",label:"SDK via Telegram",description:"Send sign request to Telegram with universal link",warning:"Signing SDK or Telegram bot is not enabled. Check System > Signing SDK and Telegram settings.",warningCondition:a=>!a?.signingEnabled||!a?.telegramEnabled||!a?.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:a=>!a?.wcConfigured},{value:"telegram_bot",label:"Telegram Bot",description:"Approve/reject via Telegram bot /approve and /reject commands",warning:"Telegram bot is not enabled. Go to System > Telegram settings.",warningCondition:a=>!a?.telegramEnabled||!a?.telegramBotConfigured},{value:"rest",label:"REST API",description:"Manual approval via REST API endpoints (POST /approve, /reject)"}];function Xn({id:a}){const t=v(null),n=v(!0),l=v(!1),i=v(""),s=v(!1),r=v(!1),c=v(!1),h=v(!1),o=v(null),u=v([]),d=v(!0),m=v(!1),p=v(null),k=v(!0),C=v([]),w=v(!0),I=v(!1),L=v(null),H=v(!1),K=v(null),S=v(!0),O=v(!1),P=v(null),q=v(!1),Y=v(""),ee=v(!1),J=v(null),T=async()=>{try{const y=await z(E.WALLET(a));t.value=y}catch(y){const V=y instanceof _?y:new _(0,"UNKNOWN","Unknown error");g("error",D(V.code))}finally{n.value=!1}},M=async()=>{s.value=!0;try{const y=await ie(E.WALLET(a),{name:i.value});t.value=y,l.value=!1,g("success","Wallet name updated")}catch(y){const V=y instanceof _?y:new _(0,"UNKNOWN","Unknown error");g("error",D(V.code))}finally{s.value=!1}},Q=async()=>{c.value=!0;try{await xe(E.WALLET(a)),g("success","Wallet terminated"),window.location.hash="#/wallets"}catch(y){const V=y instanceof _?y:new _(0,"UNKNOWN","Unknown error");g("error",D(V.code))}finally{c.value=!1}},be=()=>{i.value=t.value.name,l.value=!0},f=()=>{l.value=!1},x=async()=>{h.value=!0;try{const y=await ae(E.MCP_TOKENS,{walletId:a});o.value=y,g("success","MCP token provisioned successfully")}catch(y){const V=y instanceof _?y:new _(0,"UNKNOWN","Unknown error");g("error",D(V.code))}finally{h.value=!1}},Te=async()=>{d.value=!0;try{const y=await z(E.WALLET_NETWORKS(a));u.value=y.availableNetworks??[]}catch(y){const V=y instanceof _?y:new _(0,"UNKNOWN","Unknown error");g("error",D(V.code)),u.value=[]}finally{d.value=!1}},_t=async()=>{k.value=!0;try{p.value=await z(E.ADMIN_WALLET_BALANCE(a))}catch{p.value=null}finally{k.value=!1}},yt=async()=>{w.value=!0;try{const y=await z(E.ADMIN_WALLET_TRANSACTIONS(a));C.value=y.items}catch{C.value=[]}finally{w.value=!1}},gt=async()=>{S.value=!0;try{K.value=await z(E.WALLET_WC_SESSION(a))}catch{K.value=null}finally{S.value=!1}},bt=()=>{P.value&&clearInterval(P.value),P.value=setInterval(async()=>{try{const y=await z(E.WALLET_WC_PAIR_STATUS(a));y.status==="connected"?(P.value&&clearInterval(P.value),P.value=null,I.value=!1,L.value=null,K.value=y.session??null,g("success","Wallet connected via WalletConnect")):(y.status==="expired"||y.status==="none")&&(P.value&&clearInterval(P.value),P.value=null,I.value=!1,L.value=null,g("error","Pairing expired. Try again."))}catch{}},3e3)},wt=async()=>{H.value=!0;try{const y=await ae(E.WALLET_WC_PAIR(a));L.value=y,I.value=!0,bt()}catch(y){const V=y instanceof _?y:new _(0,"UNKNOWN","Unknown error");V.code==="WC_NOT_CONFIGURED"?(g("error","WalletConnect is not configured. Redirecting to settings..."),Z.value={tab:"walletconnect",fieldName:"walletconnect.project_id"},window.location.hash="#/wallets"):g("error",D(V.code))}finally{H.value=!1}},St=async()=>{O.value=!0;try{await xe(E.WALLET_WC_SESSION(a)),K.value=null,g("success","WalletConnect session disconnected")}catch(y){const V=y instanceof _?y:new _(0,"UNKNOWN","Unknown error");g("error",D(V.code))}finally{O.value=!1}},Xe=()=>{Y.value=t.value?.ownerAddress??"",q.value=!0},b=()=>{q.value=!1},G=async()=>{if(!Y.value.trim()){g("error","Owner address is required");return}ee.value=!0;try{await ie(E.WALLET_OWNER(a),{owner_address:Y.value.trim()}),await T(),q.value=!1,g("success","Owner address updated")}catch(y){const V=y instanceof _?y:new _(0,"UNKNOWN","Unknown error");g("error",D(V.code,V.serverMessage))}finally{ee.value=!1}},ce=async y=>{m.value=!0;try{await ie(E.WALLET_DEFAULT_NETWORK(a),{network:y}),g("success",`Default network changed to ${y}`),await T(),await Te()}catch(V){const Ce=V instanceof _?V:new _(0,"UNKNOWN","Unknown error");g("error",D(Ce.code))}finally{m.value=!1}},qa=async()=>{try{const y=await z(E.ADMIN_SETTINGS),V=y.signing_sdk?.enabled==="true",Ce=y.telegram?.enabled==="true",Ya=y.telegram?.bot_token===!0,Ja=!!y.walletconnect?.project_id&&y.walletconnect.project_id!=="";J.value={signingEnabled:V,telegramEnabled:Ce,telegramBotConfigured:Ya,wcConfigured:Ja}}catch{}},ja=async y=>{try{await ie(E.WALLET_OWNER(a),{owner_address:t.value.ownerAddress,approval_method:y??null}),await T(),g("success","Approval method updated")}catch(V){const Ce=V instanceof _?V:new _(0,"UNKNOWN","Unknown error");g("error",D(Ce.code,Ce.serverMessage))}};return R(()=>{T(),Te(),_t(),yt(),gt(),qa()},[a]),R(()=>()=>{P.value&&clearInterval(P.value)},[]),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)"}}):t.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:y=>{i.value=y.target.value},class:"inline-edit-input"}),e(A,{size:"sm",onClick:M,loading:s.value,children:"Save"}),e(A,{size:"sm",variant:"secondary",onClick:f,children:"Cancel"})]}):e("span",{children:[t.value.name,e("button",{class:"btn btn-ghost btn-sm",onClick:be,title:"Edit name",children:"✎"})]})}),e("div",{style:{display:"flex",gap:"var(--space-2)"},children:e(A,{variant:"danger",onClick:()=>{r.value=!0},children:"Terminate Wallet"})})]}),e("div",{class:"detail-grid",children:[e(te,{label:"ID",value:t.value.id,copy:!0}),e(te,{label:"Public Key",value:t.value.publicKey,copy:!0}),e(te,{label:"Chain",value:t.value.chain}),e(te,{label:"Environment",children:e(W,{variant:t.value.environment==="mainnet"?"warning":"info",children:t.value.environment})}),e(te,{label:"Default Network",value:t.value.defaultNetwork??t.value.network}),e(te,{label:"Status",children:e(W,{variant:t.value.status==="ACTIVE"?"success":"danger",children:t.value.status})}),e(te,{label:"Created",value:re(t.value.createdAt)}),e(te,{label:"Updated",value:t.value.updatedAt?re(t.value.updatedAt):"Never"})]}),e("div",{class:"balance-section",style:{marginTop:"var(--space-6)"},children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"Balances"}),k.value?e("div",{class:"stat-skeleton",style:{height:"60px"}}):p.value?.balances?.length?e("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-3)"},children:p.value.balances.map(y=>e("div",{style:{padding:"var(--space-3)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",background:y.isDefault?"var(--color-bg-secondary)":"transparent"},children:[e("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)",marginBottom:"var(--space-2)"},children:[e("strong",{children:y.network}),y.isDefault&&e("span",{class:"badge badge-info",style:{fontSize:"0.7rem"},children:"Default"})]}),y.error?e("p",{style:{color:"var(--color-text-secondary)",fontSize:"0.85rem"},children:y.error}):y.native?e("div",{children:[e(te,{label:"Native",value:`${y.native.balance} ${y.native.symbol}`}),y.tokens.length>0?y.tokens.map(V=>e(te,{label:V.symbol,value:V.balance},V.address)):null]}):e("p",{style:{color:"var(--color-text-secondary)",fontSize:"0.85rem"},children:"Balance unavailable"})]},y.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"}),d.value?e("div",{class:"stat-skeleton",style:{height:"80px"}}):e("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2)"},children:(u.value??[]).map(y=>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:[y.name??y.network,y.isDefault&&e(W,{variant:"success",style:{marginLeft:"var(--space-2)"},children:"Default"})]}),!y.isDefault&&t.value?.status==="ACTIVE"&&e(A,{size:"sm",variant:"secondary",onClick:()=>ce(y.network),loading:m.value,children:"Set Default"})]},y.network))})]}),e("div",{class:"transactions-section",style:{marginTop:"var(--space-6)"},children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"Recent Transactions"}),e(Ne,{columns:[{key:"createdAt",header:"Time",render:y=>y.createdAt?re(y.createdAt):"--"},{key:"type",header:"Type",render:y=>y.type},{key:"toAddress",header:"To",render:y=>y.toAddress?Wt(y.toAddress):"--"},{key:"amount",header:"Amount",render:y=>y.amount??"--"},{key:"status",header:"Status",render:y=>e(W,{variant:y.status==="CONFIRMED"?"success":y.status==="FAILED"?"danger":"warning",children:y.status})},{key:"network",header:"Network",render:y=>y.network??"--"}],data:C.value,loading:w.value,emptyMessage:"No transactions yet"})]}),e("div",{class:"owner-section",style:{marginTop:"var(--space-6)"},children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"Owner Wallet"}),t.value.ownerState==="NONE"&&t.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(A,{size:"sm",onClick:Xe,children:"Set Owner Address"})]}),e(te,{label:"Address",children:q.value?e("div",{class:"inline-edit",children:[e("input",{value:Y.value,onInput:y=>{Y.value=y.target.value},class:"inline-edit-input",placeholder:"Enter owner wallet address"}),e(A,{size:"sm",onClick:G,loading:ee.value,children:"Save"}),e(A,{size:"sm",variant:"secondary",onClick:b,children:"Cancel"})]}):e("span",{children:[t.value.ownerAddress?e(j,{children:[Wt(t.value.ownerAddress),e(Re,{value:t.value.ownerAddress})]}):"Not set",t.value.ownerState!=="LOCKED"&&t.value.status==="ACTIVE"&&e("button",{class:"btn btn-ghost btn-sm",onClick:Xe,title:"Set owner address",children:"✎"})]})}),e(te,{label:"State",children:e(W,{variant:za(t.value.ownerState),children:t.value.ownerState})}),t.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."})]}),t.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:Jn.map(y=>e("label",{style:{display:"flex",alignItems:"flex-start",gap:"var(--space-2)",padding:"var(--space-2) var(--space-3)",background:t.value?.approvalMethod===y.value?"var(--color-bg-secondary)":"transparent",borderRadius:"var(--radius-md)",cursor:"pointer"},children:[e("input",{type:"radio",name:"approval_method",value:y.value??"",checked:t.value?.approvalMethod===y.value,onChange:()=>ja(y.value),style:{marginTop:"2px"}}),e("div",{children:[e("div",{style:{fontWeight:500,fontSize:"0.9rem"},children:y.label}),e("div",{style:{color:"var(--color-text-secondary)",fontSize:"0.8rem"},children:y.description}),y.warning&&y.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:y.warning})]})]},y.value??"auto"))})]}),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"}),S.value?e("div",{class:"stat-skeleton",style:{height:"60px"}}):K.value?e("div",{children:[e(te,{label:"Status",children:e(W,{variant:"success",children:"Connected"})}),e(te,{label:"Peer",value:K.value.peerName??"Unknown"}),e(te,{label:"Chain ID",value:K.value.chainId}),e(te,{label:"Expires",value:re(K.value.expiry)}),e("div",{style:{marginTop:"var(--space-3)"},children:e(A,{variant:"danger",onClick:St,loading:O.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."}),t.value?.ownerAddress?e(A,{onClick:wt,loading:H.value,children:"Connect Wallet"}):e("p",{style:{color:"var(--color-text-secondary)",fontSize:"0.85rem"},children:"Set an Owner address first to enable WalletConnect."})]})]})]}),e("div",{class:"mcp-setup-section",style:{marginTop:"var(--space-6)"},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(te,{label:"Token Path",value:o.value.tokenPath}),e(te,{label:"Expires At",value:re(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(Re,{value:JSON.stringify({mcpServers:o.value.claudeDesktopConfig},null,2),label:"Copy Config"})})]}),e("div",{style:{marginTop:"var(--space-3)"},children:e(A,{variant:"secondary",onClick:x,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(A,{onClick:x,loading:h.value,children:"Setup MCP"})]})]}),e(oe,{open:r.value,title:"Terminate Wallet",onCancel:()=>{r.value=!1},onConfirm:Q,confirmText:"Terminate",confirmVariant:"danger",loading:c.value,children:e("p",{children:["Are you sure you want to terminate wallet ",e("strong",{children:t.value.name}),"? This action cannot be undone."]})}),e(oe,{open:I.value,title:"Scan QR Code",onCancel:()=>{I.value=!1,P.value&&clearInterval(P.value),P.value=null},children:L.value&&e("div",{style:{textAlign:"center"},children:[e("img",{src:L.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(Gn,{title:"Wallet not found",description:"The wallet may have been deleted."})]})}const Zn=["solana_mainnet","solana_devnet","solana_testnet"],Qn=["evm_ethereum_mainnet","evm_ethereum_sepolia","evm_polygon_mainnet","evm_polygon_amoy","evm_arbitrum_mainnet","evm_arbitrum_sepolia","evm_optimism_mainnet","evm_optimism_sepolia","evm_base_mainnet","evm_base_sepolia"],el={solana_mainnet:"RPC endpoint URL for Solana mainnet",solana_devnet:"RPC endpoint URL for Solana devnet",solana_testnet:"RPC endpoint URL for Solana testnet",evm_ethereum_mainnet:"RPC endpoint URL for Ethereum mainnet",evm_ethereum_sepolia:"RPC endpoint URL for Ethereum Sepolia testnet",evm_polygon_mainnet:"RPC endpoint URL for Polygon mainnet",evm_polygon_amoy:"RPC endpoint URL for Polygon Amoy testnet",evm_arbitrum_mainnet:"RPC endpoint URL for Arbitrum mainnet",evm_arbitrum_sepolia:"RPC endpoint URL for Arbitrum Sepolia testnet",evm_optimism_mainnet:"RPC endpoint URL for Optimism mainnet",evm_optimism_sepolia:"RPC endpoint URL for Optimism Sepolia testnet",evm_base_mainnet:"RPC endpoint URL for Base mainnet",evm_base_sepolia:"RPC endpoint URL for Base Sepolia testnet"},ia={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"},tl=[{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 al(){const a=v({}),t=v({}),n=v(!1),l=v(!0),i=v({}),s=v({}),r=async()=>{try{const p=await z(E.ADMIN_SETTINGS);a.value=p}catch(p){const k=p instanceof _?p:new _(0,"UNKNOWN","Unknown error");g("error",D(k.code))}finally{l.value=!1}};R(()=>{r()},[]);const c=(p,k)=>{const C=String(k);t.value={...t.value,[p]:C}},h=async()=>{n.value=!0;try{const p=Object.entries(t.value).filter(([C])=>C.startsWith("rpc.")).map(([C,w])=>({key:C,value:w})),k=await ie(E.ADMIN_SETTINGS,{settings:p});a.value=k.settings,t.value={},g("success","Settings saved and applied")}catch(p){const k=p instanceof _?p:new _(0,"UNKNOWN","Unknown error");g("error",D(k.code))}finally{n.value=!1}},o=()=>{t.value={}};R(()=>(ye({id:"wallets-rpc",isDirty:()=>Object.keys(t.value).filter(p=>p.startsWith("rpc.")).length>0,save:h,discard:o}),()=>ge("wallets-rpc")),[]);const u=async p=>{const k=p.split(".")[1]??"",C=$(a.value,t.value,"rpc",k);if(!C){g("warning","Enter a URL before testing");return}const w=k.startsWith("solana")?"solana":"evm";s.value={...s.value,[p]:!0};try{const I=await ae(E.ADMIN_SETTINGS_TEST_RPC,{url:C,chain:w});i.value={...i.value,[p]:I}}catch{i.value={...i.value,[p]:{success:!1,latencyMs:0,error:"Request failed"}}}finally{s.value={...s.value,[p]:!1}}};function d({shortKey:p}){const k=`rpc.${p}`,C=i.value[k],w=s.value[k];return e("div",{class:"settings-field-full",children:[e("div",{class:"rpc-field-row",children:[e(N,{label:U(p),name:k,type:"text",value:$(a.value,t.value,"rpc",p),onChange:I=>c(k,I),placeholder:"https://...",description:el[p]}),e(A,{variant:"ghost",size:"sm",onClick:()=>u(k),loading:!!w,children:"Test"})]}),C&&e("div",{class:`rpc-test-result ${C.success?"rpc-test-result--success":"rpc-test-result--failure"}`,children:[e(W,{variant:C.success?"success":"danger",children:C.success?"OK":"FAIL"}),e("span",{children:[C.latencyMs,"ms"]}),C.blockNumber!==void 0&&e("span",{children:[" (block #",C.blockNumber.toLocaleString(),")"]}),C.error&&e("span",{children:[" - ",C.error]})]})]})}const m=Object.keys(t.value).filter(p=>p.startsWith("rpc.")).length;return l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(j,{children:[m>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[m," unsaved change",m>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(A,{variant:"ghost",size:"sm",onClick:o,children:"Discard"}),e(A,{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:"RPC Endpoints"}),e("p",{class:"settings-description",children:"Configure blockchain RPC URLs for Solana and EVM networks"})]}),e("div",{class:"settings-category-body",children:[e("div",{class:"settings-subgroup",children:[e("div",{class:"settings-subgroup-title",children:"Solana"}),e("div",{class:"settings-fields-grid",children:Zn.map(p=>e(d,{shortKey:p},p))})]}),e("div",{class:"settings-subgroup",children:[e("div",{class:"settings-subgroup-title",children:"EVM"}),e("div",{class:"settings-fields-grid",children:[Qn.map(p=>e(d,{shortKey:p},p)),e("div",{class:"settings-field-full",children:e(N,{label:U("evm_default_network"),name:"rpc.evm_default_network",type:"select",value:$(a.value,t.value,"rpc","evm_default_network")||"ethereum-sepolia",onChange:p=>c("rpc.evm_default_network",p),options:tl,description:"Default EVM network for new wallets"})})]})]})]})]})]})}function nl(){const a=v({}),t=v({}),n=v(!1),l=v(!0),i=async()=>{try{const u=await z(E.ADMIN_SETTINGS);a.value=u}catch(u){const d=u instanceof _?u:new _(0,"UNKNOWN","Unknown error");g("error",D(d.code))}finally{l.value=!1}};R(()=>{i()},[]);const s=(u,d)=>{const m=String(d);t.value={...t.value,[u]:m}},r=async()=>{n.value=!0;try{const u=Object.entries(t.value).filter(([m])=>m.startsWith("monitoring.")).map(([m,p])=>({key:m,value:p})),d=await ie(E.ADMIN_SETTINGS,{settings:u});a.value=d.settings,t.value={},g("success","Settings saved and applied")}catch(u){const d=u instanceof _?u:new _(0,"UNKNOWN","Unknown error");g("error",D(d.code))}finally{n.value=!1}},c=()=>{t.value={}};R(()=>(ye({id:"wallets-monitoring",isDirty:()=>Object.keys(t.value).filter(u=>u.startsWith("monitoring.")).length>0,save:r,discard:c}),()=>ge("wallets-monitoring")),[]);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(t.value).filter(u=>u.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(A,{variant:"ghost",size:"sm",onClick:c,children:"Discard"}),e(A,{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(u=>u.type==="checkbox"?e("div",{class:"settings-field-full",children:e(N,{label:U(u.key),name:`monitoring.${u.key}`,type:"checkbox",value:Le(a.value,t.value,"monitoring",u.key),onChange:d=>s(`monitoring.${u.key}`,d),description:ia[u.key]})},u.key):e(N,{label:U(u.key),name:`monitoring.${u.key}`,type:"number",value:Number($(a.value,t.value,"monitoring",u.key))||0,onChange:d=>s(`monitoring.${u.key}`,d),min:u.min,max:u.max,description:ia[u.key]},u.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 ll(){const a=v({}),t=v({}),n=v(!1),l=v(!0),i=async()=>{try{const o=await z(E.ADMIN_SETTINGS);a.value=o}catch(o){const u=o instanceof _?o:new _(0,"UNKNOWN","Unknown error");g("error",D(u.code))}finally{l.value=!1}};R(()=>{i()},[]);const s=(o,u)=>{const d=String(u);t.value={...t.value,[o]:d}},r=async()=>{n.value=!0;try{const o=Object.entries(t.value).filter(([d])=>d.startsWith("walletconnect.")).map(([d,m])=>({key:d,value:m})),u=await ie(E.ADMIN_SETTINGS,{settings:o});a.value=u.settings,t.value={},g("success","Settings saved and applied")}catch(o){const u=o instanceof _?o:new _(0,"UNKNOWN","Unknown error");g("error",D(u.code))}finally{n.value=!1}},c=()=>{t.value={}};R(()=>(ye({id:"wallets-walletconnect",isDirty:()=>Object.keys(t.value).filter(o=>o.startsWith("walletconnect.")).length>0,save:r,discard:c}),()=>ge("wallets-walletconnect")),[]);const h=Object.keys(t.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(A,{variant:"ghost",size:"sm",onClick:c,children:"Discard"}),e(A,{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(N,{label:U("project_id"),name:"walletconnect.project_id",type:"text",value:$(a.value,t.value,"walletconnect","project_id"),onChange:o=>s("walletconnect.project_id",o),description:"WalletConnect Cloud project identifier"})}),e("div",{class:"settings-field-full",children:e(N,{label:U("relay_url"),name:"walletconnect.relay_url",type:"text",value:$(a.value,t.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."})]})]})]})}function il(){const a=v([]),t=v(!0),n=v(!1),l=v(""),i=v("solana"),s=v("testnet"),r=v(null),c=v(!1),h=v(null),o=async()=>{try{const p=await z(E.WALLETS);a.value=p.items}catch(p){const k=p instanceof _?p:new _(0,"UNKNOWN","Unknown error");g("error",D(k.code))}finally{t.value=!1}},u=async()=>{if(!l.value.trim()){r.value="Name is required";return}r.value=null,c.value=!0;try{const p=await ae(E.WALLETS,{name:l.value.trim(),chain:i.value,environment:s.value});p.session?.token?(h.value=p.session.token,g("success","Wallet created with session")):g("success","Wallet created"),l.value="",i.value="solana",s.value="testnet",n.value=!1,t.value=!0,await o()}catch(p){const k=p instanceof _?p:new _(0,"UNKNOWN","Unknown error");r.value=D(k.code)}finally{c.value=!1}},d=p=>{window.location.hash="#/wallets/"+p.id},m=p=>{i.value=p};return R(()=>{o()},[]),e(j,{children:[e("div",{class:"page-actions",children:!n.value&&e(A,{onClick:()=>{n.value=!0},children:"Create Wallet"})}),n.value&&e("div",{class:"inline-form",children:[e(N,{label:"Name",name:"name",value:l.value,onChange:p=>{l.value=p},required:!0,placeholder:"e.g. trading-bot",error:r.value??void 0}),e(N,{label:"Chain",name:"chain",type:"select",value:i.value,onChange:m,options:[{label:"Solana",value:"solana"},{label:"Ethereum",value:"ethereum"}]}),e(N,{label:"Environment",name:"environment",type:"select",value:s.value,onChange:p=>{s.value=p},options:[{label:"Testnet",value:"testnet"},{label:"Mainnet",value:"mainnet"}]}),e("div",{class:"inline-form-actions",children:[e(A,{onClick:u,loading:c.value,children:"Create"}),e(A,{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:p=>p.target.select()}),e(A,{variant:"secondary",onClick:()=>{navigator.clipboard.writeText(h.value),g("success","Token copied")},children:"Copy"}),e(A,{variant:"secondary",onClick:()=>{h.value=null},children:"Dismiss"})]})]}),e(Ne,{columns:Yn,data:a.value,loading:t.value,onRowClick:d,emptyMessage:"No wallets yet"})]})}const sa=[{key:"wallets",label:"Wallets"},{key:"rpc",label:"RPC Endpoints"},{key:"monitoring",label:"Balance Monitoring"},{key:"walletconnect",label:"WalletConnect"}];function sl(){const a=v("wallets");return R(()=>{const t=Z.value;t&&t.tab&&(a.value=t.tab,setTimeout(()=>{de.value=t.fieldName},100),Z.value=null)},[Z.value]),e("div",{class:"page",children:[e(Je,{pageName:"Wallets",tabName:sa.find(t=>t.key===a.value)?.label??"",onPageClick:()=>{a.value="wallets"}}),e(Ye,{tabs:sa,activeTab:a.value,onTabChange:t=>{a.value=t}}),a.value==="wallets"&&e(il,{}),a.value==="rpc"&&e(al,{}),a.value==="monitoring"&&e(nl,{}),a.value==="walletconnect"&&e(ll,{})]})}function ra(){const a=pe.value,t=a.startsWith("/wallets/")?a.slice(9):null;return t?e(Xn,{id:t}):e(sl,{})}function Pe({legend:a,children:t,description:n}){return e("fieldset",{class:"field-group",children:[e("legend",{class:"field-group-legend",children:a}),n&&e("p",{class:"field-group-description",children:n}),e("div",{class:"field-group-body",children:t})]})}function rl(a,t,n){t.value=a,n.value=!0}const oa=[{key:"sessions",label:"Sessions"},{key:"settings",label:"Settings"}],Nt=["security.session_ttl","security.session_absolute_lifetime","security.session_max_renewals","security.max_sessions_per_wallet","security.max_pending_tx","security.rate_limit_session_rpm","security.rate_limit_tx_rpm"];function ol(){const a=v({}),t=v({}),n=v(!1),l=v(!0),i=async()=>{try{const o=await z(E.ADMIN_SETTINGS);a.value=o}catch(o){const u=o instanceof _?o:new _(0,"UNKNOWN","Unknown error");g("error",D(u.code))}finally{l.value=!1}};R(()=>{i()},[]);const s=(o,u)=>{const d=String(u);t.value={...t.value,[o]:d}},r=async()=>{n.value=!0;try{const o=Object.entries(t.value).filter(([d])=>Nt.includes(d)).map(([d,m])=>({key:d,value:m})),u=await ie(E.ADMIN_SETTINGS,{settings:o});a.value=u.settings,t.value={},g("success","Session settings saved and applied")}catch(o){const u=o instanceof _?o:new _(0,"UNKNOWN","Unknown error");g("error",D(u.code))}finally{n.value=!1}},c=()=>{t.value={}};R(()=>(ye({id:"sessions-settings",isDirty:()=>Object.keys(t.value).filter(o=>Nt.includes(o)).length>0,save:r,discard:c}),()=>ge("sessions-settings")),[]);const h=Object.keys(t.value).filter(o=>Nt.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(A,{variant:"ghost",size:"sm",onClick:c,children:"Discard"}),e(A,{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(Pe,{legend:"Lifetime",description:"Session duration and renewal limits",children:e("div",{class:"settings-fields-grid",children:[e(N,{label:U("session_ttl"),name:"security.session_ttl",type:"number",value:Number($(a.value,t.value,"security","session_ttl"))||0,onChange:o=>s("security.session_ttl",o),min:300,description:"How long a session token is valid before renewal"}),e(N,{label:U("session_absolute_lifetime"),name:"security.session_absolute_lifetime",type:"number",value:Number($(a.value,t.value,"security","session_absolute_lifetime"))||0,onChange:o=>s("security.session_absolute_lifetime",o),min:0,description:"Maximum total session duration regardless of renewals"}),e(N,{label:U("session_max_renewals"),name:"security.session_max_renewals",type:"number",value:Number($(a.value,t.value,"security","session_max_renewals"))||0,onChange:o=>s("security.session_max_renewals",o),min:0,description:"Maximum number of times a session can be renewed"}),e(N,{label:U("max_sessions_per_wallet"),name:"security.max_sessions_per_wallet",type:"number",value:Number($(a.value,t.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(Pe,{legend:"Rate Limits",description:"Request throttling per session and transaction",children:e("div",{class:"settings-fields-grid",children:[e(N,{label:U("max_pending_tx"),name:"security.max_pending_tx",type:"number",value:Number($(a.value,t.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(N,{label:U("rate_limit_session_rpm"),name:"security.rate_limit_session_rpm",type:"number",value:Number($(a.value,t.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(N,{label:U("rate_limit_tx_rpm"),name:"security.rate_limit_tx_rpm",type:"number",value:Number($(a.value,t.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 cl(){const a=v("sessions");R(()=>{const f=Z.value;f&&f.tab&&(a.value=f.tab,setTimeout(()=>{de.value=f.fieldName},100),Z.value=null)},[Z.value]);const t=v([]),n=v(""),l=v(""),i=v([]),s=v(!1),r=v(!0),c=v(!1),h=v(!1),o=v(""),u=v(!1),d=v(""),m=v(!1),p=v(!1),k=v(new Set),C=v(""),w=v(!1),I=v("api"),L=v(new Set),H=v(!1),K=v(!1),S=v([]),O=v(null),P=async()=>{try{const f=await z(E.WALLETS);t.value=f.items.filter(x=>x.status==="ACTIVE")}catch(f){const x=f instanceof _?f:new _(0,"UNKNOWN","Unknown error");g("error",D(x.code))}finally{r.value=!1}},q=async()=>{s.value=!0;try{const f=n.value?`${E.SESSIONS}?walletId=${n.value}`:E.SESSIONS,x=await z(f);i.value=x}catch(f){const x=f instanceof _?f:new _(0,"UNKNOWN","Unknown error");g("error",D(x.code))}finally{s.value=!1}},Y=f=>{const x=new Set(k.value);x.has(f)?(x.delete(f),C.value===f&&(C.value=x.size>0?Array.from(x)[0]??"":"")):(x.add(f),x.size===1&&(C.value=f)),k.value=x},ee=async()=>{c.value=!0;try{const f=Array.from(k.value),x=f.length===1?{walletId:f[0]}:{walletIds:f,defaultWalletId:C.value||f[0]},Te=await ae(E.SESSIONS,x);o.value=Te.token,h.value=!0,p.value=!1,await q()}catch(f){const x=f instanceof _?f:new _(0,"UNKNOWN","Unknown error");g("error",D(x.code))}finally{c.value=!1}},J=f=>{const x=new Set(L.value);x.has(f)?x.delete(f):x.add(f),L.value=x},T=()=>{L.value.size===t.value.length?L.value=new Set:L.value=new Set(t.value.map(f=>f.id))},M=async()=>{if(L.value.size!==0){H.value=!0;try{const f=Array.from(L.value);if(I.value==="mcp"){const x=await ae(E.ADMIN_BULK_MCP_TOKENS,{walletIds:f});S.value=x.results,O.value=x.claudeDesktopConfig}else{const x=await ae(E.ADMIN_BULK_SESSIONS,{walletIds:f});S.value=x.results,O.value=null}w.value=!1,K.value=!0,await q()}catch(f){const x=f instanceof _?f:new _(0,"UNKNOWN","Unknown error");g("error",D(x.code))}finally{H.value=!1}}},Q=async()=>{m.value=!0;try{await xe(E.SESSION(d.value)),g("success","Session revoked"),u.value=!1,await q()}catch(f){const x=f instanceof _?f:new _(0,"UNKNOWN","Unknown error");g("error",D(x.code))}finally{m.value=!1}};R(()=>{P()},[]),R(()=>{i.value=[],q()},[n.value]);const be=[{key:"id",header:"ID",render:f=>f.id.slice(0,8)+"..."},{key:"walletName",header:"Wallet",render:f=>f.wallets&&f.wallets.length>0?e("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:f.wallets.map(x=>e("span",{children:[x.name??x.id.slice(0,8),x.isDefault&&e(W,{variant:"info",children:"default"})]},x.id))}):f.walletName??f.walletId.slice(0,8)+"..."},{key:"source",header:"Source",render:f=>e(W,{variant:f.source==="mcp"?"info":"neutral",children:f.source==="mcp"?"MCP":"API"})},{key:"status",header:"Status",render:f=>e(W,{variant:f.status==="ACTIVE"?"success":f.status==="EXPIRED"?"warning":"danger",children:f.status})},{key:"expiresAt",header:"Expires At",render:f=>re(f.expiresAt)},{key:"renewals",header:"Renewals",render:f=>`${f.renewalCount}/${f.maxRenewals}`},{key:"createdAt",header:"Created",render:f=>re(f.createdAt)},{key:"actions",header:"Actions",render:f=>f.status==="ACTIVE"?e(A,{size:"sm",variant:"danger",onClick:()=>rl(f.id,d,u),children:"Revoke"}):null}];return e("div",{class:"page",children:[e(Je,{pageName:"Sessions",tabName:oa.find(f=>f.key===a.value)?.label??"",onPageClick:()=>{a.value="sessions"}}),e(Ye,{tabs:oa,activeTab:a.value,onTabChange:f=>{a.value=f}}),a.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:f=>{n.value=f.target.value},disabled:r.value,children:[e("option",{value:"",children:"All Wallets"}),t.value.map(f=>e("option",{value:f.id,children:[f.name," (",f.chain,"/",f.network,")"]},f.id))]})]}),e("div",{class:"session-wallet-select",children:[e("label",{for:"source-select",children:"Source"}),e("select",{id:"source-select",value:l.value,onChange:f=>{l.value=f.target.value},children:[e("option",{value:"",children:"All"}),e("option",{value:"api",children:"API"}),e("option",{value:"mcp",children:"MCP"})]})]}),e(A,{onClick:()=>{k.value=new Set,C.value="",p.value=!0},disabled:t.value.length===0,children:"Create Session"}),e(A,{variant:"secondary",onClick:()=>{L.value=new Set,I.value="api",w.value=!0},disabled:t.value.length===0,children:"Bulk Create"})]}),e(Ne,{columns:be,data:l.value?i.value.filter(f=>f.source===l.value):i.value,loading:s.value,emptyMessage:"No sessions"}),e(oe,{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(Re,{value:o.value,label:"Copy Token"})]})]}),e(oe,{open:u.value,title:"Revoke Session",onCancel:()=>{u.value=!1},onConfirm:Q,confirmText:"Revoke",confirmVariant:"danger",loading:m.value,children:e("p",{children:"Are you sure you want to revoke this session? The associated token will be immediately invalidated."})}),e(oe,{open:p.value,title:"Create Session",onCancel:()=>{p.value=!1},onConfirm:ee,confirmText:`Create Session (${k.value.size} wallet${k.value.size!==1?"s":""})`,confirmDisabled:k.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:t.value.map(f=>e("label",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)",padding:"var(--space-1) 0",cursor:"pointer"},children:[e("input",{type:"checkbox",checked:k.value.has(f.id),onChange:()=>Y(f.id)}),e("span",{children:f.name}),e("span",{style:{color:"var(--color-text-secondary)",fontSize:"0.8rem"},children:["(",f.chain,"/",f.network,")"]})]},f.id))})]}),k.value.size>1&&e("div",{style:{marginTop:"var(--space-3)"},children:[e("label",{style:{fontWeight:600,display:"block",marginBottom:"var(--space-2)"},children:"Default Wallet"}),e("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"var(--space-2)"},children:t.value.filter(f=>k.value.has(f.id)).map(f=>e("label",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)",padding:"var(--space-1) 0",cursor:"pointer"},children:[e("input",{type:"radio",name:"defaultWallet",checked:C.value===f.id,onChange:()=>{C.value=f.id}}),e("span",{children:f.name}),e("span",{style:{color:"var(--color-text-secondary)",fontSize:"0.8rem"},children:["(",f.chain,"/",f.network,")"]})]},f.id))})]})]}),e(oe,{open:w.value,title:"Bulk Create Sessions",onCancel:()=>{w.value=!1},onConfirm:M,confirmText:`Create ${L.value.size} ${I.value==="mcp"?"MCP Tokens":"Sessions"}`,confirmDisabled:L.value.size===0,loading:H.value,children:[e("div",{style:{marginBottom:"var(--space-3)"},children:[e("label",{style:{fontWeight:600,display:"block",marginBottom:"var(--space-2)"},children:"Type"}),e("div",{style:{display:"flex",gap:"var(--space-3)"},children:[e("label",{style:{cursor:"pointer"},children:[e("input",{type:"radio",name:"bulkType",checked:I.value==="api",onChange:()=>{I.value="api"}})," API Session"]}),e("label",{style:{cursor:"pointer"},children:[e("input",{type:"radio",name:"bulkType",checked:I.value==="mcp",onChange:()=>{I.value="mcp"}})," MCP Token"]})]})]}),e("div",{children:[e("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"var(--space-2)"},children:[e("label",{style:{fontWeight:600},children:"Select Wallets"}),e("button",{type:"button",class:"btn btn-sm",onClick:T,children:L.value.size===t.value.length?"Deselect All":"Select All"})]}),e("div",{style:{maxHeight:"250px",overflow:"auto",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"var(--space-2)"},children:t.value.map(f=>e("label",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)",padding:"var(--space-1) 0",cursor:"pointer"},children:[e("input",{type:"checkbox",checked:L.value.has(f.id),onChange:()=>J(f.id)}),e("span",{children:f.name}),e("span",{style:{color:"var(--color-text-secondary)",fontSize:"0.8rem"},children:["(",f.chain,"/",f.network,")"]})]},f.id))})]})]}),e(oe,{open:K.value,title:"Bulk Creation Results",onCancel:()=>{K.value=!1},cancelText:"Close",children:[e("div",{style:{marginBottom:"var(--space-3)"},children:e("p",{children:["Created: ",e("strong",{children:S.value.filter(f=>!f.error).length})," / Failed: ",e("strong",{children:S.value.filter(f=>f.error).length})]})}),e("div",{style:{maxHeight:"200px",overflow:"auto",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"var(--space-2)"},children:S.value.map(f=>e("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"var(--space-1) 0",borderBottom:"1px solid var(--color-border)"},children:[e("span",{children:f.walletName??f.walletId.slice(0,8)}),f.error?e(W,{variant:"danger",children:f.error}):e(W,{variant:"success",children:"Created"})]},f.walletId))}),O.value&&Object.keys(O.value).length>0&&e("div",{style:{marginTop:"var(--space-3)"},children:[e("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"var(--space-2)"},children:[e("label",{style:{fontWeight:600},children:"Claude Desktop Config"}),e(Re,{value:JSON.stringify({mcpServers:O.value},null,2),label:"Copy Config"})]}),e("pre",{style:{fontSize:"0.75rem",maxHeight:"150px",overflow:"auto",background:"var(--color-bg-secondary)",padding:"var(--space-2)",borderRadius:"var(--radius-md)"},children:JSON.stringify({mcpServers:O.value},null,2)})]})]})]}),a.value==="settings"&&e(ol,{})]})}function dl({rules:a,onChange:t,errors:n}){const l=s=>r=>{t({...a,[s]:r})},i=s=>r=>{const c=Number(r),h={...a};r===""||r===0||Number.isNaN(c)?delete h[s]:h[s]=c,t(h)};return e("div",{class:"policy-form-fields",children:[e("h4",{children:"Native Amount Tiers"}),e("div",{class:"policy-form-grid",children:[e(N,{label:"Instant Max (lamports/wei)",name:"instant_max",value:a.instant_max||"",onChange:l("instant_max"),error:n.instant_max,required:!0}),e(N,{label:"Notify Max (lamports/wei)",name:"notify_max",value:a.notify_max||"",onChange:l("notify_max"),error:n.notify_max,required:!0}),e(N,{label:"Delay Max (lamports/wei)",name:"delay_max",value:a.delay_max||"",onChange:l("delay_max"),error:n.delay_max,required:!0})]}),e("h4",{children:"USD Amount Tiers (Optional)"}),e("div",{class:"policy-form-grid",children:[e(N,{label:"Instant Max USD",name:"instant_max_usd",type:"number",value:a.instant_max_usd??"",onChange:i("instant_max_usd"),placeholder:"Optional"}),e(N,{label:"Notify Max USD",name:"notify_max_usd",type:"number",value:a.notify_max_usd??"",onChange:i("notify_max_usd"),placeholder:"Optional"}),e(N,{label:"Delay Max USD",name:"delay_max_usd",type:"number",value:a.delay_max_usd??"",onChange:i("delay_max_usd"),placeholder:"Optional"})]}),e("h4",{children:"Cumulative USD Limits (Optional)"}),e("div",{class:"policy-form-grid",children:[e(N,{label:"Daily Limit USD (24h rolling)",name:"daily_limit_usd",type:"number",value:a.daily_limit_usd??"",onChange:i("daily_limit_usd"),placeholder:"e.g. 500",error:n.daily_limit_usd}),e(N,{label:"Monthly Limit USD (30d rolling)",name:"monthly_limit_usd",type:"number",value:a.monthly_limit_usd??"",onChange:i("monthly_limit_usd"),placeholder:"e.g. 5000",error:n.monthly_limit_usd})]}),e(N,{label:"Delay Duration (seconds, min 60)",name:"delay_seconds",type:"number",value:a.delay_seconds??900,onChange:l("delay_seconds"),error:n.delay_seconds,required:!0,min:60})]})}function _e({items:a,onAdd:t,onRemove:n,renderRow:l,onChange:i,addLabel:s="+ Add",minItems:r=0,error:c}){return e("div",{class:"dynamic-row-list",children:[a.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:a.length<=r,title:"Remove",children:"x"})]},o)),e("button",{class:"btn btn-secondary btn-sm",onClick:t,children:s}),c&&e("span",{class:"form-error",children:c})]})}function ul({rules:a,onChange:t,errors:n}){const l=a.allowed_addresses||[];return e("div",{class:"policy-form-fields",children:e(_e,{items:l,onAdd:()=>t({...a,allowed_addresses:[...l,""]}),onRemove:i=>t({...a,allowed_addresses:l.filter((s,r)=>r!==i)}),onChange:(i,s)=>{const r=[...l];r[i]=s,t({...a,allowed_addresses:r})},renderRow:(i,s,r)=>e(N,{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 vl({rules:a,onChange:t,errors:n}){const l=i=>s=>{t({...a,[i]:s})};return e("div",{class:"policy-form-fields",children:[e(N,{label:"Max Requests",name:"max_requests",type:"number",value:a.max_requests??100,onChange:l("max_requests"),error:n.max_requests,required:!0,min:1}),e(N,{label:"Window (seconds)",name:"window_seconds",type:"number",value:a.window_seconds??3600,onChange:l("window_seconds"),error:n.window_seconds,required:!0,min:1})]})}function hl({rules:a,onChange:t,errors:n}){const l=i=>{const s={...a};i===""||i===void 0?delete s.maxAmount:s.maxAmount=i,t(s)};return e("div",{class:"policy-form-fields",children:[e(N,{label:"Max Amount (lamports/wei, optional)",name:"maxAmount",value:a.maxAmount??"",onChange:l,error:n.maxAmount,placeholder:"Leave empty for no limit"}),e(N,{label:"Block Unlimited Approvals",name:"blockUnlimited",type:"checkbox",value:a.blockUnlimited??!0,onChange:i=>t({...a,blockUnlimited:i})})]})}const pl=[{label:"Instant",value:"INSTANT"},{label:"Notify",value:"NOTIFY"},{label:"Delay",value:"DELAY"},{label:"Approval",value:"APPROVAL"}];function ml({rules:a,onChange:t,errors:n}){return e("div",{class:"policy-form-fields",children:e(N,{label:"Override Tier",name:"tier",type:"select",value:a.tier??"DELAY",onChange:l=>t({...a,tier:l}),options:pl,error:n.tier})})}const fl=[{label:"All Chains",value:""},{label:"Solana",value:"solana"},{label:"Ethereum",value:"ethereum"}];function _l({rules:a,onChange:t,errors:n}){const l=a.tokens||[];return e("div",{class:"policy-form-fields",children:e(_e,{items:l,onAdd:()=>t({...a,tokens:[...l,{address:"",symbol:"",chain:""}]}),onRemove:i=>t({...a,tokens:l.filter((s,r)=>r!==i)}),onChange:(i,s)=>{const r=[...l];r[i]=s,t({...a,tokens:r})},renderRow:(i,s,r)=>e("div",{class:"dynamic-row-fields",style:{display:"flex",gap:"0.5rem",flex:1},children:[e(N,{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(N,{label:"Symbol",name:`token-symbol-${s}`,value:i.symbol,onChange:c=>r(s,{...i,symbol:c}),placeholder:"e.g. USDC"}),e(N,{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:fl})]}),addLabel:"+ Add Token",error:n.tokens})})}const yl=[{label:"All Chains",value:""},{label:"Solana",value:"solana"},{label:"Ethereum",value:"ethereum"}];function gl({rules:a,onChange:t,errors:n}){const l=a.contracts||[];return e("div",{class:"policy-form-fields",children:e(_e,{items:l,onAdd:()=>t({...a,contracts:[...l,{address:"",name:"",chain:""}]}),onRemove:i=>t({...a,contracts:l.filter((s,r)=>r!==i)}),onChange:(i,s)=>{const r=[...l];r[i]=s,t({...a,contracts:r})},renderRow:(i,s,r)=>e("div",{class:"dynamic-row-fields",style:{display:"flex",gap:"0.5rem",flex:1},children:[e(N,{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(N,{label:"Name",name:`contract-name-${s}`,value:i.name,onChange:c=>r(s,{...i,name:c}),placeholder:"e.g. Uniswap Router"}),e(N,{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:yl})]}),addLabel:"+ Add Contract",error:n.contracts})})}function bl({rules:a,onChange:t,errors:n}){const l=a.methods||[],i=s=>{t({...a,methods:s})};return e("div",{class:"policy-form-fields",children:e(_e,{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(N,{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(_e,{items:s.selectors,onAdd:()=>c(r,{...s,selectors:[...s.selectors,""]}),onRemove:h=>c(r,{...s,selectors:s.selectors.filter((o,u)=>u!==h)}),onChange:(h,o)=>{const u=[...s.selectors];u[h]=o,c(r,{...s,selectors:u})},renderRow:(h,o,u)=>e(N,{label:`Selector ${o+1}`,name:`method-sel-${r}-${o}`,value:h,onChange:d=>u(o,d),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 wl({rules:a,onChange:t,errors:n}){const l=a.spenders||[];return e("div",{class:"policy-form-fields",children:e(_e,{items:l,onAdd:()=>t({...a,spenders:[...l,{address:"",name:"",maxAmount:""}]}),onRemove:i=>t({...a,spenders:l.filter((s,r)=>r!==i)}),onChange:(i,s)=>{const r=[...l];r[i]=s,s.maxAmount||delete r[i].maxAmount,t({...a,spenders:r})},renderRow:(i,s,r)=>e("div",{class:"dynamic-row-fields",style:{display:"flex",gap:"0.5rem",flex:1},children:[e(N,{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(N,{label:"Name",name:`spender-name-${s}`,value:i.name,onChange:c=>r(s,{...i,name:c}),placeholder:"e.g. Uniswap"}),e(N,{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 Sl=Array.from({length:24},(a,t)=>({label:`${String(t).padStart(2,"0")}:00`,value:String(t)})),kl=Array.from({length:24},(a,t)=>({label:`${String(t+1).padStart(2,"0")}:00`,value:String(t+1)})),Nl=[{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 Tl({rules:a,onChange:t,errors:n}){const l=a.allowed_hours||{start:0,end:24},i=a.allowed_days||[],s=c=>h=>{const o={...l,[c]:Number(h)};t({...a,allowed_hours:o})},r=c=>{const h=i.includes(c)?i.filter(o=>o!==c):[...i,c].sort((o,u)=>o-u);t({...a,allowed_days:h})};return e("div",{class:"policy-form-fields",children:[e("h4",{children:"Allowed Hours"}),e("div",{class:"policy-form-grid",children:[e(N,{label:"Start Hour",name:"allowed_hours_start",type:"select",value:String(l.start),onChange:s("start"),options:Sl,error:n.allowed_hours}),e(N,{label:"End Hour",name:"allowed_hours_end",type:"select",value:String(l.end),onChange:s("end"),options:kl})]}),e("h4",{children:"Allowed Days"}),e("div",{style:{display:"flex",gap:"0.75rem",flexWrap:"wrap"},children:Nl.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 Cl=[{label:"mainnet",value:"mainnet"},{label:"devnet",value:"devnet"},{label:"testnet",value:"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 El({rules:a,onChange:t,errors:n}){const l=a.networks||[];return e("div",{class:"policy-form-fields",children:e(_e,{items:l,onAdd:()=>t({...a,networks:[...l,{network:"mainnet",name:""}]}),onRemove:i=>t({...a,networks:l.filter((s,r)=>r!==i)}),onChange:(i,s)=>{const r=[...l];r[i]=s,t({...a,networks:r})},renderRow:(i,s,r)=>e("div",{class:"dynamic-row-fields",style:{display:"flex",gap:"0.5rem",flex:1},children:[e(N,{label:`Network ${s+1}`,name:`network-sel-${s}`,type:"select",value:i.network,onChange:c=>r(s,{...i,network:c}),options:Cl,error:n[`networks.${s}.network`],required:!0}),e(N,{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 Al({rules:a,onChange:t,errors:n}){const l=a.domains||[];return e("div",{class:"policy-form-fields",children:e(_e,{items:l,onAdd:()=>t({...a,domains:[...l,""]}),onRemove:i=>t({...a,domains:l.filter((s,r)=>r!==i)}),onChange:(i,s)=>{const r=[...l];r[i]=s,t({...a,domains:r})},renderRow:(i,s,r)=>e(N,{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 ca({type:a,rules:t,onChange:n,errors:l}){switch(a){case"SPENDING_LIMIT":return e(dl,{rules:t,onChange:n,errors:l});case"WHITELIST":return e(ul,{rules:t,onChange:n,errors:l});case"RATE_LIMIT":return e(vl,{rules:t,onChange:n,errors:l});case"APPROVE_AMOUNT_LIMIT":return e(hl,{rules:t,onChange:n,errors:l});case"APPROVE_TIER_OVERRIDE":return e(ml,{rules:t,onChange:n,errors:l});case"ALLOWED_TOKENS":return e(_l,{rules:t,onChange:n,errors:l});case"CONTRACT_WHITELIST":return e(gl,{rules:t,onChange:n,errors:l});case"METHOD_WHITELIST":return e(bl,{rules:t,onChange:n,errors:l});case"APPROVED_SPENDERS":return e(wl,{rules:t,onChange:n,errors:l});case"TIME_RESTRICTION":return e(Tl,{rules:t,onChange:n,errors:l});case"ALLOWED_NETWORKS":return e(El,{rules:t,onChange:n,errors:l});case"X402_ALLOWED_DOMAINS":return e(Al,{rules:t,onChange:n,errors:l});default:return e("p",{class:"policy-form-placeholder",children:"This policy type uses JSON editor. Toggle to JSON mode."})}}function Mt(a){const t=typeof a=="string"?Number(a):a;return Number.isNaN(t)?String(a):t.toLocaleString("en-US")}function Il(a){return a===86400?"1d":a%86400===0?`${a/86400}d`:a===3600?"1h":a%3600===0?`${a/3600}h`:a===60?"1m":a%60===0?`${a/60}m`:`${a}s`}const Tt=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Dl(a){if(!a||a.length===0)return"";const t=[...a].sort((l,i)=>l-i);let n=!0;for(let l=1;l<t.length;l++)if(t[l]!==t[l-1]+1){n=!1;break}return n&&t.length>2?`${Tt[t[0]]}-${Tt[t[t.length-1]]}`:t.map(l=>Tt[l]??String(l)).join(", ")}function da(a){return String(a).padStart(2,"0")}function Ll({rules:a}){const t=Number(a.instant_max??0),n=Number(a.notify_max??0),l=Number(a.delay_max??0),i=Math.max(t,n,l,1),s=[{label:"Instant",value:a.instant_max,width:t/i*100,cls:"instant"},{label:"Notify",value:a.notify_max,width:n/i*100,cls:"notify"},{label:"Delay",value:a.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?Mt(r.value):""})]},r.cls))})}function ua(a){return a.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:2})}function Ol({rules:a}){const t=a.daily_limit_usd,n=a.monthly_limit_usd;return!t&&!n?null:e("div",{class:"cumulative-limits",children:[e("div",{class:"cumulative-limits-label",children:"Cumulative Limits"}),t&&e("div",{class:"cumulative-limit-row",children:[e("span",{class:"cumulative-limit-type",children:"Daily (24h)"}),e("span",{class:"cumulative-limit-value",children:["$",ua(t)]})]}),n&&e("div",{class:"cumulative-limit-row",children:[e("span",{class:"cumulative-limit-type",children:"Monthly (30d)"}),e("span",{class:"cumulative-limit-value",children:["$",ua(n)]})]})]})}const xl={INSTANT:"success",NOTIFY:"info",DELAY:"warning",APPROVAL:"danger"};function Rl({type:a,rules:t}){switch(a){case"SPENDING_LIMIT":return e("div",{class:"spending-limit-summary",children:[e(Ll,{rules:t}),e(Ol,{rules:t})]});case"ALLOWED_TOKENS":{const n=t.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(W,{variant:"info",children:l.symbol||(l.address?l.address.slice(0,8)+"...":"?")},i))})}case"RATE_LIMIT":{const n=t.max_requests,l=t.window_seconds;return e("span",{class:"rules-vis-text",children:[n," req / ",Il(l)]})}case"WHITELIST":{const n=t.allowed_addresses||[];return e(W,{variant:"neutral",children:[n.length," addresses"]})}case"TIME_RESTRICTION":{const n=t.allowed_days||[],l=t.allowed_hours,i=Dl(n),s=l?`${da(l.start)}:00-${da(l.end)}:00`:"";return e("span",{class:"rules-vis-text",children:[i," ",s]})}case"CONTRACT_WHITELIST":{const n=t.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(W,{variant:"neutral",children:s.name||(s.address?s.address.slice(0,8)+"...":"?")},r)),i>0&&e(W,{variant:"neutral",children:["+",i," more"]})]})}case"METHOD_WHITELIST":{const n=t.methods||[],l=n.length,i=n.reduce((s,r)=>s+(r.selectors?.length||0),0);return e(W,{variant:"neutral",children:[l," contracts, ",i," methods"]})}case"APPROVED_SPENDERS":{const n=t.spenders||[];return e(W,{variant:"neutral",children:[n.length," spenders"]})}case"APPROVE_AMOUNT_LIMIT":{const n=t.maxAmount,l=t.blockUnlimited;return n&&l?e("span",{class:"rules-vis-text",children:["Max: ",Mt(n)," + Block unlimited"]}):n?e("span",{class:"rules-vis-text",children:["Max: ",Mt(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=t.tier||"DELAY",l=xl[n]||"neutral";return e(W,{variant:l,children:n})}case"ALLOWED_NETWORKS":{const n=t.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(W,{variant:"info",children:s.network},r)),i>0&&e(W,{variant:"info",children:["+",i," more"]})]})}case"X402_ALLOWED_DOMAINS":{const n=t.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(W,{variant:"neutral",children:s},r)),i>0&&e(W,{variant:"neutral",children:["+",i," more"]})]})}default:{const n=JSON.stringify(t);return e("span",{class:"rules-summary",children:n.length>60?n.slice(0,60)+"...":n})}}}const Ga=[{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"}],$e={SPENDING_LIMIT:{instant_max:"1000000",notify_max:"5000000",delay_max:"10000000",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 tt(a,t){const n={};if(a==="SPENDING_LIMIT"){(!t.instant_max||!/^\d+$/.test(t.instant_max))&&(n.instant_max="Positive integer required"),(!t.notify_max||!/^\d+$/.test(t.notify_max))&&(n.notify_max="Positive integer required"),(!t.delay_max||!/^\d+$/.test(t.delay_max))&&(n.delay_max="Positive integer required");const l=Number(t.delay_seconds);(t.delay_seconds===void 0||t.delay_seconds===""||Number.isNaN(l)||l<60)&&(n.delay_seconds="Minimum 60 seconds");const i=t.daily_limit_usd;if(i!==void 0&&i!==""){const r=Number(i);(Number.isNaN(r)||r<=0)&&(n.daily_limit_usd="Must be a positive number")}const s=t.monthly_limit_usd;if(s!==void 0&&s!==""){const r=Number(s);(Number.isNaN(r)||r<=0)&&(n.monthly_limit_usd="Must be a positive number")}}else if(a==="WHITELIST"){const l=t.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(a==="RATE_LIMIT"){const l=Number(t.max_requests);(!t.max_requests||Number.isNaN(l)||l<1||!Number.isInteger(l))&&(n.max_requests="Positive integer required");const i=Number(t.window_seconds);(!t.window_seconds||Number.isNaN(i)||i<1||!Number.isInteger(i))&&(n.window_seconds="Positive integer required")}else if(a==="APPROVE_AMOUNT_LIMIT")t.maxAmount&&!/^\d+$/.test(t.maxAmount)&&(n.maxAmount="Must be a positive integer string");else if(a==="ALLOWED_TOKENS"){const l=t.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(a==="CONTRACT_WHITELIST"){const l=t.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(a==="METHOD_WHITELIST"){const l=t.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(a==="APPROVED_SPENDERS"){const l=t.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(a==="TIME_RESTRICTION"){(t.allowed_days||[]).length===0&&(n.allowed_days="At least one day required");const i=t.allowed_hours;i&&i.start>=i.end&&(n.allowed_hours="Start must be before end")}else if(a==="ALLOWED_NETWORKS"){const l=t.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(a==="X402_ALLOWED_DOMAINS"){const l=t.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 Pl(a,t){if(!a)return"Global";const n=t.find(l=>l.id===a);return n?n.name:a.slice(0,8)+"..."}function Ct(a){const t=Ga.find(n=>n.value===a);return t?t.label:a}const va=[{key:"policies",label:"Policies"},{key:"defaults",label:"Defaults"}],Et=["security.policy_defaults_delay_seconds","security.policy_defaults_approval_timeout","policy.default_deny_tokens","policy.default_deny_contracts","policy.default_deny_spenders"];function Wl(){const a=v({}),t=v({}),n=v(!1),l=v(!0),i=async()=>{try{const o=await z(E.ADMIN_SETTINGS);a.value=o}catch(o){const u=o instanceof _?o:new _(0,"UNKNOWN","Unknown error");g("error",D(u.code))}finally{l.value=!1}};R(()=>{i()},[]);const s=(o,u)=>{const d=String(u);t.value={...t.value,[o]:d}},r=async()=>{n.value=!0;try{const o=Object.entries(t.value).filter(([d])=>Et.includes(d)).map(([d,m])=>({key:d,value:m})),u=await ie(E.ADMIN_SETTINGS,{settings:o});a.value=u.settings,t.value={},g("success","Policy defaults saved and applied")}catch(o){const u=o instanceof _?o:new _(0,"UNKNOWN","Unknown error");g("error",D(u.code))}finally{n.value=!1}},c=()=>{t.value={}};R(()=>(ye({id:"policies-defaults",isDirty:()=>Object.keys(t.value).filter(o=>Et.includes(o)).length>0,save:r,discard:c}),()=>ge("policies-defaults")),[]);const h=Object.keys(t.value).filter(o=>Et.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(A,{variant:"ghost",size:"sm",onClick:c,children:"Discard"}),e(A,{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(N,{label:U("policy_defaults_delay_seconds"),name:"security.policy_defaults_delay_seconds",type:"number",value:Number($(a.value,t.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(N,{label:U("policy_defaults_approval_timeout"),name:"security.policy_defaults_approval_timeout",type:"number",value:Number($(a.value,t.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(N,{label:U("default_deny_tokens"),name:"policy.default_deny_tokens",type:"checkbox",value:Le(a.value,t.value,"policy","default_deny_tokens"),onChange:o=>s("policy.default_deny_tokens",o),description:"Deny token transfers unless a matching whitelist policy exists"}),e(N,{label:U("default_deny_contracts"),name:"policy.default_deny_contracts",type:"checkbox",value:Le(a.value,t.value,"policy","default_deny_contracts"),onChange:o=>s("policy.default_deny_contracts",o),description:"Deny contract calls unless a matching whitelist policy exists"}),e(N,{label:U("default_deny_spenders"),name:"policy.default_deny_spenders",type:"checkbox",value:Le(a.value,t.value,"policy","default_deny_spenders"),onChange:o=>s("policy.default_deny_spenders",o),description:"Deny token approvals unless a matching 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 Ml(){const a=v("policies");R(()=>{const b=Z.value;b&&b.tab&&(a.value=b.tab,setTimeout(()=>{de.value=b.fieldName},100),Z.value=null)},[Z.value]);const t=v([]),n=v([]),l=v("__all__"),i=v(!1),s=v(!0),r=v(!1),c=v("SPENDING_LIMIT"),h=v(""),o=v(JSON.stringify($e.SPENDING_LIMIT,null,2)),u=v($e.SPENDING_LIMIT),d=v({}),m=v(!1),p=v(0),k=v(!0),C=v(""),w=v(null),I=v(!1),L=v(!1),H=v(null),K=v(""),S=v({}),O=v(!1),P=v({}),q=v(0),Y=v(!0),ee=v(null),J=v(!1),T=v(!1),M=v(null),Q=v(!1),be=async()=>{try{const b=await z(E.WALLETS);t.value=b.items}catch(b){const G=b instanceof _?b:new _(0,"UNKNOWN","Unknown error");g("error",D(G.code))}finally{s.value=!1}},f=async()=>{i.value=!0;try{let b=E.POLICIES;l.value!=="__all__"&&l.value!=="__global__"&&(b=`${E.POLICIES}?walletId=${l.value}`);const G=await z(b);l.value==="__global__"?n.value=G.filter(ce=>ce.walletId===null):n.value=G}catch(b){const G=b instanceof _?b:new _(0,"UNKNOWN","Unknown error");g("error",D(G.code))}finally{i.value=!1}},x=async()=>{w.value=null;let b;if(m.value)try{b=JSON.parse(o.value)}catch{w.value="Invalid JSON in rules field";return}else{const G=tt(c.value,u.value);if(Object.keys(G).length>0){d.value=G;return}d.value={},b=u.value}I.value=!0;try{await ae(E.POLICIES,{walletId:h.value||void 0,type:c.value,rules:b,priority:p.value,enabled:k.value,network:C.value||void 0}),g("success","Policy created"),r.value=!1,c.value="SPENDING_LIMIT",h.value="",C.value="",o.value=JSON.stringify($e.SPENDING_LIMIT,null,2),u.value=$e.SPENDING_LIMIT,d.value={},m.value=!1,p.value=0,k.value=!0,w.value=null,await f()}catch(G){const ce=G instanceof _?G:new _(0,"UNKNOWN","Unknown error");g("error",D(ce.code))}finally{I.value=!1}},Te=b=>{H.value=b,K.value=JSON.stringify(b.rules,null,2),S.value={...b.rules},O.value=!1,P.value={},q.value=b.priority,Y.value=b.enabled,ee.value=null,L.value=!0},_t=async()=>{ee.value=null;let b;if(O.value)try{b=JSON.parse(K.value)}catch{ee.value="Invalid JSON in rules field";return}else{const G=tt(H.value.type,S.value);if(Object.keys(G).length>0){P.value=G;return}P.value={},b=S.value}J.value=!0;try{await ie(E.POLICY(H.value.id),{rules:b,priority:q.value,enabled:Y.value}),g("success","Policy updated"),L.value=!1,await f()}catch(G){const ce=G instanceof _?G:new _(0,"UNKNOWN","Unknown error");g("error",D(ce.code))}finally{J.value=!1}},yt=()=>{if(!O.value)K.value=JSON.stringify(S.value,null,2);else try{S.value=JSON.parse(K.value),ee.value=null}catch{ee.value="Invalid JSON — cannot switch to form mode";return}O.value=!O.value},gt=b=>{M.value=b,T.value=!0},bt=async()=>{Q.value=!0;try{await xe(E.POLICY(M.value.id)),g("success","Policy deleted"),T.value=!1,await f()}catch(b){const G=b instanceof _?b:new _(0,"UNKNOWN","Unknown error");g("error",D(G.code))}finally{Q.value=!1}},wt=b=>{const G=b;c.value=G;const ce=$e[G];ce&&(o.value=JSON.stringify(ce,null,2),u.value={...ce}),d.value={},m.value=!1},St=()=>{if(!m.value)o.value=JSON.stringify(u.value,null,2);else try{u.value=JSON.parse(o.value),w.value=null}catch{w.value="Invalid JSON — cannot switch to form mode";return}m.value=!m.value};R(()=>{be()},[]),R(()=>{f()},[l.value]);const Xe=[{key:"type",header:"Type",render:b=>e(W,{variant:b.type==="SPENDING_LIMIT"?"success":"info",children:Ct(b.type)})},{key:"walletId",header:"Wallet",render:b=>Pl(b.walletId,t.value)},{key:"network",header:"Network",render:b=>b.network??"All"},{key:"rules",header:"Rules",render:b=>e(Rl,{type:b.type,rules:b.rules})},{key:"priority",header:"Priority"},{key:"enabled",header:"Enabled",render:b=>e(W,{variant:b.enabled?"success":"danger",children:b.enabled?"ON":"OFF"})},{key:"actions",header:"Actions",render:b=>e("span",{style:{display:"flex",gap:"0.25rem"},children:[e("button",{class:"btn btn-ghost btn-sm",onClick:G=>{G.stopPropagation(),Te(b)},children:"Edit"}),e(A,{size:"sm",variant:"danger",onClick:()=>gt(b),children:"Delete"})]})}];return e("div",{class:"page",children:[e(Je,{pageName:"Policies",tabName:va.find(b=>b.key===a.value)?.label??"",onPageClick:()=>{a.value="policies"}}),e(Ye,{tabs:va,activeTab:a.value,onTabChange:b=>{a.value=b}}),a.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:b=>{l.value=b.target.value},disabled:s.value,children:[e("option",{value:"__all__",children:"All Policies"}),e("option",{value:"__global__",children:"Global Only"}),t.value.map(b=>e("option",{value:b.id,children:[b.name," (",b.chain,"/",b.network,")"]},b.id))]})]}),!r.value&&e(A,{onClick:()=>{r.value=!0},children:"Create Policy"})]}),r.value&&e("div",{class:"inline-form",children:[e(N,{label:"Type",name:"type",type:"select",value:c.value,onChange:wt,options:Ga}),e(N,{label:"Wallet",name:"walletId",type:"select",value:h.value,onChange:b=>{h.value=b},options:[{label:"Global (no wallet)",value:""},...t.value.map(b=>({label:`${b.name} (${b.chain}/${b.network})`,value:b.id}))]}),e(N,{label:"Network Scope",name:"network",value:C.value,onChange:b=>{C.value=b},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:St,children:m.value?"Switch to Form":"JSON Direct Edit"})]}),m.value?e(N,{label:"",name:"rules",type:"textarea",value:o.value,onChange:b=>{o.value=b},error:w.value??void 0}):e(ca,{type:c.value,rules:u.value,onChange:b=>{u.value=b,Object.keys(d.value).length>0&&(d.value=tt(c.value,b))},errors:d.value})]}),e(N,{label:"Priority",name:"priority",type:"number",value:p.value,onChange:b=>{p.value=b},min:0,max:999}),e(N,{label:"Enabled",name:"enabled",type:"checkbox",value:k.value,onChange:b=>{k.value=b}}),e("div",{class:"inline-form-actions",children:[e(A,{onClick:x,loading:I.value,children:"Create"}),e(A,{variant:"secondary",onClick:()=>{r.value=!1,w.value=null},children:"Cancel"})]})]}),e(Ne,{columns:Xe,data:n.value,loading:i.value,emptyMessage:"No policies found"}),e(oe,{open:L.value,title:"Edit Policy",onCancel:()=>{L.value=!1},onConfirm:_t,confirmText:"Save",loading:J.value,children:H.value&&e("div",{children:[e("div",{class:"policy-type-readonly",children:["Type: ",Ct(H.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:yt,children:O.value?"Switch to Form":"JSON Direct Edit"})]}),O.value?e("div",{class:"edit-rules-textarea",children:e(N,{label:"",name:"edit-rules",type:"textarea",value:K.value,onChange:b=>{K.value=b},error:ee.value??void 0})}):e(ca,{type:H.value.type,rules:S.value,onChange:b=>{S.value=b,Object.keys(P.value).length>0&&(P.value=tt(H.value.type,b))},errors:P.value})]}),e(N,{label:"Priority",name:"edit-priority",type:"number",value:q.value,onChange:b=>{q.value=b},min:0,max:999}),e(N,{label:"Enabled",name:"edit-enabled",type:"checkbox",value:Y.value,onChange:b=>{Y.value=b}})]})}),e(oe,{open:T.value,title:"Delete Policy",onCancel:()=>{T.value=!1},onConfirm:bt,confirmText:"Delete",confirmVariant:"danger",loading:Q.value,children:M.value&&e("p",{children:["Are you sure you want to delete this"," ",e("strong",{children:Ct(M.value.type)})," policy? This action cannot be undone."]})})]}),a.value==="defaults"&&e(Wl,{})]})}function Ul(){return e($l,{})}function $l(){const a=v([]),t=v(!0),n=v(!1),l=v(null),i=v("ADMIN"),s=v(!1),r=v(!1),c=v(null),h=v(!1),o=async()=>{t.value=!0;try{const w=await z(E.ADMIN_TELEGRAM_USERS);a.value=w.users}catch(w){const I=w instanceof _?w:new _(0,"UNKNOWN","Unknown error");g("error",D(I.code))}finally{t.value=!1}};R(()=>{o()},[]);const u=w=>{l.value=w,i.value="ADMIN",n.value=!0},d=async()=>{if(l.value){s.value=!0;try{await ie(E.ADMIN_TELEGRAM_USER(l.value.chat_id),{role:i.value}),g("success",`User approved as ${i.value}`),n.value=!1,l.value=null,await o()}catch(w){const I=w instanceof _?w:new _(0,"UNKNOWN","Unknown error");g("error",D(I.code))}finally{s.value=!1}}},m=w=>{c.value=w,r.value=!0},p=async()=>{if(c.value){h.value=!0;try{await xe(E.ADMIN_TELEGRAM_USER(c.value.chat_id)),g("success","User deleted"),r.value=!1,c.value=null,await o()}catch(w){const I=w instanceof _?w:new _(0,"UNKNOWN","Unknown error");g("error",D(I.code))}finally{h.value=!1}}},k=w=>w==="PENDING"?"warning":w==="ADMIN"?"success":"info";return e("div",{class:"page",children:[e(Ne,{columns:[{key:"chat_id",header:"Chat ID",render:w=>String(w.chat_id)},{key:"username",header:"Username",render:w=>w.username??"-"},{key:"role",header:"Role",render:w=>e(W,{variant:k(w.role),children:w.role})},{key:"registered_at",header:"Registered",render:w=>re(w.registered_at)},{key:"approved_at",header:"Approved",render:w=>w.approved_at?re(w.approved_at):"-"},{key:"actions",header:"Actions",render:w=>e("div",{style:{display:"flex",gap:"var(--space-1)"},children:[w.role==="PENDING"&&e(A,{size:"sm",variant:"primary",onClick:()=>u(w),children:"Approve"}),e(A,{size:"sm",variant:"danger",onClick:()=>m(w),children:"Delete"})]})}],data:a.value,loading:t.value,emptyMessage:"No Telegram users registered. Users appear here after sending /start to the bot."}),e(oe,{open:n.value,title:"Approve Telegram User",onCancel:()=>{n.value=!1,l.value=null},onConfirm:d,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:w=>{i.value=w.target.value},children:[e("option",{value:"ADMIN",children:"ADMIN"}),e("option",{value:"READONLY",children:"READONLY"})]})]})]})}),e(oe,{open:r.value,title:"Delete Telegram User",onCancel:()=>{r.value=!1,c.value=null},onConfirm:p,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 At=20,ha=[{key:"channels",label:"Channels & Logs"},{key:"telegram",label:"Telegram Users"},{key:"settings",label:"Settings"}];function Kl(){const a=v({}),t=v({}),n=v(!1),l=v(!0),i=v([]),s=v(!1),r=async()=>{try{const m=await z(E.ADMIN_SETTINGS);a.value=m}catch(m){const p=m instanceof _?m:new _(0,"UNKNOWN","Unknown error");g("error",D(p.code))}finally{l.value=!1}};R(()=>{r()},[]);const c=(m,p)=>{const k=String(p);t.value={...t.value,[m]:k}},h=async()=>{n.value=!0;try{const m=Object.entries(t.value).filter(([k])=>k.startsWith("notifications.")||k.startsWith("telegram.")).map(([k,C])=>({key:k,value:C})),p=await ie(E.ADMIN_SETTINGS,{settings:m});a.value=p.settings,t.value={},g("success","Notification settings saved and applied")}catch(m){const p=m instanceof _?m:new _(0,"UNKNOWN","Unknown error");g("error",D(p.code))}finally{n.value=!1}},o=()=>{t.value={}};R(()=>(ye({id:"notifications-settings",isDirty:()=>Object.keys(t.value).filter(m=>m.startsWith("notifications.")||m.startsWith("telegram.")).length>0,save:h,discard:o}),()=>ge("notifications-settings")),[]);const u=async()=>{s.value=!0,i.value=[];try{const m=await ae(E.ADMIN_NOTIFICATIONS_TEST,{});if(i.value=m.results,m.results.length===0)g("info","No notification channels configured");else{const p=m.results.every(k=>k.success);g(p?"success":"warning",p?"All test notifications sent":"Some channels failed")}}catch(m){const p=m instanceof _?m:new _(0,"UNKNOWN","Unknown error");g("error",D(p.code))}finally{s.value=!1}},d=Object.keys(t.value).filter(m=>m.startsWith("notifications.")||m.startsWith("telegram.")).length;return l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(j,{children:[d>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[d," unsaved change",d>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(A,{variant:"ghost",size:"sm",onClick:o,children:"Discard"}),e(A,{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(N,{label:"Enabled",name:"notifications.enabled",type:"checkbox",value:Le(a.value,t.value,"notifications","enabled"),onChange:m=>c("notifications.enabled",m),description:"Enable or disable notifications globally"})}),e(N,{label:U("locale"),name:"notifications.locale",type:"select",value:$(a.value,t.value,"notifications","locale")||"en",onChange:m=>c("notifications.locale",m),options:[{label:"English",value:"en"},{label:"Korean",value:"ko"}],description:"Language for notification messages"})]}),e(Pe,{legend:"Telegram",description:"Telegram notification channel and bot configuration",children:[e("div",{class:"settings-fields-grid",children:[e(N,{label:U("telegram_bot_token"),name:"notifications.telegram_bot_token",type:"password",value:$(a.value,t.value,"notifications","telegram_bot_token"),onChange:m=>c("notifications.telegram_bot_token",m),placeholder:et(a.value,t.value,"notifications","telegram_bot_token")?"(configured)":"",description:"Bot token for Telegram notifications"}),e(N,{label:U("telegram_chat_id"),name:"notifications.telegram_chat_id",type:"text",value:$(a.value,t.value,"notifications","telegram_chat_id"),onChange:m=>c("notifications.telegram_chat_id",m),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(N,{label:"Bot Enabled",name:"telegram.enabled",type:"select",value:$(a.value,t.value,"telegram","enabled")||"false",onChange:m=>c("telegram.enabled",m),options:[{label:"Yes",value:"true"},{label:"No",value:"false"}],description:"Enable or disable the Telegram bot"}),e(N,{label:U("bot_token"),name:"telegram.bot_token",type:"password",value:$(a.value,t.value,"telegram","bot_token"),onChange:m=>c("telegram.bot_token",m),placeholder:et(a.value,t.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(N,{label:"Locale",name:"telegram.locale",type:"select",value:$(a.value,t.value,"telegram","locale")||"en",onChange:m=>c("telegram.locale",m),options:[{label:"English",value:"en"},{label:"한국어",value:"ko"}],description:"Language for Telegram bot messages"})]})]})]}),e(Pe,{legend:"Other Channels",description:"Discord, ntfy, Slack, and rate limiting",children:e("div",{class:"settings-fields-grid",children:[e(N,{label:U("discord_webhook_url"),name:"notifications.discord_webhook_url",type:"password",value:$(a.value,t.value,"notifications","discord_webhook_url"),onChange:m=>c("notifications.discord_webhook_url",m),placeholder:et(a.value,t.value,"notifications","discord_webhook_url")?"(configured)":"",description:"Webhook URL for Discord notifications"}),e(N,{label:U("ntfy_server"),name:"notifications.ntfy_server",type:"text",value:$(a.value,t.value,"notifications","ntfy_server"),onChange:m=>c("notifications.ntfy_server",m),description:"Server URL for ntfy notifications"}),e(N,{label:U("ntfy_topic"),name:"notifications.ntfy_topic",type:"text",value:$(a.value,t.value,"notifications","ntfy_topic"),onChange:m=>c("notifications.ntfy_topic",m),description:"Topic name for ntfy notifications"}),e(N,{label:"Slack Webhook URL",name:"notifications.slack_webhook_url",type:"password",value:$(a.value,t.value,"notifications","slack_webhook_url"),onChange:m=>c("notifications.slack_webhook_url",m),placeholder:et(a.value,t.value,"notifications","slack_webhook_url")?"(configured)":"",description:"Webhook URL for Slack notifications"}),e(N,{label:U("rate_limit_rpm"),name:"notifications.rate_limit_rpm",type:"number",value:Number($(a.value,t.value,"notifications","rate_limit_rpm"))||20,onChange:m=>c("notifications.rate_limit_rpm",m),min:1,max:1e3,description:"Max notifications per minute"})]})}),e("div",{class:"notif-test-section",children:[e(A,{variant:"secondary",size:"sm",onClick:u,loading:s.value,children:"Test Notification"}),i.value.length>0&&e("div",{class:"test-results",children:i.value.map(m=>e("div",{class:`test-result-item ${m.success?"test-result-success":"test-result-failure"}`,children:[e(W,{variant:m.success?"success":"danger",children:m.success?"OK":"FAIL"}),e("span",{children:m.channel}),m.error&&e("span",{style:"font-size: var(--font-size-xs); color: var(--color-danger);",children:[" - ",m.error]})]},m.channel))})]})]})]})]})}function pa(){const a=v("channels");R(()=>{const S=Z.value;S&&S.tab&&(a.value=S.tab,setTimeout(()=>{de.value=S.fieldName},100),Z.value=null)},[Z.value]);const t=v(null),n=v(!0),l=v(!1),i=v(null),s=v(null),r=v(null),c=v(!0),h=v(1),o=v(null),u=async()=>{try{const S=await z(E.ADMIN_NOTIFICATIONS_STATUS);t.value=S}catch(S){const O=S instanceof _?S:new _(0,"UNKNOWN","Unknown error");g("error",D(O.code))}finally{n.value=!1}},d=async S=>{c.value=!0;try{const O=await z(`${E.ADMIN_NOTIFICATIONS_LOG}?page=${S}&pageSize=${At}`);r.value=O}catch(O){const P=O instanceof _?O:new _(0,"UNKNOWN","Unknown error");g("error",D(P.code))}finally{c.value=!1}},m=async()=>{l.value=!0,s.value=null;try{const O=(await ae(E.ADMIN_NOTIFICATIONS_TEST,{})).results;s.value=O,O.every(q=>q.success)?g("success","Test sent successfully"):g("warning","Some channels failed")}catch(S){const O=S instanceof _?S:new _(0,"UNKNOWN","Unknown error");g("error",D(O.code))}finally{l.value=!1}},p=async S=>{i.value=S,s.value=null;try{const P=(await ae(E.ADMIN_NOTIFICATIONS_TEST,{channel:S})).results;s.value=P,P.every(Y=>Y.success)?g("success",`Test sent to ${S}`):g("warning",`${S} test failed`)}catch(O){const P=O instanceof _?O:new _(0,"UNKNOWN","Unknown error");g("error",D(P.code))}finally{i.value=null}},k=()=>{h.value>1&&(h.value-=1,d(h.value))},C=()=>{const S=r.value?Math.ceil(r.value.total/At):1;h.value<S&&(h.value+=1,d(h.value))},w=S=>{o.value=o.value?.id===S.id?null:S};R(()=>{u(),d(1);const S=setInterval(()=>d(h.value),3e4);return()=>clearInterval(S)},[]);const I=n.value&&!t.value,L=t.value?.channels.some(S=>S.enabled)??!1,H=r.value?Math.max(1,Math.ceil(r.value.total/At)):1,K=[{key:"eventType",header:"Event Type"},{key:"walletId",header:"Wallet ID",render:S=>S.walletId?S.walletId.slice(0,8)+"...":"—"},{key:"channel",header:"Channel",render:S=>e("span",{style:{textTransform:"capitalize"},children:S.channel})},{key:"status",header:"Status",render:S=>e(W,{variant:S.status==="sent"?"success":"danger",children:S.status})},{key:"createdAt",header:"Time",render:S=>re(S.createdAt)}];return e("div",{class:"page",children:[e(Je,{pageName:"Notifications",tabName:ha.find(S=>S.key===a.value)?.label??"",onPageClick:()=>{a.value="channels"}}),e(Ye,{tabs:ha,activeTab:a.value,onTabChange:S=>{a.value=S}}),a.value==="telegram"?e(Ul,{}):a.value==="settings"?e(Kl,{}):e(j,{children:[e("h2",{children:"Channel Status"}),t.value&&!t.value.enabled&&e("div",{class:"notif-disabled-banner",children:["Notifications are disabled."," ",e("a",{href:"#",onClick:S=>{S.preventDefault(),a.value="settings"},children:"Enable them in the Settings tab"})]}),I?e("div",{class:"channel-grid",children:[1,2,3].map(S=>e("div",{class:"channel-card",children:e("div",{class:"stat-skeleton"})},S))}):e("div",{class:"channel-grid",children:t.value?.channels.map(S=>e("div",{class:"channel-card",children:e("div",{class:"channel-card-header",children:[e("span",{class:"channel-card-name",children:S.name}),e("div",{class:"channel-card-actions",children:[e(W,{variant:S.enabled?"success":"neutral",children:S.enabled?"Connected":"Not Configured"}),S.enabled&&e(A,{variant:"secondary",size:"sm",onClick:()=>p(S.name),loading:i.value===S.name,children:"Test"})]})]})},S.name))}),e("div",{style:{marginTop:"var(--space-4)",marginBottom:"var(--space-6)"},children:[e(A,{onClick:m,loading:l.value,disabled:!L,children:"Test All Channels"}),s.value&&e("div",{class:"test-results",children:s.value.map(S=>e("div",{class:"test-result-item",children:[e("span",{class:S.success?"test-result-success":"test-result-failure",children:S.success?"✓":"✗"}),e("span",{style:{textTransform:"capitalize"},children:S.channel}),!S.success&&S.error&&e("span",{class:"test-result-failure",children:[" - ",S.error]})]},S.channel))})]}),e("h2",{children:"Delivery Log"}),e(Ne,{columns:K,data:r.value?.logs??[],loading:c.value,emptyMessage:"No notification logs",onRowClick:w}),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(A,{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 ",H,r.value?` (${r.value.total} total)`:""]}),e("div",{class:"pagination-buttons",children:[e(A,{variant:"secondary",size:"sm",onClick:k,disabled:h.value<=1,children:"Previous"}),e(A,{variant:"secondary",size:"sm",onClick:C,disabled:h.value>=H,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 ma=[{key:"killswitch",label:"Kill Switch"},{key:"autostop",label:"AutoStop Rules"},{key:"jwt",label:"Invalidate Sessions"}];function Bl(){const a=v(null),t=v(!0),n=v(!1),l=async()=>{try{const d=await z(E.ADMIN_KILL_SWITCH);a.value=d}catch(d){const m=d instanceof _?d:new _(0,"UNKNOWN","Unknown error");g("error",D(m.code))}finally{t.value=!1}};R(()=>{l()},[]);const i=async()=>{n.value=!0;try{await ae(E.ADMIN_KILL_SWITCH),g("success","Kill switch activated - all operations suspended"),await l()}catch(d){const m=d instanceof _?d:new _(0,"UNKNOWN","Unknown error");g("error",D(m.code))}finally{n.value=!1}},s=async()=>{n.value=!0;try{await ae(E.ADMIN_KILL_SWITCH_ESCALATE),g("success","Kill switch escalated to LOCKED"),await l()}catch(d){const m=d instanceof _?d:new _(0,"UNKNOWN","Unknown error");g("error",D(m.code))}finally{n.value=!1}},r=async()=>{n.value=!0;try{await ae(E.ADMIN_RECOVER),g("success","Kill switch recovered - operations resumed"),await l()}catch(d){const m=d instanceof _?d:new _(0,"UNKNOWN","Unknown error");g("error",D(m.code))}finally{n.value=!1}},c=a.value,h=c?.state==="ACTIVE",o=c?.state==="SUSPENDED",u=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:t.value?e("span",{children:"Loading..."}):c?e(j,{children:[e("div",{class:"ks-state-card",style:{marginBottom:"var(--space-4)"},children:[e(W,{variant:h?"success":u?"danger":"warning",children:c.state}),!h&&c.activatedAt&&e("span",{class:"ks-state-info",children:["Since ",re(c.activatedAt),c.activatedBy?` by ${c.activatedBy}`:""]})]}),e("div",{style:{display:"flex",gap:"var(--space-2)",flexWrap:"wrap"},children:[h&&e(A,{variant:"danger",onClick:i,loading:n.value,children:"Activate Kill Switch"}),o&&e(j,{children:[e(A,{variant:"primary",onClick:r,loading:n.value,children:"Recover"}),e(A,{variant:"danger",onClick:s,loading:n.value,children:"Escalate to LOCKED"})]}),u&&e(A,{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."}),u&&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 Fl(){const a=v({}),t=v({}),n=v(!1),l=v(!0),i=async()=>{try{const o=await z(E.ADMIN_SETTINGS);a.value=o}catch(o){const u=o instanceof _?o:new _(0,"UNKNOWN","Unknown error");g("error",D(u.code))}finally{l.value=!1}};R(()=>{i()},[]);const s=(o,u)=>{const d=String(u);t.value={...t.value,[o]:d}},r=async()=>{n.value=!0;try{const o=Object.entries(t.value).filter(([d])=>d.startsWith("autostop.")).map(([d,m])=>({key:d,value:m})),u=await ie(E.ADMIN_SETTINGS,{settings:o});a.value=u.settings,t.value={},g("success","AutoStop settings saved and applied")}catch(o){const u=o instanceof _?o:new _(0,"UNKNOWN","Unknown error");g("error",D(u.code))}finally{n.value=!1}},c=()=>{t.value={}};R(()=>(ye({id:"security-autostop",isDirty:()=>Object.keys(t.value).filter(o=>o.startsWith("autostop.")).length>0,save:r,discard:c}),()=>ge("security-autostop")),[]);const h=Object.keys(t.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(A,{variant:"ghost",size:"sm",onClick:c,children:"Discard"}),e(A,{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(N,{label:U("enabled"),name:"autostop.enabled",type:"checkbox",value:Le(a.value,t.value,"autostop","enabled"),onChange:o=>s("autostop.enabled",o),description:"Enable or disable AutoStop protection rules"})}),e(Pe,{legend:"Activity Detection",description:"Detects failures and unusual transaction patterns",children:e("div",{class:"settings-fields-grid",children:[e(N,{label:U("consecutive_failures_threshold"),name:"autostop.consecutive_failures_threshold",type:"number",value:Number($(a.value,t.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(N,{label:U("unusual_activity_threshold"),name:"autostop.unusual_activity_threshold",type:"number",value:Number($(a.value,t.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(N,{label:U("unusual_activity_window_sec"),name:"autostop.unusual_activity_window_sec",type:"number",value:Number($(a.value,t.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(Pe,{legend:"Idle Detection",description:"Monitors inactivity and revokes idle sessions",children:e("div",{class:"settings-fields-grid",children:[e(N,{label:U("idle_timeout_sec"),name:"autostop.idle_timeout_sec",type:"number",value:Number($(a.value,t.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(N,{label:U("idle_check_interval_sec"),name:"autostop.idle_check_interval_sec",type:"number",value:Number($(a.value,t.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 Hl(){const a=v(!1),t=v(!1),n=async()=>{t.value=!0;try{await ae(E.ADMIN_ROTATE_SECRET),a.value=!1,g("success","All session tokens invalidated. Old tokens remain valid for 5 minutes.")}catch(l){const i=l instanceof _?l:new _(0,"UNKNOWN","Unknown error");g("error",D(i.code))}finally{t.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(A,{variant:"secondary",onClick:()=>{a.value=!0},children:"Invalidate All Tokens"})})]}),e(oe,{open:a.value,title:"Invalidate All Session Tokens",onCancel:()=>{a.value=!1},onConfirm:n,confirmText:"Invalidate",confirmVariant:"primary",loading:t.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 Vl(){const a=v("killswitch");R(()=>{const n=Z.value;n&&n.tab&&(a.value=n.tab,setTimeout(()=>{de.value=n.fieldName},100),Z.value=null)},[Z.value]);const t=ma.find(n=>n.key===a.value)?.label??"";return e("div",{class:"page",children:[e(Je,{pageName:"Security",tabName:t,onPageClick:()=>{a.value="killswitch"}}),e(Ye,{tabs:ma,activeTab:a.value,onTabChange:n=>{a.value=n}}),a.value==="killswitch"&&e(Bl,{}),a.value==="autostop"&&e(Fl,{}),a.value==="jwt"&&e(Hl,{})]})}const at=[{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 zl({value:a,onChange:t,name:n}){const l=v(""),i=v(!1),s=v(null),r=v(!1),c=Ft(null),h=hn(()=>{const u=l.value.toLowerCase();return u?at.filter(d=>d.code.toLowerCase().includes(u)||d.name.toLowerCase().includes(u)||d.symbol.includes(u)):at});R(()=>{if(a==="USD"){s.value="1 USD = $1.00";return}r.value=!0,z(`${E.ADMIN_FOREX_RATES}?currencies=${a}`).then(u=>{const d=u.rates[a];s.value=d?.preview??null}).catch(()=>{s.value=null}).finally(()=>{r.value=!1})},[a]),R(()=>{const u=d=>{c.current&&!c.current.contains(d.target)&&(i.value=!1,l.value="")};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[]);const o=at.find(u=>u.code===a)??at[0];return e("div",{class:"currency-select",ref:c,children:[n&&e("input",{type:"hidden",name:n,value:a}),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:u=>{l.value=u.target.value},autoFocus:!0}),e("div",{class:"currency-select-list",children:[h.value.map(u=>e("button",{type:"button",class:`currency-select-option ${u.code===a?"currency-select-option--active":""}`,onClick:()=>{t(u.code),i.value=!1,l.value=""},children:[e("span",{class:"currency-option-code",children:u.code}),e("span",{class:"currency-option-name",children:u.name}),e("span",{class:"currency-option-symbol",children:u.symbol})]},u.code)),h.value.length===0&&e("div",{class:"currency-select-empty",children:"No currencies found"})]})]})]})}const Gl=["display.","daemon.","oracle."],ql=new Set(["security.rate_limit_global_ip_rpm"]);function It(a){return Gl.some(t=>a.startsWith(t))||ql.has(a)}function jl(){const a=v({}),t=v({}),n=v(!1),l=v(!0),i=v([]),s=v(!0),r=v(null),c=v(""),h=v(!1),o=v(!1),u=v(!1),d=v(""),m=v(!1),p=async()=>{try{const T=await z(E.ADMIN_SETTINGS);a.value=T}catch(T){const M=T instanceof _?T:new _(0,"UNKNOWN","Unknown error");g("error",D(M.code))}finally{l.value=!1}},k=async()=>{try{const T=await z(E.ADMIN_API_KEYS);i.value=T.keys}catch{}finally{s.value=!1}};R(()=>{p(),k()},[]),R(()=>{const T=Z.value;T&&(setTimeout(()=>{de.value=T.fieldName},100),Z.value=null)},[Z.value]);const C=(T,M)=>$(a.value,t.value,T,M),w=(T,M)=>{const Q=String(M);t.value={...t.value,[T]:Q}},I=async()=>{n.value=!0;try{const T=Object.entries(t.value).filter(([Q])=>It(Q)).map(([Q,be])=>({key:Q,value:be})),M=await ie(E.ADMIN_SETTINGS,{settings:T});a.value=M.settings,t.value={},g("success","Settings saved and applied")}catch(T){const M=T instanceof _?T:new _(0,"UNKNOWN","Unknown error");g("error",D(M.code))}finally{n.value=!1}},L=()=>{t.value={}};R(()=>(ye({id:"system-settings",isDirty:()=>Object.keys(t.value).filter(T=>It(T)).length>0,save:I,discard:L}),()=>ge("system-settings")),[]);const H=async T=>{h.value=!0;try{await ie(E.ADMIN_API_KEY(T),{apiKey:c.value}),g("success",`API key saved for ${T}`),r.value=null,c.value="",await k()}catch(M){const Q=M instanceof _?M:new _(0,"UNKNOWN","Unknown error");g("error",D(Q.code))}finally{h.value=!1}},K=async T=>{try{await xe(E.ADMIN_API_KEY(T)),g("success",`API key deleted for ${T}`),await k()}catch(M){const Q=M instanceof _?M:new _(0,"UNKNOWN","Unknown error");g("error",D(Q.code))}},S=async()=>{u.value=!0;try{await ae(E.ADMIN_SHUTDOWN),o.value=!1,d.value="",g("info","Shutdown initiated"),m.value=!0}catch(T){const M=T instanceof _?T:new _(0,"UNKNOWN","Unknown error");g("error",D(M.code))}finally{u.value=!1}},O=Object.keys(t.value).filter(T=>It(T)).length;function P(){return s.value?e("div",{class:"settings-loading",children:"Loading API keys..."}):i.value.length===0?null:e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"API Keys"}),e("p",{class:"settings-description",children:"Manage API keys for Action Providers"})]}),e("div",{class:"settings-category-body",children:i.value.map(T=>e("div",{class:"settings-field-row",children:[e("div",{class:"settings-field-label",children:[e("span",{children:T.providerName}),T.requiresApiKey&&!T.hasKey&&e(W,{variant:"warning",children:"Required"})]}),e("div",{class:"settings-field-value",children:r.value===T.providerName?e("div",{class:"api-key-edit-row",children:[e(N,{label:"API Key",type:"password",name:`apikey-${T.providerName}`,value:c.value,onChange:M=>{c.value=String(M)},placeholder:"Enter API key"}),e(A,{onClick:()=>H(T.providerName),loading:h.value,size:"sm",children:"Save"}),e(A,{variant:"ghost",onClick:()=>{r.value=null,c.value=""},size:"sm",children:"Cancel"})]}):e("div",{class:"api-key-display-row",children:[e("span",{class:"api-key-masked",children:T.hasKey?T.maskedKey:"Not set"}),e(A,{variant:"ghost",onClick:()=>{r.value=T.providerName,c.value=""},size:"sm",children:T.hasKey?"Change":"Set"}),T.hasKey&&e(A,{variant:"danger",onClick:()=>K(T.providerName),size:"sm",children:"Delete"})]})})]},T.providerName))})]})}function q(){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(N,{label:"Cross Validation Threshold (%)",name:"oracle.cross_validation_threshold",type:"number",value:Number(C("oracle","cross_validation_threshold"))||5,onChange:T=>w("oracle.cross_validation_threshold",T),min:0,max:100,description:"Maximum allowed deviation between price oracle sources"})}),e("div",{class:"settings-info-box",children:"Maximum allowed deviation between price sources before flagging a discrepancy. Default is 5%."})]})]})}function Y(){const T=de.value==="display.currency";return R(()=>{if(T){const M=document.querySelector('[name="display.currency"]');M&&M.closest(".form-field")?.scrollIntoView({behavior:"smooth",block:"center"});const Q=setTimeout(()=>{de.value=""},2500);return()=>clearTimeout(Q)}},[T]),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${T?" form-field--highlight":""}`,children:[e("label",{children:U("currency")}),e(zl,{name:"display.currency",value:C("display","currency")||"USD",onChange:M=>w("display.currency",M)})]})}),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 ee(){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(N,{label:U("rate_limit_global_ip_rpm"),name:"security.rate_limit_global_ip_rpm",type:"number",value:Number(C("security","rate_limit_global_ip_rpm"))||0,onChange:T=>w("security.rate_limit_global_ip_rpm",T),min:10,description:"Maximum API requests per minute from a single IP address"})})})]})}function J(){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(N,{label:U("log_level"),name:"daemon.log_level",type:"select",value:C("daemon","log_level")||"info",onChange:T=>w("daemon.log_level",T),options:[{label:"debug",value:"debug"},{label:"info",value:"info"},{label:"warn",value:"warn"},{label:"error",value:"error"}],description:"Daemon logging verbosity level"})})})]})}return e("div",{class:"page",children:[m.value&&e("div",{class:"shutdown-overlay",children:[e("h2",{children:"Daemon is shutting down..."}),e("p",{children:"You can close this tab."})]}),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(A,{variant:"ghost",size:"sm",onClick:L,children:"Discard"}),e(A,{variant:"primary",size:"sm",onClick:I,loading:n.value,children:"Save"})]})]}),l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(j,{children:[e(P,{}),e(q,{}),e(Y,{}),e(ee,{}),e(J,{})]}),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(A,{variant:"danger",onClick:()=>{o.value=!0},children:"Shutdown Daemon"})})]}),e(oe,{open:o.value,title:"Shutdown Daemon",onCancel:()=>{o.value=!1,d.value=""},onConfirm:S,confirmText:"Shutdown",confirmVariant:"danger",confirmDisabled:d.value!=="SHUTDOWN",loading:u.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:d.value,onInput:T=>{d.value=T.target.value},placeholder:"SHUTDOWN"})]})]})]})}const pe=le(window.location.hash.slice(1)||"/dashboard"),nt=le(!1);window.addEventListener("hashchange",()=>{pe.value=window.location.hash.slice(1)||"/dashboard"});const Yl={"/dashboard":"Dashboard","/wallets":"Wallets","/sessions":"Sessions","/policies":"Policies","/notifications":"Notifications","/security":"Security","/system":"System"},Jl={"/dashboard":"System overview and key metrics","/wallets":"Manage wallets, balances, and connections","/sessions":"View and manage active sessions","/policies":"Configure transaction policies and rules","/notifications":"Channel status, delivery logs, and settings","/security":"Emergency controls and automatic protection rules","/system":"API keys, display preferences, and daemon configuration"};function Xl(a){return a.startsWith("/wallets/")?"Wallet Detail":Yl[a]??"Dashboard"}function fa(a){return Jl[a]}const Zl=[{path:"/dashboard",label:"Dashboard"},{path:"/wallets",label:"Wallets"},{path:"/sessions",label:"Sessions"},{path:"/policies",label:"Policies"},{path:"/notifications",label:"Notifications"},{path:"/security",label:"Security"},{path:"/system",label:"System"}];function Ql(){const a=pe.value;return a==="/sessions"?e(cl,{}):a==="/policies"?e(Ml,{}):a==="/notifications"?e(pa,{}):a==="/telegram-users"?(window.location.hash="#/notifications",e(pa,{})):a==="/settings"?(window.location.hash="#/dashboard",e(la,{})):a==="/walletconnect"?(window.location.hash="#/wallets",e(ra,{})):a==="/security"?e(Vl,{}):a==="/system"?e(jl,{}):a.startsWith("/wallets")?e(ra,{}):e(la,{})}function ei(){return R(()=>{const a=t=>{(t.metaKey||t.ctrlKey)&&t.key==="k"&&(t.preventDefault(),nt.value=!nt.value)};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[]),e("div",{class:"layout",children:[e("aside",{class:"sidebar",children:[e("div",{class:"sidebar-brand",children:"WAIaaS"}),e("nav",{class:"sidebar-nav",children:Zl.map(a=>{const t=a.path==="/wallets"?pe.value.startsWith("/wallets"):pe.value===a.path;return e("a",{href:`#${a.path}`,class:`sidebar-link ${t?"active":""}`,onClick:n=>{Ha.value&&(n.preventDefault(),Va({type:"nav",execute:()=>{window.location.hash=`#${a.path}`}}))},children:a.label})})})]}),e("main",{class:"main",children:[e("header",{class:"header",children:[e("div",{class:"header-left",children:[e("h1",{class:"header-title",children:Xl(pe.value)}),fa(pe.value)&&e("p",{class:"header-subtitle",children:fa(pe.value)})]}),e("div",{class:"header-actions",children:[e("button",{class:"btn-search",onClick:()=>{nt.value=!0},title:"Search settings (Ctrl+K)",children:"🔍"}),e("button",{class:"btn-logout",onClick:()=>zt(),children:"Logout"})]})]}),e("div",{class:"content",children:e(Ql,{})})]}),e(En,{open:nt}),e(Dn,{})]})}const lt={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 ti(){return e("div",{style:lt.overlay,children:e("div",{style:lt.content,children:[e("h1",{style:lt.title,children:"Daemon Shutting Down"}),e("p",{style:lt.message,children:"The daemon is shutting down. Please wait or restart."})]})})}function ai(){return _n.value?e(ti,{}):fn.value?e(j,{children:[e(ei,{}),e(Hn,{})]}):e(Sn,{})}nn(e(ai,{}),document.getElementById("app"));
|