wasmrun 0.20.0

A WebAssembly Runtime
1
(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const d of a.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&s(d)}).observe(document,{childList:!0,subtree:!0});function r(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function s(i){if(i.ep)return;i.ep=!0;const a=r(i);fetch(i.href,a)}})();var X,$,Fe,j,be,Ne,je,Ue,he,ae,le,He,I={},Le=[],Ze=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Y=Array.isArray;function N(t,e){for(var r in e)t[r]=e[r];return t}function fe(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function et(t,e,r){var s,i,a,d={};for(a in e)a=="key"?s=e[a]:a=="ref"?i=e[a]:d[a]=e[a];if(arguments.length>2&&(d.children=arguments.length>3?X.call(arguments,2):r),typeof t=="function"&&t.defaultProps!=null)for(a in t.defaultProps)d[a]===void 0&&(d[a]=t.defaultProps[a]);return G(t,d,s,i,null)}function G(t,e,r,s,i){var a={type:t,props:e,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Fe,__i:-1,__u:0};return i==null&&$.vnode!=null&&$.vnode(a),a}function Z(t){return t.children}function K(t,e){this.props=t,this.context=e}function H(t,e){if(e==null)return t.__?H(t.__,t.__i+1):null;for(var r;e<t.__k.length;e++)if((r=t.__k[e])!=null&&r.__e!=null)return r.__e;return typeof t.type=="function"?H(t):null}function ze(t){var e,r;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((r=t.__k[e])!=null&&r.__e!=null){t.__e=t.__c.base=r.__e;break}return ze(t)}}function oe(t){(!t.__d&&(t.__d=!0)&&j.push(t)&&!Q.__r++||be!=$.debounceRendering)&&((be=$.debounceRendering)||Ne)(Q)}function Q(){for(var t,e,r,s,i,a,d,l=1;j.length;)j.length>l&&j.sort(je),t=j.shift(),l=j.length,t.__d&&(r=void 0,i=(s=(e=t).__v).__e,a=[],d=[],e.__P&&((r=N({},s)).__v=s.__v+1,$.vnode&&$.vnode(r),pe(e.__P,r,s,e.__n,e.__P.namespaceURI,32&s.__u?[i]:null,a,i??H(s),!!(32&s.__u),d),r.__v=s.__v,r.__.__k[r.__i]=r,Oe(a,r,d),r.__e!=i&&ze(r)));Q.__r=0}function Be(t,e,r,s,i,a,d,l,u,h,c){var o,x,_,w,E,g,f,p=s&&s.__k||Le,b=e.length;for(u=tt(r,e,p,u,b),o=0;o<b;o++)(_=r.__k[o])!=null&&(x=_.__i==-1?I:p[_.__i]||I,_.__i=o,g=pe(t,_,x,i,a,d,l,u,h,c),w=_.__e,_.ref&&x.ref!=_.ref&&(x.ref&&_e(x.ref,null,_),c.push(_.ref,_.__c||w,_)),E==null&&w!=null&&(E=w),(f=!!(4&_.__u))||x.__k===_.__k?u=Ie(_,u,t,f):typeof _.type=="function"&&g!==void 0?u=g:w&&(u=w.nextSibling),_.__u&=-7);return r.__e=E,u}function tt(t,e,r,s,i){var a,d,l,u,h,c=r.length,o=c,x=0;for(t.__k=new Array(i),a=0;a<i;a++)(d=e[a])!=null&&typeof d!="boolean"&&typeof d!="function"?(u=a+x,(d=t.__k[a]=typeof d=="string"||typeof d=="number"||typeof d=="bigint"||d.constructor==String?G(null,d,null,null,null):Y(d)?G(Z,{children:d},null,null,null):d.constructor==null&&d.__b>0?G(d.type,d.props,d.key,d.ref?d.ref:null,d.__v):d).__=t,d.__b=t.__b+1,l=null,(h=d.__i=rt(d,r,u,o))!=-1&&(o--,(l=r[h])&&(l.__u|=2)),l==null||l.__v==null?(h==-1&&(i>c?x--:i<c&&x++),typeof d.type!="function"&&(d.__u|=4)):h!=u&&(h==u-1?x--:h==u+1?x++:(h>u?x--:x++,d.__u|=4))):t.__k[a]=null;if(o)for(a=0;a<c;a++)(l=r[a])!=null&&!(2&l.__u)&&(l.__e==s&&(s=H(l)),Ve(l,l));return s}function Ie(t,e,r,s){var i,a;if(typeof t.type=="function"){for(i=t.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=t,e=Ie(i[a],e,r,s));return e}t.__e!=e&&(s&&(e&&t.type&&!e.parentNode&&(e=H(t)),r.insertBefore(t.__e,e||null)),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function rt(t,e,r,s){var i,a,d,l=t.key,u=t.type,h=e[r],c=h!=null&&(2&h.__u)==0;if(h===null&&t.key==null||c&&l==h.key&&u==h.type)return r;if(s>(c?1:0)){for(i=r-1,a=r+1;i>=0||a<e.length;)if((h=e[d=i>=0?i--:a++])!=null&&!(2&h.__u)&&l==h.key&&u==h.type)return d}return-1}function ye(t,e,r){e[0]=="-"?t.setProperty(e,r??""):t[e]=r==null?"":typeof r!="number"||Ze.test(e)?r:r+"px"}function V(t,e,r,s,i){var a,d;e:if(e=="style")if(typeof r=="string")t.style.cssText=r;else{if(typeof s=="string"&&(t.style.cssText=s=""),s)for(e in s)r&&e in r||ye(t.style,e,"");if(r)for(e in r)s&&r[e]==s[e]||ye(t.style,e,r[e])}else if(e[0]=="o"&&e[1]=="n")a=e!=(e=e.replace(Ue,"$1")),d=e.toLowerCase(),e=d in t||e=="onFocusOut"||e=="onFocusIn"?d.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+a]=r,r?s?r.u=s.u:(r.u=he,t.addEventListener(e,a?le:ae,a)):t.removeEventListener(e,a?le:ae,a);else{if(i=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=r??"";break e}catch{}typeof r=="function"||(r==null||r===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&r==1?"":r))}}function ke(t){return function(e){if(this.l){var r=this.l[e.type+t];if(e.t==null)e.t=he++;else if(e.t<r.u)return;return r($.event?$.event(e):e)}}}function pe(t,e,r,s,i,a,d,l,u,h){var c,o,x,_,w,E,g,f,p,b,v,D,y,A,S,F,k,m=e.type;if(e.constructor!=null)return null;128&r.__u&&(u=!!(32&r.__u),a=[l=e.__e=r.__e]),(c=$.__b)&&c(e);e:if(typeof m=="function")try{if(f=e.props,p="prototype"in m&&m.prototype.render,b=(c=m.contextType)&&s[c.__c],v=c?b?b.props.value:c.__:s,r.__c?g=(o=e.__c=r.__c).__=o.__E:(p?e.__c=o=new m(f,v):(e.__c=o=new K(f,v),o.constructor=m,o.render=st),b&&b.sub(o),o.props=f,o.state||(o.state={}),o.context=v,o.__n=s,x=o.__d=!0,o.__h=[],o._sb=[]),p&&o.__s==null&&(o.__s=o.state),p&&m.getDerivedStateFromProps!=null&&(o.__s==o.state&&(o.__s=N({},o.__s)),N(o.__s,m.getDerivedStateFromProps(f,o.__s))),_=o.props,w=o.state,o.__v=e,x)p&&m.getDerivedStateFromProps==null&&o.componentWillMount!=null&&o.componentWillMount(),p&&o.componentDidMount!=null&&o.__h.push(o.componentDidMount);else{if(p&&m.getDerivedStateFromProps==null&&f!==_&&o.componentWillReceiveProps!=null&&o.componentWillReceiveProps(f,v),!o.__e&&o.shouldComponentUpdate!=null&&o.shouldComponentUpdate(f,o.__s,v)===!1||e.__v==r.__v){for(e.__v!=r.__v&&(o.props=f,o.state=o.__s,o.__d=!1),e.__e=r.__e,e.__k=r.__k,e.__k.some(function(C){C&&(C.__=e)}),D=0;D<o._sb.length;D++)o.__h.push(o._sb[D]);o._sb=[],o.__h.length&&d.push(o);break e}o.componentWillUpdate!=null&&o.componentWillUpdate(f,o.__s,v),p&&o.componentDidUpdate!=null&&o.__h.push(function(){o.componentDidUpdate(_,w,E)})}if(o.context=v,o.props=f,o.__P=t,o.__e=!1,y=$.__r,A=0,p){for(o.state=o.__s,o.__d=!1,y&&y(e),c=o.render(o.props,o.state,o.context),S=0;S<o._sb.length;S++)o.__h.push(o._sb[S]);o._sb=[]}else do o.__d=!1,y&&y(e),c=o.render(o.props,o.state,o.context),o.state=o.__s;while(o.__d&&++A<25);o.state=o.__s,o.getChildContext!=null&&(s=N(N({},s),o.getChildContext())),p&&!x&&o.getSnapshotBeforeUpdate!=null&&(E=o.getSnapshotBeforeUpdate(_,w)),F=c,c!=null&&c.type===Z&&c.key==null&&(F=Re(c.props.children)),l=Be(t,Y(F)?F:[F],e,r,s,i,a,d,l,u,h),o.base=e.__e,e.__u&=-161,o.__h.length&&d.push(o),g&&(o.__E=o.__=null)}catch(C){if(e.__v=null,u||a!=null)if(C.then){for(e.__u|=u?160:128;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;a[a.indexOf(l)]=null,e.__e=l}else{for(k=a.length;k--;)fe(a[k]);ce(e)}else e.__e=r.__e,e.__k=r.__k,C.then||ce(e);$.__e(C,e,r)}else a==null&&e.__v==r.__v?(e.__k=r.__k,e.__e=r.__e):l=e.__e=nt(r.__e,e,r,s,i,a,d,u,h);return(c=$.diffed)&&c(e),128&e.__u?void 0:l}function ce(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(ce)}function Oe(t,e,r){for(var s=0;s<r.length;s++)_e(r[s],r[++s],r[++s]);$.__c&&$.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(a){a.call(i)})}catch(a){$.__e(a,i.__v)}})}function Re(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:Y(t)?t.map(Re):N({},t)}function nt(t,e,r,s,i,a,d,l,u){var h,c,o,x,_,w,E,g=r.props,f=e.props,p=e.type;if(p=="svg"?i="http://www.w3.org/2000/svg":p=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),a!=null){for(h=0;h<a.length;h++)if((_=a[h])&&"setAttribute"in _==!!p&&(p?_.localName==p:_.nodeType==3)){t=_,a[h]=null;break}}if(t==null){if(p==null)return document.createTextNode(f);t=document.createElementNS(i,p,f.is&&f),l&&($.__m&&$.__m(e,a),l=!1),a=null}if(p==null)g===f||l&&t.data==f||(t.data=f);else{if(a=a&&X.call(t.childNodes),g=r.props||I,!l&&a!=null)for(g={},h=0;h<t.attributes.length;h++)g[(_=t.attributes[h]).name]=_.value;for(h in g)if(_=g[h],h!="children"){if(h=="dangerouslySetInnerHTML")o=_;else if(!(h in f)){if(h=="value"&&"defaultValue"in f||h=="checked"&&"defaultChecked"in f)continue;V(t,h,null,_,i)}}for(h in f)_=f[h],h=="children"?x=_:h=="dangerouslySetInnerHTML"?c=_:h=="value"?w=_:h=="checked"?E=_:l&&typeof _!="function"||g[h]===_||V(t,h,_,g[h],i);if(c)l||o&&(c.__html==o.__html||c.__html==t.innerHTML)||(t.innerHTML=c.__html),e.__k=[];else if(o&&(t.innerHTML=""),Be(e.type=="template"?t.content:t,Y(x)?x:[x],e,r,s,p=="foreignObject"?"http://www.w3.org/1999/xhtml":i,a,d,a?a[0]:r.__k&&H(r,0),l,u),a!=null)for(h=a.length;h--;)fe(a[h]);l||(h="value",p=="progress"&&w==null?t.removeAttribute("value"):w!=null&&(w!==t[h]||p=="progress"&&!w||p=="option"&&w!=g[h])&&V(t,h,w,g[h],i),h="checked",E!=null&&E!=t[h]&&V(t,h,E,g[h],i))}return t}function _e(t,e,r){try{if(typeof t=="function"){var s=typeof t.__u=="function";s&&t.__u(),s&&e==null||(t.__u=t(e))}else t.current=e}catch(i){$.__e(i,r)}}function Ve(t,e,r){var s,i;if($.unmount&&$.unmount(t),(s=t.ref)&&(s.current&&s.current!=t.__e||_e(s,null,e)),(s=t.__c)!=null){if(s.componentWillUnmount)try{s.componentWillUnmount()}catch(a){$.__e(a,e)}s.base=s.__P=null}if(s=t.__k)for(i=0;i<s.length;i++)s[i]&&Ve(s[i],e,r||typeof t.type!="function");r||fe(t.__e),t.__c=t.__=t.__e=void 0}function st(t,e,r){return this.constructor(t,r)}function it(t,e,r){var s,i,a,d;e==document&&(e=document.documentElement),$.__&&$.__(t,e),i=(s=!1)?null:e.__k,a=[],d=[],pe(e,t=e.__k=et(Z,null,[t]),i||I,I,e.namespaceURI,i?null:e.firstChild?X.call(e.childNodes):null,a,i?i.__e:e.firstChild,s,d),Oe(a,t,d)}function at(t){function e(r){var s,i;return this.getChildContext||(s=new Set,(i={})[e.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){s=null},this.shouldComponentUpdate=function(a){this.props.value!=a.value&&s.forEach(function(d){d.__e=!0,oe(d)})},this.sub=function(a){s.add(a);var d=a.componentWillUnmount;a.componentWillUnmount=function(){s&&s.delete(a),d&&d.call(a)}}),r.children}return e.__c="__cC"+He++,e.__=t,e.Provider=e.__l=(e.Consumer=function(r,s){return r.children(s)}).contextType=e,e}X=Le.slice,$={__e:function(t,e,r,s){for(var i,a,d;e=e.__;)if((i=e.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(t)),d=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,s||{}),d=i.__d),d)return i.__E=i}catch(l){t=l}throw t}},Fe=0,K.prototype.setState=function(t,e){var r;r=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=N({},this.state),typeof t=="function"&&(t=t(N({},r),this.props)),t&&N(r,t),t!=null&&this.__v&&(e&&this._sb.push(e),oe(this))},K.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),oe(this))},K.prototype.render=Z,j=[],Ne=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,je=function(t,e){return t.__v.__b-e.__v.__b},Q.__r=0,Ue=/(PointerCapture)$|Capture$/i,he=0,ae=ke(!1),le=ke(!0),He=0;var lt=0;function n(t,e,r,s,i,a){e||(e={});var d,l,u=e;if("ref"in u)for(l in u={},e)l=="ref"?d=e[l]:u[l]=e[l];var h={type:t,props:u,key:r,ref:d,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--lt,__i:-1,__u:0,__source:i,__self:a};if(typeof t=="function"&&(d=t.defaultProps))for(l in d)u[l]===void 0&&(u[l]=d[l]);return $.vnode&&$.vnode(h),h}var L,M,ne,ve,O=0,qe=[],P=$,we=P.__b,$e=P.__r,De=P.diffed,Me=P.__c,Ae=P.unmount,Se=P.__;function ee(t,e){P.__h&&P.__h(M,t,O||e),O=0;var r=M.__H||(M.__H={__:[],__h:[]});return t>=r.__.length&&r.__.push({}),r.__[t]}function T(t){return O=1,ot(Je,t)}function ot(t,e,r){var s=ee(L++,2);if(s.t=t,!s.__c&&(s.__=[Je(void 0,e),function(l){var u=s.__N?s.__N[0]:s.__[0],h=s.t(u,l);u!==h&&(s.__N=[h,s.__[1]],s.__c.setState({}))}],s.__c=M,!M.__f)){var i=function(l,u,h){if(!s.__c.__H)return!0;var c=s.__c.__H.__.filter(function(x){return!!x.__c});if(c.every(function(x){return!x.__N}))return!a||a.call(this,l,u,h);var o=s.__c.props!==l;return c.forEach(function(x){if(x.__N){var _=x.__[0];x.__=x.__N,x.__N=void 0,_!==x.__[0]&&(o=!0)}}),a&&a.call(this,l,u,h)||o};M.__f=!0;var a=M.shouldComponentUpdate,d=M.componentWillUpdate;M.componentWillUpdate=function(l,u,h){if(this.__e){var c=a;a=void 0,i(l,u,h),a=c}d&&d.call(this,l,u,h)},M.shouldComponentUpdate=i}return s.__N||s.__}function R(t,e){var r=ee(L++,3);!P.__s&&Ke(r.__H,e)&&(r.__=t,r.u=e,M.__H.__h.push(r))}function Pe(t){return O=5,Ge(function(){return{current:t}},[])}function Ge(t,e){var r=ee(L++,7);return Ke(r.__H,e)&&(r.__=t(),r.__H=e,r.__h=t),r.__}function q(t,e){return O=8,Ge(function(){return t},e)}function ct(t){var e=M.context[t.__c],r=ee(L++,9);return r.c=t,e?(r.__==null&&(r.__=!0,e.sub(M)),e.props.value):t.__}function dt(){for(var t;t=qe.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(J),t.__H.__h.forEach(de),t.__H.__h=[]}catch(e){t.__H.__h=[],P.__e(e,t.__v)}}P.__b=function(t){M=null,we&&we(t)},P.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),Se&&Se(t,e)},P.__r=function(t){$e&&$e(t),L=0;var e=(M=t.__c).__H;e&&(ne===M?(e.__h=[],M.__h=[],e.__.forEach(function(r){r.__N&&(r.__=r.__N),r.u=r.__N=void 0})):(e.__h.forEach(J),e.__h.forEach(de),e.__h=[],L=0)),ne=M},P.diffed=function(t){De&&De(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(qe.push(e)!==1&&ve===P.requestAnimationFrame||((ve=P.requestAnimationFrame)||ut)(dt)),e.__H.__.forEach(function(r){r.u&&(r.__H=r.u),r.u=void 0})),ne=M=null},P.__c=function(t,e){e.some(function(r){try{r.__h.forEach(J),r.__h=r.__h.filter(function(s){return!s.__||de(s)})}catch(s){e.some(function(i){i.__h&&(i.__h=[])}),e=[],P.__e(s,r.__v)}}),Me&&Me(t,e)},P.unmount=function(t){Ae&&Ae(t);var e,r=t.__c;r&&r.__H&&(r.__H.__.forEach(function(s){try{J(s)}catch(i){e=i}}),r.__H=void 0,e&&P.__e(e,r.__v))};var Ee=typeof requestAnimationFrame=="function";function ut(t){var e,r=function(){clearTimeout(s),Ee&&cancelAnimationFrame(e),setTimeout(t)},s=setTimeout(r,35);Ee&&(e=requestAnimationFrame(r))}function J(t){var e=M,r=t.__c;typeof r=="function"&&(t.__c=void 0,r()),M=e}function de(t){var e=M;t.__c=t.__(),M=e}function Ke(t,e){return!t||t.length!==e.length||e.some(function(r,s){return r!==t[s]})}function Je(t,e){return typeof e=="function"?e(t):e}const Qe=at(void 0);function ht({children:t}){const[e,r]=T("dark");R(()=>{const a=localStorage.getItem("wasmrun-theme");r(a&&(a==="light"||a==="dark")?a:"dark")},[]),R(()=>{document.documentElement.classList.remove("light","dark"),document.documentElement.classList.add(e),localStorage.setItem("wasmrun-theme",e)},[e]);const i={theme:e,toggleTheme:()=>{r(a=>a==="dark"?"light":"dark")}};return n(Qe.Provider,{value:i,children:t})}function ft(){const t=ct(Qe);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t}function pt(){const{theme:t,toggleTheme:e}=ft();return n("button",{onClick:e,class:"p-2 rounded-lg transition-colors duration-200 hover:bg-black/10 dark:hover:bg-white/10 focus:outline-none focus:ring-2 focus:ring-light-accent2 dark:focus:ring-dark-accent2",title:`Switch to ${t==="dark"?"light":"dark"} mode`,children:t==="dark"?n("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"text-light-textMuted dark:text-dark-textMuted",children:[n("circle",{cx:"12",cy:"12",r:"5"}),n("path",{d:"M12 1v2M12 21v2M4.2 4.2l1.4 1.4M18.4 18.4l1.4 1.4M1 12h2M21 12h2M4.2 19.8l1.4-1.4M18.4 5.6l1.4-1.4"})]}):n("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"text-light-textMuted dark:text-dark-textMuted",children:n("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})})}function _t(){const[t,e]=T(""),[r,s]=T(!0),[i,a]=T(null);return R(()=>{(async()=>{try{s(!0);const l=await fetch("/api/version");if(!l.ok)throw new Error(`Failed to fetch version: ${l.statusText}`);const u=await l.json();e(u.version),a(null)}catch(l){console.error("Error fetching version:",l),a(l instanceof Error?l.message:"Unknown error"),e("")}finally{s(!1)}})()},[]),{version:t,loading:r,error:i}}function Xe(t){var e,r,s="";if(typeof t=="string"||typeof t=="number")s+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(r=Xe(t[e]))&&(s&&(s+=" "),s+=r)}else for(r in t)t[r]&&(s&&(s+=" "),s+=r);return s}function U(){for(var t,e,r=0,s="",i=arguments.length;r<i;r++)(t=arguments[r])&&(e=Xe(t))&&(s&&(s+=" "),s+=e);return s}function mt({filename:t,children:e,tabs:r,activeTab:s,onTabChange:i}){const{version:a,loading:d}=_t();return n("div",{class:"h-screen flex flex-col bg-light-bg dark:bg-dark-bg text-light-text dark:text-dark-text overflow-hidden",children:[n("header",{class:"bg-light-surface dark:bg-dark-surface shadow-lg flex-shrink-0",children:[n("div",{class:"flex items-center justify-between px-8 py-4",children:[n("div",{class:"flex items-center",children:n("div",{class:"flex items-center justify-center",children:n("img",{src:"/assets/logo-text.png",alt:"Wasmrun",width:"40",height:"40",class:"w-auto h-10"})})}),n("div",{class:"flex-1 flex justify-center items-center",children:t&&n("p",{class:"text-sm text-light-textDim dark:text-dark-textDim mt-1",children:["Running:"," ",n("span",{class:"font-mono text-green-500 dark:text-green-400",children:t})]})}),n("div",{class:"flex items-center gap-4",children:[n("a",{href:"https://github.com/anistark/wasmrun",target:"_blank",title:"GitHub",class:"text-light-textDim dark:text-dark-textDim hover:text-light-accent2 dark:hover:text-purple-400 transition-colors",children:n("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:n("path",{d:"M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"})})}),n("a",{href:"https://x.com/kranirudha",target:"_blank",title:"Twitter",class:"text-light-textDim dark:text-dark-textDim hover:text-light-accent2 dark:hover:text-purple-400 transition-colors",children:n("svg",{xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",width:"20",height:"20",viewBox:"0,0,256,256",children:n("g",{fill:"#ffffff","fill-rule":"nonzero",stroke:"none","stroke-width":"1","stroke-linecap":"butt","stroke-linejoin":"miter","stroke-miterlimit":"10","stroke-dasharray":"","stroke-dashoffset":"0","font-family":"none","font-weight":"none","font-size":"none","text-anchor":"none",style:"mix-blend-mode: normal",children:n("g",{transform:"scale(5.12,5.12)",children:n("path",{d:"M5.91992,6l14.66211,21.375l-14.35156,16.625h3.17969l12.57617,-14.57812l10,14.57813h12.01367l-15.31836,-22.33008l13.51758,-15.66992h-3.16992l-11.75391,13.61719l-9.3418,-13.61719zM9.7168,8h7.16406l23.32227,34h-7.16406z"})})})})}),n(pt,{})]})]}),r&&r.length>0&&n("div",{class:"flex bg-light-surface2 dark:bg-dark-surface2 border-t border-light-surface3 dark:border-dark-surface3",children:r.map(l=>n("button",{onClick:()=>!l.disabled&&(i==null?void 0:i(l.id)),class:U("px-6 py-3 text-sm font-medium transition-colors duration-200",{"bg-light-surface dark:bg-dark-surface border-b-2 border-light-accent2 dark:border-dark-accent text-light-textMuted dark:text-dark-textMuted":s===l.id,"text-light-textMuted dark:text-dark-textMuted hover:bg-light-surface3 dark:hover:bg-dark-surface3":s!==l.id&&!l.disabled,"text-light-textDim dark:text-dark-textDim cursor-not-allowed opacity-50":l.disabled}),disabled:l.disabled,children:l.label},l.id))})]}),n("main",{class:"flex-1 flex flex-col min-h-0",children:e}),n("footer",{class:"bg-light-surface dark:bg-dark-surface py-2 flex-shrink-0",children:n("div",{class:"px-8",children:n("div",{class:"flex justify-center items-center",children:n("p",{class:"text-xs font-semibold text-light-textDim dark:text-dark-textDim",children:["Wasmrun",!d&&a&&` v${a}`]})})})})]})}function se({logs:t,height:e="h-full",onCommand:r,interactive:s=!1}){const i=Pe(null),a=Pe(null),[d,l]=T(""),[u,h]=T([]),[c,o]=T(-1),[x,_]=T(!1);R(()=>{i.current&&!x&&i.current.scrollTo({top:i.current.scrollHeight,behavior:"smooth"})},[t,x]);const w=()=>{if(i.current){const{scrollTop:f,scrollHeight:p,clientHeight:b}=i.current,v=Math.abs(p-f-b)<5;_(!v)}},E=f=>{if(f.key==="Enter")f.preventDefault(),d.trim()&&r&&(r(d.trim()),h(p=>[...p,d.trim()]),l(""),o(-1));else if(f.key==="ArrowUp"){if(f.preventDefault(),u.length>0){const p=c===-1?u.length-1:Math.max(0,c-1);o(p),l(u[p])}}else if(f.key==="ArrowDown"&&(f.preventDefault(),c!==-1)){const p=c+1;p>=u.length?(o(-1),l("")):(o(p),l(u[p]))}},g=()=>{s&&a.current&&a.current.focus()};return n("div",{class:U("flex flex-col",e),onClick:g,children:[n("div",{ref:i,onScroll:w,class:U("bg-light-bg dark:bg-dark-bg border border-light-surface3 dark:border-dark-surface3 rounded-t p-4 overflow-y-auto text-left font-mono text-sm flex-1 cursor-text max-h-full",!s&&"rounded-b"),style:{scrollBehavior:"smooth"},children:t.length===0?n("div",{class:"text-light-textDim dark:text-dark-textDim italic",children:s?"":"No logs yet..."}):t.map((f,p)=>n("div",{class:U("mb-1 flex justify-between",{"text-light-success dark:text-dark-success":f.type==="success","text-light-error dark:text-dark-error":f.type==="error","text-light-info dark:text-dark-info":f.type==="info","text-light-warning dark:text-dark-warning":f.type==="warning"}),children:[n("span",{class:"flex-1",children:f.message}),n("span",{class:"text-light-textDim dark:text-dark-textDim text-xs ml-4",children:f.timestamp.toLocaleTimeString()})]},p))}),s&&n("div",{class:"bg-light-bg dark:bg-dark-bg border-l border-r border-b border-light-surface3 dark:border-dark-surface3 rounded-b p-4",children:n("div",{class:"flex items-center gap-2",children:[n("span",{class:"text-light-accent2 dark:text-dark-accent2 font-mono text-sm font-bold",children:">"}),n("input",{ref:a,type:"text",value:d,onInput:f=>l(f.target.value),onKeyDown:E,class:"flex-1 bg-transparent text-light-textMuted dark:text-dark-textMuted border-none outline-none font-mono text-sm",autoFocus:!0})]})})]})}function Ce({functions:t,onFunctionCall:e}){const[r,s]=T({}),[i,a]=T({}),d=async l=>{if(!e)return;const u=l.name;a(h=>({...h,[u]:!0}));try{const h=l.parameters.map(o=>{const x=document.querySelector(`input[data-function="${u}"][data-param="${o.name}"]`),_=(x==null?void 0:x.value)||"";switch(o.type){case"i32":case"i64":return parseInt(_)||0;case"f32":case"f64":return parseFloat(_)||0;case"array":try{return JSON.parse(_)}catch{return _.split(",").map(w=>parseInt(w.trim())).filter(w=>!isNaN(w))}case"string":default:return _}}),c=await e(u,h);s(o=>({...o,[u]:c}))}catch(h){s(c=>({...c,[u]:`Error: ${h instanceof Error?h.message:"Unknown error"}`}))}finally{a(h=>({...h,[u]:!1}))}};return t.length===0?n("div",{class:"text-center py-8 bg-light-surface2 dark:bg-dark-surface2 rounded-lg border border-light-surface3 dark:border-dark-surface3",children:[n("h4",{class:"text-lg font-medium text-light-textMuted dark:text-dark-textMuted mb-2",children:"No exported functions found"}),n("p",{class:"text-light-textDim dark:text-dark-textDim",children:"This WASM module doesn't export any callable functions, or the module hasn't loaded yet."})]}):n("div",{class:"space-y-4",children:[n("div",{class:"mb-6",children:[n("h3",{class:"text-xl font-medium text-light-textMuted dark:text-dark-textMuted mb-2",children:"Function Playground"}),n("p",{class:"text-sm text-light-textDim dark:text-dark-textDim",children:"Interact with the WASM module's exported functions"})]}),t.map(l=>n("div",{class:"bg-light-surface2 dark:bg-dark-surface2 rounded-lg p-4 border border-light-surface3 dark:border-dark-surface3",children:[n("div",{class:"mb-4 pb-2 border-b border-light-surface3 dark:border-dark-surface3",children:[n("h4",{class:"text-lg font-semibold text-light-accent2 dark:text-purple-400 font-mono mb-1",children:l.name}),n("div",{class:"bg-light-bg dark:bg-dark-bg px-2 py-1 rounded text-sm font-mono text-light-textDim dark:text-dark-textDim mb-2",children:l.signature}),l.description&&n("p",{class:"text-sm text-light-textMuted dark:text-dark-textMuted",children:l.description})]}),n("div",{class:"space-y-3",children:[l.parameters.map(u=>n("div",{class:"space-y-1",children:[n("label",{class:"text-sm font-medium text-light-warning dark:text-orange-300 font-mono",children:[u.name,n("span",{class:"text-xs text-light-textDim dark:text-dark-textDim italic ml-2",children:["(",u.type,")"]})]}),n("input",{type:"text","data-function":l.name,"data-param":u.name,defaultValue:u.value||"",class:"w-full px-3 py-2 bg-light-bg dark:bg-dark-bg text-light-textMuted dark:text-dark-textMuted border border-light-surface3 dark:border-dark-surface3 rounded focus:outline-none focus:border-light-accent dark:focus:border-dark-accent font-mono text-sm",placeholder:u.type==="array"?"e.g., [1, 2, 3]":u.type==="string"?"Enter text":`Enter ${u.type} number`})]},u.name)),n("div",{class:"flex items-center gap-4 pt-3 border-t border-light-surface3 dark:border-dark-surface3",children:[n("button",{onClick:()=>d(l),disabled:i[l.name],class:U("px-4 py-2 bg-light-accent2 dark:bg-dark-accent2 text-white rounded font-semibold transition-colors",{"hover:bg-opacity-90":!i[l.name],"opacity-50 cursor-not-allowed":i[l.name]}),children:i[l.name]?"Calling...":"Call Function"}),n("div",{class:"flex-1 px-3 py-2 bg-light-bg dark:bg-dark-bg border border-light-surface3 dark:border-dark-surface3 rounded font-mono text-sm min-h-8 flex items-center",children:r[l.name]!==void 0?n("span",{class:U(typeof r[l.name]=="string"&&r[l.name].startsWith("Error:")?"text-light-error dark:text-dark-error":"text-light-success dark:text-dark-success"),children:String(r[l.name])}):n("span",{class:"text-light-textDim dark:text-dark-textDim italic",children:"No result yet"})})]})]})]},l.name))]})}function gt(t,e="info"){const r={timestamp:new Date,message:t,type:e};return console.log(`[${r.timestamp.toLocaleTimeString()}] ${t}`),r}function ie(t){if(t===0)return"0 Bytes";const e=1024,r=["Bytes","KB","MB","GB"],s=Math.floor(Math.log(t)/Math.log(e));return parseFloat((t/Math.pow(e,s)).toFixed(2))+" "+r[s]}function xt(t){new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});function e(r,s){return`[WASM String: ptr=${r}, len=${s}]`}return{wbg:{__wbg_log_8b68cfc62b396cc3:function(r,s){const i=e(r,s);console.log(i)},__wbindgen_init_externref_table:function(){}}}}async function bt(t){try{if(typeof window.init<"u")return await window.init();const e=await fetch(t);try{return(await WebAssembly.instantiateStreaming(e.clone(),{})).module}catch(r){console.log("Trying with imports due to error:",r.message);const s=xt();return(await WebAssembly.instantiateStreaming(e,s)).module}}catch(e){throw console.error("Error loading WASM module:",e),e}}function yt(t){try{const e=WebAssembly.Module.imports(t),r=WebAssembly.Module.exports(t);return{imports:e.map(s=>`${s.module}.${s.name}`),exports:r.map(s=>s.name),isWasi:e.some(s=>s.module==="wasmrun_wasi_impl"||s.module==="wasi_unstable"||s.module==="wasi")}}catch(e){return console.error("Error analyzing WASM module:",e),{}}}async function kt(){try{const t=await fetch("/api/module-info");if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);const e=await t.json();return e.error?(console.error("Module inspection error:",e.error),null):e}catch(t){return console.error("Error fetching module inspection:",t),null}}function vt({moduleInfo:t}){const e=t==null?void 0:t.inspection;return n("div",{class:"bg-light-surface2 dark:bg-dark-surface2 rounded-xl p-6 border border-light-surface3 dark:border-dark-surface3",children:[n("div",{class:"flex items-center mb-4",children:[n("div",{class:"w-3 h-3 bg-blue-500 rounded-full mr-3"}),n("h3",{class:"text-lg font-semibold text-light-textPrimary dark:text-dark-textPrimary",children:"Module Details"})]}),t?n("div",{class:"space-y-6",children:[n("div",{class:"space-y-3",children:[n("div",{class:"flex justify-between items-center",children:[n("span",{class:"text-light-textDim dark:text-dark-textDim text-sm",children:"Name"}),n("span",{class:"font-mono text-light-textPrimary dark:text-dark-textPrimary text-sm",children:t.name})]}),n("div",{class:"flex justify-between items-center",children:[n("span",{class:"text-light-textDim dark:text-dark-textDim text-sm",children:"Size"}),n("span",{class:"font-mono text-light-textPrimary dark:text-dark-textPrimary text-sm",children:ie(t.size)})]}),n("div",{class:"flex justify-between items-center",children:[n("span",{class:"text-light-textDim dark:text-dark-textDim text-sm",children:"Type"}),n("span",{class:`px-2 py-1 rounded-full text-xs font-medium ${t.isWasi?"bg-green-100 dark:bg-green-900/20 text-green-700 dark:text-green-300":"bg-blue-100 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300"}`,children:t.isWasi?"WASI Module":"WebAssembly"})]})]}),e&&n("div",{class:"border-t border-light-surface3 dark:border-dark-surface3 pt-4",children:[n("div",{class:"flex items-center mb-3",children:[n("div",{class:"w-2 h-2 bg-pink-500 rounded-full mr-2"}),n("h4",{class:"text-sm font-semibold text-light-textPrimary dark:text-dark-textPrimary",children:"Binary Analysis"})]}),n("div",{class:"grid grid-cols-3 gap-3 mb-4 text-center",children:[n("div",{class:"p-2 bg-light-surface3 dark:bg-dark-surface3 rounded-lg",children:[n("div",{class:"text-sm font-bold text-light-textPrimary dark:text-dark-textPrimary",children:e.section_count}),n("div",{class:"text-xs text-light-textDim dark:text-dark-textDim",children:"Sections"})]}),n("div",{class:"p-2 bg-light-surface3 dark:bg-dark-surface3 rounded-lg",children:[n("div",{class:"text-sm font-bold text-light-textPrimary dark:text-dark-textPrimary",children:"v1"}),n("div",{class:"text-xs text-light-textDim dark:text-dark-textDim",children:"WASM"})]}),n("div",{class:"p-2 bg-light-surface3 dark:bg-dark-surface3 rounded-lg",children:[n("span",{class:`text-xs px-2 py-1 rounded-full font-medium ${e.valid_magic?"bg-green-100 dark:bg-green-900/20 text-green-700 dark:text-green-300":"bg-red-100 dark:bg-red-900/20 text-red-700 dark:text-red-300"}`,children:e.valid_magic?"Valid":"Invalid"}),n("div",{class:"text-xs text-light-textDim dark:text-dark-textDim mt-1",children:"Status"})]})]}),n("div",{class:"space-y-2 mb-3",children:[n("div",{class:"flex items-center justify-between text-sm",children:[n("span",{class:"text-light-textDim dark:text-dark-textDim",children:"File Size"}),n("span",{class:"font-mono text-xs bg-light-surface3 dark:bg-dark-surface3 px-2 py-1 rounded",children:ie(e.file_size)})]}),n("div",{class:"flex items-center justify-between text-sm",children:[n("span",{class:"text-light-textDim dark:text-dark-textDim",children:"Functions"}),n("span",{class:"font-mono text-xs bg-light-surface3 dark:bg-dark-surface3 px-2 py-1 rounded",children:e.function_count})]})]}),e.sections&&e.sections.length>0&&n("div",{children:[n("h5",{class:"text-xs font-medium text-light-textPrimary dark:text-dark-textPrimary mb-2",children:"Key Sections"}),n("div",{class:"max-h-24 overflow-y-auto space-y-1",children:e.sections.slice(0,4).map((r,s)=>n("div",{class:"flex items-center justify-between text-xs p-2 bg-light-surface3 dark:bg-dark-surface3 rounded",children:[n("span",{class:"font-medium text-light-textPrimary dark:text-dark-textPrimary",children:r.name}),n("span",{class:"text-light-textDim dark:text-dark-textDim",children:ie(r.size)})]},s))})]}),e.has_memory_section&&n("div",{class:"mt-3 p-2 bg-blue-50 dark:bg-blue-900/20 rounded-lg",children:[n("div",{class:"text-xs text-blue-700 dark:text-blue-300 font-medium mb-1",children:"💾 WASI Memory Detected"}),e.memory_limits&&n("div",{class:"text-xs text-blue-600 dark:text-blue-400",children:["Initial: ",e.memory_limits[0]," pages",e.memory_limits[1]&&`, Max: ${e.memory_limits[1]} pages`]})]})]})]}):n("div",{class:"text-center py-8",children:[n("div",{class:"w-12 h-12 mx-auto mb-3 rounded-full bg-light-surface3 dark:bg-dark-surface3 flex items-center justify-center",children:n("span",{class:"text-2xl",children:"⏳"})}),n("p",{class:"text-light-textDim dark:text-dark-textDim text-sm",children:"Module analysis in progress..."})]})]})}function wt({moduleInfo:t}){var e;return n("div",{class:"bg-light-surface2 dark:bg-dark-surface2 rounded-xl p-6 border border-light-surface3 dark:border-dark-surface3 h-full",children:[n("div",{class:"flex items-center justify-between mb-4",children:[n("div",{class:"flex items-center",children:[n("div",{class:"w-3 h-3 bg-green-500 rounded-full mr-3"}),n("h3",{class:"text-lg font-semibold text-light-textPrimary dark:text-dark-textPrimary",children:"Exports"})]}),t&&n("span",{class:"text-xs bg-light-surface3 dark:bg-dark-surface3 px-2 py-1 rounded-full text-light-textDim dark:text-dark-textDim",children:((e=t.exports)==null?void 0:e.length)||0})]}),n("div",{class:"overflow-y-auto",children:t!=null&&t.exports&&t.exports.length>0?n("div",{class:"space-y-2",children:t.exports.map((r,s)=>n("div",{class:"flex items-center p-2 bg-light-surface3 dark:bg-dark-surface3 rounded-lg",children:[n("span",{class:"w-2 h-2 bg-green-400 rounded-full mr-3 flex-shrink-0"}),n("code",{class:"font-mono text-sm text-light-textPrimary dark:text-dark-textPrimary",children:r})]},s))}):t?n("div",{class:"text-center py-4",children:[n("span",{class:"text-2xl mb-2 block",children:"📭"}),n("p",{class:"text-light-textDim dark:text-dark-textDim text-sm",children:"No exports found"})]}):n("div",{class:"text-center py-4",children:[n("span",{class:"text-2xl mb-2 block",children:"⏳"}),n("p",{class:"text-light-textDim dark:text-dark-textDim text-sm",children:"Loading exports..."})]})})]})}function $t({moduleInfo:t}){var e;return n("div",{class:"bg-light-surface2 dark:bg-dark-surface2 rounded-xl p-6 border border-light-surface3 dark:border-dark-surface3 h-full",children:[n("div",{class:"flex items-center justify-between mb-4",children:[n("div",{class:"flex items-center",children:[n("div",{class:"w-3 h-3 bg-purple-500 rounded-full mr-3"}),n("h3",{class:"text-lg font-semibold text-light-textPrimary dark:text-dark-textPrimary",children:"Imports"})]}),t&&n("span",{class:"text-xs bg-light-surface3 dark:bg-dark-surface3 px-2 py-1 rounded-full text-light-textDim dark:text-dark-textDim",children:((e=t.imports)==null?void 0:e.length)||0})]}),n("div",{class:"overflow-y-auto",children:t!=null&&t.imports&&t.imports.length>0?n("div",{class:"space-y-2",children:t.imports.map((r,s)=>n("div",{class:"flex items-center p-2 bg-light-surface3 dark:bg-dark-surface3 rounded-lg",children:[n("span",{class:"w-2 h-2 bg-purple-400 rounded-full mr-3 flex-shrink-0"}),n("code",{class:"font-mono text-sm text-light-textPrimary dark:text-dark-textPrimary",children:r})]},s))}):t?n("div",{class:"text-center py-4",children:[n("span",{class:"text-2xl mb-2 block",children:"📭"}),n("p",{class:"text-light-textDim dark:text-dark-textDim text-sm",children:"No imports required"})]}):n("div",{class:"text-center py-4",children:[n("span",{class:"text-2xl mb-2 block",children:"⏳"}),n("p",{class:"text-light-textDim dark:text-dark-textDim text-sm",children:"Loading imports..."})]})})]})}function Dt({moduleInfo:t}){var s,i,a,d,l,u,h,c,o,x,_,w,E,g,f,p,b;const e=((s=t==null?void 0:t.inspection)==null?void 0:s.plugin)||(t==null?void 0:t.plugin)||{name:"unknown",version:"0.0.0",type:"builtin",description:"Plugin information unavailable",author:void 0,source:void 0,capabilities:void 0},r=v=>{switch(v==null?void 0:v.type){case"crates.io":return"🦀";case"local":return"💻";case"git":return"🌐";default:return"📦"}};return n("div",{class:"bg-light-surface2 dark:bg-dark-surface2 rounded-xl p-6 border border-light-surface3 dark:border-dark-surface3 h-full",children:[n("div",{class:"flex items-center mb-4",children:[n("div",{class:"w-3 h-3 bg-cyan-500 rounded-full mr-3"}),n("h3",{class:"text-lg font-semibold text-light-textPrimary dark:text-dark-textPrimary",children:"Build Plugin"})]}),n("div",{class:"space-y-4",children:[n("div",{class:"flex items-center justify-center",children:n("div",{class:"w-16 h-16 bg-gradient-to-br from-cyan-500 to-blue-600 rounded-xl flex items-center justify-center p-2",children:[n("img",{src:"/assets/logo-w.png",alt:"Plugin",class:"w-full h-full object-contain",onError:v=>{const D=v.currentTarget,y=D.nextElementSibling;D.style.display="none",y&&(y.style.display="flex")}}),n("span",{class:"text-white text-2xl font-bold hidden",children:e.name.slice(0,2).toUpperCase()})]})}),n("div",{class:"text-center space-y-2",children:[n("h4",{class:"font-semibold text-light-textPrimary dark:text-dark-textPrimary",children:e.name}),n("div",{class:"flex items-center justify-center gap-2",children:[n("span",{class:"text-sm text-light-textDim dark:text-dark-textDim",children:["v",e.version]}),n("span",{class:`px-2 py-1 rounded-full text-xs font-medium ${e.type==="external"?"bg-blue-100 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300":"bg-gray-100 dark:bg-gray-900/20 text-gray-700 dark:text-gray-300"}`,children:e.type==="external"?"External":"Built-in"})]}),(e.author||e.source)&&n("div",{class:"flex items-center justify-center gap-3 text-xs text-light-textDim dark:text-dark-textDim",children:[e.author&&n("span",{children:["by ",e.author]}),e.source&&n("span",{class:"flex items-center gap-1",children:[r(e.source),e.source.url?n("a",{href:e.source.url,target:"_blank",rel:"noopener noreferrer",class:"hover:text-blue-500",children:e.source.type}):n("span",{children:e.source.type})]})]})]}),n("div",{class:"p-3 bg-light-surface3 dark:bg-dark-surface3 rounded-lg",children:n("p",{class:"text-xs text-light-textDim dark:text-dark-textDim text-center",children:e.description})}),n("div",{class:"space-y-2",children:[n("div",{class:"text-xs font-medium text-light-textDim dark:text-dark-textDim text-center",children:"Capabilities"}),n("div",{class:"grid grid-cols-2 gap-2 text-center",children:[n("div",{class:`p-2 rounded ${(i=e.capabilities)!=null&&i.compile_wasm?"bg-green-50 dark:bg-green-900/20":"bg-gray-50 dark:bg-gray-900/20"}`,children:[n("div",{class:`text-lg font-bold ${(a=e.capabilities)!=null&&a.compile_wasm?"text-green-600 dark:text-green-400":"text-gray-400 dark:text-gray-600"}`,children:(d=e.capabilities)!=null&&d.compile_wasm?"🔨":"❌"}),n("div",{class:`text-xs ${(l=e.capabilities)!=null&&l.compile_wasm?"text-green-700 dark:text-green-300":"text-gray-500 dark:text-gray-400"}`,children:"WASM"})]}),n("div",{class:`p-2 rounded ${(u=e.capabilities)!=null&&u.optimization?"bg-blue-50 dark:bg-blue-900/20":"bg-gray-50 dark:bg-gray-900/20"}`,children:[n("div",{class:`text-lg font-bold ${(h=e.capabilities)!=null&&h.optimization?"text-blue-600 dark:text-blue-400":"text-gray-400 dark:text-gray-600"}`,children:(c=e.capabilities)!=null&&c.optimization?"⚡":"❌"}),n("div",{class:`text-xs ${(o=e.capabilities)!=null&&o.optimization?"text-blue-700 dark:text-blue-300":"text-gray-500 dark:text-gray-400"}`,children:"Optimize"})]}),n("div",{class:`p-2 rounded ${(x=e.capabilities)!=null&&x.live_reload?"bg-purple-50 dark:bg-purple-900/20":"bg-gray-50 dark:bg-gray-900/20"}`,children:[n("div",{class:`text-lg font-bold ${(_=e.capabilities)!=null&&_.live_reload?"text-purple-600 dark:text-purple-400":"text-gray-400 dark:text-gray-600"}`,children:(w=e.capabilities)!=null&&w.live_reload?"🔄":"❌"}),n("div",{class:`text-xs ${(E=e.capabilities)!=null&&E.live_reload?"text-purple-700 dark:text-purple-300":"text-gray-500 dark:text-gray-400"}`,children:"Hot Reload"})]}),n("div",{class:`p-2 rounded ${(g=e.capabilities)!=null&&g.compile_webapp?"bg-orange-50 dark:bg-orange-900/20":"bg-gray-50 dark:bg-gray-900/20"}`,children:[n("div",{class:`text-lg font-bold ${(f=e.capabilities)!=null&&f.compile_webapp?"text-orange-600 dark:text-orange-400":"text-gray-400 dark:text-gray-600"}`,children:(p=e.capabilities)!=null&&p.compile_webapp?"🌐":"❌"}),n("div",{class:`text-xs ${(b=e.capabilities)!=null&&b.compile_webapp?"text-orange-700 dark:text-orange-300":"text-gray-500 dark:text-gray-400"}`,children:"WebApp"})]})]})]})]})]})}const B=[{name:"Virtual Filesystem",status:"supported",description:"Full filesystem with directory structure, file creation and manipulation"},{name:"Standard I/O",status:"supported",description:"stdout, stderr with console integration"},{name:"Environment Variables",status:"supported",description:"Reading environment variables"},{name:"Command Arguments",status:"supported",description:"Access to command-line arguments"},{name:"File I/O",status:"supported",description:"Read/write operations on files"},{name:"Random Number Generation",status:"supported",description:"Secure random number generation using crypto API"},{name:"Time Functions",status:"supported",description:"Access to system time and high-precision timers"},{name:"Pre-opened Directories",status:"supported",description:"Access to pre-opened filesystem paths"},{name:"Network Sockets",status:"unsupported",description:"Network operations (will be added in future updates)"},{name:"Multi-threading",status:"unsupported",description:"Thread-related APIs (will be added in future updates)"}];function Mt(){const[t,e]=T("all"),r=B.filter(l=>l.status==="supported"),s=B.filter(l=>l.status==="partial"),i=B.filter(l=>l.status==="unsupported"),a=()=>{switch(t){case"supported":return r;case"partial":return s;case"unsupported":return i;default:return B}},d=[{id:"all",label:"All Features",count:B.length},{id:"supported",label:"Supported",count:r.length},{id:"partial",label:"Partial",count:s.length},{id:"unsupported",label:"Coming Soon",count:i.length}];return n("div",{class:"bg-light-surface2 dark:bg-dark-surface2 rounded-xl p-6 border border-light-surface3 dark:border-dark-surface3 h-full",children:[n("div",{class:"flex items-center mb-4",children:[n("div",{class:"w-3 h-3 bg-orange-500 rounded-full mr-3"}),n("h3",{class:"text-lg font-semibold text-light-textPrimary dark:text-dark-textPrimary",children:"WASI Support"})]}),n("div",{class:"space-y-4",children:[n("p",{class:"text-sm text-light-textDim dark:text-dark-textDim",children:"Comprehensive WASI implementation for WebAssembly System Interface modules."}),n("div",{class:"flex flex-wrap gap-1 p-1 bg-light-surface3 dark:bg-dark-surface3 rounded-lg",children:d.map(l=>n("button",{onClick:()=>e(l.id),class:`px-3 py-2 text-xs font-medium rounded-md transition-all flex items-center gap-2 ${t===l.id?"bg-light-surface2 dark:bg-dark-surface2 text-light-textPrimary dark:text-dark-textPrimary shadow-sm":"text-light-textDim dark:text-dark-textDim hover:text-light-textPrimary dark:hover:text-dark-textPrimary"}`,children:[l.label,n("span",{class:`px-1.5 py-0.5 rounded-full text-xs ${t===l.id?"bg-light-surface3 dark:bg-dark-surface3":"bg-light-surface2 dark:bg-dark-surface2"}`,children:l.count})]},l.id))}),n("div",{class:"max-h-56 overflow-y-auto",children:n("div",{class:"grid grid-cols-2 sm:grid-cols-6 gap-3",children:a().map((l,u)=>n("div",{class:`p-4 rounded-lg border transition-all hover:shadow-sm ${l.status==="supported"?"bg-green-50 dark:bg-green-900/20 border-green-200 dark:border-green-800/30":l.status==="partial"?"bg-yellow-50 dark:bg-yellow-900/20 border-yellow-200 dark:border-yellow-800/30":"bg-red-50 dark:bg-red-900/20 border-red-200 dark:border-red-800/30"}`,children:[n("div",{class:"flex items-center justify-between mb-2",children:[n("div",{class:`w-8 h-8 rounded-full flex items-center justify-center ${l.status==="supported"?"bg-green-100 dark:bg-green-800/50":l.status==="partial"?"bg-yellow-100 dark:bg-yellow-800/50":"bg-red-100 dark:bg-red-800/50"}`,children:n("span",{class:`text-sm ${l.status==="supported"?"text-green-600 dark:text-green-400":l.status==="partial"?"text-yellow-600 dark:text-yellow-400":"text-red-600 dark:text-red-400"}`,children:l.status==="supported"?"✓":l.status==="partial"?"⚡":"○"})}),n("span",{class:`text-xs px-2 py-1 rounded-full font-medium ${l.status==="supported"?"bg-green-100 dark:bg-green-800/30 text-green-700 dark:text-green-300":l.status==="partial"?"bg-yellow-100 dark:bg-yellow-800/30 text-yellow-700 dark:text-yellow-300":"bg-red-100 dark:bg-red-800/30 text-red-700 dark:text-red-300"}`,children:l.status==="supported"?"Ready":l.status==="partial"?"Beta":"Soon"})]}),n("h4",{class:"font-semibold text-light-textPrimary dark:text-dark-textPrimary text-sm mb-1",children:l.name}),n("p",{class:"text-xs text-light-textDim dark:text-dark-textDim leading-relaxed",children:l.description})]},u))})})]})]})}function We({moduleInfo:t}){return n("div",{class:"p-6 space-y-6",children:[n("div",{children:[n("h2",{class:"text-2xl font-bold text-light-textPrimary dark:text-dark-textPrimary mb-2",children:"WebAssembly Module Analysis"}),n("p",{class:"text-light-textDim dark:text-dark-textDim",children:"Comprehensive analysis of your WebAssembly module including binary inspection and plugin details"})]}),n("div",{class:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-6",children:[n("div",{class:"md:col-span-1 xl:col-span-1",children:n(vt,{moduleInfo:t})}),n("div",{class:"md:col-span-1 xl:col-span-1",children:n(wt,{moduleInfo:t})}),n("div",{class:"md:col-span-1 xl:col-span-1",children:n($t,{moduleInfo:t})}),n("div",{class:"md:col-span-1 xl:col-span-1",children:n(Dt,{moduleInfo:t})}),n("div",{class:"md:col-span-2 xl:col-span-2",children:n(Mt,{})})]})]})}function At(t){const e=t.trim();if(e==="help")return{type:"help",raw:t};if(e==="clear")return{type:"clear",raw:t};if(e==="list"||e==="ls")return{type:"list",raw:t};if(e.startsWith("memory."))return{type:"memory",name:e,raw:t};const r=e.match(/^(\w+)\s*\(\s*(.*?)\s*\)$/);if(r){const[,i,a]=r,d=St(a);return{type:"function",name:i,args:d,raw:t}}const s=e.match(/^(\w+)$/);if(s){const[,i]=s;return{type:"function",name:i,args:[],raw:t}}return{type:"unknown",raw:t}}function St(t){if(!t.trim())return[];const e=[];let r="",s=!1,i="",a=0,d=0;for(let l=0;l<t.length;l++){const u=t[l];s?(r+=u,u===i&&t[l-1]!=="\\"&&(s=!1,i="")):u==='"'||u==="'"?(s=!0,i=u,r+=u):u==="["?(a++,r+=u):u==="]"?(a--,r+=u):u==="("?(d++,r+=u):u===")"?(d--,r+=u):u===","&&a===0&&d===0?(e.push(ue(r.trim())),r=""):r+=u}return r.trim()&&e.push(ue(r.trim())),e}function ue(t){const e=t.trim();if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(e.startsWith("[")&&e.endsWith("]"))try{return JSON.parse(e)}catch{return e.slice(1,-1).split(",").map(s=>ue(s.trim()))}if(e==="true")return!0;if(e==="false")return!1;if(e==="null")return null;if(e!=="undefined")return/^-?\d+$/.test(e)?parseInt(e,10):/^-?\d*\.?\d+$/.test(e)?parseFloat(e):e}const Te=t=>t==="memory"||t==="main"||t.startsWith("__wbindgen"),Pt=t=>t==="greet"||t.includes("greet")||t.includes("message")||t.includes("text")||t.includes("name")||t.includes("hello"),Et=t=>t==="sum_array"||t.includes("array")||t.includes("list")||t.includes("sum")||t.includes("process")||t.includes("calculate"),Ct=t=>{const e={greet:{parameters:[{name:"name",type:"string",value:"World"}],signature:"greet(name: string) -> string",description:"Greet a person with a friendly message"},fibonacci:{parameters:[{name:"n",type:"i32",value:"10"}],signature:"fibonacci(n: u32) -> u32",description:"Calculate the nth Fibonacci number"},sum_array:{parameters:[{name:"numbers",type:"array",value:"[1, 2, 3, 4, 5]"}],signature:"sum_array(numbers: i32[]) -> i32",description:"Sum all numbers in an array"}};return e[t]?e[t]:t.includes("add")||t.includes("sum")?{parameters:[{name:"a",type:"i32",value:"5"},{name:"b",type:"i32",value:"3"}],signature:`${t}(a: i32, b: i32) -> i32`,description:`Arithmetic function: ${t}`}:t.includes("get")||t.includes("read")?{parameters:[],signature:`${t}() -> i32`,description:`Getter function: ${t}`}:t.includes("set")||t.includes("write")?{parameters:[{name:"value",type:"i32",value:"42"}],signature:`${t}(value: i32) -> void`,description:`Setter function: ${t}`}:t.includes("array")||t.includes("list")?{parameters:[{name:"items",type:"array",value:"[1, 2, 3]"}],signature:`${t}(items: i32[]) -> i32`,description:`Array processing function: ${t}`}:{parameters:[],signature:`${t}() -> unknown`,description:`Exported function: ${t}`}};function Ye(){const[t,e]=T([]),[r,s]=T(null),[i,a]=T([]),[d,l]=T(null),[u,h]=T("console"),c=q((g,f="info")=>{const p=gt(g,f);e(b=>[...b,p])},[]),o=q(async()=>{try{c(`Loading WASM module: ${FILENAME}`);const g=await bt(FILENAME),f=yt(g);let p;try{p=new WebAssembly.Instance(g,{})}catch{const y={wbg:{__wbg_log_8b68cfc62b396cc3:(A,S)=>{if(p&&p.exports.memory)try{const F=p.exports.memory,k=A,m=S,C=new Uint8Array(F.buffer,k,m),W=new TextDecoder().decode(C);c(W,"info")}catch{c(`WASM log: ${A}, ${S}`,"info")}else setTimeout(()=>{if(p&&p.exports.memory)try{const F=p.exports.memory,k=A,m=S,C=new Uint8Array(F.buffer,k,m),W=new TextDecoder().decode(C);c(W,"info")}catch{c(`WASM log: ${A}, ${S}`,"info")}},0)},__wbindgen_init_externref_table:()=>{}}};p=new WebAssembly.Instance(g,y)}l(p),c("Analyzing WASM module structure...");const b=await kt(),v={name:FILENAME,size:(b==null?void 0:b.file_size)||0,imports:f.imports||[],exports:f.exports||[],isWasi:f.isWasi||!1,inspection:b||void 0};s(v),b?c(`Module analysis complete: ${b.section_count} sections, ${b.function_count} functions`,"success"):c("Module analysis failed - using basic info only","warning");const D=(f.exports||[]).filter(y=>!Te(y)).map(y=>{const A=Ct(y);return{name:y,signature:A.signature,parameters:A.parameters,description:A.description}});a(D),c("✅ WASM module loaded successfully!","success"),c(`Found ${D.length} exported functions`,"info")}catch(g){const f=g instanceof Error?g.message:"Unknown error";console.error("❌ Error loading WASM module:",g),c(`❌ Error loading WASM module: ${f}`,"error")}},[c]);R(()=>{o()},[o]);const x=q(async(g,f,p=!1)=>{if(!d)throw new Error("WASM module not loaded");p||c(`> ${g}(${f.join(", ")})`,"info");try{const b=d.exports,v=b[g];if(typeof v!="function")throw new Error(`Function ${g} not found in exports`);if(c(`Calling ${g} with args: [${f.map(y=>typeof y=="string"?`"${y}"`:y).join(", ")}]`,"info"),g==="main"){c("Calling main function (entry point)","info");try{const y=v();return c(`✅ main() executed successfully: ${y}`,"success"),y}catch(y){const A=y instanceof Error?y.message:"Unknown error";throw c(`❌ main() failed: ${A}`,"error"),y}}if(g.startsWith("__wbindgen")){c(`Calling internal wasm-bindgen function: ${g}`,"warning");try{const y=v(...f);return c(`✅ ${g}() result: ${y}`,"success"),y}catch(y){const A=y instanceof Error?y.message:"Unknown error";throw c(`❌ ${g}() failed: ${A}`,"error"),y}}if(Pt(g)&&f.length>0){const y=b.memory,A=b.__wbindgen_malloc,S=b.__wbindgen_free;if(y&&A&&S){const F=String(f[0]),m=new TextEncoder().encode(F),C=A(m.length,1);new Uint8Array(y.buffer).set(m,C);try{const te=v(C,m.length),me=String(te);if(me.includes(",")){const[ge,re]=me.split(",").map(z=>parseInt(z.trim()));if(ge>0&&re>0&&re<1e6)try{const z=new Uint8Array(y.buffer,ge,re),xe=new TextDecoder().decode(z);return c(`✅ ${xe}`,"success"),xe}catch(z){c(`Error decoding string: ${z}`,"warning")}}return c(`✅ Raw result: ${te}`,"success"),te}finally{S(C,m.length)}}else c(`Missing wasm-bindgen functions for ${g}, using fallback`,"warning");return}if(Et(g)&&f.length>0){const y=b.memory,A=b.__wbindgen_malloc,S=b.__wbindgen_free;c("Debug: Available exports for memory management:","info"),c(`  memory: ${!!y}, malloc: ${!!A}, free: ${!!S}`,"info");const F=Object.keys(b).filter(k=>k.startsWith("__wbindgen"));if(c(`  wbindgen exports: ${F.join(", ")}`,"info"),y&&A&&S){let k;if(f.length>1)k=f.map(m=>typeof m=="number"?m:parseInt(String(m))).filter(m=>!isNaN(m));else if(k=f[0],typeof k=="string")try{k=JSON.parse(k)}catch{k=k.split(",").map(m=>parseInt(m.trim())).filter(m=>!isNaN(m))}if(Array.isArray(k)&&k.length>0){const m=A(k.length*4,4),C=new DataView(y.buffer);for(let W=0;W<k.length;W++)C.setInt32(m+W*4,k[W],!0);try{const W=v(m,k.length);c(`✅ ${W}`,"success");try{S(m,k.length*4,4)}catch{try{S(m,k.length*4)}catch{try{S(m)}catch{c("Debug: All free attempts failed, but function succeeded","warning")}}}return W}catch(W){c(`Debug: WASM function call failed: ${W}`,"error");try{S(m,k.length*4,4)}catch{try{S(m,k.length*4)}catch{try{S(m)}catch{}}}throw W}}else throw new Error("Invalid array input for ${functionName}")}else{c("Missing wasm-bindgen functions for ${functionName}, trying alternatives","warning");let k;if(f.length>1)k=f.map(m=>typeof m=="number"?m:parseInt(String(m))).filter(m=>!isNaN(m));else if(k=f[0],typeof k=="string")try{k=JSON.parse(k)}catch{k=k.split(",").map(m=>parseInt(m.trim())).filter(m=>!isNaN(m))}if(Array.isArray(k)&&k.length>0)try{c(`Debug: Trying to call ${g} with individual args: ${k.join(", ")}`,"info");const m=v(...k);return c(`✅ ${m}`,"success"),m}catch{try{c(`Debug: Trying to call ${g} with array as single arg`,"info");const m=v(k);return c(`✅ ${m}`,"success"),m}catch{c("Debug: Both WASM calls failed, computing sum manually","warning");const m=k.reduce((C,W)=>C+W,0);return c(`✅ ${m} (computed manually)`,"success"),m}}else throw new Error("Invalid array input for ${functionName}")}}const D=v(...f);return c(`✅ ${D}`,"success"),D}catch(b){const v=b instanceof Error?b.message:"Unknown error";throw c(`❌ ${v}`,"error"),b}},[d,c]),_=q(async g=>{var p;const f=At(g);c(`> ${g}`,"info");try{switch(f.type){case"help":if(c("Available commands:","info"),c("  help - Show this help message","info"),c("  clear - Clear the console","info"),c("  list - List available functions","info"),c("  memory.size() - Get memory size in pages","info"),c("  memory.grow(pages) - Grow memory by pages","info"),i.length>0&&(c("Available functions (shown in Playground):","info"),i.forEach(b=>{c(`  ${b.signature}`,"info")})),d){const v=Object.keys(d.exports).filter(D=>typeof d.exports[D]=="function").filter(D=>Te(D)||!i.some(y=>y.name===D));v.length>0&&(c("Internal functions (callable from console only):","info"),v.forEach(D=>{c(`  ${D}() - Internal/system function`,"info")}))}break;case"clear":e([]);break;case"list":i.length===0?c("No exported functions found","warning"):(c(`Found ${i.length} exported functions:`,"info"),i.forEach(b=>{c(`  ${b.signature}`,"info")}));break;case"memory":{if(!d)throw new Error("WASM module not loaded");const b=d.exports.memory;if(!b){c("❌ No memory export found","error");break}if(f.name==="memory.size()"){const v=b.buffer.byteLength/65536;c(`Memory size: ${v} pages (${(b.buffer.byteLength/1024/1024).toFixed(2)} MB)`,"success")}else if((p=f.name)!=null&&p.startsWith("memory.grow(")){const v=f.name.match(/memory\.grow\((\d+)\)/);if(v){const D=parseInt(v[1]),y=b.grow(D);c(`Memory grown from ${y} to ${y+D} pages`,"success")}}break}case"function":if(!f.name)throw new Error("Function name is required");await x(f.name,f.args||[],!0);break;case"unknown":default:c(`❌ Unknown command: ${g}`,"error"),c('Type "help" for available commands',"info");break}}catch(b){const v=b instanceof Error?b.message:"Unknown error";c(`❌ ${v}`,"error")}},[d,i,c,x]),w=[{id:"console",label:"Console",content:n(se,{logs:t,onCommand:_,interactive:!0})},{id:"playground",label:"Playground",content:n(Ce,{functions:i,onFunctionCall:x})},{id:"info",label:"Module Info",content:n(We,{moduleInfo:r})}],E=()=>{const f=u==="console"?"flex-1 flex flex-col min-h-0":"flex-1 overflow-y-auto p-6";switch(u){case"console":return n("div",{class:f,children:n(se,{logs:t,onCommand:_,interactive:!0})});case"playground":return n("div",{class:f,children:n(Ce,{functions:i,onFunctionCall:x})});case"info":return n("div",{class:f,children:n(We,{moduleInfo:r})});default:return n("div",{class:f,children:n(se,{logs:t,onCommand:_,interactive:!0})})}};return n(mt,{filename:FILENAME,tabs:w,activeTab:u,onTabChange:h,children:E()})}it(n(ht,{children:n(Ye,{})}),document.getElementById("root"));window.WasmRunConsole={Console:Ye};