lua-cli 2.0.4 → 2.0.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/README.md CHANGED
@@ -195,7 +195,7 @@ This command will:
195
195
  - Available at `http://localhost:3000` (opens automatically)
196
196
  - **Live Log Panel**:
197
197
  - Real-time log feed showing execution details
198
- - WebSocket connection to `wss://api.lua.dev/feed`
198
+ - WebSocket connection to `wss://api.heylua.ai/feed`
199
199
  - Console-style interface with color-coded log levels
200
200
  - Shows tool calls, errors, metrics, and execution metadata
201
201
  - Displays detailed information in expandable sections
@@ -498,7 +498,7 @@ For more details, see [USER_DATA_API.md](./USER_DATA_API.md).
498
498
 
499
499
  For support and questions:
500
500
  - Create an issue on [GitHub](https://github.com/lua-ai-global/lua-cli/issues)
501
- - Contact: stefan@lua.dev
501
+ - Contact: stefan@heylua.ai
502
502
 
503
503
  ## Changelog
504
504
 
@@ -4,10 +4,10 @@
4
4
  */
5
5
  // Base URLs for different environments
6
6
  const BASE_URLS = {
7
- LOCAL: 'https://api.lua.dev',
8
- API: 'https://api.lua.dev',
9
- AUTH: 'https://auth.lua.dev',
10
- CHAT: 'https://api.lua.dev'
7
+ LOCAL: 'https://api.heylua.ai',
8
+ API: 'https://api.heylua.ai',
9
+ AUTH: 'https://auth.heylua.ai',
10
+ CHAT: 'https://api.heylua.ai'
11
11
  };
12
12
  /**
13
13
  * Generic HTTP client with common error handling
package/dist/web/app.js CHANGED
@@ -19,9 +19,9 @@ Error generating stack: `+n.message+`
19
19
  `});++a<e.length;)a&&n.push({type:"text",value:`
20
20
  `}),n.push(e[a]);return t&&e.length>0&&n.push({type:"text",value:`
21
21
  `}),n}function h1(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}var Kp,sR,v1=b(()=>{Qp();$p();yu();Wx();Kp={}.hasOwnProperty,sR={}});function Iu(e,t){let n=g1(e,t),a=n.one(e,void 0),i=s1(n),r=Array.isArray(a)?{type:"root",children:a}:a||{type:"root",children:[]};return i&&("children"in r,r.children.push({type:"text",value:`
22
- `},i)),r}var y1=b(()=>{o1();v1()});var b1=b(()=>{y1()});function Gu(e,t){return e&&"run"in e?function(n,a){return z(this,null,function*(){let i=Iu(n,K({file:a},t));yield e.run(i,a)})}:function(n,a){return Iu(n,K({file:a},e||t))}}var S1=b(()=>{b1()});var x1=b(()=>{S1()});function Wp(e){if(e)throw e}var N1=b(()=>{});var D1=Ut((cz,_1)=>{"use strict";var Xu=Object.prototype.hasOwnProperty,R1=Object.prototype.toString,E1=Object.defineProperty,k1=Object.getOwnPropertyDescriptor,T1=function(t){return typeof Array.isArray=="function"?Array.isArray(t):R1.call(t)==="[object Array]"},w1=function(t){if(!t||R1.call(t)!=="[object Object]")return!1;var n=Xu.call(t,"constructor"),a=t.constructor&&t.constructor.prototype&&Xu.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!a)return!1;var i;for(i in t);return typeof i=="undefined"||Xu.call(t,i)},A1=function(t,n){E1&&n.name==="__proto__"?E1(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},C1=function(t,n){if(n==="__proto__")if(Xu.call(t,n)){if(k1)return k1(t,n).value}else return;return t[n]};_1.exports=function e(){var t,n,a,i,r,l,s=arguments[0],o=1,u=arguments.length,c=!1;for(typeof s=="boolean"&&(c=s,s=arguments[1]||{},o=2),(s==null||typeof s!="object"&&typeof s!="function")&&(s={});o<u;++o)if(t=arguments[o],t!=null)for(n in t)a=C1(s,n),i=C1(t,n),s!==i&&(c&&i&&(w1(i)||(r=T1(i)))?(r?(r=!1,l=a&&T1(a)?a:[]):l=a&&w1(a)?a:{},A1(s,{name:n,newValue:e(c,l,i)})):typeof i!="undefined"&&A1(s,{name:n,newValue:i}));return s}});function ys(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}var O1=b(()=>{});function em(){let e=[],t={run:n,use:a};return t;function n(...i){let r=-1,l=i.pop();if(typeof l!="function")throw new TypeError("Expected function as last argument, not "+l);s(null,...i);function s(o,...u){let c=e[++r],p=-1;if(o){l(o);return}for(;++p<i.length;)(u[p]===null||u[p]===void 0)&&(u[p]=i[p]);i=u,c?L1(c,s)(...u):l(null,...u)}}function a(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function L1(e,t){let n;return a;function a(...l){let s=e.length>l.length,o;s&&l.push(i);try{o=e.apply(this,l)}catch(u){let c=u;if(s&&n)throw c;return i(c)}s||(o&&o.then&&typeof o.then=="function"?o.then(r,i):o instanceof Error?i(o):r(o))}function i(l,...s){n||(n=!0,t(l,...s))}function r(l){i(null,l)}}var z1=b(()=>{});var M1=b(()=>{z1()});function dR(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');bs(e);let n=0,a=-1,i=e.length,r;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(r){n=i+1;break}}else a<0&&(r=!0,a=i+1);return a<0?"":e.slice(n,a)}if(t===e)return"";let l=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(r){n=i+1;break}}else l<0&&(r=!0,l=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(a=i):(s=-1,a=l));return n===a?a=l:a<0&&(a=e.length),e.slice(n,a)}function pR(e){if(bs(e),e.length===0)return".";let t=-1,n=e.length,a;for(;--n;)if(e.codePointAt(n)===47){if(a){t=n;break}}else a||(a=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function mR(e){bs(e);let t=e.length,n=-1,a=0,i=-1,r=0,l;for(;t--;){let s=e.codePointAt(t);if(s===47){if(l){a=t+1;break}continue}n<0&&(l=!0,n=t+1),s===46?i<0?i=t:r!==1&&(r=1):i>-1&&(r=-1)}return i<0||n<0||r===0||r===1&&i===n-1&&i===a+1?"":e.slice(i,n)}function hR(...e){let t=-1,n;for(;++t<e.length;)bs(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":gR(n)}function gR(e){bs(e);let t=e.codePointAt(0)===47,n=vR(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function vR(e,t){let n="",a=0,i=-1,r=0,l=-1,s,o;for(;++l<=e.length;){if(l<e.length)s=e.codePointAt(l);else{if(s===47)break;s=47}if(s===47){if(!(i===l-1||r===1))if(i!==l-1&&r===2){if(n.length<2||a!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(o=n.lastIndexOf("/"),o!==n.length-1){o<0?(n="",a=0):(n=n.slice(0,o),a=n.length-1-n.lastIndexOf("/")),i=l,r=0;continue}}else if(n.length>0){n="",a=0,i=l,r=0;continue}}t&&(n=n.length>0?n+"/..":"..",a=2)}else n.length>0?n+="/"+e.slice(i+1,l):n=e.slice(i+1,l),a=l-i-1;i=l,r=0}else s===46&&r>-1?r++:r=-1}return n}function bs(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}var qn,U1=b(()=>{qn={basename:dR,dirname:pR,extname:mR,join:hR,sep:"/"}});function yR(){return"/"}var B1,V1=b(()=>{B1={cwd:yR}});function Vr(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}var tm=b(()=>{});function H1(e){if(typeof e=="string")e=new URL(e);else if(!Vr(e)){let t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){let t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return bR(e)}function bR(e){if(e.hostname!==""){let a=new TypeError('File URL host must be "localhost" or empty on darwin');throw a.code="ERR_INVALID_FILE_URL_HOST",a}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let a=t.codePointAt(n+2);if(a===70||a===102){let i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}var P1=b(()=>{tm();tm()});function am(e,t){if(e&&e.includes(qn.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+qn.sep+"`")}function im(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function q1(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function SR(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var nm,Oi,j1=b(()=>{cp();U1();V1();P1();nm=["history","path","basename","stem","extname","dirname"],Oi=class{constructor(t){let n;t?Vr(t)?n={path:t}:typeof t=="string"||SR(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":B1.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let a=-1;for(;++a<nm.length;){let r=nm[a];r in n&&n[r]!==void 0&&n[r]!==null&&(this[r]=r==="history"?[...n[r]]:n[r])}let i;for(i in n)nm.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?qn.basename(this.path):void 0}set basename(t){im(t,"basename"),am(t,"basename"),this.path=qn.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?qn.dirname(this.path):void 0}set dirname(t){q1(this.basename,"dirname"),this.path=qn.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?qn.extname(this.path):void 0}set extname(t){if(am(t,"extname"),q1(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=qn.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Vr(t)&&(t=H1(t)),im(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?qn.basename(this.path,this.extname):void 0}set stem(t){im(t,"stem"),am(t,"stem"),this.path=qn.join(this.dirname||"",t+(this.extname||""))}fail(t,n,a){let i=this.message(t,n,a);throw i.fatal=!0,i}info(t,n,a){let i=this.message(t,n,a);return i.fatal=void 0,i}message(t,n,a){let i=new st(t,n,a);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}});var rm=b(()=>{j1()});var Y1,I1=b(()=>{Y1=(function(e){let a=this.constructor.prototype,i=a[e],r=function(){return i.apply(r,arguments)};return Object.setPrototypeOf(r,a),r})});function lm(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function sm(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function om(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function G1(e){if(!ys(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function X1(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Qu(e){return NR(e)?e:new Oi(e)}function NR(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function ER(e){return typeof e=="string"||kR(e)}function kR(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var Fu,xR,um,cm,Q1=b(()=>{N1();Fu=F(D1(),1);O1();M1();rm();I1();xR={}.hasOwnProperty,um=class e extends Y1{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=em()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let a=this.attachers[n];t.use(...a)}return t.data((0,Fu.default)(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(om("data",this.frozen),this.namespace[t]=n,this):xR.call(this.namespace,t)&&this.namespace[t]||void 0:t?(om("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;let t=this;for(;++this.freezeIndex<this.attachers.length;){let[n,...a]=this.attachers[this.freezeIndex];if(a[0]===!1)continue;a[0]===!0&&(a[0]=void 0);let i=n.call(t,...a);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();let n=Qu(t),a=this.parser||this.Parser;return lm("parse",a),a(String(n),n)}process(t,n){let a=this;return this.freeze(),lm("process",this.parser||this.Parser),sm("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(r,l){let s=Qu(t),o=a.parse(s);a.run(o,s,function(c,p,d){if(c||!p||!d)return u(c);let f=p,S=a.stringify(f,d);ER(S)?d.value=S:d.result=S,u(c,d)});function u(c,p){c||!p?l(c):r?r(p):n(void 0,p)}}}processSync(t){let n=!1,a;return this.freeze(),lm("processSync",this.parser||this.Parser),sm("processSync",this.compiler||this.Compiler),this.process(t,i),X1("processSync","process",n),a;function i(r,l){n=!0,Wp(r),a=l}}run(t,n,a){G1(t),this.freeze();let i=this.transformers;return!a&&typeof n=="function"&&(a=n,n=void 0),a?r(void 0,a):new Promise(r);function r(l,s){let o=Qu(n);i.run(t,o,u);function u(c,p,d){let f=p||t;c?s(c):l?l(f):a(void 0,f,d)}}}runSync(t,n){let a=!1,i;return this.run(t,n,r),X1("runSync","run",a),i;function r(l,s){Wp(l),i=s,a=!0}}stringify(t,n){this.freeze();let a=Qu(n),i=this.compiler||this.Compiler;return sm("stringify",i),G1(t),i(t,a)}use(t,...n){let a=this.attachers,i=this.namespace;if(om("use",this.frozen),t!=null)if(typeof t=="function")o(t,n);else if(typeof t=="object")Array.isArray(t)?s(t):l(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function r(u){if(typeof u=="function")o(u,[]);else if(typeof u=="object")if(Array.isArray(u)){let[c,...p]=u;o(c,p)}else l(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function l(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");s(u.plugins),u.settings&&(i.settings=(0,Fu.default)(!0,i.settings,u.settings))}function s(u){let c=-1;if(u!=null)if(Array.isArray(u))for(;++c<u.length;){let p=u[c];r(p)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function o(u,c){let p=-1,d=-1;for(;++p<a.length;)if(a[p][0]===u){d=p;break}if(d===-1)a.push([u,...c]);else if(c.length>0){let[f,...S]=c,x=a[d][1];ys(x)&&ys(f)&&(f=(0,Fu.default)(!0,x,f)),a[d]=[u,f,...S]}}}},cm=new um().freeze()});var F1=b(()=>{Q1()});function Ss(e){let t=CR(e),n=RR(e);return _R(t.runSync(t.parse(n),n),e)}function CR(e){let t=e.rehypePlugins||Z1,n=e.remarkPlugins||Z1,a=e.remarkRehypeOptions?K(K({},e.remarkRehypeOptions),J1):J1;return cm().use(Uu).use(n).use(Gu,a).use(t)}function RR(e){let t=e.children||"",n=new Oi;return typeof t=="string"?n.value=t:(""+t,void 0),n}function _R(e,t){let n=t.allowedElements,a=t.allowElement,i=t.components,r=t.disallowedElements,l=t.skipHtml,s=t.unwrapDisallowed,o=t.urlTransform||K1;for(let c of AR)Object.hasOwn(t,c.from)&&(""+c.from+(c.to?"use `"+c.to+"` instead":"remove it")+TR+c.id,void 0);return n&&r&&void 0,vs(e,u),dp(e,{Fragment:Hr.Fragment,components:i,ignoreInvalidStyle:!0,jsx:Hr.jsx,jsxs:Hr.jsxs,passKeys:!0,passNode:!0});function u(c,p,d){if(c.type==="raw"&&d&&typeof p=="number")return l?d.children.splice(p,1):d.children[p]={type:"text",value:c.value},p;if(c.type==="element"){let f;for(f in us)if(Object.hasOwn(us,f)&&Object.hasOwn(c.properties,f)){let S=c.properties[f],x=us[f];(x===null||x.includes(c.tagName))&&(c.properties[f]=o(String(S||""),f,c))}}if(c.type==="element"){let f=n?!n.includes(c.tagName):r?r.includes(c.tagName):!1;if(!f&&a&&typeof p=="number"&&(f=!a(c,p,d)),f&&d&&typeof p=="number")return s&&c.children?d.children.splice(p,1,...c.children):d.children.splice(p,1),p}}}function K1(e){let t=e.indexOf(":"),n=e.indexOf("?"),a=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||a!==-1&&t>a||wR.test(e.slice(0,t))?e:""}var Hr,$1,TR,Z1,J1,wR,AR,W1=b(()=>{B0();H0();Hr=F(re(),1),$1=F(Je(),1);tx();x1();F1();$p();rm();TR="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Z1=[],J1={allowDangerousHtml:!0},wR=/^(https?|ircs?|mailto|xmpp)$/i,AR=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}]});var fm=b(()=>{W1()});var Pe,xe,dm,ie,an=b(()=>{"use strict";Pe={LUA_API:"https://api.lua.dev",DEV_SERVER:"https://api.lua.dev",LOCAL_DEV:""},xe={CHAT_GENERATE:e=>`${Pe.LUA_API}/chat/generate/${e}?channel=dev`,TOOLS_TEST:e=>`${Pe.LUA_API}/tools/test/${e}`,CHAT_HISTORY:e=>`${Pe.LUA_API}/chat/history/${e}`,AGENT_TYPES:`${Pe.LUA_API}/agents/self-serve/types`,CREATE_AGENT:`${Pe.LUA_API}/agents/self-serve/create`,AGENT_DETAILS:e=>`${Pe.LUA_API}/admin/agents/${e}`,SKILL_VERSIONS:(e,t)=>`${Pe.DEV_SERVER}/developer/skills/${e}/${t}/versions`,PERSONA_VERSIONS:e=>`${Pe.LUA_API}/developer/agents/${e}/persona/versions`,DEPLOY_PERSONA_VERSION:(e,t)=>`${Pe.LUA_API}/developer/agents/${e}/persona/version/${t}`,AGENT_RESOURCES:e=>`${Pe.LUA_API}/admin/agents/${e}/resources`,AGENT_RESOURCE:(e,t)=>`${Pe.LUA_API}/admin/agents/${e}/resources/${t}`,AGENT_SKILLS:e=>`${Pe.LUA_API}/developer/skills/${e}`,ACTIVATE_SKILL:(e,t)=>`${Pe.LUA_API}/developer/skills/${e}/${t}`,PUBLISH_SKILL_VERSION:(e,t,n)=>`${Pe.LUA_API}/developer/skills/${e}/${t}/${n}/publish`,PRODUCTION_LOGS:e=>`${Pe.LUA_API}/developer/agents/${e}/logs`,PRODUCTION_ENV:e=>`${Pe.LUA_API}/developer/agents/${e}/env`,CREATE_SKILL:e=>`${Pe.DEV_SERVER}/developer/skills/${e}`,DEVELOPER_LOGS:(e,t)=>`${Pe.DEV_SERVER}/developer/skills/${e}/${t}/logs`,USER_DATA:e=>`${Pe.DEV_SERVER}/developer/user/data/agent/${e}`,LOCAL_CHAT:`${Pe.LOCAL_DEV}/chat`,LOCAL_PERSONA:`${Pe.LOCAL_DEV}/persona`,LOCAL_TOOLS:`${Pe.LOCAL_DEV}/tools`,LOCAL_TOOLS_TEST:`${Pe.LOCAL_DEV}/tools/test`,LOCAL_ENV:`${Pe.LOCAL_DEV}/env`},dm=class{constructor(t=""){this.baseUrl=t}getAllSkillOverrides(){return z(this,null,function*(){try{let n=yield(yield fetch("/api/skills")).json();return n.success&&n.skills&&Array.isArray(n.skills)?n.skills.map(a=>({skillId:a.skillId,sandboxId:a.sandboxId||a.skillId})).filter(a=>a.skillId&&a.sandboxId):[]}catch(t){return console.error("Error getting skill overrides:",t),[]}})}sendChatMessage(t,n,a,i,r,l){return z(this,null,function*(){try{let s=yield this.getAllSkillOverrides(),o=s.length>0?s:[{skillId:a,sandboxId:i}],u=K({messages:[{type:"text",text:t}],navigate:!0,skillOverride:o},l&&{personaOverride:l}),c=yield fetch(xe.CHAT_GENERATE(n),{method:"POST",headers:{"Content-Type":"application/json",Authorization:r},body:JSON.stringify(u)});if(!c.ok)throw new Error(`HTTP error! status: ${c.status}`);return{success:!0,text:(yield c.json()).text||"No response received"}}catch(s){return console.error("Chat API error:",s),{success:!1,error:s instanceof Error?s.message:"Unknown error occurred"}}})}sendProductionChatMessage(t,n,a){return z(this,null,function*(){try{let i={messages:[{type:"text",text:t}],navigate:!0,skillOverride:[]},r=yield fetch(xe.CHAT_GENERATE(n),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(i)});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return{success:!0,text:(yield r.json()).text||"No response received"}}catch(i){return console.error("Production chat API error:",i),{success:!1,error:i instanceof Error?i.message:"Unknown error occurred"}}})}sendLocalChatMessage(t,n){return z(this,null,function*(){try{let a=yield fetch(xe.LOCAL_CHAT,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:t,persona:n})});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return yield a.json()}catch(a){return console.error("Local chat API error:",a),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}})}loadPersona(){return z(this,null,function*(){try{let t=yield fetch(xe.LOCAL_PERSONA);if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return yield t.json()}catch(t){return console.error("Load persona error:",t),{success:!1,error:t instanceof Error?t.message:"Failed to load persona"}}})}savePersona(t){return z(this,null,function*(){try{let n=yield fetch(xe.LOCAL_PERSONA,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({persona:t})});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return yield n.json()}catch(n){return console.error("Save persona error:",n),{success:!1,error:n instanceof Error?n.message:"Failed to save persona"}}})}loadTools(){return z(this,null,function*(){try{let t=yield fetch(xe.LOCAL_TOOLS);if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return yield t.json()}catch(t){return console.error("Load tools error:",t),{success:!1,error:t instanceof Error?t.message:"Failed to load tools"}}})}testTool(t,n,a,i,r,l){return z(this,null,function*(){try{let s={toolName:t,inputs:n,skillOverride:[{skillId:i,sandboxId:r}]},o=yield fetch(xe.TOOLS_TEST(a),{method:"POST",headers:{"Content-Type":"application/json",Authorization:l},body:JSON.stringify(s)});if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);let u=yield o.json();return{success:!0,result:u.result||u}}catch(s){return console.error("Tool test error:",s),{success:!1,error:s instanceof Error?s.message:"Unknown error occurred"}}})}getSkillVersions(t,n,a){return z(this,null,function*(){try{let i=yield fetch(xe.SKILL_VERSIONS(n,t),{method:"GET",headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json"}});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);return{success:!0,versions:(yield i.json()).versions||[]}}catch(i){return console.error("Error fetching skill versions:",i),{success:!1,error:i instanceof Error?i.message:"Unknown error occurred"}}})}getPersonaVersions(t,n){return z(this,null,function*(){try{let a=yield fetch(`${Pe.DEV_SERVER}/developer/agents/${t}/persona/versions`,{method:"GET",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"}});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return{success:!0,versions:(yield a.json()).versions||[]}}catch(a){return console.error("Error fetching persona versions:",a),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}})}getProductionPersonaVersions(t,n){return z(this,null,function*(){try{let a=yield fetch(xe.PERSONA_VERSIONS(t),{method:"GET",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"}});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return{success:!0,versions:(yield a.json()).versions||[]}}catch(a){return console.error("Error fetching production persona versions:",a),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}})}deployPersonaVersion(t,n,a){return z(this,null,function*(){try{let i=yield fetch(xe.DEPLOY_PERSONA_VERSION(t,a),{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify({})});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);return{success:!0,data:yield i.json()}}catch(i){return console.error("Error deploying persona version:",i),{success:!1,error:i instanceof Error?i.message:"Unknown error occurred"}}})}createPersonaVersion(t,n,a){return z(this,null,function*(){try{let i=yield fetch(`${Pe.DEV_SERVER}/developer/agents/${t}/persona/version`,{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify({persona:a})});if(!i.ok){let l=yield i.text();throw new Error(`HTTP error! status: ${i.status}, message: ${l}`)}return{success:!0,data:yield i.json()}}catch(i){return console.error("Error creating persona version:",i),{success:!1,error:i instanceof Error?i.message:"Unknown error occurred"}}})}createSkillVersion(t,n,a,i){return z(this,null,function*(){try{let r=yield fetch(`${Pe.DEV_SERVER}/developer/skills/${n}/${t}/version`,{method:"POST",headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json"},body:JSON.stringify(i)});if(!r.ok){let s=yield r.text();throw new Error(`HTTP error! status: ${r.status}, message: ${s}`)}return{success:!0,data:yield r.json()}}catch(r){return console.error("Error creating skill version:",r),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}})}loadEnvContent(){return z(this,null,function*(){try{let t=yield fetch(xe.LOCAL_ENV);if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return yield t.json()}catch(t){return console.error("Load env error:",t),{success:!1,error:t instanceof Error?t.message:"Failed to load environment variables"}}})}saveEnvContent(t){return z(this,null,function*(){try{let n=yield fetch(xe.LOCAL_ENV,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t})});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return yield n.json()}catch(n){return console.error("Save env error:",n),{success:!1,error:n instanceof Error?n.message:"Failed to save environment variables"}}})}testLocalTool(t,n){return z(this,null,function*(){try{let a=yield fetch(xe.LOCAL_TOOLS_TEST,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({toolName:t,inputs:n})});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return yield a.json()}catch(a){return console.error("Local tool test error:",a),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}})}loadChatHistory(t,n){return z(this,null,function*(){try{console.log("ApiService: Loading chat history with API key:",t,"agentId:",n);let a=yield fetch(xe.CHAT_HISTORY(n),{method:"GET",headers:{accept:"*/*",Authorization:`Bearer ${t}`}});if(console.log("ApiService: Response status:",a.status),console.log("ApiService: Response headers:",a.headers),!a.ok){let r=yield a.text();throw console.error("ApiService: HTTP error response:",r),new Error(`HTTP error! status: ${a.status}`)}let i=yield a.json();return console.log("ApiService: Received data:",i),{success:!0,data:i}}catch(a){return console.error("ApiService: Chat history load error:",a),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}})}clearChatHistory(t,n){return z(this,null,function*(){try{console.log("ApiService: Clearing chat history with API key:",t,"agentId:",n);let a=yield fetch(xe.CHAT_HISTORY(n),{method:"DELETE",headers:{accept:"*/*",Authorization:`Bearer ${t}`}});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return{success:!0}}catch(a){return console.error("Clear chat history error:",a),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}})}clearSandboxLogs(t,n,a){return z(this,null,function*(){try{console.log("ApiService: Clearing sandbox logs with API key:",t,"agentId:",n,"sandboxId:",a);let i=yield fetch(xe.DEVELOPER_LOGS(n,a),{method:"DELETE",headers:{accept:"application/json",Authorization:`Bearer ${t}`}});if(console.log("ApiService: Clear logs response status:",i.status),!i.ok){let l=yield i.text();throw console.error("ApiService: HTTP error response:",l),new Error(`HTTP error! status: ${i.status}`)}let r=yield i.json();return console.log("ApiService: Clear logs response:",r),{success:!0,data:r}}catch(i){return console.error("ApiService: Clear sandbox logs error:",i),{success:!1,error:i instanceof Error?i.message:"Unknown error occurred"}}})}loadAllSandboxLogs(t,n,a=20){return z(this,null,function*(){try{let i=yield this.getAllSkillOverrides();if(i.length===0)return{success:!0,data:{logs:[]}};let r=i.map(o=>z(this,null,function*(){try{let u=yield this.loadSandboxLogs(t,n,o.sandboxId,a);return u.success&&u.data&&u.data.logs?u.data.logs.map(c=>ut(K({},c),{skillName:o.skillId,sandboxId:o.sandboxId})):[]}catch(u){return console.error(`Error loading logs for skill ${o.skillId}:`,u),[]}}));return{success:!0,data:{logs:(yield Promise.all(r)).flat().sort((o,u)=>new Date(u.timestamp).getTime()-new Date(o.timestamp).getTime()).slice(0,a)}}}catch(i){return console.error("Error loading all sandbox logs:",i),{success:!1,error:i instanceof Error?i.message:"Unknown error occurred",data:{logs:[]}}}})}loadSandboxLogs(t,n,a,i=20){return z(this,null,function*(){try{console.log("ApiService: Loading sandbox logs with API key:",t,"agentId:",n,"sandboxId:",a);let r=yield fetch(`${xe.DEVELOPER_LOGS(n,a)}?limit=${i}`,{method:"GET",headers:{accept:"application/json",Authorization:`Bearer ${t}`}});if(console.log("ApiService: Logs response status:",r.status),!r.ok){let s=yield r.text();throw console.error("ApiService: HTTP error response:",s),new Error(`HTTP error! status: ${r.status}`)}let l=yield r.json();return console.log("ApiService: Received logs data:",l),{success:!0,data:l}}catch(r){return console.error("ApiService: Sandbox logs load error:",r),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}})}loadUserData(t,n){return z(this,null,function*(){try{console.log("ApiService: Loading user data with API key:",t,"agentId:",n),console.log("ApiService: API key length:",t==null?void 0:t.length),console.log("ApiService: API key starts with:",t==null?void 0:t.substring(0,10));let a=yield fetch(xe.USER_DATA(n),{method:"GET",headers:{accept:"*/*",Authorization:`Bearer ${t}`}});if(console.log("ApiService: User data response status:",a.status),console.log("ApiService: Response headers:",Object.fromEntries(a.headers.entries())),!a.ok){let r=yield a.text();if(console.error("ApiService: HTTP error response:",r),a.status===401){console.log("ApiService: Trying alternative authentication method...");let l=yield fetch(xe.USER_DATA(n),{method:"GET",headers:{accept:"*/*",Authorization:t}});if(l.ok){let s=yield l.json();return console.log("ApiService: Alternative auth successful:",s),{success:!0,data:s}}}throw new Error(`HTTP error! status: ${a.status}`)}let i=yield a.json();return console.log("ApiService: Received user data:",i),{success:!0,data:i}}catch(a){return console.error("ApiService: User data load error:",a),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}})}saveUserData(t,n,a){return z(this,null,function*(){return this.updateUserData(t,n,a)})}getUserData(t,n){return z(this,null,function*(){return this.loadUserData(t,n)})}updateUserData(t,n,a){return z(this,null,function*(){try{console.log("ApiService: Updating user data with API key:",t,"agentId:",n,"data:",a);let i=yield fetch(xe.USER_DATA(n),{method:"PUT",headers:{accept:"*/*",Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify(a)});if(console.log("ApiService: Update user data response status:",i.status),!i.ok){let l=yield i.text();throw console.error("ApiService: HTTP error response:",l),new Error(`HTTP error! status: ${i.status}`)}let r=yield i.json();return console.log("ApiService: Updated user data response:",r),{success:!0,data:r}}catch(i){return console.error("ApiService: Update user data error:",i),{success:!1,error:i instanceof Error?i.message:"Unknown error occurred"}}})}loadResources(t,n){return z(this,null,function*(){try{console.log("ApiService: Loading resources with API key:",t,"agentId:",n);let a=yield fetch(xe.AGENT_RESOURCES(n),{method:"GET",headers:{accept:"application/json",Authorization:`Bearer ${t}`}});if(console.log("ApiService: Resources response status:",a.status),!a.ok)throw new Error(`HTTP error! status: ${a.status}`);let i=yield a.json();return console.log("ApiService: Resources data:",i),{success:!0,data:i||[]}}catch(a){return console.error("ApiService: Error loading resources:",a),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}})}createResource(t,n,a){return z(this,null,function*(){try{let i=yield fetch(xe.AGENT_RESOURCES(n),{method:"POST",headers:{accept:"application/json",Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify(a)});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);return{success:!0,data:yield i.json()}}catch(i){return console.error("Error creating resource:",i),{success:!1,error:i instanceof Error?i.message:"Unknown error occurred"}}})}updateResource(t,n,a,i){return z(this,null,function*(){try{let r=yield fetch(xe.AGENT_RESOURCE(n,a),{method:"PUT",headers:{accept:"application/json",Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify(i)});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return{success:!0,data:yield r.json()}}catch(r){return console.error("Error updating resource:",r),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}})}deleteResource(t,n,a){return z(this,null,function*(){try{let i=yield fetch(xe.AGENT_RESOURCE(n,a),{method:"DELETE",headers:{accept:"*/*",Authorization:`Bearer ${t}`}});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);return{success:!0}}catch(i){return console.error("Error deleting resource:",i),{success:!1,error:i instanceof Error?i.message:"Unknown error occurred"}}})}clearUserData(t,n){return z(this,null,function*(){try{console.log("ApiService: Clearing user data with API key:",t,"agentId:",n);let a=yield fetch(xe.USER_DATA(n),{method:"DELETE",headers:{accept:"*/*",Authorization:`Bearer ${t}`}});if(console.log("ApiService: Clear user data response status:",a.status),!a.ok){let r=yield a.text();throw console.error("ApiService: HTTP error response:",r),new Error(`HTTP error! status: ${a.status}`)}let i=yield a.json();return console.log("ApiService: Clear user data response:",i),{success:!0,data:i}}catch(a){return console.error("ApiService: Clear user data error:",a),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}})}createSkill(t,n,a){return z(this,null,function*(){try{let i=yield fetch(xe.CREATE_SKILL(n),{method:"POST",headers:{accept:"application/json",Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify({name:a.name,description:a.description||`A Lua skill for ${a.name}`,context:a.context||""})});if(!i.ok){let l=yield i.text();return{success:!1,error:{message:`HTTP ${i.status}: ${l}`}}}return{success:!0,data:yield i.json()}}catch(i){return{success:!1,error:{message:i instanceof Error?i.message:"Unknown error"}}}})}getAgentTypes(t){return z(this,null,function*(){try{let n=yield fetch(xe.AGENT_TYPES,{method:"GET",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"}});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return yield n.json()}catch(n){return console.error("Error fetching agent types:",n),[]}})}createAgent(t,n){return z(this,null,function*(){try{let a=yield fetch(xe.CREATE_AGENT,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify(n)});return a.ok?{success:!0,data:yield a.json()}:{success:!1,error:yield a.json()}}catch(a){return{success:!1,error:{message:a instanceof Error?a.message:"Unknown error"}}}})}getAgentDetails(t,n){return z(this,null,function*(){try{let a=yield fetch(xe.AGENT_DETAILS(n),{method:"GET",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"}});return a.ok?{success:!0,data:yield a.json()}:{success:!1,error:yield a.json()}}catch(a){return{success:!1,error:{message:a instanceof Error?a.message:"Unknown error"}}}})}getSkills(t,n){return z(this,null,function*(){try{console.log("ApiService: Loading skills with API key:",t,"agentId:",n);let a=yield fetch(xe.AGENT_SKILLS(n),{method:"GET",headers:{accept:"application/json",Authorization:`Bearer ${t}`}});if(console.log("ApiService: Skills response status:",a.status),!a.ok){let r=yield a.text();throw console.error("ApiService: HTTP error response:",r),new Error(`HTTP error! status: ${a.status}`)}let i=yield a.json();return console.log("ApiService: Received skills data:",i),{success:!0,skills:i.skills||[]}}catch(a){return console.error("ApiService: Skills load error:",a),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}})}activateSkill(t,n,a,i){return z(this,null,function*(){try{console.log(`ApiService: ${i?"Activating":"Deactivating"} skill:`,a,"for agent:",n);let r=yield fetch(xe.ACTIVATE_SKILL(n,a),{method:"PUT",headers:{accept:"application/json",Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify({active:i})});if(console.log("ApiService: Activate skill response status:",r.status),!r.ok){let s=yield r.text();throw console.error("ApiService: HTTP error response:",s),new Error(`HTTP error! status: ${r.status}`)}let l=yield r.json();return console.log("ApiService: Activate skill response:",l),{success:!0,data:l}}catch(r){return console.error("ApiService: Activate skill error:",r),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}})}publishSkillVersion(t,n,a,i){return z(this,null,function*(){try{console.log("ApiService: Publishing skill version:",i,"for skill:",a,"agent:",n);let r=yield fetch(xe.PUBLISH_SKILL_VERSION(n,a,i),{method:"PUT",headers:{accept:"application/json",Authorization:`Bearer ${t}`}});if(console.log("ApiService: Publish skill version response status:",r.status),!r.ok){let s=yield r.text();throw console.error("ApiService: HTTP error response:",s),new Error(`HTTP error! status: ${r.status}`)}let l=yield r.json();return console.log("ApiService: Publish skill version response:",l),{success:!0,data:l}}catch(r){return console.error("ApiService: Publish skill version error:",r),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}})}loadProductionLogs(t,n,a=1,i=100){return z(this,null,function*(){try{console.log("ApiService: Loading production logs with API key:",t,"agentId:",n,"page:",a,"limit:",i);let r=yield fetch(`${xe.PRODUCTION_LOGS(n)}?page=${a}&limit=${i}`,{method:"GET",headers:{accept:"application/json",Authorization:`Bearer ${t}`}});if(console.log("ApiService: Production logs response status:",r.status),!r.ok){let s=yield r.text();throw console.error("ApiService: HTTP error response:",s),new Error(`HTTP error! status: ${r.status}`)}let l=yield r.json();return console.log("ApiService: Production logs response:",l),{success:!0,logs:l.logs||[],pagination:l.pagination}}catch(r){return console.error("ApiService: Production logs error:",r),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}})}loadProductionEnv(t,n){return z(this,null,function*(){try{console.log("ApiService: Loading production env with API key:",t,"agentId:",n);let a=yield fetch(xe.PRODUCTION_ENV(n),{method:"GET",headers:{accept:"application/json",Authorization:`Bearer ${t}`}});if(console.log("ApiService: Production env response status:",a.status),!a.ok){let r=yield a.text();throw console.error("ApiService: HTTP error response:",r),new Error(`HTTP error! status: ${a.status}`)}let i=yield a.json();return console.log("ApiService: Production env response:",i),{success:!0,data:i}}catch(a){return console.error("ApiService: Production env error:",a),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}})}updateProductionEnv(t,n,a){return z(this,null,function*(){try{console.log("ApiService: Updating production env with API key:",t,"agentId:",n,"data:",a);let i=yield fetch(xe.PRODUCTION_ENV(n),{method:"POST",headers:{accept:"application/json",Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify(a)});if(console.log("ApiService: Update production env response status:",i.status),!i.ok){let l=yield i.text();throw console.error("ApiService: HTTP error response:",l),new Error(`HTTP error! status: ${i.status}`)}let r=yield i.json();return console.log("ApiService: Update production env response:",r),{success:!0,data:r}}catch(i){return console.error("ApiService: Update production env error:",i),{success:!1,error:i instanceof Error?i.message:"Unknown error occurred"}}})}},ie=new dm});var Pr,dt,pm,eN=b(()=>{"use strict";Pr=F(Je());fm();an();dt=F(re()),pm=({apiKey:e,agentId:t,skillId:n,sandboxId:a,persona:i,sharedChatMessages:r,onSharedSendMessage:l,onSharedClearHistory:s,isChatLoading:o,setIsChatLoading:u})=>{let[c,p]=(0,Pr.useState)(""),d=(0,Pr.useRef)(null),f=()=>{var h;(h=d.current)==null||h.scrollIntoView({behavior:"smooth"})};(0,Pr.useEffect)(()=>{f()},[r]);let S=r.length>0?r.map(h=>({text:h.text,isUser:h.sender==="user",timestamp:h.timestamp})):[{text:"\u{1F44B} Welcome! Start chatting to test your Lua skill. Your messages will be sent to the sandbox environment.",isUser:!1,timestamp:new Date}],x=h=>z(null,null,function*(){if(!h.trim())return;let g={id:Date.now().toString(),text:h,sender:"user",timestamp:new Date};l(g),p(""),u(!0);try{let E=yield ie.sendLocalChatMessage(h,i),T={id:(Date.now()+1).toString(),text:E.success?E.text||"No response received":`\u274C ${E.error||"Failed to send message"}`,sender:"assistant",timestamp:new Date};l(T)}catch(E){let T={id:(Date.now()+2).toString(),text:`\u274C Error: ${E instanceof Error?E.message:"Unknown error"}`,sender:"assistant",timestamp:new Date};l(T)}finally{u(!1)}}),k=h=>{h.preventDefault(),x(c)},m=h=>{h.key==="Enter"&&!h.shiftKey&&(h.preventDefault(),x(c))};return(0,dt.jsxs)("div",{className:"chat-container",children:[(0,dt.jsxs)("div",{className:"chat-header",children:[(0,dt.jsx)("div",{className:"chat-header-content",children:(0,dt.jsxs)("div",{children:[(0,dt.jsx)("h1",{children:"Chat to your Agent [Sandbox]"}),(0,dt.jsx)("p",{children:"Test your sandbox skill in real-time"})]})}),(0,dt.jsx)("button",{className:"clear-chat-button",onClick:s,disabled:o,title:"Clear chat history",children:"\u{1F5D1}\uFE0F"})]}),(0,dt.jsxs)("div",{className:"chat-messages",children:[S.map((h,g)=>(0,dt.jsx)("div",{className:`message ${h.isUser?"user":"assistant"}`,children:(0,dt.jsx)("div",{className:"message-bubble",children:(0,dt.jsx)(Ss,{children:h.text})})},g)),o&&(0,dt.jsx)("div",{className:"loading",children:(0,dt.jsx)("img",{src:"https://admin.lua.dev/images/logo.svg",alt:"Loading",className:"loading-logo"})}),(0,dt.jsx)("div",{ref:d})]}),(0,dt.jsx)("div",{className:"chat-input-container",children:(0,dt.jsxs)("form",{className:"chat-input-form",onSubmit:k,children:[(0,dt.jsx)("input",{type:"text",id:"chat-input",name:"chatMessage",className:"chat-input",value:c,onChange:h=>p(h.target.value),onKeyDown:m,placeholder:"Type your message...",disabled:o,autoComplete:"off"}),(0,dt.jsx)("button",{type:"submit",className:"send-button",disabled:o||!c.trim(),children:"Send"})]})})]})}});var Mn,Z,mm,hm=b(()=>{"use strict";Mn=F(Je());an();Z=F(re()),mm=({persona:e,onSavePersona:t,apiKey:n,agentId:a})=>{let[i,r]=(0,Mn.useState)(e),[l,s]=(0,Mn.useState)(!1),[o,u]=(0,Mn.useState)([]),[c,p]=(0,Mn.useState)(!1),[d,f]=(0,Mn.useState)("current"),[S,x]=(0,Mn.useState)(null),[k,m]=(0,Mn.useState)(!1),[h,g]=(0,Mn.useState)(!1);(0,Mn.useEffect)(()=>{r(e)},[e]),(0,Mn.useEffect)(()=>{E()},[]);let E=()=>z(null,null,function*(){p(!0);try{let R=yield ie.getPersonaVersions(a,n);if(R.success&&R.versions){let O=R.versions.sort((I,B)=>B.createdDate-I.createdDate);u(O)}else console.error("Failed to load persona versions:",R.error),u([])}catch(R){console.error("Error loading persona versions:",R),u([])}finally{p(!1)}}),T=R=>{f(R),S&&x(null)},N=R=>{x(R)},A=()=>{x(null)},C=()=>{if(!i.trim()){alert("Please enter a persona before creating a version");return}g(!0)},U=()=>z(null,null,function*(){m(!0);try{let R=yield ie.createPersonaVersion(a,n,i.trim());if(R.success)console.log("\u2705 Persona version created successfully:",R.data),yield E(),f("versions"),alert("\u2705 Persona version created successfully! You can deploy it from the Production tab.");else throw new Error(R.error||"Failed to create persona version")}catch(R){console.error("\u274C Error creating persona version:",R),alert(`\u274C Failed to create persona version: ${R instanceof Error?R.message:"Unknown error"}`)}finally{m(!1),g(!1)}}),P=()=>{g(!1)},_=()=>z(null,null,function*(){let R=i.trim();if(!R){alert("Persona cannot be empty");return}s(!0);try{(yield t(R))&&r(R)}finally{s(!1)}});return S?(0,Z.jsxs)("div",{className:"persona-section",children:[(0,Z.jsx)("div",{className:"persona-header",children:(0,Z.jsxs)("div",{className:"header-left",children:[(0,Z.jsx)("button",{className:"back-button",onClick:A,children:"\u2190"}),(0,Z.jsxs)("h3",{children:["Persona v",S.version]})]})}),(0,Z.jsxs)("div",{className:"persona-version-details",children:[(0,Z.jsx)("div",{className:"version-metadata",children:(0,Z.jsxs)("div",{className:"metadata-grid",children:[(0,Z.jsxs)("div",{className:"metadata-item",children:[(0,Z.jsx)("span",{className:"metadata-label",children:"Created By"}),(0,Z.jsx)("span",{className:"metadata-value",children:S.createdBy})]}),(0,Z.jsxs)("div",{className:"metadata-item",children:[(0,Z.jsx)("span",{className:"metadata-label",children:"Status"}),(0,Z.jsx)("span",{className:`version-status ${S.isCurrent?"active":"available"}`,children:S.isCurrent?"Active (Deployed)":"Available"})]}),(0,Z.jsxs)("div",{className:"metadata-item",children:[(0,Z.jsx)("span",{className:"metadata-label",children:"Created Date"}),(0,Z.jsx)("span",{className:"metadata-value",children:new Date(S.createdDate).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"})})]})]})}),(0,Z.jsxs)("div",{className:"persona-content",children:[(0,Z.jsx)("h4",{children:"Persona Content"}),(0,Z.jsx)("div",{className:"persona-display",children:(0,Z.jsx)("pre",{children:S.persona})})]})]})]}):(0,Z.jsxs)("div",{className:"persona-section",children:[(0,Z.jsx)("div",{className:"persona-header",children:(0,Z.jsx)("h3",{children:"Agent Persona"})}),(0,Z.jsxs)("div",{className:"persona-tabs",children:[(0,Z.jsxs)("div",{className:"tabs-header",children:[(0,Z.jsx)("button",{className:`tab-button ${d==="current"?"active":""}`,onClick:()=>T("current"),children:"Current"}),(0,Z.jsxs)("button",{className:`tab-button ${d==="versions"?"active":""}`,onClick:()=>T("versions"),children:["Versions (",o.length,")"]})]}),(0,Z.jsx)("div",{className:"tab-content",children:d==="current"?(0,Z.jsxs)("div",{className:"current-persona-tab",children:[(0,Z.jsxs)("div",{className:"persona-edit-header",children:[(0,Z.jsx)("h4",{children:"Edit Current Persona"}),(0,Z.jsxs)("div",{className:"persona-actions",children:[(0,Z.jsx)("button",{className:"save-btn",onClick:_,disabled:l,title:"Save persona to YAML",children:l?"\u27F3":"\u{1F4BE}"}),(0,Z.jsx)("button",{className:"create-version-btn",onClick:C,disabled:k||!i.trim(),title:"Create new persona version",children:k?"Creating...":"Create Version"})]})]}),(0,Z.jsx)("div",{className:"persona-edit",children:(0,Z.jsx)("textarea",{value:i,onChange:R=>r(R.target.value),placeholder:"Enter agent persona...",className:"persona-textarea"})}),(0,Z.jsx)("div",{className:"persona-help",children:(0,Z.jsxs)("p",{children:["This persona is stored in your ",(0,Z.jsx)("code",{children:"lua.skill.yaml"})," file and used for local development."]})})]}):(0,Z.jsx)("div",{className:"versions-persona-tab",children:c?(0,Z.jsx)("div",{className:"versions-loading",children:(0,Z.jsx)("img",{src:"https://admin.lua.dev/images/logo.svg",alt:"Loading",className:"loading-logo"})}):o.length>0?(0,Z.jsx)("div",{className:"versions-list",children:o.map((R,O)=>(0,Z.jsxs)("div",{className:`version-item ${R.isCurrent?"active":"available"}`,onClick:()=>N(R),children:[(0,Z.jsxs)("div",{className:"version-info",children:[(0,Z.jsxs)("div",{className:"version-header",children:[(0,Z.jsxs)("span",{className:"version-number",children:["v",R.version]}),(0,Z.jsx)("span",{className:`version-status ${R.isCurrent?"active":"available"}`,children:R.isCurrent?"Active":"Available"})]}),(0,Z.jsx)("div",{className:"version-date",children:new Date(R.createdDate).toLocaleDateString()})]}),(0,Z.jsx)("div",{className:"version-arrow",children:"\u2192"})]},O))}):(0,Z.jsxs)("div",{className:"no-versions",children:[(0,Z.jsx)("div",{className:"no-versions-icon",children:"\u{1F464}"}),(0,Z.jsx)("div",{className:"no-versions-text",children:"No persona versions found"}),(0,Z.jsx)("div",{className:"no-versions-subtext",children:"Persona versions will appear here when available"})]})})})]}),h&&(0,Z.jsx)("div",{className:"version-modal-overlay",children:(0,Z.jsxs)("div",{className:"version-modal",children:[(0,Z.jsx)("div",{className:"version-modal-header",children:(0,Z.jsx)("h3",{children:"Create Persona Version"})}),(0,Z.jsxs)("div",{className:"version-modal-body",children:[(0,Z.jsx)("p",{children:"This will create a new persona version that can be deployed to production."}),(0,Z.jsxs)("p",{children:[(0,Z.jsx)("strong",{children:"Note:"})," The version will be created but not automatically released. You can deploy it from the Production tab."]}),(0,Z.jsxs)("div",{className:"persona-preview-box",children:[(0,Z.jsx)("h4",{children:"Persona Content:"}),(0,Z.jsxs)("div",{className:"persona-preview-content",children:[i.substring(0,300),i.length>300?"...":""]})]})]}),(0,Z.jsxs)("div",{className:"version-modal-actions",children:[(0,Z.jsx)("button",{className:"cancel-button",onClick:P,disabled:k,children:"Cancel"}),(0,Z.jsx)("button",{className:"create-button",onClick:U,disabled:k,children:k?"Creating...":"Create Version"})]})]})})]})}});var Tt,w,gm,vm=b(()=>{"use strict";Tt=F(Je());an();w=F(re()),gm=({apiKey:e,agentId:t,skillId:n,sandboxId:a})=>{var Zr;let[i,r]=(0,Tt.useState)([]),[l,s]=(0,Tt.useState)(null),[o,u]=(0,Tt.useState)(null),[c,p]=(0,Tt.useState)([]),[d,f]=(0,Tt.useState)(!1),[S,x]=(0,Tt.useState)("current"),[k,m]=(0,Tt.useState)(!1),[h,g]=(0,Tt.useState)(!1),[E,T]=(0,Tt.useState)(""),[N,A]=(0,Tt.useState)({}),[C,U]=(0,Tt.useState)(null),[P,_]=(0,Tt.useState)(!0),[R,O]=(0,Tt.useState)(!1),[I,B]=(0,Tt.useState)(null),[J,ae]=(0,Tt.useState)([]);(0,Tt.useEffect)(()=>{we(),je()},[]);let we=()=>z(null,null,function*(){_(!0),B(null);try{console.log("Loading skills from /api/skills...");let q=yield fetch("/api/skills");if(console.log("Skills API response status:",q.status),!q.ok)throw new Error(`HTTP ${q.status}: ${q.statusText}`);let j=yield q.json();console.log("Skills API response data:",j),j.success&&j.skills&&Array.isArray(j.skills)?(console.log("Skills loaded successfully:",j.skills),r(j.skills),B(null)):(console.error("Failed to load skills:",j.error),B(j.error||"Failed to load skills - invalid data format"),r([]))}catch(q){console.error("Error loading skills:",q),B(q instanceof Error?q.message:"Failed to load skills"),r([])}finally{_(!1)}}),je=()=>z(null,null,function*(){try{let j=yield(yield fetch("/tools")).json();if(j.success&&j.tools){let le=[];Array.isArray(j.tools)?le=j.tools:typeof j.tools=="object"&&(le=Object.entries(j.tools).map(([Be,Mt])=>K({name:Be},Mt))),ae(le)}else console.error("Failed to load tools:",j.error),ae([])}catch(q){console.error("Error loading tools:",q),ae([])}}),v=q=>{let j={};q.inputSchema.properties&&Object.keys(q.inputSchema.properties).forEach(le=>{let Be=q.inputSchema.properties[le];j[le]=Me(Be)}),A(j)},Me=q=>{if(q.type==="object"&&q.properties){let j={};return Object.keys(q.properties).forEach(le=>{j[le]=Me(q.properties[le])}),j}else return q.type==="number"?0:q.type==="boolean"?!1:""},pt=q=>{let j=J.find(le=>le.name===q);j&&(u(j),v(j),U(null))},y=q=>z(null,null,function*(){f(!0);try{let j=yield ie.getSkillVersions(q.skillId,t,e);if(j.success&&j.versions){let le=j.versions.sort((Be,Mt)=>new Date(Mt.createdDate||Mt.createdAt).getTime()-new Date(Be.createdDate||Be.createdAt).getTime());p(le)}else console.error("Failed to load skill versions:",j.error),p([])}catch(j){console.error("Error loading skill versions:",j),p([])}finally{f(!1)}}),Ke=q=>{let j=i.find(le=>le.name===q);j&&(s(q),x("current"),y(j))},At=()=>{s(null),x("current"),p([]),u(null),U(null)},se=q=>{x(q),o&&(u(null),U(null))},X=()=>{u(null),U(null)},Q=()=>z(null,null,function*(){if(!l)return;let q=i.find(le=>le.name===l);if(!q)return;c.some(le=>le.version===q.version)?(T(q.version),g(!0)):yield ne(q.version)}),ne=q=>z(null,null,function*(){if(!l)return;let j=i.find(le=>le.name===l);if(j){m(!0);try{let Be=yield(yield fetch("/tools")).json();if(!Be.success||!Be.tools)throw new Error("Failed to load current tools data");let Mt=[];Array.isArray(Be.tools)?Mt=Be.tools:typeof Be.tools=="object"&&(Mt=Object.entries(Be.tools).map(([un,D])=>({name:un,description:D.description||"",inputSchema:D.inputSchema||{type:"object"},execute:D.execute||""})));let on=Mt.filter(un=>j.tools.includes(un.name)),Ct={name:j.name,version:q,description:j.description,context:j.context,tools:on};console.log("Creating version with data:",Ct);let We=yield ie.createSkillVersion(j.skillId,t,e,Ct);if(We.success)console.log("\u2705 Version created successfully:",We.data),yield y(j),alert(`\u2705 Version ${q} created successfully!`);else throw new Error(We.error||"Failed to create version")}catch(le){console.error("\u274C Error creating version:",le),alert(`\u274C Failed to create version: ${le instanceof Error?le.message:"Unknown error"}`)}finally{m(!1),g(!1)}}}),Y=()=>z(null,null,function*(){if(!E.trim()){alert("Please enter a version number");return}if(c.some(j=>j.version===E.trim())){alert("This version already exists. Please enter a different version number.");return}yield ne(E.trim())}),oe=()=>{g(!1),T("")},Ue=(q,j,le)=>{A(Be=>le?ut(K({},Be),{[q]:ut(K({},Be[q]),{[le]:j})}):ut(K({},Be),{[q]:j}))},mt=()=>z(null,null,function*(){if(o){O(!0),U(null);try{let q=zs(N,o.inputSchema),j=yield ie.testLocalTool(o.name,q);U(j)}catch(q){U({success:!1,error:q instanceof Error?q.message:"Unknown error occurred"})}finally{O(!1)}}}),zs=(q,j)=>{var Be,Mt;let le={};for(let[on,Ct]of Object.entries(q))if(Ct&&typeof Ct=="object"&&!Array.isArray(Ct)){let We=(Be=j.properties)==null?void 0:Be[on];if(We&&We.type==="object"&&We.properties){let un=zs(Ct,We);Object.keys(un).length>0&&(le[on]=un)}else le[on]=Ct}else{let We=(Mt=j.properties)==null?void 0:Mt[on];if((!j.required||!j.required.includes(on))&&(Ct===""||Ct===null||Ct===void 0))continue;le[on]=Ct}return le},Fr=(q,j,le)=>{var on,Ct;let Be=le?((on=N[q])==null?void 0:on[le])||"":N[q]||"",Mt=le?(Ct=j.required)==null?void 0:Ct.includes(le):o==null?void 0:o.inputSchema.required.includes(q);if(j.type==="object"&&j.properties)return(0,w.jsxs)("div",{className:"nested-object",children:[(0,w.jsx)("div",{className:"nested-object-label",children:q}),(0,w.jsx)("div",{className:"nested-fields",children:Object.entries(j.properties).map(([We,un])=>{var D;return(0,w.jsxs)("div",{className:"nested-field",children:[(0,w.jsxs)("label",{className:"nested-label",children:[We,((D=j.required)==null?void 0:D.includes(We))&&(0,w.jsx)("span",{className:"required",children:"*"})]}),Fr(q,un,We),un.description&&(0,w.jsx)("div",{className:"input-description",children:un.description})]},We)})})]});switch(j.type){case"number":return(0,w.jsx)("input",{type:"number",value:Be,onChange:We=>Ue(q,parseFloat(We.target.value)||0,le),placeholder:j.description||`Enter ${le||q}`,className:"tool-input",required:Mt});case"boolean":return(0,w.jsx)("input",{type:"checkbox",checked:Be,onChange:We=>Ue(q,We.target.checked,le),className:"tool-checkbox"});case"string":default:return(0,w.jsx)("input",{type:"text",value:Be,onChange:We=>Ue(q,We.target.value,le),placeholder:j.description||`Enter ${le||q}`,className:"tool-input",required:Mt})}};if(P)return(0,w.jsx)("div",{className:"skills-page",children:(0,w.jsx)("div",{className:"skills-loading",children:(0,w.jsx)("img",{src:"https://admin.lua.dev/images/logo.svg",alt:"Loading",className:"loading-logo"})})});if(o)return(0,w.jsx)("div",{className:"skills-page",children:(0,w.jsxs)("div",{className:"tool-form",children:[(0,w.jsxs)("div",{className:"tool-form-header",children:[(0,w.jsx)("button",{className:"back-button",onClick:X,title:"Back to skill",children:"\u2190"}),(0,w.jsx)("h3",{children:o.name})]}),(0,w.jsxs)("div",{className:"tool-form-content",children:[(0,w.jsx)("div",{className:"tool-info",children:(0,w.jsx)("p",{children:o.description})}),(0,w.jsxs)("div",{className:"tool-inputs",children:[(0,w.jsx)("h4",{children:"Input Parameters"}),Object.keys(o.inputSchema.properties||{}).length>0?(0,w.jsx)("div",{className:"input-fields",children:Object.entries(o.inputSchema.properties).map(([q,j])=>(0,w.jsxs)("div",{className:"input-field",children:[(0,w.jsxs)("label",{children:[q,o.inputSchema.required.includes(q)&&(0,w.jsx)("span",{className:"required",children:"*"})]}),Fr(q,j),j.description&&(0,w.jsx)("div",{className:"input-description",children:j.description})]},q))}):(0,w.jsx)("p",{className:"no-inputs",children:"This tool requires no input parameters."})]}),(0,w.jsx)("div",{className:"tool-actions",children:(0,w.jsx)("button",{onClick:mt,disabled:R,className:"test-button",children:R?"Testing...":"Test Tool"})}),C&&(0,w.jsxs)("div",{className:"test-result",children:[(0,w.jsx)("h4",{children:"Test Result"}),(0,w.jsx)("div",{className:`result-content ${C.success?"success":"error"}`,children:C.success?(0,w.jsxs)("div",{children:[(0,w.jsx)("div",{className:"result-label",children:"\u2705 Success"}),(0,w.jsx)("pre",{className:"result-data",children:JSON.stringify(C.result,null,2)})]}):(0,w.jsxs)("div",{children:[(0,w.jsx)("div",{className:"result-label",children:"\u274C Error"}),(0,w.jsx)("div",{className:"result-error",children:C.error})]})})]})]})]})});if(l){let q=i.find(j=>j.name===l);return q?(0,w.jsxs)("div",{className:"skills-page",children:[(0,w.jsxs)("div",{className:"skills-header",children:[(0,w.jsxs)("div",{className:"header-left",children:[(0,w.jsx)("button",{className:"back-button",onClick:At,children:"\u2190"}),(0,w.jsx)("h4",{children:q.name})]}),(0,w.jsx)("button",{className:"create-version-button",onClick:Q,disabled:k,title:"Create new version",children:k?"Creating...":"Create Version"})]}),(0,w.jsxs)("div",{className:"skill-tabs",children:[(0,w.jsxs)("div",{className:"tabs-header",children:[(0,w.jsx)("button",{className:`tab-button ${S==="current"?"active":""}`,onClick:()=>se("current"),children:"Current"}),(0,w.jsxs)("button",{className:`tab-button ${S==="versions"?"active":""}`,onClick:()=>se("versions"),children:["Versions (",c.length,")"]})]}),(0,w.jsx)("div",{className:"tab-content",children:S==="current"?(0,w.jsxs)("div",{className:"current-skill-tab",children:[(0,w.jsx)("div",{className:"skill-details",children:(0,w.jsxs)("div",{className:"skill-info-section",children:[(0,w.jsxs)("div",{className:"skill-meta",children:[(0,w.jsxs)("span",{className:"skill-version",children:["v",q.version]}),(0,w.jsxs)("span",{className:"skill-tools-count",children:[q.tools.length," tools"]})]}),q.description&&(0,w.jsxs)("div",{className:"skill-description-section",children:[(0,w.jsx)("h5",{children:"Description"}),(0,w.jsx)("p",{children:q.description})]}),q.context&&(0,w.jsxs)("div",{className:"skill-context-section",children:[(0,w.jsx)("h5",{children:"Context"}),(0,w.jsx)("p",{children:q.context})]})]})}),(0,w.jsxs)("div",{className:"tools-section",children:[(0,w.jsx)("div",{className:"tools-header",children:(0,w.jsxs)("h5",{children:["Available Tools (",q.tools.length,")"]})}),q.tools&&q.tools.length>0?(0,w.jsx)("div",{className:"tools-grid",children:q.tools.map((j,le)=>(0,w.jsxs)("div",{className:"tool-card",onClick:()=>pt(j),children:[(0,w.jsx)("div",{className:"tool-card-header",children:(0,w.jsx)("h4",{children:j})}),(0,w.jsx)("div",{className:"tool-card-body",children:(0,w.jsx)("span",{className:"skill-badge",children:q.name})})]},le))}):(0,w.jsxs)("div",{className:"no-tools",children:[(0,w.jsx)("div",{className:"no-tools-icon",children:"\u{1F527}"}),(0,w.jsx)("div",{className:"no-tools-text",children:"No tools in this skill"}),(0,w.jsx)("div",{className:"no-tools-subtext",children:"This skill doesn't have any tools defined"})]})]}),(0,w.jsx)("div",{className:"skills-help",children:(0,w.jsx)("p",{children:"This skill is compiled from your local code and updates automatically when you make changes. Use the tools above to test your skill's functionality."})})]}):(0,w.jsx)("div",{className:"versions-skill-tab",children:d?(0,w.jsx)("div",{className:"versions-loading",children:(0,w.jsx)("img",{src:"https://admin.lua.dev/images/logo.svg",alt:"Loading",className:"loading-logo"})}):c.length>0?(0,w.jsx)("div",{className:"versions-list",children:c.map((j,le)=>(0,w.jsxs)("div",{className:`version-item ${j.status}`,onClick:()=>{console.log("Selected version:",j.version)},children:[(0,w.jsxs)("div",{className:"version-info",children:[(0,w.jsxs)("div",{className:"version-header",children:[(0,w.jsxs)("span",{className:"version-number",children:["v",j.version]}),(0,w.jsx)("span",{className:`version-status ${j.status}`,children:j.status})]}),(0,w.jsxs)("div",{className:"version-meta",children:[(0,w.jsx)("span",{className:"version-date",children:new Date(j.createdDate||j.createdAt).toLocaleDateString()}),(0,w.jsxs)("span",{className:"version-author",children:["by ",j.createdByEmail||j.createdBy]})]})]}),(0,w.jsx)("div",{className:"version-arrow",children:"\u2192"})]},le))}):(0,w.jsxs)("div",{className:"no-versions",children:[(0,w.jsx)("div",{className:"no-versions-icon",children:"\u{1F4E6}"}),(0,w.jsx)("div",{className:"no-versions-text",children:"No versions found"}),(0,w.jsx)("div",{className:"no-versions-subtext",children:"Create your first version to get started"})]})})})]}),h&&(0,w.jsx)("div",{className:"version-modal-overlay",children:(0,w.jsxs)("div",{className:"version-modal",children:[(0,w.jsx)("div",{className:"version-modal-header",children:(0,w.jsx)("h3",{children:"Create New Version"})}),(0,w.jsxs)("div",{className:"version-modal-body",children:[(0,w.jsxs)("p",{children:["Version ",(0,w.jsx)("strong",{children:(Zr=i.find(j=>j.name===l))==null?void 0:Zr.version})," already exists."]}),(0,w.jsx)("p",{children:"Please enter a new version number:"}),(0,w.jsx)("input",{type:"text",value:E,onChange:j=>T(j.target.value),placeholder:"e.g., 1.0.1",className:"version-input",autoFocus:!0})]}),(0,w.jsxs)("div",{className:"version-modal-actions",children:[(0,w.jsx)("button",{className:"cancel-button",onClick:oe,disabled:k,children:"Cancel"}),(0,w.jsx)("button",{className:"create-button",onClick:Y,disabled:k||!E.trim(),children:k?"Creating...":"Create Version"})]})]})})]}):(0,w.jsxs)("div",{className:"skills-page",children:[(0,w.jsx)("div",{className:"skills-header",children:(0,w.jsxs)("div",{className:"header-left",children:[(0,w.jsx)("button",{className:"back-button",onClick:At,children:"\u2190"}),(0,w.jsx)("h4",{children:"Skill Not Found"})]})}),(0,w.jsxs)("div",{className:"no-skills",children:[(0,w.jsx)("div",{className:"no-skills-icon",children:"\u274C"}),(0,w.jsx)("div",{className:"no-skills-text",children:"Skill not found"}),(0,w.jsx)("div",{className:"no-skills-subtext",children:"The selected skill could not be loaded"})]})]})}return(0,w.jsxs)("div",{className:"skills-page",children:[(0,w.jsxs)("div",{className:"skills-header",children:[(0,w.jsx)("h3",{children:"Available Skills"}),(0,w.jsx)("button",{className:"refresh-button",onClick:we,title:"Refresh skills",children:"\u21BB"})]}),(0,w.jsx)("div",{className:"skills-content",children:I?(0,w.jsxs)("div",{className:"no-skills",children:[(0,w.jsx)("div",{className:"no-skills-icon",children:"\u274C"}),(0,w.jsx)("div",{className:"no-skills-text",children:"Error loading skills"}),(0,w.jsx)("div",{className:"no-skills-subtext",children:I}),(0,w.jsx)("button",{className:"retry-button",onClick:we,style:{marginTop:"16px"},children:"Retry"})]}):i.length===0?(0,w.jsxs)("div",{className:"no-skills",children:[(0,w.jsx)("div",{className:"no-skills-icon",children:"\u2699\uFE0F"}),(0,w.jsx)("div",{className:"no-skills-text",children:"No skills found"}),(0,w.jsx)("div",{className:"no-skills-subtext",children:"Skills will appear here when available in your project"})]}):Array.isArray(i)&&i.length>0?(0,w.jsx)("div",{className:"skills-list",children:i.map(q=>(0,w.jsxs)("div",{className:"skill-item",onClick:()=>Ke(q.name),children:[(0,w.jsxs)("div",{className:"skill-info",children:[(0,w.jsx)("div",{className:"skill-name",children:q.name}),(0,w.jsx)("div",{className:"skill-description",children:q.description}),(0,w.jsxs)("div",{className:"skill-stats",children:[(0,w.jsxs)("span",{className:"skill-stat",children:["v",q.version]}),(0,w.jsxs)("span",{className:"skill-stat",children:[q.tools.length," tools"]})]})]}),(0,w.jsx)("div",{className:"skill-arrow",children:"\u2192"})]},q.name))}):(0,w.jsxs)("div",{className:"no-skills",children:[(0,w.jsx)("div",{className:"no-skills-icon",children:"\u2699\uFE0F"}),(0,w.jsx)("div",{className:"no-skills-text",children:"No skills available"}),(0,w.jsx)("div",{className:"no-skills-subtext",children:"No valid skills data received"})]})})]})}});var qe,L,xs,DR,ym,OR,bm=b(()=>{"use strict";qe=F(Je());an();L=F(re()),xs=e=>{if(!e||!e.trim())return e||"";try{let t=JSON.parse(e);return JSON.stringify(t,null,2).replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,a=>{let i="json-number";return/^"/.test(a)?/:$/.test(a)?i="json-key":i="json-string":/true|false/.test(a)?i="json-boolean":/null/.test(a)&&(i="json-null"),`<span class="${i}">${a}</span>`})}catch(t){return e.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,n=>{let a="json-number";return/^"/.test(n)?/:$/.test(n)?a="json-key":a="json-string":/true|false/.test(n)?a="json-boolean":/null/.test(n)&&(a="json-null"),`<span class="${a}">${n}</span>`})}},DR=[{id:"user",name:"User",description:"User profile and account data",icon:"\u{1F464}"},{id:"resources",name:"Resources",description:"Files, documents, and assets",icon:"\u{1F4C1}"},{id:"products",name:"Products",description:"Coming soon",icon:"\u{1F4E6}"},{id:"orders",name:"Orders",description:"Coming soon",icon:"\u{1F4CB}"},{id:"booking",name:"Booking",description:"Coming soon",icon:"\u{1F4C5}"},{id:"custom",name:"Custom",description:"Coming soon",icon:"\u2699\uFE0F"}],ym=({apiKey:e,agentId:t})=>{let[n,a]=(0,qe.useState)(null),[i,r]=(0,qe.useState)(null),[l,s]=(0,qe.useState)(null),[o,u]=(0,qe.useState)(!1),[c,p]=(0,qe.useState)(!1),[d,f]=(0,qe.useState)(!1),[S,x]=(0,qe.useState)(""),[k,m]=(0,qe.useState)(null),[h,g]=(0,qe.useState)(null),[E,T]=(0,qe.useState)(!1),[N,A]=(0,qe.useState)("list"),C=(0,qe.useRef)(null),U=(0,qe.useRef)(null),[P,_]=(0,qe.useState)(!1),[R,O]=(0,qe.useState)(""),[I,B]=(0,qe.useState)(""),[J,ae]=(0,qe.useState)(!1);(0,qe.useEffect)(()=>{we()},[e,t]),(0,qe.useEffect)(()=>{if(console.log("JSON text changed:",S),console.log("Is editing:",E),console.log("Highlight ref exists:",!!U.current),U.current&&S&&!E){let Y=xs(S);console.log("Applying highlighting:",Y.substring(0,100)+"..."),U.current.innerHTML=Y}},[S,E]);let we=()=>z(null,null,function*(){try{if(console.log("Loading user data with API key:",e,"agentId:",t),u(!0),m(null),!e||!t){console.error("Missing API key or agentId:",{apiKey:!!e,agentId:!!t}),m("Missing API key or agent ID"),x("{}");return}let Y=yield ie.loadUserData(e,t);if(console.log("User data response:",Y),Y.success&&Y.data){a(Y.data);let oe=Y.data,Ue=JSON.stringify(oe,null,2);x(Ue),setTimeout(()=>{U.current&&(U.current.innerHTML=xs(Ue))},0),console.log("User data loaded successfully:",Y.data),console.log("Data to display:",oe)}else console.log("No user data or error:",Y.error),m(Y.error||"No user data found"),x("{}")}catch(Y){console.error("Failed to load user data:",Y),m(`Failed to load user data: ${Y instanceof Error?Y.message:"Unknown error"}`),x("{}")}finally{u(!1)}}),je=()=>z(null,null,function*(){try{console.log("Saving user data:",S),p(!0),m(null),g(null);let Y=JSON.parse(S),oe=yield ie.updateUserData(e,t,Y);console.log("Save user data response:",oe),oe.success&&oe.data?(a(oe.data),x(JSON.stringify(oe.data.data,null,2)),g("User data saved successfully!"),T(!1),setTimeout(()=>g(null),3e3)):m("Failed to save user data: "+(oe.error||"Unknown error"))}catch(Y){console.error("Failed to save user data:",Y),Y instanceof SyntaxError?m("Invalid JSON format. Please check your syntax."):m("Failed to save user data")}finally{p(!1)}}),v=()=>z(null,null,function*(){try{console.log("Clearing user data"),f(!0),m(null),g(null);let Y=yield ie.clearUserData(e,t);console.log("Clear user data response:",Y),Y.success?(a(null),x("{}"),A("list"),g("User data cleared successfully!"),T(!1),setTimeout(()=>g(null),3e3)):m("Failed to clear user data: "+(Y.error||"Unknown error"))}catch(Y){console.error("Failed to clear user data:",Y),m("Failed to clear user data")}finally{f(!1)}}),Me=Y=>z(null,null,function*(){if(r(Y),A("detail"),T(!1),m(null),Y.id==="user"){u(!0);try{let oe=yield ie.loadUserData(e,t);if(oe.success&&oe.data){s(oe.data);let Ue=JSON.stringify(oe.data,null,2);x(Ue),console.log("Setting JSON text for user data:",Ue)}else s(null),x("{}"),console.log("No user data found, setting empty JSON")}catch(oe){console.error("Failed to load user data:",oe),s(null),x("{}")}finally{u(!1)}}else if(Y.id==="resources"){u(!0);try{let oe=yield ie.loadResources(e,t);oe.success&&oe.data?(s(oe.data),console.log("Loaded resources:",oe.data)):(s([]),console.log("No resources found"))}catch(oe){console.error("Failed to load resources:",oe),s([])}finally{u(!1)}}else s(null),x("{}")}),pt=()=>{A("list"),r(null),s(null),T(!1)},y=()=>{i&&(i.id==="resources"?(_(!0),O(""),B("")):console.log(`Add new item to ${i==null?void 0:i.name}`))},Ke=()=>z(null,null,function*(){if(!R.trim()||!I.trim()){alert("Name and content cannot be empty");return}ae(!0);try{let Y=yield ie.createResource(e,t,{name:R.trim(),content:I.trim()});Y.success?(_(!1),O(""),B(""),i&&Me(i)):alert("Failed to create resource: "+(Y.error||"Unknown error"))}catch(Y){console.error("Error creating resource:",Y),alert("Failed to create resource")}finally{ae(!1)}}),At=()=>{_(!1),O(""),B("")},se=()=>z(null,null,function*(){i&&console.log(`Delete all ${i.name} data`)}),X=Y=>{x(Y),T(!0),m(null),g(null),U.current&&(U.current.innerHTML=xs(Y))},Q=()=>{T(!0),setTimeout(()=>{C.current&&C.current.focus()},0)},ne=()=>{C.current&&U.current&&(U.current.scrollTop=C.current.scrollTop,U.current.scrollLeft=C.current.scrollLeft)};return o?(0,L.jsx)("div",{className:"user-data-panel",children:(0,L.jsx)("div",{className:"user-data-loading",children:(0,L.jsx)("img",{src:"https://admin.lua.dev/images/logo.svg",alt:"Loading",className:"loading-logo"})})}):(0,L.jsxs)("div",{className:"user-data-panel",children:[(0,L.jsxs)("div",{className:"user-data-header",children:[(0,L.jsxs)("div",{className:"header-left",children:[N==="detail"&&(0,L.jsx)("button",{className:"back-button",onClick:pt,title:"Back to data categories",children:"\u2190"}),(0,L.jsx)("h3",{children:N==="list"?"Data":(i==null?void 0:i.name)||"Data Detail"})]}),(0,L.jsxs)("div",{className:"user-data-actions",children:[N==="detail"&&(i==null?void 0:i.id)!=="user"&&(i==null?void 0:i.description)!=="Coming soon"&&(0,L.jsx)("button",{className:"add-button",onClick:y,title:`Add new ${i==null?void 0:i.name.toLowerCase()}`,children:"\u2795"}),(0,L.jsx)("button",{className:"refresh-button",onClick:N==="detail"&&i?()=>Me(i):we,disabled:o,title:`Refresh ${N==="detail"?i==null?void 0:i.name.toLowerCase():"data"}`,children:o?"\u27F3":"\u21BB"}),N==="detail"&&(i==null?void 0:i.id)==="user"&&(0,L.jsx)("button",{className:"save-button",onClick:je,disabled:c,title:"Save user data",children:c?"\u27F3":"\u{1F4BE}"}),N==="detail"&&(0,L.jsx)("button",{className:"delete-button",onClick:se,disabled:d,title:`Delete all ${i==null?void 0:i.name.toLowerCase()}`,children:"\u{1F5D1}\uFE0F"})]})]}),k&&(0,L.jsxs)("div",{className:"error-message",children:["\u274C ",k]}),h&&(0,L.jsxs)("div",{className:"success-message",children:["\u2705 ",h]}),(0,L.jsx)("div",{className:"user-data-content",children:N==="list"?(0,L.jsx)("div",{className:"data-list",children:(0,L.jsx)("div",{className:"data-categories",children:DR.map(Y=>(0,L.jsxs)("div",{className:"data-category",onClick:()=>Me(Y),children:[(0,L.jsx)("div",{className:"category-icon",children:Y.icon}),(0,L.jsxs)("div",{className:"category-info",children:[(0,L.jsx)("div",{className:"category-name",children:Y.name}),(0,L.jsx)("div",{className:"category-description",children:Y.description})]}),(0,L.jsx)("div",{className:"category-arrow",children:"\u2192"})]},Y.id))})}):(0,L.jsx)("div",{className:"data-detail",children:(i==null?void 0:i.id)==="user"&&l?(0,L.jsx)("div",{className:"json-editor",children:E?(0,L.jsxs)("div",{className:"json-editor-container",children:[(0,L.jsx)("div",{ref:U,className:"json-highlight-background",dangerouslySetInnerHTML:{__html:xs(S)}}),(0,L.jsx)("textarea",{ref:C,id:"user-data-json",name:"userDataJson",value:S,onChange:Y=>X(Y.target.value),className:"json-textarea",spellCheck:!1,placeholder:"Enter JSON data...",autoComplete:"off"})]}):(0,L.jsx)("div",{className:"json-display",onClick:Q,dangerouslySetInnerHTML:{__html:xs(S)}})}):(i==null?void 0:i.id)==="resources"&&l?(0,L.jsxs)("div",{className:"resources-container",children:[(0,L.jsxs)("div",{className:"production-warning",children:[(0,L.jsx)("div",{className:"warning-icon",children:"\u26A0\uFE0F"}),(0,L.jsxs)("div",{className:"warning-text",children:[(0,L.jsx)("strong",{children:"Production Resources:"})," Changes to resources will propagate to production and affect live users."]})]}),(0,L.jsx)("div",{className:"resources-list",children:Array.isArray(l)&&l.length>0?l.map(Y=>(0,L.jsx)(OR,{resource:Y,apiKey:e,agentId:t,onUpdate:()=>Me(i)},Y.id)):(0,L.jsxs)("div",{className:"no-resources",children:[(0,L.jsx)("div",{className:"empty-icon",children:"\u{1F4C1}"}),(0,L.jsx)("h4",{children:"No resources yet"}),(0,L.jsx)("p",{children:"Resources help provide context and information to your AI agent"})]})})]}):(0,L.jsxs)("div",{className:"category-empty-state",children:[(0,L.jsx)("div",{className:"empty-icon",children:i==null?void 0:i.icon}),(i==null?void 0:i.description)==="Coming soon"?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)("h3",{children:"Coming Soon"}),(0,L.jsxs)("p",{children:[i.name," management will be available in a future update"]}),(0,L.jsx)("div",{className:"coming-soon-badge",children:"\u{1F6A7} Under Development"})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)("h3",{children:["No ",i==null?void 0:i.name.toLowerCase()," yet"]}),(0,L.jsxs)("p",{children:["Start by adding your first ",i==null?void 0:i.name.toLowerCase()," entry"]}),(0,L.jsx)("div",{className:"empty-actions",children:(0,L.jsx)("button",{className:"add-button",onClick:y,children:"\u2795"})})]})]})})}),P&&(0,L.jsx)("div",{className:"resource-modal-overlay",children:(0,L.jsxs)("div",{className:"resource-modal",children:[(0,L.jsxs)("div",{className:"resource-modal-header",children:[(0,L.jsx)("h3",{children:"Create New Resource"}),(0,L.jsx)("button",{className:"modal-close-btn",onClick:At,disabled:J,children:"\u2715"})]}),(0,L.jsxs)("div",{className:"resource-modal-body",children:[(0,L.jsxs)("div",{className:"production-warning",children:[(0,L.jsx)("div",{className:"warning-icon",children:"\u26A0\uFE0F"}),(0,L.jsxs)("div",{className:"warning-text",children:[(0,L.jsx)("strong",{children:"Production Impact:"})," This resource will be available in production and affect live users."]})]}),(0,L.jsxs)("div",{className:"resource-form",children:[(0,L.jsxs)("div",{className:"form-field",children:[(0,L.jsx)("label",{htmlFor:"resource-name",children:"Resource Name"}),(0,L.jsx)("input",{id:"resource-name",type:"text",value:R,onChange:Y=>O(Y.target.value),placeholder:"e.g., FAQ, return-policy, user-guide",className:"resource-name-input",autoFocus:!0})]}),(0,L.jsxs)("div",{className:"form-field",children:[(0,L.jsx)("label",{htmlFor:"resource-content",children:"Content"}),(0,L.jsx)("textarea",{id:"resource-content",value:I,onChange:Y=>B(Y.target.value),placeholder:"Paste your content here... This can be a large text file, FAQ content, documentation, etc.",className:"resource-content-textarea",rows:12})]}),(0,L.jsxs)("div",{className:"character-count",children:[I.length," characters"]})]})]}),(0,L.jsxs)("div",{className:"resource-modal-actions",children:[(0,L.jsx)("button",{className:"cancel-button",onClick:At,disabled:J,children:"Cancel"}),(0,L.jsx)("button",{className:"create-button",onClick:Ke,disabled:J||!R.trim()||!I.trim(),children:J?"Creating...":"Create Resource"})]})]})})]})},OR=({resource:e,apiKey:t,agentId:n,onUpdate:a})=>{let[i,r]=(0,qe.useState)(!1),[l,s]=(0,qe.useState)(e.name),[o,u]=(0,qe.useState)(e.content),[c,p]=(0,qe.useState)(!1),[d,f]=(0,qe.useState)(!1),S=()=>{r(!0),s(e.name),u(e.content)},x=()=>{r(!1),s(e.name),u(e.content)},k=()=>z(null,null,function*(){if(!l.trim()||!o.trim()){alert("Name and content cannot be empty");return}p(!0);try{let h=yield ie.updateResource(t,n,e.id,{name:l.trim(),content:o.trim()});h.success?(r(!1),a()):alert("Failed to update resource: "+(h.error||"Unknown error"))}catch(h){console.error("Error updating resource:",h),alert("Failed to update resource")}finally{p(!1)}}),m=()=>z(null,null,function*(){if(confirm(`Are you sure you want to delete "${e.name}"? This will affect production.`)){f(!0);try{let h=yield ie.deleteResource(t,n,e.id);h.success?a():alert("Failed to delete resource: "+(h.error||"Unknown error"))}catch(h){console.error("Error deleting resource:",h),alert("Failed to delete resource")}finally{f(!1)}}});return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)("div",{className:"resource-item",children:(0,L.jsxs)("div",{className:"resource-display",children:[(0,L.jsxs)("div",{className:"resource-header",children:[(0,L.jsx)("h4",{className:"resource-name",children:e.name}),(0,L.jsx)("div",{className:"resource-meta",children:(0,L.jsxs)("span",{className:"resource-date",children:["Updated ",new Date(e.updatedAt).toLocaleDateString()]})})]}),(0,L.jsx)("div",{className:"resource-content",children:(0,L.jsxs)("p",{children:[e.content.substring(0,200),e.content.length>200?"...":""]})}),(0,L.jsxs)("div",{className:"resource-actions",children:[(0,L.jsx)("button",{className:"edit-btn",onClick:S,title:"Edit resource",children:"\u270F\uFE0F"}),(0,L.jsx)("button",{className:"delete-btn",onClick:m,disabled:d,title:"Delete resource",children:d?"\u27F3":"\u{1F5D1}\uFE0F"})]})]})}),i&&(0,L.jsx)("div",{className:"resource-modal-overlay",children:(0,L.jsxs)("div",{className:"resource-modal",children:[(0,L.jsxs)("div",{className:"resource-modal-header",children:[(0,L.jsx)("h3",{children:"Edit Resource"}),(0,L.jsx)("button",{className:"modal-close-btn",onClick:x,disabled:c,children:"\u2715"})]}),(0,L.jsxs)("div",{className:"resource-modal-body",children:[(0,L.jsxs)("div",{className:"production-warning",children:[(0,L.jsx)("div",{className:"warning-icon",children:"\u26A0\uFE0F"}),(0,L.jsxs)("div",{className:"warning-text",children:[(0,L.jsx)("strong",{children:"Production Impact:"})," Changes to this resource will affect live users immediately."]})]}),(0,L.jsxs)("div",{className:"resource-form",children:[(0,L.jsxs)("div",{className:"form-field",children:[(0,L.jsx)("label",{htmlFor:"edit-resource-name",children:"Resource Name"}),(0,L.jsx)("input",{id:"edit-resource-name",type:"text",value:l,onChange:h=>s(h.target.value),placeholder:"Resource name",className:"resource-name-input",autoFocus:!0})]}),(0,L.jsxs)("div",{className:"form-field",children:[(0,L.jsx)("label",{htmlFor:"edit-resource-content",children:"Content"}),(0,L.jsx)("textarea",{id:"edit-resource-content",value:o,onChange:h=>u(h.target.value),placeholder:"Resource content",className:"resource-content-textarea",rows:12})]}),(0,L.jsxs)("div",{className:"character-count",children:[o.length," characters"]})]})]}),(0,L.jsxs)("div",{className:"resource-modal-actions",children:[(0,L.jsx)("button",{className:"cancel-button",onClick:x,disabled:c,children:"Cancel"}),(0,L.jsx)("button",{className:"create-button",onClick:k,disabled:c||!l.trim()||!o.trim(),children:c?"Saving...":"Save Changes"})]})]})})]})}});var Lt,W,Sm,LR,xm=b(()=>{"use strict";Lt=F(Je());an();W=F(re()),Sm=({apiKey:e,agentId:t})=>{let[n,a]=(0,Lt.useState)([]),[i,r]=(0,Lt.useState)(!0),[l,s]=(0,Lt.useState)(!1),[o,u]=(0,Lt.useState)(null),[c,p]=(0,Lt.useState)(null),[d,f]=(0,Lt.useState)(null),[S,x]=(0,Lt.useState)(""),[k,m]=(0,Lt.useState)(""),[h,g]=(0,Lt.useState)(!1);(0,Lt.useEffect)(()=>{C()},[]);let[E,T]=(0,Lt.useState)(!0);(0,Lt.useEffect)(()=>{if(E)return;z(null,null,function*(){console.log("Environment variables changed, auto-saving..."),s(!0),u(null),p(null);try{let J=A(n);console.log("Generated .env content:",J);let ae=yield ie.saveEnvContent(J);console.log("Save env response:",ae),ae.success?(p("Environment variables saved successfully!"),setTimeout(()=>p(null),3e3)):(console.error("Failed to save env variables:",ae.error),u(ae.error||"Failed to save environment variables"))}catch(J){console.error("Error saving env variables:",J),u("Failed to save environment variables")}finally{s(!1)}})},[n]);let N=B=>B.trim()?B.split(`
22
+ `},i)),r}var y1=b(()=>{o1();v1()});var b1=b(()=>{y1()});function Gu(e,t){return e&&"run"in e?function(n,a){return z(this,null,function*(){let i=Iu(n,K({file:a},t));yield e.run(i,a)})}:function(n,a){return Iu(n,K({file:a},e||t))}}var S1=b(()=>{b1()});var x1=b(()=>{S1()});function Wp(e){if(e)throw e}var N1=b(()=>{});var D1=Ut((cz,_1)=>{"use strict";var Xu=Object.prototype.hasOwnProperty,R1=Object.prototype.toString,E1=Object.defineProperty,k1=Object.getOwnPropertyDescriptor,T1=function(t){return typeof Array.isArray=="function"?Array.isArray(t):R1.call(t)==="[object Array]"},w1=function(t){if(!t||R1.call(t)!=="[object Object]")return!1;var n=Xu.call(t,"constructor"),a=t.constructor&&t.constructor.prototype&&Xu.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!a)return!1;var i;for(i in t);return typeof i=="undefined"||Xu.call(t,i)},A1=function(t,n){E1&&n.name==="__proto__"?E1(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},C1=function(t,n){if(n==="__proto__")if(Xu.call(t,n)){if(k1)return k1(t,n).value}else return;return t[n]};_1.exports=function e(){var t,n,a,i,r,l,s=arguments[0],o=1,u=arguments.length,c=!1;for(typeof s=="boolean"&&(c=s,s=arguments[1]||{},o=2),(s==null||typeof s!="object"&&typeof s!="function")&&(s={});o<u;++o)if(t=arguments[o],t!=null)for(n in t)a=C1(s,n),i=C1(t,n),s!==i&&(c&&i&&(w1(i)||(r=T1(i)))?(r?(r=!1,l=a&&T1(a)?a:[]):l=a&&w1(a)?a:{},A1(s,{name:n,newValue:e(c,l,i)})):typeof i!="undefined"&&A1(s,{name:n,newValue:i}));return s}});function ys(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}var O1=b(()=>{});function em(){let e=[],t={run:n,use:a};return t;function n(...i){let r=-1,l=i.pop();if(typeof l!="function")throw new TypeError("Expected function as last argument, not "+l);s(null,...i);function s(o,...u){let c=e[++r],p=-1;if(o){l(o);return}for(;++p<i.length;)(u[p]===null||u[p]===void 0)&&(u[p]=i[p]);i=u,c?L1(c,s)(...u):l(null,...u)}}function a(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function L1(e,t){let n;return a;function a(...l){let s=e.length>l.length,o;s&&l.push(i);try{o=e.apply(this,l)}catch(u){let c=u;if(s&&n)throw c;return i(c)}s||(o&&o.then&&typeof o.then=="function"?o.then(r,i):o instanceof Error?i(o):r(o))}function i(l,...s){n||(n=!0,t(l,...s))}function r(l){i(null,l)}}var z1=b(()=>{});var M1=b(()=>{z1()});function dR(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');bs(e);let n=0,a=-1,i=e.length,r;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(r){n=i+1;break}}else a<0&&(r=!0,a=i+1);return a<0?"":e.slice(n,a)}if(t===e)return"";let l=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(r){n=i+1;break}}else l<0&&(r=!0,l=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(a=i):(s=-1,a=l));return n===a?a=l:a<0&&(a=e.length),e.slice(n,a)}function pR(e){if(bs(e),e.length===0)return".";let t=-1,n=e.length,a;for(;--n;)if(e.codePointAt(n)===47){if(a){t=n;break}}else a||(a=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function mR(e){bs(e);let t=e.length,n=-1,a=0,i=-1,r=0,l;for(;t--;){let s=e.codePointAt(t);if(s===47){if(l){a=t+1;break}continue}n<0&&(l=!0,n=t+1),s===46?i<0?i=t:r!==1&&(r=1):i>-1&&(r=-1)}return i<0||n<0||r===0||r===1&&i===n-1&&i===a+1?"":e.slice(i,n)}function hR(...e){let t=-1,n;for(;++t<e.length;)bs(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":gR(n)}function gR(e){bs(e);let t=e.codePointAt(0)===47,n=vR(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function vR(e,t){let n="",a=0,i=-1,r=0,l=-1,s,o;for(;++l<=e.length;){if(l<e.length)s=e.codePointAt(l);else{if(s===47)break;s=47}if(s===47){if(!(i===l-1||r===1))if(i!==l-1&&r===2){if(n.length<2||a!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(o=n.lastIndexOf("/"),o!==n.length-1){o<0?(n="",a=0):(n=n.slice(0,o),a=n.length-1-n.lastIndexOf("/")),i=l,r=0;continue}}else if(n.length>0){n="",a=0,i=l,r=0;continue}}t&&(n=n.length>0?n+"/..":"..",a=2)}else n.length>0?n+="/"+e.slice(i+1,l):n=e.slice(i+1,l),a=l-i-1;i=l,r=0}else s===46&&r>-1?r++:r=-1}return n}function bs(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}var qn,U1=b(()=>{qn={basename:dR,dirname:pR,extname:mR,join:hR,sep:"/"}});function yR(){return"/"}var B1,V1=b(()=>{B1={cwd:yR}});function Vr(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}var tm=b(()=>{});function H1(e){if(typeof e=="string")e=new URL(e);else if(!Vr(e)){let t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){let t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return bR(e)}function bR(e){if(e.hostname!==""){let a=new TypeError('File URL host must be "localhost" or empty on darwin');throw a.code="ERR_INVALID_FILE_URL_HOST",a}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let a=t.codePointAt(n+2);if(a===70||a===102){let i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}var P1=b(()=>{tm();tm()});function am(e,t){if(e&&e.includes(qn.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+qn.sep+"`")}function im(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function q1(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function SR(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var nm,Oi,j1=b(()=>{cp();U1();V1();P1();nm=["history","path","basename","stem","extname","dirname"],Oi=class{constructor(t){let n;t?Vr(t)?n={path:t}:typeof t=="string"||SR(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":B1.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let a=-1;for(;++a<nm.length;){let r=nm[a];r in n&&n[r]!==void 0&&n[r]!==null&&(this[r]=r==="history"?[...n[r]]:n[r])}let i;for(i in n)nm.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?qn.basename(this.path):void 0}set basename(t){im(t,"basename"),am(t,"basename"),this.path=qn.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?qn.dirname(this.path):void 0}set dirname(t){q1(this.basename,"dirname"),this.path=qn.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?qn.extname(this.path):void 0}set extname(t){if(am(t,"extname"),q1(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=qn.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Vr(t)&&(t=H1(t)),im(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?qn.basename(this.path,this.extname):void 0}set stem(t){im(t,"stem"),am(t,"stem"),this.path=qn.join(this.dirname||"",t+(this.extname||""))}fail(t,n,a){let i=this.message(t,n,a);throw i.fatal=!0,i}info(t,n,a){let i=this.message(t,n,a);return i.fatal=void 0,i}message(t,n,a){let i=new st(t,n,a);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}});var rm=b(()=>{j1()});var Y1,I1=b(()=>{Y1=(function(e){let a=this.constructor.prototype,i=a[e],r=function(){return i.apply(r,arguments)};return Object.setPrototypeOf(r,a),r})});function lm(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function sm(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function om(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function G1(e){if(!ys(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function X1(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Qu(e){return NR(e)?e:new Oi(e)}function NR(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function ER(e){return typeof e=="string"||kR(e)}function kR(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var Fu,xR,um,cm,Q1=b(()=>{N1();Fu=F(D1(),1);O1();M1();rm();I1();xR={}.hasOwnProperty,um=class e extends Y1{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=em()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let a=this.attachers[n];t.use(...a)}return t.data((0,Fu.default)(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(om("data",this.frozen),this.namespace[t]=n,this):xR.call(this.namespace,t)&&this.namespace[t]||void 0:t?(om("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;let t=this;for(;++this.freezeIndex<this.attachers.length;){let[n,...a]=this.attachers[this.freezeIndex];if(a[0]===!1)continue;a[0]===!0&&(a[0]=void 0);let i=n.call(t,...a);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();let n=Qu(t),a=this.parser||this.Parser;return lm("parse",a),a(String(n),n)}process(t,n){let a=this;return this.freeze(),lm("process",this.parser||this.Parser),sm("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(r,l){let s=Qu(t),o=a.parse(s);a.run(o,s,function(c,p,d){if(c||!p||!d)return u(c);let f=p,S=a.stringify(f,d);ER(S)?d.value=S:d.result=S,u(c,d)});function u(c,p){c||!p?l(c):r?r(p):n(void 0,p)}}}processSync(t){let n=!1,a;return this.freeze(),lm("processSync",this.parser||this.Parser),sm("processSync",this.compiler||this.Compiler),this.process(t,i),X1("processSync","process",n),a;function i(r,l){n=!0,Wp(r),a=l}}run(t,n,a){G1(t),this.freeze();let i=this.transformers;return!a&&typeof n=="function"&&(a=n,n=void 0),a?r(void 0,a):new Promise(r);function r(l,s){let o=Qu(n);i.run(t,o,u);function u(c,p,d){let f=p||t;c?s(c):l?l(f):a(void 0,f,d)}}}runSync(t,n){let a=!1,i;return this.run(t,n,r),X1("runSync","run",a),i;function r(l,s){Wp(l),i=s,a=!0}}stringify(t,n){this.freeze();let a=Qu(n),i=this.compiler||this.Compiler;return sm("stringify",i),G1(t),i(t,a)}use(t,...n){let a=this.attachers,i=this.namespace;if(om("use",this.frozen),t!=null)if(typeof t=="function")o(t,n);else if(typeof t=="object")Array.isArray(t)?s(t):l(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function r(u){if(typeof u=="function")o(u,[]);else if(typeof u=="object")if(Array.isArray(u)){let[c,...p]=u;o(c,p)}else l(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function l(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");s(u.plugins),u.settings&&(i.settings=(0,Fu.default)(!0,i.settings,u.settings))}function s(u){let c=-1;if(u!=null)if(Array.isArray(u))for(;++c<u.length;){let p=u[c];r(p)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function o(u,c){let p=-1,d=-1;for(;++p<a.length;)if(a[p][0]===u){d=p;break}if(d===-1)a.push([u,...c]);else if(c.length>0){let[f,...S]=c,x=a[d][1];ys(x)&&ys(f)&&(f=(0,Fu.default)(!0,x,f)),a[d]=[u,f,...S]}}}},cm=new um().freeze()});var F1=b(()=>{Q1()});function Ss(e){let t=CR(e),n=RR(e);return _R(t.runSync(t.parse(n),n),e)}function CR(e){let t=e.rehypePlugins||Z1,n=e.remarkPlugins||Z1,a=e.remarkRehypeOptions?K(K({},e.remarkRehypeOptions),J1):J1;return cm().use(Uu).use(n).use(Gu,a).use(t)}function RR(e){let t=e.children||"",n=new Oi;return typeof t=="string"?n.value=t:(""+t,void 0),n}function _R(e,t){let n=t.allowedElements,a=t.allowElement,i=t.components,r=t.disallowedElements,l=t.skipHtml,s=t.unwrapDisallowed,o=t.urlTransform||K1;for(let c of AR)Object.hasOwn(t,c.from)&&(""+c.from+(c.to?"use `"+c.to+"` instead":"remove it")+TR+c.id,void 0);return n&&r&&void 0,vs(e,u),dp(e,{Fragment:Hr.Fragment,components:i,ignoreInvalidStyle:!0,jsx:Hr.jsx,jsxs:Hr.jsxs,passKeys:!0,passNode:!0});function u(c,p,d){if(c.type==="raw"&&d&&typeof p=="number")return l?d.children.splice(p,1):d.children[p]={type:"text",value:c.value},p;if(c.type==="element"){let f;for(f in us)if(Object.hasOwn(us,f)&&Object.hasOwn(c.properties,f)){let S=c.properties[f],x=us[f];(x===null||x.includes(c.tagName))&&(c.properties[f]=o(String(S||""),f,c))}}if(c.type==="element"){let f=n?!n.includes(c.tagName):r?r.includes(c.tagName):!1;if(!f&&a&&typeof p=="number"&&(f=!a(c,p,d)),f&&d&&typeof p=="number")return s&&c.children?d.children.splice(p,1,...c.children):d.children.splice(p,1),p}}}function K1(e){let t=e.indexOf(":"),n=e.indexOf("?"),a=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||a!==-1&&t>a||wR.test(e.slice(0,t))?e:""}var Hr,$1,TR,Z1,J1,wR,AR,W1=b(()=>{B0();H0();Hr=F(re(),1),$1=F(Je(),1);tx();x1();F1();$p();rm();TR="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Z1=[],J1={allowDangerousHtml:!0},wR=/^(https?|ircs?|mailto|xmpp)$/i,AR=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}]});var fm=b(()=>{W1()});var Pe,xe,dm,ie,an=b(()=>{"use strict";Pe={LUA_API:"https://api.heylua.ai",DEV_SERVER:"https://api.heylua.ai",LOCAL_DEV:""},xe={CHAT_GENERATE:e=>`${Pe.LUA_API}/chat/generate/${e}?channel=dev`,TOOLS_TEST:e=>`${Pe.LUA_API}/tools/test/${e}`,CHAT_HISTORY:e=>`${Pe.LUA_API}/chat/history/${e}`,AGENT_TYPES:`${Pe.LUA_API}/agents/self-serve/types`,CREATE_AGENT:`${Pe.LUA_API}/agents/self-serve/create`,AGENT_DETAILS:e=>`${Pe.LUA_API}/admin/agents/${e}`,SKILL_VERSIONS:(e,t)=>`${Pe.DEV_SERVER}/developer/skills/${e}/${t}/versions`,PERSONA_VERSIONS:e=>`${Pe.LUA_API}/developer/agents/${e}/persona/versions`,DEPLOY_PERSONA_VERSION:(e,t)=>`${Pe.LUA_API}/developer/agents/${e}/persona/version/${t}`,AGENT_RESOURCES:e=>`${Pe.LUA_API}/admin/agents/${e}/resources`,AGENT_RESOURCE:(e,t)=>`${Pe.LUA_API}/admin/agents/${e}/resources/${t}`,AGENT_SKILLS:e=>`${Pe.LUA_API}/developer/skills/${e}`,ACTIVATE_SKILL:(e,t)=>`${Pe.LUA_API}/developer/skills/${e}/${t}`,PUBLISH_SKILL_VERSION:(e,t,n)=>`${Pe.LUA_API}/developer/skills/${e}/${t}/${n}/publish`,PRODUCTION_LOGS:e=>`${Pe.LUA_API}/developer/agents/${e}/logs`,PRODUCTION_ENV:e=>`${Pe.LUA_API}/developer/agents/${e}/env`,CREATE_SKILL:e=>`${Pe.DEV_SERVER}/developer/skills/${e}`,DEVELOPER_LOGS:(e,t)=>`${Pe.DEV_SERVER}/developer/skills/${e}/${t}/logs`,USER_DATA:e=>`${Pe.DEV_SERVER}/developer/user/data/agent/${e}`,LOCAL_CHAT:`${Pe.LOCAL_DEV}/chat`,LOCAL_PERSONA:`${Pe.LOCAL_DEV}/persona`,LOCAL_TOOLS:`${Pe.LOCAL_DEV}/tools`,LOCAL_TOOLS_TEST:`${Pe.LOCAL_DEV}/tools/test`,LOCAL_ENV:`${Pe.LOCAL_DEV}/env`},dm=class{constructor(t=""){this.baseUrl=t}getAllSkillOverrides(){return z(this,null,function*(){try{let n=yield(yield fetch("/api/skills")).json();return n.success&&n.skills&&Array.isArray(n.skills)?n.skills.map(a=>({skillId:a.skillId,sandboxId:a.sandboxId||a.skillId})).filter(a=>a.skillId&&a.sandboxId):[]}catch(t){return console.error("Error getting skill overrides:",t),[]}})}sendChatMessage(t,n,a,i,r,l){return z(this,null,function*(){try{let s=yield this.getAllSkillOverrides(),o=s.length>0?s:[{skillId:a,sandboxId:i}],u=K({messages:[{type:"text",text:t}],navigate:!0,skillOverride:o},l&&{personaOverride:l}),c=yield fetch(xe.CHAT_GENERATE(n),{method:"POST",headers:{"Content-Type":"application/json",Authorization:r},body:JSON.stringify(u)});if(!c.ok)throw new Error(`HTTP error! status: ${c.status}`);return{success:!0,text:(yield c.json()).text||"No response received"}}catch(s){return console.error("Chat API error:",s),{success:!1,error:s instanceof Error?s.message:"Unknown error occurred"}}})}sendProductionChatMessage(t,n,a){return z(this,null,function*(){try{let i={messages:[{type:"text",text:t}],navigate:!0,skillOverride:[]},r=yield fetch(xe.CHAT_GENERATE(n),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(i)});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return{success:!0,text:(yield r.json()).text||"No response received"}}catch(i){return console.error("Production chat API error:",i),{success:!1,error:i instanceof Error?i.message:"Unknown error occurred"}}})}sendLocalChatMessage(t,n){return z(this,null,function*(){try{let a=yield fetch(xe.LOCAL_CHAT,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:t,persona:n})});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return yield a.json()}catch(a){return console.error("Local chat API error:",a),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}})}loadPersona(){return z(this,null,function*(){try{let t=yield fetch(xe.LOCAL_PERSONA);if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return yield t.json()}catch(t){return console.error("Load persona error:",t),{success:!1,error:t instanceof Error?t.message:"Failed to load persona"}}})}savePersona(t){return z(this,null,function*(){try{let n=yield fetch(xe.LOCAL_PERSONA,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({persona:t})});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return yield n.json()}catch(n){return console.error("Save persona error:",n),{success:!1,error:n instanceof Error?n.message:"Failed to save persona"}}})}loadTools(){return z(this,null,function*(){try{let t=yield fetch(xe.LOCAL_TOOLS);if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return yield t.json()}catch(t){return console.error("Load tools error:",t),{success:!1,error:t instanceof Error?t.message:"Failed to load tools"}}})}testTool(t,n,a,i,r,l){return z(this,null,function*(){try{let s={toolName:t,inputs:n,skillOverride:[{skillId:i,sandboxId:r}]},o=yield fetch(xe.TOOLS_TEST(a),{method:"POST",headers:{"Content-Type":"application/json",Authorization:l},body:JSON.stringify(s)});if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);let u=yield o.json();return{success:!0,result:u.result||u}}catch(s){return console.error("Tool test error:",s),{success:!1,error:s instanceof Error?s.message:"Unknown error occurred"}}})}getSkillVersions(t,n,a){return z(this,null,function*(){try{let i=yield fetch(xe.SKILL_VERSIONS(n,t),{method:"GET",headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json"}});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);return{success:!0,versions:(yield i.json()).versions||[]}}catch(i){return console.error("Error fetching skill versions:",i),{success:!1,error:i instanceof Error?i.message:"Unknown error occurred"}}})}getPersonaVersions(t,n){return z(this,null,function*(){try{let a=yield fetch(`${Pe.DEV_SERVER}/developer/agents/${t}/persona/versions`,{method:"GET",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"}});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return{success:!0,versions:(yield a.json()).versions||[]}}catch(a){return console.error("Error fetching persona versions:",a),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}})}getProductionPersonaVersions(t,n){return z(this,null,function*(){try{let a=yield fetch(xe.PERSONA_VERSIONS(t),{method:"GET",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"}});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return{success:!0,versions:(yield a.json()).versions||[]}}catch(a){return console.error("Error fetching production persona versions:",a),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}})}deployPersonaVersion(t,n,a){return z(this,null,function*(){try{let i=yield fetch(xe.DEPLOY_PERSONA_VERSION(t,a),{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify({})});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);return{success:!0,data:yield i.json()}}catch(i){return console.error("Error deploying persona version:",i),{success:!1,error:i instanceof Error?i.message:"Unknown error occurred"}}})}createPersonaVersion(t,n,a){return z(this,null,function*(){try{let i=yield fetch(`${Pe.DEV_SERVER}/developer/agents/${t}/persona/version`,{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify({persona:a})});if(!i.ok){let l=yield i.text();throw new Error(`HTTP error! status: ${i.status}, message: ${l}`)}return{success:!0,data:yield i.json()}}catch(i){return console.error("Error creating persona version:",i),{success:!1,error:i instanceof Error?i.message:"Unknown error occurred"}}})}createSkillVersion(t,n,a,i){return z(this,null,function*(){try{let r=yield fetch(`${Pe.DEV_SERVER}/developer/skills/${n}/${t}/version`,{method:"POST",headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json"},body:JSON.stringify(i)});if(!r.ok){let s=yield r.text();throw new Error(`HTTP error! status: ${r.status}, message: ${s}`)}return{success:!0,data:yield r.json()}}catch(r){return console.error("Error creating skill version:",r),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}})}loadEnvContent(){return z(this,null,function*(){try{let t=yield fetch(xe.LOCAL_ENV);if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return yield t.json()}catch(t){return console.error("Load env error:",t),{success:!1,error:t instanceof Error?t.message:"Failed to load environment variables"}}})}saveEnvContent(t){return z(this,null,function*(){try{let n=yield fetch(xe.LOCAL_ENV,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t})});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return yield n.json()}catch(n){return console.error("Save env error:",n),{success:!1,error:n instanceof Error?n.message:"Failed to save environment variables"}}})}testLocalTool(t,n){return z(this,null,function*(){try{let a=yield fetch(xe.LOCAL_TOOLS_TEST,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({toolName:t,inputs:n})});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return yield a.json()}catch(a){return console.error("Local tool test error:",a),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}})}loadChatHistory(t,n){return z(this,null,function*(){try{console.log("ApiService: Loading chat history with API key:",t,"agentId:",n);let a=yield fetch(xe.CHAT_HISTORY(n),{method:"GET",headers:{accept:"*/*",Authorization:`Bearer ${t}`}});if(console.log("ApiService: Response status:",a.status),console.log("ApiService: Response headers:",a.headers),!a.ok){let r=yield a.text();throw console.error("ApiService: HTTP error response:",r),new Error(`HTTP error! status: ${a.status}`)}let i=yield a.json();return console.log("ApiService: Received data:",i),{success:!0,data:i}}catch(a){return console.error("ApiService: Chat history load error:",a),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}})}clearChatHistory(t,n){return z(this,null,function*(){try{console.log("ApiService: Clearing chat history with API key:",t,"agentId:",n);let a=yield fetch(xe.CHAT_HISTORY(n),{method:"DELETE",headers:{accept:"*/*",Authorization:`Bearer ${t}`}});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return{success:!0}}catch(a){return console.error("Clear chat history error:",a),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}})}clearSandboxLogs(t,n,a){return z(this,null,function*(){try{console.log("ApiService: Clearing sandbox logs with API key:",t,"agentId:",n,"sandboxId:",a);let i=yield fetch(xe.DEVELOPER_LOGS(n,a),{method:"DELETE",headers:{accept:"application/json",Authorization:`Bearer ${t}`}});if(console.log("ApiService: Clear logs response status:",i.status),!i.ok){let l=yield i.text();throw console.error("ApiService: HTTP error response:",l),new Error(`HTTP error! status: ${i.status}`)}let r=yield i.json();return console.log("ApiService: Clear logs response:",r),{success:!0,data:r}}catch(i){return console.error("ApiService: Clear sandbox logs error:",i),{success:!1,error:i instanceof Error?i.message:"Unknown error occurred"}}})}loadAllSandboxLogs(t,n,a=20){return z(this,null,function*(){try{let i=yield this.getAllSkillOverrides();if(i.length===0)return{success:!0,data:{logs:[]}};let r=i.map(o=>z(this,null,function*(){try{let u=yield this.loadSandboxLogs(t,n,o.sandboxId,a);return u.success&&u.data&&u.data.logs?u.data.logs.map(c=>ut(K({},c),{skillName:o.skillId,sandboxId:o.sandboxId})):[]}catch(u){return console.error(`Error loading logs for skill ${o.skillId}:`,u),[]}}));return{success:!0,data:{logs:(yield Promise.all(r)).flat().sort((o,u)=>new Date(u.timestamp).getTime()-new Date(o.timestamp).getTime()).slice(0,a)}}}catch(i){return console.error("Error loading all sandbox logs:",i),{success:!1,error:i instanceof Error?i.message:"Unknown error occurred",data:{logs:[]}}}})}loadSandboxLogs(t,n,a,i=20){return z(this,null,function*(){try{console.log("ApiService: Loading sandbox logs with API key:",t,"agentId:",n,"sandboxId:",a);let r=yield fetch(`${xe.DEVELOPER_LOGS(n,a)}?limit=${i}`,{method:"GET",headers:{accept:"application/json",Authorization:`Bearer ${t}`}});if(console.log("ApiService: Logs response status:",r.status),!r.ok){let s=yield r.text();throw console.error("ApiService: HTTP error response:",s),new Error(`HTTP error! status: ${r.status}`)}let l=yield r.json();return console.log("ApiService: Received logs data:",l),{success:!0,data:l}}catch(r){return console.error("ApiService: Sandbox logs load error:",r),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}})}loadUserData(t,n){return z(this,null,function*(){try{console.log("ApiService: Loading user data with API key:",t,"agentId:",n),console.log("ApiService: API key length:",t==null?void 0:t.length),console.log("ApiService: API key starts with:",t==null?void 0:t.substring(0,10));let a=yield fetch(xe.USER_DATA(n),{method:"GET",headers:{accept:"*/*",Authorization:`Bearer ${t}`}});if(console.log("ApiService: User data response status:",a.status),console.log("ApiService: Response headers:",Object.fromEntries(a.headers.entries())),!a.ok){let r=yield a.text();if(console.error("ApiService: HTTP error response:",r),a.status===401){console.log("ApiService: Trying alternative authentication method...");let l=yield fetch(xe.USER_DATA(n),{method:"GET",headers:{accept:"*/*",Authorization:t}});if(l.ok){let s=yield l.json();return console.log("ApiService: Alternative auth successful:",s),{success:!0,data:s}}}throw new Error(`HTTP error! status: ${a.status}`)}let i=yield a.json();return console.log("ApiService: Received user data:",i),{success:!0,data:i}}catch(a){return console.error("ApiService: User data load error:",a),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}})}saveUserData(t,n,a){return z(this,null,function*(){return this.updateUserData(t,n,a)})}getUserData(t,n){return z(this,null,function*(){return this.loadUserData(t,n)})}updateUserData(t,n,a){return z(this,null,function*(){try{console.log("ApiService: Updating user data with API key:",t,"agentId:",n,"data:",a);let i=yield fetch(xe.USER_DATA(n),{method:"PUT",headers:{accept:"*/*",Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify(a)});if(console.log("ApiService: Update user data response status:",i.status),!i.ok){let l=yield i.text();throw console.error("ApiService: HTTP error response:",l),new Error(`HTTP error! status: ${i.status}`)}let r=yield i.json();return console.log("ApiService: Updated user data response:",r),{success:!0,data:r}}catch(i){return console.error("ApiService: Update user data error:",i),{success:!1,error:i instanceof Error?i.message:"Unknown error occurred"}}})}loadResources(t,n){return z(this,null,function*(){try{console.log("ApiService: Loading resources with API key:",t,"agentId:",n);let a=yield fetch(xe.AGENT_RESOURCES(n),{method:"GET",headers:{accept:"application/json",Authorization:`Bearer ${t}`}});if(console.log("ApiService: Resources response status:",a.status),!a.ok)throw new Error(`HTTP error! status: ${a.status}`);let i=yield a.json();return console.log("ApiService: Resources data:",i),{success:!0,data:i||[]}}catch(a){return console.error("ApiService: Error loading resources:",a),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}})}createResource(t,n,a){return z(this,null,function*(){try{let i=yield fetch(xe.AGENT_RESOURCES(n),{method:"POST",headers:{accept:"application/json",Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify(a)});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);return{success:!0,data:yield i.json()}}catch(i){return console.error("Error creating resource:",i),{success:!1,error:i instanceof Error?i.message:"Unknown error occurred"}}})}updateResource(t,n,a,i){return z(this,null,function*(){try{let r=yield fetch(xe.AGENT_RESOURCE(n,a),{method:"PUT",headers:{accept:"application/json",Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify(i)});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return{success:!0,data:yield r.json()}}catch(r){return console.error("Error updating resource:",r),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}})}deleteResource(t,n,a){return z(this,null,function*(){try{let i=yield fetch(xe.AGENT_RESOURCE(n,a),{method:"DELETE",headers:{accept:"*/*",Authorization:`Bearer ${t}`}});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);return{success:!0}}catch(i){return console.error("Error deleting resource:",i),{success:!1,error:i instanceof Error?i.message:"Unknown error occurred"}}})}clearUserData(t,n){return z(this,null,function*(){try{console.log("ApiService: Clearing user data with API key:",t,"agentId:",n);let a=yield fetch(xe.USER_DATA(n),{method:"DELETE",headers:{accept:"*/*",Authorization:`Bearer ${t}`}});if(console.log("ApiService: Clear user data response status:",a.status),!a.ok){let r=yield a.text();throw console.error("ApiService: HTTP error response:",r),new Error(`HTTP error! status: ${a.status}`)}let i=yield a.json();return console.log("ApiService: Clear user data response:",i),{success:!0,data:i}}catch(a){return console.error("ApiService: Clear user data error:",a),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}})}createSkill(t,n,a){return z(this,null,function*(){try{let i=yield fetch(xe.CREATE_SKILL(n),{method:"POST",headers:{accept:"application/json",Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify({name:a.name,description:a.description||`A Lua skill for ${a.name}`,context:a.context||""})});if(!i.ok){let l=yield i.text();return{success:!1,error:{message:`HTTP ${i.status}: ${l}`}}}return{success:!0,data:yield i.json()}}catch(i){return{success:!1,error:{message:i instanceof Error?i.message:"Unknown error"}}}})}getAgentTypes(t){return z(this,null,function*(){try{let n=yield fetch(xe.AGENT_TYPES,{method:"GET",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"}});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return yield n.json()}catch(n){return console.error("Error fetching agent types:",n),[]}})}createAgent(t,n){return z(this,null,function*(){try{let a=yield fetch(xe.CREATE_AGENT,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify(n)});return a.ok?{success:!0,data:yield a.json()}:{success:!1,error:yield a.json()}}catch(a){return{success:!1,error:{message:a instanceof Error?a.message:"Unknown error"}}}})}getAgentDetails(t,n){return z(this,null,function*(){try{let a=yield fetch(xe.AGENT_DETAILS(n),{method:"GET",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"}});return a.ok?{success:!0,data:yield a.json()}:{success:!1,error:yield a.json()}}catch(a){return{success:!1,error:{message:a instanceof Error?a.message:"Unknown error"}}}})}getSkills(t,n){return z(this,null,function*(){try{console.log("ApiService: Loading skills with API key:",t,"agentId:",n);let a=yield fetch(xe.AGENT_SKILLS(n),{method:"GET",headers:{accept:"application/json",Authorization:`Bearer ${t}`}});if(console.log("ApiService: Skills response status:",a.status),!a.ok){let r=yield a.text();throw console.error("ApiService: HTTP error response:",r),new Error(`HTTP error! status: ${a.status}`)}let i=yield a.json();return console.log("ApiService: Received skills data:",i),{success:!0,skills:i.skills||[]}}catch(a){return console.error("ApiService: Skills load error:",a),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}})}activateSkill(t,n,a,i){return z(this,null,function*(){try{console.log(`ApiService: ${i?"Activating":"Deactivating"} skill:`,a,"for agent:",n);let r=yield fetch(xe.ACTIVATE_SKILL(n,a),{method:"PUT",headers:{accept:"application/json",Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify({active:i})});if(console.log("ApiService: Activate skill response status:",r.status),!r.ok){let s=yield r.text();throw console.error("ApiService: HTTP error response:",s),new Error(`HTTP error! status: ${r.status}`)}let l=yield r.json();return console.log("ApiService: Activate skill response:",l),{success:!0,data:l}}catch(r){return console.error("ApiService: Activate skill error:",r),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}})}publishSkillVersion(t,n,a,i){return z(this,null,function*(){try{console.log("ApiService: Publishing skill version:",i,"for skill:",a,"agent:",n);let r=yield fetch(xe.PUBLISH_SKILL_VERSION(n,a,i),{method:"PUT",headers:{accept:"application/json",Authorization:`Bearer ${t}`}});if(console.log("ApiService: Publish skill version response status:",r.status),!r.ok){let s=yield r.text();throw console.error("ApiService: HTTP error response:",s),new Error(`HTTP error! status: ${r.status}`)}let l=yield r.json();return console.log("ApiService: Publish skill version response:",l),{success:!0,data:l}}catch(r){return console.error("ApiService: Publish skill version error:",r),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}})}loadProductionLogs(t,n,a=1,i=100){return z(this,null,function*(){try{console.log("ApiService: Loading production logs with API key:",t,"agentId:",n,"page:",a,"limit:",i);let r=yield fetch(`${xe.PRODUCTION_LOGS(n)}?page=${a}&limit=${i}`,{method:"GET",headers:{accept:"application/json",Authorization:`Bearer ${t}`}});if(console.log("ApiService: Production logs response status:",r.status),!r.ok){let s=yield r.text();throw console.error("ApiService: HTTP error response:",s),new Error(`HTTP error! status: ${r.status}`)}let l=yield r.json();return console.log("ApiService: Production logs response:",l),{success:!0,logs:l.logs||[],pagination:l.pagination}}catch(r){return console.error("ApiService: Production logs error:",r),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}})}loadProductionEnv(t,n){return z(this,null,function*(){try{console.log("ApiService: Loading production env with API key:",t,"agentId:",n);let a=yield fetch(xe.PRODUCTION_ENV(n),{method:"GET",headers:{accept:"application/json",Authorization:`Bearer ${t}`}});if(console.log("ApiService: Production env response status:",a.status),!a.ok){let r=yield a.text();throw console.error("ApiService: HTTP error response:",r),new Error(`HTTP error! status: ${a.status}`)}let i=yield a.json();return console.log("ApiService: Production env response:",i),{success:!0,data:i}}catch(a){return console.error("ApiService: Production env error:",a),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}})}updateProductionEnv(t,n,a){return z(this,null,function*(){try{console.log("ApiService: Updating production env with API key:",t,"agentId:",n,"data:",a);let i=yield fetch(xe.PRODUCTION_ENV(n),{method:"POST",headers:{accept:"application/json",Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify(a)});if(console.log("ApiService: Update production env response status:",i.status),!i.ok){let l=yield i.text();throw console.error("ApiService: HTTP error response:",l),new Error(`HTTP error! status: ${i.status}`)}let r=yield i.json();return console.log("ApiService: Update production env response:",r),{success:!0,data:r}}catch(i){return console.error("ApiService: Update production env error:",i),{success:!1,error:i instanceof Error?i.message:"Unknown error occurred"}}})}},ie=new dm});var Pr,dt,pm,eN=b(()=>{"use strict";Pr=F(Je());fm();an();dt=F(re()),pm=({apiKey:e,agentId:t,skillId:n,sandboxId:a,persona:i,sharedChatMessages:r,onSharedSendMessage:l,onSharedClearHistory:s,isChatLoading:o,setIsChatLoading:u})=>{let[c,p]=(0,Pr.useState)(""),d=(0,Pr.useRef)(null),f=()=>{var h;(h=d.current)==null||h.scrollIntoView({behavior:"smooth"})};(0,Pr.useEffect)(()=>{f()},[r]);let S=r.length>0?r.map(h=>({text:h.text,isUser:h.sender==="user",timestamp:h.timestamp})):[{text:"\u{1F44B} Welcome! Start chatting to test your Lua skill. Your messages will be sent to the sandbox environment.",isUser:!1,timestamp:new Date}],x=h=>z(null,null,function*(){if(!h.trim())return;let g={id:Date.now().toString(),text:h,sender:"user",timestamp:new Date};l(g),p(""),u(!0);try{let E=yield ie.sendLocalChatMessage(h,i),T={id:(Date.now()+1).toString(),text:E.success?E.text||"No response received":`\u274C ${E.error||"Failed to send message"}`,sender:"assistant",timestamp:new Date};l(T)}catch(E){let T={id:(Date.now()+2).toString(),text:`\u274C Error: ${E instanceof Error?E.message:"Unknown error"}`,sender:"assistant",timestamp:new Date};l(T)}finally{u(!1)}}),k=h=>{h.preventDefault(),x(c)},m=h=>{h.key==="Enter"&&!h.shiftKey&&(h.preventDefault(),x(c))};return(0,dt.jsxs)("div",{className:"chat-container",children:[(0,dt.jsxs)("div",{className:"chat-header",children:[(0,dt.jsx)("div",{className:"chat-header-content",children:(0,dt.jsxs)("div",{children:[(0,dt.jsx)("h1",{children:"Chat to your Agent [Sandbox]"}),(0,dt.jsx)("p",{children:"Test your sandbox skill in real-time"})]})}),(0,dt.jsx)("button",{className:"clear-chat-button",onClick:s,disabled:o,title:"Clear chat history",children:"\u{1F5D1}\uFE0F"})]}),(0,dt.jsxs)("div",{className:"chat-messages",children:[S.map((h,g)=>(0,dt.jsx)("div",{className:`message ${h.isUser?"user":"assistant"}`,children:(0,dt.jsx)("div",{className:"message-bubble",children:(0,dt.jsx)(Ss,{children:h.text})})},g)),o&&(0,dt.jsx)("div",{className:"loading",children:(0,dt.jsx)("img",{src:"https://admin.heylua.ai/images/logo.svg",alt:"Loading",className:"loading-logo"})}),(0,dt.jsx)("div",{ref:d})]}),(0,dt.jsx)("div",{className:"chat-input-container",children:(0,dt.jsxs)("form",{className:"chat-input-form",onSubmit:k,children:[(0,dt.jsx)("input",{type:"text",id:"chat-input",name:"chatMessage",className:"chat-input",value:c,onChange:h=>p(h.target.value),onKeyDown:m,placeholder:"Type your message...",disabled:o,autoComplete:"off"}),(0,dt.jsx)("button",{type:"submit",className:"send-button",disabled:o||!c.trim(),children:"Send"})]})})]})}});var Mn,Z,mm,hm=b(()=>{"use strict";Mn=F(Je());an();Z=F(re()),mm=({persona:e,onSavePersona:t,apiKey:n,agentId:a})=>{let[i,r]=(0,Mn.useState)(e),[l,s]=(0,Mn.useState)(!1),[o,u]=(0,Mn.useState)([]),[c,p]=(0,Mn.useState)(!1),[d,f]=(0,Mn.useState)("current"),[S,x]=(0,Mn.useState)(null),[k,m]=(0,Mn.useState)(!1),[h,g]=(0,Mn.useState)(!1);(0,Mn.useEffect)(()=>{r(e)},[e]),(0,Mn.useEffect)(()=>{E()},[]);let E=()=>z(null,null,function*(){p(!0);try{let R=yield ie.getPersonaVersions(a,n);if(R.success&&R.versions){let O=R.versions.sort((I,B)=>B.createdDate-I.createdDate);u(O)}else console.error("Failed to load persona versions:",R.error),u([])}catch(R){console.error("Error loading persona versions:",R),u([])}finally{p(!1)}}),T=R=>{f(R),S&&x(null)},N=R=>{x(R)},A=()=>{x(null)},C=()=>{if(!i.trim()){alert("Please enter a persona before creating a version");return}g(!0)},U=()=>z(null,null,function*(){m(!0);try{let R=yield ie.createPersonaVersion(a,n,i.trim());if(R.success)console.log("\u2705 Persona version created successfully:",R.data),yield E(),f("versions"),alert("\u2705 Persona version created successfully! You can deploy it from the Production tab.");else throw new Error(R.error||"Failed to create persona version")}catch(R){console.error("\u274C Error creating persona version:",R),alert(`\u274C Failed to create persona version: ${R instanceof Error?R.message:"Unknown error"}`)}finally{m(!1),g(!1)}}),P=()=>{g(!1)},_=()=>z(null,null,function*(){let R=i.trim();if(!R){alert("Persona cannot be empty");return}s(!0);try{(yield t(R))&&r(R)}finally{s(!1)}});return S?(0,Z.jsxs)("div",{className:"persona-section",children:[(0,Z.jsx)("div",{className:"persona-header",children:(0,Z.jsxs)("div",{className:"header-left",children:[(0,Z.jsx)("button",{className:"back-button",onClick:A,children:"\u2190"}),(0,Z.jsxs)("h3",{children:["Persona v",S.version]})]})}),(0,Z.jsxs)("div",{className:"persona-version-details",children:[(0,Z.jsx)("div",{className:"version-metadata",children:(0,Z.jsxs)("div",{className:"metadata-grid",children:[(0,Z.jsxs)("div",{className:"metadata-item",children:[(0,Z.jsx)("span",{className:"metadata-label",children:"Created By"}),(0,Z.jsx)("span",{className:"metadata-value",children:S.createdBy})]}),(0,Z.jsxs)("div",{className:"metadata-item",children:[(0,Z.jsx)("span",{className:"metadata-label",children:"Status"}),(0,Z.jsx)("span",{className:`version-status ${S.isCurrent?"active":"available"}`,children:S.isCurrent?"Active (Deployed)":"Available"})]}),(0,Z.jsxs)("div",{className:"metadata-item",children:[(0,Z.jsx)("span",{className:"metadata-label",children:"Created Date"}),(0,Z.jsx)("span",{className:"metadata-value",children:new Date(S.createdDate).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"})})]})]})}),(0,Z.jsxs)("div",{className:"persona-content",children:[(0,Z.jsx)("h4",{children:"Persona Content"}),(0,Z.jsx)("div",{className:"persona-display",children:(0,Z.jsx)("pre",{children:S.persona})})]})]})]}):(0,Z.jsxs)("div",{className:"persona-section",children:[(0,Z.jsx)("div",{className:"persona-header",children:(0,Z.jsx)("h3",{children:"Agent Persona"})}),(0,Z.jsxs)("div",{className:"persona-tabs",children:[(0,Z.jsxs)("div",{className:"tabs-header",children:[(0,Z.jsx)("button",{className:`tab-button ${d==="current"?"active":""}`,onClick:()=>T("current"),children:"Current"}),(0,Z.jsxs)("button",{className:`tab-button ${d==="versions"?"active":""}`,onClick:()=>T("versions"),children:["Versions (",o.length,")"]})]}),(0,Z.jsx)("div",{className:"tab-content",children:d==="current"?(0,Z.jsxs)("div",{className:"current-persona-tab",children:[(0,Z.jsxs)("div",{className:"persona-edit-header",children:[(0,Z.jsx)("h4",{children:"Edit Current Persona"}),(0,Z.jsxs)("div",{className:"persona-actions",children:[(0,Z.jsx)("button",{className:"save-btn",onClick:_,disabled:l,title:"Save persona to YAML",children:l?"\u27F3":"\u{1F4BE}"}),(0,Z.jsx)("button",{className:"create-version-btn",onClick:C,disabled:k||!i.trim(),title:"Create new persona version",children:k?"Creating...":"Create Version"})]})]}),(0,Z.jsx)("div",{className:"persona-edit",children:(0,Z.jsx)("textarea",{value:i,onChange:R=>r(R.target.value),placeholder:"Enter agent persona...",className:"persona-textarea"})}),(0,Z.jsx)("div",{className:"persona-help",children:(0,Z.jsxs)("p",{children:["This persona is stored in your ",(0,Z.jsx)("code",{children:"lua.skill.yaml"})," file and used for local development."]})})]}):(0,Z.jsx)("div",{className:"versions-persona-tab",children:c?(0,Z.jsx)("div",{className:"versions-loading",children:(0,Z.jsx)("img",{src:"https://admin.heylua.ai/images/logo.svg",alt:"Loading",className:"loading-logo"})}):o.length>0?(0,Z.jsx)("div",{className:"versions-list",children:o.map((R,O)=>(0,Z.jsxs)("div",{className:`version-item ${R.isCurrent?"active":"available"}`,onClick:()=>N(R),children:[(0,Z.jsxs)("div",{className:"version-info",children:[(0,Z.jsxs)("div",{className:"version-header",children:[(0,Z.jsxs)("span",{className:"version-number",children:["v",R.version]}),(0,Z.jsx)("span",{className:`version-status ${R.isCurrent?"active":"available"}`,children:R.isCurrent?"Active":"Available"})]}),(0,Z.jsx)("div",{className:"version-date",children:new Date(R.createdDate).toLocaleDateString()})]}),(0,Z.jsx)("div",{className:"version-arrow",children:"\u2192"})]},O))}):(0,Z.jsxs)("div",{className:"no-versions",children:[(0,Z.jsx)("div",{className:"no-versions-icon",children:"\u{1F464}"}),(0,Z.jsx)("div",{className:"no-versions-text",children:"No persona versions found"}),(0,Z.jsx)("div",{className:"no-versions-subtext",children:"Persona versions will appear here when available"})]})})})]}),h&&(0,Z.jsx)("div",{className:"version-modal-overlay",children:(0,Z.jsxs)("div",{className:"version-modal",children:[(0,Z.jsx)("div",{className:"version-modal-header",children:(0,Z.jsx)("h3",{children:"Create Persona Version"})}),(0,Z.jsxs)("div",{className:"version-modal-body",children:[(0,Z.jsx)("p",{children:"This will create a new persona version that can be deployed to production."}),(0,Z.jsxs)("p",{children:[(0,Z.jsx)("strong",{children:"Note:"})," The version will be created but not automatically released. You can deploy it from the Production tab."]}),(0,Z.jsxs)("div",{className:"persona-preview-box",children:[(0,Z.jsx)("h4",{children:"Persona Content:"}),(0,Z.jsxs)("div",{className:"persona-preview-content",children:[i.substring(0,300),i.length>300?"...":""]})]})]}),(0,Z.jsxs)("div",{className:"version-modal-actions",children:[(0,Z.jsx)("button",{className:"cancel-button",onClick:P,disabled:k,children:"Cancel"}),(0,Z.jsx)("button",{className:"create-button",onClick:U,disabled:k,children:k?"Creating...":"Create Version"})]})]})})]})}});var Tt,w,gm,vm=b(()=>{"use strict";Tt=F(Je());an();w=F(re()),gm=({apiKey:e,agentId:t,skillId:n,sandboxId:a})=>{var Zr;let[i,r]=(0,Tt.useState)([]),[l,s]=(0,Tt.useState)(null),[o,u]=(0,Tt.useState)(null),[c,p]=(0,Tt.useState)([]),[d,f]=(0,Tt.useState)(!1),[S,x]=(0,Tt.useState)("current"),[k,m]=(0,Tt.useState)(!1),[h,g]=(0,Tt.useState)(!1),[E,T]=(0,Tt.useState)(""),[N,A]=(0,Tt.useState)({}),[C,U]=(0,Tt.useState)(null),[P,_]=(0,Tt.useState)(!0),[R,O]=(0,Tt.useState)(!1),[I,B]=(0,Tt.useState)(null),[J,ae]=(0,Tt.useState)([]);(0,Tt.useEffect)(()=>{we(),je()},[]);let we=()=>z(null,null,function*(){_(!0),B(null);try{console.log("Loading skills from /api/skills...");let q=yield fetch("/api/skills");if(console.log("Skills API response status:",q.status),!q.ok)throw new Error(`HTTP ${q.status}: ${q.statusText}`);let j=yield q.json();console.log("Skills API response data:",j),j.success&&j.skills&&Array.isArray(j.skills)?(console.log("Skills loaded successfully:",j.skills),r(j.skills),B(null)):(console.error("Failed to load skills:",j.error),B(j.error||"Failed to load skills - invalid data format"),r([]))}catch(q){console.error("Error loading skills:",q),B(q instanceof Error?q.message:"Failed to load skills"),r([])}finally{_(!1)}}),je=()=>z(null,null,function*(){try{let j=yield(yield fetch("/tools")).json();if(j.success&&j.tools){let le=[];Array.isArray(j.tools)?le=j.tools:typeof j.tools=="object"&&(le=Object.entries(j.tools).map(([Be,Mt])=>K({name:Be},Mt))),ae(le)}else console.error("Failed to load tools:",j.error),ae([])}catch(q){console.error("Error loading tools:",q),ae([])}}),v=q=>{let j={};q.inputSchema.properties&&Object.keys(q.inputSchema.properties).forEach(le=>{let Be=q.inputSchema.properties[le];j[le]=Me(Be)}),A(j)},Me=q=>{if(q.type==="object"&&q.properties){let j={};return Object.keys(q.properties).forEach(le=>{j[le]=Me(q.properties[le])}),j}else return q.type==="number"?0:q.type==="boolean"?!1:""},pt=q=>{let j=J.find(le=>le.name===q);j&&(u(j),v(j),U(null))},y=q=>z(null,null,function*(){f(!0);try{let j=yield ie.getSkillVersions(q.skillId,t,e);if(j.success&&j.versions){let le=j.versions.sort((Be,Mt)=>new Date(Mt.createdDate||Mt.createdAt).getTime()-new Date(Be.createdDate||Be.createdAt).getTime());p(le)}else console.error("Failed to load skill versions:",j.error),p([])}catch(j){console.error("Error loading skill versions:",j),p([])}finally{f(!1)}}),Ke=q=>{let j=i.find(le=>le.name===q);j&&(s(q),x("current"),y(j))},At=()=>{s(null),x("current"),p([]),u(null),U(null)},se=q=>{x(q),o&&(u(null),U(null))},X=()=>{u(null),U(null)},Q=()=>z(null,null,function*(){if(!l)return;let q=i.find(le=>le.name===l);if(!q)return;c.some(le=>le.version===q.version)?(T(q.version),g(!0)):yield ne(q.version)}),ne=q=>z(null,null,function*(){if(!l)return;let j=i.find(le=>le.name===l);if(j){m(!0);try{let Be=yield(yield fetch("/tools")).json();if(!Be.success||!Be.tools)throw new Error("Failed to load current tools data");let Mt=[];Array.isArray(Be.tools)?Mt=Be.tools:typeof Be.tools=="object"&&(Mt=Object.entries(Be.tools).map(([un,D])=>({name:un,description:D.description||"",inputSchema:D.inputSchema||{type:"object"},execute:D.execute||""})));let on=Mt.filter(un=>j.tools.includes(un.name)),Ct={name:j.name,version:q,description:j.description,context:j.context,tools:on};console.log("Creating version with data:",Ct);let We=yield ie.createSkillVersion(j.skillId,t,e,Ct);if(We.success)console.log("\u2705 Version created successfully:",We.data),yield y(j),alert(`\u2705 Version ${q} created successfully!`);else throw new Error(We.error||"Failed to create version")}catch(le){console.error("\u274C Error creating version:",le),alert(`\u274C Failed to create version: ${le instanceof Error?le.message:"Unknown error"}`)}finally{m(!1),g(!1)}}}),Y=()=>z(null,null,function*(){if(!E.trim()){alert("Please enter a version number");return}if(c.some(j=>j.version===E.trim())){alert("This version already exists. Please enter a different version number.");return}yield ne(E.trim())}),oe=()=>{g(!1),T("")},Ue=(q,j,le)=>{A(Be=>le?ut(K({},Be),{[q]:ut(K({},Be[q]),{[le]:j})}):ut(K({},Be),{[q]:j}))},mt=()=>z(null,null,function*(){if(o){O(!0),U(null);try{let q=zs(N,o.inputSchema),j=yield ie.testLocalTool(o.name,q);U(j)}catch(q){U({success:!1,error:q instanceof Error?q.message:"Unknown error occurred"})}finally{O(!1)}}}),zs=(q,j)=>{var Be,Mt;let le={};for(let[on,Ct]of Object.entries(q))if(Ct&&typeof Ct=="object"&&!Array.isArray(Ct)){let We=(Be=j.properties)==null?void 0:Be[on];if(We&&We.type==="object"&&We.properties){let un=zs(Ct,We);Object.keys(un).length>0&&(le[on]=un)}else le[on]=Ct}else{let We=(Mt=j.properties)==null?void 0:Mt[on];if((!j.required||!j.required.includes(on))&&(Ct===""||Ct===null||Ct===void 0))continue;le[on]=Ct}return le},Fr=(q,j,le)=>{var on,Ct;let Be=le?((on=N[q])==null?void 0:on[le])||"":N[q]||"",Mt=le?(Ct=j.required)==null?void 0:Ct.includes(le):o==null?void 0:o.inputSchema.required.includes(q);if(j.type==="object"&&j.properties)return(0,w.jsxs)("div",{className:"nested-object",children:[(0,w.jsx)("div",{className:"nested-object-label",children:q}),(0,w.jsx)("div",{className:"nested-fields",children:Object.entries(j.properties).map(([We,un])=>{var D;return(0,w.jsxs)("div",{className:"nested-field",children:[(0,w.jsxs)("label",{className:"nested-label",children:[We,((D=j.required)==null?void 0:D.includes(We))&&(0,w.jsx)("span",{className:"required",children:"*"})]}),Fr(q,un,We),un.description&&(0,w.jsx)("div",{className:"input-description",children:un.description})]},We)})})]});switch(j.type){case"number":return(0,w.jsx)("input",{type:"number",value:Be,onChange:We=>Ue(q,parseFloat(We.target.value)||0,le),placeholder:j.description||`Enter ${le||q}`,className:"tool-input",required:Mt});case"boolean":return(0,w.jsx)("input",{type:"checkbox",checked:Be,onChange:We=>Ue(q,We.target.checked,le),className:"tool-checkbox"});case"string":default:return(0,w.jsx)("input",{type:"text",value:Be,onChange:We=>Ue(q,We.target.value,le),placeholder:j.description||`Enter ${le||q}`,className:"tool-input",required:Mt})}};if(P)return(0,w.jsx)("div",{className:"skills-page",children:(0,w.jsx)("div",{className:"skills-loading",children:(0,w.jsx)("img",{src:"https://admin.heylua.ai/images/logo.svg",alt:"Loading",className:"loading-logo"})})});if(o)return(0,w.jsx)("div",{className:"skills-page",children:(0,w.jsxs)("div",{className:"tool-form",children:[(0,w.jsxs)("div",{className:"tool-form-header",children:[(0,w.jsx)("button",{className:"back-button",onClick:X,title:"Back to skill",children:"\u2190"}),(0,w.jsx)("h3",{children:o.name})]}),(0,w.jsxs)("div",{className:"tool-form-content",children:[(0,w.jsx)("div",{className:"tool-info",children:(0,w.jsx)("p",{children:o.description})}),(0,w.jsxs)("div",{className:"tool-inputs",children:[(0,w.jsx)("h4",{children:"Input Parameters"}),Object.keys(o.inputSchema.properties||{}).length>0?(0,w.jsx)("div",{className:"input-fields",children:Object.entries(o.inputSchema.properties).map(([q,j])=>(0,w.jsxs)("div",{className:"input-field",children:[(0,w.jsxs)("label",{children:[q,o.inputSchema.required.includes(q)&&(0,w.jsx)("span",{className:"required",children:"*"})]}),Fr(q,j),j.description&&(0,w.jsx)("div",{className:"input-description",children:j.description})]},q))}):(0,w.jsx)("p",{className:"no-inputs",children:"This tool requires no input parameters."})]}),(0,w.jsx)("div",{className:"tool-actions",children:(0,w.jsx)("button",{onClick:mt,disabled:R,className:"test-button",children:R?"Testing...":"Test Tool"})}),C&&(0,w.jsxs)("div",{className:"test-result",children:[(0,w.jsx)("h4",{children:"Test Result"}),(0,w.jsx)("div",{className:`result-content ${C.success?"success":"error"}`,children:C.success?(0,w.jsxs)("div",{children:[(0,w.jsx)("div",{className:"result-label",children:"\u2705 Success"}),(0,w.jsx)("pre",{className:"result-data",children:JSON.stringify(C.result,null,2)})]}):(0,w.jsxs)("div",{children:[(0,w.jsx)("div",{className:"result-label",children:"\u274C Error"}),(0,w.jsx)("div",{className:"result-error",children:C.error})]})})]})]})]})});if(l){let q=i.find(j=>j.name===l);return q?(0,w.jsxs)("div",{className:"skills-page",children:[(0,w.jsxs)("div",{className:"skills-header",children:[(0,w.jsxs)("div",{className:"header-left",children:[(0,w.jsx)("button",{className:"back-button",onClick:At,children:"\u2190"}),(0,w.jsx)("h4",{children:q.name})]}),(0,w.jsx)("button",{className:"create-version-button",onClick:Q,disabled:k,title:"Create new version",children:k?"Creating...":"Create Version"})]}),(0,w.jsxs)("div",{className:"skill-tabs",children:[(0,w.jsxs)("div",{className:"tabs-header",children:[(0,w.jsx)("button",{className:`tab-button ${S==="current"?"active":""}`,onClick:()=>se("current"),children:"Current"}),(0,w.jsxs)("button",{className:`tab-button ${S==="versions"?"active":""}`,onClick:()=>se("versions"),children:["Versions (",c.length,")"]})]}),(0,w.jsx)("div",{className:"tab-content",children:S==="current"?(0,w.jsxs)("div",{className:"current-skill-tab",children:[(0,w.jsx)("div",{className:"skill-details",children:(0,w.jsxs)("div",{className:"skill-info-section",children:[(0,w.jsxs)("div",{className:"skill-meta",children:[(0,w.jsxs)("span",{className:"skill-version",children:["v",q.version]}),(0,w.jsxs)("span",{className:"skill-tools-count",children:[q.tools.length," tools"]})]}),q.description&&(0,w.jsxs)("div",{className:"skill-description-section",children:[(0,w.jsx)("h5",{children:"Description"}),(0,w.jsx)("p",{children:q.description})]}),q.context&&(0,w.jsxs)("div",{className:"skill-context-section",children:[(0,w.jsx)("h5",{children:"Context"}),(0,w.jsx)("p",{children:q.context})]})]})}),(0,w.jsxs)("div",{className:"tools-section",children:[(0,w.jsx)("div",{className:"tools-header",children:(0,w.jsxs)("h5",{children:["Available Tools (",q.tools.length,")"]})}),q.tools&&q.tools.length>0?(0,w.jsx)("div",{className:"tools-grid",children:q.tools.map((j,le)=>(0,w.jsxs)("div",{className:"tool-card",onClick:()=>pt(j),children:[(0,w.jsx)("div",{className:"tool-card-header",children:(0,w.jsx)("h4",{children:j})}),(0,w.jsx)("div",{className:"tool-card-body",children:(0,w.jsx)("span",{className:"skill-badge",children:q.name})})]},le))}):(0,w.jsxs)("div",{className:"no-tools",children:[(0,w.jsx)("div",{className:"no-tools-icon",children:"\u{1F527}"}),(0,w.jsx)("div",{className:"no-tools-text",children:"No tools in this skill"}),(0,w.jsx)("div",{className:"no-tools-subtext",children:"This skill doesn't have any tools defined"})]})]}),(0,w.jsx)("div",{className:"skills-help",children:(0,w.jsx)("p",{children:"This skill is compiled from your local code and updates automatically when you make changes. Use the tools above to test your skill's functionality."})})]}):(0,w.jsx)("div",{className:"versions-skill-tab",children:d?(0,w.jsx)("div",{className:"versions-loading",children:(0,w.jsx)("img",{src:"https://admin.heylua.ai/images/logo.svg",alt:"Loading",className:"loading-logo"})}):c.length>0?(0,w.jsx)("div",{className:"versions-list",children:c.map((j,le)=>(0,w.jsxs)("div",{className:`version-item ${j.status}`,onClick:()=>{console.log("Selected version:",j.version)},children:[(0,w.jsxs)("div",{className:"version-info",children:[(0,w.jsxs)("div",{className:"version-header",children:[(0,w.jsxs)("span",{className:"version-number",children:["v",j.version]}),(0,w.jsx)("span",{className:`version-status ${j.status}`,children:j.status})]}),(0,w.jsxs)("div",{className:"version-meta",children:[(0,w.jsx)("span",{className:"version-date",children:new Date(j.createdDate||j.createdAt).toLocaleDateString()}),(0,w.jsxs)("span",{className:"version-author",children:["by ",j.createdByEmail||j.createdBy]})]})]}),(0,w.jsx)("div",{className:"version-arrow",children:"\u2192"})]},le))}):(0,w.jsxs)("div",{className:"no-versions",children:[(0,w.jsx)("div",{className:"no-versions-icon",children:"\u{1F4E6}"}),(0,w.jsx)("div",{className:"no-versions-text",children:"No versions found"}),(0,w.jsx)("div",{className:"no-versions-subtext",children:"Create your first version to get started"})]})})})]}),h&&(0,w.jsx)("div",{className:"version-modal-overlay",children:(0,w.jsxs)("div",{className:"version-modal",children:[(0,w.jsx)("div",{className:"version-modal-header",children:(0,w.jsx)("h3",{children:"Create New Version"})}),(0,w.jsxs)("div",{className:"version-modal-body",children:[(0,w.jsxs)("p",{children:["Version ",(0,w.jsx)("strong",{children:(Zr=i.find(j=>j.name===l))==null?void 0:Zr.version})," already exists."]}),(0,w.jsx)("p",{children:"Please enter a new version number:"}),(0,w.jsx)("input",{type:"text",value:E,onChange:j=>T(j.target.value),placeholder:"e.g., 1.0.1",className:"version-input",autoFocus:!0})]}),(0,w.jsxs)("div",{className:"version-modal-actions",children:[(0,w.jsx)("button",{className:"cancel-button",onClick:oe,disabled:k,children:"Cancel"}),(0,w.jsx)("button",{className:"create-button",onClick:Y,disabled:k||!E.trim(),children:k?"Creating...":"Create Version"})]})]})})]}):(0,w.jsxs)("div",{className:"skills-page",children:[(0,w.jsx)("div",{className:"skills-header",children:(0,w.jsxs)("div",{className:"header-left",children:[(0,w.jsx)("button",{className:"back-button",onClick:At,children:"\u2190"}),(0,w.jsx)("h4",{children:"Skill Not Found"})]})}),(0,w.jsxs)("div",{className:"no-skills",children:[(0,w.jsx)("div",{className:"no-skills-icon",children:"\u274C"}),(0,w.jsx)("div",{className:"no-skills-text",children:"Skill not found"}),(0,w.jsx)("div",{className:"no-skills-subtext",children:"The selected skill could not be loaded"})]})]})}return(0,w.jsxs)("div",{className:"skills-page",children:[(0,w.jsxs)("div",{className:"skills-header",children:[(0,w.jsx)("h3",{children:"Available Skills"}),(0,w.jsx)("button",{className:"refresh-button",onClick:we,title:"Refresh skills",children:"\u21BB"})]}),(0,w.jsx)("div",{className:"skills-content",children:I?(0,w.jsxs)("div",{className:"no-skills",children:[(0,w.jsx)("div",{className:"no-skills-icon",children:"\u274C"}),(0,w.jsx)("div",{className:"no-skills-text",children:"Error loading skills"}),(0,w.jsx)("div",{className:"no-skills-subtext",children:I}),(0,w.jsx)("button",{className:"retry-button",onClick:we,style:{marginTop:"16px"},children:"Retry"})]}):i.length===0?(0,w.jsxs)("div",{className:"no-skills",children:[(0,w.jsx)("div",{className:"no-skills-icon",children:"\u2699\uFE0F"}),(0,w.jsx)("div",{className:"no-skills-text",children:"No skills found"}),(0,w.jsx)("div",{className:"no-skills-subtext",children:"Skills will appear here when available in your project"})]}):Array.isArray(i)&&i.length>0?(0,w.jsx)("div",{className:"skills-list",children:i.map(q=>(0,w.jsxs)("div",{className:"skill-item",onClick:()=>Ke(q.name),children:[(0,w.jsxs)("div",{className:"skill-info",children:[(0,w.jsx)("div",{className:"skill-name",children:q.name}),(0,w.jsx)("div",{className:"skill-description",children:q.description}),(0,w.jsxs)("div",{className:"skill-stats",children:[(0,w.jsxs)("span",{className:"skill-stat",children:["v",q.version]}),(0,w.jsxs)("span",{className:"skill-stat",children:[q.tools.length," tools"]})]})]}),(0,w.jsx)("div",{className:"skill-arrow",children:"\u2192"})]},q.name))}):(0,w.jsxs)("div",{className:"no-skills",children:[(0,w.jsx)("div",{className:"no-skills-icon",children:"\u2699\uFE0F"}),(0,w.jsx)("div",{className:"no-skills-text",children:"No skills available"}),(0,w.jsx)("div",{className:"no-skills-subtext",children:"No valid skills data received"})]})})]})}});var qe,L,xs,DR,ym,OR,bm=b(()=>{"use strict";qe=F(Je());an();L=F(re()),xs=e=>{if(!e||!e.trim())return e||"";try{let t=JSON.parse(e);return JSON.stringify(t,null,2).replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,a=>{let i="json-number";return/^"/.test(a)?/:$/.test(a)?i="json-key":i="json-string":/true|false/.test(a)?i="json-boolean":/null/.test(a)&&(i="json-null"),`<span class="${i}">${a}</span>`})}catch(t){return e.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,n=>{let a="json-number";return/^"/.test(n)?/:$/.test(n)?a="json-key":a="json-string":/true|false/.test(n)?a="json-boolean":/null/.test(n)&&(a="json-null"),`<span class="${a}">${n}</span>`})}},DR=[{id:"user",name:"User",description:"User profile and account data",icon:"\u{1F464}"},{id:"resources",name:"Resources",description:"Files, documents, and assets",icon:"\u{1F4C1}"},{id:"products",name:"Products",description:"Coming soon",icon:"\u{1F4E6}"},{id:"orders",name:"Orders",description:"Coming soon",icon:"\u{1F4CB}"},{id:"booking",name:"Booking",description:"Coming soon",icon:"\u{1F4C5}"},{id:"custom",name:"Custom",description:"Coming soon",icon:"\u2699\uFE0F"}],ym=({apiKey:e,agentId:t})=>{let[n,a]=(0,qe.useState)(null),[i,r]=(0,qe.useState)(null),[l,s]=(0,qe.useState)(null),[o,u]=(0,qe.useState)(!1),[c,p]=(0,qe.useState)(!1),[d,f]=(0,qe.useState)(!1),[S,x]=(0,qe.useState)(""),[k,m]=(0,qe.useState)(null),[h,g]=(0,qe.useState)(null),[E,T]=(0,qe.useState)(!1),[N,A]=(0,qe.useState)("list"),C=(0,qe.useRef)(null),U=(0,qe.useRef)(null),[P,_]=(0,qe.useState)(!1),[R,O]=(0,qe.useState)(""),[I,B]=(0,qe.useState)(""),[J,ae]=(0,qe.useState)(!1);(0,qe.useEffect)(()=>{we()},[e,t]),(0,qe.useEffect)(()=>{if(console.log("JSON text changed:",S),console.log("Is editing:",E),console.log("Highlight ref exists:",!!U.current),U.current&&S&&!E){let Y=xs(S);console.log("Applying highlighting:",Y.substring(0,100)+"..."),U.current.innerHTML=Y}},[S,E]);let we=()=>z(null,null,function*(){try{if(console.log("Loading user data with API key:",e,"agentId:",t),u(!0),m(null),!e||!t){console.error("Missing API key or agentId:",{apiKey:!!e,agentId:!!t}),m("Missing API key or agent ID"),x("{}");return}let Y=yield ie.loadUserData(e,t);if(console.log("User data response:",Y),Y.success&&Y.data){a(Y.data);let oe=Y.data,Ue=JSON.stringify(oe,null,2);x(Ue),setTimeout(()=>{U.current&&(U.current.innerHTML=xs(Ue))},0),console.log("User data loaded successfully:",Y.data),console.log("Data to display:",oe)}else console.log("No user data or error:",Y.error),m(Y.error||"No user data found"),x("{}")}catch(Y){console.error("Failed to load user data:",Y),m(`Failed to load user data: ${Y instanceof Error?Y.message:"Unknown error"}`),x("{}")}finally{u(!1)}}),je=()=>z(null,null,function*(){try{console.log("Saving user data:",S),p(!0),m(null),g(null);let Y=JSON.parse(S),oe=yield ie.updateUserData(e,t,Y);console.log("Save user data response:",oe),oe.success&&oe.data?(a(oe.data),x(JSON.stringify(oe.data.data,null,2)),g("User data saved successfully!"),T(!1),setTimeout(()=>g(null),3e3)):m("Failed to save user data: "+(oe.error||"Unknown error"))}catch(Y){console.error("Failed to save user data:",Y),Y instanceof SyntaxError?m("Invalid JSON format. Please check your syntax."):m("Failed to save user data")}finally{p(!1)}}),v=()=>z(null,null,function*(){try{console.log("Clearing user data"),f(!0),m(null),g(null);let Y=yield ie.clearUserData(e,t);console.log("Clear user data response:",Y),Y.success?(a(null),x("{}"),A("list"),g("User data cleared successfully!"),T(!1),setTimeout(()=>g(null),3e3)):m("Failed to clear user data: "+(Y.error||"Unknown error"))}catch(Y){console.error("Failed to clear user data:",Y),m("Failed to clear user data")}finally{f(!1)}}),Me=Y=>z(null,null,function*(){if(r(Y),A("detail"),T(!1),m(null),Y.id==="user"){u(!0);try{let oe=yield ie.loadUserData(e,t);if(oe.success&&oe.data){s(oe.data);let Ue=JSON.stringify(oe.data,null,2);x(Ue),console.log("Setting JSON text for user data:",Ue)}else s(null),x("{}"),console.log("No user data found, setting empty JSON")}catch(oe){console.error("Failed to load user data:",oe),s(null),x("{}")}finally{u(!1)}}else if(Y.id==="resources"){u(!0);try{let oe=yield ie.loadResources(e,t);oe.success&&oe.data?(s(oe.data),console.log("Loaded resources:",oe.data)):(s([]),console.log("No resources found"))}catch(oe){console.error("Failed to load resources:",oe),s([])}finally{u(!1)}}else s(null),x("{}")}),pt=()=>{A("list"),r(null),s(null),T(!1)},y=()=>{i&&(i.id==="resources"?(_(!0),O(""),B("")):console.log(`Add new item to ${i==null?void 0:i.name}`))},Ke=()=>z(null,null,function*(){if(!R.trim()||!I.trim()){alert("Name and content cannot be empty");return}ae(!0);try{let Y=yield ie.createResource(e,t,{name:R.trim(),content:I.trim()});Y.success?(_(!1),O(""),B(""),i&&Me(i)):alert("Failed to create resource: "+(Y.error||"Unknown error"))}catch(Y){console.error("Error creating resource:",Y),alert("Failed to create resource")}finally{ae(!1)}}),At=()=>{_(!1),O(""),B("")},se=()=>z(null,null,function*(){i&&console.log(`Delete all ${i.name} data`)}),X=Y=>{x(Y),T(!0),m(null),g(null),U.current&&(U.current.innerHTML=xs(Y))},Q=()=>{T(!0),setTimeout(()=>{C.current&&C.current.focus()},0)},ne=()=>{C.current&&U.current&&(U.current.scrollTop=C.current.scrollTop,U.current.scrollLeft=C.current.scrollLeft)};return o?(0,L.jsx)("div",{className:"user-data-panel",children:(0,L.jsx)("div",{className:"user-data-loading",children:(0,L.jsx)("img",{src:"https://admin.heylua.ai/images/logo.svg",alt:"Loading",className:"loading-logo"})})}):(0,L.jsxs)("div",{className:"user-data-panel",children:[(0,L.jsxs)("div",{className:"user-data-header",children:[(0,L.jsxs)("div",{className:"header-left",children:[N==="detail"&&(0,L.jsx)("button",{className:"back-button",onClick:pt,title:"Back to data categories",children:"\u2190"}),(0,L.jsx)("h3",{children:N==="list"?"Data":(i==null?void 0:i.name)||"Data Detail"})]}),(0,L.jsxs)("div",{className:"user-data-actions",children:[N==="detail"&&(i==null?void 0:i.id)!=="user"&&(i==null?void 0:i.description)!=="Coming soon"&&(0,L.jsx)("button",{className:"add-button",onClick:y,title:`Add new ${i==null?void 0:i.name.toLowerCase()}`,children:"\u2795"}),(0,L.jsx)("button",{className:"refresh-button",onClick:N==="detail"&&i?()=>Me(i):we,disabled:o,title:`Refresh ${N==="detail"?i==null?void 0:i.name.toLowerCase():"data"}`,children:o?"\u27F3":"\u21BB"}),N==="detail"&&(i==null?void 0:i.id)==="user"&&(0,L.jsx)("button",{className:"save-button",onClick:je,disabled:c,title:"Save user data",children:c?"\u27F3":"\u{1F4BE}"}),N==="detail"&&(0,L.jsx)("button",{className:"delete-button",onClick:se,disabled:d,title:`Delete all ${i==null?void 0:i.name.toLowerCase()}`,children:"\u{1F5D1}\uFE0F"})]})]}),k&&(0,L.jsxs)("div",{className:"error-message",children:["\u274C ",k]}),h&&(0,L.jsxs)("div",{className:"success-message",children:["\u2705 ",h]}),(0,L.jsx)("div",{className:"user-data-content",children:N==="list"?(0,L.jsx)("div",{className:"data-list",children:(0,L.jsx)("div",{className:"data-categories",children:DR.map(Y=>(0,L.jsxs)("div",{className:"data-category",onClick:()=>Me(Y),children:[(0,L.jsx)("div",{className:"category-icon",children:Y.icon}),(0,L.jsxs)("div",{className:"category-info",children:[(0,L.jsx)("div",{className:"category-name",children:Y.name}),(0,L.jsx)("div",{className:"category-description",children:Y.description})]}),(0,L.jsx)("div",{className:"category-arrow",children:"\u2192"})]},Y.id))})}):(0,L.jsx)("div",{className:"data-detail",children:(i==null?void 0:i.id)==="user"&&l?(0,L.jsx)("div",{className:"json-editor",children:E?(0,L.jsxs)("div",{className:"json-editor-container",children:[(0,L.jsx)("div",{ref:U,className:"json-highlight-background",dangerouslySetInnerHTML:{__html:xs(S)}}),(0,L.jsx)("textarea",{ref:C,id:"user-data-json",name:"userDataJson",value:S,onChange:Y=>X(Y.target.value),className:"json-textarea",spellCheck:!1,placeholder:"Enter JSON data...",autoComplete:"off"})]}):(0,L.jsx)("div",{className:"json-display",onClick:Q,dangerouslySetInnerHTML:{__html:xs(S)}})}):(i==null?void 0:i.id)==="resources"&&l?(0,L.jsxs)("div",{className:"resources-container",children:[(0,L.jsxs)("div",{className:"production-warning",children:[(0,L.jsx)("div",{className:"warning-icon",children:"\u26A0\uFE0F"}),(0,L.jsxs)("div",{className:"warning-text",children:[(0,L.jsx)("strong",{children:"Production Resources:"})," Changes to resources will propagate to production and affect live users."]})]}),(0,L.jsx)("div",{className:"resources-list",children:Array.isArray(l)&&l.length>0?l.map(Y=>(0,L.jsx)(OR,{resource:Y,apiKey:e,agentId:t,onUpdate:()=>Me(i)},Y.id)):(0,L.jsxs)("div",{className:"no-resources",children:[(0,L.jsx)("div",{className:"empty-icon",children:"\u{1F4C1}"}),(0,L.jsx)("h4",{children:"No resources yet"}),(0,L.jsx)("p",{children:"Resources help provide context and information to your AI agent"})]})})]}):(0,L.jsxs)("div",{className:"category-empty-state",children:[(0,L.jsx)("div",{className:"empty-icon",children:i==null?void 0:i.icon}),(i==null?void 0:i.description)==="Coming soon"?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)("h3",{children:"Coming Soon"}),(0,L.jsxs)("p",{children:[i.name," management will be available in a future update"]}),(0,L.jsx)("div",{className:"coming-soon-badge",children:"\u{1F6A7} Under Development"})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)("h3",{children:["No ",i==null?void 0:i.name.toLowerCase()," yet"]}),(0,L.jsxs)("p",{children:["Start by adding your first ",i==null?void 0:i.name.toLowerCase()," entry"]}),(0,L.jsx)("div",{className:"empty-actions",children:(0,L.jsx)("button",{className:"add-button",onClick:y,children:"\u2795"})})]})]})})}),P&&(0,L.jsx)("div",{className:"resource-modal-overlay",children:(0,L.jsxs)("div",{className:"resource-modal",children:[(0,L.jsxs)("div",{className:"resource-modal-header",children:[(0,L.jsx)("h3",{children:"Create New Resource"}),(0,L.jsx)("button",{className:"modal-close-btn",onClick:At,disabled:J,children:"\u2715"})]}),(0,L.jsxs)("div",{className:"resource-modal-body",children:[(0,L.jsxs)("div",{className:"production-warning",children:[(0,L.jsx)("div",{className:"warning-icon",children:"\u26A0\uFE0F"}),(0,L.jsxs)("div",{className:"warning-text",children:[(0,L.jsx)("strong",{children:"Production Impact:"})," This resource will be available in production and affect live users."]})]}),(0,L.jsxs)("div",{className:"resource-form",children:[(0,L.jsxs)("div",{className:"form-field",children:[(0,L.jsx)("label",{htmlFor:"resource-name",children:"Resource Name"}),(0,L.jsx)("input",{id:"resource-name",type:"text",value:R,onChange:Y=>O(Y.target.value),placeholder:"e.g., FAQ, return-policy, user-guide",className:"resource-name-input",autoFocus:!0})]}),(0,L.jsxs)("div",{className:"form-field",children:[(0,L.jsx)("label",{htmlFor:"resource-content",children:"Content"}),(0,L.jsx)("textarea",{id:"resource-content",value:I,onChange:Y=>B(Y.target.value),placeholder:"Paste your content here... This can be a large text file, FAQ content, documentation, etc.",className:"resource-content-textarea",rows:12})]}),(0,L.jsxs)("div",{className:"character-count",children:[I.length," characters"]})]})]}),(0,L.jsxs)("div",{className:"resource-modal-actions",children:[(0,L.jsx)("button",{className:"cancel-button",onClick:At,disabled:J,children:"Cancel"}),(0,L.jsx)("button",{className:"create-button",onClick:Ke,disabled:J||!R.trim()||!I.trim(),children:J?"Creating...":"Create Resource"})]})]})})]})},OR=({resource:e,apiKey:t,agentId:n,onUpdate:a})=>{let[i,r]=(0,qe.useState)(!1),[l,s]=(0,qe.useState)(e.name),[o,u]=(0,qe.useState)(e.content),[c,p]=(0,qe.useState)(!1),[d,f]=(0,qe.useState)(!1),S=()=>{r(!0),s(e.name),u(e.content)},x=()=>{r(!1),s(e.name),u(e.content)},k=()=>z(null,null,function*(){if(!l.trim()||!o.trim()){alert("Name and content cannot be empty");return}p(!0);try{let h=yield ie.updateResource(t,n,e.id,{name:l.trim(),content:o.trim()});h.success?(r(!1),a()):alert("Failed to update resource: "+(h.error||"Unknown error"))}catch(h){console.error("Error updating resource:",h),alert("Failed to update resource")}finally{p(!1)}}),m=()=>z(null,null,function*(){if(confirm(`Are you sure you want to delete "${e.name}"? This will affect production.`)){f(!0);try{let h=yield ie.deleteResource(t,n,e.id);h.success?a():alert("Failed to delete resource: "+(h.error||"Unknown error"))}catch(h){console.error("Error deleting resource:",h),alert("Failed to delete resource")}finally{f(!1)}}});return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)("div",{className:"resource-item",children:(0,L.jsxs)("div",{className:"resource-display",children:[(0,L.jsxs)("div",{className:"resource-header",children:[(0,L.jsx)("h4",{className:"resource-name",children:e.name}),(0,L.jsx)("div",{className:"resource-meta",children:(0,L.jsxs)("span",{className:"resource-date",children:["Updated ",new Date(e.updatedAt).toLocaleDateString()]})})]}),(0,L.jsx)("div",{className:"resource-content",children:(0,L.jsxs)("p",{children:[e.content.substring(0,200),e.content.length>200?"...":""]})}),(0,L.jsxs)("div",{className:"resource-actions",children:[(0,L.jsx)("button",{className:"edit-btn",onClick:S,title:"Edit resource",children:"\u270F\uFE0F"}),(0,L.jsx)("button",{className:"delete-btn",onClick:m,disabled:d,title:"Delete resource",children:d?"\u27F3":"\u{1F5D1}\uFE0F"})]})]})}),i&&(0,L.jsx)("div",{className:"resource-modal-overlay",children:(0,L.jsxs)("div",{className:"resource-modal",children:[(0,L.jsxs)("div",{className:"resource-modal-header",children:[(0,L.jsx)("h3",{children:"Edit Resource"}),(0,L.jsx)("button",{className:"modal-close-btn",onClick:x,disabled:c,children:"\u2715"})]}),(0,L.jsxs)("div",{className:"resource-modal-body",children:[(0,L.jsxs)("div",{className:"production-warning",children:[(0,L.jsx)("div",{className:"warning-icon",children:"\u26A0\uFE0F"}),(0,L.jsxs)("div",{className:"warning-text",children:[(0,L.jsx)("strong",{children:"Production Impact:"})," Changes to this resource will affect live users immediately."]})]}),(0,L.jsxs)("div",{className:"resource-form",children:[(0,L.jsxs)("div",{className:"form-field",children:[(0,L.jsx)("label",{htmlFor:"edit-resource-name",children:"Resource Name"}),(0,L.jsx)("input",{id:"edit-resource-name",type:"text",value:l,onChange:h=>s(h.target.value),placeholder:"Resource name",className:"resource-name-input",autoFocus:!0})]}),(0,L.jsxs)("div",{className:"form-field",children:[(0,L.jsx)("label",{htmlFor:"edit-resource-content",children:"Content"}),(0,L.jsx)("textarea",{id:"edit-resource-content",value:o,onChange:h=>u(h.target.value),placeholder:"Resource content",className:"resource-content-textarea",rows:12})]}),(0,L.jsxs)("div",{className:"character-count",children:[o.length," characters"]})]})]}),(0,L.jsxs)("div",{className:"resource-modal-actions",children:[(0,L.jsx)("button",{className:"cancel-button",onClick:x,disabled:c,children:"Cancel"}),(0,L.jsx)("button",{className:"create-button",onClick:k,disabled:c||!l.trim()||!o.trim(),children:c?"Saving...":"Save Changes"})]})]})})]})}});var Lt,W,Sm,LR,xm=b(()=>{"use strict";Lt=F(Je());an();W=F(re()),Sm=({apiKey:e,agentId:t})=>{let[n,a]=(0,Lt.useState)([]),[i,r]=(0,Lt.useState)(!0),[l,s]=(0,Lt.useState)(!1),[o,u]=(0,Lt.useState)(null),[c,p]=(0,Lt.useState)(null),[d,f]=(0,Lt.useState)(null),[S,x]=(0,Lt.useState)(""),[k,m]=(0,Lt.useState)(""),[h,g]=(0,Lt.useState)(!1);(0,Lt.useEffect)(()=>{C()},[]);let[E,T]=(0,Lt.useState)(!0);(0,Lt.useEffect)(()=>{if(E)return;z(null,null,function*(){console.log("Environment variables changed, auto-saving..."),s(!0),u(null),p(null);try{let J=A(n);console.log("Generated .env content:",J);let ae=yield ie.saveEnvContent(J);console.log("Save env response:",ae),ae.success?(p("Environment variables saved successfully!"),setTimeout(()=>p(null),3e3)):(console.error("Failed to save env variables:",ae.error),u(ae.error||"Failed to save environment variables"))}catch(J){console.error("Error saving env variables:",J),u("Failed to save environment variables")}finally{s(!1)}})},[n]);let N=B=>B.trim()?B.split(`
23
23
  `).map((J,ae)=>J.trim()).filter(J=>J&&!J.startsWith("#")).map((J,ae)=>{let[we,...je]=J.split("=");return{id:`env_${ae}_${Date.now()}`,key:(we==null?void 0:we.trim())||"",value:je.join("=")||""}}).filter(J=>J.key):[],A=B=>B.map(J=>`${J.key}=${J.value}`).join(`
24
- `),C=()=>z(null,null,function*(){r(!0),u(null);try{let B=yield ie.loadEnvContent();if(B.success){let J=B.content||"",ae=N(J);a(ae),T(!1)}else u(B.error||"Failed to load environment variables"),a([]),T(!1)}catch(B){console.error("Error loading env content:",B),u("Failed to load environment variables"),a([])}finally{r(!1)}}),U=()=>{if(!S.trim()){u("Please enter a variable name");return}if(n.some(J=>J.key===S.trim())){u("Variable name already exists");return}let B={id:`env_new_${Date.now()}`,key:S.trim(),value:k};a([...n,B]),x(""),m(""),g(!1),u(null)},P=(B,J,ae)=>{a(we=>we.map(je=>je.id===B?ut(K({},je),{key:J.trim(),value:ae}):je)),f(null)},_=B=>{a(J=>J.filter(ae=>ae.id!==B))},R=B=>{f(B),u(null),p(null)},O=()=>{f(null),C()},I=()=>{g(!1),x(""),m(""),u(null)};return i?(0,W.jsx)("div",{className:"env-panel",children:(0,W.jsx)("div",{className:"env-loading",children:(0,W.jsx)("img",{src:"https://admin.lua.dev/images/logo.svg",alt:"Loading",className:"loading-logo"})})}):(0,W.jsxs)("div",{className:"env-panel",children:[(0,W.jsxs)("div",{className:"env-header",children:[(0,W.jsx)("h3",{children:"Environment Variables"}),(0,W.jsxs)("div",{className:"env-actions",children:[(0,W.jsx)("button",{className:"refresh-btn",onClick:C,disabled:i,title:"Refresh environment variables",children:i?"\u27F3":"\u21BB"}),(0,W.jsx)("button",{className:"add-btn",onClick:()=>g(!0),disabled:h,title:"Add new environment variable",children:"\u2795"})]})]}),(0,W.jsxs)("div",{className:"env-content",children:[o&&(0,W.jsxs)("div",{className:"error-message",children:[(0,W.jsx)("strong",{children:"Error:"})," ",o]}),c&&(0,W.jsxs)("div",{className:"success-message",children:[(0,W.jsx)("strong",{children:"Success:"})," ",c]}),h&&(0,W.jsxs)("div",{className:"env-add-form",children:[(0,W.jsxs)("div",{className:"env-form-header",children:[(0,W.jsx)("h4",{children:"Add New Variable"}),(0,W.jsx)("button",{className:"form-cancel-btn",onClick:I,title:"Cancel",children:"\u2715"})]}),(0,W.jsxs)("div",{className:"env-form-fields",children:[(0,W.jsxs)("div",{className:"env-field",children:[(0,W.jsx)("label",{children:"Variable Name"}),(0,W.jsx)("input",{type:"text",value:S,onChange:B=>x(B.target.value),placeholder:"API_KEY",className:"env-input",autoFocus:!0})]}),(0,W.jsxs)("div",{className:"env-field",children:[(0,W.jsx)("label",{children:"Value"}),(0,W.jsx)("input",{type:"text",value:k,onChange:B=>m(B.target.value),placeholder:"your_api_key_here",className:"env-input"})]}),(0,W.jsx)("div",{className:"env-form-actions",children:(0,W.jsx)("button",{className:"add-variable-btn",onClick:U,disabled:!S.trim(),children:"Add Variable"})})]})]}),(0,W.jsx)("div",{className:"env-variables",children:n.length>0?(0,W.jsx)("div",{className:"env-list",children:n.map(B=>(0,W.jsx)(LR,{variable:B,isEditing:d===B.id,onEdit:()=>R(B.id),onSave:(J,ae)=>P(B.id,J,ae),onCancel:O,onDelete:()=>_(B.id)},B.id))}):(0,W.jsxs)("div",{className:"env-empty-state",children:[(0,W.jsx)("div",{className:"empty-icon",children:"\u{1F527}"}),(0,W.jsx)("h4",{children:"No environment variables"}),(0,W.jsx)("p",{children:"Add your first environment variable to get started"}),(0,W.jsx)("button",{className:"add-first-btn",onClick:()=>g(!0),children:"Add Variable"})]})}),(0,W.jsxs)("div",{className:"env-help",children:[(0,W.jsxs)("p",{children:["Environment variables are stored in your ",(0,W.jsx)("code",{children:".env"})," file and automatically included in tool execution and chat messages."]}),(0,W.jsxs)("p",{children:[(0,W.jsx)("strong",{children:"Auto-save:"})," Changes are saved automatically when you add, edit, or delete variables."]})]})]})]})},LR=({variable:e,isEditing:t,onEdit:n,onSave:a,onCancel:i,onDelete:r})=>{let[l,s]=(0,Lt.useState)(e.key),[o,u]=(0,Lt.useState)(e.value),[c,p]=(0,Lt.useState)(!1),d=e.value.length>60,f=c||!d?e.value:e.value.substring(0,60)+"...";return(0,W.jsx)("div",{className:"env-variable-item",children:t?(0,W.jsxs)("div",{className:"env-variable-edit",children:[(0,W.jsxs)("div",{className:"env-edit-fields",children:[(0,W.jsx)("input",{type:"text",value:l,onChange:k=>s(k.target.value),className:"env-key-input",placeholder:"Variable name"}),(0,W.jsx)("span",{className:"env-equals",children:"="}),(0,W.jsx)("textarea",{value:o,onChange:k=>u(k.target.value),className:"env-value-input",placeholder:"Value",rows:1})]}),(0,W.jsxs)("div",{className:"env-edit-actions",children:[(0,W.jsx)("button",{className:"save-edit-btn",onClick:()=>{if(!l.trim()){alert("Variable name cannot be empty");return}a(l,o)},title:"Save changes",children:"\u2713"}),(0,W.jsx)("button",{className:"cancel-edit-btn",onClick:()=>{s(e.key),u(e.value),i()},title:"Cancel editing",children:"\u2715"})]})]}):(0,W.jsxs)("div",{className:"env-variable-display",children:[(0,W.jsxs)("div",{className:"env-variable-content",children:[(0,W.jsx)("span",{className:"env-key",children:e.key}),(0,W.jsx)("span",{className:"env-equals",children:"="}),(0,W.jsxs)("div",{className:"env-value-container",children:[(0,W.jsx)("span",{className:"env-value",onClick:()=>d&&p(!c),style:{cursor:d?"pointer":"default"},title:d?"Click to expand/collapse":e.value,children:f||"<empty>"}),d&&(0,W.jsx)("button",{className:"expand-btn",onClick:()=>p(!c),title:c?"Collapse":"Expand",children:c?"\u25B2":"\u25BC"})]})]}),(0,W.jsxs)("div",{className:"env-variable-actions",children:[(0,W.jsx)("button",{className:"edit-variable-btn",onClick:n,title:"Edit variable",children:"\u270F\uFE0F"}),(0,W.jsx)("button",{className:"delete-variable-btn",onClick:r,title:"Delete variable",children:"\u{1F5D1}\uFE0F"})]})]})})}});var wt,Nm,tN=b(()=>{"use strict";hm();vm();bm();xm();wt=F(re()),Nm=({activeTab:e,onTabChange:t,persona:n,onSavePersona:a,apiKey:i,agentId:r,skillId:l,sandboxId:s,width:o})=>(0,wt.jsx)("div",{className:"log-container",style:{width:`${o}px`},children:(0,wt.jsxs)("div",{className:"top-section",children:[(0,wt.jsx)("div",{className:"log-header",children:(0,wt.jsxs)("div",{className:"tab-buttons",children:[(0,wt.jsx)("button",{className:`tab-button ${e==="persona"?"active":""}`,onClick:()=>t("persona"),children:"Persona"}),(0,wt.jsx)("button",{className:`tab-button ${e==="skills"?"active":""}`,onClick:()=>t("skills"),children:"Skills"}),(0,wt.jsx)("button",{className:`tab-button ${e==="userdata"?"active":""}`,onClick:()=>t("userdata"),children:"Data"}),(0,wt.jsx)("button",{className:`tab-button ${e==="env"?"active":""}`,onClick:()=>t("env"),children:"Env"})]})}),(0,wt.jsx)("div",{className:`tab-content ${e==="persona"?"active":"inactive"}`,children:(0,wt.jsx)(mm,{persona:n,onSavePersona:a,apiKey:i,agentId:r})}),(0,wt.jsx)("div",{className:`tab-content ${e==="skills"?"active":"inactive"}`,children:(0,wt.jsx)(gm,{apiKey:i,agentId:r,skillId:l,sandboxId:s})}),(0,wt.jsx)("div",{className:`tab-content ${e==="userdata"?"active":"inactive"}`,children:(0,wt.jsx)(ym,{apiKey:i,agentId:r})}),(0,wt.jsx)("div",{className:`tab-content ${e==="env"?"active":"inactive"}`,children:(0,wt.jsx)(Sm,{apiKey:i,agentId:r})})]})})});var jn,Ns,Es,Zu=b(()=>{jn=Object.create(null);jn.open="0";jn.close="1";jn.ping="2";jn.pong="3";jn.message="4";jn.upgrade="5";jn.noop="6";Ns=Object.create(null);Object.keys(jn).forEach(e=>{Ns[jn[e]]=e});Es={type:"error",data:"parser error"}});function aN(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function sN(e,t){if(iN&&e.data instanceof Blob)return e.data.arrayBuffer().then(aN).then(t);if(rN&&(e.data instanceof ArrayBuffer||lN(e.data)))return t(aN(e.data));ks(e,!1,n=>{Em||(Em=new TextEncoder),t(Em.encode(n))})}var iN,rN,lN,ks,nN,Em,oN=b(()=>{Zu();iN=typeof Blob=="function"||typeof Blob!="undefined"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",rN=typeof ArrayBuffer=="function",lN=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,ks=({type:e,data:t},n,a)=>iN&&t instanceof Blob?n?a(t):nN(t,a):rN&&(t instanceof ArrayBuffer||lN(t))?n?a(t):nN(new Blob([t]),a):a(jn[e]+(t||"")),nN=(e,t)=>{let n=new FileReader;return n.onload=function(){let a=n.result.split(",")[1];t("b"+(a||""))},n.readAsDataURL(e)}});var uN,Ts,cN,fN=b(()=>{uN="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ts=typeof Uint8Array=="undefined"?[]:new Uint8Array(256);for(let e=0;e<uN.length;e++)Ts[uN.charCodeAt(e)]=e;cN=e=>{let t=e.length*.75,n=e.length,a,i=0,r,l,s,o;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);let u=new ArrayBuffer(t),c=new Uint8Array(u);for(a=0;a<n;a+=4)r=Ts[e.charCodeAt(a)],l=Ts[e.charCodeAt(a+1)],s=Ts[e.charCodeAt(a+2)],o=Ts[e.charCodeAt(a+3)],c[i++]=r<<2|l>>4,c[i++]=(l&15)<<4|s>>2,c[i++]=(s&3)<<6|o&63;return u}});var zR,ws,MR,dN,pN=b(()=>{Zu();fN();zR=typeof ArrayBuffer=="function",ws=(e,t)=>{if(typeof e!="string")return{type:"message",data:dN(e,t)};let n=e.charAt(0);return n==="b"?{type:"message",data:MR(e.substring(1),t)}:Ns[n]?e.length>1?{type:Ns[n],data:e.substring(1)}:{type:Ns[n]}:Es},MR=(e,t)=>{if(zR){let n=cN(e);return dN(n,t)}else return{base64:!0,data:e}},dN=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}}});function vN(){return new TransformStream({transform(e,t){sN(e,n=>{let a=n.length,i;if(a<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,a);else if(a<65536){i=new Uint8Array(3);let r=new DataView(i.buffer);r.setUint8(0,126),r.setUint16(1,a)}else{i=new Uint8Array(9);let r=new DataView(i.buffer);r.setUint8(0,127),r.setBigUint64(1,BigInt(a))}e.data&&typeof e.data!="string"&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})}function Ju(e){return e.reduce((t,n)=>t+n.length,0)}function $u(e,t){if(e[0].length===t)return e.shift();let n=new Uint8Array(t),a=0;for(let i=0;i<t;i++)n[i]=e[0][a++],a===e[0].length&&(e.shift(),a=0);return e.length&&a<e[0].length&&(e[0]=e[0].slice(a)),n}function yN(e,t){km||(km=new TextDecoder);let n=[],a=0,i=-1,r=!1;return new TransformStream({transform(l,s){for(n.push(l);;){if(a===0){if(Ju(n)<1)break;let o=$u(n,1);r=(o[0]&128)===128,i=o[0]&127,i<126?a=3:i===126?a=1:a=2}else if(a===1){if(Ju(n)<2)break;let o=$u(n,2);i=new DataView(o.buffer,o.byteOffset,o.length).getUint16(0),a=3}else if(a===2){if(Ju(n)<8)break;let o=$u(n,8),u=new DataView(o.buffer,o.byteOffset,o.length),c=u.getUint32(0);if(c>Math.pow(2,21)-1){s.enqueue(Es);break}i=c*Math.pow(2,32)+u.getUint32(4),a=3}else{if(Ju(n)<i)break;let o=$u(n,i);s.enqueue(ws(r?o:km.decode(o),t)),a=0}if(i===0||i>e){s.enqueue(Es);break}}}})}var mN,hN,gN,km,Tm,qr=b(()=>{oN();pN();Zu();mN="",hN=(e,t)=>{let n=e.length,a=new Array(n),i=0;e.forEach((r,l)=>{ks(r,!1,s=>{a[l]=s,++i===n&&t(a.join(mN))})})},gN=(e,t)=>{let n=e.split(mN),a=[];for(let i=0;i<n.length;i++){let r=ws(n[i],t);if(a.push(r),r.type==="error")break}return a};Tm=4});function Ie(e){if(e)return UR(e)}function UR(e){for(var t in Ie.prototype)e[t]=Ie.prototype[t];return e}var Li=b(()=>{Ie.prototype.on=Ie.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this};Ie.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this};Ie.prototype.off=Ie.prototype.removeListener=Ie.prototype.removeAllListeners=Ie.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var a,i=0;i<n.length;i++)if(a=n[i],a===t||a.fn===t){n.splice(i,1);break}return n.length===0&&delete this._callbacks["$"+e],this};Ie.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],a=1;a<arguments.length;a++)t[a-1]=arguments[a];if(n){n=n.slice(0);for(var a=0,i=n.length;a<i;++a)n[a].apply(this,t)}return this};Ie.prototype.emitReserved=Ie.prototype.emit;Ie.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};Ie.prototype.hasListeners=function(e){return!!this.listeners(e).length}});var ba,Qt,bN,zi=b(()=>{ba=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,n)=>n(t,0),Qt=typeof self!="undefined"?self:typeof window!="undefined"?window:Function("return this")(),bN="arraybuffer"});function Ku(e,...t){return t.reduce((n,a)=>(e.hasOwnProperty(a)&&(n[a]=e[a]),n),{})}function Sa(e,t){t.useNativeTimers?(e.setTimeoutFn=BR.bind(Qt),e.clearTimeoutFn=VR.bind(Qt)):(e.setTimeoutFn=Qt.setTimeout.bind(Qt),e.clearTimeoutFn=Qt.clearTimeout.bind(Qt))}function SN(e){return typeof e=="string"?PR(e):Math.ceil((e.byteLength||e.size)*HR)}function PR(e){let t=0,n=0;for(let a=0,i=e.length;a<i;a++)t=e.charCodeAt(a),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(a++,n+=4);return n}function Wu(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}var BR,VR,HR,Mi=b(()=>{zi();BR=Qt.setTimeout,VR=Qt.clearTimeout;HR=1.33});function xN(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function NN(e){let t={},n=e.split("&");for(let a=0,i=n.length;a<i;a++){let r=n[a].split("=");t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}var wm=b(()=>{});var ec,xa,As=b(()=>{qr();Li();Mi();wm();ec=class extends Error{constructor(t,n,a){super(t),this.description=n,this.context=a,this.type="TransportError"}},xa=class extends Ie{constructor(t){super(),this.writable=!1,Sa(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,n,a){return super.emitReserved("error",new ec(t,n,a)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){let n=ws(t,this.socket.binaryType);this.onPacket(n)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,n={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){let t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){let n=xN(t);return n.length?"?"+n:""}}});var Cs,Am=b(()=>{As();Mi();qr();Cs=class extends xa{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";let n=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let a=0;this._polling&&(a++,this.once("pollComplete",function(){--a||n()})),this.writable||(a++,this.once("drain",function(){--a||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){let n=a=>{if(this.readyState==="opening"&&a.type==="open"&&this.onOpen(),a.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(a)};gN(t,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){let t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,hN(t,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let t=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=Wu()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}}});var EN,kN,TN=b(()=>{EN=!1;try{EN=typeof XMLHttpRequest!="undefined"&&"withCredentials"in new XMLHttpRequest}catch(e){}kN=EN});function qR(){}function wN(){for(let e in ti.requests)ti.requests.hasOwnProperty(e)&&ti.requests[e].abort()}function AN(e){let t=e.xdomain;try{if(typeof XMLHttpRequest!="undefined"&&(!t||kN))return new XMLHttpRequest}catch(n){}if(!t)try{return new Qt[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch(n){}}var Cm,ti,jR,ni,tc=b(()=>{Am();Li();Mi();zi();TN();Cm=class extends Cs{constructor(t){if(super(t),typeof location!="undefined"){let n=location.protocol==="https:",a=location.port;a||(a=n?"443":"80"),this.xd=typeof location!="undefined"&&t.hostname!==location.hostname||a!==t.port}}doWrite(t,n){let a=this.request({method:"POST",data:t});a.on("success",n),a.on("error",(i,r)=>{this.onError("xhr post error",i,r)})}doPoll(){let t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(n,a)=>{this.onError("xhr poll error",n,a)}),this.pollXhr=t}},ti=class e extends Ie{constructor(t,n,a){super(),this.createRequest=t,Sa(this,a),this._opts=a,this._method=a.method||"GET",this._uri=n,this._data=a.data!==void 0?a.data:null,this._create()}_create(){var t;let n=Ku(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;let a=this._xhr=this.createRequest(n);try{a.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){a.setDisableHeaderCheck&&a.setDisableHeaderCheck(!0);for(let i in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(i)&&a.setRequestHeader(i,this._opts.extraHeaders[i])}}catch(i){}if(this._method==="POST")try{a.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(i){}try{a.setRequestHeader("Accept","*/*")}catch(i){}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(a),"withCredentials"in a&&(a.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(a.timeout=this._opts.requestTimeout),a.onreadystatechange=()=>{var i;a.readyState===3&&((i=this._opts.cookieJar)===null||i===void 0||i.parseCookies(a.getResponseHeader("set-cookie"))),a.readyState===4&&(a.status===200||a.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof a.status=="number"?a.status:0)},0))},a.send(this._data)}catch(i){this.setTimeoutFn(()=>{this._onError(i)},0);return}typeof document!="undefined"&&(this._index=e.requestsCount++,e.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr=="undefined"||this._xhr===null)){if(this._xhr.onreadystatechange=qR,t)try{this._xhr.abort()}catch(n){}typeof document!="undefined"&&delete e.requests[this._index],this._xhr=null}}_onLoad(){let t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}};ti.requestsCount=0;ti.requests={};if(typeof document!="undefined"){if(typeof attachEvent=="function")attachEvent("onunload",wN);else if(typeof addEventListener=="function"){let e="onpagehide"in Qt?"pagehide":"unload";addEventListener(e,wN,!1)}}jR=(function(){let e=AN({xdomain:!1});return e&&e.responseType!==null})(),ni=class extends Cm{constructor(t){super(t);let n=t&&t.forceBase64;this.supportsBinary=jR&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new ti(AN,this.uri(),t)}}});var CN,_m,Rm,ai,nc=b(()=>{As();Mi();qr();zi();CN=typeof navigator!="undefined"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",_m=class extends xa{get name(){return"websocket"}doOpen(){let t=this.uri(),n=this.opts.protocols,a=CN?{}:Ku(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(a.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,n,a)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let n=0;n<t.length;n++){let a=t[n],i=n===t.length-1;ks(a,this.supportsBinary,r=>{try{this.doWrite(a,r)}catch(l){}i&&ba(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws!="undefined"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let t=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=Wu()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}},Rm=Qt.WebSocket||Qt.MozWebSocket,ai=class extends _m{createSocket(t,n,a){return CN?new Rm(t,n,a):n?new Rm(t,n):new Rm(t)}doWrite(t,n){this.ws.send(n)}}});var jr,Dm=b(()=>{As();zi();qr();jr=class extends xa{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{let n=yN(Number.MAX_SAFE_INTEGER,this.socket.binaryType),a=t.readable.pipeThrough(n).getReader(),i=vN();i.readable.pipeTo(t.writable),this._writer=i.writable.getWriter();let r=()=>{a.read().then(({done:s,value:o})=>{s||(this.onPacket(o),r())}).catch(s=>{})};r();let l={type:"open"};this.query.sid&&(l.data=`{"sid":"${this.query.sid}"}`),this._writer.write(l).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let n=0;n<t.length;n++){let a=t[n],i=n===t.length-1;this._writer.write(a).then(()=>{i&&ba(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}});var Om,Lm=b(()=>{tc();nc();Dm();Om={websocket:ai,webtransport:jr,polling:ni}});function Yr(e){if(e.length>8e3)throw"URI too long";let t=e,n=e.indexOf("["),a=e.indexOf("]");n!=-1&&a!=-1&&(e=e.substring(0,n)+e.substring(n,a).replace(/:/g,";")+e.substring(a,e.length));let i=YR.exec(e||""),r={},l=14;for(;l--;)r[IR[l]]=i[l]||"";return n!=-1&&a!=-1&&(r.source=t,r.host=r.host.substring(1,r.host.length-1).replace(/;/g,":"),r.authority=r.authority.replace("[","").replace("]","").replace(/;/g,":"),r.ipv6uri=!0),r.pathNames=GR(r,r.path),r.queryKey=XR(r,r.query),r}function GR(e,t){let n=/\/{2,9}/g,a=t.replace(n,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&a.splice(0,1),t.slice(-1)=="/"&&a.splice(a.length-1,1),a}function XR(e,t){let n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(a,i,r){i&&(n[i]=r)}),n}var YR,IR,zm=b(()=>{YR=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,IR=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"]});var Mm,ac,Ui,ic,Ir,Um=b(()=>{Lm();Mi();wm();zm();Li();qr();zi();Mm=typeof addEventListener=="function"&&typeof removeEventListener=="function",ac=[];Mm&&addEventListener("offline",()=>{ac.forEach(e=>e())},!1);Ui=class e extends Ie{constructor(t,n){if(super(),this.binaryType=bN,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(n=t,t=null),t){let a=Yr(t);n.hostname=a.host,n.secure=a.protocol==="https"||a.protocol==="wss",n.port=a.port,a.query&&(n.query=a.query)}else n.host&&(n.hostname=Yr(n.host).host);Sa(this,n),this.secure=n.secure!=null?n.secure:typeof location!="undefined"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location!="undefined"?location.hostname:"localhost"),this.port=n.port||(typeof location!="undefined"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(a=>{let i=a.prototype.name;this.transports.push(i),this._transportsByName[i]=a}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=NN(this.opts.query)),Mm&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},ac.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){let n=Object.assign({},this.opts.query);n.EIO=Tm,n.transport=t,this.id&&(n.sid=this.id);let a=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](a)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}let t=this.opts.rememberUpgrade&&e.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";let n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",e.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":let n=new Error("server error");n.code=t.data,this._onError(n);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let a=0;a<this.writeBuffer.length;a++){let i=this.writeBuffer[a].data;if(i&&(n+=SN(i)),a>0&&n>this._maxPayload)return this.writeBuffer.slice(0,a);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,ba(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,n,a){return this._sendPacket("message",t,n,a),this}send(t,n,a){return this._sendPacket("message",t,n,a),this}_sendPacket(t,n,a,i){if(typeof n=="function"&&(i=n,n=void 0),typeof a=="function"&&(i=a,a=null),this.readyState==="closing"||this.readyState==="closed")return;a=a||{},a.compress=a.compress!==!1;let r={type:t,data:n,options:a};this.emitReserved("packetCreate",r),this.writeBuffer.push(r),i&&this.once("flush",i),this.flush()}close(){let t=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),t()},a=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?a():t()}):this.upgrading?a():t()),this}_onError(t){if(e.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Mm&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){let a=ac.indexOf(this._offlineEventListener);a!==-1&&ac.splice(a,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}};Ui.protocol=Tm;ic=class extends Ui{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let n=this.createTransport(t),a=!1;Ui.priorWebsocketSuccess=!1;let i=()=>{a||(n.send([{type:"ping",data:"probe"}]),n.once("packet",p=>{if(!a)if(p.type==="pong"&&p.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;Ui.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{a||this.readyState!=="closed"&&(c(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{let d=new Error("probe error");d.transport=n.name,this.emitReserved("upgradeError",d)}}))};function r(){a||(a=!0,c(),n.close(),n=null)}let l=p=>{let d=new Error("probe error: "+p);d.transport=n.name,r(),this.emitReserved("upgradeError",d)};function s(){l("transport closed")}function o(){l("socket closed")}function u(p){n&&p.name!==n.name&&r()}let c=()=>{n.removeListener("open",i),n.removeListener("error",l),n.removeListener("close",s),this.off("close",o),this.off("upgrading",u)};n.once("open",i),n.once("error",l),n.once("close",s),this.once("close",o),this.once("upgrading",u),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{a||n.open()},200):n.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){let n=[];for(let a=0;a<t.length;a++)~this.transports.indexOf(t[a])&&n.push(t[a]);return n}},Ir=class extends ic{constructor(t,n={}){let a=typeof t=="object"?t:n;(!a.transports||a.transports&&typeof a.transports[0]=="string")&&(a.transports=(a.transports||["polling","websocket","webtransport"]).map(i=>Om[i]).filter(i=>!!i)),super(t,a)}}});var RN=b(()=>{Am()});var DU,rc=b(()=>{Um();Um();As();Lm();Mi();zm();zi();RN();tc();tc();nc();nc();Dm();DU=Ir.protocol});function _N(e,t="",n){let a=e;n=n||typeof location!="undefined"&&location,e==null&&(e=n.protocol+"//"+n.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=n.protocol+e:e=n.host+e),/^(https?|wss?):\/\//.test(e)||(typeof n!="undefined"?e=n.protocol+"//"+e:e="https://"+e),a=Yr(e)),a.port||(/^(http|ws)$/.test(a.protocol)?a.port="80":/^(http|ws)s$/.test(a.protocol)&&(a.port="443")),a.path=a.path||"/";let r=a.host.indexOf(":")!==-1?"["+a.host+"]":a.host;return a.id=a.protocol+"://"+r+":"+a.port+t,a.href=a.protocol+"://"+r+(n&&n.port===a.port?"":":"+a.port),a}var DN=b(()=>{rc()});function _s(e){return FR&&(e instanceof ArrayBuffer||ZR(e))||JR&&e instanceof Blob||$R&&e instanceof File}function Rs(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,a=e.length;n<a;n++)if(Rs(e[n]))return!0;return!1}if(_s(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return Rs(e.toJSON(),!0);for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&Rs(e[n]))return!0;return!1}var FR,ZR,ON,JR,$R,Bm=b(()=>{FR=typeof ArrayBuffer=="function",ZR=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,ON=Object.prototype.toString,JR=typeof Blob=="function"||typeof Blob!="undefined"&&ON.call(Blob)==="[object BlobConstructor]",$R=typeof File=="function"||typeof File!="undefined"&&ON.call(File)==="[object FileConstructor]"});function LN(e){let t=[],n=e.data,a=e;return a.data=Vm(n,t),a.attachments=t.length,{packet:a,buffers:t}}function Vm(e,t){if(!e)return e;if(_s(e)){let n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){let n=new Array(e.length);for(let a=0;a<e.length;a++)n[a]=Vm(e[a],t);return n}else if(typeof e=="object"&&!(e instanceof Date)){let n={};for(let a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=Vm(e[a],t));return n}return e}function zN(e,t){return e.data=Hm(e.data,t),delete e.attachments,e}function Hm(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=Hm(e[n],t);else if(typeof e=="object")for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=Hm(e[n],t));return e}var MN=b(()=>{Bm()});var Ym={};oc(Ym,{Decoder:()=>qm,Encoder:()=>Pm,PacketType:()=>be,protocol:()=>BN});function UN(e){return Object.prototype.toString.call(e)==="[object Object]"}var KR,BN,be,Pm,qm,jm,lc=b(()=>{Li();MN();Bm();KR=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],BN=5;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(be||(be={}));Pm=class{constructor(t){this.replacer=t}encode(t){return(t.type===be.EVENT||t.type===be.ACK)&&Rs(t)?this.encodeAsBinary({type:t.type===be.EVENT?be.BINARY_EVENT:be.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===be.BINARY_EVENT||t.type===be.BINARY_ACK)&&(n+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(n+=t.nsp+","),t.id!=null&&(n+=t.id),t.data!=null&&(n+=JSON.stringify(t.data,this.replacer)),n}encodeAsBinary(t){let n=LN(t),a=this.encodeAsString(n.packet),i=n.buffers;return i.unshift(a),i}};qm=class e extends Ie{constructor(t){super(),this.reviver=t}add(t){let n;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(t);let a=n.type===be.BINARY_EVENT;a||n.type===be.BINARY_ACK?(n.type=a?be.EVENT:be.ACK,this.reconstructor=new jm(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(_s(t)||t.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(t),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let n=0,a={type:Number(t.charAt(0))};if(be[a.type]===void 0)throw new Error("unknown packet type "+a.type);if(a.type===be.BINARY_EVENT||a.type===be.BINARY_ACK){let r=n+1;for(;t.charAt(++n)!=="-"&&n!=t.length;);let l=t.substring(r,n);if(l!=Number(l)||t.charAt(n)!=="-")throw new Error("Illegal attachments");a.attachments=Number(l)}if(t.charAt(n+1)==="/"){let r=n+1;for(;++n&&!(t.charAt(n)===","||n===t.length););a.nsp=t.substring(r,n)}else a.nsp="/";let i=t.charAt(n+1);if(i!==""&&Number(i)==i){let r=n+1;for(;++n;){let l=t.charAt(n);if(l==null||Number(l)!=l){--n;break}if(n===t.length)break}a.id=Number(t.substring(r,n+1))}if(t.charAt(++n)){let r=this.tryParse(t.substr(n));if(e.isPayloadValid(a.type,r))a.data=r;else throw new Error("invalid payload")}return a}tryParse(t){try{return JSON.parse(t,this.reviver)}catch(n){return!1}}static isPayloadValid(t,n){switch(t){case be.CONNECT:return UN(n);case be.DISCONNECT:return n===void 0;case be.CONNECT_ERROR:return typeof n=="string"||UN(n);case be.EVENT:case be.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&KR.indexOf(n[0])===-1);case be.ACK:case be.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},jm=class{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){let n=zN(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}});function xn(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var Im=b(()=>{});var WR,Gr,Gm=b(()=>{lc();Im();Li();WR=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),Gr=class extends Ie{constructor(t,n,a){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=n,a&&a.auth&&(this.auth=a.auth),this._opts=Object.assign({},a),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let t=this.io;this.subs=[xn(t,"open",this.onopen.bind(this)),xn(t,"packet",this.onpacket.bind(this)),xn(t,"error",this.onerror.bind(this)),xn(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...n){var a,i,r;if(WR.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(n.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;let l={type:be.EVENT,data:n};if(l.options={},l.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){let c=this.ids++,p=n.pop();this._registerAckCallback(c,p),l.id=c}let s=(i=(a=this.io.engine)===null||a===void 0?void 0:a.transport)===null||i===void 0?void 0:i.writable,o=this.connected&&!(!((r=this.io.engine)===null||r===void 0)&&r._hasPingExpired());return this.flags.volatile&&!s||(o?(this.notifyOutgoingListeners(l),this.packet(l)):this.sendBuffer.push(l)),this.flags={},this}_registerAckCallback(t,n){var a;let i=(a=this.flags.timeout)!==null&&a!==void 0?a:this._opts.ackTimeout;if(i===void 0){this.acks[t]=n;return}let r=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let s=0;s<this.sendBuffer.length;s++)this.sendBuffer[s].id===t&&this.sendBuffer.splice(s,1);n.call(this,new Error("operation has timed out"))},i),l=(...s)=>{this.io.clearTimeoutFn(r),n.apply(this,s)};l.withError=!0,this.acks[t]=l}emitWithAck(t,...n){return new Promise((a,i)=>{let r=(l,s)=>l?i(l):a(s);r.withError=!0,n.push(r),this.emit(t,...n)})}_addToQueue(t){let n;typeof t[t.length-1]=="function"&&(n=t.pop());let a={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((i,...r)=>a!==this._queue[0]?void 0:(i!==null?a.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(i)):(this._queue.shift(),n&&n(null,...r)),a.pending=!1,this._drainQueue())),this._queue.push(a),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;let n=this._queue[0];n.pending&&!t||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:be.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(a=>String(a.id)===t)){let a=this.acks[t];delete this.acks[t],a.withError&&a.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case be.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case be.EVENT:case be.BINARY_EVENT:this.onevent(t);break;case be.ACK:case be.BINARY_ACK:this.onack(t);break;case be.DISCONNECT:this.ondisconnect();break;case be.CONNECT_ERROR:this.destroy();let a=new Error(t.data.message);a.data=t.data.data,this.emitReserved("connect_error",a);break}}onevent(t){let n=t.data||[];t.id!=null&&n.push(this.ack(t.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){let n=this._anyListeners.slice();for(let a of n)a.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){let n=this,a=!1;return function(...i){a||(a=!0,n.packet({type:be.ACK,id:t,data:i}))}}onack(t){let n=this.acks[t.id];typeof n=="function"&&(delete this.acks[t.id],n.withError&&t.data.unshift(null),n.apply(this,t.data))}onconnect(t,n){this.id=t,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:be.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){let n=this._anyListeners;for(let a=0;a<n.length;a++)if(t===n[a])return n.splice(a,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){let n=this._anyOutgoingListeners;for(let a=0;a<n.length;a++)if(t===n[a])return n.splice(a,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let n=this._anyOutgoingListeners.slice();for(let a of n)a.apply(this,t.data)}}}});function Bi(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}var VN=b(()=>{Bi.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=(Math.floor(t*10)&1)==0?e-n:e+n}return Math.min(e,this.max)|0};Bi.prototype.reset=function(){this.attempts=0};Bi.prototype.setMin=function(e){this.ms=e};Bi.prototype.setMax=function(e){this.max=e};Bi.prototype.setJitter=function(e){this.jitter=e}});var Xr,HN=b(()=>{rc();Gm();lc();Im();VN();Li();Xr=class extends Ie{constructor(t,n){var a;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(n=t,t=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,Sa(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((a=n.randomizationFactor)!==null&&a!==void 0?a:.5),this.backoff=new Bi({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=t;let i=n.parser||Ym;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var n;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(n=this.backoff)===null||n===void 0||n.setMin(t),this)}randomizationFactor(t){var n;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(n=this.backoff)===null||n===void 0||n.setJitter(t),this)}reconnectionDelayMax(t){var n;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(n=this.backoff)===null||n===void 0||n.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new Ir(this.uri,this.opts);let n=this.engine,a=this;this._readyState="opening",this.skipReconnect=!1;let i=xn(n,"open",function(){a.onopen(),t&&t()}),r=s=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",s),t?t(s):this.maybeReconnectOnOpen()},l=xn(n,"error",r);if(this._timeout!==!1){let s=this._timeout,o=this.setTimeoutFn(()=>{i(),r(new Error("timeout")),n.close()},s);this.opts.autoUnref&&o.unref(),this.subs.push(()=>{this.clearTimeoutFn(o)})}return this.subs.push(i),this.subs.push(l),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");let t=this.engine;this.subs.push(xn(t,"ping",this.onping.bind(this)),xn(t,"data",this.ondata.bind(this)),xn(t,"error",this.onerror.bind(this)),xn(t,"close",this.onclose.bind(this)),xn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(n){this.onclose("parse error",n)}}ondecoded(t){ba(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,n){let a=this.nsps[t];return a?this._autoConnect&&!a.active&&a.connect():(a=new Gr(this,t,n),this.nsps[t]=a),a}_destroy(t){let n=Object.keys(this.nsps);for(let a of n)if(this.nsps[a].active)return;this._close()}_packet(t){let n=this.encoder.encode(t);for(let a=0;a<n.length;a++)this.engine.write(n[a],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,n){var a;this.cleanup(),(a=this.engine)===null||a===void 0||a.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let n=this.backoff.duration();this._reconnecting=!0;let a=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(i=>{i?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",i)):t.onreconnect()}))},n);this.opts.autoUnref&&a.unref(),this.subs.push(()=>{this.clearTimeoutFn(a)})}}onreconnect(){let t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}});function Os(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};let n=_N(e,t.path||"/socket.io"),a=n.source,i=n.id,r=n.path,l=Ds[i]&&r in Ds[i].nsps,s=t.forceNew||t["force new connection"]||t.multiplex===!1||l,o;return s?o=new Xr(a,t):(Ds[i]||(Ds[i]=new Xr(a,t)),o=Ds[i]),n.query&&!t.query&&(t.query=n.queryKey),o.socket(n.path,t)}var Ds,PN=b(()=>{DN();HN();Gm();lc();rc();Ds={};Object.assign(Os,{Manager:Xr,Socket:Gr,io:Os,connect:Os})});var rn,ge,Xm,qN=b(()=>{"use strict";rn=F(Je());PN();an();ge=F(re()),Xm=({apiKey:e,agentId:t,sandboxId:n})=>{let[a,i]=(0,rn.useState)([]),[r,l]=(0,rn.useState)(!1),[s,o]=(0,rn.useState)(new Set),[u,c]=(0,rn.useState)(!0),[p,d]=(0,rn.useState)(!1),f=(0,rn.useRef)(null),S=(0,rn.useRef)(null),x=(0,rn.useRef)(null),k=()=>{var g;(g=f.current)==null||g.scrollIntoView({behavior:"smooth"})},m=g=>{o(E=>{let T=new Set(E);return T.has(g)?T.delete(g):T.add(g),T})},h=()=>z(null,null,function*(){try{console.log("Clearing logs from all sandbox skills with API key:",e,"agentId:",t),d(!0);let g=yield ie.getAllSkillOverrides();if(g.length===0){console.log("No skills found to clear logs from"),i([]),o(new Set);return}let E=g.map(A=>z(null,null,function*(){try{return yield ie.clearSandboxLogs(e,t,A.sandboxId)}catch(C){return console.error(`Error clearing logs for skill ${A.skillId}:`,C),{success:!1,error:"Failed to clear logs"}}}));(yield Promise.all(E)).every(A=>A.success)?(i([]),o(new Set),console.log("All logs cleared successfully")):(console.error("Some log clearing operations failed"),alert("Some logs could not be cleared. Check console for details."))}catch(g){console.error("Failed to clear logs:",g),alert("Failed to clear logs")}finally{d(!1)}});return(0,rn.useEffect)(()=>{k()},[a]),(0,rn.useEffect)(()=>{e&&t&&z(null,null,function*(){try{console.log("Loading logs from all sandbox skills with API key:",e,"agentId:",t),c(!0);let E=yield ie.loadAllSandboxLogs(e,t,100);if(console.log("All sandbox logs response:",E),E.success&&E.data){let T=E.data.logs.map(N=>({_id:N._id,id:N.id,timestamp:new Date(N.timestamp).toLocaleTimeString(),type:N.type,subType:N.subType,message:N.message,duration:N.duration,error:N.error,metadata:N.metadata,skillName:N.skillName,sandboxId:N.sandboxId}));console.log("Converted logs from all skills:",T),i(T)}else console.log("No logs or error:",E.error)}catch(E){console.error("Failed to load logs from all skills:",E)}finally{c(!1)}})},[e,t]),(0,rn.useEffect)(()=>{let g=()=>{try{let N=new WebSocket("ws://localhost:3000");S.current=N,N.onopen=()=>{console.log("Connected to CLI dev server"),l(!0)},N.onclose=()=>{console.log("Disconnected from CLI dev server")},N.onmessage=A=>{try{let C=JSON.parse(A.data);if(console.log("Received message from CLI:",C),C.type==="log"){let U={id:C.id||Date.now().toString(),timestamp:new Date(C.timestamp||Date.now()).toLocaleTimeString(),type:C.type||"log",subType:C.subType||"info",message:C.message||"No message",metadata:C.metadata||{},error:C.error};i(P=>[...P,U])}}catch(C){console.error("Failed to parse CLI WebSocket message:",C)}},N.onerror=A=>{console.error("CLI WebSocket error:",A)}}catch(N){console.error("Failed to connect to CLI dev server:",N)}},E=()=>{try{let N=Os("wss://api.lua.dev/feed",{query:{apiKey:e,channel:"logs"}});x.current=N,N.on("connect",()=>{console.log("Connected to server log feed"),l(!0),T("\u{1F7E2} Connected to log feed","connected")}),N.on("disconnect",()=>{console.log("Disconnected from server log feed"),l(!1),T("\u{1F534} Disconnected from log feed","disconnected")}),N.on("log",A=>{let C="info",U="No message",P={},_="";if(A&&typeof A=="object"){let O=A.data||A;C=O.subType||"info",U=O.message||"No message",P=O.metadata||{},_=O.error||O.details||"",_&&typeof _=="object"&&(_=JSON.stringify(_,null,2))}else typeof A=="string"&&(U=A,C="info");let R={id:Date.now().toString(),timestamp:new Date().toLocaleTimeString(),type:"log",subType:C,message:U,metadata:P,error:_};i(O=>[...O,R])}),N.on("connect_error",A=>{T("\u{1F534} Connection failed","disconnected")})}catch(N){T("\u{1F534} Connection error","disconnected")}},T=(N,A)=>{let C=document.getElementById("logConnectionStatus");C&&(C.textContent=N,C.className=`log-connection-status ${A}`)};return g(),e&&t&&n&&E(),()=>{S.current&&S.current.close(),x.current&&x.current.disconnect()}},[e,t,n]),(0,ge.jsxs)("div",{className:"log-messages",children:[(0,ge.jsxs)("div",{className:"logs-header",children:[(0,ge.jsxs)("div",{className:"logs-title",children:["Console Logs (",a.length,")"]}),(0,ge.jsx)("div",{className:"logs-actions",children:(0,ge.jsx)("button",{className:"clear-logs-button",onClick:h,disabled:p,title:"Clear all logs",children:p?"\u27F3":"\u{1F5D1}\uFE0F"})})]}),(0,ge.jsxs)("div",{className:"log-content",children:[u?(0,ge.jsx)("div",{className:"no-logs",children:(0,ge.jsx)("img",{src:"https://admin.lua.dev/images/logo.svg",alt:"Loading",className:"loading-logo"})}):a.length===0?(0,ge.jsxs)("div",{className:"no-logs",children:[(0,ge.jsx)("div",{className:"no-logs-icon",children:"\u{1F4CB}"}),(0,ge.jsx)("div",{className:"no-logs-text",children:"No logs yet"}),(0,ge.jsx)("div",{className:"no-logs-subtext",children:"Console logs will appear here when your skill runs"})]}):(0,ge.jsx)(ge.Fragment,{children:a.map(g=>{let E=s.has(g.id),T=g.metadata&&Object.keys(g.metadata).length>0,N=g.error&&typeof g.error=="string"&&g.error.trim()!=="",A=T||N;return(0,ge.jsxs)("div",{className:`log-entry ${g.subType}`,children:[(0,ge.jsxs)("div",{className:"log-main",onClick:()=>m(g.id),children:[(0,ge.jsxs)("span",{className:"log-timestamp",children:["[",g.timestamp,"]"]}),(0,ge.jsxs)("span",{className:"log-type",children:["[",g.subType.toUpperCase(),"]"]}),g.skillName&&(0,ge.jsxs)("span",{className:"log-skill",children:["[",g.skillName,"]"]}),(0,ge.jsx)("span",{className:`log-message ${E?"expanded":"ellipsed"}`,children:g.message}),(0,ge.jsx)("span",{className:`expand-arrow ${E?"expanded":""}`,children:"\u25B6"})]}),E&&(0,ge.jsxs)("div",{className:"log-details",children:[(0,ge.jsxs)("div",{className:"full-message",children:[(0,ge.jsx)("div",{className:"detail-label",children:"Message:"}),(0,ge.jsx)("div",{className:"detail-content",children:g.message})]}),N&&(0,ge.jsxs)("div",{className:"error-details",children:[(0,ge.jsx)("div",{className:"detail-label",children:"Error:"}),(0,ge.jsx)("div",{className:"detail-content",children:typeof g.error=="string"?g.error:JSON.stringify(g.error)})]}),T&&(0,ge.jsxs)("div",{className:"metadata",children:[(0,ge.jsx)("div",{className:"detail-label",children:"Metadata:"}),Object.entries(g.metadata).map(([C,U])=>(0,ge.jsxs)("div",{className:"metadata-item",children:[(0,ge.jsxs)("span",{className:"metadata-key",children:[C,":"]}),(0,ge.jsx)("span",{className:"metadata-value",children:String(U)})]},C))]})]})]},g.id)})}),(0,ge.jsx)("div",{ref:f})]}),(0,ge.jsx)("div",{className:"log-footer-status",children:(0,ge.jsx)("div",{id:"logConnectionStatus",className:"log-connection-status",children:"\u{1F7E1} Connecting..."})})]})}});var jN=b(()=>{});var YN,IN,GN=b(()=>{"use strict";YN=F(Je());an();jN();IN=F(re())});var XN=b(()=>{"use strict";eN();tN();qN();hm();bm();xm();GN();vm()});var Nn,Un,QN,FN=b(()=>{"use strict";Nn=F(Je());XN();an();Un=F(re()),QN=({apiKey:e,agentId:t,skillId:n,sandboxId:a,sharedChatMessages:i,onSharedSendMessage:r,onSharedClearHistory:l,isChatLoading:s,setIsChatLoading:o})=>{let[u,c]=(0,Nn.useState)("persona"),[p,d]=(0,Nn.useState)(""),[f,S]=(0,Nn.useState)(window.innerWidth/2),[x,k]=(0,Nn.useState)(250),m=(0,Nn.useRef)(!1),h=(0,Nn.useRef)(!1),g=(0,Nn.useRef)(null),E=(0,Nn.useRef)(null);(0,Nn.useEffect)(()=>{T()},[]),(0,Nn.useEffect)(()=>{let A=P=>{var R,O;let _=P.target;_===g.current||(R=g.current)!=null&&R.contains(_)?(m.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none",P.preventDefault()):(_===E.current||(O=E.current)!=null&&O.contains(_))&&(h.current=!0,document.body.style.cursor="row-resize",document.body.style.userSelect="none",P.preventDefault())},C=P=>{if(m.current){let _=window.innerWidth,R=_-P.clientX,O=500,I=_-300;R>=O&&R<=I&&S(R)}else if(h.current){let _=window.innerHeight-60,R=_-P.clientY+60,O=150,I=_-300;R>=O&&R<=I&&k(R)}},U=()=>{m.current?(m.current=!1,document.body.style.cursor="",document.body.style.userSelect=""):h.current&&(h.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousedown",A),document.addEventListener("mousemove",C),document.addEventListener("mouseup",U),()=>{document.removeEventListener("mousedown",A),document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",U)}},[]);let T=()=>z(null,null,function*(){try{let A=yield ie.loadPersona();A.success&&d(A.persona||"")}catch(A){console.error("Failed to load persona:",A)}}),N=A=>z(null,null,function*(){try{let C=yield ie.savePersona(A);return C.success?(d(A),!0):(alert("Failed to save persona: "+(C.error||"Unknown error")),!1)}catch(C){return console.error("Failed to save persona:",C),alert("Failed to save persona"),!1}});return(0,Un.jsxs)("div",{className:"sandbox-page",children:[(0,Un.jsxs)("div",{className:"left-side",style:{width:`calc(100% - ${f}px)`},children:[(0,Un.jsx)("div",{className:"chat-container",style:{height:`calc(100% - ${x}px)`},children:(0,Un.jsx)(pm,{apiKey:e,agentId:t,skillId:n,sandboxId:a,persona:p,sharedChatMessages:i,onSharedSendMessage:r,onSharedClearHistory:l,isChatLoading:s,setIsChatLoading:o})}),(0,Un.jsx)("div",{ref:E,className:"logs-resize-handle",children:(0,Un.jsx)("div",{className:"resize-line"})}),(0,Un.jsx)("div",{className:"logs-container",style:{height:`${x}px`},children:(0,Un.jsx)(Xm,{apiKey:e,agentId:t,sandboxId:a})})]}),(0,Un.jsx)("div",{ref:g,className:"resize-handle"}),(0,Un.jsx)(Nm,{activeTab:u,onTabChange:c,persona:p,onSavePersona:N,apiKey:e,agentId:t,skillId:n,sandboxId:a,width:f})]})}});var ZN,qt,Qm,JN=b(()=>{"use strict";ZN=F(Je());fm();qt=F(re()),Qm=({messages:e,onSendMessage:t,onClearHistory:n,isLoading:a})=>{let[i,r]=(0,ZN.useState)(""),l=e.length>0?e:[{id:"welcome",text:"Welcome to Production Management! I can help you monitor deployments, analyze performance, and manage your live environment. How can I assist you today?",sender:"assistant",timestamp:new Date}],s=()=>{!i.trim()||a||(t(i),r(""))},o=u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),s())};return(0,qt.jsxs)("div",{className:"production-chat",children:[(0,qt.jsxs)("div",{className:"chat-header",children:[(0,qt.jsx)("h3",{children:"Production Chat"}),(0,qt.jsx)("button",{onClick:n,className:"clear-history-button",title:"Clear chat history",children:"\u{1F5D1}\uFE0F"})]}),(0,qt.jsxs)("div",{className:"chat-messages",children:[l.map(u=>(0,qt.jsx)("div",{className:`message ${u.sender}`,children:(0,qt.jsx)("div",{className:"message-bubble",children:(0,qt.jsx)(Ss,{children:u.text})})},u.id)),a&&(0,qt.jsx)("div",{className:"loading",children:(0,qt.jsx)("img",{src:"https://admin.lua.dev/images/logo.svg",alt:"Loading",className:"loading-logo"})})]}),(0,qt.jsx)("div",{className:"chat-input-container",children:(0,qt.jsxs)("div",{className:"chat-input-form",children:[(0,qt.jsx)("input",{type:"text",id:"production-chat-input",name:"productionChatMessage",value:i,onChange:u=>r(u.target.value),onKeyPress:o,placeholder:"Type your message...",className:"chat-input",disabled:a,autoComplete:"off"}),(0,qt.jsx)("button",{onClick:s,disabled:a||!i.trim(),className:"send-button",children:"Send"})]})})]})}});var e_,$N,KN=b(()=>{"use strict";e_=F(Je()),$N=F(re())});var t_,WN,Fm=b(()=>{"use strict";t_=F(Je()),WN=F(re())});var a_,eE,tE=b(()=>{"use strict";a_=F(Je());Fm();eE=F(re())});var ln,te,Zm,nE=b(()=>{"use strict";ln=F(Je());an();te=F(re()),Zm=({apiKey:e,agentId:t})=>{let[n,a]=(0,ln.useState)([]),[i,r]=(0,ln.useState)(!0),[l,s]=(0,ln.useState)(new Set),[o,u]=(0,ln.useState)(1),[c,p]=(0,ln.useState)(1),[d,f]=(0,ln.useState)(0),[S,x]=(0,ln.useState)(!1),[k,m]=(0,ln.useState)(!1),h=(0,ln.useRef)(null),g=()=>{var _;(_=h.current)==null||_.scrollIntoView({behavior:"smooth"})},E=_=>{s(R=>{let O=new Set(R);return O.has(_)?O.delete(_):O.add(_),O})},T=(_=1)=>z(null,null,function*(){r(!0);try{console.log("Loading production logs for page:",_);let R=yield ie.loadProductionLogs(e,t,_,20);if(R.success&&R.logs){let O=[...R.logs].reverse();a(O),R.pagination&&(u(R.pagination.currentPage),p(R.pagination.totalPages),f(R.pagination.totalCount),x(R.pagination.hasNextPage),m(R.pagination.hasPrevPage))}else console.error("Failed to load production logs:",R.error),a([])}catch(R){console.error("Error loading production logs:",R),a([])}finally{r(!1)}}),N=()=>{T(o)},A=_=>{_>=1&&_<=c&&(u(_),T(_))},C=()=>{S&&A(o+1)},U=()=>{k&&A(o-1)};(0,ln.useEffect)(()=>{e&&t&&T(1)},[e,t]),(0,ln.useEffect)(()=>{g()},[n]);let P=_=>new Date(_).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});return i&&n.length===0?(0,te.jsx)("div",{className:"logs-panel",children:(0,te.jsx)("div",{className:"logs-loading",children:(0,te.jsx)("img",{src:"https://admin.lua.dev/images/logo.svg",alt:"Loading",className:"loading-logo"})})}):(0,te.jsxs)("div",{className:"logs-panel",children:[(0,te.jsxs)("div",{className:"logs-header",children:[(0,te.jsxs)("div",{className:"logs-header-content",children:[(0,te.jsx)("h3",{children:"Production Logs"}),(0,te.jsx)("div",{className:"logs-info",children:d>0&&(0,te.jsxs)("span",{className:"logs-count",children:[d," total logs"]})})]}),(0,te.jsx)("div",{className:"logs-actions",children:(0,te.jsx)("button",{className:"refresh-logs-button",onClick:N,disabled:i,title:"Refresh logs",children:i?(0,te.jsx)("img",{src:"https://admin.lua.dev/images/logo.svg",alt:"Loading",className:"loading-logo-button"}):"\u21BB"})})]}),(0,te.jsx)("div",{className:"logs-content",children:n.length===0?(0,te.jsxs)("div",{className:"no-logs",children:[(0,te.jsx)("div",{className:"no-logs-icon",children:"\u{1F4DD}"}),(0,te.jsx)("div",{className:"no-logs-text",children:"No logs found"}),(0,te.jsx)("div",{className:"no-logs-subtext",children:"Production logs will appear here when your skills are used"})]}):(0,te.jsxs)("div",{className:"logs-list",children:[n.map(_=>{var I,B,J,ae;let R=l.has(_.id),O=_.metadata&&(_.metadata.toolId||_.metadata.skillName);return(0,te.jsxs)("div",{className:`log-entry ${_.subType} ${R?"expanded":""}`,children:[(0,te.jsxs)("div",{className:"log-main",onClick:()=>O&&E(_.id),style:{cursor:O?"pointer":"default"},children:[(0,te.jsx)("span",{className:"log-timestamp",children:P(_.timestamp)}),(0,te.jsx)("span",{className:`log-level ${_.subType}`,children:_.subType.toUpperCase()}),(0,te.jsx)("span",{className:"log-message",children:_.message}),((I=_.metadata)==null?void 0:I.skillName)&&(0,te.jsx)("span",{className:"log-skill",children:_.metadata.skillName}),O&&(0,te.jsx)("span",{className:`expand-arrow ${R?"expanded":""}`,children:"\u25B6"})]}),R&&O&&(0,te.jsxs)("div",{className:"log-details",children:[((B=_.metadata)==null?void 0:B.toolId)&&(0,te.jsxs)("div",{className:"metadata-item",children:[(0,te.jsx)("span",{className:"metadata-key",children:"Tool:"}),(0,te.jsx)("span",{className:"metadata-value",children:_.metadata.toolId})]}),((J=_.metadata)==null?void 0:J.skillName)&&(0,te.jsxs)("div",{className:"metadata-item",children:[(0,te.jsx)("span",{className:"metadata-key",children:"Skill:"}),(0,te.jsx)("span",{className:"metadata-value",children:_.metadata.skillName})]}),((ae=_.metadata)==null?void 0:ae.userId)&&(0,te.jsxs)("div",{className:"metadata-item",children:[(0,te.jsx)("span",{className:"metadata-key",children:"User:"}),(0,te.jsx)("span",{className:"metadata-value",children:_.metadata.userId})]})]})]},_.id)}),(0,te.jsx)("div",{ref:h})]})}),c>1&&(0,te.jsxs)("div",{className:"logs-pagination",children:[(0,te.jsxs)("div",{className:"pagination-info",children:["Page ",o," of ",c]}),(0,te.jsxs)("div",{className:"pagination-controls",children:[(0,te.jsx)("button",{className:"pagination-button",onClick:U,disabled:!k||i,title:"Previous page",children:"\u2190"}),(0,te.jsxs)("span",{className:"page-numbers",children:[o>2&&(0,te.jsxs)(te.Fragment,{children:[(0,te.jsx)("button",{className:"page-number",onClick:()=>A(1),disabled:i,children:"1"}),o>3&&(0,te.jsx)("span",{className:"page-ellipsis",children:"..."})]}),o>1&&(0,te.jsx)("button",{className:"page-number",onClick:()=>A(o-1),disabled:i,children:o-1}),(0,te.jsx)("button",{className:"page-number active",disabled:!0,children:o}),o<c&&(0,te.jsx)("button",{className:"page-number",onClick:()=>A(o+1),disabled:i,children:o+1}),o<c-1&&(0,te.jsxs)(te.Fragment,{children:[o<c-2&&(0,te.jsx)("span",{className:"page-ellipsis",children:"..."}),(0,te.jsx)("button",{className:"page-number",onClick:()=>A(c),disabled:i,children:c})]})]}),(0,te.jsx)("button",{className:"pagination-button",onClick:C,disabled:!S||i,title:"Next page",children:"\u2192"})]})]})]})}});var ze,H,Jm,i_,$m,r_,aE=b(()=>{"use strict";ze=F(Je());an();H=F(re()),Jm=e=>{if(!e||!e.trim())return e||"";try{let t=JSON.parse(e);return JSON.stringify(t,null,2).replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,a=>{let i="json-number";return/^"/.test(a)?/:$/.test(a)?i="json-key":i="json-string":/true|false/.test(a)?i="json-boolean":/null/.test(a)&&(i="json-null"),`<span class="${i}">${a}</span>`})}catch(t){return e.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,n=>{let a="json-number";return/^"/.test(n)?/:$/.test(n)?a="json-key":a="json-string":/true|false/.test(n)?a="json-boolean":/null/.test(n)&&(a="json-null"),`<span class="${a}">${n}</span>`})}},i_=[{id:"user",name:"User",description:"User profile and account data",icon:"\u{1F464}"},{id:"resources",name:"Resources",description:"Files, documents, and assets",icon:"\u{1F4C1}"},{id:"products",name:"Products",description:"Product catalog and inventory",icon:"\u{1F4E6}"},{id:"baskets",name:"Baskets",description:"Shopping carts and baskets",icon:"\u{1F6D2}"},{id:"orders",name:"Orders",description:"Order history and transactions",icon:"\u{1F4CB}"},{id:"booking",name:"Booking",description:"Reservations and appointments",icon:"\u{1F4C5}"},{id:"custom",name:"Custom",description:"Custom application data",icon:"\u2699\uFE0F"}],$m=({apiKey:e,agentId:t})=>{let[n,a]=(0,ze.useState)(null),[i,r]=(0,ze.useState)(null),[l,s]=(0,ze.useState)(null),[o,u]=(0,ze.useState)(!1),[c,p]=(0,ze.useState)(!1),[d,f]=(0,ze.useState)(!1),[S,x]=(0,ze.useState)(""),[k,m]=(0,ze.useState)(null),[h,g]=(0,ze.useState)(null),[E,T]=(0,ze.useState)(!1),[N,A]=(0,ze.useState)("list"),C=(0,ze.useRef)(null),U=(0,ze.useRef)(null),[P,_]=(0,ze.useState)(!1),[R,O]=(0,ze.useState)(""),[I,B]=(0,ze.useState)(""),[J,ae]=(0,ze.useState)(!1);(0,ze.useEffect)(()=>{we()},[e,t]),(0,ze.useEffect)(()=>{if(console.log("JSON text changed:",S),U.current&&C.current){let X=Jm(S);U.current.innerHTML=X,U.current.scrollTop=C.current.scrollTop,U.current.scrollLeft=C.current.scrollLeft}},[S]),(0,ze.useEffect)(()=>{if(k||h){let X=setTimeout(()=>{m(null),g(null)},5e3);return()=>clearTimeout(X)}},[k,h]);let we=()=>z(null,null,function*(){u(!0);try{let X=yield ie.loadUserData(e,t);console.log("User data response:",X),X.success&&X.data?(console.log("User data loaded successfully:",X.data),a(X.data),x(JSON.stringify(X.data,null,2))):(console.error("Failed to load user data:",X.error),a(null),x("{}"))}catch(X){console.error("Error loading user data:",X),a(null),x("{}")}finally{u(!1)}}),je=()=>z(null,null,function*(){if(S.trim()){p(!0);try{let X;try{X=JSON.parse(S)}catch(ne){m("Invalid JSON format. Please check your syntax.");return}let Q=yield ie.updateUserData(e,t,X);Q.success?(a(Q.data||null),T(!1),g("User data saved successfully"),console.log("User data saved successfully")):m("Failed to save user data: "+(Q.error||"Unknown error"))}catch(X){console.error("Error saving user data:",X),m("Failed to save user data")}finally{p(!1)}}}),v=()=>z(null,null,function*(){f(!0);try{let X=yield ie.clearUserData(e,t);X.success?(a(null),x("{}"),T(!1),g("User data cleared successfully"),console.log("User data cleared successfully")):m("Failed to clear user data: "+(X.error||"Unknown error"))}catch(X){console.error("Error clearing user data:",X),m("Failed to clear user data")}finally{f(!1)}}),Me=X=>z(null,null,function*(){if(r(X),A("detail"),T(!1),m(null),X.id==="user"){u(!0);try{let Q=yield ie.loadUserData(e,t);if(Q.success&&Q.data){s(Q.data);let ne=JSON.stringify(Q.data,null,2);x(ne),console.log("Setting JSON text for user data:",ne)}else s(null),x("{}"),console.log("No user data found, setting empty JSON")}catch(Q){console.error("Failed to load user data:",Q),s(null),x("{}")}finally{u(!1)}}else if(X.id==="resources"){u(!0);try{let Q=yield ie.loadResources(e,t);Q.success&&Q.data?(s(Q.data),console.log("Loaded resources:",Q.data)):(s([]),console.log("No resources found"))}catch(Q){console.error("Failed to load resources:",Q),s([])}finally{u(!1)}}else s(null),x("{}")}),pt=()=>{A("list"),r(null),s(null),T(!1)},y=()=>{(i==null?void 0:i.id)==="resources"?(_(!0),O(""),B("")):(x("{}"),T(!0))},Ke=()=>z(null,null,function*(){if(!R.trim()||!I.trim()){m("Please provide both name and content for the resource");return}ae(!0);try{let X=yield ie.createResource(e,t,{name:R.trim(),content:I.trim()});X.success?(_(!1),O(""),B(""),g("Resource created successfully"),(i==null?void 0:i.id)==="resources"&&(yield Me(i))):m("Failed to create resource: "+(X.error||"Unknown error"))}catch(X){console.error("Error creating resource:",X),m("Failed to create resource")}finally{ae(!1)}}),At=X=>{x(X),C.current&&U.current&&(U.current.scrollTop=C.current.scrollTop,U.current.scrollLeft=C.current.scrollLeft)},se=()=>{T(!0),setTimeout(()=>{C.current&&C.current.focus()},0)};return o&&N==="list"?(0,H.jsx)("div",{className:"user-data-panel",children:(0,H.jsx)("div",{className:"user-data-loading",children:(0,H.jsx)("img",{src:"https://admin.lua.dev/images/logo.svg",alt:"Loading",className:"loading-logo"})})}):(0,H.jsxs)("div",{className:"user-data-panel",children:[(0,H.jsxs)("div",{className:"user-data-header",children:[N==="detail"&&i?(0,H.jsxs)("div",{className:"header-with-back",children:[(0,H.jsx)("button",{className:"back-button",onClick:pt,title:"Back to Data",children:"\u2190"}),(0,H.jsxs)("h3",{children:[i.name," Data"]})]}):(0,H.jsx)("h3",{children:"Data Management"}),(0,H.jsxs)("div",{className:"user-data-actions",children:[N==="detail"&&(i==null?void 0:i.id)!=="user"&&(0,H.jsx)("button",{className:"add-button",onClick:y,title:`Add new ${i==null?void 0:i.name.toLowerCase()}`,children:"\u2795"}),(0,H.jsx)("button",{className:"refresh-button",onClick:N==="detail"&&i?()=>Me(i):we,disabled:o,title:`Refresh ${N==="detail"?i==null?void 0:i.name.toLowerCase():"data"}`,children:o?"\u27F3":"\u21BB"}),N==="detail"&&(i==null?void 0:i.id)==="user"&&(0,H.jsx)("button",{className:"save-button",onClick:je,disabled:c,title:"Save user data",children:c?"\u27F3":"\u{1F4BE}"}),N==="detail"&&(0,H.jsx)("button",{className:"delete-button",onClick:v,disabled:c,title:`Clear ${i==null?void 0:i.name.toLowerCase()} data`,children:"\u{1F5D1}\uFE0F"})]})]}),(0,H.jsx)("div",{className:"user-data-content",children:N==="list"?(0,H.jsx)("div",{className:"data-list",children:(0,H.jsx)("div",{className:"data-categories",children:i_.map(X=>(0,H.jsxs)("div",{className:"data-category",onClick:()=>Me(X),children:[(0,H.jsx)("div",{className:"category-icon",children:X.icon}),(0,H.jsxs)("div",{className:"category-info",children:[(0,H.jsx)("div",{className:"category-name",children:X.name}),(0,H.jsx)("div",{className:"category-description",children:X.description})]}),(0,H.jsx)("div",{className:"category-arrow",children:"\u2192"})]},X.id))})}):(i==null?void 0:i.id)==="user"?(0,H.jsx)("div",{className:"data-detail",children:o?(0,H.jsx)("div",{className:"loading-container",children:(0,H.jsx)("img",{src:"https://admin.lua.dev/images/logo.svg",alt:"Loading",className:"loading-logo"})}):(0,H.jsx)("div",{className:"json-editor",children:E?(0,H.jsxs)("div",{className:"json-editor-container",children:[(0,H.jsx)("div",{ref:U,className:"json-highlight-background",dangerouslySetInnerHTML:{__html:Jm(S)}}),(0,H.jsx)("textarea",{ref:C,id:"user-data-json",name:"userDataJson",value:S,onChange:X=>At(X.target.value),className:"json-textarea",spellCheck:!1,placeholder:"Enter JSON data...",autoComplete:"off"})]}):(0,H.jsx)("div",{className:"json-display",onClick:se,dangerouslySetInnerHTML:{__html:Jm(S)}})})}):(i==null?void 0:i.id)==="resources"?(0,H.jsx)("div",{className:"data-detail",children:o?(0,H.jsx)("div",{className:"loading-container",children:(0,H.jsx)("img",{src:"https://admin.lua.dev/images/logo.svg",alt:"Loading",className:"loading-logo"})}):(0,H.jsx)("div",{className:"resources-container",children:l&&l.length>0?(0,H.jsx)("div",{className:"resources-list",children:l.map(X=>(0,H.jsx)(r_,{resource:X,apiKey:e,agentId:t,onUpdate:()=>Me(i)},X.id))}):(0,H.jsxs)("div",{className:"no-resources",children:[(0,H.jsx)("div",{className:"empty-icon",children:"\u{1F4C1}"}),(0,H.jsx)("h4",{children:"No resources yet"}),(0,H.jsx)("p",{children:"Resources help provide context and information to your AI agent"})]})})}):(0,H.jsx)("div",{className:"data-detail",children:(0,H.jsxs)("div",{className:"coming-soon",children:[(0,H.jsx)("div",{className:"coming-soon-icon",children:i==null?void 0:i.icon}),(0,H.jsxs)("div",{className:"coming-soon-text",children:[i==null?void 0:i.name," management"]}),(0,H.jsx)("div",{className:"coming-soon-subtext",children:"This feature is coming soon"})]})})}),k&&(0,H.jsx)("div",{className:"error-message",children:k}),h&&(0,H.jsx)("div",{className:"success-message",children:h}),P&&(0,H.jsx)("div",{className:"modal-overlay",children:(0,H.jsxs)("div",{className:"modal-content",children:[(0,H.jsxs)("div",{className:"modal-header",children:[(0,H.jsx)("h4",{children:"Create New Resource"}),(0,H.jsx)("button",{className:"modal-close-btn",onClick:()=>_(!1),disabled:J,children:"\u2715"})]}),(0,H.jsxs)("div",{className:"modal-body",children:[(0,H.jsxs)("div",{className:"form-group",children:[(0,H.jsx)("label",{htmlFor:"resource-name",children:"Resource Name"}),(0,H.jsx)("input",{id:"resource-name",type:"text",value:R,onChange:X=>O(X.target.value),placeholder:"Enter resource name...",disabled:J})]}),(0,H.jsxs)("div",{className:"form-group",children:[(0,H.jsx)("label",{htmlFor:"resource-content",children:"Resource Content"}),(0,H.jsx)("textarea",{id:"resource-content",value:I,onChange:X=>B(X.target.value),placeholder:"Enter resource content...",rows:10,disabled:J})]})]}),(0,H.jsxs)("div",{className:"modal-footer",children:[(0,H.jsx)("button",{className:"cancel-button",onClick:()=>_(!1),disabled:J,children:"Cancel"}),(0,H.jsx)("button",{className:"create-button",onClick:Ke,disabled:J||!R.trim()||!I.trim(),children:J?"Creating...":"Create Resource"})]})]})})]})},r_=({resource:e,apiKey:t,agentId:n,onUpdate:a})=>{let[i,r]=(0,ze.useState)(!1),[l,s]=(0,ze.useState)(e.name),[o,u]=(0,ze.useState)(e.content),[c,p]=(0,ze.useState)(!1),[d,f]=(0,ze.useState)(!1),S=()=>{s(e.name),u(e.content),r(!0)},x=()=>z(null,null,function*(){if(!(!l.trim()||!o.trim())){p(!0);try{let h=yield ie.updateResource(t,n,e.id,{name:l.trim(),content:o.trim()});h.success?(r(!1),a()):alert("Failed to update resource: "+(h.error||"Unknown error"))}catch(h){console.error("Error updating resource:",h),alert("Failed to update resource")}finally{p(!1)}}}),k=()=>z(null,null,function*(){if(confirm(`Are you sure you want to delete "${e.name}"?`)){f(!0);try{let h=yield ie.deleteResource(t,n,e.id);h.success?a():alert("Failed to delete resource: "+(h.error||"Unknown error"))}catch(h){console.error("Error deleting resource:",h),alert("Failed to delete resource")}finally{f(!1)}}}),m=()=>{r(!1),s(e.name),u(e.content)};return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("div",{className:"resource-item",children:(0,H.jsxs)("div",{className:"resource-display",children:[(0,H.jsxs)("div",{className:"resource-header",children:[(0,H.jsx)("h4",{className:"resource-name",children:e.name}),(0,H.jsx)("div",{className:"resource-meta",children:(0,H.jsxs)("span",{className:"resource-date",children:["Updated ",new Date(e.updatedAt).toLocaleDateString()]})})]}),(0,H.jsx)("div",{className:"resource-content",children:(0,H.jsxs)("p",{children:[e.content.substring(0,200),e.content.length>200?"...":""]})}),(0,H.jsxs)("div",{className:"resource-actions",children:[(0,H.jsx)("button",{className:"edit-btn",onClick:S,disabled:d,title:"Edit resource",children:"\u270F\uFE0F"}),(0,H.jsx)("button",{className:"delete-btn",onClick:k,disabled:d,title:"Delete resource",children:d?"\u27F3":"\u{1F5D1}\uFE0F"})]})]})}),i&&(0,H.jsx)("div",{className:"modal-overlay",children:(0,H.jsxs)("div",{className:"modal-content",children:[(0,H.jsxs)("div",{className:"modal-header",children:[(0,H.jsx)("h4",{children:"Edit Resource"}),(0,H.jsx)("button",{className:"modal-close-btn",onClick:m,disabled:c,children:"\u2715"})]}),(0,H.jsxs)("div",{className:"modal-body",children:[(0,H.jsxs)("div",{className:"form-group",children:[(0,H.jsx)("label",{htmlFor:"edit-resource-name",children:"Resource Name"}),(0,H.jsx)("input",{id:"edit-resource-name",type:"text",value:l,onChange:h=>s(h.target.value),placeholder:"Enter resource name...",disabled:c})]}),(0,H.jsxs)("div",{className:"form-group",children:[(0,H.jsx)("label",{htmlFor:"edit-resource-content",children:"Resource Content"}),(0,H.jsx)("textarea",{id:"edit-resource-content",value:o,onChange:h=>u(h.target.value),placeholder:"Enter resource content...",rows:10,disabled:c})]})]}),(0,H.jsxs)("div",{className:"modal-footer",children:[(0,H.jsx)("button",{className:"cancel-button",onClick:m,disabled:c,children:"Cancel"}),(0,H.jsx)("button",{className:"create-button",onClick:x,disabled:c||!l.trim()||!o.trim(),children:c?"Saving...":"Save Changes"})]})]})})]})}});var Ft,Km,iE=b(()=>{"use strict";Ft=F(re()),Km=({personaVersions:e,onSelectVersion:t,onDeployVersion:n,deployingVersionId:a})=>(0,Ft.jsxs)("div",{className:"persona-panel",children:[(0,Ft.jsx)("div",{className:"panel-header",children:(0,Ft.jsx)("h3",{children:"Persona Management"})}),(0,Ft.jsx)("div",{className:"panel-content",children:(0,Ft.jsxs)("div",{className:"versions-list",children:[e.map(i=>(0,Ft.jsxs)("div",{className:`version-item ${i.isDeployed?"deployed":""} clickable`,onClick:()=>t(i),children:[(0,Ft.jsxs)("div",{className:"version-info",children:[(0,Ft.jsx)("div",{className:"version-number",children:i.version}),(0,Ft.jsx)("div",{className:"version-date",children:i.deployedAt||"No date"}),i.isDeployed&&(0,Ft.jsx)("div",{className:"deployed-badge",children:"Deployed"})]}),!i.isDeployed&&i.status==="available"&&(0,Ft.jsx)("button",{className:`deploy-button ${a===i.id?"loading":""}`,onClick:r=>{r.stopPropagation(),n(i.id)},disabled:a===i.id,children:a===i.id?(0,Ft.jsx)("img",{src:"https://admin.lua.dev/images/logo.svg",alt:"Loading",className:"loading-logo-button"}):"Deploy"})]},i.id)),e.length===0&&(0,Ft.jsx)("div",{className:"no-versions",children:"No persona versions found"})]})})]})});var at,Wm,rE=b(()=>{"use strict";at=F(re()),Wm=({skills:e,onSelectSkill:t,onActivateSkill:n,activatingSkillId:a})=>(0,at.jsxs)("div",{className:"skills-panel",children:[(0,at.jsx)("div",{className:"panel-header",children:(0,at.jsx)("h3",{children:"Skills Management"})}),(0,at.jsx)("div",{className:"panel-content",children:(0,at.jsx)("div",{className:"skills-list",children:e.map(i=>(0,at.jsxs)("div",{className:`skill-item ${i.active?"active":"inactive"}`,children:[(0,at.jsxs)("div",{className:"skill-main-content",onClick:()=>t(i.name),children:[(0,at.jsxs)("div",{className:"skill-info",children:[(0,at.jsxs)("div",{className:"skill-header",children:[(0,at.jsx)("div",{className:"skill-name",children:i.name}),(0,at.jsx)("div",{className:`skill-status ${i.active?"active":"inactive"}`,children:i.active?"Active":"Inactive"})]}),(0,at.jsx)("div",{className:"skill-description",children:i.description}),(0,at.jsxs)("div",{className:"skill-stats",children:[(0,at.jsxs)("span",{className:"skill-stat",children:[i.versionsCount," versions"]}),(0,at.jsxs)("span",{className:"skill-stat",children:["Latest: ",i.latestVersion]}),i.deployedVersion&&(0,at.jsxs)("span",{className:"skill-stat deployed",children:["Deployed: ",i.deployedVersion]})]})]}),(0,at.jsx)("div",{className:"skill-arrow",children:"\u2192"})]}),(0,at.jsx)("div",{className:"skill-actions",children:(0,at.jsx)("button",{className:`activate-button ${i.active?"deactivate":"activate"} ${a===i.id?"loading":""}`,onClick:r=>{r.stopPropagation(),n(i.id,i.active)},disabled:a===i.id,children:a===i.id?(0,at.jsx)("img",{src:"https://admin.lua.dev/images/logo.svg",alt:"Loading",className:"loading-logo-button"}):i.active?"Deactivate":"Activate"})})]},i.id))})})]})});var Zt,eh,lE=b(()=>{"use strict";Zt=F(re()),eh=({selectedPersonaVersion:e,onBack:t,onDeployVersion:n,deployingVersionId:a})=>(0,Zt.jsxs)("div",{className:"persona-detail",children:[(0,Zt.jsxs)("div",{className:"persona-detail-header",children:[(0,Zt.jsx)("button",{className:"back-button",onClick:t,children:"\u2190"}),(0,Zt.jsxs)("h4",{children:["Persona ",e.version]})]}),(0,Zt.jsxs)("div",{className:"persona-section",children:[(0,Zt.jsxs)("div",{className:"persona-header",children:[(0,Zt.jsx)("h3",{children:"Agent Persona"}),(0,Zt.jsx)("div",{className:"persona-actions",children:e.isDeployed?(0,Zt.jsx)("span",{className:"deployed-badge",children:"Deployed"}):e.status==="available"?(0,Zt.jsx)("button",{className:`deploy-button ${a===e.id?"loading":""}`,onClick:()=>n(e.id),disabled:a===e.id,children:a===e.id?(0,Zt.jsx)("img",{src:"https://admin.lua.dev/images/logo.svg",alt:"Loading",className:"loading-logo-button"}):"Deploy"}):null})]}),(0,Zt.jsx)("div",{className:"persona-content",children:(0,Zt.jsx)("div",{className:"persona-display",children:e.personaContent})})]})]})});var Ee,th,sE=b(()=>{"use strict";Ee=F(re()),th=({selectedSkillVersion:e,onBack:t,onDeployVersion:n,deployingVersionId:a})=>(0,Ee.jsxs)("div",{className:"skill-detail",children:[(0,Ee.jsx)("div",{className:"skill-detail-header",children:(0,Ee.jsxs)("div",{className:"header-left",children:[(0,Ee.jsx)("button",{className:"back-button",onClick:t,children:"\u2190"}),(0,Ee.jsxs)("h4",{children:[e.skillName," ",e.version]})]})}),(0,Ee.jsx)("div",{className:"skill-details",children:(0,Ee.jsxs)("div",{className:"skill-info-section",children:[(0,Ee.jsxs)("div",{className:"skill-meta",children:[(0,Ee.jsxs)("span",{className:"skill-version",children:["v",e.version]}),e.isDeployed&&(0,Ee.jsx)("span",{className:"deployed-badge",children:"Deployed"})]}),e.skillDescription&&(0,Ee.jsxs)("div",{className:"skill-description-section",children:[(0,Ee.jsx)("h5",{children:"Description"}),(0,Ee.jsx)("p",{children:e.skillDescription})]}),e.skillContext&&(0,Ee.jsxs)("div",{className:"skill-context-section",children:[(0,Ee.jsx)("h5",{children:"Context"}),(0,Ee.jsx)("p",{children:e.skillContext})]}),!e.isDeployed&&e.status==="available"&&(0,Ee.jsx)("div",{className:"skill-actions",children:(0,Ee.jsx)("button",{className:`deploy-button ${a===e.id?"loading":""}`,onClick:()=>n(e.id),disabled:a===e.id,children:a===e.id?(0,Ee.jsx)("img",{src:"https://admin.lua.dev/images/logo.svg",alt:"Loading",className:"loading-logo-button"}):"Deploy This Version"})})]})}),(0,Ee.jsxs)("div",{className:"tools-section",children:[(0,Ee.jsx)("div",{className:"tools-header",children:(0,Ee.jsx)("h5",{children:"Available Tools"})}),(0,Ee.jsx)("div",{className:"tools-list",children:e.tools&&e.tools.length>0?e.tools.map((i,r)=>(0,Ee.jsxs)("div",{className:"tool-item",children:[(0,Ee.jsx)("div",{className:"tool-name",children:i.name}),(0,Ee.jsx)("div",{className:"tool-description",children:i.description})]},r)):(0,Ee.jsxs)("div",{className:"no-tools",children:[(0,Ee.jsx)("div",{className:"no-tools-icon",children:"\u{1F527}"}),(0,Ee.jsx)("div",{className:"no-tools-text",children:"No tools available"}),(0,Ee.jsx)("div",{className:"no-tools-subtext",children:"This version doesn't have any tools configured"})]})})]})]})});var Jt,nh,oE=b(()=>{"use strict";Jt=F(re()),nh=({selectedSkill:e,versions:t,onBack:n,onSelectVersion:a,onDeployVersion:i,formatDate:r,deployingVersionId:l})=>(0,Jt.jsxs)("div",{className:"skill-versions",children:[(0,Jt.jsx)("div",{className:"skill-versions-header",children:(0,Jt.jsxs)("div",{className:"header-left",children:[(0,Jt.jsx)("button",{className:"back-button",onClick:n,children:"\u2190"}),(0,Jt.jsx)("h4",{children:e})]})}),(0,Jt.jsx)("div",{className:"versions-list",children:t.filter(s=>s.type==="skill"&&s.skillName===e).map(s=>(0,Jt.jsxs)("div",{className:`version-item ${s.isDeployed?"deployed":""} clickable`,onClick:()=>a(s),children:[(0,Jt.jsxs)("div",{className:"version-info",children:[(0,Jt.jsx)("div",{className:"version-number",children:s.version}),(0,Jt.jsx)("div",{className:"version-date",children:r(s.deployedAt)}),s.isDeployed&&(0,Jt.jsx)("div",{className:"deployed-badge",children:"Deployed"})]}),!s.isDeployed&&s.status==="available"&&(0,Jt.jsx)("button",{className:`deploy-button ${l===s.id?"loading":""}`,onClick:o=>{o.stopPropagation(),i(s.id)},disabled:l===s.id,children:l===s.id?(0,Jt.jsx)("img",{src:"https://admin.lua.dev/images/logo.svg",alt:"Loading",className:"loading-logo-button"}):"Deploy"})]},s.id))})]})});var jt,ee,ah,l_,uE=b(()=>{"use strict";jt=F(Je());an();ee=F(re()),ah=({apiKey:e,agentId:t})=>{let[n,a]=(0,jt.useState)([]),[i,r]=(0,jt.useState)(!0),[l,s]=(0,jt.useState)(!1),[o,u]=(0,jt.useState)(null),[c,p]=(0,jt.useState)(null),[d,f]=(0,jt.useState)(null),[S,x]=(0,jt.useState)(""),[k,m]=(0,jt.useState)(""),[h,g]=(0,jt.useState)(!1);(0,jt.useEffect)(()=>{E()},[e,t]),(0,jt.useEffect)(()=>{if(o||c){let _=setTimeout(()=>{u(null),p(null)},5e3);return()=>clearTimeout(_)}},[o,c]);let E=()=>z(null,null,function*(){r(!0);try{let _=yield ie.loadProductionEnv(e,t);if(_.success&&_.data){let R=Object.entries(_.data.data||{}).map(([O,I],B)=>({id:`${B}-${O}`,key:O,value:I}));a(R)}else console.error("Failed to load production env:",_.error),a([])}catch(_){console.error("Error loading production env:",_),a([])}finally{r(!1)}}),T=_=>z(null,null,function*(){s(!0),u(null),p(null);try{let R={};_.forEach(I=>{I.key.trim()&&(R[I.key.trim()]=I.value)});let O=yield ie.updateProductionEnv(e,t,R);O.success?(p("Environment variables saved successfully!"),yield E()):u(O.error||"Failed to save environment variables")}catch(R){console.error("Error saving production env:",R),u("Failed to save environment variables")}finally{s(!1)}}),N=()=>z(null,null,function*(){if(!S.trim()){u("Variable name is required");return}let _={id:Date.now().toString(),key:S.trim(),value:k},R=[...n,_];a(R),yield T(R),x(""),m(""),g(!1)}),A=(_,R,O)=>z(null,null,function*(){let I=n.map(B=>B.id===_?ut(K({},B),{key:R.trim(),value:O}):B);a(I),f(null),yield T(I)}),C=_=>z(null,null,function*(){let R=n.filter(O=>O.id!==_);a(R),yield T(R)}),U=_=>{f(_)},P=()=>{f(null)};return i?(0,ee.jsx)("div",{className:"env-panel",children:(0,ee.jsx)("div",{className:"env-loading",children:(0,ee.jsx)("img",{src:"https://admin.lua.dev/images/logo.svg",alt:"Loading",className:"loading-logo"})})}):(0,ee.jsxs)("div",{className:"env-panel",children:[(0,ee.jsxs)("div",{className:"env-header",children:[(0,ee.jsx)("h3",{children:"Environment Variables"}),(0,ee.jsxs)("div",{className:"env-actions",children:[(0,ee.jsx)("button",{className:"refresh-btn",onClick:E,disabled:i,title:"Refresh environment variables",children:i?(0,ee.jsx)("img",{src:"https://admin.lua.dev/images/logo.svg",alt:"Loading",className:"loading-logo-button"}):"\u21BB"}),(0,ee.jsx)("button",{className:"add-btn",onClick:()=>g(!0),disabled:h,title:"Add new environment variable",children:"\u2795"})]})]}),(0,ee.jsxs)("div",{className:"env-content",children:[o&&(0,ee.jsxs)("div",{className:"error-message",children:[(0,ee.jsx)("strong",{children:"Error:"})," ",o]}),c&&(0,ee.jsxs)("div",{className:"success-message",children:[(0,ee.jsx)("strong",{children:"Success:"})," ",c]}),h&&(0,ee.jsxs)("div",{className:"env-add-form",children:[(0,ee.jsxs)("div",{className:"env-form-header",children:[(0,ee.jsx)("h4",{children:"Add New Variable"}),(0,ee.jsx)("button",{className:"form-cancel-btn",onClick:()=>{g(!1),x(""),m("")},title:"Cancel",children:"\u2715"})]}),(0,ee.jsxs)("div",{className:"env-form-fields",children:[(0,ee.jsxs)("div",{className:"env-field",children:[(0,ee.jsx)("label",{children:"Variable Name"}),(0,ee.jsx)("input",{type:"text",value:S,onChange:_=>x(_.target.value),placeholder:"API_KEY",className:"env-input",autoFocus:!0,autoComplete:"off"})]}),(0,ee.jsxs)("div",{className:"env-field",children:[(0,ee.jsx)("label",{children:"Value"}),(0,ee.jsx)("input",{type:"text",value:k,onChange:_=>m(_.target.value),placeholder:"your_api_key_here",className:"env-input",autoComplete:"off"})]}),(0,ee.jsx)("div",{className:"env-form-actions",children:(0,ee.jsx)("button",{className:"add-variable-btn",onClick:N,disabled:!S.trim()||l,children:l?"Adding...":"Add Variable"})})]})]}),(0,ee.jsx)("div",{className:"env-variables",children:n.length>0?(0,ee.jsx)("div",{className:"env-list",children:n.map(_=>(0,ee.jsx)(l_,{variable:_,isEditing:d===_.id,onEdit:()=>U(_.id),onSave:(R,O)=>A(_.id,R,O),onCancel:P,onDelete:()=>C(_.id),isSaving:l},_.id))}):(0,ee.jsxs)("div",{className:"env-empty-state",children:[(0,ee.jsx)("div",{className:"empty-icon",children:"\u{1F527}"}),(0,ee.jsx)("h4",{children:"No environment variables"}),(0,ee.jsx)("p",{children:"Add your first environment variable to get started"}),(0,ee.jsx)("button",{className:"add-first-btn",onClick:()=>g(!0),children:"Add Variable"})]})}),(0,ee.jsxs)("div",{className:"env-help",children:[(0,ee.jsx)("p",{children:"Environment variables are used by your production skills and are securely stored."}),(0,ee.jsxs)("p",{children:[(0,ee.jsx)("strong",{children:"Auto-save:"})," Changes are saved automatically when you add, edit, or delete variables."]})]})]})]})},l_=({variable:e,isEditing:t,onEdit:n,onSave:a,onCancel:i,onDelete:r,isSaving:l})=>{let[s,o]=(0,jt.useState)(e.key),[u,c]=(0,jt.useState)(e.value),p=()=>{s.trim()&&a(s,u)},d=()=>{o(e.key),c(e.value),i()},f=h=>{h.key==="Enter"&&!h.shiftKey?(h.preventDefault(),p()):h.key==="Escape"&&d()},[S,x]=(0,jt.useState)(!1),k=e.value.length>60,m=S||!k?e.value:e.value.substring(0,60)+"...";return(0,ee.jsx)("div",{className:"env-variable-item",children:t?(0,ee.jsxs)("div",{className:"env-variable-edit",children:[(0,ee.jsxs)("div",{className:"env-edit-fields",children:[(0,ee.jsx)("input",{type:"text",value:s,onChange:h=>o(h.target.value),onKeyPress:f,className:"env-key-input",placeholder:"Variable name",disabled:l,autoComplete:"off"}),(0,ee.jsx)("span",{className:"env-equals",children:"="}),(0,ee.jsx)("textarea",{value:u,onChange:h=>c(h.target.value),className:"env-value-input",placeholder:"Value",rows:1,disabled:l,autoComplete:"off"})]}),(0,ee.jsxs)("div",{className:"env-edit-actions",children:[(0,ee.jsx)("button",{className:"save-edit-btn",onClick:p,disabled:!s.trim()||l,title:"Save changes",children:"\u2713"}),(0,ee.jsx)("button",{className:"cancel-edit-btn",onClick:d,disabled:l,title:"Cancel editing",children:"\u2715"})]})]}):(0,ee.jsxs)("div",{className:"env-variable-display",children:[(0,ee.jsxs)("div",{className:"env-variable-content",children:[(0,ee.jsx)("span",{className:"env-key",children:e.key}),(0,ee.jsx)("span",{className:"env-equals",children:"="}),(0,ee.jsxs)("div",{className:"env-value-container",children:[(0,ee.jsx)("span",{className:"env-value",onClick:()=>k&&x(!S),style:{cursor:k?"pointer":"default"},title:k?"Click to expand/collapse":e.value,children:m||"<empty>"}),k&&(0,ee.jsx)("button",{className:"expand-btn",onClick:()=>x(!S),title:S?"Collapse":"Expand",children:S?"\u25B2":"\u25BC"})]})]}),(0,ee.jsxs)("div",{className:"env-variable-actions",children:[(0,ee.jsx)("button",{className:"edit-variable-btn",onClick:n,disabled:l,title:"Edit variable",children:"\u270F\uFE0F"}),(0,ee.jsx)("button",{className:"delete-variable-btn",onClick:r,disabled:l,title:"Delete variable",children:"\u{1F5D1}\uFE0F"})]})]})})}});var cE=b(()=>{"use strict";JN();KN();tE();nE();aE();Fm();iE();rE();lE();sE();oE();uE()});var zt,De,fE,dE=b(()=>{"use strict";zt=F(Je());cE();an();De=F(re()),fE=({apiKey:e,agentId:t,skillId:n,isActive:a=!1,sharedChatMessages:i,onSharedSendMessage:r,onSharedClearHistory:l,isChatLoading:s,setIsChatLoading:o})=>{let[u,c]=(0,zt.useState)("persona"),[p,d]=(0,zt.useState)([]),[f,S]=(0,zt.useState)([]),[x,k]=(0,zt.useState)([]),[m,h]=(0,zt.useState)(null),[g,E]=(0,zt.useState)(null),[T,N]=(0,zt.useState)(500),[A,C]=(0,zt.useState)(!1),[U,P]=(0,zt.useState)(null),[_,R]=(0,zt.useState)(null),[O,I]=(0,zt.useState)(null),B=se=>z(null,null,function*(){if(!se.trim())return;let X={id:Date.now().toString(),text:se,sender:"user",timestamp:new Date};r(X),o(!0);try{let Q=yield ie.sendProductionChatMessage(se,t,e),ne={id:(Date.now()+1).toString(),text:Q.success?Q.text||"No response received":`\u274C ${Q.error||"Failed to send message"}`,sender:"assistant",timestamp:new Date};r(ne)}catch(Q){let ne={id:(Date.now()+1).toString(),text:`\u274C Error: ${Q instanceof Error?Q.message:"Unknown error"}`,sender:"assistant",timestamp:new Date};r(ne)}finally{o(!1)}}),J=(se,X)=>z(null,null,function*(){E(se);try{let Q=!X;console.log(`${Q?"Activating":"Deactivating"} skill:`,se);let ne=yield ie.activateSkill(e,t,se,Q);ne.success?(k(Y=>Y.map(oe=>oe.id===se?ut(K({},oe),{active:Q}):oe)),yield pt(),console.log(`\u2705 Skill ${Q?"activated":"deactivated"} successfully`)):(console.error(`\u274C Failed to ${Q?"activate":"deactivate"} skill:`,ne.error),alert(`Failed to ${Q?"activate":"deactivate"} skill: ${ne.error}`))}catch(Q){console.error("Error activating skill:",Q),alert("Failed to change skill activation status")}finally{E(null)}}),ae=se=>z(null,null,function*(){h(se);try{let X=f.find(ne=>ne.id===se);if(X){console.log("Deploying persona version:",X),yield At(X);return}let Q=p.find(ne=>ne.id===se);if(Q){console.log("Publishing skill version:",Q.version,"for skill:",Q.skillName);let ne=x.find(Ue=>Ue.name===Q.skillName);if(!ne)throw new Error("Could not find skill for deployment");let Y=Q.version.replace("v",""),oe=yield ie.publishSkillVersion(e,t,ne.id,Y);if(oe.success&&oe.data)d(Ue=>Ue.map(mt=>mt.id===se?ut(K({},mt),{isDeployed:!0}):mt.type===Q.type&&mt.skillName===Q.skillName?ut(K({},mt),{isDeployed:!1}):mt)),k(Ue=>Ue.map(mt=>mt.name===Q.skillName?ut(K({},mt),{deployedVersion:Q.version}):mt)),yield pt(),console.log(`\u2705 ${oe.data.message}`),alert(`\u2705 ${oe.data.message}`);else throw new Error(oe.error||"Failed to publish skill version")}}finally{h(null)}}),we=se=>{C(!0),se.preventDefault()},je=se=>{if(!A)return;let X=document.querySelector(".production-layout-new");if(!X)return;let Q=X.getBoundingClientRect(),ne=Q.right-se.clientX,Y=500,oe=Q.width*.6;ne>=Y&&ne<=oe&&N(ne)},v=()=>{C(!1)};zt.default.useEffect(()=>(A?(document.addEventListener("mousemove",je),document.addEventListener("mouseup",v),document.body.style.cursor="col-resize",document.body.style.userSelect="none"):(document.removeEventListener("mousemove",je),document.removeEventListener("mouseup",v),document.body.style.cursor="",document.body.style.userSelect=""),()=>{document.removeEventListener("mousemove",je),document.removeEventListener("mouseup",v),document.body.style.cursor="",document.body.style.userSelect=""}),[A]);let Me=se=>new Date(se).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});(0,zt.useEffect)(()=>{y()},[e,t]),(0,zt.useEffect)(()=>{a&&y()},[a]);let pt=()=>z(null,null,function*(){try{console.log("Loading skills data with apiKey:",e,"agentId:",t);let se=yield ie.getSkills(e,t);if(se.success&&se.skills){let X=se.skills.map(ne=>{let Y=ne.versions.length>0?ne.versions.reduce((Ue,mt)=>Ue.version>mt.version?Ue:mt):null,oe=ne.versions.find(Ue=>Ue.active);return{id:ne.id,name:ne.name,description:ne.description,versionsCount:ne.versions.length,latestVersion:Y?`v${Y.version}`:"No versions",deployedVersion:oe?`v${oe.version}`:void 0,active:ne.active}});k(X);let Q=[];se.skills.forEach(ne=>{ne.versions.forEach(Y=>{Q.push({id:Y.id,version:`v${Y.version}`,type:"skill",skillName:ne.name,skillDescription:Y.description,skillContext:Y.context,deployedAt:ne.updatedAt,isDeployed:Y.active,status:Y.active?"deployed":"available",tools:Y.tools})})}),d(Q)}else console.error("Failed to load skills:",se.error),k([]),d([])}catch(se){console.error("Error loading skills data:",se),k([]),d([])}}),y=()=>z(null,null,function*(){try{console.log("Loading persona versions with apiKey:",e,"agentId:",t),yield Ke(),yield pt()}catch(se){console.error("Error loading production data:",se)}}),Ke=()=>z(null,null,function*(){try{let se=yield ie.getProductionPersonaVersions(t,e);if(se.success&&se.versions){let Q=se.versions.map(ne=>({id:`persona_${ne.version}`,version:`v${ne.version}`,type:"persona",deployedAt:new Date(ne.createdDate).toISOString(),isDeployed:ne.isCurrent,status:ne.isCurrent?"deployed":"available",personaContent:ne.persona})).sort((ne,Y)=>new Date(Y.deployedAt).getTime()-new Date(ne.deployedAt).getTime());S(Q)}else console.error("Failed to load persona versions:",se.error)}catch(se){console.error("Error loading persona versions:",se)}}),At=se=>z(null,null,function*(){try{let X=parseInt(se.version.replace("v",""));console.log(`Deploying persona version ${X} to production...`);let Q=yield ie.deployPersonaVersion(t,e,X);console.log("Deploy persona response:",Q),Q.success?(yield Ke(),alert(`\u2705 Persona version ${se.version} deployed successfully!`)):alert(`\u274C Failed to deploy persona version: ${Q.error||"Unknown error"}`)}catch(X){console.error("Error deploying persona version:",X),alert("\u274C Failed to deploy persona version")}});return(0,De.jsx)("div",{className:"production-page",children:(0,De.jsxs)("div",{className:"production-layout-new",children:[(0,De.jsx)("div",{className:"production-left",style:{width:`calc(100% - ${T}px)`},children:(0,De.jsx)(Qm,{messages:i,onSendMessage:B,onClearHistory:l,isLoading:s})}),(0,De.jsx)("div",{className:"production-resize-handle",onMouseDown:we}),(0,De.jsxs)("div",{className:"production-right",children:[(0,De.jsxs)("div",{className:"right-panel-tabs",children:[(0,De.jsx)("button",{className:`tab-button ${u==="persona"?"active":""}`,onClick:()=>{c("persona"),R(null),P(null),I(null)},children:"Persona"}),(0,De.jsx)("button",{className:`tab-button ${u==="skills"?"active":""}`,onClick:()=>{c("skills"),R(null),P(null),I(null),I(null)},children:"Skills"}),(0,De.jsx)("button",{className:`tab-button ${u==="stats"?"active":""}`,onClick:()=>{c("stats"),R(null),P(null),I(null)},children:"Stats"}),(0,De.jsx)("button",{className:`tab-button ${u==="logs"?"active":""}`,onClick:()=>{c("logs"),R(null),P(null),I(null)},children:"Logs"}),(0,De.jsx)("button",{className:`tab-button ${u==="data"?"active":""}`,onClick:()=>{c("data"),R(null),P(null),I(null)},children:"Data"}),(0,De.jsx)("button",{className:`tab-button ${u==="env"?"active":""}`,onClick:()=>{c("env"),R(null),P(null),I(null)},children:"Env"})]}),(0,De.jsxs)("div",{className:"right-panel-content",children:[u==="persona"&&(_?(0,De.jsx)(eh,{selectedPersonaVersion:_,onBack:()=>R(null),onDeployVersion:ae,deployingVersionId:m}):(0,De.jsx)(Km,{personaVersions:f,onSelectVersion:R,onDeployVersion:ae,deployingVersionId:m})),u==="skills"&&(O?(0,De.jsx)(th,{selectedSkillVersion:O,onBack:()=>I(null),onDeployVersion:ae,deployingVersionId:m}):U?(0,De.jsx)(nh,{selectedSkill:U,versions:p,onBack:()=>P(null),onSelectVersion:I,onDeployVersion:ae,formatDate:Me,deployingVersionId:m}):(0,De.jsx)(Wm,{skills:x,onSelectSkill:P,onActivateSkill:J,activatingSkillId:g})),u==="stats"&&(0,De.jsx)("div",{className:"coming-soon-panel",children:(0,De.jsxs)("div",{className:"coming-soon",children:[(0,De.jsx)("div",{className:"coming-soon-icon",children:"\u{1F4CA}"}),(0,De.jsx)("div",{className:"coming-soon-text",children:"Statistics & Analytics"}),(0,De.jsx)("div",{className:"coming-soon-subtext",children:"Performance metrics and analytics dashboard coming soon"})]})}),u==="logs"&&(0,De.jsx)(Zm,{apiKey:e,agentId:t}),u==="data"&&(0,De.jsx)($m,{apiKey:e,agentId:t}),u==="env"&&(0,De.jsx)(ah,{apiKey:e,agentId:t})]})]})]})})}});var Vi,sn,pE,mE=b(()=>{"use strict";Vi=F(Je()),sn=F(re()),pE=({apiKey:e,agentId:t})=>{let[n,a]=(0,Vi.useState)(""),[i,r]=(0,Vi.useState)(!0),[l,s]=(0,Vi.useState)(""),[o,u]=(0,Vi.useState)("");(0,Vi.useEffect)(()=>{c()},[]);let c=()=>z(null,null,function*(){var p;try{r(!0);let d=yield fetch("/api/config");if(d.ok){let f=yield d.json(),S=(p=f==null?void 0:f.agent)==null?void 0:p.orgId;if(S){a(S);let x=`https://admin.lua.dev/validate-token/${e}?redirect=/admin/usage?&agentId=${t}&orgId=${S}&hideToolBar=true`;u(x)}else s("No orgId found in configuration")}else s("Failed to load configuration")}catch(d){console.error("Failed to load orgId:",d),s("Failed to load configuration")}finally{r(!1)}});return i?(0,sn.jsx)("div",{className:"admin-page",children:(0,sn.jsx)("div",{className:"loading-container",children:(0,sn.jsx)("img",{src:"https://admin.lua.dev/images/logo.svg",alt:"Loading",className:"loading-logo"})})}):l?(0,sn.jsx)("div",{className:"admin-page",children:(0,sn.jsxs)("div",{className:"error-container",children:[(0,sn.jsx)("h3",{children:"Error Loading Admin Dashboard"}),(0,sn.jsx)("p",{children:l}),(0,sn.jsx)("button",{onClick:c,className:"retry-button",children:"Retry"})]})}):(0,sn.jsx)("div",{className:"admin-page",children:o?(0,sn.jsx)("iframe",{src:o,className:"admin-iframe",title:"Lua Admin Dashboard",sandbox:"allow-same-origin allow-scripts allow-forms allow-popups allow-top-navigation"}):(0,sn.jsx)("div",{className:"loading-container",children:(0,sn.jsx)("img",{src:"https://admin.lua.dev/images/logo.svg",alt:"Loading",className:"loading-logo"})})})}});var hE=b(()=>{});var Qr,it,gE,vE=b(()=>{"use strict";Qr=F(Je());FN();dE();mE();an();hE();it=F(re()),gE=({apiKey:e,agentId:t,skillId:n,sandboxId:a})=>{let[i,r]=(0,Qr.useState)("sandbox"),[l,s]=(0,Qr.useState)([]),[o,u]=(0,Qr.useState)(!1);(0,Qr.useEffect)(()=>{c()},[e,t]);let c=()=>z(null,null,function*(){try{console.log("Loading shared chat history with API key:",e,"agentId:",t);let S=yield ie.loadChatHistory(e,t);if(S.success&&S.data&&S.data.length>0){let x=S.data.map(k=>{var m;return{id:k.id||Date.now().toString(),text:((m=k.content[0])==null?void 0:m.text)||"",sender:k.role==="user"?"user":"assistant",timestamp:new Date(k.createdAt)}});s(x)}else s([])}catch(S){console.error("Failed to load shared chat history:",S),s([])}}),p=()=>z(null,null,function*(){try{let S=yield ie.clearChatHistory(e,t);S.success?s([]):alert("Failed to clear chat history: "+(S.error||"Unknown error"))}catch(S){console.error("Failed to clear shared chat history:",S),alert("Failed to clear chat history")}}),d=S=>{s(x=>[...x,S])};return(0,it.jsxs)("div",{className:"main-container",children:[(0,it.jsx)("div",{className:"page-navigation",children:(0,it.jsxs)("div",{className:"nav-logo",children:[(0,it.jsx)("img",{src:"https://admin.lua.dev/images/logo.svg",alt:"Lua",className:"logo-icon"}),(0,it.jsxs)("span",{className:"logo-text",children:[(0,it.jsx)("strong",{children:"Lua"})," : Developer Console"]})]})}),(0,it.jsxs)("div",{className:"page-tabs",children:[(0,it.jsx)("button",{className:`page-tab ${i==="sandbox"?"active":""}`,onClick:()=>r("sandbox"),children:"Sandbox"}),(0,it.jsx)("button",{className:`page-tab ${i==="production"?"active":""}`,onClick:()=>r("production"),children:"Production"}),(0,it.jsx)("button",{className:`page-tab ${i==="admin"?"active":""}`,onClick:()=>r("admin"),children:"Admin"})]}),(0,it.jsx)("div",{className:"page-container",children:(0,it.jsxs)(it.Fragment,{children:[(0,it.jsx)("div",{className:`page-content ${i==="sandbox"?"active":"hidden"}`,children:(0,it.jsx)(QN,{apiKey:e,agentId:t,skillId:n,sandboxId:a,sharedChatMessages:l,onSharedSendMessage:d,onSharedClearHistory:p,isChatLoading:o,setIsChatLoading:u})}),(0,it.jsx)("div",{className:`page-content ${i==="production"?"active":"hidden"}`,children:(0,it.jsx)(fE,{apiKey:e,agentId:t,skillId:n,isActive:i==="production",sharedChatMessages:l,onSharedSendMessage:d,onSharedClearHistory:p,isChatLoading:o,setIsChatLoading:u})}),(0,it.jsx)("div",{className:`page-content ${i==="admin"?"active":"hidden"}`,children:(0,it.jsx)(pE,{apiKey:e,agentId:t})})]})})]})}});var o_=Ut(()=>{var yE=F(Je()),bE=F(Yb());vE();var ih=F(re()),Ls=window.__LUA_CONFIG__;if(!Ls)throw new Error("Lua configuration not found");var SE=document.getElementById("root");if(!SE)throw new Error("Root container not found");var s_=(0,bE.createRoot)(SE);s_.render((0,ih.jsx)(yE.default.StrictMode,{children:(0,ih.jsx)(gE,{apiKey:Ls.apiKey,agentId:Ls.agentId,skillId:Ls.skillId,sandboxId:Ls.sandboxId})}))});return o_();})();
24
+ `),C=()=>z(null,null,function*(){r(!0),u(null);try{let B=yield ie.loadEnvContent();if(B.success){let J=B.content||"",ae=N(J);a(ae),T(!1)}else u(B.error||"Failed to load environment variables"),a([]),T(!1)}catch(B){console.error("Error loading env content:",B),u("Failed to load environment variables"),a([])}finally{r(!1)}}),U=()=>{if(!S.trim()){u("Please enter a variable name");return}if(n.some(J=>J.key===S.trim())){u("Variable name already exists");return}let B={id:`env_new_${Date.now()}`,key:S.trim(),value:k};a([...n,B]),x(""),m(""),g(!1),u(null)},P=(B,J,ae)=>{a(we=>we.map(je=>je.id===B?ut(K({},je),{key:J.trim(),value:ae}):je)),f(null)},_=B=>{a(J=>J.filter(ae=>ae.id!==B))},R=B=>{f(B),u(null),p(null)},O=()=>{f(null),C()},I=()=>{g(!1),x(""),m(""),u(null)};return i?(0,W.jsx)("div",{className:"env-panel",children:(0,W.jsx)("div",{className:"env-loading",children:(0,W.jsx)("img",{src:"https://admin.heylua.ai/images/logo.svg",alt:"Loading",className:"loading-logo"})})}):(0,W.jsxs)("div",{className:"env-panel",children:[(0,W.jsxs)("div",{className:"env-header",children:[(0,W.jsx)("h3",{children:"Environment Variables"}),(0,W.jsxs)("div",{className:"env-actions",children:[(0,W.jsx)("button",{className:"refresh-btn",onClick:C,disabled:i,title:"Refresh environment variables",children:i?"\u27F3":"\u21BB"}),(0,W.jsx)("button",{className:"add-btn",onClick:()=>g(!0),disabled:h,title:"Add new environment variable",children:"\u2795"})]})]}),(0,W.jsxs)("div",{className:"env-content",children:[o&&(0,W.jsxs)("div",{className:"error-message",children:[(0,W.jsx)("strong",{children:"Error:"})," ",o]}),c&&(0,W.jsxs)("div",{className:"success-message",children:[(0,W.jsx)("strong",{children:"Success:"})," ",c]}),h&&(0,W.jsxs)("div",{className:"env-add-form",children:[(0,W.jsxs)("div",{className:"env-form-header",children:[(0,W.jsx)("h4",{children:"Add New Variable"}),(0,W.jsx)("button",{className:"form-cancel-btn",onClick:I,title:"Cancel",children:"\u2715"})]}),(0,W.jsxs)("div",{className:"env-form-fields",children:[(0,W.jsxs)("div",{className:"env-field",children:[(0,W.jsx)("label",{children:"Variable Name"}),(0,W.jsx)("input",{type:"text",value:S,onChange:B=>x(B.target.value),placeholder:"API_KEY",className:"env-input",autoFocus:!0})]}),(0,W.jsxs)("div",{className:"env-field",children:[(0,W.jsx)("label",{children:"Value"}),(0,W.jsx)("input",{type:"text",value:k,onChange:B=>m(B.target.value),placeholder:"your_api_key_here",className:"env-input"})]}),(0,W.jsx)("div",{className:"env-form-actions",children:(0,W.jsx)("button",{className:"add-variable-btn",onClick:U,disabled:!S.trim(),children:"Add Variable"})})]})]}),(0,W.jsx)("div",{className:"env-variables",children:n.length>0?(0,W.jsx)("div",{className:"env-list",children:n.map(B=>(0,W.jsx)(LR,{variable:B,isEditing:d===B.id,onEdit:()=>R(B.id),onSave:(J,ae)=>P(B.id,J,ae),onCancel:O,onDelete:()=>_(B.id)},B.id))}):(0,W.jsxs)("div",{className:"env-empty-state",children:[(0,W.jsx)("div",{className:"empty-icon",children:"\u{1F527}"}),(0,W.jsx)("h4",{children:"No environment variables"}),(0,W.jsx)("p",{children:"Add your first environment variable to get started"}),(0,W.jsx)("button",{className:"add-first-btn",onClick:()=>g(!0),children:"Add Variable"})]})}),(0,W.jsxs)("div",{className:"env-help",children:[(0,W.jsxs)("p",{children:["Environment variables are stored in your ",(0,W.jsx)("code",{children:".env"})," file and automatically included in tool execution and chat messages."]}),(0,W.jsxs)("p",{children:[(0,W.jsx)("strong",{children:"Auto-save:"})," Changes are saved automatically when you add, edit, or delete variables."]})]})]})]})},LR=({variable:e,isEditing:t,onEdit:n,onSave:a,onCancel:i,onDelete:r})=>{let[l,s]=(0,Lt.useState)(e.key),[o,u]=(0,Lt.useState)(e.value),[c,p]=(0,Lt.useState)(!1),d=e.value.length>60,f=c||!d?e.value:e.value.substring(0,60)+"...";return(0,W.jsx)("div",{className:"env-variable-item",children:t?(0,W.jsxs)("div",{className:"env-variable-edit",children:[(0,W.jsxs)("div",{className:"env-edit-fields",children:[(0,W.jsx)("input",{type:"text",value:l,onChange:k=>s(k.target.value),className:"env-key-input",placeholder:"Variable name"}),(0,W.jsx)("span",{className:"env-equals",children:"="}),(0,W.jsx)("textarea",{value:o,onChange:k=>u(k.target.value),className:"env-value-input",placeholder:"Value",rows:1})]}),(0,W.jsxs)("div",{className:"env-edit-actions",children:[(0,W.jsx)("button",{className:"save-edit-btn",onClick:()=>{if(!l.trim()){alert("Variable name cannot be empty");return}a(l,o)},title:"Save changes",children:"\u2713"}),(0,W.jsx)("button",{className:"cancel-edit-btn",onClick:()=>{s(e.key),u(e.value),i()},title:"Cancel editing",children:"\u2715"})]})]}):(0,W.jsxs)("div",{className:"env-variable-display",children:[(0,W.jsxs)("div",{className:"env-variable-content",children:[(0,W.jsx)("span",{className:"env-key",children:e.key}),(0,W.jsx)("span",{className:"env-equals",children:"="}),(0,W.jsxs)("div",{className:"env-value-container",children:[(0,W.jsx)("span",{className:"env-value",onClick:()=>d&&p(!c),style:{cursor:d?"pointer":"default"},title:d?"Click to expand/collapse":e.value,children:f||"<empty>"}),d&&(0,W.jsx)("button",{className:"expand-btn",onClick:()=>p(!c),title:c?"Collapse":"Expand",children:c?"\u25B2":"\u25BC"})]})]}),(0,W.jsxs)("div",{className:"env-variable-actions",children:[(0,W.jsx)("button",{className:"edit-variable-btn",onClick:n,title:"Edit variable",children:"\u270F\uFE0F"}),(0,W.jsx)("button",{className:"delete-variable-btn",onClick:r,title:"Delete variable",children:"\u{1F5D1}\uFE0F"})]})]})})}});var wt,Nm,tN=b(()=>{"use strict";hm();vm();bm();xm();wt=F(re()),Nm=({activeTab:e,onTabChange:t,persona:n,onSavePersona:a,apiKey:i,agentId:r,skillId:l,sandboxId:s,width:o})=>(0,wt.jsx)("div",{className:"log-container",style:{width:`${o}px`},children:(0,wt.jsxs)("div",{className:"top-section",children:[(0,wt.jsx)("div",{className:"log-header",children:(0,wt.jsxs)("div",{className:"tab-buttons",children:[(0,wt.jsx)("button",{className:`tab-button ${e==="persona"?"active":""}`,onClick:()=>t("persona"),children:"Persona"}),(0,wt.jsx)("button",{className:`tab-button ${e==="skills"?"active":""}`,onClick:()=>t("skills"),children:"Skills"}),(0,wt.jsx)("button",{className:`tab-button ${e==="userdata"?"active":""}`,onClick:()=>t("userdata"),children:"Data"}),(0,wt.jsx)("button",{className:`tab-button ${e==="env"?"active":""}`,onClick:()=>t("env"),children:"Env"})]})}),(0,wt.jsx)("div",{className:`tab-content ${e==="persona"?"active":"inactive"}`,children:(0,wt.jsx)(mm,{persona:n,onSavePersona:a,apiKey:i,agentId:r})}),(0,wt.jsx)("div",{className:`tab-content ${e==="skills"?"active":"inactive"}`,children:(0,wt.jsx)(gm,{apiKey:i,agentId:r,skillId:l,sandboxId:s})}),(0,wt.jsx)("div",{className:`tab-content ${e==="userdata"?"active":"inactive"}`,children:(0,wt.jsx)(ym,{apiKey:i,agentId:r})}),(0,wt.jsx)("div",{className:`tab-content ${e==="env"?"active":"inactive"}`,children:(0,wt.jsx)(Sm,{apiKey:i,agentId:r})})]})})});var jn,Ns,Es,Zu=b(()=>{jn=Object.create(null);jn.open="0";jn.close="1";jn.ping="2";jn.pong="3";jn.message="4";jn.upgrade="5";jn.noop="6";Ns=Object.create(null);Object.keys(jn).forEach(e=>{Ns[jn[e]]=e});Es={type:"error",data:"parser error"}});function aN(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function sN(e,t){if(iN&&e.data instanceof Blob)return e.data.arrayBuffer().then(aN).then(t);if(rN&&(e.data instanceof ArrayBuffer||lN(e.data)))return t(aN(e.data));ks(e,!1,n=>{Em||(Em=new TextEncoder),t(Em.encode(n))})}var iN,rN,lN,ks,nN,Em,oN=b(()=>{Zu();iN=typeof Blob=="function"||typeof Blob!="undefined"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",rN=typeof ArrayBuffer=="function",lN=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,ks=({type:e,data:t},n,a)=>iN&&t instanceof Blob?n?a(t):nN(t,a):rN&&(t instanceof ArrayBuffer||lN(t))?n?a(t):nN(new Blob([t]),a):a(jn[e]+(t||"")),nN=(e,t)=>{let n=new FileReader;return n.onload=function(){let a=n.result.split(",")[1];t("b"+(a||""))},n.readAsDataURL(e)}});var uN,Ts,cN,fN=b(()=>{uN="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ts=typeof Uint8Array=="undefined"?[]:new Uint8Array(256);for(let e=0;e<uN.length;e++)Ts[uN.charCodeAt(e)]=e;cN=e=>{let t=e.length*.75,n=e.length,a,i=0,r,l,s,o;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);let u=new ArrayBuffer(t),c=new Uint8Array(u);for(a=0;a<n;a+=4)r=Ts[e.charCodeAt(a)],l=Ts[e.charCodeAt(a+1)],s=Ts[e.charCodeAt(a+2)],o=Ts[e.charCodeAt(a+3)],c[i++]=r<<2|l>>4,c[i++]=(l&15)<<4|s>>2,c[i++]=(s&3)<<6|o&63;return u}});var zR,ws,MR,dN,pN=b(()=>{Zu();fN();zR=typeof ArrayBuffer=="function",ws=(e,t)=>{if(typeof e!="string")return{type:"message",data:dN(e,t)};let n=e.charAt(0);return n==="b"?{type:"message",data:MR(e.substring(1),t)}:Ns[n]?e.length>1?{type:Ns[n],data:e.substring(1)}:{type:Ns[n]}:Es},MR=(e,t)=>{if(zR){let n=cN(e);return dN(n,t)}else return{base64:!0,data:e}},dN=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}}});function vN(){return new TransformStream({transform(e,t){sN(e,n=>{let a=n.length,i;if(a<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,a);else if(a<65536){i=new Uint8Array(3);let r=new DataView(i.buffer);r.setUint8(0,126),r.setUint16(1,a)}else{i=new Uint8Array(9);let r=new DataView(i.buffer);r.setUint8(0,127),r.setBigUint64(1,BigInt(a))}e.data&&typeof e.data!="string"&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})}function Ju(e){return e.reduce((t,n)=>t+n.length,0)}function $u(e,t){if(e[0].length===t)return e.shift();let n=new Uint8Array(t),a=0;for(let i=0;i<t;i++)n[i]=e[0][a++],a===e[0].length&&(e.shift(),a=0);return e.length&&a<e[0].length&&(e[0]=e[0].slice(a)),n}function yN(e,t){km||(km=new TextDecoder);let n=[],a=0,i=-1,r=!1;return new TransformStream({transform(l,s){for(n.push(l);;){if(a===0){if(Ju(n)<1)break;let o=$u(n,1);r=(o[0]&128)===128,i=o[0]&127,i<126?a=3:i===126?a=1:a=2}else if(a===1){if(Ju(n)<2)break;let o=$u(n,2);i=new DataView(o.buffer,o.byteOffset,o.length).getUint16(0),a=3}else if(a===2){if(Ju(n)<8)break;let o=$u(n,8),u=new DataView(o.buffer,o.byteOffset,o.length),c=u.getUint32(0);if(c>Math.pow(2,21)-1){s.enqueue(Es);break}i=c*Math.pow(2,32)+u.getUint32(4),a=3}else{if(Ju(n)<i)break;let o=$u(n,i);s.enqueue(ws(r?o:km.decode(o),t)),a=0}if(i===0||i>e){s.enqueue(Es);break}}}})}var mN,hN,gN,km,Tm,qr=b(()=>{oN();pN();Zu();mN="",hN=(e,t)=>{let n=e.length,a=new Array(n),i=0;e.forEach((r,l)=>{ks(r,!1,s=>{a[l]=s,++i===n&&t(a.join(mN))})})},gN=(e,t)=>{let n=e.split(mN),a=[];for(let i=0;i<n.length;i++){let r=ws(n[i],t);if(a.push(r),r.type==="error")break}return a};Tm=4});function Ie(e){if(e)return UR(e)}function UR(e){for(var t in Ie.prototype)e[t]=Ie.prototype[t];return e}var Li=b(()=>{Ie.prototype.on=Ie.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this};Ie.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this};Ie.prototype.off=Ie.prototype.removeListener=Ie.prototype.removeAllListeners=Ie.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var a,i=0;i<n.length;i++)if(a=n[i],a===t||a.fn===t){n.splice(i,1);break}return n.length===0&&delete this._callbacks["$"+e],this};Ie.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],a=1;a<arguments.length;a++)t[a-1]=arguments[a];if(n){n=n.slice(0);for(var a=0,i=n.length;a<i;++a)n[a].apply(this,t)}return this};Ie.prototype.emitReserved=Ie.prototype.emit;Ie.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};Ie.prototype.hasListeners=function(e){return!!this.listeners(e).length}});var ba,Qt,bN,zi=b(()=>{ba=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,n)=>n(t,0),Qt=typeof self!="undefined"?self:typeof window!="undefined"?window:Function("return this")(),bN="arraybuffer"});function Ku(e,...t){return t.reduce((n,a)=>(e.hasOwnProperty(a)&&(n[a]=e[a]),n),{})}function Sa(e,t){t.useNativeTimers?(e.setTimeoutFn=BR.bind(Qt),e.clearTimeoutFn=VR.bind(Qt)):(e.setTimeoutFn=Qt.setTimeout.bind(Qt),e.clearTimeoutFn=Qt.clearTimeout.bind(Qt))}function SN(e){return typeof e=="string"?PR(e):Math.ceil((e.byteLength||e.size)*HR)}function PR(e){let t=0,n=0;for(let a=0,i=e.length;a<i;a++)t=e.charCodeAt(a),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(a++,n+=4);return n}function Wu(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}var BR,VR,HR,Mi=b(()=>{zi();BR=Qt.setTimeout,VR=Qt.clearTimeout;HR=1.33});function xN(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function NN(e){let t={},n=e.split("&");for(let a=0,i=n.length;a<i;a++){let r=n[a].split("=");t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}var wm=b(()=>{});var ec,xa,As=b(()=>{qr();Li();Mi();wm();ec=class extends Error{constructor(t,n,a){super(t),this.description=n,this.context=a,this.type="TransportError"}},xa=class extends Ie{constructor(t){super(),this.writable=!1,Sa(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,n,a){return super.emitReserved("error",new ec(t,n,a)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){let n=ws(t,this.socket.binaryType);this.onPacket(n)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,n={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){let t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){let n=xN(t);return n.length?"?"+n:""}}});var Cs,Am=b(()=>{As();Mi();qr();Cs=class extends xa{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";let n=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let a=0;this._polling&&(a++,this.once("pollComplete",function(){--a||n()})),this.writable||(a++,this.once("drain",function(){--a||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){let n=a=>{if(this.readyState==="opening"&&a.type==="open"&&this.onOpen(),a.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(a)};gN(t,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){let t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,hN(t,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let t=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=Wu()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}}});var EN,kN,TN=b(()=>{EN=!1;try{EN=typeof XMLHttpRequest!="undefined"&&"withCredentials"in new XMLHttpRequest}catch(e){}kN=EN});function qR(){}function wN(){for(let e in ti.requests)ti.requests.hasOwnProperty(e)&&ti.requests[e].abort()}function AN(e){let t=e.xdomain;try{if(typeof XMLHttpRequest!="undefined"&&(!t||kN))return new XMLHttpRequest}catch(n){}if(!t)try{return new Qt[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch(n){}}var Cm,ti,jR,ni,tc=b(()=>{Am();Li();Mi();zi();TN();Cm=class extends Cs{constructor(t){if(super(t),typeof location!="undefined"){let n=location.protocol==="https:",a=location.port;a||(a=n?"443":"80"),this.xd=typeof location!="undefined"&&t.hostname!==location.hostname||a!==t.port}}doWrite(t,n){let a=this.request({method:"POST",data:t});a.on("success",n),a.on("error",(i,r)=>{this.onError("xhr post error",i,r)})}doPoll(){let t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(n,a)=>{this.onError("xhr poll error",n,a)}),this.pollXhr=t}},ti=class e extends Ie{constructor(t,n,a){super(),this.createRequest=t,Sa(this,a),this._opts=a,this._method=a.method||"GET",this._uri=n,this._data=a.data!==void 0?a.data:null,this._create()}_create(){var t;let n=Ku(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;let a=this._xhr=this.createRequest(n);try{a.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){a.setDisableHeaderCheck&&a.setDisableHeaderCheck(!0);for(let i in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(i)&&a.setRequestHeader(i,this._opts.extraHeaders[i])}}catch(i){}if(this._method==="POST")try{a.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(i){}try{a.setRequestHeader("Accept","*/*")}catch(i){}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(a),"withCredentials"in a&&(a.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(a.timeout=this._opts.requestTimeout),a.onreadystatechange=()=>{var i;a.readyState===3&&((i=this._opts.cookieJar)===null||i===void 0||i.parseCookies(a.getResponseHeader("set-cookie"))),a.readyState===4&&(a.status===200||a.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof a.status=="number"?a.status:0)},0))},a.send(this._data)}catch(i){this.setTimeoutFn(()=>{this._onError(i)},0);return}typeof document!="undefined"&&(this._index=e.requestsCount++,e.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr=="undefined"||this._xhr===null)){if(this._xhr.onreadystatechange=qR,t)try{this._xhr.abort()}catch(n){}typeof document!="undefined"&&delete e.requests[this._index],this._xhr=null}}_onLoad(){let t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}};ti.requestsCount=0;ti.requests={};if(typeof document!="undefined"){if(typeof attachEvent=="function")attachEvent("onunload",wN);else if(typeof addEventListener=="function"){let e="onpagehide"in Qt?"pagehide":"unload";addEventListener(e,wN,!1)}}jR=(function(){let e=AN({xdomain:!1});return e&&e.responseType!==null})(),ni=class extends Cm{constructor(t){super(t);let n=t&&t.forceBase64;this.supportsBinary=jR&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new ti(AN,this.uri(),t)}}});var CN,_m,Rm,ai,nc=b(()=>{As();Mi();qr();zi();CN=typeof navigator!="undefined"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",_m=class extends xa{get name(){return"websocket"}doOpen(){let t=this.uri(),n=this.opts.protocols,a=CN?{}:Ku(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(a.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,n,a)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let n=0;n<t.length;n++){let a=t[n],i=n===t.length-1;ks(a,this.supportsBinary,r=>{try{this.doWrite(a,r)}catch(l){}i&&ba(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws!="undefined"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let t=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=Wu()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}},Rm=Qt.WebSocket||Qt.MozWebSocket,ai=class extends _m{createSocket(t,n,a){return CN?new Rm(t,n,a):n?new Rm(t,n):new Rm(t)}doWrite(t,n){this.ws.send(n)}}});var jr,Dm=b(()=>{As();zi();qr();jr=class extends xa{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{let n=yN(Number.MAX_SAFE_INTEGER,this.socket.binaryType),a=t.readable.pipeThrough(n).getReader(),i=vN();i.readable.pipeTo(t.writable),this._writer=i.writable.getWriter();let r=()=>{a.read().then(({done:s,value:o})=>{s||(this.onPacket(o),r())}).catch(s=>{})};r();let l={type:"open"};this.query.sid&&(l.data=`{"sid":"${this.query.sid}"}`),this._writer.write(l).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let n=0;n<t.length;n++){let a=t[n],i=n===t.length-1;this._writer.write(a).then(()=>{i&&ba(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}});var Om,Lm=b(()=>{tc();nc();Dm();Om={websocket:ai,webtransport:jr,polling:ni}});function Yr(e){if(e.length>8e3)throw"URI too long";let t=e,n=e.indexOf("["),a=e.indexOf("]");n!=-1&&a!=-1&&(e=e.substring(0,n)+e.substring(n,a).replace(/:/g,";")+e.substring(a,e.length));let i=YR.exec(e||""),r={},l=14;for(;l--;)r[IR[l]]=i[l]||"";return n!=-1&&a!=-1&&(r.source=t,r.host=r.host.substring(1,r.host.length-1).replace(/;/g,":"),r.authority=r.authority.replace("[","").replace("]","").replace(/;/g,":"),r.ipv6uri=!0),r.pathNames=GR(r,r.path),r.queryKey=XR(r,r.query),r}function GR(e,t){let n=/\/{2,9}/g,a=t.replace(n,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&a.splice(0,1),t.slice(-1)=="/"&&a.splice(a.length-1,1),a}function XR(e,t){let n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(a,i,r){i&&(n[i]=r)}),n}var YR,IR,zm=b(()=>{YR=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,IR=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"]});var Mm,ac,Ui,ic,Ir,Um=b(()=>{Lm();Mi();wm();zm();Li();qr();zi();Mm=typeof addEventListener=="function"&&typeof removeEventListener=="function",ac=[];Mm&&addEventListener("offline",()=>{ac.forEach(e=>e())},!1);Ui=class e extends Ie{constructor(t,n){if(super(),this.binaryType=bN,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(n=t,t=null),t){let a=Yr(t);n.hostname=a.host,n.secure=a.protocol==="https"||a.protocol==="wss",n.port=a.port,a.query&&(n.query=a.query)}else n.host&&(n.hostname=Yr(n.host).host);Sa(this,n),this.secure=n.secure!=null?n.secure:typeof location!="undefined"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location!="undefined"?location.hostname:"localhost"),this.port=n.port||(typeof location!="undefined"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(a=>{let i=a.prototype.name;this.transports.push(i),this._transportsByName[i]=a}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=NN(this.opts.query)),Mm&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},ac.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){let n=Object.assign({},this.opts.query);n.EIO=Tm,n.transport=t,this.id&&(n.sid=this.id);let a=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](a)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}let t=this.opts.rememberUpgrade&&e.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";let n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",e.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":let n=new Error("server error");n.code=t.data,this._onError(n);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let a=0;a<this.writeBuffer.length;a++){let i=this.writeBuffer[a].data;if(i&&(n+=SN(i)),a>0&&n>this._maxPayload)return this.writeBuffer.slice(0,a);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,ba(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,n,a){return this._sendPacket("message",t,n,a),this}send(t,n,a){return this._sendPacket("message",t,n,a),this}_sendPacket(t,n,a,i){if(typeof n=="function"&&(i=n,n=void 0),typeof a=="function"&&(i=a,a=null),this.readyState==="closing"||this.readyState==="closed")return;a=a||{},a.compress=a.compress!==!1;let r={type:t,data:n,options:a};this.emitReserved("packetCreate",r),this.writeBuffer.push(r),i&&this.once("flush",i),this.flush()}close(){let t=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),t()},a=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?a():t()}):this.upgrading?a():t()),this}_onError(t){if(e.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Mm&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){let a=ac.indexOf(this._offlineEventListener);a!==-1&&ac.splice(a,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}};Ui.protocol=Tm;ic=class extends Ui{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let n=this.createTransport(t),a=!1;Ui.priorWebsocketSuccess=!1;let i=()=>{a||(n.send([{type:"ping",data:"probe"}]),n.once("packet",p=>{if(!a)if(p.type==="pong"&&p.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;Ui.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{a||this.readyState!=="closed"&&(c(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{let d=new Error("probe error");d.transport=n.name,this.emitReserved("upgradeError",d)}}))};function r(){a||(a=!0,c(),n.close(),n=null)}let l=p=>{let d=new Error("probe error: "+p);d.transport=n.name,r(),this.emitReserved("upgradeError",d)};function s(){l("transport closed")}function o(){l("socket closed")}function u(p){n&&p.name!==n.name&&r()}let c=()=>{n.removeListener("open",i),n.removeListener("error",l),n.removeListener("close",s),this.off("close",o),this.off("upgrading",u)};n.once("open",i),n.once("error",l),n.once("close",s),this.once("close",o),this.once("upgrading",u),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{a||n.open()},200):n.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){let n=[];for(let a=0;a<t.length;a++)~this.transports.indexOf(t[a])&&n.push(t[a]);return n}},Ir=class extends ic{constructor(t,n={}){let a=typeof t=="object"?t:n;(!a.transports||a.transports&&typeof a.transports[0]=="string")&&(a.transports=(a.transports||["polling","websocket","webtransport"]).map(i=>Om[i]).filter(i=>!!i)),super(t,a)}}});var RN=b(()=>{Am()});var DU,rc=b(()=>{Um();Um();As();Lm();Mi();zm();zi();RN();tc();tc();nc();nc();Dm();DU=Ir.protocol});function _N(e,t="",n){let a=e;n=n||typeof location!="undefined"&&location,e==null&&(e=n.protocol+"//"+n.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=n.protocol+e:e=n.host+e),/^(https?|wss?):\/\//.test(e)||(typeof n!="undefined"?e=n.protocol+"//"+e:e="https://"+e),a=Yr(e)),a.port||(/^(http|ws)$/.test(a.protocol)?a.port="80":/^(http|ws)s$/.test(a.protocol)&&(a.port="443")),a.path=a.path||"/";let r=a.host.indexOf(":")!==-1?"["+a.host+"]":a.host;return a.id=a.protocol+"://"+r+":"+a.port+t,a.href=a.protocol+"://"+r+(n&&n.port===a.port?"":":"+a.port),a}var DN=b(()=>{rc()});function _s(e){return FR&&(e instanceof ArrayBuffer||ZR(e))||JR&&e instanceof Blob||$R&&e instanceof File}function Rs(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,a=e.length;n<a;n++)if(Rs(e[n]))return!0;return!1}if(_s(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return Rs(e.toJSON(),!0);for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&Rs(e[n]))return!0;return!1}var FR,ZR,ON,JR,$R,Bm=b(()=>{FR=typeof ArrayBuffer=="function",ZR=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,ON=Object.prototype.toString,JR=typeof Blob=="function"||typeof Blob!="undefined"&&ON.call(Blob)==="[object BlobConstructor]",$R=typeof File=="function"||typeof File!="undefined"&&ON.call(File)==="[object FileConstructor]"});function LN(e){let t=[],n=e.data,a=e;return a.data=Vm(n,t),a.attachments=t.length,{packet:a,buffers:t}}function Vm(e,t){if(!e)return e;if(_s(e)){let n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){let n=new Array(e.length);for(let a=0;a<e.length;a++)n[a]=Vm(e[a],t);return n}else if(typeof e=="object"&&!(e instanceof Date)){let n={};for(let a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=Vm(e[a],t));return n}return e}function zN(e,t){return e.data=Hm(e.data,t),delete e.attachments,e}function Hm(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=Hm(e[n],t);else if(typeof e=="object")for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=Hm(e[n],t));return e}var MN=b(()=>{Bm()});var Ym={};oc(Ym,{Decoder:()=>qm,Encoder:()=>Pm,PacketType:()=>be,protocol:()=>BN});function UN(e){return Object.prototype.toString.call(e)==="[object Object]"}var KR,BN,be,Pm,qm,jm,lc=b(()=>{Li();MN();Bm();KR=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],BN=5;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(be||(be={}));Pm=class{constructor(t){this.replacer=t}encode(t){return(t.type===be.EVENT||t.type===be.ACK)&&Rs(t)?this.encodeAsBinary({type:t.type===be.EVENT?be.BINARY_EVENT:be.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===be.BINARY_EVENT||t.type===be.BINARY_ACK)&&(n+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(n+=t.nsp+","),t.id!=null&&(n+=t.id),t.data!=null&&(n+=JSON.stringify(t.data,this.replacer)),n}encodeAsBinary(t){let n=LN(t),a=this.encodeAsString(n.packet),i=n.buffers;return i.unshift(a),i}};qm=class e extends Ie{constructor(t){super(),this.reviver=t}add(t){let n;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(t);let a=n.type===be.BINARY_EVENT;a||n.type===be.BINARY_ACK?(n.type=a?be.EVENT:be.ACK,this.reconstructor=new jm(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(_s(t)||t.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(t),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let n=0,a={type:Number(t.charAt(0))};if(be[a.type]===void 0)throw new Error("unknown packet type "+a.type);if(a.type===be.BINARY_EVENT||a.type===be.BINARY_ACK){let r=n+1;for(;t.charAt(++n)!=="-"&&n!=t.length;);let l=t.substring(r,n);if(l!=Number(l)||t.charAt(n)!=="-")throw new Error("Illegal attachments");a.attachments=Number(l)}if(t.charAt(n+1)==="/"){let r=n+1;for(;++n&&!(t.charAt(n)===","||n===t.length););a.nsp=t.substring(r,n)}else a.nsp="/";let i=t.charAt(n+1);if(i!==""&&Number(i)==i){let r=n+1;for(;++n;){let l=t.charAt(n);if(l==null||Number(l)!=l){--n;break}if(n===t.length)break}a.id=Number(t.substring(r,n+1))}if(t.charAt(++n)){let r=this.tryParse(t.substr(n));if(e.isPayloadValid(a.type,r))a.data=r;else throw new Error("invalid payload")}return a}tryParse(t){try{return JSON.parse(t,this.reviver)}catch(n){return!1}}static isPayloadValid(t,n){switch(t){case be.CONNECT:return UN(n);case be.DISCONNECT:return n===void 0;case be.CONNECT_ERROR:return typeof n=="string"||UN(n);case be.EVENT:case be.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&KR.indexOf(n[0])===-1);case be.ACK:case be.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},jm=class{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){let n=zN(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}});function xn(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var Im=b(()=>{});var WR,Gr,Gm=b(()=>{lc();Im();Li();WR=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),Gr=class extends Ie{constructor(t,n,a){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=n,a&&a.auth&&(this.auth=a.auth),this._opts=Object.assign({},a),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let t=this.io;this.subs=[xn(t,"open",this.onopen.bind(this)),xn(t,"packet",this.onpacket.bind(this)),xn(t,"error",this.onerror.bind(this)),xn(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...n){var a,i,r;if(WR.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(n.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;let l={type:be.EVENT,data:n};if(l.options={},l.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){let c=this.ids++,p=n.pop();this._registerAckCallback(c,p),l.id=c}let s=(i=(a=this.io.engine)===null||a===void 0?void 0:a.transport)===null||i===void 0?void 0:i.writable,o=this.connected&&!(!((r=this.io.engine)===null||r===void 0)&&r._hasPingExpired());return this.flags.volatile&&!s||(o?(this.notifyOutgoingListeners(l),this.packet(l)):this.sendBuffer.push(l)),this.flags={},this}_registerAckCallback(t,n){var a;let i=(a=this.flags.timeout)!==null&&a!==void 0?a:this._opts.ackTimeout;if(i===void 0){this.acks[t]=n;return}let r=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let s=0;s<this.sendBuffer.length;s++)this.sendBuffer[s].id===t&&this.sendBuffer.splice(s,1);n.call(this,new Error("operation has timed out"))},i),l=(...s)=>{this.io.clearTimeoutFn(r),n.apply(this,s)};l.withError=!0,this.acks[t]=l}emitWithAck(t,...n){return new Promise((a,i)=>{let r=(l,s)=>l?i(l):a(s);r.withError=!0,n.push(r),this.emit(t,...n)})}_addToQueue(t){let n;typeof t[t.length-1]=="function"&&(n=t.pop());let a={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((i,...r)=>a!==this._queue[0]?void 0:(i!==null?a.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(i)):(this._queue.shift(),n&&n(null,...r)),a.pending=!1,this._drainQueue())),this._queue.push(a),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;let n=this._queue[0];n.pending&&!t||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:be.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(a=>String(a.id)===t)){let a=this.acks[t];delete this.acks[t],a.withError&&a.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case be.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case be.EVENT:case be.BINARY_EVENT:this.onevent(t);break;case be.ACK:case be.BINARY_ACK:this.onack(t);break;case be.DISCONNECT:this.ondisconnect();break;case be.CONNECT_ERROR:this.destroy();let a=new Error(t.data.message);a.data=t.data.data,this.emitReserved("connect_error",a);break}}onevent(t){let n=t.data||[];t.id!=null&&n.push(this.ack(t.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){let n=this._anyListeners.slice();for(let a of n)a.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){let n=this,a=!1;return function(...i){a||(a=!0,n.packet({type:be.ACK,id:t,data:i}))}}onack(t){let n=this.acks[t.id];typeof n=="function"&&(delete this.acks[t.id],n.withError&&t.data.unshift(null),n.apply(this,t.data))}onconnect(t,n){this.id=t,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:be.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){let n=this._anyListeners;for(let a=0;a<n.length;a++)if(t===n[a])return n.splice(a,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){let n=this._anyOutgoingListeners;for(let a=0;a<n.length;a++)if(t===n[a])return n.splice(a,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let n=this._anyOutgoingListeners.slice();for(let a of n)a.apply(this,t.data)}}}});function Bi(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}var VN=b(()=>{Bi.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=(Math.floor(t*10)&1)==0?e-n:e+n}return Math.min(e,this.max)|0};Bi.prototype.reset=function(){this.attempts=0};Bi.prototype.setMin=function(e){this.ms=e};Bi.prototype.setMax=function(e){this.max=e};Bi.prototype.setJitter=function(e){this.jitter=e}});var Xr,HN=b(()=>{rc();Gm();lc();Im();VN();Li();Xr=class extends Ie{constructor(t,n){var a;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(n=t,t=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,Sa(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((a=n.randomizationFactor)!==null&&a!==void 0?a:.5),this.backoff=new Bi({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=t;let i=n.parser||Ym;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var n;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(n=this.backoff)===null||n===void 0||n.setMin(t),this)}randomizationFactor(t){var n;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(n=this.backoff)===null||n===void 0||n.setJitter(t),this)}reconnectionDelayMax(t){var n;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(n=this.backoff)===null||n===void 0||n.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new Ir(this.uri,this.opts);let n=this.engine,a=this;this._readyState="opening",this.skipReconnect=!1;let i=xn(n,"open",function(){a.onopen(),t&&t()}),r=s=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",s),t?t(s):this.maybeReconnectOnOpen()},l=xn(n,"error",r);if(this._timeout!==!1){let s=this._timeout,o=this.setTimeoutFn(()=>{i(),r(new Error("timeout")),n.close()},s);this.opts.autoUnref&&o.unref(),this.subs.push(()=>{this.clearTimeoutFn(o)})}return this.subs.push(i),this.subs.push(l),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");let t=this.engine;this.subs.push(xn(t,"ping",this.onping.bind(this)),xn(t,"data",this.ondata.bind(this)),xn(t,"error",this.onerror.bind(this)),xn(t,"close",this.onclose.bind(this)),xn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(n){this.onclose("parse error",n)}}ondecoded(t){ba(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,n){let a=this.nsps[t];return a?this._autoConnect&&!a.active&&a.connect():(a=new Gr(this,t,n),this.nsps[t]=a),a}_destroy(t){let n=Object.keys(this.nsps);for(let a of n)if(this.nsps[a].active)return;this._close()}_packet(t){let n=this.encoder.encode(t);for(let a=0;a<n.length;a++)this.engine.write(n[a],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,n){var a;this.cleanup(),(a=this.engine)===null||a===void 0||a.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let n=this.backoff.duration();this._reconnecting=!0;let a=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(i=>{i?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",i)):t.onreconnect()}))},n);this.opts.autoUnref&&a.unref(),this.subs.push(()=>{this.clearTimeoutFn(a)})}}onreconnect(){let t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}});function Os(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};let n=_N(e,t.path||"/socket.io"),a=n.source,i=n.id,r=n.path,l=Ds[i]&&r in Ds[i].nsps,s=t.forceNew||t["force new connection"]||t.multiplex===!1||l,o;return s?o=new Xr(a,t):(Ds[i]||(Ds[i]=new Xr(a,t)),o=Ds[i]),n.query&&!t.query&&(t.query=n.queryKey),o.socket(n.path,t)}var Ds,PN=b(()=>{DN();HN();Gm();lc();rc();Ds={};Object.assign(Os,{Manager:Xr,Socket:Gr,io:Os,connect:Os})});var rn,ge,Xm,qN=b(()=>{"use strict";rn=F(Je());PN();an();ge=F(re()),Xm=({apiKey:e,agentId:t,sandboxId:n})=>{let[a,i]=(0,rn.useState)([]),[r,l]=(0,rn.useState)(!1),[s,o]=(0,rn.useState)(new Set),[u,c]=(0,rn.useState)(!0),[p,d]=(0,rn.useState)(!1),f=(0,rn.useRef)(null),S=(0,rn.useRef)(null),x=(0,rn.useRef)(null),k=()=>{var g;(g=f.current)==null||g.scrollIntoView({behavior:"smooth"})},m=g=>{o(E=>{let T=new Set(E);return T.has(g)?T.delete(g):T.add(g),T})},h=()=>z(null,null,function*(){try{console.log("Clearing logs from all sandbox skills with API key:",e,"agentId:",t),d(!0);let g=yield ie.getAllSkillOverrides();if(g.length===0){console.log("No skills found to clear logs from"),i([]),o(new Set);return}let E=g.map(A=>z(null,null,function*(){try{return yield ie.clearSandboxLogs(e,t,A.sandboxId)}catch(C){return console.error(`Error clearing logs for skill ${A.skillId}:`,C),{success:!1,error:"Failed to clear logs"}}}));(yield Promise.all(E)).every(A=>A.success)?(i([]),o(new Set),console.log("All logs cleared successfully")):(console.error("Some log clearing operations failed"),alert("Some logs could not be cleared. Check console for details."))}catch(g){console.error("Failed to clear logs:",g),alert("Failed to clear logs")}finally{d(!1)}});return(0,rn.useEffect)(()=>{k()},[a]),(0,rn.useEffect)(()=>{e&&t&&z(null,null,function*(){try{console.log("Loading logs from all sandbox skills with API key:",e,"agentId:",t),c(!0);let E=yield ie.loadAllSandboxLogs(e,t,100);if(console.log("All sandbox logs response:",E),E.success&&E.data){let T=E.data.logs.map(N=>({_id:N._id,id:N.id,timestamp:new Date(N.timestamp).toLocaleTimeString(),type:N.type,subType:N.subType,message:N.message,duration:N.duration,error:N.error,metadata:N.metadata,skillName:N.skillName,sandboxId:N.sandboxId}));console.log("Converted logs from all skills:",T),i(T)}else console.log("No logs or error:",E.error)}catch(E){console.error("Failed to load logs from all skills:",E)}finally{c(!1)}})},[e,t]),(0,rn.useEffect)(()=>{let g=()=>{try{let N=new WebSocket("ws://localhost:3000");S.current=N,N.onopen=()=>{console.log("Connected to CLI dev server"),l(!0)},N.onclose=()=>{console.log("Disconnected from CLI dev server")},N.onmessage=A=>{try{let C=JSON.parse(A.data);if(console.log("Received message from CLI:",C),C.type==="log"){let U={id:C.id||Date.now().toString(),timestamp:new Date(C.timestamp||Date.now()).toLocaleTimeString(),type:C.type||"log",subType:C.subType||"info",message:C.message||"No message",metadata:C.metadata||{},error:C.error};i(P=>[...P,U])}}catch(C){console.error("Failed to parse CLI WebSocket message:",C)}},N.onerror=A=>{console.error("CLI WebSocket error:",A)}}catch(N){console.error("Failed to connect to CLI dev server:",N)}},E=()=>{try{let N=Os("wss://api.heylua.ai/feed",{query:{apiKey:e,channel:"logs"}});x.current=N,N.on("connect",()=>{console.log("Connected to server log feed"),l(!0),T("\u{1F7E2} Connected to log feed","connected")}),N.on("disconnect",()=>{console.log("Disconnected from server log feed"),l(!1),T("\u{1F534} Disconnected from log feed","disconnected")}),N.on("log",A=>{let C="info",U="No message",P={},_="";if(A&&typeof A=="object"){let O=A.data||A;C=O.subType||"info",U=O.message||"No message",P=O.metadata||{},_=O.error||O.details||"",_&&typeof _=="object"&&(_=JSON.stringify(_,null,2))}else typeof A=="string"&&(U=A,C="info");let R={id:Date.now().toString(),timestamp:new Date().toLocaleTimeString(),type:"log",subType:C,message:U,metadata:P,error:_};i(O=>[...O,R])}),N.on("connect_error",A=>{T("\u{1F534} Connection failed","disconnected")})}catch(N){T("\u{1F534} Connection error","disconnected")}},T=(N,A)=>{let C=document.getElementById("logConnectionStatus");C&&(C.textContent=N,C.className=`log-connection-status ${A}`)};return g(),e&&t&&n&&E(),()=>{S.current&&S.current.close(),x.current&&x.current.disconnect()}},[e,t,n]),(0,ge.jsxs)("div",{className:"log-messages",children:[(0,ge.jsxs)("div",{className:"logs-header",children:[(0,ge.jsxs)("div",{className:"logs-title",children:["Console Logs (",a.length,")"]}),(0,ge.jsx)("div",{className:"logs-actions",children:(0,ge.jsx)("button",{className:"clear-logs-button",onClick:h,disabled:p,title:"Clear all logs",children:p?"\u27F3":"\u{1F5D1}\uFE0F"})})]}),(0,ge.jsxs)("div",{className:"log-content",children:[u?(0,ge.jsx)("div",{className:"no-logs",children:(0,ge.jsx)("img",{src:"https://admin.heylua.ai/images/logo.svg",alt:"Loading",className:"loading-logo"})}):a.length===0?(0,ge.jsxs)("div",{className:"no-logs",children:[(0,ge.jsx)("div",{className:"no-logs-icon",children:"\u{1F4CB}"}),(0,ge.jsx)("div",{className:"no-logs-text",children:"No logs yet"}),(0,ge.jsx)("div",{className:"no-logs-subtext",children:"Console logs will appear here when your skill runs"})]}):(0,ge.jsx)(ge.Fragment,{children:a.map(g=>{let E=s.has(g.id),T=g.metadata&&Object.keys(g.metadata).length>0,N=g.error&&typeof g.error=="string"&&g.error.trim()!=="",A=T||N;return(0,ge.jsxs)("div",{className:`log-entry ${g.subType}`,children:[(0,ge.jsxs)("div",{className:"log-main",onClick:()=>m(g.id),children:[(0,ge.jsxs)("span",{className:"log-timestamp",children:["[",g.timestamp,"]"]}),(0,ge.jsxs)("span",{className:"log-type",children:["[",g.subType.toUpperCase(),"]"]}),g.skillName&&(0,ge.jsxs)("span",{className:"log-skill",children:["[",g.skillName,"]"]}),(0,ge.jsx)("span",{className:`log-message ${E?"expanded":"ellipsed"}`,children:g.message}),(0,ge.jsx)("span",{className:`expand-arrow ${E?"expanded":""}`,children:"\u25B6"})]}),E&&(0,ge.jsxs)("div",{className:"log-details",children:[(0,ge.jsxs)("div",{className:"full-message",children:[(0,ge.jsx)("div",{className:"detail-label",children:"Message:"}),(0,ge.jsx)("div",{className:"detail-content",children:g.message})]}),N&&(0,ge.jsxs)("div",{className:"error-details",children:[(0,ge.jsx)("div",{className:"detail-label",children:"Error:"}),(0,ge.jsx)("div",{className:"detail-content",children:typeof g.error=="string"?g.error:JSON.stringify(g.error)})]}),T&&(0,ge.jsxs)("div",{className:"metadata",children:[(0,ge.jsx)("div",{className:"detail-label",children:"Metadata:"}),Object.entries(g.metadata).map(([C,U])=>(0,ge.jsxs)("div",{className:"metadata-item",children:[(0,ge.jsxs)("span",{className:"metadata-key",children:[C,":"]}),(0,ge.jsx)("span",{className:"metadata-value",children:String(U)})]},C))]})]})]},g.id)})}),(0,ge.jsx)("div",{ref:f})]}),(0,ge.jsx)("div",{className:"log-footer-status",children:(0,ge.jsx)("div",{id:"logConnectionStatus",className:"log-connection-status",children:"\u{1F7E1} Connecting..."})})]})}});var jN=b(()=>{});var YN,IN,GN=b(()=>{"use strict";YN=F(Je());an();jN();IN=F(re())});var XN=b(()=>{"use strict";eN();tN();qN();hm();bm();xm();GN();vm()});var Nn,Un,QN,FN=b(()=>{"use strict";Nn=F(Je());XN();an();Un=F(re()),QN=({apiKey:e,agentId:t,skillId:n,sandboxId:a,sharedChatMessages:i,onSharedSendMessage:r,onSharedClearHistory:l,isChatLoading:s,setIsChatLoading:o})=>{let[u,c]=(0,Nn.useState)("persona"),[p,d]=(0,Nn.useState)(""),[f,S]=(0,Nn.useState)(window.innerWidth/2),[x,k]=(0,Nn.useState)(250),m=(0,Nn.useRef)(!1),h=(0,Nn.useRef)(!1),g=(0,Nn.useRef)(null),E=(0,Nn.useRef)(null);(0,Nn.useEffect)(()=>{T()},[]),(0,Nn.useEffect)(()=>{let A=P=>{var R,O;let _=P.target;_===g.current||(R=g.current)!=null&&R.contains(_)?(m.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none",P.preventDefault()):(_===E.current||(O=E.current)!=null&&O.contains(_))&&(h.current=!0,document.body.style.cursor="row-resize",document.body.style.userSelect="none",P.preventDefault())},C=P=>{if(m.current){let _=window.innerWidth,R=_-P.clientX,O=500,I=_-300;R>=O&&R<=I&&S(R)}else if(h.current){let _=window.innerHeight-60,R=_-P.clientY+60,O=150,I=_-300;R>=O&&R<=I&&k(R)}},U=()=>{m.current?(m.current=!1,document.body.style.cursor="",document.body.style.userSelect=""):h.current&&(h.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousedown",A),document.addEventListener("mousemove",C),document.addEventListener("mouseup",U),()=>{document.removeEventListener("mousedown",A),document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",U)}},[]);let T=()=>z(null,null,function*(){try{let A=yield ie.loadPersona();A.success&&d(A.persona||"")}catch(A){console.error("Failed to load persona:",A)}}),N=A=>z(null,null,function*(){try{let C=yield ie.savePersona(A);return C.success?(d(A),!0):(alert("Failed to save persona: "+(C.error||"Unknown error")),!1)}catch(C){return console.error("Failed to save persona:",C),alert("Failed to save persona"),!1}});return(0,Un.jsxs)("div",{className:"sandbox-page",children:[(0,Un.jsxs)("div",{className:"left-side",style:{width:`calc(100% - ${f}px)`},children:[(0,Un.jsx)("div",{className:"chat-container",style:{height:`calc(100% - ${x}px)`},children:(0,Un.jsx)(pm,{apiKey:e,agentId:t,skillId:n,sandboxId:a,persona:p,sharedChatMessages:i,onSharedSendMessage:r,onSharedClearHistory:l,isChatLoading:s,setIsChatLoading:o})}),(0,Un.jsx)("div",{ref:E,className:"logs-resize-handle",children:(0,Un.jsx)("div",{className:"resize-line"})}),(0,Un.jsx)("div",{className:"logs-container",style:{height:`${x}px`},children:(0,Un.jsx)(Xm,{apiKey:e,agentId:t,sandboxId:a})})]}),(0,Un.jsx)("div",{ref:g,className:"resize-handle"}),(0,Un.jsx)(Nm,{activeTab:u,onTabChange:c,persona:p,onSavePersona:N,apiKey:e,agentId:t,skillId:n,sandboxId:a,width:f})]})}});var ZN,qt,Qm,JN=b(()=>{"use strict";ZN=F(Je());fm();qt=F(re()),Qm=({messages:e,onSendMessage:t,onClearHistory:n,isLoading:a})=>{let[i,r]=(0,ZN.useState)(""),l=e.length>0?e:[{id:"welcome",text:"Welcome to Production Management! I can help you monitor deployments, analyze performance, and manage your live environment. How can I assist you today?",sender:"assistant",timestamp:new Date}],s=()=>{!i.trim()||a||(t(i),r(""))},o=u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),s())};return(0,qt.jsxs)("div",{className:"production-chat",children:[(0,qt.jsxs)("div",{className:"chat-header",children:[(0,qt.jsx)("h3",{children:"Production Chat"}),(0,qt.jsx)("button",{onClick:n,className:"clear-history-button",title:"Clear chat history",children:"\u{1F5D1}\uFE0F"})]}),(0,qt.jsxs)("div",{className:"chat-messages",children:[l.map(u=>(0,qt.jsx)("div",{className:`message ${u.sender}`,children:(0,qt.jsx)("div",{className:"message-bubble",children:(0,qt.jsx)(Ss,{children:u.text})})},u.id)),a&&(0,qt.jsx)("div",{className:"loading",children:(0,qt.jsx)("img",{src:"https://admin.heylua.ai/images/logo.svg",alt:"Loading",className:"loading-logo"})})]}),(0,qt.jsx)("div",{className:"chat-input-container",children:(0,qt.jsxs)("div",{className:"chat-input-form",children:[(0,qt.jsx)("input",{type:"text",id:"production-chat-input",name:"productionChatMessage",value:i,onChange:u=>r(u.target.value),onKeyPress:o,placeholder:"Type your message...",className:"chat-input",disabled:a,autoComplete:"off"}),(0,qt.jsx)("button",{onClick:s,disabled:a||!i.trim(),className:"send-button",children:"Send"})]})})]})}});var e_,$N,KN=b(()=>{"use strict";e_=F(Je()),$N=F(re())});var t_,WN,Fm=b(()=>{"use strict";t_=F(Je()),WN=F(re())});var a_,eE,tE=b(()=>{"use strict";a_=F(Je());Fm();eE=F(re())});var ln,te,Zm,nE=b(()=>{"use strict";ln=F(Je());an();te=F(re()),Zm=({apiKey:e,agentId:t})=>{let[n,a]=(0,ln.useState)([]),[i,r]=(0,ln.useState)(!0),[l,s]=(0,ln.useState)(new Set),[o,u]=(0,ln.useState)(1),[c,p]=(0,ln.useState)(1),[d,f]=(0,ln.useState)(0),[S,x]=(0,ln.useState)(!1),[k,m]=(0,ln.useState)(!1),h=(0,ln.useRef)(null),g=()=>{var _;(_=h.current)==null||_.scrollIntoView({behavior:"smooth"})},E=_=>{s(R=>{let O=new Set(R);return O.has(_)?O.delete(_):O.add(_),O})},T=(_=1)=>z(null,null,function*(){r(!0);try{console.log("Loading production logs for page:",_);let R=yield ie.loadProductionLogs(e,t,_,20);if(R.success&&R.logs){let O=[...R.logs].reverse();a(O),R.pagination&&(u(R.pagination.currentPage),p(R.pagination.totalPages),f(R.pagination.totalCount),x(R.pagination.hasNextPage),m(R.pagination.hasPrevPage))}else console.error("Failed to load production logs:",R.error),a([])}catch(R){console.error("Error loading production logs:",R),a([])}finally{r(!1)}}),N=()=>{T(o)},A=_=>{_>=1&&_<=c&&(u(_),T(_))},C=()=>{S&&A(o+1)},U=()=>{k&&A(o-1)};(0,ln.useEffect)(()=>{e&&t&&T(1)},[e,t]),(0,ln.useEffect)(()=>{g()},[n]);let P=_=>new Date(_).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});return i&&n.length===0?(0,te.jsx)("div",{className:"logs-panel",children:(0,te.jsx)("div",{className:"logs-loading",children:(0,te.jsx)("img",{src:"https://admin.heylua.ai/images/logo.svg",alt:"Loading",className:"loading-logo"})})}):(0,te.jsxs)("div",{className:"logs-panel",children:[(0,te.jsxs)("div",{className:"logs-header",children:[(0,te.jsxs)("div",{className:"logs-header-content",children:[(0,te.jsx)("h3",{children:"Production Logs"}),(0,te.jsx)("div",{className:"logs-info",children:d>0&&(0,te.jsxs)("span",{className:"logs-count",children:[d," total logs"]})})]}),(0,te.jsx)("div",{className:"logs-actions",children:(0,te.jsx)("button",{className:"refresh-logs-button",onClick:N,disabled:i,title:"Refresh logs",children:i?(0,te.jsx)("img",{src:"https://admin.heylua.ai/images/logo.svg",alt:"Loading",className:"loading-logo-button"}):"\u21BB"})})]}),(0,te.jsx)("div",{className:"logs-content",children:n.length===0?(0,te.jsxs)("div",{className:"no-logs",children:[(0,te.jsx)("div",{className:"no-logs-icon",children:"\u{1F4DD}"}),(0,te.jsx)("div",{className:"no-logs-text",children:"No logs found"}),(0,te.jsx)("div",{className:"no-logs-subtext",children:"Production logs will appear here when your skills are used"})]}):(0,te.jsxs)("div",{className:"logs-list",children:[n.map(_=>{var I,B,J,ae;let R=l.has(_.id),O=_.metadata&&(_.metadata.toolId||_.metadata.skillName);return(0,te.jsxs)("div",{className:`log-entry ${_.subType} ${R?"expanded":""}`,children:[(0,te.jsxs)("div",{className:"log-main",onClick:()=>O&&E(_.id),style:{cursor:O?"pointer":"default"},children:[(0,te.jsx)("span",{className:"log-timestamp",children:P(_.timestamp)}),(0,te.jsx)("span",{className:`log-level ${_.subType}`,children:_.subType.toUpperCase()}),(0,te.jsx)("span",{className:"log-message",children:_.message}),((I=_.metadata)==null?void 0:I.skillName)&&(0,te.jsx)("span",{className:"log-skill",children:_.metadata.skillName}),O&&(0,te.jsx)("span",{className:`expand-arrow ${R?"expanded":""}`,children:"\u25B6"})]}),R&&O&&(0,te.jsxs)("div",{className:"log-details",children:[((B=_.metadata)==null?void 0:B.toolId)&&(0,te.jsxs)("div",{className:"metadata-item",children:[(0,te.jsx)("span",{className:"metadata-key",children:"Tool:"}),(0,te.jsx)("span",{className:"metadata-value",children:_.metadata.toolId})]}),((J=_.metadata)==null?void 0:J.skillName)&&(0,te.jsxs)("div",{className:"metadata-item",children:[(0,te.jsx)("span",{className:"metadata-key",children:"Skill:"}),(0,te.jsx)("span",{className:"metadata-value",children:_.metadata.skillName})]}),((ae=_.metadata)==null?void 0:ae.userId)&&(0,te.jsxs)("div",{className:"metadata-item",children:[(0,te.jsx)("span",{className:"metadata-key",children:"User:"}),(0,te.jsx)("span",{className:"metadata-value",children:_.metadata.userId})]})]})]},_.id)}),(0,te.jsx)("div",{ref:h})]})}),c>1&&(0,te.jsxs)("div",{className:"logs-pagination",children:[(0,te.jsxs)("div",{className:"pagination-info",children:["Page ",o," of ",c]}),(0,te.jsxs)("div",{className:"pagination-controls",children:[(0,te.jsx)("button",{className:"pagination-button",onClick:U,disabled:!k||i,title:"Previous page",children:"\u2190"}),(0,te.jsxs)("span",{className:"page-numbers",children:[o>2&&(0,te.jsxs)(te.Fragment,{children:[(0,te.jsx)("button",{className:"page-number",onClick:()=>A(1),disabled:i,children:"1"}),o>3&&(0,te.jsx)("span",{className:"page-ellipsis",children:"..."})]}),o>1&&(0,te.jsx)("button",{className:"page-number",onClick:()=>A(o-1),disabled:i,children:o-1}),(0,te.jsx)("button",{className:"page-number active",disabled:!0,children:o}),o<c&&(0,te.jsx)("button",{className:"page-number",onClick:()=>A(o+1),disabled:i,children:o+1}),o<c-1&&(0,te.jsxs)(te.Fragment,{children:[o<c-2&&(0,te.jsx)("span",{className:"page-ellipsis",children:"..."}),(0,te.jsx)("button",{className:"page-number",onClick:()=>A(c),disabled:i,children:c})]})]}),(0,te.jsx)("button",{className:"pagination-button",onClick:C,disabled:!S||i,title:"Next page",children:"\u2192"})]})]})]})}});var ze,H,Jm,i_,$m,r_,aE=b(()=>{"use strict";ze=F(Je());an();H=F(re()),Jm=e=>{if(!e||!e.trim())return e||"";try{let t=JSON.parse(e);return JSON.stringify(t,null,2).replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,a=>{let i="json-number";return/^"/.test(a)?/:$/.test(a)?i="json-key":i="json-string":/true|false/.test(a)?i="json-boolean":/null/.test(a)&&(i="json-null"),`<span class="${i}">${a}</span>`})}catch(t){return e.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,n=>{let a="json-number";return/^"/.test(n)?/:$/.test(n)?a="json-key":a="json-string":/true|false/.test(n)?a="json-boolean":/null/.test(n)&&(a="json-null"),`<span class="${a}">${n}</span>`})}},i_=[{id:"user",name:"User",description:"User profile and account data",icon:"\u{1F464}"},{id:"resources",name:"Resources",description:"Files, documents, and assets",icon:"\u{1F4C1}"},{id:"products",name:"Products",description:"Product catalog and inventory",icon:"\u{1F4E6}"},{id:"baskets",name:"Baskets",description:"Shopping carts and baskets",icon:"\u{1F6D2}"},{id:"orders",name:"Orders",description:"Order history and transactions",icon:"\u{1F4CB}"},{id:"booking",name:"Booking",description:"Reservations and appointments",icon:"\u{1F4C5}"},{id:"custom",name:"Custom",description:"Custom application data",icon:"\u2699\uFE0F"}],$m=({apiKey:e,agentId:t})=>{let[n,a]=(0,ze.useState)(null),[i,r]=(0,ze.useState)(null),[l,s]=(0,ze.useState)(null),[o,u]=(0,ze.useState)(!1),[c,p]=(0,ze.useState)(!1),[d,f]=(0,ze.useState)(!1),[S,x]=(0,ze.useState)(""),[k,m]=(0,ze.useState)(null),[h,g]=(0,ze.useState)(null),[E,T]=(0,ze.useState)(!1),[N,A]=(0,ze.useState)("list"),C=(0,ze.useRef)(null),U=(0,ze.useRef)(null),[P,_]=(0,ze.useState)(!1),[R,O]=(0,ze.useState)(""),[I,B]=(0,ze.useState)(""),[J,ae]=(0,ze.useState)(!1);(0,ze.useEffect)(()=>{we()},[e,t]),(0,ze.useEffect)(()=>{if(console.log("JSON text changed:",S),U.current&&C.current){let X=Jm(S);U.current.innerHTML=X,U.current.scrollTop=C.current.scrollTop,U.current.scrollLeft=C.current.scrollLeft}},[S]),(0,ze.useEffect)(()=>{if(k||h){let X=setTimeout(()=>{m(null),g(null)},5e3);return()=>clearTimeout(X)}},[k,h]);let we=()=>z(null,null,function*(){u(!0);try{let X=yield ie.loadUserData(e,t);console.log("User data response:",X),X.success&&X.data?(console.log("User data loaded successfully:",X.data),a(X.data),x(JSON.stringify(X.data,null,2))):(console.error("Failed to load user data:",X.error),a(null),x("{}"))}catch(X){console.error("Error loading user data:",X),a(null),x("{}")}finally{u(!1)}}),je=()=>z(null,null,function*(){if(S.trim()){p(!0);try{let X;try{X=JSON.parse(S)}catch(ne){m("Invalid JSON format. Please check your syntax.");return}let Q=yield ie.updateUserData(e,t,X);Q.success?(a(Q.data||null),T(!1),g("User data saved successfully"),console.log("User data saved successfully")):m("Failed to save user data: "+(Q.error||"Unknown error"))}catch(X){console.error("Error saving user data:",X),m("Failed to save user data")}finally{p(!1)}}}),v=()=>z(null,null,function*(){f(!0);try{let X=yield ie.clearUserData(e,t);X.success?(a(null),x("{}"),T(!1),g("User data cleared successfully"),console.log("User data cleared successfully")):m("Failed to clear user data: "+(X.error||"Unknown error"))}catch(X){console.error("Error clearing user data:",X),m("Failed to clear user data")}finally{f(!1)}}),Me=X=>z(null,null,function*(){if(r(X),A("detail"),T(!1),m(null),X.id==="user"){u(!0);try{let Q=yield ie.loadUserData(e,t);if(Q.success&&Q.data){s(Q.data);let ne=JSON.stringify(Q.data,null,2);x(ne),console.log("Setting JSON text for user data:",ne)}else s(null),x("{}"),console.log("No user data found, setting empty JSON")}catch(Q){console.error("Failed to load user data:",Q),s(null),x("{}")}finally{u(!1)}}else if(X.id==="resources"){u(!0);try{let Q=yield ie.loadResources(e,t);Q.success&&Q.data?(s(Q.data),console.log("Loaded resources:",Q.data)):(s([]),console.log("No resources found"))}catch(Q){console.error("Failed to load resources:",Q),s([])}finally{u(!1)}}else s(null),x("{}")}),pt=()=>{A("list"),r(null),s(null),T(!1)},y=()=>{(i==null?void 0:i.id)==="resources"?(_(!0),O(""),B("")):(x("{}"),T(!0))},Ke=()=>z(null,null,function*(){if(!R.trim()||!I.trim()){m("Please provide both name and content for the resource");return}ae(!0);try{let X=yield ie.createResource(e,t,{name:R.trim(),content:I.trim()});X.success?(_(!1),O(""),B(""),g("Resource created successfully"),(i==null?void 0:i.id)==="resources"&&(yield Me(i))):m("Failed to create resource: "+(X.error||"Unknown error"))}catch(X){console.error("Error creating resource:",X),m("Failed to create resource")}finally{ae(!1)}}),At=X=>{x(X),C.current&&U.current&&(U.current.scrollTop=C.current.scrollTop,U.current.scrollLeft=C.current.scrollLeft)},se=()=>{T(!0),setTimeout(()=>{C.current&&C.current.focus()},0)};return o&&N==="list"?(0,H.jsx)("div",{className:"user-data-panel",children:(0,H.jsx)("div",{className:"user-data-loading",children:(0,H.jsx)("img",{src:"https://admin.heylua.ai/images/logo.svg",alt:"Loading",className:"loading-logo"})})}):(0,H.jsxs)("div",{className:"user-data-panel",children:[(0,H.jsxs)("div",{className:"user-data-header",children:[N==="detail"&&i?(0,H.jsxs)("div",{className:"header-with-back",children:[(0,H.jsx)("button",{className:"back-button",onClick:pt,title:"Back to Data",children:"\u2190"}),(0,H.jsxs)("h3",{children:[i.name," Data"]})]}):(0,H.jsx)("h3",{children:"Data Management"}),(0,H.jsxs)("div",{className:"user-data-actions",children:[N==="detail"&&(i==null?void 0:i.id)!=="user"&&(0,H.jsx)("button",{className:"add-button",onClick:y,title:`Add new ${i==null?void 0:i.name.toLowerCase()}`,children:"\u2795"}),(0,H.jsx)("button",{className:"refresh-button",onClick:N==="detail"&&i?()=>Me(i):we,disabled:o,title:`Refresh ${N==="detail"?i==null?void 0:i.name.toLowerCase():"data"}`,children:o?"\u27F3":"\u21BB"}),N==="detail"&&(i==null?void 0:i.id)==="user"&&(0,H.jsx)("button",{className:"save-button",onClick:je,disabled:c,title:"Save user data",children:c?"\u27F3":"\u{1F4BE}"}),N==="detail"&&(0,H.jsx)("button",{className:"delete-button",onClick:v,disabled:c,title:`Clear ${i==null?void 0:i.name.toLowerCase()} data`,children:"\u{1F5D1}\uFE0F"})]})]}),(0,H.jsx)("div",{className:"user-data-content",children:N==="list"?(0,H.jsx)("div",{className:"data-list",children:(0,H.jsx)("div",{className:"data-categories",children:i_.map(X=>(0,H.jsxs)("div",{className:"data-category",onClick:()=>Me(X),children:[(0,H.jsx)("div",{className:"category-icon",children:X.icon}),(0,H.jsxs)("div",{className:"category-info",children:[(0,H.jsx)("div",{className:"category-name",children:X.name}),(0,H.jsx)("div",{className:"category-description",children:X.description})]}),(0,H.jsx)("div",{className:"category-arrow",children:"\u2192"})]},X.id))})}):(i==null?void 0:i.id)==="user"?(0,H.jsx)("div",{className:"data-detail",children:o?(0,H.jsx)("div",{className:"loading-container",children:(0,H.jsx)("img",{src:"https://admin.heylua.ai/images/logo.svg",alt:"Loading",className:"loading-logo"})}):(0,H.jsx)("div",{className:"json-editor",children:E?(0,H.jsxs)("div",{className:"json-editor-container",children:[(0,H.jsx)("div",{ref:U,className:"json-highlight-background",dangerouslySetInnerHTML:{__html:Jm(S)}}),(0,H.jsx)("textarea",{ref:C,id:"user-data-json",name:"userDataJson",value:S,onChange:X=>At(X.target.value),className:"json-textarea",spellCheck:!1,placeholder:"Enter JSON data...",autoComplete:"off"})]}):(0,H.jsx)("div",{className:"json-display",onClick:se,dangerouslySetInnerHTML:{__html:Jm(S)}})})}):(i==null?void 0:i.id)==="resources"?(0,H.jsx)("div",{className:"data-detail",children:o?(0,H.jsx)("div",{className:"loading-container",children:(0,H.jsx)("img",{src:"https://admin.heylua.ai/images/logo.svg",alt:"Loading",className:"loading-logo"})}):(0,H.jsx)("div",{className:"resources-container",children:l&&l.length>0?(0,H.jsx)("div",{className:"resources-list",children:l.map(X=>(0,H.jsx)(r_,{resource:X,apiKey:e,agentId:t,onUpdate:()=>Me(i)},X.id))}):(0,H.jsxs)("div",{className:"no-resources",children:[(0,H.jsx)("div",{className:"empty-icon",children:"\u{1F4C1}"}),(0,H.jsx)("h4",{children:"No resources yet"}),(0,H.jsx)("p",{children:"Resources help provide context and information to your AI agent"})]})})}):(0,H.jsx)("div",{className:"data-detail",children:(0,H.jsxs)("div",{className:"coming-soon",children:[(0,H.jsx)("div",{className:"coming-soon-icon",children:i==null?void 0:i.icon}),(0,H.jsxs)("div",{className:"coming-soon-text",children:[i==null?void 0:i.name," management"]}),(0,H.jsx)("div",{className:"coming-soon-subtext",children:"This feature is coming soon"})]})})}),k&&(0,H.jsx)("div",{className:"error-message",children:k}),h&&(0,H.jsx)("div",{className:"success-message",children:h}),P&&(0,H.jsx)("div",{className:"modal-overlay",children:(0,H.jsxs)("div",{className:"modal-content",children:[(0,H.jsxs)("div",{className:"modal-header",children:[(0,H.jsx)("h4",{children:"Create New Resource"}),(0,H.jsx)("button",{className:"modal-close-btn",onClick:()=>_(!1),disabled:J,children:"\u2715"})]}),(0,H.jsxs)("div",{className:"modal-body",children:[(0,H.jsxs)("div",{className:"form-group",children:[(0,H.jsx)("label",{htmlFor:"resource-name",children:"Resource Name"}),(0,H.jsx)("input",{id:"resource-name",type:"text",value:R,onChange:X=>O(X.target.value),placeholder:"Enter resource name...",disabled:J})]}),(0,H.jsxs)("div",{className:"form-group",children:[(0,H.jsx)("label",{htmlFor:"resource-content",children:"Resource Content"}),(0,H.jsx)("textarea",{id:"resource-content",value:I,onChange:X=>B(X.target.value),placeholder:"Enter resource content...",rows:10,disabled:J})]})]}),(0,H.jsxs)("div",{className:"modal-footer",children:[(0,H.jsx)("button",{className:"cancel-button",onClick:()=>_(!1),disabled:J,children:"Cancel"}),(0,H.jsx)("button",{className:"create-button",onClick:Ke,disabled:J||!R.trim()||!I.trim(),children:J?"Creating...":"Create Resource"})]})]})})]})},r_=({resource:e,apiKey:t,agentId:n,onUpdate:a})=>{let[i,r]=(0,ze.useState)(!1),[l,s]=(0,ze.useState)(e.name),[o,u]=(0,ze.useState)(e.content),[c,p]=(0,ze.useState)(!1),[d,f]=(0,ze.useState)(!1),S=()=>{s(e.name),u(e.content),r(!0)},x=()=>z(null,null,function*(){if(!(!l.trim()||!o.trim())){p(!0);try{let h=yield ie.updateResource(t,n,e.id,{name:l.trim(),content:o.trim()});h.success?(r(!1),a()):alert("Failed to update resource: "+(h.error||"Unknown error"))}catch(h){console.error("Error updating resource:",h),alert("Failed to update resource")}finally{p(!1)}}}),k=()=>z(null,null,function*(){if(confirm(`Are you sure you want to delete "${e.name}"?`)){f(!0);try{let h=yield ie.deleteResource(t,n,e.id);h.success?a():alert("Failed to delete resource: "+(h.error||"Unknown error"))}catch(h){console.error("Error deleting resource:",h),alert("Failed to delete resource")}finally{f(!1)}}}),m=()=>{r(!1),s(e.name),u(e.content)};return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("div",{className:"resource-item",children:(0,H.jsxs)("div",{className:"resource-display",children:[(0,H.jsxs)("div",{className:"resource-header",children:[(0,H.jsx)("h4",{className:"resource-name",children:e.name}),(0,H.jsx)("div",{className:"resource-meta",children:(0,H.jsxs)("span",{className:"resource-date",children:["Updated ",new Date(e.updatedAt).toLocaleDateString()]})})]}),(0,H.jsx)("div",{className:"resource-content",children:(0,H.jsxs)("p",{children:[e.content.substring(0,200),e.content.length>200?"...":""]})}),(0,H.jsxs)("div",{className:"resource-actions",children:[(0,H.jsx)("button",{className:"edit-btn",onClick:S,disabled:d,title:"Edit resource",children:"\u270F\uFE0F"}),(0,H.jsx)("button",{className:"delete-btn",onClick:k,disabled:d,title:"Delete resource",children:d?"\u27F3":"\u{1F5D1}\uFE0F"})]})]})}),i&&(0,H.jsx)("div",{className:"modal-overlay",children:(0,H.jsxs)("div",{className:"modal-content",children:[(0,H.jsxs)("div",{className:"modal-header",children:[(0,H.jsx)("h4",{children:"Edit Resource"}),(0,H.jsx)("button",{className:"modal-close-btn",onClick:m,disabled:c,children:"\u2715"})]}),(0,H.jsxs)("div",{className:"modal-body",children:[(0,H.jsxs)("div",{className:"form-group",children:[(0,H.jsx)("label",{htmlFor:"edit-resource-name",children:"Resource Name"}),(0,H.jsx)("input",{id:"edit-resource-name",type:"text",value:l,onChange:h=>s(h.target.value),placeholder:"Enter resource name...",disabled:c})]}),(0,H.jsxs)("div",{className:"form-group",children:[(0,H.jsx)("label",{htmlFor:"edit-resource-content",children:"Resource Content"}),(0,H.jsx)("textarea",{id:"edit-resource-content",value:o,onChange:h=>u(h.target.value),placeholder:"Enter resource content...",rows:10,disabled:c})]})]}),(0,H.jsxs)("div",{className:"modal-footer",children:[(0,H.jsx)("button",{className:"cancel-button",onClick:m,disabled:c,children:"Cancel"}),(0,H.jsx)("button",{className:"create-button",onClick:x,disabled:c||!l.trim()||!o.trim(),children:c?"Saving...":"Save Changes"})]})]})})]})}});var Ft,Km,iE=b(()=>{"use strict";Ft=F(re()),Km=({personaVersions:e,onSelectVersion:t,onDeployVersion:n,deployingVersionId:a})=>(0,Ft.jsxs)("div",{className:"persona-panel",children:[(0,Ft.jsx)("div",{className:"panel-header",children:(0,Ft.jsx)("h3",{children:"Persona Management"})}),(0,Ft.jsx)("div",{className:"panel-content",children:(0,Ft.jsxs)("div",{className:"versions-list",children:[e.map(i=>(0,Ft.jsxs)("div",{className:`version-item ${i.isDeployed?"deployed":""} clickable`,onClick:()=>t(i),children:[(0,Ft.jsxs)("div",{className:"version-info",children:[(0,Ft.jsx)("div",{className:"version-number",children:i.version}),(0,Ft.jsx)("div",{className:"version-date",children:i.deployedAt||"No date"}),i.isDeployed&&(0,Ft.jsx)("div",{className:"deployed-badge",children:"Deployed"})]}),!i.isDeployed&&i.status==="available"&&(0,Ft.jsx)("button",{className:`deploy-button ${a===i.id?"loading":""}`,onClick:r=>{r.stopPropagation(),n(i.id)},disabled:a===i.id,children:a===i.id?(0,Ft.jsx)("img",{src:"https://admin.heylua.ai/images/logo.svg",alt:"Loading",className:"loading-logo-button"}):"Deploy"})]},i.id)),e.length===0&&(0,Ft.jsx)("div",{className:"no-versions",children:"No persona versions found"})]})})]})});var at,Wm,rE=b(()=>{"use strict";at=F(re()),Wm=({skills:e,onSelectSkill:t,onActivateSkill:n,activatingSkillId:a})=>(0,at.jsxs)("div",{className:"skills-panel",children:[(0,at.jsx)("div",{className:"panel-header",children:(0,at.jsx)("h3",{children:"Skills Management"})}),(0,at.jsx)("div",{className:"panel-content",children:(0,at.jsx)("div",{className:"skills-list",children:e.map(i=>(0,at.jsxs)("div",{className:`skill-item ${i.active?"active":"inactive"}`,children:[(0,at.jsxs)("div",{className:"skill-main-content",onClick:()=>t(i.name),children:[(0,at.jsxs)("div",{className:"skill-info",children:[(0,at.jsxs)("div",{className:"skill-header",children:[(0,at.jsx)("div",{className:"skill-name",children:i.name}),(0,at.jsx)("div",{className:`skill-status ${i.active?"active":"inactive"}`,children:i.active?"Active":"Inactive"})]}),(0,at.jsx)("div",{className:"skill-description",children:i.description}),(0,at.jsxs)("div",{className:"skill-stats",children:[(0,at.jsxs)("span",{className:"skill-stat",children:[i.versionsCount," versions"]}),(0,at.jsxs)("span",{className:"skill-stat",children:["Latest: ",i.latestVersion]}),i.deployedVersion&&(0,at.jsxs)("span",{className:"skill-stat deployed",children:["Deployed: ",i.deployedVersion]})]})]}),(0,at.jsx)("div",{className:"skill-arrow",children:"\u2192"})]}),(0,at.jsx)("div",{className:"skill-actions",children:(0,at.jsx)("button",{className:`activate-button ${i.active?"deactivate":"activate"} ${a===i.id?"loading":""}`,onClick:r=>{r.stopPropagation(),n(i.id,i.active)},disabled:a===i.id,children:a===i.id?(0,at.jsx)("img",{src:"https://admin.heylua.ai/images/logo.svg",alt:"Loading",className:"loading-logo-button"}):i.active?"Deactivate":"Activate"})})]},i.id))})})]})});var Zt,eh,lE=b(()=>{"use strict";Zt=F(re()),eh=({selectedPersonaVersion:e,onBack:t,onDeployVersion:n,deployingVersionId:a})=>(0,Zt.jsxs)("div",{className:"persona-detail",children:[(0,Zt.jsxs)("div",{className:"persona-detail-header",children:[(0,Zt.jsx)("button",{className:"back-button",onClick:t,children:"\u2190"}),(0,Zt.jsxs)("h4",{children:["Persona ",e.version]})]}),(0,Zt.jsxs)("div",{className:"persona-section",children:[(0,Zt.jsxs)("div",{className:"persona-header",children:[(0,Zt.jsx)("h3",{children:"Agent Persona"}),(0,Zt.jsx)("div",{className:"persona-actions",children:e.isDeployed?(0,Zt.jsx)("span",{className:"deployed-badge",children:"Deployed"}):e.status==="available"?(0,Zt.jsx)("button",{className:`deploy-button ${a===e.id?"loading":""}`,onClick:()=>n(e.id),disabled:a===e.id,children:a===e.id?(0,Zt.jsx)("img",{src:"https://admin.heylua.ai/images/logo.svg",alt:"Loading",className:"loading-logo-button"}):"Deploy"}):null})]}),(0,Zt.jsx)("div",{className:"persona-content",children:(0,Zt.jsx)("div",{className:"persona-display",children:e.personaContent})})]})]})});var Ee,th,sE=b(()=>{"use strict";Ee=F(re()),th=({selectedSkillVersion:e,onBack:t,onDeployVersion:n,deployingVersionId:a})=>(0,Ee.jsxs)("div",{className:"skill-detail",children:[(0,Ee.jsx)("div",{className:"skill-detail-header",children:(0,Ee.jsxs)("div",{className:"header-left",children:[(0,Ee.jsx)("button",{className:"back-button",onClick:t,children:"\u2190"}),(0,Ee.jsxs)("h4",{children:[e.skillName," ",e.version]})]})}),(0,Ee.jsx)("div",{className:"skill-details",children:(0,Ee.jsxs)("div",{className:"skill-info-section",children:[(0,Ee.jsxs)("div",{className:"skill-meta",children:[(0,Ee.jsxs)("span",{className:"skill-version",children:["v",e.version]}),e.isDeployed&&(0,Ee.jsx)("span",{className:"deployed-badge",children:"Deployed"})]}),e.skillDescription&&(0,Ee.jsxs)("div",{className:"skill-description-section",children:[(0,Ee.jsx)("h5",{children:"Description"}),(0,Ee.jsx)("p",{children:e.skillDescription})]}),e.skillContext&&(0,Ee.jsxs)("div",{className:"skill-context-section",children:[(0,Ee.jsx)("h5",{children:"Context"}),(0,Ee.jsx)("p",{children:e.skillContext})]}),!e.isDeployed&&e.status==="available"&&(0,Ee.jsx)("div",{className:"skill-actions",children:(0,Ee.jsx)("button",{className:`deploy-button ${a===e.id?"loading":""}`,onClick:()=>n(e.id),disabled:a===e.id,children:a===e.id?(0,Ee.jsx)("img",{src:"https://admin.heylua.ai/images/logo.svg",alt:"Loading",className:"loading-logo-button"}):"Deploy This Version"})})]})}),(0,Ee.jsxs)("div",{className:"tools-section",children:[(0,Ee.jsx)("div",{className:"tools-header",children:(0,Ee.jsx)("h5",{children:"Available Tools"})}),(0,Ee.jsx)("div",{className:"tools-list",children:e.tools&&e.tools.length>0?e.tools.map((i,r)=>(0,Ee.jsxs)("div",{className:"tool-item",children:[(0,Ee.jsx)("div",{className:"tool-name",children:i.name}),(0,Ee.jsx)("div",{className:"tool-description",children:i.description})]},r)):(0,Ee.jsxs)("div",{className:"no-tools",children:[(0,Ee.jsx)("div",{className:"no-tools-icon",children:"\u{1F527}"}),(0,Ee.jsx)("div",{className:"no-tools-text",children:"No tools available"}),(0,Ee.jsx)("div",{className:"no-tools-subtext",children:"This version doesn't have any tools configured"})]})})]})]})});var Jt,nh,oE=b(()=>{"use strict";Jt=F(re()),nh=({selectedSkill:e,versions:t,onBack:n,onSelectVersion:a,onDeployVersion:i,formatDate:r,deployingVersionId:l})=>(0,Jt.jsxs)("div",{className:"skill-versions",children:[(0,Jt.jsx)("div",{className:"skill-versions-header",children:(0,Jt.jsxs)("div",{className:"header-left",children:[(0,Jt.jsx)("button",{className:"back-button",onClick:n,children:"\u2190"}),(0,Jt.jsx)("h4",{children:e})]})}),(0,Jt.jsx)("div",{className:"versions-list",children:t.filter(s=>s.type==="skill"&&s.skillName===e).map(s=>(0,Jt.jsxs)("div",{className:`version-item ${s.isDeployed?"deployed":""} clickable`,onClick:()=>a(s),children:[(0,Jt.jsxs)("div",{className:"version-info",children:[(0,Jt.jsx)("div",{className:"version-number",children:s.version}),(0,Jt.jsx)("div",{className:"version-date",children:r(s.deployedAt)}),s.isDeployed&&(0,Jt.jsx)("div",{className:"deployed-badge",children:"Deployed"})]}),!s.isDeployed&&s.status==="available"&&(0,Jt.jsx)("button",{className:`deploy-button ${l===s.id?"loading":""}`,onClick:o=>{o.stopPropagation(),i(s.id)},disabled:l===s.id,children:l===s.id?(0,Jt.jsx)("img",{src:"https://admin.heylua.ai/images/logo.svg",alt:"Loading",className:"loading-logo-button"}):"Deploy"})]},s.id))})]})});var jt,ee,ah,l_,uE=b(()=>{"use strict";jt=F(Je());an();ee=F(re()),ah=({apiKey:e,agentId:t})=>{let[n,a]=(0,jt.useState)([]),[i,r]=(0,jt.useState)(!0),[l,s]=(0,jt.useState)(!1),[o,u]=(0,jt.useState)(null),[c,p]=(0,jt.useState)(null),[d,f]=(0,jt.useState)(null),[S,x]=(0,jt.useState)(""),[k,m]=(0,jt.useState)(""),[h,g]=(0,jt.useState)(!1);(0,jt.useEffect)(()=>{E()},[e,t]),(0,jt.useEffect)(()=>{if(o||c){let _=setTimeout(()=>{u(null),p(null)},5e3);return()=>clearTimeout(_)}},[o,c]);let E=()=>z(null,null,function*(){r(!0);try{let _=yield ie.loadProductionEnv(e,t);if(_.success&&_.data){let R=Object.entries(_.data.data||{}).map(([O,I],B)=>({id:`${B}-${O}`,key:O,value:I}));a(R)}else console.error("Failed to load production env:",_.error),a([])}catch(_){console.error("Error loading production env:",_),a([])}finally{r(!1)}}),T=_=>z(null,null,function*(){s(!0),u(null),p(null);try{let R={};_.forEach(I=>{I.key.trim()&&(R[I.key.trim()]=I.value)});let O=yield ie.updateProductionEnv(e,t,R);O.success?(p("Environment variables saved successfully!"),yield E()):u(O.error||"Failed to save environment variables")}catch(R){console.error("Error saving production env:",R),u("Failed to save environment variables")}finally{s(!1)}}),N=()=>z(null,null,function*(){if(!S.trim()){u("Variable name is required");return}let _={id:Date.now().toString(),key:S.trim(),value:k},R=[...n,_];a(R),yield T(R),x(""),m(""),g(!1)}),A=(_,R,O)=>z(null,null,function*(){let I=n.map(B=>B.id===_?ut(K({},B),{key:R.trim(),value:O}):B);a(I),f(null),yield T(I)}),C=_=>z(null,null,function*(){let R=n.filter(O=>O.id!==_);a(R),yield T(R)}),U=_=>{f(_)},P=()=>{f(null)};return i?(0,ee.jsx)("div",{className:"env-panel",children:(0,ee.jsx)("div",{className:"env-loading",children:(0,ee.jsx)("img",{src:"https://admin.heylua.ai/images/logo.svg",alt:"Loading",className:"loading-logo"})})}):(0,ee.jsxs)("div",{className:"env-panel",children:[(0,ee.jsxs)("div",{className:"env-header",children:[(0,ee.jsx)("h3",{children:"Environment Variables"}),(0,ee.jsxs)("div",{className:"env-actions",children:[(0,ee.jsx)("button",{className:"refresh-btn",onClick:E,disabled:i,title:"Refresh environment variables",children:i?(0,ee.jsx)("img",{src:"https://admin.heylua.ai/images/logo.svg",alt:"Loading",className:"loading-logo-button"}):"\u21BB"}),(0,ee.jsx)("button",{className:"add-btn",onClick:()=>g(!0),disabled:h,title:"Add new environment variable",children:"\u2795"})]})]}),(0,ee.jsxs)("div",{className:"env-content",children:[o&&(0,ee.jsxs)("div",{className:"error-message",children:[(0,ee.jsx)("strong",{children:"Error:"})," ",o]}),c&&(0,ee.jsxs)("div",{className:"success-message",children:[(0,ee.jsx)("strong",{children:"Success:"})," ",c]}),h&&(0,ee.jsxs)("div",{className:"env-add-form",children:[(0,ee.jsxs)("div",{className:"env-form-header",children:[(0,ee.jsx)("h4",{children:"Add New Variable"}),(0,ee.jsx)("button",{className:"form-cancel-btn",onClick:()=>{g(!1),x(""),m("")},title:"Cancel",children:"\u2715"})]}),(0,ee.jsxs)("div",{className:"env-form-fields",children:[(0,ee.jsxs)("div",{className:"env-field",children:[(0,ee.jsx)("label",{children:"Variable Name"}),(0,ee.jsx)("input",{type:"text",value:S,onChange:_=>x(_.target.value),placeholder:"API_KEY",className:"env-input",autoFocus:!0,autoComplete:"off"})]}),(0,ee.jsxs)("div",{className:"env-field",children:[(0,ee.jsx)("label",{children:"Value"}),(0,ee.jsx)("input",{type:"text",value:k,onChange:_=>m(_.target.value),placeholder:"your_api_key_here",className:"env-input",autoComplete:"off"})]}),(0,ee.jsx)("div",{className:"env-form-actions",children:(0,ee.jsx)("button",{className:"add-variable-btn",onClick:N,disabled:!S.trim()||l,children:l?"Adding...":"Add Variable"})})]})]}),(0,ee.jsx)("div",{className:"env-variables",children:n.length>0?(0,ee.jsx)("div",{className:"env-list",children:n.map(_=>(0,ee.jsx)(l_,{variable:_,isEditing:d===_.id,onEdit:()=>U(_.id),onSave:(R,O)=>A(_.id,R,O),onCancel:P,onDelete:()=>C(_.id),isSaving:l},_.id))}):(0,ee.jsxs)("div",{className:"env-empty-state",children:[(0,ee.jsx)("div",{className:"empty-icon",children:"\u{1F527}"}),(0,ee.jsx)("h4",{children:"No environment variables"}),(0,ee.jsx)("p",{children:"Add your first environment variable to get started"}),(0,ee.jsx)("button",{className:"add-first-btn",onClick:()=>g(!0),children:"Add Variable"})]})}),(0,ee.jsxs)("div",{className:"env-help",children:[(0,ee.jsx)("p",{children:"Environment variables are used by your production skills and are securely stored."}),(0,ee.jsxs)("p",{children:[(0,ee.jsx)("strong",{children:"Auto-save:"})," Changes are saved automatically when you add, edit, or delete variables."]})]})]})]})},l_=({variable:e,isEditing:t,onEdit:n,onSave:a,onCancel:i,onDelete:r,isSaving:l})=>{let[s,o]=(0,jt.useState)(e.key),[u,c]=(0,jt.useState)(e.value),p=()=>{s.trim()&&a(s,u)},d=()=>{o(e.key),c(e.value),i()},f=h=>{h.key==="Enter"&&!h.shiftKey?(h.preventDefault(),p()):h.key==="Escape"&&d()},[S,x]=(0,jt.useState)(!1),k=e.value.length>60,m=S||!k?e.value:e.value.substring(0,60)+"...";return(0,ee.jsx)("div",{className:"env-variable-item",children:t?(0,ee.jsxs)("div",{className:"env-variable-edit",children:[(0,ee.jsxs)("div",{className:"env-edit-fields",children:[(0,ee.jsx)("input",{type:"text",value:s,onChange:h=>o(h.target.value),onKeyPress:f,className:"env-key-input",placeholder:"Variable name",disabled:l,autoComplete:"off"}),(0,ee.jsx)("span",{className:"env-equals",children:"="}),(0,ee.jsx)("textarea",{value:u,onChange:h=>c(h.target.value),className:"env-value-input",placeholder:"Value",rows:1,disabled:l,autoComplete:"off"})]}),(0,ee.jsxs)("div",{className:"env-edit-actions",children:[(0,ee.jsx)("button",{className:"save-edit-btn",onClick:p,disabled:!s.trim()||l,title:"Save changes",children:"\u2713"}),(0,ee.jsx)("button",{className:"cancel-edit-btn",onClick:d,disabled:l,title:"Cancel editing",children:"\u2715"})]})]}):(0,ee.jsxs)("div",{className:"env-variable-display",children:[(0,ee.jsxs)("div",{className:"env-variable-content",children:[(0,ee.jsx)("span",{className:"env-key",children:e.key}),(0,ee.jsx)("span",{className:"env-equals",children:"="}),(0,ee.jsxs)("div",{className:"env-value-container",children:[(0,ee.jsx)("span",{className:"env-value",onClick:()=>k&&x(!S),style:{cursor:k?"pointer":"default"},title:k?"Click to expand/collapse":e.value,children:m||"<empty>"}),k&&(0,ee.jsx)("button",{className:"expand-btn",onClick:()=>x(!S),title:S?"Collapse":"Expand",children:S?"\u25B2":"\u25BC"})]})]}),(0,ee.jsxs)("div",{className:"env-variable-actions",children:[(0,ee.jsx)("button",{className:"edit-variable-btn",onClick:n,disabled:l,title:"Edit variable",children:"\u270F\uFE0F"}),(0,ee.jsx)("button",{className:"delete-variable-btn",onClick:r,disabled:l,title:"Delete variable",children:"\u{1F5D1}\uFE0F"})]})]})})}});var cE=b(()=>{"use strict";JN();KN();tE();nE();aE();Fm();iE();rE();lE();sE();oE();uE()});var zt,De,fE,dE=b(()=>{"use strict";zt=F(Je());cE();an();De=F(re()),fE=({apiKey:e,agentId:t,skillId:n,isActive:a=!1,sharedChatMessages:i,onSharedSendMessage:r,onSharedClearHistory:l,isChatLoading:s,setIsChatLoading:o})=>{let[u,c]=(0,zt.useState)("persona"),[p,d]=(0,zt.useState)([]),[f,S]=(0,zt.useState)([]),[x,k]=(0,zt.useState)([]),[m,h]=(0,zt.useState)(null),[g,E]=(0,zt.useState)(null),[T,N]=(0,zt.useState)(500),[A,C]=(0,zt.useState)(!1),[U,P]=(0,zt.useState)(null),[_,R]=(0,zt.useState)(null),[O,I]=(0,zt.useState)(null),B=se=>z(null,null,function*(){if(!se.trim())return;let X={id:Date.now().toString(),text:se,sender:"user",timestamp:new Date};r(X),o(!0);try{let Q=yield ie.sendProductionChatMessage(se,t,e),ne={id:(Date.now()+1).toString(),text:Q.success?Q.text||"No response received":`\u274C ${Q.error||"Failed to send message"}`,sender:"assistant",timestamp:new Date};r(ne)}catch(Q){let ne={id:(Date.now()+1).toString(),text:`\u274C Error: ${Q instanceof Error?Q.message:"Unknown error"}`,sender:"assistant",timestamp:new Date};r(ne)}finally{o(!1)}}),J=(se,X)=>z(null,null,function*(){E(se);try{let Q=!X;console.log(`${Q?"Activating":"Deactivating"} skill:`,se);let ne=yield ie.activateSkill(e,t,se,Q);ne.success?(k(Y=>Y.map(oe=>oe.id===se?ut(K({},oe),{active:Q}):oe)),yield pt(),console.log(`\u2705 Skill ${Q?"activated":"deactivated"} successfully`)):(console.error(`\u274C Failed to ${Q?"activate":"deactivate"} skill:`,ne.error),alert(`Failed to ${Q?"activate":"deactivate"} skill: ${ne.error}`))}catch(Q){console.error("Error activating skill:",Q),alert("Failed to change skill activation status")}finally{E(null)}}),ae=se=>z(null,null,function*(){h(se);try{let X=f.find(ne=>ne.id===se);if(X){console.log("Deploying persona version:",X),yield At(X);return}let Q=p.find(ne=>ne.id===se);if(Q){console.log("Publishing skill version:",Q.version,"for skill:",Q.skillName);let ne=x.find(Ue=>Ue.name===Q.skillName);if(!ne)throw new Error("Could not find skill for deployment");let Y=Q.version.replace("v",""),oe=yield ie.publishSkillVersion(e,t,ne.id,Y);if(oe.success&&oe.data)d(Ue=>Ue.map(mt=>mt.id===se?ut(K({},mt),{isDeployed:!0}):mt.type===Q.type&&mt.skillName===Q.skillName?ut(K({},mt),{isDeployed:!1}):mt)),k(Ue=>Ue.map(mt=>mt.name===Q.skillName?ut(K({},mt),{deployedVersion:Q.version}):mt)),yield pt(),console.log(`\u2705 ${oe.data.message}`),alert(`\u2705 ${oe.data.message}`);else throw new Error(oe.error||"Failed to publish skill version")}}finally{h(null)}}),we=se=>{C(!0),se.preventDefault()},je=se=>{if(!A)return;let X=document.querySelector(".production-layout-new");if(!X)return;let Q=X.getBoundingClientRect(),ne=Q.right-se.clientX,Y=500,oe=Q.width*.6;ne>=Y&&ne<=oe&&N(ne)},v=()=>{C(!1)};zt.default.useEffect(()=>(A?(document.addEventListener("mousemove",je),document.addEventListener("mouseup",v),document.body.style.cursor="col-resize",document.body.style.userSelect="none"):(document.removeEventListener("mousemove",je),document.removeEventListener("mouseup",v),document.body.style.cursor="",document.body.style.userSelect=""),()=>{document.removeEventListener("mousemove",je),document.removeEventListener("mouseup",v),document.body.style.cursor="",document.body.style.userSelect=""}),[A]);let Me=se=>new Date(se).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});(0,zt.useEffect)(()=>{y()},[e,t]),(0,zt.useEffect)(()=>{a&&y()},[a]);let pt=()=>z(null,null,function*(){try{console.log("Loading skills data with apiKey:",e,"agentId:",t);let se=yield ie.getSkills(e,t);if(se.success&&se.skills){let X=se.skills.map(ne=>{let Y=ne.versions.length>0?ne.versions.reduce((Ue,mt)=>Ue.version>mt.version?Ue:mt):null,oe=ne.versions.find(Ue=>Ue.active);return{id:ne.id,name:ne.name,description:ne.description,versionsCount:ne.versions.length,latestVersion:Y?`v${Y.version}`:"No versions",deployedVersion:oe?`v${oe.version}`:void 0,active:ne.active}});k(X);let Q=[];se.skills.forEach(ne=>{ne.versions.forEach(Y=>{Q.push({id:Y.id,version:`v${Y.version}`,type:"skill",skillName:ne.name,skillDescription:Y.description,skillContext:Y.context,deployedAt:ne.updatedAt,isDeployed:Y.active,status:Y.active?"deployed":"available",tools:Y.tools})})}),d(Q)}else console.error("Failed to load skills:",se.error),k([]),d([])}catch(se){console.error("Error loading skills data:",se),k([]),d([])}}),y=()=>z(null,null,function*(){try{console.log("Loading persona versions with apiKey:",e,"agentId:",t),yield Ke(),yield pt()}catch(se){console.error("Error loading production data:",se)}}),Ke=()=>z(null,null,function*(){try{let se=yield ie.getProductionPersonaVersions(t,e);if(se.success&&se.versions){let Q=se.versions.map(ne=>({id:`persona_${ne.version}`,version:`v${ne.version}`,type:"persona",deployedAt:new Date(ne.createdDate).toISOString(),isDeployed:ne.isCurrent,status:ne.isCurrent?"deployed":"available",personaContent:ne.persona})).sort((ne,Y)=>new Date(Y.deployedAt).getTime()-new Date(ne.deployedAt).getTime());S(Q)}else console.error("Failed to load persona versions:",se.error)}catch(se){console.error("Error loading persona versions:",se)}}),At=se=>z(null,null,function*(){try{let X=parseInt(se.version.replace("v",""));console.log(`Deploying persona version ${X} to production...`);let Q=yield ie.deployPersonaVersion(t,e,X);console.log("Deploy persona response:",Q),Q.success?(yield Ke(),alert(`\u2705 Persona version ${se.version} deployed successfully!`)):alert(`\u274C Failed to deploy persona version: ${Q.error||"Unknown error"}`)}catch(X){console.error("Error deploying persona version:",X),alert("\u274C Failed to deploy persona version")}});return(0,De.jsx)("div",{className:"production-page",children:(0,De.jsxs)("div",{className:"production-layout-new",children:[(0,De.jsx)("div",{className:"production-left",style:{width:`calc(100% - ${T}px)`},children:(0,De.jsx)(Qm,{messages:i,onSendMessage:B,onClearHistory:l,isLoading:s})}),(0,De.jsx)("div",{className:"production-resize-handle",onMouseDown:we}),(0,De.jsxs)("div",{className:"production-right",children:[(0,De.jsxs)("div",{className:"right-panel-tabs",children:[(0,De.jsx)("button",{className:`tab-button ${u==="persona"?"active":""}`,onClick:()=>{c("persona"),R(null),P(null),I(null)},children:"Persona"}),(0,De.jsx)("button",{className:`tab-button ${u==="skills"?"active":""}`,onClick:()=>{c("skills"),R(null),P(null),I(null),I(null)},children:"Skills"}),(0,De.jsx)("button",{className:`tab-button ${u==="stats"?"active":""}`,onClick:()=>{c("stats"),R(null),P(null),I(null)},children:"Stats"}),(0,De.jsx)("button",{className:`tab-button ${u==="logs"?"active":""}`,onClick:()=>{c("logs"),R(null),P(null),I(null)},children:"Logs"}),(0,De.jsx)("button",{className:`tab-button ${u==="data"?"active":""}`,onClick:()=>{c("data"),R(null),P(null),I(null)},children:"Data"}),(0,De.jsx)("button",{className:`tab-button ${u==="env"?"active":""}`,onClick:()=>{c("env"),R(null),P(null),I(null)},children:"Env"})]}),(0,De.jsxs)("div",{className:"right-panel-content",children:[u==="persona"&&(_?(0,De.jsx)(eh,{selectedPersonaVersion:_,onBack:()=>R(null),onDeployVersion:ae,deployingVersionId:m}):(0,De.jsx)(Km,{personaVersions:f,onSelectVersion:R,onDeployVersion:ae,deployingVersionId:m})),u==="skills"&&(O?(0,De.jsx)(th,{selectedSkillVersion:O,onBack:()=>I(null),onDeployVersion:ae,deployingVersionId:m}):U?(0,De.jsx)(nh,{selectedSkill:U,versions:p,onBack:()=>P(null),onSelectVersion:I,onDeployVersion:ae,formatDate:Me,deployingVersionId:m}):(0,De.jsx)(Wm,{skills:x,onSelectSkill:P,onActivateSkill:J,activatingSkillId:g})),u==="stats"&&(0,De.jsx)("div",{className:"coming-soon-panel",children:(0,De.jsxs)("div",{className:"coming-soon",children:[(0,De.jsx)("div",{className:"coming-soon-icon",children:"\u{1F4CA}"}),(0,De.jsx)("div",{className:"coming-soon-text",children:"Statistics & Analytics"}),(0,De.jsx)("div",{className:"coming-soon-subtext",children:"Performance metrics and analytics dashboard coming soon"})]})}),u==="logs"&&(0,De.jsx)(Zm,{apiKey:e,agentId:t}),u==="data"&&(0,De.jsx)($m,{apiKey:e,agentId:t}),u==="env"&&(0,De.jsx)(ah,{apiKey:e,agentId:t})]})]})]})})}});var Vi,sn,pE,mE=b(()=>{"use strict";Vi=F(Je()),sn=F(re()),pE=({apiKey:e,agentId:t})=>{let[n,a]=(0,Vi.useState)(""),[i,r]=(0,Vi.useState)(!0),[l,s]=(0,Vi.useState)(""),[o,u]=(0,Vi.useState)("");(0,Vi.useEffect)(()=>{c()},[]);let c=()=>z(null,null,function*(){var p;try{r(!0);let d=yield fetch("/api/config");if(d.ok){let f=yield d.json(),S=(p=f==null?void 0:f.agent)==null?void 0:p.orgId;if(S){a(S);let x=`https://admin.heylua.ai/validate-token/${e}?redirect=/admin/usage?&agentId=${t}&orgId=${S}&hideToolBar=true`;u(x)}else s("No orgId found in configuration")}else s("Failed to load configuration")}catch(d){console.error("Failed to load orgId:",d),s("Failed to load configuration")}finally{r(!1)}});return i?(0,sn.jsx)("div",{className:"admin-page",children:(0,sn.jsx)("div",{className:"loading-container",children:(0,sn.jsx)("img",{src:"https://admin.heylua.ai/images/logo.svg",alt:"Loading",className:"loading-logo"})})}):l?(0,sn.jsx)("div",{className:"admin-page",children:(0,sn.jsxs)("div",{className:"error-container",children:[(0,sn.jsx)("h3",{children:"Error Loading Admin Dashboard"}),(0,sn.jsx)("p",{children:l}),(0,sn.jsx)("button",{onClick:c,className:"retry-button",children:"Retry"})]})}):(0,sn.jsx)("div",{className:"admin-page",children:o?(0,sn.jsx)("iframe",{src:o,className:"admin-iframe",title:"Lua Admin Dashboard",sandbox:"allow-same-origin allow-scripts allow-forms allow-popups allow-top-navigation"}):(0,sn.jsx)("div",{className:"loading-container",children:(0,sn.jsx)("img",{src:"https://admin.heylua.ai/images/logo.svg",alt:"Loading",className:"loading-logo"})})})}});var hE=b(()=>{});var Qr,it,gE,vE=b(()=>{"use strict";Qr=F(Je());FN();dE();mE();an();hE();it=F(re()),gE=({apiKey:e,agentId:t,skillId:n,sandboxId:a})=>{let[i,r]=(0,Qr.useState)("sandbox"),[l,s]=(0,Qr.useState)([]),[o,u]=(0,Qr.useState)(!1);(0,Qr.useEffect)(()=>{c()},[e,t]);let c=()=>z(null,null,function*(){try{console.log("Loading shared chat history with API key:",e,"agentId:",t);let S=yield ie.loadChatHistory(e,t);if(S.success&&S.data&&S.data.length>0){let x=S.data.map(k=>{var m;return{id:k.id||Date.now().toString(),text:((m=k.content[0])==null?void 0:m.text)||"",sender:k.role==="user"?"user":"assistant",timestamp:new Date(k.createdAt)}});s(x)}else s([])}catch(S){console.error("Failed to load shared chat history:",S),s([])}}),p=()=>z(null,null,function*(){try{let S=yield ie.clearChatHistory(e,t);S.success?s([]):alert("Failed to clear chat history: "+(S.error||"Unknown error"))}catch(S){console.error("Failed to clear shared chat history:",S),alert("Failed to clear chat history")}}),d=S=>{s(x=>[...x,S])};return(0,it.jsxs)("div",{className:"main-container",children:[(0,it.jsx)("div",{className:"page-navigation",children:(0,it.jsxs)("div",{className:"nav-logo",children:[(0,it.jsx)("img",{src:"https://admin.heylua.ai/images/logo.svg",alt:"Lua",className:"logo-icon"}),(0,it.jsxs)("span",{className:"logo-text",children:[(0,it.jsx)("strong",{children:"Lua"})," : Developer Console"]})]})}),(0,it.jsxs)("div",{className:"page-tabs",children:[(0,it.jsx)("button",{className:`page-tab ${i==="sandbox"?"active":""}`,onClick:()=>r("sandbox"),children:"Sandbox"}),(0,it.jsx)("button",{className:`page-tab ${i==="production"?"active":""}`,onClick:()=>r("production"),children:"Production"}),(0,it.jsx)("button",{className:`page-tab ${i==="admin"?"active":""}`,onClick:()=>r("admin"),children:"Admin"})]}),(0,it.jsx)("div",{className:"page-container",children:(0,it.jsxs)(it.Fragment,{children:[(0,it.jsx)("div",{className:`page-content ${i==="sandbox"?"active":"hidden"}`,children:(0,it.jsx)(QN,{apiKey:e,agentId:t,skillId:n,sandboxId:a,sharedChatMessages:l,onSharedSendMessage:d,onSharedClearHistory:p,isChatLoading:o,setIsChatLoading:u})}),(0,it.jsx)("div",{className:`page-content ${i==="production"?"active":"hidden"}`,children:(0,it.jsx)(fE,{apiKey:e,agentId:t,skillId:n,isActive:i==="production",sharedChatMessages:l,onSharedSendMessage:d,onSharedClearHistory:p,isChatLoading:o,setIsChatLoading:u})}),(0,it.jsx)("div",{className:`page-content ${i==="admin"?"active":"hidden"}`,children:(0,it.jsx)(pE,{apiKey:e,agentId:t})})]})})]})}});var o_=Ut(()=>{var yE=F(Je()),bE=F(Yb());vE();var ih=F(re()),Ls=window.__LUA_CONFIG__;if(!Ls)throw new Error("Lua configuration not found");var SE=document.getElementById("root");if(!SE)throw new Error("Root container not found");var s_=(0,bE.createRoot)(SE);s_.render((0,ih.jsx)(yE.default.StrictMode,{children:(0,ih.jsx)(gE,{apiKey:Ls.apiKey,agentId:Ls.agentId,skillId:Ls.skillId,sandboxId:Ls.sandboxId})}))});return o_();})();
25
25
  /*! Bundled license information:
26
26
 
27
27
  react/cjs/react.production.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lua-cli",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "Command-line interface for Lua AI platform - develop, test, and deploy LuaSkills with custom tools",
5
5
  "readmeFilename": "README.md",
6
6
  "main": "dist/index.js",
@@ -34,7 +34,7 @@
34
34
  "deployment",
35
35
  "skills"
36
36
  ],
37
- "author": "Stefan Kruger <stefan@lua.dev>",
37
+ "author": "Stefan Kruger <stefan@heylua.ai>",
38
38
  "license": "MIT",
39
39
  "type": "module",
40
40
  "repository": {
@@ -19,7 +19,7 @@
19
19
  "axios": "^1.6.0",
20
20
  "inquirer": "^12.9.6",
21
21
  "js-yaml": "^4.1.0",
22
- "lua-cli": "2.0.4",
22
+ "lua-cli": "2.0.5",
23
23
  "openai": "^5.23.0",
24
24
  "zod": "^3.24.1"
25
25
  },