skimpyclaw 0.3.4 → 0.3.5
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/__tests__/api.test.js +19 -0
- package/dist/__tests__/doctor.runner.test.js +5 -1
- package/dist/__tests__/package-manager-detection.test.d.ts +1 -0
- package/dist/__tests__/package-manager-detection.test.js +172 -0
- package/dist/api.js +27 -0
- package/dist/cli.js +8 -0
- package/dist/code-agents/executor.d.ts +16 -0
- package/dist/code-agents/executor.js +77 -3
- package/dist/code-agents/utils.js +7 -3
- package/dist/dashboard/assets/index-UVAjSXCG.js +107 -0
- package/dist/dashboard/index.html +1 -1
- package/dist/doctor/checks.d.ts +1 -0
- package/dist/doctor/checks.js +21 -5
- package/dist/doctor/runner.js +2 -1
- package/dist/setup.js +42 -0
- package/dist/tools/definitions.js +2 -2
- package/package.json +22 -26
- package/sandbox/Dockerfile +40 -0
- package/dist/dashboard/assets/index-CkonC7Cd.js +0 -65
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
var Ya=Object.defineProperty;var Ka=(e,t,r)=>t in e?Ya(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Z=(e,t,r)=>Ka(e,typeof t!="symbol"?t+"":t,r);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const s of l.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&i(s)}).observe(document,{childList:!0,subtree:!0});function r(a){const l={};return a.integrity&&(l.integrity=a.integrity),a.referrerPolicy&&(l.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?l.credentials="include":a.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function i(a){if(a.ep)return;a.ep=!0;const l=r(a);fetch(a.href,l)}})();var Et,N,Hi,Be,Hr,Bi,Fi,Wi,Qn,Rn,Mn,Ui,Vt={},Zt=[],Ja=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Lt=Array.isArray;function Se(e,t){for(var r in t)e[r]=t[r];return e}function er(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Re(e,t,r){var i,a,l,s={};for(l in t)l=="key"?i=t[l]:l=="ref"?a=t[l]:s[l]=t[l];if(arguments.length>2&&(s.children=arguments.length>3?Et.call(arguments,2):r),typeof e=="function"&&e.defaultProps!=null)for(l in e.defaultProps)s[l]===void 0&&(s[l]=e.defaultProps[l]);return Ct(e,s,i,a,null)}function Ct(e,t,r,i,a){var l={type:e,props:t,key:r,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:a??++Hi,__i:-1,__u:0};return a==null&&N.vnode!=null&&N.vnode(l),l}function Xa(){return{current:null}}function ae(e){return e.children}function Te(e,t){this.props=e,this.context=t}function tt(e,t){if(t==null)return e.__?tt(e.__,e.__i+1):null;for(var r;t<e.__k.length;t++)if((r=e.__k[t])!=null&&r.__e!=null)return r.__e;return typeof e.type=="function"?tt(e):null}function Qa(e){if(e.__P&&e.__d){var t=e.__v,r=t.__e,i=[],a=[],l=Se({},t);l.__v=t.__v+1,N.vnode&&N.vnode(l),tr(e.__P,l,t,e.__n,e.__P.namespaceURI,32&t.__u?[r]:null,i,r??tt(t),!!(32&t.__u),a),l.__v=t.__v,l.__.__k[l.__i]=l,Vi(i,l,a),t.__e=t.__=null,l.__e!=r&&ji(l)}}function ji(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),ji(e)}function In(e){(!e.__d&&(e.__d=!0)&&Be.push(e)&&!Yt.__r++||Hr!=N.debounceRendering)&&((Hr=N.debounceRendering)||Bi)(Yt)}function Yt(){for(var e,t=1;Be.length;)Be.length>t&&Be.sort(Fi),e=Be.shift(),t=Be.length,Qa(e);Yt.__r=0}function Gi(e,t,r,i,a,l,s,o,d,c,f){var h,y,p,u,_,w,k,g=i&&i.__k||Zt,v=t.length;for(d=el(r,t,g,d,v),h=0;h<v;h++)(p=r.__k[h])!=null&&(y=p.__i!=-1&&g[p.__i]||Vt,p.__i=h,w=tr(e,p,y,a,l,s,o,d,c,f),u=p.__e,p.ref&&y.ref!=p.ref&&(y.ref&&nr(y.ref,null,p),f.push(p.ref,p.__c||u,p)),_==null&&u!=null&&(_=u),(k=!!(4&p.__u))||y.__k===p.__k?d=qi(p,d,e,k):typeof p.type=="function"&&w!==void 0?d=w:u&&(d=u.nextSibling),p.__u&=-7);return r.__e=_,d}function el(e,t,r,i,a){var l,s,o,d,c,f=r.length,h=f,y=0;for(e.__k=new Array(a),l=0;l<a;l++)(s=t[l])!=null&&typeof s!="boolean"&&typeof s!="function"?(typeof s=="string"||typeof s=="number"||typeof s=="bigint"||s.constructor==String?s=e.__k[l]=Ct(null,s,null,null,null):Lt(s)?s=e.__k[l]=Ct(ae,{children:s},null,null,null):s.constructor===void 0&&s.__b>0?s=e.__k[l]=Ct(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):e.__k[l]=s,d=l+y,s.__=e,s.__b=e.__b+1,o=null,(c=s.__i=tl(s,r,d,h))!=-1&&(h--,(o=r[c])&&(o.__u|=2)),o==null||o.__v==null?(c==-1&&(a>f?y--:a<f&&y++),typeof s.type!="function"&&(s.__u|=4)):c!=d&&(c==d-1?y--:c==d+1?y++:(c>d?y--:y++,s.__u|=4))):e.__k[l]=null;if(h)for(l=0;l<f;l++)(o=r[l])!=null&&!(2&o.__u)&&(o.__e==i&&(i=tt(o)),Yi(o,o));return i}function qi(e,t,r,i){var a,l;if(typeof e.type=="function"){for(a=e.__k,l=0;a&&l<a.length;l++)a[l]&&(a[l].__=e,t=qi(a[l],t,r,i));return t}e.__e!=t&&(i&&(t&&e.type&&!t.parentNode&&(t=tt(e)),r.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function ze(e,t){return t=t||[],e==null||typeof e=="boolean"||(Lt(e)?e.some(function(r){ze(r,t)}):t.push(e)),t}function tl(e,t,r,i){var a,l,s,o=e.key,d=e.type,c=t[r],f=c!=null&&(2&c.__u)==0;if(c===null&&o==null||f&&o==c.key&&d==c.type)return r;if(i>(f?1:0)){for(a=r-1,l=r+1;a>=0||l<t.length;)if((c=t[s=a>=0?a--:l++])!=null&&!(2&c.__u)&&o==c.key&&d==c.type)return s}return-1}function Br(e,t,r){t[0]=="-"?e.setProperty(t,r??""):e[t]=r==null?"":typeof r!="number"||Ja.test(t)?r:r+"px"}function Ht(e,t,r,i,a){var l,s;e:if(t=="style")if(typeof r=="string")e.style.cssText=r;else{if(typeof i=="string"&&(e.style.cssText=i=""),i)for(t in i)r&&t in r||Br(e.style,t,"");if(r)for(t in r)i&&r[t]==i[t]||Br(e.style,t,r[t])}else if(t[0]=="o"&&t[1]=="n")l=t!=(t=t.replace(Wi,"$1")),s=t.toLowerCase(),t=s in e||t=="onFocusOut"||t=="onFocusIn"?s.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+l]=r,r?i?r.u=i.u:(r.u=Qn,e.addEventListener(t,l?Mn:Rn,l)):e.removeEventListener(t,l?Mn:Rn,l);else{if(a=="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 e)try{e[t]=r??"";break e}catch{}typeof r=="function"||(r==null||r===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&r==1?"":r))}}function Fr(e){return function(t){if(this.l){var r=this.l[t.type+e];if(t.t==null)t.t=Qn++;else if(t.t<r.u)return;return r(N.event?N.event(t):t)}}}function tr(e,t,r,i,a,l,s,o,d,c){var f,h,y,p,u,_,w,k,g,v,E,z,F,D,P,S=t.type;if(t.constructor!==void 0)return null;128&r.__u&&(d=!!(32&r.__u),l=[o=t.__e=r.__e]),(f=N.__b)&&f(t);e:if(typeof S=="function")try{if(k=t.props,g="prototype"in S&&S.prototype.render,v=(f=S.contextType)&&i[f.__c],E=f?v?v.props.value:f.__:i,r.__c?w=(h=t.__c=r.__c).__=h.__E:(g?t.__c=h=new S(k,E):(t.__c=h=new Te(k,E),h.constructor=S,h.render=rl),v&&v.sub(h),h.state||(h.state={}),h.__n=i,y=h.__d=!0,h.__h=[],h._sb=[]),g&&h.__s==null&&(h.__s=h.state),g&&S.getDerivedStateFromProps!=null&&(h.__s==h.state&&(h.__s=Se({},h.__s)),Se(h.__s,S.getDerivedStateFromProps(k,h.__s))),p=h.props,u=h.state,h.__v=t,y)g&&S.getDerivedStateFromProps==null&&h.componentWillMount!=null&&h.componentWillMount(),g&&h.componentDidMount!=null&&h.__h.push(h.componentDidMount);else{if(g&&S.getDerivedStateFromProps==null&&k!==p&&h.componentWillReceiveProps!=null&&h.componentWillReceiveProps(k,E),t.__v==r.__v||!h.__e&&h.shouldComponentUpdate!=null&&h.shouldComponentUpdate(k,h.__s,E)===!1){t.__v!=r.__v&&(h.props=k,h.state=h.__s,h.__d=!1),t.__e=r.__e,t.__k=r.__k,t.__k.some(function(b){b&&(b.__=t)}),Zt.push.apply(h.__h,h._sb),h._sb=[],h.__h.length&&s.push(h);break e}h.componentWillUpdate!=null&&h.componentWillUpdate(k,h.__s,E),g&&h.componentDidUpdate!=null&&h.__h.push(function(){h.componentDidUpdate(p,u,_)})}if(h.context=E,h.props=k,h.__P=e,h.__e=!1,z=N.__r,F=0,g)h.state=h.__s,h.__d=!1,z&&z(t),f=h.render(h.props,h.state,h.context),Zt.push.apply(h.__h,h._sb),h._sb=[];else do h.__d=!1,z&&z(t),f=h.render(h.props,h.state,h.context),h.state=h.__s;while(h.__d&&++F<25);h.state=h.__s,h.getChildContext!=null&&(i=Se(Se({},i),h.getChildContext())),g&&!y&&h.getSnapshotBeforeUpdate!=null&&(_=h.getSnapshotBeforeUpdate(p,u)),D=f!=null&&f.type===ae&&f.key==null?Zi(f.props.children):f,o=Gi(e,Lt(D)?D:[D],t,r,i,a,l,s,o,d,c),h.base=t.__e,t.__u&=-161,h.__h.length&&s.push(h),w&&(h.__E=h.__=null)}catch(b){if(t.__v=null,d||l!=null)if(b.then){for(t.__u|=d?160:128;o&&o.nodeType==8&&o.nextSibling;)o=o.nextSibling;l[l.indexOf(o)]=null,t.__e=o}else{for(P=l.length;P--;)er(l[P]);Dn(t)}else t.__e=r.__e,t.__k=r.__k,b.then||Dn(t);N.__e(b,t,r)}else l==null&&t.__v==r.__v?(t.__k=r.__k,t.__e=r.__e):o=t.__e=nl(r.__e,t,r,i,a,l,s,d,c);return(f=N.diffed)&&f(t),128&t.__u?void 0:o}function Dn(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(Dn))}function Vi(e,t,r){for(var i=0;i<r.length;i++)nr(r[i],r[++i],r[++i]);N.__c&&N.__c(t,e),e.some(function(a){try{e=a.__h,a.__h=[],e.some(function(l){l.call(a)})}catch(l){N.__e(l,a.__v)}})}function Zi(e){return typeof e!="object"||e==null||e.__b>0?e:Lt(e)?e.map(Zi):Se({},e)}function nl(e,t,r,i,a,l,s,o,d){var c,f,h,y,p,u,_,w=r.props||Vt,k=t.props,g=t.type;if(g=="svg"?a="http://www.w3.org/2000/svg":g=="math"?a="http://www.w3.org/1998/Math/MathML":a||(a="http://www.w3.org/1999/xhtml"),l!=null){for(c=0;c<l.length;c++)if((p=l[c])&&"setAttribute"in p==!!g&&(g?p.localName==g:p.nodeType==3)){e=p,l[c]=null;break}}if(e==null){if(g==null)return document.createTextNode(k);e=document.createElementNS(a,g,k.is&&k),o&&(N.__m&&N.__m(t,l),o=!1),l=null}if(g==null)w===k||o&&e.data==k||(e.data=k);else{if(l=l&&Et.call(e.childNodes),!o&&l!=null)for(w={},c=0;c<e.attributes.length;c++)w[(p=e.attributes[c]).name]=p.value;for(c in w)p=w[c],c=="dangerouslySetInnerHTML"?h=p:c=="children"||c in k||c=="value"&&"defaultValue"in k||c=="checked"&&"defaultChecked"in k||Ht(e,c,null,p,a);for(c in k)p=k[c],c=="children"?y=p:c=="dangerouslySetInnerHTML"?f=p:c=="value"?u=p:c=="checked"?_=p:o&&typeof p!="function"||w[c]===p||Ht(e,c,p,w[c],a);if(f)o||h&&(f.__html==h.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(h&&(e.innerHTML=""),Gi(t.type=="template"?e.content:e,Lt(y)?y:[y],t,r,i,g=="foreignObject"?"http://www.w3.org/1999/xhtml":a,l,s,l?l[0]:r.__k&&tt(r,0),o,d),l!=null)for(c=l.length;c--;)er(l[c]);o||(c="value",g=="progress"&&u==null?e.removeAttribute("value"):u!=null&&(u!==e[c]||g=="progress"&&!u||g=="option"&&u!=w[c])&&Ht(e,c,u,w[c],a),c="checked",_!=null&&_!=e[c]&&Ht(e,c,_,w[c],a))}return e}function nr(e,t,r){try{if(typeof e=="function"){var i=typeof e.__u=="function";i&&e.__u(),i&&t==null||(e.__u=e(t))}else e.current=t}catch(a){N.__e(a,r)}}function Yi(e,t,r){var i,a;if(N.unmount&&N.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||nr(i,null,t)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(l){N.__e(l,t)}i.base=i.__P=null}if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&Yi(i[a],t,r||typeof e.type!="function");r||er(e.__e),e.__c=e.__=e.__e=void 0}function rl(e,t,r){return this.constructor(e,r)}function nt(e,t,r){var i,a,l,s;t==document&&(t=document.documentElement),N.__&&N.__(e,t),a=(i=typeof r=="function")?null:r&&r.__k||t.__k,l=[],s=[],tr(t,e=(!i&&r||t).__k=Re(ae,null,[e]),a||Vt,Vt,t.namespaceURI,!i&&r?[r]:a?null:t.firstChild?Et.call(t.childNodes):null,l,!i&&r?r:a?a.__e:t.firstChild,i,s),Vi(l,e,s)}function Ki(e,t){nt(e,t,Ki)}function il(e,t,r){var i,a,l,s,o=Se({},e.props);for(l in e.type&&e.type.defaultProps&&(s=e.type.defaultProps),t)l=="key"?i=t[l]:l=="ref"?a=t[l]:o[l]=t[l]===void 0&&s!=null?s[l]:t[l];return arguments.length>2&&(o.children=arguments.length>3?Et.call(arguments,2):r),Ct(e.type,o,i||e.key,a||e.ref,null)}function al(e){function t(r){var i,a;return this.getChildContext||(i=new Set,(a={})[t.__c]=this,this.getChildContext=function(){return a},this.componentWillUnmount=function(){i=null},this.shouldComponentUpdate=function(l){this.props.value!=l.value&&i.forEach(function(s){s.__e=!0,In(s)})},this.sub=function(l){i.add(l);var s=l.componentWillUnmount;l.componentWillUnmount=function(){i&&i.delete(l),s&&s.call(l)}}),r.children}return t.__c="__cC"+Ui++,t.__=e,t.Provider=t.__l=(t.Consumer=function(r,i){return r.children(i)}).contextType=t,t}Et=Zt.slice,N={__e:function(e,t,r,i){for(var a,l,s;t=t.__;)if((a=t.__c)&&!a.__)try{if((l=a.constructor)&&l.getDerivedStateFromError!=null&&(a.setState(l.getDerivedStateFromError(e)),s=a.__d),a.componentDidCatch!=null&&(a.componentDidCatch(e,i||{}),s=a.__d),s)return a.__E=a}catch(o){e=o}throw e}},Hi=0,Te.prototype.setState=function(e,t){var r;r=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Se({},this.state),typeof e=="function"&&(e=e(Se({},r),this.props)),e&&Se(r,e),e!=null&&this.__v&&(t&&this._sb.push(t),In(this))},Te.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),In(this))},Te.prototype.render=ae,Be=[],Bi=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Fi=function(e,t){return e.__v.__b-t.__v.__b},Yt.__r=0,Wi=/(PointerCapture)$|Capture$/i,Qn=0,Rn=Fr(!1),Mn=Fr(!0),Ui=0;var ll=0;function n(e,t,r,i,a,l){t||(t={});var s,o,d=t;if("ref"in d)for(o in d={},t)o=="ref"?s=t[o]:d[o]=t[o];var c={type:e,props:d,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ll,__i:-1,__u:0,__source:a,__self:l};if(typeof e=="function"&&(s=e.defaultProps))for(o in s)d[o]===void 0&&(d[o]=s[o]);return N.vnode&&N.vnode(c),c}var Ie,K,xn,Wr,rt=0,Ji=[],Q=N,Ur=Q.__b,jr=Q.__r,Gr=Q.diffed,qr=Q.__c,Vr=Q.unmount,Zr=Q.__;function st(e,t){Q.__h&&Q.__h(K,e,rt||t),rt=0;var r=K.__H||(K.__H={__:[],__h:[]});return e>=r.__.length&&r.__.push({}),r.__[e]}function x(e){return rt=1,rr(na,e)}function rr(e,t,r){var i=st(Ie++,2);if(i.t=e,!i.__c&&(i.__=[r?r(t):na(void 0,t),function(o){var d=i.__N?i.__N[0]:i.__[0],c=i.t(d,o);d!==c&&(i.__N=[c,i.__[1]],i.__c.setState({}))}],i.__c=K,!K.__f)){var a=function(o,d,c){if(!i.__c.__H)return!0;var f=i.__c.__H.__.filter(function(y){return y.__c});if(f.every(function(y){return!y.__N}))return!l||l.call(this,o,d,c);var h=i.__c.props!==o;return f.some(function(y){if(y.__N){var p=y.__[0];y.__=y.__N,y.__N=void 0,p!==y.__[0]&&(h=!0)}}),l&&l.call(this,o,d,c)||h};K.__f=!0;var l=K.shouldComponentUpdate,s=K.componentWillUpdate;K.componentWillUpdate=function(o,d,c){if(this.__e){var f=l;l=void 0,a(o,d,c),l=f}s&&s.call(this,o,d,c)},K.shouldComponentUpdate=a}return i.__N||i.__}function q(e,t){var r=st(Ie++,3);!Q.__s&&ir(r.__H,t)&&(r.__=e,r.u=t,K.__H.__h.push(r))}function $t(e,t){var r=st(Ie++,4);!Q.__s&&ir(r.__H,t)&&(r.__=e,r.u=t,K.__h.push(r))}function Le(e){return rt=5,$e(function(){return{current:e}},[])}function Xi(e,t,r){rt=6,$t(function(){if(typeof e=="function"){var i=e(t());return function(){e(null),i&&typeof i=="function"&&i()}}if(e)return e.current=t(),function(){return e.current=null}},r==null?r:r.concat(e))}function $e(e,t){var r=st(Ie++,7);return ir(r.__H,t)&&(r.__=e(),r.__H=t,r.__h=e),r.__}function an(e,t){return rt=8,$e(function(){return e},t)}function Qi(e){var t=K.context[e.__c],r=st(Ie++,9);return r.c=e,t?(r.__==null&&(r.__=!0,t.sub(K)),t.props.value):e.__}function ea(e,t){Q.useDebugValue&&Q.useDebugValue(t?t(e):e)}function ta(){var e=st(Ie++,11);if(!e.__){for(var t=K.__v;t!==null&&!t.__m&&t.__!==null;)t=t.__;var r=t.__m||(t.__m=[0,0]);e.__="P"+r[0]+"-"+r[1]++}return e.__}function sl(){for(var e;e=Ji.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(jt),t.__h.some(Pn),t.__h=[]}catch(r){t.__h=[],Q.__e(r,e.__v)}}}Q.__b=function(e){K=null,Ur&&Ur(e)},Q.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Zr&&Zr(e,t)},Q.__r=function(e){jr&&jr(e),Ie=0;var t=(K=e.__c).__H;t&&(xn===K?(t.__h=[],K.__h=[],t.__.some(function(r){r.__N&&(r.__=r.__N),r.u=r.__N=void 0})):(t.__h.some(jt),t.__h.some(Pn),t.__h=[],Ie=0)),xn=K},Q.diffed=function(e){Gr&&Gr(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Ji.push(t)!==1&&Wr===Q.requestAnimationFrame||((Wr=Q.requestAnimationFrame)||ol)(sl)),t.__H.__.some(function(r){r.u&&(r.__H=r.u),r.u=void 0})),xn=K=null},Q.__c=function(e,t){t.some(function(r){try{r.__h.some(jt),r.__h=r.__h.filter(function(i){return!i.__||Pn(i)})}catch(i){t.some(function(a){a.__h&&(a.__h=[])}),t=[],Q.__e(i,r.__v)}}),qr&&qr(e,t)},Q.unmount=function(e){Vr&&Vr(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.some(function(i){try{jt(i)}catch(a){t=a}}),r.__H=void 0,t&&Q.__e(t,r.__v))};var Yr=typeof requestAnimationFrame=="function";function ol(e){var t,r=function(){clearTimeout(i),Yr&&cancelAnimationFrame(t),setTimeout(e)},i=setTimeout(r,35);Yr&&(t=requestAnimationFrame(r))}function jt(e){var t=K,r=e.__c;typeof r=="function"&&(e.__c=void 0,r()),K=t}function Pn(e){var t=K;e.__c=e.__(),K=t}function ir(e,t){return!e||e.length!==t.length||t.some(function(r,i){return r!==e[i]})}function na(e,t){return typeof t=="function"?t(e):t}function ra(e,t){for(var r in t)e[r]=t[r];return e}function On(e,t){for(var r in e)if(r!=="__source"&&!(r in t))return!0;for(var i in t)if(i!=="__source"&&e[i]!==t[i])return!0;return!1}function ia(e,t){var r=t(),i=x({t:{__:r,u:t}}),a=i[0].t,l=i[1];return $t(function(){a.__=r,a.u=t,wn(a)&&l({t:a})},[e,r,t]),q(function(){return wn(a)&&l({t:a}),e(function(){wn(a)&&l({t:a})})},[e]),r}function wn(e){try{return!((t=e.__)===(r=e.u())&&(t!==0||1/t==1/r)||t!=t&&r!=r)}catch{return!0}var t,r}function aa(e){e()}function la(e){return e}function sa(){return[!1,aa]}var oa=$t;function Nn(e,t){this.props=e,this.context=t}function cl(e,t){function r(a){var l=this.props.ref,s=l==a.ref;return!s&&l&&(l.call?l(null):l.current=null),t?!t(this.props,a)||!s:On(this.props,a)}function i(a){return this.shouldComponentUpdate=r,Re(e,a)}return i.displayName="Memo("+(e.displayName||e.name)+")",i.prototype.isReactComponent=!0,i.__f=!0,i.type=e,i}(Nn.prototype=new Te).isPureReactComponent=!0,Nn.prototype.shouldComponentUpdate=function(e,t){return On(this.props,e)||On(this.state,t)};var Kr=N.__b;N.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Kr&&Kr(e)};var dl=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function ul(e){function t(r){var i=ra({},r);return delete i.ref,e(i,r.ref||null)}return t.$$typeof=dl,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(e.displayName||e.name)+")",t}var Jr=function(e,t){return e==null?null:ze(ze(e).map(t))},hl={map:Jr,forEach:Jr,count:function(e){return e?ze(e).length:0},only:function(e){var t=ze(e);if(t.length!==1)throw"Children.only";return t[0]},toArray:ze},pl=N.__e;N.__e=function(e,t,r,i){if(e.then){for(var a,l=t;l=l.__;)if((a=l.__c)&&a.__c)return t.__e==null&&(t.__e=r.__e,t.__k=r.__k),a.__c(e,t)}pl(e,t,r,i)};var Xr=N.unmount;function ca(e,t,r){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(i){typeof i.__c=="function"&&i.__c()}),e.__c.__H=null),(e=ra({},e)).__c!=null&&(e.__c.__P===r&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(i){return ca(i,t,r)})),e}function da(e,t,r){return e&&r&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(i){return da(i,t,r)}),e.__c&&e.__c.__P===t&&(e.__e&&r.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=r)),e}function Gt(){this.__u=0,this.o=null,this.__b=null}function ua(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function fl(e){var t,r,i,a=null;function l(s){if(t||(t=e()).then(function(o){o&&(a=o.default||o),i=!0},function(o){r=o,i=!0}),r)throw r;if(!i)throw t;return a?Re(a,s):null}return l.displayName="Lazy",l.__f=!0,l}function xt(){this.i=null,this.l=null}N.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Xr&&Xr(e)},(Gt.prototype=new Te).__c=function(e,t){var r=t.__c,i=this;i.o==null&&(i.o=[]),i.o.push(r);var a=ua(i.__v),l=!1,s=function(){l||i.__z||(l=!0,r.__R=null,a?a(d):d())};r.__R=s;var o=r.__P;r.__P=null;var d=function(){if(!--i.__u){if(i.state.__a){var c=i.state.__a;i.__v.__k[0]=da(c,c.__c.__P,c.__c.__O)}var f;for(i.setState({__a:i.__b=null});f=i.o.pop();)f.__P=o,f.forceUpdate()}};i.__u++||32&t.__u||i.setState({__a:i.__b=i.__v.__k[0]}),e.then(s,s)},Gt.prototype.componentWillUnmount=function(){this.o=[]},Gt.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var r=document.createElement("div"),i=this.__v.__k[0].__c;this.__v.__k[0]=ca(this.__b,r,i.__O=i.__P)}this.__b=null}var a=t.__a&&Re(ae,null,e.fallback);return a&&(a.__u&=-33),[Re(ae,null,t.__a?null:e.children),a]};var Qr=function(e,t,r){if(++r[1]===r[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!=="t"||!e.l.size))for(r=e.i;r;){for(;r.length>3;)r.pop()();if(r[1]<r[0])break;e.i=r=r[2]}};function ml(e){return this.getChildContext=function(){return e.context},e.children}function gl(e){var t=this,r=e.h;if(t.componentWillUnmount=function(){nt(null,t.v),t.v=null,t.h=null},t.h&&t.h!==r&&t.componentWillUnmount(),!t.v){for(var i=t.__v;i!==null&&!i.__m&&i.__!==null;)i=i.__;t.h=r,t.v={nodeType:1,parentNode:r,childNodes:[],__k:{__m:i.__m},contains:function(){return!0},namespaceURI:r.namespaceURI,insertBefore:function(a,l){this.childNodes.push(a),t.h.insertBefore(a,l)},removeChild:function(a){this.childNodes.splice(this.childNodes.indexOf(a)>>>1,1),t.h.removeChild(a)}}}nt(Re(ml,{context:t.context},e.__v),t.v)}function yl(e,t){var r=Re(gl,{__v:e,h:t});return r.containerInfo=t,r}(xt.prototype=new Te).__a=function(e){var t=this,r=ua(t.__v),i=t.l.get(e);return i[0]++,function(a){var l=function(){t.props.revealOrder?(i.push(a),Qr(t,e,i)):a()};r?r(l):l()}},xt.prototype.render=function(e){this.i=null,this.l=new Map;var t=ze(e.children);e.revealOrder&&e.revealOrder[0]==="b"&&t.reverse();for(var r=t.length;r--;)this.l.set(t[r],this.i=[1,0,this.i]);return e.children},xt.prototype.componentDidUpdate=xt.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,r){Qr(e,r,t)})};var ha=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,vl=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,_l=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,bl=/[A-Z0-9]/g,kl=typeof document<"u",xl=function(e){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(e)};function wl(e,t,r){return t.__k==null&&(t.textContent=""),nt(e,t),typeof r=="function"&&r(),e?e.__c:null}function Sl(e,t,r){return Ki(e,t),typeof r=="function"&&r(),e?e.__c:null}Te.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(Te.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var ei=N.event;function Tl(){}function Cl(){return this.cancelBubble}function Al(){return this.defaultPrevented}N.event=function(e){return ei&&(e=ei(e)),e.persist=Tl,e.isPropagationStopped=Cl,e.isDefaultPrevented=Al,e.nativeEvent=e};var ar,El={enumerable:!1,configurable:!0,get:function(){return this.class}},ti=N.vnode;N.vnode=function(e){typeof e.type=="string"&&function(t){var r=t.props,i=t.type,a={},l=i.indexOf("-")===-1;for(var s in r){var o=r[s];if(!(s==="value"&&"defaultValue"in r&&o==null||kl&&s==="children"&&i==="noscript"||s==="class"||s==="className")){var d=s.toLowerCase();s==="defaultValue"&&"value"in r&&r.value==null?s="value":s==="download"&&o===!0?o="":d==="translate"&&o==="no"?o=!1:d[0]==="o"&&d[1]==="n"?d==="ondoubleclick"?s="ondblclick":d!=="onchange"||i!=="input"&&i!=="textarea"||xl(r.type)?d==="onfocus"?s="onfocusin":d==="onblur"?s="onfocusout":_l.test(s)&&(s=d):d=s="oninput":l&&vl.test(s)?s=s.replace(bl,"-$&").toLowerCase():o===null&&(o=void 0),d==="oninput"&&a[s=d]&&(s="oninputCapture"),a[s]=o}}i=="select"&&a.multiple&&Array.isArray(a.value)&&(a.value=ze(r.children).forEach(function(c){c.props.selected=a.value.indexOf(c.props.value)!=-1})),i=="select"&&a.defaultValue!=null&&(a.value=ze(r.children).forEach(function(c){c.props.selected=a.multiple?a.defaultValue.indexOf(c.props.value)!=-1:a.defaultValue==c.props.value})),r.class&&!r.className?(a.class=r.class,Object.defineProperty(a,"className",El)):r.className&&(a.class=a.className=r.className),t.props=a}(e),e.$$typeof=ha,ti&&ti(e)};var ni=N.__r;N.__r=function(e){ni&&ni(e),ar=e.__c};var ri=N.diffed;N.diffed=function(e){ri&&ri(e);var t=e.props,r=e.__e;r!=null&&e.type==="textarea"&&"value"in t&&t.value!==r.value&&(r.value=t.value==null?"":t.value),ar=null};var Ll={ReactCurrentDispatcher:{current:{readContext:function(e){return ar.__n[e.__c].props.value},useCallback:an,useContext:Qi,useDebugValue:ea,useDeferredValue:la,useEffect:q,useId:ta,useImperativeHandle:Xi,useInsertionEffect:oa,useLayoutEffect:$t,useMemo:$e,useReducer:rr,useRef:Le,useState:x,useSyncExternalStore:ia,useTransition:sa}}};function $l(e){return Re.bind(null,e)}function ln(e){return!!e&&e.$$typeof===ha}function zl(e){return ln(e)&&e.type===ae}function Rl(e){return!!e&&typeof e.displayName=="string"&&e.displayName.startsWith("Memo(")}function Ml(e){return ln(e)?il.apply(null,arguments):e}function Il(e){return!!e.__k&&(nt(null,e),!0)}function Dl(e){return e&&(e.base||e.nodeType===1&&e)||null}var Pl=function(e,t){return e(t)},Ol=function(e,t){return e(t)},Nl=ae,Hl=ln,Ue={useState:x,useId:ta,useReducer:rr,useEffect:q,useLayoutEffect:$t,useInsertionEffect:oa,useTransition:sa,useDeferredValue:la,useSyncExternalStore:ia,startTransition:aa,useRef:Le,useImperativeHandle:Xi,useMemo:$e,useCallback:an,useContext:Qi,useDebugValue:ea,version:"18.3.1",Children:hl,render:wl,hydrate:Sl,unmountComponentAtNode:Il,createPortal:yl,createElement:Re,createContext:al,createFactory:$l,cloneElement:Ml,createRef:Xa,Fragment:ae,isValidElement:ln,isElement:Hl,isFragment:zl,isMemo:Rl,findDOMNode:Dl,Component:Te,PureComponent:Nn,memo:cl,forwardRef:ul,flushSync:Ol,unstable_batchedUpdates:Pl,StrictMode:Nl,Suspense:Gt,SuspenseList:xt,lazy:fl,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Ll},pa={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},ii=Ue.createContext&&Ue.createContext(pa),Bl=["attr","size","title"];function Fl(e,t){if(e==null)return{};var r=Wl(e,t),i,a;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a<l.length;a++)i=l[a],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(r[i]=e[i])}return r}function Wl(e,t){if(e==null)return{};var r={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){if(t.indexOf(i)>=0)continue;r[i]=e[i]}return r}function Kt(){return Kt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},Kt.apply(this,arguments)}function ai(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,i)}return r}function Jt(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?ai(Object(r),!0).forEach(function(i){Ul(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ai(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function Ul(e,t,r){return t=jl(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function jl(e){var t=Gl(e,"string");return typeof t=="symbol"?t:t+""}function Gl(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function fa(e){return e&&e.map((t,r)=>Ue.createElement(t.tag,Jt({key:r},t.attr),fa(t.child)))}function B(e){return t=>Ue.createElement(ql,Kt({attr:Jt({},e.attr)},t),fa(e.child))}function ql(e){var t=r=>{var{attr:i,size:a,title:l}=e,s=Fl(e,Bl),o=a||r.size||"1em",d;return r.className&&(d=r.className),e.className&&(d=(d?d+" ":"")+e.className),Ue.createElement("svg",Kt({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},r.attr,i,s,{className:d,style:Jt(Jt({color:e.color||r.color},r.style),e.style),height:o,width:o,xmlns:"http://www.w3.org/2000/svg"}),l&&Ue.createElement("title",null,l),e.children)};return ii!==void 0?Ue.createElement(ii.Consumer,null,r=>t(r)):t(pa)}function li(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M5 12h14"},child:[]},{tag:"path",attr:{d:"m12 5 7 7-7 7"},child:[]}]})(e)}function Vl(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z"},child:[]},{tag:"path",attr:{d:"m9 12 2 2 4-4"},child:[]}]})(e)}function Zl(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M12 7v14"},child:[]},{tag:"path",attr:{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z"},child:[]}]})(e)}function Yl(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16"},child:[]},{tag:"rect",attr:{width:"20",height:"14",x:"2",y:"6",rx:"2"},child:[]}]})(e)}function Me(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M20 6 9 17l-5-5"},child:[]}]})(e)}function Hn(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"m6 9 6 6 6-6"},child:[]}]})(e)}function Kl(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"m15 18-6-6 6-6"},child:[]}]})(e)}function Jl(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"m9 18 6-6-6-6"},child:[]}]})(e)}function ma(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"path",attr:{d:"m9 12 2 2 4-4"},child:[]}]})(e)}function Xl(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"circle",attr:{cx:"12",cy:"12",r:"1"},child:[]}]})(e)}function Ql(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"path",attr:{d:"m15 9-6 6"},child:[]},{tag:"path",attr:{d:"m9 9 6 6"},child:[]}]})(e)}function it(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"polyline",attr:{points:"12 6 12 12 16.5 12"},child:[]}]})(e)}function es(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"polyline",attr:{points:"12 6 12 12 16 14"},child:[]}]})(e)}function si(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"polyline",attr:{points:"12 6 12 12 16 14"},child:[]}]})(e)}function lr(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"16 18 22 12 16 6"},child:[]},{tag:"polyline",attr:{points:"8 6 2 12 8 18"},child:[]}]})(e)}function ga(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{width:"16",height:"16",x:"4",y:"4",rx:"2"},child:[]},{tag:"rect",attr:{width:"6",height:"6",x:"9",y:"9",rx:"1"},child:[]},{tag:"path",attr:{d:"M15 2v2"},child:[]},{tag:"path",attr:{d:"M15 20v2"},child:[]},{tag:"path",attr:{d:"M2 15h2"},child:[]},{tag:"path",attr:{d:"M2 9h2"},child:[]},{tag:"path",attr:{d:"M20 15h2"},child:[]},{tag:"path",attr:{d:"M20 9h2"},child:[]},{tag:"path",attr:{d:"M9 2v2"},child:[]},{tag:"path",attr:{d:"M9 20v2"},child:[]}]})(e)}function Bn(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"ellipse",attr:{cx:"12",cy:"5",rx:"9",ry:"3"},child:[]},{tag:"path",attr:{d:"M3 5V19A9 3 0 0 0 21 19V5"},child:[]},{tag:"path",attr:{d:"M3 12A9 3 0 0 0 21 12"},child:[]}]})(e)}function We(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"12",x2:"12",y1:"2",y2:"22"},child:[]},{tag:"path",attr:{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"},child:[]}]})(e)}function ts(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M15 3h6v6"},child:[]},{tag:"path",attr:{d:"M10 14 21 3"},child:[]},{tag:"path",attr:{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"},child:[]}]})(e)}function Xt(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"},child:[]},{tag:"path",attr:{d:"M14 2v4a2 2 0 0 0 2 2h4"},child:[]},{tag:"path",attr:{d:"M10 9H8"},child:[]},{tag:"path",attr:{d:"M16 13H8"},child:[]},{tag:"path",attr:{d:"M16 17H8"},child:[]}]})(e)}function ns(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"4",x2:"20",y1:"9",y2:"9"},child:[]},{tag:"line",attr:{x1:"4",x2:"20",y1:"15",y2:"15"},child:[]},{tag:"line",attr:{x1:"10",x2:"8",y1:"3",y2:"21"},child:[]},{tag:"line",attr:{x1:"16",x2:"14",y1:"3",y2:"21"},child:[]}]})(e)}function ya(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z"},child:[]},{tag:"path",attr:{d:"M3.22 12H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27"},child:[]}]})(e)}function rs(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"},child:[]},{tag:"path",attr:{d:"M3 3v5h5"},child:[]},{tag:"path",attr:{d:"M12 7v5l4 2"},child:[]}]})(e)}function is(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{width:"7",height:"9",x:"3",y:"3",rx:"1"},child:[]},{tag:"rect",attr:{width:"7",height:"5",x:"14",y:"3",rx:"1"},child:[]},{tag:"rect",attr:{width:"7",height:"9",x:"14",y:"12",rx:"1"},child:[]},{tag:"rect",attr:{width:"7",height:"5",x:"3",y:"16",rx:"1"},child:[]}]})(e)}function as(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M13 12h8"},child:[]},{tag:"path",attr:{d:"M13 18h8"},child:[]},{tag:"path",attr:{d:"M13 6h8"},child:[]},{tag:"path",attr:{d:"M3 12h1"},child:[]},{tag:"path",attr:{d:"M3 18h1"},child:[]},{tag:"path",attr:{d:"M3 6h1"},child:[]},{tag:"path",attr:{d:"M8 12h1"},child:[]},{tag:"path",attr:{d:"M8 18h1"},child:[]},{tag:"path",attr:{d:"M8 6h1"},child:[]}]})(e)}function ls(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"4",x2:"20",y1:"12",y2:"12"},child:[]},{tag:"line",attr:{x1:"4",x2:"20",y1:"6",y2:"6"},child:[]},{tag:"line",attr:{x1:"4",x2:"20",y1:"18",y2:"18"},child:[]}]})(e)}function at(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"},child:[]}]})(e)}function ss(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"},child:[]}]})(e)}function Fn(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2"},child:[]},{tag:"path",attr:{d:"M18 14h-8"},child:[]},{tag:"path",attr:{d:"M15 18h-5"},child:[]},{tag:"path",attr:{d:"M10 6h8v4h-8V6Z"},child:[]}]})(e)}function fe(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"},child:[]},{tag:"path",attr:{d:"M21 3v5h-5"},child:[]},{tag:"path",attr:{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"},child:[]},{tag:"path",attr:{d:"M8 16H3v5"},child:[]}]})(e)}function Wn(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"11",cy:"11",r:"8"},child:[]},{tag:"path",attr:{d:"m21 21-4.3-4.3"},child:[]}]})(e)}function os(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z"},child:[]},{tag:"path",attr:{d:"m21.854 2.147-10.94 10.939"},child:[]}]})(e)}function cs(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"},child:[]},{tag:"rect",attr:{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"},child:[]},{tag:"line",attr:{x1:"6",x2:"6.01",y1:"6",y2:"6"},child:[]},{tag:"line",attr:{x1:"6",x2:"6.01",y1:"18",y2:"18"},child:[]}]})(e)}function ds(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M20 7h-9"},child:[]},{tag:"path",attr:{d:"M14 17H5"},child:[]},{tag:"circle",attr:{cx:"17",cy:"17",r:"3"},child:[]},{tag:"circle",attr:{cx:"7",cy:"7",r:"3"},child:[]}]})(e)}function Un(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"},child:[]},{tag:"path",attr:{d:"M12 8v4"},child:[]},{tag:"path",attr:{d:"M12 16h.01"},child:[]}]})(e)}function us(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"4"},child:[]},{tag:"path",attr:{d:"M12 2v2"},child:[]},{tag:"path",attr:{d:"M12 20v2"},child:[]},{tag:"path",attr:{d:"m4.93 4.93 1.41 1.41"},child:[]},{tag:"path",attr:{d:"m17.66 17.66 1.41 1.41"},child:[]},{tag:"path",attr:{d:"M2 12h2"},child:[]},{tag:"path",attr:{d:"M20 12h2"},child:[]},{tag:"path",attr:{d:"m6.34 17.66-1.41 1.41"},child:[]},{tag:"path",attr:{d:"m19.07 4.93-1.41 1.41"},child:[]}]})(e)}function oi(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"},child:[]}]})(e)}function lt(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M18 6 6 18"},child:[]},{tag:"path",attr:{d:"m6 6 12 12"},child:[]}]})(e)}function jn(e){return B({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"},child:[]}]})(e)}const ci=[{id:"overview",label:"Overview",icon:is,section:"dashboard"},{id:"history",label:"Messages",icon:at,section:"dashboard"},{id:"approvals",label:"Approvals",icon:Vl,section:"dashboard"},{id:"digests",label:"Digests",icon:Fn,section:"dashboard"},{id:"audit",label:"Audit",icon:Wn,section:"dashboard"},{id:"usage",label:"Usage",icon:We,section:"dashboard"},{id:"coding",label:"Coding Agent",icon:lr,section:"dashboard"},{id:"office",label:"Office",icon:Yl,section:"dashboard"},{id:"memory",label:"Memory",icon:Bn,section:"settings"},{id:"templates",label:"Templates",icon:Xt,section:"settings"},{id:"model",label:"Model",icon:ga,section:"settings"},{id:"skills",label:"Skills",icon:jn,section:"settings"},{id:"cron",label:"Scheduled Jobs",icon:it,section:"settings"},{id:"config",label:"Config",icon:ds,section:"settings"},{id:"logs",label:"Logs",icon:as,section:"footer"},{id:"health",label:"Health",icon:ya,section:"footer"}],hs=[{id:"dashboard",label:"Dashboard"},{id:"settings",label:"Settings"}];function ps({currentPage:e,onNavigate:t,botName:r,botEmoji:i,pendingApprovals:a,isNarrow:l,onClose:s}){return n("nav",{class:"sidebar",children:[n("div",{class:"sidebar-header",children:[n("div",{class:"sidebar-logo",children:i}),n("div",{class:"sidebar-brand",children:[n("span",{class:"sidebar-brand-name",children:r}),n("span",{class:"sidebar-brand-status",children:"Online"})]}),l&&n("button",{class:"sidebar-close-btn",onClick:s,"aria-label":"Close sidebar",children:n(Kl,{size:16})})]}),hs.map(o=>{const d=ci.filter(c=>c.section===o.id);return n("div",{class:"sidebar-section",children:[n("div",{class:"sidebar-section-label",children:o.label}),d.map(c=>{const f=c.id==="approvals"&&a?a:void 0,h=c.icon;return n("button",{"data-page":c.id,class:`sidebar-item${e===c.id?" active":""}`,onClick:()=>t(c.id),children:[n("span",{class:"sidebar-item-icon",children:n(h,{size:16})}),n("span",{class:"sidebar-item-label",children:c.label}),f?n("span",{class:"item-badge",children:f}):null]},c.id)})]},o.id)}),n("div",{class:"sidebar-spacer"}),n("div",{class:"sidebar-footer",children:[ci.filter(o=>o.section==="footer").map(o=>{const d=o.icon;return n("button",{"data-page":o.id,class:`sidebar-footer-item${e===o.id?" active":""}`,onClick:()=>t(o.id),children:[n("span",{class:"sidebar-item-icon",children:n(d,{size:16})}),n("span",{class:"sidebar-item-label",children:o.label})]},o.id)}),n("a",{class:"sidebar-footer-item",href:"https://docs.skimpyclaw.xyz/guide/",target:"_blank",rel:"noreferrer",title:"Open SkimpyClaw documentation",children:[n("span",{class:"sidebar-item-icon",children:n(Zl,{size:16})}),n("span",{class:"sidebar-item-label",children:"Help Docs"})]})]})]})}function fs({toasts:e}){return n("div",{class:"toast-container",children:e.map(t=>n("div",{class:`toast ${t.type}`,children:t.message},t.id))})}function ms(){const[e,t]=x([]),r=an((i,a="info",l=3e3)=>{const s=crypto.randomUUID();t(o=>[...o,{id:s,message:i,type:a}]),setTimeout(()=>{t(o=>o.filter(d=>d.id!==s))},l)},[]);return{toasts:e,showToast:r}}const sr="dashboard_token",Gn="skimpy-dashboard-unauthorized";function va(){return localStorage.getItem(sr)??""}function gs(e){localStorage.setItem(sr,e)}function ys(){localStorage.removeItem(sr)}function vs(e){const t=()=>e();return window.addEventListener(Gn,t),()=>window.removeEventListener(Gn,t)}class _s extends Error{constructor(t,r){super(r),this.status=t,this.name="ApiError"}}async function U(e,t={}){const r=va(),i={...r?{Authorization:`Bearer ${r}`}:{},...t.headers??{}};t.body&&(i["Content-Type"]="application/json");const a=await fetch(`/api/dashboard/${e}`,{...t,headers:i});if(!a.ok){a.status===401&&(ys(),window.dispatchEvent(new Event(Gn)));const l=await a.text().catch(()=>a.statusText);throw new _s(a.status,l)}return a.json()}const bs=()=>U("status"),di=()=>U("health"),ui=()=>U("doctor");function _a(e={}){const t=new URLSearchParams;e.limit!==void 0&&t.set("limit",String(e.limit)),e.offset!==void 0&&t.set("offset",String(e.offset)),e.trigger&&t.set("trigger",e.trigger);const r=t.toString();return U(`audit${r?`?${r}`:""}`)}const ba=()=>U("approvals"),ka=e=>U(`approvals/${encodeURIComponent(e)}/approve`,{method:"POST"}),xa=e=>U(`approvals/${encodeURIComponent(e)}/deny`,{method:"POST"}),ks=()=>U("cron"),xs=e=>U(`cron/${encodeURIComponent(e)}/run`,{method:"POST"}),ws=e=>U(`cron/prompt-file?path=${encodeURIComponent(e)}`),Ss=()=>U("model"),Ts=e=>U("model",{method:"POST",body:JSON.stringify({model:e})}),Cs=e=>U(`memory/${encodeURIComponent(e)}`),As=(e,t)=>U(`memory/${encodeURIComponent(e)}/${encodeURIComponent(t)}`),Es=e=>U(`templates/${encodeURIComponent(e)}`),Ls=(e,t)=>U(`templates/${encodeURIComponent(e)}/${encodeURIComponent(t)}`),$s=(e,t,r)=>U(`templates/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({content:r})}),zs=()=>U("logs"),Rs=e=>U(e),Ms=()=>U("code-agents"),Is=e=>U(`code-agents/${encodeURIComponent(e)}/cancel`,{method:"POST"}),Ds=(e,t)=>U("messages/agent",{method:"POST",body:JSON.stringify({message:e,model:t})}),Ps=e=>{const t=e?`?channel=${encodeURIComponent(e)}`:"";return U(`conversations${t}`)},Os=(e,t)=>{const r=new URLSearchParams;(t==null?void 0:t.limit)!==void 0&&r.set("limit",String(t.limit)),(t==null?void 0:t.offset)!==void 0&&r.set("offset",String(t.offset));const i=r.toString();return U(`conversations/${encodeURIComponent(e)}${i?`?${i}`:""}`)},or=()=>U("config"),wa=e=>U("config",{method:"PUT",body:JSON.stringify({config:e})}),Ns=()=>U("reload",{method:"POST"}),Hs=()=>U("digests"),Bs=e=>U(`digests/${encodeURIComponent(e)}`),Fs=()=>U("skills"),Ws=e=>U(`skills/${encodeURIComponent(e)}`),Us=(e,t)=>U("skills",{method:"POST",body:JSON.stringify({name:e,content:t})}),js=(e,t)=>U(`skills/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({enabled:t})}),Gs=(e,t)=>U(`skills/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({content:t})}),qs=e=>U(`skills/${encodeURIComponent(e)}`,{method:"DELETE"}),cr=()=>U("usage");function Vs(e){const t=new URLSearchParams;t.set("limit",String(e.limit)),(e==null?void 0:e.offset)!==void 0&&t.set("offset",String(e.offset)),e!=null&&e.model&&t.set("model",e.model);const r=t.toString();return U(`usage/records${r?`?${r}`:""}`)}function Sn(e){const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const r=Math.floor(t/60);if(r<60)return`${r}m`;const i=Math.floor(r/60);return i<24?`${i}h ${r%60}m`:`${Math.floor(i/24)}d ${i%24}h`}function Zs(){const e=new Date().getHours();return e<12?"Good morning":e<17?"Good afternoon":"Good evening"}function Ys(e){const t=new Date(e),r=Date.now()-t.getTime(),i=Math.floor(r/1e3);if(i<60)return`${i}s ago`;const a=Math.floor(i/60);if(a<60)return`${a}m ago`;const l=Math.floor(a/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`}function Ks(e){const t=Date.now()-new Date(e).getTime(),r=Math.floor(t/6e4),i=Math.floor(t%6e4/1e3);return`${r}:${i.toString().padStart(2,"0")}`}function hi(e){if(!e)return"N/A";const r=new Date(e).getTime()-Date.now();if(r<0)return"overdue";const i=Math.floor(r/6e4);return i<60?`in ${i}m`:`in ${Math.floor(i/60)}h ${i%60}m`}function Js(e){return e?e==="telegram"?"Telegram":e==="discord"?"Discord":e:"—"}function Xs(e){const t=e.events.filter(r=>r.type==="tool_use").length;return t>0?`${t} tool call${t>1?"s":""}`:e.events.length>0?e.events[0].summary??"":""}function pi({onNavigate:e,showToast:t}){var g;const[r,i]=x(null),[a,l]=x([]),[s,o]=x([]),[d,c]=x(null),[f,h]=x(new Set),[y,p]=x(!0);q(()=>{u();const v=setInterval(u,1e4);return()=>clearInterval(v)},[]);async function u(){const[v,E,z,F]=await Promise.allSettled([bs(),_a({limit:8,offset:0}),ba(),cr()]);v.status==="fulfilled"?i(v.value):console.error("[overview] status load failed",v.reason),E.status==="fulfilled"?l(E.value.traces??[]):console.error("[overview] audit load failed",E.reason),z.status==="fulfilled"?o(z.value.pending??[]):console.error("[overview] approvals load failed",z.reason),F.status==="fulfilled"&&c(F.value),p(!1)}async function _(v,E){h(z=>new Set([...z,v]));try{E?(await ka(v),t==null||t("Command approved","success")):(await xa(v),t==null||t("Command denied","warning")),await u()}catch{t==null||t("Action failed","error")}finally{h(z=>{const F=new Set(z);return F.delete(v),F})}}const w=v=>v==="telegram"?n(os,{size:14}):v==="cron"?n(it,{size:14}):n(cs,{size:14});if(y)return n("div",{style:{display:"flex",justifyContent:"center",padding:"48px"},children:n("div",{class:"spinner"})});const k=r==null?void 0:r.cronJobs.reduce((v,E)=>v!=null&&v.nextRun?E.nextRun?new Date(v.nextRun)<new Date(E.nextRun)?v:E:v:E,null);return n("div",{children:[n("div",{class:"page-header",children:[n("div",{class:"page-title",children:"Overview"}),n("div",{class:"header-actions",children:n("div",{class:"header-meta",children:[(r==null?void 0:r.model)??"—"," • up ",r?Sn(r.uptime):"—"]})})]}),n("div",{class:"welcome-banner",children:[n("div",{class:"welcome-greeting",children:[Zs(),", Katrina"]}),n("div",{class:"welcome-sub",children:r?`Running for ${Sn(r.uptime)} · ${r.model}`:"Loading…"})]}),s.length>0&&n("div",{style:{marginBottom:16},children:s.map(v=>n("div",{class:"approval-card",children:[n("div",{class:"approval-card-icon",children:n(Un,{size:20})}),n("div",{class:"approval-card-content",children:[n("div",{class:"approval-card-title",children:[s.length," pending approval",s.length>1?"s":""]}),n("div",{class:"approval-card-detail",children:["Tier ",v.tier," — ",n("code",{class:"approval-cmd",children:v.command})]}),v.cwd&&n("div",{class:"approval-card-cwd",children:v.cwd})]}),n("div",{class:"approval-card-time",children:Ks(v.createdAt)}),n("div",{class:"approval-card-actions",children:[n("button",{class:"approval-btn-deny",disabled:f.has(v.id),onClick:()=>_(v.id,!1),children:"Deny"}),n("button",{class:"approval-btn-approve",disabled:f.has(v.id),onClick:()=>_(v.id,!0),children:[n(Me,{size:14})," Approve"]})]})]},v.id))}),n("div",{class:"stats-grid stats-grid-5",children:[n("div",{class:"stat-card",children:[n("div",{class:"stat-icon sage",children:n(it,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value",children:r?Sn(r.uptime):"—"}),n("div",{class:"stat-subtitle",children:"Uptime"})]})]}),n("div",{class:"stat-card",children:[n("div",{class:"stat-icon amber",children:n(es,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value stat-value-md",children:hi(k==null?void 0:k.nextRun)}),n("div",{class:"stat-subtitle",children:["Next cron · ",(r==null?void 0:r.cronJobs.length)??0," jobs"]})]})]}),n("div",{class:"stat-card",children:[n("div",{class:"stat-icon green",children:n(ga,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value stat-value-md",children:(r==null?void 0:r.model)??"—"}),n("div",{class:"stat-subtitle",children:"Active model"})]})]}),n("div",{class:"stat-card",children:[n("div",{class:"stat-icon blue",children:n(at,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value stat-value-md",children:Js((r==null?void 0:r.activeChannel)??null)}),n("div",{class:"stat-subtitle",children:"Active channel"})]})]}),n("div",{class:"stat-card",children:[n("div",{class:"stat-icon rose",children:n(We,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value stat-value-md",children:d?`$${d.today.totalCost.toFixed(2)}`:"—"}),n("div",{class:"stat-subtitle",children:"Cost today"})]})]})]}),n("div",{class:"section",children:[n("div",{class:"section-header",children:[n("div",{class:"section-title",children:"Audit Logs"}),n("a",{class:"section-link",href:"#audit",onClick:v=>{v.preventDefault(),e("audit")},children:n("span",{class:"section-link-content",children:["View all ",n(li,{size:14})]})})]}),n("div",{class:"feed-card",children:n("div",{class:"feed",children:a.length===0?n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(rs,{size:18})}),n("div",{class:"empty-state-text",children:"No recent audit logs"})]}):a.slice(0,6).map(v=>n("div",{class:"feed-item",children:[n("div",{class:`feed-icon ${v.trigger==="telegram"?"telegram":v.trigger==="cron"?"cron":"system"}`,children:w(v.trigger)}),n("div",{children:[n("div",{class:"feed-title",children:v.trigger}),n("div",{class:"feed-detail",children:Xs(v)})]}),n("div",{class:"feed-time",children:Ys(v.startedAt)})]},v.traceId))})})]}),(((g=r==null?void 0:r.cronJobs)==null?void 0:g.length)??0)>0&&n("div",{class:"section",children:[n("div",{class:"section-header",children:[n("div",{class:"section-title",children:"Scheduled Jobs"}),n("a",{class:"section-link",href:"#cron",onClick:v=>{v.preventDefault(),e("cron")},children:n("span",{class:"section-link-content",children:["Manage ",n(li,{size:14})]})})]}),n("div",{class:"cron-grid",children:((r==null?void 0:r.cronJobs)??[]).slice(0,4).map(v=>n("div",{class:"cron-card",children:[n("div",{class:"cron-info",children:[n("div",{class:"cron-name",children:v.name}),n("div",{class:"cron-schedule",children:v.id})]}),n("div",{class:"cron-next",children:hi(v.nextRun)})]},v.id))})]})]})}function qn(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Qs(e){const t=e.trim();return/^(https?:|mailto:|\/|#)/i.test(t)?t:"#"}function ut(e){let t=qn(e);return t=t.replace(/`([^`]+)`/g,"<code>$1</code>"),t=t.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),t=t.replace(/\*([^*]+)\*/g,"<em>$1</em>"),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(r,i,a)=>`<a href="${qn(Qs(a))}" target="_blank" rel="noreferrer">${i}</a>`),t}function eo(e){const t=e.replace(/\r\n/g,`
|
|
2
|
+
`).split(`
|
|
3
|
+
`),r=[];let i=!1,a=[],l=null,s=[];function o(){l&&(r.push(`</${l}>`),l=null)}function d(){s.length!==0&&(r.push(`<p>${ut(s.join(" "))}</p>`),s=[])}function c(){i&&(r.push(`<pre><code>${qn(a.join(`
|
|
4
|
+
`))}</code></pre>`),a=[],i=!1)}for(const f of t){if(f.trim().startsWith("```")){d(),o(),i?c():i=!0;continue}if(i){a.push(f);continue}const h=/^(#{1,6})\s+(.*)$/.exec(f);if(h){d(),o();const u=h[1].length;r.push(`<h${u}>${ut(h[2])}</h${u}>`);continue}const y=/^[-*]\s+(.*)$/.exec(f);if(y){d(),l!=="ul"&&(o(),l="ul",r.push("<ul>")),r.push(`<li>${ut(y[1])}</li>`);continue}const p=/^\d+\.\s+(.*)$/.exec(f);if(p){d(),l!=="ol"&&(o(),l="ol",r.push("<ol>")),r.push(`<li>${ut(p[1])}</li>`);continue}if(f.trim()===""){d(),o();continue}if(o(),f.startsWith("> ")){d(),r.push(`<blockquote>${ut(f.slice(2))}</blockquote>`);continue}s.push(f.trim())}return d(),o(),c(),r.join(`
|
|
5
|
+
`)}function sn({content:e}){const t=$e(()=>eo(e||""),[e]);return n("div",{class:"markdown-view",dangerouslySetInnerHTML:{__html:t}})}const Sa="dashboard_agent_messages_v1";function to(e){if(!e||typeof e!="object")return!1;const t=e;return(t.role==="user"||t.role==="assistant")&&typeof t.content=="string"&&typeof t.ts=="string"&&t.conversationId==="dashboard-agent"&&(t.channel==="dashboard"||t.channel==="telegram"||t.channel==="discord")&&typeof t.chatId=="string"}function no(){try{const e=localStorage.getItem(Sa);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(to).slice(-300):[]}catch{return[]}}function ro(e){const t=Date.now()-new Date(e).getTime(),r=Math.floor(t/1e3);if(r<60)return`${r}s ago`;const i=Math.floor(r/60);if(i<60)return`${i}m ago`;const a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function io(){const[e,t]=x([]),[r,i]=x([]),[a,l]=x(()=>no()),[s,o]=x("all"),[d,c]=x(1),[f,h]=x(!1),[y,p]=x(!1),[u,_]=x(!0),[w,k]=x(""),[g,v]=x(!1),E=Le(null),z=Le(!0),F=Le(!1),D=Le(0),P=Le(0),S=(s==="all"?[...r,...a]:r).sort((T,H)=>new Date(T.ts).getTime()-new Date(H.ts).getTime()),b=()=>{const T=E.current;T&&(T.scrollTop=T.scrollHeight)};q(()=>{c(1),h(!1),p(!1),z.current=!0},[s]),q(()=>{R()},[s,d]),q(()=>{const T=setInterval(()=>{R()},5e3);return()=>clearInterval(T)},[s,d]),q(()=>{try{localStorage.setItem(Sa,JSON.stringify(a.slice(-300)))}catch{}},[a]),q(()=>{const T=E.current;if(T){if(F.current){const H=T.scrollHeight;T.scrollTop=Math.max(0,H-D.current+P.current),F.current=!1,p(!1);return}if(z.current){requestAnimationFrame(b);const H=setTimeout(b,80);return()=>clearTimeout(H)}}},[S.length,u]);async function R(){_(!0);try{const H=(await Ps(s==="all"?void 0:s)).conversations??[];if(t(H),H.length===0){i([]);return}const he=H.slice(0,12),ge=Math.max(20,d*30),De=await Promise.all(he.map(async le=>{const Y=await Os(le.id,{limit:ge});return{hasMore:!!Y.hasMore,messages:(Y.messages??[]).map(Oe=>({...Oe,conversationId:le.id,channel:le.channel,chatId:le.chatId}))}})),Pe=De.some(le=>le.hasMore);h(Pe);const X=De.flatMap(le=>le.messages).sort((le,Y)=>new Date(le.ts).getTime()-new Date(Y.ts).getTime());i(X)}catch(T){console.error("[messages] load failed",T)}finally{_(!1)}}function L(T){const H=T.currentTarget,he=H.scrollHeight-(H.scrollTop+H.clientHeight);z.current=he<24,H.scrollTop<=40&&f&&!y&&!u&&(F.current=!0,D.current=H.scrollHeight,P.current=H.scrollTop,p(!0),c(ge=>ge+1))}async function G(){const T=w.trim();if(!(!T||g)){v(!0),z.current=!0;try{l(he=>[...he,{role:"user",content:T,ts:new Date().toISOString(),conversationId:"dashboard-agent",channel:"dashboard",chatId:"active"}]);const H=await Ds(T);l(he=>[...he,{role:"assistant",content:H.response,ts:H.timestamp||new Date().toISOString(),conversationId:"dashboard-agent",channel:"dashboard",chatId:"agent"}]),k("")}catch(H){console.error("[messages] send failed",H)}finally{v(!1)}}}function te(T){return T==="dashboard"?"Dashboard":T==="discord"?"Discord":"Telegram"}return n("div",{class:"messages-page",children:[n("div",{class:"page-header",children:[n("div",{class:"page-title",children:"Messages"}),n("div",{class:"header-actions",children:[n("select",{class:"btn btn-sm",value:s,onChange:T=>o(T.target.value),children:[n("option",{value:"all",children:"All channels"}),n("option",{value:"telegram",children:"Telegram"}),n("option",{value:"discord",children:"Discord"})]}),n("button",{class:"btn-refresh",onClick:()=>void R(),children:[n(fe,{size:14})," Refresh"]})]})]}),u&&e.length===0?n("div",{class:"messages-filler",children:n("div",{class:"spinner"})}):e.length===0?n("div",{class:"card messages-chat-card",children:n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(at,{size:18})}),n("div",{class:"empty-state-text",children:"No messages yet"})]})}):n("div",{class:"card messages-chat-card",children:[S.length===0?n("div",{class:"empty-state",children:n("div",{class:"empty-state-text",children:"No conversation messages"})}):n("div",{ref:E,class:"chat-list messages-chat-list",onScroll:L,children:[y&&n("div",{style:{display:"flex",justifyContent:"center",padding:"6px 0"},children:n("div",{class:"spinner",style:{width:14,height:14}})}),S.map((T,H)=>n("div",{class:`chat-row ${T.role==="user"?"user":"assistant"}`,children:[n("div",{class:"chat-meta",children:[T.role==="user"?"You":"SkimpyClaw"," · ",te(T.channel)," · ",ro(T.ts)]}),n("div",{class:`chat-bubble ${T.role==="user"?"user":"assistant"}`,children:n(sn,{content:T.content})})]},`${T.ts}-${H}`))]}),n("div",{class:"messages-composer-inline",children:n("div",{style:{display:"flex",gap:8},children:[n("input",{value:w,onInput:T=>k(T.target.value),onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),G())},placeholder:"Send a message to the agent",style:{flex:1,padding:"10px 12px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border)",background:"var(--surface-alt)",color:"var(--text)"}}),n("button",{class:"btn btn-sm btn-primary",onClick:G,disabled:g||!w.trim(),children:g?"Sending…":"Send"})]})})]})]})}function ao(e){if(!e)return"N/A";const t=new Date(e).getTime()-Date.now();if(t<0)return"overdue";const r=Math.floor(t/6e4);return r<60?`in ${r}m`:`in ${Math.floor(r/60)}h ${r%60}m`}function lo({showToast:e}){const[t,r]=x([]),[i,a]=x(!0),[l,s]=x(new Set),[o,d]=x(null),[c,f]=x(null),[h,y]=x(!1),[p,u]=x(null),[_,w]=x(null),[k,g]=x({id:"",name:"",scheduleExpr:"",tz:"America/Chicago",model:"",payloadKind:"agentTurn",message:"",script:"",url:"",cwd:"",timeoutMs:"",sendAsVoice:!1});q(()=>{v()},[]);async function v(){a(!0);try{const[S,b]=await Promise.all([ks(),or()]);r(S.jobs??[]);const R=b.config??{};d(R)}catch{e("Failed to load cron jobs","error")}finally{a(!1)}}async function E(S){var T,H,he,ge,De,Pe,X,le,Y;const b=((T=S.payload)==null?void 0:T.kind)||"agentTurn",R=((H=S.payload)==null?void 0:H.message)||"";let L=R,G=null,te=null;if(b==="agentTurn"&&typeof R=="string"&&R.trim().endsWith(".md"))try{const Oe=await ws(R);L=Oe.content,G=R,te=Oe.content}catch{}u(G),w(te),g({id:S.id||"",name:S.name||"",scheduleExpr:((he=S.schedule)==null?void 0:he.expr)||"",tz:((ge=S.schedule)==null?void 0:ge.tz)||"America/Chicago",model:S.model||"",payloadKind:b,message:L,script:((De=S.payload)==null?void 0:De.script)||"",url:((Pe=S.payload)==null?void 0:Pe.url)||"",cwd:((X=S.payload)==null?void 0:X.cwd)||"",timeoutMs:(le=S.payload)!=null&&le.timeoutMs?String(S.payload.timeoutMs):"",sendAsVoice:!!((Y=S.payload)!=null&&Y.sendAsVoice)})}function z(){f(null),u(null),w(null),g({id:"",name:"",scheduleExpr:"",tz:"America/Chicago",model:"",payloadKind:"agentTurn",message:"",script:"",url:"",cwd:"",timeoutMs:"",sendAsVoice:!1})}function F(S){var R;f(S);const b=(((R=o==null?void 0:o.cron)==null?void 0:R.jobs)??[]).find(L=>L.id===S);b&&E(b)}async function D(){if(!o)return;const S=k.id.trim(),b=k.name.trim(),R=k.scheduleExpr.trim();if(!S||!b||!R){e("ID, name, and schedule are required","error");return}const L=structuredClone(o);L.cron||(L.cron={jobs:[]}),Array.isArray(L.cron.jobs)||(L.cron.jobs=[]);const G={kind:k.payloadKind};if(k.payloadKind==="agentTurn"){const H=p&&_!==null&&k.message===_;G.message=H?p:k.message}k.payloadKind==="script"&&(G.script=k.script,k.cwd.trim()&&(G.cwd=k.cwd.trim()),k.timeoutMs.trim()&&(G.timeoutMs=Number(k.timeoutMs))),k.payloadKind==="http"&&(G.url=k.url),k.sendAsVoice&&(G.sendAsVoice=!0);const te={id:S,name:b,schedule:{kind:"cron",expr:R,tz:k.tz.trim()||"America/Chicago"},payload:G,model:k.model.trim()||void 0},T=L.cron.jobs.findIndex(H=>H.id===S);T>=0?L.cron.jobs[T]=te:L.cron.jobs.push(te),y(!0);try{await wa(L),e(T>=0?"Cron job updated":"Cron job created","success"),d(L),f(S),await v()}catch{e("Failed to save cron job","error")}finally{y(!1)}}async function P(S){s(b=>new Set([...b,S]));try{await xs(S),e("Job triggered","success")}catch{e("Failed to trigger job","error")}finally{s(b=>{const R=new Set(b);return R.delete(S),R})}}return n("div",{children:[n("div",{class:"page-header",children:[n("div",{class:"page-title",children:"Scheduled Jobs"}),n("div",{class:"header-actions",children:[n("button",{class:"btn btn-sm",onClick:z,children:"New Job"}),n("button",{class:"btn-refresh",onClick:v,children:[n(fe,{size:14})," Refresh"]})]})]}),i?n("div",{style:{display:"flex",justifyContent:"center",padding:"48px"},children:n("div",{class:"spinner"})}):t.length===0?n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(it,{size:18})}),n("div",{class:"empty-state-text",children:"No scheduled jobs configured"})]}):n("div",{style:{display:"grid",gridTemplateColumns:"320px 1fr",gap:16},children:[n("div",{class:"card",style:{marginBottom:0,padding:0,overflow:"hidden"},children:n("div",{class:"templates-list",children:t.map(S=>n("button",{class:`templates-list-item${c===S.id?" active":""}`,onClick:()=>F(S.id),children:[n("div",{class:"templates-list-icon",children:n(it,{size:14})}),n("div",{class:"templates-list-content",children:[n("div",{class:"templates-list-title",children:S.name}),n("div",{class:"templates-list-meta",children:[S.id," · ",ao(S.nextRun)]})]})]},S.id))})}),n("div",{class:"card",style:{marginBottom:0},children:[n("div",{class:"card-title",style:{fontWeight:700,marginBottom:12},children:c?"Edit Cron Job":"Create Cron Job"}),n("div",{class:"form-grid two",children:[n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Job ID"}),n("input",{value:k.id,onInput:S=>g(b=>({...b,id:S.target.value})),placeholder:"morning_digest"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Job name"}),n("input",{value:k.name,onInput:S=>g(b=>({...b,name:S.target.value})),placeholder:"Morning Digest"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Cron expression"}),n("input",{value:k.scheduleExpr,onInput:S=>g(b=>({...b,scheduleExpr:S.target.value})),placeholder:"*/30 * * * *"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Timezone"}),n("input",{value:k.tz,onInput:S=>g(b=>({...b,tz:S.target.value})),placeholder:"America/Chicago"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Model override"}),n("input",{value:k.model,onInput:S=>g(b=>({...b,model:S.target.value})),placeholder:"optional"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Payload kind"}),n("select",{value:k.payloadKind,onChange:S=>g(b=>({...b,payloadKind:S.target.value})),children:[n("option",{value:"agentTurn",children:"agentTurn"}),n("option",{value:"script",children:"script"}),n("option",{value:"http",children:"http"})]})]})]}),k.payloadKind==="agentTurn"&&n("label",{class:"form-field",style:{marginTop:10},children:[n("span",{class:"form-label",children:"Agent prompt"}),p&&n("span",{class:"form-help",children:["Loaded from ",p]}),n("textarea",{value:k.message,onInput:S=>g(b=>({...b,message:S.target.value})),placeholder:"Message prompt",style:{minHeight:120}})]}),k.payloadKind==="script"&&n(ae,{children:[n("label",{class:"form-field",style:{marginTop:10},children:[n("span",{class:"form-label",children:"Script"}),n("textarea",{value:k.script,onInput:S=>g(b=>({...b,script:S.target.value})),placeholder:"Shell script",style:{minHeight:120}})]}),n("div",{class:"form-grid two",style:{marginTop:10},children:[n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Working directory"}),n("input",{value:k.cwd,onInput:S=>g(b=>({...b,cwd:S.target.value})),placeholder:"optional"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Timeout ms"}),n("input",{value:k.timeoutMs,onInput:S=>g(b=>({...b,timeoutMs:S.target.value})),placeholder:"optional"})]})]})]}),k.payloadKind==="http"&&n("label",{class:"form-field",style:{marginTop:10},children:[n("span",{class:"form-label",children:"URL"}),n("input",{value:k.url,onInput:S=>g(b=>({...b,url:S.target.value})),placeholder:"https://..."})]}),n("label",{class:"form-checkbox",style:{marginTop:10},children:[n("input",{type:"checkbox",checked:k.sendAsVoice,onChange:S=>g(b=>({...b,sendAsVoice:S.target.checked}))}),"Send output as voice"]}),n("div",{class:"form-actions",children:[c&&n("button",{class:"btn btn-sm",disabled:l.has(c),onClick:()=>P(c),children:l.has(c)?"Running…":"Run now"}),n("button",{class:"btn btn-sm btn-primary",onClick:D,disabled:h,children:h?"Saving…":"Save Job"})]})]})]})]})}function dr(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ge=dr();function Ta(e){Ge=e}var Fe={exec:()=>null};function j(e,t=""){let r=typeof e=="string"?e:e.source,i={replace:(a,l)=>{let s=typeof l=="string"?l:l.source;return s=s.replace(ce.caret,"$1"),r=r.replace(a,s),i},getRegex:()=>new RegExp(r,t)};return i}var so=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),ce={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}>`)},oo=/^(?:[ \t]*(?:\n|$))+/,co=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,uo=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,zt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ho=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ur=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Ca=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Aa=j(Ca).replace(/bull/g,ur).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),po=j(Ca).replace(/bull/g,ur).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),hr=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,fo=/^[^\n]+/,pr=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,mo=j(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",pr).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),go=j(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ur).getRegex(),on="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",fr=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,yo=j("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",fr).replace("tag",on).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ea=j(hr).replace("hr",zt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",on).getRegex(),vo=j(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ea).getRegex(),mr={blockquote:vo,code:co,def:mo,fences:uo,heading:ho,hr:zt,html:yo,lheading:Aa,list:go,newline:oo,paragraph:Ea,table:Fe,text:fo},fi=j("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",zt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",on).getRegex(),_o={...mr,lheading:po,table:fi,paragraph:j(hr).replace("hr",zt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",fi).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",on).getRegex()},bo={...mr,html:j(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",fr).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Fe,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:j(hr).replace("hr",zt).replace("heading",` *#{1,6} *[^
|
|
6
|
+
]`).replace("lheading",Aa).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ko=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,xo=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,La=/^( {2,}|\\)\n(?!\s*$)/,wo=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,cn=/[\p{P}\p{S}]/u,gr=/[\s\p{P}\p{S}]/u,$a=/[^\s\p{P}\p{S}]/u,So=j(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,gr).getRegex(),za=/(?!~)[\p{P}\p{S}]/u,To=/(?!~)[\s\p{P}\p{S}]/u,Co=/(?:[^\s\p{P}\p{S}]|~)/u,Ra=/(?![*_])[\p{P}\p{S}]/u,Ao=/(?![*_])[\s\p{P}\p{S}]/u,Eo=/(?:[^\s\p{P}\p{S}]|[*_])/u,Lo=j(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",so?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Ma=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,$o=j(Ma,"u").replace(/punct/g,cn).getRegex(),zo=j(Ma,"u").replace(/punct/g,za).getRegex(),Ia="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Ro=j(Ia,"gu").replace(/notPunctSpace/g,$a).replace(/punctSpace/g,gr).replace(/punct/g,cn).getRegex(),Mo=j(Ia,"gu").replace(/notPunctSpace/g,Co).replace(/punctSpace/g,To).replace(/punct/g,za).getRegex(),Io=j("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,$a).replace(/punctSpace/g,gr).replace(/punct/g,cn).getRegex(),Do=j(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Ra).getRegex(),Po="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Oo=j(Po,"gu").replace(/notPunctSpace/g,Eo).replace(/punctSpace/g,Ao).replace(/punct/g,Ra).getRegex(),No=j(/\\(punct)/,"gu").replace(/punct/g,cn).getRegex(),Ho=j(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Bo=j(fr).replace("(?:-->|$)","-->").getRegex(),Fo=j("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Bo).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Qt=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Wo=j(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Qt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Da=j(/^!?\[(label)\]\[(ref)\]/).replace("label",Qt).replace("ref",pr).getRegex(),Pa=j(/^!?\[(ref)\](?:\[\])?/).replace("ref",pr).getRegex(),Uo=j("reflink|nolink(?!\\()","g").replace("reflink",Da).replace("nolink",Pa).getRegex(),mi=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,yr={_backpedal:Fe,anyPunctuation:No,autolink:Ho,blockSkip:Lo,br:La,code:xo,del:Fe,delLDelim:Fe,delRDelim:Fe,emStrongLDelim:$o,emStrongRDelimAst:Ro,emStrongRDelimUnd:Io,escape:ko,link:Wo,nolink:Pa,punctuation:So,reflink:Da,reflinkSearch:Uo,tag:Fo,text:wo,url:Fe},jo={...yr,link:j(/^!?\[(label)\]\((.*?)\)/).replace("label",Qt).getRegex(),reflink:j(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Qt).getRegex()},Vn={...yr,emStrongRDelimAst:Mo,emStrongLDelim:zo,delLDelim:Do,delRDelim:Oo,url:j(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",mi).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:j(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",mi).getRegex()},Go={...Vn,br:j(La).replace("{2,}","*").getRegex(),text:j(Vn.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Bt={normal:mr,gfm:_o,pedantic:bo},ht={normal:yr,gfm:Vn,breaks:Go,pedantic:jo},qo={"&":"&","<":"<",">":">",'"':""","'":"'"},gi=e=>qo[e];function xe(e,t){if(t){if(ce.escapeTest.test(e))return e.replace(ce.escapeReplace,gi)}else if(ce.escapeTestNoEncode.test(e))return e.replace(ce.escapeReplaceNoEncode,gi);return e}function yi(e){try{e=encodeURI(e).replace(ce.percentDecode,"%")}catch{return null}return e}function vi(e,t){var l;let r=e.replace(ce.findPipe,(s,o,d)=>{let c=!1,f=o;for(;--f>=0&&d[f]==="\\";)c=!c;return c?"|":" |"}),i=r.split(ce.splitPipe),a=0;if(i[0].trim()||i.shift(),i.length>0&&!((l=i.at(-1))!=null&&l.trim())&&i.pop(),t)if(i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;a<i.length;a++)i[a]=i[a].trim().replace(ce.slashPipe,"|");return i}function pt(e,t,r){let i=e.length;if(i===0)return"";let a=0;for(;a<i&&e.charAt(i-a-1)===t;)a++;return e.slice(0,i-a)}function Vo(e,t){if(e.indexOf(t[1])===-1)return-1;let r=0;for(let i=0;i<e.length;i++)if(e[i]==="\\")i++;else if(e[i]===t[0])r++;else if(e[i]===t[1]&&(r--,r<0))return i;return r>0?-2:-1}function Zo(e,t=0){let r=t,i="";for(let a of e)if(a===" "){let l=4-r%4;i+=" ".repeat(l),r+=l}else i+=a,r++;return i}function _i(e,t,r,i,a){let l=t.href,s=t.title||null,o=e[1].replace(a.other.outputLinkReplace,"$1");i.state.inLink=!0;let d={type:e[0].charAt(0)==="!"?"image":"link",raw:r,href:l,title:s,text:o,tokens:i.inlineTokens(o)};return i.state.inLink=!1,d}function Yo(e,t,r){let i=e.match(r.other.indentCodeCompensation);if(i===null)return t;let a=i[1];return t.split(`
|
|
7
|
+
`).map(l=>{let s=l.match(r.other.beginningSpace);if(s===null)return l;let[o]=s;return o.length>=a.length?l.slice(a.length):l}).join(`
|
|
8
|
+
`)}var en=class{constructor(e){Z(this,"options");Z(this,"rules");Z(this,"lexer");this.options=e||Ge}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let r=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?r:pt(r,`
|
|
9
|
+
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let r=t[0],i=Yo(r,t[3]||"",this.rules);return{type:"code",raw:r,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:i}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let r=t[2].trim();if(this.rules.other.endingHash.test(r)){let i=pt(r,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceChar.test(i))&&(r=i.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:pt(t[0],`
|
|
10
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let r=pt(t[0],`
|
|
11
|
+
`).split(`
|
|
12
|
+
`),i="",a="",l=[];for(;r.length>0;){let s=!1,o=[],d;for(d=0;d<r.length;d++)if(this.rules.other.blockquoteStart.test(r[d]))o.push(r[d]),s=!0;else if(!s)o.push(r[d]);else break;r=r.slice(d);let c=o.join(`
|
|
13
|
+
`),f=c.replace(this.rules.other.blockquoteSetextReplace,`
|
|
14
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");i=i?`${i}
|
|
15
|
+
${c}`:c,a=a?`${a}
|
|
16
|
+
${f}`:f;let h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(f,l,!0),this.lexer.state.top=h,r.length===0)break;let y=l.at(-1);if((y==null?void 0:y.type)==="code")break;if((y==null?void 0:y.type)==="blockquote"){let p=y,u=p.raw+`
|
|
17
|
+
`+r.join(`
|
|
18
|
+
`),_=this.blockquote(u);l[l.length-1]=_,i=i.substring(0,i.length-p.raw.length)+_.raw,a=a.substring(0,a.length-p.text.length)+_.text;break}else if((y==null?void 0:y.type)==="list"){let p=y,u=p.raw+`
|
|
19
|
+
`+r.join(`
|
|
20
|
+
`),_=this.list(u);l[l.length-1]=_,i=i.substring(0,i.length-y.raw.length)+_.raw,a=a.substring(0,a.length-p.raw.length)+_.raw,r=u.substring(l.at(-1).raw.length).split(`
|
|
21
|
+
`);continue}}return{type:"blockquote",raw:i,tokens:l,text:a}}}list(e){var r,i;let t=this.rules.block.list.exec(e);if(t){let a=t[1].trim(),l=a.length>1,s={type:"list",raw:"",ordered:l,start:l?+a.slice(0,-1):"",loose:!1,items:[]};a=l?`\\d{1,9}\\${a.slice(-1)}`:`\\${a}`,this.options.pedantic&&(a=l?a:"[*+-]");let o=this.rules.other.listItemRegex(a),d=!1;for(;e;){let f=!1,h="",y="";if(!(t=o.exec(e))||this.rules.block.hr.test(e))break;h=t[0],e=e.substring(h.length);let p=Zo(t[2].split(`
|
|
22
|
+
`,1)[0],t[1].length),u=e.split(`
|
|
23
|
+
`,1)[0],_=!p.trim(),w=0;if(this.options.pedantic?(w=2,y=p.trimStart()):_?w=t[1].length+1:(w=p.search(this.rules.other.nonSpaceChar),w=w>4?1:w,y=p.slice(w),w+=t[1].length),_&&this.rules.other.blankLine.test(u)&&(h+=u+`
|
|
24
|
+
`,e=e.substring(u.length+1),f=!0),!f){let k=this.rules.other.nextBulletRegex(w),g=this.rules.other.hrRegex(w),v=this.rules.other.fencesBeginRegex(w),E=this.rules.other.headingBeginRegex(w),z=this.rules.other.htmlBeginRegex(w),F=this.rules.other.blockquoteBeginRegex(w);for(;e;){let D=e.split(`
|
|
25
|
+
`,1)[0],P;if(u=D,this.options.pedantic?(u=u.replace(this.rules.other.listReplaceNesting," "),P=u):P=u.replace(this.rules.other.tabCharGlobal," "),v.test(u)||E.test(u)||z.test(u)||F.test(u)||k.test(u)||g.test(u))break;if(P.search(this.rules.other.nonSpaceChar)>=w||!u.trim())y+=`
|
|
26
|
+
`+P.slice(w);else{if(_||p.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||v.test(p)||E.test(p)||g.test(p))break;y+=`
|
|
27
|
+
`+u}_=!u.trim(),h+=D+`
|
|
28
|
+
`,e=e.substring(D.length+1),p=P.slice(w)}}s.loose||(d?s.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(d=!0)),s.items.push({type:"list_item",raw:h,task:!!this.options.gfm&&this.rules.other.listIsTask.test(y),loose:!1,text:y,tokens:[]}),s.raw+=h}let c=s.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;s.raw=s.raw.trimEnd();for(let f of s.items){if(this.lexer.state.top=!1,f.tokens=this.lexer.blockTokens(f.text,[]),f.task){if(f.text=f.text.replace(this.rules.other.listReplaceTask,""),((r=f.tokens[0])==null?void 0:r.type)==="text"||((i=f.tokens[0])==null?void 0:i.type)==="paragraph"){f.tokens[0].raw=f.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),f.tokens[0].text=f.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let y=this.lexer.inlineQueue.length-1;y>=0;y--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[y].src)){this.lexer.inlineQueue[y].src=this.lexer.inlineQueue[y].src.replace(this.rules.other.listReplaceTask,"");break}}let h=this.rules.other.listTaskCheckbox.exec(f.raw);if(h){let y={type:"checkbox",raw:h[0]+" ",checked:h[0]!=="[ ]"};f.checked=y.checked,s.loose?f.tokens[0]&&["paragraph","text"].includes(f.tokens[0].type)&&"tokens"in f.tokens[0]&&f.tokens[0].tokens?(f.tokens[0].raw=y.raw+f.tokens[0].raw,f.tokens[0].text=y.raw+f.tokens[0].text,f.tokens[0].tokens.unshift(y)):f.tokens.unshift({type:"paragraph",raw:y.raw,text:y.raw,tokens:[y]}):f.tokens.unshift(y)}}if(!s.loose){let h=f.tokens.filter(p=>p.type==="space"),y=h.length>0&&h.some(p=>this.rules.other.anyLine.test(p.raw));s.loose=y}}if(s.loose)for(let f of s.items){f.loose=!0;for(let h of f.tokens)h.type==="text"&&(h.type="paragraph")}return s}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let r=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),i=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",a=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:r,raw:t[0],href:i,title:a}}}table(e){var s;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let r=vi(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),a=(s=t[3])!=null&&s.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
29
|
+
`):[],l={type:"table",raw:t[0],header:[],align:[],rows:[]};if(r.length===i.length){for(let o of i)this.rules.other.tableAlignRight.test(o)?l.align.push("right"):this.rules.other.tableAlignCenter.test(o)?l.align.push("center"):this.rules.other.tableAlignLeft.test(o)?l.align.push("left"):l.align.push(null);for(let o=0;o<r.length;o++)l.header.push({text:r[o],tokens:this.lexer.inline(r[o]),header:!0,align:l.align[o]});for(let o of a)l.rows.push(vi(o,l.header.length).map((d,c)=>({text:d,tokens:this.lexer.inline(d),header:!1,align:l.align[c]})));return l}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let r=t[1].charAt(t[1].length-1)===`
|
|
30
|
+
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:r,tokens:this.lexer.inline(r)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let r=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let l=pt(r.slice(0,-1),"\\");if((r.length-l.length)%2===0)return}else{let l=Vo(t[2],"()");if(l===-2)return;if(l>-1){let s=(t[0].indexOf("!")===0?5:4)+t[1].length+l;t[2]=t[2].substring(0,l),t[0]=t[0].substring(0,s).trim(),t[3]=""}}let i=t[2],a="";if(this.options.pedantic){let l=this.rules.other.pedanticHrefTitle.exec(i);l&&(i=l[1],a=l[3])}else a=t[3]?t[3].slice(1,-1):"";return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?i=i.slice(1):i=i.slice(1,-1)),_i(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:a&&a.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let r;if((r=this.rules.inline.reflink.exec(e))||(r=this.rules.inline.nolink.exec(e))){let i=(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," "),a=t[i.toLowerCase()];if(!a){let l=r[0].charAt(0);return{type:"text",raw:l,text:l}}return _i(r,a,r[0],this.lexer,this.rules)}}emStrong(e,t,r=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||i[3]&&r.match(this.rules.other.unicodeAlphaNumeric))&&(!(i[1]||i[2])||!r||this.rules.inline.punctuation.exec(r))){let a=[...i[0]].length-1,l,s,o=a,d=0,c=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+a);(i=c.exec(t))!=null;){if(l=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!l)continue;if(s=[...l].length,i[3]||i[4]){o+=s;continue}else if((i[5]||i[6])&&a%3&&!((a+s)%3)){d+=s;continue}if(o-=s,o>0)continue;s=Math.min(s,s+o+d);let f=[...i[0]][0].length,h=e.slice(0,a+i.index+f+s);if(Math.min(a,s)%2){let p=h.slice(1,-1);return{type:"em",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}let y=h.slice(2,-2);return{type:"strong",raw:h,text:y,tokens:this.lexer.inlineTokens(y)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let r=t[2].replace(this.rules.other.newLineCharGlobal," "),i=this.rules.other.nonSpaceChar.test(r),a=this.rules.other.startingSpaceChar.test(r)&&this.rules.other.endingSpaceChar.test(r);return i&&a&&(r=r.substring(1,r.length-1)),{type:"codespan",raw:t[0],text:r}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,r=""){let i=this.rules.inline.delLDelim.exec(e);if(i&&(!i[1]||!r||this.rules.inline.punctuation.exec(r))){let a=[...i[0]].length-1,l,s,o=a,d=this.rules.inline.delRDelim;for(d.lastIndex=0,t=t.slice(-1*e.length+a);(i=d.exec(t))!=null;){if(l=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!l||(s=[...l].length,s!==a))continue;if(i[3]||i[4]){o+=s;continue}if(o-=s,o>0)continue;s=Math.min(s,s+o);let c=[...i[0]][0].length,f=e.slice(0,a+i.index+c+s),h=f.slice(a,-a);return{type:"del",raw:f,text:h,tokens:this.lexer.inlineTokens(h)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let r,i;return t[2]==="@"?(r=t[1],i="mailto:"+r):(r=t[1],i=r),{type:"link",raw:t[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}url(e){var r;let t;if(t=this.rules.inline.url.exec(e)){let i,a;if(t[2]==="@")i=t[0],a="mailto:"+i;else{let l;do l=t[0],t[0]=((r=this.rules.inline._backpedal.exec(t[0]))==null?void 0:r[0])??"";while(l!==t[0]);i=t[0],t[1]==="www."?a="http://"+t[0]:a=t[0]}return{type:"link",raw:t[0],text:i,href:a,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let r=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:r}}}},ve=class Zn{constructor(t){Z(this,"tokens");Z(this,"options");Z(this,"state");Z(this,"inlineQueue");Z(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Ge,this.options.tokenizer=this.options.tokenizer||new en,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let r={other:ce,block:Bt.normal,inline:ht.normal};this.options.pedantic?(r.block=Bt.pedantic,r.inline=ht.pedantic):this.options.gfm&&(r.block=Bt.gfm,this.options.breaks?r.inline=ht.breaks:r.inline=ht.gfm),this.tokenizer.rules=r}static get rules(){return{block:Bt,inline:ht}}static lex(t,r){return new Zn(r).lex(t)}static lexInline(t,r){return new Zn(r).inlineTokens(t)}lex(t){t=t.replace(ce.carriageReturn,`
|
|
31
|
+
`),this.blockTokens(t,this.tokens);for(let r=0;r<this.inlineQueue.length;r++){let i=this.inlineQueue[r];this.inlineTokens(i.src,i.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,r=[],i=!1){var a,l,s;for(this.options.pedantic&&(t=t.replace(ce.tabCharGlobal," ").replace(ce.spaceLine,""));t;){let o;if((l=(a=this.options.extensions)==null?void 0:a.block)!=null&&l.some(c=>(o=c.call({lexer:this},t,r))?(t=t.substring(o.raw.length),r.push(o),!0):!1))continue;if(o=this.tokenizer.space(t)){t=t.substring(o.raw.length);let c=r.at(-1);o.raw.length===1&&c!==void 0?c.raw+=`
|
|
32
|
+
`:r.push(o);continue}if(o=this.tokenizer.code(t)){t=t.substring(o.raw.length);let c=r.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
|
|
33
|
+
`)?"":`
|
|
34
|
+
`)+o.raw,c.text+=`
|
|
35
|
+
`+o.text,this.inlineQueue.at(-1).src=c.text):r.push(o);continue}if(o=this.tokenizer.fences(t)){t=t.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.heading(t)){t=t.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.hr(t)){t=t.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.blockquote(t)){t=t.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.list(t)){t=t.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.html(t)){t=t.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.def(t)){t=t.substring(o.raw.length);let c=r.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
|
|
36
|
+
`)?"":`
|
|
37
|
+
`)+o.raw,c.text+=`
|
|
38
|
+
`+o.raw,this.inlineQueue.at(-1).src=c.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title},r.push(o));continue}if(o=this.tokenizer.table(t)){t=t.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.lheading(t)){t=t.substring(o.raw.length),r.push(o);continue}let d=t;if((s=this.options.extensions)!=null&&s.startBlock){let c=1/0,f=t.slice(1),h;this.options.extensions.startBlock.forEach(y=>{h=y.call({lexer:this},f),typeof h=="number"&&h>=0&&(c=Math.min(c,h))}),c<1/0&&c>=0&&(d=t.substring(0,c+1))}if(this.state.top&&(o=this.tokenizer.paragraph(d))){let c=r.at(-1);i&&(c==null?void 0:c.type)==="paragraph"?(c.raw+=(c.raw.endsWith(`
|
|
39
|
+
`)?"":`
|
|
40
|
+
`)+o.raw,c.text+=`
|
|
41
|
+
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):r.push(o),i=d.length!==t.length,t=t.substring(o.raw.length);continue}if(o=this.tokenizer.text(t)){t=t.substring(o.raw.length);let c=r.at(-1);(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
|
|
42
|
+
`)?"":`
|
|
43
|
+
`)+o.raw,c.text+=`
|
|
44
|
+
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):r.push(o);continue}if(t){let c="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return this.state.top=!0,r}inline(t,r=[]){return this.inlineQueue.push({src:t,tokens:r}),r}inlineTokens(t,r=[]){var d,c,f,h,y;let i=t,a=null;if(this.tokens.links){let p=Object.keys(this.tokens.links);if(p.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)p.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+"a".repeat(a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.anyPunctuation.exec(i))!=null;)i=i.slice(0,a.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let l;for(;(a=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)l=a[2]?a[2].length:0,i=i.slice(0,a.index+l)+"["+"a".repeat(a[0].length-l-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);i=((c=(d=this.options.hooks)==null?void 0:d.emStrongMask)==null?void 0:c.call({lexer:this},i))??i;let s=!1,o="";for(;t;){s||(o=""),s=!1;let p;if((h=(f=this.options.extensions)==null?void 0:f.inline)!=null&&h.some(_=>(p=_.call({lexer:this},t,r))?(t=t.substring(p.raw.length),r.push(p),!0):!1))continue;if(p=this.tokenizer.escape(t)){t=t.substring(p.raw.length),r.push(p);continue}if(p=this.tokenizer.tag(t)){t=t.substring(p.raw.length),r.push(p);continue}if(p=this.tokenizer.link(t)){t=t.substring(p.raw.length),r.push(p);continue}if(p=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(p.raw.length);let _=r.at(-1);p.type==="text"&&(_==null?void 0:_.type)==="text"?(_.raw+=p.raw,_.text+=p.text):r.push(p);continue}if(p=this.tokenizer.emStrong(t,i,o)){t=t.substring(p.raw.length),r.push(p);continue}if(p=this.tokenizer.codespan(t)){t=t.substring(p.raw.length),r.push(p);continue}if(p=this.tokenizer.br(t)){t=t.substring(p.raw.length),r.push(p);continue}if(p=this.tokenizer.del(t,i,o)){t=t.substring(p.raw.length),r.push(p);continue}if(p=this.tokenizer.autolink(t)){t=t.substring(p.raw.length),r.push(p);continue}if(!this.state.inLink&&(p=this.tokenizer.url(t))){t=t.substring(p.raw.length),r.push(p);continue}let u=t;if((y=this.options.extensions)!=null&&y.startInline){let _=1/0,w=t.slice(1),k;this.options.extensions.startInline.forEach(g=>{k=g.call({lexer:this},w),typeof k=="number"&&k>=0&&(_=Math.min(_,k))}),_<1/0&&_>=0&&(u=t.substring(0,_+1))}if(p=this.tokenizer.inlineText(u)){t=t.substring(p.raw.length),p.raw.slice(-1)!=="_"&&(o=p.raw.slice(-1)),s=!0;let _=r.at(-1);(_==null?void 0:_.type)==="text"?(_.raw+=p.raw,_.text+=p.text):r.push(p);continue}if(t){let _="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(_);break}else throw new Error(_)}}return r}},tn=class{constructor(e){Z(this,"options");Z(this,"parser");this.options=e||Ge}space(e){return""}code({text:e,lang:t,escaped:r}){var l;let i=(l=(t||"").match(ce.notSpaceStart))==null?void 0:l[0],a=e.replace(ce.endingNewline,"")+`
|
|
45
|
+
`;return i?'<pre><code class="language-'+xe(i)+'">'+(r?a:xe(a,!0))+`</code></pre>
|
|
46
|
+
`:"<pre><code>"+(r?a:xe(a,!0))+`</code></pre>
|
|
47
|
+
`}blockquote({tokens:e}){return`<blockquote>
|
|
48
|
+
${this.parser.parse(e)}</blockquote>
|
|
49
|
+
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
50
|
+
`}hr(e){return`<hr>
|
|
51
|
+
`}list(e){let t=e.ordered,r=e.start,i="";for(let s=0;s<e.items.length;s++){let o=e.items[s];i+=this.listitem(o)}let a=t?"ol":"ul",l=t&&r!==1?' start="'+r+'"':"";return"<"+a+l+`>
|
|
52
|
+
`+i+"</"+a+`>
|
|
53
|
+
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
54
|
+
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
55
|
+
`}table(e){let t="",r="";for(let a=0;a<e.header.length;a++)r+=this.tablecell(e.header[a]);t+=this.tablerow({text:r});let i="";for(let a=0;a<e.rows.length;a++){let l=e.rows[a];r="";for(let s=0;s<l.length;s++)r+=this.tablecell(l[s]);i+=this.tablerow({text:r})}return i&&(i=`<tbody>${i}</tbody>`),`<table>
|
|
56
|
+
<thead>
|
|
57
|
+
`+t+`</thead>
|
|
58
|
+
`+i+`</table>
|
|
59
|
+
`}tablerow({text:e}){return`<tr>
|
|
60
|
+
${e}</tr>
|
|
61
|
+
`}tablecell(e){let t=this.parser.parseInline(e.tokens),r=e.header?"th":"td";return(e.align?`<${r} align="${e.align}">`:`<${r}>`)+t+`</${r}>
|
|
62
|
+
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${xe(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:r}){let i=this.parser.parseInline(r),a=yi(e);if(a===null)return i;e=a;let l='<a href="'+e+'"';return t&&(l+=' title="'+xe(t)+'"'),l+=">"+i+"</a>",l}image({href:e,title:t,text:r,tokens:i}){i&&(r=this.parser.parseInline(i,this.parser.textRenderer));let a=yi(e);if(a===null)return xe(r);e=a;let l=`<img src="${e}" alt="${xe(r)}"`;return t&&(l+=` title="${xe(t)}"`),l+=">",l}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:xe(e.text)}},vr=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},_e=class Yn{constructor(t){Z(this,"options");Z(this,"renderer");Z(this,"textRenderer");this.options=t||Ge,this.options.renderer=this.options.renderer||new tn,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new vr}static parse(t,r){return new Yn(r).parse(t)}static parseInline(t,r){return new Yn(r).parseInline(t)}parse(t){var i,a;let r="";for(let l=0;l<t.length;l++){let s=t[l];if((a=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&a[s.type]){let d=s,c=this.options.extensions.renderers[d.type].call({parser:this},d);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(d.type)){r+=c||"";continue}}let o=s;switch(o.type){case"space":{r+=this.renderer.space(o);break}case"hr":{r+=this.renderer.hr(o);break}case"heading":{r+=this.renderer.heading(o);break}case"code":{r+=this.renderer.code(o);break}case"table":{r+=this.renderer.table(o);break}case"blockquote":{r+=this.renderer.blockquote(o);break}case"list":{r+=this.renderer.list(o);break}case"checkbox":{r+=this.renderer.checkbox(o);break}case"html":{r+=this.renderer.html(o);break}case"def":{r+=this.renderer.def(o);break}case"paragraph":{r+=this.renderer.paragraph(o);break}case"text":{r+=this.renderer.text(o);break}default:{let d='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(d),"";throw new Error(d)}}}return r}parseInline(t,r=this.renderer){var a,l;let i="";for(let s=0;s<t.length;s++){let o=t[s];if((l=(a=this.options.extensions)==null?void 0:a.renderers)!=null&&l[o.type]){let c=this.options.extensions.renderers[o.type].call({parser:this},o);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(o.type)){i+=c||"";continue}}let d=o;switch(d.type){case"escape":{i+=r.text(d);break}case"html":{i+=r.html(d);break}case"link":{i+=r.link(d);break}case"image":{i+=r.image(d);break}case"checkbox":{i+=r.checkbox(d);break}case"strong":{i+=r.strong(d);break}case"em":{i+=r.em(d);break}case"codespan":{i+=r.codespan(d);break}case"br":{i+=r.br(d);break}case"del":{i+=r.del(d);break}case"text":{i+=r.text(d);break}default:{let c='Token with "'+d.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return i}},Ut,wt=(Ut=class{constructor(e){Z(this,"options");Z(this,"block");this.options=e||Ge}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?ve.lex:ve.lexInline}provideParser(){return this.block?_e.parse:_e.parseInline}},Z(Ut,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),Z(Ut,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Ut),Ko=class{constructor(...e){Z(this,"defaults",dr());Z(this,"options",this.setOptions);Z(this,"parse",this.parseMarkdown(!0));Z(this,"parseInline",this.parseMarkdown(!1));Z(this,"Parser",_e);Z(this,"Renderer",tn);Z(this,"TextRenderer",vr);Z(this,"Lexer",ve);Z(this,"Tokenizer",en);Z(this,"Hooks",wt);this.use(...e)}walkTokens(e,t){var i,a;let r=[];for(let l of e)switch(r=r.concat(t.call(this,l)),l.type){case"table":{let s=l;for(let o of s.header)r=r.concat(this.walkTokens(o.tokens,t));for(let o of s.rows)for(let d of o)r=r.concat(this.walkTokens(d.tokens,t));break}case"list":{let s=l;r=r.concat(this.walkTokens(s.items,t));break}default:{let s=l;(a=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&a[s.type]?this.defaults.extensions.childTokens[s.type].forEach(o=>{let d=s[o].flat(1/0);r=r.concat(this.walkTokens(d,t))}):s.tokens&&(r=r.concat(this.walkTokens(s.tokens,t)))}}return r}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(r=>{let i={...r};if(i.async=this.defaults.async||i.async||!1,r.extensions&&(r.extensions.forEach(a=>{if(!a.name)throw new Error("extension name required");if("renderer"in a){let l=t.renderers[a.name];l?t.renderers[a.name]=function(...s){let o=a.renderer.apply(this,s);return o===!1&&(o=l.apply(this,s)),o}:t.renderers[a.name]=a.renderer}if("tokenizer"in a){if(!a.level||a.level!=="block"&&a.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let l=t[a.level];l?l.unshift(a.tokenizer):t[a.level]=[a.tokenizer],a.start&&(a.level==="block"?t.startBlock?t.startBlock.push(a.start):t.startBlock=[a.start]:a.level==="inline"&&(t.startInline?t.startInline.push(a.start):t.startInline=[a.start]))}"childTokens"in a&&a.childTokens&&(t.childTokens[a.name]=a.childTokens)}),i.extensions=t),r.renderer){let a=this.defaults.renderer||new tn(this.defaults);for(let l in r.renderer){if(!(l in a))throw new Error(`renderer '${l}' does not exist`);if(["options","parser"].includes(l))continue;let s=l,o=r.renderer[s],d=a[s];a[s]=(...c)=>{let f=o.apply(a,c);return f===!1&&(f=d.apply(a,c)),f||""}}i.renderer=a}if(r.tokenizer){let a=this.defaults.tokenizer||new en(this.defaults);for(let l in r.tokenizer){if(!(l in a))throw new Error(`tokenizer '${l}' does not exist`);if(["options","rules","lexer"].includes(l))continue;let s=l,o=r.tokenizer[s],d=a[s];a[s]=(...c)=>{let f=o.apply(a,c);return f===!1&&(f=d.apply(a,c)),f}}i.tokenizer=a}if(r.hooks){let a=this.defaults.hooks||new wt;for(let l in r.hooks){if(!(l in a))throw new Error(`hook '${l}' does not exist`);if(["options","block"].includes(l))continue;let s=l,o=r.hooks[s],d=a[s];wt.passThroughHooks.has(l)?a[s]=c=>{if(this.defaults.async&&wt.passThroughHooksRespectAsync.has(l))return(async()=>{let h=await o.call(a,c);return d.call(a,h)})();let f=o.call(a,c);return d.call(a,f)}:a[s]=(...c)=>{if(this.defaults.async)return(async()=>{let h=await o.apply(a,c);return h===!1&&(h=await d.apply(a,c)),h})();let f=o.apply(a,c);return f===!1&&(f=d.apply(a,c)),f}}i.hooks=a}if(r.walkTokens){let a=this.defaults.walkTokens,l=r.walkTokens;i.walkTokens=function(s){let o=[];return o.push(l.call(this,s)),a&&(o=o.concat(a.call(this,s))),o}}this.defaults={...this.defaults,...i}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ve.lex(e,t??this.defaults)}parser(e,t){return _e.parse(e,t??this.defaults)}parseMarkdown(e){return(t,r)=>{let i={...r},a={...this.defaults,...i},l=this.onError(!!a.silent,!!a.async);if(this.defaults.async===!0&&i.async===!1)return l(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return l(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return l(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(a.hooks&&(a.hooks.options=a,a.hooks.block=e),a.async)return(async()=>{let s=a.hooks?await a.hooks.preprocess(t):t,o=await(a.hooks?await a.hooks.provideLexer():e?ve.lex:ve.lexInline)(s,a),d=a.hooks?await a.hooks.processAllTokens(o):o;a.walkTokens&&await Promise.all(this.walkTokens(d,a.walkTokens));let c=await(a.hooks?await a.hooks.provideParser():e?_e.parse:_e.parseInline)(d,a);return a.hooks?await a.hooks.postprocess(c):c})().catch(l);try{a.hooks&&(t=a.hooks.preprocess(t));let s=(a.hooks?a.hooks.provideLexer():e?ve.lex:ve.lexInline)(t,a);a.hooks&&(s=a.hooks.processAllTokens(s)),a.walkTokens&&this.walkTokens(s,a.walkTokens);let o=(a.hooks?a.hooks.provideParser():e?_e.parse:_e.parseInline)(s,a);return a.hooks&&(o=a.hooks.postprocess(o)),o}catch(s){return l(s)}}}onError(e,t){return r=>{if(r.message+=`
|
|
63
|
+
Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+xe(r.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(r);throw r}}},je=new Ko;function V(e,t){return je.parse(e,t)}V.options=V.setOptions=function(e){return je.setOptions(e),V.defaults=je.defaults,Ta(V.defaults),V};V.getDefaults=dr;V.defaults=Ge;V.use=function(...e){return je.use(...e),V.defaults=je.defaults,Ta(V.defaults),V};V.walkTokens=function(e,t){return je.walkTokens(e,t)};V.parseInline=je.parseInline;V.Parser=_e;V.parser=_e.parse;V.Renderer=tn;V.TextRenderer=vr;V.Lexer=ve;V.lexer=ve.lex;V.Tokenizer=en;V.Hooks=wt;V.parse=V;V.options;V.setOptions;V.use;V.walkTokens;V.parseInline;_e.parse;ve.lex;/*! @license DOMPurify 3.3.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.1/LICENSE */const{entries:Oa,setPrototypeOf:bi,isFrozen:Jo,getPrototypeOf:Xo,getOwnPropertyDescriptor:Qo}=Object;let{freeze:de,seal:me,create:Kn}=Object,{apply:Jn,construct:Xn}=typeof Reflect<"u"&&Reflect;de||(de=function(t){return t});me||(me=function(t){return t});Jn||(Jn=function(t,r){for(var i=arguments.length,a=new Array(i>2?i-2:0),l=2;l<i;l++)a[l-2]=arguments[l];return t.apply(r,a)});Xn||(Xn=function(t){for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];return new t(...i)});const Ft=ue(Array.prototype.forEach),ec=ue(Array.prototype.lastIndexOf),ki=ue(Array.prototype.pop),ft=ue(Array.prototype.push),tc=ue(Array.prototype.splice),qt=ue(String.prototype.toLowerCase),Tn=ue(String.prototype.toString),Cn=ue(String.prototype.match),mt=ue(String.prototype.replace),nc=ue(String.prototype.indexOf),rc=ue(String.prototype.trim),ye=ue(Object.prototype.hasOwnProperty),oe=ue(RegExp.prototype.test),gt=ic(TypeError);function ue(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];return Jn(e,t,i)}}function ic(e){return function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return Xn(e,r)}}function W(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:qt;bi&&bi(e,null);let i=t.length;for(;i--;){let a=t[i];if(typeof a=="string"){const l=r(a);l!==a&&(Jo(t)||(t[i]=l),a=l)}e[a]=!0}return e}function ac(e){for(let t=0;t<e.length;t++)ye(e,t)||(e[t]=null);return e}function we(e){const t=Kn(null);for(const[r,i]of Oa(e))ye(e,r)&&(Array.isArray(i)?t[r]=ac(i):i&&typeof i=="object"&&i.constructor===Object?t[r]=we(i):t[r]=i);return t}function yt(e,t){for(;e!==null;){const i=Qo(e,t);if(i){if(i.get)return ue(i.get);if(typeof i.value=="function")return ue(i.value)}e=Xo(e)}function r(){return null}return r}const xi=de(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),An=de(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),En=de(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),lc=de(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Ln=de(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),sc=de(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),wi=de(["#text"]),Si=de(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),$n=de(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Ti=de(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Wt=de(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),oc=me(/\{\{[\w\W]*|[\w\W]*\}\}/gm),cc=me(/<%[\w\W]*|[\w\W]*%>/gm),dc=me(/\$\{[\w\W]*/gm),uc=me(/^data-[\-\w.\u00B7-\uFFFF]+$/),hc=me(/^aria-[\-\w]+$/),Na=me(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),pc=me(/^(?:\w+script|data):/i),fc=me(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ha=me(/^html$/i),mc=me(/^[a-z][.\w]*(-[.\w]+)+$/i);var Ci=Object.freeze({__proto__:null,ARIA_ATTR:hc,ATTR_WHITESPACE:fc,CUSTOM_ELEMENT:mc,DATA_ATTR:uc,DOCTYPE_NAME:Ha,ERB_EXPR:cc,IS_ALLOWED_URI:Na,IS_SCRIPT_OR_DATA:pc,MUSTACHE_EXPR:oc,TMPLIT_EXPR:dc});const vt={element:1,text:3,progressingInstruction:7,comment:8,document:9},gc=function(){return typeof window>"u"?null:window},yc=function(t,r){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let i=null;const a="data-tt-policy-suffix";r&&r.hasAttribute(a)&&(i=r.getAttribute(a));const l="dompurify"+(i?"#"+i:"");try{return t.createPolicy(l,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+l+" could not be created."),null}},Ai=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Ba(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:gc();const t=I=>Ba(I);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==vt.document||!e.Element)return t.isSupported=!1,t;let{document:r}=e;const i=r,a=i.currentScript,{DocumentFragment:l,HTMLTemplateElement:s,Node:o,Element:d,NodeFilter:c,NamedNodeMap:f=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:h,DOMParser:y,trustedTypes:p}=e,u=d.prototype,_=yt(u,"cloneNode"),w=yt(u,"remove"),k=yt(u,"nextSibling"),g=yt(u,"childNodes"),v=yt(u,"parentNode");if(typeof s=="function"){const I=r.createElement("template");I.content&&I.content.ownerDocument&&(r=I.content.ownerDocument)}let E,z="";const{implementation:F,createNodeIterator:D,createDocumentFragment:P,getElementsByTagName:S}=r,{importNode:b}=i;let R=Ai();t.isSupported=typeof Oa=="function"&&typeof v=="function"&&F&&F.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:L,ERB_EXPR:G,TMPLIT_EXPR:te,DATA_ATTR:T,ARIA_ATTR:H,IS_SCRIPT_OR_DATA:he,ATTR_WHITESPACE:ge,CUSTOM_ELEMENT:De}=Ci;let{IS_ALLOWED_URI:Pe}=Ci,X=null;const le=W({},[...xi,...An,...En,...Ln,...wi]);let Y=null;const Oe=W({},[...Si,...$n,...Ti,...Wt]);let ee=Object.seal(Kn(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ot=null,dn=null;const qe=Object.seal(Kn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let _r=!0,un=!0,br=!1,kr=!0,Ve=!1,Rt=!0,Ne=!1,hn=!1,pn=!1,Ze=!1,Mt=!1,It=!1,xr=!0,wr=!1;const Fa="user-content-";let fn=!0,ct=!1,Ye={},be=null;const mn=W({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Sr=null;const Tr=W({},["audio","video","img","source","image","track"]);let gn=null;const Cr=W({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Dt="http://www.w3.org/1998/Math/MathML",Pt="http://www.w3.org/2000/svg",Ce="http://www.w3.org/1999/xhtml";let Ke=Ce,yn=!1,vn=null;const Wa=W({},[Dt,Pt,Ce],Tn);let Ot=W({},["mi","mo","mn","ms","mtext"]),Nt=W({},["annotation-xml"]);const Ua=W({},["title","style","font","a","script"]);let dt=null;const ja=["application/xhtml+xml","text/html"],Ga="text/html";let re=null,Je=null;const qa=r.createElement("form"),Ar=function(m){return m instanceof RegExp||m instanceof Function},_n=function(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Je&&Je===m)){if((!m||typeof m!="object")&&(m={}),m=we(m),dt=ja.indexOf(m.PARSER_MEDIA_TYPE)===-1?Ga:m.PARSER_MEDIA_TYPE,re=dt==="application/xhtml+xml"?Tn:qt,X=ye(m,"ALLOWED_TAGS")?W({},m.ALLOWED_TAGS,re):le,Y=ye(m,"ALLOWED_ATTR")?W({},m.ALLOWED_ATTR,re):Oe,vn=ye(m,"ALLOWED_NAMESPACES")?W({},m.ALLOWED_NAMESPACES,Tn):Wa,gn=ye(m,"ADD_URI_SAFE_ATTR")?W(we(Cr),m.ADD_URI_SAFE_ATTR,re):Cr,Sr=ye(m,"ADD_DATA_URI_TAGS")?W(we(Tr),m.ADD_DATA_URI_TAGS,re):Tr,be=ye(m,"FORBID_CONTENTS")?W({},m.FORBID_CONTENTS,re):mn,ot=ye(m,"FORBID_TAGS")?W({},m.FORBID_TAGS,re):we({}),dn=ye(m,"FORBID_ATTR")?W({},m.FORBID_ATTR,re):we({}),Ye=ye(m,"USE_PROFILES")?m.USE_PROFILES:!1,_r=m.ALLOW_ARIA_ATTR!==!1,un=m.ALLOW_DATA_ATTR!==!1,br=m.ALLOW_UNKNOWN_PROTOCOLS||!1,kr=m.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ve=m.SAFE_FOR_TEMPLATES||!1,Rt=m.SAFE_FOR_XML!==!1,Ne=m.WHOLE_DOCUMENT||!1,Ze=m.RETURN_DOM||!1,Mt=m.RETURN_DOM_FRAGMENT||!1,It=m.RETURN_TRUSTED_TYPE||!1,pn=m.FORCE_BODY||!1,xr=m.SANITIZE_DOM!==!1,wr=m.SANITIZE_NAMED_PROPS||!1,fn=m.KEEP_CONTENT!==!1,ct=m.IN_PLACE||!1,Pe=m.ALLOWED_URI_REGEXP||Na,Ke=m.NAMESPACE||Ce,Ot=m.MATHML_TEXT_INTEGRATION_POINTS||Ot,Nt=m.HTML_INTEGRATION_POINTS||Nt,ee=m.CUSTOM_ELEMENT_HANDLING||{},m.CUSTOM_ELEMENT_HANDLING&&Ar(m.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(ee.tagNameCheck=m.CUSTOM_ELEMENT_HANDLING.tagNameCheck),m.CUSTOM_ELEMENT_HANDLING&&Ar(m.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(ee.attributeNameCheck=m.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),m.CUSTOM_ELEMENT_HANDLING&&typeof m.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(ee.allowCustomizedBuiltInElements=m.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Ve&&(un=!1),Mt&&(Ze=!0),Ye&&(X=W({},wi),Y=[],Ye.html===!0&&(W(X,xi),W(Y,Si)),Ye.svg===!0&&(W(X,An),W(Y,$n),W(Y,Wt)),Ye.svgFilters===!0&&(W(X,En),W(Y,$n),W(Y,Wt)),Ye.mathMl===!0&&(W(X,Ln),W(Y,Ti),W(Y,Wt))),m.ADD_TAGS&&(typeof m.ADD_TAGS=="function"?qe.tagCheck=m.ADD_TAGS:(X===le&&(X=we(X)),W(X,m.ADD_TAGS,re))),m.ADD_ATTR&&(typeof m.ADD_ATTR=="function"?qe.attributeCheck=m.ADD_ATTR:(Y===Oe&&(Y=we(Y)),W(Y,m.ADD_ATTR,re))),m.ADD_URI_SAFE_ATTR&&W(gn,m.ADD_URI_SAFE_ATTR,re),m.FORBID_CONTENTS&&(be===mn&&(be=we(be)),W(be,m.FORBID_CONTENTS,re)),m.ADD_FORBID_CONTENTS&&(be===mn&&(be=we(be)),W(be,m.ADD_FORBID_CONTENTS,re)),fn&&(X["#text"]=!0),Ne&&W(X,["html","head","body"]),X.table&&(W(X,["tbody"]),delete ot.tbody),m.TRUSTED_TYPES_POLICY){if(typeof m.TRUSTED_TYPES_POLICY.createHTML!="function")throw gt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof m.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw gt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');E=m.TRUSTED_TYPES_POLICY,z=E.createHTML("")}else E===void 0&&(E=yc(p,a)),E!==null&&typeof z=="string"&&(z=E.createHTML(""));de&&de(m),Je=m}},Er=W({},[...An,...En,...lc]),Lr=W({},[...Ln,...sc]),Va=function(m){let A=v(m);(!A||!A.tagName)&&(A={namespaceURI:Ke,tagName:"template"});const $=qt(m.tagName),J=qt(A.tagName);return vn[m.namespaceURI]?m.namespaceURI===Pt?A.namespaceURI===Ce?$==="svg":A.namespaceURI===Dt?$==="svg"&&(J==="annotation-xml"||Ot[J]):!!Er[$]:m.namespaceURI===Dt?A.namespaceURI===Ce?$==="math":A.namespaceURI===Pt?$==="math"&&Nt[J]:!!Lr[$]:m.namespaceURI===Ce?A.namespaceURI===Pt&&!Nt[J]||A.namespaceURI===Dt&&!Ot[J]?!1:!Lr[$]&&(Ua[$]||!Er[$]):!!(dt==="application/xhtml+xml"&&vn[m.namespaceURI]):!1},ke=function(m){ft(t.removed,{element:m});try{v(m).removeChild(m)}catch{w(m)}},He=function(m,A){try{ft(t.removed,{attribute:A.getAttributeNode(m),from:A})}catch{ft(t.removed,{attribute:null,from:A})}if(A.removeAttribute(m),m==="is")if(Ze||Mt)try{ke(A)}catch{}else try{A.setAttribute(m,"")}catch{}},$r=function(m){let A=null,$=null;if(pn)m="<remove></remove>"+m;else{const ne=Cn(m,/^[\r\n\t ]+/);$=ne&&ne[0]}dt==="application/xhtml+xml"&&Ke===Ce&&(m='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+m+"</body></html>");const J=E?E.createHTML(m):m;if(Ke===Ce)try{A=new y().parseFromString(J,dt)}catch{}if(!A||!A.documentElement){A=F.createDocument(Ke,"template",null);try{A.documentElement.innerHTML=yn?z:J}catch{}}const se=A.body||A.documentElement;return m&&$&&se.insertBefore(r.createTextNode($),se.childNodes[0]||null),Ke===Ce?S.call(A,Ne?"html":"body")[0]:Ne?A.documentElement:se},zr=function(m){return D.call(m.ownerDocument||m,m,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},bn=function(m){return m instanceof h&&(typeof m.nodeName!="string"||typeof m.textContent!="string"||typeof m.removeChild!="function"||!(m.attributes instanceof f)||typeof m.removeAttribute!="function"||typeof m.setAttribute!="function"||typeof m.namespaceURI!="string"||typeof m.insertBefore!="function"||typeof m.hasChildNodes!="function")},Rr=function(m){return typeof o=="function"&&m instanceof o};function Ae(I,m,A){Ft(I,$=>{$.call(t,m,A,Je)})}const Mr=function(m){let A=null;if(Ae(R.beforeSanitizeElements,m,null),bn(m))return ke(m),!0;const $=re(m.nodeName);if(Ae(R.uponSanitizeElement,m,{tagName:$,allowedTags:X}),Rt&&m.hasChildNodes()&&!Rr(m.firstElementChild)&&oe(/<[/\w!]/g,m.innerHTML)&&oe(/<[/\w!]/g,m.textContent)||m.nodeType===vt.progressingInstruction||Rt&&m.nodeType===vt.comment&&oe(/<[/\w]/g,m.data))return ke(m),!0;if(!(qe.tagCheck instanceof Function&&qe.tagCheck($))&&(!X[$]||ot[$])){if(!ot[$]&&Dr($)&&(ee.tagNameCheck instanceof RegExp&&oe(ee.tagNameCheck,$)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck($)))return!1;if(fn&&!be[$]){const J=v(m)||m.parentNode,se=g(m)||m.childNodes;if(se&&J){const ne=se.length;for(let pe=ne-1;pe>=0;--pe){const Ee=_(se[pe],!0);Ee.__removalCount=(m.__removalCount||0)+1,J.insertBefore(Ee,k(m))}}}return ke(m),!0}return m instanceof d&&!Va(m)||($==="noscript"||$==="noembed"||$==="noframes")&&oe(/<\/no(script|embed|frames)/i,m.innerHTML)?(ke(m),!0):(Ve&&m.nodeType===vt.text&&(A=m.textContent,Ft([L,G,te],J=>{A=mt(A,J," ")}),m.textContent!==A&&(ft(t.removed,{element:m.cloneNode()}),m.textContent=A)),Ae(R.afterSanitizeElements,m,null),!1)},Ir=function(m,A,$){if(xr&&(A==="id"||A==="name")&&($ in r||$ in qa))return!1;if(!(un&&!dn[A]&&oe(T,A))){if(!(_r&&oe(H,A))){if(!(qe.attributeCheck instanceof Function&&qe.attributeCheck(A,m))){if(!Y[A]||dn[A]){if(!(Dr(m)&&(ee.tagNameCheck instanceof RegExp&&oe(ee.tagNameCheck,m)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck(m))&&(ee.attributeNameCheck instanceof RegExp&&oe(ee.attributeNameCheck,A)||ee.attributeNameCheck instanceof Function&&ee.attributeNameCheck(A,m))||A==="is"&&ee.allowCustomizedBuiltInElements&&(ee.tagNameCheck instanceof RegExp&&oe(ee.tagNameCheck,$)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck($))))return!1}else if(!gn[A]){if(!oe(Pe,mt($,ge,""))){if(!((A==="src"||A==="xlink:href"||A==="href")&&m!=="script"&&nc($,"data:")===0&&Sr[m])){if(!(br&&!oe(he,mt($,ge,"")))){if($)return!1}}}}}}}return!0},Dr=function(m){return m!=="annotation-xml"&&Cn(m,De)},Pr=function(m){Ae(R.beforeSanitizeAttributes,m,null);const{attributes:A}=m;if(!A||bn(m))return;const $={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Y,forceKeepAttr:void 0};let J=A.length;for(;J--;){const se=A[J],{name:ne,namespaceURI:pe,value:Ee}=se,Xe=re(ne),kn=Ee;let ie=ne==="value"?kn:rc(kn);if($.attrName=Xe,$.attrValue=ie,$.keepAttr=!0,$.forceKeepAttr=void 0,Ae(R.uponSanitizeAttribute,m,$),ie=$.attrValue,wr&&(Xe==="id"||Xe==="name")&&(He(ne,m),ie=Fa+ie),Rt&&oe(/((--!?|])>)|<\/(style|title|textarea)/i,ie)){He(ne,m);continue}if(Xe==="attributename"&&Cn(ie,"href")){He(ne,m);continue}if($.forceKeepAttr)continue;if(!$.keepAttr){He(ne,m);continue}if(!kr&&oe(/\/>/i,ie)){He(ne,m);continue}Ve&&Ft([L,G,te],Nr=>{ie=mt(ie,Nr," ")});const Or=re(m.nodeName);if(!Ir(Or,Xe,ie)){He(ne,m);continue}if(E&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!pe)switch(p.getAttributeType(Or,Xe)){case"TrustedHTML":{ie=E.createHTML(ie);break}case"TrustedScriptURL":{ie=E.createScriptURL(ie);break}}if(ie!==kn)try{pe?m.setAttributeNS(pe,ne,ie):m.setAttribute(ne,ie),bn(m)?ke(m):ki(t.removed)}catch{He(ne,m)}}Ae(R.afterSanitizeAttributes,m,null)},Za=function I(m){let A=null;const $=zr(m);for(Ae(R.beforeSanitizeShadowDOM,m,null);A=$.nextNode();)Ae(R.uponSanitizeShadowNode,A,null),Mr(A),Pr(A),A.content instanceof l&&I(A.content);Ae(R.afterSanitizeShadowDOM,m,null)};return t.sanitize=function(I){let m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},A=null,$=null,J=null,se=null;if(yn=!I,yn&&(I="<!-->"),typeof I!="string"&&!Rr(I))if(typeof I.toString=="function"){if(I=I.toString(),typeof I!="string")throw gt("dirty is not a string, aborting")}else throw gt("toString is not a function");if(!t.isSupported)return I;if(hn||_n(m),t.removed=[],typeof I=="string"&&(ct=!1),ct){if(I.nodeName){const Ee=re(I.nodeName);if(!X[Ee]||ot[Ee])throw gt("root node is forbidden and cannot be sanitized in-place")}}else if(I instanceof o)A=$r("<!---->"),$=A.ownerDocument.importNode(I,!0),$.nodeType===vt.element&&$.nodeName==="BODY"||$.nodeName==="HTML"?A=$:A.appendChild($);else{if(!Ze&&!Ve&&!Ne&&I.indexOf("<")===-1)return E&&It?E.createHTML(I):I;if(A=$r(I),!A)return Ze?null:It?z:""}A&&pn&&ke(A.firstChild);const ne=zr(ct?I:A);for(;J=ne.nextNode();)Mr(J),Pr(J),J.content instanceof l&&Za(J.content);if(ct)return I;if(Ze){if(Mt)for(se=P.call(A.ownerDocument);A.firstChild;)se.appendChild(A.firstChild);else se=A;return(Y.shadowroot||Y.shadowrootmode)&&(se=b.call(i,se,!0)),se}let pe=Ne?A.outerHTML:A.innerHTML;return Ne&&X["!doctype"]&&A.ownerDocument&&A.ownerDocument.doctype&&A.ownerDocument.doctype.name&&oe(Ha,A.ownerDocument.doctype.name)&&(pe="<!DOCTYPE "+A.ownerDocument.doctype.name+`>
|
|
64
|
+
`+pe),Ve&&Ft([L,G,te],Ee=>{pe=mt(pe,Ee," ")}),E&&It?E.createHTML(pe):pe},t.setConfig=function(){let I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_n(I),hn=!0},t.clearConfig=function(){Je=null,hn=!1},t.isValidAttribute=function(I,m,A){Je||_n({});const $=re(I),J=re(m);return Ir($,J,A)},t.addHook=function(I,m){typeof m=="function"&&ft(R[I],m)},t.removeHook=function(I,m){if(m!==void 0){const A=ec(R[I],m);return A===-1?void 0:tc(R[I],A,1)[0]}return ki(R[I])},t.removeHooks=function(I){R[I]=[]},t.removeAllHooks=function(){R=Ai()},t}var vc=Ba();function At({content:e,className:t,style:r}){if(!e)return null;const i=V.parse(e,{breaks:!0,gfm:!0}),a=vc.sanitize(i,{ALLOWED_TAGS:["h1","h2","h3","h4","h5","h6","p","br","hr","strong","em","b","i","u","code","pre","ul","ol","li","blockquote","a","table","thead","tbody","tr","th","td","span","div"],ALLOWED_ATTR:["href","target","rel","class"]});return n("div",{className:t,style:r,dangerouslySetInnerHTML:{__html:a}})}const nn=[{color:"#b48b7f",soft:"rgba(180, 139, 127, 0.12)"},{color:"#9d8792",soft:"rgba(157, 135, 146, 0.12)"},{color:"#7f9a9a",soft:"rgba(127, 154, 154, 0.12)"},{color:"#a9957a",soft:"rgba(169, 149, 122, 0.12)"},{color:"#8a859d",soft:"rgba(138, 133, 157, 0.12)"}];function _c(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return Math.abs(t)}function bc(e){return nn[_c(e)%nn.length]}function kc(e){return typeof e.durationSeconds=="number"?e.durationSeconds:Math.max(0,Math.round((Date.now()-new Date(e.startedAt).getTime())/1e3))}function Ei(e){const t=kc(e);if(t<60)return`${t}s`;const r=Math.floor(t/60),i=t%60;return`${r}m ${i}s`}function _t(e){return e==="completed"?"completed":e==="cancelled"||e==="failed"||e==="timeout"?"failed":e==="pending"?"pending":"running"}function xc(e){return e?new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"--:--"}function Li(e){return e==="completed"?n(Me,{size:20}):e==="cancelled"?n(lt,{size:20}):e==="failed"||e==="timeout"?n(lt,{size:20}):n(fe,{size:20})}function wc(){const[e,t]=x([]),[r,i]=x(0),[a,l]=x(!0),[s,o]=x(0),[d,c]=x(new Set),[f]=x(()=>nn[Math.floor(Math.random()*nn.length)]),h=10;q(()=>{y();const g=setInterval(y,3e3);return()=>clearInterval(g)},[]);async function y(){try{const[g,v]=await Promise.all([Ms(),cr().catch(()=>null)]);t(g.agents??[]),v&&i(v.today.totalCost)}catch{}finally{l(!1)}}async function p(g){if(!d.has(g)){c(v=>new Set(v).add(g));try{await Is(g),await y()}catch{}finally{c(v=>{const E=new Set(v);return E.delete(g),E})}}}const u=$e(()=>{const g=new Map;for(const v of e){if(!v.parentTaskId)continue;const E=g.get(v.parentTaskId)??[];E.push(v),g.set(v.parentTaskId,E)}return g},[e]),_=$e(()=>e.filter(g=>!g.parentTaskId),[e]),w=$e(()=>{const g=s*h;return _.slice(g,g+h)},[_,s]);q(()=>{const g=Math.max(0,Math.ceil(_.length/h)-1);s>g&&o(g)},[_.length,s]);const k=$e(()=>{const g=_.filter(z=>_t(z.status)==="running").length,v=_.filter(z=>_t(z.status)==="completed").length,E=_.filter(z=>_t(z.status)==="failed").length;return{running:g,completed:v,failed:E,cost:r}},[_,r]);return n("div",{class:"coding-page",style:{"--coding-accent":f.color,"--coding-accent-soft":f.soft},children:[n("div",{class:"page-header",children:[n("div",{class:"page-title",children:"Coding Agent"}),n("div",{class:"header-actions",children:[n("div",{class:"coding-refresh-pill",children:[n("span",{class:"dot"})," Auto-refresh 3s"]}),n("button",{class:"btn-refresh",onClick:y,children:[n(fe,{size:14})," Refresh"]})]})]}),a&&e.length===0?n("div",{style:{display:"flex",justifyContent:"center",padding:"48px"},children:n("div",{class:"spinner"})}):_.length===0?n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(lr,{size:18})}),n("div",{class:"empty-state-text",children:"No coding agent sessions"})]}):n("div",{class:"coding-body",children:[n("div",{class:"coding-stats-grid",children:[n("div",{class:"coding-stat-card",children:[n("div",{class:"coding-stat-icon running",children:n(fe,{size:14})}),n("div",{class:"coding-stat-content",children:[n("div",{class:"coding-stat-value",children:k.running}),n("div",{class:"coding-stat-label",children:"Running"})]})]}),n("div",{class:"coding-stat-card",children:[n("div",{class:"coding-stat-icon completed",children:n(Me,{size:14})}),n("div",{class:"coding-stat-content",children:[n("div",{class:"coding-stat-value",children:k.completed}),n("div",{class:"coding-stat-label",children:"Completed"})]})]}),n("div",{class:"coding-stat-card",children:[n("div",{class:"coding-stat-icon failed",children:n(lt,{size:14})}),n("div",{class:"coding-stat-content",children:[n("div",{class:"coding-stat-value",children:k.failed}),n("div",{class:"coding-stat-label",children:"Failed"})]})]}),n("div",{class:"coding-stat-card",children:[n("div",{class:"coding-stat-icon cost",children:n(We,{size:14})}),n("div",{class:"coding-stat-content",children:[n("div",{class:"coding-stat-value",children:["$",k.cost.toFixed(2)]}),n("div",{class:"coding-stat-label",children:"Cost today"})]})]})]}),w.map(g=>{const v=u.get(g.id)??[],E=g.liveOutput||g.outputPreview,z=_t(g.status),F=z==="running",D=bc(g.id);return n("div",{class:`coding-task-card ${z}`,style:{"--card-accent":D.color,"--card-accent-soft":D.soft},children:[n("div",{class:"coding-task-main",children:[n("div",{class:`coding-task-icon ${z}`,children:Li(g.status)}),n("div",{class:"coding-task-content",children:[n("div",{class:"coding-task-pills",children:[n("span",{class:"coding-pill id",children:g.id}),n("span",{class:"coding-pill",children:["TEAM (",v.length,")"]}),n("span",{class:`coding-pill status ${z}`,children:g.status})]}),n("div",{class:"coding-task-title",children:g.task}),n("div",{class:"coding-task-submeta",children:[g.model&&n("span",{children:g.model}),n("span",{children:"•"}),n("span",{children:[n(it,{size:13})," ",Ei(g)]}),n("span",{children:"•"}),n("span",{class:"coding-pill",children:[g.totalCost!=null?`$${g.totalCost.toFixed(2)}`:"$--"," · ",g.inputTokens!=null||g.outputTokens!=null?`${((g.inputTokens??0)+(g.outputTokens??0)).toLocaleString()} tok`:"-- tok"]}),n("span",{children:xc(g.startedAt)})]})]}),F?n("button",{class:`coding-task-action ${z}`,type:"button",disabled:d.has(g.id),onClick:()=>{p(g.id)},children:d.has(g.id)?"Cancelling…":"Cancel"}):null]}),n("div",{class:`coding-task-progress ${z}`}),v.length>0&&n("details",{class:"coding-subagents",open:!0,children:[n("summary",{children:[n(Hn,{size:14})," Subagents (",v.length,")"]}),n("div",{class:"coding-subagents-list",children:v.map(P=>n("div",{class:"coding-subagent-row",children:[n("span",{class:`coding-subagent-icon ${_t(P.status)}`,children:Li(P.status)}),n("span",{class:"audit-id",children:P.id}),n("span",{class:`ca-status-badge ${P.status}`,children:P.status}),n("span",{class:"coding-pill",children:P.totalCost!=null?`$${P.totalCost.toFixed(2)}`:"$--"}),n("span",{class:"coding-subagent-task",children:P.subtask||P.task}),n("span",{class:"coding-subagent-time",children:Ei(P)})]},P.id))})]}),n("details",{class:"coding-output",children:[n("summary",{children:[n(Hn,{size:14})," Live output"]}),E?n(At,{content:E,className:`ca-output markdown-content${g.error?" ca-error":""}`}):null,!E&&g.error?n(At,{content:g.error,className:"ca-output markdown-content ca-error"}):null,!E&&!g.error&&g.synthesisResult?n(At,{content:g.synthesisResult,className:"ca-output markdown-content"}):null]})]},g.id)}),_.length>h&&n("div",{style:{display:"flex",justifyContent:"center",gap:"8px",padding:"12px"},children:[n("button",{class:"btn btn-sm",disabled:s===0,onClick:()=>o(g=>Math.max(0,g-1)),children:"Previous"}),n("span",{style:{fontSize:"12px",color:"var(--text-muted)",alignSelf:"center"},children:[s*h+1,"–",Math.min((s+1)*h,_.length)," of ",_.length]}),n("button",{class:"btn btn-sm",disabled:(s+1)*h>=_.length,onClick:()=>o(g=>g+1),children:"Next"})]})]})]})}function $i(e){if(e==null)return e;if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e}function Sc(e){if(e.type==="tool_use"&&e.detail!=null){const t=$i(e.detail);if(t!==null&&typeof t=="object"&&!Array.isArray(t)){const r=t,i=r.tool||r.name||r.toolName||"",a=r.tool!=null?"tool":r.name!=null?"name":r.toolName!=null?"toolName":"",s=Object.entries(r).filter(([o])=>o!==a).map(([o,d])=>{const c=typeof d=="string"?`"${d.length>60?d.slice(0,57)+"...":d}"`:typeof d=="object"&&d!==null?JSON.stringify(d).slice(0,60):String(d);return`${o}: ${c}`}).join(", ");return i?`${i}({${s}})`:`{${s}}`}}if(e.summary){if(e.detail!=null&&typeof e.detail=="object"){const t=Object.entries(e.detail).slice(0,3).map(([r,i])=>`${r}: ${typeof i=="object"?JSON.stringify(i):String(i)}`);if(t.length>0)return`${e.summary} — ${t.join(", ")}`}return e.summary}if(e.detail!=null){const t=$i(e.detail);return typeof t=="string"?t:JSON.stringify(t).slice(0,80)}return""}function Tc(e){return e===void 0?"":e>=1e3?`${(e/1e3).toFixed(1)}s`:`${Math.round(e)}ms`}function Cc(){const[e,t]=x([]),[r,i]=x(0),[a,l]=x(0),[s,o]=x(""),[d,c]=x(""),[f,h]=x("all"),[y,p]=x(!0),[u,_]=x(new Set),w=20;q(()=>{l(0)},[d]),q(()=>{k()},[a,d]),q(()=>{const b=Math.max(0,Math.ceil(r/w)-1);a>b&&l(b)},[a,r]);async function k(){p(!0);try{const b=await _a({limit:w,offset:a*w,trigger:d||void 0});t(b.traces??[]),i(b.total??0)}catch(b){console.error("[audit] load failed",b)}finally{p(!1)}}function g(b){if(b.endedAt){const R=new Date(b.endedAt).getTime()-new Date(b.startedAt).getTime();return R>=1e3?`${(R/1e3).toFixed(1)}s`:`${Math.max(0,Math.round(R))}ms`}return"running"}function v(b){return new Date(b).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}const E=s.trim().toLowerCase(),z=e.filter(b=>f!=="all"&&b.status!==f?!1:E?b.trigger.toLowerCase().includes(E)||b.traceId.toLowerCase().includes(E)||b.events.some(L=>`${L.type} ${L.summary}`.toLowerCase().includes(E)):!0),F=e.filter(b=>{const R=new Date(b.startedAt),L=new Date;return R.getFullYear()===L.getFullYear()&&R.getMonth()===L.getMonth()&&R.getDate()===L.getDate()}).length;function D(b){var R;return((R=b.events.find(L=>L.summary.trim()))==null?void 0:R.summary)??`${b.events.length} events`}function P(b){_(R=>{const L=new Set(R);return L.has(b)?L.delete(b):L.add(b),L})}function S(b){return b.events.length>0}return n("div",{class:"audit-page",children:[n("div",{class:"page-header",children:[n("div",{class:"page-title",children:"Audit Log"}),n("div",{class:"header-actions",children:[n("div",{class:"audit-header-meta",children:[F," traces today"]}),n("button",{class:"btn-refresh",onClick:()=>k(),children:[n(fe,{size:14})," Refresh"]})]})]}),y&&e.length===0?n("div",{style:{display:"flex",justifyContent:"center",padding:"48px"},children:n("div",{class:"spinner"})}):n(ae,{children:[n("div",{class:"audit-filters-row",children:[n("label",{class:"audit-search",children:[n(Wn,{size:14}),n("input",{value:s,onInput:b=>o(b.target.value),placeholder:"Search traces, events, tools…"})]}),n("div",{class:"audit-filter-controls",children:[n("select",{class:"btn btn-sm",value:d,onChange:b=>c(b.target.value),children:[n("option",{value:"",children:"All triggers"}),n("option",{value:"telegram",children:"Telegram"}),n("option",{value:"discord",children:"Discord"}),n("option",{value:"cron",children:"Cron"}),n("option",{value:"gateway",children:"Gateway"}),n("option",{value:"dashboard",children:"Dashboard"}),n("option",{value:"system",children:"System"})]}),n("select",{class:"btn btn-sm",value:f,onChange:b=>h(b.target.value),children:[n("option",{value:"all",children:"All status"}),n("option",{value:"success",children:"OK"}),n("option",{value:"error",children:"Error"}),n("option",{value:"running",children:"Running"})]})]})]}),n("div",{class:"audit-timeline",children:z.length===0?n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(Wn,{size:18})}),n("div",{class:"empty-state-text",children:"No audit traces"})]}):z.map((b,R)=>n("div",{class:"audit-row",children:[n("div",{class:"audit-time-col",children:[n("div",{class:"audit-time",children:v(b.startedAt)}),R<z.length-1&&n("div",{class:"audit-time-line"})]}),n("div",{class:`audit-card${S(b)?" audit-card-expandable":""}`,children:[n("div",{class:"audit-card-head",...S(b)?{role:"button",tabIndex:0,"aria-expanded":u.has(b.traceId),"aria-label":`Toggle details for trace ${b.traceId.slice(0,8)}`,onClick:()=>P(b.traceId),onKeyDown:L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),P(b.traceId))},style:{cursor:"pointer"}}:{},children:[n("div",{class:"audit-chip-row",children:[n("span",{class:`audit-chip trigger ${b.trigger}`,children:b.trigger.toUpperCase()}),n("span",{class:"audit-chip id",children:b.traceId.slice(0,8)}),n("span",{class:`audit-chip status ${b.status}`,children:b.status==="success"?"OK":b.status==="error"?"Error":"Running"})]}),n("div",{class:"audit-card-head-right",children:[n("div",{class:"audit-duration",children:g(b)}),S(b)&&n("span",{class:"audit-expand-icon",children:u.has(b.traceId)?n(Hn,{size:12}):n(Jl,{size:12})})]})]}),n("div",{class:"audit-title-line",children:D(b)}),b.events.length>0&&n("div",{class:"audit-event-pills",children:b.events.slice(0,4).map((L,G)=>n("span",{class:"audit-chip soft",children:[L.type,L.durationMs!==void 0?` ${L.durationMs}ms`:""]},`${b.traceId}-${G}`))}),u.has(b.traceId)&&S(b)&&n("div",{class:"audit-detail-section",children:b.events.map((L,G)=>n("div",{class:"audit-event-row",children:[n("span",{class:`audit-event-type-label${L.type==="tool_use"?" tool":""}`,children:L.type}),n("span",{class:`audit-event-content${L.type==="tool_use"?" mono":""}`,children:Sc(L)}),n("span",{class:"audit-event-dur",children:Tc(L.durationMs)})]},`${b.traceId}-detail-${G}`))})]})]},b.traceId))}),r>w&&n("div",{style:{display:"flex",justifyContent:"center",gap:"8px",padding:"12px"},children:[n("button",{class:"btn btn-sm",disabled:a===0||y,onClick:()=>l(b=>Math.max(0,b-1)),children:"Previous"}),n("span",{style:{fontSize:"12px",color:"var(--text-muted)",alignSelf:"center"},children:[r===0?0:a*w+1,"–",Math.min((a+1)*w,r)," of ",r]}),n("button",{class:"btn btn-sm",disabled:(a+1)*w>=r||y,onClick:()=>l(b=>b+1),children:"Next"})]})]})]})}function Ac(e){const t=Date.now()-new Date(e).getTime(),r=Math.floor(t/1e3);if(r<60)return`${r}s`;const i=Math.floor(r/60),a=r%60;return`${i}m ${a.toString().padStart(2,"0")}s`}function zi(e){const t=new Date(e);return t.toLocaleDateString("en-US",{month:"short",day:"numeric"})+", "+t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"})}function Ec(e){if(e.status==="expired")return"Expired after 5m (no response)";const t=e.approvedBy||e.deniedBy||"unknown",r=e.status==="approved"?"Approved":"Denied";if(e.resolvedAt&&e.createdAt){const i=new Date(e.resolvedAt).getTime()-new Date(e.createdAt).getTime(),a=Math.floor(i/1e3),l=a<60?`${a}s`:`${Math.floor(a/60)}m ${a%60}s`;return`${r} by ${t} · ${l} after request`}return`${r} by ${t}`}function Ri(e){var r;const t=(r=e.channelMeta)==null?void 0:r.channel;return t==="telegram"?"Telegram":t==="discord"?"Discord":t==="dashboard"?"Dashboard":t||"System"}function Mi(e){var r;const t=(r=e.channelMeta)==null?void 0:r.channel;return t==="telegram"||t==="discord"?n(at,{size:12}):t==="dashboard"?n(at,{size:12}):n(lr,{size:12})}function Ii(e){return e?e.replace(/^\/Users\/[^/]+/,"~"):""}function Di(e){return e===1?"tier-1":e===2?"tier-2":"tier-3"}function Lc({showToast:e,onCountChange:t}){const[r,i]=x([]),[a,l]=x([]),[s,o]=x(!0),[d,c]=x(new Set),[f,h]=x(null),y=Le(0),[,p]=x(0);q(()=>{u(),_();const g=setInterval(u,5e3),v=setInterval(()=>{y.current++,p(y.current)},1e3);return()=>{clearInterval(g),clearInterval(v)}},[]);async function u(){var g;try{const v=await ba();i(v.pending??[]),l((v.recent??[]).filter(E=>E.status!=="pending")),t==null||t(((g=v.pending)==null?void 0:g.length)??0)}catch{}finally{o(!1)}}async function _(){var g,v,E,z,F,D,P,S;try{const b=(await or()).config,R=(E=(v=(g=b.channels)==null?void 0:g.telegram)==null?void 0:v.tools)==null?void 0:E.execApproval,L=(D=(F=(z=b.channels)==null?void 0:z.discord)==null?void 0:F.tools)==null?void 0:D.execApproval,G=(S=(P=b.heartbeat)==null?void 0:P.tools)==null?void 0:S.execApproval,te=R||L||G||{},T=Array.isArray(te.requireForTiers)&&te.requireForTiers.length>0?te.requireForTiers:[2,3];h({enabled:te.enabled!==!1,ttlMs:Number(te.ttlMs)>0?Number(te.ttlMs):3e5,tiers:T})}catch{h(null)}}async function w(g,v){c(E=>new Set([...E,g]));try{v?(await ka(g),e("Command approved","success")):(await xa(g),e("Command denied","warning")),await u()}catch{e("Action failed","error")}finally{c(E=>{const z=new Set(E);return z.delete(g),z})}}function k(g){return g==="approved"?n(Me,{size:18}):g==="denied"?n(lt,{size:18}):g==="expired"?n(si,{size:18}):n(Un,{size:18})}return n("div",{class:"approvals-page",children:[n("div",{class:"page-header",children:[n("div",{class:"page-title",children:"Approvals"}),n("div",{class:"header-actions",children:[n("span",{class:"appr-auto-refresh",children:[n("span",{class:"appr-auto-dot"})," Auto-refresh 5s"]}),n("button",{class:"btn-refresh",onClick:u,children:[n(fe,{size:14})," Refresh"]})]})]}),s?n("div",{style:{display:"flex",justifyContent:"center",padding:"48px"},children:n("div",{class:"spinner"})}):n(ae,{children:[f&&n("div",{class:"card",style:{marginBottom:16},children:[n("div",{class:"card-title",style:{fontWeight:700,marginBottom:8},children:"Exec Approval Policy"}),n("div",{style:{fontSize:13,color:"var(--text-dim)",lineHeight:1.5},children:["Gate: ",n("strong",{children:f.enabled?"Enabled":"Disabled"})," · ","Tiers: ",n("strong",{children:f.tiers.map(g=>`T${g}`).join(", ")})," · ","TTL: ",n("strong",{children:[Math.round(f.ttlMs/1e3),"s"]})]}),n("div",{class:"appr-tier-legend",children:[n("span",{class:"appr-chip tier tier-1",children:"TIER 1"}),n("span",{class:"appr-tier-label",children:"Low risk"}),n("span",{class:"appr-chip tier tier-2",children:"TIER 2"}),n("span",{class:"appr-tier-label",children:"Dangerous / review required"}),n("span",{class:"appr-chip tier tier-3",children:"TIER 3"}),n("span",{class:"appr-tier-label",children:"Catastrophic / irreversible"})]})]}),n("div",{class:"appr-section-label",children:["PENDING (",r.length,")"]}),r.length===0?n("div",{class:"empty-state",style:{marginBottom:32},children:[n("div",{class:"empty-state-icon",children:n(ma,{size:18})}),n("div",{class:"empty-state-text",children:"No pending approvals"})]}):n("div",{class:"appr-list",children:r.map(g=>n("div",{class:"appr-item pending",children:[n("div",{class:"appr-item-border pending"}),n("div",{class:"appr-item-body",children:[n("div",{class:"appr-item-head",children:[n("div",{class:"appr-item-icon pending",children:n(Un,{size:18})}),n("span",{class:"appr-item-id",children:["req-",g.id]}),n("span",{class:`appr-chip tier ${Di(g.tier)}`,children:["TIER ",g.tier]}),n("span",{class:"appr-chip pending",children:"PENDING"}),n("span",{class:"appr-elapsed",children:[n(si,{size:12})," ",Ac(g.createdAt)]}),n("div",{style:{flex:1}}),n("div",{class:"appr-actions",children:[n("button",{class:"approval-btn-deny",disabled:d.has(g.id),onClick:()=>w(g.id,!1),children:"Deny"}),n("button",{class:"approval-btn-approve",disabled:d.has(g.id),onClick:()=>w(g.id,!0),children:[n(Me,{size:14})," Approve"]})]})]}),n("div",{class:"appr-reason",children:g.reason}),n("div",{class:"appr-cmd-block",children:g.command}),n("div",{class:"appr-footer",children:[n("span",{class:"appr-footer-item",children:[Mi(g)," via ",Ri(g)]}),g.cwd&&n("span",{class:"appr-footer-sep",children:"·"}),g.cwd&&n("span",{class:"appr-footer-item",children:Ii(g.cwd)}),n("span",{class:"appr-footer-sep",children:"·"}),n("span",{class:"appr-footer-item",children:zi(g.createdAt)})]})]})]},g.id))}),a.length>0&&n(ae,{children:[n("div",{class:"appr-section-label",style:{marginTop:32},children:"RECENT HISTORY"}),n("div",{class:"appr-list",children:a.slice(0,30).map(g=>n("div",{class:`appr-item ${g.status}`,children:[n("div",{class:`appr-item-border ${g.status}`}),n("div",{class:"appr-item-body",children:[n("div",{class:"appr-item-head",children:[n("div",{class:`appr-item-icon ${g.status}`,children:k(g.status)}),n("span",{class:"appr-item-id",children:["req-",g.id]}),n("span",{class:`appr-chip tier ${Di(g.tier)}`,children:["TIER ",g.tier]}),n("span",{class:`appr-chip ${g.status}`,children:g.status.toUpperCase()})]}),n("div",{class:"appr-reason",children:g.reason}),n("div",{class:"appr-cmd-block",children:g.command}),n("div",{class:"appr-footer",children:[n("span",{class:"appr-footer-item",children:[Mi(g)," via ",Ri(g)]}),g.cwd&&n("span",{class:"appr-footer-sep",children:"·"}),g.cwd&&n("span",{class:"appr-footer-item",children:Ii(g.cwd)}),n("span",{class:"appr-footer-sep",children:"·"}),n("span",{class:"appr-footer-item",children:zi(g.createdAt)}),n("span",{class:"appr-footer-sep",children:"·"}),n("span",{class:"appr-footer-resolution",children:Ec(g)})]})]})]},g.id))})]})]})]})}const Pi="main";function $c(){const[e,t]=x([]),[r,i]=x(null),[a,l]=x(""),[s,o]=x(!0),[d,c]=x(!1);q(()=>{f()},[]);async function f(){o(!0);try{const y=await Cs(Pi);t(y.files??[])}catch(y){console.error("[memory] load failed",y)}finally{o(!1)}}async function h(y){i(y),c(!0);try{const p=await As(Pi,y);l(p.content??"")}catch(p){console.error("[memory] file load failed",p),l("")}finally{c(!1)}}return n("div",{class:"templates-page",children:[n("div",{class:"templates-header",children:[n("div",{class:"page-title",children:"Memory"}),n("div",{class:"header-actions",style:{display:"flex",gap:10,alignItems:"center"},children:n("button",{class:"btn-refresh",onClick:f,children:[n(fe,{size:14})," Refresh"]})})]}),s?n("div",{class:"templates-loading",children:n("div",{class:"spinner"})}):e.length===0?n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(Bn,{size:18})}),n("div",{class:"empty-state-text",children:"No memory files found"})]}):n("div",{class:"templates-layout",children:[n("div",{class:"templates-sidebar",children:n("div",{class:"templates-list",children:e.map(y=>n("button",{class:`templates-list-item${r===y.name?" active":""}`,onClick:()=>h(y.name),children:[n("div",{class:"templates-list-icon",children:y.name.substring(0,2).toUpperCase()}),n("div",{class:"templates-list-content",children:[n("div",{class:"templates-list-title",children:y.name}),n("div",{class:"templates-list-meta",children:[(y.size/1024).toFixed(1)," KB"]})]})]},y.name))})}),n("div",{class:"templates-main",children:r?d?n("div",{class:"templates-loading",children:n("div",{class:"spinner"})}):n("div",{class:"templates-content",children:n("div",{class:"templates-markdown-preview",children:n(sn,{content:a})})}):n("div",{class:"templates-empty",children:[n(Bn,{size:32}),n("p",{children:"Select a file to view"})]})})]})]})}const zc=/^[A-Za-z0-9._-]+\/[A-Za-z0-9._/-]+$/,Rc=/^[A-Za-z0-9.-]+$/,Mc=/^[A-Za-z0-9._/-]+$/;function Ic(e,t){return t[e]?{ok:!0}:zc.test(e)?{ok:!0}:Rc.test(e)&&/[-.]/.test(e)?{ok:!0}:!Mc.test(e)||e.includes("/")?{ok:!1,error:`Invalid model selection: "${e}". Use alias, provider/model, or model-id.`}:{ok:!1,error:`Unknown model alias: "${e}"`}}function Dc({showToast:e}){const[t,r]=x(""),[i,a]=x(""),[l,s]=x({}),[o,d]=x(!0),[c,f]=x(!1);q(()=>{h()},[]);async function h(){d(!0);try{const p=await Ss();r(p.current??""),a(p.current??""),s(p.aliases??{})}catch(p){console.error("[model] load failed",p)}finally{d(!1)}}async function y(){const p=i.trim();if(!p)return;const u=Ic(p,l);if(!u.ok){e(u.error,"error");return}f(!0);try{const _=await Ts(p);r(_.model),a(_.model),e("Model updated","success")}catch{e("Failed to update model","error")}finally{f(!1)}}return n("div",{children:[n("div",{class:"page-header",children:n("div",{class:"page-title",children:"Model"})}),o?n("div",{style:{display:"flex",justifyContent:"center",padding:"48px"},children:n("div",{class:"spinner"})}):n("div",{style:{maxWidth:560},children:n("div",{class:"feed-card",style:{padding:"28px 32px"},children:[n("div",{style:{marginBottom:20},children:[n("div",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:600,marginBottom:8,textTransform:"uppercase",letterSpacing:"0.06em"},children:"Active Model"}),n("div",{style:{fontFamily:"var(--mono)",fontSize:15,color:"var(--accent)",fontWeight:600},children:t||"—"})]}),n("div",{style:{marginBottom:20},children:[n("div",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:600,marginBottom:8,textTransform:"uppercase",letterSpacing:"0.06em"},children:"Switch Model"}),n("input",{type:"text",value:i,onInput:p=>a(p.target.value),placeholder:"Model ID or alias",style:{width:"100%",padding:"10px 14px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border)",background:"var(--surface-alt)",color:"var(--text)",fontFamily:"var(--mono)",fontSize:14,marginBottom:14,outline:"none"}}),n("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginBottom:16},children:Object.entries(l).sort(([p],[u])=>p.localeCompare(u)).map(([p,u])=>n("button",{class:`btn btn-sm${i===p?" btn-primary":""}`,onClick:()=>a(p),title:u,children:p},p))}),n("button",{class:"btn btn-primary",onClick:y,disabled:c||!i.trim(),children:c?"Saving…":"Switch Model"})]})]})})]})}function Pc(){const[e,t]=x([]),[r,i]=x(null),[a,l]=x(""),[s,o]=x(!0),[d,c]=x(!1);q(()=>{f()},[]);async function f(){o(!0);try{const y=await zs();t(y.files??[])}catch(y){console.error("[logs] load failed",y)}finally{o(!1)}}async function h(y){i(y),c(!0);try{const p=await Rs(`logs/${encodeURIComponent(y.name)}`);l(p.content??"")}catch(p){console.error("[logs] file load failed",p),l("Error loading log file.")}finally{c(!1)}}return n("div",{children:[n("div",{class:"page-header",children:[n("div",{class:"page-title",children:"Logs"}),n("div",{class:"header-actions",children:n("button",{class:"btn-refresh",onClick:f,children:[n(fe,{size:14})," Refresh"]})})]}),s?n("div",{style:{display:"flex",justifyContent:"center",padding:"48px"},children:n("div",{class:"spinner"})}):e.length===0?n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(Xt,{size:18})}),n("div",{class:"empty-state-text",children:"No log files found"})]}):n("div",{style:{display:"grid",gridTemplateColumns:"240px 1fr",gap:20},children:[n("div",{class:"feed-card",style:{height:"fit-content",overflow:"hidden"},children:n("div",{class:"feed",children:e.map(y=>n("button",{style:{display:"block",width:"100%",textAlign:"left",padding:"12px 16px",border:"none",borderBottom:"1px solid var(--border-light)",background:(r==null?void 0:r.name)===y.name?"var(--accent-soft)":"transparent",cursor:"pointer",fontFamily:"var(--sans)",color:(r==null?void 0:r.name)===y.name?"var(--accent)":"var(--text-dim)"},onClick:()=>h(y),children:[n("div",{style:{fontWeight:600,fontSize:13,marginBottom:2},children:y.name}),n("div",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--mono)"},children:[(y.size/1024).toFixed(1)," KB"]})]},y.name))})}),n("div",{class:"feed-card",style:{padding:"20px 24px",maxHeight:"70vh",overflow:"auto"},children:r?d?n("div",{style:{display:"flex",justifyContent:"center",padding:"32px"},children:n("div",{class:"spinner"})}):n("div",{style:{fontFamily:"var(--mono)",fontSize:12,lineHeight:1.6},children:a.split(`
|
|
65
|
+
`).map((y,p)=>n("div",{style:{color:y.toLowerCase().includes("error")?"var(--log-error)":y.toLowerCase().includes("warn")?"var(--log-warn)":"var(--log-info)",padding:"1px 0"},children:y||" "},p))}):n("div",{class:"empty-state",style:{padding:"32px 0"},children:n("div",{class:"empty-state-text",children:"Select a log file to view"})})})]})]})}function Oc(e){var s,o,d,c,f,h,y,p;const t=(d=(o=(s=e.channels)==null?void 0:s.telegram)==null?void 0:o.tools)==null?void 0:d.execApproval,r=(h=(f=(c=e.channels)==null?void 0:c.discord)==null?void 0:f.tools)==null?void 0:h.execApproval,i=(p=(y=e.heartbeat)==null?void 0:y.tools)==null?void 0:p.execApproval,a=t||r||i||{},l=Array.isArray(a.requireForTiers)&&a.requireForTiers.length>0?a.requireForTiers:[2,3];return{enabled:a.enabled!==!1,ttlMs:Number(a.ttlMs)>0?Number(a.ttlMs):3e5,requireForTiers:l}}function Nc({showToast:e}){const[t,r]=x(null),[i,a]=x(!0),[l,s]=x(!1),[o,d]=x(!1),[c,f]=x({gatewayHost:"127.0.0.1",gatewayPort:"18790",gatewayMode:"local",activeChannel:"",telegramEnabled:!0,discordEnabled:!1,agentsDefault:"main",heartbeatIntervalMs:"300000",heartbeatPrompt:"",heartbeatModel:"",execApprovalEnabled:!0,execApprovalTtlMs:"300000",execApprovalTier1:!1,execApprovalTier2:!0,execApprovalTier3:!0});q(()=>{h()},[]);async function h(){var u,_,w,k,g,v,E,z,F,D,P,S,b;a(!0);try{const L=(await or()).config??{},G=Oc(L);r(L),f({gatewayHost:((u=L.gateway)==null?void 0:u.host)??"127.0.0.1",gatewayPort:String(((_=L.gateway)==null?void 0:_.port)??18790),gatewayMode:((w=L.gateway)==null?void 0:w.mode)==="remote"?"remote":"local",activeChannel:((k=L.channels)==null?void 0:k.active)==="telegram"||((g=L.channels)==null?void 0:g.active)==="discord"?L.channels.active:"",telegramEnabled:!!((E=(v=L.channels)==null?void 0:v.telegram)!=null&&E.enabled),discordEnabled:!!((F=(z=L.channels)==null?void 0:z.discord)!=null&&F.enabled),agentsDefault:((D=L.agents)==null?void 0:D.default)??"main",heartbeatIntervalMs:String(((P=L.heartbeat)==null?void 0:P.intervalMs)??3e5),heartbeatPrompt:((S=L.heartbeat)==null?void 0:S.prompt)??"",heartbeatModel:((b=L.heartbeat)==null?void 0:b.model)??"",execApprovalEnabled:G.enabled,execApprovalTtlMs:String(G.ttlMs),execApprovalTier1:G.requireForTiers.includes(1),execApprovalTier2:G.requireForTiers.includes(2),execApprovalTier3:G.requireForTiers.includes(3)})}catch(R){console.error("[config] load failed",R),e("Failed to load config","error")}finally{a(!1)}}async function y(){d(!0);try{await Ns(),e("Config reloaded","success"),await h()}catch(u){console.error("[config] reload failed",u),e("Reload failed","error")}finally{d(!1)}}async function p(){if(!t)return;const u=structuredClone(t);u.gateway=u.gateway||{},u.channels=u.channels||{},u.channels.telegram=u.channels.telegram||{},u.channels.discord=u.channels.discord||{},u.channels.telegram.tools=u.channels.telegram.tools||{},u.channels.discord.tools=u.channels.discord.tools||{},u.agents=u.agents||{},u.heartbeat=u.heartbeat||{},u.heartbeat.tools=u.heartbeat.tools||{},u.cron=u.cron||{jobs:[]},u.models=u.models||{providers:{},aliases:{}},u.gateway.host=c.gatewayHost.trim()||"127.0.0.1",u.gateway.port=Number(c.gatewayPort)||18790,u.gateway.mode=c.gatewayMode,c.activeChannel?u.channels.active=c.activeChannel:delete u.channels.active,u.channels.telegram.enabled=c.telegramEnabled,u.channels.discord.enabled=c.discordEnabled,u.agents.default=c.agentsDefault.trim()||"main",u.heartbeat.intervalMs=Number(c.heartbeatIntervalMs)||3e5,u.heartbeat.prompt=c.heartbeatPrompt,u.heartbeat.model=c.heartbeatModel.trim()||void 0;const _=[1,2,3].filter(k=>k===1?c.execApprovalTier1:k===2?c.execApprovalTier2:c.execApprovalTier3);_.length===0&&_.push(2,3);const w={enabled:c.execApprovalEnabled,ttlMs:Number(c.execApprovalTtlMs)||3e5,requireForTiers:_};u.channels.telegram.tools.execApproval=w,u.channels.discord.tools.execApproval=w,u.heartbeat.tools.execApproval=w,s(!0);try{await wa(u),r(u),e("Config saved","success")}catch(k){console.error("[config] save failed",k),e("Failed to save config","error")}finally{s(!1)}}return n("div",{children:[n("div",{class:"page-header",children:[n("div",{class:"page-title",children:"Config"}),n("div",{class:"header-actions",children:[n("button",{class:"btn btn-sm",onClick:()=>void y(),disabled:o,children:o?"Reloading…":"Reload"}),n("button",{class:"btn btn-sm btn-primary",onClick:()=>void p(),disabled:l,children:l?"Saving…":"Save"})]})]}),i?n("div",{style:{display:"flex",justifyContent:"center",padding:"48px"},children:n("div",{class:"spinner"})}):n("div",{style:{display:"grid",gap:14},children:[n("div",{class:"card",children:[n("div",{class:"card-title",style:{fontWeight:700},children:"Gateway"}),n("div",{class:"form-grid three",children:[n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Host"}),n("input",{value:c.gatewayHost,onInput:u=>f(_=>({..._,gatewayHost:u.target.value})),placeholder:"127.0.0.1"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Port"}),n("input",{value:c.gatewayPort,onInput:u=>f(_=>({..._,gatewayPort:u.target.value})),placeholder:"18790"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Mode"}),n("select",{value:c.gatewayMode,onChange:u=>f(_=>({..._,gatewayMode:u.target.value})),children:[n("option",{value:"local",children:"local"}),n("option",{value:"remote",children:"remote"})]})]})]})]}),n("div",{class:"card",children:[n("div",{class:"card-title",style:{fontWeight:700},children:"Channels"}),n("div",{class:"form-grid",children:[n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Active channel"}),n("select",{value:c.activeChannel,onChange:u=>f(_=>({..._,activeChannel:u.target.value})),children:[n("option",{value:"",children:"auto"}),n("option",{value:"telegram",children:"telegram"}),n("option",{value:"discord",children:"discord"})]})]}),n("div",{class:"form-check-row",children:[n("label",{class:"form-checkbox",children:[n("input",{type:"checkbox",checked:c.telegramEnabled,onChange:u=>f(_=>({..._,telegramEnabled:u.target.checked}))}),"Telegram enabled"]}),n("label",{class:"form-checkbox",children:[n("input",{type:"checkbox",checked:c.discordEnabled,onChange:u=>f(_=>({..._,discordEnabled:u.target.checked}))}),"Discord enabled"]})]})]})]}),n("div",{class:"card",children:[n("div",{class:"card-title",style:{fontWeight:700},children:"Agent"}),n("div",{class:"form-grid",children:n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Default agent"}),n("input",{value:c.agentsDefault,onInput:u=>f(_=>({..._,agentsDefault:u.target.value})),placeholder:"main"})]})})]}),n("div",{class:"card",children:[n("div",{class:"card-title",style:{fontWeight:700},children:"Heartbeat"}),n("div",{class:"form-grid two",style:{marginBottom:10},children:[n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Interval (ms)"}),n("input",{value:c.heartbeatIntervalMs,onInput:u=>f(_=>({..._,heartbeatIntervalMs:u.target.value})),placeholder:"300000"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Model override"}),n("input",{value:c.heartbeatModel,onInput:u=>f(_=>({..._,heartbeatModel:u.target.value})),placeholder:"optional"})]})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Prompt"}),n("textarea",{value:c.heartbeatPrompt,onInput:u=>f(_=>({..._,heartbeatPrompt:u.target.value})),placeholder:"Heartbeat prompt",style:{minHeight:120}})]})]}),n("div",{class:"card",children:[n("div",{class:"card-title",style:{fontWeight:700},children:"Exec Approvals"}),n("div",{class:"form-grid",style:{marginBottom:10},children:[n("div",{class:"form-check-col",children:[n("span",{class:"form-label",children:"Gate"}),n("label",{class:"form-checkbox",children:[n("input",{type:"checkbox",checked:c.execApprovalEnabled,onChange:u=>f(_=>({..._,execApprovalEnabled:u.target.checked}))}),"Enable approval gate"]})]}),n("label",{class:"form-field",style:{maxWidth:260},children:[n("span",{class:"form-label",children:"Approval TTL (ms)"}),n("input",{value:c.execApprovalTtlMs,onInput:u=>f(_=>({..._,execApprovalTtlMs:u.target.value})),placeholder:"300000",disabled:!c.execApprovalEnabled})]})]}),n("div",{class:"form-check-row tight",children:[n("label",{class:"form-checkbox",children:[n("input",{type:"checkbox",checked:c.execApprovalTier1,onChange:u=>f(_=>({..._,execApprovalTier1:u.target.checked}))}),"Require approval for Tier 1"]}),n("label",{class:"form-checkbox",children:[n("input",{type:"checkbox",checked:c.execApprovalTier2,onChange:u=>f(_=>({..._,execApprovalTier2:u.target.checked}))}),"Require approval for Tier 2"]}),n("label",{class:"form-checkbox",children:[n("input",{type:"checkbox",checked:c.execApprovalTier3,onChange:u=>f(_=>({..._,execApprovalTier3:u.target.checked}))}),"Require approval for Tier 3"]})]}),n("div",{style:{marginTop:8,fontSize:12,color:"var(--text-muted)"},children:"Applied to Telegram, Discord, and Heartbeat tool execution."}),n("div",{class:"appr-tier-legend",style:{marginTop:10},children:[n("span",{class:"appr-chip tier tier-1",children:"TIER 1"}),n("span",{class:"appr-tier-label",children:"Low risk operations"}),n("span",{class:"appr-chip tier tier-2",children:"TIER 2"}),n("span",{class:"appr-tier-label",children:"Dangerous operations"}),n("span",{class:"appr-chip tier tier-3",children:"TIER 3"}),n("span",{class:"appr-tier-label",children:"Catastrophic operations"})]})]})]})]})}function Hc(){var p;const[e,t]=x([]),[r,i]=x(null),[a,l]=x(null),[s,o]=x(!0),[d,c]=x(!1);q(()=>{f()},[]);async function f(){o(!0);try{const u=await Hs();t(u.digests??[])}finally{o(!1)}}async function h(u){i(u),c(!0);try{const _=await Bs(u);l(_)}catch{l(null)}finally{c(!1)}}function y(u){return new Date(u).toLocaleString()}return n("div",{children:[n("div",{class:"page-header",children:[n("div",{class:"page-title",children:"Digests"}),n("div",{class:"header-actions",children:n("button",{class:"btn-refresh",onClick:()=>void f(),children:[n(fe,{size:14})," Refresh"]})})]}),s?n("div",{style:{display:"flex",justifyContent:"center",padding:"48px"},children:n("div",{class:"spinner"})}):e.length===0?n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(Fn,{size:18})}),n("div",{class:"empty-state-text",children:"No digests yet"})]}):n("div",{class:"split",children:[n("div",{class:"split-list",children:n("div",{class:"templates-list",children:e.map(u=>{var _;return n("button",{onClick:()=>void h(u.id),class:`templates-list-item${r===u.id?" active":""}`,children:[n("div",{class:"templates-list-icon",children:n(Fn,{size:14})}),n("div",{class:"templates-list-content",children:[n("div",{class:"templates-list-title",children:u.jobName}),n("div",{class:"templates-list-meta",children:[u.articleCount," article",u.articleCount===1?"":"s"," · ",y(u.createdAt)]}),((_=u.preview)==null?void 0:_.length)>0&&n("div",{style:{fontSize:12,color:"var(--text-dim)",marginTop:6,lineHeight:1.45},children:u.preview[0]})]})]},u.id)})})}),n("div",{class:"split-detail",children:r?d?n("div",{style:{display:"flex",justifyContent:"center",padding:"32px"},children:n("div",{class:"spinner"})}):a?n("div",{children:[n("div",{class:"digest-header",children:[n("div",{class:"digest-title",children:a.jobName}),n("div",{class:"digest-meta",children:y(a.createdAt)})]}),a.summary&&a.summary.trim().length>0&&n(At,{content:a.summary,className:"digest-reader markdown-content",style:{marginBottom:12}}),((p=a.articles)==null?void 0:p.length)>0?n("div",{class:"digest-articles",children:a.articles.map(u=>n("div",{class:"digest-article-card",children:[n("div",{class:"source-badge",children:u.source}),n("a",{href:u.url,target:"_blank",rel:"noreferrer",class:"article-title",children:[u.title," ",n(ts,{size:12})]}),(u.score!==void 0||u.comments!==void 0)&&n("div",{class:"article-stats",children:[u.score!==void 0?`Score ${u.score}`:"",u.comments!==void 0?`${u.score!==void 0?" · ":""}${u.comments} comments`:""]}),u.summary&&n(At,{content:u.summary,className:"markdown-content",style:{fontSize:13,color:"var(--text-dim)",marginTop:8}})]},u.id))}):a.summary?null:n("div",{class:"empty-state",style:{padding:"24px 0"},children:n("div",{class:"empty-state-text",children:"No content in this digest"})})]}):n("div",{class:"empty-state",style:{padding:"32px 0"},children:n("div",{class:"empty-state-text",children:"Failed to load digest"})}):n("div",{class:"empty-state",style:{padding:"32px 0"},children:n("div",{class:"empty-state-text",children:"Select a digest"})})})]})]})}function Bc({showToast:e}){const[t,r]=x([]),[i,a]=x(null),[l,s]=x(null),[o,d]=x(!0),[c,f]=x(!1),[h,y]=x(""),[p,u]=x(""),[_,w]=x(!1),[k,g]=x(!1),[v,E]=x("raw"),[z,F]=x(!1),[D,P]=x("");q(()=>{S()},[]);async function S(){d(!0);try{const T=await Fs();r(T.skills??[])}catch{e("Failed to load skills","error")}finally{d(!1)}}async function b(T){a(T),E("markdown"),f(!0);try{const H=await Ws(T);s(H),P(H.rawContent||H.body||""),F(!1)}catch{e("Failed to load skill details","error"),s(null)}finally{f(!1)}}async function R(){if(l){g(!0);try{await Gs(l.name,D),e("Skill updated","success"),await b(l.name)}catch{e("Failed to update skill","error")}finally{g(!1)}}}async function L(T){if(T.enabled!==void 0)try{await js(T.name,!T.enabled),e(`Skill ${T.name} ${T.enabled?"disabled":"enabled"}`,"success"),await S(),i===T.name&&await b(T.name)}catch{e("Failed to update skill","error")}}async function G(T){if(window.confirm(`Delete skill "${T}"? This action cannot be undone.`)){r(he=>he.filter(ge=>ge.name!==T)),i===T&&(a(null),s(null));try{await qs(T),e(`Deleted ${T}`,"warning"),await S()}catch{e("Failed to delete skill","error"),await S()}}}async function te(){const T=h.trim();if(!(!T||!p.trim())){g(!0);try{await Us(T,p),e("Skill created","success"),y(""),u(""),w(!1),await S(),await b(T)}catch{e("Failed to create skill","error")}finally{g(!1)}}}return n("div",{children:[n("div",{class:"page-header",children:[n("div",{class:"page-title",children:"Skills"}),n("div",{class:"header-actions",children:[n("button",{class:"btn btn-sm",onClick:()=>w(T=>!T),children:_?"Close":"New"}),n("button",{class:"btn-refresh",onClick:S,children:[n(fe,{size:14})," Refresh"]})]})]}),o?n("div",{style:{display:"flex",justifyContent:"center",padding:"48px"},children:n("div",{class:"spinner"})}):n("div",{children:[t.length===0?n("div",{class:"empty-state",style:{padding:"24px 16px"},children:[n("div",{class:"empty-state-icon",children:n(jn,{size:18})}),n("div",{class:"empty-state-text",children:"No skills found"})]}):n("div",{class:"skills-grid",style:{marginBottom:14},children:t.map(T=>n("div",{class:"skill-card",children:[n("div",{class:"skill-header",children:[n("div",{class:"skill-name",children:T.name}),n("div",{title:T.eligible?"Eligible":T.reason||"Ineligible",children:T.eligible===!1?n(Ql,{size:16,color:"var(--error)"}):n(ma,{size:16,color:"var(--success)"})})]}),n("div",{class:"skill-desc",children:T.description||"No description"}),T.tags&&T.tags.length>0&&n("div",{class:"skill-tags",children:T.tags.slice(0,4).map(H=>n("span",{class:"skill-tag",children:H},H))}),n("div",{style:{display:"flex",gap:8,marginTop:10},children:[n("button",{class:"btn btn-sm",onClick:()=>void b(T.name),children:"View"}),n("button",{class:"btn btn-sm",disabled:!0,title:"Coming soon",onClick:()=>void L(T),children:T.enabled?"Disable":"Enable"}),n("button",{class:"btn btn-sm btn-danger",onClick:()=>void G(T.name),children:"Delete"})]})]},T.name))}),n("div",{children:[_&&n("div",{class:"card",children:[n("div",{class:"card-title",style:{fontWeight:700,marginBottom:10},children:"Create Skill"}),n("label",{class:"form-field",style:{marginBottom:8},children:[n("span",{class:"form-label",children:"Skill name"}),n("input",{value:h,onInput:T=>y(T.target.value),placeholder:"skill-name"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"SKILL.md content"}),n("textarea",{value:p,onInput:T=>u(T.target.value),placeholder:"SKILL.md content",style:{minHeight:180}})]}),n("div",{class:"form-actions",children:n("button",{class:"btn btn-sm btn-primary",disabled:k||!h.trim()||!p.trim(),onClick:te,children:k?"Creating…":"Create"})})]}),n("div",{class:"card",children:i?c?n("div",{style:{display:"flex",justifyContent:"center",padding:"32px"},children:n("div",{class:"spinner"})}):l?n(ae,{children:[n("div",{class:"audit-header",children:[n("div",{style:{fontWeight:700},children:l.name}),n("div",{style:{display:"flex",gap:8},children:[n("button",{class:"btn btn-sm",onClick:()=>E(T=>T==="raw"?"markdown":"raw"),children:v==="raw"?"Markdown":"Raw"}),n("button",{class:"btn btn-sm btn-danger",onClick:()=>void G(l.name),children:"Delete"})]})]}),n("div",{class:"audit-summary",style:{marginBottom:8},children:l.description||"No description"}),n("div",{class:"audit-meta",style:{marginBottom:12},children:[n("span",{children:["Eligible: ",l.eligible?"yes":"no"]}),n("span",{children:["Enabled: ",l.enabled?"yes":"no"]}),n("span",{children:["Priority: ",l.priority??100]})]}),z?n(ae,{children:[n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Edit SKILL.md"}),n("textarea",{value:D,onInput:T=>P(T.target.value),style:{minHeight:280}})]}),n("div",{class:"form-actions",children:[n("button",{class:"btn btn-sm btn-primary",onClick:()=>void R(),disabled:k||!D.trim(),children:k?"Saving…":"Save"}),n("button",{class:"btn btn-sm",onClick:()=>{F(!1),P(l.rawContent||l.body||"")},children:"Cancel"})]})]}):v==="markdown"?n(sn,{content:l.rawContent||l.body||""}):n("pre",{class:"ca-output",style:{marginTop:0,maxHeight:420},children:l.rawContent||l.body||"(empty)"})]}):n("div",{class:"empty-state",style:{padding:"32px 0"},children:n("div",{class:"empty-state-text",children:"Failed to load skill detail"})}):n("div",{class:"empty-state",style:{padding:"32px 0"},children:[n("div",{class:"empty-state-icon",children:n(jn,{size:18})}),n("div",{class:"empty-state-text",children:"Select a skill to inspect"})]})})]})]})]})}function Fc(){var g;const[e,t]=x(null),[r,i]=x(null),[a,l]=x(!0),[s,o]=x(!1);q(()=>{d()},[]);async function d(){l(!0);try{const[v,E]=await Promise.all([di(),ui()]);t(v),i(E)}catch(v){console.error("[health] load failed",v)}finally{l(!1)}}async function c(){o(!0);try{const[v,E]=await Promise.all([di(),ui()]);t(v),i(E)}catch(v){console.error("[health] recheck failed",v)}finally{o(!1)}}function f(v){return v==="ok"?"ok":v==="warn"?"warn":"error"}function h(v){return v==="ok"?"var(--success)":v==="warn"?"var(--warning)":"var(--error)"}function y(v){return"status"in v&&v.status?v:"ok"in v?{name:v.name,status:v.ok?"ok":v.fatal?"error":"warn",message:v.detail||v.remedy}:{name:v.name,status:"error"}}const u=(((g=r==null?void 0:r.report)==null?void 0:g.checks)??(e==null?void 0:e.checks)??[]).map(v=>y(v)),_=u.filter(v=>v.status==="error").length,w=u.filter(v=>v.status==="warn").length,k=u.filter(v=>v.status==="ok").length;return n("div",{children:[n("div",{class:"page-header",id:"healthRecheckBtn",children:[n("div",{class:"page-title",children:"Health"}),n("button",{class:"btn btn-sm",id:"healthRecheckBtn",onClick:c,disabled:s||a,children:s?"Checking…":"Recheck"})]}),a?n("div",{style:{display:"flex",justifyContent:"center",padding:"48px"},children:n("div",{class:"spinner"})}):n("div",{children:[n("div",{class:"stats-grid",style:{gridTemplateColumns:"repeat(3, 1fr)",marginBottom:28},children:[n("div",{class:"stat-card",children:[n("div",{class:"stat-icon green",children:n(Xl,{size:16})}),n("div",{class:"stat-label",children:"System"}),n("div",{class:"stat-value",children:e!=null&&e.ok?"OK":"Issue"}),n("div",{class:"stat-sub",children:[u.length," checks"]})]}),n("div",{class:"stat-card",children:[n("div",{class:"stat-icon sage",children:n(Me,{size:16})}),n("div",{class:"stat-label",children:"Checks Passing"}),n("div",{class:"stat-value",style:{color:"var(--success)"},children:k}),n("div",{class:"stat-sub",children:["out of ",u.length]})]}),n("div",{class:"stat-card",children:[n("div",{class:"stat-icon",style:{background:_>0?"var(--error-soft)":w>0?"var(--warning-soft)":"var(--success-soft)",color:_>0?"var(--error)":w>0?"var(--warning)":"var(--success)"},children:_>0?n(lt,{size:16}):w>0?n(oi,{size:16}):n(Me,{size:16})}),n("div",{class:"stat-label",children:"Issues"}),n("div",{class:"stat-value",style:{color:_>0?"var(--error)":w>0?"var(--warning)":"var(--success)"},children:_+w}),n("div",{class:"stat-sub",children:[_," errors, ",w," warnings"]})]})]}),n("div",{id:"doctorSummary",children:[n("div",{class:"section-header",style:{marginBottom:16},children:[n("div",{class:"section-title",children:"Diagnostics"}),n("div",{class:"header-meta",id:"doctorTimestamp",children:new Date().toLocaleTimeString()})]}),n("div",{id:"doctorCategories",children:u.length===0?n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(ya,{size:18})}),n("div",{class:"empty-state-text",children:"No diagnostics available"})]}):n("div",{class:"feed-card",children:n("div",{class:"feed",children:u.map((v,E)=>n("div",{class:"feed-item",children:[n("div",{style:{width:32,height:32,borderRadius:"var(--radius-sm)",background:h(v.status)+"18",color:h(v.status),display:"flex",alignItems:"center",justifyContent:"center",fontWeight:700,fontSize:14,flexShrink:0},children:f(v.status)==="ok"?n(Me,{size:14}):f(v.status)==="warn"?n(oi,{size:14}):n(lt,{size:14})}),n("div",{children:[n("div",{class:"feed-title",children:v.name}),v.message&&n("div",{class:"feed-detail",children:v.message})]}),n("div",{style:{fontSize:12,color:h(v.status),fontWeight:600,fontFamily:"var(--mono)",whiteSpace:"nowrap"},children:v.status})]},E))})})})]}),n("div",{id:"healthEnvVars",style:{display:"none"}}),n("div",{id:"healthFeatures",style:{display:"none"}})]})]})}const Qe="main";function Wc({showToast:e}){const[t,r]=x([]),[i,a]=x(null),[l,s]=x(""),[o,d]=x(""),[c,f]=x(!0),[h,y]=x(!1),[p,u]=x(!1),[_,w]=x("edit");q(()=>{k()},[]);async function k(){f(!0);try{const D=await Es(Qe);r(D.templates??[])}catch(D){console.error("[templates] load failed",D)}finally{f(!1)}}async function g(D){a(D),w(D.toLowerCase().endsWith(".md")?"preview":"edit"),y(!0);try{const S=(await Ls(Qe,D)).content??"";s(S),d(S)}catch(P){console.error("[templates] file load failed",P),s(""),d("")}finally{y(!1)}}async function v(){if(i){u(!0);try{await $s(Qe,i,l),d(l),e("Template saved","success")}catch{e("Failed to save template","error")}finally{u(!1)}}}function E(){s(o)}const z=l!==o,F=t.find(D=>D.name===i);return n("div",{class:"templates-page",children:[n("div",{class:"templates-header",children:[n("div",{class:"page-title",children:"Templates"}),n("button",{class:"btn-refresh",onClick:k,children:[n(fe,{size:14})," Refresh"]})]}),c?n("div",{class:"templates-loading",children:n("div",{class:"spinner"})}):t.length===0?n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(Xt,{size:18})}),n("div",{class:"empty-state-text",children:"No templates found"})]}):n("div",{class:"templates-layout",children:[n("div",{class:"templates-sidebar",children:[n("div",{class:"templates-sidebar-header",children:[n("div",{class:"templates-sidebar-label",children:"Agent Templates"}),n("select",{class:"templates-agent-select",value:Qe,disabled:!0,children:n("option",{value:"main",children:"main"})})]}),n("div",{class:"templates-list",children:t.map(D=>n("button",{class:`templates-list-item${i===D.name?" active":""}`,onClick:()=>g(D.name),children:[n("div",{class:"templates-list-icon",children:D.name.substring(0,2).toUpperCase()}),n("div",{class:"templates-list-content",children:[n("div",{class:"templates-list-title",children:D.name}),n("div",{class:"templates-list-meta",children:[Math.round((D.size||0)/1024),"KB"]})]})]},D.name))})]}),n("div",{class:"templates-main",children:i?h?n("div",{class:"templates-loading",children:n("div",{class:"spinner"})}):n(ae,{children:[n("div",{class:"templates-editor-header",children:[n("div",{class:"templates-editor-title-row",children:[n("h2",{class:"templates-editor-title",children:i}),z&&n("span",{class:"templates-unsaved-pill",children:"Unsaved changes"})]}),n("div",{class:"templates-editor-actions",children:[z&&n("button",{class:"templates-discard-btn",onClick:E,children:"Discard"}),n("button",{class:"templates-save-btn",onClick:v,disabled:p||!z,children:p?"Saving…":"Save"})]})]}),n("div",{class:"templates-tabs",children:[n("button",{class:`templates-tab${_==="edit"?" active":""}`,onClick:()=>w("edit"),children:"Edit"}),n("button",{class:`templates-tab${_==="preview"?" active":""}`,onClick:()=>w("preview"),children:"Preview"})]}),F&&n("div",{class:"templates-metadata",children:[n("div",{class:"templates-metadata-item",children:[n("div",{class:"templates-metadata-label",children:"SIZE"}),n("div",{class:"templates-metadata-value",children:(F.size||0)>1024?`${Math.round((F.size||0)/1024)}KB`:`${F.size||0}B`})]}),n("div",{class:"templates-metadata-item",children:[n("div",{class:"templates-metadata-label",children:"LAST EDITED"}),n("div",{class:"templates-metadata-value",children:"—"})]}),n("div",{class:"templates-metadata-item",children:[n("div",{class:"templates-metadata-label",children:"AGENT"}),n("div",{class:"templates-metadata-value",children:Qe})]}),n("div",{class:"templates-metadata-item",children:[n("div",{class:"templates-metadata-label",children:"PATH"}),n("div",{class:"templates-metadata-value templates-metadata-path",children:["~/.skimpyclaw/agents/",Qe,"/",i]})]})]}),n("div",{class:"templates-content",children:_==="preview"?n("div",{class:"templates-markdown-preview",children:n(sn,{content:l})}):n("textarea",{class:"templates-textarea",value:l,onInput:D=>s(D.target.value),spellcheck:!1})})]}):n("div",{class:"templates-empty",children:[n(Xt,{size:32}),n("p",{children:"Select a template to edit"})]})})]})]})}function bt(e){return e===0?"$0.00":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function kt(e){return e===0?"0":e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function Uc(e){const t=Date.now()-new Date(e).getTime(),r=Math.floor(t/1e3);if(r<60)return`${r}s ago`;const i=Math.floor(r/60);if(i<60)return`${i}m ago`;const a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function jc(){const[e,t]=x(null),[r,i]=x([]),[a,l]=x(0),[s,o]=x(0),[d,c]=x(!0),f=25;q(()=>{h();const w=setInterval(h,3e4);return()=>clearInterval(w)},[s]);async function h(){try{const[w,k]=await Promise.all([cr(),Vs({limit:f,offset:s*f})]);t(w),i(k.records??[]),l(k.total??0)}catch(w){console.error("[usage] load failed",w)}finally{c(!1)}}if(d&&!e)return n("div",{style:{display:"flex",justifyContent:"center",padding:"48px"},children:n("div",{class:"spinner"})});const y=e==null?void 0:e.today,p=e==null?void 0:e.week,u=e==null?void 0:e.month,_=u!=null&&u.byModel?Object.entries(u.byModel).sort((w,k)=>k[1].cost-w[1].cost):[];return n("div",{children:[n("div",{class:"page-header",children:[n("div",{class:"page-title",children:"Usage"}),n("div",{class:"header-actions",children:[n("div",{class:"coding-refresh-pill",children:[n("span",{class:"dot"})," Auto-refresh 30s"]}),n("button",{class:"btn-refresh",onClick:h,children:[n(fe,{size:14})," Refresh"]})]})]}),n("div",{class:"usage-stats-grid",children:[n("div",{class:"stat-card",children:[n("div",{class:"stat-icon rose",children:n(We,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value",children:bt((y==null?void 0:y.totalCost)??0)}),n("div",{class:"stat-subtitle",children:"Cost today"})]})]}),n("div",{class:"stat-card",children:[n("div",{class:"stat-icon amber",children:n(We,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value",children:bt((p==null?void 0:p.totalCost)??0)}),n("div",{class:"stat-subtitle",children:"Last 7 days"})]})]}),n("div",{class:"stat-card",children:[n("div",{class:"stat-icon sage",children:n(We,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value",children:bt((u==null?void 0:u.totalCost)??0)}),n("div",{class:"stat-subtitle",children:"Last 30 days"})]})]}),n("div",{class:"stat-card",children:[n("div",{class:"stat-icon blue",children:n(at,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value",children:(y==null?void 0:y.totalCalls)??0}),n("div",{class:"stat-subtitle",children:["Calls today · ",kt(((y==null?void 0:y.totalInputTokens)??0)+((y==null?void 0:y.totalOutputTokens)??0))," tok"]})]})]})]}),_.length>0&&n("div",{class:"section",children:[n("div",{class:"section-header",children:n("div",{class:"section-title",children:"Model Breakdown (30d)"})}),n("div",{class:"feed-card",children:n("table",{class:"usage-table",children:[n("thead",{children:n("tr",{children:[n("th",{children:"Model"}),n("th",{children:"Calls"}),n("th",{children:"Input Tokens"}),n("th",{children:"Output Tokens"}),n("th",{children:"Cost"})]})}),n("tbody",{children:_.map(([w,k])=>n("tr",{children:[n("td",{children:n("code",{class:"usage-model-pill",children:w})}),n("td",{children:k.calls}),n("td",{children:kt(k.inputTokens)}),n("td",{children:kt(k.outputTokens)}),n("td",{class:"usage-cost-cell",children:bt(k.cost)})]},w))})]})})]}),n("div",{class:"section",children:[n("div",{class:"section-header",children:[n("div",{class:"section-title",children:"Recent Calls"}),n("div",{class:"audit-header-meta",children:[a," total"]})]}),r.length===0?n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(ns,{size:18})}),n("div",{class:"empty-state-text",children:"No usage records yet"})]}):n("div",{class:"feed-card",children:[n("div",{class:"feed",children:r.map(w=>n("div",{class:"feed-item",children:[n("div",{class:`feed-icon ${w.trigger==="telegram"?"telegram":w.trigger==="cron"?"cron":"system"}`,children:n(We,{size:14})}),n("div",{children:[n("div",{class:"feed-title",children:[n("code",{class:"usage-model-pill",children:w.model})," ",n("span",{class:"audit-chip trigger muted",children:w.trigger})]}),n("div",{class:"feed-detail",children:[kt(w.inputTokens)," in · ",kt(w.outputTokens)," out · ",bt(w.totalCost)]})]}),n("div",{class:"feed-time",children:Uc(w.timestamp)})]},w.id))}),a>f&&n("div",{style:{display:"flex",justifyContent:"center",gap:"8px",padding:"12px"},children:[n("button",{class:"btn btn-sm",disabled:s===0,onClick:()=>o(w=>Math.max(0,w-1)),children:"Previous"}),n("span",{style:{fontSize:"12px",color:"var(--text-muted)",alignSelf:"center"},children:[s*f+1,"–",Math.min((s+1)*f,a)," of ",a]}),n("button",{class:"btn btn-sm",disabled:(s+1)*f>=a,onClick:()=>o(w=>w+1),children:"Next"})]})]})]})]})}async function Gc(){try{const e=await fetch("/api/dashboard/office-status");return e.ok?await e.json():null}catch{return null}}const zn=[{state:"working",task:"Refactoring cron scheduler",durationMs:5e3},{state:"thinking",task:"Analyzing test failures…",durationMs:3e3},{state:"working",task:"Writing audit trail events",durationMs:4e3},{state:"waiting",task:"Waiting for API response",durationMs:3500},{state:"thinking",task:"Planning subagent strategy…",durationMs:3e3},{state:"working",task:"Updating Telegram handler",durationMs:4500},{state:"offline",task:"Zzz…",durationMs:4e3},{state:"waiting",task:"Idle — no tasks queued",durationMs:3e3}],rn={working:{color:"#4ade80",label:"working",blurb:"typing away..."},thinking:{color:"#facc15",label:"thinking",blurb:"pondering..."},waiting:{color:"#60a5fa",label:"waiting",blurb:"idle"},offline:{color:"#9ca3af",label:"offline",blurb:"zzz"}};function qc(){const[e,t]=x({state:"waiting",currentTask:"Initializing…",updatedAt:new Date().toISOString()}),[r,i]=x(!1),[a,l]=x(0),[s,o]=x(!1),d=Le();q(()=>{let f=!0;return Gc().then(h=>{f&&(h?(t(h),i(!1)):(i(!0),o(!0)))}),()=>{f=!1}},[]),q(()=>{if(!r||!s){clearTimeout(d.current);return}function f(h){d.current=setTimeout(()=>{const y=(h+1)%zn.length,p=zn[y];t({state:p.state,currentTask:p.task,updatedAt:new Date().toISOString()}),l(y),f(y)},zn[h].durationMs)}return f(a),()=>clearTimeout(d.current)},[r,s,a]);const c=an(f=>{o(!1),clearTimeout(d.current),t({state:f,currentTask:rn[f].blurb,updatedAt:new Date().toISOString()})},[]);return{status:e,useMock:r,setMockState:c,autoCycle:s,setAutoCycle:o}}function M(e,t,r){const i=e-t,a=(e+t)/2-r;return[i,a]}function O(e){return e.map(([t,r,i],a)=>{const[l,s]=M(t,r,i);return`${a===0?"M":"L"}${l},${s}`}).join(" ")+" Z"}const C={pageBg:"#b8d4e8",wallLeft:"#d4d0cc",wallRight:"#cac6c2",wallTrim:"#b8b4b0",wallHighlight:"#e8e5e2",floorLight:"#e8e2da",floorDark:"#ddd7cf",floorLine:"#d0c8c0",deskTop:"#c4a882",deskFront:"#b09570",deskSide:"#a88a65",deskLeg:"#8a7050",partitionTop:"#b0b8c0",partitionFront:"#9aa2aa",partitionSide:"#8a9298",partitionFrame:"#7a8288",chairSeat:"#3a3a42",chairBack:"#2e2e36",chairBase:"#555560",chairWheel:"#444",monitorFrame:"#2a2a32",monitorScreen:"#1a2a3a",monitorScreenGlow:"#2a4a6a",monitorStand:"#3a3a42",lobsterBody:"#e04030",lobsterBelly:"#e86050",lobsterClaw:"#d03828",lobsterEye:"#fff",lobsterPupil:"#222",lobsterGrey:"#888",plantPot:"#c08060",plantLeaf:"#5a9a50",plantLeafDark:"#4a8040",cabinetFront:"#9a9aa0",cabinetBody:"#8a8a90",cabinetHandle:"#666",coolerBody:"#dde8f0",coolerJug:"#a0d0f0",coolerWater:"#70b8e8",boardFrame:"#888",boardSurface:"#f5f5f0",clockFace:"#f8f5f0",clockRim:"#888",clockHand:"#333",shelfWood:"#b09070",bookRed:"#c04040",bookBlue:"#4060b0",bookGreen:"#408050",bookYellow:"#d0a030",corkBoard:"#c4a060",corkFrame:"#8a7040",stickyYellow:"#f0e060",stickyPink:"#f090a0",stickyBlue:"#80c0e0",windowFrame:"#a0a0a0",windowGlass:"#c0ddf0",windowSky:"#a0d4f0",boxBody:"#c4a878",boxTop:"#d4b888",boxSide:"#b09868",trashBody:"#a0a0a8",trashInner:"#888890",codeLine1:"#6acc7a",codeLine2:"#60a0d8",codeLine3:"#d0a050",codeLine4:"#cc6a6a"},St=160,Tt=160,et=100,Vc=320,Zc=60;function Yc(){const t=[];for(let r=0;r<St;r+=20)for(let i=0;i<Tt;i+=20){const a=(r/20+i/20)%2===0,l=O([[r,i,0],[r+20,i,0],[r+20,i+20,0],[r,i+20,0]]);t.push(n("path",{d:l,fill:a?C.floorLight:C.floorDark,stroke:C.floorLine,strokeWidth:.3},`${r}-${i}`))}return n("g",{children:t})}function Kc(){const e=O([[0,0,0],[0,Tt,0],[0,Tt,et],[0,0,et]]),t=O([[0,0,0],[St,0,0],[St,0,et],[0,0,et]]),r=O([[0,0,0],[0,Tt,0],[0,Tt,6],[0,0,6]]),i=O([[0,0,0],[St,0,0],[St,0,6],[0,0,6]]);return n("g",{children:[n("path",{d:e,fill:C.wallLeft}),n("path",{d:t,fill:C.wallRight}),n("path",{d:r,fill:C.wallTrim}),n("path",{d:i,fill:C.wallTrim}),n("line",{x1:M(0,0,0)[0],y1:M(0,0,0)[1],x2:M(0,0,et)[0],y2:M(0,0,et)[1],stroke:C.wallHighlight,strokeWidth:1.5})]})}function Jc(){const l=O([[70,0,40],[110,0,40],[110,0,75],[70,0,75]]),s=O([[73,0,43],[107,0,43],[107,0,72],[73,0,72]]),o=70+40/2,d=40+35/2;return n("g",{children:[n("path",{d:l,fill:C.windowFrame}),n("path",{d:s,fill:C.windowGlass,opacity:.7}),n("path",{d:s,fill:C.windowSky,opacity:.3}),n("line",{x1:M(o,0,43)[0],y1:M(o,0,43)[1],x2:M(o,0,72)[0],y2:M(o,0,72)[1],stroke:C.windowFrame,strokeWidth:1.5}),n("line",{x1:M(73,0,d)[0],y1:M(73,0,d)[1],x2:M(107,0,d)[0],y2:M(107,0,d)[1],stroke:C.windowFrame,strokeWidth:1.5})]})}function Xc(){const a=O([[0,30,45],[0,80,45],[0,80,75],[0,30,75]]),l=O([[0,32,47],[0,78,47],[0,78,73],[0,32,73]]);return n("g",{children:[n("path",{d:a,fill:C.boardFrame}),n("path",{d:l,fill:C.boardSurface}),n("line",{x1:M(0,38,67)[0],y1:M(0,38,67)[1],x2:M(0,60,67)[0],y2:M(0,60,67)[1],stroke:"#4080c0",strokeWidth:1,opacity:.6}),n("line",{x1:M(0,38,63)[0],y1:M(0,38,63)[1],x2:M(0,55,63)[0],y2:M(0,55,63)[1],stroke:"#d04040",strokeWidth:1,opacity:.6}),n("line",{x1:M(0,38,59)[0],y1:M(0,38,59)[1],x2:M(0,65,59)[0],y2:M(0,65,59)[1],stroke:"#408040",strokeWidth:1,opacity:.6})]})}function Qc(){const[r,i]=M(130,0,70);return n("g",{children:[n("circle",{cx:r,cy:i,r:10,fill:C.clockFace,stroke:C.clockRim,strokeWidth:1.5}),n("line",{x1:r,y1:i,x2:r+3,y2:i-4,stroke:C.clockHand,strokeWidth:1.5,strokeLinecap:"round"}),n("line",{x1:r,y1:i,x2:r-2,y2:i-6,stroke:C.clockHand,strokeWidth:1,strokeLinecap:"round"}),n("circle",{cx:r,cy:i,r:1.5,fill:C.clockHand})]})}function ed(){const i=O([[0,100,55],[0,135,55],[0,135,56.5],[0,100,56.5]]),a=[{y:103,w:4,h:12,color:C.bookRed},{y:108,w:3,h:14,color:C.bookBlue},{y:112,w:5,h:11,color:C.bookGreen},{y:118,w:3,h:13,color:C.bookYellow},{y:122,w:4,h:10,color:C.bookRed},{y:127,w:3,h:12,color:C.bookBlue}];return n("g",{children:[n("path",{d:i,fill:C.shelfWood}),a.map((l,s)=>n("path",{d:O([[0,l.y,55+1.5],[0,l.y+l.w,55+1.5],[0,l.y+l.w,55+1.5+l.h],[0,l.y,55+1.5+l.h]]),fill:l.color,opacity:.85},s)),n("circle",{cx:M(0,133,63)[0],cy:M(0,133,63)[1],r:4,fill:C.plantLeaf}),n("circle",{cx:M(0,133,65)[0],cy:M(0,133,65)[1],r:3,fill:C.plantLeafDark}),n("path",{d:O([[0,131,55+1.5],[0,135,55+1.5],[0,135,61],[0,131,61]]),fill:C.plantPot})]})}function td(){const a=O([[0,90,60],[0,114,60],[0,114,78],[0,90,78]]),l=O([[0,90+1.5,60+1.5],[0,114-1.5,60+1.5],[0,114-1.5,78-1.5],[0,90+1.5,78-1.5]]);return n("g",{children:[n("path",{d:a,fill:C.corkFrame}),n("path",{d:l,fill:C.corkBoard}),n("path",{d:O([[0,94,64],[0,100,64],[0,100,69],[0,94,69]]),fill:C.stickyYellow,opacity:.9}),n("path",{d:O([[0,102,66],[0,108,66],[0,108,71],[0,102,71]]),fill:C.stickyPink,opacity:.9}),n("path",{d:O([[0,96,71],[0,102,71],[0,102,75],[0,96,75]]),fill:C.stickyBlue,opacity:.9})]})}function nd(){const l=O([[55,55,28],[105,55,28],[105,90,28],[55,90,28]]),s=O([[105,55,28],[105,90,28],[105,90,25],[105,55,25]]),o=O([[55,90,28],[105,90,28],[105,90,25],[55,90,25]]),d=3,c=25,f=[[58,58],[102,58],[58,87],[102,87]],h=O([[105,59,24],[105,71,24],[105,71,10],[105,59,10]]);return n("g",{children:[f.map(([y,p],u)=>n("path",{d:O([[y,p,0],[y+d,p,0],[y+d,p,c],[y,p,c]]),fill:C.deskLeg},u)),n("path",{d:s,fill:C.deskFront}),n("path",{d:o,fill:C.deskSide}),n("path",{d:l,fill:C.deskTop}),n("path",{d:h,fill:C.deskSide,opacity:.7}),(()=>{const[y,p]=M(105,65,17);return n("line",{x1:y,y1:p,x2:y,y2:p+3,stroke:C.deskLeg,strokeWidth:1.5,strokeLinecap:"round"})})()]})}function rd({state:e}){const o=O([[55,55,0],[105,55,0],[105,55,42],[55,55,42]]),d=O([[55,55,42],[105,55,42],[105,58,42],[55,58,42]]),c=O([[55,55,0],[55,58,0],[55,58,42],[55,55,42]]),f=O([[55,58,0],[55,90,0],[55,90,42],[55,58,42]]),h=O([[55,58,42],[55,90,42],[58,90,42],[58,58,42]]),y=O([[55,55,41],[105,55,41],[105,55,42],[55,55,42]]),p=O([[55,55,41],[55,90,41],[55,90,42],[55,55,42]]);return n("g",{children:[n("path",{d:o,fill:C.partitionFront}),n("path",{d:c,fill:C.partitionSide}),n("path",{d,fill:C.partitionTop}),n("path",{d:f,fill:C.partitionSide}),n("path",{d:h,fill:C.partitionTop}),n("path",{d:y,fill:C.partitionFrame}),n("path",{d:p,fill:C.partitionFrame}),(()=>{const[u,_]=M(100,56,42);return n("circle",{cx:u,cy:_,r:2,fill:rn[e].color,opacity:.8})})()]})}function id({state:e}){const o=O([[68,60,28],[92,60,28],[92,60,46],[68,60,46]]),d=O([[68,58,28],[92,58,28],[92,58,46],[68,58,46]]),c=O([[68,58,46],[92,58,46],[92,60,46],[68,60,46]]),f=O([[77,60,26],[83,60,26],[83,64,26],[77,64,26]]),h=O([[69,60,29],[91,60,29],[91,60,45],[69,60,45]]),y=e==="offline"?[]:[{y:42,w:14,color:C.codeLine1},{y:40,w:10,color:C.codeLine2},{y:38,w:16,color:C.codeLine3},{y:36,w:8,color:C.codeLine4},{y:34,w:12,color:C.codeLine1},{y:32,w:10,color:C.codeLine2}];return n("g",{children:[n("path",{d:O([[79,61,26],[81,61,26],[81,61,28],[79,61,28]]),fill:C.monitorStand}),n("path",{d:f,fill:C.monitorStand}),n("path",{d,fill:C.monitorFrame}),n("path",{d:c,fill:"#3a3a44"}),n("path",{d:o,fill:C.monitorFrame}),n("path",{d:h,fill:e==="offline"?"#222":C.monitorScreen}),e!=="offline"&&n("path",{d:h,fill:C.monitorScreenGlow,opacity:.3}),y.map((p,u)=>n("line",{x1:M(71,60,p.y)[0],y1:M(71,60,p.y)[1],x2:M(71+p.w,60,p.y)[0],y2:M(71+p.w,60,p.y)[1],stroke:p.color,strokeWidth:1,opacity:.7},u))]})}function ad(){const i=O([[67,82,18],[83,82,18],[83,92,18],[67,92,18]]),a=O([[68,90,18],[82,90,18],[82,92,32],[68,92,32]]),[l,s]=M(75,87,0),[o,d]=M(75,87,18);return n("g",{children:[[[-6,-3],[6,-3],[-6,8],[6,8],[0,10]].map(([c,f],h)=>{const[y,p]=M(75+c,87+f,1);return n("circle",{cx:y,cy:p,r:2,fill:C.chairWheel},h)}),n("line",{x1:l,y1:s,x2:o,y2:d,stroke:C.chairBase,strokeWidth:3}),n("path",{d:i,fill:C.chairSeat}),n("path",{d:a,fill:C.chairBack})]})}function ld({state:e}){const[a,l]=M(77,78,26),s=e==="offline"?C.lobsterGrey:C.lobsterBody,o=e==="offline"?"#aaa":C.lobsterBelly,d=e==="thinking",c=e==="offline",f=e==="working";return n("g",{children:[n("ellipse",{cx:a,cy:l,rx:10,ry:7,fill:s}),n("ellipse",{cx:a,cy:l+1,rx:6,ry:4,fill:o,opacity:.6}),n("ellipse",{cx:a,cy:l-8,rx:8,ry:6,fill:s}),n("circle",{cx:a-3,cy:l-9,r:2.5,fill:C.lobsterEye}),n("circle",{cx:a+3,cy:l-9,r:2.5,fill:C.lobsterEye}),n("circle",{cx:a-3,cy:l-9,r:1.2,fill:C.lobsterPupil}),n("circle",{cx:a+3,cy:l-9,r:1.2,fill:C.lobsterPupil}),n("line",{x1:a-4,y1:l-14,x2:a-8,y2:l-20,stroke:s,strokeWidth:1.2,strokeLinecap:"round"}),n("line",{x1:a+4,y1:l-14,x2:a+8,y2:l-20,stroke:s,strokeWidth:1.2,strokeLinecap:"round"}),n("circle",{cx:a-8,cy:l-20,r:1.5,fill:s}),n("circle",{cx:a+8,cy:l-20,r:1.5,fill:s}),n("g",{className:f?"lobster-typing":"",children:[n("path",{d:`M${a-8},${l} Q${a-16},${l+4} ${a-14},${l+8}`,stroke:s,strokeWidth:3,fill:"none",strokeLinecap:"round"}),n("ellipse",{cx:a-14,cy:l+9,rx:3,ry:2,fill:e==="offline"?"#999":C.lobsterClaw}),n("path",{d:`M${a+8},${l} Q${a+16},${l+4} ${a+14},${l+8}`,stroke:s,strokeWidth:3,fill:"none",strokeLinecap:"round"}),n("ellipse",{cx:a+14,cy:l+9,rx:3,ry:2,fill:e==="offline"?"#999":C.lobsterClaw})]}),d&&n("g",{children:[n("circle",{cx:a+14,cy:l-18,r:2,fill:"#fff",opacity:.7}),n("circle",{cx:a+18,cy:l-24,r:3,fill:"#fff",opacity:.7}),n("circle",{cx:a+22,cy:l-30,r:5,fill:"#fff",opacity:.6}),n("text",{x:a+22,y:l-28,textAnchor:"middle",fontSize:5,fill:"#666",children:"?"})]}),c&&n("g",{className:"lobster-zzz",children:[n("text",{x:a+10,y:l-16,fontSize:7,fill:"#666",fontWeight:"bold",opacity:.6,children:"z"}),n("text",{x:a+16,y:l-22,fontSize:9,fill:"#666",fontWeight:"bold",opacity:.5,children:"z"}),n("text",{x:a+22,y:l-30,fontSize:11,fill:"#666",fontWeight:"bold",opacity:.4,children:"Z"})]})]})}function sd(){const[e,t]=M(95,65,28);return n("g",{children:[n("rect",{x:e-4,y:t-6,width:8,height:8,rx:1,fill:"#e0d0c0"}),n("path",{d:`M${e+4},${t-4} Q${e+8},${t-2} ${e+4},${t}`,stroke:"#c8b8a8",strokeWidth:1.5,fill:"none"}),n("rect",{x:e-3,y:t-5,width:6,height:2,rx:1,fill:"#6a4030"}),n("path",{className:"coffee-steam",d:`M${e-1},${t-7} Q${e},${t-10} ${e+1},${t-8}`,stroke:"#ccc",strokeWidth:.8,fill:"none",opacity:.5}),n("path",{className:"coffee-steam-2",d:`M${e+1},${t-7} Q${e+2},${t-11} ${e+3},${t-8}`,stroke:"#ccc",strokeWidth:.8,fill:"none",opacity:.4})]})}function Oi({x:e,y:t}){const[r,i]=M(e,t,0);return n("g",{children:[n("rect",{x:r-5,y:i-8,width:10,height:10,rx:1,fill:C.plantPot}),n("rect",{x:r-6,y:i-9,width:12,height:2,rx:1,fill:"#b07050"}),n("ellipse",{cx:r,cy:i-14,rx:8,ry:6,fill:C.plantLeaf}),n("ellipse",{cx:r-3,cy:i-16,rx:5,ry:4,fill:C.plantLeafDark}),n("ellipse",{cx:r+4,cy:i-13,rx:4,ry:3,fill:"#6aaa5a"})]})}function od(){const l=O([[31,120,0],[31,134,0],[31,134,32],[31,120,32]]),s=O([[15,134,0],[31,134,0],[31,134,32],[15,134,32]]),o=O([[15,120,32],[31,120,32],[31,134,32],[15,134,32]]),d=[10,20];return n("g",{children:[n("path",{d:l,fill:C.cabinetFront}),n("path",{d:s,fill:C.cabinetBody}),n("path",{d:o,fill:"#a0a0a8"}),d.map((c,f)=>n("line",{x1:M(31,120,c)[0],y1:M(31,120,c)[1],x2:M(31,134,c)[0],y2:M(31,134,c)[1],stroke:C.cabinetHandle,strokeWidth:.5},f)),[5,15,25].map((c,f)=>{const[h,y]=M(31,127,c);return n("line",{x1:h-2,y1:y,x2:h+2,y2:y,stroke:C.cabinetHandle,strokeWidth:1.5,strokeLinecap:"round"},f)})]})}function cd(){const[e,t]=M(130,130,0);return n("g",{children:[n("rect",{x:e-6,y:t-2,width:12,height:4,rx:1,fill:"#888"}),n("rect",{x:e-5,y:t-18,width:10,height:16,rx:2,fill:C.coolerBody,stroke:"#bbb",strokeWidth:.5}),n("rect",{x:e+4,y:t-10,width:3,height:2,rx:.5,fill:"#999"}),n("ellipse",{cx:e,cy:t-22,rx:5,ry:3,fill:C.coolerJug,opacity:.8}),n("rect",{x:e-4,y:t-30,width:8,height:9,rx:3,fill:C.coolerJug,opacity:.7}),n("rect",{x:e-3,y:t-27,width:6,height:5,rx:2,fill:C.coolerWater,opacity:.5})]})}function dd(){const[e,t]=M(140,105,0);return n("g",{children:[n("rect",{x:e-8,y:t-10,width:16,height:10,rx:1,fill:C.boxBody}),n("rect",{x:e-8,y:t-12,width:16,height:2,rx:.5,fill:C.boxTop}),n("rect",{x:e-6,y:t-20,width:12,height:8,rx:1,fill:C.boxSide}),n("rect",{x:e-6,y:t-22,width:12,height:2,rx:.5,fill:C.boxTop})]})}function ud(){const[e,t]=M(120,100,0);return n("g",{children:[n("path",{d:`M${e-5},${t} L${e-4},${t-10} L${e+4},${t-10} L${e+5},${t} Z`,fill:C.trashBody}),n("ellipse",{cx:e,cy:t-10,rx:5,ry:2,fill:C.trashInner}),n("ellipse",{cx:e,cy:t-10,rx:5,ry:2,fill:"none",stroke:C.trashBody,strokeWidth:1})]})}function hd(){const a=O([[70,72,28.5],[88,72,28.5],[88,78,28.5],[70,78,28.5]]);return n("g",{children:[n("path",{d:a,fill:"#444"}),[0,2,4].map((l,s)=>n("line",{x1:M(72,73+l,28+.6)[0],y1:M(72,73+l,28+.6)[1],x2:M(86,73+l,28+.6)[0],y2:M(86,73+l,28+.6)[1],stroke:"#666",strokeWidth:.8},s))]})}function pd({state:e}){return n("svg",{viewBox:"-10 -120 640 380",style:{width:"100%",maxWidth:800,height:"auto"},role:"img","aria-label":"SkimpyClaw's isometric office",children:[n("defs",{children:n("radialGradient",{id:"floorShadow",cx:"50%",cy:"50%",r:"50%",children:[n("stop",{offset:"0%",stopColor:"#000",stopOpacity:.06}),n("stop",{offset:"100%",stopColor:"#000",stopOpacity:0})]})}),n("g",{transform:`translate(${Vc}, ${Zc})`,children:[n(Yc,{}),n("ellipse",{cx:M(80,80,0)[0],cy:M(80,80,0)[1],rx:100,ry:50,fill:"url(#floorShadow)"}),n(Kc,{}),n(Jc,{}),n(Xc,{}),n(Qc,{}),n(ed,{}),n(td,{}),n(od,{}),n(cd,{}),n(dd,{}),n(ud,{}),n(Oi,{x:20,y:140}),n(Oi,{x:145,y:145}),n(rd,{state:e}),n(nd,{}),n(hd,{}),n(id,{state:e}),n(sd,{}),n(ad,{}),n(ld,{state:e})]})]})}function fd(){const{status:e,useMock:t,setMockState:r,autoCycle:i,setAutoCycle:a}=qc(),l=rn[e.state];return n("div",{class:"page",style:{padding:0,overflow:"hidden"},children:[n("div",{style:{position:"relative",width:"100%",minHeight:"calc(100vh - 48px)",background:C.pageBg,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:0},children:[n("div",{style:{position:"absolute",top:24,left:"50%",transform:"translateX(-50%)",zIndex:10,display:"flex",alignItems:"center",gap:10,background:"rgba(30, 30, 40, 0.82)",backdropFilter:"blur(10px)",borderRadius:24,padding:"8px 22px",boxShadow:"0 2px 16px rgba(0,0,0,0.25)",whiteSpace:"nowrap"},children:[n("div",{style:{width:9,height:9,borderRadius:"50%",background:l.color,boxShadow:`0 0 8px ${l.color}`,animation:"pulse-dot 2s ease-in-out infinite",flexShrink:0}}),n("span",{style:{color:"#fff",fontWeight:700,fontSize:14,fontFamily:"var(--mono, monospace)"},children:l.label}),n("span",{style:{color:"rgba(255,255,255,0.55)",fontSize:13,fontFamily:"var(--mono, monospace)"},children:e.currentTask||l.blurb})]}),n("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",width:"100%",padding:"60px 20px 80px"},children:n(pd,{state:e.state})}),n("div",{style:{position:"absolute",bottom:24,left:"50%",transform:"translateX(-50%)",zIndex:10,display:"flex",gap:6,flexWrap:"wrap",justifyContent:"center"},children:[Object.keys(rn).map(s=>{const o=e.state===s&&!i;return n("button",{onClick:()=>t?r(s):void 0,disabled:!t,style:{padding:"6px 18px",borderRadius:20,border:"none",background:o?"rgba(50, 50, 80, 0.9)":"rgba(30, 30, 50, 0.65)",color:"#fff",fontSize:13,fontFamily:"var(--mono, monospace)",fontWeight:o?700:400,cursor:t?"pointer":"default",opacity:t?1:.6,boxShadow:o?`0 0 10px rgba(${{working:"74,222,128",thinking:"250,204,21",waiting:"96,165,250",offline:"156,163,175"}[s]},0.3)`:"0 2px 8px rgba(0,0,0,0.2)",transition:"all 0.2s ease",backdropFilter:"blur(6px)"},children:s},s)}),t&&n("button",{onClick:()=>a(!i),style:{padding:"6px 18px",borderRadius:20,border:"none",background:i?"rgba(100, 60, 180, 0.85)":"rgba(30, 30, 50, 0.65)",color:"#fff",fontSize:13,fontFamily:"var(--mono, monospace)",fontWeight:i?700:400,cursor:"pointer",boxShadow:i?"0 0 10px rgba(100,60,180,0.4)":"0 2px 8px rgba(0,0,0,0.2)",transition:"all 0.2s ease",backdropFilter:"blur(6px)"},children:"auto-cycle"})]})]}),n("style",{children:`
|
|
66
|
+
@keyframes pulse-dot {
|
|
67
|
+
0%, 100% { opacity: 1; }
|
|
68
|
+
50% { opacity: 0.5; }
|
|
69
|
+
}
|
|
70
|
+
.lobster-typing {
|
|
71
|
+
animation: typing-bounce 0.6s ease-in-out infinite alternate;
|
|
72
|
+
}
|
|
73
|
+
@keyframes typing-bounce {
|
|
74
|
+
0% { transform: translateY(0); }
|
|
75
|
+
100% { transform: translateY(-1px); }
|
|
76
|
+
}
|
|
77
|
+
.lobster-zzz text {
|
|
78
|
+
animation: zzz-float 2s ease-in-out infinite;
|
|
79
|
+
}
|
|
80
|
+
.lobster-zzz text:nth-child(2) {
|
|
81
|
+
animation-delay: 0.5s;
|
|
82
|
+
}
|
|
83
|
+
.lobster-zzz text:nth-child(3) {
|
|
84
|
+
animation-delay: 1s;
|
|
85
|
+
}
|
|
86
|
+
@keyframes zzz-float {
|
|
87
|
+
0%, 100% { opacity: 0.3; transform: translateY(0); }
|
|
88
|
+
50% { opacity: 0.7; transform: translateY(-3px); }
|
|
89
|
+
}
|
|
90
|
+
.coffee-steam {
|
|
91
|
+
animation: steam-rise 2s ease-in-out infinite;
|
|
92
|
+
}
|
|
93
|
+
.coffee-steam-2 {
|
|
94
|
+
animation: steam-rise 2s ease-in-out infinite;
|
|
95
|
+
animation-delay: 0.8s;
|
|
96
|
+
}
|
|
97
|
+
@keyframes steam-rise {
|
|
98
|
+
0%, 100% { opacity: 0.3; transform: translateY(0); }
|
|
99
|
+
50% { opacity: 0.6; transform: translateY(-2px); }
|
|
100
|
+
}
|
|
101
|
+
@media (prefers-reduced-motion: reduce) {
|
|
102
|
+
.lobster-typing, .lobster-zzz text,
|
|
103
|
+
.coffee-steam, .coffee-steam-2 {
|
|
104
|
+
animation: none !important;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
`})]})}const md=["overview","history","cron","memory","model","coding","logs","audit","digests","skills","approvals","health","usage","config","templates","office"];function gd(e){return md.includes(e)}function Ni(){const e=window.location.hash.replace(/^#/,"").trim();return gd(e)?e:"overview"}function yd(){const e=window.__SKIMPY_DASHBOARD__,t=typeof(e==null?void 0:e.botName)=="string"&&e.botName.trim()?e.botName:"SkimpyClaw",r=typeof(e==null?void 0:e.botEmoji)=="string"&&e.botEmoji.trim()?e.botEmoji:"👙🦞";return{name:t,emoji:r}}function vd({onLogin:e,botName:t,botEmoji:r}){const[i,a]=x(""),[l,s]=x("");async function o(){const d=i.trim();if(d)try{if((await fetch("/api/dashboard/status",{headers:{Authorization:`Bearer ${d}`}})).status===401){s("Invalid token");return}gs(d),e(d)}catch{s("Could not reach server")}}return n("div",{style:{minHeight:"100vh",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--bg)"},children:n("div",{style:{background:"var(--surface)",border:"1px solid var(--border)",borderRadius:"var(--radius)",padding:"40px 48px",width:360,boxShadow:"var(--shadow-md)",textAlign:"center"},children:[n("div",{style:{fontSize:36,marginBottom:16},children:r}),n("div",{style:{fontFamily:"var(--serif)",fontSize:22,fontWeight:800,marginBottom:8},children:t}),n("div",{style:{fontSize:13,color:"var(--text-muted)",marginBottom:28},children:"Enter your dashboard token"}),n("input",{type:"password",placeholder:"Bearer token",value:i,onInput:d=>{a(d.target.value),s("")},onKeyDown:d=>d.key==="Enter"&&o(),style:{width:"100%",padding:"10px 14px",borderRadius:"var(--radius-sm)",border:`1px solid ${l?"var(--error)":"var(--border)"}`,background:"var(--surface-alt)",color:"var(--text)",fontFamily:"var(--mono)",fontSize:13,marginBottom:12,outline:"none",boxSizing:"border-box"}}),l&&n("div",{style:{fontSize:12,color:"var(--error)",marginBottom:12},children:l}),n("button",{class:"btn btn-primary",style:{width:"100%"},onClick:o,children:"Sign in"})]})})}function _d(){const e=yd(),[t,r]=x(!!va()),[i,a]=x(()=>Ni()),[l,s]=x(()=>window.innerWidth<=980),[o,d]=x(()=>window.innerWidth>980),[c,f]=x(()=>localStorage.getItem("theme")??"light"),[h,y]=x(0),{toasts:p,showToast:u}=ms();q(()=>vs(()=>{r(!1)}),[]),q(()=>{document.documentElement.setAttribute("data-theme",c),localStorage.setItem("theme",c)},[c]),q(()=>{function g(){const v=window.innerWidth<=980;s(E=>(E!==v&&d(!v),v))}return window.addEventListener("resize",g),()=>window.removeEventListener("resize",g)},[]),q(()=>{if(!l||!o){document.body.style.overflow="";return}return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[l,o]),q(()=>{const g=()=>{const v=Ni();a(v),l&&d(!1)};return window.location.hash?g():window.location.hash="#overview",window.addEventListener("hashchange",g),()=>window.removeEventListener("hashchange",g)},[l]);function _(){f(g=>g==="light"?"dark":"light")}function w(g){const v=`#${g}`;window.location.hash!==v?window.location.hash=v:a(g),l&&d(!1)}if(!t)return n(vd,{botName:e.name,botEmoji:e.emoji,onLogin:()=>r(!0)});function k(){switch(i){case"overview":return n(pi,{onNavigate:w,showToast:u});case"history":return n(io,{});case"cron":return n(lo,{showToast:u});case"usage":return n(jc,{});case"coding":return n(wc,{});case"audit":return n(Cc,{});case"approvals":return n(Lc,{showToast:u,onCountChange:y});case"memory":return n($c,{});case"model":return n(Dc,{showToast:u});case"logs":return n(Pc,{});case"config":return n(Nc,{showToast:u});case"digests":return n(Hc,{});case"skills":return n(Bc,{showToast:u});case"health":return n(Fc,{});case"templates":return n(Wc,{showToast:u});case"office":return n(fd,{});default:return n(pi,{onNavigate:w,showToast:u})}}return n(ae,{children:[n("div",{class:`shell${l?" shell-narrow":""}${l&&o?" sidebar-open":""}`,children:[l&&n("button",{class:"global-sidebar-toggle",onClick:()=>d(!0),"aria-label":"Open sidebar",children:n(ls,{size:16})}),n(ps,{currentPage:i,onNavigate:w,botName:e.name,botEmoji:e.emoji,pendingApprovals:h,isNarrow:l,onClose:()=>d(!1)}),l&&o?n("button",{class:"sidebar-backdrop",onClick:()=>d(!1),"aria-label":"Close sidebar"}):null,n("main",{class:"main",children:[n("button",{class:"global-theme-toggle",onClick:_,"aria-label":"Toggle theme",children:c==="light"?n(ss,{size:16}):n(us,{size:16})}),k()]})]}),n(fs,{toasts:p})]})}nt(n(_d,{}),document.getElementById("app"));
|