@sentry/junior-dashboard 0.241.0 → 0.242.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/dist/client.js CHANGED
@@ -67,7 +67,7 @@ ${l}
67
67
 
68
68
  Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let s=i[1];if(t===i[0]){o(i);continue}if(e.external){let c=e.external.registry.get(i[0])?.id;if(t!==i[0]&&c){o(i);continue}}if(e.metadataRegistry.get(i[0])?.id){o(i);continue}if(s.cycle){o(i);continue}if(s.count>1&&e.reused==="ref"){o(i);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function k7(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let a=[];for(let r of t){if(!r||typeof r!="object")return;k7(r);let n=Object.keys(r);if(n.length!==1||n[0]!=="type")return;let o=r.type;for(let i of Array.isArray(o)?o:[o]){if(typeof i!="string")return;a.includes(i)||a.push(i)}}delete e.anyOf,e.type=a.length===1?a[0]:a}var I7=new Set(["type","properties","required","additionalProperties"]),w7=["oneOf","anyOf"];function C7(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function vP(e){let t=[];for(let o of e){if(typeof o!="object"||o.type!=="object")return null;for(let i in o)if(!I7.has(i))return null;t.push(o)}let a={},r=new Set;for(let o of t){for(let i in o.properties){if(Object.prototype.hasOwnProperty.call(a,i))continue;let s=[];for(let c of t){let d=c.properties?.[i]??C7(c);d!=null&&(s.some(f=>JSON.stringify(f)===JSON.stringify(d))||s.push(d))}let l=s.length===1?s[0]:vP(s)??{allOf:s};Xa(a,i,l)}for(let i of o.required??[])r.add(i)}let n={type:"object",properties:a};if(r.size&&(n.required=[...r]),t.every(o=>o.additionalProperties===!1))n.additionalProperties=!1;else{let o=[];for(let i of t){let s=C7(i);s&&!o.some(l=>JSON.stringify(l)===JSON.stringify(s))&&o.push(s)}o.length===1?n.additionalProperties=o[0]:o.length>1&&(n.additionalProperties={allOf:o})}return n}function Cpe(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let n of I7)if(n in e)return;let a=t.filter(n=>w7.some(o=>Array.isArray(n[o]))),r=null;if(!a.length)r=vP(t);else{let n=a[0],o=w7.find(l=>Array.isArray(n[l]));if(Object.keys(n).length!==1)return;let i=t.filter(l=>l!==n),s=n[o].map(l=>vP([...i,l]));if(s.some(l=>!l))return;r={[o]:s}}r&&(delete e.allOf,qb(e,r))}function wd(e,t){let a=e.seen.get(t);if(!a)throw new Error("Unprocessed schema. This is a bug in Zod.");let r=s=>{let l=e.seen.get(s);if(l.ref===null)return;let c=l.def??l.schema,d={...c},f=l.ref;if(l.ref=null,f){r(f);let p=e.seen.get(f),h=p.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(h)):qb(c,h),qb(c,d),s._zod.parent===f)for(let x in c)x==="$ref"||x==="allOf"||x in d||delete c[x];if(h.$ref&&p.def)for(let x in c)x==="$ref"||x==="allOf"||x in p.def&&JSON.stringify(c[x])===JSON.stringify(p.def[x])&&delete c[x]}let m=s._zod.parent;if(m&&m!==f){r(m);let p=e.seen.get(m);if(p?.schema.$ref&&(c.$ref=p.schema.$ref,p.def))for(let h in c)h==="$ref"||h==="allOf"||h in p.def&&JSON.stringify(c[h])===JSON.stringify(p.def[h])&&delete c[h]}e.override({zodSchema:s,jsonSchema:c,path:l.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let s of[...e.seen.entries()].reverse())r(s[0]);if(e.target!=="openapi-3.0")for(let s of e.seen.entries())k7(s[1].def??s[1].schema);for(let s of e.deferred)s();if(e.intersections.length){let s=new Map;for(let l of e.seen.values())for(let c of[l.schema,l.def]){let d=c?.allOf;if(!Array.isArray(d))continue;let f=s.get(d);f?f.push(c):s.set(d,[c])}for(let l of e.intersections)for(let c of s.get(l)??[])Cpe(c)}}let n={};if(e.target==="draft-2020-12"?n.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?n.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?n.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");n.$id=e.external.uri(s)}qb(n,a.defId?a.schema:a.def??a.schema);let o=e.metadataRegistry.get(t)?.id;o!==void 0&&n.id===o&&delete n.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let s of e.seen.entries()){let l=s[1];l.def&&l.defId&&(l.def.id===l.defId&&delete l.def.id,Xa(i,l.defId,l.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?n.$defs=i:n.definitions=i);try{let s=JSON.parse(JSON.stringify(n));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:Hh(t,"input",e.processors),output:Hh(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function bo(e,t){let a=t??{seen:new Set};if(a.seen.has(e))return!1;a.seen.add(e);let r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return bo(r.element,a);if(r.type==="set")return bo(r.valueType,a);if(r.type==="lazy")return bo(r.getter(),a);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault"||r.type==="catch")return bo(r.innerType,a);if(r.type==="intersection")return bo(r.left,a)||bo(r.right,a);if(r.type==="record"||r.type==="map")return bo(r.keyType,a)||bo(r.valueType,a);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:bo(r.in,a)||bo(r.out,a);if(r.type==="object"){for(let n in r.shape)if(bo(r.shape[n],a))return!0;return!1}if(r.type==="union"){for(let n of r.options)if(bo(n,a))return!0;return!1}if(r.type==="tuple"){for(let n of r.items)if(bo(n,a))return!0;return!!(r.rest&&bo(r.rest,a))}return!1}var yP=(e,t={})=>a=>{let r=xd({...a,processors:t});return Xt(e,r),Sd(r,e),wd(r,e)},Hh=(e,t,a={})=>r=>{let{libraryOptions:n,target:o}=r??{},i=xd({...n??{},target:o,io:t,processors:a});return Xt(e,i),Sd(i,e),wd(i,e)};var kpe={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},SP=(e,t,a,r)=>{let n=a;n.type="string";let{minimum:o,maximum:i,format:s,patterns:l,contentEncoding:c,laxFormat:d}=e._zod.bag;if(typeof o=="number"&&(n.minLength=o),typeof i=="number"&&(n.maxLength=i),s&&(n.format=kpe[s]??s,n.format===""&&delete n.format,(s==="time"||d)&&delete n.format),c&&(n.contentEncoding=c),l&&l.size>0){let f=[...l];f.length===1?n.pattern=f[0].source:f.length>1&&(n.allOf=[...f.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},wP=(e,t,a,r)=>{let n=a,{minimum:o,maximum:i,format:s,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:d}=e._zod.bag;typeof s=="string"&&s.includes("int")?n.type="integer":n.type="number";let f=typeof d=="number"&&d>=(o??Number.NEGATIVE_INFINITY),m=typeof c=="number"&&c<=(i??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";f?p?(n.minimum=d,n.exclusiveMinimum=!0):n.exclusiveMinimum=d:typeof o=="number"&&(n.minimum=o),m?p?(n.maximum=c,n.exclusiveMaximum=!0):n.exclusiveMaximum=c:typeof i=="number"&&(n.maximum=i),typeof l=="number"&&(Number.isFinite(l)&&l!==0?n.multipleOf=Math.abs(l):Xn(e,t,n,r,`A multipleOf divisor of ${l} cannot be represented in JSON Schema`))},CP=(e,t,a,r)=>{a.type="boolean"},kP=(e,t,a,r)=>{Xn(e,t,a,r,"BigInt cannot be represented in JSON Schema")},IP=(e,t,a,r)=>{Xn(e,t,a,r,"Symbols cannot be represented in JSON Schema")},LP=(e,t,a,r)=>{t.target==="openapi-3.0"?(a.type="string",a.nullable=!0,a.enum=[null]):a.type="null"},TP=(e,t,a,r)=>{Xn(e,t,a,r,"Undefined cannot be represented in JSON Schema")},RP=(e,t,a,r)=>{Xn(e,t,a,r,"Void cannot be represented in JSON Schema")},_P=(e,t,a,r)=>{a.not={}},NP=(e,t,a,r)=>{},AP=(e,t,a,r)=>{},$P=(e,t,a,r)=>{Xn(e,t,a,r,"Date cannot be represented in JSON Schema")},PP=(e,t,a,r)=>{let n=e._zod.def,o=yb(n.entries);if(o.length===0){a.not={};return}o.every(i=>typeof i=="number")&&(a.type="number"),o.every(i=>typeof i=="string")&&(a.type="string"),a.enum=o},DP=(e,t,a,r)=>{let n=e._zod.def;if(n.values.length===0){a.not={};return}let o=[];for(let i of n.values)if(i===void 0){if(Xn(e,t,a,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(Xn(e,t,a,r,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(i))}else o.push(i);if(o.length!==0)if(o.length===1){let i=o[0];a.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?a.enum=[i]:a.const=i}else o.every(i=>typeof i=="number")&&(a.type="number"),o.every(i=>typeof i=="string")&&(a.type="string"),o.every(i=>typeof i=="boolean")&&(a.type="boolean"),o.every(i=>i===null)&&(a.type="null"),a.enum=o},EP=(e,t,a,r)=>{Xn(e,t,a,r,"NaN cannot be represented in JSON Schema")},MP=(e,t,a,r)=>{let n=a,o=e._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");n.type="string",n.pattern=o.source},OP=(e,t,a,r)=>{let n=a,o={type:"string",format:"binary",contentEncoding:"binary"},{minimum:i,maximum:s,mime:l}=e._zod.bag;i!==void 0&&(o.minLength=i),s!==void 0&&(o.maxLength=s),l?l.length===1?(o.contentMediaType=l[0],Object.assign(n,o)):(Object.assign(n,o),n.anyOf=l.map(c=>({contentMediaType:c}))):Object.assign(n,o)},zP=(e,t,a,r)=>{a.type="boolean"},UP=(e,t,a,r)=>{Xn(e,t,a,r,"Custom types cannot be represented in JSON Schema")},jP=(e,t,a,r)=>{Xn(e,t,a,r,"Function types cannot be represented in JSON Schema")},BP=(e,t,a,r)=>{Xn(e,t,a,r,"Transforms cannot be represented in JSON Schema")},FP=(e,t,a,r)=>{Xn(e,t,a,r,"Map cannot be represented in JSON Schema")},HP=(e,t,a,r)=>{Xn(e,t,a,r,"Set cannot be represented in JSON Schema")},VP=(e,t,a,r)=>{let n=a,o=e._zod.def,{minimum:i,maximum:s}=e._zod.bag;typeof i=="number"&&(n.minItems=i),typeof s=="number"&&(n.maxItems=s),n.type="array",n.items=Xt(o.element,t,{...r,path:[...r.path,"items"]})};function Zb(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?Zb(t.out):t.type==="catch"?Zb(t.innerType):e._zod.optin}var qP=(e,t,a,r)=>{let n=a,o=e._zod.def,i=o.shape;if(Object.getOwnPropertySymbols(i).length&&Xn(e,t,n,r,"Symbol keys cannot be represented in JSON Schema"))return;n.type="object",n.properties={};for(let d in i)Xa(n.properties,d,Xt(i[d],t,{...r,path:[...r.path,"properties",d]}));let l=new Set(Object.keys(i)),c=new Set([...l].filter(d=>{let f=o.shape[d];return t.io==="input"?Zb(f)===void 0:f._zod.optout===void 0}));c.size>0&&(n.required=Array.from(c)),o.catchall?._zod.def.type==="never"?n.additionalProperties=!1:o.catchall?o.catchall&&(n.additionalProperties=Xt(o.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(n.additionalProperties=!1)},hk=(e,t,a,r)=>{let n=e._zod.def,o=n.inclusive===!1,i=n.options.map((s,l)=>Xt(s,t,{...r,path:[...r.path,o?"oneOf":"anyOf",l]}));o?a.oneOf=i:a.anyOf=i},ZP=(e,t,a,r)=>{let n=e._zod.def,o=Xt(n.left,t,{...r,path:[...r.path,"allOf",0]}),i=Xt(n.right,t,{...r,path:[...r.path,"allOf",1]}),s=c=>"allOf"in c&&Object.keys(c).length===1,l=[...s(o)?o.allOf:[o],...s(i)?i.allOf:[i]];a.allOf=l,t.intersections.push(l)},GP=(e,t,a,r)=>{let n=a,o=e._zod.def;n.type="array";let i=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",l=o.items.map((g,x)=>Xt(g,t,{...r,path:[...r.path,i,x]})),c=o.rest?Xt(o.rest,t,{...r,path:[...r.path,s,...t.target==="openapi-3.0"?[o.items.length]:[]]}):null,d=o.items.length;for(;d>0;){let g=o.items[d-1];if(!(t.io==="input"?Zb(g)!==void 0:g._zod.optout==="optional"))break;d--}let f=o.items.length,m=!o.rest;t.target==="draft-2020-12"?(n.prefixItems=l,m?n.items=!1:c&&(n.items=c),d>0&&(n.minItems=d),m&&(n.maxItems=f)):t.target==="openapi-3.0"?(n.items={anyOf:l},c&&n.items.anyOf.push(c),d>0&&(n.minItems=d),m&&(n.maxItems=f)):(n.items=l,m?n.additionalItems=!1:c&&(n.additionalItems=c),d>0&&(n.minItems=d),m&&(n.maxItems=f));let{minimum:p,maximum:h}=e._zod.bag;typeof p=="number"&&(n.minItems=p),typeof h=="number"&&(n.maxItems=h)};function bP(e,t,a){if(t.$ref){if(a.has(t))return t;a.add(t);let h=e.get(t)?.def;if(!h)return t;let g=bP(e,h,a);return g===h?t:g}for(let h of["anyOf","oneOf"]){let g=t[h];if(!Array.isArray(g))continue;let x=g.map(y=>bP(e,y,a));x.some((y,v)=>y!==g[v])&&(t={...t,[h]:x})}let r=Array.isArray(t.type)?t.type:[t.type],n=!r.includes("string")&&r.some(h=>h==="number"||h==="integer"),o=t.enum??(t.const!==void 0?[t.const]:void 0);if(!n&&!o?.some(h=>typeof h=="number"))return t;let{minimum:i,maximum:s,exclusiveMinimum:l,exclusiveMaximum:c,multipleOf:d,format:f,id:m,...p}=t;return p.enum?p.enum=p.enum.map(h=>typeof h=="number"?String(h):h):typeof p.const=="number"&&(p.const=String(p.const)),n&&(p.type="string",o||(p.pattern=(r.includes("number")?vd:Rb).source)),p}var xP=new WeakMap;function Ipe(e){let t=new Map;for(let r of e.seen.values())r.def&&!t.has(r.schema)&&t.set(r.schema,r);let a=new Map;for(let r of xP.get(e)??[]){let n=e.seen.get(r),o=(n?.def??n?.schema)?.propertyNames;if(!o||o===!0||a.has(o))continue;let i=bP(t,o,new Set);i!==o&&a.set(o,i)}if(a.size)for(let r of e.seen.values())for(let n of[r.schema,r.def]){let o=n&&a.get(n.propertyNames);o&&(n.propertyNames=o)}}var KP=(e,t,a,r)=>{let n=a,o=e._zod.def;n.type="object";let i=o.keyType,l=i._zod.bag?.patterns;if(o.mode==="loose"&&l&&l.size>0){let f=Xt(o.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});n.patternProperties={};for(let m of l)Xa(n.patternProperties,m.source,f)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){n.propertyNames=Xt(o.keyType,t,{...r,path:[...r.path,"propertyNames"]});let f=xP.get(t);f||(f=[],xP.set(t,f),t.deferred.push(()=>Ipe(t))),f.push(e)}n.additionalProperties=Xt(o.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}let c=i._zod.values,d=t.io==="input"&&Zb(o.valueType)!==void 0;if(c&&!o.partial&&!d){let f=[...c].filter(m=>typeof m=="string"||typeof m=="number");f.length>0&&(n.required=f.map(String))}},WP=(e,t,a,r)=>{let n=e._zod.def,o=Xt(n.innerType,t,r),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=n.innerType,a.nullable=!0):a.anyOf=[o,{type:"null"}]},JP=(e,t,a,r)=>{let n=e._zod.def;Xt(n.innerType,t,r);let o=t.seen.get(e);o.ref=n.innerType},QP=Symbol();function L7(e,t,a,r,n){let o=!1,i=JSON.stringify(e,(s,l)=>typeof l!="bigint"?l:(o=!0,null));return o?(Xn(t,a,r,n,"BigInt defaults cannot be represented in JSON Schema"),QP):JSON.parse(i)}var XP=(e,t,a,r)=>{let n=e._zod.def;Xt(n.innerType,t,r);let o=t.seen.get(e);o.ref=n.innerType;let i=L7(n.defaultValue,e,t,a,r);i!==QP&&(a.default=i)},YP=(e,t,a,r)=>{let n=e._zod.def;Xt(n.innerType,t,r);let o=t.seen.get(e);if(o.ref=n.innerType,t.io!=="input")return;let i=L7(n.defaultValue,e,t,a,r);i!==QP&&(a._prefault=i)},eD=(e,t,a,r)=>{let n=e._zod.def;Xt(n.innerType,t,r);let o=t.seen.get(e);o.ref=n.innerType;let i;try{i=n.catchValue(void 0)}catch{Xn(e,t,a,r,"Dynamic catch values are not supported in JSON Schema");return}a.default=i},tD=(e,t,a,r)=>{let n=e._zod.def,o=n.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?o?n.out:n.in:n.out;Xt(i,t,r);let s=t.seen.get(e);s.ref=i},aD=(e,t,a,r)=>{let n=e._zod.def;Xt(n.innerType,t,r);let o=t.seen.get(e);o.ref=n.innerType,a.readOnly=!0},nD=(e,t,a,r)=>{let n=e._zod.def;Xt(n.innerType,t,r);let o=t.seen.get(e);o.ref=n.innerType},gk=(e,t,a,r)=>{let n=e._zod.def;Xt(n.innerType,t,r);let o=t.seen.get(e);o.ref=n.innerType},rD=(e,t,a,r)=>{let n=e._zod.innerType;Xt(n,t,r);let o=t.seen.get(e);o.ref=n},pk={string:SP,number:wP,boolean:CP,bigint:kP,symbol:IP,null:LP,undefined:TP,void:RP,never:_P,any:NP,unknown:AP,date:$P,enum:PP,literal:DP,nan:EP,template_literal:MP,file:OP,success:zP,custom:UP,function:jP,transform:BP,map:FP,set:HP,array:VP,object:qP,union:hk,intersection:ZP,tuple:GP,record:KP,nullable:WP,nonoptional:JP,default:XP,prefault:YP,catch:eD,pipe:tD,readonly:aD,promise:nD,optional:gk,lazy:rD};function vk(e,t){if("_idmap"in e){let r=e,n=xd({...t,processors:pk}),o={};for(let l of r._idmap.entries()){let[c,d]=l;Xt(d,n)}let i={},s={registry:r,uri:t?.uri,defs:o};n.external=s;for(let l of r._idmap.entries()){let[c,d]=l;Sd(n,d),Xa(i,c,wd(n,d))}if(Object.keys(o).length>0){let l=n.target==="draft-2020-12"?"$defs":"definitions";i.__shared={[l]:o}}return{schemas:i}}let a=xd({...t,processors:pk});return Xt(e,a),Sd(a,e),wd(a,e)}var yk=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let a=t?.target??"draft-2020-12";a==="draft-4"&&(a="draft-04"),a==="draft-7"&&(a="draft-07"),this.ctx=xd({processors:pk,target:a,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,a={path:[],schemaPath:[]}){return Xt(t,this.ctx,a)}emit(t,a){a&&(a.cycles&&(this.ctx.cycles=a.cycles),a.reused&&(this.ctx.reused=a.reused),a.external&&(this.ctx.external=a.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,Sd(this.ctx,t);let r=wd(this.ctx,t),{"~standard":n,...o}=r;return o}};var T7={};var Xh={};Sl(Xh,{ZodAny:()=>ID,ZodArray:()=>_D,ZodBase64:()=>Ok,ZodBase64URL:()=>zk,ZodBigInt:()=>Jh,ZodBigIntFormat:()=>Bk,ZodBoolean:()=>Wh,ZodCIDRv4:()=>Ek,ZodCIDRv6:()=>Mk,ZodCUID:()=>Rk,ZodCUID2:()=>_k,ZodCatch:()=>JD,ZodCodec:()=>ax,ZodCreditCard:()=>yD,ZodCustom:()=>nx,ZodCustomStringFormat:()=>Gh,ZodDate:()=>Jb,ZodDefault:()=>VD,ZodDiscriminatedUnion:()=>AD,ZodE164:()=>Uk,ZodEmail:()=>kk,ZodEmoji:()=>Lk,ZodEnum:()=>qh,ZodExactOptional:()=>qk,ZodFile:()=>jD,ZodFunction:()=>iE,ZodGUID:()=>Ik,ZodIPv4:()=>Pk,ZodIPv6:()=>Dk,ZodISODate:()=>kd,ZodISODateTime:()=>Cd,ZodISODuration:()=>Ld,ZodISOTime:()=>Id,ZodIntersection:()=>$D,ZodJWT:()=>jk,ZodKSUID:()=>$k,ZodLazy:()=>nE,ZodLiteral:()=>UD,ZodMAC:()=>vD,ZodMap:()=>OD,ZodNaN:()=>XD,ZodNanoID:()=>Tk,ZodNever:()=>TD,ZodNonOptional:()=>Zk,ZodNull:()=>CD,ZodNullable:()=>HD,ZodNumber:()=>Kh,ZodNumberFormat:()=>fm,ZodObject:()=>Xb,ZodOptional:()=>ex,ZodPipe:()=>tx,ZodPrefault:()=>ZD,ZodPreprocess:()=>YD,ZodPromise:()=>oE,ZodReadonly:()=>eE,ZodRecord:()=>Vh,ZodSet:()=>zD,ZodString:()=>Zh,ZodStringFormat:()=>ua,ZodSuccess:()=>WD,ZodSymbol:()=>SD,ZodTemplateLiteral:()=>aE,ZodTransform:()=>BD,ZodTuple:()=>DD,ZodType:()=>rt,ZodULID:()=>Nk,ZodURL:()=>Wb,ZodUUID:()=>Fl,ZodUndefined:()=>wD,ZodUnion:()=>Yb,ZodUnknown:()=>LD,ZodVoid:()=>RD,ZodXID:()=>Ak,ZodXor:()=>ND,_ZodString:()=>Ck,_default:()=>qD,_function:()=>O8,any:()=>p8,array:()=>Qb,base64:()=>J7,base64url:()=>Q7,bigint:()=>u8,boolean:()=>xD,catch:()=>QD,check:()=>z8,cidrv4:()=>K7,cidrv6:()=>W7,codec:()=>P8,creditCard:()=>Y7,cuid:()=>j7,cuid2:()=>B7,custom:()=>U8,date:()=>g8,describe:()=>j8,discriminatedUnion:()=>w8,e164:()=>X7,email:()=>N7,emoji:()=>z7,enum:()=>Hk,exactOptional:()=>FD,file:()=>_8,float32:()=>o8,float64:()=>i8,function:()=>O8,guid:()=>A7,hash:()=>r8,hex:()=>n8,hostname:()=>a8,httpUrl:()=>O7,instanceof:()=>F8,int:()=>Sk,int32:()=>s8,int64:()=>c8,intersection:()=>PD,invertCodec:()=>D8,ipv4:()=>q7,ipv6:()=>G7,json:()=>V8,jwt:()=>e8,keyof:()=>v8,ksuid:()=>V7,lazy:()=>rE,literal:()=>R8,looseObject:()=>x8,looseRecord:()=>k8,mac:()=>Z7,map:()=>I8,meta:()=>B8,nan:()=>$8,nanoid:()=>U7,nativeEnum:()=>T8,never:()=>Fk,nonoptional:()=>KD,null:()=>kD,nullable:()=>Kb,nullish:()=>N8,number:()=>bD,object:()=>y8,optional:()=>cm,partialRecord:()=>C8,pipe:()=>wk,prefault:()=>GD,preprocess:()=>q8,promise:()=>M8,readonly:()=>tE,record:()=>MD,refine:()=>sE,set:()=>L8,strictObject:()=>b8,string:()=>Gb,stringFormat:()=>t8,stringbool:()=>H8,success:()=>A8,superRefine:()=>lE,symbol:()=>f8,templateLiteral:()=>E8,transform:()=>Vk,tuple:()=>ED,uint32:()=>l8,uint64:()=>d8,ulid:()=>F7,undefined:()=>m8,union:()=>Qh,unknown:()=>um,url:()=>M7,uuid:()=>$7,uuidv4:()=>P7,uuidv6:()=>D7,uuidv7:()=>E7,void:()=>h8,xid:()=>H7,xor:()=>S8});var bk={};Sl(bk,{endsWith:()=>Eh,gt:()=>jl,gte:()=>Ri,includes:()=>Ph,length:()=>lm,lowercase:()=>Ah,lt:()=>Ul,lte:()=>Ti,maxLength:()=>sm,maxSize:()=>bd,mime:()=>Mh,minLength:()=>Wu,minSize:()=>Bl,multipleOf:()=>yd,negative:()=>uk,nonnegative:()=>dk,nonpositive:()=>ck,normalize:()=>Oh,overwrite:()=>Ws,positive:()=>lk,properties:()=>mk,property:()=>fk,regex:()=>Nh,size:()=>im,slugify:()=>Bh,startsWith:()=>Dh,toLowerCase:()=>Uh,toUpperCase:()=>jh,trim:()=>zh,uppercase:()=>$h});var R7=new WeakSet([Object.prototype,Error.prototype]);function xk(e,t,a){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let r=a(this);return Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0})}})}var _7=(e,t)=>{Ib.init(e,t),e.name="ZodError";let a=Object.getPrototypeOf(e);R7.has(a)||(R7.add(a),xk(a,"format",r=>n=>Tb(r,n)),xk(a,"flatten",r=>n=>Lb(r,n)),xk(a,"addIssue",r=>n=>{r.issues.push(n),r.message=JSON.stringify(r.issues,xh,2)}),xk(a,"addIssues",r=>n=>{r.issues.push(...n),r.message=JSON.stringify(r.issues,xh,2)}),Object.defineProperty(a,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Tpe=A("ZodError",_7),ei=A("ZodError",_7,void 0,{Parent:Error});var oD=Ch(ei),iD=kh(ei),sD=Ih(ei),lD=Lh(ei),uD=Yw(ei),cD=eC(ei),dD=tC(ei),fD=aC(ei),mD=nC(ei),pD=rC(ei),hD=oC(ei),gD=iC(ei);function _pe(){pr.localeError||vn(EC())}function dm(){pr.memoizer||vn({memoizer:Ob()})}var rt=A("ZodType",(e,t)=>(_pe(),Ke.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(q.mergeDefs(t,{checks:[...t.checks??[],...e.map(a=>typeof a=="function"?{_zod:{check:a,def:{check:"custom"},onattach:[]}}:a)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Qt(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(sE(e,t))},superRefine(e,t){return this.check(lE(e,t))},overwrite(e){return this.check(Ws(e))},optional(){return cm(this)},exactOptional(){return FD(this)},nullable(){return Kb(this)},nullish(){return cm(Kb(this))},nonoptional(e){return KD(this,e)},array(){return Qb(this)},or(e){return Qh([this,e])},and(e){return PD(this,e)},transform(e){return wk(this,Vk(e))},default(e){return qD(this,e)},prefault(e){return GD(this,e)},catch(e){return QD(this,e)},pipe(e){return wk(this,e)},readonly(){return tE(this)},describe(e){let t=this.clone();return _r.add(t,{description:e}),t},meta(...e){if(e.length===0)return _r.get(this);let t=this.clone();return _r.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return q.hide(this,"~standard",{...vC(this),jsonSchema:{input:Hh(this,"input"),output:Hh(this,"output")}})},set"~standard"(e){q.own(this,"~standard",e)},parse:function e(t,a){return oD(this,t,a,{callee:e})},parseAsync:async function e(t,a){return await iD(this,t,a,{callee:e})},safeParse(e,t){return sD(this,e,t)},async safeParseAsync(e,t){return lD(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){q.own(this,"spa",e)},encode:function e(t,a){return uD(this,t,a,{callee:e})},decode:function e(t,a){return cD(this,t,a,{callee:e})},encodeAsync:async function e(t,a){return await dD(this,t,a,{callee:e})},decodeAsync:async function e(t,a){return await fD(this,t,a,{callee:e})},safeEncode(e,t){return mD(this,e,t)},safeDecode(e,t){return pD(this,e,t)},async safeEncodeAsync(e,t){return hD(this,e,t)},async safeDecodeAsync(e,t){return gD(this,e,t)},toJSONSchema(e){return yP(this,{})(e)},get description(){return _r.get(this)?.description},get _def(){return this._zod.def}}),Ck=A("_ZodString",(e,t)=>{tm.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>SP(e,r,n,o);let a=e._zod.bag;e.format=a.format??null,e.minLength=a.minimum??null,e.maxLength=a.maximum??null},{regex(...e){return this.check(Nh(...e))},includes(...e){return this.check(Ph(...e))},startsWith(...e){return this.check(Dh(...e))},endsWith(...e){return this.check(Eh(...e))},min(...e){return this.check(Wu(...e))},max(...e){return this.check(sm(...e))},length(...e){return this.check(lm(...e))},nonempty(...e){return this.check(Wu(1,...e))},lowercase(e){return this.check(Ah(e))},uppercase(e){return this.check($h(e))},trim(){return this.check(zh())},normalize(...e){return this.check(Oh(...e))},toLowerCase(){return this.check(Uh())},toUpperCase(){return this.check(jh())},slugify(){return this.check(Bh())}}),Zh=A("ZodString",(e,t)=>{tm.init(e,t),Ck.init(e,t)},{email(e){return this.check(BC(kk,e))},url(e){return this.check(jb(Wb,e))},jwt(e){return this.check(sk(jk,e))},emoji(e){return this.check(GC(Lk,e))},guid(e){return this.check(FC(Ik,e))},uuid(e){return this.check(HC(Fl,e))},uuidv4(e){return this.check(VC(Fl,e))},uuidv6(e){return this.check(qC(Fl,e))},uuidv7(e){return this.check(ZC(Fl,e))},nanoid(e){return this.check(KC(Tk,e))},cuid(e){return this.check(WC(Rk,e))},cuid2(e){return this.check(JC(_k,e))},ulid(e){return this.check(QC(Nk,e))},base64(e){return this.check(rk(Ok,e))},base64url(e){return this.check(ok(zk,e))},xid(e){return this.check(XC(Ak,e))},ksuid(e){return this.check(YC($k,e))},ipv4(e){return this.check(ek(Pk,e))},ipv6(e){return this.check(tk(Dk,e))},cidrv4(e){return this.check(ak(Ek,e))},cidrv6(e){return this.check(nk(Mk,e))},e164(e){return this.check(ik(Uk,e))},datetime(e){return this.check(Bb(Cd,e))},date(e){return this.check(Fb(kd,e))},time(e){return this.check(Hb(Id,e))},duration(e){return this.check(Vb(Ld,e))}});function Gb(e){return E$(Zh,e)}var ua=A("ZodStringFormat",(e,t)=>{ta.init(e,t),Ck.init(e,t)}),Cd=A("ZodISODateTime",(e,t)=>{LA.init(e,t),ua.init(e,t)}),kd=A("ZodISODate",(e,t)=>{TA.init(e,t),ua.init(e,t)}),Id=A("ZodISOTime",(e,t)=>{RA.init(e,t),ua.init(e,t)}),Ld=A("ZodISODuration",(e,t)=>{_A.init(e,t),ua.init(e,t)}),kk=A("ZodEmail",(e,t)=>{hA.init(e,t),ua.init(e,t)});function N7(e){return BC(kk,e)}var Ik=A("ZodGUID",(e,t)=>{mA.init(e,t),ua.init(e,t)});function A7(e){return FC(Ik,e)}var Fl=A("ZodUUID",(e,t)=>{pA.init(e,t),ua.init(e,t)});function $7(e){return HC(Fl,e)}function P7(e){return VC(Fl,e)}function D7(e){return qC(Fl,e)}function E7(e){return ZC(Fl,e)}var Wb=A("ZodURL",(e,t)=>{yA.init(e,t),ua.init(e,t)});function M7(e){return jb(Wb,e)}function O7(e){return jb(Wb,{protocol:vo.httpProtocol,hostname:vo.domain,...q.normalizeParams(e)})}var Lk=A("ZodEmoji",(e,t)=>{bA.init(e,t),ua.init(e,t)});function z7(e){return GC(Lk,e)}var Tk=A("ZodNanoID",(e,t)=>{xA.init(e,t),ua.init(e,t)});function U7(e){return KC(Tk,e)}var Rk=A("ZodCUID",(e,t)=>{SA.init(e,t),ua.init(e,t)});function j7(e){return WC(Rk,e)}var _k=A("ZodCUID2",(e,t)=>{wA.init(e,t),ua.init(e,t)});function B7(e){return JC(_k,e)}var Nk=A("ZodULID",(e,t)=>{CA.init(e,t),ua.init(e,t)});function F7(e){return QC(Nk,e)}var Ak=A("ZodXID",(e,t)=>{kA.init(e,t),ua.init(e,t)});function H7(e){return XC(Ak,e)}var $k=A("ZodKSUID",(e,t)=>{IA.init(e,t),ua.init(e,t)});function V7(e){return YC($k,e)}var Pk=A("ZodIPv4",(e,t)=>{NA.init(e,t),ua.init(e,t)});function q7(e){return ek(Pk,e)}var vD=A("ZodMAC",(e,t)=>{$A.init(e,t),ua.init(e,t)});function Z7(e){return O$(vD,e)}var Dk=A("ZodIPv6",(e,t)=>{AA.init(e,t),ua.init(e,t)});function G7(e){return tk(Dk,e)}var Ek=A("ZodCIDRv4",(e,t)=>{PA.init(e,t),ua.init(e,t)});function K7(e){return ak(Ek,e)}var Mk=A("ZodCIDRv6",(e,t)=>{DA.init(e,t),ua.init(e,t)});function W7(e){return nk(Mk,e)}var Ok=A("ZodBase64",(e,t)=>{EA.init(e,t),ua.init(e,t)});function J7(e){return rk(Ok,e)}var zk=A("ZodBase64URL",(e,t)=>{MA.init(e,t),ua.init(e,t)});function Q7(e){return ok(zk,e)}var Uk=A("ZodE164",(e,t)=>{OA.init(e,t),ua.init(e,t)});function X7(e){return ik(Uk,e)}var yD=A("ZodCreditCard",(e,t)=>{zA.init(e,t),ua.init(e,t)});function Y7(e){return z$(yD,e)}var jk=A("ZodJWT",(e,t)=>{UA.init(e,t),ua.init(e,t)});function e8(e){return sk(jk,e)}var Gh=A("ZodCustomStringFormat",(e,t)=>{jA.init(e,t),ua.init(e,t)});function t8(e,t,a={}){return Fh(Gh,e,t,a)}function a8(e){return Fh(Gh,"hostname",vo.hostname,e)}function n8(e){return Fh(Gh,"hex",vo.hex,e)}function r8(e,t){let a=t?.enc??"hex",r=`${e}_${a}`,n=vo[r];if(!n)throw new Error(`Unrecognized hash format: ${r}`);return Fh(Gh,r,n,t)}var Kh=A("ZodNumber",(e,t)=>{LC.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>wP(e,r,n,o);let a=e._zod.bag;e.minValue=Math.max(a.minimum??Number.NEGATIVE_INFINITY,a.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(a.maximum??Number.POSITIVE_INFINITY,a.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(a.format??"").includes("int")||Number.isSafeInteger(a.multipleOf??.5),e.isFinite=!0,e.format=a.format??null},{gt(e,t){return this.check(jl(e,t))},gte(e,t){return this.check(Ri(e,t))},min(e,t){return this.check(Ri(e,t))},lt(e,t){return this.check(Ul(e,t))},lte(e,t){return this.check(Ti(e,t))},max(e,t){return this.check(Ti(e,t))},int(e){return this.check(Sk(e))},safe(e){return this.check(Sk(e))},positive(e){return this.check(jl(0,e))},nonnegative(e){return this.check(Ri(0,e))},negative(e){return this.check(Ul(0,e))},nonpositive(e){return this.check(Ti(0,e))},multipleOf(e,t){return this.check(yd(e,t))},step(e,t){return this.check(yd(e,t))},finite(){return this}});function bD(e){return j$(Kh,e)}var fm=A("ZodNumberFormat",(e,t)=>{BA.init(e,t),Kh.init(e,t)});function Sk(e){return F$(fm,e)}function o8(e){return H$(fm,e)}function i8(e){return V$(fm,e)}function s8(e){return q$(fm,e)}function l8(e){return Z$(fm,e)}var Wh=A("ZodBoolean",(e,t)=>{Pb.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>CP(e,a,r,n)});function xD(e){return G$(Wh,e)}var Jh=A("ZodBigInt",(e,t)=>{TC.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>kP(e,r,n,o);let a=e._zod.bag;e.minValue=a.minimum??null,e.maxValue=a.maximum??null,e.format=a.format??null},{gte(e,t){return this.check(Ri(e,t))},min(e,t){return this.check(Ri(e,t))},gt(e,t){return this.check(jl(e,t))},lt(e,t){return this.check(Ul(e,t))},lte(e,t){return this.check(Ti(e,t))},max(e,t){return this.check(Ti(e,t))},positive(e){return this.check(jl(BigInt(0),e))},negative(e){return this.check(Ul(BigInt(0),e))},nonpositive(e){return this.check(Ti(BigInt(0),e))},nonnegative(e){return this.check(Ri(BigInt(0),e))},multipleOf(e,t){return this.check(yd(e,t))}});function u8(e){return W$(Jh,e)}var Bk=A("ZodBigIntFormat",(e,t)=>{FA.init(e,t),Jh.init(e,t)});function c8(e){return Q$(Bk,e)}function d8(e){return X$(Bk,e)}var SD=A("ZodSymbol",(e,t)=>{HA.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>IP(e,a,r,n)});function f8(e){return Y$(SD,e)}var wD=A("ZodUndefined",(e,t)=>{VA.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>TP(e,a,r,n)});function m8(e){return eP(wD,e)}var CD=A("ZodNull",(e,t)=>{qA.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>LP(e,a,r,n)});function kD(e){return tP(CD,e)}var ID=A("ZodAny",(e,t)=>{ZA.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>NP(e,a,r,n)});function p8(){return aP(ID)}var LD=A("ZodUnknown",(e,t)=>{GA.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>AP(e,a,r,n)});function um(){return nP(LD)}var TD=A("ZodNever",(e,t)=>{KA.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>_P(e,a,r,n)});function Fk(e){return rP(TD,e)}var RD=A("ZodVoid",(e,t)=>{WA.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>RP(e,a,r,n)});function h8(e){return oP(RD,e)}var Jb=A("ZodDate",(e,t)=>{JA.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>$P(e,r,n,o),e.min=(r,n)=>e.check(Ri(r,n)),e.max=(r,n)=>e.check(Ti(r,n));let a=e._zod.bag;e.minDate=a.minimum?new Date(a.minimum):null,e.maxDate=a.maximum?new Date(a.maximum):null});function g8(e){return iP(Jb,e)}var _D=A("ZodArray",(e,t)=>{dm(),QA.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>VP(e,a,r,n),e.element=t.element},{min(e,t){return this.check(Wu(e,t))},nonempty(e){return this.check(Wu(1,e))},max(e,t){return this.check(sm(e,t))},length(e,t){return this.check(lm(e,t))},unwrap(){return this.element}});function Qb(e,t){return uP(_D,e,t)}function v8(e){let t=e._zod.def.shape;return Hk(Object.keys(t))}var Xb=A("ZodObject",(e,t)=>{dm(),XA.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>qP(e,a,r,n),q.installLazyProp(e,"shape",a=>a._zod.def.shape,!1)},{keyof(){return Hk(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:um()})},loose(){return this.clone({...this._zod.def,catchall:um()})},strict(){return this.clone({...this._zod.def,catchall:Fk()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return q.extend(this,e)},safeExtend(e){return q.safeExtend(this,e)},merge(e){return q.merge(this,e)},pick(e){return q.pick(this,e)},omit(e){return q.omit(this,e)},partial(...e){return q.partial(ex,this,e[0])},exactPartial(...e){return q.partial(qk,this,e[0],"exactPartial")},required(...e){return q.required(Zk,this,e[0])}});function y8(e,t){let a={type:"object",shape:e??{},...q.normalizeParams(t)};return new Xb(a)}function b8(e,t){return new Xb({type:"object",shape:e,catchall:Fk(),...q.normalizeParams(t)})}function x8(e,t){return new Xb({type:"object",shape:e,catchall:um(),...q.normalizeParams(t)})}var Yb=A("ZodUnion",(e,t)=>{Db.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>hk(e,a,r,n),e.options=t.options});function Qh(e,t){return new Yb({type:"union",options:e,...q.normalizeParams(t)})}var ND=A("ZodXor",(e,t)=>{Yb.init(e,t),YA.init(e,t),e._zod.processJSONSchema=(a,r,n)=>hk(e,a,r,n),e.options=t.options});function S8(e,t){return new ND({type:"union",options:e,inclusive:!1,...q.normalizeParams(t)})}var AD=A("ZodDiscriminatedUnion",(e,t)=>{Yb.init(e,t),t$.init(e,t)});function w8(e,t,a){return new AD({type:"union",options:t,discriminator:e,...q.normalizeParams(a)})}var $D=A("ZodIntersection",(e,t)=>{a$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>ZP(e,a,r,n)});function PD(e,t){return new $D({type:"intersection",left:e,right:t})}var DD=A("ZodTuple",(e,t)=>{dm(),RC.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>GP(e,a,r,n)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(t=>new ex({type:"optional",innerType:t}))})}});function ED(e,t,a){let r=t instanceof Ke,n=r?a:t,o=r?t:null;return new DD({type:"tuple",items:e,rest:o,...q.normalizeParams(n)})}var Vh=A("ZodRecord",(e,t)=>{dm(),n$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>KP(e,a,r,n),e.keyType=t.keyType,e.valueType=t.valueType});function MD(e,t,a){return!t||!t._zod?new Vh({type:"record",keyType:Gb(),valueType:e,...q.normalizeParams(t)}):new Vh({type:"record",keyType:e,valueType:t,...q.normalizeParams(a)})}function C8(e,t,a){return new Vh({type:"record",keyType:e,valueType:t,...q.normalizeParams(a),partial:!0})}function k8(e,t,a){return new Vh({type:"record",keyType:e,valueType:t,mode:"loose",...q.normalizeParams(a)})}var OD=A("ZodMap",(e,t)=>{dm(),r$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>FP(e,a,r,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...a)=>e.check(Bl(...a)),e.nonempty=a=>e.check(Bl(1,a)),e.max=(...a)=>e.check(bd(...a)),e.size=(...a)=>e.check(im(...a))});function I8(e,t,a){return new OD({type:"map",keyType:e,valueType:t,...q.normalizeParams(a)})}var zD=A("ZodSet",(e,t)=>{dm(),o$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>HP(e,a,r,n),e.min=(...a)=>e.check(Bl(...a)),e.nonempty=a=>e.check(Bl(1,a)),e.max=(...a)=>e.check(bd(...a)),e.size=(...a)=>e.check(im(...a))});function L8(e,t){return new zD({type:"set",valueType:e,...q.normalizeParams(t)})}var qh=A("ZodEnum",(e,t)=>{i$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>PP(e,r,n,o),e.enum=t.entries,e.options=Object.values(t.entries);let a=new Set(Object.keys(t.entries));e.extract=(r,n)=>{let o={};for(let i of r)if(a.has(i))o[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new qh({...t,checks:[],...q.normalizeParams(n),entries:o})},e.exclude=(r,n)=>{let o={...t.entries};for(let i of r)if(a.has(i))delete o[i];else throw new Error(`Key ${i} not found in enum`);return new qh({...t,checks:[],...q.normalizeParams(n),entries:o})}});function Hk(e,t){let a=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new qh({type:"enum",entries:a,...q.normalizeParams(t)})}function T8(e,t){return new qh({type:"enum",entries:e,...q.normalizeParams(t)})}var UD=A("ZodLiteral",(e,t)=>{s$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>DP(e,a,r,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function R8(e,t){return new UD({type:"literal",values:Array.isArray(e)?e:[e],...q.normalizeParams(t)})}var jD=A("ZodFile",(e,t)=>{l$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>OP(e,a,r,n),e.min=(a,r)=>e.check(Bl(a,r)),e.max=(a,r)=>e.check(bd(a,r)),e.mime=(a,r)=>e.check(Mh(Array.isArray(a)?a:[a],r))});function _8(e){return cP(jD,e)}var BD=A("ZodTransform",(e,t)=>{dm(),u$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>BP(e,a,r,n),e._zod.parse=(a,r)=>{if(r.direction==="backward")throw new gd(e.constructor.name);a.addIssue=o=>{if(typeof o=="string")a.issues.push(q.issue(o,a.value,t));else{let i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=a.value),i.inst??(i.inst=e),a.issues.push(q.issue(i))}};let n=t.transform(a.value,a);return n instanceof Promise?n.then(o=>(a.value=o,a)):(a.value=n,a)}});function Vk(e){return new BD({type:"transform",transform:e})}var ex=A("ZodOptional",(e,t)=>{_C.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>gk(e,a,r,n),e.unwrap=()=>e._zod.def.innerType});function cm(e){return new ex({type:"optional",innerType:e})}var qk=A("ZodExactOptional",(e,t)=>{c$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>gk(e,a,r,n),e.unwrap=()=>e._zod.def.innerType});function FD(e){return new qk({type:"optional",innerType:e})}var HD=A("ZodNullable",(e,t)=>{d$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>WP(e,a,r,n),e.unwrap=()=>e._zod.def.innerType});function Kb(e){return new HD({type:"nullable",innerType:e})}function N8(e){return cm(Kb(e))}var VD=A("ZodDefault",(e,t)=>{f$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>XP(e,a,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function qD(e,t){return new VD({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():q.shallowClone(t)}})}var ZD=A("ZodPrefault",(e,t)=>{m$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>YP(e,a,r,n),e.unwrap=()=>e._zod.def.innerType});function GD(e,t){return new ZD({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():q.shallowClone(t)}})}var Zk=A("ZodNonOptional",(e,t)=>{p$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>JP(e,a,r,n),e.unwrap=()=>e._zod.def.innerType});function KD(e,t){return new Zk({type:"nonoptional",innerType:e,...q.normalizeParams(t)})}var WD=A("ZodSuccess",(e,t)=>{h$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>zP(e,a,r,n),e.unwrap=()=>e._zod.def.innerType});function A8(e){return new WD({type:"success",innerType:e})}var JD=A("ZodCatch",(e,t)=>{g$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>eD(e,a,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function QD(e,t){return new JD({type:"catch",innerType:e,catchValue:typeof t=="function"?t:q.constantCatch(t)})}var XD=A("ZodNaN",(e,t)=>{v$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>EP(e,a,r,n)});function $8(e){return lP(XD,e)}var tx=A("ZodPipe",(e,t)=>{NC.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>tD(e,a,r,n),e.in=t.in,e.out=t.out});function wk(e,t){return new tx({type:"pipe",in:e,out:t})}var ax=A("ZodCodec",(e,t)=>{tx.init(e,t),Eb.init(e,t)});function P8(e,t,a){return new ax({type:"pipe",in:e,out:t,transform:a.decode,reverseTransform:a.encode})}function D8(e){let t=e._zod.def;return new ax({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var YD=A("ZodPreprocess",(e,t)=>{tx.init(e,t),y$.init(e,t)}),eE=A("ZodReadonly",(e,t)=>{b$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>aD(e,a,r,n),e.unwrap=()=>e._zod.def.innerType});function tE(e){return new eE({type:"readonly",innerType:e})}var aE=A("ZodTemplateLiteral",(e,t)=>{x$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>MP(e,a,r,n)});function E8(e,t){return new aE({type:"template_literal",parts:e,...q.normalizeParams(t)})}var nE=A("ZodLazy",(e,t)=>{Mb.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>rD(e,a,r,n),e.unwrap=()=>e._zod.def.getter()});function rE(e){return new nE({type:"lazy",getter:e})}var oE=A("ZodPromise",(e,t)=>{w$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>nD(e,a,r,n),e.unwrap=()=>e._zod.def.innerType});function M8(e){return new oE({type:"promise",innerType:e})}var iE=A("ZodFunction",(e,t)=>{S$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>jP(e,a,r,n)});function O8(e){return new iE({type:"function",input:Array.isArray(e?.input)?ED(e?.input):e?.input??Qb(um()),output:e?.output??um()})}var nx=A("ZodCustom",(e,t)=>{C$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>UP(e,a,r,n)});function z8(e){let t=new ya({check:"custom"});return t._zod.check=e,t}function U8(e,t){return dP(nx,e??(()=>!0),t)}function sE(e,t={}){return fP(nx,e,t)}function lE(e,t){return mP(e,t)}var j8=pP,B8=hP;function F8(e,t={}){let a=new nx({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...q.normalizeParams(t)});return a._zod.bag.Class=e,a._zod.check=r=>{r.value instanceof e||r.issues.push({code:"invalid_type",expected:e.name,input:r.value,inst:a,path:[...a._zod.def.path??[]]})},a}var H8=(...e)=>gP({Codec:ax,Boolean:Wh,String:Zh},...e);function V8(e){let t=rE(()=>Qh([Gb(e),bD(),xD(),kD(),Qb(t),MD(Gb(),t)]));return t}function q8(e,t){return new YD({type:"pipe",in:Vk(e),out:t})}var Npe={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function Ape(e){vn({customError:e})}function $pe(){return vn().customError}var uE;uE||(uE={});var rx={};Sl(rx,{ZodISODate:()=>kd,ZodISODateTime:()=>Cd,ZodISODuration:()=>Ld,ZodISOTime:()=>Id,date:()=>Dpe,datetime:()=>Ppe,duration:()=>Mpe,time:()=>Epe});function Ppe(e){return Bb(Cd,e)}function Dpe(e){return Fb(kd,e)}function Epe(e){return Hb(Id,e)}function Mpe(e){return Vb(Ld,e)}var le={...Xh,...bk,iso:rx},Ope=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function zpe(e,t){let a=e.$schema;return a==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":a==="http://json-schema.org/draft-07/schema#"?"draft-7":a==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function Z8(e,t){return e.map((a,r)=>r<t?a:a.optional())}function Upe(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function jpe(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let a=e.slice(1).split("/").filter(Boolean);if(a.length===0)return t.rootSchema;let r=t.version==="draft-2020-12"?"$defs":"definitions";if(a[0]===r){let n=a[1]===void 0?void 0:Upe(a[1]);if(!n||!t.defs[n])throw new Error(`Reference not found: ${e}`);return t.defs[n]}throw new Error(`Reference not found: ${e}`)}function Bpe(e,t){return le.transform(r=>r).check(r=>{let n=r.value;if(!(typeof n!="object"||n===null||Array.isArray(n)))for(let o of Object.getOwnPropertyNames(n)){let i=t.safeParse(o);i.success||r.issues.push({code:"invalid_key",origin:"record",issues:i.error.issues,input:o,path:[o],continue:!0})}}).pipe(e)}function G8(e,t){if(e!==!1)return e===void 0||e===!0?le.any():ti(e,t)}var Fpe=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function K8(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return le.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return le.lazy(()=>{if(!t.refs.has(n))throw new Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let o=jpe(n,t),i=ti(o,t);return t.refs.set(n,i),t.processing.delete(n),i}if(e.enum!==void 0){let n=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&n.length===1&&n[0]===null)return le.null();if(n.length===0)return le.never();if(n.length===1)return le.literal(n[0]);if(n.every(i=>typeof i=="string"))return le.enum(n);let o=n.map(i=>le.literal(i));return o.length<2?o[0]:le.union([o[0],o[1],...o.slice(2)])}if(e.const!==void 0)return le.literal(e.const);let a=e.type;if(Array.isArray(a)){let n=a.map(o=>{let i={...e,type:o};return K8(i,t)});return n.length===0?le.never():n.length===1?n[0]:le.union(n)}if(!a)return le.any();let r;switch(a){case"string":{let n=le.string();if(e.format){let o=e.format;o==="email"?n=n.check(le.email()):o==="uri"||o==="uri-reference"?n=n.check(le.url()):o==="uuid"||o==="guid"?n=n.check(le.uuid()):o==="date-time"?n=n.check(le.iso.datetime({offset:!0})):o==="date"?n=n.check(le.iso.date()):o==="time"?n=n.check(le.regex(Fpe)):o==="duration"?n=n.check(le.iso.duration()):o==="hostname"?n=n.check(le.hostname()):o==="ipv4"?n=n.check(le.ipv4()):o==="ipv6"?n=n.check(le.ipv6()):o==="mac"?n=n.check(le.mac()):o==="cidr"?n=n.check(le.cidrv4()):o==="cidr-v6"?n=n.check(le.cidrv6()):o==="base64"?n=n.check(le.base64()):o==="base64url"?n=n.check(le.base64url()):o==="e164"?n=n.check(le.e164()):o==="credit_card"?n=n.check(le.creditCard()):o==="jwt"?n=n.check(le.jwt()):o==="emoji"?n=n.check(le.emoji()):o==="nanoid"?n=n.check(le.nanoid()):o==="cuid"?n=n.check(le.cuid()):o==="cuid2"?n=n.check(le.cuid2()):o==="ulid"?n=n.check(le.ulid()):o==="xid"?n=n.check(le.xid()):o==="ksuid"&&(n=n.check(le.ksuid()))}typeof e.minLength=="number"&&(n=n.min(e.minLength)),typeof e.maxLength=="number"&&(n=n.max(e.maxLength)),e.pattern&&(n=n.regex(new RegExp(e.pattern))),r=n;break}case"number":case"integer":{let n=a==="integer"?le.number().int():le.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(n=n.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(n=n.max(e.maximum)),typeof e.exclusiveMinimum=="number"?n=n.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(n=n.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?n=n.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(n=n.lt(e.maximum)),typeof e.multipleOf=="number"&&(n=n.multipleOf(e.multipleOf)),r=n;break}case"boolean":{r=le.boolean();break}case"null":{r=le.null();break}case"object":{let n={},o=e.properties||{},i=new Set(e.required||[]),s=typeof e.additionalProperties=="object"?ti(e.additionalProperties,t):void 0;for(let[l,c]of Object.entries(o)){let d=ti(c,t);Xa(n,l,i.has(l)?d:d.optional())}if(e.patternProperties){let l=e.patternProperties,c=Object.keys(l),d=[];for(let m of c){let p=ti(l[m],t),h=le.string().regex(new RegExp(m));d.push(le.looseRecord(h,p))}let f=[];if(Object.keys(n).length>0&&f.push(le.object(n).passthrough()),f.push(...d),f.length===0)r=le.object({}).passthrough();else if(f.length===1)r=f[0];else{let m=le.intersection(f[0],f[1]);for(let p=2;p<f.length;p++)m=le.intersection(m,f[p]);r=m}if(e.additionalProperties===!1){let m=Object.keys(n),p=c.map(g=>new RegExp(g)),h=r;r=r.check(g=>{if(!us(g.value))return;let x=[];for(let y of Object.keys(g.value))m.includes(y)||p.some(v=>v.test(y))||x.push(y);x.length&&g.issues.push({code:"unrecognized_keys",keys:x,input:g.value,inst:h})})}}else{let l=le.object(n);e.additionalProperties===!1?r=l.strict():s?r=l.catchall(s):r=l.passthrough()}if(e.propertyNames!==void 0&&e.propertyNames!==!0){let l=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;r=Bpe(r,ti(l,t))}break}case"array":{let n=e.prefixItems,o=e.items;if(n&&Array.isArray(n)){let i=typeof e.minItems=="number"?e.minItems:0,s=n.map(f=>ti(f,t)),l=Z8(s,i),c=Array.isArray(o)?void 0:G8(o,t),d=le.tuple(l);r=c?d.rest(c):d,typeof e.minItems=="number"&&(r=r.check(le.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(le.maxLength(e.maxItems)))}else if(Array.isArray(o)){let i=typeof e.minItems=="number"?e.minItems:0,s=o.map(f=>ti(f,t)),l=Z8(s,i),c=G8(e.additionalItems,t),d=le.tuple(l);r=c?d.rest(c):d,typeof e.minItems=="number"&&(r=r.check(le.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(le.maxLength(e.maxItems)))}else if(o!==void 0){let i=ti(o,t),s=le.array(i);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),r=s}else r=le.array(le.any());break}default:throw new Error(`Unsupported type: ${a}`)}return r}function ti(e,t){if(typeof e=="boolean")return e?le.any():le.never();let a=K8(e,t),r=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let s=e.anyOf.map(c=>ti(c,t)),l=le.union(s);a=r?le.intersection(a,l):l}if(e.oneOf&&Array.isArray(e.oneOf)){let s=e.oneOf.map(c=>ti(c,t)),l=le.xor(s);a=r?le.intersection(a,l):l}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)a=r?a:le.any();else{let s=r?a:ti(e.allOf[0],t),l=r?0:1;for(let c=l;c<e.allOf.length;c++)s=le.intersection(s,ti(e.allOf[c],t));a=s}e.nullable===!0&&t.version==="openapi-3.0"&&(a=le.nullable(a)),e.readOnly===!0&&(a=le.readonly(a)),e.default!==void 0&&(a=a.default(e.default));let n={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of o)s in e&&(n[s]=e[s]);let i=["contentEncoding","contentMediaType","contentSchema"];for(let s of i)s in e&&(n[s]=e[s]);e.propertyNames!==void 0&&e.type==="object"&&e.$ref===void 0&&(n.propertyNames=e.propertyNames);for(let s of Object.keys(e))Ope.has(s)||Xa(n,s,e[s]);return Object.keys(n).length>0&&t.registry.add(a,n),e.description&&(a=a.describe(e.description)),a}function W8(e,t){if(typeof e=="boolean")return e?le.any():le.never();let a;try{a=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let r=zpe(a,t?.defaultTarget),n=a.$defs||a.definitions||{},o={version:r,defs:n,refs:new Map,processing:new Set,rootSchema:a,registry:t?.registry??_r};return ti(a,o)}var J8=Symbol("z.visit/resolving");function ox(e,t){let a=typeof t=="function"?t:(i,s)=>{let l=t[i._zod.def.type];return l?l(i,s):i},r=new Map;function n(i){let s=r.get(i);if(s===J8)return new Mb({type:"lazy",getter:()=>r.get(i)});if(s!==void 0)return s;r.set(i,J8);let l=o(i),c=a(l,l!==i);return r.set(i,c),c}function o(i){let s=i._zod.def,l=s.type;switch(l){case"object":{let c=s.shape,d=Object.keys(c),f=!1,m={};for(let h of d){let g=n(c[h]);g!==c[h]&&(f=!0),m[h]=g}let p=s.catchall;return s.catchall&&(p=n(s.catchall),p!==s.catchall&&(f=!0)),f?Qt(i,{...s,shape:m,catchall:p}):i}case"array":{let c=n(s.element);return c===s.element?i:Qt(i,{...s,element:c})}case"tuple":{let c=s.items,d=!1,f=[];for(let p of c){let h=n(p);h!==p&&(d=!0),f.push(h)}let m=s.rest;return s.rest&&(m=n(s.rest),m!==s.rest&&(d=!0)),d?Qt(i,{...s,items:f,rest:m}):i}case"record":case"map":{let c=n(s.keyType),d=n(s.valueType);return c===s.keyType&&d===s.valueType?i:Qt(i,{...s,keyType:c,valueType:d})}case"set":{let c=n(s.valueType);return c===s.valueType?i:Qt(i,{...s,valueType:c})}case"union":{let c=s.options,d=!1,f=[];for(let m of c){let p=n(m);p!==m&&(d=!0),f.push(p)}return d?Qt(i,{...s,options:f}):i}case"intersection":{let c=n(s.left),d=n(s.right);return c===s.left&&d===s.right?i:Qt(i,{...s,left:c,right:d})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let c=n(s.innerType);return c===s.innerType?i:Qt(i,{...s,innerType:c})}case"pipe":{let c=n(s.in),d=n(s.out);return c===s.in&&d===s.out?i:Qt(i,{...s,in:c,out:d})}case"function":{let c=n(s.input),d=n(s.output);return c===s.input&&d===s.output?i:Qt(i,{...s,input:c,output:d})}case"lazy":{let c=s.getter,{_cachedInner:d,...f}=s;return Qt(i,{...f,getter:()=>n(c())})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return i;default:return i}}return n(e)}function Q8(e){return ox(e,{object:t=>t.partial(),union:t=>{let a=t._zod.def;return a.discriminator===void 0?t:Qh(a.options)}})}function Hpe(e,t){if(!t?.length)return e;let a=e._zod.def;return Qt(e,Gs(a,{checks:[...a.checks??[],...t]}),{parent:!0})}function X8(e){return Hpe(e.out,e.checks)}function Vpe(e){return e.in._zod.traits.has("$ZodTransform")?X8(e):e.in}function Y8(e){return ox(e,{pipe:t=>Vpe(t._zod.def),default:(t,a)=>a?cm(t._zod.def.innerType):t,catch:(t,a)=>a?t._zod.def.innerType:t})}function e9(e){return ox(e,{pipe:t=>X8(t._zod.def),prefault:(t,a)=>a?t._zod.def.innerType:t})}var cE={};Sl(cE,{bigint:()=>Kpe,boolean:()=>Gpe,date:()=>Wpe,number:()=>Zpe,string:()=>qpe});function qpe(e){return M$(Zh,e)}function Zpe(e){return B$(Kh,e)}function Gpe(e){return K$(Wh,e)}function Kpe(e){return J$(Jh,e)}function Wpe(e){return sP(Jb,e)}var t9=["none","low","medium","high","xhigh"];var Gk=u.string().regex(/^[a-z][a-z0-9_-]*$/);var xo=u.string().trim().min(1).max(160),Yh=u.number().int().nonnegative(),Jpe=u.discriminatedUnion("type",[u.strictObject({type:u.literal("code_change"),author:xo.optional(),sourceBranch:xo.optional(),targetBranch:xo.optional(),reviewers:u.array(xo).max(5).optional(),review:u.enum(["required","approved","changes_requested"]).optional(),checks:u.strictObject({passed:Yh,failed:Yh,pending:Yh}).optional(),mergeable:u.boolean().optional(),changedFiles:Yh.optional(),additions:Yh.optional(),deletions:Yh.optional()}),u.strictObject({type:u.literal("task"),assignees:u.array(xo).max(5).optional(),priority:xo.optional(),project:xo.optional(),cycle:xo.optional(),dueDate:u.iso.date().optional(),labels:u.array(xo).max(5).optional()}),u.strictObject({type:u.literal("deployment"),project:xo.optional(),environment:xo.optional(),revision:xo.optional(),branch:xo.optional()}),u.strictObject({type:u.literal("calendar_event"),when:xo.optional(),attendees:u.array(xo).max(5).optional()})]);function n9(e){if(!e)return[];let t=[],a=n=>n?.length?`${n.join(", ")}${n.length===5?" (up to 5 shown)":""}`:void 0;function r(n,o,i){i!==void 0&&i!==""&&t.push({key:n,label:o,value:String(i)})}switch(e.type){case"code_change":r("sourceBranch","Branch",e.sourceBranch);break;case"task":r("assignees","Assignees",e.assignees?.length===0?"Unassigned":a(e.assignees)),r("priority","Priority",e.priority),r("project","Project",e.project),r("cycle","Cycle",e.cycle),r("dueDate","Due",e.dueDate),r("labels","Labels",a(e.labels));break;case"deployment":r("environment","Environment",e.environment),r("project","Project",e.project),r("revision","Revision",e.revision),r("branch","Branch",e.branch);break;case"calendar_event":r("when","When",e.when),r("attendees","Attendees",a(e.attendees));break}return t.slice(0,4)}var tg=u.enum(["task","code_change","automation","deployment","calendar_event","item"]);var dE=u.object({kind:u.literal("object"),key:u.string().trim().min(1).max(256),label:u.string().trim().min(1).max(256),objectType:tg,title:u.string().trim().min(1).max(512),url:u.url().max(2048).refine(e=>["http:","https:"].includes(new URL(e).protocol)).nullable(),description:u.string().max(4e3).optional(),status:u.string().trim().min(1).max(100).optional(),trigger:u.string().max(4e3).optional(),warning:u.string().max(1e3).optional(),displayType:u.string().trim().min(1).max(80).optional(),sourceUpdatedAt:u.iso.datetime({offset:!0}).optional(),facts:Jpe.refine(e=>new TextEncoder().encode(JSON.stringify(e)).length<=4096,"Object facts must not exceed 4 KiB").optional()}).strict().refine(e=>!e.facts||(e.facts.type==="deployment"?e.objectType==="deployment"||e.objectType==="item":e.facts.type===e.objectType),"Object facts must match the object type"),m4e=dE.safeExtend({plugin:u.string().min(1)});function Qpe(e){try{let t=new URL(e).protocol;return t==="http:"||t==="https:"}catch{return!1}}var Xpe=u.object({kind:u.literal("resource_link"),objectType:tg.optional(),key:u.string().trim().min(1).max(256),label:u.string().trim().min(1).max(256),url:u.string().url().max(2048).refine(Qpe,"URL must use HTTP or HTTPS."),description:u.string().trim().min(1).max(512).optional(),status:u.enum(["open","draft","closed","merged","warning"]).optional()}).strict(),r9=u.discriminatedUnion("kind",[Xpe,dE]),Ype=u.enum(["circle-dot","circle-dashed","circle-x","git-merge","git-pull-request","triangle-alert"]),o9=u.object({icon:Ype.optional(),objectType:tg.optional(),status:u.string().trim().min(1).max(100).optional(),key:u.string().trim().min(1).max(256),label:u.string().trim().min(1).max(256)}).strict(),sx=u.enum(["closed","merged","open"]),g4e=u.object({closedAt:u.date().optional(),conversationIds:u.array(u.string().min(1)).default([]),mergedAt:u.date().optional(),number:u.number().int().positive(),openedAt:u.date(),providerId:u.string().min(1),repository:u.object({name:u.string().min(1),providerId:u.string().min(1),url:u.string().url().optional()}).strict(),state:sx,title:u.string().min(1).optional(),updatedAt:u.date(),url:u.string().url().optional()}).strict(),y4e=u.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_]*$/),ehe=u.enum(["activity","brain","calendar","check","database","info","key","link","sparkles","warning"]),the=u.object({content:u.string().min(1).max(32*1024).optional(),description:u.string().trim().min(1).max(2e3).optional(),metadata:u.array(u.string().trim().min(1).max(120)).max(8).optional(),title:u.string().trim().min(1).max(4e3)}).strict(),i9=u.object({details:u.array(the).max(100).optional(),icon:ehe.optional(),preview:u.string().trim().min(1).max(500).optional(),title:u.string().trim().min(1).max(120)}).strict();var Wk=u.string().regex(/^T[A-Z0-9]+$/),fE=u.string().regex(/^(C|G|D)[A-Z0-9]+$/),s9=u.string().regex(/^local:[a-z0-9_-]+:[a-z0-9][a-z0-9_-]*$/),Jk=u.string().min(1).refine(e=>e===e.trim()&&e.toLowerCase()!=="unknown"),Kk=Jk,je=u.string().refine(e=>e.trim().length>0),Jr=je.refine(e=>e===e.trim()),ahe=u.object({id:je,provider:Jr}).strict(),nhe=ahe.extend({provider:u.literal("slack"),teamId:Wk,channelId:fE,threadTs:Jr.optional()}).strict(),x4e=u.discriminatedUnion("provider",[nhe]),S4e=u.enum(["slack","local"]),l9=u.enum(["public","private"]),mE=u.enum(["public","private"]),rhe=u.object({platform:u.literal("slack"),teamId:Wk,channelId:fE,threadTs:Jr.optional()}).strict(),ag=rhe,ohe=u.object({platform:u.literal("local"),conversationId:s9}).strict(),ihe=u.discriminatedUnion("platform",[ag,ohe]),lx=u.object({action:u.literal("send_message"),destination:ag}).strict(),she=u.object({kind:u.literal("slack"),teamId:Wk,channelId:fE,visibility:l9,messageTs:je.optional(),threadTs:je.optional()}).strict(),lhe=u.object({kind:u.literal("local"),visibility:u.literal("private"),conversationId:s9}).strict(),uhe=u.object({kind:u.literal("web"),visibility:l9,conversationId:Jr}).strict(),che=u.object({kind:u.literal("event"),eventKey:Jr,eventType:Jr,identifier:Jr,namespace:Jr}).strict(),dhe=u.object({kind:u.literal("scheduled_automation")}).strict(),fhe=u.object({kind:u.literal("event_automation")}).strict(),mhe=u.object({kind:u.literal("plugin_dispatch")}).strict(),phe=u.object({kind:u.literal("agent_invocation")}).strict(),hhe=u.discriminatedUnion("kind",[she,lhe,uhe,che,dhe,fhe,mhe,phe]);function ghe(e){if(!e||typeof e!="object"||Array.isArray(e))return e;let t=e;if("kind"in t){let o={event_task:"event_automation",resource_event:"event",scheduled_task:"scheduled_automation"},i=typeof t.kind=="string"?o[t.kind]:void 0;return i?{...t,kind:i}:e}if(t.platform!=="slack"&&t.platform!=="local"&&t.platform!=="web")return e;let{location:a,platform:r,...n}=t;return{...n,kind:r}}var vhe=u.preprocess(ghe,hhe),yhe=u.discriminatedUnion("allowedWhen",[u.object({type:u.literal("user"),userId:Kk,allowedWhen:u.literal("private-direct-conversation")}).strict(),u.object({type:u.literal("user"),userId:Kk,allowedWhen:u.literal("scheduled-automation"),taskId:Jr}).strict()]),pE={email:je.optional(),fullName:je.optional(),userId:Kk,userName:je.optional()},bhe=u.object({...pE,platform:u.literal("slack"),teamId:Wk}).strict(),xhe=u.object({...pE,platform:u.literal("local")}).strict(),She=u.object({...pE,platform:u.literal("web")}).strict(),whe=u.object({platform:u.literal("system"),name:Kk}).strict(),ix=u.discriminatedUnion("platform",[bhe,xhe,She,whe]),Che=u.object({displayName:je.optional(),handle:je.optional(),id:Jr,provider:Jr,providerSubjectId:Jr,providerTenantId:Jr.optional()}).strict(),w4e=u.object({displayName:je.optional(),email:je.max(320),id:Jr,identities:u.array(Che).max(100),isAdmin:u.literal(!0).optional()}).strict(),khe=u.record(u.string(),u.string()).superRefine((e,t)=>{let a=Object.entries(e);if(a.length>20){t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata has too many keys"});return}for(let[r,n]of a){if(!r.trim()){t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata values must be strings",path:[r]});continue}r.length>128&&t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata key exceeds the maximum length",path:[r]}),/[\r\n]/.test(r)&&t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata keys must be single-line strings",path:[r]}),/[\r\n]/.test(n)&&t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata values must be single-line strings",path:[r]}),n.length>512&&t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata value exceeds the maximum length",path:[r]})}}),Ihe=u.object({label:Jr.pipe(u.string().max(48)).refine(e=>!/[\r\n]/.test(e)),detail:Jr.pipe(u.string().max(128)).refine(e=>!/[\r\n]/.test(e)).optional()}).strict(),C4e=u.object({idempotencyKey:je.pipe(u.string().max(512)),credentialSubject:yhe.optional(),destination:ag,destinationVisibility:mE,input:je.pipe(u.string().max(32e3)),metadata:khe.optional(),replyAttribution:Ihe.optional()}).strict();var Lhe=u.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_-]*$/),I4e=u.object({text:u.string().trim().min(1).max(8e3)}).strict(),L4e=u.object({kind:Lhe,version:u.number().int().positive(),content:u.record(u.string(),u.unknown())}).strict();var The=4e3,Rhe=8e3,eg=32,a9=4e3,_he=1e3,Nhe=u.record(u.string(),u.unknown()).superRefine((e,t)=>{Object.keys(e).length>eg&&t.addIssue({code:"custom",message:`Event data may include at most ${eg} keys.`}),new TextEncoder().encode(JSON.stringify(e)).byteLength>a9&&t.addIssue({code:"custom",message:`Event data may be at most ${a9} JSON bytes.`})}),Qu=u.string().regex(/^[a-z][a-z0-9_-]*(?:\.[a-z][a-z0-9_-]*)+$/).describe("Canonical dotted event type, such as issue.closed or pull_request.review.changes_requested."),u9=u.string().regex(/^[a-z][a-z0-9_]*$/).describe("Canonical plugin-defined resource type, such as issue or pull_request."),c9=/^[a-z][a-zA-Z0-9]*$/,Ahe=u.object({kind:u.enum(["boolean","string","number"]),description:u.string().trim().min(1).max(200),enum:u.array(u.string().min(1)).min(1).optional()}).strict().superRefine((e,t)=>{e.enum&&e.kind!=="string"&&t.addIssue({code:"custom",message:'Event match field enum requires kind "string".',path:["enum"]})}),$he=u.record(u.string().regex(c9),Ahe).superRefine((e,t)=>{Object.keys(e).length>eg&&t.addIssue({code:"custom",message:`Event match keys may include at most ${eg} keys.`})}),hE=u.record(u.string().regex(c9),u.union([u.boolean(),u.number().finite(),u.string().min(1),u.array(u.union([u.number().finite(),u.string().min(1)])).min(1)])).superRefine((e,t)=>{Object.keys(e).length>eg&&t.addIssue({code:"custom",message:`Event match may include at most ${eg} keys.`});for(let[a,r]of Object.entries(e))Array.isArray(r)&&r.some(n=>typeof n=="boolean")&&t.addIssue({code:"custom",message:`Event match field "${a}" cannot use a boolean list.`,path:[a]})});var Phe=u.object({format:u.string().trim().min(1).max(200),pattern:u.instanceof(RegExp)}).strict(),gE=u.object({type:u9,identifier:Phe.optional(),supportedEvents:u.array(Qu).min(1),suggestedEvents:u.array(Qu).optional(),matchFields:$he.optional(),guidance:u.record(Qu,u.string().trim().min(1).max(_he)).optional()}).strict().superRefine((e,t)=>{let a=new Set;e.supportedEvents.forEach((n,o)=>{a.has(n)&&t.addIssue({code:"custom",message:`Duplicate supported event type "${n}".`,path:["supportedEvents",o]}),a.add(n)});for(let n of Object.keys(e.guidance??{}))a.has(n)||t.addIssue({code:"custom",message:`Guidance event type "${n}" is not supported.`,path:["guidance",n]});let r=new Set;e.suggestedEvents?.forEach((n,o)=>{r.has(n)&&t.addIssue({code:"custom",message:`Duplicate suggested event type "${n}".`,path:["suggestedEvents",o]}),a.has(n)||t.addIssue({code:"custom",message:`Suggested event type "${n}" is not supported.`,path:["suggestedEvents",o]}),r.add(n)})}),R4e=u.object({resourceTypes:u.array(gE).min(1),isEnabled:u.function({input:[],output:u.boolean()}).optional(),normalizeIdentifier:u.function({input:[u.string()],output:u.string()}).optional()}).strict().superRefine((e,t)=>{let a=new Set;e.resourceTypes.forEach((r,n)=>{a.has(r.type)&&t.addIssue({code:"custom",message:`Duplicate resource type "${r.type}".`,path:["resourceTypes",n,"type"]}),a.add(r.type)})});var _4e=u.object({identifier:u.string().min(1),label:u.string().min(1),namespace:u.string().min(1),suggestedEvents:u.array(Qu).optional(),supportedEvents:u.array(Qu),type:u9}).strict(),N4e=u.object({events:u.array(Qu).min(1),id:u.string().min(1)}).strict(),Dhe=u.object({objectType:tg.optional(),eventKey:u.string().min(1),eventType:Qu,identifier:u.string().min(1),occurredAtMs:u.number().finite(),terminal:u.boolean().optional(),trustedSummary:u.string().min(1).transform(e=>e.slice(0,The)),data:Nhe.optional(),untrustedText:u.string().transform(e=>e.slice(0,Rhe)).optional()}).strict(),A4e=Dhe.extend({namespace:u.string().min(1)}),Ehe=u.object({authority:u.enum(["instruction","context"]),actor:ix.optional()}).strict(),Mhe=u.discriminatedUnion("type",[u.object({type:u.literal("message"),role:u.enum(["user","assistant"]),text:u.string().min(1),provenance:Ehe.optional(),isRunActor:u.boolean().optional()}).strict(),u.object({type:u.literal("toolResult"),toolName:u.string().min(1),isError:u.boolean(),text:u.string().min(1).optional()}).strict()]),P4e=u.object({actorUserId:u.string().min(1).optional(),completedAtMs:u.number().finite(),conversationId:u.string().min(1),destination:ihe,locationId:u.string().min(1).optional(),actors:u.array(ix),actor:ix.optional(),runId:u.string().min(1),source:vhe,transcript:u.array(Mhe)}).strict();var E4e=u.discriminatedUnion("type",[u.object({type:u.literal("text"),text:u.string()}).strict(),u.object({type:u.literal("image"),data:u.string(),mimeType:u.string()}).strict()]),Ohe=u.object({arguments:u.record(u.string(),u.unknown()),reason:u.string().min(1).optional()}).strict(),M4e=u.object({objectAnnotations:u.array(dE).optional(),target:u.string().min(1).optional(),truncated:u.boolean().optional(),continuation:Ohe.optional()}).passthrough(),O4e=u.enum(["auto","review","approve"]);var U4e=u.object({auth:u.object({user:u.object({email:u.string().nullable().optional(),emailVerified:u.boolean().optional(),isAdmin:u.boolean(),name:u.string().nullable().optional()}).strict()}).strict(),pluginName:je}).strict(),zhe=u.string().regex(/^[a-z][a-z0-9-]*$/),Uhe=u.string().regex(/^[a-z][a-z0-9.-]*$/),jhe=u.union([u.literal("read"),u.literal("write")]),d9=u.object({provider:zhe,scope:je.optional(),type:u.literal("oauth")}).strict(),f9=u.object({displayName:je.optional(),handle:je.optional(),id:je,label:je.optional(),url:je.optional()}).strict(),B4e=u.object({account:f9.optional(),accessToken:je,expiresAt:u.number().finite().optional(),refreshToken:je,refreshTokenExpiresAt:u.number().finite().optional(),scope:je.optional()}).strict(),F4e=u.object({access:jhe,leaseScope:je.optional(),name:Uhe,reason:je.optional(),requirements:u.array(je).min(1).optional()}).strict(),Bhe=u.object({domain:u.string().min(1),headers:u.record(u.string(),u.string()).refine(e=>Object.keys(e).length>0)}).strict(),Fhe=u.object({account:f9.optional(),authorization:d9.optional(),expiresAt:u.string().refine(e=>Number.isFinite(Date.parse(e))),headerTransforms:u.array(Bhe).min(1)}).strict(),H4e=u.discriminatedUnion("type",[u.object({lease:Fhe,type:u.literal("lease")}).strict(),u.object({authorization:d9.optional(),message:je,type:u.literal("needed")}).strict(),u.object({message:je,type:u.literal("unavailable")}).strict()]);var Hhe=je.max(64).regex(/^[a-z][a-z0-9-]*$/),Vhe=je.max(80),qhe=je.max(500),Zhe=u.enum(["primary","profile","admin"]),Ghe=u.object({detail:je.max(500).optional(),label:je.max(80),tone:u.enum(["good","neutral","warning"]).optional(),value:je.max(120)}).strict(),Khe=u.object({label:je.max(80),value:je.max(500)}).strict(),Whe=u.object({confirmation:je.max(500).optional(),href:je.max(500).regex(/^\/api\/plugins\/[a-z][a-z0-9-]*(?:\/|$)/),label:je.max(80),method:u.enum(["DELETE","GET"]),tone:u.enum(["danger","neutral"]).optional()}).strict(),Jhe=u.object({actions:u.array(Whe).max(4).optional(),description:je.max(1e3).optional(),id:je.max(128),metadata:u.array(Khe).max(8).optional(),title:je.max(4e3)}).strict(),q4e=u.object({emptyText:je.max(500).optional(),metrics:u.array(Ghe).max(6).optional(),nextCursor:je.max(1e3).optional(),records:u.array(Jhe).max(100),searchPlaceholder:je.max(120).optional(),type:u.literal("list")}).strict(),Qhe=u.object({description:qhe,id:Hhe,label:Vhe,navigation:Zhe,pluginDisplayName:je.max(200),pluginName:je.max(100)}).strict(),Z4e=u.array(Qhe),Xhe=je.max(1e3).optional(),Yhe=je.max(64).optional(),ege=u.string().trim().max(200).optional(),G4e=u.object({cursor:Xhe,filter:Yhe,limit:u.number().int().min(1).max(50),query:ege}).strict();var tge=u.object({input:u.number().finite().nonnegative().optional(),output:u.number().finite().nonnegative().optional(),cacheRead:u.number().finite().nonnegative().optional(),cacheWrite:u.number().finite().nonnegative().optional(),total:u.number().finite().nonnegative().optional()}).strict(),p9=u.object({inputTokens:u.number().int().nonnegative().optional(),outputTokens:u.number().int().nonnegative().optional(),cachedInputTokens:u.number().int().nonnegative().optional(),cacheCreationTokens:u.number().int().nonnegative().optional(),reasoningTokens:u.number().int().nonnegative().optional(),totalTokens:u.number().int().nonnegative().optional(),cost:tge.optional()}).strict(),age=u.union([u.literal("instruction"),u.literal("context")]),nge=u.object({authority:age,actor:ix.optional()}).strict();var X4e=u.record(u.string(),u.unknown()),Y4e=u.object({item:u.string()}).passthrough();function rge(e){return e==="user_message"||e==="assistant_message"||e==="tool_result"||e==="handoff"||e==="compaction"}var oge=u.object({type:u.literal("user_message"),role:u.never().optional(),provenance:nge}).passthrough(),ige=u.object({type:u.literal("assistant_message"),role:u.never().optional()}).passthrough(),sge=u.object({type:u.literal("tool_result"),role:u.never().optional()}).passthrough(),h9=u.discriminatedUnion("type",[oge,ige,sge]),lge=u.object({item:h9,sourceEventSeq:u.number().int().nonnegative().optional()}).strict(),m9=u.array(lge),uge=u.object({reason:u.literal("capacity"),estimatedInputTokens:u.number().int().nonnegative(),replacementInputTokens:u.number().int().nonnegative().optional(),triggerTokens:u.number().int().nonnegative(),inputLimitTokens:u.number().int().positive(),inputMessageCount:u.number().int().nonnegative(),retainedMessageCount:u.number().int().nonnegative(),summaryChars:u.number().int().nonnegative()}).strict(),g9=u.discriminatedUnion("type",[u.object({type:u.literal("handoff"),modelProfile:Gk,modelId:u.string().min(1),reasoningLevel:u.string().min(1).optional(),triggeringToolCallId:u.string().min(1).optional(),summary:u.string().min(1).optional(),replacementHistory:m9}).strict(),u.object({type:u.literal("compaction"),modelProfile:Gk,modelId:u.string().min(1),details:uge.optional(),summary:u.string().min(1).optional(),replacementHistory:m9}).strict()]),e5e=u.object({data:g9,createdAtMs:u.number().finite()}).strict(),cge=u.object({type:u.literal("mcp_provider_connected"),provider:u.string().min(1),credentialSubjectId:u.string().min(1)}).strict(),dge=u.object({type:u.literal("mcp_provider_connected_unowned"),provider:u.string().min(1)}).strict(),v9=u.union([u.literal("plugin"),u.literal("mcp")]),fge=u.object({type:u.literal("authorization_requested"),kind:v9,provider:u.string().min(1),actorId:u.string().min(1),authorizationId:u.string().min(1),delivery:u.union([u.literal("private_link_sent"),u.literal("private_link_reused")])}).strict(),mge=u.object({type:u.literal("authorization_completed"),kind:v9,provider:u.string().min(1),actorId:u.string().min(1),authorizationId:u.string().min(1)}).strict(),pge=u.object({type:u.literal("tool_execution_started"),toolCallId:u.string().min(1),toolName:u.string().min(1)}).strict(),hge=u.object({type:u.literal("guardian_action_reviewed"),turnId:u.string().min(1),toolCallId:u.string().min(1),toolName:u.string().min(1),costUsd:u.number().finite().nonnegative().optional(),decision:u.enum(["allow","ask","deny"]),riskLevel:u.enum(["low","medium","high","critical"]),userAuthorization:u.enum(["high","medium","low","unknown"])}).strict(),gge=u.union([u.literal("user"),u.literal("assistant"),u.literal("system")]),y9=u.object({type:u.literal("message"),messageId:u.string().min(1),role:gge,text:u.string(),authorIdentityId:u.string().min(1).optional(),meta:u.record(u.string(),u.unknown()).optional()}).strict(),vge=y9.extend({type:u.literal("message_updated")}),yge=u.object({type:u.literal("message_handled"),messageId:u.string().min(1)}).strict(),bge=u.object({type:u.literal("messages_summarized"),historyFromSeq:u.number().int().nonnegative(),compactions:u.array(u.object({coveredMessageCount:u.number().int().nonnegative(),createdAtMs:u.number(),id:u.string().min(1),summary:u.string()}).strict())}).strict(),xge=u.enum(["slack","api","scheduler","internal"]),Qk=u.enum(["agent_run_failed","delivery_failed","model_execution_failed","persistence_failed"]),Xk=u.enum(["auth","permission","rate_limit","capacity","timeout","network","server","invalid_request","invalid_response","quota","content_policy","unknown","empty_output","tool_errors","suppressed_output"]),Sge=u.object({type:u.literal("turn_started"),turnId:u.string().min(1),inputMessageIds:u.array(u.string().min(1)).min(1),surface:xge}).strict().refine(e=>new Set(e.inputMessageIds).size===e.inputMessageIds.length,"turn input message ids must be unique"),wge=u.object({type:u.literal("turn_routed"),turnId:u.string().min(1),modelProfile:Gk,modelId:u.string().min(1),costUsd:u.number().finite().nonnegative().optional(),reasoningLevel:u.enum(t9),confidence:u.number().min(0).max(1).optional(),source:u.enum(["configured","inherited","router"])}).strict(),Cge=u.object({type:u.literal("turn_context"),turnId:u.string().min(1),pluginName:u.string().min(1),kind:u.string().min(1).max(64),version:u.number().int().positive(),content:u.record(u.string(),u.unknown())}).strict(),kge=u.object({type:u.literal("structured_event"),namespace:u.string().regex(/^[a-z][a-z0-9-]*$/),name:u.string().regex(/^[a-z][a-z0-9_]*$/),version:u.number().int().positive(),turnId:u.string().min(1).optional(),content:u.record(u.string(),u.unknown())}).strict(),Ige=u.object({id:u.string().min(1),filename:u.string().min(1),contentType:u.string().min(1),bytes:u.number().int().nonnegative()}).strict(),Lge=u.object({type:u.literal("attachments_delivered"),attachments:u.array(Ige).min(1),toolCallId:u.string().min(1).optional(),turnId:u.string().min(1).optional()}).strict(),Tge=u.object({type:u.literal("turn_completed"),turnId:u.string().min(1),outcome:u.enum(["success","no_reply","cancelled"])}).strict(),Rge=u.object({type:u.literal("turn_failed"),turnId:u.string().min(1),failureCode:Qk,failureReason:Xk.optional(),eventId:u.string().regex(/^[a-f0-9]{32}$/i).optional()}).strict(),_ge=u.object({type:u.literal("subagent_started"),subagentInvocationId:u.string().min(1),subagentKind:u.string().min(1),modelId:u.string().min(1).optional(),parentToolCallId:u.string().min(1).optional(),reasoningLevel:u.string().min(1).optional(),childConversationId:u.string().min(1)}).strict(),Nge=u.object({type:u.literal("subagent_ended"),subagentInvocationId:u.string().min(1),outcome:u.union([u.literal("success"),u.literal("error"),u.literal("aborted")]),errorCode:u.string().min(1).optional()}).strict(),b9=u.union([y9,vge,h9,cge,fge,mge,pge,hge,yge,bge,Sge,Cge,kge,Lge,wge,Tge,Rge,_ge,Nge]),Age=u.union([b9,g9,dge]),$ge=["message","message_updated","user_message","assistant_message","tool_result","mcp_provider_connected","mcp_provider_connected_unowned","authorization_requested","authorization_completed","tool_execution_started","guardian_action_reviewed","message_handled","messages_summarized","turn_started","turn_context","structured_event","attachments_delivered","turn_routed","turn_completed","turn_failed","subagent_started","subagent_ended","handoff","compaction"],t5e=u.enum($ge),Pge=u.object({type:u.literal("unknown"),originalType:u.string().min(1),payload:u.unknown()}).strict(),vE=u.object({schemaVersion:u.number().int().nonnegative(),seq:u.number().int().nonnegative(),historyVersion:u.number().int().nonnegative(),idempotencyKey:u.string().min(1).optional(),createdAtMs:u.number().finite()}).strict(),a5e=u.union([vE.extend({schemaVersion:u.union([u.literal(1),u.literal(2)]),data:Age}).refine(e=>e.schemaVersion===1||rge(e.data.type)),vE.extend({data:Pge})]),n5e=vE.extend({type:u.string().min(1),payload:u.unknown()});var r5e=u.object({data:b9,idempotencyKey:u.string().min(1).optional(),createdAtMs:u.number().finite()}).strict();var Dge=u.object({kind:u.literal("automation"),id:u.string().min(1),title:u.string().min(1).max(160),url:u.string().url().nullable(),instruction:u.string().max(4e3),trigger:u.string().min(1),warning:u.string().nullable()}).strict();function Ege(e){return[e.title,e.warning,e.trigger,e.instruction,e.url,`Automation ID: ${e.id}`].filter(Boolean).join(`
69
69
  `)}var u5e=Dge.extend({operation:u.enum(["created","updated","deleted"]).optional()});function xE(e){switch(e.kind){case"object":return[e.title,e.label!==e.title?e.label:void 0,e.description,e.status,...n9(e.facts).map(t=>`${t.label}: ${t.value}`),e.trigger,e.warning,e.url].filter(Boolean).join(`
70
- `);case"automation":return Ege(e)}}var Mge=u.object({plugin:u.string().min(1),key:u.string().min(1)}).strict(),Oge=Mge.extend({kind:u.literal("object")});function SE(e,t){return e.map(a=>{let r=t.find(n=>n.kind===a.kind&&n.plugin===a.plugin&&n.key===a.key);return r?zge(r):{...a,objectType:"item",title:a.key,label:a.key,url:null,warning:"Saved annotation is unavailable."}})}function zge(e){let{createdAt:t,updatedAt:a,...r}=e;return r.kind==="object"?r:{...r,kind:"object",objectType:r.objectType??"item",title:r.label}}var Qr=u.string().trim().min(1).max(400),wE=u.string().url().max(2048),ux=u.string().datetime(),x9=u.object({provider:u.string().trim().min(1).max(100),channelName:Qr.optional()}).strict(),Uge=u.enum(["in_progress","answered","done","partial","blocked","abandoned"]),S9=u.object({repository:Qr,number:u.number().int().positive(),title:Qr.optional(),url:wE,state:sx,openedAt:ux.optional(),mergedAt:ux.optional(),closedAt:ux.optional()}).strict(),jge=u.object({kind:u.enum(["code_change","resource","url"]),label:Qr,url:wE,status:Qr.optional()}).strict(),Bge=u.object({startedAt:ux,lastActivityAt:ux,durationMs:u.number().int().nonnegative(),participants:u.array(u.object({name:Qr,messages:u.number().int().positive()}).strict()),userMessages:u.number().int().nonnegative(),assistantMessages:u.number().int().nonnegative(),toolResults:u.number().int().nonnegative(),events:u.number().int().nonnegative(),turns:u.number().int().positive().optional(),location:x9.optional(),codeChanges:u.array(S9)}).strict(),Fge=u.object({schemaVersion:u.literal(1),record:Bge,summary:u.string().trim().min(1).max(600),intent:Qr,outcome:u.object({status:Uge,text:u.string().trim().min(1).max(600)}).strict(),decisions:u.array(u.object({text:Qr,by:Qr.optional(),kind:u.enum(["stated","confirmed","assumed"])}).strict()).max(20),openDecisions:u.array(u.object({text:Qr,owner:Qr.optional()}).strict()).max(20),facts:u.array(Qr).max(30),links:u.array(jge).max(40),keywords:u.array(u.string().trim().toLowerCase().min(1).max(400)).max(12)}).strict(),Hge=u.object({index:u.number().int().nonnegative(),role:u.enum(["user","assistant","tool","event"]),author:Qr.optional(),text:u.string().min(1),createdAtMs:u.number().int().nonnegative(),turnId:u.string().min(1).optional()}).strict(),Vge=u.object({label:Qr,url:wE,status:Qr.optional()}).strict(),c5e=u.object({conversationId:u.string().min(1),title:Qr.optional(),visibility:u.enum(["private","public"]),location:x9.optional(),entries:u.array(Hge),codeChanges:u.array(S9),resources:u.array(Vge)}).strict();var Td=["image/png","image/jpeg","image/gif","image/webp"];var cx=3145728,CE=3,qge=u.object({filename:u.string().trim().min(1).max(255),contentType:u.enum(Td),data:u.string().min(4).max(cx*4/3).regex(/^[A-Za-z0-9+/]*={0,2}$/).refine(e=>e.length%4===0)}).strict(),kE=u.object({id:u.string().min(1),filename:u.string().min(1),contentType:u.string().min(1),bytes:u.number().int().nonnegative()}).strict();var Zge=u.enum(["active","completed","failed"]),Gge=u.enum(["api","internal","scheduler","slack"]),IE=p9,Kge=u.object({conversationId:u.string().min(1)}).strict(),d5e=u.object({attachmentId:u.string().min(1),conversationId:u.string().min(1)}).strict(),Wge=u.object({limit:u.coerce.number().int().min(1).max(1e3).default(500)}).strict(),Jge=u.object({before:u.string().min(1),limit:u.coerce.number().int().min(1).max(1e3).default(500)}).strict(),Qge=u.object({actorEmail:u.string().trim().email().transform(e=>e.toLowerCase()).optional(),codeRepositoryId:u.string().uuid().optional(),q:u.string().trim().max(200).optional(),status:u.enum(["active","archived"]).default("active")}).strict(),Xge=u.object({archived:u.boolean(),lastSeenAt:u.string().datetime()}).strict(),LE=u.object({archivedAt:u.string().datetime().nullable()}).strict(),w9=u.object({idempotencyKey:u.string().trim().min(1).max(200),message:u.string().trim().max(32e3),images:u.array(qge).max(3).optional()}).strict().refine(e=>!!(e.message||e.images?.length),"Add a message or an image.").refine(e=>(e.images??[]).reduce((t,a)=>t+a.data.length,0)<=cx*4/3,"Images must total 3 MB or less."),Yge=w9.safeExtend({visibility:u.enum(["private","public"]).optional()}),dx=u.object({conversationId:u.string().min(1),messageId:u.string().min(1),status:u.enum(["accepted","duplicate"])}).strict(),mm=u.object({email:u.string().optional(),fullName:u.string().optional(),slackUserId:u.string().optional(),slackUserName:u.string().optional()}).strict(),C9=u.enum(["defer","interrupt"]),k9=u.object({actorIdentity:mm.optional(),createdAt:u.string().datetime(),delivery:C9,inboundMessageId:u.string().min(1),messageId:u.string().min(1),receivedAt:u.string().datetime(),role:u.literal("user"),source:u.enum(["slack","web"]),text:u.string().optional(),attachments:u.array(kE).optional(),redacted:u.literal(!0).optional()}).strict().superRefine((e,t)=>{e.text===void 0==(e.redacted!==!0)&&t.addIssue({code:"custom",message:"pending message content must be text or explicitly redacted"}),e.redacted&&(e.actorIdentity||e.attachments)&&t.addIssue({code:"custom",message:"redacted pending messages must not expose actor identity or attachments"})}),I9=u.object({authorizationUrl:u.string().url(),completionText:u.string().min(1),label:u.string().min(1)}).strict(),TE=u.object({authorization:I9.optional(),conversationId:u.string().min(1),generatedAt:u.string().datetime(),messages:u.array(k9)}).strict(),eve=u.object({inboundMessageIds:u.array(u.string().min(1)).min(1).optional(),receivedBefore:u.string().datetime().optional()}).strict(),RE=u.object({cancelledCount:u.number().int().nonnegative(),cancelledInboundMessageIds:u.array(u.string().min(1)),conversationId:u.string().min(1)}).strict(),L9=u.object({costUsd:u.number().finite().nonnegative(),operations:u.array(u.object({costUsd:u.number().finite().nonnegative(),events:u.number().int().positive(),name:u.string().min(1),namespace:u.string().min(1)}).strict()).min(1)}).strict(),tve=u.object({id:u.string().min(1).optional(),kind:u.enum(["scheduled","event"]),label:u.string().min(1).optional(),title:u.string().min(1).optional()}).strict().superRefine((e,t)=>{!!e.id!=!!e.label&&t.addIssue({code:"custom",message:"sourceTask id and label must both be set or both omitted"})}),ave=r9.and(u.object({plugin:u.string().min(1),createdAt:u.string().datetime(),updatedAt:u.string().datetime()})),T9=u.object({createdAt:u.string().datetime(),role:u.enum(["assistant","user"]),text:u.string().min(1)}).strict(),ng=u.object({displayTitle:u.string(),activityPreview:T9.optional(),cumulativeDurationMs:u.number(),cumulativeUsage:IE.optional(),auxiliaryCosts:L9.optional(),conversationId:u.string(),isParticipant:u.boolean(),visibility:u.enum(["private","public"]).optional(),status:Zge,startedAt:u.string(),lastSeenAt:u.string(),lastProgressAt:u.string(),surface:Gge,actorIdentity:mm.optional(),participants:u.array(mm).optional(),archivedAt:u.string().datetime().nullable().optional(),channel:u.string().optional(),channelName:u.string().optional(),channelNameRedacted:u.boolean().optional(),locationId:u.string().optional(),sentryTraceUrl:u.string().optional(),locationUrl:u.string().url().optional(),traceId:u.string().optional(),annotations:u.array(ave).optional(),sidebarAnnotations:u.array(o9).optional(),assignedWork:u.boolean().optional(),finishedWorkAt:u.string().datetime().optional(),isPriority:u.boolean().optional(),unfinishedWork:u.boolean().optional()}).strict(),nve=u.object({type:u.literal("message"),messageId:u.string().min(1),role:u.enum(["assistant","system","user"]),source:u.enum(["slack","web"]).optional(),actorIdentity:mm.optional(),eventType:u.string().min(1).optional(),eventObjectType:tg.optional(),explicitMention:u.boolean().optional(),trustedSummary:u.string().min(1).optional(),cards:u.array(Oge).optional(),text:u.string().optional(),attachments:u.array(kE).optional(),redacted:u.literal(!0).optional()}).strict().superRefine((e,t)=>{e.text===void 0==(e.redacted!==!0)&&t.addIssue({code:"custom",message:"message content must be text or explicitly redacted"}),e.redacted&&(e.actorIdentity||e.cards||e.attachments)&&t.addIssue({code:"custom",message:"redacted messages must not expose actor identity, cards, or attachments"})}),rve=u.object({type:u.literal("message_handled"),messageId:u.string().min(1)}).strict(),ove=u.object({toolCallId:u.string().min(1),name:u.string().min(1),status:u.enum(["running","completed","error"]),startedAt:u.string().datetime().optional(),startedSeq:u.number().int().nonnegative().optional(),input:u.unknown().optional(),output:u.unknown().optional()}).strict().superRefine((e,t)=>{e.startedAt===void 0!=(e.startedSeq===void 0)&&t.addIssue({code:"custom",message:"tool start sequence and timestamp must be provided together"})}),R9=u.object({type:u.literal("reasoning"),text:u.string().min(1).optional(),redacted:u.literal(!0).optional()}).strict().superRefine((e,t)=>{e.text===void 0==(e.redacted!==!0)&&t.addIssue({code:"custom",message:"reasoning content must be text or explicitly redacted"})}),ive=u.object({type:u.literal("tool_call"),toolCallId:u.string().min(1)}).strict(),sve=u.object({parts:u.array(u.discriminatedUnion("type",[R9,ive])).min(1)}).strict(),lve=u.object({type:u.literal("tool_calls"),calls:u.array(ove).min(1),assistant:sve.optional()}).strict().superRefine((e,t)=>{if(!e.assistant)return;let a=new Map;for(let n of e.calls)a.set(n.toolCallId,(a.get(n.toolCallId)??0)+1);let r=new Map;for(let n of e.assistant.parts)n.type==="tool_call"&&r.set(n.toolCallId,(r.get(n.toolCallId)??0)+1);(a.size!==r.size||[...a].some(([n,o])=>r.get(n)!==o))&&t.addIssue({code:"custom",path:["assistant","parts"],message:"assistant tool parts must reference every call exactly once"})}),uve=u.object({type:u.literal("assistant_message"),parts:u.array(R9)}).strict(),cve=u.discriminatedUnion("state",[u.object({type:u.literal("turn_lifecycle"),turnId:u.string().min(1),state:u.enum(["succeeded","no_reply"])}).strict(),u.object({type:u.literal("turn_lifecycle"),turnId:u.string().min(1),state:u.literal("started"),inputMessageIds:u.array(u.string().min(1)).min(1).optional()}).strict(),u.object({type:u.literal("turn_lifecycle"),turnId:u.string().min(1),state:u.literal("failed"),failureCode:Qk,failureReason:Xk.optional(),eventId:u.string().regex(/^[a-f0-9]{32}$/i).optional(),sentryEventUrl:u.string().url().optional()}).strict()]),dve=u.object({type:u.literal("turn_routed"),turnId:u.string().min(1),modelProfile:u.string().min(1),modelId:u.string().min(1),costUsd:u.number().finite().nonnegative().optional(),reasoningLevel:u.string().min(1),confidence:u.number().min(0).max(1).optional(),source:u.enum(["configured","inherited","router"])}).strict(),fve=u.object({type:u.literal("guardian_action_reviewed"),turnId:u.string().min(1),toolCallId:u.string().min(1),toolName:u.string().min(1),decision:u.enum(["allow","ask","deny"]),riskLevel:u.enum(["low","medium","high","critical"]),userAuthorization:u.enum(["high","medium","low","unknown"])}).strict(),mve=u.object({type:u.literal("turn_context"),turnId:u.string().min(1),pluginName:u.string().min(1),kind:u.string().min(1),version:u.number().int().positive(),content:u.record(u.string(),u.unknown())}).strict(),pve=u.object({type:u.literal("structured_event"),namespace:u.string().min(1),name:u.string().min(1),version:u.number().int().positive(),turnId:u.string().min(1).optional(),presentation:i9}).strict(),hve=u.object({type:u.literal("attachments_delivered"),attachments:u.array(kE).min(1)}).strict(),gve=u.object({type:u.literal("compaction"),modelProfile:u.string().min(1).optional(),modelId:u.string().min(1).optional(),summary:u.string().min(1).optional(),details:u.object({reason:u.literal("capacity"),estimatedInputTokens:u.number().int().nonnegative(),replacementInputTokens:u.number().int().nonnegative().optional(),triggerTokens:u.number().int().nonnegative(),inputLimitTokens:u.number().int().positive(),inputMessageCount:u.number().int().nonnegative(),retainedMessageCount:u.number().int().nonnegative(),summaryChars:u.number().int().nonnegative()}).strict().optional()}).strict(),vve=u.object({type:u.literal("handoff"),modelProfile:u.string().min(1),modelId:u.string().min(1),reasoningLevel:u.string().min(1).optional(),triggeringToolCallId:u.string().min(1).optional(),summary:u.string().min(1).optional()}).strict(),yve=u.object({type:u.literal("subagent"),startedSeq:u.number().int().nonnegative(),startedAt:u.string().datetime(),childConversationId:u.string().min(1),subagentKind:u.string().min(1),parentToolCallId:u.string().min(1).optional(),status:u.enum(["running","completed","error","aborted"])}).strict(),_9=u.discriminatedUnion("type",[nve,rve,uve,lve,cve,mve,pve,hve,dve,fve,gve,vve,yve]),_E=u.object({seq:u.number().int().nonnegative(),createdAt:u.string().datetime(),data:_9,model:u.object({modelId:u.string().min(1),modelProfile:u.string().min(1).optional(),reasoningLevel:u.string().min(1).optional()}).strict().optional(),modelCall:u.object({provider:u.string().min(1).optional(),api:u.string().min(1).optional(),stopReason:u.string().min(1).optional(),usage:IE.optional()}).strict().optional()}).strict(),NE=u.discriminatedUnion("status",[u.object({status:u.literal("available")}).strict(),u.object({status:u.literal("redacted"),reason:u.literal("non_public_conversation")}).strict(),u.object({status:u.literal("expired"),expiredAt:u.string().datetime()}).strict()]),bve=u.object({modelId:u.string(),usage:IE}).strict();function N9(e,t){e.eventHistory.status==="expired"&&e.events.length>0&&t.addIssue({code:"custom",path:["events"],message:"expired event history must not contain events"});for(let a=1;a<e.events.length;a+=1)e.events[a].seq<=e.events[a-1].seq&&t.addIssue({code:"custom",path:["events",a,"seq"],message:"report event sequences must be strictly increasing"});for(let[a,r]of e.events.entries())r.data.type==="message"&&(e.eventHistory.status==="redacted"&&r.data.redacted!==!0&&t.addIssue({code:"custom",path:["events",a,"data"],message:"redacted event history must redact messages"}),e.eventHistory.status==="available"&&r.data.redacted===!0&&t.addIssue({code:"custom",path:["events",a,"data"],message:"available event history must expose messages"})),e.eventHistory.status==="redacted"&&r.data.type==="tool_calls"&&r.data.calls.some(n=>n.input!==void 0||n.output!==void 0)&&t.addIssue({code:"custom",path:["events",a,"data"],message:"redacted event history must redact tool payloads"}),e.eventHistory.status==="redacted"&&r.data.type==="assistant_message"&&r.data.parts.some(n=>n.text!==void 0)&&t.addIssue({code:"custom",path:["events",a,"data"],message:"redacted event history must redact assistant messages"}),e.eventHistory.status==="available"&&r.data.type==="assistant_message"&&r.data.parts.some(n=>n.redacted===!0)&&t.addIssue({code:"custom",path:["events",a,"data"],message:"available event history must expose reasoning"}),r.data.type==="tool_calls"&&(e.eventHistory.status==="redacted"&&r.data.assistant?.parts.some(n=>n.type==="reasoning"&&n.text!==void 0)||e.eventHistory.status==="available"&&r.data.assistant?.parts.some(n=>n.type==="reasoning"&&n.redacted===!0))&&t.addIssue({code:"custom",path:["events",a,"data","assistant"],message:"assistant reasoning must match event history visibility"})}var xve=u.object({messageId:u.string().min(1).max(500),idempotencyKey:u.string().trim().min(1).max(200)}).strict(),AE=u.object({conversationId:u.string()}).strict(),$E=ng.extend({canFork:u.boolean().optional(),forkedFromConversationId:u.string().optional(),forkedFromTitle:u.string().optional(),forks:u.array(u.string()).optional(),brief:u.object({content:Fge,updatedAt:u.string().datetime(),version:u.number().int().positive()}).strict().optional(),modelUsage:u.array(bve).optional(),events:u.array(_E),eventHistory:NE,previousCursor:u.string().min(1).optional(),generatedAt:u.string(),sentryConversationUrl:u.string().optional(),sourceTask:tve.optional()}).strict().superRefine(N9),PE=u.object({events:u.array(_E),eventHistory:NE,previousCursor:u.string().min(1).optional(),generatedAt:u.string()}).strict().superRefine(N9),Yk=u.object({conversations:u.array(ng),source:u.literal("conversation_index"),generatedAt:u.string()}).strict(),pm=u.object({active:u.number(),conversations:u.number(),durationMs:u.number(),failed:u.number(),label:u.string(),costUsd:u.number().optional(),tokens:u.number().optional()}).strict(),A9=u.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),yE=u.object({cachedInputTokens:u.number().optional(),cacheCreationTokens:u.number().optional(),conversations:u.number(),costUsd:u.number().optional(),date:A9,durationMs:u.number(),inputTokens:u.number().optional(),tokens:u.number().optional()}).strict(),bE=u.object({allow:u.number(),ask:u.number(),costUsd:u.number().optional(),date:A9,deny:u.number(),requests:u.number()}).strict(),Sve=u.object({allow:u.number(),ask:u.number(),costUsd:u.number().optional(),deny:u.number(),metricDays:u.array(bE),metricHours:u.array(bE).optional(),metricSixHours:u.array(bE).optional(),requests:u.number()}).strict(),DE=u.object({active:u.number(),cachedInputTokens:u.number().optional(),cacheCreationTokens:u.number().optional(),conversations:u.number(),durationMs:u.number(),failed:u.number(),generatedAt:u.string(),guardian:Sve,metricDays:u.array(yE),metricHours:u.array(yE).optional(),metricSixHours:u.array(yE).optional(),locations:u.array(pm),actors:u.array(pm),source:u.literal("conversation_index"),costUsd:u.number().optional(),inputTokens:u.number().optional(),tokens:u.number().optional(),windowEnd:u.string(),windowStart:u.string()}).strict();var wve=u.enum(["current_conversation","task_creator"]).describe("Where to send the message. Use current_conversation for posts, digests, summaries, and channel reminders. Use task_creator only when the user asks for a direct reminder or notification."),Cve=u.object({action:u.literal("send_message"),destination:wve}).strict(),M9=u.string().regex(/^\d{4}-\d{2}-\d{2}$/,"Use a local date in YYYY-MM-DD format."),O9=u.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/,"Use local time in HH:MM format."),z9=u.string().min(1).max(80).describe("IANA timezone the user asked for, for example America/New_York. Omit or use null to use the creator's timezone on create, or to keep the saved timezone on update. Do not guess it from office locations.").nullable().optional(),kve=u.enum(["sunday","monday","tuesday","wednesday","thursday","friday","saturday"]),Ive=u.object({kind:u.literal("one_off").describe("A schedule that runs once."),timezone:z9,timing:u.discriminatedUnion("type",[u.object({type:u.literal("after").describe("Run after a relative delay from the server clock."),value:u.number().int().positive().max(1e5),unit:u.enum(["second","minute","hour","day","week"])}).strict(),u.object({type:u.literal("at").describe("Run at an explicit local calendar date and time."),date:M9.describe("Requested local calendar date in YYYY-MM-DD format."),time:O9.describe("Requested local wall-clock time in HH:MM format.")}).strict()]).describe("Relative delay or explicit local time for the one-off run.")}).strict(),Lve=u.object({kind:u.literal("recurring").describe("A repeating calendar schedule."),frequency:u.enum(["daily","weekly","monthly","yearly"]).describe("Recurring tasks can run at most once per day."),interval:u.number().int().positive().max(365).describe("Repeat every N frequency units. Defaults to 1.").nullable().optional(),time:O9.describe("Local wall-clock time for each occurrence in HH:MM format."),weekdays:u.array(kve).min(1).max(7).describe("Required for weekly schedules.").nullable().optional(),dayOfMonth:u.number().int().min(1).max(31).describe("Required for monthly and yearly schedules.").nullable().optional(),month:u.number().int().min(1).max(12).describe("Required for yearly schedules, where January is 1.").nullable().optional(),startDate:M9.describe("Optional local calendar date that anchors the recurrence. Omit to start with the next matching occurrence.").nullable().optional(),timezone:z9}).strict().superRefine((e,t)=>{e.frequency==="weekly"&&e.weekdays==null&&t.addIssue({code:"custom",message:"Weekly schedules require weekdays.",path:["weekdays"]}),(e.frequency==="monthly"||e.frequency==="yearly")&&e.dayOfMonth==null&&t.addIssue({code:"custom",message:`${e.frequency} schedules require dayOfMonth.`,path:["dayOfMonth"]}),e.frequency==="yearly"&&e.month==null&&t.addIssue({code:"custom",message:"Yearly schedules require month.",path:["month"]}),e.frequency!=="weekly"&&e.weekdays!=null&&t.addIssue({code:"custom",message:"weekdays applies only to weekly schedules.",path:["weekdays"]}),e.frequency!=="monthly"&&e.frequency!=="yearly"&&e.dayOfMonth!=null&&t.addIssue({code:"custom",message:"dayOfMonth applies only to monthly or yearly schedules.",path:["dayOfMonth"]}),e.frequency!=="yearly"&&e.month!=null&&t.addIssue({code:"custom",message:"month applies only to yearly schedules.",path:["month"]})}),U9=u.union([Ive,Lve]);var j9=u.object({slackUserId:Jk,fullName:u.string().optional(),userName:u.string().optional()}).strict(),ME=u.object({events:u.array(Qu).min(1),label:u.string().min(1),match:hE.optional(),namespace:u.string().min(1),identifier:u.string().min(1).max(300),resourceType:u.string().min(1)}).strict(),B9=ag.omit({threadTs:!0}),Tve=lx.extend({destination:B9}),Rve=u.object({id:u.string().min(1),createdAtMs:u.number().finite(),createdBy:j9,credentialMode:u.enum(["system","creator"]),destination:B9,destinationVisibility:mE,outcomes:u.array(Tve).max(5),task:u.object({text:u.string().min(1)}).strict(),trigger:ME}).strict(),_ve=u.string().trim().min(1).max(60),F9=u.string().trim().min(1).max(4e3),S5e=F9.describe("Work to perform when the Automation runs. It runs later without this conversation, so write it to stand alone: name each person with their Slack mention, such as <@U123>, instead of me, my, or you. Preserve the user's scope, targets, and constraints. Do not add permissions or side effects the user did not request."),H9=u.object({title:_ve.optional(),instruction:F9.optional(),credentialMode:u.enum(["system","creator"]).optional(),outcomes:u.array(u.union([Cve,lx])).max(5).optional()}),Nve=H9.extend({schedule:U9.optional(),status:u.enum(["active","blocked"]).optional()}).strict(),Ave=H9.extend({trigger:ME.extend({identifier:u.string().trim().min(1).max(300),label:u.string().trim().min(1).max(500)}).optional()}).strict(),$ve=u.enum(["active","blocked","paused","completed","deleted"]),Pve=u.enum(["system","creator"]),Dve=u.enum(["pending","running","completed","failed","blocked","skipped"]),Eve=u.object({slackUserId:Jk,fullName:u.string().optional(),userName:u.string().optional()}).strict(),Mve=u.object({dayOfMonth:u.number().optional(),frequency:u.enum(["daily","weekly","monthly","yearly"]),interval:u.number(),month:u.number().optional(),startDate:u.string(),time:u.object({hour:u.number(),minute:u.number()}).strict(),weekdays:u.array(u.number()).optional()}).strict(),Ove=u.object({description:u.string(),kind:u.enum(["one_off","recurring"]),recurrence:Mve.optional(),timezone:u.string()}).strict(),zve=u.object({platform:u.literal("system"),name:u.string()}).strict(),V9=ag.omit({threadTs:!0}),Uve=u.object({action:u.literal("send_message"),destination:V9}).strict(),t1=u.object({id:u.string(),conversationAccess:u.object({audience:u.enum(["direct","group","channel"]),visibility:u.enum(["private","public"])}).strict(),createdAtMs:u.number(),createdBy:Eve,creatorIdentityId:u.string(),credentialMode:Pve,destination:V9,executionActor:zve.optional(),lastRunAtMs:u.number().optional(),nextRunAtMs:u.number().optional(),originalRequest:u.string().optional(),runNowAtMs:u.number().optional(),schedule:Ove,status:$ve,statusReason:u.string().optional(),outcomes:u.array(Uve).max(5),task:u.object({text:u.string()}).strict(),title:u.string().optional(),updatedAtMs:u.number()}).strict(),w5e=u.object({id:u.string(),attempt:u.number(),claimedAtMs:u.number(),completedAtMs:u.number().optional(),dispatchId:u.string().optional(),errorMessage:u.string().optional(),resultMessageTs:u.string().optional(),scheduledForMs:u.number(),startedAtMs:u.number().optional(),status:Dve,taskId:u.string()}).strict(),C5e=Object.freeze({platform:"system",name:"scheduled-automation"}),jve=u.object({channelId:u.string().min(1),label:u.string().min(1),teamId:u.string().min(1),visibility:u.enum(["private","public"])}).strict(),q9=u.object({1:u.number().int().nonnegative(),7:u.number().int().nonnegative(),30:u.number().int().nonnegative(),90:u.number().int().nonnegative()}).strict(),Z9=u.object({credentialMode:u.enum(["creator","system"]),createdAt:u.string().datetime(),createdBy:u.string().min(1),createdByAvatarUrl:u.string().url().optional(),createdByEmail:u.string().trim().email().optional(),destination:jve,id:u.string().min(1),instruction:u.string().min(1),lastConversationId:u.string().min(1).optional(),lastRunAt:u.string().datetime().optional(),lastRunStatus:u.enum(["blocked","completed","failed"]).optional(),ownedByViewer:u.boolean(),runs:q9,outcomes:u.array(lx).max(5),title:u.string().min(1),totalRuns:u.number().int().nonnegative()}),G9=Z9.extend({kind:u.literal("scheduled"),nextRunAt:u.string().datetime().optional(),schedule:u.string().min(1),timezone:u.string().min(1),statusReason:u.string().optional(),status:u.enum(["active","blocked","paused","completed"])}).strict(),K9=Z9.extend({events:u.array(u.string().min(1)).min(1),match:hE.optional(),kind:u.literal("event"),resource:u.string().min(1),source:u.string().min(1),triggerAvailable:u.boolean(),statusReason:u.string().optional(),status:u.enum(["active","blocked","paused"])}).strict(),mx=u.discriminatedUnion("kind",[G9,K9]),W9=u.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),EE=u.object({costUsd:u.number().finite().nonnegative(),date:W9,event:u.number().int().nonnegative(),scheduled:u.number().int().nonnegative()}).strict(),a1=u.object({q:u.string().trim().max(200).optional(),scope:u.enum(["all","mine","public","attention"]).default("all"),type:u.enum(["all","scheduled","event"]).default("all"),state:u.enum(["all","active","blocked","paused","completed","unavailable"]).default("all"),creator:u.string().max(300).optional(),destination:u.string().max(300).optional(),sort:u.enum(["newest","oldest","title"]).default("newest"),page:u.coerce.number().int().min(1).max(1e6).default(1),pageSize:u.coerce.number().int().min(1).max(100).default(25)}).strict(),$9=u.object({value:u.string(),label:u.string()}).strict(),OE=u.object({executionDays:u.array(EE),executionHours:u.array(EE).optional(),executionSixHours:u.array(EE).optional(),automations:u.array(mx),total:u.number().int().nonnegative(),page:u.number().int().positive(),pageSize:u.number().int().positive(),counts:u.object({all:u.number().int().nonnegative(),mine:u.number().int().nonnegative(),public:u.number().int().nonnegative(),private:u.number().int().nonnegative()}).strict(),creators:u.array($9),destinations:u.array($9)}).strict(),J9=u.object({id:u.string().min(1),kind:u.enum(["scheduled","event"])}).strict(),Q9=u.enum(["blocked","completed","failed"]),zE=u.object({conversationId:u.string().min(1).optional(),costUsd:u.number().finite().nonnegative().optional(),durationMs:u.number().finite().nonnegative().optional(),executedAt:u.string().datetime(),executionId:u.string().min(1),status:Q9,title:u.string().min(1).optional(),totalTokens:u.number().int().nonnegative().optional()}).strict(),e1=u.object({blocked:u.number().int().nonnegative(),completed:u.number().int().nonnegative(),date:W9,failed:u.number().int().nonnegative()}).strict(),UE=u.object({executionDays:u.array(e1),executionHours:u.array(e1).optional(),executionSixHours:u.array(e1).optional(),executions:u.array(zE),automation:mx,truncated:u.boolean()}).strict(),X9=zE.extend({kind:u.enum(["scheduled","event"]),automationId:u.string().min(1),automationTitle:u.string().min(1)}).strict(),jE=u.object({runs:u.array(X9),truncated:u.boolean()}).strict(),P9={title:u.string().nullable(),instruction:u.string()},D9={version:u.number().int().positive(),createdAt:u.string().datetime(),editedBy:j9.nullable()},Y9=u.discriminatedUnion("kind",[u.object({...D9,kind:u.literal("scheduled"),definition:t1.pick({credentialMode:!0,destination:!0,outcomes:!0,schedule:!0}).extend(P9).strict()}).strict(),u.object({...D9,kind:u.literal("event"),definition:Rve.pick({credentialMode:!0,destination:!0,outcomes:!0,trigger:!0}).extend(P9).strict()}).strict()]),BE=u.object({versions:u.array(Y9),activeVersion:u.number().int().positive().nullable(),truncated:u.boolean()}).strict(),Bve=J9.extend({version:u.coerce.number().int().positive()}).strict(),fx=u.string().regex(/^[a-f0-9]{64}$/),Fve=u.object({revision:fx}).strict(),k5e=u.object({action:u.enum(["pause","resume"]),revision:fx}).strict(),E9=t1.pick({destination:!0,createdBy:!0}).extend({id:u.string().min(1),revision:fx,title:u.string().nullable(),instruction:u.string(),credentialMode:u.enum(["system","creator"]),outcomes:u.array(lx).max(5),ownedByViewer:u.boolean()}),ds=u.discriminatedUnion("kind",[E9.merge(t1.pick({schedule:!0})).extend({kind:u.literal("scheduled"),nextRunAtMs:u.number().optional(),status:u.enum(["active","blocked","paused","completed"])}).strict(),E9.extend({kind:u.literal("event"),trigger:ME,triggerAvailable:u.boolean(),status:u.enum(["active","blocked","paused"])}).strict()]),FE=u.discriminatedUnion("kind",[Nve.omit({status:!0}).extend({kind:u.literal("scheduled"),revision:fx}).strict(),Ave.extend({kind:u.literal("event"),revision:fx}).strict()]),Hve=u.object({error:u.string(),code:u.enum(["invalid_edit","conflict","not_found"]),fields:u.record(u.string(),u.array(u.string())).optional()}).strict(),HE=u.array(gE.safeExtend({namespace:u.string()})),VE=U9,qE=t1.pick({schedule:!0}).extend({nextRunAtMs:u.number()}).strict();var Vve=u.object({status:u.literal("ok"),service:u.string(),timestamp:u.string()}).strict(),eZ=u.object({configKeys:u.array(u.string()),description:u.string(),displayName:u.string(),name:u.string()}).strict(),ZE=u.array(eZ),GE=u.object({name:u.string(),pluginProvider:u.string().optional()}).strict(),KE=u.array(GE),tZ=u.object({dir:u.string(),hasMigrationsDir:u.boolean(),hasSkillsDir:u.boolean(),packageName:u.string()}).strict(),aZ=u.object({packageNames:u.array(u.string()),packages:u.array(tZ),manifestRoots:u.array(u.string()),skillRoots:u.array(u.string()),tracingIncludes:u.array(u.string())}).strict(),qve=u.object({cwd:u.string(),homeDir:u.string(),descriptionText:u.string().optional(),providers:u.array(u.string()),skills:u.array(GE),packagedContent:aZ}).strict(),WE=u.enum(["danger","good","neutral","warning"]),Zve=u.object({label:u.string(),tone:WE.optional(),value:u.string()}).strict(),Gve=u.object({key:u.string(),label:u.string()}).strict(),Kve=u.object({id:u.string(),tone:WE.optional(),values:u.record(u.string(),u.string())}).strict(),Wve=u.object({fields:u.array(Gve).optional(),emptyText:u.string().optional(),records:u.array(Kve).optional(),title:u.string()}).strict(),Jve=u.object({categories:u.array(u.object({id:u.string().min(1),label:u.string().min(1),values:u.record(u.string(),u.number().finite())}).strict()).max(100),description:u.string().optional(),emptyText:u.string().optional(),id:u.string().min(1),series:u.array(u.object({format:u.literal("usd").optional(),key:u.string().min(1),label:u.string().min(1),tone:WE.optional()}).strict()).min(1).max(8),timeRangeDays:u.array(u.union([u.literal(1),u.literal(7),u.literal(30),u.literal(90)])).min(1).max(4).optional(),title:u.string().min(1),type:u.literal("bar_chart")}).strict(),nZ=u.object({generatedAt:u.string().optional(),metrics:u.array(Zve).optional(),recordSets:u.array(Wve).optional(),title:u.string().optional(),pluginName:u.string(),widgets:u.array(Jve).max(12).optional()}).strict(),n1=u.object({generatedAt:u.string(),reports:u.array(nZ),source:u.literal("plugins")}).strict(),rZ=36e5,T5e=6*rZ,R5e=24*rZ;async function JE(e){let t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(`${e.conversationId}\0${e.idempotencyKey}`));return`api-msg:${Array.from(new Uint8Array(t),a=>a.toString(16).padStart(2,"0")).join("").slice(0,24)}`}var D=Symbol.for("drizzle:entityKind");function Bn(e,t){if(!e||typeof e!="object")return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,D))throw new Error(`Class "${t.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let a=Object.getPrototypeOf(e).constructor;if(a)for(;a;){if(D in a&&a[D]===t[D])return!0;a=Object.getPrototypeOf(a)}return!1}var hm=class{constructor(t,a){this.table=t,this.config=a,this.name=a.name,this.keyAsName=a.keyAsName,this.notNull=a.notNull,this.default=a.default,this.defaultFn=a.defaultFn,this.onUpdateFn=a.onUpdateFn,this.hasDefault=a.hasDefault,this.primary=a.primaryKey,this.isUnique=a.isUnique,this.uniqueName=a.uniqueName,this.uniqueType=a.uniqueType,this.dataType=a.dataType,this.columnType=a.columnType,this.generated=a.generated,this.generatedIdentity=a.generatedIdentity}static[D]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(t){return t}mapToDriverValue(t){return t}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}};var r1=class{static[D]="ColumnBuilder";config;constructor(t,a,r){this.config={name:t,keyAsName:t==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:a,columnType:r,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(t){return this.config.default=t,this.config.hasDefault=!0,this}$defaultFn(t){return this.config.defaultFn=t,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(t){return this.config.onUpdateFn=t,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(t){this.config.name===""&&(this.config.name=t)}};var Xu=Symbol.for("drizzle:Name");var o1=class{static[D]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor(t,a){this.reference=()=>{let{name:r,columns:n,foreignColumns:o}=t();return{name:r,columns:n,foreignTable:o[0].table,foreignColumns:o}},a&&(this._onUpdate=a.onUpdate,this._onDelete=a.onDelete)}onUpdate(t){return this._onUpdate=t===void 0?"no action":t,this}onDelete(t){return this._onDelete=t===void 0?"no action":t,this}build(t){return new QE(t,this)}},QE=class{constructor(t,a){this.table=t,this.reference=a.reference,this.onUpdate=a._onUpdate,this.onDelete=a._onDelete}static[D]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:t,columns:a,foreignColumns:r}=this.reference(),n=a.map(s=>s.name),o=r.map(s=>s.name),i=[this.table[Xu],...n,r[0].table[Xu],...o];return t??`${i.join("_")}_fk`}};function i1(e,...t){return e(...t)}function eM(e,t){return`${e[Xu]}_${t.join("_")}_unique`}var XE=class{constructor(t,a){this.name=a,this.columns=t}static[D]="PgUniqueConstraintBuilder";columns;nullsNotDistinctConfig=!1;nullsNotDistinct(){return this.nullsNotDistinctConfig=!0,this}build(t){return new YE(t,this.columns,this.nullsNotDistinctConfig,this.name)}},oZ=class{static[D]="PgUniqueOnConstraintBuilder";name;constructor(t){this.name=t}on(...t){return new XE(t,this.name)}},YE=class{constructor(t,a,r,n){this.table=t,this.columns=a,this.name=n??eM(this.table,this.columns.map(o=>o.name)),this.nullsNotDistinct=r}static[D]="PgUniqueConstraint";columns;name;nullsNotDistinct=!1;getName(){return this.name}};function iZ(e,t,a){for(let r=t;r<e.length;r++){let n=e[r];if(n==="\\"){r++;continue}if(n==='"')return[e.slice(t,r).replace(/\\/g,""),r+1];if(!a&&(n===","||n==="}"))return[e.slice(t,r).replace(/\\/g,""),r]}return[e.slice(t).replace(/\\/g,""),e.length]}function sZ(e,t=0){let a=[],r=t,n=!1;for(;r<e.length;){let o=e[r];if(o===","){(n||r===t)&&a.push(""),n=!0,r++;continue}if(n=!1,o==="\\"){r+=2;continue}if(o==='"'){let[l,c]=iZ(e,r+1,!0);a.push(l),r=c;continue}if(o==="}")return[a,r+1];if(o==="{"){let[l,c]=sZ(e,r+1);a.push(l),r=c;continue}let[i,s]=iZ(e,r,!1);a.push(i),r=s}return[a,r]}function lZ(e){let[t]=sZ(e,1);return t}function tM(e){return`{${e.map(t=>Array.isArray(t)?tM(t):typeof t=="string"?`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`${t}`).join(",")}}`}var de=class extends r1{foreignKeyConfigs=[];static[D]="PgColumnBuilder";array(t){return new nM(this.config.name,this,t)}references(t,a={}){return this.foreignKeyConfigs.push({ref:t,actions:a}),this}unique(t,a){return this.config.isUnique=!0,this.config.uniqueName=t,this.config.uniqueType=a?.nulls,this}generatedAlwaysAs(t){return this.config.generated={as:t,type:"always",mode:"stored"},this}buildForeignKeys(t,a){return this.foreignKeyConfigs.map(({ref:r,actions:n})=>i1((o,i)=>{let s=new o1(()=>{let l=o();return{columns:[t],foreignColumns:[l]}});return i.onUpdate&&s.onUpdate(i.onUpdate),i.onDelete&&s.onDelete(i.onDelete),s.build(a)},r,n))}buildExtraConfigColumn(t){return new aM(t,this.config)}},ne=class extends hm{constructor(t,a){a.uniqueName||(a.uniqueName=eM(t,[a.name])),super(t,a),this.table=t}static[D]="PgColumn"},aM=class extends ne{static[D]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op(t){return this.indexConfig.opClass=t,this}},rg=class{static[D]="IndexedColumn";constructor(t,a,r,n){this.name=t,this.keyAsName=a,this.type=r,this.indexConfig=n}name;keyAsName;type;indexConfig},nM=class extends de{static[D]="PgArrayBuilder";constructor(t,a,r){super(t,"array","PgArray"),this.config.baseBuilder=a,this.config.size=r}build(t){let a=this.config.baseBuilder.build(t);return new rM(t,this.config,a)}},rM=class e extends ne{constructor(t,a,r,n){super(t,a),this.baseColumn=r,this.range=n,this.size=a.size}size;static[D]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size=="number"?this.size:""}]`}mapFromDriverValue(t){return typeof t=="string"&&(t=lZ(t)),t.map(a=>this.baseColumn.mapFromDriverValue(a))}mapToDriverValue(t,a=!1){let r=t.map(n=>n===null?null:Bn(this.baseColumn,e)?this.baseColumn.mapToDriverValue(n,!0):this.baseColumn.mapToDriverValue(n));return a?r:tM(r)}};var uZ=class extends de{static[D]="PgEnumObjectColumnBuilder";constructor(t,a){super(t,"string","PgEnumObjectColumn"),this.config.enum=a}build(t){return new oM(t,this.config)}},oM=class extends ne{static[D]="PgEnumObjectColumn";enum;enumValues=this.config.enum.enumValues;constructor(t,a){super(t,a),this.enum=a.enum}getSQLType(){return this.enum.enumName}},cZ=Symbol.for("drizzle:isPgEnum");function fZ(e){return!!e&&typeof e=="function"&&cZ in e&&e[cZ]===!0}var dZ=class extends de{static[D]="PgEnumColumnBuilder";constructor(t,a){super(t,"string","PgEnumColumn"),this.config.enum=a}build(t){return new iM(t,this.config)}},iM=class extends ne{static[D]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor(t,a){super(t,a),this.enum=a.enum}getSQLType(){return this.enum.enumName}};var og=class{static[D]="Subquery";constructor(t,a,r,n=!1,o=[]){this._={brand:"Subquery",sql:t,selectedFields:a,alias:r,isWith:n,usedTables:o}}},mZ=class extends og{static[D]="WithSubquery"};var pZ="0.45.2";var sM,lM,hZ={startActiveSpan(e,t){return sM?(lM||(lM=sM.trace.getTracer("drizzle-orm",pZ)),i1((a,r)=>r.startActiveSpan(e,n=>{try{return t(n)}catch(o){throw n.setStatus({code:a.SpanStatusCode.ERROR,message:o instanceof Error?o.message:"Unknown error"}),o}finally{n.end()}}),sM,lM)):t()}};var ig=Symbol.for("drizzle:ViewBaseConfig");var uM=Symbol.for("drizzle:Schema"),gZ=Symbol.for("drizzle:Columns"),vZ=Symbol.for("drizzle:ExtraConfigColumns"),cM=Symbol.for("drizzle:OriginalName"),dM=Symbol.for("drizzle:BaseName"),px=Symbol.for("drizzle:IsAlias"),yZ=Symbol.for("drizzle:ExtraConfigBuilder"),Qve=Symbol.for("drizzle:IsDrizzleTable"),kn=class{static[D]="Table";static Symbol={Name:Xu,Schema:uM,OriginalName:cM,Columns:gZ,ExtraConfigColumns:vZ,BaseName:dM,IsAlias:px,ExtraConfigBuilder:yZ};[Xu];[cM];[uM];[gZ];[vZ];[dM];[px]=!1;[Qve]=!0;[yZ]=void 0;constructor(t,a,r){this[Xu]=this[cM]=t,this[uM]=a,this[dM]=r}};var bZ=class{static[D]="FakePrimitiveParam"};function Xve(e){return e!=null&&typeof e.getSQL=="function"}function Yve(e){let t={sql:"",params:[]};for(let a of e)t.sql+=a.sql,t.params.push(...a.params),a.typings?.length&&(t.typings||(t.typings=[]),t.typings.push(...a.typings));return t}var _i=class{static[D]="StringChunk";value;constructor(t){this.value=Array.isArray(t)?t:[t]}getSQL(){return new In([this])}},In=class e{constructor(t){this.queryChunks=t;for(let a of t)if(Bn(a,kn)){let r=a[kn.Symbol.Schema];this.usedTables.push(r===void 0?a[kn.Symbol.Name]:r+"."+a[kn.Symbol.Name])}}static[D]="SQL";decoder=xZ;shouldInlineParams=!1;usedTables=[];append(t){return this.queryChunks.push(...t.queryChunks),this}toQuery(t){return hZ.startActiveSpan("drizzle.buildSQL",a=>{let r=this.buildQueryFromSourceParams(this.queryChunks,t);return a?.setAttributes({"drizzle.query.text":r.sql,"drizzle.query.params":JSON.stringify(r.params)}),r})}buildQueryFromSourceParams(t,a){let r=Object.assign({},a,{inlineParams:a.inlineParams||this.shouldInlineParams,paramStartIndex:a.paramStartIndex||{value:0}}),{casing:n,escapeName:o,escapeParam:i,prepareTyping:s,inlineParams:l,paramStartIndex:c}=r;return Yve(t.map(d=>{if(Bn(d,_i))return{sql:d.value.join(""),params:[]};if(Bn(d,hx))return{sql:o(d.value),params:[]};if(d===void 0)return{sql:"",params:[]};if(Array.isArray(d)){let f=[new _i("(")];for(let[m,p]of d.entries())f.push(p),m<d.length-1&&f.push(new _i(", "));return f.push(new _i(")")),this.buildQueryFromSourceParams(f,r)}if(Bn(d,e))return this.buildQueryFromSourceParams(d.queryChunks,{...r,inlineParams:l||d.shouldInlineParams});if(Bn(d,kn)){let f=d[kn.Symbol.Schema],m=d[kn.Symbol.Name];return{sql:f===void 0||d[px]?o(m):o(f)+"."+o(m),params:[]}}if(Bn(d,hm)){let f=n.getColumnCasing(d);if(a.invokeSource==="indexes")return{sql:o(f),params:[]};let m=d.table[kn.Symbol.Schema];return{sql:d.table[px]||m===void 0?o(d.table[kn.Symbol.Name])+"."+o(f):o(m)+"."+o(d.table[kn.Symbol.Name])+"."+o(f),params:[]}}if(Bn(d,fM)){let f=d[ig].schema,m=d[ig].name;return{sql:f===void 0||d[ig].isAlias?o(m):o(f)+"."+o(m),params:[]}}if(Bn(d,s1)){if(Bn(d.value,gx))return{sql:i(c.value++,d),params:[d],typings:["none"]};let f=d.value===null?null:d.encoder.mapToDriverValue(d.value);if(Bn(f,e))return this.buildQueryFromSourceParams([f],r);if(l)return{sql:this.mapInlineParam(f,r),params:[]};let m=["none"];return s&&(m=[s(d.encoder)]),{sql:i(c.value++,f),params:[f],typings:m}}return Bn(d,gx)?{sql:i(c.value++,d),params:[d],typings:["none"]}:Bn(d,e.Aliased)&&d.fieldAlias!==void 0?{sql:o(d.fieldAlias),params:[]}:Bn(d,og)?d._.isWith?{sql:o(d._.alias),params:[]}:this.buildQueryFromSourceParams([new _i("("),d._.sql,new _i(") "),new hx(d._.alias)],r):fZ(d)?d.schema?{sql:o(d.schema)+"."+o(d.enumName),params:[]}:{sql:o(d.enumName),params:[]}:Xve(d)?d.shouldOmitSQLParens?.()?this.buildQueryFromSourceParams([d.getSQL()],r):this.buildQueryFromSourceParams([new _i("("),d.getSQL(),new _i(")")],r):l?{sql:this.mapInlineParam(d,r),params:[]}:{sql:i(c.value++,d),params:[d],typings:["none"]}}))}mapInlineParam(t,{escapeString:a}){if(t===null)return"null";if(typeof t=="number"||typeof t=="boolean")return t.toString();if(typeof t=="string")return a(t);if(typeof t=="object"){let r=t.toString();return a(r==="[object Object]"?JSON.stringify(t):r)}throw new Error("Unexpected param value: "+t)}getSQL(){return this}as(t){return t===void 0?this:new e.Aliased(this,t)}mapWith(t){return this.decoder=typeof t=="function"?{mapFromDriverValue:t}:t,this}inlineParams(){return this.shouldInlineParams=!0,this}if(t){return t?this:void 0}},hx=class{constructor(t){this.value=t}static[D]="Name";brand;getSQL(){return new In([this])}};var xZ={mapFromDriverValue:e=>e},SZ={mapToDriverValue:e=>e},yUe={...xZ,...SZ},s1=class{constructor(t,a=SZ){this.value=t,this.encoder=a}static[D]="Param";brand;getSQL(){return new In([this])}};function sg(e,...t){let a=[];(t.length>0||e.length>0&&e[0]!=="")&&a.push(new _i(e[0]));for(let[r,n]of t.entries())a.push(n,new _i(e[r+1]));return new In(a)}(e=>{function t(){return new In([])}e.empty=t;function a(l){return new In(l)}e.fromList=a;function r(l){return new In([new _i(l)])}e.raw=r;function n(l,c){let d=[];for(let[f,m]of l.entries())f>0&&c!==void 0&&d.push(c),d.push(m);return new In(d)}e.join=n;function o(l){return new hx(l)}e.identifier=o;function i(l){return new gx(l)}e.placeholder=i;function s(l,c){return new s1(l,c)}e.param=s})(sg||(sg={}));(e=>{class t{constructor(r,n){this.sql=r,this.fieldAlias=n}static[D]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new t(this.sql,this.fieldAlias)}}e.Aliased=t})(In||(In={}));var gx=class{constructor(t){this.name=t}static[D]="Placeholder";getSQL(){return new In([this])}};var eye=Symbol.for("drizzle:IsDrizzleView"),fM=class{static[D]="View";[ig];[eye]=!0;constructor({name:t,schema:a,selectedFields:r,query:n}){this[ig]={name:t,originalName:t,schema:a,selectedFields:r,query:n,isExisting:!n,isAlias:!1}}getSQL(){return new In([this])}};hm.prototype.getSQL=function(){return new In([this])};kn.prototype.getSQL=function(){return new In([this])};og.prototype.getSQL=function(){return new In([this])};function _t(e,t){return{name:typeof e=="string"&&e.length>0?e:"",config:typeof e=="object"?e:t}}var xUe=typeof TextDecoder>"u"?null:new TextDecoder;var Yu=class extends de{static[D]="PgIntColumnBaseBuilder";generatedAlwaysAsIdentity(t){if(t){let{name:a,...r}=t;this.config.generatedIdentity={type:"always",sequenceName:a,sequenceOptions:r}}else this.config.generatedIdentity={type:"always"};return this.config.hasDefault=!0,this.config.notNull=!0,this}generatedByDefaultAsIdentity(t){if(t){let{name:a,...r}=t;this.config.generatedIdentity={type:"byDefault",sequenceName:a,sequenceOptions:r}}else this.config.generatedIdentity={type:"byDefault"};return this.config.hasDefault=!0,this.config.notNull=!0,this}};var mM=class extends Yu{static[D]="PgBigInt53Builder";constructor(t){super(t,"number","PgBigInt53")}build(t){return new pM(t,this.config)}},pM=class extends ne{static[D]="PgBigInt53";getSQLType(){return"bigint"}mapFromDriverValue(t){return typeof t=="number"?t:Number(t)}},hM=class extends Yu{static[D]="PgBigInt64Builder";constructor(t){super(t,"bigint","PgBigInt64")}build(t){return new gM(t,this.config)}},gM=class extends ne{static[D]="PgBigInt64";getSQLType(){return"bigint"}mapFromDriverValue(t){return BigInt(t)}};function wZ(e,t){let{name:a,config:r}=_t(e,t);return r.mode==="number"?new mM(a):new hM(a)}var vM=class extends de{static[D]="PgBigSerial53Builder";constructor(t){super(t,"number","PgBigSerial53"),this.config.hasDefault=!0,this.config.notNull=!0}build(t){return new yM(t,this.config)}},yM=class extends ne{static[D]="PgBigSerial53";getSQLType(){return"bigserial"}mapFromDriverValue(t){return typeof t=="number"?t:Number(t)}},bM=class extends de{static[D]="PgBigSerial64Builder";constructor(t){super(t,"bigint","PgBigSerial64"),this.config.hasDefault=!0}build(t){return new xM(t,this.config)}},xM=class extends ne{static[D]="PgBigSerial64";getSQLType(){return"bigserial"}mapFromDriverValue(t){return BigInt(t)}};function CZ(e,t){let{name:a,config:r}=_t(e,t);return r.mode==="number"?new vM(a):new bM(a)}var SM=class extends de{static[D]="PgBooleanBuilder";constructor(t){super(t,"boolean","PgBoolean")}build(t){return new wM(t,this.config)}},wM=class extends ne{static[D]="PgBoolean";getSQLType(){return"boolean"}};function kZ(e){return new SM(e??"")}var CM=class extends de{static[D]="PgCharBuilder";constructor(t,a){super(t,"string","PgChar"),this.config.length=a.length,this.config.enumValues=a.enum}build(t){return new kM(t,this.config)}},kM=class extends ne{static[D]="PgChar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"char":`char(${this.length})`}};function IZ(e,t={}){let{name:a,config:r}=_t(e,t);return new CM(a,r)}var IM=class extends de{static[D]="PgCidrBuilder";constructor(t){super(t,"string","PgCidr")}build(t){return new LM(t,this.config)}},LM=class extends ne{static[D]="PgCidr";getSQLType(){return"cidr"}};function LZ(e){return new IM(e??"")}var TM=class extends de{static[D]="PgCustomColumnBuilder";constructor(t,a,r){super(t,"custom","PgCustomColumn"),this.config.fieldConfig=a,this.config.customTypeParams=r}build(t){return new RM(t,this.config)}},RM=class extends ne{static[D]="PgCustomColumn";sqlName;mapTo;mapFrom;constructor(t,a){super(t,a),this.sqlName=a.customTypeParams.dataType(a.fieldConfig),this.mapTo=a.customTypeParams.toDriver,this.mapFrom=a.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(t){return typeof this.mapFrom=="function"?this.mapFrom(t):t}mapToDriverValue(t){return typeof this.mapTo=="function"?this.mapTo(t):t}};function TZ(e){return(t,a)=>{let{name:r,config:n}=_t(t,a);return new TM(r,n,e)}}var Hl=class extends de{static[D]="PgDateColumnBaseBuilder";defaultNow(){return this.default(sg`now()`)}};var _M=class extends Hl{static[D]="PgDateBuilder";constructor(t){super(t,"date","PgDate")}build(t){return new NM(t,this.config)}},NM=class extends ne{static[D]="PgDate";getSQLType(){return"date"}mapFromDriverValue(t){return typeof t=="string"?new Date(t):t}mapToDriverValue(t){return t.toISOString()}},AM=class extends Hl{static[D]="PgDateStringBuilder";constructor(t){super(t,"string","PgDateString")}build(t){return new $M(t,this.config)}},$M=class extends ne{static[D]="PgDateString";getSQLType(){return"date"}mapFromDriverValue(t){return typeof t=="string"?t:t.toISOString().slice(0,-14)}};function RZ(e,t){let{name:a,config:r}=_t(e,t);return r?.mode==="date"?new _M(a):new AM(a)}var PM=class extends de{static[D]="PgDoublePrecisionBuilder";constructor(t){super(t,"number","PgDoublePrecision")}build(t){return new DM(t,this.config)}},DM=class extends ne{static[D]="PgDoublePrecision";getSQLType(){return"double precision"}mapFromDriverValue(t){return typeof t=="string"?Number.parseFloat(t):t}};function _Z(e){return new PM(e??"")}var EM=class extends de{static[D]="PgInetBuilder";constructor(t){super(t,"string","PgInet")}build(t){return new MM(t,this.config)}},MM=class extends ne{static[D]="PgInet";getSQLType(){return"inet"}};function NZ(e){return new EM(e??"")}var OM=class extends Yu{static[D]="PgIntegerBuilder";constructor(t){super(t,"number","PgInteger")}build(t){return new zM(t,this.config)}},zM=class extends ne{static[D]="PgInteger";getSQLType(){return"integer"}mapFromDriverValue(t){return typeof t=="string"?Number.parseInt(t):t}};function AZ(e){return new OM(e??"")}var UM=class extends de{static[D]="PgIntervalBuilder";constructor(t,a){super(t,"string","PgInterval"),this.config.intervalConfig=a}build(t){return new jM(t,this.config)}},jM=class extends ne{static[D]="PgInterval";fields=this.config.intervalConfig.fields;precision=this.config.intervalConfig.precision;getSQLType(){let t=this.fields?` ${this.fields}`:"",a=this.precision?`(${this.precision})`:"";return`interval${t}${a}`}};function $Z(e,t={}){let{name:a,config:r}=_t(e,t);return new UM(a,r)}var BM=class extends de{static[D]="PgJsonBuilder";constructor(t){super(t,"json","PgJson")}build(t){return new FM(t,this.config)}},FM=class extends ne{static[D]="PgJson";constructor(t,a){super(t,a)}getSQLType(){return"json"}mapToDriverValue(t){return JSON.stringify(t)}mapFromDriverValue(t){if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t}};function PZ(e){return new BM(e??"")}var HM=class extends de{static[D]="PgJsonbBuilder";constructor(t){super(t,"json","PgJsonb")}build(t){return new VM(t,this.config)}},VM=class extends ne{static[D]="PgJsonb";constructor(t,a){super(t,a)}getSQLType(){return"jsonb"}mapToDriverValue(t){return JSON.stringify(t)}mapFromDriverValue(t){if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t}};function l1(e){return new HM(e??"")}var qM=class extends de{static[D]="PgLineBuilder";constructor(t){super(t,"array","PgLine")}build(t){return new ZM(t,this.config)}},ZM=class extends ne{static[D]="PgLine";getSQLType(){return"line"}mapFromDriverValue(t){let[a,r,n]=t.slice(1,-1).split(",");return[Number.parseFloat(a),Number.parseFloat(r),Number.parseFloat(n)]}mapToDriverValue(t){return`{${t[0]},${t[1]},${t[2]}}`}},GM=class extends de{static[D]="PgLineABCBuilder";constructor(t){super(t,"json","PgLineABC")}build(t){return new KM(t,this.config)}},KM=class extends ne{static[D]="PgLineABC";getSQLType(){return"line"}mapFromDriverValue(t){let[a,r,n]=t.slice(1,-1).split(",");return{a:Number.parseFloat(a),b:Number.parseFloat(r),c:Number.parseFloat(n)}}mapToDriverValue(t){return`{${t.a},${t.b},${t.c}}`}};function DZ(e,t){let{name:a,config:r}=_t(e,t);return!r?.mode||r.mode==="tuple"?new qM(a):new GM(a)}var WM=class extends de{static[D]="PgMacaddrBuilder";constructor(t){super(t,"string","PgMacaddr")}build(t){return new JM(t,this.config)}},JM=class extends ne{static[D]="PgMacaddr";getSQLType(){return"macaddr"}};function EZ(e){return new WM(e??"")}var QM=class extends de{static[D]="PgMacaddr8Builder";constructor(t){super(t,"string","PgMacaddr8")}build(t){return new XM(t,this.config)}},XM=class extends ne{static[D]="PgMacaddr8";getSQLType(){return"macaddr8"}};function MZ(e){return new QM(e??"")}var YM=class extends de{static[D]="PgNumericBuilder";constructor(t,a,r){super(t,"string","PgNumeric"),this.config.precision=a,this.config.scale=r}build(t){return new eO(t,this.config)}},eO=class extends ne{static[D]="PgNumeric";precision;scale;constructor(t,a){super(t,a),this.precision=a.precision,this.scale=a.scale}mapFromDriverValue(t){return typeof t=="string"?t:String(t)}getSQLType(){return this.precision!==void 0&&this.scale!==void 0?`numeric(${this.precision}, ${this.scale})`:this.precision===void 0?"numeric":`numeric(${this.precision})`}},tO=class extends de{static[D]="PgNumericNumberBuilder";constructor(t,a,r){super(t,"number","PgNumericNumber"),this.config.precision=a,this.config.scale=r}build(t){return new aO(t,this.config)}},aO=class extends ne{static[D]="PgNumericNumber";precision;scale;constructor(t,a){super(t,a),this.precision=a.precision,this.scale=a.scale}mapFromDriverValue(t){return typeof t=="number"?t:Number(t)}mapToDriverValue=String;getSQLType(){return this.precision!==void 0&&this.scale!==void 0?`numeric(${this.precision}, ${this.scale})`:this.precision===void 0?"numeric":`numeric(${this.precision})`}},nO=class extends de{static[D]="PgNumericBigIntBuilder";constructor(t,a,r){super(t,"bigint","PgNumericBigInt"),this.config.precision=a,this.config.scale=r}build(t){return new rO(t,this.config)}},rO=class extends ne{static[D]="PgNumericBigInt";precision;scale;constructor(t,a){super(t,a),this.precision=a.precision,this.scale=a.scale}mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return this.precision!==void 0&&this.scale!==void 0?`numeric(${this.precision}, ${this.scale})`:this.precision===void 0?"numeric":`numeric(${this.precision})`}};function OZ(e,t){let{name:a,config:r}=_t(e,t),n=r?.mode;return n==="number"?new tO(a,r?.precision,r?.scale):n==="bigint"?new nO(a,r?.precision,r?.scale):new YM(a,r?.precision,r?.scale)}var oO=class extends de{static[D]="PgPointTupleBuilder";constructor(t){super(t,"array","PgPointTuple")}build(t){return new iO(t,this.config)}},iO=class extends ne{static[D]="PgPointTuple";getSQLType(){return"point"}mapFromDriverValue(t){if(typeof t=="string"){let[a,r]=t.slice(1,-1).split(",");return[Number.parseFloat(a),Number.parseFloat(r)]}return[t.x,t.y]}mapToDriverValue(t){return`(${t[0]},${t[1]})`}},sO=class extends de{static[D]="PgPointObjectBuilder";constructor(t){super(t,"json","PgPointObject")}build(t){return new lO(t,this.config)}},lO=class extends ne{static[D]="PgPointObject";getSQLType(){return"point"}mapFromDriverValue(t){if(typeof t=="string"){let[a,r]=t.slice(1,-1).split(",");return{x:Number.parseFloat(a),y:Number.parseFloat(r)}}return t}mapToDriverValue(t){return`(${t.x},${t.y})`}};function zZ(e,t){let{name:a,config:r}=_t(e,t);return!r?.mode||r.mode==="tuple"?new oO(a):new sO(a)}function tye(e){let t=[];for(let a=0;a<e.length;a+=2)t.push(Number.parseInt(e.slice(a,a+2),16));return new Uint8Array(t)}function UZ(e,t){let a=new ArrayBuffer(8),r=new DataView(a);for(let n=0;n<8;n++)r.setUint8(n,e[t+n]);return r.getFloat64(0,!0)}function uO(e){let t=tye(e),a=0,r=t[a];a+=1;let n=new DataView(t.buffer),o=n.getUint32(a,r===1);a+=4;let i;if(o&536870912&&(i=n.getUint32(a,r===1),a+=4),(o&65535)===1){let s=UZ(t,a);a+=8;let l=UZ(t,a);return a+=8,[s,l]}throw new Error("Unsupported geometry type")}var cO=class extends de{static[D]="PgGeometryBuilder";constructor(t){super(t,"array","PgGeometry")}build(t){return new dO(t,this.config)}},dO=class extends ne{static[D]="PgGeometry";getSQLType(){return"geometry(point)"}mapFromDriverValue(t){return uO(t)}mapToDriverValue(t){return`point(${t[0]} ${t[1]})`}},fO=class extends de{static[D]="PgGeometryObjectBuilder";constructor(t){super(t,"json","PgGeometryObject")}build(t){return new mO(t,this.config)}},mO=class extends ne{static[D]="PgGeometryObject";getSQLType(){return"geometry(point)"}mapFromDriverValue(t){let a=uO(t);return{x:a[0],y:a[1]}}mapToDriverValue(t){return`point(${t.x} ${t.y})`}};function jZ(e,t){let{name:a,config:r}=_t(e,t);return!r?.mode||r.mode==="tuple"?new cO(a):new fO(a)}var pO=class extends de{static[D]="PgRealBuilder";constructor(t,a){super(t,"number","PgReal"),this.config.length=a}build(t){return new hO(t,this.config)}},hO=class extends ne{static[D]="PgReal";constructor(t,a){super(t,a)}getSQLType(){return"real"}mapFromDriverValue=t=>typeof t=="string"?Number.parseFloat(t):t};function BZ(e){return new pO(e??"")}var gO=class extends de{static[D]="PgSerialBuilder";constructor(t){super(t,"number","PgSerial"),this.config.hasDefault=!0,this.config.notNull=!0}build(t){return new vO(t,this.config)}},vO=class extends ne{static[D]="PgSerial";getSQLType(){return"serial"}};function FZ(e){return new gO(e??"")}var yO=class extends Yu{static[D]="PgSmallIntBuilder";constructor(t){super(t,"number","PgSmallInt")}build(t){return new bO(t,this.config)}},bO=class extends ne{static[D]="PgSmallInt";getSQLType(){return"smallint"}mapFromDriverValue=t=>typeof t=="string"?Number(t):t};function HZ(e){return new yO(e??"")}var xO=class extends de{static[D]="PgSmallSerialBuilder";constructor(t){super(t,"number","PgSmallSerial"),this.config.hasDefault=!0,this.config.notNull=!0}build(t){return new SO(t,this.config)}},SO=class extends ne{static[D]="PgSmallSerial";getSQLType(){return"smallserial"}};function VZ(e){return new xO(e??"")}var wO=class extends de{static[D]="PgTextBuilder";constructor(t,a){super(t,"string","PgText"),this.config.enumValues=a.enum}build(t){return new CO(t,this.config)}},CO=class extends ne{static[D]="PgText";enumValues=this.config.enumValues;getSQLType(){return"text"}};function Js(e,t={}){let{name:a,config:r}=_t(e,t);return new wO(a,r)}var kO=class extends Hl{constructor(t,a,r){super(t,"string","PgTime"),this.withTimezone=a,this.precision=r,this.config.withTimezone=a,this.config.precision=r}static[D]="PgTimeBuilder";build(t){return new IO(t,this.config)}},IO=class extends ne{static[D]="PgTime";withTimezone;precision;constructor(t,a){super(t,a),this.withTimezone=a.withTimezone,this.precision=a.precision}getSQLType(){return`time${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}};function qZ(e,t={}){let{name:a,config:r}=_t(e,t);return new kO(a,r.withTimezone??!1,r.precision)}var LO=class extends Hl{static[D]="PgTimestampBuilder";constructor(t,a,r){super(t,"date","PgTimestamp"),this.config.withTimezone=a,this.config.precision=r}build(t){return new TO(t,this.config)}},TO=class extends ne{static[D]="PgTimestamp";withTimezone;precision;constructor(t,a){super(t,a),this.withTimezone=a.withTimezone,this.precision=a.precision}getSQLType(){return`timestamp${this.precision===void 0?"":` (${this.precision})`}${this.withTimezone?" with time zone":""}`}mapFromDriverValue(t){return typeof t=="string"?new Date(this.withTimezone?t:t+"+0000"):t}mapToDriverValue=t=>t.toISOString()},RO=class extends Hl{static[D]="PgTimestampStringBuilder";constructor(t,a,r){super(t,"string","PgTimestampString"),this.config.withTimezone=a,this.config.precision=r}build(t){return new _O(t,this.config)}},_O=class extends ne{static[D]="PgTimestampString";withTimezone;precision;constructor(t,a){super(t,a),this.withTimezone=a.withTimezone,this.precision=a.precision}getSQLType(){return`timestamp${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}mapFromDriverValue(t){if(typeof t=="string")return t;let a=t.toISOString().slice(0,-1).replace("T"," ");if(this.withTimezone){let r=t.getTimezoneOffset(),n=r<=0?"+":"-";return`${a}${n}${Math.floor(Math.abs(r)/60).toString().padStart(2,"0")}`}return a}};function u1(e,t={}){let{name:a,config:r}=_t(e,t);return r?.mode==="string"?new RO(a,r.withTimezone??!1,r.precision):new LO(a,r?.withTimezone??!1,r?.precision)}var NO=class extends de{static[D]="PgUUIDBuilder";constructor(t){super(t,"string","PgUUID")}defaultRandom(){return this.default(sg`gen_random_uuid()`)}build(t){return new AO(t,this.config)}},AO=class extends ne{static[D]="PgUUID";getSQLType(){return"uuid"}};function ZZ(e){return new NO(e??"")}var $O=class extends de{static[D]="PgVarcharBuilder";constructor(t,a){super(t,"string","PgVarchar"),this.config.length=a.length,this.config.enumValues=a.enum}build(t){return new PO(t,this.config)}},PO=class extends ne{static[D]="PgVarchar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"varchar":`varchar(${this.length})`}};function GZ(e,t={}){let{name:a,config:r}=_t(e,t);return new $O(a,r)}var DO=class extends de{static[D]="PgBinaryVectorBuilder";constructor(t,a){super(t,"string","PgBinaryVector"),this.config.dimensions=a.dimensions}build(t){return new EO(t,this.config)}},EO=class extends ne{static[D]="PgBinaryVector";dimensions=this.config.dimensions;getSQLType(){return`bit(${this.dimensions})`}};function KZ(e,t){let{name:a,config:r}=_t(e,t);return new DO(a,r)}var MO=class extends de{static[D]="PgHalfVectorBuilder";constructor(t,a){super(t,"array","PgHalfVector"),this.config.dimensions=a.dimensions}build(t){return new OO(t,this.config)}},OO=class extends ne{static[D]="PgHalfVector";dimensions=this.config.dimensions;getSQLType(){return`halfvec(${this.dimensions})`}mapToDriverValue(t){return JSON.stringify(t)}mapFromDriverValue(t){return t.slice(1,-1).split(",").map(a=>Number.parseFloat(a))}};function WZ(e,t){let{name:a,config:r}=_t(e,t);return new MO(a,r)}var zO=class extends de{static[D]="PgSparseVectorBuilder";constructor(t,a){super(t,"string","PgSparseVector"),this.config.dimensions=a.dimensions}build(t){return new UO(t,this.config)}},UO=class extends ne{static[D]="PgSparseVector";dimensions=this.config.dimensions;getSQLType(){return`sparsevec(${this.dimensions})`}};function JZ(e,t){let{name:a,config:r}=_t(e,t);return new zO(a,r)}var jO=class extends de{static[D]="PgVectorBuilder";constructor(t,a){super(t,"array","PgVector"),this.config.dimensions=a.dimensions}build(t){return new BO(t,this.config)}},BO=class extends ne{static[D]="PgVector";dimensions=this.config.dimensions;getSQLType(){return`vector(${this.dimensions})`}mapToDriverValue(t){return JSON.stringify(t)}mapFromDriverValue(t){return t.slice(1,-1).split(",").map(a=>Number.parseFloat(a))}};function QZ(e,t){let{name:a,config:r}=_t(e,t);return new jO(a,r)}function XZ(){return{bigint:wZ,bigserial:CZ,boolean:kZ,char:IZ,cidr:LZ,customType:TZ,date:RZ,doublePrecision:_Z,inet:NZ,integer:AZ,interval:$Z,json:PZ,jsonb:l1,line:DZ,macaddr:EZ,macaddr8:MZ,numeric:OZ,point:zZ,geometry:jZ,real:BZ,serial:FZ,smallint:HZ,smallserial:VZ,text:Js,time:qZ,timestamp:u1,uuid:ZZ,varchar:GZ,bit:KZ,halfvec:WZ,sparsevec:JZ,vector:QZ}}var FO=Symbol.for("drizzle:PgInlineForeignKeys"),YZ=Symbol.for("drizzle:EnableRLS"),vx=class extends kn{static[D]="PgTable";static Symbol=Object.assign({},kn.Symbol,{InlineForeignKeys:FO,EnableRLS:YZ});[FO]=[];[YZ]=!1;[kn.Symbol.ExtraConfigBuilder]=void 0;[kn.Symbol.ExtraConfigColumns]={}};function aye(e,t,a,r,n=e){let o=new vx(e,r,n),i=typeof t=="function"?t(XZ()):t,s=Object.fromEntries(Object.entries(i).map(([d,f])=>{let m=f;m.setName(d);let p=m.build(o);return o[FO].push(...m.buildForeignKeys(p,o)),[d,p]})),l=Object.fromEntries(Object.entries(i).map(([d,f])=>{let m=f;m.setName(d);let p=m.buildExtraConfigColumn(o);return[d,p]})),c=Object.assign(o,s);return c[kn.Symbol.Columns]=s,c[kn.Symbol.ExtraConfigColumns]=l,a&&(c[vx.Symbol.ExtraConfigBuilder]=a),Object.assign(c,{enableRLS:()=>(c[vx.Symbol.EnableRLS]=!0,c)})}var eG=(e,t,a)=>aye(e,t,a,void 0);var c1=class{constructor(t,a){this.unique=t,this.name=a}static[D]="PgIndexBuilderOn";on(...t){return new yx(t.map(a=>{if(Bn(a,In))return a;a=a;let r=new rg(a.name,!!a.keyAsName,a.columnType,a.indexConfig);return a.indexConfig=JSON.parse(JSON.stringify(a.defaultConfig)),r}),this.unique,!1,this.name)}onOnly(...t){return new yx(t.map(a=>{if(Bn(a,In))return a;a=a;let r=new rg(a.name,!!a.keyAsName,a.columnType,a.indexConfig);return a.indexConfig=a.defaultConfig,r}),this.unique,!0,this.name)}using(t,...a){return new yx(a.map(r=>{if(Bn(r,In))return r;r=r;let n=new rg(r.name,!!r.keyAsName,r.columnType,r.indexConfig);return r.indexConfig=JSON.parse(JSON.stringify(r.defaultConfig)),n}),this.unique,!0,this.name,t)}},yx=class{static[D]="PgIndexBuilder";config;constructor(t,a,r,n,o="btree"){this.config={name:n,columns:t,unique:a,only:r,method:o}}concurrently(){return this.config.concurrently=!0,this}with(t){return this.config.with=t,this}where(t){return this.config.where=t,this}build(t){return new HO(this.config,t)}},HO=class{static[D]="PgIndex";config;constructor(t,a){this.config={...t,table:a}}};function tG(e){return new c1(!1,e)}function aG(e){return new c1(!0,e)}var nG=e=>u1(e,{withTimezone:!0}),rG=u.enum(["channel","dm","group","local_conversation","thread","web_session"]),Pje=eG("junior_destinations",{id:Js("id").primaryKey(),provider:Js("provider").notNull(),providerTenantId:Js("provider_tenant_id").notNull().default(""),providerDestinationId:Js("provider_destination_id").notNull(),kind:Js("kind").$type().notNull(),parentDestinationId:Js("parent_destination_id"),displayName:Js("display_name"),visibility:Js("visibility").$type().notNull().default("unknown"),metadata:l1("metadata_json"),createdAt:nG("created_at").notNull(),updatedAt:nG("updated_at").notNull()},e=>[aG("junior_destinations_provider_destination_uidx").on(e.provider,e.providerTenantId,e.providerDestinationId),tG("junior_destinations_provider_kind_idx").on(e.provider,e.kind)]);var nye=u.object({error:u.string().min(1)}).strict(),p1=u.object({closed:u.number().int().nonnegative(),costUsd:u.number().nonnegative().optional(),created:u.number().int().nonnegative(),medianCostUsd:u.number().nonnegative().optional(),medianMergeTimeMs:u.number().nonnegative().optional(),merged:u.number().int().nonnegative(),mergeRate:u.number().min(0).max(1).optional(),open:u.number().int().nonnegative()}).strict(),rye=u.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),Vl=u.object({closed:u.number().int().nonnegative(),created:u.number().int().nonnegative(),date:rye,merged:u.number().int().nonnegative()}).strict(),iG=u.object({closed:u.number().int().nonnegative(),created:u.number().int().nonnegative(),id:u.string().uuid(),medianCostUsd:u.number().nonnegative().optional(),merged:u.number().int().nonnegative(),mergeRate:u.number().min(0).max(1).optional(),name:u.string().min(1),open:u.number().int().nonnegative(),provider:u.string().min(1),url:u.string().url().optional()}).strict(),ZO=u.object({closedAt:u.string().optional(),id:u.string().uuid(),mergedAt:u.string().optional(),number:u.number().int().positive(),openedAt:u.string(),provider:u.string().min(1),repository:u.string().min(1),state:sx,title:u.string().optional(),url:u.string().url().optional()}).strict(),GO=u.object({activityDays:u.array(Vl),activityHours:u.array(Vl).optional(),activitySixHours:u.array(Vl).optional(),changes:u.array(ZO),generatedAt:u.string(),repositories:u.array(iG),summary:p1,windowEnd:u.string(),windowStart:u.string()}).strict(),oye=u.object({repositoryId:u.string().uuid()}).strict(),KO=u.object({activityDays:u.array(Vl),activityHours:u.array(Vl).optional(),activitySixHours:u.array(Vl).optional(),changes:u.array(ZO),generatedAt:u.string(),repository:u.object({id:u.string().uuid(),name:u.string().min(1),provider:u.string().min(1),url:u.string().url().optional()}).strict(),summary:p1,windowEnd:u.string(),windowStart:u.string(),workspaces:u.array(u.object({id:u.string().min(1),name:u.string().min(1)}).strict())}).strict(),WO=u.object({activityDays:u.array(Vl),activityHours:u.array(Vl).optional(),activitySixHours:u.array(Vl).optional(),generatedAt:u.string(),summary:p1,windowEnd:u.string(),windowStart:u.string()}).strict(),f1=u.object({active:u.number(),conversations:u.number(),date:u.string(),durationMs:u.number(),failed:u.number(),tokens:u.number().optional()}).strict();var iye=u.object({locationId:u.string().min(1)}).strict(),sG=pm.extend({id:u.string(),firstSeenAt:u.string(),kind:rG,lastSeenAt:u.string(),provider:u.string(),providerDestinationId:u.string(),visibility:u.literal("public")}).strict(),sye=pm.extend({actor:mm}).strict(),lye=u.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),m1=u.object({date:lye,privateConversations:u.number(),publicConversations:u.number()}).strict(),JO=u.object({activityDays:u.array(m1),activityHours:u.array(m1).optional(),activitySixHours:u.array(m1).optional(),generatedAt:u.string(),locations:u.array(sG),privateActivity:pm,source:u.literal("conversation_index"),windowEnd:u.string(),windowStart:u.string()}).strict(),QO=sG.extend({activityDays:u.array(f1),activityHours:u.array(f1).optional(),activitySixHours:u.array(f1).optional(),actors:u.array(sye),generatedAt:u.string(),recentConversations:u.array(ng),source:u.literal("conversation_index"),windowEnd:u.string(),windowStart:u.string()}).strict(),uye=u.object({email:u.string().trim().min(1)}).strict(),oG=pm.omit({costUsd:!0}),lG=u.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),VO=u.object({active:u.number(),conversations:u.number(),costUsd:u.number().optional(),date:lG,durationMs:u.number(),failed:u.number(),tokens:u.number().optional()}).strict(),qO=u.object({activePeople:u.number(),conversations:u.number(),date:lG}).strict(),uG=u.object({active:u.number(),activeDays:u.number(),conversations:u.number(),durationMs:u.number(),failed:u.number(),tokens:u.number().optional()}).strict(),d1=u.object({conversations:u.number().int().nonnegative(),costUsd:u.number().finite().nonnegative(),durationMs:u.number().finite().nonnegative(),priorCostUsd:u.number().finite().nonnegative()}).strict(),cye=u.object({1:d1,7:d1,30:d1,90:d1}).strict(),cG=mm.extend({email:u.string().min(1)}).strict(),dye=uG.extend({firstSeenAt:u.string(),lastSeenAt:u.string(),actor:cG,windows:cye}).strict(),XO=u.object({activityDays:u.array(qO),activityHours:u.array(qO).optional(),activitySixHours:u.array(qO).optional(),generatedAt:u.string(),people:u.array(dye),source:u.literal("conversation_index"),windowEnd:u.string(),windowStart:u.string()}).strict(),YO=u.object({activityDays:u.array(VO),activityHours:u.array(VO).optional(),activitySixHours:u.array(VO).optional(),generatedAt:u.string(),locations:u.array(oG),recentConversations:u.array(ng),actor:cG,source:u.literal("conversation_index"),surfaces:u.array(oG),totals:uG,windowEnd:u.string(),windowStart:u.string()}).strict(),ez=u.object({generatedAt:u.string(),sevenDaysUsd:u.number().finite().nonnegative(),source:u.literal("conversation_index"),thirtyDaysUsd:u.number().finite().nonnegative(),windowEnd:u.string(),windowStart:u.string()}).strict(),tz=u.object({id:u.string().uuid(),name:u.string(),tokenSuffix:u.string(),createdAt:u.string().datetime(),expiresAt:u.string().datetime(),lastUsedAt:u.string().datetime().nullable()}).strict(),az=u.object({tokens:u.array(tz)}).strict(),fye=u.object({name:u.string().trim().min(1).max(80)}).strict(),nz=tz.extend({token:u.string().startsWith("jr_pat_")}).strict(),mye=u.object({id:u.string().uuid()}).strict(),pye=u.object({revoked:u.literal(!0)}).strict(),hye=u.object({provider:u.string(),repo:u.string()}).strict(),dG=u.object({provider:u.string(),repo:u.string(),checkoutPath:u.string()}).strict(),gye=u.object({id:u.string(),generatedAt:u.iso.datetime(),buildDurationMs:u.number().int().nonnegative(),sizeBytes:u.number().int().nonnegative().nullable()}).strict(),fG=u.object({id:u.string(),generatedAt:u.iso.datetime(),buildDurationMs:u.number().int().nonnegative(),dependencyCount:u.number().int().nonnegative()}).strict(),lg=u.object({id:u.string().uuid(),name:u.string(),setupScript:u.string(),repos:u.array(dG),snapshot:gye.nullable()}).strict(),rz=u.object({baselineSnapshot:fG.nullable(),workspaces:u.array(lg)}).strict(),vye=u.object({name:u.string(),setupScript:u.string().optional(),repos:u.array(hye)}).strict(),yye=u.object({id:u.string().uuid()}).strict(),bye=u.object({deleted:u.literal(!0)}).strict(),mG=u.object({count:u.number().int().nonnegative(),date:u.string(),metric:u.string().min(1),name:u.string().min(1),namespace:u.string().min(1)}).strict(),oz=u.object({generatedAt:u.string().datetime(),stats:u.array(mG),windowEnd:u.string(),windowStart:u.string()}).strict();var So=u.string().trim().min(1).max(160),ug=u.number().int().nonnegative(),xye=u.discriminatedUnion("type",[u.strictObject({type:u.literal("code_change"),author:So.optional(),sourceBranch:So.optional(),targetBranch:So.optional(),reviewers:u.array(So).max(5).optional(),review:u.enum(["required","approved","changes_requested"]).optional(),checks:u.strictObject({passed:ug,failed:ug,pending:ug}).optional(),mergeable:u.boolean().optional(),changedFiles:ug.optional(),additions:ug.optional(),deletions:ug.optional()}),u.strictObject({type:u.literal("task"),assignees:u.array(So).max(5).optional(),priority:So.optional(),project:So.optional(),cycle:So.optional(),dueDate:u.iso.date().optional(),labels:u.array(So).max(5).optional()}),u.strictObject({type:u.literal("deployment"),project:So.optional(),environment:So.optional(),revision:So.optional(),branch:So.optional()}),u.strictObject({type:u.literal("calendar_event"),when:So.optional(),attendees:u.array(So).max(5).optional()})]);function hG(e){if(!e)return[];let t=[],a=n=>n?.length?`${n.join(", ")}${n.length===5?" (up to 5 shown)":""}`:void 0;function r(n,o,i){i!==void 0&&i!==""&&t.push({key:n,label:o,value:String(i)})}switch(e.type){case"code_change":r("sourceBranch","Branch",e.sourceBranch);break;case"task":r("assignees","Assignees",e.assignees?.length===0?"Unassigned":a(e.assignees)),r("priority","Priority",e.priority),r("project","Project",e.project),r("cycle","Cycle",e.cycle),r("dueDate","Due",e.dueDate),r("labels","Labels",a(e.labels));break;case"deployment":r("environment","Environment",e.environment),r("project","Project",e.project),r("revision","Revision",e.revision),r("branch","Branch",e.branch);break;case"calendar_event":r("when","When",e.when),r("attendees","Attendees",a(e.attendees));break}return t.slice(0,4)}var g1=u.enum(["task","code_change","automation","deployment","calendar_event","item"]),Sye={task:"Ticket",code_change:"Code change",automation:"Automation",deployment:"Deployment",calendar_event:"Calendar event",item:"Item"};function fs(e){let t=e.objectType==="item"&&e.facts?.type==="deployment"?"deployment":e.objectType,a=e.status?.toLowerCase(),r={task:"issue-opened",code_change:"git-pull-request",automation:"workflow",deployment:"rocket",calendar_event:"calendar",item:"package"}[t],n=t==="automation"?"info":"neutral";return t==="code_change"?(a==="draft"&&(r="git-pull-request-draft"),a==="closed"&&(r="git-pull-request-closed",n="danger"),a==="merged"&&(r="git-merge",n="accent"),a==="open"&&(n="success")):t==="task"?(a==="closed"&&(r="issue-closed",n="accent"),a==="open"&&(n="success")):t==="deployment"&&((a==="ready"||a==="succeeded")&&(n="success"),(a==="error"||a==="failed")&&(n="danger"),(a==="building"||a==="in_progress")&&(n="info")),(a==="warning"||a==="blocked")&&(n="warning"),{icon:r,tone:n,label:Sye[t]}}function gG(e){return`/_junior/dashboard/object-icons/v1/${e}.png`}var sz=u.object({kind:u.literal("object"),key:u.string().trim().min(1).max(256),label:u.string().trim().min(1).max(256),objectType:g1,title:u.string().trim().min(1).max(512),url:u.url().max(2048).refine(e=>["http:","https:"].includes(new URL(e).protocol)).nullable(),description:u.string().max(4e3).optional(),status:u.string().trim().min(1).max(100).optional(),trigger:u.string().max(4e3).optional(),warning:u.string().max(1e3).optional(),displayType:u.string().trim().min(1).max(80).optional(),sourceUpdatedAt:u.iso.datetime({offset:!0}).optional(),facts:xye.refine(e=>new TextEncoder().encode(JSON.stringify(e)).length<=4096,"Object facts must not exceed 4 KiB").optional()}).strict().refine(e=>!e.facts||(e.facts.type==="deployment"?e.objectType==="deployment"||e.objectType==="item":e.facts.type===e.objectType),"Object facts must match the object type"),eBe=sz.safeExtend({plugin:u.string().min(1)}),vG={"issue-opened":["M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z","M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Z"],"issue-closed":["M11.28 6.78a.75.75 0 0 0-1.06-1.06L7.25 8.69 5.78 7.22a.75.75 0 0 0-1.06 1.06l2 2a.75.75 0 0 0 1.06 0l3.5-3.5Z","M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0Zm-1.5 0a6.5 6.5 0 1 0-13 0 6.5 6.5 0 0 0 13 0Z"],"git-pull-request":["M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z"],"git-pull-request-draft":["M3.25 1A2.25 2.25 0 0 1 4 5.372v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.251 2.251 0 0 1 3.25 1Zm9.5 14a2.25 2.25 0 1 1 0-4.5 2.25 2.25 0 0 1 0 4.5ZM2.5 3.25a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0ZM3.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm9.5 0a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM14 7.5a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Zm0-4.25a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Z"],"git-pull-request-closed":["M3.25 1A2.25 2.25 0 0 1 4 5.372v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.251 2.251 0 0 1 3.25 1Zm9.5 5.5a.75.75 0 0 1 .75.75v3.378a2.251 2.251 0 1 1-1.5 0V7.25a.75.75 0 0 1 .75-.75Zm-2.03-5.273a.75.75 0 0 1 1.06 0l.97.97.97-.97a.748.748 0 0 1 1.265.332.75.75 0 0 1-.205.729l-.97.97.97.97a.751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018l-.97-.97-.97.97a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734l.97-.97-.97-.97a.75.75 0 0 1 0-1.06ZM2.5 3.25a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0ZM3.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm9.5 0a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"],"git-merge":["M5.45 5.154A4.25 4.25 0 0 0 9.25 7.5h1.378a2.251 2.251 0 1 1 0 1.5H9.25A5.734 5.734 0 0 1 5 7.123v3.505a2.25 2.25 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.95-.218ZM4.25 13.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm8.5-4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5ZM5 3.25a.75.75 0 1 0 0 .005V3.25Z"],workflow:["M0 1.75C0 .784.784 0 1.75 0h3.5C6.216 0 7 .784 7 1.75v3.5A1.75 1.75 0 0 1 5.25 7H4v4a1 1 0 0 0 1 1h4v-1.25C9 9.784 9.784 9 10.75 9h3.5c.966 0 1.75.784 1.75 1.75v3.5A1.75 1.75 0 0 1 14.25 16h-3.5A1.75 1.75 0 0 1 9 14.25v-.75H5A2.5 2.5 0 0 1 2.5 11V7h-.75A1.75 1.75 0 0 1 0 5.25Zm1.75-.25a.25.25 0 0 0-.25.25v3.5c0 .138.112.25.25.25h3.5a.25.25 0 0 0 .25-.25v-3.5a.25.25 0 0 0-.25-.25Zm9 9a.25.25 0 0 0-.25.25v3.5c0 .138.112.25.25.25h3.5a.25.25 0 0 0 .25-.25v-3.5a.25.25 0 0 0-.25-.25Z"],rocket:["M14.064 0h.186C15.216 0 16 .784 16 1.75v.186a8.752 8.752 0 0 1-2.564 6.186l-.458.459c-.314.314-.641.616-.979.904v3.207c0 .608-.315 1.172-.833 1.49l-2.774 1.707a.749.749 0 0 1-1.11-.418l-.954-3.102a1.214 1.214 0 0 1-.145-.125L3.754 9.816a1.218 1.218 0 0 1-.124-.145L.528 8.717a.749.749 0 0 1-.418-1.11l1.71-2.774A1.748 1.748 0 0 1 3.31 4h3.204c.288-.338.59-.665.904-.979l.459-.458A8.749 8.749 0 0 1 14.064 0ZM8.938 3.623h-.002l-.458.458c-.76.76-1.437 1.598-2.02 2.5l-1.5 2.317 2.143 2.143 2.317-1.5c.902-.583 1.74-1.26 2.499-2.02l.459-.458a7.25 7.25 0 0 0 2.123-5.127V1.75a.25.25 0 0 0-.25-.25h-.186a7.249 7.249 0 0 0-5.125 2.123ZM3.56 14.56c-.732.732-2.334 1.045-3.005 1.148a.234.234 0 0 1-.201-.064.234.234 0 0 1-.064-.201c.103-.671.416-2.273 1.15-3.003a1.502 1.502 0 1 1 2.12 2.12Zm6.94-3.935c-.088.06-.177.118-.266.175l-2.35 1.521.548 1.783 1.949-1.2a.25.25 0 0 0 .119-.213ZM3.678 8.116 5.2 5.766c.058-.09.117-.178.176-.266H3.309a.25.25 0 0 0-.213.119l-1.2 1.95ZM12 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"],calendar:["M4.75 0a.75.75 0 0 1 .75.75V2h5V.75a.75.75 0 0 1 1.5 0V2h1.25c.966 0 1.75.784 1.75 1.75v10.5A1.75 1.75 0 0 1 13.25 16H2.75A1.75 1.75 0 0 1 1 14.25V3.75C1 2.784 1.784 2 2.75 2H4V.75A.75.75 0 0 1 4.75 0ZM2.5 7.5v6.75c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25V7.5Zm10.75-4H2.75a.25.25 0 0 0-.25.25V6h11V3.75a.25.25 0 0 0-.25-.25Z"],package:["m8.878.392 5.25 3.045c.54.314.872.89.872 1.514v6.098a1.75 1.75 0 0 1-.872 1.514l-5.25 3.045a1.75 1.75 0 0 1-1.756 0l-5.25-3.045A1.75 1.75 0 0 1 1 11.049V4.951c0-.624.332-1.201.872-1.514L7.122.392a1.75 1.75 0 0 1 1.756 0ZM7.875 1.69l-4.63 2.685L8 7.133l4.755-2.758-4.63-2.685a.248.248 0 0 0-.25 0ZM2.5 5.677v5.372c0 .09.047.171.125.216l4.625 2.683V8.432Zm6.25 8.271 4.625-2.683a.25.25 0 0 0 .125-.216V5.677L8.75 8.432Z"]};function wye(e){try{let t=new URL(e).protocol;return t==="http:"||t==="https:"}catch{return!1}}var Cye=u.object({kind:u.literal("resource_link"),objectType:g1.optional(),key:u.string().trim().min(1).max(256),label:u.string().trim().min(1).max(256),url:u.string().url().max(2048).refine(wye,"URL must use HTTP or HTTPS."),description:u.string().trim().min(1).max(512).optional(),status:u.enum(["open","draft","closed","merged","warning"]).optional()}).strict(),aBe=u.discriminatedUnion("kind",[Cye,sz]),kye=u.enum(["circle-dot","circle-dashed","circle-x","git-merge","git-pull-request","triangle-alert"]),nBe=u.object({icon:kye.optional(),objectType:g1.optional(),status:u.string().trim().min(1).max(100).optional(),key:u.string().trim().min(1).max(256),label:u.string().trim().min(1).max(256)}).strict(),Iye=u.enum(["closed","merged","open"]),oBe=u.object({closedAt:u.date().optional(),conversationIds:u.array(u.string().min(1)).default([]),mergedAt:u.date().optional(),number:u.number().int().positive(),openedAt:u.date(),providerId:u.string().min(1),repository:u.object({name:u.string().min(1),providerId:u.string().min(1),url:u.string().url().optional()}).strict(),state:Iye,title:u.string().min(1).optional(),updatedAt:u.date(),url:u.string().url().optional()}).strict(),sBe=u.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_]*$/),Lye=u.enum(["activity","brain","calendar","check","database","info","key","link","sparkles","warning"]),Tye=u.object({content:u.string().min(1).max(32*1024).optional(),description:u.string().trim().min(1).max(2e3).optional(),metadata:u.array(u.string().trim().min(1).max(120)).max(8).optional(),title:u.string().trim().min(1).max(4e3)}).strict(),lBe=u.object({details:u.array(Tye).max(100).optional(),icon:Lye.optional(),preview:u.string().trim().min(1).max(500).optional(),title:u.string().trim().min(1).max(120)}).strict();var v1=u.string().regex(/^T[A-Z0-9]+$/),lz=u.string().regex(/^(C|G|D)[A-Z0-9]+$/),yG=u.string().regex(/^local:[a-z0-9_-]+:[a-z0-9][a-z0-9_-]*$/),Rye=u.string().min(1).refine(e=>e===e.trim()&&e.toLowerCase()!=="unknown"),h1=Rye,Be=u.string().refine(e=>e.trim().length>0),Xr=Be.refine(e=>e===e.trim()),_ye=u.object({id:Be,provider:Xr}).strict(),Nye=_ye.extend({provider:u.literal("slack"),teamId:v1,channelId:lz,threadTs:Xr.optional()}).strict(),cBe=u.discriminatedUnion("provider",[Nye]),dBe=u.enum(["slack","local"]),bG=u.enum(["public","private"]),Aye=u.enum(["public","private"]),$ye=u.object({platform:u.literal("slack"),teamId:v1,channelId:lz,threadTs:Xr.optional()}).strict(),uz=$ye,Pye=u.object({platform:u.literal("local"),conversationId:yG}).strict(),Dye=u.discriminatedUnion("platform",[uz,Pye]),fBe=u.object({action:u.literal("send_message"),destination:uz}).strict(),Eye=u.object({kind:u.literal("slack"),teamId:v1,channelId:lz,visibility:bG,messageTs:Be.optional(),threadTs:Be.optional()}).strict(),Mye=u.object({kind:u.literal("local"),visibility:u.literal("private"),conversationId:yG}).strict(),Oye=u.object({kind:u.literal("web"),visibility:bG,conversationId:Xr}).strict(),zye=u.object({kind:u.literal("event"),eventKey:Xr,eventType:Xr,identifier:Xr,namespace:Xr}).strict(),Uye=u.object({kind:u.literal("scheduled_automation")}).strict(),jye=u.object({kind:u.literal("event_automation")}).strict(),Bye=u.object({kind:u.literal("plugin_dispatch")}).strict(),Fye=u.object({kind:u.literal("agent_invocation")}).strict(),Hye=u.discriminatedUnion("kind",[Eye,Mye,Oye,zye,Uye,jye,Bye,Fye]);function Vye(e){if(!e||typeof e!="object"||Array.isArray(e))return e;let t=e;if("kind"in t){let o={event_task:"event_automation",resource_event:"event",scheduled_task:"scheduled_automation"},i=typeof t.kind=="string"?o[t.kind]:void 0;return i?{...t,kind:i}:e}if(t.platform!=="slack"&&t.platform!=="local"&&t.platform!=="web")return e;let{location:a,platform:r,...n}=t;return{...n,kind:r}}var qye=u.preprocess(Vye,Hye),Zye=u.discriminatedUnion("allowedWhen",[u.object({type:u.literal("user"),userId:h1,allowedWhen:u.literal("private-direct-conversation")}).strict(),u.object({type:u.literal("user"),userId:h1,allowedWhen:u.literal("scheduled-automation"),taskId:Xr}).strict()]),cz={email:Be.optional(),fullName:Be.optional(),userId:h1,userName:Be.optional()},Gye=u.object({...cz,platform:u.literal("slack"),teamId:v1}).strict(),Kye=u.object({...cz,platform:u.literal("local")}).strict(),Wye=u.object({...cz,platform:u.literal("web")}).strict(),Jye=u.object({platform:u.literal("system"),name:h1}).strict(),iz=u.discriminatedUnion("platform",[Gye,Kye,Wye,Jye]),Qye=u.object({displayName:Be.optional(),handle:Be.optional(),id:Xr,provider:Xr,providerSubjectId:Xr,providerTenantId:Xr.optional()}).strict(),mBe=u.object({displayName:Be.optional(),email:Be.max(320),id:Xr,identities:u.array(Qye).max(100),isAdmin:u.literal(!0).optional()}).strict(),Xye=u.record(u.string(),u.string()).superRefine((e,t)=>{let a=Object.entries(e);if(a.length>20){t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata has too many keys"});return}for(let[r,n]of a){if(!r.trim()){t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata values must be strings",path:[r]});continue}r.length>128&&t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata key exceeds the maximum length",path:[r]}),/[\r\n]/.test(r)&&t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata keys must be single-line strings",path:[r]}),/[\r\n]/.test(n)&&t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata values must be single-line strings",path:[r]}),n.length>512&&t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata value exceeds the maximum length",path:[r]})}}),Yye=u.object({label:Xr.pipe(u.string().max(48)).refine(e=>!/[\r\n]/.test(e)),detail:Xr.pipe(u.string().max(128)).refine(e=>!/[\r\n]/.test(e)).optional()}).strict(),pBe=u.object({idempotencyKey:Be.pipe(u.string().max(512)),credentialSubject:Zye.optional(),destination:uz,destinationVisibility:Aye,input:Be.pipe(u.string().max(32e3)),metadata:Xye.optional(),replyAttribution:Yye.optional()}).strict();var ebe=u.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_-]*$/),gBe=u.object({text:u.string().trim().min(1).max(8e3)}).strict(),vBe=u.object({kind:ebe,version:u.number().int().positive(),content:u.record(u.string(),u.unknown())}).strict();var tbe=4e3,abe=8e3,cg=32,pG=4e3,nbe=1e3,rbe=u.record(u.string(),u.unknown()).superRefine((e,t)=>{Object.keys(e).length>cg&&t.addIssue({code:"custom",message:`Event data may include at most ${cg} keys.`}),new TextEncoder().encode(JSON.stringify(e)).byteLength>pG&&t.addIssue({code:"custom",message:`Event data may be at most ${pG} JSON bytes.`})}),gm=u.string().regex(/^[a-z][a-z0-9_-]*(?:\.[a-z][a-z0-9_-]*)+$/).describe("Canonical dotted event type, such as issue.closed or pull_request.review.changes_requested."),xG=u.string().regex(/^[a-z][a-z0-9_]*$/).describe("Canonical plugin-defined resource type, such as issue or pull_request."),SG=/^[a-z][a-zA-Z0-9]*$/,obe=u.object({kind:u.enum(["boolean","string","number"]),description:u.string().trim().min(1).max(200),enum:u.array(u.string().min(1)).min(1).optional()}).strict().superRefine((e,t)=>{e.enum&&e.kind!=="string"&&t.addIssue({code:"custom",message:'Event match field enum requires kind "string".',path:["enum"]})}),ibe=u.record(u.string().regex(SG),obe).superRefine((e,t)=>{Object.keys(e).length>cg&&t.addIssue({code:"custom",message:`Event match keys may include at most ${cg} keys.`})}),bBe=u.record(u.string().regex(SG),u.union([u.boolean(),u.number().finite(),u.string().min(1),u.array(u.union([u.number().finite(),u.string().min(1)])).min(1)])).superRefine((e,t)=>{Object.keys(e).length>cg&&t.addIssue({code:"custom",message:`Event match may include at most ${cg} keys.`});for(let[a,r]of Object.entries(e))Array.isArray(r)&&r.some(n=>typeof n=="boolean")&&t.addIssue({code:"custom",message:`Event match field "${a}" cannot use a boolean list.`,path:[a]})});var sbe=u.object({format:u.string().trim().min(1).max(200),pattern:u.instanceof(RegExp)}).strict(),lbe=u.object({type:xG,identifier:sbe.optional(),supportedEvents:u.array(gm).min(1),suggestedEvents:u.array(gm).optional(),matchFields:ibe.optional(),guidance:u.record(gm,u.string().trim().min(1).max(nbe)).optional()}).strict().superRefine((e,t)=>{let a=new Set;e.supportedEvents.forEach((n,o)=>{a.has(n)&&t.addIssue({code:"custom",message:`Duplicate supported event type "${n}".`,path:["supportedEvents",o]}),a.add(n)});for(let n of Object.keys(e.guidance??{}))a.has(n)||t.addIssue({code:"custom",message:`Guidance event type "${n}" is not supported.`,path:["guidance",n]});let r=new Set;e.suggestedEvents?.forEach((n,o)=>{r.has(n)&&t.addIssue({code:"custom",message:`Duplicate suggested event type "${n}".`,path:["suggestedEvents",o]}),a.has(n)||t.addIssue({code:"custom",message:`Suggested event type "${n}" is not supported.`,path:["suggestedEvents",o]}),r.add(n)})}),xBe=u.object({resourceTypes:u.array(lbe).min(1),isEnabled:u.function({input:[],output:u.boolean()}).optional(),normalizeIdentifier:u.function({input:[u.string()],output:u.string()}).optional()}).strict().superRefine((e,t)=>{let a=new Set;e.resourceTypes.forEach((r,n)=>{a.has(r.type)&&t.addIssue({code:"custom",message:`Duplicate resource type "${r.type}".`,path:["resourceTypes",n,"type"]}),a.add(r.type)})});var SBe=u.object({identifier:u.string().min(1),label:u.string().min(1),namespace:u.string().min(1),suggestedEvents:u.array(gm).optional(),supportedEvents:u.array(gm),type:xG}).strict(),wBe=u.object({events:u.array(gm).min(1),id:u.string().min(1)}).strict(),ube=u.object({objectType:g1.optional(),eventKey:u.string().min(1),eventType:gm,identifier:u.string().min(1),occurredAtMs:u.number().finite(),terminal:u.boolean().optional(),trustedSummary:u.string().min(1).transform(e=>e.slice(0,tbe)),data:rbe.optional(),untrustedText:u.string().transform(e=>e.slice(0,abe)).optional()}).strict(),CBe=ube.extend({namespace:u.string().min(1)}),cbe=u.object({authority:u.enum(["instruction","context"]),actor:iz.optional()}).strict(),dbe=u.discriminatedUnion("type",[u.object({type:u.literal("message"),role:u.enum(["user","assistant"]),text:u.string().min(1),provenance:cbe.optional(),isRunActor:u.boolean().optional()}).strict(),u.object({type:u.literal("toolResult"),toolName:u.string().min(1),isError:u.boolean(),text:u.string().min(1).optional()}).strict()]),IBe=u.object({actorUserId:u.string().min(1).optional(),completedAtMs:u.number().finite(),conversationId:u.string().min(1),destination:Dye,locationId:u.string().min(1).optional(),actors:u.array(iz),actor:iz.optional(),runId:u.string().min(1),source:qye,transcript:u.array(dbe)}).strict();var TBe=u.discriminatedUnion("type",[u.object({type:u.literal("text"),text:u.string()}).strict(),u.object({type:u.literal("image"),data:u.string(),mimeType:u.string()}).strict()]),fbe=u.object({arguments:u.record(u.string(),u.unknown()),reason:u.string().min(1).optional()}).strict(),RBe=u.object({objectAnnotations:u.array(sz).optional(),target:u.string().min(1).optional(),truncated:u.boolean().optional(),continuation:fbe.optional()}).passthrough(),_Be=u.enum(["auto","review","approve"]);var ABe=u.object({auth:u.object({user:u.object({email:u.string().nullable().optional(),emailVerified:u.boolean().optional(),isAdmin:u.boolean(),name:u.string().nullable().optional()}).strict()}).strict(),pluginName:Be}).strict(),mbe=u.string().regex(/^[a-z][a-z0-9-]*$/),pbe=u.string().regex(/^[a-z][a-z0-9.-]*$/),hbe=u.union([u.literal("read"),u.literal("write")]),wG=u.object({provider:mbe,scope:Be.optional(),type:u.literal("oauth")}).strict(),CG=u.object({displayName:Be.optional(),handle:Be.optional(),id:Be,label:Be.optional(),url:Be.optional()}).strict(),PBe=u.object({account:CG.optional(),accessToken:Be,expiresAt:u.number().finite().optional(),refreshToken:Be,refreshTokenExpiresAt:u.number().finite().optional(),scope:Be.optional()}).strict(),DBe=u.object({access:hbe,leaseScope:Be.optional(),name:pbe,reason:Be.optional(),requirements:u.array(Be).min(1).optional()}).strict(),gbe=u.object({domain:u.string().min(1),headers:u.record(u.string(),u.string()).refine(e=>Object.keys(e).length>0)}).strict(),vbe=u.object({account:CG.optional(),authorization:wG.optional(),expiresAt:u.string().refine(e=>Number.isFinite(Date.parse(e))),headerTransforms:u.array(gbe).min(1)}).strict(),EBe=u.discriminatedUnion("type",[u.object({lease:vbe,type:u.literal("lease")}).strict(),u.object({authorization:wG.optional(),message:Be,type:u.literal("needed")}).strict(),u.object({message:Be,type:u.literal("unavailable")}).strict()]);var ybe=Be.max(64).regex(/^[a-z][a-z0-9-]*$/),bbe=Be.max(80),xbe=Be.max(500),Sbe=u.enum(["primary","profile","admin"]),wbe=u.object({detail:Be.max(500).optional(),label:Be.max(80),tone:u.enum(["good","neutral","warning"]).optional(),value:Be.max(120)}).strict(),Cbe=u.object({label:Be.max(80),value:Be.max(500)}).strict(),kbe=u.object({confirmation:Be.max(500).optional(),href:Be.max(500).regex(/^\/api\/plugins\/[a-z][a-z0-9-]*(?:\/|$)/),label:Be.max(80),method:u.enum(["DELETE","GET"]),tone:u.enum(["danger","neutral"]).optional()}).strict(),Ibe=u.object({actions:u.array(kbe).max(4).optional(),description:Be.max(1e3).optional(),id:Be.max(128),metadata:u.array(Cbe).max(8).optional(),title:Be.max(4e3)}).strict(),kG=u.object({emptyText:Be.max(500).optional(),metrics:u.array(wbe).max(6).optional(),nextCursor:Be.max(1e3).optional(),records:u.array(Ibe).max(100),searchPlaceholder:Be.max(120).optional(),type:u.literal("list")}).strict(),Lbe=u.object({description:xbe,id:ybe,label:bbe,navigation:Sbe,pluginDisplayName:Be.max(200),pluginName:Be.max(100)}).strict(),IG=u.array(Lbe),Tbe=Be.max(1e3).optional(),Rbe=Be.max(64).optional(),_be=u.string().trim().max(200).optional(),OBe=u.object({cursor:Tbe,filter:Rbe,limit:u.number().int().min(1).max(50),query:_be}).strict();var LG=u.object({email:u.string().trim().email(),emailVerified:u.boolean().optional(),name:u.string().nullable().optional()}).strict(),jBe=u.object({user:LG}).strict(),y1=u.object({user:LG.extend({isAdmin:u.boolean()}).strict()}).strict(),BBe=u.object({displayName:u.string().trim().min(1).max(80)}).strict(),TG=u.object({allowedEmailCount:u.number(),allowedGoogleDomainCount:u.number(),authRequired:u.boolean(),authPath:u.string(),basePath:u.string(),componentGallery:u.boolean(),sentryConversationLinks:u.boolean(),timeZone:u.string().optional(),version:u.string().min(1)}).strict();var bx=b(G(),1);var RG="x-junior-version";var dz="junior:dashboard-version";function _G(e){let t=e.headers.get(RG)?.trim();!t||typeof window>"u"||window.dispatchEvent(new CustomEvent(dz,{detail:t}))}function NG(e){let[t,a]=(0,bx.useState)(e);return(0,bx.useEffect)(()=>{e&&a(e)},[e]),(0,bx.useEffect)(()=>{let r=n=>{a(n.detail)};return window.addEventListener(dz,r),()=>window.removeEventListener(dz,r)},[]),t}var yn=class extends Error{status;fields;code;apiError;constructor(t,a,r,n){super(`${t} returned ${a}`),this.status=a,this.fields=n?.fields,this.code=n?.code,r?.trim()&&(this.apiError=r.trim())}};async function dg(e,t){let a,r,n;try{let o=await t.json();typeof o.error=="string"&&(a=o.error),typeof o.code=="string"&&(n=o.code),o.fields&&typeof o.fields=="object"&&(r=Object.fromEntries(Object.entries(o.fields).filter(i=>Array.isArray(i[1])&&i[1].every(s=>typeof s=="string"))))}catch{}throw new yn(e,t.status,a,{fields:r,code:n})}function fg(){if(typeof window>"u")return;let e=window.__JUNIOR_DASHBOARD_BASE_PATH__??"/",t=e==="/"?"/auth/login":`${e}/auth/login`;if(window.location.pathname!==t){let a=`${window.location.pathname}${window.location.search||""}`,r=new URLSearchParams;a!=="/"&&r.set("next",a);let n=r.toString();window.location.assign(n?`${t}?${n}`:t)}}async function mg(e,t,a){let r=await pg(t,{body:JSON.stringify(a),credentials:"same-origin",headers:{"content-type":"application/json"},method:"PATCH"});return r.status===401&&fg(),r.ok||await dg(t,r),e.parse(await r.json())}async function wo(e,t,a){let r=await pg(t,{body:JSON.stringify(a),credentials:"same-origin",headers:{"content-type":"application/json"},method:"POST"});return r.status===401&&fg(),r.ok||await dg(t,r),e.parse(await r.json())}async function AG(e,t,a){let r=await pg(t,{body:JSON.stringify(a),credentials:"same-origin",headers:{"content-type":"application/json"},method:"PUT"});return r.status===401&&fg(),r.ok||await dg(t,r),e.parse(await r.json())}async function Rd(e){let t=await pg(e,{credentials:"same-origin",method:"DELETE"});t.status===401&&fg(),t.ok||await dg(e,t)}async function $G(e,t,a={}){let r=await pg(t,{body:JSON.stringify(a),credentials:"same-origin",headers:{"content-type":"application/json"},method:"DELETE"});return r.status===401&&fg(),r.ok||await dg(t,r),e.parse(await r.json())}async function pg(e,t){let a=await fetch(e,t);return _G(a),a}async function Ne(e,t,a){let r=await fz(t,a);return e.parse(await r.json())}async function fz(e,t,a){let r=await pg(e,{credentials:"same-origin",...t?{signal:t}:void 0,...a?{cache:"no-store",headers:{"if-none-match":a}}:void 0});return r.status===401&&fg(),!r.ok&&!(a&&r.status===304)&&await dg(e,r),r}var b1=5*6e4,mz=5*6e4,Nbe=1e3;function Abe(e,t=Date.now()){if(!e)return mz;let a=Date.parse(e);if(!Number.isFinite(a))return mz;let r=Math.max(0,t-a);return Math.max(Nbe,mz-r)}function PG(){return Ue({queryKey:["dashboard","core"],queryFn:async({signal:e})=>{let[t,a]=await Promise.all([Ne(y1,"/api/me",e),Ne(TG,"/api/config",e)]);return{config:a,me:t}},retry:!1,staleTime:b1})}function $be(){return Ue({queryKey:["dashboard","plugins"],queryFn:({signal:e})=>Ne(ZE,"/api/plugins",e),retry:!1,staleTime:b1})}function DG(){return Ue({queryKey:["dashboard","plugin-user-pages"],queryFn:({signal:e})=>Ne(IG,"/api/user-pages",e),retry:!1,staleTime:b1})}function x1(e=""){return Ue({queryKey:["dashboard","conversations","viewer",{search:e}],queryFn:({signal:t})=>Ne(Yk,`/api/conversations${e?`?q=${encodeURIComponent(e)}`:""}`,t),placeholderData:pf,retry:!1})}function EG(){return Ue({queryKey:["dashboard","code"],queryFn:({signal:e})=>Ne(GO,"/api/code",e),retry:!1})}function MG(e){return Ue({enabled:!!e,queryKey:["dashboard","code","repositories",e],queryFn:({signal:t})=>Ne(KO,`/api/code/repositories/${encodeURIComponent(e)}`,t),retry:!1})}function S1(e,t=""){return Ue({enabled:!!e,queryKey:["dashboard","conversations","code-repository",{repositoryId:e,search:t}],queryFn:({signal:a})=>{let r=new URLSearchParams({codeRepositoryId:e});return t&&r.set("q",t),Ne(Yk,`/api/conversations?${r.toString()}`,a)},placeholderData:pf,retry:!1})}function OG(e,t){return Ue({enabled:e,queryKey:["dashboard","automations",t],queryFn:({signal:a})=>Ne(OE,`/api/automations${t?`?${t}`:""}`,a),placeholderData:pf,retry:!1})}function hg(e,t){return Ue({enabled:e&&!!t,queryKey:["dashboard","automations","detail",t],queryFn:({signal:a})=>Ne(mx,`/api/automations/${encodeURIComponent(t)}`,a),retry:!1})}function zG(e){return Ue({enabled:e,queryKey:["dashboard","automations","runs"],queryFn:({signal:t})=>Ne(jE,"/api/automations/runs",t),retry:!1})}function UG(e,t,a){return Ue({enabled:e&&!!(t&&a),queryKey:["dashboard","automations",t,a,"executions"],queryFn:({signal:r})=>Ne(UE,`/api/automations/${t}/${encodeURIComponent(a)}/executions`,r),retry:!1})}function jG(e,t,a){return Ue({enabled:e&&!!(t&&a),queryKey:["dashboard","automations",t,a,"versions"],queryFn:({signal:r})=>Ne(BE,`/api/automations/${t}/${encodeURIComponent(a)}/versions`,r),retry:!1})}function BG(){return Ue({queryKey:["dashboard","people"],queryFn:({signal:e})=>Ne(XO,"/api/people",e),retry:!1})}function FG(e){return Ue({enabled:!!e,queryKey:["dashboard","people",e],queryFn:async({signal:t})=>Ne(YO,`/api/people/${encodeURIComponent(e)}`,t),retry:!1})}function HG(e){return Ue({enabled:!!e,queryKey:["dashboard","people",e,"plugin-reports"],queryFn:({signal:t})=>Ne(n1,`/api/people/${encodeURIComponent(e)}/plugin-reports`,t),retry:!1})}function VG(e){return Ue({enabled:!!e,queryKey:["dashboard","people",e,"code"],queryFn:({signal:t})=>Ne(WO,`/api/people/${encodeURIComponent(e)}/code`,t),retry:!1})}function qG(e){return Ue({enabled:e,queryKey:["dashboard","personal-spend"],queryFn:({signal:t})=>Ne(ez,"/api/people/me/spend",t),refetchInterval:t=>Abe(t.state.data?.generatedAt),retry:!1,staleTime:0})}function ZG(){return Ue({queryKey:["dashboard","locations"],queryFn:({signal:e})=>Ne(JO,"/api/locations",e),retry:!1})}function GG(e){return Ue({enabled:!!e,queryKey:["dashboard","locations",e],queryFn:async({signal:t})=>Ne(QO,`/api/locations/${encodeURIComponent(e)}`,t),retry:!1})}function Pbe(){return Ue({queryKey:["dashboard","skills"],queryFn:({signal:e})=>Ne(KE,"/api/skills",e),retry:!1,staleTime:b1})}function Dbe(){return Ue({queryKey:["dashboard","plugin-reports"],queryFn:({signal:e})=>Ne(n1,"/api/plugin-reports",e),retry:!1})}function KG(){return Ue({queryKey:["dashboard","stats"],queryFn:({signal:e})=>Ne(oz,"/api/stats",e),retry:!1})}function WG(e){let t=$be(),a=Ue({queryKey:["dashboard","conversation-stats"],queryFn:({signal:i})=>Ne(DE,"/api/conversations/stats",i),retry:!1}),r=Pbe(),n=Dbe();return{data:t.data&&r.data?{...e,conversationStatsError:!!a.error,...a.data?{conversationStats:a.data}:void 0,conversationStatsLoading:a.isPending,pluginReportsError:!!n.error,...n.data?{pluginReports:n.data}:void 0,pluginReportsLoading:n.isPending,plugins:t.data,skills:r.data}:void 0,error:t.error??r.error,isPending:t.isPending||r.isPending}}function I(...e){return e.filter(Boolean).join(" ")}var Ya="mx-auto w-full min-w-0 max-w-screen-xl",vm="text-dashboard-text-muted hover:text-dashboard-text",JG="rounded-xl border border-dashboard-border-interactive bg-dashboard-surface-active",QG="dashboard-shell-bg";var w1=b(w(),1),XG="inline-flex h-9 max-w-full items-center gap-2 rounded border border-dashboard-border-emphasis bg-dashboard-surface-raised px-3 font-mono text-sm font-semibold leading-none text-dashboard-text transition-colors hover:border-dashboard-border-heavy hover:bg-dashboard-surface-hover hover:text-dashboard-text",Ebe="inline-flex h-9 max-w-full items-center justify-center gap-1.5 rounded border border-dashboard-border-strong bg-transparent px-3 font-mono text-xs font-semibold text-dashboard-text-muted transition-colors hover:border-rose-300/40 hover:text-rose-300";function ie({className:e,size:t="default",tone:a="default",type:r="button",...n}){let o=a==="danger";return(0,w1.jsx)("button",{...n,className:I("font-mono transition-colors disabled:cursor-not-allowed disabled:opacity-50",t==="icon"?I("grid size-9 place-items-center rounded-md border-0 bg-transparent p-0 focus-visible:outline focus-visible:outline-1 disabled:hover:!bg-transparent",o?"text-dashboard-text-muted hover:!bg-rose-300/10 hover:!text-rose-300 focus-visible:outline-rose-300/55 disabled:hover:!text-dashboard-text-muted":"text-dashboard-text-muted hover:!bg-dashboard-fill-strong hover:!text-dashboard-text focus-visible:outline-cyan-300/55 disabled:hover:!text-dashboard-text-muted"):a==="primary"?"inline-flex h-9 items-center justify-center gap-2 rounded border border-dashboard-text-solid bg-dashboard-text-solid px-3 font-sans text-sm font-semibold text-dashboard-text-inverse hover:bg-dashboard-text-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-dashboard-focus":o?I(Ebe,"disabled:hover:border-dashboard-border-strong disabled:hover:text-dashboard-text-muted"):I(XG,"disabled:hover:border-dashboard-border-emphasis disabled:hover:bg-dashboard-surface-raised disabled:hover:text-dashboard-text"),n.disabled?"":"cursor-pointer",e),type:r})}function _d({className:e,...t}){return(0,w1.jsx)(ae,{...t,className:I(XG,"no-underline",e)})}function Ln({className:e,pressed:t,type:a="button",variant:r,...n}){return(0,w1.jsx)("button",{...n,"aria-pressed":t,className:I(Mbe[r],t?Obe[r]:zbe[r],e),type:a})}var Mbe={pill:"cursor-pointer rounded border px-2 py-1 font-mono text-xs font-semibold uppercase leading-tight transition-colors focus-visible:outline focus-visible:outline-1 focus-visible:outline-cyan-300/55",segment:"h-7 min-w-10 cursor-pointer rounded border px-2 font-mono text-xs transition-colors focus-visible:outline focus-visible:outline-1 focus-visible:outline-cyan-300/55",text:"cursor-pointer border-0 bg-transparent px-1.5 py-1 font-mono uppercase tracking-normal underline-offset-4 transition-colors focus-visible:outline focus-visible:outline-1 focus-visible:outline-cyan-300/55"},Obe={pill:"border-dashboard-border-heavy bg-dashboard-text-solid text-dashboard-text-inverse",segment:"border-amber-500/30 bg-amber-500/20 text-amber-400",text:"text-dashboard-text underline decoration-dashboard-text-solid"},zbe={pill:"border-dashboard-border-strong bg-dashboard-surface-raised text-dashboard-text-muted hover:border-dashboard-border-interactive hover:bg-dashboard-surface-hover hover:text-dashboard-text",segment:"border-dashboard-border-strong bg-dashboard-fill-faint text-dashboard-text-muted hover:bg-dashboard-fill-strong hover:text-dashboard-text",text:"text-dashboard-text-muted hover:text-dashboard-text"};var ym=b(w(),1);function Yr(e){let t=e.tone==="error";return(0,ym.jsxs)("div",{role:t?"alert":"status",className:I("flex min-w-0 gap-3 rounded-md border p-4",t?"border-rose-300/25 bg-rose-300/5":"border-amber-300/25 bg-amber-300/5"),children:[(0,ym.jsx)(Kr,{"aria-hidden":!0,size:18,className:I("mt-0.5 shrink-0",t?"text-rose-300":"text-amber-300")}),(0,ym.jsxs)("div",{className:"min-w-0",children:[(0,ym.jsx)("p",{className:"m-0 text-sm font-medium",children:e.title}),e.children?(0,ym.jsx)("div",{className:"mt-1 text-sm leading-relaxed text-dashboard-text-muted",children:e.children}):null]})]})}var xx=b(w(),1),Ube={accent:"text-violet-300",danger:"text-rose-300",info:"text-cyan-300",neutral:"text-dashboard-text-muted",success:"text-emerald-300",warning:"text-amber-300"},jbe={compact:"text-xs",default:"text-sm"};function ba(e){return(0,xx.jsxs)("span",{className:I("inline-flex w-fit items-center gap-1.5 font-sans font-medium normal-case leading-snug tracking-normal",jbe[e.size??"default"],Ube[e.tone??"neutral"],e.className),children:[(0,xx.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-current"}),(0,xx.jsx)("span",{className:"block first-letter:uppercase",children:e.children})]})}var YG=b(w(),1);function U(e){let t=e.as??"div",a={none:"",sm:"p-4",md:"p-5 sm:p-6"}[e.padding??"none"],r=e.variant==="section"?"mb-4 border-dashboard-border-subtle bg-dashboard-fill-faint shadow-[0_24px_80px_rgba(0,0,0,0.18)]":e.variant==="raised"?"border-dashboard-border-emphasis bg-dashboard-surface-raised":"border-dashboard-border-subtle bg-dashboard-fill-faint";return(0,YG.jsx)(t,{className:I("min-w-0 overflow-hidden rounded-lg border",r,a,e.className),children:e.children})}var eK=b(w(),1);function Qe(e){let t=e.as??"div";return(0,eK.jsx)(t,{"aria-hidden":"true",className:I("animate-pulse rounded bg-dashboard-fill-soft motion-reduce:animate-none",e.className)})}var ot=b(w(),1);function Yn(e){let t=e.variant??"panel";return(0,ot.jsxs)("div",{"aria-busy":"true","aria-live":"polite",className:I("grid gap-4",e.className),role:"status",children:[(0,ot.jsx)("span",{className:"sr-only",children:e.label}),Bbe(t)]})}function Bbe(e){switch(e){case"stats":return(0,ot.jsx)(Fbe,{});case"overview":return(0,ot.jsx)(Hbe,{});case"list":return(0,ot.jsx)(Vbe,{});case"library":return(0,ot.jsx)(qbe,{});case"panel":return(0,ot.jsx)(ql,{className:"min-h-64"})}}function Fbe(){return(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsx)("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:Array.from({length:4},(e,t)=>(0,ot.jsx)(ql,{className:"min-h-[7.5rem] p-4 sm:min-h-32 sm:p-5"},t))}),(0,ot.jsx)(ql,{className:"min-h-[17rem]"})]})}function Hbe(){return(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,ot.jsx)(ql,{className:"min-h-[17rem]"}),(0,ot.jsx)(ql,{className:"min-h-[17rem]"})]}),(0,ot.jsx)(gg,{className:"h-24 border-y border-dashboard-border-subtle bg-dashboard-fill-faint"}),(0,ot.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,ot.jsx)(ql,{className:"min-h-56"}),(0,ot.jsx)(ql,{className:"min-h-56"})]})]})}function Vbe(){return(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsx)(ql,{className:"min-h-20 p-4"}),(0,ot.jsx)(gg,{className:"h-10 border-b border-dashboard-border-subtle"}),(0,ot.jsx)(ql,{className:"min-h-80"})]})}function qbe(){return(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsxs)("div",{className:"flex flex-wrap items-end justify-between gap-4",children:[(0,ot.jsx)(gg,{className:"h-7 w-56 rounded bg-dashboard-fill-soft"}),(0,ot.jsx)(gg,{className:"h-10 w-full max-w-md rounded-lg border border-dashboard-border-subtle bg-dashboard-fill-faint sm:w-72"})]}),(0,ot.jsx)("div",{"aria-hidden":"true",className:"grid min-w-0 grid-cols-3 gap-1 border-b border-dashboard-border-subtle sm:flex",children:Array.from({length:3},(e,t)=>(0,ot.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2.5 sm:justify-start",children:[(0,ot.jsx)(gg,{className:"h-3 w-12 rounded bg-dashboard-fill-soft"}),(0,ot.jsx)(gg,{className:"h-5 w-8 rounded-sm border border-dashboard-border-subtle bg-dashboard-fill-faint"})]},t))}),(0,ot.jsx)(ql,{className:"min-h-80"})]})}function ql(e){return(0,ot.jsx)(U,{className:I("animate-pulse motion-reduce:animate-none",e.className),children:(0,ot.jsx)("span",{"aria-hidden":"true"})})}function gg(e){return(0,ot.jsx)(Qe,{className:e.className})}var pz=b(w(),1),Zbe=[1,7,30,90];function hz(e){return e===1?"24h":`${e}d`}function vg(e){return e===1?"last 24 hours":`last ${e} days`}function Ha(e){return e===1?"hour":e===7?"6hour":"day"}function tK(e){return e===1}function Gbe(e){return e===7}function eo(e){return e==="hour"?"hour":e==="6hour"?"6h":"day"}function yg(e){return e==="hour"?"hour":e==="6hour"?"6 hours":"day"}function Sx(e){return e==="hour"?"Hourly":e==="6hour"?"6-hour":"Daily"}function en(e){return tK(e.range)&&e.hours?.length?e.hours.slice(-24):tK(e.range)?e.days.slice(-1):Gbe(e.range)?e.sixHours?.length?[...e.sixHours]:e.hours?.length&&e.emptySixHour?Kbe({empty:e.emptySixHour,hours:e.hours}):e.days.slice(-e.range):e.days.slice(-e.range)}function Kbe(e){let t=new Map;for(let a of e.hours){let r=Date.parse(`${a.date}:00:00.000Z`);if(Number.isNaN(r))continue;let n=new Date(r);n.setUTCMinutes(0,0,0),n.setUTCHours(Math.floor(n.getUTCHours()/6)*6,0,0,0);let o=n.toISOString().slice(0,13),s={...t.get(o)??e.empty(o),date:o};for(let[l,c]of Object.entries(a))if(l!=="date"&&typeof c=="number"){let d=s[l];s[l]=(typeof d=="number"?d:0)+c}t.set(o,s)}if(e.hours.length>=24){let a=e.hours[e.hours.length-1]?.date,r=a?Date.parse(`${a}:00:00.000Z`):Date.now(),n=new Date(r);n.setUTCMinutes(0,0,0),n.setUTCHours(Math.floor(n.getUTCHours()/6)*6,0,0,0);let o=new Date(n.getTime()-9720*60*1e3),i=[];for(let s=new Date(o);s.getTime()<=n.getTime();s.setTime(s.getTime()+360*60*1e3)){let l=s.toISOString().slice(0,13);i.push(t.get(l)??e.empty(l))}return i}return[...t.values()].sort((a,r)=>a.date.localeCompare(r.date))}function bg(e){return(0,pz.jsx)("div",{"aria-label":"Reporting period",className:"flex items-center gap-1",role:"group",children:(e.options??Zbe).map(t=>(0,pz.jsx)(Ln,{onClick:()=>e.onChange(t),pressed:e.value===t,variant:"segment",children:hz(t)},t))})}var Nd=b(w(),1);function We(e){let t=e.range!==void 0&&e.onRangeChange?(0,Nd.jsx)(bg,{onChange:e.onRangeChange,...e.rangeOptions?{options:e.rangeOptions}:{},value:e.range}):void 0,a=e.actions??t;return(0,Nd.jsxs)("header",{className:"flex min-w-0 items-center justify-between gap-6 border-b border-white/[0.05] pb-4 sm:pb-6 max-md:flex-col max-md:items-stretch",children:[(0,Nd.jsxs)("div",{className:"min-w-0",children:[(0,Nd.jsx)("h2",{className:"m-0 font-display text-3xl font-light leading-none tracking-[-0.03em] text-dashboard-text sm:text-4xl",children:e.title}),(0,Nd.jsx)("div",{className:"mt-2 max-w-2xl font-mono text-xs leading-relaxed text-dashboard-text-muted sm:text-sm",children:e.description})]}),a?(0,Nd.jsx)("div",{className:"shrink-0",children:a}):null]})}var aK=b(w(),1);function Co(e){return(0,aK.jsx)("div",{className:I(Ya,"grid min-w-0 content-start gap-4 px-4 py-4 pb-[max(1rem,env(safe-area-inset-bottom))] sm:gap-6 sm:px-8 sm:py-8 sm:pb-8",e.className),children:e.children})}var xm=b(G(),1);var bm=b(G(),1);function Ni(e,t){let a=typeof t=="string"?t.startsWith("?")?t.slice(1):t:t?.toString()??"",r=e.indexOf("?"),n=r===-1?e:e.slice(0,r),o=r===-1?"":e.slice(r+1).replace(/^\?+/,""),i=new URLSearchParams(a);for(let[l,c]of new URLSearchParams(o))i.set(l,c);let s=i.toString();return s?`${n}?${s}`:n}function Wbe(e,t){let a=e?.trim();return a&&t.includes(a)?a:void 0}function Zl(e="q",t={}){let a=t.delayMs??250,r=t.resetPage??!1,[n,o]=qo(),i=n.get(e)?.trim()??"",[s,l]=(0,bm.useState)(i);return(0,bm.useEffect)(()=>{l(c=>c.trim()===i?c:i)},[i]),(0,bm.useEffect)(()=>{let c=window.setTimeout(()=>{let d=s.trim();d!==i&&o(f=>{let m=new URLSearchParams(f);return r&&m.delete("page"),d?m.set(e,d):m.delete(e),m},{replace:!0})},a);return()=>window.clearTimeout(c)},[i,a,e,r,o,s]),[s,l,i]}function ec(e,t,a){let[r,n]=qo(),o=Wbe(r.get(e),a)??t,i=(0,bm.useCallback)(s=>{n(l=>{let c=new URLSearchParams(l);return s===t?c.delete(e):c.set(e,s),c},{replace:!0})},[t,e,n]);return[o,i]}var nK=b(G(),1);var xg=b(w(),1),gz="rounded-lg border border-dashboard-border bg-dashboard-surface-panel",vz="gap-1 p-1";function yz(e){return I("min-h-9 cursor-pointer rounded-md border-0 px-3 py-2 font-sans text-sm font-medium transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus",e?"bg-dashboard-fill-strong text-dashboard-text":"bg-transparent text-dashboard-text-muted hover:bg-dashboard-fill-faint hover:text-dashboard-text")}function C1(e){let t=(0,nK.useId)();return(0,xg.jsxs)("div",{className:"grid min-w-0 gap-4",children:[(0,xg.jsx)("div",{"aria-label":e.label,className:I("grid auto-cols-fr grid-flow-col",gz,vz),role:"tablist",children:e.items.map((a,r)=>(0,xg.jsx)("button",{"aria-controls":`${t}-panel`,"aria-selected":e.value===a.value,className:I("min-w-0",yz(e.value===a.value)),id:`${t}-${a.value}`,onClick:()=>e.onChange(a.value),onKeyDown:n=>{let o,i=e.items.length;switch(n.key){case"ArrowLeft":o=(r+i-1)%i;break;case"ArrowRight":o=(r+1)%i;break;case"Home":o=0;break;case"End":o=i-1;break;default:return}n.preventDefault(),e.onChange(e.items[o].value),n.currentTarget.parentElement?.querySelectorAll('[role="tab"]')[o]?.focus()},role:"tab",tabIndex:e.value===a.value?0:-1,type:"button",children:a.label},a.value))}),(0,xg.jsx)("div",{"aria-labelledby":`${t}-${e.value}`,className:"min-w-0 rounded focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus",id:`${t}-panel`,role:"tabpanel",tabIndex:0,children:e.children})]})}var Sg=b(w(),1);function xz(e){let{className:t,item:a}=e,r=vt(),n=Ni(a.to,r.search);if(a.isActive){let o=a.isActive(r.pathname);return(0,Sg.jsx)(ae,{"aria-current":o?"page":void 0,className:t({isActive:o}),to:n,children:a.label})}return(0,Sg.jsx)(jf,{className:t,end:a.end,to:n,children:a.label})}var bz=24;function oK(e){let t=e.scrollWidth-e.clientWidth;return{end:e.scrollLeft<t-1,start:e.scrollLeft>1}}function rK(e){let t=e.querySelector('[aria-current="page"]');if(!t||e.clientWidth===0)return;let a=oK(e),r=e.scrollLeft+(a.start?bz:0),n=e.scrollLeft+e.clientWidth-(a.end?bz:0),o=t.offsetLeft,i=o+t.offsetWidth;o>=r&&i<=n||(e.scrollLeft=o-(e.clientWidth-t.offsetWidth)/2)}function Jbe(e){if(!e.start&&!e.end)return;let t=`${bz}px`,a=e.start?`transparent, black ${t}`:"black",r=e.end?`black calc(100% - ${t}), transparent`:"black",n=`linear-gradient(to right, ${a}, ${r})`;return{maskImage:n,WebkitMaskImage:n}}function Sm(e){let{pathname:t}=vt(),a=(0,xm.useRef)(null),[r,n]=(0,xm.useState)({end:!1,start:!1});(0,xm.useLayoutEffect)(()=>{let i=a.current;if(!i)return;let s=()=>{let{end:c,start:d}=oK(i);n(f=>f.start===d&&f.end===c?f:{end:c,start:d})},l=new ResizeObserver(()=>{i.scrollLeft=0,rK(i),s()});s(),i.addEventListener("scroll",s,{passive:!0}),l.observe(i);for(let c of i.children)l.observe(c);return()=>{i.removeEventListener("scroll",s),l.disconnect()}},[]),(0,xm.useLayoutEffect)(()=>{a.current&&rK(a.current)},[t]);let o=({isActive:i})=>I(yz(i),"flex items-center justify-center whitespace-nowrap no-underline",e.fill?"min-w-max flex-[1_0_0]":"shrink-0");return(0,Sg.jsx)("nav",{"aria-label":e.ariaLabel,className:I(gz,"flex min-w-0 max-w-full",!e.fill&&"w-fit"),children:(0,Sg.jsx)("div",{className:I(vz,"relative flex min-w-0 flex-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"),ref:a,style:Jbe(r),children:e.items.map(i=>(0,Sg.jsx)(xz,{className:o,item:i},i.to))})})}var Gt=b(G(),1),wx=b(Tl(),1),Qs=b(w(),1),Gl=(0,Gt.createContext)(null);function k1(e){let[t,a]=(0,Gt.useState)(null),[r,n]=(0,Gt.useState)(null),[o,i]=(0,Gt.useState)(null),[s,l]=(0,Gt.useState)(null),c=(0,Gt.useRef)(null),d=(0,Gt.useCallback)(y=>{a(y)},[]),f=(0,Gt.useCallback)(y=>{n(y)},[]),m=(0,Gt.useCallback)(y=>{i(y)},[]),p=(0,Gt.useCallback)(y=>{l(y)},[]),h=(0,Gt.useCallback)(y=>{c.current=y},[]),g=(0,Gt.useCallback)(()=>{c.current?.()},[]),x=(0,Gt.useMemo)(()=>({mobileHeaderActionsSlot:o,mobileHeaderActionsSlotRef:m,mobileHeaderLiveSlot:s,mobileHeaderLiveSlotRef:p,mobileSecondarySlot:r,mobileSecondarySlotRef:f,openMobileNavigation:g,registerOpenMobileNavigation:h,secondarySlot:t,secondarySlotRef:d}),[o,m,s,p,r,f,g,h,t,d]);return(0,Qs.jsx)(Gl.Provider,{value:x,children:e.children})}function iK(e){let t=(0,Gt.useContext)(Gl);if(!t)throw new Error("DashboardChrome requires DashboardChromeProvider");return(0,Qs.jsxs)("div",{className:"sticky top-0 z-30 bg-dashboard-bg/95 pt-[env(safe-area-inset-top)]",children:[e.header,(0,Qs.jsx)("div",{className:"hidden md:block",ref:t.secondarySlotRef}),e.banner]})}function sK(){let e=(0,Gt.useContext)(Gl);if(!e)throw new Error("MobileSecondaryNavigationSlot requires DashboardChromeProvider");return(0,Qs.jsx)("div",{ref:e.mobileSecondarySlotRef})}function lK(){let e=(0,Gt.useContext)(Gl);if(!e)throw new Error("MobileHeaderActionsSlot requires DashboardChromeProvider");return(0,Qs.jsx)("div",{className:"col-start-3 row-start-1 flex min-w-0 items-center justify-self-end md:hidden",ref:e.mobileHeaderActionsSlotRef})}function uK(){let e=(0,Gt.useContext)(Gl);if(!e)throw new Error("MobileHeaderLiveSlot requires DashboardChromeProvider");return(0,Qs.jsx)("div",{className:"flex shrink-0 items-center md:hidden",ref:e.mobileHeaderLiveSlotRef})}function cK(e){let t=(0,Gt.useContext)(Gl);return t?.mobileHeaderActionsSlot?(0,wx.createPortal)(e.children,t.mobileHeaderActionsSlot):null}function dK(e){let t=(0,Gt.useContext)(Gl);return t?.mobileHeaderLiveSlot?(0,wx.createPortal)(e.children,t.mobileHeaderLiveSlot):null}function fK(){let e=(0,Gt.useContext)(Gl);return e?e.openMobileNavigation:null}function mK(e){let t=(0,Gt.useContext)(Gl),a=(0,Gt.useRef)(e);a.current=e,(0,Gt.useEffect)(()=>{if(!t)return;let r=()=>{a.current?.()};return t.registerOpenMobileNavigation(e?r:null),()=>{t.registerOpenMobileNavigation(null)}},[t,e])}function pK(e){let t=(0,Gt.useContext)(Gl);return t?t.secondarySlot?(0,Qs.jsxs)(Qs.Fragment,{children:[(0,wx.createPortal)(e.desktop,t.secondarySlot),t.mobileSecondarySlot?(0,wx.createPortal)(e.mobile,t.mobileSecondarySlot):null]}):null:e.desktop}var Xs=b(w(),1);function Ad(e){let t=({isActive:a})=>I("rounded-lg px-3 py-3 pl-6 font-mono text-sm font-medium no-underline transition-colors",a?"bg-cyan-300/[0.1] text-cyan-50":I("hover:bg-white/[0.035]",vm));return(0,Xs.jsxs)("div",{className:"min-w-0",children:[(0,Xs.jsx)(pK,{desktop:(0,Xs.jsx)("div",{className:"border-b border-white/[0.06] bg-white/[0.018]",children:(0,Xs.jsx)("div",{className:I(Ya,"min-w-0 px-4 py-2 md:px-8"),children:(0,Xs.jsx)(Sm,{ariaLabel:e.ariaLabel,items:e.items})})}),mobile:(0,Xs.jsx)("nav",{"aria-label":e.ariaLabel,className:"mt-3 grid gap-1 border-t border-white/[0.07] pt-3",children:e.items.map(a=>(0,Xs.jsx)(xz,{className:t,item:a},a.to))})}),(0,Xs.jsx)("div",{className:"px-4 pt-4 sm:px-8 md:hidden",children:(0,Xs.jsx)(Sm,{ariaLabel:e.ariaLabel,fill:!0,items:e.items})}),e.children]})}var Kl=b(w(),1),Qbe=new Set(["list","runs"]);function Xbe(e){if(e==="/automations/list"||/^\/automations\/(scheduled|event)\/[^/]+\/edit$/.test(e))return!0;let t=e.match(/^\/automations\/([^/]+)$/);return!!(t?.[1]&&!Qbe.has(t[1]))}var Ybe=[{end:!0,label:"Overview",to:"/automations"},{isActive:Xbe,label:"Automations",to:"/automations/list"},{label:"Runs",to:"/automations/runs"}];function Sz(e){return(0,Kl.jsx)(Ad,{ariaLabel:"Automations navigation",items:Ybe,children:e.children})}function Ai(e){return(0,Kl.jsx)(Sz,{children:(0,Kl.jsx)(Co,{children:e.children})})}function wm(e){return(0,Kl.jsxs)(Kl.Fragment,{children:[(0,Kl.jsx)(We,{description:e.description,title:e.title}),(0,Kl.jsx)(Yn,{label:e.label,variant:e.variant})]})}var ps=b(G(),1);var wg=b(w(),1),exe={compact:"font-mono text-xs uppercase tracking-[0.12em] text-dashboard-text-muted",default:"text-sm font-semibold text-dashboard-text"},txe={compact:"grid gap-1.5",default:"grid gap-2"};function Ot(e){let t=e.size??"default";return(0,wg.jsxs)("div",{className:I(txe[t],e.className),children:[(0,wg.jsx)("label",{className:exe[t],htmlFor:e.htmlFor,children:e.label}),e.children,e.error?(0,wg.jsx)("p",{id:e.htmlFor?`${e.htmlFor}-error`:void 0,role:"alert",className:"m-0 text-xs leading-relaxed text-rose-300",children:e.error}):null,e.help?(0,wg.jsx)("p",{id:e.htmlFor?`${e.htmlFor}-help`:void 0,className:"m-0 text-xs leading-relaxed text-dashboard-text-muted sm:text-sm",children:e.help}):null]})}var wz=b(w(),1),hK="block w-full rounded border border-dashboard-border-emphasis bg-dashboard-ink px-3 py-2 text-sm text-dashboard-text focus:border-dashboard-focus focus:outline-none aria-invalid:border-rose-300 disabled:cursor-not-allowed disabled:opacity-50";function xa({className:e,type:t="text",size:a="default",...r}){return(0,wz.jsx)("input",{...r,className:I(hK,a==="comfortable"&&"min-h-11 text-base sm:min-h-10 sm:text-sm",e),type:t})}function tc({className:e,prose:t=!1,...a}){return(0,wz.jsx)("textarea",{...a,className:I(hK,"min-h-36",t?"font-sans leading-relaxed":"font-mono",e)})}var Cm=b(w(),1);function ms(e){return(0,Cm.jsxs)("section",{className:"grid min-w-0 gap-5 border-t border-dashboard-border-emphasis py-8 md:grid-cols-[12rem_minmax(0,1fr)] md:gap-10",children:[(0,Cm.jsxs)("div",{children:[(0,Cm.jsx)("h2",{className:"m-0 font-display text-lg font-medium",children:e.title}),e.detail?(0,Cm.jsx)("p",{className:"mt-2 mb-0 text-sm leading-relaxed text-dashboard-text-muted",children:e.detail}):null]}),(0,Cm.jsx)("div",{className:"grid min-w-0 content-start gap-5",children:e.children})]})}var R1=b(G(),1);var gK=b(w(),1);function Wl({className:e,...t}){return(0,gK.jsx)("select",{...t,className:I("block min-h-11 w-full min-w-0 rounded border border-dashboard-border-emphasis bg-dashboard-ink px-3 py-2 text-base text-dashboard-text focus:border-dashboard-focus focus:outline-none aria-invalid:border-rose-300 disabled:cursor-not-allowed disabled:opacity-60 sm:min-h-10 sm:text-sm",e)})}var I1=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function L1(e){return{title:e.title??"",instruction:e.instruction,credentialMode:e.credentialMode,outcomes:e.outcomes,trigger:e.kind==="event"?e.trigger:void 0}}function T1(e){let t=e.schedule.recurrence;if(e.schedule.kind==="recurring"&&t){let{time:a,weekdays:r,...n}=t;return{kind:"recurring",...n,timezone:e.schedule.timezone,time:`${String(a.hour).padStart(2,"0")}:${String(a.minute).padStart(2,"0")}`,weekdays:r?.map(o=>I1[o])}}if(e.nextRunAtMs){let a=new Intl.DateTimeFormat("en-CA",{timeZone:e.schedule.timezone,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(e.nextRunAtMs),r=n=>a.find(o=>o.type===n)?.value??"";return{kind:"one_off",timezone:e.schedule.timezone,timing:{type:"at",date:`${r("year")}-${r("month")}-${r("day")}`,time:`${r("hour")}:${r("minute")}`}}}return{kind:"recurring",frequency:"daily",time:"09:00",timezone:e.schedule.timezone}}function vK(e,t){let a={};return t.title!==(e.title??"")&&(a.title=t.title),t.instruction!==e.instruction&&(a.instruction=t.instruction),t.credentialMode!==e.credentialMode&&(a.credentialMode=t.credentialMode),JSON.stringify(t.outcomes)!==JSON.stringify(e.outcomes)&&(a.outcomes=t.outcomes),e.kind==="scheduled"&&t.schedule&&(a.schedule=t.schedule),e.kind==="event"&&JSON.stringify(t.trigger)!==JSON.stringify(e.trigger)&&(a.trigger=t.trigger),a}var He=b(w(),1);function yK(e){let t=e.value??T1(e.automation),[a,r]=(0,R1.useState)(e.value);(0,R1.useEffect)(()=>{let f=setTimeout(()=>r(e.value),300);return()=>clearTimeout(f)},[e.value]);let n=VE.safeParse(a),o=Ue({queryKey:["dashboard","automation-schedule-preview",e.automation.id,a],enabled:!!a&&n.success,retry:!1,queryFn:()=>wo(qE,`/api/automations/scheduled/${encodeURIComponent(e.automation.id)}/preview`,a)}),i=t.kind==="recurring"?t.frequency:"once",s=t.kind==="recurring"?t.time:t.timing.time,l=e.value?o.data?.nextRunAtMs:e.automation.nextRunAtMs,c=e.value!==a||o.isFetching,d=o.error instanceof yn?o.error.apiError:o.error?"Schedule preview could not be loaded. Try again.":e.value&&!n.success&&!c?n.error.issues[0]?.message:void 0;return(0,He.jsxs)(He.Fragment,{children:[(0,He.jsxs)("div",{className:"grid grid-cols-1 items-start gap-4 sm:grid-cols-2",children:[(0,He.jsx)(Ot,{label:"Repeat",htmlFor:"schedule-frequency",children:(0,He.jsxs)(Wl,{id:"schedule-frequency",value:i,onChange:f=>{let m=f.target.value;m!=="once"&&m!=="daily"&&m!=="weekly"&&m!=="monthly"&&m!=="yearly"||e.onChange(m==="once"?{kind:"one_off",timezone:t.timezone??e.automation.schedule.timezone,timing:{type:"at",date:"",time:s}}:{kind:"recurring",timezone:t.timezone,time:s,frequency:m,interval:1,weekdays:m==="weekly"?["monday"]:void 0,dayOfMonth:["monthly","yearly"].includes(m)?1:void 0,month:m==="yearly"?1:void 0})},children:[(0,He.jsx)("option",{value:"once",children:"Once"}),(0,He.jsx)("option",{value:"daily",children:"Every day"}),(0,He.jsx)("option",{value:"weekly",children:"Every week"}),(0,He.jsx)("option",{value:"monthly",children:"Every month"}),(0,He.jsx)("option",{value:"yearly",children:"Every year"})]})}),(0,He.jsx)(Ot,{label:"Time",htmlFor:"schedule-time",children:(0,He.jsx)(xa,{size:"comfortable",id:"schedule-time",type:"time",value:s,onChange:f=>e.onChange(t.kind==="recurring"?{...t,time:f.target.value}:{...t,timing:{type:"at",date:t.timing.date,time:f.target.value}})})})]}),t.kind==="recurring"?(0,He.jsxs)(He.Fragment,{children:[t.frequency==="weekly"?(0,He.jsxs)("fieldset",{children:[(0,He.jsx)("legend",{className:"mb-2 text-sm font-semibold",children:"On"}),(0,He.jsx)("div",{className:"grid grid-cols-7 gap-1.5",children:[...I1.slice(1),I1[0]].map(f=>(0,He.jsx)("button",{type:"button","aria-label":f,"aria-pressed":t.weekdays?.includes(f)??!1,onClick:()=>e.onChange({...t,weekdays:t.weekdays?.includes(f)?t.weekdays.filter(m=>m!==f):[...t.weekdays??[],f]}),className:I("min-h-11 cursor-pointer rounded border px-1 text-xs font-medium capitalize focus-visible:outline-2 focus-visible:outline-dashboard-focus sm:min-h-10 sm:text-sm",t.weekdays?.includes(f)?"border-dashboard-focus/50 bg-dashboard-focus/10 text-dashboard-focus":"border-dashboard-border-emphasis text-dashboard-text-muted hover:bg-dashboard-fill-hover"),children:f.slice(0,3)},f))})]}):null,(0,He.jsxs)("div",{className:"grid grid-cols-1 items-start gap-4 sm:grid-cols-2",children:[(0,He.jsx)(Ot,{label:"Interval",htmlFor:"schedule-interval",help:"Number of calendar periods between runs.",children:(0,He.jsx)(xa,{size:"comfortable",id:"schedule-interval",type:"number",min:1,max:365,value:t.interval??1,onChange:f=>e.onChange({...t,interval:f.target.valueAsNumber})})}),(0,He.jsx)(Ot,{label:"Start date",htmlFor:"schedule-start",children:(0,He.jsx)(xa,{size:"comfortable",id:"schedule-start",type:"date",value:t.startDate??"",onChange:f=>e.onChange({...t,startDate:f.target.value||void 0})})})]}),t.frequency==="monthly"||t.frequency==="yearly"?(0,He.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[(0,He.jsx)(Ot,{label:"Day of month",htmlFor:"schedule-day",children:(0,He.jsx)(xa,{size:"comfortable",id:"schedule-day",type:"number",min:1,max:31,value:t.dayOfMonth??1,onChange:f=>e.onChange({...t,dayOfMonth:f.target.valueAsNumber})})}),t.frequency==="yearly"?(0,He.jsx)(Ot,{label:"Month",htmlFor:"schedule-month",children:(0,He.jsx)(Wl,{id:"schedule-month",value:t.month??1,onChange:f=>e.onChange({...t,month:Number(f.target.value)}),children:Array.from({length:12},(f,m)=>(0,He.jsx)("option",{value:m+1,children:new Intl.DateTimeFormat("en",{month:"long",timeZone:"UTC"}).format(new Date(Date.UTC(2026,m,1)))},m))})}):null]}):null]}):(0,He.jsx)(Ot,{label:"Date",htmlFor:"schedule-date",children:(0,He.jsx)(xa,{size:"comfortable",id:"schedule-date",type:"date",value:t.timing.date,onChange:f=>e.onChange({...t,timing:{type:"at",time:s,date:f.target.value}})})}),(0,He.jsxs)(Ot,{label:"Timezone",htmlFor:"schedule-timezone",help:"Use an IANA timezone. The schedule follows local time, including daylight saving time.",children:[(0,He.jsx)(xa,{size:"comfortable",id:"schedule-timezone",list:"automation-timezones",value:t.timezone??"",onChange:f=>e.onChange({...t,timezone:f.target.value})}),(0,He.jsx)("datalist",{id:"automation-timezones",children:["UTC",...Intl.supportedValuesOf("timeZone")].map(f=>(0,He.jsx)("option",{children:f},f))})]}),(0,He.jsxs)("div",{role:"status",className:"flex gap-3 rounded-md bg-dashboard-fill-soft p-3 text-sm leading-relaxed",children:[(0,He.jsx)(Fs,{"aria-hidden":!0,size:17,className:"mt-0.5 shrink-0 text-dashboard-text-muted"}),(0,He.jsx)("div",{children:c?"Checking schedule\u2026":d?(0,He.jsxs)(He.Fragment,{children:[(0,He.jsx)("span",{className:"text-rose-300",children:d}),o.error?(0,He.jsx)(ie,{onClick:()=>{o.refetch()},children:"Try again"}):null]}):l?(0,He.jsxs)(He.Fragment,{children:["Next run"," ",new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short",timeZone:e.value?o.data?.schedule.timezone??"UTC":e.automation.schedule.timezone}).format(l)]}):"No next run."})]}),e.value?(0,He.jsx)(ie,{className:"w-fit",onClick:()=>e.onChange(void 0),children:"Keep saved schedule"}):null]})}var ht=b(w(),1);function bK(e){let t=Ue({queryKey:["dashboard","automation-event-catalog"],queryFn:({signal:o})=>Ne(HE,"/api/automations/event-catalog",o),retry:!1}),a=t.data?.find(o=>o.namespace===e.value.namespace&&o.type===e.value.resourceType),r=!a||e.value.events.some(o=>!a.supportedEvents.includes(o))||Object.entries(e.value.match??{}).some(([o,i])=>{let s=a.matchFields?.[o];return s?(Array.isArray(i)?i:[i]).some(l=>typeof l!==s.kind||s.enum&&!s.enum.includes(String(l))):!0}),n=(o,i)=>{let s={...e.value.match};i===void 0?delete s[o]:s[o]=i,e.onChange({...e.value,match:s})};return(0,ht.jsxs)(ht.Fragment,{children:[t.error?(0,ht.jsxs)(Yr,{title:"Event choices could not be loaded.",children:["Saved values are kept."," ",(0,ht.jsx)(ie,{onClick:()=>{t.refetch()},children:"Try again"})]}):t.isPending?(0,ht.jsx)("p",{role:"status",children:"Loading event choices\u2026"}):null,r&&t.data?(0,ht.jsxs)(Yr,{title:"Saved trigger \xB7 Kept unchanged",children:["Some saved values are not in the current catalog. You can edit other fields, or select a new resource type to replace the trigger.",(0,ht.jsx)("pre",{className:"whitespace-pre-wrap break-all text-xs",children:JSON.stringify(e.value,null,2)})]}):null,(0,ht.jsx)(Ot,{label:r?"Replace trigger":"Resource type",htmlFor:"trigger-resource",children:(0,ht.jsxs)(Wl,{id:"trigger-resource",value:r?"":`${e.value.namespace}:${e.value.resourceType}`,onChange:o=>{let i=t.data?.find(s=>`${s.namespace}:${s.type}`===o.target.value);i&&window.confirm("Replace the saved trigger? Its resource, events, and conditions will be cleared.")&&e.onChange({namespace:i.namespace,resourceType:i.type,identifier:"",label:"",events:[]})},children:[(0,ht.jsx)("option",{value:"",disabled:!0,children:"Keep saved trigger"}),t.data?.map(o=>(0,ht.jsxs)("option",{value:`${o.namespace}:${o.type}`,children:[o.namespace," \xB7 ",o.type.replaceAll("_"," ")]},`${o.namespace}:${o.type}`))]})}),!r&&a?(0,ht.jsxs)(ht.Fragment,{children:[(0,ht.jsx)(Ot,{label:"Resource name",htmlFor:"trigger-label",children:(0,ht.jsx)(xa,{size:"comfortable",id:"trigger-label",value:e.value.label,onChange:o=>e.onChange({...e.value,label:o.target.value})})}),(0,ht.jsx)(Ot,{label:"Resource identifier",htmlFor:"trigger-identifier",help:"Use the exact provider resource identifier, not its display name.",children:(0,ht.jsx)(xa,{size:"comfortable",id:"trigger-identifier",value:e.value.identifier,onChange:o=>e.onChange({...e.value,identifier:o.target.value})})}),(0,ht.jsxs)("fieldset",{children:[(0,ht.jsx)("legend",{className:"mb-2 text-sm font-semibold",children:"Run on these events"}),(0,ht.jsx)("div",{className:"divide-y divide-dashboard-border-subtle rounded-md border border-dashboard-border-emphasis",children:a.supportedEvents.map(o=>(0,ht.jsxs)("label",{className:"flex min-h-11 cursor-pointer items-start gap-3 px-3 py-3 text-sm",children:[(0,ht.jsx)("input",{type:"checkbox",className:"mt-0.5 size-4 shrink-0 accent-dashboard-focus",checked:e.value.events.includes(o),onChange:()=>e.onChange({...e.value,events:e.value.events.includes(o)?e.value.events.filter(i=>i!==o):[...e.value.events,o]})}),(0,ht.jsxs)("span",{className:"min-w-0 break-words",children:[o.replaceAll("_"," ").replaceAll("."," \xB7 "),a.guidance?.[o]?(0,ht.jsx)("span",{className:"mt-1 block text-xs leading-relaxed text-dashboard-text-muted",children:a.guidance[o]}):null]})]},o))})]}),Object.keys(a.matchFields??{}).length?(0,ht.jsxs)("fieldset",{className:"grid gap-4",children:[(0,ht.jsx)("legend",{className:"mb-3 text-sm font-semibold",children:"Only when"}),(0,ht.jsx)("p",{className:"m-0 text-xs leading-relaxed text-dashboard-text-muted",children:"All conditions must match. Leave a field blank to match any value. Existing lists match any one listed value."}),Object.entries(a.matchFields??{}).map(([o,i])=>{let s=e.value.match?.[o];return(0,ht.jsx)(Ot,{label:o,htmlFor:`match-${o}`,help:i.description,children:Array.isArray(s)?(0,ht.jsxs)("div",{className:"text-sm",children:[(0,ht.jsx)("span",{className:"break-all",children:s.join(", ")})," ",(0,ht.jsx)(ie,{onClick:()=>n(o,void 0),children:"Remove condition"})]}):i.kind==="boolean"||i.enum?(0,ht.jsxs)(Wl,{id:`match-${o}`,value:s===void 0?"":String(s),onChange:l=>n(o,l.target.value===""?void 0:i.kind==="boolean"?l.target.value==="true":l.target.value),children:[(0,ht.jsx)("option",{value:"",children:"Any value"}),(i.enum??["true","false"]).map(l=>(0,ht.jsx)("option",{children:l},l))]}):(0,ht.jsx)(xa,{size:"comfortable",id:`match-${o}`,type:i.kind==="number"?"number":"text",step:"any",value:s===void 0?"":String(s),onChange:l=>n(o,l.target.value===""?void 0:i.kind==="number"?l.target.valueAsNumber:l.target.value)})},o)})]}):null]}):null,JSON.stringify(e.value)!==JSON.stringify(e.original)?(0,ht.jsx)(ie,{className:"w-fit",onClick:()=>e.onChange(e.original),children:"Keep saved trigger"}):null]})}function km(e,t){return typeof e.destination=="string"?e.destination==="task_creator"?"Creator \xB7 Direct message":`${t.label} \xB7 ${t.visibility}`:e.destination.channelId===t.channelId&&e.destination.teamId===t.teamId?`${t.label} \xB7 ${t.visibility}`:`Saved destination \xB7 ${e.destination.channelId}`}var aa=b(w(),1);function _1(e){return e.outcomes.length?(0,aa.jsx)("ol",{className:"m-0 grid gap-2 pl-5 text-sm",children:e.outcomes.map((t,a)=>(0,aa.jsx)("li",{children:km(t,e.destination)},a))}):(0,aa.jsx)("p",{className:"m-0 text-sm",children:"No success message"})}function xK(e){let t=e.original.length?e.original:[{action:"send_message",destination:"current_conversation"}],a=[...e.original.flatMap((r,n)=>typeof r.destination=="string"?[]:[{value:`saved:${n}`,label:km(r,e.destination),outcome:r}]),{value:"current_conversation",label:`${e.destination.label} \xB7 ${e.destination.visibility}`,outcome:{action:"send_message",destination:"current_conversation"}},{value:"task_creator",label:"Creator \xB7 Direct message",outcome:{action:"send_message",destination:"task_creator"}}];return(0,aa.jsxs)(aa.Fragment,{children:[(0,aa.jsxs)("fieldset",{children:[(0,aa.jsx)("legend",{className:"sr-only",children:"Success messages"}),(0,aa.jsx)("div",{className:"flex flex-wrap gap-x-6 gap-y-3",children:[!0,!1].map(r=>(0,aa.jsxs)("label",{className:"inline-flex min-h-8 cursor-pointer items-center gap-2 text-sm",children:[(0,aa.jsx)("input",{type:"radio",name:"messages",className:"size-4 accent-dashboard-focus",checked:!!e.value.length===r,onChange:()=>e.onChange(r?t:[])}),r?"Send a message":"No success message"]},String(r)))})]}),e.value.length?(0,aa.jsxs)("div",{className:"grid gap-4 sm:gap-2",children:[e.value.map((r,n)=>{let o=e.original.findIndex(i=>JSON.stringify(i)===JSON.stringify(r));return(0,aa.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,aa.jsxs)("span",{className:"w-4 text-xs text-dashboard-text-muted",children:[n+1,"."]}),(0,aa.jsx)("div",{className:I("min-w-0 flex-1",e.value.length>1&&"order-last basis-full sm:order-none sm:basis-auto"),children:(0,aa.jsx)(Wl,{"aria-label":`Message ${n+1} destination`,value:typeof r.destination=="string"?r.destination:`saved:${o}`,onChange:i=>{let s=a.find(l=>l.value===i.target.value);s&&e.onChange(e.value.map((l,c)=>c===n?s.outcome:l))},children:a.map(i=>(0,aa.jsx)("option",{value:i.value,children:i.label},i.value))})}),e.value.length>1?(0,aa.jsxs)(aa.Fragment,{children:[(0,aa.jsx)(ie,{size:"icon",className:"ml-auto sm:ml-0","aria-label":`Move message ${n+1} up`,disabled:n===0,onClick:()=>{let i=[...e.value];[i[n-1],i[n]]=[i[n],i[n-1]],e.onChange(i)},children:(0,aa.jsx)(Uy,{size:16})}),(0,aa.jsx)(ie,{size:"icon","aria-label":`Remove message ${n+1}`,onClick:()=>e.onChange(e.value.filter((i,s)=>s!==n)),children:(0,aa.jsx)(jn,{size:16})})]}):null]},n)}),e.value.length<5?(0,aa.jsxs)(ie,{className:"w-fit",onClick:()=>e.onChange([...e.value,{action:"send_message",destination:"task_creator"}]),children:[(0,aa.jsx)(Ku,{size:15}),"Add message"]}):null]}):(0,aa.jsx)("p",{className:"m-0 text-sm leading-relaxed text-dashboard-text-muted",children:"Junior still does the work. No message is sent after success."}),(0,aa.jsxs)("p",{className:"m-0 text-xs leading-relaxed text-dashboard-text-muted",children:[e.value.length?"Messages are sent in this order. ":"","This does not limit actions in the instruction."]})]})}var ce=b(w(),1);function wK(e){let[t,a]=(0,ps.useState)(e.automation),[r,n]=(0,ps.useState)(()=>L1(e.automation)),[o,i]=(0,ps.useState)({}),[s,l]=(0,ps.useState)(),c=(0,ps.useRef)(null),d=(0,ps.useRef)(!1),f=gn(),m=Bt(),p=vK(t,r),h=Object.keys(p).length>0,g={kind:t.kind,revision:t.revision,...p},x=MN(()=>h&&!d.current),y=(0,ps.useRef)(null);(0,ps.useEffect)(()=>{x.state==="blocked"&&y.current?.focus()},[x.state]);let v=`/api/automations/${t.kind}/${encodeURIComponent(t.id)}`;(0,ps.useEffect)(()=>{let Z=fe=>{h&&!d.current&&(fe.preventDefault(),fe.returnValue="")};return window.addEventListener("beforeunload",Z),()=>window.removeEventListener("beforeunload",Z)},[h]);let S=()=>requestAnimationFrame(()=>(c.current?.querySelector('[aria-invalid="true"]')??c.current?.querySelector("[data-save-error]"))?.focus()),C=ga({mutationFn:()=>mg(ds,v,g),onSuccess:async()=>{d.current=!0,await m.invalidateQueries({queryKey:["dashboard","automations"]}),f(e.returnPath,{state:{automationSaved:!0}})},onError:Z=>{i(Z instanceof yn?Z.fields??{}:{}),S()}});function L(Z){s&&(n(Z?{...L1(s),...p}:L1(s)),a(s),l(void 0),C.reset(),i({}))}let T=ga({mutationFn:()=>Ne(ds,`${v}/edit`),onSuccess:l}),_=C.error instanceof yn&&C.error.code==="conflict",k=Z=>n(fe=>({...fe,...Z})),j=Z=>Object.entries(o).filter(([fe])=>fe===Z||fe.startsWith(`${Z}.`)).flatMap(([,fe])=>fe).join(" ")||void 0,F=t.kind==="scheduled"?"schedule":"trigger",ue=t.ownedByViewer,z=e.summary.createdBy,Y=!ue&&t.credentialMode==="creator"&&(p.instruction!==void 0||t.kind==="event"&&p.trigger!==void 0),ee=j(F),ve=Z=>({"aria-invalid":!!j(Z)||void 0,"aria-describedby":j(Z)?`${Z}-error`:void 0});return(0,ce.jsxs)("form",{ref:c,noValidate:!0,onSubmit:Z=>{if(Z.preventDefault(),C.isPending||_||!h)return;let fe=FE.safeParse(g);if(!fe.success){let Q={};for(let se of fe.error.issues)(Q[se.path.join(".")]??=[]).push(se.message);i(Q),S();return}i({}),C.mutate()},children:[x.state==="blocked"?(0,ce.jsx)("div",{tabIndex:-1,ref:y,className:"mb-6 outline-none",children:(0,ce.jsxs)(Yr,{title:"Discard unsaved changes?",children:[(0,ce.jsx)("p",{children:"Your changes have not been saved."}),(0,ce.jsxs)("div",{className:"flex gap-2",children:[(0,ce.jsx)(ie,{onClick:()=>x.reset(),children:"Keep editing"}),(0,ce.jsx)(ie,{onClick:()=>x.proceed(),children:"Discard changes"})]})]})}):null,C.error||Object.keys(o).length?(0,ce.jsx)("div",{tabIndex:-1,"data-save-error":!0,className:"mb-6 outline-none",children:(0,ce.jsxs)(Yr,{tone:_?"warning":"error",title:_?"This automation changed while you were editing.":"Changes could not be saved.",children:[(0,ce.jsxs)("p",{className:"mt-1",children:["Your edits are still here."," ",_?"Review the latest version before saving again.":C.error instanceof yn?C.error.apiError:"Check the fields below, or try again."]}),_?(0,ce.jsx)(ie,{disabled:T.isPending,onClick:()=>T.mutate(),children:T.isPending?"Loading\u2026":"Review latest version"}):null,T.error?(0,ce.jsx)("p",{role:"alert",children:"The latest version could not be loaded. Try again."}):null]})}):null,s?(0,ce.jsx)("div",{className:"mb-6",children:(0,ce.jsxs)(Yr,{title:"Compare your edits with the latest saved version",children:[(0,ce.jsx)("p",{children:"Only the fields you changed are shown. Keeping your edits will replace these fields. Other saved fields stay unchanged."}),Object.entries(p).map(([Z,fe])=>(0,ce.jsxs)("section",{className:"my-4",children:[(0,ce.jsx)("h3",{className:"text-sm font-semibold capitalize",children:Z==="credentialMode"?"Credentials":Z}),(0,ce.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,ce.jsxs)("div",{children:[(0,ce.jsx)("p",{children:"Latest saved"}),(0,ce.jsx)("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm",children:SK(Z==="schedule"&&s.kind==="scheduled"?T1(s):s[Z])})]}),(0,ce.jsxs)("div",{children:[(0,ce.jsx)("p",{children:"Your edit"}),(0,ce.jsx)("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm",children:SK(fe)})]})]})]},Z)),(0,ce.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,ce.jsx)(ie,{onClick:()=>L(!0),children:"Keep my changed fields"}),(0,ce.jsx)(ie,{onClick:()=>L(!1),children:"Use latest saved version"})]})]})}):null,ue?null:(0,ce.jsxs)("p",{className:"mt-0 mb-6 max-w-2xl text-sm leading-relaxed text-dashboard-text-muted",children:[z," created this automation. You can edit it because it is in a public channel. Only ",z," can change where results go or turn on their connected accounts. Version history keeps every saved change."]}),(0,ce.jsxs)("fieldset",{disabled:C.isPending,className:"min-w-0",children:[(0,ce.jsxs)(ms,{title:"What to do",detail:"Give Junior a clear instruction and a name you can find later.",children:[(0,ce.jsx)(Ot,{label:"Title",htmlFor:"title",error:j("title"),children:(0,ce.jsx)(xa,{size:"comfortable",id:"title",value:r.title,placeholder:e.summary.title,onChange:Z=>k({title:Z.target.value}),...ve("title")})}),(0,ce.jsxs)(Ot,{label:"Instruction",htmlFor:"instruction",error:j("instruction"),children:[(0,ce.jsx)(tc,{prose:!0,id:"instruction",rows:8,value:r.instruction,onChange:Z=>k({instruction:Z.target.value}),...ve("instruction"),className:"resize-y text-base sm:text-sm"}),(0,ce.jsxs)("p",{className:"m-0 text-right text-xs text-dashboard-text-muted",children:[r.instruction.length.toLocaleString()," / 4,000"]})]})]}),(0,ce.jsx)(ms,{title:"When to run",detail:t.kind==="scheduled"?"Choose a schedule in a specific timezone.":"Run when a matching event occurs.",children:(0,ce.jsxs)("div",{id:`${F}-error`,tabIndex:-1,"aria-invalid":!!ee||void 0,className:"grid min-w-0 gap-5 outline-none",children:[ee?(0,ce.jsx)("p",{role:"alert",className:"m-0 text-sm text-rose-300",children:ee}):null,t.kind==="scheduled"?(0,ce.jsx)(yK,{automation:t,value:r.schedule,onChange:Z=>k({schedule:Z})}):(0,ce.jsx)(bK,{value:r.trigger??t.trigger,original:t.trigger,onChange:Z=>k({trigger:Z})})]})}),(0,ce.jsxs)(ms,{title:"Where results go",detail:"Choose who gets a message after successful work.",children:[j("outcomes")?(0,ce.jsx)("p",{role:"alert",className:"m-0 text-sm text-rose-300",children:j("outcomes")}):null,ue?(0,ce.jsx)(xK,{value:r.outcomes,original:t.outcomes,destination:e.summary.destination,onChange:Z=>k({outcomes:Z})}):(0,ce.jsxs)(ce.Fragment,{children:[(0,ce.jsx)(_1,{outcomes:t.outcomes,destination:e.summary.destination}),(0,ce.jsxs)("p",{className:"m-0 text-xs text-dashboard-text-muted",children:["Only ",z," can change where results go."]})]})]}),(0,ce.jsxs)(ms,{title:"Credentials",detail:"Choose which connected accounts Junior can use.",children:[(0,ce.jsxs)("fieldset",{className:"divide-y divide-dashboard-border-subtle rounded-md border border-dashboard-border-emphasis",children:[(0,ce.jsx)("legend",{className:"sr-only",children:"Credential mode"}),[["creator",ue?"Your connected accounts":`${z}\u2019s connected accounts`,ue?"Uses accounts connected by you, the creator.":`Uses accounts connected by ${z}. Only ${z} can turn this on.`],["system","System credentials only",ue?"Does not use your connected accounts. Some work may not be possible.":"Does not use anyone\u2019s connected accounts. Some work may not be possible."]].map(([Z,fe,Q])=>(0,ce.jsxs)("label",{className:"flex cursor-pointer items-start gap-3 px-4 py-4 has-checked:bg-dashboard-fill-soft has-disabled:cursor-not-allowed has-disabled:opacity-60",children:[(0,ce.jsx)("input",{type:"radio",name:"credentials",className:"mt-0.5 size-4 shrink-0 accent-dashboard-focus",checked:Y?Z==="system":r.credentialMode===Z,disabled:Z==="creator"&&!ue&&(t.credentialMode!=="creator"||Y),onChange:()=>k({credentialMode:Z})}),(0,ce.jsxs)("span",{children:[(0,ce.jsx)("span",{className:"block text-sm font-medium",children:fe}),(0,ce.jsx)("span",{className:"mt-1 block text-xs leading-relaxed text-dashboard-text-muted",children:Q})]})]},Z))]}),Y?(0,ce.jsxs)(Yr,{title:"Saving switches this automation to system credentials.",children:["Only ",z," can let a changed instruction",t.kind==="event"?" or trigger":""," use their connected accounts."]}):null,j("credentialMode")?(0,ce.jsx)("p",{role:"alert",children:j("credentialMode")}):null]})]}),(0,ce.jsx)("p",{className:"mb-5 text-xs leading-relaxed text-dashboard-text-muted sm:hidden",children:"Changes apply to future work. Saving does not run this automation."}),(0,ce.jsx)("div",{className:"sticky bottom-0 z-20 -mx-4 border-t border-dashboard-border-emphasis bg-dashboard-bg px-4 py-4 sm:-mx-8 sm:px-8",children:(0,ce.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ce.jsxs)("div",{className:"min-w-0 flex-1",role:"status",children:[(0,ce.jsx)("p",{className:"m-0 text-xs font-medium sm:text-sm",children:C.isPending?"Saving\u2026":h?"Unsaved changes":"Unchanged"}),(0,ce.jsx)("p",{className:"mt-1 mb-0 hidden text-xs text-dashboard-text-muted sm:block",children:"Changes apply to future work. Saving does not run it."})]}),(0,ce.jsxs)("div",{className:"flex shrink-0 gap-2",children:[(0,ce.jsx)(ae,{to:e.returnPath,className:"inline-flex min-h-11 items-center rounded border border-dashboard-border-emphasis px-3 text-sm text-dashboard-text no-underline sm:min-h-9",children:"Cancel"}),(0,ce.jsx)(ie,{type:"submit",tone:"primary",className:"min-h-11 sm:min-h-9",disabled:!h||C.isPending||_,children:"Save changes"})]})]})})]})}function SK(e){return e==null?"Not set":typeof e=="string"?e:JSON.stringify(e,null,2)}var Cg=b(w(),1);function CK(){return(0,Cg.jsx)("div",{role:"status","aria-label":"Loading automation editor",children:["What to do","When to run","Where results go","Credentials"].map((e,t)=>(0,Cg.jsxs)(ms,{title:e,children:[(0,Cg.jsx)(Qe,{className:"h-4 w-24"}),(0,Cg.jsx)(Qe,{className:t===0?"h-48 w-full":"h-20 w-full"})]},e))})}var Mt=b(w(),1);function kK(e){let{kind:t,automationId:a}=Ba(),r=vt(),n=hg(e.enabled,a),o=n.data&&!(n.data.kind==="scheduled"&&n.data.status==="completed"),i=Ue({queryKey:["dashboard","automations","edit",t,a],enabled:e.enabled&&!!o&&n.data?.kind===t,retry:!1,queryFn:({signal:f})=>Ne(ds,`/api/automations/${t}/${encodeURIComponent(a)}/edit`,f)}),s=`/automations/list${r.search}`,l=n.data,c=l?.kind==="event"?l.status!=="active"?l.status:l.triggerAvailable?"active":"unavailable":l?.status,d=c==="active"?"success":c==="blocked"||c==="unavailable"?"warning":"neutral";return(0,Mt.jsx)(Sz,{children:(0,Mt.jsxs)("div",{className:"mx-auto w-full min-w-0 max-w-5xl px-4 pt-7 sm:px-8 sm:pt-9",children:[(0,Mt.jsxs)(ae,{to:s,className:"inline-flex min-h-8 items-center gap-2 text-sm text-dashboard-text-muted no-underline hover:text-dashboard-text",children:[(0,Mt.jsx)(Zr,{"aria-hidden":!0,size:15}),"All automations"]}),(0,Mt.jsxs)("div",{className:"mt-4 mb-8 flex flex-wrap items-start justify-between gap-4",children:[(0,Mt.jsxs)("div",{className:"min-w-0",children:[(0,Mt.jsx)("h1",{className:"m-0 break-words font-display text-3xl font-light tracking-tight",children:l&&!o?l.title:"Edit automation"}),l?(0,Mt.jsxs)("p",{className:"mt-2 mb-0 text-sm text-dashboard-text-muted",children:["Created by ",l.ownedByViewer?"you":l.createdBy," \xB7"," ",l.destination.label]}):null]}),l?(0,Mt.jsxs)("div",{className:"flex items-center gap-4",children:[(0,Mt.jsx)(ae,{to:`/automations/${l.kind}/${encodeURIComponent(l.id)}/versions${r.search}`,className:"text-sm text-dashboard-text-muted underline underline-offset-2 hover:text-dashboard-text",children:"Version history"}),(0,Mt.jsx)(ba,{tone:d,children:c==="unavailable"?"Trigger unavailable":c})]}):null]}),!l&&n.error||!i.data&&i.error||l&&l.kind!==t?(0,Mt.jsxs)(Yr,{tone:"error",title:"Automation could not be loaded.",children:["It may no longer be available, or you may not have access."," ",(0,Mt.jsx)(ie,{onClick:()=>{n.refetch(),o&&i.refetch()},children:"Try again"})]}):!l||o&&!i.data?(0,Mt.jsx)(CK,{}):o&&i.data?(0,Mt.jsx)(wK,{automation:i.data,summary:l,returnPath:s},`${t}:${a}`):(0,Mt.jsx)(axe,{automation:l})]})})}function axe({automation:e}){return(0,Mt.jsxs)(Mt.Fragment,{children:[(0,Mt.jsx)("p",{className:"mb-6 text-sm text-dashboard-text-muted",children:"This automation has completed and cannot be edited. It will not run again."}),(0,Mt.jsx)(ms,{title:"What to do",detail:"The saved instruction.",children:(0,Mt.jsx)("p",{className:"m-0 whitespace-pre-wrap break-words text-sm leading-relaxed",children:e.instruction})}),(0,Mt.jsx)(ms,{title:"When to run",detail:"The saved trigger.",children:e.kind==="scheduled"?(0,Mt.jsxs)("p",{className:"m-0 text-sm",children:[e.schedule," \xB7 ",e.timezone]}):(0,Mt.jsxs)("div",{className:"grid gap-3 text-sm",children:[(0,Mt.jsx)("p",{className:"m-0 break-words",children:e.resource}),(0,Mt.jsx)("p",{className:"m-0 break-words",children:e.events.join(", ")}),e.match?(0,Mt.jsx)("pre",{className:"whitespace-pre-wrap break-words text-xs",children:JSON.stringify(e.match,null,2)}):null]})}),(0,Mt.jsx)(ms,{title:"Where results go",detail:"Messages after successful work.",children:(0,Mt.jsx)(_1,{outcomes:e.outcomes,destination:e.destination})}),(0,Mt.jsx)(ms,{title:"Credentials",detail:"The accounts Junior can use.",children:(0,Mt.jsx)("p",{className:"m-0 text-sm",children:e.credentialMode==="creator"?`Uses ${e.ownedByViewer?"your":`${e.createdBy}\u2019s`} connected accounts.`:"System credentials only."})})]})}var ip=b(G(),1);var IK=b(G(),1);function N1(){return(0,IK.useSyncExternalStore)(e=>Il.subscribe(e),()=>Il.isOnline(),()=>!0)}var TK=b(w(),1);function LK(){return N1()?null:(0,TK.jsx)("div",{"aria-live":"polite",className:"border-t border-amber-300/15 bg-amber-300/[0.07] px-3 py-1.5 text-center font-sans text-xs text-amber-100/80",role:"status",children:"You\u2019re offline. Drafts stay on this device."})}var Cz=b(w(),1);function A1(){return(0,Cz.jsx)("div",{className:"relative grid size-10 shrink-0 select-none place-items-center overflow-visible",children:(0,Cz.jsx)("img",{alt:"",className:"relative size-11 max-w-none -translate-y-0.5 object-contain opacity-90 drop-shadow-[0_0_7px_rgba(255,255,255,0.16)]",draggable:!1,src:"/_junior/dashboard/avatar.png"})})}var RK=["relative","overflow-hidden","bg-white/15","before:absolute","before:inset-0","before:content-['']","before:bg-[linear-gradient(90deg,#ff4d6d,#ffb703,#56f39a,#4cc9f0,#9b5de5,#ff4d6d)]","before:bg-[length:200%_100%]","before:animate-[junior-rainbow-flow_1.2s_linear_infinite]","motion-reduce:before:animate-none"].join(" ");var $d=b(w(),1);function Tn(e){return(0,$d.jsx)("div",{className:I(Ya,"grid min-h-[calc(100dvh-5rem)] place-items-center px-4 py-8 md:px-8"),children:(0,$d.jsxs)("section",{className:"grid w-full max-w-lg grid-cols-[auto_minmax(0,1fr)] items-center gap-3 rounded-lg border border-dashboard-border-emphasis bg-dashboard-surface-raised p-4",children:[(0,$d.jsx)(A1,{}),(0,$d.jsxs)("div",{children:[(0,$d.jsx)("div",{className:"font-bold",children:e.label}),(0,$d.jsx)("div",{"aria-label":e.label,className:`${RK} mt-3 h-1.5 w-full`,role:"progressbar"})]})]})})}var kz="0.241.0",$1=typeof kz=="string"&&kz.trim()?kz:"unknown";var Cx=b(w(),1);function _K(e){return nxe(e.serverVersion)?(0,Cx.jsxs)("div",{"aria-live":"polite",className:"flex flex-wrap items-center justify-center gap-x-3 gap-y-1 border-t border-cyan-300/15 bg-cyan-300/[0.07] px-3 py-1.5 text-center font-sans text-xs text-cyan-100/80",role:"status",children:[(0,Cx.jsx)("span",{children:"The dashboard changed. Refresh to load the latest version."}),(0,Cx.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0 font-mono font-semibold text-cyan-100 underline decoration-cyan-300/40 underline-offset-2 hover:text-dashboard-text-solid",onClick:()=>window.location.reload(),type:"button",children:"Refresh"})]}):null}function nxe(e){return!!e&&$1!=="unknown"&&e!=="unknown"&&e!==$1}var kx=b(w(),1);function ac(e){return(0,kx.jsxs)(Co,{children:[(0,kx.jsx)(We,{description:e.description,title:e.title}),(0,kx.jsx)(Yn,{label:e.label,variant:e.variant})]})}var iu=b(G(),1);var P1={"angular-html":()=>import("./chunks/angular-html-ZNDXTZDN.js"),"angular-ts":()=>import("./chunks/angular-ts-ON3WFVNV.js"),astro:()=>import("./chunks/astro-TCFNN3TA.js"),blade:()=>import("./chunks/blade-XRKVUGGE.js"),c:()=>import("./chunks/c-WHCDUHJR.js"),coffee:()=>import("./chunks/coffee-NWMA7ZVV.js"),coffeescript:()=>import("./chunks/coffee-NWMA7ZVV.js"),cpp:()=>import("./chunks/cpp-7ZDYJCCI.js"),"c++":()=>import("./chunks/cpp-7ZDYJCCI.js"),css:()=>import("./chunks/css-XF3SDJYW.js"),csv:()=>import("./chunks/csv-I2Y5BPVG.js"),glsl:()=>import("./chunks/glsl-SDKJ4MVB.js"),graphql:()=>import("./chunks/graphql-XJBKAS4G.js"),gql:()=>import("./chunks/graphql-XJBKAS4G.js"),haml:()=>import("./chunks/haml-QQIA6ZDV.js"),handlebars:()=>import("./chunks/handlebars-A4STSCQ6.js"),hbs:()=>import("./chunks/handlebars-A4STSCQ6.js"),html:()=>import("./chunks/html-T3MIDC6T.js"),"html-derivative":()=>import("./chunks/html-derivative-A5ABNIZH.js"),http:()=>import("./chunks/http-VGZ3EXS5.js"),hurl:()=>import("./chunks/hurl-TO4NQQLI.js"),imba:()=>import("./chunks/imba-P3ARIZRP.js"),java:()=>import("./chunks/java-WCBM5OUU.js"),javascript:()=>import("./chunks/javascript-TQH7GGAM.js"),js:()=>import("./chunks/javascript-TQH7GGAM.js"),cjs:()=>import("./chunks/javascript-TQH7GGAM.js"),mjs:()=>import("./chunks/javascript-TQH7GGAM.js"),jinja:()=>import("./chunks/jinja-UYMB4X6S.js"),jison:()=>import("./chunks/jison-ED4UFXGK.js"),json:()=>import("./chunks/json-XRHV7G5W.js"),json5:()=>import("./chunks/json5-2OA2ZMVI.js"),jsonc:()=>import("./chunks/jsonc-KO53QF6Y.js"),jsonl:()=>import("./chunks/jsonl-GHTNFMM6.js"),jsx:()=>import("./chunks/jsx-V5TSP3NI.js"),julia:()=>import("./chunks/julia-EI7BACOV.js"),jl:()=>import("./chunks/julia-EI7BACOV.js"),less:()=>import("./chunks/less-FPWZXUDW.js"),markdown:()=>import("./chunks/markdown-QWIM2DOI.js"),md:()=>import("./chunks/markdown-QWIM2DOI.js"),marko:()=>import("./chunks/marko-3POAQSZY.js"),mdc:()=>import("./chunks/mdc-KT6TTBUF.js"),mdx:()=>import("./chunks/mdx-CWS3UMSH.js"),php:()=>import("./chunks/php-3CK4FBZI.js"),postcss:()=>import("./chunks/postcss-7K34RN34.js"),pug:()=>import("./chunks/pug-IEW5PJRA.js"),jade:()=>import("./chunks/pug-IEW5PJRA.js"),python:()=>import("./chunks/python-GCPXLELR.js"),py:()=>import("./chunks/python-GCPXLELR.js"),r:()=>import("./chunks/r-XV5O7BSV.js"),regexp:()=>import("./chunks/regexp-655IUQFI.js"),regex:()=>import("./chunks/regexp-655IUQFI.js"),sass:()=>import("./chunks/sass-MSBN6O54.js"),scss:()=>import("./chunks/scss-N73GNFL4.js"),shellscript:()=>import("./chunks/shellscript-OPDT4ZZ3.js"),bash:()=>import("./chunks/shellscript-OPDT4ZZ3.js"),sh:()=>import("./chunks/shellscript-OPDT4ZZ3.js"),shell:()=>import("./chunks/shellscript-OPDT4ZZ3.js"),zsh:()=>import("./chunks/shellscript-OPDT4ZZ3.js"),sql:()=>import("./chunks/sql-ZR72I7RP.js"),stylus:()=>import("./chunks/stylus-NVEQWGLA.js"),styl:()=>import("./chunks/stylus-NVEQWGLA.js"),svelte:()=>import("./chunks/svelte-ZZAXFLSI.js"),"ts-tags":()=>import("./chunks/ts-tags-MCSPJMMM.js"),lit:()=>import("./chunks/ts-tags-MCSPJMMM.js"),tsx:()=>import("./chunks/tsx-ZTNB67YL.js"),typescript:()=>import("./chunks/typescript-HV6B525T.js"),ts:()=>import("./chunks/typescript-HV6B525T.js"),cts:()=>import("./chunks/typescript-HV6B525T.js"),mts:()=>import("./chunks/typescript-HV6B525T.js"),vue:()=>import("./chunks/vue-WXFFFGZ3.js"),"vue-html":()=>import("./chunks/vue-html-SKWAUQDE.js"),"vue-vine":()=>import("./chunks/vue-vine-V3A5HTCZ.js"),wasm:()=>import("./chunks/wasm-JWJ5BADC.js"),wgsl:()=>import("./chunks/wgsl-ZCQ7MKDM.js"),wit:()=>import("./chunks/wit-MLLAONFF.js"),xml:()=>import("./chunks/xml-VST5CLIL.js"),yaml:()=>import("./chunks/yaml-BX3BWN2A.js"),yml:()=>import("./chunks/yaml-BX3BWN2A.js")};var NK="Junior";function Ft(){return typeof window>"u"?NK:window.__JUNIOR_DASHBOARD_AGENT_NAME__?.trim()||NK}function AK(e=Ft()){return e.endsWith("s")?`${e}'`:`${e}'s`}var D1=b(w(),1);function to(e){if(typeof e!="number"||!Number.isFinite(e))return"";let t=Math.max(0,Math.floor(e));if(t<1e3)return`${t}ms`;if(t<6e4){let n=t/1e3;return`${n.toFixed(n<10?1:0)}s`}let a=[],r=[["mo",2592e6],["d",864e5],["h",36e5],["m",6e4],["s",1e3]];for(let[n,o]of r){let i=Math.floor(t/o);if(i!==0){if(a.push(`${i}${n}`),a.length===2)break;t%=o}}return a.join(" ")}function nc(e){return(0,D1.jsx)(D1.Fragment,{children:to(e.value)||e.fallback||null})}function Ix(e){return Date.parse(e.createdAt)}function Pd(e,t,a){return{parts:a,role:t,sourceSeq:e.seq,timestamp:Ix(e)}}function rxe(e){let t=new Set;for(let a of e){let r=a.data;r.type==="handoff"&&r.triggeringToolCallId&&t.add(r.triggeringToolCallId),r.type==="subagent"&&r.parentToolCallId&&t.add(r.parentToolCallId)}return t}function oxe(e){let t=new Set;for(let a of e)a.messageId&&t.add(a.messageId);return t}function ixe(e,t){return{delivery:e.delivery,messageId:e.messageId,parts:e.redacted?[{type:"text",redacted:!0}]:[{type:"text",text:e.text??""}],...e.attachments?{attachments:e.attachments}:void 0,pending:!0,role:"user",source:e.source,sourceSeq:Number.MAX_SAFE_INTEGER-1e6+t,timestamp:Date.parse(e.createdAt),...e.actorIdentity?{actorIdentity:e.actorIdentity}:void 0}}function sxe(e,t){if(!t?.length)return e;let a=lxe(e,t);return a.length===0?e:[...e,...a]}function lxe(e,t){if(!t?.length)return[];let a=oxe(e);return t.filter(r=>!a.has(r.messageId)).map((r,n)=>ixe(r,n))}function Iz(e,t){return Lz(e.events,e.annotations,t)}function Lz(e,t,a){let r=rxe(e),n=new Map,o=new Map,i=new Map,s=[],l=new Map,c=new Map,d,f=(p,h)=>{if(r.has(h.toolCallId))return;let g="output"in h?h.output:void 0,x=n.get(h.toolCallId);if(x){x.name=h.name,x.status=h.status,h.input!==void 0&&(x.input=h.input),g!==void 0&&(x.output=g),x.startedTimestamp===void 0&&h.startedAt&&(x.startedTimestamp=Date.parse(h.startedAt)),h.status!=="running"&&(x.resultTimestamp=Ix(p));return}let y={type:"tool_call",id:h.toolCallId,name:h.name,status:h.status,...h.input===void 0?void 0:{input:h.input},...g===void 0?void 0:{output:g},...h.status==="running"?void 0:{resultTimestamp:Ix(p)}},v={...Pd(p,"tool",[y]),sourceSeq:h.startedSeq??p.seq,timestamp:h.startedAt?Date.parse(h.startedAt):Ix(p)};n.set(h.toolCallId,y),o.set(h.toolCallId,v),s.push(v)};for(let p of e){let h=p.data;if(h.type==="message"){let g={...Pd(p,h.role,[h.redacted?{type:"text",redacted:!0}:{type:"text",text:h.text}]),messageId:h.messageId,...h.attachments?{attachments:h.attachments}:void 0,...h.cards?{cards:SE(h.cards,t??[])}:void 0,...h.actorIdentity?{actorIdentity:h.actorIdentity}:void 0,...h.eventType?{eventType:h.eventType}:void 0,eventObjectType:h.eventObjectType,...h.trustedSummary?{trustedSummary:h.trustedSummary}:void 0,...h.explicitMention!==void 0?{explicitMention:h.explicitMention}:void 0,...h.source?{source:h.source}:void 0};s.push(g),l.set(g.messageId,g),g.role==="user"&&(d=g);continue}if(h.type==="message_handled"){let g=l.get(h.messageId);g?.role==="user"&&g.explicitMention===!1&&!g.eventType&&(g.context=!0);continue}if(h.type==="assistant_message"){if(h.parts.length===0)continue;s.push(Pd(p,"assistant",h.parts.map(g=>g.redacted?{type:"reasoning",redacted:!0}:{type:"reasoning",text:g.text})));continue}if(h.type==="turn_lifecycle"&&h.state==="started"){let g=h.inputMessageIds?.map(y=>l.get(y)).filter(y=>y!==void 0),x=g?.slice().reverse().find(y=>y.role==="user");x?c.set(h.turnId,x):d&&c.set(h.turnId,d);for(let y of g??[])y.role==="user"&&y.explicitMention===!1&&!y.eventType&&(y.context=!0);continue}if(h.type==="turn_routed"){let g=c.get(h.turnId);g&&(g.route={modelProfile:h.modelProfile,modelId:h.modelId,reasoningLevel:h.reasoningLevel,...h.confidence!==void 0?{confidence:h.confidence}:void 0,source:h.source});continue}if(h.type==="turn_context"){let g=c.get(h.turnId);g&&(g.contexts??=[],g.contexts.push({content:h.content,kind:h.kind,loadedAt:p.createdAt,pluginName:h.pluginName,version:h.version}));continue}if(h.type==="tool_calls"){for(let g of h.calls)f(p,g);if(h.assistant){let g=[];for(let x of h.assistant.parts){if(x.type==="reasoning"){g.push(x.redacted?{type:"reasoning",redacted:!0}:{type:"reasoning",text:x.text});continue}if(r.has(x.toolCallId))continue;let y=n.get(x.toolCallId);if(!y)continue;let v=o.get(x.toolCallId);if(v){v.sourceSeq!==p.seq&&(y.startedTimestamp=v.timestamp);let S=s.indexOf(v);S>=0&&s.splice(S,1),o.delete(x.toolCallId)}g.push(y)}g.length>0&&s.push(Pd(p,"assistant",g))}continue}if(h.type==="subagent"){let g=`${h.childConversationId}:${h.startedSeq}`,x=i.get(g);if(x){x.status=h.status;continue}let y={type:"subagent",id:g,childConversationId:h.childConversationId,subagentKind:h.subagentKind,status:h.status};i.set(g,y),s.push({...Pd(p,"tool",[y]),sourceSeq:h.startedSeq,timestamp:Date.parse(h.startedAt)});continue}if(h.type==="structured_event"){s.push(Pd(p,"system",[{type:"structured_event",namespace:h.namespace,name:h.name,version:h.version,presentation:h.presentation}]));continue}if(h.type==="attachments_delivered"){s.push(Pd(p,"system",[{type:"attachments_delivered",attachments:h.attachments}]));continue}if(h.type==="compaction"||h.type==="handoff"){s.push(Pd(p,"system",[{type:"context_event",event:h.type==="handoff"?{type:h.type,createdAt:p.createdAt,modelId:h.modelId,modelProfile:h.modelProfile,...h.summary?{summary:h.summary}:void 0,...h.reasoningLevel?{reasoningLevel:h.reasoningLevel}:void 0}:{type:h.type,createdAt:p.createdAt,...h.modelId?{modelId:h.modelId}:void 0,...h.modelProfile?{modelProfile:h.modelProfile}:void 0,...h.summary?{summary:h.summary}:void 0,...h.details?{details:h.details}:void 0}}]));continue}if(h.type==="turn_lifecycle"&&h.state==="failed"){s.push({role:h.failureCode==="delivery_failed"?"system":"assistant",failureCode:h.failureCode,...h.failureReason?{failureReason:h.failureReason}:void 0,...h.eventId?{eventId:h.eventId}:void 0,...h.sentryEventUrl?{sentryEventUrl:h.sentryEventUrl}:void 0,parts:[],sourceSeq:p.seq,timestamp:Ix(p)});continue}}let m=s.filter(p=>p.role!=="user"||p.eventType!==void 0||p.explicitMention!==!1||p.context===!0).sort((p,h)=>p.sourceSeq-h.sourceSeq);return sxe(m,a)}function $K(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return"UTC"}}var Rz=$K();function PK(e){Rz=e||$K()}function Ed(){return Rz}function M1(){return Rz}function uxe(e){return e.status==="active"}function cxe(e){return e.status==="failed"}function dxe(e){return e.status==="active"}function fxe(e){return e.status==="failed"}function O1(e){if(!e)return null;let t=Date.parse(e);return Number.isFinite(t)?t:null}function Rn(e,t){let a=O1(e);return a==null?"none":new Date(a).toLocaleString(void 0,{...t,timeZone:M1()})}function ao(e){let t=O1(e);if(t==null)return"not updated yet";let a=Math.round((t-Date.now())/1e3),r=Math.abs(a),n=[["year",3600*24*365],["month",3600*24*30],["week",3600*24*7],["day",3600*24],["hour",3600],["minute",60]];for(let[o,i]of n)if(r>=i)return new Intl.RelativeTimeFormat(void 0,{numeric:"auto"}).format(Math.round(a/i),o);return"just now"}function Lm(e){if(typeof e!="number"||!Number.isFinite(e))return"none";let t=Math.max(0,Math.floor(e));if(t<1e3)return`${t}ms`;let a=t/1e3;if(a<60)return`${a.toFixed(a<10?1:0)}s`;let r=Math.round(a),n=Math.floor(r/60),o=r%60;return`${n}m ${o}s`}function DK(e){if(e===void 0)return;let t=typeof e=="string"?e:JSON.stringify(e);if(t===void 0)return;let a=new TextEncoder().encode(t).byteLength;return a<1e3?`${a}b`:`${Math.round(a/1e3)}kb`}function z1(e,t){if(!(typeof e!="number"||typeof t!="number"||t<e))return Lm(t-e)}function Tx(e){if(typeof e!="number"||!Number.isFinite(e))return"";let t=Math.max(0,Math.floor(e));return t===0?"":to(t)}function ca(e,t=!1){if(typeof e!="number"||!Number.isFinite(e))return"no timestamp";let a=new Date(e);return t?a.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium",timeZone:M1()}):a.toLocaleTimeString(void 0,{timeZone:M1()})}function EK(e){if(typeof e!="number"||!Number.isFinite(e))return"no timestamp";let t=Math.round((e-Date.now())/1e3),a=Math.abs(t),r=[["year",3600*24*365],["month",3600*24*30],["week",3600*24*7],["day",3600*24],["hour",3600]],[n,o]=r.find(([,i])=>a>=i)??r.at(-1);return new Intl.RelativeTimeFormat(void 0,{numeric:"auto"}).format(Math.round(t/o),n)}function MK(e){let t=new Date(e),a={dateStyle:"medium",timeStyle:"long"};return{local:t.toLocaleString(void 0,{...a,timeZone:M1()}),utc:t.toLocaleString(void 0,{...a,timeZone:"UTC"})}}function OK(e){if(typeof e!="number"||!Number.isFinite(e))return"0";let t=Math.max(0,Math.floor(e));if(t<1e3)return String(t);let a=[["t",1e12],["b",1e9],["m",1e6],["k",1e3]],[r,n]=a.find(([,s])=>t>=s)??a[1],o=t/n;return`${o>=100||Number.isInteger(o)||o>=10?Math.round(o).toString():(Math.floor(o*10)/10).toFixed(1).replace(/\.0$/,"")}${r}`}function Im(e){return typeof e=="number"&&Number.isFinite(e)?Math.max(0,Math.floor(e)):void 0}function mxe(e){return[e.inputTokens,e.outputTokens,e.cachedInputTokens,e.cacheCreationTokens].reduce((t,a)=>{let r=Im(a);return r===void 0?t:(t??0)+r},void 0)}function Tm(e){let t=e.toLowerCase();return t==="assistant"?"assistant":t==="user"?"user":t==="system"?"system":t.includes("tool")?"tool":"other"}function Md(e,t){let a=Tm(t.role);return a==="assistant"?Ft():a==="user"?Dd(t.actorIdentity)??Dd(e.actorIdentity)??"User":a==="system"?"System":a==="tool"?"Tool":t.role||"Unknown"}function re(e){return OK(e)}function ai(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?"0":e<10?(Math.round(e*10)/10).toFixed(1).replace(/\.0$/,""):re(e)}function kg(e){if(!e)return;let t={totalTokens:0};t.reasoningTokens=Im(e.reasoningTokens);let a=mxe(e);if(a!==void 0)t.totalTokens=a,t.inputTokens=Im(e.inputTokens),t.outputTokens=Im(e.outputTokens),t.cachedInputTokens=Im(e.cachedInputTokens),t.cacheCreationTokens=Im(e.cacheCreationTokens);else{let r=Im(e.totalTokens);r!==void 0&&(t.totalTokens=r,t.providerTotalTokens=r)}return t.totalTokens>0?t:void 0}function zK(e){if(!e?.length)return;let t={totalTokens:0};for(let a of e){let r=kg(a.usage);if(r){t.totalTokens+=r.totalTokens;for(let n of["inputTokens","outputTokens","cachedInputTokens","cacheCreationTokens","reasoningTokens"]){let o=r[n];o!==void 0&&(t[n]=(t[n]??0)+o)}}}return t.totalTokens>0?t:void 0}function _z(e){return e?`${OK(e.totalTokens)} tokens`:""}function UK(e){return _z(kg(e))}function Lx(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:void 0}function Nz(e,t){return Math.round((e+t)*1e12)/1e12}function Jl(e){if(!e?.cost)return;let t={total:0},a=e.cost,r=Lx(a.total),n={input:Lx(a.input),output:Lx(a.output),cacheRead:Lx(a.cacheRead),cacheWrite:Lx(a.cacheWrite)},o=Object.values(n).reduce((i,s)=>i+(s??0),0);return t.total=Nz(t.total,r??o),t.input=n.input,t.output=n.output,t.cacheRead=n.cacheRead,t.cacheWrite=n.cacheWrite,r!==void 0||o>0?t:void 0}function jK(e){let t;for(let a of e??[]){let r=Jl(a.usage);r&&(t=Nz(t??0,r.total))}return t===void 0?void 0:{total:t}}function ze(e){if(!e)return"";let t=e.total>0&&e.total<.01?4:2;return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:t}).format(e.total)}function Nr(e){return e?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:4}).format(e.total):""}function U1(e,t){if(!(!e&&!t))return{...e,total:Nz(e?.total??0,t?.costUsd??0)}}function BK(e,t){return ze(U1(Jl(e),t))}function FK(e){return Tx(e.cumulativeDurationMs)||"none"}function pxe(e,t){return(O1(t)??0)-(O1(e)??0)}function Ar(e){return e?.displayTitle??"Conversation"}function Dd(e){let t=e?.email?.trim()||void 0,a=e?.fullName?.trim()||void 0,r=e?.slackUserName?.trim()||void 0;return t??a??r??e?.slackUserId}function Ys(e,t={}){let a=e.channel;if(!a)return;let n=t.includeId??!0?` (${a})`:"";if(e.channelNameRedacted&&e.channelName)return`${e.channelName}${n}`;let o=e.channelName?.replace(/^#/,"");return a.startsWith("D")?`Direct Message${n}`:a.startsWith("C")?o?`#${o}${n}`:`Public Channel${n}`:a.startsWith("G")?o?.startsWith("mpdm-")?`Group DM${n}`:`Private Channel${n}`:o?`${o}${n}`:a}function hxe(e){return cxe(e)?"failed":uxe(e)?"active":"idle"}function Od(e){return dxe(e)?"active":fxe(e)?"failed":"idle"}function Rx(e){return e.eventHistory.status==="redacted"?"Transcript hidden because this conversation is not public.":e.eventHistory.status==="expired"?"Transcript expired for this conversation.":hxe(e)==="active"?"Transcript pending while this conversation is active.":"Transcript unavailable for this conversation."}function el(e){return`/people/${encodeURIComponent(e)}`}function HK(e){return`/system/locations/${encodeURIComponent(e)}`}function tl(e){return`/automations/${encodeURIComponent(e)}`}function gxe(e){let t=e?.trim().toLowerCase();if(!t)return"markdown";let r={console:"shellscript",htm:"html",js:"javascript",jsonl:"json",md:"markdown",ndjson:"json",sh:"shellscript",text:"markdown",txt:"markdown",xml:"xml",yml:"yaml"}[t]??t;return Object.hasOwn(P1,r)?r:"markdown"}function VK(e){let t=e.trim();if(t)try{return JSON.stringify(JSON.parse(t),null,2)}catch{return}}function qK(e){let t=e.trim().split(/\r?\n/).filter(r=>r.trim().length>0);if(t.length<2)return;let a=[];for(let r of t){let n=VK(r);if(!n)return;a.push(n)}return a.join(`
70
+ `);case"automation":return Ege(e)}}var Mge=u.object({plugin:u.string().min(1),key:u.string().min(1)}).strict(),Oge=Mge.extend({kind:u.literal("object")});function SE(e,t){return e.map(a=>{let r=t.find(n=>n.kind===a.kind&&n.plugin===a.plugin&&n.key===a.key);return r?zge(r):{...a,objectType:"item",title:a.key,label:a.key,url:null,warning:"Saved annotation is unavailable."}})}function zge(e){let{createdAt:t,updatedAt:a,...r}=e;return r.kind==="object"?r:{...r,kind:"object",objectType:r.objectType??"item",title:r.label}}var Qr=u.string().trim().min(1).max(400),wE=u.string().url().max(2048),ux=u.string().datetime(),x9=u.object({provider:u.string().trim().min(1).max(100),channelName:Qr.optional()}).strict(),Uge=u.enum(["in_progress","answered","done","partial","blocked","abandoned"]),S9=u.object({repository:Qr,number:u.number().int().positive(),title:Qr.optional(),url:wE,state:sx,openedAt:ux.optional(),mergedAt:ux.optional(),closedAt:ux.optional()}).strict(),jge=u.object({kind:u.enum(["code_change","resource","url"]),label:Qr,url:wE,status:Qr.optional()}).strict(),Bge=u.object({startedAt:ux,lastActivityAt:ux,durationMs:u.number().int().nonnegative(),participants:u.array(u.object({name:Qr,messages:u.number().int().positive()}).strict()),userMessages:u.number().int().nonnegative(),assistantMessages:u.number().int().nonnegative(),toolResults:u.number().int().nonnegative(),events:u.number().int().nonnegative(),turns:u.number().int().positive().optional(),location:x9.optional(),codeChanges:u.array(S9)}).strict(),Fge=u.object({schemaVersion:u.literal(1),record:Bge,summary:u.string().trim().min(1).max(600),intent:Qr,outcome:u.object({status:Uge,text:u.string().trim().min(1).max(600)}).strict(),decisions:u.array(u.object({text:Qr,by:Qr.optional(),kind:u.enum(["stated","confirmed","assumed"])}).strict()).max(20),openDecisions:u.array(u.object({text:Qr,owner:Qr.optional()}).strict()).max(20),facts:u.array(Qr).max(30),links:u.array(jge).max(40),keywords:u.array(u.string().trim().toLowerCase().min(1).max(400)).max(12)}).strict(),Hge=u.object({index:u.number().int().nonnegative(),role:u.enum(["user","assistant","tool","event"]),author:Qr.optional(),text:u.string().min(1),createdAtMs:u.number().int().nonnegative(),turnId:u.string().min(1).optional()}).strict(),Vge=u.object({label:Qr,url:wE,status:Qr.optional()}).strict(),c5e=u.object({conversationId:u.string().min(1),title:Qr.optional(),visibility:u.enum(["private","public"]),location:x9.optional(),entries:u.array(Hge),codeChanges:u.array(S9),resources:u.array(Vge)}).strict();var Td=["image/png","image/jpeg","image/gif","image/webp"];var cx=3145728,CE=3,qge=u.object({filename:u.string().trim().min(1).max(255),contentType:u.enum(Td),data:u.string().min(4).max(cx*4/3).regex(/^[A-Za-z0-9+/]*={0,2}$/).refine(e=>e.length%4===0)}).strict(),kE=u.object({id:u.string().min(1),filename:u.string().min(1),contentType:u.string().min(1),bytes:u.number().int().nonnegative()}).strict();var Zge=u.enum(["active","completed","failed"]),Gge=u.enum(["api","internal","scheduler","slack"]),IE=p9,Kge=u.object({conversationId:u.string().min(1)}).strict(),d5e=u.object({attachmentId:u.string().min(1),conversationId:u.string().min(1)}).strict(),Wge=u.object({limit:u.coerce.number().int().min(1).max(1e3).default(500)}).strict(),Jge=u.object({before:u.string().min(1),limit:u.coerce.number().int().min(1).max(1e3).default(500)}).strict(),Qge=u.object({actorEmail:u.string().trim().email().transform(e=>e.toLowerCase()).optional(),codeRepositoryId:u.string().uuid().optional(),q:u.string().trim().max(200).optional(),status:u.enum(["active","archived"]).default("active")}).strict(),Xge=u.object({archived:u.boolean(),lastSeenAt:u.string().datetime()}).strict(),LE=u.object({archivedAt:u.string().datetime().nullable()}).strict(),w9=u.object({idempotencyKey:u.string().trim().min(1).max(200),message:u.string().trim().max(32e3),images:u.array(qge).max(3).optional()}).strict().refine(e=>!!(e.message||e.images?.length),"Add a message or an image.").refine(e=>(e.images??[]).reduce((t,a)=>t+a.data.length,0)<=cx*4/3,"Images must total 3 MB or less."),Yge=w9.safeExtend({visibility:u.enum(["private","public"]).optional()}),dx=u.object({conversationId:u.string().min(1),messageId:u.string().min(1),status:u.enum(["accepted","duplicate"])}).strict(),mm=u.object({email:u.string().optional(),fullName:u.string().optional(),slackUserId:u.string().optional(),slackUserName:u.string().optional()}).strict(),C9=u.enum(["defer","interrupt"]),k9=u.object({actorIdentity:mm.optional(),createdAt:u.string().datetime(),delivery:C9,inboundMessageId:u.string().min(1),messageId:u.string().min(1),receivedAt:u.string().datetime(),role:u.literal("user"),source:u.enum(["slack","web"]),text:u.string().optional(),attachments:u.array(kE).optional(),redacted:u.literal(!0).optional()}).strict().superRefine((e,t)=>{e.text===void 0==(e.redacted!==!0)&&t.addIssue({code:"custom",message:"pending message content must be text or explicitly redacted"}),e.redacted&&(e.actorIdentity||e.attachments)&&t.addIssue({code:"custom",message:"redacted pending messages must not expose actor identity or attachments"})}),I9=u.object({authorizationUrl:u.string().url(),completionText:u.string().min(1),label:u.string().min(1)}).strict(),TE=u.object({authorization:I9.optional(),conversationId:u.string().min(1),generatedAt:u.string().datetime(),messages:u.array(k9)}).strict(),eve=u.object({inboundMessageIds:u.array(u.string().min(1)).min(1).optional(),receivedBefore:u.string().datetime().optional()}).strict(),RE=u.object({cancelledCount:u.number().int().nonnegative(),cancelledInboundMessageIds:u.array(u.string().min(1)),conversationId:u.string().min(1)}).strict(),L9=u.object({costUsd:u.number().finite().nonnegative(),operations:u.array(u.object({costUsd:u.number().finite().nonnegative(),events:u.number().int().positive(),name:u.string().min(1),namespace:u.string().min(1)}).strict()).min(1)}).strict(),tve=u.object({id:u.string().min(1).optional(),kind:u.enum(["scheduled","event"]),label:u.string().min(1).optional(),title:u.string().min(1).optional()}).strict().superRefine((e,t)=>{!!e.id!=!!e.label&&t.addIssue({code:"custom",message:"sourceTask id and label must both be set or both omitted"})}),ave=r9.and(u.object({plugin:u.string().min(1),createdAt:u.string().datetime(),updatedAt:u.string().datetime()})),T9=u.object({createdAt:u.string().datetime(),role:u.enum(["assistant","user"]),text:u.string().min(1)}).strict(),ng=u.object({displayTitle:u.string(),activityPreview:T9.optional(),cumulativeDurationMs:u.number(),cumulativeUsage:IE.optional(),auxiliaryCosts:L9.optional(),conversationId:u.string(),isParticipant:u.boolean(),visibility:u.enum(["private","public"]).optional(),status:Zge,startedAt:u.string(),lastSeenAt:u.string(),lastProgressAt:u.string(),surface:Gge,actorIdentity:mm.optional(),participants:u.array(mm).optional(),archivedAt:u.string().datetime().nullable().optional(),channel:u.string().optional(),channelName:u.string().optional(),channelNameRedacted:u.boolean().optional(),locationId:u.string().optional(),sentryTraceUrl:u.string().optional(),locationUrl:u.string().url().optional(),traceId:u.string().optional(),annotations:u.array(ave).optional(),sidebarAnnotations:u.array(o9).optional(),assignedWork:u.boolean().optional(),finishedWorkAt:u.string().datetime().optional(),isPriority:u.boolean().optional(),unfinishedWork:u.boolean().optional()}).strict(),nve=u.object({type:u.literal("message"),messageId:u.string().min(1),role:u.enum(["assistant","system","user"]),source:u.enum(["slack","web"]).optional(),actorIdentity:mm.optional(),eventType:u.string().min(1).optional(),eventObjectType:tg.optional(),explicitMention:u.boolean().optional(),trustedSummary:u.string().min(1).optional(),cards:u.array(Oge).optional(),text:u.string().optional(),attachments:u.array(kE).optional(),redacted:u.literal(!0).optional()}).strict().superRefine((e,t)=>{e.text===void 0==(e.redacted!==!0)&&t.addIssue({code:"custom",message:"message content must be text or explicitly redacted"}),e.redacted&&(e.actorIdentity||e.cards||e.attachments)&&t.addIssue({code:"custom",message:"redacted messages must not expose actor identity, cards, or attachments"})}),rve=u.object({type:u.literal("message_handled"),messageId:u.string().min(1)}).strict(),ove=u.object({toolCallId:u.string().min(1),name:u.string().min(1),status:u.enum(["running","completed","error"]),startedAt:u.string().datetime().optional(),startedSeq:u.number().int().nonnegative().optional(),input:u.unknown().optional(),output:u.unknown().optional()}).strict().superRefine((e,t)=>{e.startedAt===void 0!=(e.startedSeq===void 0)&&t.addIssue({code:"custom",message:"tool start sequence and timestamp must be provided together"})}),R9=u.object({type:u.literal("reasoning"),text:u.string().min(1).optional(),redacted:u.literal(!0).optional()}).strict().superRefine((e,t)=>{e.text===void 0==(e.redacted!==!0)&&t.addIssue({code:"custom",message:"reasoning content must be text or explicitly redacted"})}),ive=u.object({type:u.literal("tool_call"),toolCallId:u.string().min(1)}).strict(),sve=u.object({parts:u.array(u.discriminatedUnion("type",[R9,ive])).min(1)}).strict(),lve=u.object({type:u.literal("tool_calls"),calls:u.array(ove).min(1),assistant:sve.optional()}).strict().superRefine((e,t)=>{if(!e.assistant)return;let a=new Map;for(let n of e.calls)a.set(n.toolCallId,(a.get(n.toolCallId)??0)+1);let r=new Map;for(let n of e.assistant.parts)n.type==="tool_call"&&r.set(n.toolCallId,(r.get(n.toolCallId)??0)+1);(a.size!==r.size||[...a].some(([n,o])=>r.get(n)!==o))&&t.addIssue({code:"custom",path:["assistant","parts"],message:"assistant tool parts must reference every call exactly once"})}),uve=u.object({type:u.literal("assistant_message"),parts:u.array(R9)}).strict(),cve=u.discriminatedUnion("state",[u.object({type:u.literal("turn_lifecycle"),turnId:u.string().min(1),state:u.enum(["succeeded","no_reply"])}).strict(),u.object({type:u.literal("turn_lifecycle"),turnId:u.string().min(1),state:u.literal("started"),inputMessageIds:u.array(u.string().min(1)).min(1).optional()}).strict(),u.object({type:u.literal("turn_lifecycle"),turnId:u.string().min(1),state:u.literal("failed"),failureCode:Qk,failureReason:Xk.optional(),eventId:u.string().regex(/^[a-f0-9]{32}$/i).optional(),sentryEventUrl:u.string().url().optional()}).strict()]),dve=u.object({type:u.literal("turn_routed"),turnId:u.string().min(1),modelProfile:u.string().min(1),modelId:u.string().min(1),costUsd:u.number().finite().nonnegative().optional(),reasoningLevel:u.string().min(1),confidence:u.number().min(0).max(1).optional(),source:u.enum(["configured","inherited","router"])}).strict(),fve=u.object({type:u.literal("guardian_action_reviewed"),turnId:u.string().min(1),toolCallId:u.string().min(1),toolName:u.string().min(1),decision:u.enum(["allow","ask","deny"]),riskLevel:u.enum(["low","medium","high","critical"]),userAuthorization:u.enum(["high","medium","low","unknown"])}).strict(),mve=u.object({type:u.literal("turn_context"),turnId:u.string().min(1),pluginName:u.string().min(1),kind:u.string().min(1),version:u.number().int().positive(),content:u.record(u.string(),u.unknown())}).strict(),pve=u.object({type:u.literal("structured_event"),namespace:u.string().min(1),name:u.string().min(1),version:u.number().int().positive(),turnId:u.string().min(1).optional(),presentation:i9}).strict(),hve=u.object({type:u.literal("attachments_delivered"),attachments:u.array(kE).min(1)}).strict(),gve=u.object({type:u.literal("compaction"),modelProfile:u.string().min(1).optional(),modelId:u.string().min(1).optional(),summary:u.string().min(1).optional(),details:u.object({reason:u.literal("capacity"),estimatedInputTokens:u.number().int().nonnegative(),replacementInputTokens:u.number().int().nonnegative().optional(),triggerTokens:u.number().int().nonnegative(),inputLimitTokens:u.number().int().positive(),inputMessageCount:u.number().int().nonnegative(),retainedMessageCount:u.number().int().nonnegative(),summaryChars:u.number().int().nonnegative()}).strict().optional()}).strict(),vve=u.object({type:u.literal("handoff"),modelProfile:u.string().min(1),modelId:u.string().min(1),reasoningLevel:u.string().min(1).optional(),triggeringToolCallId:u.string().min(1).optional(),summary:u.string().min(1).optional()}).strict(),yve=u.object({type:u.literal("subagent"),startedSeq:u.number().int().nonnegative(),startedAt:u.string().datetime(),childConversationId:u.string().min(1),subagentKind:u.string().min(1),parentToolCallId:u.string().min(1).optional(),status:u.enum(["running","completed","error","aborted"])}).strict(),_9=u.discriminatedUnion("type",[nve,rve,uve,lve,cve,mve,pve,hve,dve,fve,gve,vve,yve]),_E=u.object({seq:u.number().int().nonnegative(),createdAt:u.string().datetime(),data:_9,model:u.object({modelId:u.string().min(1),modelProfile:u.string().min(1).optional(),reasoningLevel:u.string().min(1).optional()}).strict().optional(),modelCall:u.object({provider:u.string().min(1).optional(),api:u.string().min(1).optional(),stopReason:u.string().min(1).optional(),usage:IE.optional()}).strict().optional()}).strict(),NE=u.discriminatedUnion("status",[u.object({status:u.literal("available")}).strict(),u.object({status:u.literal("redacted"),reason:u.literal("non_public_conversation")}).strict(),u.object({status:u.literal("expired"),expiredAt:u.string().datetime()}).strict()]),bve=u.object({modelId:u.string(),usage:IE}).strict();function N9(e,t){e.eventHistory.status==="expired"&&e.events.length>0&&t.addIssue({code:"custom",path:["events"],message:"expired event history must not contain events"});for(let a=1;a<e.events.length;a+=1)e.events[a].seq<=e.events[a-1].seq&&t.addIssue({code:"custom",path:["events",a,"seq"],message:"report event sequences must be strictly increasing"});for(let[a,r]of e.events.entries())r.data.type==="message"&&(e.eventHistory.status==="redacted"&&r.data.redacted!==!0&&t.addIssue({code:"custom",path:["events",a,"data"],message:"redacted event history must redact messages"}),e.eventHistory.status==="available"&&r.data.redacted===!0&&t.addIssue({code:"custom",path:["events",a,"data"],message:"available event history must expose messages"})),e.eventHistory.status==="redacted"&&r.data.type==="tool_calls"&&r.data.calls.some(n=>n.input!==void 0||n.output!==void 0)&&t.addIssue({code:"custom",path:["events",a,"data"],message:"redacted event history must redact tool payloads"}),e.eventHistory.status==="redacted"&&r.data.type==="assistant_message"&&r.data.parts.some(n=>n.text!==void 0)&&t.addIssue({code:"custom",path:["events",a,"data"],message:"redacted event history must redact assistant messages"}),e.eventHistory.status==="available"&&r.data.type==="assistant_message"&&r.data.parts.some(n=>n.redacted===!0)&&t.addIssue({code:"custom",path:["events",a,"data"],message:"available event history must expose reasoning"}),r.data.type==="tool_calls"&&(e.eventHistory.status==="redacted"&&r.data.assistant?.parts.some(n=>n.type==="reasoning"&&n.text!==void 0)||e.eventHistory.status==="available"&&r.data.assistant?.parts.some(n=>n.type==="reasoning"&&n.redacted===!0))&&t.addIssue({code:"custom",path:["events",a,"data","assistant"],message:"assistant reasoning must match event history visibility"})}var xve=u.object({messageId:u.string().min(1).max(500),idempotencyKey:u.string().trim().min(1).max(200)}).strict(),AE=u.object({conversationId:u.string()}).strict(),$E=ng.extend({canFork:u.boolean().optional(),forkedFromConversationId:u.string().optional(),forkedFromTitle:u.string().optional(),forks:u.array(u.string()).optional(),brief:u.object({content:Fge,updatedAt:u.string().datetime(),version:u.number().int().positive()}).strict().optional(),modelUsage:u.array(bve).optional(),events:u.array(_E),eventHistory:NE,previousCursor:u.string().min(1).optional(),generatedAt:u.string(),sentryConversationUrl:u.string().optional(),sourceTask:tve.optional()}).strict().superRefine(N9),PE=u.object({events:u.array(_E),eventHistory:NE,previousCursor:u.string().min(1).optional(),generatedAt:u.string()}).strict().superRefine(N9),Yk=u.object({conversations:u.array(ng),source:u.literal("conversation_index"),generatedAt:u.string()}).strict(),pm=u.object({active:u.number(),conversations:u.number(),durationMs:u.number(),failed:u.number(),label:u.string(),costUsd:u.number().optional(),tokens:u.number().optional()}).strict(),A9=u.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),yE=u.object({cachedInputTokens:u.number().optional(),cacheCreationTokens:u.number().optional(),conversations:u.number(),costUsd:u.number().optional(),date:A9,durationMs:u.number(),inputTokens:u.number().optional(),tokens:u.number().optional()}).strict(),bE=u.object({allow:u.number(),ask:u.number(),costUsd:u.number().optional(),date:A9,deny:u.number(),requests:u.number()}).strict(),Sve=u.object({allow:u.number(),ask:u.number(),costUsd:u.number().optional(),deny:u.number(),metricDays:u.array(bE),metricHours:u.array(bE).optional(),metricSixHours:u.array(bE).optional(),requests:u.number()}).strict(),DE=u.object({active:u.number(),cachedInputTokens:u.number().optional(),cacheCreationTokens:u.number().optional(),conversations:u.number(),durationMs:u.number(),failed:u.number(),generatedAt:u.string(),guardian:Sve,metricDays:u.array(yE),metricHours:u.array(yE).optional(),metricSixHours:u.array(yE).optional(),locations:u.array(pm),actors:u.array(pm),source:u.literal("conversation_index"),costUsd:u.number().optional(),inputTokens:u.number().optional(),tokens:u.number().optional(),windowEnd:u.string(),windowStart:u.string()}).strict();var wve=u.enum(["current_conversation","task_creator"]).describe("Where to send the message. Use current_conversation for posts, digests, summaries, and channel reminders. Use task_creator only when the user asks for a direct reminder or notification."),Cve=u.object({action:u.literal("send_message"),destination:wve}).strict(),M9=u.string().regex(/^\d{4}-\d{2}-\d{2}$/,"Use a local date in YYYY-MM-DD format."),O9=u.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/,"Use local time in HH:MM format."),z9=u.string().min(1).max(80).describe("IANA timezone the user asked for, for example America/New_York. Omit or use null to use the creator's timezone on create, or to keep the saved timezone on update. Do not guess it from office locations.").nullable().optional(),kve=u.enum(["sunday","monday","tuesday","wednesday","thursday","friday","saturday"]),Ive=u.object({kind:u.literal("one_off").describe("A schedule that runs once."),timezone:z9,timing:u.discriminatedUnion("type",[u.object({type:u.literal("after").describe("Run after a relative delay from the server clock."),value:u.number().int().positive().max(1e5),unit:u.enum(["second","minute","hour","day","week"])}).strict(),u.object({type:u.literal("at").describe("Run at an explicit local calendar date and time."),date:M9.describe("Requested local calendar date in YYYY-MM-DD format."),time:O9.describe("Requested local wall-clock time in HH:MM format.")}).strict()]).describe("Relative delay or explicit local time for the one-off run.")}).strict(),Lve=u.object({kind:u.literal("recurring").describe("A repeating calendar schedule."),frequency:u.enum(["daily","weekly","monthly","yearly"]).describe("Recurring tasks can run at most once per day."),interval:u.number().int().positive().max(365).describe("Repeat every N frequency units. Defaults to 1.").nullable().optional(),time:O9.describe("Local wall-clock time for each occurrence in HH:MM format."),weekdays:u.array(kve).min(1).max(7).describe("Required for weekly schedules.").nullable().optional(),dayOfMonth:u.number().int().min(1).max(31).describe("Required for monthly and yearly schedules.").nullable().optional(),month:u.number().int().min(1).max(12).describe("Required for yearly schedules, where January is 1.").nullable().optional(),startDate:M9.describe("Optional local calendar date that anchors the recurrence. Omit to start with the next matching occurrence.").nullable().optional(),timezone:z9}).strict().superRefine((e,t)=>{e.frequency==="weekly"&&e.weekdays==null&&t.addIssue({code:"custom",message:"Weekly schedules require weekdays.",path:["weekdays"]}),(e.frequency==="monthly"||e.frequency==="yearly")&&e.dayOfMonth==null&&t.addIssue({code:"custom",message:`${e.frequency} schedules require dayOfMonth.`,path:["dayOfMonth"]}),e.frequency==="yearly"&&e.month==null&&t.addIssue({code:"custom",message:"Yearly schedules require month.",path:["month"]}),e.frequency!=="weekly"&&e.weekdays!=null&&t.addIssue({code:"custom",message:"weekdays applies only to weekly schedules.",path:["weekdays"]}),e.frequency!=="monthly"&&e.frequency!=="yearly"&&e.dayOfMonth!=null&&t.addIssue({code:"custom",message:"dayOfMonth applies only to monthly or yearly schedules.",path:["dayOfMonth"]}),e.frequency!=="yearly"&&e.month!=null&&t.addIssue({code:"custom",message:"month applies only to yearly schedules.",path:["month"]})}),U9=u.union([Ive,Lve]);var j9=u.object({slackUserId:Jk,fullName:u.string().optional(),userName:u.string().optional()}).strict(),ME=u.object({events:u.array(Qu).min(1),label:u.string().min(1),match:hE.optional(),namespace:u.string().min(1),identifier:u.string().min(1).max(300),resourceType:u.string().min(1)}).strict(),B9=ag.omit({threadTs:!0}),Tve=lx.extend({destination:B9}),Rve=u.object({id:u.string().min(1),createdAtMs:u.number().finite(),createdBy:j9,credentialMode:u.enum(["system","creator"]),destination:B9,destinationVisibility:mE,outcomes:u.array(Tve).max(5),task:u.object({text:u.string().min(1)}).strict(),trigger:ME}).strict(),_ve=u.string().trim().min(1).max(60),F9=u.string().trim().min(1).max(4e3),S5e=F9.describe("Work to perform when the Automation runs. It runs later without this conversation, so write it to stand alone: name each person with their Slack mention, such as <@U123>, instead of me, my, or you. Preserve the user's scope, targets, and constraints. Do not add permissions or side effects the user did not request."),H9=u.object({title:_ve.optional(),instruction:F9.optional(),credentialMode:u.enum(["system","creator"]).optional(),outcomes:u.array(u.union([Cve,lx])).max(5).optional()}),Nve=H9.extend({schedule:U9.optional(),status:u.enum(["active","blocked"]).optional()}).strict(),Ave=H9.extend({trigger:ME.extend({identifier:u.string().trim().min(1).max(300),label:u.string().trim().min(1).max(500)}).optional()}).strict(),$ve=u.enum(["active","blocked","paused","completed","deleted"]),Pve=u.enum(["system","creator"]),Dve=u.enum(["pending","running","completed","failed","blocked","skipped"]),Eve=u.object({slackUserId:Jk,fullName:u.string().optional(),userName:u.string().optional()}).strict(),Mve=u.object({dayOfMonth:u.number().optional(),frequency:u.enum(["daily","weekly","monthly","yearly"]),interval:u.number(),month:u.number().optional(),startDate:u.string(),time:u.object({hour:u.number(),minute:u.number()}).strict(),weekdays:u.array(u.number()).optional()}).strict(),Ove=u.object({description:u.string(),kind:u.enum(["one_off","recurring"]),recurrence:Mve.optional(),timezone:u.string()}).strict(),zve=u.object({platform:u.literal("system"),name:u.string()}).strict(),V9=ag.omit({threadTs:!0}),Uve=u.object({action:u.literal("send_message"),destination:V9}).strict(),t1=u.object({id:u.string(),conversationAccess:u.object({audience:u.enum(["direct","group","channel"]),visibility:u.enum(["private","public"])}).strict(),createdAtMs:u.number(),createdBy:Eve,creatorIdentityId:u.string(),credentialMode:Pve,destination:V9,executionActor:zve.optional(),lastRunAtMs:u.number().optional(),nextRunAtMs:u.number().optional(),originalRequest:u.string().optional(),runNowAtMs:u.number().optional(),schedule:Ove,status:$ve,statusReason:u.string().optional(),outcomes:u.array(Uve).max(5),task:u.object({text:u.string()}).strict(),title:u.string().optional(),updatedAtMs:u.number()}).strict(),w5e=u.object({id:u.string(),attempt:u.number(),claimedAtMs:u.number(),completedAtMs:u.number().optional(),dispatchId:u.string().optional(),errorMessage:u.string().optional(),resultMessageTs:u.string().optional(),scheduledForMs:u.number(),startedAtMs:u.number().optional(),status:Dve,taskId:u.string()}).strict(),C5e=Object.freeze({platform:"system",name:"scheduled-automation"}),jve=u.object({channelId:u.string().min(1),label:u.string().min(1),teamId:u.string().min(1),visibility:u.enum(["private","public"])}).strict(),q9=u.object({1:u.number().int().nonnegative(),7:u.number().int().nonnegative(),30:u.number().int().nonnegative(),90:u.number().int().nonnegative()}).strict(),Z9=u.object({credentialMode:u.enum(["creator","system"]),createdAt:u.string().datetime(),createdBy:u.string().min(1),createdByAvatarUrl:u.string().url().optional(),createdByEmail:u.string().trim().email().optional(),destination:jve,id:u.string().min(1),instruction:u.string().min(1),lastConversationId:u.string().min(1).optional(),lastRunAt:u.string().datetime().optional(),lastRunStatus:u.enum(["blocked","completed","failed"]).optional(),ownedByViewer:u.boolean(),runs:q9,outcomes:u.array(lx).max(5),title:u.string().min(1),totalRuns:u.number().int().nonnegative()}),G9=Z9.extend({kind:u.literal("scheduled"),nextRunAt:u.string().datetime().optional(),schedule:u.string().min(1),timezone:u.string().min(1),statusReason:u.string().optional(),status:u.enum(["active","blocked","paused","completed"])}).strict(),K9=Z9.extend({events:u.array(u.string().min(1)).min(1),match:hE.optional(),kind:u.literal("event"),resource:u.string().min(1),source:u.string().min(1),triggerAvailable:u.boolean(),statusReason:u.string().optional(),status:u.enum(["active","blocked","paused"])}).strict(),mx=u.discriminatedUnion("kind",[G9,K9]),W9=u.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),EE=u.object({costUsd:u.number().finite().nonnegative(),date:W9,event:u.number().int().nonnegative(),scheduled:u.number().int().nonnegative()}).strict(),a1=u.object({q:u.string().trim().max(200).optional(),scope:u.enum(["all","mine","public","attention"]).default("all"),type:u.enum(["all","scheduled","event"]).default("all"),state:u.enum(["all","active","blocked","paused","completed","unavailable"]).default("all"),creator:u.string().max(300).optional(),destination:u.string().max(300).optional(),sort:u.enum(["newest","oldest","title"]).default("newest"),page:u.coerce.number().int().min(1).max(1e6).default(1),pageSize:u.coerce.number().int().min(1).max(100).default(25)}).strict(),$9=u.object({value:u.string(),label:u.string()}).strict(),OE=u.object({executionDays:u.array(EE),executionHours:u.array(EE).optional(),executionSixHours:u.array(EE).optional(),automations:u.array(mx),total:u.number().int().nonnegative(),page:u.number().int().positive(),pageSize:u.number().int().positive(),counts:u.object({all:u.number().int().nonnegative(),mine:u.number().int().nonnegative(),public:u.number().int().nonnegative(),private:u.number().int().nonnegative()}).strict(),creators:u.array($9),destinations:u.array($9)}).strict(),J9=u.object({id:u.string().min(1),kind:u.enum(["scheduled","event"])}).strict(),Q9=u.enum(["blocked","completed","failed"]),zE=u.object({conversationId:u.string().min(1).optional(),costUsd:u.number().finite().nonnegative().optional(),durationMs:u.number().finite().nonnegative().optional(),executedAt:u.string().datetime(),executionId:u.string().min(1),status:Q9,title:u.string().min(1).optional(),totalTokens:u.number().int().nonnegative().optional()}).strict(),e1=u.object({blocked:u.number().int().nonnegative(),completed:u.number().int().nonnegative(),date:W9,failed:u.number().int().nonnegative()}).strict(),UE=u.object({executionDays:u.array(e1),executionHours:u.array(e1).optional(),executionSixHours:u.array(e1).optional(),executions:u.array(zE),automation:mx,truncated:u.boolean()}).strict(),X9=zE.extend({kind:u.enum(["scheduled","event"]),automationId:u.string().min(1),automationTitle:u.string().min(1)}).strict(),jE=u.object({runs:u.array(X9),truncated:u.boolean()}).strict(),P9={title:u.string().nullable(),instruction:u.string()},D9={version:u.number().int().positive(),createdAt:u.string().datetime(),editedBy:j9.nullable()},Y9=u.discriminatedUnion("kind",[u.object({...D9,kind:u.literal("scheduled"),definition:t1.pick({credentialMode:!0,destination:!0,outcomes:!0,schedule:!0}).extend(P9).strict()}).strict(),u.object({...D9,kind:u.literal("event"),definition:Rve.pick({credentialMode:!0,destination:!0,outcomes:!0,trigger:!0}).extend(P9).strict()}).strict()]),BE=u.object({versions:u.array(Y9),activeVersion:u.number().int().positive().nullable(),truncated:u.boolean()}).strict(),Bve=J9.extend({version:u.coerce.number().int().positive()}).strict(),fx=u.string().regex(/^[a-f0-9]{64}$/),Fve=u.object({revision:fx}).strict(),k5e=u.object({action:u.enum(["pause","resume"]),revision:fx}).strict(),E9=t1.pick({destination:!0,createdBy:!0}).extend({id:u.string().min(1),revision:fx,title:u.string().nullable(),instruction:u.string(),credentialMode:u.enum(["system","creator"]),outcomes:u.array(lx).max(5),ownedByViewer:u.boolean()}),ds=u.discriminatedUnion("kind",[E9.merge(t1.pick({schedule:!0})).extend({kind:u.literal("scheduled"),nextRunAtMs:u.number().optional(),status:u.enum(["active","blocked","paused","completed"])}).strict(),E9.extend({kind:u.literal("event"),trigger:ME,triggerAvailable:u.boolean(),status:u.enum(["active","blocked","paused"])}).strict()]),FE=u.discriminatedUnion("kind",[Nve.omit({status:!0}).extend({kind:u.literal("scheduled"),revision:fx}).strict(),Ave.extend({kind:u.literal("event"),revision:fx}).strict()]),Hve=u.object({error:u.string(),code:u.enum(["invalid_edit","conflict","not_found"]),fields:u.record(u.string(),u.array(u.string())).optional()}).strict(),HE=u.array(gE.safeExtend({namespace:u.string()})),VE=U9,qE=t1.pick({schedule:!0}).extend({nextRunAtMs:u.number()}).strict();var Vve=u.object({status:u.literal("ok"),service:u.string(),timestamp:u.string()}).strict(),eZ=u.object({configKeys:u.array(u.string()),description:u.string(),displayName:u.string(),name:u.string()}).strict(),ZE=u.array(eZ),GE=u.object({name:u.string(),pluginProvider:u.string().optional()}).strict(),KE=u.array(GE),tZ=u.object({dir:u.string(),hasMigrationsDir:u.boolean(),hasSkillsDir:u.boolean(),packageName:u.string()}).strict(),aZ=u.object({packageNames:u.array(u.string()),packages:u.array(tZ),manifestRoots:u.array(u.string()),skillRoots:u.array(u.string()),tracingIncludes:u.array(u.string())}).strict(),qve=u.object({cwd:u.string(),homeDir:u.string(),descriptionText:u.string().optional(),providers:u.array(u.string()),skills:u.array(GE),packagedContent:aZ}).strict(),WE=u.enum(["danger","good","neutral","warning"]),Zve=u.object({label:u.string(),tone:WE.optional(),value:u.string()}).strict(),Gve=u.object({key:u.string(),label:u.string()}).strict(),Kve=u.object({id:u.string(),tone:WE.optional(),values:u.record(u.string(),u.string())}).strict(),Wve=u.object({fields:u.array(Gve).optional(),emptyText:u.string().optional(),records:u.array(Kve).optional(),title:u.string()}).strict(),Jve=u.object({categories:u.array(u.object({id:u.string().min(1),label:u.string().min(1),values:u.record(u.string(),u.number().finite())}).strict()).max(100),description:u.string().optional(),emptyText:u.string().optional(),id:u.string().min(1),series:u.array(u.object({format:u.literal("usd").optional(),key:u.string().min(1),label:u.string().min(1),tone:WE.optional()}).strict()).min(1).max(8),timeRangeDays:u.array(u.union([u.literal(1),u.literal(7),u.literal(30),u.literal(90)])).min(1).max(4).optional(),title:u.string().min(1),type:u.literal("bar_chart")}).strict(),nZ=u.object({generatedAt:u.string().optional(),metrics:u.array(Zve).optional(),recordSets:u.array(Wve).optional(),title:u.string().optional(),pluginName:u.string(),widgets:u.array(Jve).max(12).optional()}).strict(),n1=u.object({generatedAt:u.string(),reports:u.array(nZ),source:u.literal("plugins")}).strict(),rZ=36e5,T5e=6*rZ,R5e=24*rZ;async function JE(e){let t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(`${e.conversationId}\0${e.idempotencyKey}`));return`api-msg:${Array.from(new Uint8Array(t),a=>a.toString(16).padStart(2,"0")).join("").slice(0,24)}`}var D=Symbol.for("drizzle:entityKind");function Bn(e,t){if(!e||typeof e!="object")return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,D))throw new Error(`Class "${t.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let a=Object.getPrototypeOf(e).constructor;if(a)for(;a;){if(D in a&&a[D]===t[D])return!0;a=Object.getPrototypeOf(a)}return!1}var hm=class{constructor(t,a){this.table=t,this.config=a,this.name=a.name,this.keyAsName=a.keyAsName,this.notNull=a.notNull,this.default=a.default,this.defaultFn=a.defaultFn,this.onUpdateFn=a.onUpdateFn,this.hasDefault=a.hasDefault,this.primary=a.primaryKey,this.isUnique=a.isUnique,this.uniqueName=a.uniqueName,this.uniqueType=a.uniqueType,this.dataType=a.dataType,this.columnType=a.columnType,this.generated=a.generated,this.generatedIdentity=a.generatedIdentity}static[D]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(t){return t}mapToDriverValue(t){return t}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}};var r1=class{static[D]="ColumnBuilder";config;constructor(t,a,r){this.config={name:t,keyAsName:t==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:a,columnType:r,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(t){return this.config.default=t,this.config.hasDefault=!0,this}$defaultFn(t){return this.config.defaultFn=t,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(t){return this.config.onUpdateFn=t,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(t){this.config.name===""&&(this.config.name=t)}};var Xu=Symbol.for("drizzle:Name");var o1=class{static[D]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor(t,a){this.reference=()=>{let{name:r,columns:n,foreignColumns:o}=t();return{name:r,columns:n,foreignTable:o[0].table,foreignColumns:o}},a&&(this._onUpdate=a.onUpdate,this._onDelete=a.onDelete)}onUpdate(t){return this._onUpdate=t===void 0?"no action":t,this}onDelete(t){return this._onDelete=t===void 0?"no action":t,this}build(t){return new QE(t,this)}},QE=class{constructor(t,a){this.table=t,this.reference=a.reference,this.onUpdate=a._onUpdate,this.onDelete=a._onDelete}static[D]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:t,columns:a,foreignColumns:r}=this.reference(),n=a.map(s=>s.name),o=r.map(s=>s.name),i=[this.table[Xu],...n,r[0].table[Xu],...o];return t??`${i.join("_")}_fk`}};function i1(e,...t){return e(...t)}function eM(e,t){return`${e[Xu]}_${t.join("_")}_unique`}var XE=class{constructor(t,a){this.name=a,this.columns=t}static[D]="PgUniqueConstraintBuilder";columns;nullsNotDistinctConfig=!1;nullsNotDistinct(){return this.nullsNotDistinctConfig=!0,this}build(t){return new YE(t,this.columns,this.nullsNotDistinctConfig,this.name)}},oZ=class{static[D]="PgUniqueOnConstraintBuilder";name;constructor(t){this.name=t}on(...t){return new XE(t,this.name)}},YE=class{constructor(t,a,r,n){this.table=t,this.columns=a,this.name=n??eM(this.table,this.columns.map(o=>o.name)),this.nullsNotDistinct=r}static[D]="PgUniqueConstraint";columns;name;nullsNotDistinct=!1;getName(){return this.name}};function iZ(e,t,a){for(let r=t;r<e.length;r++){let n=e[r];if(n==="\\"){r++;continue}if(n==='"')return[e.slice(t,r).replace(/\\/g,""),r+1];if(!a&&(n===","||n==="}"))return[e.slice(t,r).replace(/\\/g,""),r]}return[e.slice(t).replace(/\\/g,""),e.length]}function sZ(e,t=0){let a=[],r=t,n=!1;for(;r<e.length;){let o=e[r];if(o===","){(n||r===t)&&a.push(""),n=!0,r++;continue}if(n=!1,o==="\\"){r+=2;continue}if(o==='"'){let[l,c]=iZ(e,r+1,!0);a.push(l),r=c;continue}if(o==="}")return[a,r+1];if(o==="{"){let[l,c]=sZ(e,r+1);a.push(l),r=c;continue}let[i,s]=iZ(e,r,!1);a.push(i),r=s}return[a,r]}function lZ(e){let[t]=sZ(e,1);return t}function tM(e){return`{${e.map(t=>Array.isArray(t)?tM(t):typeof t=="string"?`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`${t}`).join(",")}}`}var de=class extends r1{foreignKeyConfigs=[];static[D]="PgColumnBuilder";array(t){return new nM(this.config.name,this,t)}references(t,a={}){return this.foreignKeyConfigs.push({ref:t,actions:a}),this}unique(t,a){return this.config.isUnique=!0,this.config.uniqueName=t,this.config.uniqueType=a?.nulls,this}generatedAlwaysAs(t){return this.config.generated={as:t,type:"always",mode:"stored"},this}buildForeignKeys(t,a){return this.foreignKeyConfigs.map(({ref:r,actions:n})=>i1((o,i)=>{let s=new o1(()=>{let l=o();return{columns:[t],foreignColumns:[l]}});return i.onUpdate&&s.onUpdate(i.onUpdate),i.onDelete&&s.onDelete(i.onDelete),s.build(a)},r,n))}buildExtraConfigColumn(t){return new aM(t,this.config)}},ne=class extends hm{constructor(t,a){a.uniqueName||(a.uniqueName=eM(t,[a.name])),super(t,a),this.table=t}static[D]="PgColumn"},aM=class extends ne{static[D]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op(t){return this.indexConfig.opClass=t,this}},rg=class{static[D]="IndexedColumn";constructor(t,a,r,n){this.name=t,this.keyAsName=a,this.type=r,this.indexConfig=n}name;keyAsName;type;indexConfig},nM=class extends de{static[D]="PgArrayBuilder";constructor(t,a,r){super(t,"array","PgArray"),this.config.baseBuilder=a,this.config.size=r}build(t){let a=this.config.baseBuilder.build(t);return new rM(t,this.config,a)}},rM=class e extends ne{constructor(t,a,r,n){super(t,a),this.baseColumn=r,this.range=n,this.size=a.size}size;static[D]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size=="number"?this.size:""}]`}mapFromDriverValue(t){return typeof t=="string"&&(t=lZ(t)),t.map(a=>this.baseColumn.mapFromDriverValue(a))}mapToDriverValue(t,a=!1){let r=t.map(n=>n===null?null:Bn(this.baseColumn,e)?this.baseColumn.mapToDriverValue(n,!0):this.baseColumn.mapToDriverValue(n));return a?r:tM(r)}};var uZ=class extends de{static[D]="PgEnumObjectColumnBuilder";constructor(t,a){super(t,"string","PgEnumObjectColumn"),this.config.enum=a}build(t){return new oM(t,this.config)}},oM=class extends ne{static[D]="PgEnumObjectColumn";enum;enumValues=this.config.enum.enumValues;constructor(t,a){super(t,a),this.enum=a.enum}getSQLType(){return this.enum.enumName}},cZ=Symbol.for("drizzle:isPgEnum");function fZ(e){return!!e&&typeof e=="function"&&cZ in e&&e[cZ]===!0}var dZ=class extends de{static[D]="PgEnumColumnBuilder";constructor(t,a){super(t,"string","PgEnumColumn"),this.config.enum=a}build(t){return new iM(t,this.config)}},iM=class extends ne{static[D]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor(t,a){super(t,a),this.enum=a.enum}getSQLType(){return this.enum.enumName}};var og=class{static[D]="Subquery";constructor(t,a,r,n=!1,o=[]){this._={brand:"Subquery",sql:t,selectedFields:a,alias:r,isWith:n,usedTables:o}}},mZ=class extends og{static[D]="WithSubquery"};var pZ="0.45.2";var sM,lM,hZ={startActiveSpan(e,t){return sM?(lM||(lM=sM.trace.getTracer("drizzle-orm",pZ)),i1((a,r)=>r.startActiveSpan(e,n=>{try{return t(n)}catch(o){throw n.setStatus({code:a.SpanStatusCode.ERROR,message:o instanceof Error?o.message:"Unknown error"}),o}finally{n.end()}}),sM,lM)):t()}};var ig=Symbol.for("drizzle:ViewBaseConfig");var uM=Symbol.for("drizzle:Schema"),gZ=Symbol.for("drizzle:Columns"),vZ=Symbol.for("drizzle:ExtraConfigColumns"),cM=Symbol.for("drizzle:OriginalName"),dM=Symbol.for("drizzle:BaseName"),px=Symbol.for("drizzle:IsAlias"),yZ=Symbol.for("drizzle:ExtraConfigBuilder"),Qve=Symbol.for("drizzle:IsDrizzleTable"),kn=class{static[D]="Table";static Symbol={Name:Xu,Schema:uM,OriginalName:cM,Columns:gZ,ExtraConfigColumns:vZ,BaseName:dM,IsAlias:px,ExtraConfigBuilder:yZ};[Xu];[cM];[uM];[gZ];[vZ];[dM];[px]=!1;[Qve]=!0;[yZ]=void 0;constructor(t,a,r){this[Xu]=this[cM]=t,this[uM]=a,this[dM]=r}};var bZ=class{static[D]="FakePrimitiveParam"};function Xve(e){return e!=null&&typeof e.getSQL=="function"}function Yve(e){let t={sql:"",params:[]};for(let a of e)t.sql+=a.sql,t.params.push(...a.params),a.typings?.length&&(t.typings||(t.typings=[]),t.typings.push(...a.typings));return t}var _i=class{static[D]="StringChunk";value;constructor(t){this.value=Array.isArray(t)?t:[t]}getSQL(){return new In([this])}},In=class e{constructor(t){this.queryChunks=t;for(let a of t)if(Bn(a,kn)){let r=a[kn.Symbol.Schema];this.usedTables.push(r===void 0?a[kn.Symbol.Name]:r+"."+a[kn.Symbol.Name])}}static[D]="SQL";decoder=xZ;shouldInlineParams=!1;usedTables=[];append(t){return this.queryChunks.push(...t.queryChunks),this}toQuery(t){return hZ.startActiveSpan("drizzle.buildSQL",a=>{let r=this.buildQueryFromSourceParams(this.queryChunks,t);return a?.setAttributes({"drizzle.query.text":r.sql,"drizzle.query.params":JSON.stringify(r.params)}),r})}buildQueryFromSourceParams(t,a){let r=Object.assign({},a,{inlineParams:a.inlineParams||this.shouldInlineParams,paramStartIndex:a.paramStartIndex||{value:0}}),{casing:n,escapeName:o,escapeParam:i,prepareTyping:s,inlineParams:l,paramStartIndex:c}=r;return Yve(t.map(d=>{if(Bn(d,_i))return{sql:d.value.join(""),params:[]};if(Bn(d,hx))return{sql:o(d.value),params:[]};if(d===void 0)return{sql:"",params:[]};if(Array.isArray(d)){let f=[new _i("(")];for(let[m,p]of d.entries())f.push(p),m<d.length-1&&f.push(new _i(", "));return f.push(new _i(")")),this.buildQueryFromSourceParams(f,r)}if(Bn(d,e))return this.buildQueryFromSourceParams(d.queryChunks,{...r,inlineParams:l||d.shouldInlineParams});if(Bn(d,kn)){let f=d[kn.Symbol.Schema],m=d[kn.Symbol.Name];return{sql:f===void 0||d[px]?o(m):o(f)+"."+o(m),params:[]}}if(Bn(d,hm)){let f=n.getColumnCasing(d);if(a.invokeSource==="indexes")return{sql:o(f),params:[]};let m=d.table[kn.Symbol.Schema];return{sql:d.table[px]||m===void 0?o(d.table[kn.Symbol.Name])+"."+o(f):o(m)+"."+o(d.table[kn.Symbol.Name])+"."+o(f),params:[]}}if(Bn(d,fM)){let f=d[ig].schema,m=d[ig].name;return{sql:f===void 0||d[ig].isAlias?o(m):o(f)+"."+o(m),params:[]}}if(Bn(d,s1)){if(Bn(d.value,gx))return{sql:i(c.value++,d),params:[d],typings:["none"]};let f=d.value===null?null:d.encoder.mapToDriverValue(d.value);if(Bn(f,e))return this.buildQueryFromSourceParams([f],r);if(l)return{sql:this.mapInlineParam(f,r),params:[]};let m=["none"];return s&&(m=[s(d.encoder)]),{sql:i(c.value++,f),params:[f],typings:m}}return Bn(d,gx)?{sql:i(c.value++,d),params:[d],typings:["none"]}:Bn(d,e.Aliased)&&d.fieldAlias!==void 0?{sql:o(d.fieldAlias),params:[]}:Bn(d,og)?d._.isWith?{sql:o(d._.alias),params:[]}:this.buildQueryFromSourceParams([new _i("("),d._.sql,new _i(") "),new hx(d._.alias)],r):fZ(d)?d.schema?{sql:o(d.schema)+"."+o(d.enumName),params:[]}:{sql:o(d.enumName),params:[]}:Xve(d)?d.shouldOmitSQLParens?.()?this.buildQueryFromSourceParams([d.getSQL()],r):this.buildQueryFromSourceParams([new _i("("),d.getSQL(),new _i(")")],r):l?{sql:this.mapInlineParam(d,r),params:[]}:{sql:i(c.value++,d),params:[d],typings:["none"]}}))}mapInlineParam(t,{escapeString:a}){if(t===null)return"null";if(typeof t=="number"||typeof t=="boolean")return t.toString();if(typeof t=="string")return a(t);if(typeof t=="object"){let r=t.toString();return a(r==="[object Object]"?JSON.stringify(t):r)}throw new Error("Unexpected param value: "+t)}getSQL(){return this}as(t){return t===void 0?this:new e.Aliased(this,t)}mapWith(t){return this.decoder=typeof t=="function"?{mapFromDriverValue:t}:t,this}inlineParams(){return this.shouldInlineParams=!0,this}if(t){return t?this:void 0}},hx=class{constructor(t){this.value=t}static[D]="Name";brand;getSQL(){return new In([this])}};var xZ={mapFromDriverValue:e=>e},SZ={mapToDriverValue:e=>e},yUe={...xZ,...SZ},s1=class{constructor(t,a=SZ){this.value=t,this.encoder=a}static[D]="Param";brand;getSQL(){return new In([this])}};function sg(e,...t){let a=[];(t.length>0||e.length>0&&e[0]!=="")&&a.push(new _i(e[0]));for(let[r,n]of t.entries())a.push(n,new _i(e[r+1]));return new In(a)}(e=>{function t(){return new In([])}e.empty=t;function a(l){return new In(l)}e.fromList=a;function r(l){return new In([new _i(l)])}e.raw=r;function n(l,c){let d=[];for(let[f,m]of l.entries())f>0&&c!==void 0&&d.push(c),d.push(m);return new In(d)}e.join=n;function o(l){return new hx(l)}e.identifier=o;function i(l){return new gx(l)}e.placeholder=i;function s(l,c){return new s1(l,c)}e.param=s})(sg||(sg={}));(e=>{class t{constructor(r,n){this.sql=r,this.fieldAlias=n}static[D]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new t(this.sql,this.fieldAlias)}}e.Aliased=t})(In||(In={}));var gx=class{constructor(t){this.name=t}static[D]="Placeholder";getSQL(){return new In([this])}};var eye=Symbol.for("drizzle:IsDrizzleView"),fM=class{static[D]="View";[ig];[eye]=!0;constructor({name:t,schema:a,selectedFields:r,query:n}){this[ig]={name:t,originalName:t,schema:a,selectedFields:r,query:n,isExisting:!n,isAlias:!1}}getSQL(){return new In([this])}};hm.prototype.getSQL=function(){return new In([this])};kn.prototype.getSQL=function(){return new In([this])};og.prototype.getSQL=function(){return new In([this])};function _t(e,t){return{name:typeof e=="string"&&e.length>0?e:"",config:typeof e=="object"?e:t}}var xUe=typeof TextDecoder>"u"?null:new TextDecoder;var Yu=class extends de{static[D]="PgIntColumnBaseBuilder";generatedAlwaysAsIdentity(t){if(t){let{name:a,...r}=t;this.config.generatedIdentity={type:"always",sequenceName:a,sequenceOptions:r}}else this.config.generatedIdentity={type:"always"};return this.config.hasDefault=!0,this.config.notNull=!0,this}generatedByDefaultAsIdentity(t){if(t){let{name:a,...r}=t;this.config.generatedIdentity={type:"byDefault",sequenceName:a,sequenceOptions:r}}else this.config.generatedIdentity={type:"byDefault"};return this.config.hasDefault=!0,this.config.notNull=!0,this}};var mM=class extends Yu{static[D]="PgBigInt53Builder";constructor(t){super(t,"number","PgBigInt53")}build(t){return new pM(t,this.config)}},pM=class extends ne{static[D]="PgBigInt53";getSQLType(){return"bigint"}mapFromDriverValue(t){return typeof t=="number"?t:Number(t)}},hM=class extends Yu{static[D]="PgBigInt64Builder";constructor(t){super(t,"bigint","PgBigInt64")}build(t){return new gM(t,this.config)}},gM=class extends ne{static[D]="PgBigInt64";getSQLType(){return"bigint"}mapFromDriverValue(t){return BigInt(t)}};function wZ(e,t){let{name:a,config:r}=_t(e,t);return r.mode==="number"?new mM(a):new hM(a)}var vM=class extends de{static[D]="PgBigSerial53Builder";constructor(t){super(t,"number","PgBigSerial53"),this.config.hasDefault=!0,this.config.notNull=!0}build(t){return new yM(t,this.config)}},yM=class extends ne{static[D]="PgBigSerial53";getSQLType(){return"bigserial"}mapFromDriverValue(t){return typeof t=="number"?t:Number(t)}},bM=class extends de{static[D]="PgBigSerial64Builder";constructor(t){super(t,"bigint","PgBigSerial64"),this.config.hasDefault=!0}build(t){return new xM(t,this.config)}},xM=class extends ne{static[D]="PgBigSerial64";getSQLType(){return"bigserial"}mapFromDriverValue(t){return BigInt(t)}};function CZ(e,t){let{name:a,config:r}=_t(e,t);return r.mode==="number"?new vM(a):new bM(a)}var SM=class extends de{static[D]="PgBooleanBuilder";constructor(t){super(t,"boolean","PgBoolean")}build(t){return new wM(t,this.config)}},wM=class extends ne{static[D]="PgBoolean";getSQLType(){return"boolean"}};function kZ(e){return new SM(e??"")}var CM=class extends de{static[D]="PgCharBuilder";constructor(t,a){super(t,"string","PgChar"),this.config.length=a.length,this.config.enumValues=a.enum}build(t){return new kM(t,this.config)}},kM=class extends ne{static[D]="PgChar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"char":`char(${this.length})`}};function IZ(e,t={}){let{name:a,config:r}=_t(e,t);return new CM(a,r)}var IM=class extends de{static[D]="PgCidrBuilder";constructor(t){super(t,"string","PgCidr")}build(t){return new LM(t,this.config)}},LM=class extends ne{static[D]="PgCidr";getSQLType(){return"cidr"}};function LZ(e){return new IM(e??"")}var TM=class extends de{static[D]="PgCustomColumnBuilder";constructor(t,a,r){super(t,"custom","PgCustomColumn"),this.config.fieldConfig=a,this.config.customTypeParams=r}build(t){return new RM(t,this.config)}},RM=class extends ne{static[D]="PgCustomColumn";sqlName;mapTo;mapFrom;constructor(t,a){super(t,a),this.sqlName=a.customTypeParams.dataType(a.fieldConfig),this.mapTo=a.customTypeParams.toDriver,this.mapFrom=a.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(t){return typeof this.mapFrom=="function"?this.mapFrom(t):t}mapToDriverValue(t){return typeof this.mapTo=="function"?this.mapTo(t):t}};function TZ(e){return(t,a)=>{let{name:r,config:n}=_t(t,a);return new TM(r,n,e)}}var Hl=class extends de{static[D]="PgDateColumnBaseBuilder";defaultNow(){return this.default(sg`now()`)}};var _M=class extends Hl{static[D]="PgDateBuilder";constructor(t){super(t,"date","PgDate")}build(t){return new NM(t,this.config)}},NM=class extends ne{static[D]="PgDate";getSQLType(){return"date"}mapFromDriverValue(t){return typeof t=="string"?new Date(t):t}mapToDriverValue(t){return t.toISOString()}},AM=class extends Hl{static[D]="PgDateStringBuilder";constructor(t){super(t,"string","PgDateString")}build(t){return new $M(t,this.config)}},$M=class extends ne{static[D]="PgDateString";getSQLType(){return"date"}mapFromDriverValue(t){return typeof t=="string"?t:t.toISOString().slice(0,-14)}};function RZ(e,t){let{name:a,config:r}=_t(e,t);return r?.mode==="date"?new _M(a):new AM(a)}var PM=class extends de{static[D]="PgDoublePrecisionBuilder";constructor(t){super(t,"number","PgDoublePrecision")}build(t){return new DM(t,this.config)}},DM=class extends ne{static[D]="PgDoublePrecision";getSQLType(){return"double precision"}mapFromDriverValue(t){return typeof t=="string"?Number.parseFloat(t):t}};function _Z(e){return new PM(e??"")}var EM=class extends de{static[D]="PgInetBuilder";constructor(t){super(t,"string","PgInet")}build(t){return new MM(t,this.config)}},MM=class extends ne{static[D]="PgInet";getSQLType(){return"inet"}};function NZ(e){return new EM(e??"")}var OM=class extends Yu{static[D]="PgIntegerBuilder";constructor(t){super(t,"number","PgInteger")}build(t){return new zM(t,this.config)}},zM=class extends ne{static[D]="PgInteger";getSQLType(){return"integer"}mapFromDriverValue(t){return typeof t=="string"?Number.parseInt(t):t}};function AZ(e){return new OM(e??"")}var UM=class extends de{static[D]="PgIntervalBuilder";constructor(t,a){super(t,"string","PgInterval"),this.config.intervalConfig=a}build(t){return new jM(t,this.config)}},jM=class extends ne{static[D]="PgInterval";fields=this.config.intervalConfig.fields;precision=this.config.intervalConfig.precision;getSQLType(){let t=this.fields?` ${this.fields}`:"",a=this.precision?`(${this.precision})`:"";return`interval${t}${a}`}};function $Z(e,t={}){let{name:a,config:r}=_t(e,t);return new UM(a,r)}var BM=class extends de{static[D]="PgJsonBuilder";constructor(t){super(t,"json","PgJson")}build(t){return new FM(t,this.config)}},FM=class extends ne{static[D]="PgJson";constructor(t,a){super(t,a)}getSQLType(){return"json"}mapToDriverValue(t){return JSON.stringify(t)}mapFromDriverValue(t){if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t}};function PZ(e){return new BM(e??"")}var HM=class extends de{static[D]="PgJsonbBuilder";constructor(t){super(t,"json","PgJsonb")}build(t){return new VM(t,this.config)}},VM=class extends ne{static[D]="PgJsonb";constructor(t,a){super(t,a)}getSQLType(){return"jsonb"}mapToDriverValue(t){return JSON.stringify(t)}mapFromDriverValue(t){if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t}};function l1(e){return new HM(e??"")}var qM=class extends de{static[D]="PgLineBuilder";constructor(t){super(t,"array","PgLine")}build(t){return new ZM(t,this.config)}},ZM=class extends ne{static[D]="PgLine";getSQLType(){return"line"}mapFromDriverValue(t){let[a,r,n]=t.slice(1,-1).split(",");return[Number.parseFloat(a),Number.parseFloat(r),Number.parseFloat(n)]}mapToDriverValue(t){return`{${t[0]},${t[1]},${t[2]}}`}},GM=class extends de{static[D]="PgLineABCBuilder";constructor(t){super(t,"json","PgLineABC")}build(t){return new KM(t,this.config)}},KM=class extends ne{static[D]="PgLineABC";getSQLType(){return"line"}mapFromDriverValue(t){let[a,r,n]=t.slice(1,-1).split(",");return{a:Number.parseFloat(a),b:Number.parseFloat(r),c:Number.parseFloat(n)}}mapToDriverValue(t){return`{${t.a},${t.b},${t.c}}`}};function DZ(e,t){let{name:a,config:r}=_t(e,t);return!r?.mode||r.mode==="tuple"?new qM(a):new GM(a)}var WM=class extends de{static[D]="PgMacaddrBuilder";constructor(t){super(t,"string","PgMacaddr")}build(t){return new JM(t,this.config)}},JM=class extends ne{static[D]="PgMacaddr";getSQLType(){return"macaddr"}};function EZ(e){return new WM(e??"")}var QM=class extends de{static[D]="PgMacaddr8Builder";constructor(t){super(t,"string","PgMacaddr8")}build(t){return new XM(t,this.config)}},XM=class extends ne{static[D]="PgMacaddr8";getSQLType(){return"macaddr8"}};function MZ(e){return new QM(e??"")}var YM=class extends de{static[D]="PgNumericBuilder";constructor(t,a,r){super(t,"string","PgNumeric"),this.config.precision=a,this.config.scale=r}build(t){return new eO(t,this.config)}},eO=class extends ne{static[D]="PgNumeric";precision;scale;constructor(t,a){super(t,a),this.precision=a.precision,this.scale=a.scale}mapFromDriverValue(t){return typeof t=="string"?t:String(t)}getSQLType(){return this.precision!==void 0&&this.scale!==void 0?`numeric(${this.precision}, ${this.scale})`:this.precision===void 0?"numeric":`numeric(${this.precision})`}},tO=class extends de{static[D]="PgNumericNumberBuilder";constructor(t,a,r){super(t,"number","PgNumericNumber"),this.config.precision=a,this.config.scale=r}build(t){return new aO(t,this.config)}},aO=class extends ne{static[D]="PgNumericNumber";precision;scale;constructor(t,a){super(t,a),this.precision=a.precision,this.scale=a.scale}mapFromDriverValue(t){return typeof t=="number"?t:Number(t)}mapToDriverValue=String;getSQLType(){return this.precision!==void 0&&this.scale!==void 0?`numeric(${this.precision}, ${this.scale})`:this.precision===void 0?"numeric":`numeric(${this.precision})`}},nO=class extends de{static[D]="PgNumericBigIntBuilder";constructor(t,a,r){super(t,"bigint","PgNumericBigInt"),this.config.precision=a,this.config.scale=r}build(t){return new rO(t,this.config)}},rO=class extends ne{static[D]="PgNumericBigInt";precision;scale;constructor(t,a){super(t,a),this.precision=a.precision,this.scale=a.scale}mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return this.precision!==void 0&&this.scale!==void 0?`numeric(${this.precision}, ${this.scale})`:this.precision===void 0?"numeric":`numeric(${this.precision})`}};function OZ(e,t){let{name:a,config:r}=_t(e,t),n=r?.mode;return n==="number"?new tO(a,r?.precision,r?.scale):n==="bigint"?new nO(a,r?.precision,r?.scale):new YM(a,r?.precision,r?.scale)}var oO=class extends de{static[D]="PgPointTupleBuilder";constructor(t){super(t,"array","PgPointTuple")}build(t){return new iO(t,this.config)}},iO=class extends ne{static[D]="PgPointTuple";getSQLType(){return"point"}mapFromDriverValue(t){if(typeof t=="string"){let[a,r]=t.slice(1,-1).split(",");return[Number.parseFloat(a),Number.parseFloat(r)]}return[t.x,t.y]}mapToDriverValue(t){return`(${t[0]},${t[1]})`}},sO=class extends de{static[D]="PgPointObjectBuilder";constructor(t){super(t,"json","PgPointObject")}build(t){return new lO(t,this.config)}},lO=class extends ne{static[D]="PgPointObject";getSQLType(){return"point"}mapFromDriverValue(t){if(typeof t=="string"){let[a,r]=t.slice(1,-1).split(",");return{x:Number.parseFloat(a),y:Number.parseFloat(r)}}return t}mapToDriverValue(t){return`(${t.x},${t.y})`}};function zZ(e,t){let{name:a,config:r}=_t(e,t);return!r?.mode||r.mode==="tuple"?new oO(a):new sO(a)}function tye(e){let t=[];for(let a=0;a<e.length;a+=2)t.push(Number.parseInt(e.slice(a,a+2),16));return new Uint8Array(t)}function UZ(e,t){let a=new ArrayBuffer(8),r=new DataView(a);for(let n=0;n<8;n++)r.setUint8(n,e[t+n]);return r.getFloat64(0,!0)}function uO(e){let t=tye(e),a=0,r=t[a];a+=1;let n=new DataView(t.buffer),o=n.getUint32(a,r===1);a+=4;let i;if(o&536870912&&(i=n.getUint32(a,r===1),a+=4),(o&65535)===1){let s=UZ(t,a);a+=8;let l=UZ(t,a);return a+=8,[s,l]}throw new Error("Unsupported geometry type")}var cO=class extends de{static[D]="PgGeometryBuilder";constructor(t){super(t,"array","PgGeometry")}build(t){return new dO(t,this.config)}},dO=class extends ne{static[D]="PgGeometry";getSQLType(){return"geometry(point)"}mapFromDriverValue(t){return uO(t)}mapToDriverValue(t){return`point(${t[0]} ${t[1]})`}},fO=class extends de{static[D]="PgGeometryObjectBuilder";constructor(t){super(t,"json","PgGeometryObject")}build(t){return new mO(t,this.config)}},mO=class extends ne{static[D]="PgGeometryObject";getSQLType(){return"geometry(point)"}mapFromDriverValue(t){let a=uO(t);return{x:a[0],y:a[1]}}mapToDriverValue(t){return`point(${t.x} ${t.y})`}};function jZ(e,t){let{name:a,config:r}=_t(e,t);return!r?.mode||r.mode==="tuple"?new cO(a):new fO(a)}var pO=class extends de{static[D]="PgRealBuilder";constructor(t,a){super(t,"number","PgReal"),this.config.length=a}build(t){return new hO(t,this.config)}},hO=class extends ne{static[D]="PgReal";constructor(t,a){super(t,a)}getSQLType(){return"real"}mapFromDriverValue=t=>typeof t=="string"?Number.parseFloat(t):t};function BZ(e){return new pO(e??"")}var gO=class extends de{static[D]="PgSerialBuilder";constructor(t){super(t,"number","PgSerial"),this.config.hasDefault=!0,this.config.notNull=!0}build(t){return new vO(t,this.config)}},vO=class extends ne{static[D]="PgSerial";getSQLType(){return"serial"}};function FZ(e){return new gO(e??"")}var yO=class extends Yu{static[D]="PgSmallIntBuilder";constructor(t){super(t,"number","PgSmallInt")}build(t){return new bO(t,this.config)}},bO=class extends ne{static[D]="PgSmallInt";getSQLType(){return"smallint"}mapFromDriverValue=t=>typeof t=="string"?Number(t):t};function HZ(e){return new yO(e??"")}var xO=class extends de{static[D]="PgSmallSerialBuilder";constructor(t){super(t,"number","PgSmallSerial"),this.config.hasDefault=!0,this.config.notNull=!0}build(t){return new SO(t,this.config)}},SO=class extends ne{static[D]="PgSmallSerial";getSQLType(){return"smallserial"}};function VZ(e){return new xO(e??"")}var wO=class extends de{static[D]="PgTextBuilder";constructor(t,a){super(t,"string","PgText"),this.config.enumValues=a.enum}build(t){return new CO(t,this.config)}},CO=class extends ne{static[D]="PgText";enumValues=this.config.enumValues;getSQLType(){return"text"}};function Js(e,t={}){let{name:a,config:r}=_t(e,t);return new wO(a,r)}var kO=class extends Hl{constructor(t,a,r){super(t,"string","PgTime"),this.withTimezone=a,this.precision=r,this.config.withTimezone=a,this.config.precision=r}static[D]="PgTimeBuilder";build(t){return new IO(t,this.config)}},IO=class extends ne{static[D]="PgTime";withTimezone;precision;constructor(t,a){super(t,a),this.withTimezone=a.withTimezone,this.precision=a.precision}getSQLType(){return`time${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}};function qZ(e,t={}){let{name:a,config:r}=_t(e,t);return new kO(a,r.withTimezone??!1,r.precision)}var LO=class extends Hl{static[D]="PgTimestampBuilder";constructor(t,a,r){super(t,"date","PgTimestamp"),this.config.withTimezone=a,this.config.precision=r}build(t){return new TO(t,this.config)}},TO=class extends ne{static[D]="PgTimestamp";withTimezone;precision;constructor(t,a){super(t,a),this.withTimezone=a.withTimezone,this.precision=a.precision}getSQLType(){return`timestamp${this.precision===void 0?"":` (${this.precision})`}${this.withTimezone?" with time zone":""}`}mapFromDriverValue(t){return typeof t=="string"?new Date(this.withTimezone?t:t+"+0000"):t}mapToDriverValue=t=>t.toISOString()},RO=class extends Hl{static[D]="PgTimestampStringBuilder";constructor(t,a,r){super(t,"string","PgTimestampString"),this.config.withTimezone=a,this.config.precision=r}build(t){return new _O(t,this.config)}},_O=class extends ne{static[D]="PgTimestampString";withTimezone;precision;constructor(t,a){super(t,a),this.withTimezone=a.withTimezone,this.precision=a.precision}getSQLType(){return`timestamp${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}mapFromDriverValue(t){if(typeof t=="string")return t;let a=t.toISOString().slice(0,-1).replace("T"," ");if(this.withTimezone){let r=t.getTimezoneOffset(),n=r<=0?"+":"-";return`${a}${n}${Math.floor(Math.abs(r)/60).toString().padStart(2,"0")}`}return a}};function u1(e,t={}){let{name:a,config:r}=_t(e,t);return r?.mode==="string"?new RO(a,r.withTimezone??!1,r.precision):new LO(a,r?.withTimezone??!1,r?.precision)}var NO=class extends de{static[D]="PgUUIDBuilder";constructor(t){super(t,"string","PgUUID")}defaultRandom(){return this.default(sg`gen_random_uuid()`)}build(t){return new AO(t,this.config)}},AO=class extends ne{static[D]="PgUUID";getSQLType(){return"uuid"}};function ZZ(e){return new NO(e??"")}var $O=class extends de{static[D]="PgVarcharBuilder";constructor(t,a){super(t,"string","PgVarchar"),this.config.length=a.length,this.config.enumValues=a.enum}build(t){return new PO(t,this.config)}},PO=class extends ne{static[D]="PgVarchar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"varchar":`varchar(${this.length})`}};function GZ(e,t={}){let{name:a,config:r}=_t(e,t);return new $O(a,r)}var DO=class extends de{static[D]="PgBinaryVectorBuilder";constructor(t,a){super(t,"string","PgBinaryVector"),this.config.dimensions=a.dimensions}build(t){return new EO(t,this.config)}},EO=class extends ne{static[D]="PgBinaryVector";dimensions=this.config.dimensions;getSQLType(){return`bit(${this.dimensions})`}};function KZ(e,t){let{name:a,config:r}=_t(e,t);return new DO(a,r)}var MO=class extends de{static[D]="PgHalfVectorBuilder";constructor(t,a){super(t,"array","PgHalfVector"),this.config.dimensions=a.dimensions}build(t){return new OO(t,this.config)}},OO=class extends ne{static[D]="PgHalfVector";dimensions=this.config.dimensions;getSQLType(){return`halfvec(${this.dimensions})`}mapToDriverValue(t){return JSON.stringify(t)}mapFromDriverValue(t){return t.slice(1,-1).split(",").map(a=>Number.parseFloat(a))}};function WZ(e,t){let{name:a,config:r}=_t(e,t);return new MO(a,r)}var zO=class extends de{static[D]="PgSparseVectorBuilder";constructor(t,a){super(t,"string","PgSparseVector"),this.config.dimensions=a.dimensions}build(t){return new UO(t,this.config)}},UO=class extends ne{static[D]="PgSparseVector";dimensions=this.config.dimensions;getSQLType(){return`sparsevec(${this.dimensions})`}};function JZ(e,t){let{name:a,config:r}=_t(e,t);return new zO(a,r)}var jO=class extends de{static[D]="PgVectorBuilder";constructor(t,a){super(t,"array","PgVector"),this.config.dimensions=a.dimensions}build(t){return new BO(t,this.config)}},BO=class extends ne{static[D]="PgVector";dimensions=this.config.dimensions;getSQLType(){return`vector(${this.dimensions})`}mapToDriverValue(t){return JSON.stringify(t)}mapFromDriverValue(t){return t.slice(1,-1).split(",").map(a=>Number.parseFloat(a))}};function QZ(e,t){let{name:a,config:r}=_t(e,t);return new jO(a,r)}function XZ(){return{bigint:wZ,bigserial:CZ,boolean:kZ,char:IZ,cidr:LZ,customType:TZ,date:RZ,doublePrecision:_Z,inet:NZ,integer:AZ,interval:$Z,json:PZ,jsonb:l1,line:DZ,macaddr:EZ,macaddr8:MZ,numeric:OZ,point:zZ,geometry:jZ,real:BZ,serial:FZ,smallint:HZ,smallserial:VZ,text:Js,time:qZ,timestamp:u1,uuid:ZZ,varchar:GZ,bit:KZ,halfvec:WZ,sparsevec:JZ,vector:QZ}}var FO=Symbol.for("drizzle:PgInlineForeignKeys"),YZ=Symbol.for("drizzle:EnableRLS"),vx=class extends kn{static[D]="PgTable";static Symbol=Object.assign({},kn.Symbol,{InlineForeignKeys:FO,EnableRLS:YZ});[FO]=[];[YZ]=!1;[kn.Symbol.ExtraConfigBuilder]=void 0;[kn.Symbol.ExtraConfigColumns]={}};function aye(e,t,a,r,n=e){let o=new vx(e,r,n),i=typeof t=="function"?t(XZ()):t,s=Object.fromEntries(Object.entries(i).map(([d,f])=>{let m=f;m.setName(d);let p=m.build(o);return o[FO].push(...m.buildForeignKeys(p,o)),[d,p]})),l=Object.fromEntries(Object.entries(i).map(([d,f])=>{let m=f;m.setName(d);let p=m.buildExtraConfigColumn(o);return[d,p]})),c=Object.assign(o,s);return c[kn.Symbol.Columns]=s,c[kn.Symbol.ExtraConfigColumns]=l,a&&(c[vx.Symbol.ExtraConfigBuilder]=a),Object.assign(c,{enableRLS:()=>(c[vx.Symbol.EnableRLS]=!0,c)})}var eG=(e,t,a)=>aye(e,t,a,void 0);var c1=class{constructor(t,a){this.unique=t,this.name=a}static[D]="PgIndexBuilderOn";on(...t){return new yx(t.map(a=>{if(Bn(a,In))return a;a=a;let r=new rg(a.name,!!a.keyAsName,a.columnType,a.indexConfig);return a.indexConfig=JSON.parse(JSON.stringify(a.defaultConfig)),r}),this.unique,!1,this.name)}onOnly(...t){return new yx(t.map(a=>{if(Bn(a,In))return a;a=a;let r=new rg(a.name,!!a.keyAsName,a.columnType,a.indexConfig);return a.indexConfig=a.defaultConfig,r}),this.unique,!0,this.name)}using(t,...a){return new yx(a.map(r=>{if(Bn(r,In))return r;r=r;let n=new rg(r.name,!!r.keyAsName,r.columnType,r.indexConfig);return r.indexConfig=JSON.parse(JSON.stringify(r.defaultConfig)),n}),this.unique,!0,this.name,t)}},yx=class{static[D]="PgIndexBuilder";config;constructor(t,a,r,n,o="btree"){this.config={name:n,columns:t,unique:a,only:r,method:o}}concurrently(){return this.config.concurrently=!0,this}with(t){return this.config.with=t,this}where(t){return this.config.where=t,this}build(t){return new HO(this.config,t)}},HO=class{static[D]="PgIndex";config;constructor(t,a){this.config={...t,table:a}}};function tG(e){return new c1(!1,e)}function aG(e){return new c1(!0,e)}var nG=e=>u1(e,{withTimezone:!0}),rG=u.enum(["channel","dm","group","local_conversation","thread","web_session"]),Pje=eG("junior_destinations",{id:Js("id").primaryKey(),provider:Js("provider").notNull(),providerTenantId:Js("provider_tenant_id").notNull().default(""),providerDestinationId:Js("provider_destination_id").notNull(),kind:Js("kind").$type().notNull(),parentDestinationId:Js("parent_destination_id"),displayName:Js("display_name"),visibility:Js("visibility").$type().notNull().default("unknown"),metadata:l1("metadata_json"),createdAt:nG("created_at").notNull(),updatedAt:nG("updated_at").notNull()},e=>[aG("junior_destinations_provider_destination_uidx").on(e.provider,e.providerTenantId,e.providerDestinationId),tG("junior_destinations_provider_kind_idx").on(e.provider,e.kind)]);var nye=u.object({error:u.string().min(1)}).strict(),p1=u.object({closed:u.number().int().nonnegative(),costUsd:u.number().nonnegative().optional(),created:u.number().int().nonnegative(),medianCostUsd:u.number().nonnegative().optional(),medianMergeTimeMs:u.number().nonnegative().optional(),merged:u.number().int().nonnegative(),mergeRate:u.number().min(0).max(1).optional(),open:u.number().int().nonnegative()}).strict(),rye=u.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),Vl=u.object({closed:u.number().int().nonnegative(),created:u.number().int().nonnegative(),date:rye,merged:u.number().int().nonnegative()}).strict(),iG=u.object({closed:u.number().int().nonnegative(),created:u.number().int().nonnegative(),id:u.string().uuid(),medianCostUsd:u.number().nonnegative().optional(),merged:u.number().int().nonnegative(),mergeRate:u.number().min(0).max(1).optional(),name:u.string().min(1),open:u.number().int().nonnegative(),provider:u.string().min(1),url:u.string().url().optional()}).strict(),ZO=u.object({closedAt:u.string().optional(),id:u.string().uuid(),mergedAt:u.string().optional(),number:u.number().int().positive(),openedAt:u.string(),provider:u.string().min(1),repository:u.string().min(1),state:sx,title:u.string().optional(),url:u.string().url().optional()}).strict(),GO=u.object({activityDays:u.array(Vl),activityHours:u.array(Vl).optional(),activitySixHours:u.array(Vl).optional(),changes:u.array(ZO),generatedAt:u.string(),repositories:u.array(iG),summary:p1,windowEnd:u.string(),windowStart:u.string()}).strict(),oye=u.object({repositoryId:u.string().uuid()}).strict(),KO=u.object({activityDays:u.array(Vl),activityHours:u.array(Vl).optional(),activitySixHours:u.array(Vl).optional(),changes:u.array(ZO),generatedAt:u.string(),repository:u.object({id:u.string().uuid(),name:u.string().min(1),provider:u.string().min(1),url:u.string().url().optional()}).strict(),summary:p1,windowEnd:u.string(),windowStart:u.string(),workspaces:u.array(u.object({id:u.string().min(1),name:u.string().min(1)}).strict())}).strict(),WO=u.object({activityDays:u.array(Vl),activityHours:u.array(Vl).optional(),activitySixHours:u.array(Vl).optional(),generatedAt:u.string(),summary:p1,windowEnd:u.string(),windowStart:u.string()}).strict(),f1=u.object({active:u.number(),conversations:u.number(),date:u.string(),durationMs:u.number(),failed:u.number(),tokens:u.number().optional()}).strict();var iye=u.object({locationId:u.string().min(1)}).strict(),sG=pm.extend({id:u.string(),firstSeenAt:u.string(),kind:rG,lastSeenAt:u.string(),provider:u.string(),providerDestinationId:u.string(),visibility:u.literal("public")}).strict(),sye=pm.extend({actor:mm}).strict(),lye=u.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),m1=u.object({date:lye,privateConversations:u.number(),publicConversations:u.number()}).strict(),JO=u.object({activityDays:u.array(m1),activityHours:u.array(m1).optional(),activitySixHours:u.array(m1).optional(),generatedAt:u.string(),locations:u.array(sG),privateActivity:pm,source:u.literal("conversation_index"),windowEnd:u.string(),windowStart:u.string()}).strict(),QO=sG.extend({activityDays:u.array(f1),activityHours:u.array(f1).optional(),activitySixHours:u.array(f1).optional(),actors:u.array(sye),generatedAt:u.string(),recentConversations:u.array(ng),source:u.literal("conversation_index"),windowEnd:u.string(),windowStart:u.string()}).strict(),uye=u.object({email:u.string().trim().min(1)}).strict(),oG=pm.omit({costUsd:!0}),lG=u.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),VO=u.object({active:u.number(),conversations:u.number(),costUsd:u.number().optional(),date:lG,durationMs:u.number(),failed:u.number(),tokens:u.number().optional()}).strict(),qO=u.object({activePeople:u.number(),conversations:u.number(),date:lG}).strict(),uG=u.object({active:u.number(),activeDays:u.number(),conversations:u.number(),durationMs:u.number(),failed:u.number(),tokens:u.number().optional()}).strict(),d1=u.object({conversations:u.number().int().nonnegative(),costUsd:u.number().finite().nonnegative(),durationMs:u.number().finite().nonnegative(),priorCostUsd:u.number().finite().nonnegative()}).strict(),cye=u.object({1:d1,7:d1,30:d1,90:d1}).strict(),cG=mm.extend({email:u.string().min(1)}).strict(),dye=uG.extend({firstSeenAt:u.string(),lastSeenAt:u.string(),actor:cG,windows:cye}).strict(),XO=u.object({activityDays:u.array(qO),activityHours:u.array(qO).optional(),activitySixHours:u.array(qO).optional(),generatedAt:u.string(),people:u.array(dye),source:u.literal("conversation_index"),windowEnd:u.string(),windowStart:u.string()}).strict(),YO=u.object({activityDays:u.array(VO),activityHours:u.array(VO).optional(),activitySixHours:u.array(VO).optional(),generatedAt:u.string(),locations:u.array(oG),recentConversations:u.array(ng),actor:cG,source:u.literal("conversation_index"),surfaces:u.array(oG),totals:uG,windowEnd:u.string(),windowStart:u.string()}).strict(),ez=u.object({generatedAt:u.string(),sevenDaysUsd:u.number().finite().nonnegative(),source:u.literal("conversation_index"),thirtyDaysUsd:u.number().finite().nonnegative(),windowEnd:u.string(),windowStart:u.string()}).strict(),tz=u.object({id:u.string().uuid(),name:u.string(),tokenSuffix:u.string(),createdAt:u.string().datetime(),expiresAt:u.string().datetime(),lastUsedAt:u.string().datetime().nullable()}).strict(),az=u.object({tokens:u.array(tz)}).strict(),fye=u.object({name:u.string().trim().min(1).max(80)}).strict(),nz=tz.extend({token:u.string().startsWith("jr_pat_")}).strict(),mye=u.object({id:u.string().uuid()}).strict(),pye=u.object({revoked:u.literal(!0)}).strict(),hye=u.object({provider:u.string(),repo:u.string()}).strict(),dG=u.object({provider:u.string(),repo:u.string(),checkoutPath:u.string()}).strict(),gye=u.object({id:u.string(),generatedAt:u.iso.datetime(),buildDurationMs:u.number().int().nonnegative(),sizeBytes:u.number().int().nonnegative().nullable()}).strict(),fG=u.object({id:u.string(),generatedAt:u.iso.datetime(),buildDurationMs:u.number().int().nonnegative(),dependencyCount:u.number().int().nonnegative()}).strict(),lg=u.object({id:u.string().uuid(),name:u.string(),setupScript:u.string(),repos:u.array(dG),snapshot:gye.nullable()}).strict(),rz=u.object({baselineSnapshot:fG.nullable(),workspaces:u.array(lg)}).strict(),vye=u.object({name:u.string(),setupScript:u.string().optional(),repos:u.array(hye)}).strict(),yye=u.object({id:u.string().uuid()}).strict(),bye=u.object({deleted:u.literal(!0)}).strict(),mG=u.object({count:u.number().int().nonnegative(),date:u.string(),metric:u.string().min(1),name:u.string().min(1),namespace:u.string().min(1)}).strict(),oz=u.object({generatedAt:u.string().datetime(),stats:u.array(mG),windowEnd:u.string(),windowStart:u.string()}).strict();var So=u.string().trim().min(1).max(160),ug=u.number().int().nonnegative(),xye=u.discriminatedUnion("type",[u.strictObject({type:u.literal("code_change"),author:So.optional(),sourceBranch:So.optional(),targetBranch:So.optional(),reviewers:u.array(So).max(5).optional(),review:u.enum(["required","approved","changes_requested"]).optional(),checks:u.strictObject({passed:ug,failed:ug,pending:ug}).optional(),mergeable:u.boolean().optional(),changedFiles:ug.optional(),additions:ug.optional(),deletions:ug.optional()}),u.strictObject({type:u.literal("task"),assignees:u.array(So).max(5).optional(),priority:So.optional(),project:So.optional(),cycle:So.optional(),dueDate:u.iso.date().optional(),labels:u.array(So).max(5).optional()}),u.strictObject({type:u.literal("deployment"),project:So.optional(),environment:So.optional(),revision:So.optional(),branch:So.optional()}),u.strictObject({type:u.literal("calendar_event"),when:So.optional(),attendees:u.array(So).max(5).optional()})]);function hG(e){if(!e)return[];let t=[],a=n=>n?.length?`${n.join(", ")}${n.length===5?" (up to 5 shown)":""}`:void 0;function r(n,o,i){i!==void 0&&i!==""&&t.push({key:n,label:o,value:String(i)})}switch(e.type){case"code_change":r("sourceBranch","Branch",e.sourceBranch);break;case"task":r("assignees","Assignees",e.assignees?.length===0?"Unassigned":a(e.assignees)),r("priority","Priority",e.priority),r("project","Project",e.project),r("cycle","Cycle",e.cycle),r("dueDate","Due",e.dueDate),r("labels","Labels",a(e.labels));break;case"deployment":r("environment","Environment",e.environment),r("project","Project",e.project),r("revision","Revision",e.revision),r("branch","Branch",e.branch);break;case"calendar_event":r("when","When",e.when),r("attendees","Attendees",a(e.attendees));break}return t.slice(0,4)}var g1=u.enum(["task","code_change","automation","deployment","calendar_event","item"]),Sye={task:"Ticket",code_change:"Code change",automation:"Automation",deployment:"Deployment",calendar_event:"Calendar event",item:"Item"};function fs(e){let t=e.objectType==="item"&&e.facts?.type==="deployment"?"deployment":e.objectType,a=e.status?.toLowerCase(),r={task:"issue-opened",code_change:"git-pull-request",automation:"workflow",deployment:"rocket",calendar_event:"calendar",item:"package"}[t],n=t==="automation"?"info":"neutral";return t==="code_change"?(a==="draft"&&(r="git-pull-request-draft"),a==="closed"&&(r="git-pull-request-closed",n="danger"),a==="merged"&&(r="git-merge",n="accent"),a==="open"&&(n="success")):t==="task"?(a==="closed"&&(r="issue-closed",n="accent"),a==="open"&&(n="success")):t==="deployment"&&((a==="ready"||a==="succeeded")&&(n="success"),(a==="error"||a==="failed")&&(n="danger"),(a==="building"||a==="in_progress")&&(n="info")),(a==="warning"||a==="blocked")&&(n="warning"),{icon:r,tone:n,label:Sye[t]}}function gG(e){return`/_junior/dashboard/object-icons/v1/${e}.png`}var sz=u.object({kind:u.literal("object"),key:u.string().trim().min(1).max(256),label:u.string().trim().min(1).max(256),objectType:g1,title:u.string().trim().min(1).max(512),url:u.url().max(2048).refine(e=>["http:","https:"].includes(new URL(e).protocol)).nullable(),description:u.string().max(4e3).optional(),status:u.string().trim().min(1).max(100).optional(),trigger:u.string().max(4e3).optional(),warning:u.string().max(1e3).optional(),displayType:u.string().trim().min(1).max(80).optional(),sourceUpdatedAt:u.iso.datetime({offset:!0}).optional(),facts:xye.refine(e=>new TextEncoder().encode(JSON.stringify(e)).length<=4096,"Object facts must not exceed 4 KiB").optional()}).strict().refine(e=>!e.facts||(e.facts.type==="deployment"?e.objectType==="deployment"||e.objectType==="item":e.facts.type===e.objectType),"Object facts must match the object type"),eBe=sz.safeExtend({plugin:u.string().min(1)}),vG={"issue-opened":["M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z","M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Z"],"issue-closed":["M11.28 6.78a.75.75 0 0 0-1.06-1.06L7.25 8.69 5.78 7.22a.75.75 0 0 0-1.06 1.06l2 2a.75.75 0 0 0 1.06 0l3.5-3.5Z","M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0Zm-1.5 0a6.5 6.5 0 1 0-13 0 6.5 6.5 0 0 0 13 0Z"],"git-pull-request":["M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z"],"git-pull-request-draft":["M3.25 1A2.25 2.25 0 0 1 4 5.372v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.251 2.251 0 0 1 3.25 1Zm9.5 14a2.25 2.25 0 1 1 0-4.5 2.25 2.25 0 0 1 0 4.5ZM2.5 3.25a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0ZM3.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm9.5 0a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM14 7.5a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Zm0-4.25a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Z"],"git-pull-request-closed":["M3.25 1A2.25 2.25 0 0 1 4 5.372v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.251 2.251 0 0 1 3.25 1Zm9.5 5.5a.75.75 0 0 1 .75.75v3.378a2.251 2.251 0 1 1-1.5 0V7.25a.75.75 0 0 1 .75-.75Zm-2.03-5.273a.75.75 0 0 1 1.06 0l.97.97.97-.97a.748.748 0 0 1 1.265.332.75.75 0 0 1-.205.729l-.97.97.97.97a.751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018l-.97-.97-.97.97a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734l.97-.97-.97-.97a.75.75 0 0 1 0-1.06ZM2.5 3.25a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0ZM3.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm9.5 0a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"],"git-merge":["M5.45 5.154A4.25 4.25 0 0 0 9.25 7.5h1.378a2.251 2.251 0 1 1 0 1.5H9.25A5.734 5.734 0 0 1 5 7.123v3.505a2.25 2.25 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.95-.218ZM4.25 13.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm8.5-4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5ZM5 3.25a.75.75 0 1 0 0 .005V3.25Z"],workflow:["M0 1.75C0 .784.784 0 1.75 0h3.5C6.216 0 7 .784 7 1.75v3.5A1.75 1.75 0 0 1 5.25 7H4v4a1 1 0 0 0 1 1h4v-1.25C9 9.784 9.784 9 10.75 9h3.5c.966 0 1.75.784 1.75 1.75v3.5A1.75 1.75 0 0 1 14.25 16h-3.5A1.75 1.75 0 0 1 9 14.25v-.75H5A2.5 2.5 0 0 1 2.5 11V7h-.75A1.75 1.75 0 0 1 0 5.25Zm1.75-.25a.25.25 0 0 0-.25.25v3.5c0 .138.112.25.25.25h3.5a.25.25 0 0 0 .25-.25v-3.5a.25.25 0 0 0-.25-.25Zm9 9a.25.25 0 0 0-.25.25v3.5c0 .138.112.25.25.25h3.5a.25.25 0 0 0 .25-.25v-3.5a.25.25 0 0 0-.25-.25Z"],rocket:["M14.064 0h.186C15.216 0 16 .784 16 1.75v.186a8.752 8.752 0 0 1-2.564 6.186l-.458.459c-.314.314-.641.616-.979.904v3.207c0 .608-.315 1.172-.833 1.49l-2.774 1.707a.749.749 0 0 1-1.11-.418l-.954-3.102a1.214 1.214 0 0 1-.145-.125L3.754 9.816a1.218 1.218 0 0 1-.124-.145L.528 8.717a.749.749 0 0 1-.418-1.11l1.71-2.774A1.748 1.748 0 0 1 3.31 4h3.204c.288-.338.59-.665.904-.979l.459-.458A8.749 8.749 0 0 1 14.064 0ZM8.938 3.623h-.002l-.458.458c-.76.76-1.437 1.598-2.02 2.5l-1.5 2.317 2.143 2.143 2.317-1.5c.902-.583 1.74-1.26 2.499-2.02l.459-.458a7.25 7.25 0 0 0 2.123-5.127V1.75a.25.25 0 0 0-.25-.25h-.186a7.249 7.249 0 0 0-5.125 2.123ZM3.56 14.56c-.732.732-2.334 1.045-3.005 1.148a.234.234 0 0 1-.201-.064.234.234 0 0 1-.064-.201c.103-.671.416-2.273 1.15-3.003a1.502 1.502 0 1 1 2.12 2.12Zm6.94-3.935c-.088.06-.177.118-.266.175l-2.35 1.521.548 1.783 1.949-1.2a.25.25 0 0 0 .119-.213ZM3.678 8.116 5.2 5.766c.058-.09.117-.178.176-.266H3.309a.25.25 0 0 0-.213.119l-1.2 1.95ZM12 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"],calendar:["M4.75 0a.75.75 0 0 1 .75.75V2h5V.75a.75.75 0 0 1 1.5 0V2h1.25c.966 0 1.75.784 1.75 1.75v10.5A1.75 1.75 0 0 1 13.25 16H2.75A1.75 1.75 0 0 1 1 14.25V3.75C1 2.784 1.784 2 2.75 2H4V.75A.75.75 0 0 1 4.75 0ZM2.5 7.5v6.75c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25V7.5Zm10.75-4H2.75a.25.25 0 0 0-.25.25V6h11V3.75a.25.25 0 0 0-.25-.25Z"],package:["m8.878.392 5.25 3.045c.54.314.872.89.872 1.514v6.098a1.75 1.75 0 0 1-.872 1.514l-5.25 3.045a1.75 1.75 0 0 1-1.756 0l-5.25-3.045A1.75 1.75 0 0 1 1 11.049V4.951c0-.624.332-1.201.872-1.514L7.122.392a1.75 1.75 0 0 1 1.756 0ZM7.875 1.69l-4.63 2.685L8 7.133l4.755-2.758-4.63-2.685a.248.248 0 0 0-.25 0ZM2.5 5.677v5.372c0 .09.047.171.125.216l4.625 2.683V8.432Zm6.25 8.271 4.625-2.683a.25.25 0 0 0 .125-.216V5.677L8.75 8.432Z"]};function wye(e){try{let t=new URL(e).protocol;return t==="http:"||t==="https:"}catch{return!1}}var Cye=u.object({kind:u.literal("resource_link"),objectType:g1.optional(),key:u.string().trim().min(1).max(256),label:u.string().trim().min(1).max(256),url:u.string().url().max(2048).refine(wye,"URL must use HTTP or HTTPS."),description:u.string().trim().min(1).max(512).optional(),status:u.enum(["open","draft","closed","merged","warning"]).optional()}).strict(),aBe=u.discriminatedUnion("kind",[Cye,sz]),kye=u.enum(["circle-dot","circle-dashed","circle-x","git-merge","git-pull-request","triangle-alert"]),nBe=u.object({icon:kye.optional(),objectType:g1.optional(),status:u.string().trim().min(1).max(100).optional(),key:u.string().trim().min(1).max(256),label:u.string().trim().min(1).max(256)}).strict(),Iye=u.enum(["closed","merged","open"]),oBe=u.object({closedAt:u.date().optional(),conversationIds:u.array(u.string().min(1)).default([]),mergedAt:u.date().optional(),number:u.number().int().positive(),openedAt:u.date(),providerId:u.string().min(1),repository:u.object({name:u.string().min(1),providerId:u.string().min(1),url:u.string().url().optional()}).strict(),state:Iye,title:u.string().min(1).optional(),updatedAt:u.date(),url:u.string().url().optional()}).strict(),sBe=u.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_]*$/),Lye=u.enum(["activity","brain","calendar","check","database","info","key","link","sparkles","warning"]),Tye=u.object({content:u.string().min(1).max(32*1024).optional(),description:u.string().trim().min(1).max(2e3).optional(),metadata:u.array(u.string().trim().min(1).max(120)).max(8).optional(),title:u.string().trim().min(1).max(4e3)}).strict(),lBe=u.object({details:u.array(Tye).max(100).optional(),icon:Lye.optional(),preview:u.string().trim().min(1).max(500).optional(),title:u.string().trim().min(1).max(120)}).strict();var v1=u.string().regex(/^T[A-Z0-9]+$/),lz=u.string().regex(/^(C|G|D)[A-Z0-9]+$/),yG=u.string().regex(/^local:[a-z0-9_-]+:[a-z0-9][a-z0-9_-]*$/),Rye=u.string().min(1).refine(e=>e===e.trim()&&e.toLowerCase()!=="unknown"),h1=Rye,Be=u.string().refine(e=>e.trim().length>0),Xr=Be.refine(e=>e===e.trim()),_ye=u.object({id:Be,provider:Xr}).strict(),Nye=_ye.extend({provider:u.literal("slack"),teamId:v1,channelId:lz,threadTs:Xr.optional()}).strict(),cBe=u.discriminatedUnion("provider",[Nye]),dBe=u.enum(["slack","local"]),bG=u.enum(["public","private"]),Aye=u.enum(["public","private"]),$ye=u.object({platform:u.literal("slack"),teamId:v1,channelId:lz,threadTs:Xr.optional()}).strict(),uz=$ye,Pye=u.object({platform:u.literal("local"),conversationId:yG}).strict(),Dye=u.discriminatedUnion("platform",[uz,Pye]),fBe=u.object({action:u.literal("send_message"),destination:uz}).strict(),Eye=u.object({kind:u.literal("slack"),teamId:v1,channelId:lz,visibility:bG,messageTs:Be.optional(),threadTs:Be.optional()}).strict(),Mye=u.object({kind:u.literal("local"),visibility:u.literal("private"),conversationId:yG}).strict(),Oye=u.object({kind:u.literal("web"),visibility:bG,conversationId:Xr}).strict(),zye=u.object({kind:u.literal("event"),eventKey:Xr,eventType:Xr,identifier:Xr,namespace:Xr}).strict(),Uye=u.object({kind:u.literal("scheduled_automation")}).strict(),jye=u.object({kind:u.literal("event_automation")}).strict(),Bye=u.object({kind:u.literal("plugin_dispatch")}).strict(),Fye=u.object({kind:u.literal("agent_invocation")}).strict(),Hye=u.discriminatedUnion("kind",[Eye,Mye,Oye,zye,Uye,jye,Bye,Fye]);function Vye(e){if(!e||typeof e!="object"||Array.isArray(e))return e;let t=e;if("kind"in t){let o={event_task:"event_automation",resource_event:"event",scheduled_task:"scheduled_automation"},i=typeof t.kind=="string"?o[t.kind]:void 0;return i?{...t,kind:i}:e}if(t.platform!=="slack"&&t.platform!=="local"&&t.platform!=="web")return e;let{location:a,platform:r,...n}=t;return{...n,kind:r}}var qye=u.preprocess(Vye,Hye),Zye=u.discriminatedUnion("allowedWhen",[u.object({type:u.literal("user"),userId:h1,allowedWhen:u.literal("private-direct-conversation")}).strict(),u.object({type:u.literal("user"),userId:h1,allowedWhen:u.literal("scheduled-automation"),taskId:Xr}).strict()]),cz={email:Be.optional(),fullName:Be.optional(),userId:h1,userName:Be.optional()},Gye=u.object({...cz,platform:u.literal("slack"),teamId:v1}).strict(),Kye=u.object({...cz,platform:u.literal("local")}).strict(),Wye=u.object({...cz,platform:u.literal("web")}).strict(),Jye=u.object({platform:u.literal("system"),name:h1}).strict(),iz=u.discriminatedUnion("platform",[Gye,Kye,Wye,Jye]),Qye=u.object({displayName:Be.optional(),handle:Be.optional(),id:Xr,provider:Xr,providerSubjectId:Xr,providerTenantId:Xr.optional()}).strict(),mBe=u.object({displayName:Be.optional(),email:Be.max(320),id:Xr,identities:u.array(Qye).max(100),isAdmin:u.literal(!0).optional()}).strict(),Xye=u.record(u.string(),u.string()).superRefine((e,t)=>{let a=Object.entries(e);if(a.length>20){t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata has too many keys"});return}for(let[r,n]of a){if(!r.trim()){t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata values must be strings",path:[r]});continue}r.length>128&&t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata key exceeds the maximum length",path:[r]}),/[\r\n]/.test(r)&&t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata keys must be single-line strings",path:[r]}),/[\r\n]/.test(n)&&t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata values must be single-line strings",path:[r]}),n.length>512&&t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata value exceeds the maximum length",path:[r]})}}),Yye=u.object({label:Xr.pipe(u.string().max(48)).refine(e=>!/[\r\n]/.test(e)),detail:Xr.pipe(u.string().max(128)).refine(e=>!/[\r\n]/.test(e)).optional()}).strict(),pBe=u.object({idempotencyKey:Be.pipe(u.string().max(512)),credentialSubject:Zye.optional(),destination:uz,destinationVisibility:Aye,input:Be.pipe(u.string().max(32e3)),metadata:Xye.optional(),replyAttribution:Yye.optional()}).strict();var ebe=u.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_-]*$/),gBe=u.object({text:u.string().trim().min(1).max(8e3)}).strict(),vBe=u.object({kind:ebe,version:u.number().int().positive(),content:u.record(u.string(),u.unknown())}).strict();var tbe=4e3,abe=8e3,cg=32,pG=4e3,nbe=1e3,rbe=u.record(u.string(),u.unknown()).superRefine((e,t)=>{Object.keys(e).length>cg&&t.addIssue({code:"custom",message:`Event data may include at most ${cg} keys.`}),new TextEncoder().encode(JSON.stringify(e)).byteLength>pG&&t.addIssue({code:"custom",message:`Event data may be at most ${pG} JSON bytes.`})}),gm=u.string().regex(/^[a-z][a-z0-9_-]*(?:\.[a-z][a-z0-9_-]*)+$/).describe("Canonical dotted event type, such as issue.closed or pull_request.review.changes_requested."),xG=u.string().regex(/^[a-z][a-z0-9_]*$/).describe("Canonical plugin-defined resource type, such as issue or pull_request."),SG=/^[a-z][a-zA-Z0-9]*$/,obe=u.object({kind:u.enum(["boolean","string","number"]),description:u.string().trim().min(1).max(200),enum:u.array(u.string().min(1)).min(1).optional()}).strict().superRefine((e,t)=>{e.enum&&e.kind!=="string"&&t.addIssue({code:"custom",message:'Event match field enum requires kind "string".',path:["enum"]})}),ibe=u.record(u.string().regex(SG),obe).superRefine((e,t)=>{Object.keys(e).length>cg&&t.addIssue({code:"custom",message:`Event match keys may include at most ${cg} keys.`})}),bBe=u.record(u.string().regex(SG),u.union([u.boolean(),u.number().finite(),u.string().min(1),u.array(u.union([u.number().finite(),u.string().min(1)])).min(1)])).superRefine((e,t)=>{Object.keys(e).length>cg&&t.addIssue({code:"custom",message:`Event match may include at most ${cg} keys.`});for(let[a,r]of Object.entries(e))Array.isArray(r)&&r.some(n=>typeof n=="boolean")&&t.addIssue({code:"custom",message:`Event match field "${a}" cannot use a boolean list.`,path:[a]})});var sbe=u.object({format:u.string().trim().min(1).max(200),pattern:u.instanceof(RegExp)}).strict(),lbe=u.object({type:xG,identifier:sbe.optional(),supportedEvents:u.array(gm).min(1),suggestedEvents:u.array(gm).optional(),matchFields:ibe.optional(),guidance:u.record(gm,u.string().trim().min(1).max(nbe)).optional()}).strict().superRefine((e,t)=>{let a=new Set;e.supportedEvents.forEach((n,o)=>{a.has(n)&&t.addIssue({code:"custom",message:`Duplicate supported event type "${n}".`,path:["supportedEvents",o]}),a.add(n)});for(let n of Object.keys(e.guidance??{}))a.has(n)||t.addIssue({code:"custom",message:`Guidance event type "${n}" is not supported.`,path:["guidance",n]});let r=new Set;e.suggestedEvents?.forEach((n,o)=>{r.has(n)&&t.addIssue({code:"custom",message:`Duplicate suggested event type "${n}".`,path:["suggestedEvents",o]}),a.has(n)||t.addIssue({code:"custom",message:`Suggested event type "${n}" is not supported.`,path:["suggestedEvents",o]}),r.add(n)})}),xBe=u.object({resourceTypes:u.array(lbe).min(1),isEnabled:u.function({input:[],output:u.boolean()}).optional(),normalizeIdentifier:u.function({input:[u.string()],output:u.string()}).optional()}).strict().superRefine((e,t)=>{let a=new Set;e.resourceTypes.forEach((r,n)=>{a.has(r.type)&&t.addIssue({code:"custom",message:`Duplicate resource type "${r.type}".`,path:["resourceTypes",n,"type"]}),a.add(r.type)})});var SBe=u.object({identifier:u.string().min(1),label:u.string().min(1),namespace:u.string().min(1),suggestedEvents:u.array(gm).optional(),supportedEvents:u.array(gm),type:xG}).strict(),wBe=u.object({events:u.array(gm).min(1),id:u.string().min(1)}).strict(),ube=u.object({objectType:g1.optional(),eventKey:u.string().min(1),eventType:gm,identifier:u.string().min(1),occurredAtMs:u.number().finite(),terminal:u.boolean().optional(),trustedSummary:u.string().min(1).transform(e=>e.slice(0,tbe)),data:rbe.optional(),untrustedText:u.string().transform(e=>e.slice(0,abe)).optional()}).strict(),CBe=ube.extend({namespace:u.string().min(1)}),cbe=u.object({authority:u.enum(["instruction","context"]),actor:iz.optional()}).strict(),dbe=u.discriminatedUnion("type",[u.object({type:u.literal("message"),role:u.enum(["user","assistant"]),text:u.string().min(1),provenance:cbe.optional(),isRunActor:u.boolean().optional()}).strict(),u.object({type:u.literal("toolResult"),toolName:u.string().min(1),isError:u.boolean(),text:u.string().min(1).optional()}).strict()]),IBe=u.object({actorUserId:u.string().min(1).optional(),completedAtMs:u.number().finite(),conversationId:u.string().min(1),destination:Dye,locationId:u.string().min(1).optional(),actors:u.array(iz),actor:iz.optional(),runId:u.string().min(1),source:qye,transcript:u.array(dbe)}).strict();var TBe=u.discriminatedUnion("type",[u.object({type:u.literal("text"),text:u.string()}).strict(),u.object({type:u.literal("image"),data:u.string(),mimeType:u.string()}).strict()]),fbe=u.object({arguments:u.record(u.string(),u.unknown()),reason:u.string().min(1).optional()}).strict(),RBe=u.object({objectAnnotations:u.array(sz).optional(),target:u.string().min(1).optional(),truncated:u.boolean().optional(),continuation:fbe.optional()}).passthrough(),_Be=u.enum(["auto","review","approve"]);var ABe=u.object({auth:u.object({user:u.object({email:u.string().nullable().optional(),emailVerified:u.boolean().optional(),isAdmin:u.boolean(),name:u.string().nullable().optional()}).strict()}).strict(),pluginName:Be}).strict(),mbe=u.string().regex(/^[a-z][a-z0-9-]*$/),pbe=u.string().regex(/^[a-z][a-z0-9.-]*$/),hbe=u.union([u.literal("read"),u.literal("write")]),wG=u.object({provider:mbe,scope:Be.optional(),type:u.literal("oauth")}).strict(),CG=u.object({displayName:Be.optional(),handle:Be.optional(),id:Be,label:Be.optional(),url:Be.optional()}).strict(),PBe=u.object({account:CG.optional(),accessToken:Be,expiresAt:u.number().finite().optional(),refreshToken:Be,refreshTokenExpiresAt:u.number().finite().optional(),scope:Be.optional()}).strict(),DBe=u.object({access:hbe,leaseScope:Be.optional(),name:pbe,reason:Be.optional(),requirements:u.array(Be).min(1).optional()}).strict(),gbe=u.object({domain:u.string().min(1),headers:u.record(u.string(),u.string()).refine(e=>Object.keys(e).length>0)}).strict(),vbe=u.object({account:CG.optional(),authorization:wG.optional(),expiresAt:u.string().refine(e=>Number.isFinite(Date.parse(e))),headerTransforms:u.array(gbe).min(1)}).strict(),EBe=u.discriminatedUnion("type",[u.object({lease:vbe,type:u.literal("lease")}).strict(),u.object({authorization:wG.optional(),message:Be,type:u.literal("needed")}).strict(),u.object({message:Be,type:u.literal("unavailable")}).strict()]);var ybe=Be.max(64).regex(/^[a-z][a-z0-9-]*$/),bbe=Be.max(80),xbe=Be.max(500),Sbe=u.enum(["primary","profile","admin"]),wbe=u.object({detail:Be.max(500).optional(),label:Be.max(80),tone:u.enum(["good","neutral","warning"]).optional(),value:Be.max(120)}).strict(),Cbe=u.object({label:Be.max(80),value:Be.max(500)}).strict(),kbe=u.object({confirmation:Be.max(500).optional(),href:Be.max(500).regex(/^\/api\/plugins\/[a-z][a-z0-9-]*(?:\/|$)/),label:Be.max(80),method:u.enum(["DELETE","GET"]),tone:u.enum(["danger","neutral"]).optional()}).strict(),Ibe=u.object({actions:u.array(kbe).max(4).optional(),description:Be.max(1e3).optional(),id:Be.max(128),metadata:u.array(Cbe).max(8).optional(),title:Be.max(4e3)}).strict(),kG=u.object({emptyText:Be.max(500).optional(),metrics:u.array(wbe).max(6).optional(),nextCursor:Be.max(1e3).optional(),records:u.array(Ibe).max(100),searchPlaceholder:Be.max(120).optional(),type:u.literal("list")}).strict(),Lbe=u.object({description:xbe,id:ybe,label:bbe,navigation:Sbe,pluginDisplayName:Be.max(200),pluginName:Be.max(100)}).strict(),IG=u.array(Lbe),Tbe=Be.max(1e3).optional(),Rbe=Be.max(64).optional(),_be=u.string().trim().max(200).optional(),OBe=u.object({cursor:Tbe,filter:Rbe,limit:u.number().int().min(1).max(50),query:_be}).strict();var LG=u.object({email:u.string().trim().email(),emailVerified:u.boolean().optional(),name:u.string().nullable().optional()}).strict(),jBe=u.object({user:LG}).strict(),y1=u.object({user:LG.extend({isAdmin:u.boolean()}).strict()}).strict(),BBe=u.object({displayName:u.string().trim().min(1).max(80)}).strict(),TG=u.object({allowedEmailCount:u.number(),allowedGoogleDomainCount:u.number(),authRequired:u.boolean(),authPath:u.string(),basePath:u.string(),componentGallery:u.boolean(),sentryConversationLinks:u.boolean(),timeZone:u.string().optional(),version:u.string().min(1)}).strict();var bx=b(G(),1);var RG="x-junior-version";var dz="junior:dashboard-version";function _G(e){let t=e.headers.get(RG)?.trim();!t||typeof window>"u"||window.dispatchEvent(new CustomEvent(dz,{detail:t}))}function NG(e){let[t,a]=(0,bx.useState)(e);return(0,bx.useEffect)(()=>{e&&a(e)},[e]),(0,bx.useEffect)(()=>{let r=n=>{a(n.detail)};return window.addEventListener(dz,r),()=>window.removeEventListener(dz,r)},[]),t}var yn=class extends Error{status;fields;code;apiError;constructor(t,a,r,n){super(`${t} returned ${a}`),this.status=a,this.fields=n?.fields,this.code=n?.code,r?.trim()&&(this.apiError=r.trim())}};async function dg(e,t){let a,r,n;try{let o=await t.json();typeof o.error=="string"&&(a=o.error),typeof o.code=="string"&&(n=o.code),o.fields&&typeof o.fields=="object"&&(r=Object.fromEntries(Object.entries(o.fields).filter(i=>Array.isArray(i[1])&&i[1].every(s=>typeof s=="string"))))}catch{}throw new yn(e,t.status,a,{fields:r,code:n})}function fg(){if(typeof window>"u")return;let e=window.__JUNIOR_DASHBOARD_BASE_PATH__??"/",t=e==="/"?"/auth/login":`${e}/auth/login`;if(window.location.pathname!==t){let a=`${window.location.pathname}${window.location.search||""}`,r=new URLSearchParams;a!=="/"&&r.set("next",a);let n=r.toString();window.location.assign(n?`${t}?${n}`:t)}}async function mg(e,t,a){let r=await pg(t,{body:JSON.stringify(a),credentials:"same-origin",headers:{"content-type":"application/json"},method:"PATCH"});return r.status===401&&fg(),r.ok||await dg(t,r),e.parse(await r.json())}async function wo(e,t,a){let r=await pg(t,{body:JSON.stringify(a),credentials:"same-origin",headers:{"content-type":"application/json"},method:"POST"});return r.status===401&&fg(),r.ok||await dg(t,r),e.parse(await r.json())}async function AG(e,t,a){let r=await pg(t,{body:JSON.stringify(a),credentials:"same-origin",headers:{"content-type":"application/json"},method:"PUT"});return r.status===401&&fg(),r.ok||await dg(t,r),e.parse(await r.json())}async function Rd(e){let t=await pg(e,{credentials:"same-origin",method:"DELETE"});t.status===401&&fg(),t.ok||await dg(e,t)}async function $G(e,t,a={}){let r=await pg(t,{body:JSON.stringify(a),credentials:"same-origin",headers:{"content-type":"application/json"},method:"DELETE"});return r.status===401&&fg(),r.ok||await dg(t,r),e.parse(await r.json())}async function pg(e,t){let a=await fetch(e,t);return _G(a),a}async function Ne(e,t,a){let r=await fz(t,a);return e.parse(await r.json())}async function fz(e,t,a){let r=await pg(e,{credentials:"same-origin",...t?{signal:t}:void 0,...a?{cache:"no-store",headers:{"if-none-match":a}}:void 0});return r.status===401&&fg(),!r.ok&&!(a&&r.status===304)&&await dg(e,r),r}var b1=5*6e4,mz=5*6e4,Nbe=1e3;function Abe(e,t=Date.now()){if(!e)return mz;let a=Date.parse(e);if(!Number.isFinite(a))return mz;let r=Math.max(0,t-a);return Math.max(Nbe,mz-r)}function PG(){return Ue({queryKey:["dashboard","core"],queryFn:async({signal:e})=>{let[t,a]=await Promise.all([Ne(y1,"/api/me",e),Ne(TG,"/api/config",e)]);return{config:a,me:t}},retry:!1,staleTime:b1})}function $be(){return Ue({queryKey:["dashboard","plugins"],queryFn:({signal:e})=>Ne(ZE,"/api/plugins",e),retry:!1,staleTime:b1})}function DG(){return Ue({queryKey:["dashboard","plugin-user-pages"],queryFn:({signal:e})=>Ne(IG,"/api/user-pages",e),retry:!1,staleTime:b1})}function x1(e=""){return Ue({queryKey:["dashboard","conversations","viewer",{search:e}],queryFn:({signal:t})=>Ne(Yk,`/api/conversations${e?`?q=${encodeURIComponent(e)}`:""}`,t),placeholderData:pf,retry:!1})}function EG(){return Ue({queryKey:["dashboard","code"],queryFn:({signal:e})=>Ne(GO,"/api/code",e),retry:!1})}function MG(e){return Ue({enabled:!!e,queryKey:["dashboard","code","repositories",e],queryFn:({signal:t})=>Ne(KO,`/api/code/repositories/${encodeURIComponent(e)}`,t),retry:!1})}function S1(e,t=""){return Ue({enabled:!!e,queryKey:["dashboard","conversations","code-repository",{repositoryId:e,search:t}],queryFn:({signal:a})=>{let r=new URLSearchParams({codeRepositoryId:e});return t&&r.set("q",t),Ne(Yk,`/api/conversations?${r.toString()}`,a)},placeholderData:pf,retry:!1})}function OG(e,t){return Ue({enabled:e,queryKey:["dashboard","automations",t],queryFn:({signal:a})=>Ne(OE,`/api/automations${t?`?${t}`:""}`,a),placeholderData:pf,retry:!1})}function hg(e,t){return Ue({enabled:e&&!!t,queryKey:["dashboard","automations","detail",t],queryFn:({signal:a})=>Ne(mx,`/api/automations/${encodeURIComponent(t)}`,a),retry:!1})}function zG(e){return Ue({enabled:e,queryKey:["dashboard","automations","runs"],queryFn:({signal:t})=>Ne(jE,"/api/automations/runs",t),retry:!1})}function UG(e,t,a){return Ue({enabled:e&&!!(t&&a),queryKey:["dashboard","automations",t,a,"executions"],queryFn:({signal:r})=>Ne(UE,`/api/automations/${t}/${encodeURIComponent(a)}/executions`,r),retry:!1})}function jG(e,t,a){return Ue({enabled:e&&!!(t&&a),queryKey:["dashboard","automations",t,a,"versions"],queryFn:({signal:r})=>Ne(BE,`/api/automations/${t}/${encodeURIComponent(a)}/versions`,r),retry:!1})}function BG(){return Ue({queryKey:["dashboard","people"],queryFn:({signal:e})=>Ne(XO,"/api/people",e),retry:!1})}function FG(e){return Ue({enabled:!!e,queryKey:["dashboard","people",e],queryFn:async({signal:t})=>Ne(YO,`/api/people/${encodeURIComponent(e)}`,t),retry:!1})}function HG(e){return Ue({enabled:!!e,queryKey:["dashboard","people",e,"plugin-reports"],queryFn:({signal:t})=>Ne(n1,`/api/people/${encodeURIComponent(e)}/plugin-reports`,t),retry:!1})}function VG(e){return Ue({enabled:!!e,queryKey:["dashboard","people",e,"code"],queryFn:({signal:t})=>Ne(WO,`/api/people/${encodeURIComponent(e)}/code`,t),retry:!1})}function qG(e){return Ue({enabled:e,queryKey:["dashboard","personal-spend"],queryFn:({signal:t})=>Ne(ez,"/api/people/me/spend",t),refetchInterval:t=>Abe(t.state.data?.generatedAt),retry:!1,staleTime:0})}function ZG(){return Ue({queryKey:["dashboard","locations"],queryFn:({signal:e})=>Ne(JO,"/api/locations",e),retry:!1})}function GG(e){return Ue({enabled:!!e,queryKey:["dashboard","locations",e],queryFn:async({signal:t})=>Ne(QO,`/api/locations/${encodeURIComponent(e)}`,t),retry:!1})}function Pbe(){return Ue({queryKey:["dashboard","skills"],queryFn:({signal:e})=>Ne(KE,"/api/skills",e),retry:!1,staleTime:b1})}function Dbe(){return Ue({queryKey:["dashboard","plugin-reports"],queryFn:({signal:e})=>Ne(n1,"/api/plugin-reports",e),retry:!1})}function KG(){return Ue({queryKey:["dashboard","stats"],queryFn:({signal:e})=>Ne(oz,"/api/stats",e),retry:!1})}function WG(e){let t=$be(),a=Ue({queryKey:["dashboard","conversation-stats"],queryFn:({signal:i})=>Ne(DE,"/api/conversations/stats",i),retry:!1}),r=Pbe(),n=Dbe();return{data:t.data&&r.data?{...e,conversationStatsError:!!a.error,...a.data?{conversationStats:a.data}:void 0,conversationStatsLoading:a.isPending,pluginReportsError:!!n.error,...n.data?{pluginReports:n.data}:void 0,pluginReportsLoading:n.isPending,plugins:t.data,skills:r.data}:void 0,error:t.error??r.error,isPending:t.isPending||r.isPending}}function I(...e){return e.filter(Boolean).join(" ")}var Ya="mx-auto w-full min-w-0 max-w-screen-xl",vm="text-dashboard-text-muted hover:text-dashboard-text",JG="rounded-xl border border-dashboard-border-interactive bg-dashboard-surface-active",QG="dashboard-shell-bg";var w1=b(w(),1),XG="inline-flex h-9 max-w-full items-center gap-2 rounded border border-dashboard-border-emphasis bg-dashboard-surface-raised px-3 font-mono text-sm font-semibold leading-none text-dashboard-text transition-colors hover:border-dashboard-border-heavy hover:bg-dashboard-surface-hover hover:text-dashboard-text",Ebe="inline-flex h-9 max-w-full items-center justify-center gap-1.5 rounded border border-dashboard-border-strong bg-transparent px-3 font-mono text-xs font-semibold text-dashboard-text-muted transition-colors hover:border-rose-300/40 hover:text-rose-300";function ie({className:e,size:t="default",tone:a="default",type:r="button",...n}){let o=a==="danger";return(0,w1.jsx)("button",{...n,className:I("font-mono transition-colors disabled:cursor-not-allowed disabled:opacity-50",t==="icon"?I("grid size-9 place-items-center rounded-md border-0 bg-transparent p-0 focus-visible:outline focus-visible:outline-1 disabled:hover:!bg-transparent",o?"text-dashboard-text-muted hover:!bg-rose-300/10 hover:!text-rose-300 focus-visible:outline-rose-300/55 disabled:hover:!text-dashboard-text-muted":"text-dashboard-text-muted hover:!bg-dashboard-fill-strong hover:!text-dashboard-text focus-visible:outline-cyan-300/55 disabled:hover:!text-dashboard-text-muted"):a==="primary"?"inline-flex h-9 items-center justify-center gap-2 rounded border border-dashboard-text-solid bg-dashboard-text-solid px-3 font-sans text-sm font-semibold text-dashboard-text-inverse hover:bg-dashboard-text-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-dashboard-focus":o?I(Ebe,"disabled:hover:border-dashboard-border-strong disabled:hover:text-dashboard-text-muted"):I(XG,"disabled:hover:border-dashboard-border-emphasis disabled:hover:bg-dashboard-surface-raised disabled:hover:text-dashboard-text"),n.disabled?"":"cursor-pointer",e),type:r})}function _d({className:e,...t}){return(0,w1.jsx)(ae,{...t,className:I(XG,"no-underline",e)})}function Ln({className:e,pressed:t,type:a="button",variant:r,...n}){return(0,w1.jsx)("button",{...n,"aria-pressed":t,className:I(Mbe[r],t?Obe[r]:zbe[r],e),type:a})}var Mbe={pill:"cursor-pointer rounded border px-2 py-1 font-mono text-xs font-semibold uppercase leading-tight transition-colors focus-visible:outline focus-visible:outline-1 focus-visible:outline-cyan-300/55",segment:"h-7 min-w-10 cursor-pointer rounded border px-2 font-mono text-xs transition-colors focus-visible:outline focus-visible:outline-1 focus-visible:outline-cyan-300/55",text:"cursor-pointer border-0 bg-transparent px-1.5 py-1 font-mono uppercase tracking-normal underline-offset-4 transition-colors focus-visible:outline focus-visible:outline-1 focus-visible:outline-cyan-300/55"},Obe={pill:"border-dashboard-border-heavy bg-dashboard-text-solid text-dashboard-text-inverse",segment:"border-amber-500/30 bg-amber-500/20 text-amber-400",text:"text-dashboard-text underline decoration-dashboard-text-solid"},zbe={pill:"border-dashboard-border-strong bg-dashboard-surface-raised text-dashboard-text-muted hover:border-dashboard-border-interactive hover:bg-dashboard-surface-hover hover:text-dashboard-text",segment:"border-dashboard-border-strong bg-dashboard-fill-faint text-dashboard-text-muted hover:bg-dashboard-fill-strong hover:text-dashboard-text",text:"text-dashboard-text-muted hover:text-dashboard-text"};var ym=b(w(),1);function Yr(e){let t=e.tone==="error";return(0,ym.jsxs)("div",{role:t?"alert":"status",className:I("flex min-w-0 gap-3 rounded-md border p-4",t?"border-rose-300/25 bg-rose-300/5":"border-amber-300/25 bg-amber-300/5"),children:[(0,ym.jsx)(Kr,{"aria-hidden":!0,size:18,className:I("mt-0.5 shrink-0",t?"text-rose-300":"text-amber-300")}),(0,ym.jsxs)("div",{className:"min-w-0",children:[(0,ym.jsx)("p",{className:"m-0 text-sm font-medium",children:e.title}),e.children?(0,ym.jsx)("div",{className:"mt-1 text-sm leading-relaxed text-dashboard-text-muted",children:e.children}):null]})]})}var xx=b(w(),1),Ube={accent:"text-violet-300",danger:"text-rose-300",info:"text-cyan-300",neutral:"text-dashboard-text-muted",success:"text-emerald-300",warning:"text-amber-300"},jbe={compact:"text-xs",default:"text-sm"};function ba(e){return(0,xx.jsxs)("span",{className:I("inline-flex w-fit items-center gap-1.5 font-sans font-medium normal-case leading-snug tracking-normal",jbe[e.size??"default"],Ube[e.tone??"neutral"],e.className),children:[(0,xx.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-current"}),(0,xx.jsx)("span",{className:"block first-letter:uppercase",children:e.children})]})}var YG=b(w(),1);function U(e){let t=e.as??"div",a={none:"",sm:"p-4",md:"p-5 sm:p-6"}[e.padding??"none"],r=e.variant==="section"?"mb-4 border-dashboard-border-subtle bg-dashboard-fill-faint shadow-[0_24px_80px_rgba(0,0,0,0.18)]":e.variant==="raised"?"border-dashboard-border-emphasis bg-dashboard-surface-raised":"border-dashboard-border-subtle bg-dashboard-fill-faint";return(0,YG.jsx)(t,{className:I("min-w-0 overflow-hidden rounded-lg border",r,a,e.className),children:e.children})}var eK=b(w(),1);function Qe(e){let t=e.as??"div";return(0,eK.jsx)(t,{"aria-hidden":"true",className:I("animate-pulse rounded bg-dashboard-fill-soft motion-reduce:animate-none",e.className)})}var ot=b(w(),1);function Yn(e){let t=e.variant??"panel";return(0,ot.jsxs)("div",{"aria-busy":"true","aria-live":"polite",className:I("grid gap-4",e.className),role:"status",children:[(0,ot.jsx)("span",{className:"sr-only",children:e.label}),Bbe(t)]})}function Bbe(e){switch(e){case"stats":return(0,ot.jsx)(Fbe,{});case"overview":return(0,ot.jsx)(Hbe,{});case"list":return(0,ot.jsx)(Vbe,{});case"library":return(0,ot.jsx)(qbe,{});case"panel":return(0,ot.jsx)(ql,{className:"min-h-64"})}}function Fbe(){return(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsx)("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:Array.from({length:4},(e,t)=>(0,ot.jsx)(ql,{className:"min-h-[7.5rem] p-4 sm:min-h-32 sm:p-5"},t))}),(0,ot.jsx)(ql,{className:"min-h-[17rem]"})]})}function Hbe(){return(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,ot.jsx)(ql,{className:"min-h-[17rem]"}),(0,ot.jsx)(ql,{className:"min-h-[17rem]"})]}),(0,ot.jsx)(gg,{className:"h-24 border-y border-dashboard-border-subtle bg-dashboard-fill-faint"}),(0,ot.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,ot.jsx)(ql,{className:"min-h-56"}),(0,ot.jsx)(ql,{className:"min-h-56"})]})]})}function Vbe(){return(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsx)(ql,{className:"min-h-20 p-4"}),(0,ot.jsx)(gg,{className:"h-10 border-b border-dashboard-border-subtle"}),(0,ot.jsx)(ql,{className:"min-h-80"})]})}function qbe(){return(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsxs)("div",{className:"flex flex-wrap items-end justify-between gap-4",children:[(0,ot.jsx)(gg,{className:"h-7 w-56 rounded bg-dashboard-fill-soft"}),(0,ot.jsx)(gg,{className:"h-10 w-full max-w-md rounded-lg border border-dashboard-border-subtle bg-dashboard-fill-faint sm:w-72"})]}),(0,ot.jsx)("div",{"aria-hidden":"true",className:"grid min-w-0 grid-cols-3 gap-1 border-b border-dashboard-border-subtle sm:flex",children:Array.from({length:3},(e,t)=>(0,ot.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2.5 sm:justify-start",children:[(0,ot.jsx)(gg,{className:"h-3 w-12 rounded bg-dashboard-fill-soft"}),(0,ot.jsx)(gg,{className:"h-5 w-8 rounded-sm border border-dashboard-border-subtle bg-dashboard-fill-faint"})]},t))}),(0,ot.jsx)(ql,{className:"min-h-80"})]})}function ql(e){return(0,ot.jsx)(U,{className:I("animate-pulse motion-reduce:animate-none",e.className),children:(0,ot.jsx)("span",{"aria-hidden":"true"})})}function gg(e){return(0,ot.jsx)(Qe,{className:e.className})}var pz=b(w(),1),Zbe=[1,7,30,90];function hz(e){return e===1?"24h":`${e}d`}function vg(e){return e===1?"last 24 hours":`last ${e} days`}function Ha(e){return e===1?"hour":e===7?"6hour":"day"}function tK(e){return e===1}function Gbe(e){return e===7}function eo(e){return e==="hour"?"hour":e==="6hour"?"6h":"day"}function yg(e){return e==="hour"?"hour":e==="6hour"?"6 hours":"day"}function Sx(e){return e==="hour"?"Hourly":e==="6hour"?"6-hour":"Daily"}function en(e){return tK(e.range)&&e.hours?.length?e.hours.slice(-24):tK(e.range)?e.days.slice(-1):Gbe(e.range)?e.sixHours?.length?[...e.sixHours]:e.hours?.length&&e.emptySixHour?Kbe({empty:e.emptySixHour,hours:e.hours}):e.days.slice(-e.range):e.days.slice(-e.range)}function Kbe(e){let t=new Map;for(let a of e.hours){let r=Date.parse(`${a.date}:00:00.000Z`);if(Number.isNaN(r))continue;let n=new Date(r);n.setUTCMinutes(0,0,0),n.setUTCHours(Math.floor(n.getUTCHours()/6)*6,0,0,0);let o=n.toISOString().slice(0,13),s={...t.get(o)??e.empty(o),date:o};for(let[l,c]of Object.entries(a))if(l!=="date"&&typeof c=="number"){let d=s[l];s[l]=(typeof d=="number"?d:0)+c}t.set(o,s)}if(e.hours.length>=24){let a=e.hours[e.hours.length-1]?.date,r=a?Date.parse(`${a}:00:00.000Z`):Date.now(),n=new Date(r);n.setUTCMinutes(0,0,0),n.setUTCHours(Math.floor(n.getUTCHours()/6)*6,0,0,0);let o=new Date(n.getTime()-9720*60*1e3),i=[];for(let s=new Date(o);s.getTime()<=n.getTime();s.setTime(s.getTime()+360*60*1e3)){let l=s.toISOString().slice(0,13);i.push(t.get(l)??e.empty(l))}return i}return[...t.values()].sort((a,r)=>a.date.localeCompare(r.date))}function bg(e){return(0,pz.jsx)("div",{"aria-label":"Reporting period",className:"flex items-center gap-1",role:"group",children:(e.options??Zbe).map(t=>(0,pz.jsx)(Ln,{onClick:()=>e.onChange(t),pressed:e.value===t,variant:"segment",children:hz(t)},t))})}var Nd=b(w(),1);function We(e){let t=e.range!==void 0&&e.onRangeChange?(0,Nd.jsx)(bg,{onChange:e.onRangeChange,...e.rangeOptions?{options:e.rangeOptions}:{},value:e.range}):void 0,a=e.actions??t;return(0,Nd.jsxs)("header",{className:"flex min-w-0 items-center justify-between gap-6 border-b border-white/[0.05] pb-4 sm:pb-6 max-md:flex-col max-md:items-stretch",children:[(0,Nd.jsxs)("div",{className:"min-w-0",children:[(0,Nd.jsx)("h2",{className:"m-0 font-display text-3xl font-light leading-none tracking-[-0.03em] text-dashboard-text sm:text-4xl",children:e.title}),(0,Nd.jsx)("div",{className:"mt-2 max-w-2xl font-mono text-xs leading-relaxed text-dashboard-text-muted sm:text-sm",children:e.description})]}),a?(0,Nd.jsx)("div",{className:"shrink-0",children:a}):null]})}var aK=b(w(),1);function Co(e){return(0,aK.jsx)("div",{className:I(Ya,"grid min-w-0 content-start gap-4 px-4 py-4 pb-[max(1rem,env(safe-area-inset-bottom))] sm:gap-6 sm:px-8 sm:py-8 sm:pb-8",e.className),children:e.children})}var xm=b(G(),1);var bm=b(G(),1);function Ni(e,t){let a=typeof t=="string"?t.startsWith("?")?t.slice(1):t:t?.toString()??"",r=e.indexOf("?"),n=r===-1?e:e.slice(0,r),o=r===-1?"":e.slice(r+1).replace(/^\?+/,""),i=new URLSearchParams(a);for(let[l,c]of new URLSearchParams(o))i.set(l,c);let s=i.toString();return s?`${n}?${s}`:n}function Wbe(e,t){let a=e?.trim();return a&&t.includes(a)?a:void 0}function Zl(e="q",t={}){let a=t.delayMs??250,r=t.resetPage??!1,[n,o]=qo(),i=n.get(e)?.trim()??"",[s,l]=(0,bm.useState)(i);return(0,bm.useEffect)(()=>{l(c=>c.trim()===i?c:i)},[i]),(0,bm.useEffect)(()=>{let c=window.setTimeout(()=>{let d=s.trim();d!==i&&o(f=>{let m=new URLSearchParams(f);return r&&m.delete("page"),d?m.set(e,d):m.delete(e),m},{replace:!0})},a);return()=>window.clearTimeout(c)},[i,a,e,r,o,s]),[s,l,i]}function ec(e,t,a){let[r,n]=qo(),o=Wbe(r.get(e),a)??t,i=(0,bm.useCallback)(s=>{n(l=>{let c=new URLSearchParams(l);return s===t?c.delete(e):c.set(e,s),c},{replace:!0})},[t,e,n]);return[o,i]}var nK=b(G(),1);var xg=b(w(),1),gz="rounded-lg border border-dashboard-border bg-dashboard-surface-panel",vz="gap-1 p-1";function yz(e){return I("min-h-9 cursor-pointer rounded-md border-0 px-3 py-2 font-sans text-sm font-medium transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus",e?"bg-dashboard-fill-strong text-dashboard-text":"bg-transparent text-dashboard-text-muted hover:bg-dashboard-fill-faint hover:text-dashboard-text")}function C1(e){let t=(0,nK.useId)();return(0,xg.jsxs)("div",{className:"grid min-w-0 gap-4",children:[(0,xg.jsx)("div",{"aria-label":e.label,className:I("grid auto-cols-fr grid-flow-col",gz,vz),role:"tablist",children:e.items.map((a,r)=>(0,xg.jsx)("button",{"aria-controls":`${t}-panel`,"aria-selected":e.value===a.value,className:I("min-w-0",yz(e.value===a.value)),id:`${t}-${a.value}`,onClick:()=>e.onChange(a.value),onKeyDown:n=>{let o,i=e.items.length;switch(n.key){case"ArrowLeft":o=(r+i-1)%i;break;case"ArrowRight":o=(r+1)%i;break;case"Home":o=0;break;case"End":o=i-1;break;default:return}n.preventDefault(),e.onChange(e.items[o].value),n.currentTarget.parentElement?.querySelectorAll('[role="tab"]')[o]?.focus()},role:"tab",tabIndex:e.value===a.value?0:-1,type:"button",children:a.label},a.value))}),(0,xg.jsx)("div",{"aria-labelledby":`${t}-${e.value}`,className:"min-w-0 rounded focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus",id:`${t}-panel`,role:"tabpanel",tabIndex:0,children:e.children})]})}var Sg=b(w(),1);function xz(e){let{className:t,item:a}=e,r=vt(),n=Ni(a.to,r.search);if(a.isActive){let o=a.isActive(r.pathname);return(0,Sg.jsx)(ae,{"aria-current":o?"page":void 0,className:t({isActive:o}),to:n,children:a.label})}return(0,Sg.jsx)(jf,{className:t,end:a.end,to:n,children:a.label})}var bz=24;function oK(e){let t=e.scrollWidth-e.clientWidth;return{end:e.scrollLeft<t-1,start:e.scrollLeft>1}}function rK(e){let t=e.querySelector('[aria-current="page"]');if(!t||e.clientWidth===0)return;let a=oK(e),r=e.scrollLeft+(a.start?bz:0),n=e.scrollLeft+e.clientWidth-(a.end?bz:0),o=t.offsetLeft,i=o+t.offsetWidth;o>=r&&i<=n||(e.scrollLeft=o-(e.clientWidth-t.offsetWidth)/2)}function Jbe(e){if(!e.start&&!e.end)return;let t=`${bz}px`,a=e.start?`transparent, black ${t}`:"black",r=e.end?`black calc(100% - ${t}), transparent`:"black",n=`linear-gradient(to right, ${a}, ${r})`;return{maskImage:n,WebkitMaskImage:n}}function Sm(e){let{pathname:t}=vt(),a=(0,xm.useRef)(null),[r,n]=(0,xm.useState)({end:!1,start:!1});(0,xm.useLayoutEffect)(()=>{let i=a.current;if(!i)return;let s=()=>{let{end:c,start:d}=oK(i);n(f=>f.start===d&&f.end===c?f:{end:c,start:d})},l=new ResizeObserver(()=>{i.scrollLeft=0,rK(i),s()});s(),i.addEventListener("scroll",s,{passive:!0}),l.observe(i);for(let c of i.children)l.observe(c);return()=>{i.removeEventListener("scroll",s),l.disconnect()}},[]),(0,xm.useLayoutEffect)(()=>{a.current&&rK(a.current)},[t]);let o=({isActive:i})=>I(yz(i),"flex items-center justify-center whitespace-nowrap no-underline",e.fill?"min-w-max flex-[1_0_0]":"shrink-0");return(0,Sg.jsx)("nav",{"aria-label":e.ariaLabel,className:I(gz,"flex min-w-0 max-w-full",!e.fill&&"w-fit"),children:(0,Sg.jsx)("div",{className:I(vz,"relative flex min-w-0 flex-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"),ref:a,style:Jbe(r),children:e.items.map(i=>(0,Sg.jsx)(xz,{className:o,item:i},i.to))})})}var Gt=b(G(),1),wx=b(Tl(),1),Qs=b(w(),1),Gl=(0,Gt.createContext)(null);function k1(e){let[t,a]=(0,Gt.useState)(null),[r,n]=(0,Gt.useState)(null),[o,i]=(0,Gt.useState)(null),[s,l]=(0,Gt.useState)(null),c=(0,Gt.useRef)(null),d=(0,Gt.useCallback)(y=>{a(y)},[]),f=(0,Gt.useCallback)(y=>{n(y)},[]),m=(0,Gt.useCallback)(y=>{i(y)},[]),p=(0,Gt.useCallback)(y=>{l(y)},[]),h=(0,Gt.useCallback)(y=>{c.current=y},[]),g=(0,Gt.useCallback)(()=>{c.current?.()},[]),x=(0,Gt.useMemo)(()=>({mobileHeaderActionsSlot:o,mobileHeaderActionsSlotRef:m,mobileHeaderLiveSlot:s,mobileHeaderLiveSlotRef:p,mobileSecondarySlot:r,mobileSecondarySlotRef:f,openMobileNavigation:g,registerOpenMobileNavigation:h,secondarySlot:t,secondarySlotRef:d}),[o,m,s,p,r,f,g,h,t,d]);return(0,Qs.jsx)(Gl.Provider,{value:x,children:e.children})}function iK(e){let t=(0,Gt.useContext)(Gl);if(!t)throw new Error("DashboardChrome requires DashboardChromeProvider");return(0,Qs.jsxs)("div",{className:"sticky top-0 z-30 bg-dashboard-bg/95 pt-[env(safe-area-inset-top)]",children:[e.header,(0,Qs.jsx)("div",{className:"hidden md:block",ref:t.secondarySlotRef}),e.banner]})}function sK(){let e=(0,Gt.useContext)(Gl);if(!e)throw new Error("MobileSecondaryNavigationSlot requires DashboardChromeProvider");return(0,Qs.jsx)("div",{ref:e.mobileSecondarySlotRef})}function lK(){let e=(0,Gt.useContext)(Gl);if(!e)throw new Error("MobileHeaderActionsSlot requires DashboardChromeProvider");return(0,Qs.jsx)("div",{className:"col-start-3 row-start-1 flex min-w-0 items-center justify-self-end md:hidden",ref:e.mobileHeaderActionsSlotRef})}function uK(){let e=(0,Gt.useContext)(Gl);if(!e)throw new Error("MobileHeaderLiveSlot requires DashboardChromeProvider");return(0,Qs.jsx)("div",{className:"flex shrink-0 items-center md:hidden",ref:e.mobileHeaderLiveSlotRef})}function cK(e){let t=(0,Gt.useContext)(Gl);return t?.mobileHeaderActionsSlot?(0,wx.createPortal)(e.children,t.mobileHeaderActionsSlot):null}function dK(e){let t=(0,Gt.useContext)(Gl);return t?.mobileHeaderLiveSlot?(0,wx.createPortal)(e.children,t.mobileHeaderLiveSlot):null}function fK(){let e=(0,Gt.useContext)(Gl);return e?e.openMobileNavigation:null}function mK(e){let t=(0,Gt.useContext)(Gl),a=(0,Gt.useRef)(e);a.current=e,(0,Gt.useEffect)(()=>{if(!t)return;let r=()=>{a.current?.()};return t.registerOpenMobileNavigation(e?r:null),()=>{t.registerOpenMobileNavigation(null)}},[t,e])}function pK(e){let t=(0,Gt.useContext)(Gl);return t?t.secondarySlot?(0,Qs.jsxs)(Qs.Fragment,{children:[(0,wx.createPortal)(e.desktop,t.secondarySlot),t.mobileSecondarySlot?(0,wx.createPortal)(e.mobile,t.mobileSecondarySlot):null]}):null:e.desktop}var Xs=b(w(),1);function Ad(e){let t=({isActive:a})=>I("rounded-lg px-3 py-3 pl-6 font-mono text-sm font-medium no-underline transition-colors",a?"bg-cyan-300/[0.1] text-cyan-50":I("hover:bg-white/[0.035]",vm));return(0,Xs.jsxs)("div",{className:"min-w-0",children:[(0,Xs.jsx)(pK,{desktop:(0,Xs.jsx)("div",{className:"border-b border-white/[0.06] bg-white/[0.018]",children:(0,Xs.jsx)("div",{className:I(Ya,"min-w-0 px-4 py-2 md:px-8"),children:(0,Xs.jsx)(Sm,{ariaLabel:e.ariaLabel,items:e.items})})}),mobile:(0,Xs.jsx)("nav",{"aria-label":e.ariaLabel,className:"mt-3 grid gap-1 border-t border-white/[0.07] pt-3",children:e.items.map(a=>(0,Xs.jsx)(xz,{className:t,item:a},a.to))})}),(0,Xs.jsx)("div",{className:"px-4 pt-4 sm:px-8 md:hidden",children:(0,Xs.jsx)(Sm,{ariaLabel:e.ariaLabel,fill:!0,items:e.items})}),e.children]})}var Kl=b(w(),1),Qbe=new Set(["list","runs"]);function Xbe(e){if(e==="/automations/list"||/^\/automations\/(scheduled|event)\/[^/]+\/edit$/.test(e))return!0;let t=e.match(/^\/automations\/([^/]+)$/);return!!(t?.[1]&&!Qbe.has(t[1]))}var Ybe=[{end:!0,label:"Overview",to:"/automations"},{isActive:Xbe,label:"Automations",to:"/automations/list"},{label:"Runs",to:"/automations/runs"}];function Sz(e){return(0,Kl.jsx)(Ad,{ariaLabel:"Automations navigation",items:Ybe,children:e.children})}function Ai(e){return(0,Kl.jsx)(Sz,{children:(0,Kl.jsx)(Co,{children:e.children})})}function wm(e){return(0,Kl.jsxs)(Kl.Fragment,{children:[(0,Kl.jsx)(We,{description:e.description,title:e.title}),(0,Kl.jsx)(Yn,{label:e.label,variant:e.variant})]})}var ps=b(G(),1);var wg=b(w(),1),exe={compact:"font-mono text-xs uppercase tracking-[0.12em] text-dashboard-text-muted",default:"text-sm font-semibold text-dashboard-text"},txe={compact:"grid gap-1.5",default:"grid gap-2"};function Ot(e){let t=e.size??"default";return(0,wg.jsxs)("div",{className:I(txe[t],e.className),children:[(0,wg.jsx)("label",{className:exe[t],htmlFor:e.htmlFor,children:e.label}),e.children,e.error?(0,wg.jsx)("p",{id:e.htmlFor?`${e.htmlFor}-error`:void 0,role:"alert",className:"m-0 text-xs leading-relaxed text-rose-300",children:e.error}):null,e.help?(0,wg.jsx)("p",{id:e.htmlFor?`${e.htmlFor}-help`:void 0,className:"m-0 text-xs leading-relaxed text-dashboard-text-muted sm:text-sm",children:e.help}):null]})}var wz=b(w(),1),hK="block w-full rounded border border-dashboard-border-emphasis bg-dashboard-ink px-3 py-2 text-sm text-dashboard-text focus:border-dashboard-focus focus:outline-none aria-invalid:border-rose-300 disabled:cursor-not-allowed disabled:opacity-50";function xa({className:e,type:t="text",size:a="default",...r}){return(0,wz.jsx)("input",{...r,className:I(hK,a==="comfortable"&&"min-h-11 text-base sm:min-h-10 sm:text-sm",e),type:t})}function tc({className:e,prose:t=!1,...a}){return(0,wz.jsx)("textarea",{...a,className:I(hK,"min-h-36",t?"font-sans leading-relaxed":"font-mono",e)})}var Cm=b(w(),1);function ms(e){return(0,Cm.jsxs)("section",{className:"grid min-w-0 gap-5 border-t border-dashboard-border-emphasis py-8 md:grid-cols-[12rem_minmax(0,1fr)] md:gap-10",children:[(0,Cm.jsxs)("div",{children:[(0,Cm.jsx)("h2",{className:"m-0 font-display text-lg font-medium",children:e.title}),e.detail?(0,Cm.jsx)("p",{className:"mt-2 mb-0 text-sm leading-relaxed text-dashboard-text-muted",children:e.detail}):null]}),(0,Cm.jsx)("div",{className:"grid min-w-0 content-start gap-5",children:e.children})]})}var R1=b(G(),1);var gK=b(w(),1);function Wl({className:e,...t}){return(0,gK.jsx)("select",{...t,className:I("block min-h-11 w-full min-w-0 rounded border border-dashboard-border-emphasis bg-dashboard-ink px-3 py-2 text-base text-dashboard-text focus:border-dashboard-focus focus:outline-none aria-invalid:border-rose-300 disabled:cursor-not-allowed disabled:opacity-60 sm:min-h-10 sm:text-sm",e)})}var I1=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function L1(e){return{title:e.title??"",instruction:e.instruction,credentialMode:e.credentialMode,outcomes:e.outcomes,trigger:e.kind==="event"?e.trigger:void 0}}function T1(e){let t=e.schedule.recurrence;if(e.schedule.kind==="recurring"&&t){let{time:a,weekdays:r,...n}=t;return{kind:"recurring",...n,timezone:e.schedule.timezone,time:`${String(a.hour).padStart(2,"0")}:${String(a.minute).padStart(2,"0")}`,weekdays:r?.map(o=>I1[o])}}if(e.nextRunAtMs){let a=new Intl.DateTimeFormat("en-CA",{timeZone:e.schedule.timezone,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(e.nextRunAtMs),r=n=>a.find(o=>o.type===n)?.value??"";return{kind:"one_off",timezone:e.schedule.timezone,timing:{type:"at",date:`${r("year")}-${r("month")}-${r("day")}`,time:`${r("hour")}:${r("minute")}`}}}return{kind:"recurring",frequency:"daily",time:"09:00",timezone:e.schedule.timezone}}function vK(e,t){let a={};return t.title!==(e.title??"")&&(a.title=t.title),t.instruction!==e.instruction&&(a.instruction=t.instruction),t.credentialMode!==e.credentialMode&&(a.credentialMode=t.credentialMode),JSON.stringify(t.outcomes)!==JSON.stringify(e.outcomes)&&(a.outcomes=t.outcomes),e.kind==="scheduled"&&t.schedule&&(a.schedule=t.schedule),e.kind==="event"&&JSON.stringify(t.trigger)!==JSON.stringify(e.trigger)&&(a.trigger=t.trigger),a}var He=b(w(),1);function yK(e){let t=e.value??T1(e.automation),[a,r]=(0,R1.useState)(e.value);(0,R1.useEffect)(()=>{let f=setTimeout(()=>r(e.value),300);return()=>clearTimeout(f)},[e.value]);let n=VE.safeParse(a),o=Ue({queryKey:["dashboard","automation-schedule-preview",e.automation.id,a],enabled:!!a&&n.success,retry:!1,queryFn:()=>wo(qE,`/api/automations/scheduled/${encodeURIComponent(e.automation.id)}/preview`,a)}),i=t.kind==="recurring"?t.frequency:"once",s=t.kind==="recurring"?t.time:t.timing.time,l=e.value?o.data?.nextRunAtMs:e.automation.nextRunAtMs,c=e.value!==a||o.isFetching,d=o.error instanceof yn?o.error.apiError:o.error?"Schedule preview could not be loaded. Try again.":e.value&&!n.success&&!c?n.error.issues[0]?.message:void 0;return(0,He.jsxs)(He.Fragment,{children:[(0,He.jsxs)("div",{className:"grid grid-cols-1 items-start gap-4 sm:grid-cols-2",children:[(0,He.jsx)(Ot,{label:"Repeat",htmlFor:"schedule-frequency",children:(0,He.jsxs)(Wl,{id:"schedule-frequency",value:i,onChange:f=>{let m=f.target.value;m!=="once"&&m!=="daily"&&m!=="weekly"&&m!=="monthly"&&m!=="yearly"||e.onChange(m==="once"?{kind:"one_off",timezone:t.timezone??e.automation.schedule.timezone,timing:{type:"at",date:"",time:s}}:{kind:"recurring",timezone:t.timezone,time:s,frequency:m,interval:1,weekdays:m==="weekly"?["monday"]:void 0,dayOfMonth:["monthly","yearly"].includes(m)?1:void 0,month:m==="yearly"?1:void 0})},children:[(0,He.jsx)("option",{value:"once",children:"Once"}),(0,He.jsx)("option",{value:"daily",children:"Every day"}),(0,He.jsx)("option",{value:"weekly",children:"Every week"}),(0,He.jsx)("option",{value:"monthly",children:"Every month"}),(0,He.jsx)("option",{value:"yearly",children:"Every year"})]})}),(0,He.jsx)(Ot,{label:"Time",htmlFor:"schedule-time",children:(0,He.jsx)(xa,{size:"comfortable",id:"schedule-time",type:"time",value:s,onChange:f=>e.onChange(t.kind==="recurring"?{...t,time:f.target.value}:{...t,timing:{type:"at",date:t.timing.date,time:f.target.value}})})})]}),t.kind==="recurring"?(0,He.jsxs)(He.Fragment,{children:[t.frequency==="weekly"?(0,He.jsxs)("fieldset",{children:[(0,He.jsx)("legend",{className:"mb-2 text-sm font-semibold",children:"On"}),(0,He.jsx)("div",{className:"grid grid-cols-7 gap-1.5",children:[...I1.slice(1),I1[0]].map(f=>(0,He.jsx)("button",{type:"button","aria-label":f,"aria-pressed":t.weekdays?.includes(f)??!1,onClick:()=>e.onChange({...t,weekdays:t.weekdays?.includes(f)?t.weekdays.filter(m=>m!==f):[...t.weekdays??[],f]}),className:I("min-h-11 cursor-pointer rounded border px-1 text-xs font-medium capitalize focus-visible:outline-2 focus-visible:outline-dashboard-focus sm:min-h-10 sm:text-sm",t.weekdays?.includes(f)?"border-dashboard-focus/50 bg-dashboard-focus/10 text-dashboard-focus":"border-dashboard-border-emphasis text-dashboard-text-muted hover:bg-dashboard-fill-hover"),children:f.slice(0,3)},f))})]}):null,(0,He.jsxs)("div",{className:"grid grid-cols-1 items-start gap-4 sm:grid-cols-2",children:[(0,He.jsx)(Ot,{label:"Interval",htmlFor:"schedule-interval",help:"Number of calendar periods between runs.",children:(0,He.jsx)(xa,{size:"comfortable",id:"schedule-interval",type:"number",min:1,max:365,value:t.interval??1,onChange:f=>e.onChange({...t,interval:f.target.valueAsNumber})})}),(0,He.jsx)(Ot,{label:"Start date",htmlFor:"schedule-start",children:(0,He.jsx)(xa,{size:"comfortable",id:"schedule-start",type:"date",value:t.startDate??"",onChange:f=>e.onChange({...t,startDate:f.target.value||void 0})})})]}),t.frequency==="monthly"||t.frequency==="yearly"?(0,He.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[(0,He.jsx)(Ot,{label:"Day of month",htmlFor:"schedule-day",children:(0,He.jsx)(xa,{size:"comfortable",id:"schedule-day",type:"number",min:1,max:31,value:t.dayOfMonth??1,onChange:f=>e.onChange({...t,dayOfMonth:f.target.valueAsNumber})})}),t.frequency==="yearly"?(0,He.jsx)(Ot,{label:"Month",htmlFor:"schedule-month",children:(0,He.jsx)(Wl,{id:"schedule-month",value:t.month??1,onChange:f=>e.onChange({...t,month:Number(f.target.value)}),children:Array.from({length:12},(f,m)=>(0,He.jsx)("option",{value:m+1,children:new Intl.DateTimeFormat("en",{month:"long",timeZone:"UTC"}).format(new Date(Date.UTC(2026,m,1)))},m))})}):null]}):null]}):(0,He.jsx)(Ot,{label:"Date",htmlFor:"schedule-date",children:(0,He.jsx)(xa,{size:"comfortable",id:"schedule-date",type:"date",value:t.timing.date,onChange:f=>e.onChange({...t,timing:{type:"at",time:s,date:f.target.value}})})}),(0,He.jsxs)(Ot,{label:"Timezone",htmlFor:"schedule-timezone",help:"Use an IANA timezone. The schedule follows local time, including daylight saving time.",children:[(0,He.jsx)(xa,{size:"comfortable",id:"schedule-timezone",list:"automation-timezones",value:t.timezone??"",onChange:f=>e.onChange({...t,timezone:f.target.value})}),(0,He.jsx)("datalist",{id:"automation-timezones",children:["UTC",...Intl.supportedValuesOf("timeZone")].map(f=>(0,He.jsx)("option",{children:f},f))})]}),(0,He.jsxs)("div",{role:"status",className:"flex gap-3 rounded-md bg-dashboard-fill-soft p-3 text-sm leading-relaxed",children:[(0,He.jsx)(Fs,{"aria-hidden":!0,size:17,className:"mt-0.5 shrink-0 text-dashboard-text-muted"}),(0,He.jsx)("div",{children:c?"Checking schedule\u2026":d?(0,He.jsxs)(He.Fragment,{children:[(0,He.jsx)("span",{className:"text-rose-300",children:d}),o.error?(0,He.jsx)(ie,{onClick:()=>{o.refetch()},children:"Try again"}):null]}):l?(0,He.jsxs)(He.Fragment,{children:["Next run"," ",new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short",timeZone:e.value?o.data?.schedule.timezone??"UTC":e.automation.schedule.timezone}).format(l)]}):"No next run."})]}),e.value?(0,He.jsx)(ie,{className:"w-fit",onClick:()=>e.onChange(void 0),children:"Keep saved schedule"}):null]})}var ht=b(w(),1);function bK(e){let t=Ue({queryKey:["dashboard","automation-event-catalog"],queryFn:({signal:o})=>Ne(HE,"/api/automations/event-catalog",o),retry:!1}),a=t.data?.find(o=>o.namespace===e.value.namespace&&o.type===e.value.resourceType),r=!a||e.value.events.some(o=>!a.supportedEvents.includes(o))||Object.entries(e.value.match??{}).some(([o,i])=>{let s=a.matchFields?.[o];return s?(Array.isArray(i)?i:[i]).some(l=>typeof l!==s.kind||s.enum&&!s.enum.includes(String(l))):!0}),n=(o,i)=>{let s={...e.value.match};i===void 0?delete s[o]:s[o]=i,e.onChange({...e.value,match:s})};return(0,ht.jsxs)(ht.Fragment,{children:[t.error?(0,ht.jsxs)(Yr,{title:"Event choices could not be loaded.",children:["Saved values are kept."," ",(0,ht.jsx)(ie,{onClick:()=>{t.refetch()},children:"Try again"})]}):t.isPending?(0,ht.jsx)("p",{role:"status",children:"Loading event choices\u2026"}):null,r&&t.data?(0,ht.jsxs)(Yr,{title:"Saved trigger \xB7 Kept unchanged",children:["Some saved values are not in the current catalog. You can edit other fields, or select a new resource type to replace the trigger.",(0,ht.jsx)("pre",{className:"whitespace-pre-wrap break-all text-xs",children:JSON.stringify(e.value,null,2)})]}):null,(0,ht.jsx)(Ot,{label:r?"Replace trigger":"Resource type",htmlFor:"trigger-resource",children:(0,ht.jsxs)(Wl,{id:"trigger-resource",value:r?"":`${e.value.namespace}:${e.value.resourceType}`,onChange:o=>{let i=t.data?.find(s=>`${s.namespace}:${s.type}`===o.target.value);i&&window.confirm("Replace the saved trigger? Its resource, events, and conditions will be cleared.")&&e.onChange({namespace:i.namespace,resourceType:i.type,identifier:"",label:"",events:[]})},children:[(0,ht.jsx)("option",{value:"",disabled:!0,children:"Keep saved trigger"}),t.data?.map(o=>(0,ht.jsxs)("option",{value:`${o.namespace}:${o.type}`,children:[o.namespace," \xB7 ",o.type.replaceAll("_"," ")]},`${o.namespace}:${o.type}`))]})}),!r&&a?(0,ht.jsxs)(ht.Fragment,{children:[(0,ht.jsx)(Ot,{label:"Resource name",htmlFor:"trigger-label",children:(0,ht.jsx)(xa,{size:"comfortable",id:"trigger-label",value:e.value.label,onChange:o=>e.onChange({...e.value,label:o.target.value})})}),(0,ht.jsx)(Ot,{label:"Resource identifier",htmlFor:"trigger-identifier",help:"Use the exact provider resource identifier, not its display name.",children:(0,ht.jsx)(xa,{size:"comfortable",id:"trigger-identifier",value:e.value.identifier,onChange:o=>e.onChange({...e.value,identifier:o.target.value})})}),(0,ht.jsxs)("fieldset",{children:[(0,ht.jsx)("legend",{className:"mb-2 text-sm font-semibold",children:"Run on these events"}),(0,ht.jsx)("div",{className:"divide-y divide-dashboard-border-subtle rounded-md border border-dashboard-border-emphasis",children:a.supportedEvents.map(o=>(0,ht.jsxs)("label",{className:"flex min-h-11 cursor-pointer items-start gap-3 px-3 py-3 text-sm",children:[(0,ht.jsx)("input",{type:"checkbox",className:"mt-0.5 size-4 shrink-0 accent-dashboard-focus",checked:e.value.events.includes(o),onChange:()=>e.onChange({...e.value,events:e.value.events.includes(o)?e.value.events.filter(i=>i!==o):[...e.value.events,o]})}),(0,ht.jsxs)("span",{className:"min-w-0 break-words",children:[o.replaceAll("_"," ").replaceAll("."," \xB7 "),a.guidance?.[o]?(0,ht.jsx)("span",{className:"mt-1 block text-xs leading-relaxed text-dashboard-text-muted",children:a.guidance[o]}):null]})]},o))})]}),Object.keys(a.matchFields??{}).length?(0,ht.jsxs)("fieldset",{className:"grid gap-4",children:[(0,ht.jsx)("legend",{className:"mb-3 text-sm font-semibold",children:"Only when"}),(0,ht.jsx)("p",{className:"m-0 text-xs leading-relaxed text-dashboard-text-muted",children:"All conditions must match. Leave a field blank to match any value. Existing lists match any one listed value."}),Object.entries(a.matchFields??{}).map(([o,i])=>{let s=e.value.match?.[o];return(0,ht.jsx)(Ot,{label:o,htmlFor:`match-${o}`,help:i.description,children:Array.isArray(s)?(0,ht.jsxs)("div",{className:"text-sm",children:[(0,ht.jsx)("span",{className:"break-all",children:s.join(", ")})," ",(0,ht.jsx)(ie,{onClick:()=>n(o,void 0),children:"Remove condition"})]}):i.kind==="boolean"||i.enum?(0,ht.jsxs)(Wl,{id:`match-${o}`,value:s===void 0?"":String(s),onChange:l=>n(o,l.target.value===""?void 0:i.kind==="boolean"?l.target.value==="true":l.target.value),children:[(0,ht.jsx)("option",{value:"",children:"Any value"}),(i.enum??["true","false"]).map(l=>(0,ht.jsx)("option",{children:l},l))]}):(0,ht.jsx)(xa,{size:"comfortable",id:`match-${o}`,type:i.kind==="number"?"number":"text",step:"any",value:s===void 0?"":String(s),onChange:l=>n(o,l.target.value===""?void 0:i.kind==="number"?l.target.valueAsNumber:l.target.value)})},o)})]}):null]}):null,JSON.stringify(e.value)!==JSON.stringify(e.original)?(0,ht.jsx)(ie,{className:"w-fit",onClick:()=>e.onChange(e.original),children:"Keep saved trigger"}):null]})}function km(e,t){return typeof e.destination=="string"?e.destination==="task_creator"?"Creator \xB7 Direct message":`${t.label} \xB7 ${t.visibility}`:e.destination.channelId===t.channelId&&e.destination.teamId===t.teamId?`${t.label} \xB7 ${t.visibility}`:`Saved destination \xB7 ${e.destination.channelId}`}var aa=b(w(),1);function _1(e){return e.outcomes.length?(0,aa.jsx)("ol",{className:"m-0 grid gap-2 pl-5 text-sm",children:e.outcomes.map((t,a)=>(0,aa.jsx)("li",{children:km(t,e.destination)},a))}):(0,aa.jsx)("p",{className:"m-0 text-sm",children:"No success message"})}function xK(e){let t=e.original.length?e.original:[{action:"send_message",destination:"current_conversation"}],a=[...e.original.flatMap((r,n)=>typeof r.destination=="string"?[]:[{value:`saved:${n}`,label:km(r,e.destination),outcome:r}]),{value:"current_conversation",label:`${e.destination.label} \xB7 ${e.destination.visibility}`,outcome:{action:"send_message",destination:"current_conversation"}},{value:"task_creator",label:"Creator \xB7 Direct message",outcome:{action:"send_message",destination:"task_creator"}}];return(0,aa.jsxs)(aa.Fragment,{children:[(0,aa.jsxs)("fieldset",{children:[(0,aa.jsx)("legend",{className:"sr-only",children:"Success messages"}),(0,aa.jsx)("div",{className:"flex flex-wrap gap-x-6 gap-y-3",children:[!0,!1].map(r=>(0,aa.jsxs)("label",{className:"inline-flex min-h-8 cursor-pointer items-center gap-2 text-sm",children:[(0,aa.jsx)("input",{type:"radio",name:"messages",className:"size-4 accent-dashboard-focus",checked:!!e.value.length===r,onChange:()=>e.onChange(r?t:[])}),r?"Send a message":"No success message"]},String(r)))})]}),e.value.length?(0,aa.jsxs)("div",{className:"grid gap-4 sm:gap-2",children:[e.value.map((r,n)=>{let o=e.original.findIndex(i=>JSON.stringify(i)===JSON.stringify(r));return(0,aa.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,aa.jsxs)("span",{className:"w-4 text-xs text-dashboard-text-muted",children:[n+1,"."]}),(0,aa.jsx)("div",{className:I("min-w-0 flex-1",e.value.length>1&&"order-last basis-full sm:order-none sm:basis-auto"),children:(0,aa.jsx)(Wl,{"aria-label":`Message ${n+1} destination`,value:typeof r.destination=="string"?r.destination:`saved:${o}`,onChange:i=>{let s=a.find(l=>l.value===i.target.value);s&&e.onChange(e.value.map((l,c)=>c===n?s.outcome:l))},children:a.map(i=>(0,aa.jsx)("option",{value:i.value,children:i.label},i.value))})}),e.value.length>1?(0,aa.jsxs)(aa.Fragment,{children:[(0,aa.jsx)(ie,{size:"icon",className:"ml-auto sm:ml-0","aria-label":`Move message ${n+1} up`,disabled:n===0,onClick:()=>{let i=[...e.value];[i[n-1],i[n]]=[i[n],i[n-1]],e.onChange(i)},children:(0,aa.jsx)(Uy,{size:16})}),(0,aa.jsx)(ie,{size:"icon","aria-label":`Remove message ${n+1}`,onClick:()=>e.onChange(e.value.filter((i,s)=>s!==n)),children:(0,aa.jsx)(jn,{size:16})})]}):null]},n)}),e.value.length<5?(0,aa.jsxs)(ie,{className:"w-fit",onClick:()=>e.onChange([...e.value,{action:"send_message",destination:"task_creator"}]),children:[(0,aa.jsx)(Ku,{size:15}),"Add message"]}):null]}):(0,aa.jsx)("p",{className:"m-0 text-sm leading-relaxed text-dashboard-text-muted",children:"Junior still does the work. No message is sent after success."}),(0,aa.jsxs)("p",{className:"m-0 text-xs leading-relaxed text-dashboard-text-muted",children:[e.value.length?"Messages are sent in this order. ":"","This does not limit actions in the instruction."]})]})}var ce=b(w(),1);function wK(e){let[t,a]=(0,ps.useState)(e.automation),[r,n]=(0,ps.useState)(()=>L1(e.automation)),[o,i]=(0,ps.useState)({}),[s,l]=(0,ps.useState)(),c=(0,ps.useRef)(null),d=(0,ps.useRef)(!1),f=gn(),m=Bt(),p=vK(t,r),h=Object.keys(p).length>0,g={kind:t.kind,revision:t.revision,...p},x=MN(()=>h&&!d.current),y=(0,ps.useRef)(null);(0,ps.useEffect)(()=>{x.state==="blocked"&&y.current?.focus()},[x.state]);let v=`/api/automations/${t.kind}/${encodeURIComponent(t.id)}`;(0,ps.useEffect)(()=>{let Z=fe=>{h&&!d.current&&(fe.preventDefault(),fe.returnValue="")};return window.addEventListener("beforeunload",Z),()=>window.removeEventListener("beforeunload",Z)},[h]);let S=()=>requestAnimationFrame(()=>(c.current?.querySelector('[aria-invalid="true"]')??c.current?.querySelector("[data-save-error]"))?.focus()),C=ga({mutationFn:()=>mg(ds,v,g),onSuccess:async()=>{d.current=!0,await m.invalidateQueries({queryKey:["dashboard","automations"]}),f(e.returnPath,{state:{automationSaved:!0}})},onError:Z=>{i(Z instanceof yn?Z.fields??{}:{}),S()}});function L(Z){s&&(n(Z?{...L1(s),...p}:L1(s)),a(s),l(void 0),C.reset(),i({}))}let T=ga({mutationFn:()=>Ne(ds,`${v}/edit`),onSuccess:l}),_=C.error instanceof yn&&C.error.code==="conflict",k=Z=>n(fe=>({...fe,...Z})),j=Z=>Object.entries(o).filter(([fe])=>fe===Z||fe.startsWith(`${Z}.`)).flatMap(([,fe])=>fe).join(" ")||void 0,F=t.kind==="scheduled"?"schedule":"trigger",ue=t.ownedByViewer,z=e.summary.createdBy,Y=!ue&&t.credentialMode==="creator"&&(p.instruction!==void 0||t.kind==="event"&&p.trigger!==void 0),ee=j(F),ve=Z=>({"aria-invalid":!!j(Z)||void 0,"aria-describedby":j(Z)?`${Z}-error`:void 0});return(0,ce.jsxs)("form",{ref:c,noValidate:!0,onSubmit:Z=>{if(Z.preventDefault(),C.isPending||_||!h)return;let fe=FE.safeParse(g);if(!fe.success){let Q={};for(let se of fe.error.issues)(Q[se.path.join(".")]??=[]).push(se.message);i(Q),S();return}i({}),C.mutate()},children:[x.state==="blocked"?(0,ce.jsx)("div",{tabIndex:-1,ref:y,className:"mb-6 outline-none",children:(0,ce.jsxs)(Yr,{title:"Discard unsaved changes?",children:[(0,ce.jsx)("p",{children:"Your changes have not been saved."}),(0,ce.jsxs)("div",{className:"flex gap-2",children:[(0,ce.jsx)(ie,{onClick:()=>x.reset(),children:"Keep editing"}),(0,ce.jsx)(ie,{onClick:()=>x.proceed(),children:"Discard changes"})]})]})}):null,C.error||Object.keys(o).length?(0,ce.jsx)("div",{tabIndex:-1,"data-save-error":!0,className:"mb-6 outline-none",children:(0,ce.jsxs)(Yr,{tone:_?"warning":"error",title:_?"This automation changed while you were editing.":"Changes could not be saved.",children:[(0,ce.jsxs)("p",{className:"mt-1",children:["Your edits are still here."," ",_?"Review the latest version before saving again.":C.error instanceof yn?C.error.apiError:"Check the fields below, or try again."]}),_?(0,ce.jsx)(ie,{disabled:T.isPending,onClick:()=>T.mutate(),children:T.isPending?"Loading\u2026":"Review latest version"}):null,T.error?(0,ce.jsx)("p",{role:"alert",children:"The latest version could not be loaded. Try again."}):null]})}):null,s?(0,ce.jsx)("div",{className:"mb-6",children:(0,ce.jsxs)(Yr,{title:"Compare your edits with the latest saved version",children:[(0,ce.jsx)("p",{children:"Only the fields you changed are shown. Keeping your edits will replace these fields. Other saved fields stay unchanged."}),Object.entries(p).map(([Z,fe])=>(0,ce.jsxs)("section",{className:"my-4",children:[(0,ce.jsx)("h3",{className:"text-sm font-semibold capitalize",children:Z==="credentialMode"?"Credentials":Z}),(0,ce.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,ce.jsxs)("div",{children:[(0,ce.jsx)("p",{children:"Latest saved"}),(0,ce.jsx)("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm",children:SK(Z==="schedule"&&s.kind==="scheduled"?T1(s):s[Z])})]}),(0,ce.jsxs)("div",{children:[(0,ce.jsx)("p",{children:"Your edit"}),(0,ce.jsx)("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm",children:SK(fe)})]})]})]},Z)),(0,ce.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,ce.jsx)(ie,{onClick:()=>L(!0),children:"Keep my changed fields"}),(0,ce.jsx)(ie,{onClick:()=>L(!1),children:"Use latest saved version"})]})]})}):null,ue?null:(0,ce.jsxs)("p",{className:"mt-0 mb-6 max-w-2xl text-sm leading-relaxed text-dashboard-text-muted",children:[z," created this automation. You can edit it because it is in a public channel. Only ",z," can change where results go or turn on their connected accounts. Version history keeps every saved change."]}),(0,ce.jsxs)("fieldset",{disabled:C.isPending,className:"min-w-0",children:[(0,ce.jsxs)(ms,{title:"What to do",detail:"Give Junior a clear instruction and a name you can find later.",children:[(0,ce.jsx)(Ot,{label:"Title",htmlFor:"title",error:j("title"),children:(0,ce.jsx)(xa,{size:"comfortable",id:"title",value:r.title,placeholder:e.summary.title,onChange:Z=>k({title:Z.target.value}),...ve("title")})}),(0,ce.jsxs)(Ot,{label:"Instruction",htmlFor:"instruction",error:j("instruction"),children:[(0,ce.jsx)(tc,{prose:!0,id:"instruction",rows:8,value:r.instruction,onChange:Z=>k({instruction:Z.target.value}),...ve("instruction"),className:"resize-y text-base sm:text-sm"}),(0,ce.jsxs)("p",{className:"m-0 text-right text-xs text-dashboard-text-muted",children:[r.instruction.length.toLocaleString()," / 4,000"]})]})]}),(0,ce.jsx)(ms,{title:"When to run",detail:t.kind==="scheduled"?"Choose a schedule in a specific timezone.":"Run when a matching event occurs.",children:(0,ce.jsxs)("div",{id:`${F}-error`,tabIndex:-1,"aria-invalid":!!ee||void 0,className:"grid min-w-0 gap-5 outline-none",children:[ee?(0,ce.jsx)("p",{role:"alert",className:"m-0 text-sm text-rose-300",children:ee}):null,t.kind==="scheduled"?(0,ce.jsx)(yK,{automation:t,value:r.schedule,onChange:Z=>k({schedule:Z})}):(0,ce.jsx)(bK,{value:r.trigger??t.trigger,original:t.trigger,onChange:Z=>k({trigger:Z})})]})}),(0,ce.jsxs)(ms,{title:"Where results go",detail:"Choose who gets a message after successful work.",children:[j("outcomes")?(0,ce.jsx)("p",{role:"alert",className:"m-0 text-sm text-rose-300",children:j("outcomes")}):null,ue?(0,ce.jsx)(xK,{value:r.outcomes,original:t.outcomes,destination:e.summary.destination,onChange:Z=>k({outcomes:Z})}):(0,ce.jsxs)(ce.Fragment,{children:[(0,ce.jsx)(_1,{outcomes:t.outcomes,destination:e.summary.destination}),(0,ce.jsxs)("p",{className:"m-0 text-xs text-dashboard-text-muted",children:["Only ",z," can change where results go."]})]})]}),(0,ce.jsxs)(ms,{title:"Credentials",detail:"Choose which connected accounts Junior can use.",children:[(0,ce.jsxs)("fieldset",{className:"divide-y divide-dashboard-border-subtle rounded-md border border-dashboard-border-emphasis",children:[(0,ce.jsx)("legend",{className:"sr-only",children:"Credential mode"}),[["creator",ue?"Your connected accounts":`${z}\u2019s connected accounts`,ue?"Uses accounts connected by you, the creator.":`Uses accounts connected by ${z}. Only ${z} can turn this on.`],["system","System credentials only",ue?"Does not use your connected accounts. Some work may not be possible.":"Does not use anyone\u2019s connected accounts. Some work may not be possible."]].map(([Z,fe,Q])=>(0,ce.jsxs)("label",{className:"flex cursor-pointer items-start gap-3 px-4 py-4 has-checked:bg-dashboard-fill-soft has-disabled:cursor-not-allowed has-disabled:opacity-60",children:[(0,ce.jsx)("input",{type:"radio",name:"credentials",className:"mt-0.5 size-4 shrink-0 accent-dashboard-focus",checked:Y?Z==="system":r.credentialMode===Z,disabled:Z==="creator"&&!ue&&(t.credentialMode!=="creator"||Y),onChange:()=>k({credentialMode:Z})}),(0,ce.jsxs)("span",{children:[(0,ce.jsx)("span",{className:"block text-sm font-medium",children:fe}),(0,ce.jsx)("span",{className:"mt-1 block text-xs leading-relaxed text-dashboard-text-muted",children:Q})]})]},Z))]}),Y?(0,ce.jsxs)(Yr,{title:"Saving switches this automation to system credentials.",children:["Only ",z," can let a changed instruction",t.kind==="event"?" or trigger":""," use their connected accounts."]}):null,j("credentialMode")?(0,ce.jsx)("p",{role:"alert",children:j("credentialMode")}):null]})]}),(0,ce.jsx)("p",{className:"mb-5 text-xs leading-relaxed text-dashboard-text-muted sm:hidden",children:"Changes apply to future work. Saving does not run this automation."}),(0,ce.jsx)("div",{className:"sticky bottom-0 z-20 -mx-4 border-t border-dashboard-border-emphasis bg-dashboard-bg px-4 py-4 sm:-mx-8 sm:px-8",children:(0,ce.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ce.jsxs)("div",{className:"min-w-0 flex-1",role:"status",children:[(0,ce.jsx)("p",{className:"m-0 text-xs font-medium sm:text-sm",children:C.isPending?"Saving\u2026":h?"Unsaved changes":"Unchanged"}),(0,ce.jsx)("p",{className:"mt-1 mb-0 hidden text-xs text-dashboard-text-muted sm:block",children:"Changes apply to future work. Saving does not run it."})]}),(0,ce.jsxs)("div",{className:"flex shrink-0 gap-2",children:[(0,ce.jsx)(ae,{to:e.returnPath,className:"inline-flex min-h-11 items-center rounded border border-dashboard-border-emphasis px-3 text-sm text-dashboard-text no-underline sm:min-h-9",children:"Cancel"}),(0,ce.jsx)(ie,{type:"submit",tone:"primary",className:"min-h-11 sm:min-h-9",disabled:!h||C.isPending||_,children:"Save changes"})]})]})})]})}function SK(e){return e==null?"Not set":typeof e=="string"?e:JSON.stringify(e,null,2)}var Cg=b(w(),1);function CK(){return(0,Cg.jsx)("div",{role:"status","aria-label":"Loading automation editor",children:["What to do","When to run","Where results go","Credentials"].map((e,t)=>(0,Cg.jsxs)(ms,{title:e,children:[(0,Cg.jsx)(Qe,{className:"h-4 w-24"}),(0,Cg.jsx)(Qe,{className:t===0?"h-48 w-full":"h-20 w-full"})]},e))})}var Mt=b(w(),1);function kK(e){let{kind:t,automationId:a}=Ba(),r=vt(),n=hg(e.enabled,a),o=n.data&&!(n.data.kind==="scheduled"&&n.data.status==="completed"),i=Ue({queryKey:["dashboard","automations","edit",t,a],enabled:e.enabled&&!!o&&n.data?.kind===t,retry:!1,queryFn:({signal:f})=>Ne(ds,`/api/automations/${t}/${encodeURIComponent(a)}/edit`,f)}),s=`/automations/list${r.search}`,l=n.data,c=l?.kind==="event"?l.status!=="active"?l.status:l.triggerAvailable?"active":"unavailable":l?.status,d=c==="active"?"success":c==="blocked"||c==="unavailable"?"warning":"neutral";return(0,Mt.jsx)(Sz,{children:(0,Mt.jsxs)("div",{className:"mx-auto w-full min-w-0 max-w-5xl px-4 pt-7 sm:px-8 sm:pt-9",children:[(0,Mt.jsxs)(ae,{to:s,className:"inline-flex min-h-8 items-center gap-2 text-sm text-dashboard-text-muted no-underline hover:text-dashboard-text",children:[(0,Mt.jsx)(Zr,{"aria-hidden":!0,size:15}),"All automations"]}),(0,Mt.jsxs)("div",{className:"mt-4 mb-8 flex flex-wrap items-start justify-between gap-4",children:[(0,Mt.jsxs)("div",{className:"min-w-0",children:[(0,Mt.jsx)("h1",{className:"m-0 break-words font-display text-3xl font-light tracking-tight",children:l&&!o?l.title:"Edit automation"}),l?(0,Mt.jsxs)("p",{className:"mt-2 mb-0 text-sm text-dashboard-text-muted",children:["Created by ",l.ownedByViewer?"you":l.createdBy," \xB7"," ",l.destination.label]}):null]}),l?(0,Mt.jsxs)("div",{className:"flex items-center gap-4",children:[(0,Mt.jsx)(ae,{to:`/automations/${l.kind}/${encodeURIComponent(l.id)}/versions${r.search}`,className:"text-sm text-dashboard-text-muted underline underline-offset-2 hover:text-dashboard-text",children:"Version history"}),(0,Mt.jsx)(ba,{tone:d,children:c==="unavailable"?"Trigger unavailable":c})]}):null]}),!l&&n.error||!i.data&&i.error||l&&l.kind!==t?(0,Mt.jsxs)(Yr,{tone:"error",title:"Automation could not be loaded.",children:["It may no longer be available, or you may not have access."," ",(0,Mt.jsx)(ie,{onClick:()=>{n.refetch(),o&&i.refetch()},children:"Try again"})]}):!l||o&&!i.data?(0,Mt.jsx)(CK,{}):o&&i.data?(0,Mt.jsx)(wK,{automation:i.data,summary:l,returnPath:s},`${t}:${a}`):(0,Mt.jsx)(axe,{automation:l})]})})}function axe({automation:e}){return(0,Mt.jsxs)(Mt.Fragment,{children:[(0,Mt.jsx)("p",{className:"mb-6 text-sm text-dashboard-text-muted",children:"This automation has completed and cannot be edited. It will not run again."}),(0,Mt.jsx)(ms,{title:"What to do",detail:"The saved instruction.",children:(0,Mt.jsx)("p",{className:"m-0 whitespace-pre-wrap break-words text-sm leading-relaxed",children:e.instruction})}),(0,Mt.jsx)(ms,{title:"When to run",detail:"The saved trigger.",children:e.kind==="scheduled"?(0,Mt.jsxs)("p",{className:"m-0 text-sm",children:[e.schedule," \xB7 ",e.timezone]}):(0,Mt.jsxs)("div",{className:"grid gap-3 text-sm",children:[(0,Mt.jsx)("p",{className:"m-0 break-words",children:e.resource}),(0,Mt.jsx)("p",{className:"m-0 break-words",children:e.events.join(", ")}),e.match?(0,Mt.jsx)("pre",{className:"whitespace-pre-wrap break-words text-xs",children:JSON.stringify(e.match,null,2)}):null]})}),(0,Mt.jsx)(ms,{title:"Where results go",detail:"Messages after successful work.",children:(0,Mt.jsx)(_1,{outcomes:e.outcomes,destination:e.destination})}),(0,Mt.jsx)(ms,{title:"Credentials",detail:"The accounts Junior can use.",children:(0,Mt.jsx)("p",{className:"m-0 text-sm",children:e.credentialMode==="creator"?`Uses ${e.ownedByViewer?"your":`${e.createdBy}\u2019s`} connected accounts.`:"System credentials only."})})]})}var ip=b(G(),1);var IK=b(G(),1);function N1(){return(0,IK.useSyncExternalStore)(e=>Il.subscribe(e),()=>Il.isOnline(),()=>!0)}var TK=b(w(),1);function LK(){return N1()?null:(0,TK.jsx)("div",{"aria-live":"polite",className:"border-t border-amber-300/15 bg-amber-300/[0.07] px-3 py-1.5 text-center font-sans text-xs text-amber-100/80",role:"status",children:"You\u2019re offline. Drafts stay on this device."})}var Cz=b(w(),1);function A1(){return(0,Cz.jsx)("div",{className:"relative grid size-10 shrink-0 select-none place-items-center overflow-visible",children:(0,Cz.jsx)("img",{alt:"",className:"relative size-11 max-w-none -translate-y-0.5 object-contain opacity-90 drop-shadow-[0_0_7px_rgba(255,255,255,0.16)]",draggable:!1,src:"/_junior/dashboard/avatar.png"})})}var RK=["relative","overflow-hidden","bg-white/15","before:absolute","before:inset-0","before:content-['']","before:bg-[linear-gradient(90deg,#ff4d6d,#ffb703,#56f39a,#4cc9f0,#9b5de5,#ff4d6d)]","before:bg-[length:200%_100%]","before:animate-[junior-rainbow-flow_1.2s_linear_infinite]","motion-reduce:before:animate-none"].join(" ");var $d=b(w(),1);function Tn(e){return(0,$d.jsx)("div",{className:I(Ya,"grid min-h-[calc(100dvh-5rem)] place-items-center px-4 py-8 md:px-8"),children:(0,$d.jsxs)("section",{className:"grid w-full max-w-lg grid-cols-[auto_minmax(0,1fr)] items-center gap-3 rounded-lg border border-dashboard-border-emphasis bg-dashboard-surface-raised p-4",children:[(0,$d.jsx)(A1,{}),(0,$d.jsxs)("div",{children:[(0,$d.jsx)("div",{className:"font-bold",children:e.label}),(0,$d.jsx)("div",{"aria-label":e.label,className:`${RK} mt-3 h-1.5 w-full`,role:"progressbar"})]})]})})}var kz="0.242.0",$1=typeof kz=="string"&&kz.trim()?kz:"unknown";var Cx=b(w(),1);function _K(e){return nxe(e.serverVersion)?(0,Cx.jsxs)("div",{"aria-live":"polite",className:"flex flex-wrap items-center justify-center gap-x-3 gap-y-1 border-t border-cyan-300/15 bg-cyan-300/[0.07] px-3 py-1.5 text-center font-sans text-xs text-cyan-100/80",role:"status",children:[(0,Cx.jsx)("span",{children:"The dashboard changed. Refresh to load the latest version."}),(0,Cx.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0 font-mono font-semibold text-cyan-100 underline decoration-cyan-300/40 underline-offset-2 hover:text-dashboard-text-solid",onClick:()=>window.location.reload(),type:"button",children:"Refresh"})]}):null}function nxe(e){return!!e&&$1!=="unknown"&&e!=="unknown"&&e!==$1}var kx=b(w(),1);function ac(e){return(0,kx.jsxs)(Co,{children:[(0,kx.jsx)(We,{description:e.description,title:e.title}),(0,kx.jsx)(Yn,{label:e.label,variant:e.variant})]})}var iu=b(G(),1);var P1={"angular-html":()=>import("./chunks/angular-html-ZNDXTZDN.js"),"angular-ts":()=>import("./chunks/angular-ts-ON3WFVNV.js"),astro:()=>import("./chunks/astro-TCFNN3TA.js"),blade:()=>import("./chunks/blade-XRKVUGGE.js"),c:()=>import("./chunks/c-WHCDUHJR.js"),coffee:()=>import("./chunks/coffee-NWMA7ZVV.js"),coffeescript:()=>import("./chunks/coffee-NWMA7ZVV.js"),cpp:()=>import("./chunks/cpp-7ZDYJCCI.js"),"c++":()=>import("./chunks/cpp-7ZDYJCCI.js"),css:()=>import("./chunks/css-XF3SDJYW.js"),csv:()=>import("./chunks/csv-I2Y5BPVG.js"),glsl:()=>import("./chunks/glsl-SDKJ4MVB.js"),graphql:()=>import("./chunks/graphql-XJBKAS4G.js"),gql:()=>import("./chunks/graphql-XJBKAS4G.js"),haml:()=>import("./chunks/haml-QQIA6ZDV.js"),handlebars:()=>import("./chunks/handlebars-A4STSCQ6.js"),hbs:()=>import("./chunks/handlebars-A4STSCQ6.js"),html:()=>import("./chunks/html-T3MIDC6T.js"),"html-derivative":()=>import("./chunks/html-derivative-A5ABNIZH.js"),http:()=>import("./chunks/http-VGZ3EXS5.js"),hurl:()=>import("./chunks/hurl-TO4NQQLI.js"),imba:()=>import("./chunks/imba-P3ARIZRP.js"),java:()=>import("./chunks/java-WCBM5OUU.js"),javascript:()=>import("./chunks/javascript-TQH7GGAM.js"),js:()=>import("./chunks/javascript-TQH7GGAM.js"),cjs:()=>import("./chunks/javascript-TQH7GGAM.js"),mjs:()=>import("./chunks/javascript-TQH7GGAM.js"),jinja:()=>import("./chunks/jinja-UYMB4X6S.js"),jison:()=>import("./chunks/jison-ED4UFXGK.js"),json:()=>import("./chunks/json-XRHV7G5W.js"),json5:()=>import("./chunks/json5-2OA2ZMVI.js"),jsonc:()=>import("./chunks/jsonc-KO53QF6Y.js"),jsonl:()=>import("./chunks/jsonl-GHTNFMM6.js"),jsx:()=>import("./chunks/jsx-V5TSP3NI.js"),julia:()=>import("./chunks/julia-EI7BACOV.js"),jl:()=>import("./chunks/julia-EI7BACOV.js"),less:()=>import("./chunks/less-FPWZXUDW.js"),markdown:()=>import("./chunks/markdown-QWIM2DOI.js"),md:()=>import("./chunks/markdown-QWIM2DOI.js"),marko:()=>import("./chunks/marko-3POAQSZY.js"),mdc:()=>import("./chunks/mdc-KT6TTBUF.js"),mdx:()=>import("./chunks/mdx-CWS3UMSH.js"),php:()=>import("./chunks/php-3CK4FBZI.js"),postcss:()=>import("./chunks/postcss-7K34RN34.js"),pug:()=>import("./chunks/pug-IEW5PJRA.js"),jade:()=>import("./chunks/pug-IEW5PJRA.js"),python:()=>import("./chunks/python-GCPXLELR.js"),py:()=>import("./chunks/python-GCPXLELR.js"),r:()=>import("./chunks/r-XV5O7BSV.js"),regexp:()=>import("./chunks/regexp-655IUQFI.js"),regex:()=>import("./chunks/regexp-655IUQFI.js"),sass:()=>import("./chunks/sass-MSBN6O54.js"),scss:()=>import("./chunks/scss-N73GNFL4.js"),shellscript:()=>import("./chunks/shellscript-OPDT4ZZ3.js"),bash:()=>import("./chunks/shellscript-OPDT4ZZ3.js"),sh:()=>import("./chunks/shellscript-OPDT4ZZ3.js"),shell:()=>import("./chunks/shellscript-OPDT4ZZ3.js"),zsh:()=>import("./chunks/shellscript-OPDT4ZZ3.js"),sql:()=>import("./chunks/sql-ZR72I7RP.js"),stylus:()=>import("./chunks/stylus-NVEQWGLA.js"),styl:()=>import("./chunks/stylus-NVEQWGLA.js"),svelte:()=>import("./chunks/svelte-ZZAXFLSI.js"),"ts-tags":()=>import("./chunks/ts-tags-MCSPJMMM.js"),lit:()=>import("./chunks/ts-tags-MCSPJMMM.js"),tsx:()=>import("./chunks/tsx-ZTNB67YL.js"),typescript:()=>import("./chunks/typescript-HV6B525T.js"),ts:()=>import("./chunks/typescript-HV6B525T.js"),cts:()=>import("./chunks/typescript-HV6B525T.js"),mts:()=>import("./chunks/typescript-HV6B525T.js"),vue:()=>import("./chunks/vue-WXFFFGZ3.js"),"vue-html":()=>import("./chunks/vue-html-SKWAUQDE.js"),"vue-vine":()=>import("./chunks/vue-vine-V3A5HTCZ.js"),wasm:()=>import("./chunks/wasm-JWJ5BADC.js"),wgsl:()=>import("./chunks/wgsl-ZCQ7MKDM.js"),wit:()=>import("./chunks/wit-MLLAONFF.js"),xml:()=>import("./chunks/xml-VST5CLIL.js"),yaml:()=>import("./chunks/yaml-BX3BWN2A.js"),yml:()=>import("./chunks/yaml-BX3BWN2A.js")};var NK="Junior";function Ft(){return typeof window>"u"?NK:window.__JUNIOR_DASHBOARD_AGENT_NAME__?.trim()||NK}function AK(e=Ft()){return e.endsWith("s")?`${e}'`:`${e}'s`}var D1=b(w(),1);function to(e){if(typeof e!="number"||!Number.isFinite(e))return"";let t=Math.max(0,Math.floor(e));if(t<1e3)return`${t}ms`;if(t<6e4){let n=t/1e3;return`${n.toFixed(n<10?1:0)}s`}let a=[],r=[["mo",2592e6],["d",864e5],["h",36e5],["m",6e4],["s",1e3]];for(let[n,o]of r){let i=Math.floor(t/o);if(i!==0){if(a.push(`${i}${n}`),a.length===2)break;t%=o}}return a.join(" ")}function nc(e){return(0,D1.jsx)(D1.Fragment,{children:to(e.value)||e.fallback||null})}function Ix(e){return Date.parse(e.createdAt)}function Pd(e,t,a){return{parts:a,role:t,sourceSeq:e.seq,timestamp:Ix(e)}}function rxe(e){let t=new Set;for(let a of e){let r=a.data;r.type==="handoff"&&r.triggeringToolCallId&&t.add(r.triggeringToolCallId),r.type==="subagent"&&r.parentToolCallId&&t.add(r.parentToolCallId)}return t}function oxe(e){let t=new Set;for(let a of e)a.messageId&&t.add(a.messageId);return t}function ixe(e,t){return{delivery:e.delivery,messageId:e.messageId,parts:e.redacted?[{type:"text",redacted:!0}]:[{type:"text",text:e.text??""}],...e.attachments?{attachments:e.attachments}:void 0,pending:!0,role:"user",source:e.source,sourceSeq:Number.MAX_SAFE_INTEGER-1e6+t,timestamp:Date.parse(e.createdAt),...e.actorIdentity?{actorIdentity:e.actorIdentity}:void 0}}function sxe(e,t){if(!t?.length)return e;let a=lxe(e,t);return a.length===0?e:[...e,...a]}function lxe(e,t){if(!t?.length)return[];let a=oxe(e);return t.filter(r=>!a.has(r.messageId)).map((r,n)=>ixe(r,n))}function Iz(e,t){return Lz(e.events,e.annotations,t)}function Lz(e,t,a){let r=rxe(e),n=new Map,o=new Map,i=new Map,s=[],l=new Map,c=new Map,d,f=(p,h)=>{if(r.has(h.toolCallId))return;let g="output"in h?h.output:void 0,x=n.get(h.toolCallId);if(x){x.name=h.name,x.status=h.status,h.input!==void 0&&(x.input=h.input),g!==void 0&&(x.output=g),x.startedTimestamp===void 0&&h.startedAt&&(x.startedTimestamp=Date.parse(h.startedAt)),h.status!=="running"&&(x.resultTimestamp=Ix(p));return}let y={type:"tool_call",id:h.toolCallId,name:h.name,status:h.status,...h.input===void 0?void 0:{input:h.input},...g===void 0?void 0:{output:g},...h.status==="running"?void 0:{resultTimestamp:Ix(p)}},v={...Pd(p,"tool",[y]),sourceSeq:h.startedSeq??p.seq,timestamp:h.startedAt?Date.parse(h.startedAt):Ix(p)};n.set(h.toolCallId,y),o.set(h.toolCallId,v),s.push(v)};for(let p of e){let h=p.data;if(h.type==="message"){let g={...Pd(p,h.role,[h.redacted?{type:"text",redacted:!0}:{type:"text",text:h.text}]),messageId:h.messageId,...h.attachments?{attachments:h.attachments}:void 0,...h.cards?{cards:SE(h.cards,t??[])}:void 0,...h.actorIdentity?{actorIdentity:h.actorIdentity}:void 0,...h.eventType?{eventType:h.eventType}:void 0,eventObjectType:h.eventObjectType,...h.trustedSummary?{trustedSummary:h.trustedSummary}:void 0,...h.explicitMention!==void 0?{explicitMention:h.explicitMention}:void 0,...h.source?{source:h.source}:void 0};s.push(g),l.set(g.messageId,g),g.role==="user"&&(d=g);continue}if(h.type==="message_handled"){let g=l.get(h.messageId);g?.role==="user"&&g.explicitMention===!1&&!g.eventType&&(g.context=!0);continue}if(h.type==="assistant_message"){if(h.parts.length===0)continue;s.push(Pd(p,"assistant",h.parts.map(g=>g.redacted?{type:"reasoning",redacted:!0}:{type:"reasoning",text:g.text})));continue}if(h.type==="turn_lifecycle"&&h.state==="started"){let g=h.inputMessageIds?.map(y=>l.get(y)).filter(y=>y!==void 0),x=g?.slice().reverse().find(y=>y.role==="user");x?c.set(h.turnId,x):d&&c.set(h.turnId,d);for(let y of g??[])y.role==="user"&&y.explicitMention===!1&&!y.eventType&&(y.context=!0);continue}if(h.type==="turn_routed"){let g=c.get(h.turnId);g&&(g.route={modelProfile:h.modelProfile,modelId:h.modelId,reasoningLevel:h.reasoningLevel,...h.confidence!==void 0?{confidence:h.confidence}:void 0,source:h.source});continue}if(h.type==="turn_context"){let g=c.get(h.turnId);g&&(g.contexts??=[],g.contexts.push({content:h.content,kind:h.kind,loadedAt:p.createdAt,pluginName:h.pluginName,version:h.version}));continue}if(h.type==="tool_calls"){for(let g of h.calls)f(p,g);if(h.assistant){let g=[];for(let x of h.assistant.parts){if(x.type==="reasoning"){g.push(x.redacted?{type:"reasoning",redacted:!0}:{type:"reasoning",text:x.text});continue}if(r.has(x.toolCallId))continue;let y=n.get(x.toolCallId);if(!y)continue;let v=o.get(x.toolCallId);if(v){v.sourceSeq!==p.seq&&(y.startedTimestamp=v.timestamp);let S=s.indexOf(v);S>=0&&s.splice(S,1),o.delete(x.toolCallId)}g.push(y)}g.length>0&&s.push(Pd(p,"assistant",g))}continue}if(h.type==="subagent"){let g=`${h.childConversationId}:${h.startedSeq}`,x=i.get(g);if(x){x.status=h.status;continue}let y={type:"subagent",id:g,childConversationId:h.childConversationId,subagentKind:h.subagentKind,status:h.status};i.set(g,y),s.push({...Pd(p,"tool",[y]),sourceSeq:h.startedSeq,timestamp:Date.parse(h.startedAt)});continue}if(h.type==="structured_event"){s.push(Pd(p,"system",[{type:"structured_event",namespace:h.namespace,name:h.name,version:h.version,presentation:h.presentation}]));continue}if(h.type==="attachments_delivered"){s.push(Pd(p,"system",[{type:"attachments_delivered",attachments:h.attachments}]));continue}if(h.type==="compaction"||h.type==="handoff"){s.push(Pd(p,"system",[{type:"context_event",event:h.type==="handoff"?{type:h.type,createdAt:p.createdAt,modelId:h.modelId,modelProfile:h.modelProfile,...h.summary?{summary:h.summary}:void 0,...h.reasoningLevel?{reasoningLevel:h.reasoningLevel}:void 0}:{type:h.type,createdAt:p.createdAt,...h.modelId?{modelId:h.modelId}:void 0,...h.modelProfile?{modelProfile:h.modelProfile}:void 0,...h.summary?{summary:h.summary}:void 0,...h.details?{details:h.details}:void 0}}]));continue}if(h.type==="turn_lifecycle"&&h.state==="failed"){s.push({role:h.failureCode==="delivery_failed"?"system":"assistant",failureCode:h.failureCode,...h.failureReason?{failureReason:h.failureReason}:void 0,...h.eventId?{eventId:h.eventId}:void 0,...h.sentryEventUrl?{sentryEventUrl:h.sentryEventUrl}:void 0,parts:[],sourceSeq:p.seq,timestamp:Ix(p)});continue}}let m=s.filter(p=>p.role!=="user"||p.eventType!==void 0||p.explicitMention!==!1||p.context===!0).sort((p,h)=>p.sourceSeq-h.sourceSeq);return sxe(m,a)}function $K(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return"UTC"}}var Rz=$K();function PK(e){Rz=e||$K()}function Ed(){return Rz}function M1(){return Rz}function uxe(e){return e.status==="active"}function cxe(e){return e.status==="failed"}function dxe(e){return e.status==="active"}function fxe(e){return e.status==="failed"}function O1(e){if(!e)return null;let t=Date.parse(e);return Number.isFinite(t)?t:null}function Rn(e,t){let a=O1(e);return a==null?"none":new Date(a).toLocaleString(void 0,{...t,timeZone:M1()})}function ao(e){let t=O1(e);if(t==null)return"not updated yet";let a=Math.round((t-Date.now())/1e3),r=Math.abs(a),n=[["year",3600*24*365],["month",3600*24*30],["week",3600*24*7],["day",3600*24],["hour",3600],["minute",60]];for(let[o,i]of n)if(r>=i)return new Intl.RelativeTimeFormat(void 0,{numeric:"auto"}).format(Math.round(a/i),o);return"just now"}function Lm(e){if(typeof e!="number"||!Number.isFinite(e))return"none";let t=Math.max(0,Math.floor(e));if(t<1e3)return`${t}ms`;let a=t/1e3;if(a<60)return`${a.toFixed(a<10?1:0)}s`;let r=Math.round(a),n=Math.floor(r/60),o=r%60;return`${n}m ${o}s`}function DK(e){if(e===void 0)return;let t=typeof e=="string"?e:JSON.stringify(e);if(t===void 0)return;let a=new TextEncoder().encode(t).byteLength;return a<1e3?`${a}b`:`${Math.round(a/1e3)}kb`}function z1(e,t){if(!(typeof e!="number"||typeof t!="number"||t<e))return Lm(t-e)}function Tx(e){if(typeof e!="number"||!Number.isFinite(e))return"";let t=Math.max(0,Math.floor(e));return t===0?"":to(t)}function ca(e,t=!1){if(typeof e!="number"||!Number.isFinite(e))return"no timestamp";let a=new Date(e);return t?a.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium",timeZone:M1()}):a.toLocaleTimeString(void 0,{timeZone:M1()})}function EK(e){if(typeof e!="number"||!Number.isFinite(e))return"no timestamp";let t=Math.round((e-Date.now())/1e3),a=Math.abs(t),r=[["year",3600*24*365],["month",3600*24*30],["week",3600*24*7],["day",3600*24],["hour",3600]],[n,o]=r.find(([,i])=>a>=i)??r.at(-1);return new Intl.RelativeTimeFormat(void 0,{numeric:"auto"}).format(Math.round(t/o),n)}function MK(e){let t=new Date(e),a={dateStyle:"medium",timeStyle:"long"};return{local:t.toLocaleString(void 0,{...a,timeZone:M1()}),utc:t.toLocaleString(void 0,{...a,timeZone:"UTC"})}}function OK(e){if(typeof e!="number"||!Number.isFinite(e))return"0";let t=Math.max(0,Math.floor(e));if(t<1e3)return String(t);let a=[["t",1e12],["b",1e9],["m",1e6],["k",1e3]],[r,n]=a.find(([,s])=>t>=s)??a[1],o=t/n;return`${o>=100||Number.isInteger(o)||o>=10?Math.round(o).toString():(Math.floor(o*10)/10).toFixed(1).replace(/\.0$/,"")}${r}`}function Im(e){return typeof e=="number"&&Number.isFinite(e)?Math.max(0,Math.floor(e)):void 0}function mxe(e){return[e.inputTokens,e.outputTokens,e.cachedInputTokens,e.cacheCreationTokens].reduce((t,a)=>{let r=Im(a);return r===void 0?t:(t??0)+r},void 0)}function Tm(e){let t=e.toLowerCase();return t==="assistant"?"assistant":t==="user"?"user":t==="system"?"system":t.includes("tool")?"tool":"other"}function Md(e,t){let a=Tm(t.role);return a==="assistant"?Ft():a==="user"?Dd(t.actorIdentity)??Dd(e.actorIdentity)??"User":a==="system"?"System":a==="tool"?"Tool":t.role||"Unknown"}function re(e){return OK(e)}function ai(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?"0":e<10?(Math.round(e*10)/10).toFixed(1).replace(/\.0$/,""):re(e)}function kg(e){if(!e)return;let t={totalTokens:0};t.reasoningTokens=Im(e.reasoningTokens);let a=mxe(e);if(a!==void 0)t.totalTokens=a,t.inputTokens=Im(e.inputTokens),t.outputTokens=Im(e.outputTokens),t.cachedInputTokens=Im(e.cachedInputTokens),t.cacheCreationTokens=Im(e.cacheCreationTokens);else{let r=Im(e.totalTokens);r!==void 0&&(t.totalTokens=r,t.providerTotalTokens=r)}return t.totalTokens>0?t:void 0}function zK(e){if(!e?.length)return;let t={totalTokens:0};for(let a of e){let r=kg(a.usage);if(r){t.totalTokens+=r.totalTokens;for(let n of["inputTokens","outputTokens","cachedInputTokens","cacheCreationTokens","reasoningTokens"]){let o=r[n];o!==void 0&&(t[n]=(t[n]??0)+o)}}}return t.totalTokens>0?t:void 0}function _z(e){return e?`${OK(e.totalTokens)} tokens`:""}function UK(e){return _z(kg(e))}function Lx(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:void 0}function Nz(e,t){return Math.round((e+t)*1e12)/1e12}function Jl(e){if(!e?.cost)return;let t={total:0},a=e.cost,r=Lx(a.total),n={input:Lx(a.input),output:Lx(a.output),cacheRead:Lx(a.cacheRead),cacheWrite:Lx(a.cacheWrite)},o=Object.values(n).reduce((i,s)=>i+(s??0),0);return t.total=Nz(t.total,r??o),t.input=n.input,t.output=n.output,t.cacheRead=n.cacheRead,t.cacheWrite=n.cacheWrite,r!==void 0||o>0?t:void 0}function jK(e){let t;for(let a of e??[]){let r=Jl(a.usage);r&&(t=Nz(t??0,r.total))}return t===void 0?void 0:{total:t}}function ze(e){if(!e)return"";let t=e.total>0&&e.total<.01?4:2;return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:t}).format(e.total)}function Nr(e){return e?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:4}).format(e.total):""}function U1(e,t){if(!(!e&&!t))return{...e,total:Nz(e?.total??0,t?.costUsd??0)}}function BK(e,t){return ze(U1(Jl(e),t))}function FK(e){return Tx(e.cumulativeDurationMs)||"none"}function pxe(e,t){return(O1(t)??0)-(O1(e)??0)}function Ar(e){return e?.displayTitle??"Conversation"}function Dd(e){let t=e?.email?.trim()||void 0,a=e?.fullName?.trim()||void 0,r=e?.slackUserName?.trim()||void 0;return t??a??r??e?.slackUserId}function Ys(e,t={}){let a=e.channel;if(!a)return;let n=t.includeId??!0?` (${a})`:"";if(e.channelNameRedacted&&e.channelName)return`${e.channelName}${n}`;let o=e.channelName?.replace(/^#/,"");return a.startsWith("D")?`Direct Message${n}`:a.startsWith("C")?o?`#${o}${n}`:`Public Channel${n}`:a.startsWith("G")?o?.startsWith("mpdm-")?`Group DM${n}`:`Private Channel${n}`:o?`${o}${n}`:a}function hxe(e){return cxe(e)?"failed":uxe(e)?"active":"idle"}function Od(e){return dxe(e)?"active":fxe(e)?"failed":"idle"}function Rx(e){return e.eventHistory.status==="redacted"?"Transcript hidden because this conversation is not public.":e.eventHistory.status==="expired"?"Transcript expired for this conversation.":hxe(e)==="active"?"Transcript pending while this conversation is active.":"Transcript unavailable for this conversation."}function el(e){return`/people/${encodeURIComponent(e)}`}function HK(e){return`/system/locations/${encodeURIComponent(e)}`}function tl(e){return`/automations/${encodeURIComponent(e)}`}function gxe(e){let t=e?.trim().toLowerCase();if(!t)return"markdown";let r={console:"shellscript",htm:"html",js:"javascript",jsonl:"json",md:"markdown",ndjson:"json",sh:"shellscript",text:"markdown",txt:"markdown",xml:"xml",yml:"yaml"}[t]??t;return Object.hasOwn(P1,r)?r:"markdown"}function VK(e){let t=e.trim();if(t)try{return JSON.stringify(JSON.parse(t),null,2)}catch{return}}function qK(e){let t=e.trim().split(/\r?\n/).filter(r=>r.trim().length>0);if(t.length<2)return;let a=[];for(let r of t){let n=VK(r);if(!n)return;a.push(n)}return a.join(`
71
71
  `)}function ZK(e){return VK(e)??qK(e)}function E1(e,t){return t==="json"?ZK(e)??e:e}function Tz(e){let t=e.trim();if(!t)return"markdown";try{return JSON.parse(t),"json"}catch{}return qK(t)?"json":"markdown"}function GK(e){let t=[],a=/```([A-Za-z0-9_-]+)?\n([\s\S]*?)```/g,r=0,n;for(;n=a.exec(e);){let s=e.slice(r,n.index).trim();if(s){let c=Tz(s);t.push({code:E1(s,c),fenced:!1,language:c})}let l=gxe(n[1]);t.push({code:E1(n[2]??"",l),fenced:!0,language:l}),r=n.index+n[0].length}let o=e.slice(r).trim();if(o){let s=Tz(o);t.push({code:E1(o,s),fenced:!1,language:s})}if(t.length>0)return t;let i=Tz(e);return[{code:E1(e,i),fenced:!1,language:i}]}function $i(e){return e.map(t=>({activityPreview:t.activityPreview,annotations:t.annotations,sidebarAnnotations:t.sidebarAnnotations,archivedAt:t.archivedAt,auxiliaryCosts:t.auxiliaryCosts,channel:t.channel,channelName:t.channelName,channelNameRedacted:t.channelNameRedacted,cumulativeDurationMs:t.cumulativeDurationMs,cumulativeUsage:t.cumulativeUsage,displayTitle:t.displayTitle,id:t.conversationId,lastProgressAt:t.lastProgressAt,lastSeenAt:t.lastSeenAt,locationId:t.locationId,locationUrl:t.locationUrl,actorIdentity:t.actorIdentity,participants:t.participants,sentryTraceUrl:t.sentryTraceUrl,startedAt:t.startedAt,status:t.status,surface:t.surface,traceId:t.traceId,isPriority:t.isPriority,unfinishedWork:t.unfinishedWork,visibility:t.visibility})).sort((t,a)=>pxe(t.lastSeenAt,a.lastSeenAt))}function KK(e){if(!e)return;let t=$i([e])[0];return t?{...t,displayTitle:e.displayTitle}:void 0}function Ql(e){return e==null||e===""?"":typeof e=="string"?ZK(e)??e:JSON.stringify(e,null,2)??""}var WK=b(w(),1);function tn(e){return(0,WK.jsx)("p",{className:I("m-0 text-sm text-rose-300",e.className),role:"alert",children:e.children})}var al=b(w(),1);function j1(e){return e.hasMore?(0,al.jsx)(ie,{className:I("justify-self-center",e.className),disabled:e.loading,onClick:e.onLoadMore,children:e.loading?"Loading\u2026":"Load more"}):null}function Rm(e,t,a){let n=(Math.max(1,t)-1)*a;return e.slice(n,n+a)}function rc(e,t){return e<=0?1:Math.max(1,Math.ceil(e/t))}function oc(e){if(e.total<=e.pageSize||e.pageCount<=1)return null;let t=Math.min(Math.max(1,e.page),e.pageCount),a=(t-1)*e.pageSize+1,r=Math.min(e.total,t*e.pageSize);return(0,al.jsxs)("div",{"aria-label":"Pagination",className:I("flex flex-wrap items-center justify-between gap-3",e.className),children:[(0,al.jsxs)("p",{className:"m-0 font-mono text-xs text-dashboard-text-muted",children:["Showing ",a.toLocaleString("en-US"),"-",r.toLocaleString("en-US")," of"," ",e.total.toLocaleString("en-US")]}),(0,al.jsxs)("div",{className:"flex items-center gap-2",children:[(0,al.jsx)(ie,{"aria-label":"Previous page",disabled:t<=1,onClick:()=>e.onPageChange(t-1),size:"icon",children:(0,al.jsx)(Hy,{"aria-hidden":"true",size:16})}),(0,al.jsxs)("span",{className:"min-w-16 text-center font-mono text-xs text-dashboard-text-muted",children:[t," / ",e.pageCount]}),(0,al.jsx)(ie,{"aria-label":"Next page",disabled:t>=e.pageCount,onClick:()=>e.onPageChange(t+1),size:"icon",children:(0,al.jsx)(Qa,{"aria-hidden":"true",size:16})})]})]})}var _x=b(w(),1);function an(e){let t=e.size??"compact";return(0,_x.jsxs)("div",{className:I("relative min-w-0",e.className),children:[(0,_x.jsx)(md,{"aria-hidden":"true",className:I("pointer-events-none absolute top-1/2 -translate-y-1/2 text-dashboard-text-muted",vxe[t]),size:t==="compact"?13:14,strokeWidth:2.5}),(0,_x.jsx)("input",{"aria-label":e.label,className:I("w-full rounded-lg border border-dashboard-border font-mono text-xs text-dashboard-text outline-none transition-colors placeholder:text-dashboard-text-muted hover:border-dashboard-border-emphasis focus:border-dashboard-focus",yxe[t]),onChange:a=>e.onChange(a.currentTarget.value),placeholder:e.placeholder,ref:e.inputRef,type:"search",value:e.value})]})}var vxe={compact:"left-2.5",default:"left-3"},yxe={compact:"h-9 bg-dashboard-overlay-soft pr-3 pl-8 focus:ring-1 focus:ring-dashboard-focus/25",default:"h-10 bg-dashboard-overlay-soft pr-3 pl-9 focus:ring-2 focus:ring-dashboard-focus/20"};var UI=b(G(),1);var nl=b(w(),1);function JK(e){return(0,nl.jsxs)(U,{className:I("flex flex-wrap items-end gap-4 p-4",e.className),children:[e.children,e.search?(0,nl.jsx)(_m,{className:"min-w-[16rem] flex-1",label:"Search",children:(0,nl.jsx)(an,{className:"w-full max-w-md",label:e.search.label,onChange:e.search.onChange,placeholder:e.search.placeholder,value:e.search.value})}):null]})}function _m(e){return(0,nl.jsxs)("div",{className:I("min-w-0",e.className),children:[(0,nl.jsx)("div",{className:"mb-2 font-mono text-xs uppercase tracking-[0.12em] text-dashboard-text-muted",children:e.label}),(0,nl.jsx)("div",{"aria-label":e.label,className:"flex flex-wrap gap-2",role:"group",children:e.children})]})}function B1(e){return(0,nl.jsx)("div",{"aria-label":e.ariaLabel,className:"grid min-w-0 grid-cols-3 gap-1 border-b border-white/[0.06] sm:flex sm:overflow-x-auto",role:"tablist",children:e.items.map(t=>{let a=e.value===t.value;return(0,nl.jsxs)("button",{"aria-selected":a,className:I("relative flex min-w-0 cursor-pointer items-center justify-between gap-2 border-0 bg-transparent px-3 py-2.5 font-mono text-xs uppercase tracking-[0.1em] transition-colors after:absolute after:inset-x-2 after:bottom-0 after:h-px sm:shrink-0 sm:justify-start",a?"text-cyan-100 after:bg-cyan-300":"text-dashboard-text-muted after:bg-transparent hover:text-dashboard-text"),onClick:()=>e.onChange(t.value),role:"tab",type:"button",children:[t.label,t.count!==void 0?(0,nl.jsx)("span",{className:I("rounded-sm border px-1.5 py-0.5 text-xs",a?"border-cyan-300/20 bg-cyan-300/10 text-cyan-100":"border-white/[0.07] bg-white/[0.025] text-dashboard-text-muted"),children:t.count.toLocaleString("en-US")}):null]},t.value||"all")})})}var QK=b(w(),1),bxe="a, button, input, select, textarea, [role='button'], [role='link']";function Ig(e){function t(a){a.target instanceof Element&&a.target.closest(bxe)||e.onSelect()}return(0,QK.jsx)("div",{className:I("group cursor-pointer transition-colors",e.selected?"bg-cyan-300/[0.045]":"hover:bg-white/[0.035] focus-within:bg-white/[0.035]",e.className),onClick:t,children:e.children})}var F1=b(G(),1);function H1(e){let[t,a]=qo(),r=Bt(),n=(0,F1.useRef)(!1),o=t.get("filter")?.trim()??"",[i,s,l]=Zl(),c=wv({initialPageParam:void 0,queryKey:["dashboard","plugin-user-page",e.pluginName,e.id,o,l],queryFn:({pageParam:h,signal:g})=>{let x=new URLSearchParams;o&&x.set("filter",o),l&&x.set("q",l),h&&x.set("cursor",h);let y=x.toString();return Ne(kG,`/api/user-pages/${encodeURIComponent(e.pluginName)}/${encodeURIComponent(e.id)}${y?`?${y}`:""}`,g)},getNextPageParam:h=>h.nextCursor,placeholderData:h=>h,retry:!1}),d=(0,F1.useMemo)(()=>[...new Map((c.data?.pages??[]).flatMap(h=>h.records).map(h=>[h.id,h])).values()],[c.data?.pages]),f=ga({mutationFn:h=>Rd(h.href),onMutate:()=>({pluginName:e.pluginName}),onSuccess:async(h,g,x)=>{r.removeQueries({queryKey:["dashboard","plugin-user-page",x.pluginName,"record"]}),await r.invalidateQueries({queryKey:["dashboard","plugin-user-page",x.pluginName]})},onSettled:()=>{n.current=!1}});function m(h){n.current||h.confirmation&&!window.confirm(h.confirmation)||(n.current=!0,f.mutate(h))}function p(h){let g=new URLSearchParams(t);h?g.set("filter",h):g.delete("filter"),a(g,{replace:!0})}return{action:f,content:c.data?.pages[0],filter:o,query:c,records:d,runAction:m,searchQuery:l,searchText:i,setFilter:p,setSearchText:s}}var YK=u.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),XK=u.object({date:YK,personal:u.number().int().min(0),public:u.number().int().min(0)}).strict(),V1=u.object({costUsd:u.number().finite().min(0),date:YK,events:u.number().int().min(0)}).strict(),xxe=u.object({days:u.array(XK).length(90),extractionDays:u.array(V1).length(90),extractionHours:u.array(V1).min(24).optional(),generatedAt:u.iso.datetime(),hours:u.array(XK).min(24).optional(),recallDays:u.array(V1).length(90),recallHours:u.array(V1).min(24).optional(),stats:u.object({active:u.number().int().min(0),automatic:u.number().int().min(0),createdThirtyDays:u.number().int().min(0),embedded:u.number().int().min(0),explicit:u.number().int().min(0),knowledge:u.number().int().min(0),personal:u.number().int().min(0),preference:u.number().int().min(0),procedure:u.number().int().min(0),public:u.number().int().min(0)}).strict()}).strict();function Az(){return Ue({queryFn:({signal:e})=>Ne(xxe,"/api/plugins/memory/dashboard",e),queryKey:["dashboard","plugin-user-page","memory","summary"],retry:!1})}var Sxe=u.object({active:u.number().int().min(0),personal:u.number().int().min(0),public:u.number().int().min(0)}).strict();function eW(e){return Ue({enabled:!!e,placeholderData:pf,queryFn:({signal:t})=>Ne(Sxe,`/api/plugins/memory/counts?${new URLSearchParams({q:e})}`,t),queryKey:["dashboard","plugin-user-page","memory","counts",e],retry:!1})}var BJ=b(G(),1);var Lg=b(w(),1);function Pi(e){return(0,Lg.jsx)("dl",{className:I("grid gap-px overflow-hidden rounded border border-white/[0.06] bg-white/[0.055]",e.className),children:e.children})}function da(e){return(0,Lg.jsxs)("div",{className:"min-w-0 bg-[#09090b] px-3 py-3",children:[(0,Lg.jsx)("dt",{className:"font-mono text-xs uppercase tracking-[0.12em] text-dashboard-text-muted",children:e.label}),(0,Lg.jsx)("dd",{className:I("mt-1.5 ml-0 break-words text-sm leading-relaxed text-dashboard-text",e.valueClassName),children:e.children})]})}var Tg=b(G(),1);function wxe(){let e=0,t;return{acquire(){if(!(typeof document>"u")){if(e===0){let a=document.documentElement,r=document.body,n=typeof window>"u"?0:window.scrollX||window.pageXOffset||0,o=typeof window>"u"?0:window.scrollY||window.pageYOffset||0;t={bodyHeight:r.style.height,bodyLeft:r.style.left,bodyOverflow:r.style.overflow,bodyOverscroll:r.style.overscrollBehavior,bodyPosition:r.style.position,bodyRight:r.style.right,bodyTop:r.style.top,bodyWidth:r.style.width,htmlHeight:a.style.height,htmlOverflow:a.style.overflow,htmlOverscroll:a.style.overscrollBehavior,scrollX:n,scrollY:o},a.style.overflow="hidden",a.style.overscrollBehavior="none",a.style.height="100%",r.style.overflow="hidden",r.style.overscrollBehavior="none",r.style.position="fixed",r.style.top=`-${o}px`,r.style.left=`-${n}px`,r.style.right="0",r.style.width="100%",r.style.height="100%"}e+=1}},release(){if(typeof document>"u"||e===0||(e=Math.max(0,e-1),e>0||t===void 0))return;let a=document.documentElement,r=document.body;a.style.overflow=t.htmlOverflow,a.style.overscrollBehavior=t.htmlOverscroll,a.style.height=t.htmlHeight,r.style.overflow=t.bodyOverflow,r.style.overscrollBehavior=t.bodyOverscroll,r.style.position=t.bodyPosition,r.style.top=t.bodyTop,r.style.left=t.bodyLeft,r.style.right=t.bodyRight,r.style.width=t.bodyWidth,r.style.height=t.bodyHeight;let{scrollX:n,scrollY:o}=t;t=void 0,typeof window<"u"&&window.scrollTo(n,o)}}}var tW=wxe();function zd(){tW.acquire()}function Ud(){tW.release()}var rl=b(w(),1),Cxe=["a[href]","button:not([disabled])","input:not([disabled]):not([type='hidden'])","select:not([disabled])","textarea:not([disabled])","summary","[tabindex]:not([tabindex='-1'])"].join(",");function $r(e){let t=(0,Tg.useRef)(null),a=(0,Tg.useRef)(e.onClose),r=(0,Tg.useRef)(void 0);return a.current=e.onClose,(0,Tg.useEffect)(()=>{r.current=document.activeElement instanceof HTMLElement?document.activeElement:void 0,zd();let n=requestAnimationFrame(()=>{t.current?.querySelector("[data-drawer-close]")?.focus()}),o=i=>{let s=document.querySelectorAll("[data-dashboard-drawer]");if(s[s.length-1]!==t.current)return;if(i.key==="Escape"){i.preventDefault(),a.current();return}if(i.key!=="Tab")return;let l=t.current,c=Array.from(l?.querySelectorAll(Cxe)??[]).filter(p=>p.tabIndex>=0&&p.getClientRects().length>0),d=c.at(0),f=c.at(-1);if(!l||!d||!f){i.preventDefault();return}let m=document.activeElement;i.shiftKey&&(m===d||!l.contains(m))?(i.preventDefault(),f.focus()):!i.shiftKey&&(m===f||!l.contains(m))&&(i.preventDefault(),d.focus())};return window.addEventListener("keydown",o),()=>{cancelAnimationFrame(n),window.removeEventListener("keydown",o),Ud();let i=r.current;r.current=void 0,i?.isConnected&&i.focus()}},[e.openKey]),(0,rl.jsxs)("div",{"aria-labelledby":e.titleId,"aria-modal":"true","data-dashboard-drawer":"",className:"fixed inset-0 z-50",ref:t,role:"dialog",children:[(0,rl.jsx)("button",{"aria-label":e.dismissLabel,className:"absolute inset-0 cursor-default bg-dashboard-overlay",onClick:e.onClose,tabIndex:-1,type:"button"}),(0,rl.jsxs)("aside",{className:I("absolute top-0 right-0 grid h-full w-full grid-rows-[auto_minmax(0,1fr)] bg-dashboard-bg-elevated shadow-[-20px_0_60px_rgba(0,0,0,0.45)] md:border-l md:border-dashboard-border-emphasis",e.width==="wide"?"md:w-[min(760px,94vw)]":e.width==="narrow"?"md:w-[min(440px,94vw)]":"md:w-[min(560px,94vw)]"),children:[(0,rl.jsxs)("header",{className:"relative grid grid-cols-[minmax(0,1fr)_auto] gap-3 border-b border-dashboard-border-strong bg-dashboard-surface-raised px-4 py-3 pt-[max(0.75rem,env(safe-area-inset-top))] md:px-5",children:[(0,rl.jsx)("div",{className:"min-w-0",children:e.header}),(0,rl.jsxs)("div",{className:"flex items-start gap-1.5",children:[e.actions,(0,rl.jsx)(ie,{"aria-label":e.closeLabel,"data-drawer-close":!0,onClick:e.onClose,size:"icon",title:"Close",children:(0,rl.jsx)(Wr,{"aria-hidden":"true",size:15,strokeWidth:2.25})})]})]}),(0,rl.jsx)("div",{className:"min-h-0 overflow-auto px-4 py-4 pb-[max(1rem,env(safe-area-inset-bottom))] md:px-5",children:e.children})]})]})}var jJ=b(G(),1);var na=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function kxe(e){return Bz(e)}function Bz(e){return Array.isArray(e)?Ixe(e):e instanceof RegExp?e:typeof e=="object"?Lxe(e):e}function Ixe(e){let t=[];for(let a=0,r=e.length;a<r;a++)t[a]=Bz(e[a]);return t}function Lxe(e){let t={};for(let a in e)t[a]=Bz(e[a]);return t}function cW(e,...t){return t.forEach(a=>{for(let r in a)e[r]=a[r]}),e}function dW(e){let t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?dW(e.substring(0,e.length-1)):e.substr(~t+1)}var $z=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,q1=class{static hasCaptures(e){return e===null?!1:($z.lastIndex=0,$z.test(e))}static replaceCaptures(e,t,a){return e.replace($z,(r,n,o,i)=>{let s=a[parseInt(n||o,10)];if(s){let l=t.substring(s.start,s.end);for(;l[0]===".";)l=l.substring(1);switch(i){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return r})}};function fW(e,t){return e<t?-1:e>t?1:0}function mW(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let a=e.length,r=t.length;if(a===r){for(let n=0;n<a;n++){let o=fW(e[n],t[n]);if(o!==0)return o}return 0}return a-r}function aW(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function pW(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var hW=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},$x=class{constructor(e,t,a){this._colorMap=e,this._defaults=t,this._root=a}static createFromRawTheme(e,t){return this.createFromParsedTheme(_xe(e),t)}static createFromParsedTheme(e,t){return Axe(e,t)}_cachedMatchRoot=new hW(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,r=this._cachedMatchRoot.get(t).find(n=>Txe(e.parent,n.parentScopes));return r?new gW(r.fontStyle,r.foreground,r.background):null}},Pz=class Z1{constructor(t,a){this.parent=t,this.scopeName=a}static push(t,a){for(let r of a)t=new Z1(t,r);return t}static from(...t){let a=null;for(let r=0;r<t.length;r++)a=new Z1(a,t[r]);return a}push(t){return new Z1(this,t)}getSegments(){let t=this,a=[];for(;t;)a.push(t.scopeName),t=t.parent;return a.reverse(),a}toString(){return this.getSegments().join(" ")}extends(t){return this===t?!0:this.parent===null?!1:this.parent.extends(t)}getExtensionIfDefined(t){let a=[],r=this;for(;r&&r!==t;)a.push(r.scopeName),r=r.parent;return r===t?a.reverse():void 0}};function Txe(e,t){if(t.length===0)return!0;for(let a=0;a<t.length;a++){let r=t[a],n=!1;if(r===">"){if(a===t.length-1)return!1;r=t[++a],n=!0}for(;e&&!Rxe(e.scopeName,r);){if(n)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function Rxe(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var gW=class{constructor(e,t,a){this.fontStyle=e,this.foregroundId=t,this.backgroundId=a}};function _xe(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,a=[],r=0;for(let n=0,o=t.length;n<o;n++){let i=t[n];if(!i.settings)continue;let s;if(typeof i.scope=="string"){let f=i.scope;f=f.replace(/^[,]+/,""),f=f.replace(/[,]+$/,""),s=f.split(",")}else Array.isArray(i.scope)?s=i.scope:s=[""];let l=-1;if(typeof i.settings.fontStyle=="string"){l=0;let f=i.settings.fontStyle.split(" ");for(let m=0,p=f.length;m<p;m++)switch(f[m]){case"italic":l=l|1;break;case"bold":l=l|2;break;case"underline":l=l|4;break;case"strikethrough":l=l|8;break}}let c=null;typeof i.settings.foreground=="string"&&aW(i.settings.foreground)&&(c=i.settings.foreground);let d=null;typeof i.settings.background=="string"&&aW(i.settings.background)&&(d=i.settings.background);for(let f=0,m=s.length;f<m;f++){let h=s[f].trim().split(" "),g=h[h.length-1],x=null;h.length>1&&(x=h.slice(0,h.length-1),x.reverse()),a[r++]=new Nxe(g,x,n,l,c,d)}}return a}var Nxe=class{constructor(e,t,a,r,n,o){this.scope=e,this.parentScopes=t,this.index=a,this.fontStyle=r,this.foreground=n,this.background=o}},Pr=(e=>(e[e.NotSet=-1]="NotSet",e[e.None=0]="None",e[e.Italic=1]="Italic",e[e.Bold=2]="Bold",e[e.Underline=4]="Underline",e[e.Strikethrough=8]="Strikethrough",e))(Pr||{});function Axe(e,t){e.sort((l,c)=>{let d=fW(l.scope,c.scope);return d!==0||(d=mW(l.parentScopes,c.parentScopes),d!==0)?d:l.index-c.index});let a=0,r="#000000",n="#ffffff";for(;e.length>=1&&e[0].scope==="";){let l=e.shift();l.fontStyle!==-1&&(a=l.fontStyle),l.foreground!==null&&(r=l.foreground),l.background!==null&&(n=l.background)}let o=new $xe(t),i=new gW(a,o.getId(r),o.getId(n)),s=new Dxe(new Ez(0,null,-1,0,0),[]);for(let l=0,c=e.length;l<c;l++){let d=e[l];s.insert(0,d.scope,d.parentScopes,d.fontStyle,o.getId(d.foreground),o.getId(d.background))}return new $x(o,i,s)}var $xe=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,a=e.length;t<a;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw new Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},Pxe=Object.freeze([]),Ez=class vW{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,a,r,n,o){this.scopeDepth=t,this.parentScopes=a||Pxe,this.fontStyle=r,this.foreground=n,this.background=o}clone(){return new vW(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let a=[];for(let r=0,n=t.length;r<n;r++)a[r]=t[r].clone();return a}acceptOverwrite(t,a,r,n){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,a!==-1&&(this.fontStyle=a),r!==0&&(this.foreground=r),n!==0&&(this.background=n)}},Dxe=class Mz{constructor(t,a=[],r={}){this._mainRule=t,this._children=r,this._rulesWithParentScopes=a}_rulesWithParentScopes;static _cmpBySpecificity(t,a){if(t.scopeDepth!==a.scopeDepth)return a.scopeDepth-t.scopeDepth;let r=0,n=0;for(;t.parentScopes[r]===">"&&r++,a.parentScopes[n]===">"&&n++,!(r>=t.parentScopes.length||n>=a.parentScopes.length);){let o=a.parentScopes[n].length-t.parentScopes[r].length;if(o!==0)return o;r++,n++}return a.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let r=t.indexOf("."),n,o;if(r===-1?(n=t,o=""):(n=t.substring(0,r),o=t.substring(r+1)),this._children.hasOwnProperty(n))return this._children[n].match(o)}let a=this._rulesWithParentScopes.concat(this._mainRule);return a.sort(Mz._cmpBySpecificity),a}insert(t,a,r,n,o,i){if(a===""){this._doInsertHere(t,r,n,o,i);return}let s=a.indexOf("."),l,c;s===-1?(l=a,c=""):(l=a.substring(0,s),c=a.substring(s+1));let d;this._children.hasOwnProperty(l)?d=this._children[l]:(d=new Mz(this._mainRule.clone(),Ez.cloneArr(this._rulesWithParentScopes)),this._children[l]=d),d.insert(t+1,c,r,n,o,i)}_doInsertHere(t,a,r,n,o){if(a===null){this._mainRule.acceptOverwrite(t,r,n,o);return}for(let i=0,s=this._rulesWithParentScopes.length;i<s;i++){let l=this._rulesWithParentScopes[i];if(mW(l.parentScopes,a)===0){l.acceptOverwrite(t,r,n,o);return}}r===-1&&(r=this._mainRule.fontStyle),n===0&&(n=this._mainRule.foreground),o===0&&(o=this._mainRule.background),this._rulesWithParentScopes.push(new Ez(t,a,r,n,o))}},Am=class hs{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){let a=hs.getLanguageId(t),r=hs.getTokenType(t),n=hs.getFontStyle(t),o=hs.getForeground(t),i=hs.getBackground(t);console.log({languageId:a,tokenType:r,fontStyle:n,foreground:o,background:i})}static getLanguageId(t){return(t&255)>>>0}static getTokenType(t){return(t&768)>>>8}static containsBalancedBrackets(t){return(t&1024)!==0}static getFontStyle(t){return(t&30720)>>>11}static getForeground(t){return(t&16744448)>>>15}static getBackground(t){return(t&4278190080)>>>24}static set(t,a,r,n,o,i,s){let l=hs.getLanguageId(t),c=hs.getTokenType(t),d=hs.containsBalancedBrackets(t)?1:0,f=hs.getFontStyle(t),m=hs.getForeground(t),p=hs.getBackground(t);return a!==0&&(l=a),r!==8&&(c=r),n!==null&&(d=n?1:0),o!==-1&&(f=o),i!==0&&(m=i),s!==0&&(p=s),(l<<0|c<<8|d<<10|f<<11|m<<15|p<<24)>>>0}};function K1(e,t){let a=[],r=Exe(e),n=r.next();for(;n!==null;){let l=0;if(n.length===2&&n.charAt(1)===":"){switch(n.charAt(0)){case"R":l=1;break;case"L":l=-1;break;default:console.log(`Unknown priority ${n} in scope selector`)}n=r.next()}let c=i();if(a.push({matcher:c,priority:l}),n!==",")break;n=r.next()}return a;function o(){if(n==="-"){n=r.next();let l=o();return c=>!!l&&!l(c)}if(n==="("){n=r.next();let l=s();return n===")"&&(n=r.next()),l}if(nW(n)){let l=[];do l.push(n),n=r.next();while(nW(n));return c=>t(l,c)}return null}function i(){let l=[],c=o();for(;c;)l.push(c),c=o();return d=>l.every(f=>f(d))}function s(){let l=[],c=i();for(;c&&(l.push(c),n==="|"||n===",");){do n=r.next();while(n==="|"||n===",");c=i()}return d=>l.some(f=>f(d))}}function nW(e){return!!e&&!!e.match(/[\w\.:]+/)}function Exe(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,a=t.exec(e);return{next:()=>{if(!a)return null;let r=a[0];return a=t.exec(e),r}}}function yW(e){typeof e.dispose=="function"&&e.dispose()}var Px=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},Mxe=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},Oxe=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},zxe=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Px(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new Oxe;for(let a of e)Uxe(a,this.initialScopeName,this.repo,t);for(let a of t.references)if(a instanceof Px){if(this.seenFullScopeRequests.has(a.scopeName))continue;this.seenFullScopeRequests.add(a.scopeName),this.Q.push(a)}else{if(this.seenFullScopeRequests.has(a.scopeName)||this.seenPartialScopeRequests.has(a.toKey()))continue;this.seenPartialScopeRequests.add(a.toKey()),this.Q.push(a)}}};function Uxe(e,t,a,r){let n=a.lookup(e.scopeName);if(!n){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}let o=a.lookup(t);e instanceof Px?G1({baseGrammar:o,selfGrammar:n},r):Oz(e.ruleName,{baseGrammar:o,selfGrammar:n,repository:n.repository},r);let i=a.injections(e.scopeName);if(i)for(let s of i)r.add(new Px(s))}function Oz(e,t,a){if(t.repository&&t.repository[e]){let r=t.repository[e];W1([r],t,a)}}function G1(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&W1(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&W1(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function W1(e,t,a){for(let r of e){if(a.visitedRule.has(r))continue;a.visitedRule.add(r);let n=r.repository?cW({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&W1(r.patterns,{...t,repository:n},a);let o=r.include;if(!o)continue;let i=bW(o);switch(i.kind){case 0:G1({...t,selfGrammar:t.baseGrammar},a);break;case 1:G1(t,a);break;case 2:Oz(i.ruleName,{...t,repository:n},a);break;case 3:case 4:let s=i.scopeName===t.selfGrammar.scopeName?t.selfGrammar:i.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(s){let l={baseGrammar:t.baseGrammar,selfGrammar:s,repository:n};i.kind===4?Oz(i.ruleName,l,a):G1(l,a)}else i.kind===4?a.add(new Mxe(i.scopeName,i.ruleName)):a.add(new Px(i.scopeName));break}}}var jxe=class{kind=0},Bxe=class{kind=1},Fxe=class{constructor(e){this.ruleName=e}kind=2},Hxe=class{constructor(e){this.scopeName=e}kind=3},Vxe=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function bW(e){if(e==="$base")return new jxe;if(e==="$self")return new Bxe;let t=e.indexOf("#");if(t===-1)return new Hxe(e);if(t===0)return new Fxe(e.substring(1));{let a=e.substring(0,t),r=e.substring(t+1);return new Vxe(a,r)}}var qxe=/\\(\d+)/,rW=/\\(\d+)/g;var Zxe=-1,xW=-2;var Mx=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,a,r){this.$location=e,this.id=t,this._name=a||null,this._nameIsCapturing=q1.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=q1.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${dW(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:q1.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:q1.replaceCaptures(this._contentName,e,t)}},Gxe=class extends Mx{retokenizeCapturedWithRuleId;constructor(e,t,a,r,n){super(e,t,a,r),this.retokenizeCapturedWithRuleId=n}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,a,r){throw new Error("Not supported!")}},Kxe=class extends Mx{_match;captures;_cachedCompiledPatterns;constructor(e,t,a,r,n){super(e,t,a,null),this._match=new Dx(r,this.id),this.captures=n,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,a,r){return this._getCachedCompiledPatterns(e).compileAG(e,a,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Ex,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},oW=class extends Mx{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,a,r,n){super(e,t,a,r),this.patterns=n.patterns,this.hasMissingPatterns=n.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(let a of this.patterns)e.getRule(a).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,a,r){return this._getCachedCompiledPatterns(e).compileAG(e,a,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Ex,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},zz=class extends Mx{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,a,r,n,o,i,s,l,c){super(e,t,a,r),this._begin=new Dx(n,this.id),this.beginCaptures=o,this._end=new Dx(i||"\uFFFF",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=s,this.applyEndPatternLast=l||!1,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,a,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,a,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Ex;for(let a of this.patterns)e.getRule(a).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},J1=class extends Mx{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,a,r,n,o,i,s,l){super(e,t,a,r),this._begin=new Dx(n,this.id),this.beginCaptures=o,this.whileCaptures=s,this._while=new Dx(i,xW),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,a,r){return this._getCachedCompiledPatterns(e).compileAG(e,a,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Ex;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,a,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,a,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Ex,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"\uFFFF"),this._cachedCompiledWhilePatterns}},SW=class no{static createCaptureRule(t,a,r,n,o){return t.registerRule(i=>new Gxe(a,i,r,n,o))}static getCompiledRuleId(t,a,r){return t.id||a.registerRule(n=>{if(t.id=n,t.match)return new Kxe(t.$vscodeTextmateLocation,t.id,t.name,t.match,no._compileCaptures(t.captures,a,r));if(typeof t.begin>"u"){t.repository&&(r=cW({},r,t.repository));let o=t.patterns;return typeof o>"u"&&t.include&&(o=[{include:t.include}]),new oW(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,no._compilePatterns(o,a,r))}return t.while?new J1(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,no._compileCaptures(t.beginCaptures||t.captures,a,r),t.while,no._compileCaptures(t.whileCaptures||t.captures,a,r),no._compilePatterns(t.patterns,a,r)):new zz(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,no._compileCaptures(t.beginCaptures||t.captures,a,r),t.end,no._compileCaptures(t.endCaptures||t.captures,a,r),t.applyEndPatternLast,no._compilePatterns(t.patterns,a,r))}),t.id}static _compileCaptures(t,a,r){let n=[];if(t){let o=0;for(let i in t){if(i==="$vscodeTextmateLocation")continue;let s=parseInt(i,10);s>o&&(o=s)}for(let i=0;i<=o;i++)n[i]=null;for(let i in t){if(i==="$vscodeTextmateLocation")continue;let s=parseInt(i,10),l=0;t[i].patterns&&(l=no.getCompiledRuleId(t[i],a,r)),n[s]=no.createCaptureRule(a,t[i].$vscodeTextmateLocation,t[i].name,t[i].contentName,l)}}return n}static _compilePatterns(t,a,r){let n=[];if(t)for(let o=0,i=t.length;o<i;o++){let s=t[o],l=-1;if(s.include){let c=bW(s.include);switch(c.kind){case 0:case 1:l=no.getCompiledRuleId(r[s.include],a,r);break;case 2:let d=r[c.ruleName];d&&(l=no.getCompiledRuleId(d,a,r));break;case 3:case 4:let f=c.scopeName,m=c.kind===4?c.ruleName:null,p=a.getExternalGrammar(f,r);if(p)if(m){let h=p.repository[m];h&&(l=no.getCompiledRuleId(h,a,p.repository))}else l=no.getCompiledRuleId(p.repository.$self,a,p.repository);break}}else l=no.getCompiledRuleId(s,a,r);if(l!==-1){let c=a.getRule(l),d=!1;if((c instanceof oW||c instanceof zz||c instanceof J1)&&c.hasMissingPatterns&&c.patterns.length===0&&(d=!0),d)continue;n.push(l)}}return{patterns:n,hasMissingPatterns:(t?t.length:0)!==n.length}}},Dx=class wW{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(t,a){if(t&&typeof t=="string"){let r=t.length,n=0,o=[],i=!1;for(let s=0;s<r;s++)if(t.charAt(s)==="\\"&&s+1<r){let c=t.charAt(s+1);c==="z"?(o.push(t.substring(n,s)),o.push("$(?!\\n)(?<!\\n)"),n=s+2):(c==="A"||c==="G")&&(i=!0),s++}this.hasAnchor=i,n===0?this.source=t:(o.push(t.substring(n,r)),this.source=o.join(""))}else this.hasAnchor=!1,this.source=t;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=a,typeof this.source=="string"?this.hasBackReferences=qxe.test(this.source):this.hasBackReferences=!1}clone(){return new wW(this.source,this.ruleId)}setSource(t){this.source!==t&&(this.source=t,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(t,a){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let r=a.map(n=>t.substring(n.start,n.end));return rW.lastIndex=0,this.source.replace(rW,(n,o)=>pW(r[parseInt(o,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let t=[],a=[],r=[],n=[],o,i,s,l;for(o=0,i=this.source.length;o<i;o++)s=this.source.charAt(o),t[o]=s,a[o]=s,r[o]=s,n[o]=s,s==="\\"&&o+1<i&&(l=this.source.charAt(o+1),l==="A"?(t[o+1]="\uFFFF",a[o+1]="\uFFFF",r[o+1]="A",n[o+1]="A"):l==="G"?(t[o+1]="\uFFFF",a[o+1]="G",r[o+1]="\uFFFF",n[o+1]="G"):(t[o+1]=l,a[o+1]=l,r[o+1]=l,n[o+1]=l),o++);return{A0_G0:t.join(""),A0_G1:a.join(""),A1_G0:r.join(""),A1_G1:n.join("")}}resolveAnchors(t,a){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:t?a?this._anchorCache.A1_G1:this._anchorCache.A1_G0:a?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Ex=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(a=>a.source);this._cached=new iW(e,t,this._items.map(a=>a.ruleId))}return this._cached}compileAG(e,t,a){return this._hasAnchors?t?a?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,a)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,a)),this._anchorCache.A1_G0):a?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,a)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,a)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,a){let r=this._items.map(n=>n.resolveAnchors(t,a));return new iW(e,r,this._items.map(n=>n.ruleId))}},iW=class{constructor(e,t,a){this.regExps=t,this.rules=a,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){let e=[];for(let t=0,a=this.rules.length;t<a;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join(`
72
72
  `)}findNextMatchSync(e,t,a){let r=this.scanner.findNextMatchSync(e,t,a);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},Dz=class{constructor(e,t){this.languageId=e,this.tokenType=t}},Wxe=class Uz{_defaultAttributes;_embeddedLanguagesMatcher;constructor(t,a){this._defaultAttributes=new Dz(t,8),this._embeddedLanguagesMatcher=new Jxe(Object.entries(a||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?Uz._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new Dz(0,0);_getBasicScopeAttributes=new hW(t=>{let a=this._scopeToLanguage(t),r=this._toStandardTokenType(t);return new Dz(a,r)});_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){let a=t.match(Uz.STANDARD_TOKEN_TYPE_REGEXP);if(!a)return 8;switch(a[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},Jxe=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);let t=e.map(([a,r])=>pW(a));t.sort(),t.reverse(),this.scopesRegExp=new RegExp(`^((${t.join(")|(")}))($|\\.)`,"")}}match(e){if(!this.scopesRegExp)return;let t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}},mqe={InDebugMode:typeof process<"u"&&!!process.env.VSCODE_TEXTMATE_DEBUG},CW=!1,sW=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function kW(e,t,a,r,n,o,i,s){let l=t.content.length,c=!1,d=-1;if(i){let p=Qxe(e,t,a,r,n,o);n=p.stack,r=p.linePos,a=p.isFirstLine,d=p.anchorPosition}let f=Date.now();for(;!c;){if(s!==0&&Date.now()-f>s)return new sW(n,!0);m()}return new sW(n,!1);function m(){let p=Xxe(e,t,a,r,n,d);if(!p){o.produce(n,l),c=!0;return}let h=p.captureIndices,g=p.matchedRuleId,x=h&&h.length>0?h[0].end>r:!1;if(g===Zxe){let y=n.getRule(e);o.produce(n,h[0].start),n=n.withContentNameScopesList(n.nameScopesList),Nx(e,t,a,n,o,y.endCaptures,h),o.produce(n,h[0].end);let v=n;if(n=n.parent,d=v.getAnchorPos(),!x&&v.getEnterPos()===r){n=v,o.produce(n,l),c=!0;return}}else{let y=e.getRule(g);o.produce(n,h[0].start);let v=n,S=y.getName(t.content,h),C=n.contentNameScopesList.pushAttributed(S,e);if(n=n.push(g,r,d,h[0].end===l,null,C,C),y instanceof zz){let L=y;Nx(e,t,a,n,o,L.beginCaptures,h),o.produce(n,h[0].end),d=h[0].end;let T=L.getContentName(t.content,h),_=C.pushAttributed(T,e);if(n=n.withContentNameScopesList(_),L.endHasBackReferences&&(n=n.withEndRule(L.getEndWithResolvedBackReferences(t.content,h))),!x&&v.hasSameRuleAs(n)){n=n.pop(),o.produce(n,l),c=!0;return}}else if(y instanceof J1){let L=y;Nx(e,t,a,n,o,L.beginCaptures,h),o.produce(n,h[0].end),d=h[0].end;let T=L.getContentName(t.content,h),_=C.pushAttributed(T,e);if(n=n.withContentNameScopesList(_),L.whileHasBackReferences&&(n=n.withEndRule(L.getWhileWithResolvedBackReferences(t.content,h))),!x&&v.hasSameRuleAs(n)){n=n.pop(),o.produce(n,l),c=!0;return}}else if(Nx(e,t,a,n,o,y.captures,h),o.produce(n,h[0].end),n=n.pop(),!x){n=n.safePop(),o.produce(n,l),c=!0;return}}h[0].end>r&&(r=h[0].end,a=!1)}}function Qxe(e,t,a,r,n,o){let i=n.beginRuleCapturedEOL?0:-1,s=[];for(let l=n;l;l=l.pop()){let c=l.getRule(e);c instanceof J1&&s.push({rule:c,stack:l})}for(let l=s.pop();l;l=s.pop()){let{ruleScanner:c,findOptions:d}=t0e(l.rule,e,l.stack.endRule,a,r===i),f=c.findNextMatchSync(t,r,d);if(f){if(f.ruleId!==xW){n=l.stack.pop();break}f.captureIndices&&f.captureIndices.length&&(o.produce(l.stack,f.captureIndices[0].start),Nx(e,t,a,l.stack,o,l.rule.whileCaptures,f.captureIndices),o.produce(l.stack,f.captureIndices[0].end),i=f.captureIndices[0].end,f.captureIndices[0].end>r&&(r=f.captureIndices[0].end,a=!1))}else{n=l.stack.pop();break}}return{stack:n,linePos:r,anchorPosition:i,isFirstLine:a}}function Xxe(e,t,a,r,n,o){let i=Yxe(e,t,a,r,n,o),s=e.getInjections();if(s.length===0)return i;let l=e0e(s,e,t,a,r,n,o);if(!l)return i;if(!i)return l;let c=i.captureIndices[0].start,d=l.captureIndices[0].start;return d<c||l.priorityMatch&&d===c?l:i}function Yxe(e,t,a,r,n,o){let i=n.getRule(e),{ruleScanner:s,findOptions:l}=IW(i,e,n.endRule,a,r===o),c=s.findNextMatchSync(t,r,l);return c?{captureIndices:c.captureIndices,matchedRuleId:c.ruleId}:null}function e0e(e,t,a,r,n,o,i){let s=Number.MAX_VALUE,l=null,c,d=0,f=o.contentNameScopesList.getScopeNames();for(let m=0,p=e.length;m<p;m++){let h=e[m];if(!h.matcher(f))continue;let g=t.getRule(h.ruleId),{ruleScanner:x,findOptions:y}=IW(g,t,null,r,n===i),v=x.findNextMatchSync(a,n,y);if(!v)continue;let S=v.captureIndices[0].start;if(!(S>=s)&&(s=S,l=v.captureIndices,c=v.ruleId,d=h.priority,s===n))break}return l?{priorityMatch:d===-1,captureIndices:l,matchedRuleId:c}:null}function IW(e,t,a,r,n){if(CW){let i=e.compile(t,a),s=LW(r,n);return{ruleScanner:i,findOptions:s}}return{ruleScanner:e.compileAG(t,a,r,n),findOptions:0}}function t0e(e,t,a,r,n){if(CW){let i=e.compileWhile(t,a),s=LW(r,n);return{ruleScanner:i,findOptions:s}}return{ruleScanner:e.compileWhileAG(t,a,r,n),findOptions:0}}function LW(e,t){let a=0;return e||(a|=1),t||(a|=4),a}function Nx(e,t,a,r,n,o,i){if(o.length===0)return;let s=t.content,l=Math.min(o.length,i.length),c=[],d=i[0].end;for(let f=0;f<l;f++){let m=o[f];if(m===null)continue;let p=i[f];if(p.length===0)continue;if(p.start>d)break;for(;c.length>0&&c[c.length-1].endPos<=p.start;)n.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop();if(c.length>0?n.produceFromScopes(c[c.length-1].scopes,p.start):n.produce(r,p.start),m.retokenizeCapturedWithRuleId){let g=m.getName(s,i),x=r.contentNameScopesList.pushAttributed(g,e),y=m.getContentName(s,i),v=x.pushAttributed(y,e),S=r.push(m.retokenizeCapturedWithRuleId,p.start,-1,!1,null,x,v),C=e.createOnigString(s.substring(0,p.end));kW(e,C,a&&p.start===0,p.start,S,n,!1,0),yW(C);continue}let h=m.getName(s,i);if(h!==null){let x=(c.length>0?c[c.length-1].scopes:r.contentNameScopesList).pushAttributed(h,e);c.push(new a0e(x,p.end))}}for(;c.length>0;)n.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop()}var a0e=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function n0e(e,t,a,r,n,o,i,s){return new o0e(e,t,a,r,n,o,i,s)}function lW(e,t,a,r,n){let o=K1(t,Q1),i=SW.getCompiledRuleId(a,r,n.repository);for(let s of o)e.push({debugSelector:t,matcher:s.matcher,ruleId:i,grammar:n,priority:s.priority})}function Q1(e,t){if(t.length<e.length)return!1;let a=0;return e.every(r=>{for(let n=a;n<t.length;n++)if(r0e(t[n],r))return a=n+1,!0;return!1})}function r0e(e,t){if(!e)return!1;if(e===t)return!0;let a=t.length;return e.length>a&&e.substr(0,a)===t&&e[a]==="."}var o0e=class{constructor(e,t,a,r,n,o,i,s){if(this._rootScopeName=e,this.balancedBracketSelectors=o,this._onigLib=s,this._basicScopeAttributesProvider=new Wxe(a,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=i,this._grammar=uW(t,null),this._injections=null,this._tokenTypeMatchers=[],n)for(let l of Object.keys(n)){let c=K1(l,Q1);for(let d of c)this._tokenTypeMatchers.push({matcher:d.matcher,type:n[l]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(let e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){let e={lookup:n=>n===this._rootScopeName?this._grammar:this.getExternalGrammar(n),injections:n=>this._grammarRepository.injections(n)},t=[],a=this._rootScopeName,r=e.lookup(a);if(r){let n=r.injections;if(n)for(let i in n)lW(t,i,n[i],this,r);let o=this._grammarRepository.injections(a);o&&o.forEach(i=>{let s=this.getExternalGrammar(i);if(s){let l=s.injectionSelector;l&&lW(t,l,s,this,s)}})}return t.sort((n,o)=>n.priority-o.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){let t=++this._lastRuleId,a=e(t);return this._ruleId2desc[t]=a,a}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){let a=this._grammarRepository.lookup(e);if(a)return this._includedGrammars[e]=uW(a,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,a=0){let r=this._tokenize(e,t,!1,a);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,a=0){let r=this._tokenize(e,t,!0,a);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,a,r){this._rootId===-1&&(this._rootId=SW.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let n;if(!t||t===jz.NULL){n=!0;let c=this._basicScopeAttributesProvider.getDefaultAttributes(),d=this.themeProvider.getDefaults(),f=Am.set(0,c.languageId,c.tokenType,null,d.fontStyle,d.foregroundId,d.backgroundId),m=this.getRule(this._rootId).getName(null,null),p;m?p=Ax.createRootAndLookUpScopeName(m,f,this):p=Ax.createRoot("unknown",f),t=new jz(null,this._rootId,-1,-1,!1,null,p,p)}else n=!1,t.reset();e=e+`
73
73
  `;let o=this.createOnigString(e),i=o.content.length,s=new s0e(a,e,this._tokenTypeMatchers,this.balancedBracketSelectors),l=kW(this,o,n,0,t,s,!0,r);return yW(o),{lineLength:i,lineTokens:s,ruleStack:l.stack,stoppedEarly:l.stoppedEarly}}};function uW(e,t){return e=kxe(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var Ax=class Xl{constructor(t,a,r){this.parent=t,this.scopePath=a,this.tokenAttributes=r}static fromExtension(t,a){let r=t,n=t?.scopePath??null;for(let o of a)n=Pz.push(n,o.scopeNames),r=new Xl(r,n,o.encodedTokenAttributes);return r}static createRoot(t,a){return new Xl(null,new Pz(null,t),a)}static createRootAndLookUpScopeName(t,a,r){let n=r.getMetadataForScope(t),o=new Pz(null,t),i=r.themeProvider.themeMatch(o),s=Xl.mergeAttributes(a,n,i);return new Xl(null,o,s)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return Xl.equals(this,t)}static equals(t,a){do{if(t===a||!t&&!a)return!0;if(!t||!a||t.scopeName!==a.scopeName||t.tokenAttributes!==a.tokenAttributes)return!1;t=t.parent,a=a.parent}while(!0)}static mergeAttributes(t,a,r){let n=-1,o=0,i=0;return r!==null&&(n=r.fontStyle,o=r.foregroundId,i=r.backgroundId),Am.set(t,a.languageId,a.tokenType,null,n,o,i)}pushAttributed(t,a){if(t===null)return this;if(t.indexOf(" ")===-1)return Xl._pushAttributed(this,t,a);let r=t.split(/ /g),n=this;for(let o of r)n=Xl._pushAttributed(n,o,a);return n}static _pushAttributed(t,a,r){let n=r.getMetadataForScope(a),o=t.scopePath.push(a),i=r.themeProvider.themeMatch(o),s=Xl.mergeAttributes(t.tokenAttributes,n,i);return new Xl(t,o,s)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){let a=[],r=this;for(;r&&r!==t;)a.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(r.parent?.scopePath??null)}),r=r.parent;return r===t?a.reverse():void 0}},jz=class Nm{constructor(t,a,r,n,o,i,s,l){this.parent=t,this.ruleId=a,this.beginRuleCapturedEOL=o,this.endRule=i,this.nameScopesList=s,this.contentNameScopesList=l,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=n}_stackElementBrand=void 0;static NULL=new Nm(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:Nm._equals(this,t)}static _equals(t,a){return t===a?!0:this._structuralEquals(t,a)?Ax.equals(t.contentNameScopesList,a.contentNameScopesList):!1}static _structuralEquals(t,a){do{if(t===a||!t&&!a)return!0;if(!t||!a||t.depth!==a.depth||t.ruleId!==a.ruleId||t.endRule!==a.endRule)return!1;t=t.parent,a=a.parent}while(!0)}clone(){return this}static _reset(t){for(;t;)t._enterPos=-1,t._anchorPos=-1,t=t.parent}reset(){Nm._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,a,r,n,o,i,s){return new Nm(this,t,a,r,n,o,i,s)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(t){return t.getRule(this.ruleId)}toString(){let t=[];return this._writeString(t,0),"["+t.join(",")+"]"}_writeString(t,a){return this.parent&&(a=this.parent._writeString(t,a)),t[a++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,a}withContentNameScopesList(t){return this.contentNameScopesList===t?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,t)}withEndRule(t){return this.endRule===t?this:new Nm(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(t){let a=this;for(;a&&a._enterPos===t._enterPos;){if(a.ruleId===t.ruleId)return!0;a=a.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,a){let r=Ax.fromExtension(t?.nameScopesList??null,a.nameScopesList);return new Nm(t,a.ruleId,a.enterPos??-1,a.anchorPos??-1,a.beginRuleCapturedEOL,a.endRule,r,Ax.fromExtension(r,a.contentNameScopesList))}},i0e=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(a=>a==="*"?(this.allowAny=!0,[]):K1(a,Q1).map(r=>r.matcher)),this.unbalancedBracketScopes=t.flatMap(a=>K1(a,Q1).map(r=>r.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},s0e=class{constructor(e,t,a,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=a,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let r=e?.tokenAttributes??0,n=!1;if(this.balancedBracketSelectors?.matchesAlways&&(n=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let o=e?.getScopeNames()??[];for(let i of this._tokenTypeOverrides)i.matcher(o)&&(r=Am.set(r,0,i.type,null,-1,0,0));this.balancedBracketSelectors&&(n=this.balancedBracketSelectors.match(o))}if(n&&(r=Am.set(r,0,8,n,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===r){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(r),this._lastTokenEndIndex=t;return}let a=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:a}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let a=new Uint32Array(this._binaryTokens.length);for(let r=0,n=this._binaryTokens.length;r<n;r++)a[r]=this._binaryTokens[r];return a}},l0e=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,a,r,n){if(!this._grammars.has(e)){let o=this._rawGrammars.get(e);if(!o)return null;this._grammars.set(e,n0e(e,o,t,a,r,n,this,this._onigLib))}return this._grammars.get(e)}},TW=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new l0e($x.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme($x.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,a){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:a})}loadGrammarWithConfiguration(e,t,a){return this._loadGrammar(e,t,a.embeddedLanguages,a.tokenTypes,new i0e(a.balancedBracketSelectors||[],a.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,a,r,n){let o=new zxe(this._syncRegistry,e);for(;o.Q.length>0;)o.Q.map(i=>this._loadSingleGrammar(i.scopeName)),o.processQueue();return this._grammarForScopeName(e,t,a,r,n)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let a=typeof this._options.getInjections=="function"?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,a)}}addGrammar(e,t=[],a=0,r=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,a,r)}_grammarForScopeName(e,t=0,a=null,r=null,n=null){return this._syncRegistry.grammarForScopeName(e,t,a,r,n)}},X1=jz.NULL;function zx(e,t){let a=typeof e=="string"?{}:{...e.colorReplacements},r=typeof e=="string"?e:e.name;for(let[n,o]of Object.entries(t?.colorReplacements||{}))typeof o=="string"?a[n]=o:n===r&&Object.assign(a,o);return a}function ic(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function $W(e){return Array.isArray(e)?e:[e]}async function Fz(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function Ux(e){return!e||["plaintext","txt","text","plain"].includes(e)}function Hz(e){return e==="ansi"||Ux(e)}function jx(e){return e==="none"}function Vz(e){return jx(e)}var u0e=/(\r?\n)/g;function Rg(e,t=!1){if(e.length===0)return[["",0]];let a=e.split(u0e),r=0,n=[];for(let o=0;o<a.length;o+=2){let i=t?a[o]+(a[o+1]||""):a[o];n.push([i,r]),r+=a[o].length,r+=a[o+1]?.length||0}return n}var RW={light:"#333333",dark:"#bbbbbb"},_W={light:"#fffffe",dark:"#1e1e1e"},NW="__shiki_resolved";function Y1(e){if(e?.[NW])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||="dark",t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:a,fg:r}=t;if(!a||!r){let s=t.settings?t.settings.find(l=>!l.name&&!l.scope):void 0;s?.settings?.foreground&&(r=s.settings.foreground),s?.settings?.background&&(a=s.settings.background),!r&&t?.colors?.["editor.foreground"]&&(r=t.colors["editor.foreground"]),!a&&t?.colors?.["editor.background"]&&(a=t.colors["editor.background"]),r||(r=t.type==="light"?RW.light:RW.dark),a||(a=t.type==="light"?_W.light:_W.dark),t.fg=r,t.bg=a}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let n=0,o=new Map;function i(s){if(o.has(s))return o.get(s);n+=1;let l=`#${n.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${l}`]?i(s):(o.set(s,l),l)}t.settings=t.settings.map(s=>{let l=s.settings?.foreground&&!s.settings.foreground.startsWith("#"),c=s.settings?.background&&!s.settings.background.startsWith("#");if(!l&&!c)return s;let d={...s,settings:{...s.settings}};if(l){let f=i(s.settings.foreground);t.colorReplacements[f]=s.settings.foreground,d.settings.foreground=f}if(c){let f=i(s.settings.background);t.colorReplacements[f]=s.settings.background,d.settings.background=f}return d});for(let s of Object.keys(t.colors||{}))if((s==="editor.foreground"||s==="editor.background"||s.startsWith("terminal.ansi"))&&!t.colors[s]?.startsWith("#")){let l=i(t.colors[s]);t.colorReplacements[l]=t.colors[s],t.colors[s]=l}return Object.defineProperty(t,NW,{enumerable:!1,writable:!1,value:!0}),t}async function PW(e){return[...new Set((await Promise.all(e.filter(t=>!Hz(t)).map(async t=>await Fz(t).then(a=>Array.isArray(a)?a:[a])))).flat())]}async function DW(e){return(await Promise.all(e.map(async t=>Vz(t)?null:Y1(await Fz(t))))).filter(t=>!!t)}function EW(e,t){if(!t)return e;if(t[e]){let a=new Set([e]);for(;t[e];){if(e=t[e],a.has(e))throw new na(`Circular alias \`${[...a].join(" -> ")} -> ${e}\``);a.add(e)}}return e}var c0e=class extends TW{_resolver;_themes;_langs;_alias;_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;constructor(e,t,a,r={}){super(e),this._resolver=e,this._themes=t,this._langs=a,this._alias=r,this._themes.map(n=>this.loadTheme(n)),this.loadLanguages(this._langs)}getTheme(e){return typeof e=="string"?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){let t=Y1(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=$x.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=EW(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;let t=new Set([...this._langMap.values()].filter(n=>n.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);let a={balancedBracketSelectors:e.balancedBracketSelectors||["*"],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);let r=this.loadGrammarWithConfiguration(e.scopeName,1,a);if(r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(n=>{this._alias[n]=e.name}),this._loadedLanguagesCache=null,t.size)for(let n of t)this._resolvedGrammars.delete(n.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(n.scopeName),this._syncRegistry?._grammars?.delete(n.scopeName),this.loadLanguage(this._langMap.get(n.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(let r of e)this.resolveEmbeddedLanguages(r);let t=[...this._langGraph.entries()],a=t.filter(([r,n])=>!n);if(a.length){let r=t.filter(([n,o])=>o?(o.embeddedLanguages||o.embeddedLangs)?.some(i=>a.map(([s])=>s).includes(i)):!1).filter(n=>!a.includes(n));throw new na(`Missing languages ${a.map(([n])=>`\`${n}\``).join(", ")}, required by ${r.map(([n])=>`\`${n}\``).join(", ")}`)}for(let[r,n]of t)this._resolver.addLanguage(n);for(let[r,n]of t)this.loadLanguage(n)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);let t=e.embeddedLanguages??e.embeddedLangs;if(t)for(let a of t)this._langGraph.set(a,this._langMap.get(a))}},d0e=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:a=>e.createScanner(a),createOnigString:a=>e.createString(a)},t.forEach(a=>this.addLanguage(a))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).push(e.scopeName)})}getInjections(e){let t=e.split("."),a=[];for(let r=1;r<=t.length;r++){let n=t.slice(0,r).join(".");a=[...a,...this._injections.get(n)||[]]}return a}},Ox=0;function qz(e){Ox+=1,e.warnings!==!1&&Ox>=10&&Ox%10===0&&console.warn(`[Shiki] ${Ox} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new na("`engine` option is required for synchronous mode");let a=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(Y1),n=new c0e(new d0e(e.engine,a),r,a,e.langAlias),o;function i(v){return EW(v,e.langAlias)}function s(v){x();let S=n.getGrammar(typeof v=="string"?v:v.name);if(!S)throw new na(`Language \`${v}\` not found, you may need to load it first`);return S}function l(v){if(v==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};x();let S=n.getTheme(v);if(!S)throw new na(`Theme \`${v}\` not found, you may need to load it first`);return S}function c(v){x();let S=l(v);return o!==v&&(n.setTheme(S),o=v),{theme:S,colorMap:n.getColorMap()}}function d(){return x(),n.getLoadedThemes()}function f(){return x(),n.getLoadedLanguages()}function m(...v){x(),n.loadLanguages(v.flat(1))}async function p(...v){return m(await PW(v))}function h(...v){x();for(let S of v.flat(1))n.loadTheme(S)}async function g(...v){return x(),h(await DW(v))}function x(){if(t)throw new na("Shiki instance has been disposed")}function y(){t||(t=!0,n.dispose(),Ox-=1)}return{setTheme:c,getTheme:l,getLanguage:s,getLoadedThemes:d,getLoadedLanguages:f,resolveLangAlias:i,loadLanguage:p,loadLanguageSync:m,loadTheme:g,loadThemeSync:h,dispose:y,[Symbol.dispose]:y}}async function Zz(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,a,r]=await Promise.all([DW(e.themes||[]),PW(e.langs||[]),e.engine]);return qz({...e,themes:t,langs:a,engine:r})}var MW=new WeakMap;function Bx(e,t){MW.set(e,t)}function _g(e){return MW.get(e)}var eI=class OW{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,a){return new OW(Object.fromEntries($W(a).map(r=>[r,X1])),t)}constructor(...t){if(t.length===2){let[a,r]=t;this.lang=r,this._stacks=a}else{let[a,r,n]=t;this.lang=r,this._stacks={[n]:a}}}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return f0e(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function f0e(e){let t=[],a=new Set;function r(n){if(a.has(n))return;a.add(n);let o=n?.nameScopesList?.scopeName;o&&t.push(o),n.parent&&r(n.parent)}return r(e),t}function m0e(e,t){if(!(e instanceof eI))throw new na("Invalid grammar state");return e.getInternalStack(t)}var p0e=/,/,h0e=/ /;function Gz(e,t,a={}){let{theme:r=e.getLoadedThemes()[0]}=a;if(Ux(e.resolveLangAlias(a.lang||"text"))||jx(r))return Rg(t).map(s=>[{content:s[0],offset:s[1]}]);let{theme:n,colorMap:o}=e.setTheme(r),i=e.getLanguage(a.lang||"text");if(a.grammarState){if(a.grammarState.lang!==i.name)throw new na(`Grammar state language "${a.grammarState.lang}" does not match highlight language "${i.name}"`);if(!a.grammarState.themes.includes(n.name))throw new na(`Grammar state themes "${a.grammarState.themes}" do not contain highlight theme "${n.name}"`)}return UW(t,i,n,o,a)}function zW(...e){if(e.length===2)return _g(e[1]);let[t,a,r={}]=e,{lang:n="text",theme:o=t.getLoadedThemes()[0]}=r;if(Ux(n)||jx(o))throw new na("Plain language does not have grammar state");if(n==="ansi")throw new na("ANSI language does not have grammar state");let{theme:i,colorMap:s}=t.setTheme(o),l=t.getLanguage(n);return new eI(Kz(a,l,i,s,r).stateStack,l.name,i.name)}function UW(e,t,a,r,n){let o=Kz(e,t,a,r,n),i=new eI(o.stateStack,t.name,a.name);return Bx(o.tokens,i),o.tokens}function Kz(e,t,a,r,n){let o=zx(a,n),{tokenizeMaxLineLength:i=0,tokenizeTimeLimit:s=500}=n,l=Rg(e),c=n.grammarState?m0e(n.grammarState,a.name)??X1:n.grammarContextCode!=null?Kz(n.grammarContextCode,t,a,r,{...n,grammarState:void 0,grammarContextCode:void 0}).stateStack:X1,d=[],f=[];for(let m=0,p=l.length;m<p;m++){let[h,g]=l[m];if(h===""){d=[],f.push([]);continue}if(i>0&&h.length>=i){d=[],f.push([{content:h,offset:g,color:"",fontStyle:0}]);continue}let x,y,v;n.includeExplanation&&(x=t.tokenizeLine(h,c,s),y=x.tokens,v=0);let S=t.tokenizeLine2(h,c,s),C=S.tokens.length/2;for(let L=0;L<C;L++){let T=S.tokens[2*L],_=L+1<C?S.tokens[2*L+2]:h.length;if(T===_)continue;let k=S.tokens[2*L+1],j=ic(r[Am.getForeground(k)],o),F=Am.getFontStyle(k),ue={content:h.substring(T,_),offset:g+T,color:j,fontStyle:F};if(n.includeExplanation){let z=[];if(n.includeExplanation!=="scopeName")for(let ee of a.settings){let ve;switch(typeof ee.scope){case"string":ve=ee.scope.split(p0e).map(Z=>Z.trim());break;case"object":ve=ee.scope;break;default:continue}z.push({settings:ee,selectors:ve.map(Z=>Z.split(h0e))})}ue.explanation=[];let Y=0;for(;T+Y<_;){let ee=y[v],ve=h.substring(ee.startIndex,ee.endIndex);Y+=ve.length,ue.explanation.push({content:ve,scopes:n.includeExplanation==="scopeName"?g0e(ee.scopes):v0e(z,ee.scopes)}),v+=1}}d.push(ue)}f.push(d),d=[],c=S.ruleStack}return{tokens:f,stateStack:c}}function g0e(e){return e.map(t=>({scopeName:t}))}function v0e(e,t){let a=[];for(let r=0,n=t.length;r<n;r++){let o=t[r];a[r]={scopeName:o,themeMatches:b0e(e,o,t.slice(0,r))}}return a}function AW(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function y0e(e,t,a){if(!AW(e.at(-1),t))return!1;let r=e.length-2,n=a.length-1;for(;r>=0&&n>=0;)AW(e[r],a[n])&&(r-=1),n-=1;return r===-1}function b0e(e,t,a){let r=[];for(let{selectors:n,settings:o}of e)for(let i of n)if(y0e(i,t,a)){r.push(o);break}return r}function tI(e,t,a,r=Gz){let n=Object.entries(a.themes).filter(c=>c[1]).map(c=>({color:c[0],theme:c[1]})),o=n.map(c=>{let d=r(e,t,{...a,theme:c.theme});return{tokens:d,state:_g(d),theme:typeof c.theme=="string"?c.theme:c.theme.name}}),i=x0e(...o.map(c=>c.tokens)),s=i[0].map((c,d)=>c.map((f,m)=>{let p={content:f.content,variants:{},offset:f.offset};return"includeExplanation"in a&&a.includeExplanation&&(p.explanation=f.explanation),i.forEach((h,g)=>{let{content:x,explanation:y,offset:v,...S}=h[d][m];p.variants[n[g].color]=S}),p})),l=o[0].state?new eI(Object.fromEntries(o.map(c=>[c.theme,c.state?.getInternalStack(c.theme)])),o[0].state.lang):void 0;return l&&Bx(s,l),s}function x0e(...e){let t=e.map(()=>[]),a=e.length;for(let r=0;r<e[0].length;r++){let n=e.map(l=>l[r]),o=t.map(()=>[]);t.forEach((l,c)=>l.push(o[c]));let i=n.map(()=>0),s=n.map(l=>l[0]);for(;s.every(l=>l);){let l=Math.min(...s.map(c=>c.content.length));for(let c=0;c<a;c++){let d=s[c];d.content.length===l?(o[c].push(d),i[c]+=1,s[c]=n[c][i[c]]):(o[c].push({...d,content:d.content.slice(0,l)}),s[c]={...d,content:d.content.slice(l),offset:d.offset+l})}}}return t}var jW=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];var sc=class{constructor(t,a,r){this.normal=a,this.property=t,r&&(this.space=r)}};sc.prototype.normal={};sc.prototype.property={};sc.prototype.space=void 0;function Wz(e,t){let a={},r={};for(let n of e)Object.assign(a,n.property),Object.assign(r,n.normal);return new sc(a,r,t)}function Fx(e){return e.toLowerCase()}var hr=class{constructor(t,a){this.attribute=a,this.property=t}};hr.prototype.attribute="";hr.prototype.booleanish=!1;hr.prototype.boolean=!1;hr.prototype.commaOrSpaceSeparated=!1;hr.prototype.commaSeparated=!1;hr.prototype.defined=!1;hr.prototype.mustUseProperty=!1;hr.prototype.number=!1;hr.prototype.overloadedBoolean=!1;hr.prototype.property="";hr.prototype.spaceSeparated=!1;hr.prototype.space=void 0;var Hx={};Sl(Hx,{boolean:()=>et,booleanish:()=>bn,commaOrSpaceSeparated:()=>ni,commaSeparated:()=>jd,number:()=>J,overloadedBoolean:()=>aI,spaceSeparated:()=>ra});var S0e=0,et=$m(),bn=$m(),aI=$m(),J=$m(),ra=$m(),jd=$m(),ni=$m();function $m(){return 2**++S0e}var Jz=Object.keys(Hx),Pm=class extends hr{constructor(t,a,r,n){let o=-1;if(super(t,a),BW(this,"space",n),typeof r=="number")for(;++o<Jz.length;){let i=Jz[o];BW(this,Jz[o],(r&Hx[i])===Hx[i])}}};Pm.prototype.defined=!0;function BW(e,t,a){a&&(e[t]=a)}function gs(e){let t={},a={};for(let[r,n]of Object.entries(e.properties)){let o=new Pm(r,e.transform(e.attributes||{},r),n,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,a[Fx(r)]=r,a[Fx(o.attribute)]=r}return new sc(t,a,e.space)}var Qz=gs({properties:{ariaActiveDescendant:null,ariaAtomic:bn,ariaAutoComplete:null,ariaBusy:bn,ariaChecked:bn,ariaColCount:J,ariaColIndex:J,ariaColSpan:J,ariaControls:ra,ariaCurrent:null,ariaDescribedBy:ra,ariaDetails:null,ariaDisabled:bn,ariaDropEffect:ra,ariaErrorMessage:null,ariaExpanded:bn,ariaFlowTo:ra,ariaGrabbed:bn,ariaHasPopup:null,ariaHidden:bn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ra,ariaLevel:J,ariaLive:null,ariaModal:bn,ariaMultiLine:bn,ariaMultiSelectable:bn,ariaOrientation:null,ariaOwns:ra,ariaPlaceholder:null,ariaPosInSet:J,ariaPressed:bn,ariaReadOnly:bn,ariaRelevant:null,ariaRequired:bn,ariaRoleDescription:ra,ariaRowCount:J,ariaRowIndex:J,ariaRowSpan:J,ariaSelected:bn,ariaSetSize:J,ariaSort:null,ariaValueMax:J,ariaValueMin:J,ariaValueNow:J,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function nI(e,t){return t in e?e[t]:t}function rI(e,t){return nI(e,t.toLowerCase())}var FW=gs({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:jd,acceptCharset:ra,accessKey:ra,action:null,allow:null,allowFullScreen:et,allowPaymentRequest:et,allowUserMedia:et,alt:null,as:null,async:et,autoCapitalize:null,autoComplete:ra,autoFocus:et,autoPlay:et,blocking:ra,capture:null,charSet:null,checked:et,cite:null,className:ra,cols:J,colSpan:null,content:null,contentEditable:bn,controls:et,controlsList:ra,coords:J|jd,crossOrigin:null,data:null,dateTime:null,decoding:null,default:et,defer:et,dir:null,dirName:null,disabled:et,download:aI,draggable:bn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:et,formTarget:null,headers:ra,height:J,hidden:aI,high:J,href:null,hrefLang:null,htmlFor:ra,httpEquiv:ra,id:null,imageSizes:null,imageSrcSet:null,inert:et,inputMode:null,integrity:null,is:null,isMap:et,itemId:null,itemProp:ra,itemRef:ra,itemScope:et,itemType:ra,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:et,low:J,manifest:null,max:null,maxLength:J,media:null,method:null,min:null,minLength:J,multiple:et,muted:et,name:null,nonce:null,noModule:et,noValidate:et,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:et,optimum:J,pattern:null,ping:ra,placeholder:null,playsInline:et,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:et,referrerPolicy:null,rel:ra,required:et,reversed:et,rows:J,rowSpan:J,sandbox:ra,scope:null,scoped:et,seamless:et,selected:et,shadowRootClonable:et,shadowRootDelegatesFocus:et,shadowRootMode:null,shape:null,size:J,sizes:null,slot:null,span:J,spellCheck:bn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:J,step:null,style:null,tabIndex:J,target:null,title:null,translate:null,type:null,typeMustMatch:et,useMap:null,value:bn,width:J,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ra,axis:null,background:null,bgColor:null,border:J,borderColor:null,bottomMargin:J,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:et,declare:et,event:null,face:null,frame:null,frameBorder:null,hSpace:J,leftMargin:J,link:null,longDesc:null,lowSrc:null,marginHeight:J,marginWidth:J,noResize:et,noHref:et,noShade:et,noWrap:et,object:null,profile:null,prompt:null,rev:null,rightMargin:J,rules:null,scheme:null,scrolling:bn,standby:null,summary:null,text:null,topMargin:J,valueType:null,version:null,vAlign:null,vLink:null,vSpace:J,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:et,disableRemotePlayback:et,prefix:null,property:null,results:J,security:null,unselectable:null},space:"html",transform:rI});var HW=gs({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ni,accentHeight:J,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:J,amplitude:J,arabicForm:null,ascent:J,attributeName:null,attributeType:null,azimuth:J,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:J,by:null,calcMode:null,capHeight:J,className:ra,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:J,diffuseConstant:J,direction:null,display:null,dur:null,divisor:J,dominantBaseline:null,download:et,dx:null,dy:null,edgeMode:null,editable:null,elevation:J,enableBackground:null,end:null,event:null,exponent:J,externalResourcesRequired:null,fill:null,fillOpacity:J,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:jd,g2:jd,glyphName:jd,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:J,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:J,horizOriginX:J,horizOriginY:J,id:null,ideographic:J,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:J,k:J,k1:J,k2:J,k3:J,k4:J,kernelMatrix:ni,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:J,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:J,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:J,overlineThickness:J,paintOrder:null,panose1:null,path:null,pathLength:J,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ra,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:J,pointsAtY:J,pointsAtZ:J,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ni,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ni,rev:ni,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ni,requiredFeatures:ni,requiredFonts:ni,requiredFormats:ni,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:J,specularExponent:J,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:J,strikethroughThickness:J,string:null,stroke:null,strokeDashArray:ni,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:J,strokeOpacity:J,strokeWidth:null,style:null,surfaceScale:J,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ni,tabIndex:J,tableValues:null,target:null,targetX:J,targetY:J,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ni,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:J,underlineThickness:J,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:J,values:null,vAlphabetic:J,vMathematical:J,vectorEffect:null,vHanging:J,vIdeographic:J,version:null,vertAdvY:J,vertOriginX:J,vertOriginY:J,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:J,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:nI});var Xz=gs({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}});var Yz=gs({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:rI});var e4=gs({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});var w0e=/[A-Z]/g,VW=/-[a-z]/g,C0e=/^data[-\w.:]+$/i;function t4(e,t){let a=Fx(t),r=t,n=hr;if(a in e.normal)return e.property[e.normal[a]];if(a.length>4&&a.slice(0,4)==="data"&&C0e.test(t)){if(t.charAt(4)==="-"){let o=t.slice(5).replace(VW,I0e);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{let o=t.slice(4);if(!VW.test(o)){let i=o.replace(w0e,k0e);i.charAt(0)!=="-"&&(i="-"+i),t="data"+i}}n=Pm}return new n(r,t)}function k0e(e){return"-"+e.toLowerCase()}function I0e(e){return e.charAt(1).toUpperCase()}var qW=Wz([Qz,FW,Xz,Yz,e4],"html"),oI=Wz([Qz,HW,Xz,Yz,e4],"svg");var ZW={}.hasOwnProperty;function GW(e,t){let a=t||{};function r(n,...o){let i=r.invalid,s=r.handlers;if(n&&ZW.call(n,e)){let l=String(n[e]);i=ZW.call(s,l)?s[l]:r.unknown}if(i)return i.call(this,n,...o)}return r.handlers=a.handlers||{},r.invalid=a.invalid,r.unknown=a.unknown,r}var L0e=/["&'<>`]/g,T0e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,R0e=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,_0e=/[|\\{}()[\]^$+*?.]/g,KW=new WeakMap;function WW(e,t){if(e=e.replace(t.subset?N0e(t.subset):L0e,r),t.subset||t.escapeOnly)return e;return e.replace(T0e,a).replace(R0e,r);function a(n,o,i){return t.format((n.charCodeAt(0)-55296)*1024+n.charCodeAt(1)-56320+65536,i.charCodeAt(o+2),t)}function r(n,o,i){return t.format(n.charCodeAt(0),i.charCodeAt(o+1),t)}}function N0e(e){let t=KW.get(e);return t||(t=A0e(e),KW.set(e,t)),t}function A0e(e){let t=[],a=-1;for(;++a<e.length;)t.push(e[a].replace(_0e,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}var $0e=/[\dA-Fa-f]/;function JW(e,t,a){let r="&#x"+e.toString(16).toUpperCase();return a&&t&&!$0e.test(String.fromCharCode(t))?r:r+";"}var P0e=/\d/;function QW(e,t,a){let r="&#"+String(e);return a&&t&&!P0e.test(String.fromCharCode(t))?r:r+";"}var XW=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"];var iI={nbsp:"\xA0",iexcl:"\xA1",cent:"\xA2",pound:"\xA3",curren:"\xA4",yen:"\xA5",brvbar:"\xA6",sect:"\xA7",uml:"\xA8",copy:"\xA9",ordf:"\xAA",laquo:"\xAB",not:"\xAC",shy:"\xAD",reg:"\xAE",macr:"\xAF",deg:"\xB0",plusmn:"\xB1",sup2:"\xB2",sup3:"\xB3",acute:"\xB4",micro:"\xB5",para:"\xB6",middot:"\xB7",cedil:"\xB8",sup1:"\xB9",ordm:"\xBA",raquo:"\xBB",frac14:"\xBC",frac12:"\xBD",frac34:"\xBE",iquest:"\xBF",Agrave:"\xC0",Aacute:"\xC1",Acirc:"\xC2",Atilde:"\xC3",Auml:"\xC4",Aring:"\xC5",AElig:"\xC6",Ccedil:"\xC7",Egrave:"\xC8",Eacute:"\xC9",Ecirc:"\xCA",Euml:"\xCB",Igrave:"\xCC",Iacute:"\xCD",Icirc:"\xCE",Iuml:"\xCF",ETH:"\xD0",Ntilde:"\xD1",Ograve:"\xD2",Oacute:"\xD3",Ocirc:"\xD4",Otilde:"\xD5",Ouml:"\xD6",times:"\xD7",Oslash:"\xD8",Ugrave:"\xD9",Uacute:"\xDA",Ucirc:"\xDB",Uuml:"\xDC",Yacute:"\xDD",THORN:"\xDE",szlig:"\xDF",agrave:"\xE0",aacute:"\xE1",acirc:"\xE2",atilde:"\xE3",auml:"\xE4",aring:"\xE5",aelig:"\xE6",ccedil:"\xE7",egrave:"\xE8",eacute:"\xE9",ecirc:"\xEA",euml:"\xEB",igrave:"\xEC",iacute:"\xED",icirc:"\xEE",iuml:"\xEF",eth:"\xF0",ntilde:"\xF1",ograve:"\xF2",oacute:"\xF3",ocirc:"\xF4",otilde:"\xF5",ouml:"\xF6",divide:"\xF7",oslash:"\xF8",ugrave:"\xF9",uacute:"\xFA",ucirc:"\xFB",uuml:"\xFC",yacute:"\xFD",thorn:"\xFE",yuml:"\xFF",fnof:"\u0192",Alpha:"\u0391",Beta:"\u0392",Gamma:"\u0393",Delta:"\u0394",Epsilon:"\u0395",Zeta:"\u0396",Eta:"\u0397",Theta:"\u0398",Iota:"\u0399",Kappa:"\u039A",Lambda:"\u039B",Mu:"\u039C",Nu:"\u039D",Xi:"\u039E",Omicron:"\u039F",Pi:"\u03A0",Rho:"\u03A1",Sigma:"\u03A3",Tau:"\u03A4",Upsilon:"\u03A5",Phi:"\u03A6",Chi:"\u03A7",Psi:"\u03A8",Omega:"\u03A9",alpha:"\u03B1",beta:"\u03B2",gamma:"\u03B3",delta:"\u03B4",epsilon:"\u03B5",zeta:"\u03B6",eta:"\u03B7",theta:"\u03B8",iota:"\u03B9",kappa:"\u03BA",lambda:"\u03BB",mu:"\u03BC",nu:"\u03BD",xi:"\u03BE",omicron:"\u03BF",pi:"\u03C0",rho:"\u03C1",sigmaf:"\u03C2",sigma:"\u03C3",tau:"\u03C4",upsilon:"\u03C5",phi:"\u03C6",chi:"\u03C7",psi:"\u03C8",omega:"\u03C9",thetasym:"\u03D1",upsih:"\u03D2",piv:"\u03D6",bull:"\u2022",hellip:"\u2026",prime:"\u2032",Prime:"\u2033",oline:"\u203E",frasl:"\u2044",weierp:"\u2118",image:"\u2111",real:"\u211C",trade:"\u2122",alefsym:"\u2135",larr:"\u2190",uarr:"\u2191",rarr:"\u2192",darr:"\u2193",harr:"\u2194",crarr:"\u21B5",lArr:"\u21D0",uArr:"\u21D1",rArr:"\u21D2",dArr:"\u21D3",hArr:"\u21D4",forall:"\u2200",part:"\u2202",exist:"\u2203",empty:"\u2205",nabla:"\u2207",isin:"\u2208",notin:"\u2209",ni:"\u220B",prod:"\u220F",sum:"\u2211",minus:"\u2212",lowast:"\u2217",radic:"\u221A",prop:"\u221D",infin:"\u221E",ang:"\u2220",and:"\u2227",or:"\u2228",cap:"\u2229",cup:"\u222A",int:"\u222B",there4:"\u2234",sim:"\u223C",cong:"\u2245",asymp:"\u2248",ne:"\u2260",equiv:"\u2261",le:"\u2264",ge:"\u2265",sub:"\u2282",sup:"\u2283",nsub:"\u2284",sube:"\u2286",supe:"\u2287",oplus:"\u2295",otimes:"\u2297",perp:"\u22A5",sdot:"\u22C5",lceil:"\u2308",rceil:"\u2309",lfloor:"\u230A",rfloor:"\u230B",lang:"\u2329",rang:"\u232A",loz:"\u25CA",spades:"\u2660",clubs:"\u2663",hearts:"\u2665",diams:"\u2666",quot:'"',amp:"&",lt:"<",gt:">",OElig:"\u0152",oelig:"\u0153",Scaron:"\u0160",scaron:"\u0161",Yuml:"\u0178",circ:"\u02C6",tilde:"\u02DC",ensp:"\u2002",emsp:"\u2003",thinsp:"\u2009",zwnj:"\u200C",zwj:"\u200D",lrm:"\u200E",rlm:"\u200F",ndash:"\u2013",mdash:"\u2014",lsquo:"\u2018",rsquo:"\u2019",sbquo:"\u201A",ldquo:"\u201C",rdquo:"\u201D",bdquo:"\u201E",dagger:"\u2020",Dagger:"\u2021",permil:"\u2030",lsaquo:"\u2039",rsaquo:"\u203A",euro:"\u20AC"};var YW=["cent","copy","divide","gt","lt","not","para","times"];var eJ={}.hasOwnProperty,a4={},sI;for(sI in iI)eJ.call(iI,sI)&&(a4[iI[sI]]=sI);var D0e=/[^\dA-Za-z]/;function tJ(e,t,a,r){let n=String.fromCharCode(e);if(eJ.call(a4,n)){let o=a4[n],i="&"+o;return a&&XW.includes(o)&&!YW.includes(o)&&(!r||t&&t!==61&&D0e.test(String.fromCharCode(t)))?i:i+";"}return""}function aJ(e,t,a){let r=JW(e,t,a.omitOptionalSemicolons),n;if((a.useNamedReferences||a.useShortestReferences)&&(n=tJ(e,t,a.omitOptionalSemicolons,a.attribute)),(a.useShortestReferences||!n)&&a.useShortestReferences){let o=QW(e,t,a.omitOptionalSemicolons);o.length<r.length&&(r=o)}return n&&(!a.useShortestReferences||n.length<r.length)?n:r}function lc(e,t){return WW(e,Object.assign({format:aJ},t))}var E0e=/^>|^->|<!--|-->|--!>|<!-$/g,M0e=[">"],O0e=["<",">"];function nJ(e,t,a,r){return r.settings.bogusComments?"<?"+lc(e.value,Object.assign({},r.settings.characterReferences,{subset:M0e}))+">":"<!--"+e.value.replace(E0e,n)+"-->";function n(o){return lc(o,Object.assign({},r.settings.characterReferences,{subset:O0e}))}}function rJ(e,t,a,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}function n4(e,t){let a=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,n=a.indexOf(t);for(;n!==-1;)r++,n=a.indexOf(t,n+t.length);return r}function oJ(e,t){let a=t||{};return(e[e.length-1]===""?[...e,""]:e).join((a.padRight?" ":"")+","+(a.padLeft===!1?"":" ")).trim()}function iJ(e){return e.join(" ").trim()}var z0e=/[ \t\n\f\r]/g;function Dm(e){return typeof e=="object"?e.type==="text"?sJ(e.value):!1:sJ(e)}function sJ(e){return e.replace(z0e,"")===""}var _n=lJ(1),r4=lJ(-1),U0e=[];function lJ(e){return t;function t(a,r,n){let o=a?a.children:U0e,i=(r||0)+e,s=o[i];if(!n)for(;s&&Dm(s);)i+=e,s=o[i];return s}}var j0e={}.hasOwnProperty;function lI(e){return t;function t(a,r,n){return j0e.call(e,a.tagName)&&e[a.tagName](a,r,n)}}var Vx=lI({body:F0e,caption:o4,colgroup:o4,dd:Z0e,dt:q0e,head:o4,html:B0e,li:V0e,optgroup:G0e,option:K0e,p:H0e,rp:uJ,rt:uJ,tbody:J0e,td:cJ,tfoot:Q0e,th:cJ,thead:W0e,tr:X0e});function o4(e,t,a){let r=_n(a,t,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&Dm(r.value.charAt(0)))}function B0e(e,t,a){let r=_n(a,t);return!r||r.type!=="comment"}function F0e(e,t,a){let r=_n(a,t);return!r||r.type!=="comment"}function H0e(e,t,a){let r=_n(a,t);return r?r.type==="element"&&(r.tagName==="address"||r.tagName==="article"||r.tagName==="aside"||r.tagName==="blockquote"||r.tagName==="details"||r.tagName==="div"||r.tagName==="dl"||r.tagName==="fieldset"||r.tagName==="figcaption"||r.tagName==="figure"||r.tagName==="footer"||r.tagName==="form"||r.tagName==="h1"||r.tagName==="h2"||r.tagName==="h3"||r.tagName==="h4"||r.tagName==="h5"||r.tagName==="h6"||r.tagName==="header"||r.tagName==="hgroup"||r.tagName==="hr"||r.tagName==="main"||r.tagName==="menu"||r.tagName==="nav"||r.tagName==="ol"||r.tagName==="p"||r.tagName==="pre"||r.tagName==="section"||r.tagName==="table"||r.tagName==="ul"):!a||!(a.type==="element"&&(a.tagName==="a"||a.tagName==="audio"||a.tagName==="del"||a.tagName==="ins"||a.tagName==="map"||a.tagName==="noscript"||a.tagName==="video"))}function V0e(e,t,a){let r=_n(a,t);return!r||r.type==="element"&&r.tagName==="li"}function q0e(e,t,a){let r=_n(a,t);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function Z0e(e,t,a){let r=_n(a,t);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function uJ(e,t,a){let r=_n(a,t);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function G0e(e,t,a){let r=_n(a,t);return!r||r.type==="element"&&r.tagName==="optgroup"}function K0e(e,t,a){let r=_n(a,t);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function W0e(e,t,a){let r=_n(a,t);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function J0e(e,t,a){let r=_n(a,t);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function Q0e(e,t,a){return!_n(a,t)}function X0e(e,t,a){let r=_n(a,t);return!r||r.type==="element"&&r.tagName==="tr"}function cJ(e,t,a){let r=_n(a,t);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}var dJ=lI({body:tSe,colgroup:aSe,head:eSe,html:Y0e,tbody:nSe});function Y0e(e){let t=_n(e,-1);return!t||t.type!=="comment"}function eSe(e){let t=new Set;for(let r of e.children)if(r.type==="element"&&(r.tagName==="base"||r.tagName==="title")){if(t.has(r.tagName))return!1;t.add(r.tagName)}let a=e.children[0];return!a||a.type==="element"}function tSe(e){let t=_n(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&Dm(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function aSe(e,t,a){let r=r4(a,t),n=_n(e,-1,!0);return a&&r&&r.type==="element"&&r.tagName==="colgroup"&&Vx(r,a.children.indexOf(r),a)?!1:!!(n&&n.type==="element"&&n.tagName==="col")}function nSe(e,t,a){let r=r4(a,t),n=_n(e,-1);return a&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&Vx(r,a.children.indexOf(r),a)?!1:!!(n&&n.type==="element"&&n.tagName==="tr")}var uI={name:[[`