operatr 0.12.0
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/LICENSE +21 -0
- package/README.md +87 -0
- package/bin/operator.js +14 -0
- package/package.json +49 -0
- package/public/assets/arc-C3oZj6HF.js +1 -0
- package/public/assets/architectureDiagram-3BPJPVTR-BFENfeP2.js +36 -0
- package/public/assets/blockDiagram-GPEHLZMM-C1A8KgJE.js +132 -0
- package/public/assets/c4Diagram-AAUBKEIU-03jekykM.js +10 -0
- package/public/assets/channel-BFxhh-e6.js +1 -0
- package/public/assets/chunk-2J33WTMH-Cd16JLFK.js +1 -0
- package/public/assets/chunk-4BX2VUAB-70lJk7KH.js +1 -0
- package/public/assets/chunk-55IACEB6-DzNNKRy6.js +1 -0
- package/public/assets/chunk-727SXJPM-CZjd3AP5.js +206 -0
- package/public/assets/chunk-AQP2D5EJ-B_48wDVV.js +231 -0
- package/public/assets/chunk-FMBD7UC4-u93wErxL.js +15 -0
- package/public/assets/chunk-ND2GUHAM-GWZJNHoC.js +1 -0
- package/public/assets/chunk-QZHKN3VN-BHGAVy4h.js +1 -0
- package/public/assets/classDiagram-4FO5ZUOK-BWxq3avf.js +1 -0
- package/public/assets/classDiagram-v2-Q7XG4LA2-BWxq3avf.js +1 -0
- package/public/assets/cose-bilkent-S5V4N54A-HdalsDiB.js +1 -0
- package/public/assets/cytoscape.esm-DTSO7Bv0.js +331 -0
- package/public/assets/dagre-BM42HDAG-DlIcXTjT.js +4 -0
- package/public/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/public/assets/diagram-2AECGRRQ-D0GHawOW.js +43 -0
- package/public/assets/diagram-5GNKFQAL-Cd36guSH.js +10 -0
- package/public/assets/diagram-KO2AKTUF-DtYM_ie4.js +3 -0
- package/public/assets/diagram-LMA3HP47-2KIpJ02P.js +24 -0
- package/public/assets/diagram-OG6HWLK6-DFwD1qiv.js +24 -0
- package/public/assets/erDiagram-TEJ5UH35-DslM2UDd.js +85 -0
- package/public/assets/flowDiagram-I6XJVG4X-DGGy4pet.js +162 -0
- package/public/assets/ganttDiagram-6RSMTGT7-CPWMAKNx.js +292 -0
- package/public/assets/gitGraphDiagram-PVQCEYII-DPlcGM7A.js +106 -0
- package/public/assets/graph-CAnANduQ.js +1 -0
- package/public/assets/index-C3Ld66t2.js +348 -0
- package/public/assets/index-CglXVmBD.css +32 -0
- package/public/assets/infoDiagram-5YYISTIA-BvfzdQ33.js +2 -0
- package/public/assets/init-Gi6I4Gst.js +1 -0
- package/public/assets/ishikawaDiagram-YF4QCWOH-BXBtXmNa.js +70 -0
- package/public/assets/journeyDiagram-JHISSGLW-0k6NYR9M.js +139 -0
- package/public/assets/kanban-definition-UN3LZRKU-Br-pJVoB.js +89 -0
- package/public/assets/katex-C5jXJg4s.js +257 -0
- package/public/assets/layout-DGIYPm2g.js +1 -0
- package/public/assets/linear-Dw294nF-.js +1 -0
- package/public/assets/mermaid.core-890uePvN.js +309 -0
- package/public/assets/mindmap-definition-RKZ34NQL-r7qhn-Fa.js +96 -0
- package/public/assets/ordinal-Cboi1Yqb.js +1 -0
- package/public/assets/pieDiagram-4H26LBE5-B4p_YihD.js +30 -0
- package/public/assets/quadrantDiagram-W4KKPZXB-DYJjK2r-.js +7 -0
- package/public/assets/requirementDiagram-4Y6WPE33-kRWJDus9.js +84 -0
- package/public/assets/sankeyDiagram-5OEKKPKP-Cs0dDmxJ.js +40 -0
- package/public/assets/sequenceDiagram-3UESZ5HK-e3s6dVA4.js +162 -0
- package/public/assets/stateDiagram-AJRCARHV-CpVW_jun.js +1 -0
- package/public/assets/stateDiagram-v2-BHNVJYJU-BZ88_i1s.js +1 -0
- package/public/assets/timeline-definition-PNZ67QCA-BXF5ufP-.js +120 -0
- package/public/assets/vennDiagram-CIIHVFJN-DhA6SmOv.js +34 -0
- package/public/assets/wardley-L42UT6IY-DwnN1FeQ.js +173 -0
- package/public/assets/wardleyDiagram-YWT4CUSO-C4y3XA-b.js +78 -0
- package/public/assets/xychartDiagram-2RQKCTM6-CrWgrBy2.js +7 -0
- package/public/index.html +19 -0
- package/public/operator-devtools.iife.js +416 -0
- package/public/operator-devtools.js +5870 -0
- package/server/index.js +9458 -0
- package/server/runner.js +3799 -0
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
var OperatorDevtools=(function(ge){"use strict";function Xt(n){const t={...tn(),...window.__OPERATOR_DEVTOOLS__??{},...n??{}};return!t.server||!t.projectId||!t.taskId?(console.warn("[operator-devtools] missing config — need { server, projectId, taskId }. Set window.__OPERATOR_DEVTOOLS__, pass it to init(), or use data-operator-* script attrs. Overlay disabled."),null):{server:nn(t.server),projectId:t.projectId,taskId:t.taskId,taskLabel:t.taskLabel,color:t.color,open:t.open??!1,favicon:en(t.favicon)}}function en(n){return n==="always"||n==="off"?n:"auto"}function tn(){const n=document.currentScript??document.querySelector("script[data-operator-task]");if(!n)return{};const e=n.dataset,t={};return e.operatorServer&&(t.server=e.operatorServer),e.operatorProject&&(t.projectId=e.operatorProject),e.operatorTask&&(t.taskId=e.operatorTask),e.operatorLabel&&(t.taskLabel=e.operatorLabel),e.operatorOpen!=null&&(t.open=!/^(false|0|no|off)$/i.test(e.operatorOpen.trim())),e.operatorFavicon&&(t.favicon=e.operatorFavicon),t}function nn(n){return n.replace(/\/+$/,"")}var k;(function(n){n.assertEqual=i=>{};function e(i){}n.assertIs=e;function t(i){throw new Error}n.assertNever=t,n.arrayToEnum=i=>{const r={};for(const o of i)r[o]=o;return r},n.getValidEnumValues=i=>{const r=n.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),o={};for(const a of r)o[a]=i[a];return n.objectValues(o)},n.objectValues=i=>n.objectKeys(i).map(function(r){return i[r]}),n.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const r=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&r.push(o);return r},n.find=(i,r)=>{for(const o of i)if(r(o))return o},n.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function s(i,r=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(r)}n.joinValues=s,n.jsonStringifyReplacer=(i,r)=>typeof r=="bigint"?r.toString():r})(k||(k={}));var st;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(st||(st={}));const m=k.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),U=n=>{switch(typeof n){case"undefined":return m.undefined;case"string":return m.string;case"number":return Number.isNaN(n)?m.nan:m.number;case"boolean":return m.boolean;case"function":return m.function;case"bigint":return m.bigint;case"symbol":return m.symbol;case"object":return Array.isArray(n)?m.array:n===null?m.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?m.promise:typeof Map<"u"&&n instanceof Map?m.map:typeof Set<"u"&&n instanceof Set?m.set:typeof Date<"u"&&n instanceof Date?m.date:m.object;default:return m.unknown}},l=k.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class B extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(r){return r.message},s={_errors:[]},i=r=>{for(const o of r.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)s._errors.push(t(o));else{let a=s,c=0;for(;c<o.path.length;){const p=o.path[c];c===o.path.length-1?(a[p]=a[p]||{_errors:[]},a[p]._errors.push(t(o))):a[p]=a[p]||{_errors:[]},a=a[p],c++}}};return i(this),s}static assert(e){if(!(e instanceof B))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,k.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const i of this.issues)if(i.path.length>0){const r=i.path[0];t[r]=t[r]||[],t[r].push(e(i))}else s.push(e(i));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}B.create=n=>new B(n);const Pe=(n,e)=>{let t;switch(n.code){case l.invalid_type:n.received===m.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case l.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,k.jsonStringifyReplacer)}`;break;case l.unrecognized_keys:t=`Unrecognized key(s) in object: ${k.joinValues(n.keys,", ")}`;break;case l.invalid_union:t="Invalid input";break;case l.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${k.joinValues(n.options)}`;break;case l.invalid_enum_value:t=`Invalid enum value. Expected ${k.joinValues(n.options)}, received '${n.received}'`;break;case l.invalid_arguments:t="Invalid function arguments";break;case l.invalid_return_type:t="Invalid function return type";break;case l.invalid_date:t="Invalid date";break;case l.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:k.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case l.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="bigint"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case l.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case l.custom:t="Invalid input";break;case l.invalid_intersection_types:t="Intersection results could not be merged";break;case l.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case l.not_finite:t="Number must be finite";break;default:t=e.defaultError,k.assertNever(n)}return{message:t}};let sn=Pe;function rn(){return sn}const on=n=>{const{data:e,path:t,errorMaps:s,issueData:i}=n,r=[...t,...i.path||[]],o={...i,path:r};if(i.message!==void 0)return{...i,path:r,message:i.message};let a="";const c=s.filter(p=>!!p).slice().reverse();for(const p of c)a=p(o,{data:e,defaultError:a}).message;return{...i,path:r,message:a}};function h(n,e){const t=rn(),s=on({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===Pe?void 0:Pe].filter(i=>!!i)});n.common.issues.push(s)}class ${constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const i of t){if(i.status==="aborted")return y;i.status==="dirty"&&e.dirty(),s.push(i.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const i of t){const r=await i.key,o=await i.value;s.push({key:r,value:o})}return $.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const i of t){const{key:r,value:o}=i;if(r.status==="aborted"||o.status==="aborted")return y;r.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),r.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(s[r.value]=o.value)}return{status:e.value,value:s}}}const y=Object.freeze({status:"aborted"}),oe=n=>({status:"dirty",value:n}),P=n=>({status:"valid",value:n}),it=n=>n.status==="aborted",rt=n=>n.status==="dirty",ee=n=>n.status==="valid",ye=n=>typeof Promise<"u"&&n instanceof Promise;var g;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e?.message})(g||(g={}));class j{constructor(e,t,s,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const ot=(n,e)=>{if(ee(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new B(n.common.issues);return this._error=t,this._error}}};function b(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:i}=n;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(o,a)=>{const{message:c}=n;return o.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??s??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:c??t??a.defaultError}},description:i}}class x{get description(){return this._def.description}_getType(e){return U(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:U(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new $,ctx:{common:e.parent.common,data:e.data,parsedType:U(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ye(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){const s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:U(e)},i=this._parseSync({data:e,path:s.path,parent:s});return ot(s,i)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:U(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:t});return ee(s)?{value:s.value}:{issues:t.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(s=>ee(s)?{value:s.value}:{issues:t.common.issues})}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:U(e)},i=this._parse({data:e,path:s.path,parent:s}),r=await(ye(i)?i:Promise.resolve(i));return ot(s,r)}refine(e,t){const s=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,r)=>{const o=e(i),a=()=>r.addIssue({code:l.custom,...s(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,t){return this._refinement((s,i)=>e(s)?!0:(i.addIssue(typeof t=="function"?t(s,i):t),!1))}_refinement(e){return new G({schema:this,typeName:v.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return Z.create(this,this._def)}nullable(){return Q.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return L.create(this)}promise(){return _e.create(this,this._def)}or(e){return be.create([this,e],this._def)}and(e){return xe.create(this,e,this._def)}transform(e){return new G({...b(this._def),schema:this,typeName:v.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Se({...b(this._def),innerType:this,defaultValue:t,typeName:v.ZodDefault})}brand(){return new mt({typeName:v.ZodBranded,type:this,...b(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Ce({...b(this._def),innerType:this,catchValue:t,typeName:v.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ke.create(this,e)}readonly(){return Ee.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const an=/^c[^\s-]{8,}$/i,cn=/^[0-9a-z]+$/,dn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ln=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,pn=/^[a-z0-9_-]{21}$/i,un=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,hn=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,fn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,mn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Me;const gn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,yn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,vn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,bn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,xn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,kn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,at="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",wn=new RegExp(`^${at}$`);function ct(n){let e="[0-5]\\d";n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`);const t=n.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function _n(n){return new RegExp(`^${ct(n)}$`)}function Sn(n){let e=`${at}T${ct(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Cn(n,e){return!!((e==="v4"||!e)&&gn.test(n)||(e==="v6"||!e)&&vn.test(n))}function En(n,e){if(!un.test(n))return!1;try{const[t]=n.split(".");if(!t)return!1;const s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),i=JSON.parse(atob(s));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return!1}}function Tn(n,e){return!!((e==="v4"||!e)&&yn.test(n)||(e==="v6"||!e)&&bn.test(n))}class D extends x{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==m.string){const r=this._getOrReturnCtx(e);return h(r,{code:l.invalid_type,expected:m.string,received:r.parsedType}),y}const s=new $;let i;for(const r of this._def.checks)if(r.kind==="min")e.data.length<r.value&&(i=this._getOrReturnCtx(e,i),h(i,{code:l.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),s.dirty());else if(r.kind==="max")e.data.length>r.value&&(i=this._getOrReturnCtx(e,i),h(i,{code:l.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),s.dirty());else if(r.kind==="length"){const o=e.data.length>r.value,a=e.data.length<r.value;(o||a)&&(i=this._getOrReturnCtx(e,i),o?h(i,{code:l.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):a&&h(i,{code:l.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),s.dirty())}else if(r.kind==="email")fn.test(e.data)||(i=this._getOrReturnCtx(e,i),h(i,{validation:"email",code:l.invalid_string,message:r.message}),s.dirty());else if(r.kind==="emoji")Me||(Me=new RegExp(mn,"u")),Me.test(e.data)||(i=this._getOrReturnCtx(e,i),h(i,{validation:"emoji",code:l.invalid_string,message:r.message}),s.dirty());else if(r.kind==="uuid")ln.test(e.data)||(i=this._getOrReturnCtx(e,i),h(i,{validation:"uuid",code:l.invalid_string,message:r.message}),s.dirty());else if(r.kind==="nanoid")pn.test(e.data)||(i=this._getOrReturnCtx(e,i),h(i,{validation:"nanoid",code:l.invalid_string,message:r.message}),s.dirty());else if(r.kind==="cuid")an.test(e.data)||(i=this._getOrReturnCtx(e,i),h(i,{validation:"cuid",code:l.invalid_string,message:r.message}),s.dirty());else if(r.kind==="cuid2")cn.test(e.data)||(i=this._getOrReturnCtx(e,i),h(i,{validation:"cuid2",code:l.invalid_string,message:r.message}),s.dirty());else if(r.kind==="ulid")dn.test(e.data)||(i=this._getOrReturnCtx(e,i),h(i,{validation:"ulid",code:l.invalid_string,message:r.message}),s.dirty());else if(r.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),h(i,{validation:"url",code:l.invalid_string,message:r.message}),s.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),h(i,{validation:"regex",code:l.invalid_string,message:r.message}),s.dirty())):r.kind==="trim"?e.data=e.data.trim():r.kind==="includes"?e.data.includes(r.value,r.position)||(i=this._getOrReturnCtx(e,i),h(i,{code:l.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),s.dirty()):r.kind==="toLowerCase"?e.data=e.data.toLowerCase():r.kind==="toUpperCase"?e.data=e.data.toUpperCase():r.kind==="startsWith"?e.data.startsWith(r.value)||(i=this._getOrReturnCtx(e,i),h(i,{code:l.invalid_string,validation:{startsWith:r.value},message:r.message}),s.dirty()):r.kind==="endsWith"?e.data.endsWith(r.value)||(i=this._getOrReturnCtx(e,i),h(i,{code:l.invalid_string,validation:{endsWith:r.value},message:r.message}),s.dirty()):r.kind==="datetime"?Sn(r).test(e.data)||(i=this._getOrReturnCtx(e,i),h(i,{code:l.invalid_string,validation:"datetime",message:r.message}),s.dirty()):r.kind==="date"?wn.test(e.data)||(i=this._getOrReturnCtx(e,i),h(i,{code:l.invalid_string,validation:"date",message:r.message}),s.dirty()):r.kind==="time"?_n(r).test(e.data)||(i=this._getOrReturnCtx(e,i),h(i,{code:l.invalid_string,validation:"time",message:r.message}),s.dirty()):r.kind==="duration"?hn.test(e.data)||(i=this._getOrReturnCtx(e,i),h(i,{validation:"duration",code:l.invalid_string,message:r.message}),s.dirty()):r.kind==="ip"?Cn(e.data,r.version)||(i=this._getOrReturnCtx(e,i),h(i,{validation:"ip",code:l.invalid_string,message:r.message}),s.dirty()):r.kind==="jwt"?En(e.data,r.alg)||(i=this._getOrReturnCtx(e,i),h(i,{validation:"jwt",code:l.invalid_string,message:r.message}),s.dirty()):r.kind==="cidr"?Tn(e.data,r.version)||(i=this._getOrReturnCtx(e,i),h(i,{validation:"cidr",code:l.invalid_string,message:r.message}),s.dirty()):r.kind==="base64"?xn.test(e.data)||(i=this._getOrReturnCtx(e,i),h(i,{validation:"base64",code:l.invalid_string,message:r.message}),s.dirty()):r.kind==="base64url"?kn.test(e.data)||(i=this._getOrReturnCtx(e,i),h(i,{validation:"base64url",code:l.invalid_string,message:r.message}),s.dirty()):k.assertNever(r);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(i=>e.test(i),{validation:t,code:l.invalid_string,...g.errToObj(s)})}_addCheck(e){return new D({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...g.errToObj(e)})}url(e){return this._addCheck({kind:"url",...g.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...g.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...g.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...g.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...g.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...g.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...g.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...g.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...g.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...g.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...g.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...g.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...g.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...g.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...g.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...g.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...g.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...g.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...g.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...g.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...g.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...g.errToObj(t)})}nonempty(e){return this.min(1,g.errToObj(e))}trim(){return new D({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new D({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new D({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}D.create=n=>new D({checks:[],typeName:v.ZodString,coerce:n?.coerce??!1,...b(n)});function In(n,e){const t=(n.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,i=t>s?t:s,r=Number.parseInt(n.toFixed(i).replace(".","")),o=Number.parseInt(e.toFixed(i).replace(".",""));return r%o/10**i}class te extends x{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==m.number){const r=this._getOrReturnCtx(e);return h(r,{code:l.invalid_type,expected:m.number,received:r.parsedType}),y}let s;const i=new $;for(const r of this._def.checks)r.kind==="int"?k.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:l.invalid_type,expected:"integer",received:"float",message:r.message}),i.dirty()):r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(s=this._getOrReturnCtx(e,s),h(s,{code:l.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),i.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(s=this._getOrReturnCtx(e,s),h(s,{code:l.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),i.dirty()):r.kind==="multipleOf"?In(e.data,r.value)!==0&&(s=this._getOrReturnCtx(e,s),h(s,{code:l.not_multiple_of,multipleOf:r.value,message:r.message}),i.dirty()):r.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:l.not_finite,message:r.message}),i.dirty()):k.assertNever(r);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,g.toString(t))}gt(e,t){return this.setLimit("min",e,!1,g.toString(t))}lte(e,t){return this.setLimit("max",e,!0,g.toString(t))}lt(e,t){return this.setLimit("max",e,!1,g.toString(t))}setLimit(e,t,s,i){return new te({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:g.toString(i)}]})}_addCheck(e){return new te({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:g.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:g.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:g.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:g.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:g.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&k.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}te.create=n=>new te({checks:[],typeName:v.ZodNumber,coerce:n?.coerce||!1,...b(n)});class ae extends x{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==m.bigint)return this._getInvalidInput(e);let s;const i=new $;for(const r of this._def.checks)r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(s=this._getOrReturnCtx(e,s),h(s,{code:l.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),i.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(s=this._getOrReturnCtx(e,s),h(s,{code:l.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),i.dirty()):r.kind==="multipleOf"?e.data%r.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),h(s,{code:l.not_multiple_of,multipleOf:r.value,message:r.message}),i.dirty()):k.assertNever(r);return{status:i.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return h(t,{code:l.invalid_type,expected:m.bigint,received:t.parsedType}),y}gte(e,t){return this.setLimit("min",e,!0,g.toString(t))}gt(e,t){return this.setLimit("min",e,!1,g.toString(t))}lte(e,t){return this.setLimit("max",e,!0,g.toString(t))}lt(e,t){return this.setLimit("max",e,!1,g.toString(t))}setLimit(e,t,s,i){return new ae({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:g.toString(i)}]})}_addCheck(e){return new ae({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:g.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ae.create=n=>new ae({checks:[],typeName:v.ZodBigInt,coerce:n?.coerce??!1,...b(n)});class je extends x{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==m.boolean){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:m.boolean,received:s.parsedType}),y}return P(e.data)}}je.create=n=>new je({typeName:v.ZodBoolean,coerce:n?.coerce||!1,...b(n)});class ve extends x{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==m.date){const r=this._getOrReturnCtx(e);return h(r,{code:l.invalid_type,expected:m.date,received:r.parsedType}),y}if(Number.isNaN(e.data.getTime())){const r=this._getOrReturnCtx(e);return h(r,{code:l.invalid_date}),y}const s=new $;let i;for(const r of this._def.checks)r.kind==="min"?e.data.getTime()<r.value&&(i=this._getOrReturnCtx(e,i),h(i,{code:l.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),s.dirty()):r.kind==="max"?e.data.getTime()>r.value&&(i=this._getOrReturnCtx(e,i),h(i,{code:l.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),s.dirty()):k.assertNever(r);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ve({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:g.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:g.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}ve.create=n=>new ve({checks:[],coerce:n?.coerce||!1,typeName:v.ZodDate,...b(n)});class dt extends x{_parse(e){if(this._getType(e)!==m.symbol){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:m.symbol,received:s.parsedType}),y}return P(e.data)}}dt.create=n=>new dt({typeName:v.ZodSymbol,...b(n)});class Le extends x{_parse(e){if(this._getType(e)!==m.undefined){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:m.undefined,received:s.parsedType}),y}return P(e.data)}}Le.create=n=>new Le({typeName:v.ZodUndefined,...b(n)});class Ne extends x{_parse(e){if(this._getType(e)!==m.null){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:m.null,received:s.parsedType}),y}return P(e.data)}}Ne.create=n=>new Ne({typeName:v.ZodNull,...b(n)});class lt extends x{constructor(){super(...arguments),this._any=!0}_parse(e){return P(e.data)}}lt.create=n=>new lt({typeName:v.ZodAny,...b(n)});class ze extends x{constructor(){super(...arguments),this._unknown=!0}_parse(e){return P(e.data)}}ze.create=n=>new ze({typeName:v.ZodUnknown,...b(n)});class F extends x{_parse(e){const t=this._getOrReturnCtx(e);return h(t,{code:l.invalid_type,expected:m.never,received:t.parsedType}),y}}F.create=n=>new F({typeName:v.ZodNever,...b(n)});class pt extends x{_parse(e){if(this._getType(e)!==m.undefined){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:m.void,received:s.parsedType}),y}return P(e.data)}}pt.create=n=>new pt({typeName:v.ZodVoid,...b(n)});class L extends x{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),i=this._def;if(t.parsedType!==m.array)return h(t,{code:l.invalid_type,expected:m.array,received:t.parsedType}),y;if(i.exactLength!==null){const o=t.data.length>i.exactLength.value,a=t.data.length<i.exactLength.value;(o||a)&&(h(t,{code:o?l.too_big:l.too_small,minimum:a?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),s.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(h(t,{code:l.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),s.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(h(t,{code:l.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((o,a)=>i.type._parseAsync(new j(t,o,t.path,a)))).then(o=>$.mergeArray(s,o));const r=[...t.data].map((o,a)=>i.type._parseSync(new j(t,o,t.path,a)));return $.mergeArray(s,r)}get element(){return this._def.type}min(e,t){return new L({...this._def,minLength:{value:e,message:g.toString(t)}})}max(e,t){return new L({...this._def,maxLength:{value:e,message:g.toString(t)}})}length(e,t){return new L({...this._def,exactLength:{value:e,message:g.toString(t)}})}nonempty(e){return this.min(1,e)}}L.create=(n,e)=>new L({type:n,minLength:null,maxLength:null,exactLength:null,typeName:v.ZodArray,...b(e)});function ne(n){if(n instanceof C){const e={};for(const t in n.shape){const s=n.shape[t];e[t]=Z.create(ne(s))}return new C({...n._def,shape:()=>e})}else return n instanceof L?new L({...n._def,type:ne(n.element)}):n instanceof Z?Z.create(ne(n.unwrap())):n instanceof Q?Q.create(ne(n.unwrap())):n instanceof J?J.create(n.items.map(e=>ne(e))):n}class C extends x{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=k.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==m.object){const p=this._getOrReturnCtx(e);return h(p,{code:l.invalid_type,expected:m.object,received:p.parsedType}),y}const{status:s,ctx:i}=this._processInputParams(e),{shape:r,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof F&&this._def.unknownKeys==="strip"))for(const p in i.data)o.includes(p)||a.push(p);const c=[];for(const p of o){const u=r[p],S=i.data[p];c.push({key:{status:"valid",value:p},value:u._parse(new j(i,S,i.path,p)),alwaysSet:p in i.data})}if(this._def.catchall instanceof F){const p=this._def.unknownKeys;if(p==="passthrough")for(const u of a)c.push({key:{status:"valid",value:u},value:{status:"valid",value:i.data[u]}});else if(p==="strict")a.length>0&&(h(i,{code:l.unrecognized_keys,keys:a}),s.dirty());else if(p!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const p=this._def.catchall;for(const u of a){const S=i.data[u];c.push({key:{status:"valid",value:u},value:p._parse(new j(i,S,i.path,u)),alwaysSet:u in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const p=[];for(const u of c){const S=await u.key,E=await u.value;p.push({key:S,value:E,alwaysSet:u.alwaysSet})}return p}).then(p=>$.mergeObjectSync(s,p)):$.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(e){return g.errToObj,new C({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{const i=this._def.errorMap?.(t,s).message??s.defaultError;return t.code==="unrecognized_keys"?{message:g.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new C({...this._def,unknownKeys:"strip"})}passthrough(){return new C({...this._def,unknownKeys:"passthrough"})}extend(e){return new C({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new C({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:v.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new C({...this._def,catchall:e})}pick(e){const t={};for(const s of k.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new C({...this._def,shape:()=>t})}omit(e){const t={};for(const s of k.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new C({...this._def,shape:()=>t})}deepPartial(){return ne(this)}partial(e){const t={};for(const s of k.objectKeys(this.shape)){const i=this.shape[s];e&&!e[s]?t[s]=i:t[s]=i.optional()}return new C({...this._def,shape:()=>t})}required(e){const t={};for(const s of k.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let r=this.shape[s];for(;r instanceof Z;)r=r._def.innerType;t[s]=r}return new C({...this._def,shape:()=>t})}keyof(){return ht(k.objectKeys(this.shape))}}C.create=(n,e)=>new C({shape:()=>n,unknownKeys:"strip",catchall:F.create(),typeName:v.ZodObject,...b(e)}),C.strictCreate=(n,e)=>new C({shape:()=>n,unknownKeys:"strict",catchall:F.create(),typeName:v.ZodObject,...b(e)}),C.lazycreate=(n,e)=>new C({shape:n,unknownKeys:"strip",catchall:F.create(),typeName:v.ZodObject,...b(e)});class be extends x{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function i(r){for(const a of r)if(a.result.status==="valid")return a.result;for(const a of r)if(a.result.status==="dirty")return t.common.issues.push(...a.ctx.common.issues),a.result;const o=r.map(a=>new B(a.ctx.common.issues));return h(t,{code:l.invalid_union,unionErrors:o}),y}if(t.common.async)return Promise.all(s.map(async r=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await r._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(i);{let r;const o=[];for(const c of s){const p={...t,common:{...t.common,issues:[]},parent:null},u=c._parseSync({data:t.data,path:t.path,parent:p});if(u.status==="valid")return u;u.status==="dirty"&&!r&&(r={result:u,ctx:p}),p.common.issues.length&&o.push(p.common.issues)}if(r)return t.common.issues.push(...r.ctx.common.issues),r.result;const a=o.map(c=>new B(c));return h(t,{code:l.invalid_union,unionErrors:a}),y}}get options(){return this._def.options}}be.create=(n,e)=>new be({options:n,typeName:v.ZodUnion,...b(e)});const q=n=>n instanceof qe?q(n.schema):n instanceof G?q(n.innerType()):n instanceof we?[n.value]:n instanceof Y?n.options:n instanceof Ze?k.objectValues(n.enum):n instanceof Se?q(n._def.innerType):n instanceof Le?[void 0]:n instanceof Ne?[null]:n instanceof Z?[void 0,...q(n.unwrap())]:n instanceof Q?[null,...q(n.unwrap())]:n instanceof mt||n instanceof Ee?q(n.unwrap()):n instanceof Ce?q(n._def.innerType):[];class Be extends x{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==m.object)return h(t,{code:l.invalid_type,expected:m.object,received:t.parsedType}),y;const s=this.discriminator,i=t.data[s],r=this.optionsMap.get(i);return r?t.common.async?r._parseAsync({data:t.data,path:t.path,parent:t}):r._parseSync({data:t.data,path:t.path,parent:t}):(h(t,{code:l.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const i=new Map;for(const r of t){const o=q(r.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const a of o){if(i.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);i.set(a,r)}}return new Be({typeName:v.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...b(s)})}}function De(n,e){const t=U(n),s=U(e);if(n===e)return{valid:!0,data:n};if(t===m.object&&s===m.object){const i=k.objectKeys(e),r=k.objectKeys(n).filter(a=>i.indexOf(a)!==-1),o={...n,...e};for(const a of r){const c=De(n[a],e[a]);if(!c.valid)return{valid:!1};o[a]=c.data}return{valid:!0,data:o}}else if(t===m.array&&s===m.array){if(n.length!==e.length)return{valid:!1};const i=[];for(let r=0;r<n.length;r++){const o=n[r],a=e[r],c=De(o,a);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return t===m.date&&s===m.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class xe extends x{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),i=(r,o)=>{if(it(r)||it(o))return y;const a=De(r.value,o.value);return a.valid?((rt(r)||rt(o))&&t.dirty(),{status:t.value,value:a.data}):(h(s,{code:l.invalid_intersection_types}),y)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([r,o])=>i(r,o)):i(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}xe.create=(n,e,t)=>new xe({left:n,right:e,typeName:v.ZodIntersection,...b(t)});class J extends x{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==m.array)return h(s,{code:l.invalid_type,expected:m.array,received:s.parsedType}),y;if(s.data.length<this._def.items.length)return h(s,{code:l.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;!this._def.rest&&s.data.length>this._def.items.length&&(h(s,{code:l.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...s.data].map((o,a)=>{const c=this._def.items[a]||this._def.rest;return c?c._parse(new j(s,o,s.path,a)):null}).filter(o=>!!o);return s.common.async?Promise.all(r).then(o=>$.mergeArray(t,o)):$.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new J({...this._def,rest:e})}}J.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new J({items:n,typeName:v.ZodTuple,rest:null,...b(e)})};class ke extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==m.object)return h(s,{code:l.invalid_type,expected:m.object,received:s.parsedType}),y;const i=[],r=this._def.keyType,o=this._def.valueType;for(const a in s.data)i.push({key:r._parse(new j(s,a,s.path,a)),value:o._parse(new j(s,s.data[a],s.path,a)),alwaysSet:a in s.data});return s.common.async?$.mergeObjectAsync(t,i):$.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof x?new ke({keyType:e,valueType:t,typeName:v.ZodRecord,...b(s)}):new ke({keyType:D.create(),valueType:e,typeName:v.ZodRecord,...b(t)})}}class ut extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==m.map)return h(s,{code:l.invalid_type,expected:m.map,received:s.parsedType}),y;const i=this._def.keyType,r=this._def.valueType,o=[...s.data.entries()].map(([a,c],p)=>({key:i._parse(new j(s,a,s.path,[p,"key"])),value:r._parse(new j(s,c,s.path,[p,"value"]))}));if(s.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const c of o){const p=await c.key,u=await c.value;if(p.status==="aborted"||u.status==="aborted")return y;(p.status==="dirty"||u.status==="dirty")&&t.dirty(),a.set(p.value,u.value)}return{status:t.value,value:a}})}else{const a=new Map;for(const c of o){const p=c.key,u=c.value;if(p.status==="aborted"||u.status==="aborted")return y;(p.status==="dirty"||u.status==="dirty")&&t.dirty(),a.set(p.value,u.value)}return{status:t.value,value:a}}}}ut.create=(n,e,t)=>new ut({valueType:e,keyType:n,typeName:v.ZodMap,...b(t)});class ce extends x{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==m.set)return h(s,{code:l.invalid_type,expected:m.set,received:s.parsedType}),y;const i=this._def;i.minSize!==null&&s.data.size<i.minSize.value&&(h(s,{code:l.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&s.data.size>i.maxSize.value&&(h(s,{code:l.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const r=this._def.valueType;function o(c){const p=new Set;for(const u of c){if(u.status==="aborted")return y;u.status==="dirty"&&t.dirty(),p.add(u.value)}return{status:t.value,value:p}}const a=[...s.data.values()].map((c,p)=>r._parse(new j(s,c,s.path,p)));return s.common.async?Promise.all(a).then(c=>o(c)):o(a)}min(e,t){return new ce({...this._def,minSize:{value:e,message:g.toString(t)}})}max(e,t){return new ce({...this._def,maxSize:{value:e,message:g.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ce.create=(n,e)=>new ce({valueType:n,minSize:null,maxSize:null,typeName:v.ZodSet,...b(e)});class qe extends x{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}qe.create=(n,e)=>new qe({getter:n,typeName:v.ZodLazy,...b(e)});class we extends x{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return h(t,{received:t.data,code:l.invalid_literal,expected:this._def.value}),y}return{status:"valid",value:e.data}}get value(){return this._def.value}}we.create=(n,e)=>new we({value:n,typeName:v.ZodLiteral,...b(e)});function ht(n,e){return new Y({values:n,typeName:v.ZodEnum,...b(e)})}class Y extends x{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return h(t,{expected:k.joinValues(s),received:t.parsedType,code:l.invalid_type}),y}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return h(t,{received:t.data,code:l.invalid_enum_value,options:s}),y}return P(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Y.create(e,{...this._def,...t})}exclude(e,t=this._def){return Y.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}}Y.create=ht;class Ze extends x{_parse(e){const t=k.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==m.string&&s.parsedType!==m.number){const i=k.objectValues(t);return h(s,{expected:k.joinValues(i),received:s.parsedType,code:l.invalid_type}),y}if(this._cache||(this._cache=new Set(k.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const i=k.objectValues(t);return h(s,{received:s.data,code:l.invalid_enum_value,options:i}),y}return P(e.data)}get enum(){return this._def.values}}Ze.create=(n,e)=>new Ze({values:n,typeName:v.ZodNativeEnum,...b(e)});class _e extends x{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==m.promise&&t.common.async===!1)return h(t,{code:l.invalid_type,expected:m.promise,received:t.parsedType}),y;const s=t.parsedType===m.promise?t.data:Promise.resolve(t.data);return P(s.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}_e.create=(n,e)=>new _e({type:n,typeName:v.ZodPromise,...b(e)});class G extends x{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===v.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),i=this._def.effect||null,r={addIssue:o=>{h(s,o),o.fatal?t.abort():t.dirty()},get path(){return s.path}};if(r.addIssue=r.addIssue.bind(r),i.type==="preprocess"){const o=i.transform(s.data,r);if(s.common.async)return Promise.resolve(o).then(async a=>{if(t.value==="aborted")return y;const c=await this._def.schema._parseAsync({data:a,path:s.path,parent:s});return c.status==="aborted"?y:c.status==="dirty"||t.value==="dirty"?oe(c.value):c});{if(t.value==="aborted")return y;const a=this._def.schema._parseSync({data:o,path:s.path,parent:s});return a.status==="aborted"?y:a.status==="dirty"||t.value==="dirty"?oe(a.value):a}}if(i.type==="refinement"){const o=a=>{const c=i.refinement(a,r);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(s.common.async===!1){const a=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?y:(a.status==="dirty"&&t.dirty(),o(a.value),{status:t.value,value:a.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(a=>a.status==="aborted"?y:(a.status==="dirty"&&t.dirty(),o(a.value).then(()=>({status:t.value,value:a.value}))))}if(i.type==="transform")if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!ee(o))return y;const a=i.transform(o.value,r);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>ee(o)?Promise.resolve(i.transform(o.value,r)).then(a=>({status:t.value,value:a})):y);k.assertNever(i)}}G.create=(n,e,t)=>new G({schema:n,typeName:v.ZodEffects,effect:e,...b(t)}),G.createWithPreprocess=(n,e,t)=>new G({schema:e,effect:{type:"preprocess",transform:n},typeName:v.ZodEffects,...b(t)});class Z extends x{_parse(e){return this._getType(e)===m.undefined?P(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Z.create=(n,e)=>new Z({innerType:n,typeName:v.ZodOptional,...b(e)});class Q extends x{_parse(e){return this._getType(e)===m.null?P(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Q.create=(n,e)=>new Q({innerType:n,typeName:v.ZodNullable,...b(e)});class Se extends x{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===m.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Se.create=(n,e)=>new Se({innerType:n,typeName:v.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...b(e)});class Ce extends x{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return ye(i)?i.then(r=>({status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new B(s.common.issues)},input:s.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new B(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}Ce.create=(n,e)=>new Ce({innerType:n,typeName:v.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...b(e)});class ft extends x{_parse(e){if(this._getType(e)!==m.nan){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:m.nan,received:s.parsedType}),y}return{status:"valid",value:e.data}}}ft.create=n=>new ft({typeName:v.ZodNaN,...b(n)});class mt extends x{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ke extends x{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const r=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?y:r.status==="dirty"?(t.dirty(),oe(r.value)):this._def.out._parseAsync({data:r.value,path:s.path,parent:s})})();{const i=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return i.status==="aborted"?y:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:s.path,parent:s})}}static create(e,t){return new Ke({in:e,out:t,typeName:v.ZodPipeline})}}class Ee extends x{_parse(e){const t=this._def.innerType._parse(e),s=i=>(ee(i)&&(i.value=Object.freeze(i.value)),i);return ye(t)?t.then(i=>s(i)):s(t)}unwrap(){return this._def.innerType}}Ee.create=(n,e)=>new Ee({innerType:n,typeName:v.ZodReadonly,...b(e)});var v;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(v||(v={}));const f=D.create,de=te.create,N=je.create,Ue=ze.create;F.create;const Te=L.create,w=C.create;be.create;const $n=Be.create;xe.create,J.create;const le=ke.create,z=we.create,_=Y.create;_e.create,Z.create,Q.create;const M=["backlog","discovery","architecture","implementation","local-testing","pr-review","ci","prod-testing","done"],An=["backlog","discovery","architecture","implementation"],On=[{id:"backlog",title:"Backlog",blurb:"Ideas and to-do. No agent yet.",automated:!1},{id:"discovery",title:"Design",blurb:"Product discovery for larger features: clarifying questions, draft descriptions, rough wireframes, approach trade-offs.",automated:!0},{id:"architecture",title:"Arch",blurb:"Agent proposes an implementation design.",automated:!0},{id:"implementation",title:"Build",blurb:"Agent implements in an isolated worktree.",automated:!0},{id:"local-testing",title:"Test",blurb:"Extensive local testing and polish.",automated:!0},{id:"pr-review",title:"Review",blurb:"Independent agent reviews, then opens a PR.",automated:!0},{id:"ci",title:"Merge",blurb:"Merge and babysit the pipeline to green.",automated:!0},{id:"prod-testing",title:"Verify",blurb:"Verify the feature live; nothing broke.",automated:!0},{id:"done",title:"Done",blurb:"Complete.",automated:!1}],Ie=["low","medium","high","xhigh","max"],gt=["xs","s","m","l","xl"],yt=["ask","policy","auto"],Rn={never:"ask",decide:"policy",always:"auto"},$e=["default","acceptEdits","auto","plan","dontAsk","bypassPermissions"],vt=["startup","company","enterprise"],bt=["none","last-open","eager","all-active"],Pn="eager",xt=w({key:f(),sessionId:f().catch(""),label:f().catch(""),createdAt:f().catch(""),model:f().optional().catch(void 0),effort:_(Ie).optional().catch(void 0),permissionMode:_($e).optional().catch(void 0),autonomous:N().optional().catch(void 0)});w({id:f().optional().catch(void 0),title:f().optional().catch(void 0),shortDescription:f().optional().catch(void 0),order:de().optional().catch(void 0),status:_(M).optional().catch(void 0),sessionId:f().optional().catch(void 0),worktree:f().optional().catch(void 0),branch:f().optional().catch(void 0),model:f().optional().catch(void 0),effort:_(Ie).optional().catch(void 0),size:_(gt).optional().catch(void 0),permissionMode:_($e).optional().catch(void 0),autonomous:N().optional().catch(void 0),forks:Te(xt).optional().catch(void 0),prUrl:f().optional().catch(void 0),prNumber:de().optional().catch(void 0),createdAt:f().optional().catch(void 0),doneAt:f().optional().catch(void 0),workflowEnteredAt:f().optional().catch(void 0),lastGroomedAt:f().optional().catch(void 0),lastDocUpdatedAt:f().optional().catch(void 0),pendingKickoff:_(M).optional().catch(void 0),kickedLane:_(M).optional().catch(void 0),proposedLane:_(M).optional().catch(void 0),grooming:N().optional().catch(void 0)}).passthrough();const Mn=le(f(),Ue()).transform(n=>{const e={};for(const[t,s]of Object.entries(n)){const i=Rn[s]??s;M.includes(t)&&yt.includes(i)&&(e[t]=i)}return e}).catch({}),jn=le(f(),Ue()).transform(n=>{const e={};for(const[t,s]of Object.entries(n))M.includes(t)&&typeof s=="string"&&s.trim()&&(e[t]=s.trim());return e}).catch({});w({trunk:f().optional().catch(void 0),reviewMode:_(["local","remote"]).catch("local"),autoExpand:N().catch(!0),devSpeed:_(vt).catch("enterprise"),iframeCaching:_(bt).catch(Pn),orchestratorSessionId:f().optional().catch(void 0),orchestratorModel:f().optional().catch(void 0),orchestratorEffort:_(Ie).optional().catch(void 0),orchestratorPermissionMode:_($e).optional().catch(void 0),orchestratorForks:Te(xt).optional().catch(void 0),stepGates:Mn.default({}),phaseHooks:jn.default({}),worktreeSetup:f().optional().catch(void 0),devCommand:f().optional().catch(void 0)}).passthrough();const Ln=["permission_request","clarification","ask_user_question","advance_proposal"];function kt(n){return Ln.includes(n.type)}$n("kind",[w({kind:z("subscribe_agent"),taskId:f(),afterSeq:de().int().nonnegative().optional()}),w({kind:z("subscribe_run"),taskId:f(),runId:f()}),w({kind:z("unsubscribe_run"),taskId:f(),runId:f()}),w({kind:z("subscribe_project"),projectId:f()}),w({kind:z("run_command"),taskId:f(),command:f()}),w({kind:z("kill_command"),taskId:f()}),w({kind:z("dictation_start")}),w({kind:z("dictation_audio"),audio:f()}),w({kind:z("dictation_stop")}),w({kind:z("devtools_result"),taskId:f(),commandId:f(),ok:N(),result:Ue().optional(),error:f().optional()})]),w({path:f().min(1),trunk:f().optional()}).strict(),w({name:f().min(1).optional(),trunk:f().min(1).optional()}).strict(),w({reviewMode:_(["local","remote"]).optional(),trunk:f().optional(),autoExpand:N().optional(),devSpeed:_(vt).optional(),iframeCaching:_(bt).optional(),stepGates:le(_(M),_(yt)).optional(),phaseHooks:le(_(M),f()).optional(),worktreeSetup:f().optional()}).strict();const Nn=["groom","orchestrator"];w({scope:_(["project","user"]),lane:_(M).optional(),agent:_(Nn).optional()}).strict().refine(n=>n.lane===void 0!=(n.agent===void 0),{message:"Provide exactly one of `lane` or `agent`."}),w({title:f().default(""),shortDescription:f().default(""),toLane:_(An).optional(),kickoff:N().optional()}).strict(),w({toLane:_(M),toOrder:de().int().nonnegative().optional(),userNote:f().max(4e3).optional()}).strict(),w({text:f().min(1)}).strict(),w({model:f().optional(),effort:_(Ie).optional(),size:_(gt).optional(),permissionMode:_($e).optional(),streamKey:f().optional()}).strict(),w({requestId:f(),decision:_(["allow","deny"]),message:f().optional()}).strict(),w({requestId:f(),answer:f()}).strict(),w({requestId:f(),answers:le(f()).optional()}).strict(),w({requestId:f(),accept:N(),toLane:_(M).optional()}).strict(),w({elevenLabsApiKey:f().optional(),passthroughUserSettings:N().optional(),dictationSubmitKeywords:f().optional()}).strict(),w({label:f().min(1),token:f().min(1)}).strict(),w({key:f().min(1),draft:f().default(""),queue:Te(f()).default([]),pending:Te(f()).default([])}).strict(),w({key:f().min(1)}).strict(),w({sourceKey:f().optional(),message:f().optional(),blank:N().optional()}).strict(),w({name:f().trim().min(1)}).strict(),w({toUuid:f().min(1),preview:f().optional(),index:de().int().nonnegative().optional()}).strict(),On.filter(n=>n.automated).map(n=>n.id);function zn(n){let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return e>>>0}const wt=["hsl(182, 62%, 46%)","hsl(320, 68%, 62%)","hsl(228, 72%, 64%)","hsl(55, 68%, 56%)","hsl(310, 64%, 50%)","hsl(195, 78%, 52%)","hsl(248, 62%, 68%)","hsl(332, 62%, 58%)","hsl(185, 58%, 58%)","hsl(300, 52%, 58%)","hsl(212, 60%, 46%)","hsl(285, 56%, 60%)","hsl(205, 70%, 56%)","hsl(265, 58%, 64%)","hsl(178, 52%, 50%)","hsl(238, 52%, 58%)"];function Bn(n){const e=zn(n)%wt.length;return{index:e,hsl:wt[e]}}const Dn=new Set(["cat","head","tail","less","grep","rg","egrep","fgrep","ls","ll","find","fd","tree","wc","stat","file","pwd","whoami","env","printenv","du","df","date","cut","sort","uniq","diff","echo","which","type","basename","dirname","realpath","readlink","sed","awk","jq","column","nl","comm","cd"]),qn=new Set(["status","log","diff","show","branch","remote","describe","blame","ls-files","rev-parse","config","stash","shortlog","reflog"]);function _t(n){return n.replace(/"(?:[^"\\]|\\.)*"/g,'""').replace(/'(?:[^'\\]|\\.)*'/g,"''")}function Zn(n){if(!n)return!1;const e=_t(n).split(/\||&&|;|\n/).map(t=>t.trim()).filter(Boolean);return e.length?e.every(t=>{if(/>>?\s*(?!&|\/dev\/null)\S/.test(t))return!1;const s=t.split(/\s+/);return s[0]==="git"?qn.has(s[1]??""):Dn.has(s[0])}):!1}const Kn=[{key:"problem",heading:"Problem"},{key:"context",heading:"Context"},{key:"acceptance",heading:"Acceptance criteria"},{key:"expectedResult",heading:"Expected result"},{key:"affectedAreas",heading:"Affected areas"},{key:"clarifications",heading:"Clarifications"},{key:"notes",heading:"Notes"}];new Map(Kn.map(n=>[n.heading.toLowerCase(),n.key]));function St(n){return n.replace(/\/[^\s"']*?\/worktrees\/[^/\s"']+\//g,"")}function Un(n,e=120){try{const t=typeof n=="string"?n:JSON.stringify(n),s=St(t);return s.length>e?s.slice(0,e)+"…":s}catch{return""}}function Fn(n){return n.replace(/\x1b\[[0-9;]*m/g,"")}function Fe(n){if(n&&typeof n=="object"){const e=n.command;if(typeof e=="string")return e}}function Vn(n){if(n&&typeof n=="object"){const e=n,t=e.file_path??e.notebook_path??e.path;if(typeof t=="string")return t}}const Hn={update_task_doc:"update doc",propose_advance:"propose advance",request_clarification:"ask clarification",ask_form:"ask question",attach_artifact:"attach artifact",render_mockup:"render mockup",render_diagram:"render diagram",report_pr:"report PR",set_size:"set size",start_run:"start run",stop_run:"stop run"};function Wn(n,e){const t=e??{},s=i=>typeof t[i]=="string"?t[i]:"";return n==="start_run"||n==="stop_run"?s("name")||s("runId"):n==="propose_advance"?s("to_lane"):n==="set_size"?s("size"):n==="report_pr"?s("url"):n==="attach_artifact"||n==="render_mockup"||n==="render_diagram"?s("title"):""}function Jn(n){const e=n.split(/\s+/);if(e[0]!=="git")return null;for(let t=1;t<e.length;t++){const s=e[t];if(s==="-C"||s==="-c"){t++;continue}if(!s.startsWith("-"))return/^[a-z-]+$/.test(s)?s:null}return null}function Yn(n){const e=n.replace(/\s+/g," ").trim(),t=Jn(e);if(t){if(t==="commit"){const i=n.match(/-m\s+(['"])([\s\S]*?)\1/)?.[2]?.trim()??"";return{kind:"commit",label:"commit",detail:i.length>120?i.slice(0,120).trimEnd()+"…":i}}return{kind:"git",label:`git ${t}`,detail:""}}const s=/\b(pnpm|npm|yarn|npx)\b/.test(e);return/\b(tsc|typecheck)\b/.test(e)?{kind:"typecheck",label:"typecheck",detail:""}:/\b(vitest|jest)\b/.test(e)||s&&/\btest\b/.test(e)?{kind:"test",label:"test",detail:""}:s&&/\b(install|add|i)\b/.test(e)?{kind:"install",label:"install",detail:""}:s&&/\bbuild\b/.test(e)?{kind:"build",label:"build",detail:""}:s&&/\b(dev|start)\b/.test(e)?{kind:"dev",label:"dev",detail:""}:null}function Gn(n){const e=t=>t[0]+" ".repeat(t.length-2)+t[0];return n.replace(/"(?:[^"\\]|\\.)*"/g,e).replace(/'(?:[^'\\]|\\.)*'/g,e)}function Qn(n){const e=Gn(n),t=/&&|\|\||;|\n|\|/g,s=[];let i=0,r;for(;r=t.exec(e);)s.push(n.slice(i,r.index)),i=r.index+r[0].length;s.push(n.slice(i));const o=[];for(const a of s){const c=Yn(St(a));c&&o[o.length-1]?.label!==c.label&&o.push(c)}return o}function Ct(n){if(n.type!=="tool_use")return[];if(n.name.startsWith("mcp__operator__")){const e=n.name.slice(15);return[{kind:"operator",label:`Operator · ${Hn[e]??e}`,detail:Wn(e,n.input)}]}return n.name==="Bash"?Qn(Fe(n.input)??""):[]}const Xn=new Set(["Edit","Write","MultiEdit","NotebookEdit"]);function Et(n){if(!n)return;const e=_t(n.split(`
|
|
2
|
+
`)[0]),t=/(?<![=\-0-9])>>?\s*([^\s|&;<>(){}'"=]+)/g;let s,i;for(;s=t.exec(e);){const r=s[1];r&&r!=="/dev/null"&&(i=r)}return i}function es(n){if(n.type!=="tool_use")return null;if(n.name==="Read"||n.name==="Grep"||n.name==="Glob")return"read";if(n.name==="Bash"){const e=Fe(n.input);return Zn(e)?"read":Et(e)?"edit":null}return Xn.has(n.name)?"edit":null}function ts(n){if(n.type==="tool_use")return n.name==="Bash"?Et(Fe(n.input)):Vn(n.input)}function ns(n){const e=new Map;for(const o of n)if(o.type==="tool_use"){const a=es(o);a&&e.set(o.id,a)}const t=[];let s=[],i=null;const r=()=>{if(s.length===0||!i){s=[],i=null;return}let o=0;const a=[];for(const c of s)if(c.type==="tool_use"&&(o++,i==="edit")){const p=ts(c);p&&a.push(p)}t.push({kind:"toolGroup",category:i,events:s,count:o,files:a}),s=[],i=null};for(const o of n){const a=o.type==="tool_use"||o.type==="tool_result"?o.id:void 0,c=a!=null?e.get(a):void 0;c?(i&&c!==i&&r(),i=c,s.push(o)):(r(),t.push({kind:"event",event:o}))}return r(),t}function Tt(n){return n.type==="advance_auto"||n.type==="prompt_dismissed"?n.id:null}function ss(n,e){return kt(n)?e?.has(n.id)??!1:!1}function It(n,e){const t=n[n.length-1];return t&&kt(t)&&!ss(t,e)?t:null}const is=new TextEncoder;function rs(n,e){e!==void 0&&(n.seq=e)}function os(n,e){if(e===void 0)return;let t=e;for(let s=n.length-1;s>=0;s--){const i=n[s];if(i.seq!==void 0){t=i.seq;continue}t-=is.encode(JSON.stringify(i)).length+1,i.seq=t}}function $t(n){const e=n.seq;return e!==void 0?e:n}function as(n,e){const t=[];for(let s=Math.max(0,e);s<n.length;s++)t.push($t(n[s]));return t}function pe(n,e){return e.size===0?n:n.filter(t=>!e.has($t(t)))}function cs(n){const e=/^\s*also\b[\s,:;.–—-]*/i.exec(n);return e?n.slice(e[0].length):null}function Ve(n,e){if(n.preview&&n.queue[n.preview.index]!==e){const t=n.preview.index;return{...n,draft:e,queue:n.queue.map((s,i)=>i===t?e:s)}}return{...n,draft:e}}function ds(n,e){if(n.preview?.index===e)return{...n,draft:n.preview.stash,preview:null};const t=n.preview?n.preview.stash:n.draft;return{...n,draft:n.queue[e]??"",preview:{index:e,stash:t}}}function ls(n,e){const t=n.queue[e];if(!t?.trim())return{state:n,text:null};const s=n.queue.filter((o,a)=>a!==e),i=n.preview,r=i&&(i.index===e?null:i.index>e?{...i,index:i.index-1}:i);return{state:{...n,queue:s,preview:r},text:t}}function ps(n,e){const t=n.preview?{...n.preview,index:n.preview.index+1}:null;return{...n,queue:[e,...n.queue],preview:t}}function us(n,e){const t=n.queue.filter((i,r)=>r!==e),s=n.preview;return s?s.index===e?{...n,queue:t,draft:s.stash,preview:null}:{...n,queue:t,preview:s.index>e?{...s,index:s.index-1}:s}:{...n,queue:t}}function hs(n,e){if(!n.draft.trim())return{kind:"noop",state:n};const t=n.draft;if(n.preview===null){const i=cs(t);if(i!==null&&i.trim()){const r=i.trim(),o=n.queue.includes(r)?n.queue:[...n.queue,r];return{kind:"parked",state:{...n,queue:o,draft:""}}}}let s={...n,draft:"",preview:null};return n.preview&&(s={...s,queue:n.queue.filter((i,r)=>r!==n.preview.index),draft:n.preview.stash}),e.running&&!e.promptParked?{kind:"pending",state:{...s,pending:[...s.pending,t]}}:{kind:"send",state:s,text:t}}function fs(n,e){return Ve(n,e)}function ms(n,e){const t=n.pending[e];if(t===void 0)return n;const s=n.pending.filter((r,o)=>o!==e),i=n.draft.trim()?`${n.draft}
|
|
3
|
+
|
|
4
|
+
${t}`:t;return Ve({...n,pending:s},i)}const gs=800;function At(n,e){return n.length===e.length&&n.every((t,s)=>t===e[s])}function ys(n){if(At(n.local.queue,n.remote.queue)&&At(n.local.pending,n.remote.pending))return{kind:"skip"};const e=gs-n.sinceLocalEditMs;return e>0?{kind:"defer",retryInMs:e}:{kind:"apply"}}function Ot(n){for(let e=n.length-1;e>=0;e--){const t=n[e];if(t.type==="session_init")return t.sessionId}}function vs(n,e){for(let t=n.length-1;t>=0;t--){const s=n[t];if(s.type==="status")return s.state}return e}function bs(n,e,t){os(e,t);const s=Ot(n.events),i=Ot(e),r=s===i||i===void 0;if(r&&n.events.length>0&&e.length<=n.events.length)return{adopted:!1};const o=new Set(r?n.resolved:[]);for(const a of e){const c=Tt(a);c&&o.add(c)}return{adopted:!0,events:e,resolved:o,sameSession:r}}function xs(n){return n?It(n.events,n.resolved)?"input":n.status==="running"?"thinking":null:null}function ks(n){return n&&(n.flushed||n.empty)?"done":"restore"}function ws(n){return n.wasState==="running"&&n.state!=="running"&&n.pendingCount>0}const K=encodeURIComponent,V=(n,e)=>`/api/projects/${K(n)}/tasks/${K(e)}`,A={projects:()=>"/api/projects",task:V,message:(n,e)=>`${V(n,e)}/message`,forkMessage:(n,e,t)=>`${V(n,e)}/forks/${K(t)}/message`,interrupt:(n,e)=>`${V(n,e)}/interrupt`,permission:(n,e)=>`${V(n,e)}/permission`,clarify:(n,e)=>`${V(n,e)}/clarify`,askQuestion:(n,e)=>`${V(n,e)}/ask-question`,advanceDecision:(n,e)=>`${V(n,e)}/advance-decision`,composer:(n,e)=>`/api/projects/${K(n)}/composer${e!==void 0?`?key=${K(e)}`:""}`,composerFlush:n=>`/api/projects/${K(n)}/composer/flush`,composerClaimPending:n=>`/api/projects/${K(n)}/composer/claim-pending`,asset:(n,e)=>`/api/projects/${K(n)}/assets/${K(e)}`};function Rt(...n){return n.map(e=>e.trim()).filter(Boolean).join(" ")}function _s(n){const e=new Int16Array(n.length);for(let i=0;i<n.length;i++){const r=Math.max(-1,Math.min(1,n[i]));e[i]=r<0?r*32768:r*32767}const t=new Uint8Array(e.buffer);let s="";for(let i=0;i<t.length;i++)s+=String.fromCharCode(t[i]);return btoa(s)}function Ss(n){const e=ns(n),t=[];for(let s=0;s<e.length;s++){const i=e[s];if(i.kind==="toolGroup"){const o=i.events.flatMap(a=>a.type==="tool_result"&&a.images?a.images:[]);t.push({kind:"toolGroup",item:i,images:o});continue}const r=i.event;if(r.type==="assistant_text"){let o=r.text,a=s+1;for(;a<e.length;a++){const c=e[a];if(c.kind!=="event"||c.event.type!=="assistant_text")break;o+=`
|
|
5
|
+
|
|
6
|
+
`+c.event.text}t.push({kind:"text",text:o}),s=a-1;continue}if(r.type==="tool_use"){const o=Ct(r);if(o.length>0){t.push({kind:"steps",steps:o});continue}const a=r.name;let c=1;const p=[],u=[];let S=s+1;for(;S<e.length;S++){const E=e[S];if(E.kind!=="event")break;const O=E.event;if(O.type==="tool_result"){O.images?.length&&p.push(...O.images),O.isError&&u.push(O);continue}if(O.type==="tool_use"&&O.name===a&&Ct(O).length===0){c++;continue}break}t.push({kind:"toolRun",name:a,count:c,images:p,errors:u}),s=S-1;continue}t.push({kind:"event",event:r})}return t}const Cs=new Set(["thinking","status","session_init"]);function Es(n){let e=n.length-1;for(;e>=0&&n[e].type!=="user_message";e--);if(e<0)return null;let t=!0;for(let s=e+1;s<n.length;s++)Cs.has(n[s].type)||(t=!1);return{text:n[e].text??"",onlyThought:t,index:e}}function Ts(n){if(!n.stoppable)return null;const e=n.pendingCount>0;return!e&&!n.draft.trim()&&n.lastUserTurn?.onlyThought&&n.lastUserTurn.text?{interrupt:!0,flush:e,restore:n.lastUserTurn.text,hideFromIndex:n.lastUserTurn.index}:{interrupt:!0,flush:e}}function Is(n,e){const t=/^\/([\w:-]*)$/.exec(n);if(!t)return[];const s=t[1].toLowerCase();return e.filter(i=>i.name.toLowerCase().startsWith(s)||(i.aliases??[]).some(r=>r.toLowerCase().startsWith(s)))}function $s(n,e){const t=[];if(n.picks.length){const s=n.picks.map((i,r)=>`${`${r+1}. \`${i.selector}\` — <${i.tag}>${i.text?` "${i.text}"`:""}`}
|
|
7
|
+
\`\`\`html
|
|
8
|
+
${i.html}
|
|
9
|
+
\`\`\``);t.push(`**Picked elements (${n.picks.length}):**
|
|
10
|
+
${s.join(`
|
|
11
|
+
`)}`)}if(n.includeNetwork){const s=e.network.recent(30);if(s.length){const i=s.map(r=>{const o=r.error?`ERR ${r.error}`:r.status!=null?String(r.status):"pending",a=r.error||r.status!=null&&r.status>=400?" ⚠":"",c=r.durationMs!=null?` (${r.durationMs}ms)`:"";return`- ${r.method} ${As(r.url)} → ${o}${c}${a}`});t.push(`**Recent network (${s.length}):**
|
|
12
|
+
${i.join(`
|
|
13
|
+
`)}`)}}if(n.includeConsole){const s=e.console.recent(30);if(s.length){const i=s.map(r=>`- [${r.level}] ${r.text}`);t.push(`**Console (${s.length}):**
|
|
14
|
+
${i.join(`
|
|
15
|
+
`)}`)}}if(n.includeErrors){const s=e.errors.recent(20);if(s.length){const i=s.map(r=>{const o=r.stack?`
|
|
16
|
+
${Os(r.stack)}`:"";return`- ${r.message}${o}`});t.push(`**Page errors (${s.length}):**
|
|
17
|
+
${i.join(`
|
|
18
|
+
`)}`)}}return t.length?[`
|
|
19
|
+
|
|
20
|
+
---`,`_Operator DevTools context — ${location.href}_`,"",t.join(`
|
|
21
|
+
|
|
22
|
+
`)].join(`
|
|
23
|
+
`):""}function Pt(n,e){return n.picks.length>0||n.includeNetwork&&e.network.all().length>0||n.includeConsole&&e.console.all().length>0||n.includeErrors&&e.errors.all().length>0}function As(n){try{const e=new URL(n,location.href);return e.origin===location.origin?e.pathname+e.search:n}catch{return n}}function Os(n){return n.split(`
|
|
24
|
+
`).slice(1,3).map(e=>e.trim()).join(`
|
|
25
|
+
`)}const Rs=typeof navigator<"u"&&!!navigator.mediaDevices?.getUserMedia&&typeof AudioContext<"u"&&typeof AudioWorkletNode<"u",Ps=`
|
|
26
|
+
class PCMTap extends AudioWorkletProcessor {
|
|
27
|
+
process(inputs) {
|
|
28
|
+
const ch = inputs[0] && inputs[0][0];
|
|
29
|
+
if (ch) this.port.postMessage(ch.slice(0));
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
registerProcessor('pcm-tap', PCMTap);
|
|
34
|
+
`;class Ms{constructor(e){this.send=e}handlers=null;media=null;pending=[];get recording(){return this.handlers!=null}onReply(e){if(this.handlers)if(e.kind==="dictation_partial")this.handlers.onPartial(e.text);else if(e.kind==="dictation_final")this.handlers.onCommit(e.text);else{const t=this.handlers;this.teardown(),t.onError(e.text),t.onEnd()}}async start(e){this.handlers&&this.stop(),this.handlers=e;try{const t=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1}}),s=new AudioContext({sampleRate:16e3});this.media={stream:t,ctx:s},await s.resume();const i=URL.createObjectURL(new Blob([Ps],{type:"application/javascript"}));await s.audioWorklet.addModule(i),URL.revokeObjectURL(i);const r=new AudioWorkletNode(s,"pcm-tap");r.port.onmessage=o=>{const a=o.data;for(let c=0;c<a.length;c++)this.pending.push(a[c]);this.pending.length>=4096&&this.flush()},s.createMediaStreamSource(t).connect(r),r.connect(s.destination),this.send({kind:"dictation_start"})}catch(t){const s=this.handlers;this.teardown(),s?.onError(js(t)),s?.onEnd()}}stop(){if(!this.handlers)return;this.flush(),this.send({kind:"dictation_stop"});const e=this.handlers;this.teardown(),e?.onEnd()}abort(){if(this.handlers){const e=this.handlers;this.teardown(),e.onEnd()}}flush(){this.pending.length&&(this.send({kind:"dictation_audio",audio:_s(this.pending)}),this.pending=[])}teardown(){this.media&&(this.media.stream.getTracks().forEach(e=>e.stop()),this.media.ctx.close().catch(()=>{}),this.media=null),this.pending=[],this.handlers=null}}function js(n){const e=n instanceof Error?n.name:"",t=n instanceof Error?n.message:String(n);return e==="NotAllowedError"||/permission|denied/i.test(t)?"microphone permission denied":e==="NotFoundError"?"no microphone found":/content security policy|unsafe-eval|blocked by csp|worklet|blob:/i.test(t)?"dictation is blocked by the page's Content-Security-Policy (the audio worklet can't load)":t||"dictation failed"}class Ls{constructor(e,t="auto"){this.color=e,this.mode=t}injected=null;displaced=[];apply(){if(this.mode!=="off")try{this.injected&&!this.injected.isConnected&&(this.injected=null);const e=Array.from(document.querySelectorAll('link[rel~="icon"]')).filter(s=>s!==this.injected);if(this.mode==="auto"&&e.length)return;const t=this.dataUrl();if(!t)return;if(this.mode==="always")for(const s of e)this.displaced.push(s),s.remove();if(this.injected)this.injected.href=t;else{const s=document.createElement("link");s.rel="icon",s.type="image/png",s.href=t,document.head?.append(s),this.injected=s}}catch{}}restore(){try{this.injected?.remove(),this.injected=null;for(const e of this.displaced.splice(0))e.isConnected||document.head?.append(e)}catch{}}dataUrl(){const t=document.createElement("canvas");t.width=t.height=64;const s=t.getContext("2d");if(!s)return null;const i=64*.22;return s.fillStyle=this.color,s.beginPath(),s.moveTo(i,0),s.arcTo(64,0,64,64,i),s.arcTo(64,64,0,64,i),s.arcTo(0,64,0,0,i),s.arcTo(0,0,64,0,i),s.closePath(),s.fill(),t.toDataURL("image/png")}}function Ns(n){const e=n.replace(/\r\n/g,`
|
|
35
|
+
`).split(`
|
|
36
|
+
`);let t="",s=!1;const i=()=>{s&&(t+="</ul>",s=!1)};let r=0;for(;r<e.length;){const o=e[r];if(/^```/.test(o)){i(),r++;let u="";for(;r<e.length&&!/^```\s*$/.test(e[r]);)u+=e[r]+`
|
|
37
|
+
`,r++;r++,t+=`<pre class="op-md-pre"><code>${Mt(u.replace(/\n$/,""))}</code></pre>`;continue}const a=/^(#{1,6})\s+(.*)$/.exec(o);if(a){i(),t+=`<div class="op-md-h">${se(a[2])}</div>`,r++;continue}if(He(o)&&r+1<e.length&&jt(e[r+1])){i(),t+='<table class="op-md-table"><thead><tr>';for(const u of Lt(o))t+=`<th>${se(u)}</th>`;for(t+="</tr></thead><tbody>",r+=2;r<e.length&&He(e[r]);){t+="<tr>";for(const u of Lt(e[r]))t+=`<td>${se(u)}</td>`;t+="</tr>",r++}t+="</tbody></table>";continue}if(/^>\s?/.test(o)){i(),t+=`<blockquote class="op-md-q">${se(o.replace(/^>\s?/,""))}</blockquote>`,r++;continue}const c=/^\s*(?:[-*+]|\d+\.)\s+(.*)$/.exec(o);if(c){s||(t+='<ul class="op-md-ul">',s=!0),t+=`<li>${se(c[1])}</li>`,r++;continue}if(/^\s*$/.test(o)){i(),r++;continue}i();let p=o;for(r++;r<e.length&&!/^\s*$/.test(e[r])&&!/^(```|#{1,6}\s|>\s?|\s*(?:[-*+]|\d+\.)\s)/.test(e[r])&&!(He(e[r])&&r+1<e.length&&jt(e[r+1]));)p+=`
|
|
38
|
+
`+e[r],r++;t+=`<p class="op-md-p">${se(p).replace(/\n/g,"<br>")}</p>`}return i(),t}function Mt(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function He(n){return/\|/.test(n)&&!/^(```|#{1,6}\s|>\s?)/.test(n)&&n.trim().length>0}function jt(n){const e=n.trim();return/^\|?[\s:|-]+\|?$/.test(e)&&/-/.test(e)&&/\|/.test(n)}function Lt(n){let e=n.trim();return e.startsWith("|")&&(e=e.slice(1)),e.endsWith("|")&&(e=e.slice(0,-1)),e.split("|").map(t=>t.trim())}function se(n){let e=Mt(n);return e=e.replace(/`([^`]+)`/g,(t,s)=>`<code class="op-md-code">${s}</code>`),e=e.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),e=e.replace(/(^|[^*])\*([^*\s][^*]*)\*/g,"$1<em>$2</em>"),e=e.replace(/~~([^~]+)~~/g,"<del>$1</del>"),e=e.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g,(t,s,i)=>/^(https?:\/\/|\/)[^"']*$/.test(i)?`<img class="op-md-img" src="${i}" alt="${s}" loading="lazy">`:s),e=e.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(t,s,i)=>`<a href="${/^(https?:\/\/|\/)[^"']*$/.test(i)?i:"#"}" target="_blank" rel="noreferrer">${s}</a>`),e}let ue;function zs(){if(ue!==void 0)return ue;try{const n=globalThis.trustedTypes;ue=n?.createPolicy?n.createPolicy("operator-devtools",{createHTML:e=>e}):null}catch{ue=null}return ue}function Ae(n,e,t){const s=zs();try{n.innerHTML=s?s.createHTML(e):e}catch{n.textContent=t??e.replace(/<[^>]*>/g,"")}}function d(n,e){const t=document.createElement(n);return e&&(t.className=e),t}function H(n,e,t,s=!1){const i=d("button",`op-btn op-btn-${e}`);return i.textContent=n,i.disabled=s,i.onclick=t,i}function Nt(n,e){const t=d("div",`op-msg ${n} op-md`);return Ae(t,Ns(e),e),t}function Bs(n){const e=d("div","op-think");return e.textContent=n.length>240?n.slice(0,240)+"…":n,e}function Ds(n){const e=d("div","op-steps"),t=d("div","op-steps-labels");n.forEach((i,r)=>{if(r>0){const a=d("span","op-steps-sep");a.textContent="·",t.append(a)}const o=d("span",`op-step op-step-${i.kind}`);o.textContent=i.label,t.append(o)}),e.append(t);const s=n.map(i=>i.detail).filter(Boolean);if(s.length){const i=d("div","op-steps-detail");i.textContent=s.join(`
|
|
39
|
+
`),e.append(i)}return e}function qs(n,e){const t=d("div","op-tool");return t.textContent=e>1?`⚙ ${e}× ${n}`:`⚙ ${n}`,t}function zt(n){if(!n.isError)return null;const e=n.summary&&Fn(n.summary)||"error",t=d("div","op-tres err");return t.textContent=`↳ ${e.length>400?e.slice(0,400)+"…":e}`,t}function We(n,e){const t=d("div","op-images");for(const s of n){const i=e(s.file),r=d("a");r.href=i,r.target="_blank",r.rel="noreferrer";const o=d("img","op-img");o.src=i,o.loading="lazy",r.append(o),t.append(r)}return t}function Zs(n){const e=d("div","op-group-head");return e.textContent=`${n.count} edit${n.count===1?"":"s"}`,e}function Ks(n){const e=d("div","op-turnend");return e.textContent=n?"Stopped":"Turn complete",e}function Us(n){const e=d("div","op-throttle"),t=n.resetsAt?"Usage limit reached":"Rate-limited",s=n.attempt>1?` (attempt ${n.attempt})`:"",i=n.limitType?` [${n.limitType.replace(/_/g," ")}]`:"",r=n.resetsAt?`auto-resumes at ${new Date(n.resetsAt).toLocaleString()}.`:"waiting for a coordinated retry.";return e.textContent=`⏳ ${t}${s}${i} — ${r}`,e}function Fs(n){const e=d("div","op-rewound");return e.textContent=`↩ rewound${n?` to “${n.slice(0,60)}”`:""}`,e}function Vs(n){const e=d("div","op-artifact"),t=d("div","op-artifact-head");if(t.textContent=`${n.kind}: ${n.title}`,e.append(t),n.path){const s=d("div","op-artifact-path");s.textContent=n.path,e.append(s)}return e}function Bt(n,e){const t=d("div","op-artifact"),s=d("div","op-artifact-head");s.textContent=`${n}${e?`: ${e}`:""}`;const i=d("div","op-artifact-path");return i.textContent="view it in the Operator chat",t.append(s,i),t}function Hs(n){const e=d("div","op-todos"),t=d("div","op-todos-head");t.textContent="Plan",e.append(t);for(const s of n){const i=d("div",`op-todo ${s.status}`),r=d("span");r.textContent=s.status==="completed"?"✓":s.status==="in_progress"?"▸":"○";const o=d("span");o.textContent=s.content,i.append(r,o),e.append(i)}return e}function Ws(n){for(let e=n.length-1;e>=0;e--){const t=n[e];if(t.type==="todos")return t.items}return null}const he=6e4;async function Js(n,e){switch(n){case"eval":{const t=String(e.code??"");let s;try{s=new Function(`return (async () => { ${t} })()`)}catch(i){throw i instanceof EvalError||/unsafe-eval|content security policy|blocked by csp/i.test(String(i?.message))?new Error("eval is blocked by the page's Content-Security-Policy (script-src lacks 'unsafe-eval'). The snapshot, click, and info commands still work."):i}return Ys(await s())}case"snapshot":{const t=e.selector?String(e.selector):"",s=t?document.querySelector(t):document.documentElement;if(!s)throw new Error(`No element matches selector: ${t}`);return fe(s.outerHTML,he)}case"click":{const t=String(e.selector??""),s=document.querySelector(t);if(!s)throw new Error(`No element matches selector: ${t}`);return s.scrollIntoView?.({block:"center"}),s.click(),`Clicked ${Gs(s)}`}case"info":return{url:location.href,title:document.title,readyState:document.readyState};default:throw new Error(`Unknown page command: ${n}`)}}function Ys(n){if(n===void 0)return null;if(typeof n=="function")return fe(String(n),he);if(typeof Element<"u"&&n instanceof Element)return fe(n.outerHTML,he);if(typeof n=="string")return fe(n,he);try{return JSON.stringify(n),n}catch{return fe(String(n),he)}}function fe(n,e){return n.length>e?n.slice(0,e)+`
|
|
40
|
+
… [truncated ${n.length-e} chars]`:n}function Gs(n){const e=n.id?`#${n.id}`:"",t=n.classList.length?`.${[...n.classList].slice(0,2).join(".")}`:"";return`<${n.tagName.toLowerCase()}${e}${t}>`}class Oe{constructor(e){this.cap=e}items=[];push(e){this.items.push(e),this.items.length>this.cap&&this.items.shift()}all(){return this.items}recent(e){return this.items.slice(-e)}clear(){this.items=[]}}class Qs{network=new Oe(100);console=new Oe(200);errors=new Oe(50);sockets=new Oe(30);seq=0;installed=!1;ignoreOrigin;restore=[];constructor(e){this.ignoreOrigin=e}next(){return++this.seq}isIgnored(e){try{return new URL(e,location.href).origin===new URL(this.ignoreOrigin).origin}catch{return!1}}install(){this.installed||(this.installed=!0,this.installFetch(),this.installXhr(),this.installWebSocket(),this.installConsole(),this.installErrors())}now(){return typeof performance<"u"?performance.now():Date.now()}installFetch(){if(typeof window.fetch!="function")return;const e=window.fetch.bind(window);window.fetch=async(t,s)=>{const i=typeof t=="string"?t:t instanceof URL?t.href:t.url,r=(s?.method??(t instanceof Request?t.method:"GET")).toUpperCase();if(this.isIgnored(i))return e(t,s);const o={id:this.next(),method:r,url:i,status:null,ok:null,durationMs:null,startedAt:Date.now()},a=this.now();try{const c=await e(t,s);return this.safe(()=>{o.status=c.status,o.ok=c.ok,o.durationMs=Math.round(this.now()-a),this.network.push(o)}),c}catch(c){throw this.safe(()=>{o.error=String(c?.message??c),o.durationMs=Math.round(this.now()-a),this.network.push(o)}),c}},this.restore.push(()=>{window.fetch=e})}installXhr(){if(typeof XMLHttpRequest>"u")return;const e=this,t=XMLHttpRequest.prototype.open,s=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(i,r,...o){return this.__op={method:String(i).toUpperCase(),url:String(r),t0:0},t.call(this,i,r,...o)},XMLHttpRequest.prototype.send=function(i){const r=this.__op;if(r&&!e.isIgnored(r.url)){r.t0=e.now();const o={id:e.next(),method:r.method,url:r.url,status:null,ok:null,durationMs:null,startedAt:Date.now()};this.addEventListener("loadend",()=>{e.safe(()=>{o.status=this.status||null,o.ok=this.status>=200&&this.status<400,o.durationMs=Math.round(e.now()-r.t0),this.status===0&&(o.error="network error / aborted"),e.network.push(o)})})}return s.call(this,i)},this.restore.push(()=>{XMLHttpRequest.prototype.open=t,XMLHttpRequest.prototype.send=s})}installWebSocket(){if(typeof WebSocket>"u")return;const e=this,t=WebSocket;class s extends t{constructor(r,o){super(r,o);try{const a=typeof r=="string"?r:r.href;if(e.isIgnored(a))return;const c={id:e.next(),url:a,openedAt:Date.now(),closedAt:null,sent:0,received:0};e.sockets.push(c),this.addEventListener("message",()=>e.safe(()=>void c.received++)),this.addEventListener("close",()=>e.safe(()=>void(c.closedAt=Date.now())));const p=this.send.bind(this);this.send=u=>(e.safe(()=>void c.sent++),p(u))}catch{}}}window.WebSocket=s,this.restore.push(()=>{window.WebSocket=t})}installConsole(){const e=["log","info","warn","error","debug"];for(const t of e){const s=console[t]?.bind(console);s&&(console[t]=(...i)=>{this.safe(()=>{this.console.push({id:this.next(),level:t,text:Xs(i),at:Date.now()})}),s(...i)},this.restore.push(()=>{console[t]=s}))}}installErrors(){const e=s=>{this.safe(()=>{this.errors.push({id:this.next(),message:s.message||String(s.error?.message??"Error"),stack:s.error?.stack,at:Date.now()})})},t=s=>{this.safe(()=>{const i=s.reason;this.errors.push({id:this.next(),message:"Unhandled rejection: "+String(i?.message??i),stack:i?.stack,at:Date.now()})})};window.addEventListener("error",e),window.addEventListener("unhandledrejection",t),this.restore.push(()=>{window.removeEventListener("error",e),window.removeEventListener("unhandledrejection",t)})}safe(e){try{e()}catch{}}clear(){this.network.clear(),this.console.clear(),this.errors.clear(),this.sockets.clear()}uninstall(){for(const e of this.restore.splice(0))try{e()}catch{}this.installed=!1}}function Xs(n){return n.map(e=>{if(typeof e=="string")return e;if(e instanceof Error)return`${e.name}: ${e.message}`;try{return JSON.stringify(e)}catch{return String(e)}}).join(" ").slice(0,2e3)}function ei(n){if(n.id)return`#${Je(n.id)}`;const e=[];let t=n,s=0;for(;t&&t.nodeType===1&&t!==document.documentElement&&s<5;){if(t.id){e.unshift(`#${Je(t.id)}`);break}let i=t.tagName.toLowerCase();const r=ti(t);if(r)i+=`.${Je(r)}`;else{const o=ni(t);o>0&&(i+=`:nth-of-type(${o+1})`)}e.unshift(i),t=t.parentElement,s++}return e.join(" > ")}function ti(n){return Array.from(n.classList).find(s=>s.length<=24&&/^[a-zA-Z][\w-]*$/.test(s))??null}function ni(n){return n.parentElement?Array.from(n.parentElement.children).filter(t=>t.tagName===n.tagName).indexOf(n):0}function Je(n){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(n):n.replace(/([^\w-])/g,"\\$1")}class si{active=!1;highlight;label;current=null;onPick;onDone;hostEl;constructor(e,t,s,i){this.hostEl=t,this.onPick=s,this.onDone=i,this.highlight=document.createElement("div"),this.highlight.className="op-pick-highlight",this.label=document.createElement("div"),this.label.className="op-pick-label",e.append(this.highlight,this.label),this.hide()}get isActive(){return this.active}start(){this.active||(this.active=!0,document.addEventListener("mousemove",this.onMove,!0),document.addEventListener("click",this.onClick,!0),document.addEventListener("keydown",this.onKey,!0),document.body.style.cursor="crosshair")}stop(){this.active&&(this.active=!1,document.removeEventListener("mousemove",this.onMove,!0),document.removeEventListener("click",this.onClick,!0),document.removeEventListener("keydown",this.onKey,!0),document.body.style.cursor="",this.current=null,this.hide(),this.onDone())}hide(){this.highlight.style.display="none",this.label.style.display="none"}resolveTarget(e,t){const s=ii(e,t);if(!s)return null;const i=s.getRootNode();return s===this.hostEl||this.hostEl.contains(s)||i instanceof ShadowRoot&&i.host===this.hostEl?null:s}onMove=e=>{const t=this.resolveTarget(e.clientX,e.clientY);if(!t){this.current=null,this.hide();return}this.current=t;const s=t.getBoundingClientRect(),i=this.highlight.style;i.display="block",i.top=`${s.top}px`,i.left=`${s.left}px`,i.width=`${s.width}px`,i.height=`${s.height}px`;const r=t.tagName.toLowerCase(),o=t.classList.length?"."+Array.from(t.classList).slice(0,2).join("."):"";this.label.textContent=`${r}${o} ${Math.round(s.width)}×${Math.round(s.height)}`,this.label.style.display="block",this.label.style.top=`${Math.max(0,s.top-22)}px`,this.label.style.left=`${s.left}px`};onClick=e=>{if(!this.active)return;e.preventDefault(),e.stopPropagation();const t=this.current??this.resolveTarget(e.clientX,e.clientY);t&&this.onPick(ri(t)),this.stop()};onKey=e=>{e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),this.stop())}}function ii(n,e){let t=document.elementFromPoint(n,e),s=0;for(;t&&s++<20;){const i=t.shadowRoot;if(!i)break;const r=i.elementFromPoint(n,e);if(!r||r===t)break;t=r}return t}function ri(n){const e=(n.textContent??"").trim().replace(/\s+/g," ").slice(0,200);let t=n.outerHTML??"";return t.length>1500&&(t=t.slice(0,1500)+`
|
|
41
|
+
…(truncated)`),{selector:ei(n),tag:n.tagName.toLowerCase(),text:e,html:t}}const Dt=`
|
|
42
|
+
:host { all: initial; }
|
|
43
|
+
* { box-sizing: border-box; font-family: ui-sans-serif, system-ui, -apple-system, sans-serif; }
|
|
44
|
+
|
|
45
|
+
.op-root {
|
|
46
|
+
position: fixed; inset: 0; z-index: 2147483000; pointer-events: none;
|
|
47
|
+
color: #e7e7ea; font-size: 13px; line-height: 1.45;
|
|
48
|
+
}
|
|
49
|
+
.op-root > * { pointer-events: auto; }
|
|
50
|
+
|
|
51
|
+
/* Floating action button — draggable launcher, positioned via left/top in JS */
|
|
52
|
+
.op-fab {
|
|
53
|
+
position: absolute; left: 18px; top: 18px;
|
|
54
|
+
width: 44px; height: 44px; border-radius: 50%;
|
|
55
|
+
background: #6ea8fe; color: #06121f; border: none; cursor: grab; touch-action: none;
|
|
56
|
+
font-size: 20px; display: flex; align-items: center; justify-content: center;
|
|
57
|
+
box-shadow: 0 4px 16px rgba(0,0,0,.45); z-index: 2; user-select: none;
|
|
58
|
+
}
|
|
59
|
+
.op-fab:active { cursor: grabbing; }
|
|
60
|
+
.op-fab-badge {
|
|
61
|
+
position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px;
|
|
62
|
+
padding: 0 4px; border-radius: 8px; background: #f87171; color: #1a0606;
|
|
63
|
+
font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center;
|
|
64
|
+
}
|
|
65
|
+
/* Status ring on the FAB: pulsing while the agent thinks, solid amber when it
|
|
66
|
+
is waiting on the user — visible without opening the panel. */
|
|
67
|
+
.op-fab-status {
|
|
68
|
+
position: absolute; inset: -3px; border-radius: 50%; pointer-events: none;
|
|
69
|
+
border: 2px solid transparent;
|
|
70
|
+
}
|
|
71
|
+
.op-fab-status.thinking { border-color: rgba(255,255,255,.6); animation: op-pulse 1.4s ease-in-out infinite; }
|
|
72
|
+
.op-fab-status.input { border-color: #fbbf24; }
|
|
73
|
+
@keyframes op-pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
|
|
74
|
+
|
|
75
|
+
/* Panel — positioned relative to the FAB in JS (left/top) */
|
|
76
|
+
.op-panel {
|
|
77
|
+
/* Position + size are fully JS-driven (positionPanel) — anchored to the FAB by
|
|
78
|
+
whichever edges are pinned; no top/left/size defaults here or they'd fight the
|
|
79
|
+
inline values. */
|
|
80
|
+
position: absolute;
|
|
81
|
+
display: none; flex-direction: column; overflow: hidden;
|
|
82
|
+
background: #141418; border: 1px solid #2c2c34; border-radius: 12px;
|
|
83
|
+
box-shadow: 0 12px 40px rgba(0,0,0,.55);
|
|
84
|
+
}
|
|
85
|
+
.op-panel.open { display: flex; }
|
|
86
|
+
|
|
87
|
+
/* Resize grip on the corner opposite the FAB (corner + cursor set inline). */
|
|
88
|
+
.op-resize {
|
|
89
|
+
position: absolute; width: 16px; height: 16px; z-index: 3;
|
|
90
|
+
background:
|
|
91
|
+
linear-gradient(135deg, transparent 0 50%, #5a5a66 50% 62%, transparent 62% 74%, #5a5a66 74% 86%, transparent 86%);
|
|
92
|
+
opacity: .55; touch-action: none;
|
|
93
|
+
}
|
|
94
|
+
.op-resize:hover { opacity: 1; }
|
|
95
|
+
|
|
96
|
+
.op-head {
|
|
97
|
+
display: flex; align-items: center; gap: 8px; padding: 10px 12px;
|
|
98
|
+
background: #1a1a1f; border-bottom: 1px solid #26262c; flex: 0 0 auto;
|
|
99
|
+
cursor: grab; user-select: none; touch-action: none;
|
|
100
|
+
}
|
|
101
|
+
.op-head:active { cursor: grabbing; }
|
|
102
|
+
.op-dot { width: 8px; height: 8px; border-radius: 50%; background: #6b7280; flex: 0 0 auto; }
|
|
103
|
+
.op-dot.open { background: #4ade80; }
|
|
104
|
+
.op-dot.connecting { background: #fbbf24; }
|
|
105
|
+
.op-dot.closed { background: #6b7280; }
|
|
106
|
+
.op-title { font-size: 12px; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
107
|
+
/* Working indicator at the bottom of the chat (above the composer) — muted gray
|
|
108
|
+
with bouncing dots, matching the main agent chat. */
|
|
109
|
+
.op-running {
|
|
110
|
+
font-size: 11px; color: #9a9aa2; padding: 4px 12px 2px; flex: 0 0 auto;
|
|
111
|
+
display: flex; align-items: center; gap: 6px;
|
|
112
|
+
}
|
|
113
|
+
.op-running:empty { display: none; }
|
|
114
|
+
.op-dots { display: inline-flex; gap: 3px; }
|
|
115
|
+
.op-dots i { width: 5px; height: 5px; border-radius: 50%; background: #9a9aa2; animation: op-bounce 1s infinite; }
|
|
116
|
+
.op-dots i:nth-child(1) { animation-delay: -0.3s; }
|
|
117
|
+
.op-dots i:nth-child(2) { animation-delay: -0.15s; }
|
|
118
|
+
@keyframes op-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-4px); opacity: 1; } }
|
|
119
|
+
.op-close { background: none; border: none; color: #9a9aa2; cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 4px; }
|
|
120
|
+
.op-close:hover { color: #e7e7ea; }
|
|
121
|
+
|
|
122
|
+
/* Session tabs (multisession tasks: main + forks) */
|
|
123
|
+
.op-tabs { display: flex; gap: 4px; padding: 6px 8px 0; overflow-x: auto; flex: 0 0 auto; }
|
|
124
|
+
.op-tabs:empty { display: none; }
|
|
125
|
+
.op-tab {
|
|
126
|
+
display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto;
|
|
127
|
+
background: #15151b; border: 1px solid #26262c; border-bottom: none;
|
|
128
|
+
border-radius: 7px 7px 0 0; color: #9a9aa2; cursor: pointer;
|
|
129
|
+
font-size: 11px; padding: 5px 9px; max-width: 140px; white-space: nowrap;
|
|
130
|
+
}
|
|
131
|
+
.op-tab > span:last-child { overflow: hidden; text-overflow: ellipsis; }
|
|
132
|
+
.op-tab.active { background: #1f1f26; color: #e7e7ea; border-color: #2c2c34; }
|
|
133
|
+
.op-tab-dot { width: 6px; height: 6px; border-radius: 50%; background: #3a3a42; flex: 0 0 auto; }
|
|
134
|
+
.op-tab-dot.on { background: #4ade80; animation: op-pulse 1.4s ease-in-out infinite; }
|
|
135
|
+
|
|
136
|
+
/* Feed (wrapped so the "↓ latest" pill can float over it) */
|
|
137
|
+
.op-feedwrap { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
|
|
138
|
+
.op-feed {
|
|
139
|
+
flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px;
|
|
140
|
+
}
|
|
141
|
+
.op-feed::-webkit-scrollbar { width: 8px; }
|
|
142
|
+
.op-feed::-webkit-scrollbar-thumb { background: #2c2c34; border-radius: 4px; }
|
|
143
|
+
.op-empty { color: #6b7280; font-size: 12px; text-align: center; margin: auto 0; }
|
|
144
|
+
.op-jump {
|
|
145
|
+
position: absolute; bottom: 8px; right: 12px; z-index: 2;
|
|
146
|
+
background: #4f46e5; color: #eef; border: none; border-radius: 999px;
|
|
147
|
+
font-size: 11px; padding: 4px 10px; cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,.4);
|
|
148
|
+
}
|
|
149
|
+
.op-jump:hover { background: #6366f1; }
|
|
150
|
+
|
|
151
|
+
.op-msg { padding: 7px 10px; border-radius: 9px; max-width: 88%; white-space: pre-wrap; word-break: break-word; }
|
|
152
|
+
.op-msg.user { background: #2a3550; align-self: flex-end; }
|
|
153
|
+
.op-msg.assistant { background: #1f1f26; align-self: flex-start; }
|
|
154
|
+
/* One muted thinking line (bounded glimpse — nothing in this feed expands) */
|
|
155
|
+
.op-think { align-self: flex-start; max-width: 88%; font-size: 11px; color: #8a8a94; font-style: italic; word-break: break-word; }
|
|
156
|
+
.op-evt-error { align-self: flex-start; background: #2a1414; border: 1px solid #5a2a2a; color: #f8b4b4; padding: 6px 9px; border-radius: 8px; max-width: 88%; }
|
|
157
|
+
.op-status { align-self: center; font-size: 10px; color: #6b7280; }
|
|
158
|
+
|
|
159
|
+
/* Classified tool steps ("commit · git push") — accents mirror the main chat */
|
|
160
|
+
.op-steps { align-self: stretch; font-size: 11px; background: #15151b; border: 1px solid #26262c; border-radius: 6px; padding: 3px 7px; }
|
|
161
|
+
.op-steps-labels { display: flex; flex-wrap: wrap; gap: 5px; align-items: baseline; }
|
|
162
|
+
.op-steps-sep { color: #4b4b55; }
|
|
163
|
+
.op-step { font-weight: 600; }
|
|
164
|
+
.op-step-commit { color: #6ee7b7; }
|
|
165
|
+
.op-step-git { color: #7dd3fc; }
|
|
166
|
+
.op-step-typecheck { color: #7dd3fc; }
|
|
167
|
+
.op-step-test { color: #fcd34d; }
|
|
168
|
+
.op-step-install { color: #f0abfc; }
|
|
169
|
+
.op-step-build { color: #fdba74; }
|
|
170
|
+
.op-step-dev { color: #6ee7b7; }
|
|
171
|
+
.op-step-operator { color: #a5b4fc; }
|
|
172
|
+
.op-steps-detail { color: #9a9aa2; white-space: pre-wrap; word-break: break-word; margin-top: 2px; }
|
|
173
|
+
|
|
174
|
+
/* Unclassified tool calls — "⚙ Name" / "⚙ N× Name", nothing more */
|
|
175
|
+
.op-tool {
|
|
176
|
+
align-self: flex-start; font-size: 11px; color: #9ab; background: #10131c;
|
|
177
|
+
border: 1px solid #24304a; border-radius: 6px; padding: 3px 7px; font-family: ui-monospace, monospace;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/* Edit-run rows ("3 edits") — plain, never expandable */
|
|
181
|
+
.op-group-head {
|
|
182
|
+
align-self: stretch; font-size: 11px; color: #9a9aa2;
|
|
183
|
+
background: #15151b; border: 1px solid #26262c; border-radius: 6px; padding: 3px 7px;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/* Tool-result summary lines */
|
|
187
|
+
.op-tres { align-self: stretch; font-size: 11px; color: #9a9aa2; padding-left: 8px; white-space: pre-wrap; word-break: break-word; }
|
|
188
|
+
.op-tres.err { color: #f8b4b4; }
|
|
189
|
+
.op-tres-wrap { align-self: stretch; display: flex; flex-direction: column; gap: 4px; }
|
|
190
|
+
|
|
191
|
+
/* End-of-turn marker / throttled / rewound / artifacts */
|
|
192
|
+
.op-turnend { align-self: stretch; border-top: 1px solid #26262c; padding-top: 3px; font-size: 11px; color: #6b7280; }
|
|
193
|
+
.op-throttle { align-self: stretch; font-size: 11px; color: #fdba74; background: #2a1c0e; border: 1px solid #5a3a1a; border-radius: 8px; padding: 6px 9px; }
|
|
194
|
+
.op-rewound { align-self: center; font-size: 10px; color: #fbbf24cc; }
|
|
195
|
+
.op-artifact { align-self: stretch; font-size: 11px; background: #16162a; border: 1px solid #3b3b6b; border-radius: 8px; padding: 6px 9px; }
|
|
196
|
+
.op-artifact-head { color: #a5b4fc; font-weight: 600; }
|
|
197
|
+
.op-artifact-path { color: #8a8a94; font-family: ui-monospace, monospace; }
|
|
198
|
+
|
|
199
|
+
/* The agent's plan (last todos event) */
|
|
200
|
+
.op-todos { align-self: stretch; font-size: 11px; background: #15151b; border: 1px solid #26262c; border-radius: 8px; padding: 6px 9px; display: flex; flex-direction: column; gap: 2px; }
|
|
201
|
+
.op-todos-head { font-weight: 600; color: #9a9aa2; margin-bottom: 2px; }
|
|
202
|
+
.op-todo { display: flex; gap: 6px; color: #cdd6e6; }
|
|
203
|
+
.op-todo.completed { color: #6b7280; text-decoration: line-through; }
|
|
204
|
+
.op-todo.in_progress { color: #e7e7ea; }
|
|
205
|
+
|
|
206
|
+
/* Context bar (chips + toggles) */
|
|
207
|
+
.op-ctx { flex: 0 0 auto; border-top: 1px solid #26262c; padding: 8px 10px 0; display: flex; flex-direction: column; gap: 6px; }
|
|
208
|
+
.op-chips { display: flex; flex-wrap: wrap; gap: 5px; }
|
|
209
|
+
.op-chip {
|
|
210
|
+
display: inline-flex; align-items: center; gap: 5px; max-width: 220px;
|
|
211
|
+
background: #10131c; border: 1px solid #24304a; color: #6ea8fe;
|
|
212
|
+
border-radius: 6px; padding: 3px 6px; font-size: 11px;
|
|
213
|
+
}
|
|
214
|
+
.op-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, monospace; }
|
|
215
|
+
.op-chip button { background: none; border: none; color: #6ea8fe; cursor: pointer; padding: 0; font-size: 13px; line-height: 1; }
|
|
216
|
+
.op-toggles { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
217
|
+
.op-toggle {
|
|
218
|
+
display: inline-flex; align-items: center; gap: 4px; cursor: pointer;
|
|
219
|
+
font-size: 10px; color: #9a9aa2; background: #0d0d10; border: 1px solid #2c2c34;
|
|
220
|
+
border-radius: 6px; padding: 3px 6px; user-select: none;
|
|
221
|
+
}
|
|
222
|
+
.op-toggle.on { color: #6ea8fe; border-color: #24304a; background: #10131c; }
|
|
223
|
+
.op-toggle .ct { color: #6b7280; }
|
|
224
|
+
|
|
225
|
+
/* Pick button — sits in the toggles row (icon only); right-click cycles trigger */
|
|
226
|
+
.op-pick { position: relative; padding: 3px 6px; color: #9a9aa2; }
|
|
227
|
+
.op-pick svg { display: block; width: 14px; height: 14px; }
|
|
228
|
+
.op-pick.active { color: #06121f; background: #6ea8fe; border-color: #6ea8fe; }
|
|
229
|
+
.op-pick.hint::after {
|
|
230
|
+
content: attr(data-hint); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
|
|
231
|
+
white-space: nowrap; background: #1a1a1f; border: 1px solid #2c2c34; color: #e7e7ea;
|
|
232
|
+
font-size: 10px; padding: 3px 6px; border-radius: 5px; pointer-events: none;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/* Composer: transparent textarea over a highlight backdrop, mic pinned top-right */
|
|
236
|
+
.op-composer { flex: 0 0 auto; display: flex; gap: 6px; padding: 8px 10px 10px; align-items: flex-end; }
|
|
237
|
+
.op-input-wrap {
|
|
238
|
+
position: relative; flex: 1; min-height: 34px;
|
|
239
|
+
background: #0d0d10; border: 1px solid #2c2c34; border-radius: 7px;
|
|
240
|
+
}
|
|
241
|
+
.op-input-wrap:focus-within { border-color: #3b4a6b; }
|
|
242
|
+
.op-backdrop, .op-input {
|
|
243
|
+
margin: 0; min-height: 34px; max-height: 120px; box-sizing: border-box;
|
|
244
|
+
padding: 8px 30px 8px 9px; font-size: 13px; line-height: 1.4;
|
|
245
|
+
font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
|
|
246
|
+
white-space: pre-wrap; overflow-wrap: break-word; word-break: break-word;
|
|
247
|
+
}
|
|
248
|
+
.op-backdrop {
|
|
249
|
+
position: absolute; inset: 0; pointer-events: none; overflow: hidden;
|
|
250
|
+
color: #e7e7ea; border: 1px solid transparent; border-radius: 7px;
|
|
251
|
+
}
|
|
252
|
+
.op-backdrop .op-kw {
|
|
253
|
+
background: linear-gradient(to right, #e879f9, #fcd34d, #22d3ee);
|
|
254
|
+
-webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 600;
|
|
255
|
+
}
|
|
256
|
+
.op-input {
|
|
257
|
+
/* Transparent over the backdrop so the highlighted text shows through (an
|
|
258
|
+
opaque background here would hide the backdrop → invisible "black on black"). */
|
|
259
|
+
position: relative; display: block; width: 100%; resize: none; overflow-y: auto;
|
|
260
|
+
background: transparent; border: 1px solid transparent; border-radius: 7px;
|
|
261
|
+
color: transparent; caret-color: #e7e7ea; outline: none;
|
|
262
|
+
}
|
|
263
|
+
.op-input::placeholder { color: #6b7280; }
|
|
264
|
+
.op-mic {
|
|
265
|
+
position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; padding: 0;
|
|
266
|
+
display: flex; align-items: center; justify-content: center;
|
|
267
|
+
background: transparent; color: #6b7280; border: none; border-radius: 5px; cursor: pointer;
|
|
268
|
+
}
|
|
269
|
+
.op-mic:hover { color: #6ea8fe; background: #181b24; }
|
|
270
|
+
.op-mic svg { display: block; }
|
|
271
|
+
.op-mic.active { color: #f87171; animation: op-pulse 1.2s ease-in-out infinite; }
|
|
272
|
+
.op-send {
|
|
273
|
+
background: #6ea8fe; color: #06121f; border: none; border-radius: 7px;
|
|
274
|
+
width: 34px; height: 34px; cursor: pointer; font-size: 16px; flex: 0 0 auto;
|
|
275
|
+
}
|
|
276
|
+
.op-send:disabled { opacity: .4; cursor: default; }
|
|
277
|
+
|
|
278
|
+
/* Tool-result images in the feed */
|
|
279
|
+
.op-images { display: flex; flex-wrap: wrap; gap: 6px; align-self: flex-start; max-width: 88%; }
|
|
280
|
+
.op-img { max-width: 130px; max-height: 130px; border-radius: 6px; border: 1px solid #2c2c34; display: block; }
|
|
281
|
+
|
|
282
|
+
/* Parked "also" chips above the composer */
|
|
283
|
+
.op-queue { display: flex; flex-direction: column; gap: 4px; padding: 6px 10px 0; }
|
|
284
|
+
.op-queue:empty { display: none; }
|
|
285
|
+
.op-qchip {
|
|
286
|
+
display: flex; align-items: center; gap: 6px; font-size: 11px;
|
|
287
|
+
background: #10131c; border: 1px solid #24304a; border-radius: 6px; padding: 4px 6px;
|
|
288
|
+
}
|
|
289
|
+
.op-qchip.preview { border-color: #6366f1; }
|
|
290
|
+
.op-qchip > span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; color: #cdd6e6; }
|
|
291
|
+
.op-qchip > span:hover { color: #fff; }
|
|
292
|
+
.op-qsend, .op-qx { background: none; border: none; cursor: pointer; padding: 0 2px; font-size: 13px; line-height: 1; flex: 0 0 auto; }
|
|
293
|
+
.op-qsend { color: #6ea8fe; }
|
|
294
|
+
.op-qx { color: #6b7280; }
|
|
295
|
+
.op-qx:hover { color: #f87171; }
|
|
296
|
+
|
|
297
|
+
/* Mid-turn "queued" messages — right-aligned, ring-bordered bubbles at the chat
|
|
298
|
+
end, matching the main chat. */
|
|
299
|
+
.op-pmsg {
|
|
300
|
+
align-self: flex-end; max-width: 92%; border-radius: 9px; padding: 7px 10px;
|
|
301
|
+
color: #b6c0d0; box-shadow: inset 0 0 0 1px rgba(99,102,241,.3); word-break: break-word;
|
|
302
|
+
}
|
|
303
|
+
.op-pmsg-head { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: rgba(165,180,252,.7); }
|
|
304
|
+
.op-pmsg-x { margin-left: auto; background: none; border: none; cursor: pointer; color: #9a9aa2; font-size: 13px; line-height: 1; padding: 0 2px; }
|
|
305
|
+
.op-pmsg-x:hover { color: #e7e7ea; }
|
|
306
|
+
.op-pmsg-body { white-space: pre-wrap; }
|
|
307
|
+
|
|
308
|
+
/* Interactive prompts (permission / advance / clarification / question) */
|
|
309
|
+
.op-prompt {
|
|
310
|
+
align-self: stretch; background: #14171f; border: 1px solid #2f3b52; border-left: 3px solid #6ea8fe;
|
|
311
|
+
border-radius: 8px; padding: 9px 10px; display: flex; flex-direction: column; gap: 7px;
|
|
312
|
+
}
|
|
313
|
+
.op-prompt-head { font-size: 12px; font-weight: 600; color: #cdd6e6; }
|
|
314
|
+
.op-prompt-body { font-size: 12px; color: #b6c0d0; white-space: pre-wrap; word-break: break-word; }
|
|
315
|
+
.op-prompt-note { font-size: 11px; font-weight: 600; color: #fbbf24; }
|
|
316
|
+
.op-prompt-pre {
|
|
317
|
+
margin: 0; max-height: 130px; overflow: auto; background: #0b0d12; border: 1px solid #222938;
|
|
318
|
+
border-radius: 6px; padding: 6px 8px; font-family: ui-monospace, monospace; font-size: 11px;
|
|
319
|
+
white-space: pre-wrap; overflow-wrap: anywhere;
|
|
320
|
+
}
|
|
321
|
+
.op-prompt-q { display: flex; flex-direction: column; gap: 5px; }
|
|
322
|
+
.op-prompt-qt { font-size: 12px; color: #cdd6e6; display: flex; align-items: baseline; gap: 6px; }
|
|
323
|
+
.op-prompt-tag {
|
|
324
|
+
font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
|
|
325
|
+
background: #26262c; color: #9a9aa2; border-radius: 4px; padding: 1px 5px; flex: 0 0 auto;
|
|
326
|
+
}
|
|
327
|
+
.op-prompt-opts, .op-prompt-actions { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
328
|
+
/* Question-form options: full-width column with label + description (parity
|
|
329
|
+
with the main chat's QuestionPrompt), selected state highlighted. */
|
|
330
|
+
.op-prompt-choices { display: flex; flex-direction: column; gap: 4px; }
|
|
331
|
+
.op-choice {
|
|
332
|
+
text-align: left; font-size: 11px; cursor: pointer; border-radius: 6px; padding: 5px 8px;
|
|
333
|
+
background: #1a1d26; border: 1px solid #2c2c34; color: #cdd6e6;
|
|
334
|
+
}
|
|
335
|
+
.op-choice:hover { border-color: #3b4a6b; }
|
|
336
|
+
.op-choice.on { border-color: #6366f1; background: #1d2040; }
|
|
337
|
+
.op-choice-label { font-weight: 600; }
|
|
338
|
+
.op-choice-desc { color: #8a8a94; }
|
|
339
|
+
.op-btn:disabled, .op-choice:disabled { opacity: .4; cursor: default; }
|
|
340
|
+
.op-prompt-input {
|
|
341
|
+
background: #0d0d10; border: 1px solid #2c2c34; border-radius: 6px; color: #e7e7ea;
|
|
342
|
+
padding: 6px 8px; font-size: 12px; outline: none;
|
|
343
|
+
}
|
|
344
|
+
.op-prompt-input:focus { border-color: #3b4a6b; }
|
|
345
|
+
.op-btn {
|
|
346
|
+
border: 1px solid #2c2c34; border-radius: 6px; padding: 5px 10px; font-size: 11px; font-weight: 600;
|
|
347
|
+
cursor: pointer; background: #1a1d26; color: #cdd6e6;
|
|
348
|
+
}
|
|
349
|
+
.op-btn-ok { background: #15803d; border-color: #15803d; color: #eafff0; }
|
|
350
|
+
.op-btn-danger { background: #b91c1c; border-color: #b91c1c; color: #fff0f0; }
|
|
351
|
+
.op-btn-muted { background: #1a1d26; color: #9a9aa2; }
|
|
352
|
+
|
|
353
|
+
/* Markdown in assistant bubbles */
|
|
354
|
+
.op-md.op-msg { display: block; }
|
|
355
|
+
.op-md p { margin: 0 0 6px; }
|
|
356
|
+
.op-md p:last-child { margin-bottom: 0; }
|
|
357
|
+
.op-md .op-md-h { font-weight: 700; margin: 4px 0; }
|
|
358
|
+
.op-md .op-md-ul { margin: 4px 0; padding-left: 18px; }
|
|
359
|
+
.op-md .op-md-q { border-left: 2px solid #3b4a6b; padding-left: 8px; color: #9aa7bd; margin: 4px 0; }
|
|
360
|
+
.op-md .op-md-code, .op-md code {
|
|
361
|
+
font-family: ui-monospace, monospace; font-size: 12px; background: #0b0d12; border: 1px solid #222938;
|
|
362
|
+
border-radius: 4px; padding: 0 4px;
|
|
363
|
+
}
|
|
364
|
+
.op-md .op-md-pre {
|
|
365
|
+
margin: 6px 0; background: #0b0d12; border: 1px solid #222938; border-radius: 6px; padding: 8px;
|
|
366
|
+
overflow: auto; font-size: 12px;
|
|
367
|
+
}
|
|
368
|
+
.op-md .op-md-pre code { background: none; border: none; padding: 0; }
|
|
369
|
+
.op-md a { color: #6ea8fe; }
|
|
370
|
+
.op-md strong { font-weight: 700; }
|
|
371
|
+
.op-md em { font-style: italic; }
|
|
372
|
+
.op-md del { color: #8a8a94; }
|
|
373
|
+
.op-md .op-md-img { max-width: 100%; max-height: 220px; border-radius: 6px; border: 1px solid #2c2c34; display: block; margin: 4px 0; }
|
|
374
|
+
.op-md .op-md-table { border-collapse: collapse; margin: 6px 0; font-size: 12px; display: block; overflow-x: auto; max-width: 100%; }
|
|
375
|
+
.op-md .op-md-table th, .op-md .op-md-table td { border: 1px solid #2c2c34; padding: 3px 8px; text-align: left; white-space: nowrap; }
|
|
376
|
+
.op-md .op-md-table th { background: #1a1a1f; font-weight: 600; }
|
|
377
|
+
|
|
378
|
+
/* Slash-command autocomplete over the composer */
|
|
379
|
+
.op-menu {
|
|
380
|
+
position: absolute; bottom: calc(100% + 4px); left: 0; right: 0; z-index: 3;
|
|
381
|
+
max-height: 180px; overflow-y: auto; padding: 3px;
|
|
382
|
+
background: #1a1a1f; border: 1px solid #2c2c34; border-radius: 8px;
|
|
383
|
+
box-shadow: 0 8px 24px rgba(0,0,0,.5); display: flex; flex-direction: column;
|
|
384
|
+
}
|
|
385
|
+
.op-menu-item {
|
|
386
|
+
display: flex; align-items: baseline; gap: 6px; text-align: left; cursor: pointer;
|
|
387
|
+
background: none; border: none; border-radius: 5px; padding: 4px 7px; font-size: 11px; color: #cdd6e6;
|
|
388
|
+
}
|
|
389
|
+
.op-menu-item.active { background: #26304a; }
|
|
390
|
+
.op-menu-name { font-family: ui-monospace, monospace; color: #fcd34d; flex: 0 0 auto; }
|
|
391
|
+
.op-menu-hint { font-family: ui-monospace, monospace; color: #6b7280; flex: 0 0 auto; }
|
|
392
|
+
.op-menu-desc { color: #8a8a94; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
393
|
+
|
|
394
|
+
/* While picking an element, hide our own UI so clicks land on the page behind it
|
|
395
|
+
(the highlight/label layers below are separate and stay visible). */
|
|
396
|
+
.op-root.picking .op-fab, .op-root.picking .op-panel { display: none !important; }
|
|
397
|
+
|
|
398
|
+
/* Pick mode overlay layer */
|
|
399
|
+
.op-pick-highlight {
|
|
400
|
+
position: fixed; pointer-events: none; z-index: 2147483001;
|
|
401
|
+
background: rgba(110,168,254,.18); border: 2px solid #6ea8fe; border-radius: 3px;
|
|
402
|
+
}
|
|
403
|
+
.op-pick-label {
|
|
404
|
+
position: fixed; pointer-events: none; z-index: 2147483002;
|
|
405
|
+
background: #6ea8fe; color: #06121f; font-size: 10px; font-weight: 600;
|
|
406
|
+
padding: 2px 6px; border-radius: 4px; font-family: ui-monospace, monospace; white-space: nowrap;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/* Respect a user's reduced-motion preference: drop the looping animations (the
|
|
410
|
+
pulse ring, thinking dots, recording mic) — the colors still convey state. */
|
|
411
|
+
@media (prefers-reduced-motion: reduce) {
|
|
412
|
+
.op-fab-status.thinking, .op-tab-dot.on, .op-mic.active, .op-dots i {
|
|
413
|
+
animation: none !important;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
`;class oi{constructor(e,t){this.cfg=e,this.handlers=t,this.wsUrl=e.server.replace(/^http/,"ws")+"/ws",this.projectId=e.projectId,this.keys.add(e.taskId)}socket=null;closed=!1;warnedInsecure=!1;reconnectDelay=500;RECONNECT_CAP=15e3;wsUrl;projectId;keys=new Set;subscribe(e){this.keys.has(e)||(this.keys.add(e),this.send({kind:"subscribe_agent",taskId:e}))}setProjectId(e){this.projectId=e}warnInsecureContext(){if(!this.warnedInsecure)try{const e=!!globalThis.isSecureContext,t=new URL(this.wsUrl).hostname,s=t==="localhost"||t==="127.0.0.1"||t==="::1"||t==="[::1]";e&&this.wsUrl.startsWith("ws://")&&!s&&(this.warnedInsecure=!0,console.warn(`[operator-devtools] the host page is a secure context but the Operator server is ws:// (${this.wsUrl}). Browsers block mixed-content WebSockets to non-localhost hosts, so the chat will not connect. Use an https/wss Operator origin, or serve the host page over http.`))}catch{}}connect(){if(this.socket||this.closed)return;this.warnInsecureContext(),this.handlers.onState("connecting");let e;try{e=new WebSocket(this.wsUrl)}catch{this.scheduleReconnect();return}this.socket=e,e.onopen=()=>{this.reconnectDelay=500,this.handlers.onState("open");for(const t of this.keys)this.send({kind:"subscribe_agent",taskId:t})},e.onmessage=t=>{let s;try{s=JSON.parse(t.data)}catch{return}this.dispatch(s)},e.onclose=()=>{this.socket=null,this.handlers.onState("closed"),this.scheduleReconnect()},e.onerror=()=>{}}dispatch(e){switch(e.kind){case"agent_history":this.keys.has(e.taskId)&&this.handlers.onHistory(e.taskId,e.events,e.lastSeq);break;case"agent":this.keys.has(e.taskId)&&this.handlers.onEvent(e.taskId,e.event,e.seq);break;case"dictation_partial":case"dictation_final":this.handlers.onDictation?.({kind:e.kind,text:e.text});break;case"dictation_error":this.handlers.onDictation?.({kind:e.kind,text:e.message});break;case"devtools_command":this.keys.has(e.taskId)&&this.handlers.onDevtoolsCommand?.(e.taskId,e.commandId,e.action,e.args);break;case"error":this.handlers.onError(e.message);break}}send(e){this.socket?.readyState===WebSocket.OPEN&&this.socket.send(JSON.stringify(e))}scheduleReconnect(){if(this.closed)return;const e=Math.random()*this.reconnectDelay;this.reconnectDelay=Math.min(this.reconnectDelay*2,this.RECONNECT_CAP),setTimeout(()=>this.connect(),e)}async sendMessage(e,t=this.cfg.taskId){const s=t===this.cfg.taskId?A.message(this.projectId,this.cfg.taskId):A.forkMessage(this.projectId,this.cfg.taskId,t),i=await fetch(this.cfg.server+s,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:e})});if(!i.ok)throw new Error(`send failed: ${i.status} ${i.statusText}`)}async interrupt(e=this.cfg.taskId){await fetch(this.cfg.server+A.interrupt(this.projectId,e),{method:"POST"}).catch(()=>{})}dispose(){this.closed=!0,this.socket?.close(),this.socket=null}}const qt=n=>`operator:devtools:open:${n}`,Zt=n=>`operator:devtools:pos:${n}`,Kt=n=>`operator:devtools:size:${n}`,ai=260,Ut=200,ci=340,di=480,Ye=n=>`operator:devtools:draft:${n}`,Ft="operator:devtools:pickmod",me=44,Ge=["none","cmd","cmd-shift"],Vt={none:"button only",cmd:"hold ⌘","cmd-shift":"hold ⌘⇧"},li='<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="2" width="6" height="11" rx="3"/><path d="M5 10a7 7 0 0 0 14 0"/><line x1="12" y1="17" x2="12" y2="21"/></svg>',pi='<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><line x1="12" y1="2" x2="12" y2="6"/><line x1="12" y1="18" x2="12" y2="22"/><line x1="2" y1="12" x2="6" y2="12"/><line x1="18" y1="12" x2="22" y2="12"/></svg>';class ui{constructor(e){this.cfg=e,this.isOpen=hi(e.taskId)??e.open??!1,this.pos=bi(e.taskId)??{x:18,y:Math.max(18,window.innerHeight-me-18)},this.size=yi(e.taskId)??{w:ci,h:di},this.pickMod=ki(),this.projectId=e.projectId,this.activeKey=e.taskId,this.inst=new Qs(e.server),this.inst.install(),this.dictation=new Ms(t=>this.transport.send(t)),this.host=document.createElement("div"),this.host.id="operator-devtools-root",this.shadow=this.host.attachShadow({mode:"open"}),this.installStyles(),this.buildUI(),document.body.append(this.host),this.favicon=new Ls(this.markerColor,e.favicon??"auto"),this.favicon.apply(),this.picker=new si(this.shadow.querySelector(".op-root"),this.host,t=>this.addPick(t),()=>this.refreshPickBtn()),this.transport=new oi(e,{onHistory:(t,s,i)=>this.onHistory(t,s,i),onEvent:(t,s,i)=>this.onEvent(t,s,i),onState:t=>this.setConnState(t),onError:t=>this.onEvent(this.activeKey,{type:"error",message:t}),onDictation:t=>this.dictation.onReply(t),onDevtoolsCommand:(t,s,i,r)=>this.runDevtoolsCommand(t,s,i,r)}),this.transport.connect(),this.applyPos(),this.applyOpen(),this.resolveProjectId().then(()=>{this.loadComposer(),this.fetchForks()}),window.addEventListener("keydown",this.onKeyMod),window.addEventListener("keyup",this.onKeyMod),window.addEventListener("keydown",this.onKeyEsc),window.addEventListener("resize",this.onResize),document.addEventListener("astro:after-swap",this.reattach),document.addEventListener("astro:page-load",this.reattach)}host;shadow;inst;transport;picker;favicon;sessions=new Map;stateByKey=new Map;pendingByKey=new Map;commandsByKey=new Map;hiddenByKey=new Map;activeKey;forks=[];picks=[];toggles={includeNetwork:!1,includeConsole:!1,includeErrors:!1};connState="connecting";get events(){let e=this.sessions.get(this.activeKey);return e||(e=[],this.sessions.set(this.activeKey,e)),e}get running(){return this.stateByKey.get(this.activeKey)==="running"}get stoppable(){const e=this.stateByKey.get(this.activeKey);return e==="running"||e==="throttled"}get hidden(){let e=this.hiddenByKey.get(this.activeKey);return e||(e=new Set,this.hiddenByKey.set(this.activeKey,e)),e}get markerColor(){return this.cfg.color||Bn(this.cfg.taskId).hsl}get pending(){let e=this.pendingByKey.get(this.activeKey);return e||(e=[],this.pendingByKey.set(this.activeKey,e)),e}isOpen;unread=0;countTimer=null;queue=[];preview=null;composerLoaded=!1;saveTimer=null;lastLocalEdit=0;syncTimer=null;resolved=new Set;suppressed=new Set;busyPrompts=new Set;askState=new Map;menuMatches=[];menuIndex=0;menuDismissed=!1;pinned=!0;dictation;recording=!1;pos;size;flipRight=!0;flipUp=!0;pickMod;modArmed=!1;projectId;rootEl;fab;fabBadge;fabStatus;panel;resizeHandle;head;tabsEl;dot;runningEl;feed;jumpBtn;menuEl;chips;queueEl;togglesEl;input;backdrop;pickBtn;micBtn;sendBtn;reattach=()=>{this.host.isConnected||document.body.append(this.host),this.favicon.apply()};installStyles(){try{if("adoptedStyleSheets"in Document.prototype&&typeof CSSStyleSheet=="function"){const t=new CSSStyleSheet;t.replaceSync(Dt),this.shadow.adoptedStyleSheets=[t];return}}catch{}const e=document.createElement("style");e.textContent=Dt,this.shadow.append(e)}onKeyMod=e=>{if(this.pickMod==="none")return;const t=this.pickMod==="cmd-shift"?e.metaKey&&e.shiftKey:e.metaKey&&!e.shiftKey;t&&!this.picker.isActive?(this.modArmed=!0,this.picker.start(),this.refreshPickBtn()):!t&&this.modArmed&&(this.modArmed=!1,this.picker.stop(),this.refreshPickBtn())};onKeyEsc=e=>{e.key==="Escape"&&e.metaKey&&this.stoppable&&!(this.picker?.isActive??!1)&&(e.preventDefault(),this.interruptActive())};interruptActive(){if(this.picker?.isActive??!1)return;const e=Ts({stoppable:this.stoppable,pendingCount:this.pending.length,draft:this.input.value,lastUserTurn:Es(pe(this.events,this.hidden))});if(!e)return;const t=this.activeKey,s=this.transport.interrupt(t);if(e.flush&&s.then(()=>this.flushPending(t)),e.restore!==void 0){const i=pe(this.events,this.hidden);for(const r of as(i,e.hideFromIndex))this.hidden.add(r);this.input.value=e.restore,this.autosize(),this.persistDraft(),this.renderFeed(),this.input.focus()}}onResize=()=>{this.pos=Qe(this.pos),this.applyPos(),this.isOpen&&this.positionPanel()};async resolveProjectId(){const e=async t=>{try{return(await fetch(this.api(A.task(t,this.cfg.taskId)))).ok}catch{return!1}};if(!(this.projectId&&await e(this.projectId)))try{const t=await fetch(this.api(A.projects()));if(!t.ok)return;const{projects:s}=await t.json();for(const i of s??[])if(await e(i.id)){this.projectId=i.id,this.transport.setProjectId(i.id);return}}catch{}}api(e){return this.cfg.server+e}applyRemoteComposer(e,t){this.syncTimer!=null&&(clearTimeout(this.syncTimer),this.syncTimer=null);const s=ys({local:{queue:this.queue,pending:this.pending},remote:{queue:e,pending:t},sinceLocalEditMs:Date.now()-this.lastLocalEdit});if(s.kind!=="skip"){if(s.kind==="defer"){const i=this.activeKey;this.syncTimer=window.setTimeout(()=>{this.syncTimer=null,i===this.activeKey&&this.applyRemoteComposer(e,t)},s.retryInMs);return}this.queue=[...e],this.preview=null,this.pendingByKey.set(this.activeKey,[...t]),this.renderQueue(),this.renderPending()}}async loadComposer(){const e=this.activeKey;try{const t=await fetch(this.api(A.composer(this.projectId,e)));if(!t.ok||e!==this.activeKey)return;const s=await t.json();if(e!==this.activeKey)return;if(!this.composerLoaded){this.queue=Re(s.queue),this.preview=null,this.pendingByKey.set(e,Re(s.pending));const i=mi(e);i&&!this.input.value&&(this.input.value=i,this.autosize()),this.composerLoaded=!0,this.renderQueue(),this.renderPending();return}this.applyRemoteComposer(Re(s.queue),Re(s.pending))}catch{}}persistDraft(){gi(this.activeKey,this.input.value)}saveQueue(){if(!this.composerLoaded)return;this.saveTimer!=null&&clearTimeout(this.saveTimer);const e=this.activeKey,t=[...this.queue],s=[...this.pendingByKey.get(e)??[]];this.saveTimer=window.setTimeout(async()=>{this.saveTimer=null;try{let i="";const r=await fetch(this.api(A.composer(this.projectId,e)));r.ok&&(i=(await r.json()).draft??""),await fetch(this.api(A.composer(this.projectId)),{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({key:e,draft:i,queue:t,pending:s})})}catch{}},300)}buildUI(){const e=d("div","op-root");this.rootEl=e,this.fab=d("button","op-fab"),this.fab.title="Operator DevTools — drag to move",this.fab.textContent="◎",this.fab.setAttribute("aria-label","Operator DevTools — agent chat"),this.fab.setAttribute("aria-haspopup","dialog"),this.fab.setAttribute("aria-expanded",String(this.isOpen)),this.fab.style.background=this.markerColor,this.fabBadge=d("span","op-fab-badge"),this.fabBadge.style.display="none",this.fabStatus=d("span","op-fab-status"),this.fabStatus.style.display="none",this.fab.append(this.fabBadge,this.fabStatus),this.makeDraggable(this.fab,()=>this.setOpen(!this.isOpen)),e.append(this.fab),this.panel=d("div","op-panel"),this.panel.setAttribute("role","dialog"),this.panel.setAttribute("aria-label",`Operator agent chat — ${this.cfg.taskLabel??this.cfg.taskId}`),this.panel.addEventListener("keydown",a=>{if(!(a.key!=="Escape"||(this.picker?.isActive??!1))){if(this.recording){a.preventDefault(),a.stopPropagation(),this.toggleMic();return}if(this.menuOpen){a.preventDefault(),a.stopPropagation(),this.menuDismissed=!0,this.refreshMenu();return}this.stoppable&&(a.preventDefault(),a.stopPropagation(),this.interruptActive())}}),this.head=d("div","op-head"),this.dot=d("span","op-dot");const t=d("span","op-title");t.textContent=this.cfg.taskLabel??this.cfg.taskId,this.head.append(t),this.makeDraggable(this.head),this.tabsEl=d("div","op-tabs"),this.runningEl=d("div","op-running"),this.runningEl.setAttribute("aria-live","polite"),this.feed=d("div","op-feed"),this.feed.addEventListener("scroll",()=>{const a=this.feed,c=a.scrollHeight-a.scrollTop-a.clientHeight<64;c!==this.pinned&&(this.pinned=c,this.updateJump())}),this.jumpBtn=d("button","op-jump"),this.jumpBtn.textContent="↓ latest",this.jumpBtn.style.display="none",this.jumpBtn.onclick=()=>{this.pinned=!0,this.feed.scrollTop=this.feed.scrollHeight,this.updateJump()};const s=d("div","op-feedwrap");s.append(this.feed,this.jumpBtn);const i=d("div","op-ctx");this.chips=d("div","op-chips"),this.togglesEl=d("div","op-toggles"),i.append(this.chips,this.togglesEl),this.queueEl=d("div","op-queue"),this.pickBtn=d("button","op-pick op-toggle"),Ae(this.pickBtn,pi),this.pickBtn.setAttribute("aria-label","Pick a page element to attach"),this.pickBtn.onclick=()=>this.togglePick(),this.pickBtn.oncontextmenu=a=>{a.preventDefault(),this.cyclePickMod()},this.refreshPickBtn();const r=d("div","op-composer"),o=d("div","op-input-wrap");this.backdrop=d("div","op-backdrop"),this.backdrop.setAttribute("aria-hidden","true"),this.input=d("textarea","op-input"),this.input.placeholder="Message agent",this.input.setAttribute("aria-label","Message agent"),this.input.rows=1,this.input.addEventListener("input",()=>{if(this.autosize(),this.renderBackdrop(),this.persistDraft(),this.preview){this.lastLocalEdit=Date.now();const a=Ve(this.core,this.input.value);this.queue=a.queue,this.renderQueue(),this.saveQueue()}this.menuDismissed=!1,this.refreshMenu()}),this.input.addEventListener("scroll",()=>{this.backdrop.scrollTop=this.input.scrollTop}),this.input.addEventListener("keydown",a=>{if(this.menuOpen){const c=this.menuMatches.length;if(a.key==="ArrowDown"||a.key==="ArrowUp"){a.preventDefault(),this.menuIndex=(this.menuIndex+(a.key==="ArrowDown"?1:c-1))%c,this.renderMenu();return}if(a.key==="Tab"||a.key==="Enter"){a.preventDefault(),this.acceptCommand(this.menuMatches[this.menuIndex]);return}}a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),this.send())}),this.micBtn=d("button","op-mic"),Ae(this.micBtn,li),this.micBtn.title="Dictate",this.micBtn.setAttribute("aria-label","Dictate a message"),this.micBtn.style.display=Rs?"":"none",this.micBtn.onclick=()=>this.toggleMic(),this.menuEl=d("div","op-menu"),this.menuEl.style.display="none",o.append(this.menuEl,this.backdrop,this.input,this.micBtn),this.sendBtn=d("button","op-send"),this.sendBtn.textContent="↑",this.sendBtn.setAttribute("aria-label","Send message"),this.sendBtn.style.background=this.markerColor,this.sendBtn.onclick=()=>void this.send(),r.append(o,this.sendBtn),this.resizeHandle=d("div","op-resize"),this.makeResizable(this.resizeHandle),this.panel.append(this.head,this.tabsEl,s,this.runningEl,i,this.queueEl,r,this.resizeHandle),e.append(this.panel),this.shadow.append(e),this.renderFeed(),this.renderChips(),this.renderQueue(),this.renderPending(),this.renderToggles(),this.renderBackdrop(),this.renderTabs()}async fetchForks(){try{const e=await fetch(this.api(A.task(this.projectId,this.cfg.taskId)));if(!e.ok)return;const{task:t}=await e.json();this.forks=t?.forks??[];for(const s of this.forks)this.transport.subscribe(s.key);this.activeKey!==this.cfg.taskId&&!this.forks.some(s=>s.key===this.activeKey)&&this.switchTab(this.cfg.taskId),this.renderTabs()}catch{}}renderTabs(){if(!this.forks.length){this.tabsEl.replaceChildren();return}const e=[{key:this.cfg.taskId,label:"Session"},...this.forks.map(t=>({key:t.key,label:t.label}))];this.tabsEl.replaceChildren();for(const t of e){const s=d("button","op-tab");s.classList.toggle("active",t.key===this.activeKey);const i=d("span","op-tab-dot");this.stateByKey.get(t.key)==="running"&&i.classList.add("on");const r=d("span");r.textContent=t.label,s.append(i,r),s.onclick=()=>this.switchTab(t.key),this.tabsEl.append(s)}}switchTab(e){e!==this.activeKey&&(this.activeKey=e,this.composerLoaded=!1,this.queue=[],this.preview=null,this.menuDismissed=!1,this.pinned=!0,this.syncTimer!=null&&(clearTimeout(this.syncTimer),this.syncTimer=null),this.renderQueue(),this.input.value="",this.autosize(),this.loadComposer(),this.renderTabs(),this.renderFeed(),this.renderPending(),this.updateStatus(),this.refreshMenu(),this.feed.scrollTop=this.feed.scrollHeight,this.input.focus())}buffer(e){let t=this.sessions.get(e);return t||(t=[],this.sessions.set(e,t)),t}onHistory(e,t,s){const i={events:this.sessions.get(e)??[],resolved:this.resolved},r=bs(i,t,s);if(r.adopted){for(const o of r.resolved)this.resolved.add(o);this.sessions.set(e,r.events),this.stateByKey.set(e,vs(r.events,this.stateByKey.get(e)??"idle"))}e===this.activeKey&&(this.renderFeed(),this.updateStatus()),this.renderTabs()}onEvent(e,t,s){if(t.type==="status"){this.setState(e,t.state);return}if(t.type==="composer_state"){e===this.activeKey?this.applyRemoteComposer([...t.queue],[...t.pending]):this.pendingByKey.set(e,[...t.pending]);return}if(t.type==="slash_commands"){this.commandsByKey.set(e,t.commands),e===this.activeKey&&this.refreshMenu();return}if(t.type==="usage")return;rs(t,s);const i=Tt(t);i&&this.resolved.add(i);const r=this.buffer(e);r.push(t),r.length>500&&r.shift(),(e!==this.activeKey||!this.isOpen)&&(t.type==="assistant_text"||t.type==="error")&&(this.unread++,this.updateBadge()),e===this.activeKey&&(this.renderFeed(),this.updateStatus()),this.renderTabs()}setState(e,t){const s=this.stateByKey.get(e);this.stateByKey.set(e,t),ws({wasState:s,state:t,pendingCount:this.pendingByKey.get(e)?.length??0})&&this.flushPending(e),e===this.activeKey&&this.updateStatus(),this.renderTabs()}assetUrl=e=>this.api(A.asset(this.projectId,e));renderFeed(){if(this.feed.replaceChildren(),!this.events.length&&!this.pending.length){const i=d("div","op-empty");i.textContent=this.connState==="open"?"No messages yet. Say hello to the agent.":"Connecting to the task session…",this.feed.append(i);return}const e=pe(this.events,this.hidden),t=e[e.length-1];for(const i of Ss(e))switch(i.kind){case"text":this.feed.append(Nt("assistant",i.text));break;case"steps":this.feed.append(Ds(i.steps));break;case"toolRun":{this.feed.append(qs(i.name,i.count));for(const r of i.errors){const o=zt(r);o&&this.feed.append(o)}i.images.length&&this.feed.append(We(i.images,this.assetUrl));break}case"toolGroup":{i.item.category!=="read"&&this.feed.append(Zs(i.item)),i.images.length&&this.feed.append(We(i.images,this.assetUrl));break}case"event":{const r=this.renderEvent(i.event,i.event===t);r&&this.feed.append(r);break}}const s=Ws(e);s&&this.feed.append(Hs(s)),this.pending.forEach((i,r)=>this.feed.append(this.pendingBubble(i,r))),this.pinned&&(this.feed.scrollTop=this.feed.scrollHeight),this.updateJump()}updateJump(){this.jumpBtn.style.display=this.pinned?"none":""}pendingBubble(e,t){const s=d("div","op-pmsg"),i=d("div","op-pmsg-head"),r=d("span");r.textContent="queued";const o=d("button","op-pmsg-x");o.textContent="×",o.title="Back to composer",o.onclick=()=>{this.applyCore(ms(this.core,t)),this.input.focus()},i.append(r,o);const a=d("div","op-pmsg-body");return a.textContent=e,s.append(i,a),s}renderEvent(e,t){switch(e.type){case"user_message":return Nt("user",e.text);case"thinking":return Bs(e.text);case"tool_result":{const s=zt(e);if(!e.images?.length)return s;const i=d("div","op-tres-wrap");return s&&i.append(s),i.append(We(e.images,this.assetUrl)),i}case"permission_request":case"clarification":case"ask_user_question":case"advance_proposal":return this.resolved.has(e.id)||this.suppressed.has(e.id)?null:this.renderPrompt(e,t);case"artifact":return Vs(e);case"mockup":return Bt("mockup",e.title);case"diagram":return Bt("diagram",e.title);case"result":return Ks(e.isError);case"error":{const s=d("div","op-evt-error");return s.textContent=e.message,s}case"throttled":return Us(e);case"rewound":return Fs(e.preview);default:return null}}async resolvePrompt(e,t,s){const i={permission:A.permission,clarify:A.clarify,"ask-question":A.askQuestion,"advance-decision":A.advanceDecision}[t];if(!this.busyPrompts.has(e)){this.busyPrompts.add(e),this.renderFeed();try{const r=await fetch(this.api(i(this.projectId,this.activeKey)),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(s)});if(!r.ok)throw new Error(`${r.status} ${r.statusText}`)}catch(r){this.busyPrompts.delete(e),this.renderFeed(),this.onEvent(this.activeKey,{type:"error",message:`Action failed: ${String(r?.message??r)}`});return}this.busyPrompts.delete(e),this.resolved.add(e),this.askState.delete(e),this.renderFeed(),this.updateStatus()}}renderPrompt(e,t){if(!t){const p=d("div","op-status");return p.textContent=e.type==="permission_request"?`↳ ${e.toolName} permission`:e.type==="advance_proposal"?`↳ proposed → ${e.toLane}`:e.type==="clarification"?"↳ clarification":"↳ question answered",p}const s=e.id,i=this.busyPrompts.has(s),r=d("div","op-prompt"),o=d("div","op-prompt-head"),a=d("div","op-prompt-body"),c=d("div","op-prompt-actions");if(e.type==="permission_request"){o.textContent=`Allow ${e.toolName}?`;const p=d("pre","op-prompt-pre");p.textContent=Un(e.input,600),a.append(p),c.append(H("Allow","ok",()=>this.resolvePrompt(s,"permission",{requestId:s,decision:"allow"}),i),H("Deny","danger",()=>this.resolvePrompt(s,"permission",{requestId:s,decision:"deny"}),i))}else if(e.type==="advance_proposal"){if(o.textContent=`Agent proposes → ${e.toLane}`,e.confident){const u=d("div","op-prompt-note");u.textContent="Agent is confident this phase is complete.",a.append(u)}const p=d("div");p.textContent=e.rationale??null,a.append(p),c.append(H("Accept & move","ok",()=>this.resolvePrompt(s,"advance-decision",{requestId:s,accept:!0,toLane:e.toLane}),i),H("Give feedback","muted",()=>{this.suppressed.add(s),this.renderFeed(),this.input.focus()},i))}else if(e.type==="clarification"){o.textContent="Clarification needed";const p=d("div");if(p.textContent=e.question,a.append(p),e.options?.length){const E=d("div","op-prompt-opts");for(const O of e.options)E.append(H(O,"ok",()=>this.resolvePrompt(s,"clarify",{requestId:s,answer:O}),i));a.append(E)}const u=d("input","op-prompt-input");u.placeholder="Type an answer…";const S=()=>{!i&&u.value.trim()&&this.resolvePrompt(s,"clarify",{requestId:s,answer:u.value.trim()})};u.addEventListener("keydown",E=>{E.key==="Enter"&&S(),E.stopPropagation()}),a.append(u),c.append(H("Send","ok",S,i))}else if(e.type==="ask_user_question"){o.textContent=e.questions.length>1?"The agent has questions":"The agent has a question";const p="__other__";let u=this.askState.get(s);u||(u={picked:{},other:{}},this.askState.set(s,u));const S=u,E=I=>(S.picked[I]??[]).map(T=>T===p?S.other[I]?.trim()??"":T).filter(Boolean).join(", "),O=()=>e.questions.every((I,T)=>E(T).length>0),Wt=(I,T,X)=>{const W=S.picked[I]??[];S.picked[I]=X?W.includes(T)?W.filter(ie=>ie!==T):[...W,T]:W[0]===T?[]:[T],this.renderFeed()};e.questions.forEach((I,T)=>{const X=d("div","op-prompt-q"),W=d("div","op-prompt-qt");if(I.header){const R=d("span","op-prompt-tag");R.textContent=I.header,W.append(R)}W.append(document.createTextNode(I.question)),X.append(W);const ie=d("div","op-prompt-choices"),tt=S.picked[T]??[];for(const R of I.options){const re=d("button",`op-choice${tt.includes(R.label)?" on":""}`),Gt=d("span","op-choice-label");if(Gt.textContent=R.label,re.append(Gt),R.description){const Qt=d("span","op-choice-desc");Qt.textContent=` — ${R.description}`,re.append(Qt)}re.onclick=()=>Wt(T,R.label,I.multiSelect),ie.append(re)}const nt=d("button",`op-choice${tt.includes(p)?" on":""}`),Yt=d("span","op-choice-label");if(Yt.textContent="Other…",nt.append(Yt),nt.onclick=()=>Wt(T,p,I.multiSelect),ie.append(nt),tt.includes(p)){const R=d("input","op-prompt-input");R.placeholder="Type your answer…",R.value=S.other[T]??"",R.addEventListener("input",()=>{S.other[T]=R.value,Jt.disabled=i||!O()}),R.addEventListener("keydown",re=>re.stopPropagation()),ie.append(R)}X.append(ie),a.append(X)});const Jt=H("Submit","ok",()=>{if(!O())return;const I={};e.questions.forEach((T,X)=>I[T.question]=E(X)),this.resolvePrompt(s,"ask-question",{requestId:s,answers:I})},i||!O());c.append(Jt,H("Cancel","muted",()=>this.resolvePrompt(s,"ask-question",{requestId:s}),i))}return r.append(o,a,c),r}togglePick(){this.picker.isActive?this.picker.stop():this.picker.start(),this.refreshPickBtn()}refreshPickBtn(){const e=this.picker?.isActive??!1;this.pickBtn.classList.toggle("active",e),this.pickBtn.title=`Pick element to attach · ${Vt[this.pickMod]} (right-click to change)`,this.rootEl.classList.toggle("picking",e)}cyclePickMod(){this.pickMod=Ge[(Ge.indexOf(this.pickMod)+1)%Ge.length],wi(this.pickMod),this.refreshPickBtn(),this.pickBtn.dataset.hint=Vt[this.pickMod],this.pickBtn.classList.add("hint"),window.setTimeout(()=>this.pickBtn.classList.remove("hint"),1100)}addPick(e){this.picks.push(e),this.renderChips()}removePick(e){this.picks.splice(e,1),this.renderChips()}renderChips(){this.chips.replaceChildren(),this.picks.forEach((e,t)=>{const s=d("div","op-chip"),i=d("span");i.textContent=`${e.tag} ${e.selector}`;const r=d("button");r.textContent="×",r.title="Remove",r.onclick=()=>this.removePick(t),s.append(i,r),this.chips.append(s)})}renderToggles(){this.togglesEl.replaceChildren(),this.togglesEl.append(this.pickBtn);const e=[{key:"includeNetwork",label:"Network",count:()=>this.inst.network.all().length},{key:"includeConsole",label:"Console",count:()=>this.inst.console.all().length},{key:"includeErrors",label:"Errors",count:()=>this.inst.errors.all().length}];for(const t of e){const s=d("label","op-toggle"),i=this.toggles[t.key];s.classList.toggle("on",i);const r=document.createTextNode((i?"● ":"○ ")+t.label+" "),o=d("span","ct");o.textContent=`(${t.count()})`,s.append(r,o),s.onclick=()=>{this.toggles[t.key]=!this.toggles[t.key],this.renderToggles()},this.togglesEl.append(s)}}currentContextOptions(){return{picks:this.picks,...this.toggles}}get core(){return{draft:this.input.value,queue:this.queue,preview:this.preview,pending:this.pending}}applyCore(e){this.lastLocalEdit=Date.now(),this.queue=e.queue,this.preview=e.preview,this.pendingByKey.set(this.activeKey,[...e.pending]),this.input.value!==e.draft&&(this.input.value=e.draft,this.autosize()),this.persistDraft(),this.renderQueue(),this.renderPending(),this.saveQueue()}async send(){if(!this.input.value.trim()){Pt(this.currentContextOptions(),this.inst)&&await this.deliver("",!0);return}const e=It(pe(this.events,this.hidden),this.resolved)!==null,t=hs(this.core,{running:this.running,promptParked:e});this.applyCore(t.state),t.kind==="send"&&(await this.deliver(t.text,!1)||this.applyCore(fs(this.core,t.text)))}async sendQueuedNow(e){const{state:t,text:s}=ls(this.core,e);if(s===null)return;this.applyCore(t),await this.deliver(s,!1)||this.applyCore(ps(this.core,s))}async deliver(e,t,s=this.activeKey){const i=this.currentContextOptions(),r=Pt(i,this.inst)?$s(i,this.inst):"";if(!e&&!r)return!0;const o=e+r;this.sendBtn.disabled=!0;try{return await this.transport.sendMessage(o,s),t&&(this.input.value="",this.autosize(),this.persistDraft()),this.picks=[],this.renderChips(),!0}catch(a){return this.onEvent(this.activeKey,{type:"error",message:`Failed to send: ${String(a?.message??a)}`}),!1}finally{this.sendBtn.disabled=!1}}flushPending(e){const t=this.pendingByKey.get(e);if(!t||!t.length)return;const s=[...t];this.pendingByKey.set(e,[]),e===this.activeKey&&this.renderPending(),this.serverFlush(e,s)}async serverFlush(e,t){let s;try{const r=await fetch(this.api(A.composerFlush(this.projectId)),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({key:e})});s=r.ok?await r.json():null}catch{s=void 0}if(ks(s)==="done")return;const i=this.pendingByKey.get(e)??[];this.pendingByKey.set(e,[...t,...i]),e===this.activeKey&&this.renderPending()}renderQueue(){this.queueEl.replaceChildren(),this.queue.forEach((e,t)=>{const s=d("div","op-qchip");this.preview?.index===t&&s.classList.add("preview");const i=d("span");i.textContent=e,i.title="Click to edit (again to restore) · ⌘-click to send now",i.onclick=a=>{if(a.metaKey||a.ctrlKey){this.sendQueuedNow(t);return}const c=this.preview?.index!==t;this.applyCore(ds(this.core,t)),c&&this.input.focus()};const r=d("button","op-qsend");r.textContent="↑",r.title="Send now",r.onclick=a=>{a.stopPropagation(),this.sendQueuedNow(t)};const o=d("button","op-qx");o.textContent="×",o.title="Remove",o.onclick=a=>{a.stopPropagation(),this.applyCore(us(this.core,t))},s.append(i,r,o),this.queueEl.append(s)})}get menuOpen(){return this.menuMatches.length>0&&!this.menuDismissed}refreshMenu(){const e=this.commandsByKey.get(this.activeKey)??[];this.menuMatches=Is(this.input.value,e),this.menuIndex>=this.menuMatches.length&&(this.menuIndex=0),this.renderMenu()}renderMenu(){if(!this.menuOpen){this.menuEl.style.display="none",this.menuEl.replaceChildren();return}this.menuEl.style.display="",this.menuEl.replaceChildren(),this.menuMatches.forEach((e,t)=>{const s=d("button",`op-menu-item${t===this.menuIndex?" active":""}`),i=d("span","op-menu-name");if(i.textContent=`/${e.name}`,s.append(i),e.argumentHint){const r=d("span","op-menu-hint");r.textContent=e.argumentHint,s.append(r)}if(e.description){const r=d("span","op-menu-desc");r.textContent=e.description,s.append(r)}s.onmousedown=r=>{r.preventDefault(),this.acceptCommand(e)},s.onmouseenter=()=>{this.menuIndex!==t&&(this.menuIndex=t,this.renderMenu())},this.menuEl.append(s)}),this.menuEl.children[this.menuIndex]?.scrollIntoView({block:"nearest"})}acceptCommand(e){e&&(this.input.value=`/${e.name} `,this.autosize(),this.persistDraft(),this.refreshMenu(),this.input.focus())}renderPending(){this.renderFeed()}toggleMic(){if(this.recording){this.dictation.stop();return}const e=this.input.value;let t="";const s=i=>{this.input.value=Rt(e,t,i),this.autosize()};this.recording=!0,this.micBtn.classList.add("active"),this.dictation.start({onPartial:i=>s(i),onCommit:i=>{t=Rt(t,i),s(""),this.persistDraft()},onError:i=>this.onEvent(this.activeKey,{type:"error",message:`Dictation: ${i}`}),onEnd:()=>{this.recording=!1,this.micBtn.classList.remove("active")}})}autosize(){this.input.style.height="auto",this.input.style.height=Math.min(120,this.input.scrollHeight)+"px",this.renderBackdrop()}setConnState(e){const t=e==="open"&&this.connState!=="open";this.connState=e,this.dot.className=`op-dot ${e}`,this.dot.title=e==="open"?"Connected":e==="connecting"?"Connecting…":"Disconnected — reconnecting",this.events.length||this.renderFeed(),t&&(this.recording&&this.dictation.abort(),this.loadComposer())}computePulse(){return xs({events:pe(this.events,this.hidden),resolved:this.resolved,status:this.stateByKey.get(this.activeKey)??"idle"})??"idle"}updateStatus(){const e=this.computePulse();this.runningEl.className=`op-running ${e}`,e==="thinking"?Ae(this.runningEl,'<span class="op-dots"><i></i><i></i><i></i></span>thinking…',"thinking…"):e==="input"?this.runningEl.textContent="waiting for your reply":this.runningEl.textContent="",e==="idle"?this.fabStatus.style.display="none":(this.fabStatus.style.display="block",this.fabStatus.className=`op-fab-status ${e}`)}updateBadge(){this.unread>0&&!this.isOpen?(this.fabBadge.textContent=this.unread>9?"9+":String(this.unread),this.fabBadge.style.display="flex"):this.fabBadge.style.display="none"}setOpen(e){this.isOpen=e,this.fab.setAttribute("aria-expanded",String(e)),fi(this.cfg.taskId,e),e?(this.unread=0,this.updateBadge(),this.loadComposer()):this.picker.isActive&&(this.picker.stop(),this.refreshPickBtn()),this.applyOpen()}applyOpen(){this.panel.classList.toggle("open",this.isOpen),this.isOpen?(this.renderToggles(),this.positionPanel(),this.feed.scrollTop=this.feed.scrollHeight,this.input.focus(),this.countTimer==null&&(this.countTimer=window.setInterval(()=>{this.renderToggles(),this.loadComposer(),this.fetchForks()},1500))):this.countTimer!=null&&(clearInterval(this.countTimer),this.countTimer=null)}applyPos(){this.fab.style.left=`${this.pos.x}px`,this.fab.style.top=`${this.pos.y}px`}positionPanel(){const t=window.innerWidth,s=window.innerHeight,i=this.pos.x+me/2,r=this.pos.y+me/2,o=this.panel.style;o.left=o.right=o.top=o.bottom=o.maxHeight="";const a=Math.min(this.size.w,t-12);this.flipRight=i+a<=t-6,this.flipUp=r>=160;const c=(this.flipUp?r:s-r)-6,p=Math.max(Ut,Math.min(this.size.h,c));o.width=`${a}px`,o.height=`${p}px`,this.flipRight?o.left=`${Math.max(6,i)}px`:o.right=`${Math.max(6,t-i)}px`,this.flipUp?o.bottom=`${Math.max(6,s-r)}px`:o.top=`${r}px`;const u=this.resizeHandle.style;u.top=this.flipUp?"0":"",u.bottom=this.flipUp?"":"0",u.right=this.flipRight?"0":"",u.left=this.flipRight?"":"0";const S=this.flipUp===this.flipRight;u.cursor=S?"nesw-resize":"nwse-resize";const E=S?45:135;u.background=`linear-gradient(${E}deg, transparent 0 50%, #5a5a66 50% 62%, transparent 62% 74%, #5a5a66 74% 86%, transparent 86%)`}makeResizable(e){let t=0,s=0,i=0,r=0;const o=c=>{const p=c.clientX-t,u=c.clientY-s;this.size={w:Math.max(ai,i+(this.flipRight?p:-p)),h:Math.max(Ut,r+(this.flipUp?-u:u))},this.positionPanel()},a=c=>{e.releasePointerCapture(c.pointerId),window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",a),vi(this.cfg.taskId,this.size)};e.addEventListener("pointerdown",c=>{c.button===0&&(c.preventDefault(),c.stopPropagation(),t=c.clientX,s=c.clientY,i=this.size.w,r=this.size.h,e.setPointerCapture(c.pointerId),window.addEventListener("pointermove",o),window.addEventListener("pointerup",a))})}makeDraggable(e,t){let s=0,i=0,r=0,o=0,a=!1;const c=u=>{const S=u.clientX-s,E=u.clientY-i;!a&&Math.hypot(S,E)<4||(a=!0,this.pos=Qe({x:r+S,y:o+E}),this.applyPos(),this.isOpen&&this.positionPanel())},p=u=>{e.releasePointerCapture(u.pointerId),window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",p),!a&&t?t():a&&xi(this.cfg.taskId,this.pos)};e.addEventListener("pointerdown",u=>{u.button===0&&(u.preventDefault(),a=!1,s=u.clientX,i=u.clientY,r=this.pos.x,o=this.pos.y,e.setPointerCapture(u.pointerId),window.addEventListener("pointermove",c),window.addEventListener("pointerup",p))})}renderBackdrop(){const e=this.input.value;this.backdrop.replaceChildren();const t=/^(\s*)(also)\b([\s\S]*)$/i.exec(e);if(t){const[,s,i,r]=t;this.backdrop.append(document.createTextNode(s));const o=d("span","op-kw");o.textContent=i,this.backdrop.append(o,document.createTextNode(r))}else this.backdrop.append(document.createTextNode(e));this.backdrop.scrollTop=this.input.scrollTop}async runDevtoolsCommand(e,t,s,i){let r;try{r={ok:!0,result:await Js(s,i??{})}}catch(o){r={ok:!1,error:String(o?.message??o)}}this.transport.send({kind:"devtools_result",taskId:e,commandId:t,...r})}dispose(){this.countTimer!=null&&clearInterval(this.countTimer),this.saveTimer!=null&&clearTimeout(this.saveTimer),this.syncTimer!=null&&clearTimeout(this.syncTimer),this.recording&&this.dictation.abort(),window.removeEventListener("keydown",this.onKeyMod),window.removeEventListener("keyup",this.onKeyMod),window.removeEventListener("keydown",this.onKeyEsc),window.removeEventListener("resize",this.onResize),document.removeEventListener("astro:after-swap",this.reattach),document.removeEventListener("astro:page-load",this.reattach),this.picker.stop(),this.transport.dispose(),this.inst.uninstall(),this.favicon.restore(),this.host.remove()}}function hi(n){try{const e=localStorage.getItem(qt(n));return e==null?null:e==="1"}catch{return null}}function fi(n,e){try{localStorage.setItem(qt(n),e?"1":"0")}catch{}}function Re(n){return Array.isArray(n)?n.filter(e=>typeof e=="string"):[]}function mi(n){try{return localStorage.getItem(Ye(n))??""}catch{return""}}function gi(n,e){try{e?localStorage.setItem(Ye(n),e):localStorage.removeItem(Ye(n))}catch{}}function yi(n){try{const e=JSON.parse(localStorage.getItem(Kt(n))??"null");return e&&typeof e.w=="number"&&typeof e.h=="number"?{w:e.w,h:e.h}:null}catch{return null}}function vi(n,e){try{localStorage.setItem(Kt(n),JSON.stringify(e))}catch{}}function Qe(n){const e=Math.max(6,window.innerWidth-me-6),t=Math.max(6,window.innerHeight-me-6);return{x:Math.min(Math.max(6,n.x),e),y:Math.min(Math.max(6,n.y),t)}}function bi(n){try{const e=localStorage.getItem(Zt(n));if(!e)return null;const t=JSON.parse(e);return typeof t?.x=="number"&&typeof t?.y=="number"?Qe(t):null}catch{return null}}function xi(n,e){try{localStorage.setItem(Zt(n),JSON.stringify(e))}catch{}}function ki(){try{const n=localStorage.getItem(Ft);return n==="cmd"||n==="cmd-shift"?n:"none"}catch{return"none"}}function wi(n){try{localStorage.setItem(Ft,n)}catch{}}let Xe=null;function Ht(n){const e=Xt(n);if(!e)return null;et();const t=()=>{Xe=new ui(e)};return document.body?t():window.addEventListener("DOMContentLoaded",t,{once:!0}),{dispose:et}}function et(){Xe?.dispose(),Xe=null}function _i(){const n=typeof window<"u"&&!!window.__OPERATOR_DEVTOOLS__,e=typeof document<"u"&&!!document.querySelector("script[data-operator-task]");(n||e)&&Ht()}return typeof window<"u"&&_i(),ge.destroy=et,ge.init=Ht,Object.defineProperty(ge,Symbol.toStringTag,{value:"Module"}),ge})({});
|