@michael-joseph-miller/ant-bot 0.4.0 → 0.4.1
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/CHANGELOG.md +11 -0
- package/README.md +4 -4
- package/dist/{chunk-BKF7CUVN.js → chunk-G4IIENWF.js} +8 -2
- package/dist/chunk-G4IIENWF.js.map +7 -0
- package/dist/index.js +4 -3
- package/dist/index.js.map +2 -2
- package/dist/server.js +15 -3
- package/dist/server.js.map +2 -2
- package/package.json +1 -1
- package/web/dist/assets/{index-9uemvauV.js → index-Cpi4IKb8.js} +1 -1
- package/web/dist/index.html +1 -1
- package/dist/chunk-BKF7CUVN.js.map +0 -7
package/package.json
CHANGED
|
@@ -127,4 +127,4 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
127
127
|
|
|
128
128
|
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=xn,s=!sn.jitless,c=s&&Sn.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?Bi([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function Ui(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Ln(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Vn(e,r,cn())))}),t)}var Wi=M(`$ZodUnion`,(e,t)=>{F.init(e,t),N(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),N(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),N(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),N(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>pn(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Ui(t,r,e,i)):Ui(o,r,e,i)}}),Gi=M(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Wi.init(e,t);let n=e._zod.parse;N(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=dn(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!xn(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),Ki=M(`$ZodIntersection`,(e,t)=>{F.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Ji(e,t,n)):Ji(e,i,a)}});function qi(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Cn(e)&&Cn(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=qi(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=qi(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ji(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),Ln(e))return e;let o=qi(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var Yi=M(`$ZodRecord`,(e,t)=>{F.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Cn(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>Vn(e,r,cn())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...zn(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...zn(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&Ir.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Vn(e,r,cn())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...zn(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...zn(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Xi=M(`$ZodEnum`,(e,t)=>{F.init(e,t);let n=ln(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Tn.has(typeof e)).map(e=>typeof e==`string`?En(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Zi=M(`$ZodLiteral`,(e,t)=>{if(F.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?En(e):e?En(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Qi=M(`$ZodTransform`,(e,t)=>{F.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new on(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new an;return n.value=i,n.fallback=!0,n}});function $i(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var ea=M(`$ZodOptional`,(e,t)=>{F.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,N(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),N(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${pn(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>$i(e,r)):$i(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),ta=M(`$ZodExactOptional`,(e,t)=>{ea.init(e,t),N(e._zod,`values`,()=>t.innerType._zod.values),N(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),na=M(`$ZodNullable`,(e,t)=>{F.init(e,t),N(e._zod,`optin`,()=>t.innerType._zod.optin),N(e._zod,`optout`,()=>t.innerType._zod.optout),N(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${pn(e.source)}|null)$`):void 0}),N(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),ra=M(`$ZodDefault`,(e,t)=>{F.init(e,t),e._zod.optin=`optional`,N(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>ia(e,t)):ia(r,t)}});function ia(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var aa=M(`$ZodPrefault`,(e,t)=>{F.init(e,t),e._zod.optin=`optional`,N(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),oa=M(`$ZodNonOptional`,(e,t)=>{F.init(e,t),N(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>sa(t,e)):sa(i,e)}});function sa(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var ca=M(`$ZodCatch`,(e,t)=>{F.init(e,t),e._zod.optin=`optional`,N(e._zod,`optout`,()=>t.innerType._zod.optout),N(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Vn(e,n,cn()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Vn(e,n,cn()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),la=M(`$ZodPipe`,(e,t)=>{F.init(e,t),N(e._zod,`values`,()=>t.in._zod.values),N(e._zod,`optin`,()=>t.in._zod.optin),N(e._zod,`optout`,()=>t.out._zod.optout),N(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>ua(e,t.in,n)):ua(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>ua(e,t.out,n)):ua(r,t.out,n)}});function ua(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var da=M(`$ZodReadonly`,(e,t)=>{F.init(e,t),N(e._zod,`propValues`,()=>t.innerType._zod.propValues),N(e._zod,`values`,()=>t.innerType._zod.values),N(e._zod,`optin`,()=>t.innerType?._zod?.optin),N(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(fa):fa(r)}});function fa(e){return e.value=Object.freeze(e.value),e}var pa=M(`$ZodCustom`,(e,t)=>{Br.init(e,t),F.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>ma(t,n,r,e));ma(i,n,r,e)}});function ma(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Un(e))}}var ha,ga=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function _a(){return new ga}(ha=globalThis).__zod_globalRegistry??(ha.__zod_globalRegistry=_a());var va=globalThis.__zod_globalRegistry;function ya(e,t){return new e({type:`string`,...P(t)})}function ba(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...P(t)})}function xa(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...P(t)})}function Sa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...P(t)})}function Ca(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...P(t)})}function wa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...P(t)})}function Ta(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...P(t)})}function Ea(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...P(t)})}function Da(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...P(t)})}function Oa(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...P(t)})}function ka(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...P(t)})}function Aa(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...P(t)})}function ja(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...P(t)})}function Ma(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...P(t)})}function Na(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...P(t)})}function Pa(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...P(t)})}function Fa(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...P(t)})}function Ia(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...P(t)})}function La(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...P(t)})}function Ra(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...P(t)})}function za(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...P(t)})}function Ba(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...P(t)})}function Va(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...P(t)})}function Ha(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...P(t)})}function Ua(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...P(t)})}function Wa(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...P(t)})}function Ga(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...P(t)})}function Ka(e,t){return new e({type:`number`,checks:[],...P(t)})}function qa(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...P(t)})}function Ja(e,t){return new e({type:`boolean`,...P(t)})}function Ya(e){return new e({type:`unknown`})}function Xa(e,t){return new e({type:`never`,...P(t)})}function Za(e,t){return new Hr({check:`less_than`,...P(t),value:e,inclusive:!1})}function Qa(e,t){return new Hr({check:`less_than`,...P(t),value:e,inclusive:!0})}function $a(e,t){return new Ur({check:`greater_than`,...P(t),value:e,inclusive:!1})}function eo(e,t){return new Ur({check:`greater_than`,...P(t),value:e,inclusive:!0})}function to(e,t){return new Wr({check:`multiple_of`,...P(t),value:e})}function no(e,t){return new Kr({check:`max_length`,...P(t),maximum:e})}function ro(e,t){return new qr({check:`min_length`,...P(t),minimum:e})}function io(e,t){return new Jr({check:`length_equals`,...P(t),length:e})}function ao(e,t){return new Xr({check:`string_format`,format:`regex`,...P(t),pattern:e})}function oo(e){return new Zr({check:`string_format`,format:`lowercase`,...P(e)})}function so(e){return new Qr({check:`string_format`,format:`uppercase`,...P(e)})}function co(e,t){return new $r({check:`string_format`,format:`includes`,...P(t),includes:e})}function lo(e,t){return new ei({check:`string_format`,format:`starts_with`,...P(t),prefix:e})}function uo(e,t){return new ti({check:`string_format`,format:`ends_with`,...P(t),suffix:e})}function fo(e){return new ni({check:`overwrite`,tx:e})}function po(e){return fo(t=>t.normalize(e))}function mo(){return fo(e=>e.trim())}function ho(){return fo(e=>e.toLowerCase())}function R(){return fo(e=>e.toUpperCase())}function z(){return fo(e=>yn(e))}function go(e,t,n){return new e({type:`array`,element:t,...P(n)})}function _o(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...P(n)})}function vo(e,t){let n=yo(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Un(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Un(r))}},e(t.value,t)),t);return n}function yo(e,t){let n=new Br({check:`custom`,...P(t)});return n._zod.check=e,n}function bo(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??va,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function xo(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,xo(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&B(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function So(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
129
129
|
|
|
130
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Co(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:To(t,`input`,e.processors),output:To(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function B(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return B(r.element,n);if(r.type===`set`)return B(r.valueType,n);if(r.type===`lazy`)return B(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return B(r.innerType,n);if(r.type===`intersection`)return B(r.left,n)||B(r.right,n);if(r.type===`record`||r.type===`map`)return B(r.keyType,n)||B(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:B(r.in,n)||B(r.out,n);if(r.type===`object`){for(let e in r.shape)if(B(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(B(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(B(e,n))return!0;return!!(r.rest&&B(r.rest,n))}return!1}var wo=(e,t={})=>n=>{let r=bo({...n,processors:t});return xo(e,r),So(r,e),Co(r,e)},To=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=bo({...i??{},target:a,io:t,processors:n});return xo(e,o),So(o,e),Co(o,e)},Eo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Do=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Eo[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Oo=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},ko=(e,t,n,r)=>{n.type=`boolean`},Ao=(e,t,n,r)=>{n.not={}},jo=(e,t,n,r)=>{let i=e._zod.def,a=ln(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Mo=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},No=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Po=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Fo=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=xo(a.element,t,{...r,path:[...r.path,`items`]})},Io=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=xo(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=xo(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Lo=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>xo(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Ro=(e,t,n,r)=>{let i=e._zod.def,a=xo(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=xo(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},zo=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=xo(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=xo(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=xo(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Bo=(e,t,n,r)=>{let i=e._zod.def,a=xo(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Vo=(e,t,n,r)=>{let i=e._zod.def;xo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ho=(e,t,n,r)=>{let i=e._zod.def;xo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Uo=(e,t,n,r)=>{let i=e._zod.def;xo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Wo=(e,t,n,r)=>{let i=e._zod.def;xo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Go=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;xo(o,t,r);let s=t.seen.get(e);s.ref=o},Ko=(e,t,n,r)=>{let i=e._zod.def;xo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},qo=(e,t,n,r)=>{let i=e._zod.def;xo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Jo=M(`ZodISODateTime`,(e,t)=>{_i.init(e,t),bs.init(e,t)});function Yo(e){return Ha(Jo,e)}var Xo=M(`ZodISODate`,(e,t)=>{vi.init(e,t),bs.init(e,t)});function Zo(e){return Ua(Xo,e)}var Qo=M(`ZodISOTime`,(e,t)=>{yi.init(e,t),bs.init(e,t)});function $o(e){return Wa(Qo,e)}var es=M(`ZodISODuration`,(e,t)=>{bi.init(e,t),bs.init(e,t)});function ts(e){return Ga(es,e)}var ns=M(`ZodError`,(e,t)=>{Gn.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Jn(e,t)},flatten:{value:t=>qn(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,un,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,un,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),rs=Yn(ns),is=Xn(ns),as=Zn(ns),os=$n(ns),ss=tr(ns),cs=nr(ns),ls=rr(ns),us=ir(ns),ds=ar(ns),fs=or(ns),ps=sr(ns),ms=cr(ns),hs=new WeakMap;function gs(e,t,n){let r=Object.getPrototypeOf(e),i=hs.get(r);if(i||(i=new Set,hs.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var _s=M(`ZodType`,(e,t)=>(F.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:To(e,`input`),output:To(e,`output`)}}),e.toJSONSchema=wo(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>rs(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>as(e,t,n),e.parseAsync=async(t,n)=>is(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>os(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>ss(e,t,n),e.decode=(t,n)=>cs(e,t,n),e.encodeAsync=async(t,n)=>ls(e,t,n),e.decodeAsync=async(t,n)=>us(e,t,n),e.safeEncode=(t,n)=>ds(e,t,n),e.safeDecode=(t,n)=>fs(e,t,n),e.safeEncodeAsync=async(t,n)=>ps(e,t,n),e.safeDecodeAsync=async(t,n)=>ms(e,t,n),gs(e,`ZodType`,{check(...e){let t=this.def;return this.clone(_n(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Dn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(kc(e,t))},superRefine(e,t){return this.check(Ac(e,t))},overwrite(e){return this.check(fo(e))},optional(){return dc(this)},exactOptional(){return pc(this)},nullable(){return hc(this)},nullish(){return dc(hc(this))},nonoptional(e){return xc(this,e)},array(){return Xs(this)},or(e){return $s([this,e])},and(e){return rc(this,e)},transform(e){return Tc(this,lc(e))},default(e){return _c(this,e)},prefault(e){return yc(this,e)},catch(e){return Cc(this,e)},pipe(e){return Tc(this,e)},readonly(){return Dc(this)},describe(e){let t=this.clone();return va.add(t,{description:e}),t},meta(...e){if(e.length===0)return va.get(this);let t=this.clone();return va.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return va.get(e)?.description},configurable:!0}),e)),vs=M(`_ZodString`,(e,t)=>{ai.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Do(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,gs(e,`_ZodString`,{regex(...e){return this.check(ao(...e))},includes(...e){return this.check(co(...e))},startsWith(...e){return this.check(lo(...e))},endsWith(...e){return this.check(uo(...e))},min(...e){return this.check(ro(...e))},max(...e){return this.check(no(...e))},length(...e){return this.check(io(...e))},nonempty(...e){return this.check(ro(1,...e))},lowercase(e){return this.check(oo(e))},uppercase(e){return this.check(so(e))},trim(){return this.check(mo())},normalize(...e){return this.check(po(...e))},toLowerCase(){return this.check(ho())},toUpperCase(){return this.check(R())},slugify(){return this.check(z())}})}),ys=M(`ZodString`,(e,t)=>{ai.init(e,t),vs.init(e,t),e.email=t=>e.check(ba(xs,t)),e.url=t=>e.check(Ea(ws,t)),e.jwt=t=>e.check(Va(zs,t)),e.emoji=t=>e.check(Da(Ts,t)),e.guid=t=>e.check(xa(Ss,t)),e.uuid=t=>e.check(Sa(Cs,t)),e.uuidv4=t=>e.check(Ca(Cs,t)),e.uuidv6=t=>e.check(wa(Cs,t)),e.uuidv7=t=>e.check(Ta(Cs,t)),e.nanoid=t=>e.check(Oa(Es,t)),e.guid=t=>e.check(xa(Ss,t)),e.cuid=t=>e.check(ka(Ds,t)),e.cuid2=t=>e.check(Aa(Os,t)),e.ulid=t=>e.check(ja(ks,t)),e.base64=t=>e.check(Ra(Is,t)),e.base64url=t=>e.check(za(Ls,t)),e.xid=t=>e.check(Ma(As,t)),e.ksuid=t=>e.check(Na(js,t)),e.ipv4=t=>e.check(Pa(Ms,t)),e.ipv6=t=>e.check(Fa(Ns,t)),e.cidrv4=t=>e.check(Ia(Ps,t)),e.cidrv6=t=>e.check(La(Fs,t)),e.e164=t=>e.check(Ba(Rs,t)),e.datetime=t=>e.check(Yo(t)),e.date=t=>e.check(Zo(t)),e.time=t=>e.check($o(t)),e.duration=t=>e.check(ts(t))});function V(e){return ya(ys,e)}var bs=M(`ZodStringFormat`,(e,t)=>{I.init(e,t),vs.init(e,t)}),xs=M(`ZodEmail`,(e,t)=>{ci.init(e,t),bs.init(e,t)}),Ss=M(`ZodGUID`,(e,t)=>{oi.init(e,t),bs.init(e,t)}),Cs=M(`ZodUUID`,(e,t)=>{si.init(e,t),bs.init(e,t)}),ws=M(`ZodURL`,(e,t)=>{li.init(e,t),bs.init(e,t)}),Ts=M(`ZodEmoji`,(e,t)=>{ui.init(e,t),bs.init(e,t)}),Es=M(`ZodNanoID`,(e,t)=>{di.init(e,t),bs.init(e,t)}),Ds=M(`ZodCUID`,(e,t)=>{fi.init(e,t),bs.init(e,t)}),Os=M(`ZodCUID2`,(e,t)=>{pi.init(e,t),bs.init(e,t)}),ks=M(`ZodULID`,(e,t)=>{mi.init(e,t),bs.init(e,t)}),As=M(`ZodXID`,(e,t)=>{hi.init(e,t),bs.init(e,t)}),js=M(`ZodKSUID`,(e,t)=>{gi.init(e,t),bs.init(e,t)}),Ms=M(`ZodIPv4`,(e,t)=>{xi.init(e,t),bs.init(e,t)}),Ns=M(`ZodIPv6`,(e,t)=>{Si.init(e,t),bs.init(e,t)}),Ps=M(`ZodCIDRv4`,(e,t)=>{Ci.init(e,t),bs.init(e,t)}),Fs=M(`ZodCIDRv6`,(e,t)=>{wi.init(e,t),bs.init(e,t)}),Is=M(`ZodBase64`,(e,t)=>{Ei.init(e,t),bs.init(e,t)}),Ls=M(`ZodBase64URL`,(e,t)=>{Oi.init(e,t),bs.init(e,t)}),Rs=M(`ZodE164`,(e,t)=>{ki.init(e,t),bs.init(e,t)}),zs=M(`ZodJWT`,(e,t)=>{ji.init(e,t),bs.init(e,t)}),Bs=M(`ZodNumber`,(e,t)=>{Mi.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oo(e,t,n,r),gs(e,`ZodNumber`,{gt(e,t){return this.check($a(e,t))},gte(e,t){return this.check(eo(e,t))},min(e,t){return this.check(eo(e,t))},lt(e,t){return this.check(Za(e,t))},lte(e,t){return this.check(Qa(e,t))},max(e,t){return this.check(Qa(e,t))},int(e){return this.check(Hs(e))},safe(e){return this.check(Hs(e))},positive(e){return this.check($a(0,e))},nonnegative(e){return this.check(eo(0,e))},negative(e){return this.check(Za(0,e))},nonpositive(e){return this.check(Qa(0,e))},multipleOf(e,t){return this.check(to(e,t))},step(e,t){return this.check(to(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function H(e){return Ka(Bs,e)}var Vs=M(`ZodNumberFormat`,(e,t)=>{Ni.init(e,t),Bs.init(e,t)});function Hs(e){return qa(Vs,e)}var Us=M(`ZodBoolean`,(e,t)=>{Pi.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ko(e,t,n,r)});function Ws(e){return Ja(Us,e)}var Gs=M(`ZodUnknown`,(e,t)=>{Fi.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Ks(){return Ya(Gs)}var qs=M(`ZodNever`,(e,t)=>{Ii.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ao(e,t,n,r)});function Js(e){return Xa(qs,e)}var Ys=M(`ZodArray`,(e,t)=>{Li.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fo(e,t,n,r),e.element=t.element,gs(e,`ZodArray`,{min(e,t){return this.check(ro(e,t))},nonempty(e){return this.check(ro(1,e))},max(e,t){return this.check(no(e,t))},length(e,t){return this.check(io(e,t))},unwrap(){return this.element}})});function Xs(e,t){return go(Ys,e,t)}var Zs=M(`ZodObject`,(e,t)=>{Hi.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Io(e,t,n,r),N(e,`shape`,()=>t.shape),gs(e,`ZodObject`,{keyof(){return W(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Ks()})},loose(){return this.clone({...this._zod.def,catchall:Ks()})},strict(){return this.clone({...this._zod.def,catchall:Js()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Mn(this,e)},safeExtend(e){return Nn(this,e)},merge(e){return Pn(this,e)},pick(e){return An(this,e)},omit(e){return jn(this,e)},partial(...e){return Fn(uc,this,e[0])},required(...e){return In(bc,this,e[0])}})});function U(e,t){return new Zs({type:`object`,shape:e??{},...P(t)})}var Qs=M(`ZodUnion`,(e,t)=>{Wi.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lo(e,t,n,r),e.options=t.options});function $s(e,t){return new Qs({type:`union`,options:e,...P(t)})}var ec=M(`ZodDiscriminatedUnion`,(e,t)=>{Qs.init(e,t),Gi.init(e,t)});function tc(e,t,n){return new ec({type:`union`,options:t,discriminator:e,...P(n)})}var nc=M(`ZodIntersection`,(e,t)=>{Ki.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ro(e,t,n,r)});function rc(e,t){return new nc({type:`intersection`,left:e,right:t})}var ic=M(`ZodRecord`,(e,t)=>{Yi.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zo(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function ac(e,t,n){return!t||!t._zod?new ic({type:`record`,keyType:V(),valueType:e,...P(t)}):new ic({type:`record`,keyType:e,valueType:t,...P(n)})}var oc=M(`ZodEnum`,(e,t)=>{Xi.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jo(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new oc({...t,checks:[],...P(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new oc({...t,checks:[],...P(r),entries:i})}});function W(e,t){return new oc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...P(t)})}var sc=M(`ZodLiteral`,(e,t)=>{Zi.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mo(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function G(e,t){return new sc({type:`literal`,values:Array.isArray(e)?e:[e],...P(t)})}var cc=M(`ZodTransform`,(e,t)=>{Qi.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Po(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new on(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Un(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Un(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function lc(e){return new cc({type:`transform`,transform:e})}var uc=M(`ZodOptional`,(e,t)=>{ea.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function dc(e){return new uc({type:`optional`,innerType:e})}var fc=M(`ZodExactOptional`,(e,t)=>{ta.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function pc(e){return new fc({type:`optional`,innerType:e})}var mc=M(`ZodNullable`,(e,t)=>{na.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function hc(e){return new mc({type:`nullable`,innerType:e})}var gc=M(`ZodDefault`,(e,t)=>{ra.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ho(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function _c(e,t){return new gc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():wn(t)}})}var vc=M(`ZodPrefault`,(e,t)=>{aa.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function yc(e,t){return new vc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():wn(t)}})}var bc=M(`ZodNonOptional`,(e,t)=>{oa.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function xc(e,t){return new bc({type:`nonoptional`,innerType:e,...P(t)})}var Sc=M(`ZodCatch`,(e,t)=>{ca.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Cc(e,t){return new Sc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var wc=M(`ZodPipe`,(e,t)=>{la.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Go(e,t,n,r),e.in=t.in,e.out=t.out});function Tc(e,t){return new wc({type:`pipe`,in:e,out:t})}var Ec=M(`ZodReadonly`,(e,t)=>{da.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ko(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Dc(e){return new Ec({type:`readonly`,innerType:e})}var Oc=M(`ZodCustom`,(e,t)=>{pa.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>No(e,t,n,r)});function kc(e,t={}){return _o(Oc,e,t)}function Ac(e,t){return vo(e,t)}var jc=W([`idle`,`queued`,`running`,`waiting_approval`,`waiting_input`,`interrupted`]),Mc=W([`none`,`unread`,`needs_attention`]),Nc=[`fable`,`opus`,`sonnet`,`haiku`],Pc=W(Nc);U({id:V(),slug:V().regex(/^[a-z0-9][a-z0-9-]*$/),name:V().min(1).max(60),title:V().max(120).default(``),description:V().max(8e3).default(``),avatarEmoji:V().max(8).default(`🤖`),modelTier:Pc.default(`sonnet`),pinned:Ws().default(!1),hidden:Ws().default(!1),notifications:Ws().default(!0),sessionId:V().nullable().default(null),state:jc.default(`idle`),attention:Mc.default(`none`),threadId:V().nullable().default(null),createdAt:H(),deletedAt:H().nullable().default(null)});var Fc=W([`dm`,`group`]);U({id:V(),kind:Fc,title:V().default(``),memberBotIds:Xs(V()).default([]),pinned:Ws().default(!1),hidden:Ws().default(!1),lastReadAt:H().default(0),createdAt:H()});var Ic=tc(`type`,[U({type:G(`tool`),toolName:V(),summary:V(),input:Ks().optional(),result:V().optional(),status:W([`running`,`ok`,`error`,`denied`])}),U({type:G(`file`),path:V(),name:V(),mime:V(),bytes:H(),action:W([`created`,`modified`]).default(`created`)}),U({type:G(`approval`),approvalId:V()}),U({type:G(`handoff`),fromBotId:V(),toBotId:V(),note:V()}),U({type:G(`error`),message:V()}),U({type:G(`signin`),serverName:V(),url:V()})]),Lc=W([`user`,`bot`,`system`]),Rc=U({id:V(),threadId:V(),authorKind:Lc,authorBotId:V().nullable().default(null),replyToId:V().nullable().default(null),contentMd:V().default(``),cards:Xs(Ic).default([]),streaming:Ws().default(!1),createdAt:H()});U({id:V(),messageId:V().nullable(),path:V(),name:V(),mime:V(),bytes:H(),createdAt:H()});var zc=W([`pending`,`allowed`,`denied`,`expired`]),Bc=U({id:V(),botId:V(),threadId:V(),toolName:V(),inputSummary:V(),rawInput:Ks(),status:zc.default(`pending`),decidedBy:W([`user`,`rule`,`auto_review`]).nullable().default(null),reason:V().default(``),ruleId:V().nullable().default(null),createdAt:H(),decidedAt:H().nullable().default(null)}),Vc=W([`require`,`allow`]);U({id:V(),kind:Vc,toolPattern:V().default(`*`),inputPattern:V().default(``),scopeNote:V().default(``),builtin:Ws().default(!1),enabled:Ws().default(!0),createdAt:H()}),U({id:V(),slug:V(),name:V(),description:V().default(``),path:V(),source:W([`user`,`taught`,`imported`]).default(`user`),createdAt:H()});var Hc=/^[a-z0-9][a-z0-9-]{0,31}$/,Uc=[`antbot`,`browser`],Wc=tc(`transport`,[U({transport:G(`stdio`),command:V().min(1),args:Xs(V()).default([]),env:ac(V(),V()).default({})}),U({transport:G(`http`),url:V().url(),headers:ac(V(),V()).default({}),tools:Xs(V()).optional()}),U({transport:G(`sse`),url:V().url(),headers:ac(V(),V()).default({}),tools:Xs(V()).optional()})]),Gc=U({id:V(),name:V().regex(Hc,`lowercase letters, digits and hyphens only, max 32 characters`).refine(e=>!Uc.includes(e),{message:`"antbot" and "browser" are reserved for the built-in servers`}),description:V().default(``),enabled:Ws().default(!0),kind:W([`custom`,`builtin`]).default(`custom`),config:Wc,lastStatus:V().nullable().default(null),lastError:V().nullable().default(null),checkedAt:H().nullable().default(null),createdAt:H()});U({status:W([`ready`,`needs-sign-in`,`needs-credential`,`unreachable`]),selfRegistration:Ws().optional(),provider:V().optional(),tools:Xs(U({name:V(),description:V()})).default([]),detail:V().optional()}),U({id:V(),botId:V(),name:V().min(1),cronExpr:V(),timezone:V().default(`UTC`),instructionMd:V(),enabled:Ws().default(!0),lastRunAt:H().nullable().default(null),nextRunAt:H().nullable().default(null),createdAt:H()});var Kc=U({id:V(),routineId:V(),startedAt:H(),finishedAt:H().nullable().default(null),status:W([`running`,`ok`,`failed`,`interrupted`]),summary:V().default(``),threadId:V().nullable().default(null),isTest:Ws().default(!1)});U({id:V(),fromBotId:V(),toBotId:V(),contentMd:V(),hops:H().default(1),delivered:Ws().default(!1),createdAt:H()}),U({id:V(),botId:V(),turnId:V(),model:V(),inputTokens:H().default(0),outputTokens:H().default(0),cacheReadTokens:H().default(0),costEstimate:H().default(0),createdAt:H()}),W([`user`,`bot`,`routine`,`system`]);var qc={seq:H(),threadId:V().nullable(),botId:V().nullable()};tc(`type`,[U({...qc,type:G(`hello`)}),U({...qc,type:G(`message.created`),message:Rc}),U({...qc,type:G(`message.delta`),messageId:V(),delta:V()}),U({...qc,type:G(`message.done`),messageId:V(),contentMd:V()}),U({...qc,type:G(`message.card`),messageId:V(),card:Ic,cardIndex:H()}),U({...qc,type:G(`bot.state`),state:jc,attention:Mc}),U({...qc,type:G(`approval.pending`),approval:Bc}),U({...qc,type:G(`approval.resolved`),approval:Bc}),U({...qc,type:G(`routine.run`),run:Kc}),U({...qc,type:G(`usage.tick`),inputTokens:H(),outputTokens:H(),model:V()}),U({...qc,type:G(`notify`),title:V(),body:V(),level:W([`info`,`warn`,`error`])}),U({...qc,type:G(`secret.request`),requestId:V(),name:V(),reason:V()}),U({...qc,type:G(`thread.updated`),threadId2:V()})]);var Jc=tc(`kind`,[U({kind:G(`mouse`),action:W([`move`,`down`,`up`,`wheel`]),x:H().min(0).max(1),y:H().min(0).max(1),button:W([`left`,`middle`,`right`]).default(`left`),clickCount:H().int().min(0).max(3).default(1),deltaX:H().default(0),deltaY:H().default(0)}),U({kind:G(`key`),action:W([`down`,`up`]),key:V().min(1).max(32)}),U({kind:G(`text`),text:V().min(1).max(4096)})]);tc(`type`,[U({type:G(`input`),input:Jc}),U({type:G(`selection-request`)})]),U({name:V().min(1).max(60),title:V().max(120).optional(),description:V().max(8e3).optional(),avatarEmoji:V().max(8).optional(),modelTier:Pc.optional()}).partial().extend({pinned:Ws().optional(),hidden:Ws().optional(),notifications:Ws().optional()}),U({kind:W([`dm`,`group`]),title:V().optional(),memberBotIds:Xs(V())}),U({contentMd:V(),attachmentIds:Xs(V()).optional(),replyToId:V().nullable().optional(),mentionBotIds:Xs(V()).optional(),mentionEveryone:Ws().optional()}),U({decision:W([`allow`,`deny`]),alwaysRule:U({toolPattern:V(),inputPattern:V().default(``),scopeNote:V().default(``)}).optional()}),U({kind:W([`require`,`allow`]),toolPattern:V().min(1),inputPattern:V().default(``),scopeNote:V().default(``)}),U({botId:V(),name:V().min(1),cronExpr:V().min(1),timezone:V().optional(),instructionMd:V().min(1),enabled:Ws().optional()}),U({name:V().min(1),description:V().default(``),bodyMd:V().min(1),source:W([`user`,`taught`,`imported`]).optional()}),U({name:Gc.shape.name,description:V().default(``),config:Wc.optional(),builtin:V().optional(),enabled:Ws().optional(),botIds:Xs(V()).optional()}).refine(e=>!!e.config!=!!e.builtin,{message:`Give either config or builtin, not both`}),U({description:V().optional(),config:Wc.optional(),enabled:Ws().optional()});var Yc={timezone:V(),maxConcurrentSessions:H().min(1).max(8),autoReviewEnabled:Ws(),theme:W([`system`,`light`,`dark`]),localExecution:W([`ask`,`always`,`never`]),dailyTokenBudget:H(),notificationsEnabled:Ws(),billingMode:W([`subscription`,`api`]),computerMode:W([`host`,`container`])};U({timezone:Yc.timezone.default(`UTC`),maxConcurrentSessions:Yc.maxConcurrentSessions.default(2),autoReviewEnabled:Yc.autoReviewEnabled.default(!0),theme:Yc.theme.default(`system`),localExecution:Yc.localExecution.default(`ask`),dailyTokenBudget:Yc.dailyTokenBudget.default(0),notificationsEnabled:Yc.notificationsEnabled.default(!0),billingMode:Yc.billingMode.default(`subscription`),computerMode:Yc.computerMode.default(`host`)}),U(Yc).partial(),U({kind:W([`message`,`file`,`routine`,`bot`]),id:V(),threadId:V().nullable(),botId:V().nullable(),title:V(),snippet:V(),createdAt:H()});var Xc=nn.MAX_ATTACHMENTS_PER_MESSAGE;function Zc(e,t){let n=e.slice(0,t),r=/(^|\s)([@/])([\w-]*)$/.exec(n);if(!r)return null;let i=r[2];return i===`/`&&n.trim()!==`/${r[3]}`?null:{prefix:i,query:r[3],start:t-r[3].length-1}}function Qc({onSend:e,bots:t,skills:n,running:r,onStop:i,uploadFile:a}){let[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)([]),[u,d]=(0,_.useState)(null),f=(0,_.useRef)(null),p=(0,_.useRef)(null),m=(0,_.useRef)(0);(0,_.useEffect)(()=>{m.current=c.length},[c.length]);let h=(0,_.useMemo)(()=>a??(e=>T.attachments.upload(e)),[a]),g=(0,_.useMemo)(()=>{if(!u||u.prefix!==`@`)return[];let e=u.query.toLowerCase();return t.filter(t=>t.bot.name.toLowerCase().includes(e)||t.bot.slug.toLowerCase().includes(e)).slice(0,8)},[u,t]),v=(0,_.useMemo)(()=>{if(!u||u.prefix!==`/`)return[];let e=u.query.toLowerCase();return n.filter(t=>t.slug.toLowerCase().includes(e)||t.name.toLowerCase().includes(e)).slice(0,8)},[u,n]);function y(e){let t=Array.from(e),n=Math.max(0,Xc-m.current),r=t.slice(0,n);m.current=Math.min(Xc,m.current+r.length);for(let e of r)h(e).then(e=>{l(t=>t.length>=Xc?t:[...t,e])}).catch(()=>{m.current=Math.max(0,m.current-1)})}function b(e){l(t=>t.filter(t=>t.id!==e))}function x(){let t=o.trim();t&&(e(t,c.map(e=>e.id)),s(``),l([]),d(null))}function ee(e,t){s(e),d(Zc(e,t))}function te(e){e.key===`Enter`&&!e.shiftKey?(e.preventDefault(),x()):e.key===`Escape`&&d(null)}function S(e){if(!u)return;let t=p.current,n=t?t.selectionStart:o.length,r=o.slice(0,u.start),i=o.slice(n),a=u.prefix===`@`?`@${e} `:`/${e} `,c=`${r}${a}${i}`;s(c),d(null),requestAnimationFrame(()=>{t?.focus();let e=r.length+a.length;t?.setSelectionRange(e,e)})}function ne(e){let t=Array.from(e.clipboardData?.items??[]).filter(e=>e.kind===`file`&&e.type.startsWith(`image/`)).map(e=>e.getAsFile()).filter(e=>!!e);t.length>0&&(e.preventDefault(),y(t))}function re(e){e.preventDefault(),e.dataTransfer.files.length>0&&y(e.dataTransfer.files)}return(0,O.jsxs)(`div`,{className:`shrink-0 border-t border-(--color-border) bg-(--color-bg-elevated) p-3`,onDrop:re,onDragOver:e=>e.preventDefault(),children:[c.length>0&&(0,O.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:c.map(e=>(0,O.jsxs)(`span`,{"data-testid":`attachment-chip`,className:`flex items-center gap-1.5 rounded-full border border-(--color-border) bg-(--color-bg) px-2.5 py-1 text-xs`,children:[e.name,(0,O.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,className:`text-(--color-text-muted) hover:text-(--color-red)`,onClick:()=>b(e.id),children:`×`})]},e.id))}),u&&(g.length>0||v.length>0)&&(0,O.jsx)(`div`,{className:`mb-2 max-h-40 overflow-auto rounded border border-(--color-border) bg-(--color-bg) text-sm shadow-lg`,children:u.prefix===`@`?g.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-1.5 text-left hover:bg-(--color-bg-hover)`,onClick:()=>S(e.bot.slug),children:[(0,O.jsx)(`span`,{children:e.bot.avatarEmoji}),(0,O.jsx)(`span`,{children:e.bot.name})]},e.bot.id)):v.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-1.5 text-left hover:bg-(--color-bg-hover)`,onClick:()=>S(e.slug),children:[(0,O.jsxs)(`span`,{className:`shrink-0 font-mono text-(--color-text-muted)`,children:[`/`,e.slug]}),(0,O.jsx)(`span`,{className:`min-w-0 truncate text-(--color-text-muted)`,title:e.description,children:e.description})]},e.id))}),(0,O.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,"aria-label":`Attach files`,className:`shrink-0 rounded border border-(--color-border) px-2.5 py-2 text-sm hover:bg-(--color-bg-hover)`,onClick:()=>f.current?.click(),children:`+`}),(0,O.jsx)(`input`,{ref:f,"data-testid":`attachment-input`,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&y(e.target.files),e.target.value=``}}),(0,O.jsx)(`textarea`,{ref:p,value:o,rows:1,placeholder:`Message… (@ to mention, / for a skill)`,className:`max-h-40 min-h-[38px] flex-1 resize-none rounded border border-(--color-border) bg-(--color-bg) px-3 py-2 text-sm outline-none focus:border-(--color-accent)`,onChange:e=>ee(e.target.value,e.target.selectionStart),onKeyDown:te,onPaste:ne}),r&&(0,O.jsx)(`button`,{type:`button`,onClick:i,className:`shrink-0 rounded border border-(--color-red) px-3 py-2 text-sm font-medium text-(--color-red) hover:bg-(--color-red)/10`,children:`Stop`}),(0,O.jsx)(`button`,{type:`button`,onClick:x,disabled:!o.trim(),className:`shrink-0 rounded bg-(--color-accent) px-3 py-2 text-sm font-medium text-(--color-accent-fg) disabled:opacity-40`,children:`Send`})]})]})}j.setOptions({breaks:!0});function $c(e){return j.parse(e,{async:!1}).replace(/<script[\s\S]*?<\/script>/gi,``)}function el(e,t){if(e.authorKind===`user`)return{name:`You`,emoji:`🧑`};if(e.authorKind===`system`)return{name:`System`,emoji:`⚙️`};let n=e.authorBotId?t[e.authorBotId]?.bot:void 0;return{name:n?.name??`Bot`,emoji:n?.avatarEmoji??`🤖`}}function tl({message:e,botsById:t}){let{name:n,emoji:r}=el(e,t),i=e.authorKind===`user`;return(0,O.jsxs)(`div`,{className:b(`flex gap-3 px-4 py-2`,i&&`flex-row-reverse`),children:[(0,O.jsx)(`span`,{className:`mt-0.5 text-lg leading-none`,children:r}),(0,O.jsxs)(`div`,{className:b(`min-w-0 max-w-[75%]`,i&&`items-end text-right`),children:[(0,O.jsxs)(`div`,{className:b(`mb-0.5 flex items-baseline gap-2`,i&&`flex-row-reverse`),children:[(0,O.jsx)(`span`,{className:`text-xs font-semibold text-(--color-text-muted)`,children:n}),(0,O.jsx)(`span`,{className:`text-[11px] text-(--color-text-faint)`,children:new Date(e.createdAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})})]}),e.contentMd&&(0,O.jsxs)(`div`,{className:b(`markdown-body inline-block rounded-lg px-3 py-2 text-sm`,i?`bg-(--color-accent) text-(--color-accent-fg)`:`bg-(--color-bg-elevated)`),children:[(0,O.jsx)(`span`,{dangerouslySetInnerHTML:{__html:$c(e.contentMd)}}),e.streaming&&(0,O.jsx)(`span`,{className:`ml-0.5 inline-block w-1.5 animate-pulse bg-current align-middle`,children:`\xA0`})]}),(0,O.jsx)(tn,{cards:e.cards})]})]})}function nl({thread:e,messages:t,botsById:n,bots:r,skills:i,running:a,onSend:o,onStop:s}){let c=(0,_.useRef)(null),[l,u]=(0,_.useState)(!0);(0,_.useEffect)(()=>{if(!l)return;let e=()=>{let e=c.current;e&&(e.scrollTop=e.scrollHeight)};e();let t=requestAnimationFrame(()=>{e(),requestAnimationFrame(e)});return()=>cancelAnimationFrame(t)},[t,l]);function d(){let e=c.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight;u(t<80)}return e?(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,O.jsx)(`div`,{ref:c,onScroll:d,className:`min-h-0 flex-1 overflow-y-auto py-2`,children:t.length===0?(0,O.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-(--color-text-muted)`,children:`No messages yet — say hello and give this bot a job.`}):t.map(e=>(0,O.jsx)(tl,{message:e,botsById:n},e.id))}),(0,O.jsx)(Qc,{onSend:o,bots:r,skills:i,running:a,onStop:s})]}):(0,O.jsx)(`div`,{className:`flex h-full flex-1 flex-col items-center justify-center text-(--color-text-muted)`,children:(0,O.jsx)(`p`,{className:`text-sm`,children:`Select a bot to start a conversation, or create a new one.`})})}var rl=`🤖.🧠.🦾.🛰️.🧭.🗂️.📚.🔍.🧮.🧰.🛠️.⚙️.🧪.🧬.📈.📊.💡.🗒️.✍️.📝.📅.⏰.📬.📡.🌐.🔐.🗝️.🧯.🚀.🛎️.🎯.🧵.🧩.🕵️.🧑💻.👩💻.🧑🔬.🐜.🐝.🦉`.split(`.`);function il({onCreate:e,onClose:t,busy:n,error:r}){let[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(`🤖`),[f,p]=(0,_.useState)(`sonnet`);function m(){i.trim()&&e({name:i.trim(),title:o.trim(),description:c.trim(),avatarEmoji:u,modelTier:f})}return(0,O.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,children:(0,O.jsxs)(`div`,{className:`w-full max-w-md rounded-lg border border-(--color-border) bg-(--color-bg-elevated) p-5 shadow-xl`,children:[(0,O.jsx)(`h2`,{className:`mb-4 text-base font-semibold`,children:`New bot`}),(0,O.jsxs)(`div`,{className:`space-y-3`,children:[(0,O.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,O.jsx)(`div`,{className:`grid grid-cols-8 gap-1 rounded border border-(--color-border) p-1.5`,children:rl.slice(0,16).map(e=>(0,O.jsx)(`button`,{type:`button`,"aria-pressed":u===e,onClick:()=>d(e),className:`rounded p-1 text-lg ${u===e?`bg-(--color-accent)/25`:`hover:bg-(--color-bg-hover)`}`,children:e},e))})}),(0,O.jsxs)(`label`,{className:`block text-xs`,children:[(0,O.jsx)(`span`,{className:`mb-1 block text-(--color-text-muted)`,children:`Name`}),(0,O.jsx)(`input`,{autoFocus:!0,className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1.5 text-sm`,value:i,onChange:e=>a(e.target.value),placeholder:`Scout`})]}),(0,O.jsxs)(`label`,{className:`block text-xs`,children:[(0,O.jsx)(`span`,{className:`mb-1 block text-(--color-text-muted)`,children:`Title`}),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1.5 text-sm`,value:o,onChange:e=>s(e.target.value),placeholder:`Research assistant`})]}),(0,O.jsxs)(`label`,{className:`block text-xs`,children:[(0,O.jsx)(`span`,{className:`mb-1 block text-(--color-text-muted)`,children:`Description`}),(0,O.jsx)(`textarea`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1.5 text-sm`,rows:3,value:c,onChange:e=>l(e.target.value),placeholder:`What should this bot do?`})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:`mb-1 block text-xs text-(--color-text-muted)`,children:`Model tier`}),(0,O.jsx)(`div`,{className:`inline-flex rounded border border-(--color-border) p-0.5`,children:Nc.map(e=>(0,O.jsx)(`button`,{type:`button`,onClick:()=>p(e),className:`rounded px-3 py-1 text-xs font-medium capitalize ${f===e?`bg-(--color-accent) text-(--color-accent-fg)`:`text-(--color-text-muted)`}`,children:e},e))})]}),(0,O.jsx)(`p`,{className:`rounded border border-(--color-amber)/40 bg-(--color-amber)/10 p-2 text-xs text-(--color-amber)`,children:`Bots share one computer, workspace, browser profile and logins. Bots are not a security boundary.`}),r&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:r})]}),(0,O.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:t,className:`rounded px-3 py-1.5 text-sm text-(--color-text-muted) hover:bg-(--color-bg-hover)`,children:`Cancel`}),(0,O.jsx)(`button`,{type:`button`,onClick:m,disabled:!i.trim()||n,className:`rounded bg-(--color-accent) px-3 py-1.5 text-sm font-medium text-(--color-accent-fg) disabled:opacity-40`,children:`Create bot`})]})]})})}var al={running:`text-(--color-blue)`,ok:`text-(--color-green)`,failed:`text-(--color-red)`,interrupted:`text-(--color-amber)`};function ol({botId:e,onCreated:t}){let[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(`0 9 * * *`),[o,s]=(0,_.useState)(Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(null);async function m(){if(!(!n.trim()||!i.trim()||!c.trim())){d(!0),p(null);try{t(await T.routines.create({botId:e,name:n,cronExpr:i,timezone:o,instructionMd:c})),r(``),l(``)}catch(e){p(e instanceof ie?e.message:`Failed to create routine`)}finally{d(!1)}}}return(0,O.jsxs)(`div`,{className:`space-y-2 rounded-md border border-(--color-border) p-3`,children:[(0,O.jsx)(`div`,{className:`text-xs font-semibold text-(--color-text-muted)`,children:`New routine`}),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,placeholder:`Name`,value:n,onChange:e=>r(e.target.value)}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(`input`,{className:`flex-1 rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 font-mono text-sm`,placeholder:`Cron expression (e.g. 0 9 * * *)`,value:i,onChange:e=>a(e.target.value)}),(0,O.jsx)(`input`,{className:`w-40 rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,placeholder:`Timezone`,value:o,onChange:e=>s(e.target.value)})]}),(0,O.jsx)(`textarea`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,placeholder:`Instructions for this run…`,rows:3,value:c,onChange:e=>l(e.target.value)}),f&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:f}),(0,O.jsx)(`button`,{type:`button`,disabled:u,onClick:m,className:`rounded bg-(--color-accent) px-3 py-1.5 text-sm font-medium text-(--color-accent-fg) disabled:opacity-40`,children:`Create routine`})]})}function sl({routine:e,onChanged:t,onDeleted:n}){let[r,i]=(0,_.useState)([]),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(!1);async function d(){let t=await T.routines.runs(e.id);i(t.slice(0,20))}async function f(){let e=!a;o(e),e&&await d()}async function p(){t(await T.routines.update(e.id,{enabled:!e.enabled}))}async function m(){window.confirm(`Delete routine "${e.name}"?`)&&(await T.routines.remove(e.id),n(e.id))}async function h(){u(!0),c(!1);try{await T.routines.testRun(e.id),await d(),o(!0)}finally{u(!1)}}return(0,O.jsxs)(`div`,{className:`rounded-md border border-(--color-border) p-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`text-sm font-medium`,children:e.name}),(0,O.jsxs)(`div`,{className:`font-mono text-xs text-(--color-text-muted)`,children:[e.cronExpr,` · `,e.timezone]}),e.nextRunAt&&(0,O.jsxs)(`div`,{className:`text-xs text-(--color-text-faint)`,children:[`Next run: `,new Date(e.nextRunAt).toLocaleString()]})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(`label`,{className:`flex items-center gap-1 text-xs text-(--color-text-muted)`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:p}),`Enabled`]}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>c(!0),disabled:l,className:`rounded border border-(--color-border) px-2 py-1 text-xs hover:bg-(--color-bg-hover)`,children:`Test run`}),(0,O.jsx)(`button`,{type:`button`,onClick:m,className:`rounded border border-(--color-red)/50 px-2 py-1 text-xs text-(--color-red)`,children:`Delete`})]})]}),s&&(0,O.jsxs)(`div`,{className:`mt-2 rounded border border-(--color-amber)/50 bg-(--color-amber)/10 p-2 text-xs`,children:[(0,O.jsx)(`p`,{className:`text-(--color-amber)`,children:`A test run performs real work — it can navigate websites, change files and call connected tools.`}),(0,O.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:h,className:`rounded bg-(--color-amber) px-2 py-1 font-medium text-(--color-bg)`,children:`Run anyway`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>c(!1),className:`rounded px-2 py-1 text-(--color-text-muted)`,children:`Cancel`})]})]}),(0,O.jsx)(`button`,{type:`button`,onClick:f,className:`mt-2 text-xs text-(--color-text-muted) hover:underline`,children:a?`Hide run history`:`Show run history`}),a&&(0,O.jsxs)(`ul`,{className:`mt-1 space-y-1`,children:[r.length===0&&(0,O.jsx)(`li`,{className:`text-xs text-(--color-text-faint)`,children:`No runs yet.`}),r.map(e=>(0,O.jsxs)(`li`,{className:`flex items-center gap-2 text-xs`,children:[(0,O.jsx)(`span`,{className:b(`font-medium`,al[e.status]),children:e.status}),(0,O.jsx)(`span`,{className:`text-(--color-text-faint)`,children:new Date(e.startedAt).toLocaleString()}),e.isTest&&(0,O.jsx)(`span`,{className:`rounded bg-(--color-border) px-1 text-[10px]`,children:`test`}),e.summary&&(0,O.jsx)(`span`,{className:`truncate text-(--color-text-muted)`,children:e.summary})]},e.id))]})]})}function cl({botId:e}){let[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(!0);return(0,_.useEffect)(()=>{let t=!1;return i(!0),T.routines.list(e).then(e=>{t||n(e)}).finally(()=>{t||i(!1)}),()=>{t=!0}},[e]),(0,O.jsxs)(`div`,{className:`space-y-3`,children:[(0,O.jsx)(ol,{botId:e,onCreated:e=>n(t=>[e,...t])}),r&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`Loading routines…`}),!r&&t.length===0&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No routines yet.`}),t.map(e=>(0,O.jsx)(sl,{routine:e,onChanged:e=>n(t=>t.map(t=>t.id===e.id?e:t)),onDeleted:e=>n(t=>t.filter(t=>t.id!==e))},e.id))]})}function ll({bot:e,onUpdated:t}){let[n,r]=(0,_.useState)(e.name),[i,a]=(0,_.useState)(e.title),[o,s]=(0,_.useState)(e.description),[c,l]=(0,_.useState)(e.avatarEmoji),[u,d]=(0,_.useState)(e.modelTier),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)(!1);async function y(){p(!0),h(null);try{t(await T.bots.update(e.id,{name:n,title:i,description:o,avatarEmoji:c,modelTier:u}))}catch(e){h(e instanceof ie?e.message:`Failed to save`)}finally{p(!1)}}return(0,O.jsxs)(`div`,{className:`space-y-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>v(e=>!e),className:`flex h-12 w-12 items-center justify-center rounded-lg border border-(--color-border) text-2xl hover:bg-(--color-bg-hover)`,children:c}),(0,O.jsx)(`div`,{className:`flex-1`,children:(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1.5 text-sm font-medium`,value:n,onChange:e=>r(e.target.value),"aria-label":`Name`})})]}),g&&(0,O.jsx)(`div`,{className:`grid grid-cols-10 gap-1 rounded border border-(--color-border) p-2`,children:rl.map(e=>(0,O.jsx)(`button`,{type:`button`,onClick:()=>{l(e),v(!1)},className:`rounded p-1 text-lg hover:bg-(--color-bg-hover)`,children:e},e))}),(0,O.jsxs)(`label`,{className:`block text-xs`,children:[(0,O.jsx)(`span`,{className:`mb-1 block text-(--color-text-muted)`,children:`Title`}),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1.5 text-sm`,value:i,onChange:e=>a(e.target.value)})]}),(0,O.jsxs)(`label`,{className:`block text-xs`,children:[(0,O.jsx)(`span`,{className:`mb-1 block text-(--color-text-muted)`,children:`Description / persona`}),(0,O.jsx)(`textarea`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1.5 text-sm`,rows:4,value:o,onChange:e=>s(e.target.value)})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:`mb-1 block text-xs text-(--color-text-muted)`,children:`Model tier`}),(0,O.jsx)(`div`,{className:`inline-flex rounded border border-(--color-border) p-0.5`,children:Nc.map(e=>(0,O.jsx)(`button`,{type:`button`,onClick:()=>d(e),className:`rounded px-3 py-1 text-xs font-medium capitalize ${u===e?`bg-(--color-accent) text-(--color-accent-fg)`:`text-(--color-text-muted)`}`,children:e},e))})]}),m&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:m}),(0,O.jsx)(`button`,{type:`button`,onClick:y,disabled:f,className:`rounded bg-(--color-accent) px-3 py-1.5 text-sm font-medium text-(--color-accent-fg) disabled:opacity-40`,children:`Save profile`})]})}function ul({botId:e}){let[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``);(0,_.useEffect)(()=>{T.bots.memory.list(e).then(n)},[e]);function l(e){i(e),o(t.find(t=>t.name===e)?.content??``)}async function u(){let t=r??s.trim();t&&(await T.bots.memory.save(e,t,a),n(e=>{let n=e.findIndex(e=>e.name===t);return n===-1?[...e,{name:t,content:a}]:e.map((e,r)=>r===n?{name:t,content:a}:e)}),i(t),c(``))}async function d(t){await T.bots.memory.remove(e,t),n(e=>e.filter(e=>e.name!==t)),r===t&&(i(null),o(``))}return(0,O.jsxs)(`div`,{className:`grid grid-cols-[160px_1fr] gap-3`,children:[(0,O.jsxs)(`div`,{className:`space-y-1`,children:[t.map(e=>(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>l(e.name),className:`flex-1 truncate rounded px-2 py-1 text-left text-xs ${r===e.name?`bg-(--color-accent)/15`:`hover:bg-(--color-bg-hover)`}`,children:e.name}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>d(e.name),"aria-label":`Delete ${e.name}`,className:`text-xs text-(--color-text-faint) hover:text-(--color-red)`,children:`×`})]},e.name)),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-xs`,placeholder:`new-file.md`,value:s,onChange:e=>{c(e.target.value),i(null),o(``)}})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`textarea`,{className:`h-40 w-full rounded border border-(--color-border) bg-(--color-bg) p-2 font-mono text-xs`,value:a,onChange:e=>o(e.target.value),placeholder:`Durable facts this bot should remember…`}),(0,O.jsx)(`button`,{type:`button`,onClick:u,className:`mt-2 rounded bg-(--color-accent) px-3 py-1.5 text-xs font-medium text-(--color-accent-fg)`,children:`Save memory file`})]})]})}function dl({skill:e,checked:t,onToggle:n}){let[r,i]=(0,_.useState)(!1),a=`skill-${e.id}`;return(0,O.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[(0,O.jsx)(`input`,{id:a,type:`checkbox`,className:`mt-1 shrink-0`,checked:t,onChange:n}),(0,O.jsx)(`label`,{htmlFor:a,className:`shrink-0 cursor-pointer whitespace-nowrap font-medium`,children:e.name}),e.description&&(0,O.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),"aria-expanded":r,title:r?`Collapse description`:`Show the full description`,className:`min-w-0 flex-1 cursor-pointer text-left text-xs text-(--color-text-muted) hover:text-(--color-text) ${r?`whitespace-pre-wrap break-words`:`truncate`}`,children:[`— `,e.description]})]})}function fl({botId:e}){let[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(null);(0,_.useEffect)(()=>{T.connectors.list().then(n)},[]),(0,_.useEffect)(()=>{T.bots.connectors.get(e).then(e=>i(new Set(e.map(e=>e.id))))},[e]);async function s(t){if(!r)return;let n=new Set(r);n.has(t)?n.delete(t):n.add(t),i(n),o(null);try{await T.bots.connectors.set(e,Array.from(n))}catch(e){i(r),o(e instanceof ie?e.message:`Could not save`)}}return t.length===0?(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No connectors yet. Add one on the Connectors screen.`}):(0,O.jsxs)(`div`,{className:`space-y-2`,children:[t.map(e=>(0,O.jsxs)(`label`,{className:`flex items-start gap-2 text-xs`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:r?.has(e.id)??!1,disabled:!r,onChange:()=>s(e.id),className:`mt-0.5`}),(0,O.jsxs)(`span`,{className:`min-w-0`,children:[(0,O.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,O.jsx)(`span`,{className:`ml-1 text-(--color-text-muted)`,children:e.kind===`builtin`?`built-in`:String(e.config.transport)}),!e.enabled&&(0,O.jsx)(`span`,{className:`ml-1 text-(--color-text-muted)`,children:`(disabled)`}),e.missingSecrets.length>0&&(0,O.jsxs)(`span`,{className:`ml-1 text-(--color-amber)`,children:[`missing secret: `,e.missingSecrets.join(`, `)]}),e.lastStatus===`needs-sign-in`&&(0,O.jsx)(`span`,{className:`ml-1 text-(--color-amber)`,children:`needs sign-in`}),e.description&&(0,O.jsx)(`span`,{className:`block truncate text-(--color-text-muted)`,title:e.description,children:e.description})]})]},e.id)),a&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:a})]})}function pl({botId:e}){let[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(new Set),[a,o]=(0,_.useState)(!1);(0,_.useEffect)(()=>{T.skills.list().then(n)},[]),(0,_.useEffect)(()=>{T.bots.skills.get(e).then(e=>i(new Set(e.map(e=>e.id))))},[e]);function s(e){i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),o(!1)}async function c(){await T.bots.skills.set(e,Array.from(r)),o(!0)}return t.length===0?(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No skills taught yet.`}):(0,O.jsxs)(`div`,{className:`space-y-2`,children:[t.map(e=>(0,O.jsx)(dl,{skill:e,checked:r.has(e.id),onToggle:()=>s(e.id)},e.id)),(0,O.jsx)(`button`,{type:`button`,onClick:c,className:`rounded bg-(--color-accent) px-3 py-1.5 text-xs font-medium text-(--color-accent-fg)`,children:`Save skills`}),a&&(0,O.jsx)(`span`,{className:`ml-2 text-xs text-(--color-green)`,children:`Saved`})]})}function ml({bot:e,onClose:t,onUpdated:n,onDuplicated:r,onDeleted:i}){let[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(null);async function d(){n(await T.bots.update(e.id,{pinned:!e.pinned}))}async function f(){n(await T.bots.update(e.id,{hidden:!e.hidden}))}async function p(){n(await T.bots.update(e.id,{notifications:!e.notifications}))}async function m(){r(await T.bots.duplicate(e.id))}async function h(){await T.bots.remove(e.id),i(e.id)}return(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto p-5`,children:[(0,O.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,O.jsxs)(`h2`,{className:`text-lg font-semibold`,children:[e.name,` settings`]}),(0,O.jsx)(`button`,{type:`button`,onClick:t,className:`text-sm text-(--color-text-muted) hover:text-(--color-text)`,children:`Close`})]}),(0,O.jsx)(`section`,{className:`mb-6`,children:(0,O.jsx)(ll,{bot:e,onUpdated:n})}),(0,O.jsxs)(`section`,{className:`mb-6 flex flex-wrap gap-2 border-t border-(--color-border) pt-4`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:d,className:`rounded border border-(--color-border) px-3 py-1.5 text-xs hover:bg-(--color-bg-hover)`,children:e.pinned?`Unpin`:`Pin`}),(0,O.jsx)(`button`,{type:`button`,onClick:f,className:`rounded border border-(--color-border) px-3 py-1.5 text-xs hover:bg-(--color-bg-hover)`,children:e.hidden?`Unhide`:`Hide`}),(0,O.jsx)(`button`,{type:`button`,onClick:p,className:`rounded border border-(--color-border) px-3 py-1.5 text-xs hover:bg-(--color-bg-hover)`,children:e.notifications?`Mute notifications`:`Unmute notifications`}),(0,O.jsx)(`button`,{type:`button`,onClick:m,className:`rounded border border-(--color-border) px-3 py-1.5 text-xs hover:bg-(--color-bg-hover)`,children:`Duplicate`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>c(!0),className:`rounded border border-(--color-border) px-3 py-1.5 text-xs hover:bg-(--color-bg-hover)`,children:`Start fresh`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`rounded border border-(--color-red)/50 px-3 py-1.5 text-xs text-(--color-red) hover:bg-(--color-red)/10`,children:`Delete`})]}),s&&(0,O.jsxs)(`div`,{className:`mb-6 rounded border border-(--color-border) bg-(--color-bg-elevated) p-3 text-sm`,children:[(0,O.jsx)(`p`,{className:`mb-1`,children:`Clear this conversation and start a fresh session?`}),(0,O.jsx)(`p`,{className:`mb-2 text-xs text-(--color-text-muted)`,children:`Deletes the messages in this thread and drops the model’s accumulated context. Keeps the Bot’s description, memory, skills, connectors, routines and files.`}),l&&(0,O.jsx)(`p`,{className:`mb-2 text-xs text-(--color-red)`,children:l}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:async()=>{u(null);try{await T.bots.reset(e.id),c(!1),n(e)}catch(e){u(e instanceof ie?e.message:`Could not start fresh`)}},className:`rounded bg-(--color-accent) px-3 py-1.5 text-xs font-medium text-(--color-accent-fg)`,children:`Start fresh`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>{c(!1),u(null)},className:`rounded border border-(--color-border) px-3 py-1.5 text-xs`,children:`Cancel`})]})]}),a&&(0,O.jsxs)(`div`,{className:`mb-6 rounded border border-(--color-red)/50 bg-(--color-red)/10 p-3 text-sm`,children:[(0,O.jsxs)(`p`,{className:`text-(--color-red)`,children:[`Delete `,e.name,`? This removes it from your roster and conversation history, but its workspace files and any browser logins it used survive deletion.`]}),(0,O.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:h,className:`rounded bg-(--color-red) px-3 py-1.5 text-xs font-medium text-white`,children:`Delete permanently`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`rounded px-3 py-1.5 text-xs text-(--color-text-muted)`,children:`Cancel`})]})]}),(0,O.jsxs)(`section`,{className:`mb-6 border-t border-(--color-border) pt-4`,children:[(0,O.jsx)(`h3`,{className:`mb-2 text-sm font-semibold`,children:`Memory`}),(0,O.jsx)(ul,{botId:e.id})]}),(0,O.jsxs)(`section`,{className:`mb-6 border-t border-(--color-border) pt-4`,children:[(0,O.jsx)(`h3`,{className:`mb-2 text-sm font-semibold`,children:`Skills`}),(0,O.jsx)(pl,{botId:e.id})]}),(0,O.jsxs)(`section`,{className:`mb-6 border-t border-(--color-border) pt-4`,children:[(0,O.jsx)(`h3`,{className:`mb-2 text-sm font-semibold`,children:`Connectors`}),(0,O.jsx)(fl,{botId:e.id})]}),(0,O.jsxs)(`section`,{className:`border-t border-(--color-border) pt-4`,children:[(0,O.jsx)(`h3`,{className:`mb-2 text-sm font-semibold`,children:`Routines`}),(0,O.jsx)(cl,{botId:e.id})]})]})}function hl({kind:e}){return(0,O.jsx)(`span`,{className:b(`rounded px-1.5 py-0.5 text-[11px] font-semibold uppercase tracking-wide`,e===`require`?`bg-(--color-red)/15 text-(--color-red)`:`bg-(--color-green)/15 text-(--color-green)`),children:e===`require`?`Require approval`:`Always allow`})}function gl({onCreated:e}){let[t,n]=(0,_.useState)(`require`),[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(null);async function d(){if(r.trim())try{e(await T.rules.create({kind:t,toolPattern:r.trim(),inputPattern:a,scopeNote:s})),i(``),o(``),c(``),u(null)}catch(e){u(e instanceof ie?e.message:`Failed to create rule`)}}return(0,O.jsxs)(`div`,{className:`mb-4 space-y-2 rounded-md border border-(--color-border) p-3`,children:[(0,O.jsx)(`div`,{className:`flex gap-2`,children:[`require`,`allow`].map(e=>(0,O.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:b(`rounded px-3 py-1 text-xs font-medium`,t===e?`bg-(--color-accent) text-(--color-accent-fg)`:`border border-(--color-border) text-(--color-text-muted)`),children:e===`require`?`Require approval`:`Always allow`},e))}),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 font-mono text-sm`,placeholder:`Tool pattern (e.g. Bash, browser_*, *)`,value:r,onChange:e=>i(e.target.value)}),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 font-mono text-sm`,placeholder:`Input pattern (optional regex)`,value:a,onChange:e=>o(e.target.value)}),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,placeholder:`Scope note (why this rule exists)`,value:s,onChange:e=>c(e.target.value)}),l&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:l}),(0,O.jsx)(`button`,{type:`button`,onClick:d,className:`rounded bg-(--color-accent) px-3 py-1.5 text-sm font-medium text-(--color-accent-fg)`,children:`Add rule`})]})}function _l(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)(!0);(0,_.useEffect)(()=>{T.rules.list().then(t).finally(()=>r(!1))},[]);async function i(e){let n=await T.rules.update(e.id,!e.enabled);t(e=>e.map(e=>e.id===n.id?n:e))}async function a(e){e.builtin||window.confirm(`Delete rule for "${e.toolPattern}"?`)&&(await T.rules.remove(e.id),t(t=>t.filter(t=>t.id!==e.id)))}return(0,O.jsxs)(`div`,{className:`mx-auto max-w-3xl p-6`,children:[(0,O.jsx)(`h1`,{className:`mb-1 text-lg font-semibold`,children:`Rules`}),(0,O.jsx)(`p`,{className:`mb-4 text-sm text-(--color-text-muted)`,children:`Require Approval always wins over Always Allow.`}),(0,O.jsx)(gl,{onCreated:e=>t(t=>[e,...t])}),n&&(0,O.jsx)(`p`,{className:`text-sm text-(--color-text-muted)`,children:`Loading…`}),!n&&e.length===0&&(0,O.jsx)(`p`,{className:`text-sm text-(--color-text-muted)`,children:`No rules yet.`}),(0,O.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-(--color-border) p-3`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(hl,{kind:e.kind}),e.builtin&&(0,O.jsx)(`span`,{title:`Built-in rule`,"aria-label":`Built-in rule`,className:`text-(--color-text-faint)`,children:`🔒`}),(0,O.jsx)(`span`,{className:`truncate font-mono text-sm`,children:e.toolPattern})]}),e.inputPattern&&(0,O.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-xs text-(--color-text-muted)`,children:e.inputPattern}),e.scopeNote&&(0,O.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-(--color-text-faint)`,children:e.scopeNote})]}),(0,O.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,O.jsxs)(`label`,{className:`flex items-center gap-1 text-xs text-(--color-text-muted)`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:()=>i(e)}),`Enabled`]}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>a(e),disabled:e.builtin,className:`rounded border border-(--color-red)/50 px-2 py-1 text-xs text-(--color-red) disabled:cursor-not-allowed disabled:opacity-30`,children:`Delete`})]})]},e.id))})]})}function vl({label:e,value:t,max:n,sublabel:r}){let i=n>0?Math.max(2,Math.round(t/n*100)):0;return(0,O.jsxs)(`div`,{className:`mb-2`,children:[(0,O.jsxs)(`div`,{className:`mb-0.5 flex items-baseline justify-between text-xs`,children:[(0,O.jsx)(`span`,{className:`font-medium`,children:e}),(0,O.jsx)(`span`,{className:`text-(--color-text-muted)`,children:r??t.toLocaleString()})]}),(0,O.jsx)(`div`,{className:`h-2 rounded bg-(--color-bg)`,children:(0,O.jsx)(`div`,{className:`h-2 rounded bg-(--color-accent)`,style:{width:`${i}%`}})})]})}function yl(){let[e,t]=(0,_.useState)(null);if((0,_.useEffect)(()=>{T.usage().then(t)},[]),!e)return(0,O.jsx)(`p`,{className:`p-6 text-sm text-(--color-text-muted)`,children:`Loading usage…`});let n=e.totals.inputTokens+e.totals.outputTokens,r=Math.max(1,...e.byBot.map(e=>e.inputTokens+e.outputTokens)),i=Math.max(1,...e.byDay.map(e=>e.inputTokens+e.outputTokens)),a=Math.max(1,...e.byModel.map(e=>e.inputTokens+e.outputTokens));return(0,O.jsxs)(`div`,{className:`mx-auto max-w-3xl p-6`,children:[(0,O.jsx)(`h1`,{className:`mb-4 text-lg font-semibold`,children:`Usage`}),(0,O.jsxs)(`section`,{className:`mb-6 grid grid-cols-3 gap-3`,children:[(0,O.jsxs)(`div`,{className:`rounded-md border border-(--color-border) p-3`,children:[(0,O.jsx)(`div`,{className:`text-xs text-(--color-text-muted)`,children:`Input tokens`}),(0,O.jsx)(`div`,{className:`text-xl font-semibold`,children:e.totals.inputTokens.toLocaleString()})]}),(0,O.jsxs)(`div`,{className:`rounded-md border border-(--color-border) p-3`,children:[(0,O.jsx)(`div`,{className:`text-xs text-(--color-text-muted)`,children:`Output tokens`}),(0,O.jsx)(`div`,{className:`text-xl font-semibold`,children:e.totals.outputTokens.toLocaleString()})]}),(0,O.jsxs)(`div`,{className:`rounded-md border border-(--color-border) p-3`,children:[(0,O.jsx)(`div`,{className:`text-xs text-(--color-text-muted)`,children:`Cache-read tokens`}),(0,O.jsx)(`div`,{className:`text-xl font-semibold`,children:e.totals.cacheReadTokens.toLocaleString()})]})]}),(0,O.jsxs)(`section`,{className:`mb-6`,children:[(0,O.jsx)(`h2`,{className:`mb-2 text-sm font-semibold`,children:`By bot`}),e.byBot.length===0&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No usage yet.`}),e.byBot.map(e=>(0,O.jsx)(vl,{label:e.botName,value:e.inputTokens+e.outputTokens,max:r},e.botId))]}),(0,O.jsxs)(`section`,{className:`mb-6`,children:[(0,O.jsx)(`h2`,{className:`mb-2 text-sm font-semibold`,children:`By day`}),(0,O.jsx)(`div`,{className:`flex items-end gap-1`,style:{height:96},children:e.byDay.map(e=>{let t=e.inputTokens+e.outputTokens,n=Math.max(2,Math.round(t/i*88));return(0,O.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-end`,title:`${e.day}: ${t.toLocaleString()} tokens`,children:[(0,O.jsx)(`div`,{className:`w-full rounded-t bg-(--color-accent)`,style:{height:n}}),(0,O.jsx)(`span`,{className:`mt-1 rotate-0 text-[9px] text-(--color-text-faint)`,children:e.day.slice(5)})]},e.day)})}),e.byDay.length===0&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No usage yet.`})]}),(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h2`,{className:`mb-2 text-sm font-semibold`,children:`By model`}),e.byModel.length===0&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No usage yet.`}),e.byModel.map(e=>(0,O.jsx)(vl,{label:e.model,value:e.inputTokens+e.outputTokens,max:a,sublabel:n>0?`${Math.round((e.inputTokens+e.outputTokens)/n*100)}%`:`0%`},e.model))]})]})}var bl=`rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`;function xl(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(!1);(0,_.useEffect)(()=>{T.secrets.list().then(e=>{t(e.names),r(e.backend)}).catch(()=>d(!0))},[]);async function f(){l(null);try{let e=await T.secrets.set(i.trim(),o);t(e.names),a(``),s(``)}catch(e){l(e instanceof ie?e.message:`Could not store the secret`)}}async function p(e){l(null);try{let n=await T.secrets.remove(e);t(n.names)}catch(e){l(e instanceof ie?e.message:`Could not remove the secret`)}}return u?(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No secrets backend is available on this machine.`}):(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsxs)(`p`,{className:`text-xs text-(--color-text-muted)`,children:[`Stored in your `,n===`file`?`ant-bot data directory`:n??`keychain`,`. Names only are ever shown; a value cannot be read back, by you or by a bot.`]}),e.length===0?(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No secrets stored.`}):(0,O.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>(0,O.jsxs)(`li`,{className:`flex items-center gap-2 text-sm`,children:[(0,O.jsx)(`code`,{className:`flex-1 truncate`,children:e}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>p(e),className:`rounded border border-(--color-border) px-2 py-0.5 text-xs text-(--color-red)`,children:`Remove`})]},e))}),(0,O.jsxs)(`div`,{className:`flex gap-1`,children:[(0,O.jsx)(`input`,{className:`${bl} w-2/5`,placeholder:`NAME`,value:i,onChange:e=>a(e.target.value)}),(0,O.jsx)(`input`,{type:`password`,className:`${bl} flex-1`,placeholder:`value`,value:o,onChange:e=>s(e.target.value)}),(0,O.jsx)(`button`,{type:`button`,onClick:f,disabled:!i.trim()||!o,className:`rounded border border-(--color-border) px-2 py-1 text-xs disabled:opacity-40`,children:`Store`})]}),c&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:c})]})}function Sl({label:e,children:t}){return(0,O.jsxs)(`label`,{className:`mb-3 flex items-center justify-between gap-4 border-b border-(--color-border) py-2 text-sm`,children:[(0,O.jsx)(`span`,{className:`text-(--color-text-muted)`,children:e}),t]})}function Cl({onSettingsChange:e}){let[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!1);(0,_.useEffect)(()=>{T.settings.get().then(t=>{n(t),e?.(t)})},[]);async function a(r){if(!t)return;let a={...t,...r};n(a),i(!0);try{let t=await T.settings.update(r);n(t),e?.(t)}finally{i(!1)}}return t?(0,O.jsxs)(`div`,{className:`mx-auto max-w-xl p-6`,children:[(0,O.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,O.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Settings`}),r&&(0,O.jsx)(`span`,{className:`text-xs text-(--color-text-muted)`,children:`Saving…`})]}),(0,O.jsx)(Sl,{label:`Timezone`,children:(0,O.jsx)(`input`,{className:`w-48 rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.timezone,onChange:e=>a({timezone:e.target.value})})}),(0,O.jsx)(Sl,{label:`Max concurrent sessions`,children:(0,O.jsx)(`input`,{type:`number`,min:1,max:8,className:`w-20 rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.maxConcurrentSessions,onChange:e=>a({maxConcurrentSessions:Math.min(8,Math.max(1,Number(e.target.value)||1))})})}),(0,O.jsx)(Sl,{label:`Auto-review (Haiku triage of tool calls)`,children:(0,O.jsx)(`input`,{type:`checkbox`,checked:t.autoReviewEnabled,onChange:e=>a({autoReviewEnabled:e.target.checked})})}),(0,O.jsx)(Sl,{label:`Theme`,children:(0,O.jsxs)(`select`,{className:`rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.theme,onChange:e=>a({theme:e.target.value}),children:[(0,O.jsx)(`option`,{value:`system`,children:`System`}),(0,O.jsx)(`option`,{value:`light`,children:`Light`}),(0,O.jsx)(`option`,{value:`dark`,children:`Dark`})]})}),(0,O.jsx)(Sl,{label:`Local execution (run commands on this machine)`,children:(0,O.jsxs)(`select`,{className:`rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.localExecution,onChange:e=>a({localExecution:e.target.value}),children:[(0,O.jsx)(`option`,{value:`ask`,children:`Ask`}),(0,O.jsx)(`option`,{value:`always`,children:`Always`}),(0,O.jsx)(`option`,{value:`never`,children:`Never`})]})}),(0,O.jsx)(Sl,{label:`Daily token budget (0 = unlimited)`,children:(0,O.jsx)(`input`,{type:`number`,min:0,className:`w-32 rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.dailyTokenBudget,onChange:e=>a({dailyTokenBudget:Math.max(0,Number(e.target.value)||0)})})}),(0,O.jsx)(Sl,{label:`Desktop notifications`,children:(0,O.jsx)(`input`,{type:`checkbox`,checked:t.notificationsEnabled,onChange:e=>a({notificationsEnabled:e.target.checked})})}),(0,O.jsx)(Sl,{label:`Billing mode`,children:(0,O.jsxs)(`select`,{className:`rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.billingMode,onChange:e=>a({billingMode:e.target.value}),children:[(0,O.jsx)(`option`,{value:`subscription`,children:`Subscription`}),(0,O.jsx)(`option`,{value:`api`,children:`API (metered)`})]})}),(0,O.jsx)(Sl,{label:`Computer mode`,children:(0,O.jsxs)(`select`,{className:`rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.computerMode,onChange:e=>a({computerMode:e.target.value}),children:[(0,O.jsx)(`option`,{value:`host`,children:`Host`}),(0,O.jsx)(`option`,{value:`container`,children:`Container`})]})}),(0,O.jsx)(`h2`,{className:`mt-8 mb-2 text-sm font-semibold`,children:`Secrets`}),(0,O.jsx)(xl,{})]}):(0,O.jsx)(`p`,{className:`p-6 text-sm text-(--color-text-muted)`,children:`Loading settings…`})}var wl=/\.(png|jpe?g|gif|webp|svg|bmp)$/i,Tl=/\.(md|markdown|txt|json|ya?ml|csv|log|ts|tsx|js|jsx|py|sh|css|html)$/i;function El(e){return e.startsWith(`.`)}function Dl({entry:e,depth:t,showHidden:n,onOpenFile:r}){let[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(!1);async function u(){if(!e.dir){r(e.path);return}if(!i&&o===null){l(!0);let t=await T.workspace.tree(e.path);s(t),l(!1)}a(e=>!e)}return(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`button`,{type:`button`,onClick:u,className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-left text-sm hover:bg-(--color-bg-hover)`,style:{paddingLeft:`${t*14+6}px`},children:[(0,O.jsx)(`span`,{className:`w-3 shrink-0 text-(--color-text-faint)`,children:e.dir?i?`▾`:`▸`:``}),(0,O.jsx)(`span`,{className:`shrink-0`,children:e.dir?`📁`:`📄`}),(0,O.jsx)(`span`,{className:`truncate`,children:e.name}),!e.dir&&(0,O.jsxs)(`span`,{className:`ml-auto shrink-0 text-xs text-(--color-text-faint)`,children:[e.bytes,`B`]})]}),i&&(0,O.jsxs)(`div`,{children:[c&&(0,O.jsx)(`div`,{style:{paddingLeft:`${(t+1)*14+6}px`},className:`py-1 text-xs text-(--color-text-faint)`,children:`Loading…`}),o?.filter(e=>n||!El(e.name)).map(e=>(0,O.jsx)(Dl,{entry:e,depth:t+1,showHidden:n,onOpenFile:r},e.path))]})]})}function Ol({path:e,onClose:t}){let[n,r]=(0,_.useState)(null),i=e.split(`/`).pop()??e,a=wl.test(i),o=Tl.test(i);return(0,_.useEffect)(()=>{r(null),o&&fetch(T.workspace.fileUrl(e)).then(e=>e.text()).then(r).catch(()=>r(`(failed to load preview)`))},[e,o]),(0,O.jsxs)(`div`,{className:`flex h-full flex-col border-l border-(--color-border)`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between border-b border-(--color-border) p-2`,children:[(0,O.jsx)(`span`,{className:`truncate text-sm font-medium`,children:i}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`a`,{href:T.workspace.fileUrl(e),download:i,className:`text-xs text-(--color-accent) hover:underline`,children:`Download`}),(0,O.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs text-(--color-text-muted) hover:text-(--color-text)`,children:`Close`})]})]}),(0,O.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-2`,children:[a&&(0,O.jsx)(`img`,{src:T.workspace.fileUrl(e),alt:i,className:`max-w-full`}),o&&(0,O.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs`,children:n??`Loading…`}),!a&&!o&&(0,O.jsx)(`p`,{className:`text-sm text-(--color-text-muted)`,children:`No inline preview available — use Download.`})]})]})}function kl(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(!0);return(0,_.useEffect)(()=>{T.workspace.tree(``).then(t).finally(()=>s(!1))},[]),(0,O.jsxs)(`div`,{className:`flex h-full`,children:[(0,O.jsxs)(`div`,{className:`flex w-80 shrink-0 flex-col border-r border-(--color-border)`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between border-b border-(--color-border) p-2`,children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Workspace`}),(0,O.jsxs)(`label`,{className:`flex items-center gap-1 text-xs text-(--color-text-muted)`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>r(e.target.checked)}),`Hidden files`]})]}),(0,O.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-1`,children:[o&&(0,O.jsx)(`p`,{className:`p-2 text-xs text-(--color-text-muted)`,children:`Loading…`}),!o&&e.length===0&&(0,O.jsx)(`p`,{className:`p-2 text-xs text-(--color-text-muted)`,children:`Workspace is empty.`}),e.filter(e=>n||!El(e.name)).map(e=>(0,O.jsx)(Dl,{entry:e,depth:0,showHidden:n,onOpenFile:a},e.path))]})]}),i&&(0,O.jsx)(`div`,{className:`w-96 shrink-0`,children:(0,O.jsx)(Ol,{path:i,onClose:()=>a(null)})})]})}function Al(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(null),u=(0,_.useRef)(null),d=(0,_.useRef)(null),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(null);(0,_.useEffect)(()=>{T.computer.status().then(e=>{t(e),e.pages.length>0&&r(e.pages[0].botId)})},[]);async function g(e){if(!e){h(`Nothing is selected on the remote page.`);return}try{await navigator.clipboard.writeText(e),h(`Copied ${e.length.toLocaleString()} character${e.length===1?``:`s`} from the page.`)}catch{h(`The browser refused clipboard access, so the selection was not copied.`)}}(0,_.useEffect)(()=>{if(a(null),u.current?.close(),!n||!e?.available)return;let t=window.location.protocol===`https:`?`wss`:`ws`,r=new WebSocket(`${t}://${window.location.host}/api/computer/screencast/${n}`);return u.current=r,r.onmessage=e=>{try{let t=JSON.parse(e.data);t.type===`frame`?a({data:t.data,w:t.w,h:t.h}):t.type===`selection`?g(t.text??``):t.type===`input-error`&&h(t.message??`Input was rejected.`)}catch{}},()=>r.close()},[n,e?.available]),(0,_.useEffect)(()=>{if(!m)return;let e=setTimeout(()=>h(null),4e3);return()=>clearTimeout(e)},[m]),(0,_.useEffect)(()=>{o&&d.current?.focus()},[o]);async function v(){if(!n)return;let e=await T.computer.takeover(n);s(e.ok),l(e.message??null)}async function y(){n&&(await T.computer.returnControl(n),s(!1),l(null))}function b(e){let t=u.current;if(!(!o||!t||t.readyState!==WebSocket.OPEN))try{t.send(JSON.stringify(e))}catch{}}function x(e){b({type:`input`,input:e})}function ee(e){let t=e.currentTarget.getBoundingClientRect();return t.width<=0||t.height<=0?null:{x:(e.clientX-t.left)/t.width,y:(e.clientY-t.top)/t.height}}let te=[`left`,`middle`,`right`];return e?e.available?(0,O.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-(--color-border) p-3`,children:[(0,O.jsxs)(`select`,{className:`rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:n??``,onChange:e=>r(e.target.value||null),children:[e.pages.length===0&&(0,O.jsx)(`option`,{value:``,children:`No active pages`}),e.pages.map(e=>(0,O.jsx)(`option`,{value:e.botId,children:e.title||e.url},e.botId))]}),(0,O.jsx)(`div`,{className:`flex items-center gap-2`,children:o?(0,O.jsx)(`button`,{type:`button`,onClick:y,className:`rounded bg-(--color-accent) px-3 py-1.5 text-xs font-medium text-(--color-accent-fg)`,children:`Return control`}):(0,O.jsx)(`button`,{type:`button`,onClick:v,disabled:!n,className:`rounded border border-(--color-border) px-3 py-1.5 text-xs font-medium hover:bg-(--color-bg-hover) disabled:opacity-40`,children:`Take over`})})]}),(0,O.jsx)(`p`,{className:`border-b border-(--color-border) bg-(--color-amber)/10 px-3 py-2 text-xs text-(--color-amber)`,children:`Never paste passwords or one-time codes into chat — use takeover.`}),c&&(0,O.jsx)(`p`,{className:`border-b border-(--color-border) bg-(--color-bg-elevated) px-3 py-2 text-xs text-(--color-text-muted)`,children:c}),(0,O.jsx)(`div`,{ref:d,tabIndex:o?0:-1,onFocus:()=>p(!0),onBlur:()=>p(!1),onKeyDown:e=>{if(o&&!((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`v`)){if((e.ctrlKey||e.metaKey)&&(e.key.toLowerCase()===`c`||e.key.toLowerCase()===`x`)){e.preventDefault(),b({type:`selection-request`}),e.key.toLowerCase()===`x`&&x({kind:`key`,action:`down`,key:e.key});return}e.preventDefault(),e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey?x({kind:`text`,text:e.key}):x({kind:`key`,action:`down`,key:e.key})}},onKeyUp:e=>{o&&((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`v`||(e.preventDefault(),e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey||x({kind:`key`,action:`up`,key:e.key})))},onPaste:e=>{if(!o)return;e.preventDefault();let t=e.clipboardData.getData(`text`);t&&x({kind:`text`,text:t.slice(0,4096)})},className:`flex min-h-0 flex-1 items-center justify-center overflow-auto bg-black/20 p-3 outline-none ${o&&!f?`ring-2 ring-(--color-amber) ring-inset`:``}`,children:i?(0,O.jsx)(`img`,{src:`data:image/jpeg;base64,${i.data}`,width:i.w,height:i.h,alt:`Agent computer screencast`,draggable:!1,onPointerMove:e=>{let t=ee(e);t&&x({kind:`mouse`,action:`move`,...t,button:`left`,clickCount:1,deltaX:0,deltaY:0})},onPointerDown:e=>{let t=ee(e);t&&(d.current?.focus(),x({kind:`mouse`,action:`down`,...t,button:te[e.button]??`left`,clickCount:e.detail||1,deltaX:0,deltaY:0}))},onPointerUp:e=>{let t=ee(e);t&&x({kind:`mouse`,action:`up`,...t,button:te[e.button]??`left`,clickCount:e.detail||1,deltaX:0,deltaY:0})},onWheel:e=>{let t=ee(e);t&&x({kind:`mouse`,action:`wheel`,...t,button:`left`,clickCount:1,deltaX:e.deltaX,deltaY:e.deltaY})},onContextMenu:e=>{o&&e.preventDefault()},className:`max-h-full max-w-full rounded border border-(--color-border) ${o?`cursor-crosshair`:`pointer-events-none select-none`}`}):(0,O.jsx)(`p`,{className:`text-sm text-(--color-text-muted)`,children:`Waiting for a screencast frame…`})}),o&&!f&&(0,O.jsx)(`p`,{className:`border-t border-(--color-border) bg-(--color-amber)/10 px-3 py-2 text-xs text-(--color-amber)`,children:`Click the screen to send keystrokes to it.`}),m&&(0,O.jsx)(`p`,{className:`border-t border-(--color-border) bg-(--color-bg-elevated) px-3 py-2 text-xs text-(--color-text-muted)`,children:m})]}):(0,O.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 p-6 text-center`,children:[(0,O.jsx)(`p`,{className:`text-sm font-medium`,children:`The agent computer isn't available right now.`}),(0,O.jsx)(`p`,{className:`max-w-sm text-xs text-(--color-text-muted)`,children:`Bots can still browse the web and use tools — you just won't see a live screencast until the computer service starts.`})]}):(0,O.jsx)(`p`,{className:`p-6 text-sm text-(--color-text-muted)`,children:`Checking the computer service…`})}var jl=`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-xs`,Ml=`mb-1 block text-xs text-(--color-text-muted)`,Nl=`rounded border border-(--color-border) px-2 py-1 text-xs disabled:opacity-40`,Pl=0,Fl=()=>({id:Pl++,k:``,v:``,secret:!1}),Il=(e,t)=>`mcp/${e}/${t}`;function Ll(e){let t=(e.match(/"[^"]*"|'[^']*'|\S+/g)??[]).map(e=>/^["'].*["']$/.test(e)?e.slice(1,-1):e);return{command:t[0]??``,args:t.slice(1)}}var Rl=e=>/^https?:\/\//i.test(e.trim());function K(e){let t=e.trim();if(!t)return``;let n;if(Rl(t))try{n=new URL(t).hostname.replace(/^(mcp|www|api)\./,``).split(`.`)[0]??``}catch{n=``}else{let{command:e,args:r}=Ll(t);n=(r.find(e=>!e.startsWith(`-`))??e).split(`/`).pop()?.replace(/^(mcp-)?server-|-mcp(-server)?$/g,``)??``}return n.toLowerCase().replace(/[^a-z0-9-]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,32)}function q(e){let t=e.tools.length;switch(e.status){case`ready`:return{text:`ready — ${t} tool${t===1?``:`s`}`,tone:`ok`};case`needs-sign-in`:return{text:`needs sign-in${e.provider?` (${e.provider})`:``}`,tone:`warn`};case`needs-credential`:return{text:e.detail??`needs a credential`,tone:`warn`};case`unreachable`:return{text:`unreachable${e.detail?` — ${e.detail}`:``}`,tone:`bad`}}}var J={ok:`text-(--color-green)`,warn:`text-(--color-amber)`,bad:`text-(--color-red)`};function Y({pairs:e,onChange:t,keyLabel:n}){let r=(n,r)=>t(e.map(e=>e.id===n?{...e,...r}:e));return(0,O.jsxs)(`div`,{className:`space-y-1`,children:[e.map(i=>(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(`input`,{className:b(jl,`w-2/5`),placeholder:n,value:i.k,onChange:e=>r(i.id,{k:e.target.value})}),(0,O.jsx)(`input`,{className:jl,type:i.secret?`password`:`text`,placeholder:i.secret?`value (stored in your keychain)`:`value`,value:i.v,onChange:e=>r(i.id,{v:e.target.value})}),(0,O.jsxs)(`label`,{className:`flex shrink-0 items-center gap-1 text-[11px] text-(--color-text-muted)`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:i.secret,onChange:e=>r(i.id,{secret:e.target.checked}),"aria-label":`${i.k||n} is a secret`}),`secret`]}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>t(e.filter(e=>e.id!==i.id)),className:b(Nl,`text-(--color-text-muted)`),children:`×`})]},i.id)),(0,O.jsxs)(`button`,{type:`button`,onClick:()=>t([...e,Fl()]),className:b(Nl,`text-(--color-text-muted)`),children:[`+ add `,n.toLowerCase()]})]})}function X({entry:e,provider:t,onSubmit:n,error:r}){let[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``);return(0,O.jsxs)(`div`,{className:`mt-2 space-y-1 rounded bg-(--color-bg-elevated) p-2`,children:[(0,O.jsxs)(`p`,{className:`text-xs text-(--color-amber)`,children:[t??`This provider`,` needs an OAuth client you create yourself — a one-time setup that every`,` `,t??`provider`,` connector then shares.`]}),e&&e.setupSteps.length>0&&(0,O.jsx)(`ol`,{className:`list-decimal space-y-0.5 pl-5 text-[11px] text-(--color-text-muted)`,children:e.setupSteps.map(e=>(0,O.jsx)(`li`,{children:e},e))}),(0,O.jsxs)(`div`,{className:`flex gap-1`,children:[(0,O.jsx)(`input`,{className:jl,placeholder:`client ID`,value:i,onChange:e=>a(e.target.value)}),(0,O.jsx)(`input`,{type:`password`,className:jl,placeholder:`client secret`,value:o,onChange:e=>s(e.target.value)}),(0,O.jsx)(`button`,{type:`button`,disabled:!i.trim(),onClick:()=>n({clientId:i.trim(),...o.trim()?{clientSecret:o.trim()}:{}}),className:Nl,children:`Sign in`})]}),r&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:r})]})}function zl({catalog:e,bots:t,onCreated:n}){let[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)([]),[d,f]=(0,_.useState)(new Set),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(null),v=e.find(e=>e.name===r.trim()||e.name===a.trim()&&!r.trim())??null,y=Rl(r),b=a.trim()||(v?v.name:K(r)),x=e=>{i(e),s||o(K(e))};async function ee(){g(null),m(!0);try{let e=b,t;if(v&&!y&&(r.trim()===v.name||!r.trim()))t={name:e,description:v.description,builtin:v.name};else if(y)t={name:e,description:``,config:{transport:`http`,url:r.trim(),headers:await te(e)}};else{let{command:n,args:i}=Ll(r);if(!n)throw new ie(`Type a command, a URL, or a built-in name.`,400);t={name:e,description:``,config:{transport:`stdio`,command:n,args:i,env:await te(e)}}}d.size&&(t.botIds=Array.from(d));let a=await T.connectors.create(t);i(``),o(``),c(!1),u([]),f(new Set),n(a,a.check)}catch(e){g(e instanceof ie?e.message:`Failed to add connector`)}finally{m(!1)}}async function te(e){let t={};for(let n of l){let r=n.k.trim();if(r){if(n.secret){let i=Il(e,r);await T.secrets.set(i,n.v),t[r]=`{{secret:${i}}}`}else t[r]=n.v}}return t}let S=v&&(r.trim()===v.name||!r.trim())&&(a.trim()===v.name||r.trim()===v.name)?`${v.displayName} is built into ant-bot. ${v.description}`:y?`A remote server. If it needs a sign-in, that starts right after adding.`:r.trim()?`A local command ant-bot runs itself.`:null;return(0,O.jsxs)(`div`,{className:`mb-6 space-y-2 rounded border border-(--color-border) p-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:Ml,children:`Add`}),(0,O.jsx)(`input`,{className:jl,list:`antbot-catalog`,placeholder:`a built-in (${e.map(e=>e.name).join(`, `)||`gmail`}), a command, or a URL`,value:r,onChange:e=>x(e.target.value)}),(0,O.jsx)(`datalist`,{id:`antbot-catalog`,children:e.map(e=>(0,O.jsx)(`option`,{value:e.name,children:e.displayName},e.name))}),S&&(0,O.jsx)(`p`,{className:`mt-1 text-[11px] text-(--color-text-muted)`,children:S})]}),(0,O.jsx)(`div`,{className:`flex gap-2`,children:(0,O.jsxs)(`div`,{className:`w-1/3`,children:[(0,O.jsx)(`span`,{className:Ml,children:`Name`}),(0,O.jsx)(`input`,{className:jl,placeholder:`github`,value:a,onChange:e=>{o(e.target.value),c(!0)}})]})}),r.trim()&&!v&&(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:Ml,children:y?`Headers`:`Environment`}),(0,O.jsx)(Y,{pairs:l,onChange:u,keyLabel:y?`Header`:`VAR`})]}),t.length>0&&(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:Ml,children:`Give it to`}),(0,O.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:t.map(e=>(0,O.jsxs)(`label`,{className:`flex items-center gap-1 text-xs`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:d.has(e.id),onChange:t=>{let n=new Set(d);t.target.checked?n.add(e.id):n.delete(e.id),f(n)}}),e.name]},e.id))})]}),h&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:h}),(0,O.jsx)(`button`,{type:`button`,onClick:ee,disabled:p||!b||!r.trim()&&!v,className:`rounded bg-(--color-accent) px-3 py-1.5 text-xs font-medium text-(--color-accent-fg) disabled:opacity-40`,children:p?`Adding…`:`Add`})]})}function Bl({connector:e,catalog:t,assignedTo:n,initialCheck:r,onChanged:i}){let[a,o]=(0,_.useState)(r),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(null),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(!1),h=e.kind===`builtin`?t.find(t=>t.name===e.name)??null:null;(0,_.useEffect)(()=>{r&&(o(r),r.status===`needs-sign-in`&&r.selfRegistration===!1&&f(!0))},[r]);async function g(t={}){u(null);try{let{authorizeUrl:n}=await T.connectors.login(e.id,t);window.open(n,`_blank`,`noopener`),f(!1)}catch(e){let t=e instanceof ie?e.message:`Could not start sign-in`;u(t),/client ID|client secret/i.test(t)&&f(!0)}}async function v(){c(!0);try{let t=await T.connectors.check(e.id);o(t),t.status===`needs-sign-in`&&t.selfRegistration===!1&&f(!0),i()}catch(e){o({status:`unreachable`,tools:[],detail:e instanceof ie?e.message:`Check failed`})}finally{c(!1)}}let y=a?q(a):e.enabled?e.missingSecrets.length?{text:`missing secret: ${e.missingSecrets.join(`, `)}`,tone:`warn`}:e.signedIn?{text:`signed in`,tone:`ok`}:e.lastStatus===`ready`||e.lastStatus===`connected`?{text:`ready`,tone:`ok`}:e.lastStatus?{text:e.lastStatus.replace(/-/g,` `),tone:`warn`}:{text:`unchecked`,tone:`warn`}:{text:`disabled`,tone:`warn`},x=e.kind===`builtin`||e.config.transport!==`stdio`;return(0,O.jsxs)(`div`,{className:`border-b border-(--color-border) py-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium`,children:e.name}),(0,O.jsx)(`span`,{className:`ml-2 rounded bg-(--color-bg-elevated) px-1.5 py-0.5 text-[11px] text-(--color-text-muted)`,children:e.kind===`builtin`?`built-in`:e.config.transport}),(0,O.jsx)(`span`,{className:b(`ml-2 text-xs`,J[y.tone]),"data-testid":`connector-state`,children:y.text}),e.description&&(0,O.jsx)(`p`,{className:`truncate text-xs text-(--color-text-muted)`,title:e.description,children:e.description}),(0,O.jsx)(`p`,{className:`text-[11px] text-(--color-text-muted)`,children:n.length?`→ ${n.join(`, `)}`:`→ no bots yet — tick it in Bot settings`}),e.lastError&&!a&&y.tone!==`ok`&&(0,O.jsx)(`p`,{className:`text-[11px] text-(--color-text-muted)`,children:e.lastError})]}),x&&(0,O.jsx)(`button`,{type:`button`,onClick:e.signedIn?async()=>{await T.connectors.logout(e.id),i()}:()=>g(),className:Nl,children:e.signedIn?`Sign out`:`Sign in`}),(0,O.jsx)(`button`,{type:`button`,onClick:v,disabled:s,className:Nl,children:s?`Checking…`:`Check`}),(0,O.jsx)(`button`,{type:`button`,onClick:async()=>{await T.connectors.update(e.id,{enabled:!e.enabled}),i()},className:Nl,children:e.enabled?`Disable`:`Enable`}),(0,O.jsx)(`button`,{type:`button`,onClick:async()=>{await T.connectors.remove(e.id),i()},className:b(Nl,`text-(--color-red)`),children:`Delete`})]}),l&&!d&&(0,O.jsx)(`p`,{className:`mt-2 text-xs text-(--color-red)`,children:l}),d&&(0,O.jsx)(X,{entry:h,provider:a?.provider,onSubmit:g,error:l}),a&&a.tools.length>0&&(0,O.jsxs)(`div`,{className:`mt-1 text-xs`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>m(e=>!e),className:`text-(--color-text-muted) underline`,children:p?`hide tools`:`show ${a.tools.length} tools`}),p&&(0,O.jsx)(`ul`,{className:`mt-1 space-y-0.5`,children:a.tools.map(t=>(0,O.jsxs)(`li`,{className:`truncate`,title:t.description,children:[(0,O.jsx)(`code`,{children:`mcp__${e.name}__${t.name}`}),t.description&&(0,O.jsx)(`span`,{className:`ml-2 text-(--color-text-muted)`,children:t.description})]},t.name))})]})]})}function Vl(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)({}),[c,l]=(0,_.useState)({}),u=()=>{T.connectors.list().then(t),T.bots.list().then(async e=>{let t=e.map(e=>({id:e.bot.id,name:e.bot.name}));a(t);let n={};for(let e of t){let t=await T.bots.connectors.get(e.id).catch(()=>[]);for(let r of t)n[r.name]=[...n[r.name]??[],e.name]}s(n)}).catch(()=>a([]))};return(0,_.useEffect)(()=>{u(),T.connectors.catalog().then(r).catch(()=>r([]))},[]),(0,O.jsxs)(`div`,{className:`mx-auto max-w-4xl p-6`,children:[(0,O.jsx)(`h2`,{className:`mb-1 text-lg font-semibold`,children:`Connectors`}),(0,O.jsxs)(`p`,{className:`mb-4 text-xs text-(--color-text-muted)`,children:[`MCP servers your Bots can use: a built-in like Gmail, a command ant-bot runs, or a URL. Add one here, tick which Bots get it — a Bot without an assignment cannot see its tools at all. Tools reach Bots as`,` `,(0,O.jsx)(`code`,{children:`mcp__<name>__<tool>`}),` and still pass the permission gateway.`]}),(0,O.jsx)(zl,{catalog:n,bots:i,onCreated:(e,t)=>{l(n=>({...n,[e.id]:t})),u()}}),e.length===0?(0,O.jsx)(`p`,{className:`text-sm text-(--color-text-muted)`,children:`No connectors yet.`}):e.map(e=>(0,O.jsx)(Bl,{connector:e,catalog:n,assignedTo:o[e.name]??[],initialCheck:c[e.id]??null,onChanged:u},e.id))]})}var Hl=[{label:`New bot`,target:{kind:`newBot`}},{label:`Open settings`,target:{kind:`settings`}},{label:`Open rules`,target:{kind:`rules`}},{label:`Open usage`,target:{kind:`usage`}},{label:`Open workspace`,target:{kind:`workspace`}}];function Ul({open:e,onClose:t,onNavigate:n}){let[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)([]);if((0,_.useEffect)(()=>{e||(i(``),o([]))},[e]),(0,_.useEffect)(()=>{if(!r.trim()){o([]);return}let e=!1,t=setTimeout(()=>{T.search(r).then(t=>{e||o(t)})},150);return()=>{e=!0,clearTimeout(t)}},[r]),!e)return null;let s=Hl.filter(e=>e.label.toLowerCase().includes(r.toLowerCase()));function c(e){n(e),t()}return(0,O.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center bg-black/50 pt-24`,onClick:t,children:(0,O.jsxs)(`div`,{className:`w-full max-w-lg rounded-lg border border-(--color-border) bg-(--color-bg-elevated) shadow-2xl`,onClick:e=>e.stopPropagation(),children:[(0,O.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>e.key===`Escape`&&t(),placeholder:`Search bots, threads, messages, files… or run a command`,className:`w-full border-b border-(--color-border) bg-transparent px-4 py-3 text-sm outline-none`}),(0,O.jsxs)(`div`,{className:`max-h-96 overflow-y-auto p-1.5`,children:[s.length>0&&(0,O.jsxs)(`div`,{className:`mb-1`,children:[(0,O.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-semibold uppercase tracking-wide text-(--color-text-faint)`,children:`Actions`}),s.map(e=>(0,O.jsx)(`button`,{type:`button`,onClick:()=>c(e.target),className:`flex w-full items-center rounded px-2.5 py-1.5 text-left text-sm hover:bg-(--color-bg-hover)`,children:e.label},e.label))]}),a.length>0&&(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-semibold uppercase tracking-wide text-(--color-text-faint)`,children:`Results`}),a.map(e=>(0,O.jsxs)(`button`,{type:`button`,onClick:()=>e.threadId&&c({kind:`thread`,id:e.threadId}),className:`flex w-full flex-col items-start rounded px-2.5 py-1.5 text-left text-sm hover:bg-(--color-bg-hover)`,children:[(0,O.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`rounded bg-(--color-border) px-1 text-[10px] uppercase text-(--color-text-muted)`,children:e.kind}),(0,O.jsx)(`span`,{className:`truncate font-medium`,children:e.title})]}),e.snippet&&(0,O.jsx)(`span`,{className:`truncate text-xs text-(--color-text-muted)`,children:e.snippet})]},`${e.kind}-${e.id}`))]}),r.trim()&&s.length===0&&a.length===0&&(0,O.jsx)(`p`,{className:`px-2.5 py-4 text-center text-sm text-(--color-text-muted)`,children:`No results.`})]})]})})}var Wl=[{view:`thread`,label:`Chats`},{view:`workspace`,label:`Workspace`},{view:`computer`,label:`Computer`},{view:`rules`,label:`Rules`},{view:`connectors`,label:`Connectors`},{view:`usage`,label:`Usage`},{view:`settings`,label:`Settings`}],Gl={connecting:`Connecting…`,open:`Connected`,closed:`Disconnected`},Kl={connecting:`bg-(--color-amber) animate-pulse`,open:`bg-(--color-green)`,closed:`bg-(--color-red)`};function ql({connection:e,pendingCount:t,view:n,onChangeView:r,onOpenPalette:i}){return(0,O.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center justify-between border-b border-(--color-border) bg-(--color-bg-elevated) px-3`,children:[(0,O.jsx)(`nav`,{className:`flex items-center gap-1`,children:Wl.map(e=>(0,O.jsxs)(`button`,{type:`button`,onClick:()=>r(e.view),className:b(`rounded px-2.5 py-1 text-xs font-medium`,n===e.view?`bg-(--color-accent)/15 text-(--color-accent)`:`text-(--color-text-muted) hover:bg-(--color-bg-hover)`),children:[e.label,e.view===`rules`&&t>0&&(0,O.jsx)(`span`,{className:`ml-1.5 rounded-full bg-(--color-amber) px-1.5 py-0.5 text-[10px] font-semibold text-(--color-bg)`,children:t})]},e.view))}),(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,O.jsxs)(`button`,{type:`button`,onClick:i,className:`rounded border border-(--color-border) px-2.5 py-1 text-xs text-(--color-text-muted) hover:bg-(--color-bg-hover)`,children:[`Search… `,(0,O.jsx)(`span`,{className:`ml-1 opacity-60`,children:`⌘K`})]}),t>0&&(0,O.jsxs)(`span`,{className:`flex items-center gap-1 rounded-full bg-(--color-amber)/15 px-2 py-0.5 text-xs font-medium text-(--color-amber)`,children:[t,` pending approval`,t===1?``:`s`]}),(0,O.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-(--color-text-muted)`,children:[(0,O.jsx)(`span`,{className:b(`h-1.5 w-1.5 rounded-full`,Kl[e])}),Gl[e]]})]})]})}function Jl({children:e}){return(0,O.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:e})}function Yl({children:e}){return(0,O.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:e})}function Xl(){let e=oe(e=>e.bots),t=oe(e=>e.threads),n=oe(e=>e.activeThreadId),r=oe(e=>e.messagesByThread),i=oe(e=>e.pendingApprovals),a=oe(e=>e.connection),o=oe(e=>e.notifications),s=oe(e=>e.setBots),c=oe(e=>e.setThreads),l=oe(e=>e.setThreadMessages),u=oe(e=>e.setActiveThreadId),d=oe(e=>e.appendLocalMessage),f=oe(e=>e.dismissNotification),p=oe(e=>e.setPendingApprovals),[m,h]=(0,_.useState)(`thread`),[g,v]=(0,_.useState)(!1),[y,x]=(0,_.useState)(!1),[ee,te]=(0,_.useState)(null),[S,ne]=(0,_.useState)(null),[re,ie]=(0,_.useState)(!1),[C,w]=(0,_.useState)([]),[ae,se]=(0,_.useState)(`system`);(0,_.useEffect)(()=>{let e=document.documentElement,t=window.matchMedia(`(prefers-color-scheme: dark)`);function n(){let n=ae===`light`||ae===`system`&&!t.matches;e.classList.toggle(`light`,n)}return n(),t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[ae]),(0,_.useEffect)(()=>{T.bots.list().then(s),T.threads.list().then(c),T.skills.list().then(w),T.approvals.list().then(p).catch(()=>{});let e=E();return()=>e.close()},[s,c,p]);let ce=oe(e=>e.threadEpoch);(0,_.useEffect)(()=>{n&&(T.threads.get(n).then(({messages:e})=>{l(n,e)}),T.threads.markRead(n).catch(()=>{}))},[n,ce,l]),(0,_.useEffect)(()=>{function e(e){let t=e.metaKey||e.ctrlKey;t&&e.key.toLowerCase()===`n`?(e.preventDefault(),v(!0)):t&&e.key.toLowerCase()===`k`&&(e.preventDefault(),ie(!0))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let le=(0,_.useMemo)(()=>{let t={};for(let n of e)t[n.bot.id]=n;return t},[e]),D=(0,_.useMemo)(()=>Object.values(t).filter(e=>e.kind===`group`),[t]),ue=n?t[n]??null:null,de=n?r[n]??[]:[],fe=ue?e.find(e=>e.thread?.id===ue.id):void 0,pe=S?le[S]?.bot??null:null;async function k(){s(await T.bots.list())}async function me(e){x(!0),te(null);try{let t=await T.bots.create(e);await k(),v(!1),t.threadId&&(c(await T.threads.list()),u(t.threadId),h(`thread`))}catch(e){te(e instanceof Error?e.message:`Failed to create bot`)}finally{x(!1)}}async function he(e,t){if(!n)return;let r=await T.threads.postMessage(n,{contentMd:e,attachmentIds:t});d(n,r)}async function _e(){fe&&await T.bots.stop(fe.bot.id)}function ve(e){u(e),ne(null),h(`thread`)}function ye(e){e.kind===`thread`?ve(e.id):e.kind===`newBot`?v(!0):h(e.kind)}return(0,O.jsxs)(`div`,{className:`flex h-dvh flex-col overflow-hidden`,children:[(0,O.jsx)(ql,{connection:a,pendingCount:i.length,view:m,onChangeView:e=>{ne(null),h(e)},onOpenPalette:()=>ie(!0)}),(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,O.jsx)(ge,{entries:e,groupThreads:D,botsById:le,activeThreadId:n,onSelectThread:ve,onNewBot:()=>v(!0)}),(0,O.jsxs)(`main`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[m===`thread`&&(pe?(0,O.jsx)(ml,{bot:pe,onClose:()=>ne(null),onUpdated:t=>s(e.map(e=>e.bot.id===t.id?{...e,bot:t}:e)),onDuplicated:e=>{k(),ne(e.id)},onDeleted:()=>{ne(null),k()}}):(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[fe&&(0,O.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-(--color-border) px-4 py-2`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`text-lg leading-none`,children:fe.bot.avatarEmoji}),(0,O.jsx)(`span`,{className:`text-sm font-semibold`,children:fe.bot.name}),fe.bot.title&&(0,O.jsx)(`span`,{className:`text-xs text-(--color-text-muted)`,children:fe.bot.title})]}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>ne(fe.bot.id),className:`text-xs text-(--color-text-muted) hover:text-(--color-text)`,children:`Bot settings`})]}),(0,O.jsx)(nl,{thread:ue,messages:de,botsById:le,bots:e,skills:C,running:fe?.bot.state===`running`||fe?.bot.state===`queued`,onSend:he,onStop:_e})]})),m===`rules`&&(0,O.jsx)(Jl,{children:(0,O.jsx)(_l,{})}),m===`connectors`&&(0,O.jsx)(Jl,{children:(0,O.jsx)(Vl,{})}),m===`usage`&&(0,O.jsx)(Jl,{children:(0,O.jsx)(yl,{})}),m===`settings`&&(0,O.jsx)(Jl,{children:(0,O.jsx)(Cl,{onSettingsChange:e=>se(e.theme)})}),m===`workspace`&&(0,O.jsx)(Yl,{children:(0,O.jsx)(kl,{})}),m===`computer`&&(0,O.jsx)(Yl,{children:(0,O.jsx)(Al,{})})]})]}),o.length>0&&(0,O.jsx)(`div`,{className:`pointer-events-none fixed bottom-24 right-4 z-50 flex flex-col gap-2`,children:o.slice(-4).map(e=>(0,O.jsxs)(`div`,{className:b(`pointer-events-auto w-72 rounded-md border p-3 text-sm shadow-lg`,e.level===`error`&&`border-(--color-red)/50 bg-(--color-bg-elevated)`,e.level===`warn`&&`border-(--color-amber)/50 bg-(--color-bg-elevated)`,e.level===`info`&&`border-(--color-border) bg-(--color-bg-elevated)`),children:[(0,O.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,O.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>f(e.id),className:`text-(--color-text-faint) hover:text-(--color-text)`,children:`×`})]}),e.body&&(0,O.jsx)(`p`,{className:`mt-0.5 text-xs text-(--color-text-muted)`,children:e.body})]},e.id))}),g&&(0,O.jsx)(il,{onCreate:me,onClose:()=>v(!1),busy:y,error:ee}),(0,O.jsx)(Ul,{open:re,onClose:()=>ie(!1),onNavigate:ye})]})}var Zl=document.getElementById(`root`);if(!Zl)throw Error(`#root not found`);(0,v.createRoot)(Zl).render((0,O.jsx)(_.StrictMode,{children:(0,O.jsx)(Xl,{})}));
|
|
130
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Co(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:To(t,`input`,e.processors),output:To(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function B(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return B(r.element,n);if(r.type===`set`)return B(r.valueType,n);if(r.type===`lazy`)return B(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return B(r.innerType,n);if(r.type===`intersection`)return B(r.left,n)||B(r.right,n);if(r.type===`record`||r.type===`map`)return B(r.keyType,n)||B(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:B(r.in,n)||B(r.out,n);if(r.type===`object`){for(let e in r.shape)if(B(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(B(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(B(e,n))return!0;return!!(r.rest&&B(r.rest,n))}return!1}var wo=(e,t={})=>n=>{let r=bo({...n,processors:t});return xo(e,r),So(r,e),Co(r,e)},To=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=bo({...i??{},target:a,io:t,processors:n});return xo(e,o),So(o,e),Co(o,e)},Eo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Do=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Eo[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Oo=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},ko=(e,t,n,r)=>{n.type=`boolean`},Ao=(e,t,n,r)=>{n.not={}},jo=(e,t,n,r)=>{let i=e._zod.def,a=ln(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Mo=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},No=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Po=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Fo=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=xo(a.element,t,{...r,path:[...r.path,`items`]})},Io=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=xo(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=xo(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Lo=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>xo(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Ro=(e,t,n,r)=>{let i=e._zod.def,a=xo(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=xo(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},zo=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=xo(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=xo(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=xo(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Bo=(e,t,n,r)=>{let i=e._zod.def,a=xo(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Vo=(e,t,n,r)=>{let i=e._zod.def;xo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ho=(e,t,n,r)=>{let i=e._zod.def;xo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Uo=(e,t,n,r)=>{let i=e._zod.def;xo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Wo=(e,t,n,r)=>{let i=e._zod.def;xo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Go=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;xo(o,t,r);let s=t.seen.get(e);s.ref=o},Ko=(e,t,n,r)=>{let i=e._zod.def;xo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},qo=(e,t,n,r)=>{let i=e._zod.def;xo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Jo=M(`ZodISODateTime`,(e,t)=>{_i.init(e,t),bs.init(e,t)});function Yo(e){return Ha(Jo,e)}var Xo=M(`ZodISODate`,(e,t)=>{vi.init(e,t),bs.init(e,t)});function Zo(e){return Ua(Xo,e)}var Qo=M(`ZodISOTime`,(e,t)=>{yi.init(e,t),bs.init(e,t)});function $o(e){return Wa(Qo,e)}var es=M(`ZodISODuration`,(e,t)=>{bi.init(e,t),bs.init(e,t)});function ts(e){return Ga(es,e)}var ns=M(`ZodError`,(e,t)=>{Gn.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Jn(e,t)},flatten:{value:t=>qn(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,un,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,un,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),rs=Yn(ns),is=Xn(ns),as=Zn(ns),os=$n(ns),ss=tr(ns),cs=nr(ns),ls=rr(ns),us=ir(ns),ds=ar(ns),fs=or(ns),ps=sr(ns),ms=cr(ns),hs=new WeakMap;function gs(e,t,n){let r=Object.getPrototypeOf(e),i=hs.get(r);if(i||(i=new Set,hs.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var _s=M(`ZodType`,(e,t)=>(F.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:To(e,`input`),output:To(e,`output`)}}),e.toJSONSchema=wo(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>rs(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>as(e,t,n),e.parseAsync=async(t,n)=>is(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>os(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>ss(e,t,n),e.decode=(t,n)=>cs(e,t,n),e.encodeAsync=async(t,n)=>ls(e,t,n),e.decodeAsync=async(t,n)=>us(e,t,n),e.safeEncode=(t,n)=>ds(e,t,n),e.safeDecode=(t,n)=>fs(e,t,n),e.safeEncodeAsync=async(t,n)=>ps(e,t,n),e.safeDecodeAsync=async(t,n)=>ms(e,t,n),gs(e,`ZodType`,{check(...e){let t=this.def;return this.clone(_n(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Dn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(kc(e,t))},superRefine(e,t){return this.check(Ac(e,t))},overwrite(e){return this.check(fo(e))},optional(){return dc(this)},exactOptional(){return pc(this)},nullable(){return hc(this)},nullish(){return dc(hc(this))},nonoptional(e){return xc(this,e)},array(){return Xs(this)},or(e){return $s([this,e])},and(e){return rc(this,e)},transform(e){return Tc(this,lc(e))},default(e){return _c(this,e)},prefault(e){return yc(this,e)},catch(e){return Cc(this,e)},pipe(e){return Tc(this,e)},readonly(){return Dc(this)},describe(e){let t=this.clone();return va.add(t,{description:e}),t},meta(...e){if(e.length===0)return va.get(this);let t=this.clone();return va.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return va.get(e)?.description},configurable:!0}),e)),vs=M(`_ZodString`,(e,t)=>{ai.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Do(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,gs(e,`_ZodString`,{regex(...e){return this.check(ao(...e))},includes(...e){return this.check(co(...e))},startsWith(...e){return this.check(lo(...e))},endsWith(...e){return this.check(uo(...e))},min(...e){return this.check(ro(...e))},max(...e){return this.check(no(...e))},length(...e){return this.check(io(...e))},nonempty(...e){return this.check(ro(1,...e))},lowercase(e){return this.check(oo(e))},uppercase(e){return this.check(so(e))},trim(){return this.check(mo())},normalize(...e){return this.check(po(...e))},toLowerCase(){return this.check(ho())},toUpperCase(){return this.check(R())},slugify(){return this.check(z())}})}),ys=M(`ZodString`,(e,t)=>{ai.init(e,t),vs.init(e,t),e.email=t=>e.check(ba(xs,t)),e.url=t=>e.check(Ea(ws,t)),e.jwt=t=>e.check(Va(zs,t)),e.emoji=t=>e.check(Da(Ts,t)),e.guid=t=>e.check(xa(Ss,t)),e.uuid=t=>e.check(Sa(Cs,t)),e.uuidv4=t=>e.check(Ca(Cs,t)),e.uuidv6=t=>e.check(wa(Cs,t)),e.uuidv7=t=>e.check(Ta(Cs,t)),e.nanoid=t=>e.check(Oa(Es,t)),e.guid=t=>e.check(xa(Ss,t)),e.cuid=t=>e.check(ka(Ds,t)),e.cuid2=t=>e.check(Aa(Os,t)),e.ulid=t=>e.check(ja(ks,t)),e.base64=t=>e.check(Ra(Is,t)),e.base64url=t=>e.check(za(Ls,t)),e.xid=t=>e.check(Ma(As,t)),e.ksuid=t=>e.check(Na(js,t)),e.ipv4=t=>e.check(Pa(Ms,t)),e.ipv6=t=>e.check(Fa(Ns,t)),e.cidrv4=t=>e.check(Ia(Ps,t)),e.cidrv6=t=>e.check(La(Fs,t)),e.e164=t=>e.check(Ba(Rs,t)),e.datetime=t=>e.check(Yo(t)),e.date=t=>e.check(Zo(t)),e.time=t=>e.check($o(t)),e.duration=t=>e.check(ts(t))});function V(e){return ya(ys,e)}var bs=M(`ZodStringFormat`,(e,t)=>{I.init(e,t),vs.init(e,t)}),xs=M(`ZodEmail`,(e,t)=>{ci.init(e,t),bs.init(e,t)}),Ss=M(`ZodGUID`,(e,t)=>{oi.init(e,t),bs.init(e,t)}),Cs=M(`ZodUUID`,(e,t)=>{si.init(e,t),bs.init(e,t)}),ws=M(`ZodURL`,(e,t)=>{li.init(e,t),bs.init(e,t)}),Ts=M(`ZodEmoji`,(e,t)=>{ui.init(e,t),bs.init(e,t)}),Es=M(`ZodNanoID`,(e,t)=>{di.init(e,t),bs.init(e,t)}),Ds=M(`ZodCUID`,(e,t)=>{fi.init(e,t),bs.init(e,t)}),Os=M(`ZodCUID2`,(e,t)=>{pi.init(e,t),bs.init(e,t)}),ks=M(`ZodULID`,(e,t)=>{mi.init(e,t),bs.init(e,t)}),As=M(`ZodXID`,(e,t)=>{hi.init(e,t),bs.init(e,t)}),js=M(`ZodKSUID`,(e,t)=>{gi.init(e,t),bs.init(e,t)}),Ms=M(`ZodIPv4`,(e,t)=>{xi.init(e,t),bs.init(e,t)}),Ns=M(`ZodIPv6`,(e,t)=>{Si.init(e,t),bs.init(e,t)}),Ps=M(`ZodCIDRv4`,(e,t)=>{Ci.init(e,t),bs.init(e,t)}),Fs=M(`ZodCIDRv6`,(e,t)=>{wi.init(e,t),bs.init(e,t)}),Is=M(`ZodBase64`,(e,t)=>{Ei.init(e,t),bs.init(e,t)}),Ls=M(`ZodBase64URL`,(e,t)=>{Oi.init(e,t),bs.init(e,t)}),Rs=M(`ZodE164`,(e,t)=>{ki.init(e,t),bs.init(e,t)}),zs=M(`ZodJWT`,(e,t)=>{ji.init(e,t),bs.init(e,t)}),Bs=M(`ZodNumber`,(e,t)=>{Mi.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oo(e,t,n,r),gs(e,`ZodNumber`,{gt(e,t){return this.check($a(e,t))},gte(e,t){return this.check(eo(e,t))},min(e,t){return this.check(eo(e,t))},lt(e,t){return this.check(Za(e,t))},lte(e,t){return this.check(Qa(e,t))},max(e,t){return this.check(Qa(e,t))},int(e){return this.check(Hs(e))},safe(e){return this.check(Hs(e))},positive(e){return this.check($a(0,e))},nonnegative(e){return this.check(eo(0,e))},negative(e){return this.check(Za(0,e))},nonpositive(e){return this.check(Qa(0,e))},multipleOf(e,t){return this.check(to(e,t))},step(e,t){return this.check(to(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function H(e){return Ka(Bs,e)}var Vs=M(`ZodNumberFormat`,(e,t)=>{Ni.init(e,t),Bs.init(e,t)});function Hs(e){return qa(Vs,e)}var Us=M(`ZodBoolean`,(e,t)=>{Pi.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ko(e,t,n,r)});function Ws(e){return Ja(Us,e)}var Gs=M(`ZodUnknown`,(e,t)=>{Fi.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Ks(){return Ya(Gs)}var qs=M(`ZodNever`,(e,t)=>{Ii.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ao(e,t,n,r)});function Js(e){return Xa(qs,e)}var Ys=M(`ZodArray`,(e,t)=>{Li.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fo(e,t,n,r),e.element=t.element,gs(e,`ZodArray`,{min(e,t){return this.check(ro(e,t))},nonempty(e){return this.check(ro(1,e))},max(e,t){return this.check(no(e,t))},length(e,t){return this.check(io(e,t))},unwrap(){return this.element}})});function Xs(e,t){return go(Ys,e,t)}var Zs=M(`ZodObject`,(e,t)=>{Hi.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Io(e,t,n,r),N(e,`shape`,()=>t.shape),gs(e,`ZodObject`,{keyof(){return W(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Ks()})},loose(){return this.clone({...this._zod.def,catchall:Ks()})},strict(){return this.clone({...this._zod.def,catchall:Js()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Mn(this,e)},safeExtend(e){return Nn(this,e)},merge(e){return Pn(this,e)},pick(e){return An(this,e)},omit(e){return jn(this,e)},partial(...e){return Fn(uc,this,e[0])},required(...e){return In(bc,this,e[0])}})});function U(e,t){return new Zs({type:`object`,shape:e??{},...P(t)})}var Qs=M(`ZodUnion`,(e,t)=>{Wi.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lo(e,t,n,r),e.options=t.options});function $s(e,t){return new Qs({type:`union`,options:e,...P(t)})}var ec=M(`ZodDiscriminatedUnion`,(e,t)=>{Qs.init(e,t),Gi.init(e,t)});function tc(e,t,n){return new ec({type:`union`,options:t,discriminator:e,...P(n)})}var nc=M(`ZodIntersection`,(e,t)=>{Ki.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ro(e,t,n,r)});function rc(e,t){return new nc({type:`intersection`,left:e,right:t})}var ic=M(`ZodRecord`,(e,t)=>{Yi.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zo(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function ac(e,t,n){return!t||!t._zod?new ic({type:`record`,keyType:V(),valueType:e,...P(t)}):new ic({type:`record`,keyType:e,valueType:t,...P(n)})}var oc=M(`ZodEnum`,(e,t)=>{Xi.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jo(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new oc({...t,checks:[],...P(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new oc({...t,checks:[],...P(r),entries:i})}});function W(e,t){return new oc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...P(t)})}var sc=M(`ZodLiteral`,(e,t)=>{Zi.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mo(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function G(e,t){return new sc({type:`literal`,values:Array.isArray(e)?e:[e],...P(t)})}var cc=M(`ZodTransform`,(e,t)=>{Qi.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Po(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new on(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Un(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Un(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function lc(e){return new cc({type:`transform`,transform:e})}var uc=M(`ZodOptional`,(e,t)=>{ea.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function dc(e){return new uc({type:`optional`,innerType:e})}var fc=M(`ZodExactOptional`,(e,t)=>{ta.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function pc(e){return new fc({type:`optional`,innerType:e})}var mc=M(`ZodNullable`,(e,t)=>{na.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function hc(e){return new mc({type:`nullable`,innerType:e})}var gc=M(`ZodDefault`,(e,t)=>{ra.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ho(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function _c(e,t){return new gc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():wn(t)}})}var vc=M(`ZodPrefault`,(e,t)=>{aa.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function yc(e,t){return new vc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():wn(t)}})}var bc=M(`ZodNonOptional`,(e,t)=>{oa.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function xc(e,t){return new bc({type:`nonoptional`,innerType:e,...P(t)})}var Sc=M(`ZodCatch`,(e,t)=>{ca.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Cc(e,t){return new Sc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var wc=M(`ZodPipe`,(e,t)=>{la.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Go(e,t,n,r),e.in=t.in,e.out=t.out});function Tc(e,t){return new wc({type:`pipe`,in:e,out:t})}var Ec=M(`ZodReadonly`,(e,t)=>{da.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ko(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Dc(e){return new Ec({type:`readonly`,innerType:e})}var Oc=M(`ZodCustom`,(e,t)=>{pa.init(e,t),_s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>No(e,t,n,r)});function kc(e,t={}){return _o(Oc,e,t)}function Ac(e,t){return vo(e,t)}var jc=W([`idle`,`queued`,`running`,`waiting_approval`,`waiting_input`,`interrupted`]),Mc=W([`none`,`unread`,`needs_attention`]),Nc=[`fable`,`opus`,`sonnet`,`haiku`],Pc=W(Nc);U({id:V(),slug:V().regex(/^[a-z0-9][a-z0-9-]*$/),name:V().min(1).max(60),title:V().max(120).default(``),description:V().max(8e3).default(``),avatarEmoji:V().max(8).default(`🤖`),modelTier:Pc.default(`sonnet`),pinned:Ws().default(!1),hidden:Ws().default(!1),notifications:Ws().default(!0),sessionId:V().nullable().default(null),state:jc.default(`idle`),attention:Mc.default(`none`),threadId:V().nullable().default(null),createdAt:H(),deletedAt:H().nullable().default(null)});var Fc=W([`dm`,`group`]);U({id:V(),kind:Fc,title:V().default(``),memberBotIds:Xs(V()).default([]),pinned:Ws().default(!1),hidden:Ws().default(!1),lastReadAt:H().default(0),createdAt:H()});var Ic=tc(`type`,[U({type:G(`tool`),toolName:V(),summary:V(),input:Ks().optional(),result:V().optional(),status:W([`running`,`ok`,`error`,`denied`])}),U({type:G(`file`),path:V(),name:V(),mime:V(),bytes:H(),action:W([`created`,`modified`]).default(`created`)}),U({type:G(`approval`),approvalId:V()}),U({type:G(`handoff`),fromBotId:V(),toBotId:V(),note:V()}),U({type:G(`error`),message:V()}),U({type:G(`signin`),serverName:V(),url:V()})]),Lc=W([`user`,`bot`,`system`]),Rc=U({id:V(),threadId:V(),authorKind:Lc,authorBotId:V().nullable().default(null),replyToId:V().nullable().default(null),contentMd:V().default(``),cards:Xs(Ic).default([]),streaming:Ws().default(!1),createdAt:H()});U({id:V(),messageId:V().nullable(),path:V(),name:V(),mime:V(),bytes:H(),createdAt:H()});var zc=W([`pending`,`allowed`,`denied`,`expired`]),Bc=U({id:V(),botId:V(),threadId:V(),toolName:V(),inputSummary:V(),rawInput:Ks(),status:zc.default(`pending`),decidedBy:W([`user`,`rule`,`auto_review`]).nullable().default(null),reason:V().default(``),ruleId:V().nullable().default(null),createdAt:H(),decidedAt:H().nullable().default(null)}),Vc=W([`require`,`allow`]);U({id:V(),kind:Vc,toolPattern:V().default(`*`),inputPattern:V().default(``),scopeNote:V().default(``),builtin:Ws().default(!1),enabled:Ws().default(!0),createdAt:H()}),U({id:V(),slug:V(),name:V(),description:V().default(``),path:V(),source:W([`user`,`taught`,`imported`]).default(`user`),createdAt:H()});var Hc=/^[a-z0-9][a-z0-9-]{0,31}$/,Uc=[`antbot`,`browser`],Wc=tc(`transport`,[U({transport:G(`stdio`),command:V().min(1),args:Xs(V()).default([]),env:ac(V(),V()).default({})}),U({transport:G(`http`),url:V().url(),headers:ac(V(),V()).default({}),tools:Xs(V()).optional()}),U({transport:G(`sse`),url:V().url(),headers:ac(V(),V()).default({}),tools:Xs(V()).optional()})]),Gc=U({id:V(),name:V().regex(Hc,`lowercase letters, digits and hyphens only, max 32 characters`).refine(e=>!Uc.includes(e),{message:`"antbot" and "browser" are reserved for the built-in servers`}),description:V().default(``),enabled:Ws().default(!0),kind:W([`custom`,`builtin`]).default(`custom`),config:Wc,lastStatus:V().nullable().default(null),lastError:V().nullable().default(null),checkedAt:H().nullable().default(null),createdAt:H()});U({status:W([`ready`,`needs-sign-in`,`needs-credential`,`unreachable`]),selfRegistration:Ws().optional(),provider:V().optional(),tools:Xs(U({name:V(),description:V()})).default([]),detail:V().optional(),alternative:V().optional()}),U({id:V(),botId:V(),name:V().min(1),cronExpr:V(),timezone:V().default(`UTC`),instructionMd:V(),enabled:Ws().default(!0),lastRunAt:H().nullable().default(null),nextRunAt:H().nullable().default(null),createdAt:H()});var Kc=U({id:V(),routineId:V(),startedAt:H(),finishedAt:H().nullable().default(null),status:W([`running`,`ok`,`failed`,`interrupted`]),summary:V().default(``),threadId:V().nullable().default(null),isTest:Ws().default(!1)});U({id:V(),fromBotId:V(),toBotId:V(),contentMd:V(),hops:H().default(1),delivered:Ws().default(!1),createdAt:H()}),U({id:V(),botId:V(),turnId:V(),model:V(),inputTokens:H().default(0),outputTokens:H().default(0),cacheReadTokens:H().default(0),costEstimate:H().default(0),createdAt:H()}),W([`user`,`bot`,`routine`,`system`]);var qc={seq:H(),threadId:V().nullable(),botId:V().nullable()};tc(`type`,[U({...qc,type:G(`hello`)}),U({...qc,type:G(`message.created`),message:Rc}),U({...qc,type:G(`message.delta`),messageId:V(),delta:V()}),U({...qc,type:G(`message.done`),messageId:V(),contentMd:V()}),U({...qc,type:G(`message.card`),messageId:V(),card:Ic,cardIndex:H()}),U({...qc,type:G(`bot.state`),state:jc,attention:Mc}),U({...qc,type:G(`approval.pending`),approval:Bc}),U({...qc,type:G(`approval.resolved`),approval:Bc}),U({...qc,type:G(`routine.run`),run:Kc}),U({...qc,type:G(`usage.tick`),inputTokens:H(),outputTokens:H(),model:V()}),U({...qc,type:G(`notify`),title:V(),body:V(),level:W([`info`,`warn`,`error`])}),U({...qc,type:G(`secret.request`),requestId:V(),name:V(),reason:V()}),U({...qc,type:G(`thread.updated`),threadId2:V()})]);var Jc=tc(`kind`,[U({kind:G(`mouse`),action:W([`move`,`down`,`up`,`wheel`]),x:H().min(0).max(1),y:H().min(0).max(1),button:W([`left`,`middle`,`right`]).default(`left`),clickCount:H().int().min(0).max(3).default(1),deltaX:H().default(0),deltaY:H().default(0)}),U({kind:G(`key`),action:W([`down`,`up`]),key:V().min(1).max(32)}),U({kind:G(`text`),text:V().min(1).max(4096)})]);tc(`type`,[U({type:G(`input`),input:Jc}),U({type:G(`selection-request`)})]),U({name:V().min(1).max(60),title:V().max(120).optional(),description:V().max(8e3).optional(),avatarEmoji:V().max(8).optional(),modelTier:Pc.optional()}).partial().extend({pinned:Ws().optional(),hidden:Ws().optional(),notifications:Ws().optional()}),U({kind:W([`dm`,`group`]),title:V().optional(),memberBotIds:Xs(V())}),U({contentMd:V(),attachmentIds:Xs(V()).optional(),replyToId:V().nullable().optional(),mentionBotIds:Xs(V()).optional(),mentionEveryone:Ws().optional()}),U({decision:W([`allow`,`deny`]),alwaysRule:U({toolPattern:V(),inputPattern:V().default(``),scopeNote:V().default(``)}).optional()}),U({kind:W([`require`,`allow`]),toolPattern:V().min(1),inputPattern:V().default(``),scopeNote:V().default(``)}),U({botId:V(),name:V().min(1),cronExpr:V().min(1),timezone:V().optional(),instructionMd:V().min(1),enabled:Ws().optional()}),U({name:V().min(1),description:V().default(``),bodyMd:V().min(1),source:W([`user`,`taught`,`imported`]).optional()}),U({name:Gc.shape.name,description:V().default(``),config:Wc.optional(),builtin:V().optional(),enabled:Ws().optional(),botIds:Xs(V()).optional()}).refine(e=>!!e.config!=!!e.builtin,{message:`Give either config or builtin, not both`}),U({description:V().optional(),config:Wc.optional(),enabled:Ws().optional()});var Yc={timezone:V(),maxConcurrentSessions:H().min(1).max(8),autoReviewEnabled:Ws(),theme:W([`system`,`light`,`dark`]),localExecution:W([`ask`,`always`,`never`]),dailyTokenBudget:H(),notificationsEnabled:Ws(),billingMode:W([`subscription`,`api`]),computerMode:W([`host`,`container`])};U({timezone:Yc.timezone.default(`UTC`),maxConcurrentSessions:Yc.maxConcurrentSessions.default(2),autoReviewEnabled:Yc.autoReviewEnabled.default(!0),theme:Yc.theme.default(`system`),localExecution:Yc.localExecution.default(`ask`),dailyTokenBudget:Yc.dailyTokenBudget.default(0),notificationsEnabled:Yc.notificationsEnabled.default(!0),billingMode:Yc.billingMode.default(`subscription`),computerMode:Yc.computerMode.default(`host`)}),U(Yc).partial(),U({kind:W([`message`,`file`,`routine`,`bot`]),id:V(),threadId:V().nullable(),botId:V().nullable(),title:V(),snippet:V(),createdAt:H()});var Xc=nn.MAX_ATTACHMENTS_PER_MESSAGE;function Zc(e,t){let n=e.slice(0,t),r=/(^|\s)([@/])([\w-]*)$/.exec(n);if(!r)return null;let i=r[2];return i===`/`&&n.trim()!==`/${r[3]}`?null:{prefix:i,query:r[3],start:t-r[3].length-1}}function Qc({onSend:e,bots:t,skills:n,running:r,onStop:i,uploadFile:a}){let[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)([]),[u,d]=(0,_.useState)(null),f=(0,_.useRef)(null),p=(0,_.useRef)(null),m=(0,_.useRef)(0);(0,_.useEffect)(()=>{m.current=c.length},[c.length]);let h=(0,_.useMemo)(()=>a??(e=>T.attachments.upload(e)),[a]),g=(0,_.useMemo)(()=>{if(!u||u.prefix!==`@`)return[];let e=u.query.toLowerCase();return t.filter(t=>t.bot.name.toLowerCase().includes(e)||t.bot.slug.toLowerCase().includes(e)).slice(0,8)},[u,t]),v=(0,_.useMemo)(()=>{if(!u||u.prefix!==`/`)return[];let e=u.query.toLowerCase();return n.filter(t=>t.slug.toLowerCase().includes(e)||t.name.toLowerCase().includes(e)).slice(0,8)},[u,n]);function y(e){let t=Array.from(e),n=Math.max(0,Xc-m.current),r=t.slice(0,n);m.current=Math.min(Xc,m.current+r.length);for(let e of r)h(e).then(e=>{l(t=>t.length>=Xc?t:[...t,e])}).catch(()=>{m.current=Math.max(0,m.current-1)})}function b(e){l(t=>t.filter(t=>t.id!==e))}function x(){let t=o.trim();t&&(e(t,c.map(e=>e.id)),s(``),l([]),d(null))}function ee(e,t){s(e),d(Zc(e,t))}function te(e){e.key===`Enter`&&!e.shiftKey?(e.preventDefault(),x()):e.key===`Escape`&&d(null)}function S(e){if(!u)return;let t=p.current,n=t?t.selectionStart:o.length,r=o.slice(0,u.start),i=o.slice(n),a=u.prefix===`@`?`@${e} `:`/${e} `,c=`${r}${a}${i}`;s(c),d(null),requestAnimationFrame(()=>{t?.focus();let e=r.length+a.length;t?.setSelectionRange(e,e)})}function ne(e){let t=Array.from(e.clipboardData?.items??[]).filter(e=>e.kind===`file`&&e.type.startsWith(`image/`)).map(e=>e.getAsFile()).filter(e=>!!e);t.length>0&&(e.preventDefault(),y(t))}function re(e){e.preventDefault(),e.dataTransfer.files.length>0&&y(e.dataTransfer.files)}return(0,O.jsxs)(`div`,{className:`shrink-0 border-t border-(--color-border) bg-(--color-bg-elevated) p-3`,onDrop:re,onDragOver:e=>e.preventDefault(),children:[c.length>0&&(0,O.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:c.map(e=>(0,O.jsxs)(`span`,{"data-testid":`attachment-chip`,className:`flex items-center gap-1.5 rounded-full border border-(--color-border) bg-(--color-bg) px-2.5 py-1 text-xs`,children:[e.name,(0,O.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,className:`text-(--color-text-muted) hover:text-(--color-red)`,onClick:()=>b(e.id),children:`×`})]},e.id))}),u&&(g.length>0||v.length>0)&&(0,O.jsx)(`div`,{className:`mb-2 max-h-40 overflow-auto rounded border border-(--color-border) bg-(--color-bg) text-sm shadow-lg`,children:u.prefix===`@`?g.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-1.5 text-left hover:bg-(--color-bg-hover)`,onClick:()=>S(e.bot.slug),children:[(0,O.jsx)(`span`,{children:e.bot.avatarEmoji}),(0,O.jsx)(`span`,{children:e.bot.name})]},e.bot.id)):v.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-1.5 text-left hover:bg-(--color-bg-hover)`,onClick:()=>S(e.slug),children:[(0,O.jsxs)(`span`,{className:`shrink-0 font-mono text-(--color-text-muted)`,children:[`/`,e.slug]}),(0,O.jsx)(`span`,{className:`min-w-0 truncate text-(--color-text-muted)`,title:e.description,children:e.description})]},e.id))}),(0,O.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,"aria-label":`Attach files`,className:`shrink-0 rounded border border-(--color-border) px-2.5 py-2 text-sm hover:bg-(--color-bg-hover)`,onClick:()=>f.current?.click(),children:`+`}),(0,O.jsx)(`input`,{ref:f,"data-testid":`attachment-input`,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&y(e.target.files),e.target.value=``}}),(0,O.jsx)(`textarea`,{ref:p,value:o,rows:1,placeholder:`Message… (@ to mention, / for a skill)`,className:`max-h-40 min-h-[38px] flex-1 resize-none rounded border border-(--color-border) bg-(--color-bg) px-3 py-2 text-sm outline-none focus:border-(--color-accent)`,onChange:e=>ee(e.target.value,e.target.selectionStart),onKeyDown:te,onPaste:ne}),r&&(0,O.jsx)(`button`,{type:`button`,onClick:i,className:`shrink-0 rounded border border-(--color-red) px-3 py-2 text-sm font-medium text-(--color-red) hover:bg-(--color-red)/10`,children:`Stop`}),(0,O.jsx)(`button`,{type:`button`,onClick:x,disabled:!o.trim(),className:`shrink-0 rounded bg-(--color-accent) px-3 py-2 text-sm font-medium text-(--color-accent-fg) disabled:opacity-40`,children:`Send`})]})]})}j.setOptions({breaks:!0});function $c(e){return j.parse(e,{async:!1}).replace(/<script[\s\S]*?<\/script>/gi,``)}function el(e,t){if(e.authorKind===`user`)return{name:`You`,emoji:`🧑`};if(e.authorKind===`system`)return{name:`System`,emoji:`⚙️`};let n=e.authorBotId?t[e.authorBotId]?.bot:void 0;return{name:n?.name??`Bot`,emoji:n?.avatarEmoji??`🤖`}}function tl({message:e,botsById:t}){let{name:n,emoji:r}=el(e,t),i=e.authorKind===`user`;return(0,O.jsxs)(`div`,{className:b(`flex gap-3 px-4 py-2`,i&&`flex-row-reverse`),children:[(0,O.jsx)(`span`,{className:`mt-0.5 text-lg leading-none`,children:r}),(0,O.jsxs)(`div`,{className:b(`min-w-0 max-w-[75%]`,i&&`items-end text-right`),children:[(0,O.jsxs)(`div`,{className:b(`mb-0.5 flex items-baseline gap-2`,i&&`flex-row-reverse`),children:[(0,O.jsx)(`span`,{className:`text-xs font-semibold text-(--color-text-muted)`,children:n}),(0,O.jsx)(`span`,{className:`text-[11px] text-(--color-text-faint)`,children:new Date(e.createdAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})})]}),e.contentMd&&(0,O.jsxs)(`div`,{className:b(`markdown-body inline-block rounded-lg px-3 py-2 text-sm`,i?`bg-(--color-accent) text-(--color-accent-fg)`:`bg-(--color-bg-elevated)`),children:[(0,O.jsx)(`span`,{dangerouslySetInnerHTML:{__html:$c(e.contentMd)}}),e.streaming&&(0,O.jsx)(`span`,{className:`ml-0.5 inline-block w-1.5 animate-pulse bg-current align-middle`,children:`\xA0`})]}),(0,O.jsx)(tn,{cards:e.cards})]})]})}function nl({thread:e,messages:t,botsById:n,bots:r,skills:i,running:a,onSend:o,onStop:s}){let c=(0,_.useRef)(null),[l,u]=(0,_.useState)(!0);(0,_.useEffect)(()=>{if(!l)return;let e=()=>{let e=c.current;e&&(e.scrollTop=e.scrollHeight)};e();let t=requestAnimationFrame(()=>{e(),requestAnimationFrame(e)});return()=>cancelAnimationFrame(t)},[t,l]);function d(){let e=c.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight;u(t<80)}return e?(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,O.jsx)(`div`,{ref:c,onScroll:d,className:`min-h-0 flex-1 overflow-y-auto py-2`,children:t.length===0?(0,O.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-(--color-text-muted)`,children:`No messages yet — say hello and give this bot a job.`}):t.map(e=>(0,O.jsx)(tl,{message:e,botsById:n},e.id))}),(0,O.jsx)(Qc,{onSend:o,bots:r,skills:i,running:a,onStop:s})]}):(0,O.jsx)(`div`,{className:`flex h-full flex-1 flex-col items-center justify-center text-(--color-text-muted)`,children:(0,O.jsx)(`p`,{className:`text-sm`,children:`Select a bot to start a conversation, or create a new one.`})})}var rl=`🤖.🧠.🦾.🛰️.🧭.🗂️.📚.🔍.🧮.🧰.🛠️.⚙️.🧪.🧬.📈.📊.💡.🗒️.✍️.📝.📅.⏰.📬.📡.🌐.🔐.🗝️.🧯.🚀.🛎️.🎯.🧵.🧩.🕵️.🧑💻.👩💻.🧑🔬.🐜.🐝.🦉`.split(`.`);function il({onCreate:e,onClose:t,busy:n,error:r}){let[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(`🤖`),[f,p]=(0,_.useState)(`sonnet`);function m(){i.trim()&&e({name:i.trim(),title:o.trim(),description:c.trim(),avatarEmoji:u,modelTier:f})}return(0,O.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,children:(0,O.jsxs)(`div`,{className:`w-full max-w-md rounded-lg border border-(--color-border) bg-(--color-bg-elevated) p-5 shadow-xl`,children:[(0,O.jsx)(`h2`,{className:`mb-4 text-base font-semibold`,children:`New bot`}),(0,O.jsxs)(`div`,{className:`space-y-3`,children:[(0,O.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,O.jsx)(`div`,{className:`grid grid-cols-8 gap-1 rounded border border-(--color-border) p-1.5`,children:rl.slice(0,16).map(e=>(0,O.jsx)(`button`,{type:`button`,"aria-pressed":u===e,onClick:()=>d(e),className:`rounded p-1 text-lg ${u===e?`bg-(--color-accent)/25`:`hover:bg-(--color-bg-hover)`}`,children:e},e))})}),(0,O.jsxs)(`label`,{className:`block text-xs`,children:[(0,O.jsx)(`span`,{className:`mb-1 block text-(--color-text-muted)`,children:`Name`}),(0,O.jsx)(`input`,{autoFocus:!0,className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1.5 text-sm`,value:i,onChange:e=>a(e.target.value),placeholder:`Scout`})]}),(0,O.jsxs)(`label`,{className:`block text-xs`,children:[(0,O.jsx)(`span`,{className:`mb-1 block text-(--color-text-muted)`,children:`Title`}),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1.5 text-sm`,value:o,onChange:e=>s(e.target.value),placeholder:`Research assistant`})]}),(0,O.jsxs)(`label`,{className:`block text-xs`,children:[(0,O.jsx)(`span`,{className:`mb-1 block text-(--color-text-muted)`,children:`Description`}),(0,O.jsx)(`textarea`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1.5 text-sm`,rows:3,value:c,onChange:e=>l(e.target.value),placeholder:`What should this bot do?`})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:`mb-1 block text-xs text-(--color-text-muted)`,children:`Model tier`}),(0,O.jsx)(`div`,{className:`inline-flex rounded border border-(--color-border) p-0.5`,children:Nc.map(e=>(0,O.jsx)(`button`,{type:`button`,onClick:()=>p(e),className:`rounded px-3 py-1 text-xs font-medium capitalize ${f===e?`bg-(--color-accent) text-(--color-accent-fg)`:`text-(--color-text-muted)`}`,children:e},e))})]}),(0,O.jsx)(`p`,{className:`rounded border border-(--color-amber)/40 bg-(--color-amber)/10 p-2 text-xs text-(--color-amber)`,children:`Bots share one computer, workspace, browser profile and logins. Bots are not a security boundary.`}),r&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:r})]}),(0,O.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:t,className:`rounded px-3 py-1.5 text-sm text-(--color-text-muted) hover:bg-(--color-bg-hover)`,children:`Cancel`}),(0,O.jsx)(`button`,{type:`button`,onClick:m,disabled:!i.trim()||n,className:`rounded bg-(--color-accent) px-3 py-1.5 text-sm font-medium text-(--color-accent-fg) disabled:opacity-40`,children:`Create bot`})]})]})})}var al={running:`text-(--color-blue)`,ok:`text-(--color-green)`,failed:`text-(--color-red)`,interrupted:`text-(--color-amber)`};function ol({botId:e,onCreated:t}){let[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(`0 9 * * *`),[o,s]=(0,_.useState)(Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(null);async function m(){if(!(!n.trim()||!i.trim()||!c.trim())){d(!0),p(null);try{t(await T.routines.create({botId:e,name:n,cronExpr:i,timezone:o,instructionMd:c})),r(``),l(``)}catch(e){p(e instanceof ie?e.message:`Failed to create routine`)}finally{d(!1)}}}return(0,O.jsxs)(`div`,{className:`space-y-2 rounded-md border border-(--color-border) p-3`,children:[(0,O.jsx)(`div`,{className:`text-xs font-semibold text-(--color-text-muted)`,children:`New routine`}),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,placeholder:`Name`,value:n,onChange:e=>r(e.target.value)}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(`input`,{className:`flex-1 rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 font-mono text-sm`,placeholder:`Cron expression (e.g. 0 9 * * *)`,value:i,onChange:e=>a(e.target.value)}),(0,O.jsx)(`input`,{className:`w-40 rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,placeholder:`Timezone`,value:o,onChange:e=>s(e.target.value)})]}),(0,O.jsx)(`textarea`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,placeholder:`Instructions for this run…`,rows:3,value:c,onChange:e=>l(e.target.value)}),f&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:f}),(0,O.jsx)(`button`,{type:`button`,disabled:u,onClick:m,className:`rounded bg-(--color-accent) px-3 py-1.5 text-sm font-medium text-(--color-accent-fg) disabled:opacity-40`,children:`Create routine`})]})}function sl({routine:e,onChanged:t,onDeleted:n}){let[r,i]=(0,_.useState)([]),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(!1);async function d(){let t=await T.routines.runs(e.id);i(t.slice(0,20))}async function f(){let e=!a;o(e),e&&await d()}async function p(){t(await T.routines.update(e.id,{enabled:!e.enabled}))}async function m(){window.confirm(`Delete routine "${e.name}"?`)&&(await T.routines.remove(e.id),n(e.id))}async function h(){u(!0),c(!1);try{await T.routines.testRun(e.id),await d(),o(!0)}finally{u(!1)}}return(0,O.jsxs)(`div`,{className:`rounded-md border border-(--color-border) p-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`text-sm font-medium`,children:e.name}),(0,O.jsxs)(`div`,{className:`font-mono text-xs text-(--color-text-muted)`,children:[e.cronExpr,` · `,e.timezone]}),e.nextRunAt&&(0,O.jsxs)(`div`,{className:`text-xs text-(--color-text-faint)`,children:[`Next run: `,new Date(e.nextRunAt).toLocaleString()]})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(`label`,{className:`flex items-center gap-1 text-xs text-(--color-text-muted)`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:p}),`Enabled`]}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>c(!0),disabled:l,className:`rounded border border-(--color-border) px-2 py-1 text-xs hover:bg-(--color-bg-hover)`,children:`Test run`}),(0,O.jsx)(`button`,{type:`button`,onClick:m,className:`rounded border border-(--color-red)/50 px-2 py-1 text-xs text-(--color-red)`,children:`Delete`})]})]}),s&&(0,O.jsxs)(`div`,{className:`mt-2 rounded border border-(--color-amber)/50 bg-(--color-amber)/10 p-2 text-xs`,children:[(0,O.jsx)(`p`,{className:`text-(--color-amber)`,children:`A test run performs real work — it can navigate websites, change files and call connected tools.`}),(0,O.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:h,className:`rounded bg-(--color-amber) px-2 py-1 font-medium text-(--color-bg)`,children:`Run anyway`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>c(!1),className:`rounded px-2 py-1 text-(--color-text-muted)`,children:`Cancel`})]})]}),(0,O.jsx)(`button`,{type:`button`,onClick:f,className:`mt-2 text-xs text-(--color-text-muted) hover:underline`,children:a?`Hide run history`:`Show run history`}),a&&(0,O.jsxs)(`ul`,{className:`mt-1 space-y-1`,children:[r.length===0&&(0,O.jsx)(`li`,{className:`text-xs text-(--color-text-faint)`,children:`No runs yet.`}),r.map(e=>(0,O.jsxs)(`li`,{className:`flex items-center gap-2 text-xs`,children:[(0,O.jsx)(`span`,{className:b(`font-medium`,al[e.status]),children:e.status}),(0,O.jsx)(`span`,{className:`text-(--color-text-faint)`,children:new Date(e.startedAt).toLocaleString()}),e.isTest&&(0,O.jsx)(`span`,{className:`rounded bg-(--color-border) px-1 text-[10px]`,children:`test`}),e.summary&&(0,O.jsx)(`span`,{className:`truncate text-(--color-text-muted)`,children:e.summary})]},e.id))]})]})}function cl({botId:e}){let[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(!0);return(0,_.useEffect)(()=>{let t=!1;return i(!0),T.routines.list(e).then(e=>{t||n(e)}).finally(()=>{t||i(!1)}),()=>{t=!0}},[e]),(0,O.jsxs)(`div`,{className:`space-y-3`,children:[(0,O.jsx)(ol,{botId:e,onCreated:e=>n(t=>[e,...t])}),r&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`Loading routines…`}),!r&&t.length===0&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No routines yet.`}),t.map(e=>(0,O.jsx)(sl,{routine:e,onChanged:e=>n(t=>t.map(t=>t.id===e.id?e:t)),onDeleted:e=>n(t=>t.filter(t=>t.id!==e))},e.id))]})}function ll({bot:e,onUpdated:t}){let[n,r]=(0,_.useState)(e.name),[i,a]=(0,_.useState)(e.title),[o,s]=(0,_.useState)(e.description),[c,l]=(0,_.useState)(e.avatarEmoji),[u,d]=(0,_.useState)(e.modelTier),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)(!1);async function y(){p(!0),h(null);try{t(await T.bots.update(e.id,{name:n,title:i,description:o,avatarEmoji:c,modelTier:u}))}catch(e){h(e instanceof ie?e.message:`Failed to save`)}finally{p(!1)}}return(0,O.jsxs)(`div`,{className:`space-y-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>v(e=>!e),className:`flex h-12 w-12 items-center justify-center rounded-lg border border-(--color-border) text-2xl hover:bg-(--color-bg-hover)`,children:c}),(0,O.jsx)(`div`,{className:`flex-1`,children:(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1.5 text-sm font-medium`,value:n,onChange:e=>r(e.target.value),"aria-label":`Name`})})]}),g&&(0,O.jsx)(`div`,{className:`grid grid-cols-10 gap-1 rounded border border-(--color-border) p-2`,children:rl.map(e=>(0,O.jsx)(`button`,{type:`button`,onClick:()=>{l(e),v(!1)},className:`rounded p-1 text-lg hover:bg-(--color-bg-hover)`,children:e},e))}),(0,O.jsxs)(`label`,{className:`block text-xs`,children:[(0,O.jsx)(`span`,{className:`mb-1 block text-(--color-text-muted)`,children:`Title`}),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1.5 text-sm`,value:i,onChange:e=>a(e.target.value)})]}),(0,O.jsxs)(`label`,{className:`block text-xs`,children:[(0,O.jsx)(`span`,{className:`mb-1 block text-(--color-text-muted)`,children:`Description / persona`}),(0,O.jsx)(`textarea`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1.5 text-sm`,rows:4,value:o,onChange:e=>s(e.target.value)})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:`mb-1 block text-xs text-(--color-text-muted)`,children:`Model tier`}),(0,O.jsx)(`div`,{className:`inline-flex rounded border border-(--color-border) p-0.5`,children:Nc.map(e=>(0,O.jsx)(`button`,{type:`button`,onClick:()=>d(e),className:`rounded px-3 py-1 text-xs font-medium capitalize ${u===e?`bg-(--color-accent) text-(--color-accent-fg)`:`text-(--color-text-muted)`}`,children:e},e))})]}),m&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:m}),(0,O.jsx)(`button`,{type:`button`,onClick:y,disabled:f,className:`rounded bg-(--color-accent) px-3 py-1.5 text-sm font-medium text-(--color-accent-fg) disabled:opacity-40`,children:`Save profile`})]})}function ul({botId:e}){let[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``);(0,_.useEffect)(()=>{T.bots.memory.list(e).then(n)},[e]);function l(e){i(e),o(t.find(t=>t.name===e)?.content??``)}async function u(){let t=r??s.trim();t&&(await T.bots.memory.save(e,t,a),n(e=>{let n=e.findIndex(e=>e.name===t);return n===-1?[...e,{name:t,content:a}]:e.map((e,r)=>r===n?{name:t,content:a}:e)}),i(t),c(``))}async function d(t){await T.bots.memory.remove(e,t),n(e=>e.filter(e=>e.name!==t)),r===t&&(i(null),o(``))}return(0,O.jsxs)(`div`,{className:`grid grid-cols-[160px_1fr] gap-3`,children:[(0,O.jsxs)(`div`,{className:`space-y-1`,children:[t.map(e=>(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>l(e.name),className:`flex-1 truncate rounded px-2 py-1 text-left text-xs ${r===e.name?`bg-(--color-accent)/15`:`hover:bg-(--color-bg-hover)`}`,children:e.name}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>d(e.name),"aria-label":`Delete ${e.name}`,className:`text-xs text-(--color-text-faint) hover:text-(--color-red)`,children:`×`})]},e.name)),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-xs`,placeholder:`new-file.md`,value:s,onChange:e=>{c(e.target.value),i(null),o(``)}})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`textarea`,{className:`h-40 w-full rounded border border-(--color-border) bg-(--color-bg) p-2 font-mono text-xs`,value:a,onChange:e=>o(e.target.value),placeholder:`Durable facts this bot should remember…`}),(0,O.jsx)(`button`,{type:`button`,onClick:u,className:`mt-2 rounded bg-(--color-accent) px-3 py-1.5 text-xs font-medium text-(--color-accent-fg)`,children:`Save memory file`})]})]})}function dl({skill:e,checked:t,onToggle:n}){let[r,i]=(0,_.useState)(!1),a=`skill-${e.id}`;return(0,O.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[(0,O.jsx)(`input`,{id:a,type:`checkbox`,className:`mt-1 shrink-0`,checked:t,onChange:n}),(0,O.jsx)(`label`,{htmlFor:a,className:`shrink-0 cursor-pointer whitespace-nowrap font-medium`,children:e.name}),e.description&&(0,O.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),"aria-expanded":r,title:r?`Collapse description`:`Show the full description`,className:`min-w-0 flex-1 cursor-pointer text-left text-xs text-(--color-text-muted) hover:text-(--color-text) ${r?`whitespace-pre-wrap break-words`:`truncate`}`,children:[`— `,e.description]})]})}function fl({botId:e}){let[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(null);(0,_.useEffect)(()=>{T.connectors.list().then(n)},[]),(0,_.useEffect)(()=>{T.bots.connectors.get(e).then(e=>i(new Set(e.map(e=>e.id))))},[e]);async function s(t){if(!r)return;let n=new Set(r);n.has(t)?n.delete(t):n.add(t),i(n),o(null);try{await T.bots.connectors.set(e,Array.from(n))}catch(e){i(r),o(e instanceof ie?e.message:`Could not save`)}}return t.length===0?(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No connectors yet. Add one on the Connectors screen.`}):(0,O.jsxs)(`div`,{className:`space-y-2`,children:[t.map(e=>(0,O.jsxs)(`label`,{className:`flex items-start gap-2 text-xs`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:r?.has(e.id)??!1,disabled:!r,onChange:()=>s(e.id),className:`mt-0.5`}),(0,O.jsxs)(`span`,{className:`min-w-0`,children:[(0,O.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,O.jsx)(`span`,{className:`ml-1 text-(--color-text-muted)`,children:e.kind===`builtin`?`built-in`:String(e.config.transport)}),!e.enabled&&(0,O.jsx)(`span`,{className:`ml-1 text-(--color-text-muted)`,children:`(disabled)`}),e.missingSecrets.length>0&&(0,O.jsxs)(`span`,{className:`ml-1 text-(--color-amber)`,children:[`missing secret: `,e.missingSecrets.join(`, `)]}),e.lastStatus===`needs-sign-in`&&(0,O.jsx)(`span`,{className:`ml-1 text-(--color-amber)`,children:`needs sign-in`}),e.description&&(0,O.jsx)(`span`,{className:`block truncate text-(--color-text-muted)`,title:e.description,children:e.description})]})]},e.id)),a&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:a})]})}function pl({botId:e}){let[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(new Set),[a,o]=(0,_.useState)(!1);(0,_.useEffect)(()=>{T.skills.list().then(n)},[]),(0,_.useEffect)(()=>{T.bots.skills.get(e).then(e=>i(new Set(e.map(e=>e.id))))},[e]);function s(e){i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),o(!1)}async function c(){await T.bots.skills.set(e,Array.from(r)),o(!0)}return t.length===0?(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No skills taught yet.`}):(0,O.jsxs)(`div`,{className:`space-y-2`,children:[t.map(e=>(0,O.jsx)(dl,{skill:e,checked:r.has(e.id),onToggle:()=>s(e.id)},e.id)),(0,O.jsx)(`button`,{type:`button`,onClick:c,className:`rounded bg-(--color-accent) px-3 py-1.5 text-xs font-medium text-(--color-accent-fg)`,children:`Save skills`}),a&&(0,O.jsx)(`span`,{className:`ml-2 text-xs text-(--color-green)`,children:`Saved`})]})}function ml({bot:e,onClose:t,onUpdated:n,onDuplicated:r,onDeleted:i}){let[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(null);async function d(){n(await T.bots.update(e.id,{pinned:!e.pinned}))}async function f(){n(await T.bots.update(e.id,{hidden:!e.hidden}))}async function p(){n(await T.bots.update(e.id,{notifications:!e.notifications}))}async function m(){r(await T.bots.duplicate(e.id))}async function h(){await T.bots.remove(e.id),i(e.id)}return(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto p-5`,children:[(0,O.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,O.jsxs)(`h2`,{className:`text-lg font-semibold`,children:[e.name,` settings`]}),(0,O.jsx)(`button`,{type:`button`,onClick:t,className:`text-sm text-(--color-text-muted) hover:text-(--color-text)`,children:`Close`})]}),(0,O.jsx)(`section`,{className:`mb-6`,children:(0,O.jsx)(ll,{bot:e,onUpdated:n})}),(0,O.jsxs)(`section`,{className:`mb-6 flex flex-wrap gap-2 border-t border-(--color-border) pt-4`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:d,className:`rounded border border-(--color-border) px-3 py-1.5 text-xs hover:bg-(--color-bg-hover)`,children:e.pinned?`Unpin`:`Pin`}),(0,O.jsx)(`button`,{type:`button`,onClick:f,className:`rounded border border-(--color-border) px-3 py-1.5 text-xs hover:bg-(--color-bg-hover)`,children:e.hidden?`Unhide`:`Hide`}),(0,O.jsx)(`button`,{type:`button`,onClick:p,className:`rounded border border-(--color-border) px-3 py-1.5 text-xs hover:bg-(--color-bg-hover)`,children:e.notifications?`Mute notifications`:`Unmute notifications`}),(0,O.jsx)(`button`,{type:`button`,onClick:m,className:`rounded border border-(--color-border) px-3 py-1.5 text-xs hover:bg-(--color-bg-hover)`,children:`Duplicate`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>c(!0),className:`rounded border border-(--color-border) px-3 py-1.5 text-xs hover:bg-(--color-bg-hover)`,children:`Start fresh`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`rounded border border-(--color-red)/50 px-3 py-1.5 text-xs text-(--color-red) hover:bg-(--color-red)/10`,children:`Delete`})]}),s&&(0,O.jsxs)(`div`,{className:`mb-6 rounded border border-(--color-border) bg-(--color-bg-elevated) p-3 text-sm`,children:[(0,O.jsx)(`p`,{className:`mb-1`,children:`Clear this conversation and start a fresh session?`}),(0,O.jsx)(`p`,{className:`mb-2 text-xs text-(--color-text-muted)`,children:`Deletes the messages in this thread and drops the model’s accumulated context. Keeps the Bot’s description, memory, skills, connectors, routines and files.`}),l&&(0,O.jsx)(`p`,{className:`mb-2 text-xs text-(--color-red)`,children:l}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:async()=>{u(null);try{await T.bots.reset(e.id),c(!1),n(e)}catch(e){u(e instanceof ie?e.message:`Could not start fresh`)}},className:`rounded bg-(--color-accent) px-3 py-1.5 text-xs font-medium text-(--color-accent-fg)`,children:`Start fresh`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>{c(!1),u(null)},className:`rounded border border-(--color-border) px-3 py-1.5 text-xs`,children:`Cancel`})]})]}),a&&(0,O.jsxs)(`div`,{className:`mb-6 rounded border border-(--color-red)/50 bg-(--color-red)/10 p-3 text-sm`,children:[(0,O.jsxs)(`p`,{className:`text-(--color-red)`,children:[`Delete `,e.name,`? This removes it from your roster and conversation history, but its workspace files and any browser logins it used survive deletion.`]}),(0,O.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:h,className:`rounded bg-(--color-red) px-3 py-1.5 text-xs font-medium text-white`,children:`Delete permanently`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`rounded px-3 py-1.5 text-xs text-(--color-text-muted)`,children:`Cancel`})]})]}),(0,O.jsxs)(`section`,{className:`mb-6 border-t border-(--color-border) pt-4`,children:[(0,O.jsx)(`h3`,{className:`mb-2 text-sm font-semibold`,children:`Memory`}),(0,O.jsx)(ul,{botId:e.id})]}),(0,O.jsxs)(`section`,{className:`mb-6 border-t border-(--color-border) pt-4`,children:[(0,O.jsx)(`h3`,{className:`mb-2 text-sm font-semibold`,children:`Skills`}),(0,O.jsx)(pl,{botId:e.id})]}),(0,O.jsxs)(`section`,{className:`mb-6 border-t border-(--color-border) pt-4`,children:[(0,O.jsx)(`h3`,{className:`mb-2 text-sm font-semibold`,children:`Connectors`}),(0,O.jsx)(fl,{botId:e.id})]}),(0,O.jsxs)(`section`,{className:`border-t border-(--color-border) pt-4`,children:[(0,O.jsx)(`h3`,{className:`mb-2 text-sm font-semibold`,children:`Routines`}),(0,O.jsx)(cl,{botId:e.id})]})]})}function hl({kind:e}){return(0,O.jsx)(`span`,{className:b(`rounded px-1.5 py-0.5 text-[11px] font-semibold uppercase tracking-wide`,e===`require`?`bg-(--color-red)/15 text-(--color-red)`:`bg-(--color-green)/15 text-(--color-green)`),children:e===`require`?`Require approval`:`Always allow`})}function gl({onCreated:e}){let[t,n]=(0,_.useState)(`require`),[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(null);async function d(){if(r.trim())try{e(await T.rules.create({kind:t,toolPattern:r.trim(),inputPattern:a,scopeNote:s})),i(``),o(``),c(``),u(null)}catch(e){u(e instanceof ie?e.message:`Failed to create rule`)}}return(0,O.jsxs)(`div`,{className:`mb-4 space-y-2 rounded-md border border-(--color-border) p-3`,children:[(0,O.jsx)(`div`,{className:`flex gap-2`,children:[`require`,`allow`].map(e=>(0,O.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:b(`rounded px-3 py-1 text-xs font-medium`,t===e?`bg-(--color-accent) text-(--color-accent-fg)`:`border border-(--color-border) text-(--color-text-muted)`),children:e===`require`?`Require approval`:`Always allow`},e))}),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 font-mono text-sm`,placeholder:`Tool pattern (e.g. Bash, browser_*, *)`,value:r,onChange:e=>i(e.target.value)}),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 font-mono text-sm`,placeholder:`Input pattern (optional regex)`,value:a,onChange:e=>o(e.target.value)}),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,placeholder:`Scope note (why this rule exists)`,value:s,onChange:e=>c(e.target.value)}),l&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:l}),(0,O.jsx)(`button`,{type:`button`,onClick:d,className:`rounded bg-(--color-accent) px-3 py-1.5 text-sm font-medium text-(--color-accent-fg)`,children:`Add rule`})]})}function _l(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)(!0);(0,_.useEffect)(()=>{T.rules.list().then(t).finally(()=>r(!1))},[]);async function i(e){let n=await T.rules.update(e.id,!e.enabled);t(e=>e.map(e=>e.id===n.id?n:e))}async function a(e){e.builtin||window.confirm(`Delete rule for "${e.toolPattern}"?`)&&(await T.rules.remove(e.id),t(t=>t.filter(t=>t.id!==e.id)))}return(0,O.jsxs)(`div`,{className:`mx-auto max-w-3xl p-6`,children:[(0,O.jsx)(`h1`,{className:`mb-1 text-lg font-semibold`,children:`Rules`}),(0,O.jsx)(`p`,{className:`mb-4 text-sm text-(--color-text-muted)`,children:`Require Approval always wins over Always Allow.`}),(0,O.jsx)(gl,{onCreated:e=>t(t=>[e,...t])}),n&&(0,O.jsx)(`p`,{className:`text-sm text-(--color-text-muted)`,children:`Loading…`}),!n&&e.length===0&&(0,O.jsx)(`p`,{className:`text-sm text-(--color-text-muted)`,children:`No rules yet.`}),(0,O.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-(--color-border) p-3`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(hl,{kind:e.kind}),e.builtin&&(0,O.jsx)(`span`,{title:`Built-in rule`,"aria-label":`Built-in rule`,className:`text-(--color-text-faint)`,children:`🔒`}),(0,O.jsx)(`span`,{className:`truncate font-mono text-sm`,children:e.toolPattern})]}),e.inputPattern&&(0,O.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-xs text-(--color-text-muted)`,children:e.inputPattern}),e.scopeNote&&(0,O.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-(--color-text-faint)`,children:e.scopeNote})]}),(0,O.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,O.jsxs)(`label`,{className:`flex items-center gap-1 text-xs text-(--color-text-muted)`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:()=>i(e)}),`Enabled`]}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>a(e),disabled:e.builtin,className:`rounded border border-(--color-red)/50 px-2 py-1 text-xs text-(--color-red) disabled:cursor-not-allowed disabled:opacity-30`,children:`Delete`})]})]},e.id))})]})}function vl({label:e,value:t,max:n,sublabel:r}){let i=n>0?Math.max(2,Math.round(t/n*100)):0;return(0,O.jsxs)(`div`,{className:`mb-2`,children:[(0,O.jsxs)(`div`,{className:`mb-0.5 flex items-baseline justify-between text-xs`,children:[(0,O.jsx)(`span`,{className:`font-medium`,children:e}),(0,O.jsx)(`span`,{className:`text-(--color-text-muted)`,children:r??t.toLocaleString()})]}),(0,O.jsx)(`div`,{className:`h-2 rounded bg-(--color-bg)`,children:(0,O.jsx)(`div`,{className:`h-2 rounded bg-(--color-accent)`,style:{width:`${i}%`}})})]})}function yl(){let[e,t]=(0,_.useState)(null);if((0,_.useEffect)(()=>{T.usage().then(t)},[]),!e)return(0,O.jsx)(`p`,{className:`p-6 text-sm text-(--color-text-muted)`,children:`Loading usage…`});let n=e.totals.inputTokens+e.totals.outputTokens,r=Math.max(1,...e.byBot.map(e=>e.inputTokens+e.outputTokens)),i=Math.max(1,...e.byDay.map(e=>e.inputTokens+e.outputTokens)),a=Math.max(1,...e.byModel.map(e=>e.inputTokens+e.outputTokens));return(0,O.jsxs)(`div`,{className:`mx-auto max-w-3xl p-6`,children:[(0,O.jsx)(`h1`,{className:`mb-4 text-lg font-semibold`,children:`Usage`}),(0,O.jsxs)(`section`,{className:`mb-6 grid grid-cols-3 gap-3`,children:[(0,O.jsxs)(`div`,{className:`rounded-md border border-(--color-border) p-3`,children:[(0,O.jsx)(`div`,{className:`text-xs text-(--color-text-muted)`,children:`Input tokens`}),(0,O.jsx)(`div`,{className:`text-xl font-semibold`,children:e.totals.inputTokens.toLocaleString()})]}),(0,O.jsxs)(`div`,{className:`rounded-md border border-(--color-border) p-3`,children:[(0,O.jsx)(`div`,{className:`text-xs text-(--color-text-muted)`,children:`Output tokens`}),(0,O.jsx)(`div`,{className:`text-xl font-semibold`,children:e.totals.outputTokens.toLocaleString()})]}),(0,O.jsxs)(`div`,{className:`rounded-md border border-(--color-border) p-3`,children:[(0,O.jsx)(`div`,{className:`text-xs text-(--color-text-muted)`,children:`Cache-read tokens`}),(0,O.jsx)(`div`,{className:`text-xl font-semibold`,children:e.totals.cacheReadTokens.toLocaleString()})]})]}),(0,O.jsxs)(`section`,{className:`mb-6`,children:[(0,O.jsx)(`h2`,{className:`mb-2 text-sm font-semibold`,children:`By bot`}),e.byBot.length===0&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No usage yet.`}),e.byBot.map(e=>(0,O.jsx)(vl,{label:e.botName,value:e.inputTokens+e.outputTokens,max:r},e.botId))]}),(0,O.jsxs)(`section`,{className:`mb-6`,children:[(0,O.jsx)(`h2`,{className:`mb-2 text-sm font-semibold`,children:`By day`}),(0,O.jsx)(`div`,{className:`flex items-end gap-1`,style:{height:96},children:e.byDay.map(e=>{let t=e.inputTokens+e.outputTokens,n=Math.max(2,Math.round(t/i*88));return(0,O.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-end`,title:`${e.day}: ${t.toLocaleString()} tokens`,children:[(0,O.jsx)(`div`,{className:`w-full rounded-t bg-(--color-accent)`,style:{height:n}}),(0,O.jsx)(`span`,{className:`mt-1 rotate-0 text-[9px] text-(--color-text-faint)`,children:e.day.slice(5)})]},e.day)})}),e.byDay.length===0&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No usage yet.`})]}),(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h2`,{className:`mb-2 text-sm font-semibold`,children:`By model`}),e.byModel.length===0&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No usage yet.`}),e.byModel.map(e=>(0,O.jsx)(vl,{label:e.model,value:e.inputTokens+e.outputTokens,max:a,sublabel:n>0?`${Math.round((e.inputTokens+e.outputTokens)/n*100)}%`:`0%`},e.model))]})]})}var bl=`rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`;function xl(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(!1);(0,_.useEffect)(()=>{T.secrets.list().then(e=>{t(e.names),r(e.backend)}).catch(()=>d(!0))},[]);async function f(){l(null);try{let e=await T.secrets.set(i.trim(),o);t(e.names),a(``),s(``)}catch(e){l(e instanceof ie?e.message:`Could not store the secret`)}}async function p(e){l(null);try{let n=await T.secrets.remove(e);t(n.names)}catch(e){l(e instanceof ie?e.message:`Could not remove the secret`)}}return u?(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No secrets backend is available on this machine.`}):(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsxs)(`p`,{className:`text-xs text-(--color-text-muted)`,children:[`Stored in your `,n===`file`?`ant-bot data directory`:n??`keychain`,`. Names only are ever shown; a value cannot be read back, by you or by a bot.`]}),e.length===0?(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No secrets stored.`}):(0,O.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>(0,O.jsxs)(`li`,{className:`flex items-center gap-2 text-sm`,children:[(0,O.jsx)(`code`,{className:`flex-1 truncate`,children:e}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>p(e),className:`rounded border border-(--color-border) px-2 py-0.5 text-xs text-(--color-red)`,children:`Remove`})]},e))}),(0,O.jsxs)(`div`,{className:`flex gap-1`,children:[(0,O.jsx)(`input`,{className:`${bl} w-2/5`,placeholder:`NAME`,value:i,onChange:e=>a(e.target.value)}),(0,O.jsx)(`input`,{type:`password`,className:`${bl} flex-1`,placeholder:`value`,value:o,onChange:e=>s(e.target.value)}),(0,O.jsx)(`button`,{type:`button`,onClick:f,disabled:!i.trim()||!o,className:`rounded border border-(--color-border) px-2 py-1 text-xs disabled:opacity-40`,children:`Store`})]}),c&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:c})]})}function Sl({label:e,children:t}){return(0,O.jsxs)(`label`,{className:`mb-3 flex items-center justify-between gap-4 border-b border-(--color-border) py-2 text-sm`,children:[(0,O.jsx)(`span`,{className:`text-(--color-text-muted)`,children:e}),t]})}function Cl({onSettingsChange:e}){let[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!1);(0,_.useEffect)(()=>{T.settings.get().then(t=>{n(t),e?.(t)})},[]);async function a(r){if(!t)return;let a={...t,...r};n(a),i(!0);try{let t=await T.settings.update(r);n(t),e?.(t)}finally{i(!1)}}return t?(0,O.jsxs)(`div`,{className:`mx-auto max-w-xl p-6`,children:[(0,O.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,O.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Settings`}),r&&(0,O.jsx)(`span`,{className:`text-xs text-(--color-text-muted)`,children:`Saving…`})]}),(0,O.jsx)(Sl,{label:`Timezone`,children:(0,O.jsx)(`input`,{className:`w-48 rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.timezone,onChange:e=>a({timezone:e.target.value})})}),(0,O.jsx)(Sl,{label:`Max concurrent sessions`,children:(0,O.jsx)(`input`,{type:`number`,min:1,max:8,className:`w-20 rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.maxConcurrentSessions,onChange:e=>a({maxConcurrentSessions:Math.min(8,Math.max(1,Number(e.target.value)||1))})})}),(0,O.jsx)(Sl,{label:`Auto-review (Haiku triage of tool calls)`,children:(0,O.jsx)(`input`,{type:`checkbox`,checked:t.autoReviewEnabled,onChange:e=>a({autoReviewEnabled:e.target.checked})})}),(0,O.jsx)(Sl,{label:`Theme`,children:(0,O.jsxs)(`select`,{className:`rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.theme,onChange:e=>a({theme:e.target.value}),children:[(0,O.jsx)(`option`,{value:`system`,children:`System`}),(0,O.jsx)(`option`,{value:`light`,children:`Light`}),(0,O.jsx)(`option`,{value:`dark`,children:`Dark`})]})}),(0,O.jsx)(Sl,{label:`Local execution (run commands on this machine)`,children:(0,O.jsxs)(`select`,{className:`rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.localExecution,onChange:e=>a({localExecution:e.target.value}),children:[(0,O.jsx)(`option`,{value:`ask`,children:`Ask`}),(0,O.jsx)(`option`,{value:`always`,children:`Always`}),(0,O.jsx)(`option`,{value:`never`,children:`Never`})]})}),(0,O.jsx)(Sl,{label:`Daily token budget (0 = unlimited)`,children:(0,O.jsx)(`input`,{type:`number`,min:0,className:`w-32 rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.dailyTokenBudget,onChange:e=>a({dailyTokenBudget:Math.max(0,Number(e.target.value)||0)})})}),(0,O.jsx)(Sl,{label:`Desktop notifications`,children:(0,O.jsx)(`input`,{type:`checkbox`,checked:t.notificationsEnabled,onChange:e=>a({notificationsEnabled:e.target.checked})})}),(0,O.jsx)(Sl,{label:`Billing mode`,children:(0,O.jsxs)(`select`,{className:`rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.billingMode,onChange:e=>a({billingMode:e.target.value}),children:[(0,O.jsx)(`option`,{value:`subscription`,children:`Subscription`}),(0,O.jsx)(`option`,{value:`api`,children:`API (metered)`})]})}),(0,O.jsx)(Sl,{label:`Computer mode`,children:(0,O.jsxs)(`select`,{className:`rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.computerMode,onChange:e=>a({computerMode:e.target.value}),children:[(0,O.jsx)(`option`,{value:`host`,children:`Host`}),(0,O.jsx)(`option`,{value:`container`,children:`Container`})]})}),(0,O.jsx)(`h2`,{className:`mt-8 mb-2 text-sm font-semibold`,children:`Secrets`}),(0,O.jsx)(xl,{})]}):(0,O.jsx)(`p`,{className:`p-6 text-sm text-(--color-text-muted)`,children:`Loading settings…`})}var wl=/\.(png|jpe?g|gif|webp|svg|bmp)$/i,Tl=/\.(md|markdown|txt|json|ya?ml|csv|log|ts|tsx|js|jsx|py|sh|css|html)$/i;function El(e){return e.startsWith(`.`)}function Dl({entry:e,depth:t,showHidden:n,onOpenFile:r}){let[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(!1);async function u(){if(!e.dir){r(e.path);return}if(!i&&o===null){l(!0);let t=await T.workspace.tree(e.path);s(t),l(!1)}a(e=>!e)}return(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`button`,{type:`button`,onClick:u,className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-left text-sm hover:bg-(--color-bg-hover)`,style:{paddingLeft:`${t*14+6}px`},children:[(0,O.jsx)(`span`,{className:`w-3 shrink-0 text-(--color-text-faint)`,children:e.dir?i?`▾`:`▸`:``}),(0,O.jsx)(`span`,{className:`shrink-0`,children:e.dir?`📁`:`📄`}),(0,O.jsx)(`span`,{className:`truncate`,children:e.name}),!e.dir&&(0,O.jsxs)(`span`,{className:`ml-auto shrink-0 text-xs text-(--color-text-faint)`,children:[e.bytes,`B`]})]}),i&&(0,O.jsxs)(`div`,{children:[c&&(0,O.jsx)(`div`,{style:{paddingLeft:`${(t+1)*14+6}px`},className:`py-1 text-xs text-(--color-text-faint)`,children:`Loading…`}),o?.filter(e=>n||!El(e.name)).map(e=>(0,O.jsx)(Dl,{entry:e,depth:t+1,showHidden:n,onOpenFile:r},e.path))]})]})}function Ol({path:e,onClose:t}){let[n,r]=(0,_.useState)(null),i=e.split(`/`).pop()??e,a=wl.test(i),o=Tl.test(i);return(0,_.useEffect)(()=>{r(null),o&&fetch(T.workspace.fileUrl(e)).then(e=>e.text()).then(r).catch(()=>r(`(failed to load preview)`))},[e,o]),(0,O.jsxs)(`div`,{className:`flex h-full flex-col border-l border-(--color-border)`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between border-b border-(--color-border) p-2`,children:[(0,O.jsx)(`span`,{className:`truncate text-sm font-medium`,children:i}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`a`,{href:T.workspace.fileUrl(e),download:i,className:`text-xs text-(--color-accent) hover:underline`,children:`Download`}),(0,O.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs text-(--color-text-muted) hover:text-(--color-text)`,children:`Close`})]})]}),(0,O.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-2`,children:[a&&(0,O.jsx)(`img`,{src:T.workspace.fileUrl(e),alt:i,className:`max-w-full`}),o&&(0,O.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs`,children:n??`Loading…`}),!a&&!o&&(0,O.jsx)(`p`,{className:`text-sm text-(--color-text-muted)`,children:`No inline preview available — use Download.`})]})]})}function kl(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(!0);return(0,_.useEffect)(()=>{T.workspace.tree(``).then(t).finally(()=>s(!1))},[]),(0,O.jsxs)(`div`,{className:`flex h-full`,children:[(0,O.jsxs)(`div`,{className:`flex w-80 shrink-0 flex-col border-r border-(--color-border)`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between border-b border-(--color-border) p-2`,children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Workspace`}),(0,O.jsxs)(`label`,{className:`flex items-center gap-1 text-xs text-(--color-text-muted)`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>r(e.target.checked)}),`Hidden files`]})]}),(0,O.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-1`,children:[o&&(0,O.jsx)(`p`,{className:`p-2 text-xs text-(--color-text-muted)`,children:`Loading…`}),!o&&e.length===0&&(0,O.jsx)(`p`,{className:`p-2 text-xs text-(--color-text-muted)`,children:`Workspace is empty.`}),e.filter(e=>n||!El(e.name)).map(e=>(0,O.jsx)(Dl,{entry:e,depth:0,showHidden:n,onOpenFile:a},e.path))]})]}),i&&(0,O.jsx)(`div`,{className:`w-96 shrink-0`,children:(0,O.jsx)(Ol,{path:i,onClose:()=>a(null)})})]})}function Al(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(null),u=(0,_.useRef)(null),d=(0,_.useRef)(null),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(null);(0,_.useEffect)(()=>{T.computer.status().then(e=>{t(e),e.pages.length>0&&r(e.pages[0].botId)})},[]);async function g(e){if(!e){h(`Nothing is selected on the remote page.`);return}try{await navigator.clipboard.writeText(e),h(`Copied ${e.length.toLocaleString()} character${e.length===1?``:`s`} from the page.`)}catch{h(`The browser refused clipboard access, so the selection was not copied.`)}}(0,_.useEffect)(()=>{if(a(null),u.current?.close(),!n||!e?.available)return;let t=window.location.protocol===`https:`?`wss`:`ws`,r=new WebSocket(`${t}://${window.location.host}/api/computer/screencast/${n}`);return u.current=r,r.onmessage=e=>{try{let t=JSON.parse(e.data);t.type===`frame`?a({data:t.data,w:t.w,h:t.h}):t.type===`selection`?g(t.text??``):t.type===`input-error`&&h(t.message??`Input was rejected.`)}catch{}},()=>r.close()},[n,e?.available]),(0,_.useEffect)(()=>{if(!m)return;let e=setTimeout(()=>h(null),4e3);return()=>clearTimeout(e)},[m]),(0,_.useEffect)(()=>{o&&d.current?.focus()},[o]);async function v(){if(!n)return;let e=await T.computer.takeover(n);s(e.ok),l(e.message??null)}async function y(){n&&(await T.computer.returnControl(n),s(!1),l(null))}function b(e){let t=u.current;if(!(!o||!t||t.readyState!==WebSocket.OPEN))try{t.send(JSON.stringify(e))}catch{}}function x(e){b({type:`input`,input:e})}function ee(e){let t=e.currentTarget.getBoundingClientRect();return t.width<=0||t.height<=0?null:{x:(e.clientX-t.left)/t.width,y:(e.clientY-t.top)/t.height}}let te=[`left`,`middle`,`right`];return e?e.available?(0,O.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-(--color-border) p-3`,children:[(0,O.jsxs)(`select`,{className:`rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:n??``,onChange:e=>r(e.target.value||null),children:[e.pages.length===0&&(0,O.jsx)(`option`,{value:``,children:`No active pages`}),e.pages.map(e=>(0,O.jsx)(`option`,{value:e.botId,children:e.title||e.url},e.botId))]}),(0,O.jsx)(`div`,{className:`flex items-center gap-2`,children:o?(0,O.jsx)(`button`,{type:`button`,onClick:y,className:`rounded bg-(--color-accent) px-3 py-1.5 text-xs font-medium text-(--color-accent-fg)`,children:`Return control`}):(0,O.jsx)(`button`,{type:`button`,onClick:v,disabled:!n,className:`rounded border border-(--color-border) px-3 py-1.5 text-xs font-medium hover:bg-(--color-bg-hover) disabled:opacity-40`,children:`Take over`})})]}),(0,O.jsx)(`p`,{className:`border-b border-(--color-border) bg-(--color-amber)/10 px-3 py-2 text-xs text-(--color-amber)`,children:`Never paste passwords or one-time codes into chat — use takeover.`}),c&&(0,O.jsx)(`p`,{className:`border-b border-(--color-border) bg-(--color-bg-elevated) px-3 py-2 text-xs text-(--color-text-muted)`,children:c}),(0,O.jsx)(`div`,{ref:d,tabIndex:o?0:-1,onFocus:()=>p(!0),onBlur:()=>p(!1),onKeyDown:e=>{if(o&&!((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`v`)){if((e.ctrlKey||e.metaKey)&&(e.key.toLowerCase()===`c`||e.key.toLowerCase()===`x`)){e.preventDefault(),b({type:`selection-request`}),e.key.toLowerCase()===`x`&&x({kind:`key`,action:`down`,key:e.key});return}e.preventDefault(),e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey?x({kind:`text`,text:e.key}):x({kind:`key`,action:`down`,key:e.key})}},onKeyUp:e=>{o&&((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`v`||(e.preventDefault(),e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey||x({kind:`key`,action:`up`,key:e.key})))},onPaste:e=>{if(!o)return;e.preventDefault();let t=e.clipboardData.getData(`text`);t&&x({kind:`text`,text:t.slice(0,4096)})},className:`flex min-h-0 flex-1 items-center justify-center overflow-auto bg-black/20 p-3 outline-none ${o&&!f?`ring-2 ring-(--color-amber) ring-inset`:``}`,children:i?(0,O.jsx)(`img`,{src:`data:image/jpeg;base64,${i.data}`,width:i.w,height:i.h,alt:`Agent computer screencast`,draggable:!1,onPointerMove:e=>{let t=ee(e);t&&x({kind:`mouse`,action:`move`,...t,button:`left`,clickCount:1,deltaX:0,deltaY:0})},onPointerDown:e=>{let t=ee(e);t&&(d.current?.focus(),x({kind:`mouse`,action:`down`,...t,button:te[e.button]??`left`,clickCount:e.detail||1,deltaX:0,deltaY:0}))},onPointerUp:e=>{let t=ee(e);t&&x({kind:`mouse`,action:`up`,...t,button:te[e.button]??`left`,clickCount:e.detail||1,deltaX:0,deltaY:0})},onWheel:e=>{let t=ee(e);t&&x({kind:`mouse`,action:`wheel`,...t,button:`left`,clickCount:1,deltaX:e.deltaX,deltaY:e.deltaY})},onContextMenu:e=>{o&&e.preventDefault()},className:`max-h-full max-w-full rounded border border-(--color-border) ${o?`cursor-crosshair`:`pointer-events-none select-none`}`}):(0,O.jsx)(`p`,{className:`text-sm text-(--color-text-muted)`,children:`Waiting for a screencast frame…`})}),o&&!f&&(0,O.jsx)(`p`,{className:`border-t border-(--color-border) bg-(--color-amber)/10 px-3 py-2 text-xs text-(--color-amber)`,children:`Click the screen to send keystrokes to it.`}),m&&(0,O.jsx)(`p`,{className:`border-t border-(--color-border) bg-(--color-bg-elevated) px-3 py-2 text-xs text-(--color-text-muted)`,children:m})]}):(0,O.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 p-6 text-center`,children:[(0,O.jsx)(`p`,{className:`text-sm font-medium`,children:`The agent computer isn't available right now.`}),(0,O.jsx)(`p`,{className:`max-w-sm text-xs text-(--color-text-muted)`,children:`Bots can still browse the web and use tools — you just won't see a live screencast until the computer service starts.`})]}):(0,O.jsx)(`p`,{className:`p-6 text-sm text-(--color-text-muted)`,children:`Checking the computer service…`})}var jl=`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-xs`,Ml=`mb-1 block text-xs text-(--color-text-muted)`,Nl=`rounded border border-(--color-border) px-2 py-1 text-xs disabled:opacity-40`,Pl=0,Fl=()=>({id:Pl++,k:``,v:``,secret:!1}),Il=(e,t)=>`mcp/${e}/${t}`;function Ll(e){let t=(e.match(/"[^"]*"|'[^']*'|\S+/g)??[]).map(e=>/^["'].*["']$/.test(e)?e.slice(1,-1):e);return{command:t[0]??``,args:t.slice(1)}}var Rl=e=>/^https?:\/\//i.test(e.trim());function K(e){let t=e.trim();if(!t)return``;let n;if(Rl(t))try{n=new URL(t).hostname.replace(/^(mcp|www|api)\./,``).split(`.`)[0]??``}catch{n=``}else{let{command:e,args:r}=Ll(t);n=(r.find(e=>!e.startsWith(`-`))??e).split(`/`).pop()?.replace(/^(mcp-)?server-|-mcp(-server)?$/g,``)??``}return n.toLowerCase().replace(/[^a-z0-9-]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,32)}function q(e){let t=e.tools.length;switch(e.status){case`ready`:return{text:`ready — ${t} tool${t===1?``:`s`}`,tone:`ok`};case`needs-sign-in`:return e.alternative?{text:e.detail??`use the built-in instead: ${e.alternative}`,tone:`bad`}:{text:`needs sign-in${e.provider?` (${e.provider})`:``}`,tone:`warn`};case`needs-credential`:return{text:e.detail??`needs a credential`,tone:`warn`};case`unreachable`:return{text:`unreachable${e.detail?` — ${e.detail}`:``}`,tone:`bad`}}}var J={ok:`text-(--color-green)`,warn:`text-(--color-amber)`,bad:`text-(--color-red)`};function Y({pairs:e,onChange:t,keyLabel:n}){let r=(n,r)=>t(e.map(e=>e.id===n?{...e,...r}:e));return(0,O.jsxs)(`div`,{className:`space-y-1`,children:[e.map(i=>(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(`input`,{className:b(jl,`w-2/5`),placeholder:n,value:i.k,onChange:e=>r(i.id,{k:e.target.value})}),(0,O.jsx)(`input`,{className:jl,type:i.secret?`password`:`text`,placeholder:i.secret?`value (stored in your keychain)`:`value`,value:i.v,onChange:e=>r(i.id,{v:e.target.value})}),(0,O.jsxs)(`label`,{className:`flex shrink-0 items-center gap-1 text-[11px] text-(--color-text-muted)`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:i.secret,onChange:e=>r(i.id,{secret:e.target.checked}),"aria-label":`${i.k||n} is a secret`}),`secret`]}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>t(e.filter(e=>e.id!==i.id)),className:b(Nl,`text-(--color-text-muted)`),children:`×`})]},i.id)),(0,O.jsxs)(`button`,{type:`button`,onClick:()=>t([...e,Fl()]),className:b(Nl,`text-(--color-text-muted)`),children:[`+ add `,n.toLowerCase()]})]})}function X({entry:e,provider:t,onSubmit:n,error:r}){let[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``);return(0,O.jsxs)(`div`,{className:`mt-2 space-y-1 rounded bg-(--color-bg-elevated) p-2`,children:[(0,O.jsxs)(`p`,{className:`text-xs text-(--color-amber)`,children:[t??`This provider`,` needs an OAuth client you create yourself — a one-time setup that every`,` `,t??`provider`,` connector then shares.`]}),e&&e.setupSteps.length>0&&(0,O.jsx)(`ol`,{className:`list-decimal space-y-0.5 pl-5 text-[11px] text-(--color-text-muted)`,children:e.setupSteps.map(e=>(0,O.jsx)(`li`,{children:e},e))}),(0,O.jsxs)(`div`,{className:`flex gap-1`,children:[(0,O.jsx)(`input`,{className:jl,placeholder:`client ID`,value:i,onChange:e=>a(e.target.value)}),(0,O.jsx)(`input`,{type:`password`,className:jl,placeholder:`client secret`,value:o,onChange:e=>s(e.target.value)}),(0,O.jsx)(`button`,{type:`button`,disabled:!i.trim(),onClick:()=>n({clientId:i.trim(),...o.trim()?{clientSecret:o.trim()}:{}}),className:Nl,children:`Sign in`})]}),r&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:r})]})}function zl({catalog:e,bots:t,onCreated:n}){let[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)([]),[d,f]=(0,_.useState)(new Set),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(null),v=e.find(e=>e.name===r.trim()||e.name===a.trim()&&!r.trim())??null,y=Rl(r),b=a.trim()||(v?v.name:K(r)),x=e=>{i(e),s||o(K(e))};async function ee(){g(null),m(!0);try{let e=b,t;if(v&&!y&&(r.trim()===v.name||!r.trim()))t={name:e,description:v.description,builtin:v.name};else if(y)t={name:e,description:``,config:{transport:`http`,url:r.trim(),headers:await te(e)}};else{let{command:n,args:i}=Ll(r);if(!n)throw new ie(`Type a command, a URL, or a built-in name.`,400);t={name:e,description:``,config:{transport:`stdio`,command:n,args:i,env:await te(e)}}}d.size&&(t.botIds=Array.from(d));let a=await T.connectors.create(t);i(``),o(``),c(!1),u([]),f(new Set),n(a,a.check)}catch(e){g(e instanceof ie?e.message:`Failed to add connector`)}finally{m(!1)}}async function te(e){let t={};for(let n of l){let r=n.k.trim();if(r){if(n.secret){let i=Il(e,r);await T.secrets.set(i,n.v),t[r]=`{{secret:${i}}}`}else t[r]=n.v}}return t}let S=v&&(r.trim()===v.name||!r.trim())&&(a.trim()===v.name||r.trim()===v.name)?`${v.displayName} is built into ant-bot. ${v.description}`:y?`A remote server. If it needs a sign-in, that starts right after adding.`:r.trim()?`A local command ant-bot runs itself.`:null;return(0,O.jsxs)(`div`,{className:`mb-6 space-y-2 rounded border border-(--color-border) p-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:Ml,children:`Add`}),(0,O.jsx)(`input`,{className:jl,list:`antbot-catalog`,placeholder:`a built-in (${e.map(e=>e.name).join(`, `)||`gmail`}), a command, or a URL`,value:r,onChange:e=>x(e.target.value)}),(0,O.jsx)(`datalist`,{id:`antbot-catalog`,children:e.map(e=>(0,O.jsx)(`option`,{value:e.name,children:e.displayName},e.name))}),S&&(0,O.jsx)(`p`,{className:`mt-1 text-[11px] text-(--color-text-muted)`,children:S})]}),(0,O.jsx)(`div`,{className:`flex gap-2`,children:(0,O.jsxs)(`div`,{className:`w-1/3`,children:[(0,O.jsx)(`span`,{className:Ml,children:`Name`}),(0,O.jsx)(`input`,{className:jl,placeholder:`github`,value:a,onChange:e=>{o(e.target.value),c(!0)}})]})}),r.trim()&&!v&&(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:Ml,children:y?`Headers`:`Environment`}),(0,O.jsx)(Y,{pairs:l,onChange:u,keyLabel:y?`Header`:`VAR`})]}),t.length>0&&(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:Ml,children:`Give it to`}),(0,O.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:t.map(e=>(0,O.jsxs)(`label`,{className:`flex items-center gap-1 text-xs`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:d.has(e.id),onChange:t=>{let n=new Set(d);t.target.checked?n.add(e.id):n.delete(e.id),f(n)}}),e.name]},e.id))})]}),h&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:h}),(0,O.jsx)(`button`,{type:`button`,onClick:ee,disabled:p||!b||!r.trim()&&!v,className:`rounded bg-(--color-accent) px-3 py-1.5 text-xs font-medium text-(--color-accent-fg) disabled:opacity-40`,children:p?`Adding…`:`Add`})]})}function Bl({connector:e,catalog:t,assignedTo:n,initialCheck:r,onChanged:i}){let[a,o]=(0,_.useState)(r),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(null),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(!1),h=e.kind===`builtin`?t.find(t=>t.name===e.name)??null:null;(0,_.useEffect)(()=>{r&&(o(r),r.status===`needs-sign-in`&&r.selfRegistration===!1&&!r.alternative&&f(!0))},[r]);async function g(t={}){u(null);try{let{authorizeUrl:n}=await T.connectors.login(e.id,t);window.open(n,`_blank`,`noopener`),f(!1)}catch(e){let t=e instanceof ie?e.message:`Could not start sign-in`;u(t),/client ID|client secret/i.test(t)&&f(!0)}}async function v(){c(!0);try{let t=await T.connectors.check(e.id);o(t),t.status===`needs-sign-in`&&t.selfRegistration===!1&&!t.alternative&&f(!0),i()}catch(e){o({status:`unreachable`,tools:[],detail:e instanceof ie?e.message:`Check failed`})}finally{c(!1)}}let y=a?q(a):e.enabled?e.missingSecrets.length?{text:`missing secret: ${e.missingSecrets.join(`, `)}`,tone:`warn`}:e.signedIn?{text:`signed in`,tone:`ok`}:e.lastStatus===`ready`||e.lastStatus===`connected`?{text:`ready`,tone:`ok`}:e.lastStatus?{text:e.lastStatus.replace(/-/g,` `),tone:`warn`}:{text:`unchecked`,tone:`warn`}:{text:`disabled`,tone:`warn`},x=e.kind===`builtin`||e.config.transport!==`stdio`;return(0,O.jsxs)(`div`,{className:`border-b border-(--color-border) py-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium`,children:e.name}),(0,O.jsx)(`span`,{className:`ml-2 rounded bg-(--color-bg-elevated) px-1.5 py-0.5 text-[11px] text-(--color-text-muted)`,children:e.kind===`builtin`?`built-in`:e.config.transport}),(0,O.jsx)(`span`,{className:b(`ml-2 text-xs`,J[y.tone]),"data-testid":`connector-state`,children:y.text}),e.description&&(0,O.jsx)(`p`,{className:`truncate text-xs text-(--color-text-muted)`,title:e.description,children:e.description}),(0,O.jsx)(`p`,{className:`text-[11px] text-(--color-text-muted)`,children:n.length?`→ ${n.join(`, `)}`:`→ no bots yet — tick it in Bot settings`}),e.lastError&&!a&&y.tone!==`ok`&&(0,O.jsx)(`p`,{className:`text-[11px] text-(--color-text-muted)`,children:e.lastError})]}),x&&(0,O.jsx)(`button`,{type:`button`,onClick:e.signedIn?async()=>{await T.connectors.logout(e.id),i()}:()=>g(),className:Nl,children:e.signedIn?`Sign out`:`Sign in`}),(0,O.jsx)(`button`,{type:`button`,onClick:v,disabled:s,className:Nl,children:s?`Checking…`:`Check`}),(0,O.jsx)(`button`,{type:`button`,onClick:async()=>{await T.connectors.update(e.id,{enabled:!e.enabled}),i()},className:Nl,children:e.enabled?`Disable`:`Enable`}),(0,O.jsx)(`button`,{type:`button`,onClick:async()=>{await T.connectors.remove(e.id),i()},className:b(Nl,`text-(--color-red)`),children:`Delete`})]}),l&&!d&&(0,O.jsx)(`p`,{className:`mt-2 text-xs text-(--color-red)`,children:l}),d&&(0,O.jsx)(X,{entry:h,provider:a?.provider,onSubmit:g,error:l}),a&&a.tools.length>0&&(0,O.jsxs)(`div`,{className:`mt-1 text-xs`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>m(e=>!e),className:`text-(--color-text-muted) underline`,children:p?`hide tools`:`show ${a.tools.length} tools`}),p&&(0,O.jsx)(`ul`,{className:`mt-1 space-y-0.5`,children:a.tools.map(t=>(0,O.jsxs)(`li`,{className:`truncate`,title:t.description,children:[(0,O.jsx)(`code`,{children:`mcp__${e.name}__${t.name}`}),t.description&&(0,O.jsx)(`span`,{className:`ml-2 text-(--color-text-muted)`,children:t.description})]},t.name))})]})]})}function Vl(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)({}),[c,l]=(0,_.useState)({}),u=()=>{T.connectors.list().then(t),T.bots.list().then(async e=>{let t=e.map(e=>({id:e.bot.id,name:e.bot.name}));a(t);let n={};for(let e of t){let t=await T.bots.connectors.get(e.id).catch(()=>[]);for(let r of t)n[r.name]=[...n[r.name]??[],e.name]}s(n)}).catch(()=>a([]))};return(0,_.useEffect)(()=>{u(),T.connectors.catalog().then(r).catch(()=>r([]))},[]),(0,O.jsxs)(`div`,{className:`mx-auto max-w-4xl p-6`,children:[(0,O.jsx)(`h2`,{className:`mb-1 text-lg font-semibold`,children:`Connectors`}),(0,O.jsxs)(`p`,{className:`mb-4 text-xs text-(--color-text-muted)`,children:[`MCP servers your Bots can use: a built-in like Gmail, a command ant-bot runs, or a URL. Add one here, tick which Bots get it — a Bot without an assignment cannot see its tools at all. Tools reach Bots as`,` `,(0,O.jsx)(`code`,{children:`mcp__<name>__<tool>`}),` and still pass the permission gateway.`]}),(0,O.jsx)(zl,{catalog:n,bots:i,onCreated:(e,t)=>{l(n=>({...n,[e.id]:t})),u()}}),e.length===0?(0,O.jsx)(`p`,{className:`text-sm text-(--color-text-muted)`,children:`No connectors yet.`}):e.map(e=>(0,O.jsx)(Bl,{connector:e,catalog:n,assignedTo:o[e.name]??[],initialCheck:c[e.id]??null,onChanged:u},e.id))]})}var Hl=[{label:`New bot`,target:{kind:`newBot`}},{label:`Open settings`,target:{kind:`settings`}},{label:`Open rules`,target:{kind:`rules`}},{label:`Open usage`,target:{kind:`usage`}},{label:`Open workspace`,target:{kind:`workspace`}}];function Ul({open:e,onClose:t,onNavigate:n}){let[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)([]);if((0,_.useEffect)(()=>{e||(i(``),o([]))},[e]),(0,_.useEffect)(()=>{if(!r.trim()){o([]);return}let e=!1,t=setTimeout(()=>{T.search(r).then(t=>{e||o(t)})},150);return()=>{e=!0,clearTimeout(t)}},[r]),!e)return null;let s=Hl.filter(e=>e.label.toLowerCase().includes(r.toLowerCase()));function c(e){n(e),t()}return(0,O.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center bg-black/50 pt-24`,onClick:t,children:(0,O.jsxs)(`div`,{className:`w-full max-w-lg rounded-lg border border-(--color-border) bg-(--color-bg-elevated) shadow-2xl`,onClick:e=>e.stopPropagation(),children:[(0,O.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>e.key===`Escape`&&t(),placeholder:`Search bots, threads, messages, files… or run a command`,className:`w-full border-b border-(--color-border) bg-transparent px-4 py-3 text-sm outline-none`}),(0,O.jsxs)(`div`,{className:`max-h-96 overflow-y-auto p-1.5`,children:[s.length>0&&(0,O.jsxs)(`div`,{className:`mb-1`,children:[(0,O.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-semibold uppercase tracking-wide text-(--color-text-faint)`,children:`Actions`}),s.map(e=>(0,O.jsx)(`button`,{type:`button`,onClick:()=>c(e.target),className:`flex w-full items-center rounded px-2.5 py-1.5 text-left text-sm hover:bg-(--color-bg-hover)`,children:e.label},e.label))]}),a.length>0&&(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-semibold uppercase tracking-wide text-(--color-text-faint)`,children:`Results`}),a.map(e=>(0,O.jsxs)(`button`,{type:`button`,onClick:()=>e.threadId&&c({kind:`thread`,id:e.threadId}),className:`flex w-full flex-col items-start rounded px-2.5 py-1.5 text-left text-sm hover:bg-(--color-bg-hover)`,children:[(0,O.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`rounded bg-(--color-border) px-1 text-[10px] uppercase text-(--color-text-muted)`,children:e.kind}),(0,O.jsx)(`span`,{className:`truncate font-medium`,children:e.title})]}),e.snippet&&(0,O.jsx)(`span`,{className:`truncate text-xs text-(--color-text-muted)`,children:e.snippet})]},`${e.kind}-${e.id}`))]}),r.trim()&&s.length===0&&a.length===0&&(0,O.jsx)(`p`,{className:`px-2.5 py-4 text-center text-sm text-(--color-text-muted)`,children:`No results.`})]})]})})}var Wl=[{view:`thread`,label:`Chats`},{view:`workspace`,label:`Workspace`},{view:`computer`,label:`Computer`},{view:`rules`,label:`Rules`},{view:`connectors`,label:`Connectors`},{view:`usage`,label:`Usage`},{view:`settings`,label:`Settings`}],Gl={connecting:`Connecting…`,open:`Connected`,closed:`Disconnected`},Kl={connecting:`bg-(--color-amber) animate-pulse`,open:`bg-(--color-green)`,closed:`bg-(--color-red)`};function ql({connection:e,pendingCount:t,view:n,onChangeView:r,onOpenPalette:i}){return(0,O.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center justify-between border-b border-(--color-border) bg-(--color-bg-elevated) px-3`,children:[(0,O.jsx)(`nav`,{className:`flex items-center gap-1`,children:Wl.map(e=>(0,O.jsxs)(`button`,{type:`button`,onClick:()=>r(e.view),className:b(`rounded px-2.5 py-1 text-xs font-medium`,n===e.view?`bg-(--color-accent)/15 text-(--color-accent)`:`text-(--color-text-muted) hover:bg-(--color-bg-hover)`),children:[e.label,e.view===`rules`&&t>0&&(0,O.jsx)(`span`,{className:`ml-1.5 rounded-full bg-(--color-amber) px-1.5 py-0.5 text-[10px] font-semibold text-(--color-bg)`,children:t})]},e.view))}),(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,O.jsxs)(`button`,{type:`button`,onClick:i,className:`rounded border border-(--color-border) px-2.5 py-1 text-xs text-(--color-text-muted) hover:bg-(--color-bg-hover)`,children:[`Search… `,(0,O.jsx)(`span`,{className:`ml-1 opacity-60`,children:`⌘K`})]}),t>0&&(0,O.jsxs)(`span`,{className:`flex items-center gap-1 rounded-full bg-(--color-amber)/15 px-2 py-0.5 text-xs font-medium text-(--color-amber)`,children:[t,` pending approval`,t===1?``:`s`]}),(0,O.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-(--color-text-muted)`,children:[(0,O.jsx)(`span`,{className:b(`h-1.5 w-1.5 rounded-full`,Kl[e])}),Gl[e]]})]})]})}function Jl({children:e}){return(0,O.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:e})}function Yl({children:e}){return(0,O.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:e})}function Xl(){let e=oe(e=>e.bots),t=oe(e=>e.threads),n=oe(e=>e.activeThreadId),r=oe(e=>e.messagesByThread),i=oe(e=>e.pendingApprovals),a=oe(e=>e.connection),o=oe(e=>e.notifications),s=oe(e=>e.setBots),c=oe(e=>e.setThreads),l=oe(e=>e.setThreadMessages),u=oe(e=>e.setActiveThreadId),d=oe(e=>e.appendLocalMessage),f=oe(e=>e.dismissNotification),p=oe(e=>e.setPendingApprovals),[m,h]=(0,_.useState)(`thread`),[g,v]=(0,_.useState)(!1),[y,x]=(0,_.useState)(!1),[ee,te]=(0,_.useState)(null),[S,ne]=(0,_.useState)(null),[re,ie]=(0,_.useState)(!1),[C,w]=(0,_.useState)([]),[ae,se]=(0,_.useState)(`system`);(0,_.useEffect)(()=>{let e=document.documentElement,t=window.matchMedia(`(prefers-color-scheme: dark)`);function n(){let n=ae===`light`||ae===`system`&&!t.matches;e.classList.toggle(`light`,n)}return n(),t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[ae]),(0,_.useEffect)(()=>{T.bots.list().then(s),T.threads.list().then(c),T.skills.list().then(w),T.approvals.list().then(p).catch(()=>{});let e=E();return()=>e.close()},[s,c,p]);let ce=oe(e=>e.threadEpoch);(0,_.useEffect)(()=>{n&&(T.threads.get(n).then(({messages:e})=>{l(n,e)}),T.threads.markRead(n).catch(()=>{}))},[n,ce,l]),(0,_.useEffect)(()=>{function e(e){let t=e.metaKey||e.ctrlKey;t&&e.key.toLowerCase()===`n`?(e.preventDefault(),v(!0)):t&&e.key.toLowerCase()===`k`&&(e.preventDefault(),ie(!0))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let le=(0,_.useMemo)(()=>{let t={};for(let n of e)t[n.bot.id]=n;return t},[e]),D=(0,_.useMemo)(()=>Object.values(t).filter(e=>e.kind===`group`),[t]),ue=n?t[n]??null:null,de=n?r[n]??[]:[],fe=ue?e.find(e=>e.thread?.id===ue.id):void 0,pe=S?le[S]?.bot??null:null;async function k(){s(await T.bots.list())}async function me(e){x(!0),te(null);try{let t=await T.bots.create(e);await k(),v(!1),t.threadId&&(c(await T.threads.list()),u(t.threadId),h(`thread`))}catch(e){te(e instanceof Error?e.message:`Failed to create bot`)}finally{x(!1)}}async function he(e,t){if(!n)return;let r=await T.threads.postMessage(n,{contentMd:e,attachmentIds:t});d(n,r)}async function _e(){fe&&await T.bots.stop(fe.bot.id)}function ve(e){u(e),ne(null),h(`thread`)}function ye(e){e.kind===`thread`?ve(e.id):e.kind===`newBot`?v(!0):h(e.kind)}return(0,O.jsxs)(`div`,{className:`flex h-dvh flex-col overflow-hidden`,children:[(0,O.jsx)(ql,{connection:a,pendingCount:i.length,view:m,onChangeView:e=>{ne(null),h(e)},onOpenPalette:()=>ie(!0)}),(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,O.jsx)(ge,{entries:e,groupThreads:D,botsById:le,activeThreadId:n,onSelectThread:ve,onNewBot:()=>v(!0)}),(0,O.jsxs)(`main`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[m===`thread`&&(pe?(0,O.jsx)(ml,{bot:pe,onClose:()=>ne(null),onUpdated:t=>s(e.map(e=>e.bot.id===t.id?{...e,bot:t}:e)),onDuplicated:e=>{k(),ne(e.id)},onDeleted:()=>{ne(null),k()}}):(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[fe&&(0,O.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-(--color-border) px-4 py-2`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`text-lg leading-none`,children:fe.bot.avatarEmoji}),(0,O.jsx)(`span`,{className:`text-sm font-semibold`,children:fe.bot.name}),fe.bot.title&&(0,O.jsx)(`span`,{className:`text-xs text-(--color-text-muted)`,children:fe.bot.title})]}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>ne(fe.bot.id),className:`text-xs text-(--color-text-muted) hover:text-(--color-text)`,children:`Bot settings`})]}),(0,O.jsx)(nl,{thread:ue,messages:de,botsById:le,bots:e,skills:C,running:fe?.bot.state===`running`||fe?.bot.state===`queued`,onSend:he,onStop:_e})]})),m===`rules`&&(0,O.jsx)(Jl,{children:(0,O.jsx)(_l,{})}),m===`connectors`&&(0,O.jsx)(Jl,{children:(0,O.jsx)(Vl,{})}),m===`usage`&&(0,O.jsx)(Jl,{children:(0,O.jsx)(yl,{})}),m===`settings`&&(0,O.jsx)(Jl,{children:(0,O.jsx)(Cl,{onSettingsChange:e=>se(e.theme)})}),m===`workspace`&&(0,O.jsx)(Yl,{children:(0,O.jsx)(kl,{})}),m===`computer`&&(0,O.jsx)(Yl,{children:(0,O.jsx)(Al,{})})]})]}),o.length>0&&(0,O.jsx)(`div`,{className:`pointer-events-none fixed bottom-24 right-4 z-50 flex flex-col gap-2`,children:o.slice(-4).map(e=>(0,O.jsxs)(`div`,{className:b(`pointer-events-auto w-72 rounded-md border p-3 text-sm shadow-lg`,e.level===`error`&&`border-(--color-red)/50 bg-(--color-bg-elevated)`,e.level===`warn`&&`border-(--color-amber)/50 bg-(--color-bg-elevated)`,e.level===`info`&&`border-(--color-border) bg-(--color-bg-elevated)`),children:[(0,O.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,O.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>f(e.id),className:`text-(--color-text-faint) hover:text-(--color-text)`,children:`×`})]}),e.body&&(0,O.jsx)(`p`,{className:`mt-0.5 text-xs text-(--color-text-muted)`,children:e.body})]},e.id))}),g&&(0,O.jsx)(il,{onCreate:me,onClose:()=>v(!1),busy:y,error:ee}),(0,O.jsx)(Ul,{open:re,onClose:()=>ie(!1),onNavigate:ye})]})}var Zl=document.getElementById(`root`);if(!Zl)throw Error(`#root not found`);(0,v.createRoot)(Zl).render((0,O.jsx)(_.StrictMode,{children:(0,O.jsx)(Xl,{})}));
|
package/web/dist/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>ant-bot</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-Cpi4IKb8.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/assets/index-Bd_zE95N.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|